Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp =================================================================== --- clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -1906,7 +1906,7 @@ return false; } - if (!this->emitCallBI(Func, E)) + if (!this->emitCallBI(Func, E, E)) return false; QualType ReturnType = E->getCallReturnType(Ctx.getASTContext()); Index: clang/lib/AST/Interp/Interp.h =================================================================== --- clang/lib/AST/Interp/Interp.h +++ clang/lib/AST/Interp/Interp.h @@ -180,7 +180,8 @@ bool Interpret(InterpState &S, APValue &Result); /// Interpret a builtin function. -bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F); +bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F, + const CallExpr *Call); /// Perform a bitcast of all fields of P into Buff. This performs the /// actions of a __builtin_bit_cast expression when the target type @@ -1843,13 +1844,14 @@ return Call(S, OpPC, Func); } -inline bool CallBI(InterpState &S, CodePtr &PC, const Function *Func) { +inline bool CallBI(InterpState &S, CodePtr &PC, const Function *Func, + const CallExpr *CE) { auto NewFrame = std::make_unique(S, Func, PC); InterpFrame *FrameBefore = S.Current; S.Current = NewFrame.get(); - if (InterpretBuiltin(S, PC, Func)) { + if (InterpretBuiltin(S, PC, Func, CE)) { NewFrame.release(); return true; } Index: clang/lib/AST/Interp/InterpBuiltin.cpp =================================================================== --- clang/lib/AST/Interp/InterpBuiltin.cpp +++ clang/lib/AST/Interp/InterpBuiltin.cpp @@ -237,10 +237,9 @@ /// second one is an integral value. static bool interp__builtin_isfpclass(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, - const Function *Func) { - const Expr *E = S.Current->getExpr(OpPC); - const CallExpr *CE = cast(E); - PrimType FPClassArgT = *S.getContext().classify(CE->getArgs()[1]->getType()); + const Function *Func, + const CallExpr *Call) { + PrimType FPClassArgT = *S.getContext().classify(Call->getArg(1)->getType()); APSInt FPClassArg = peekToAPSInt(S.Stk, FPClassArgT); const Floating &F = S.Stk.peek(align(primSize(FPClassArgT) + primSize(PT_Float))); @@ -301,10 +300,9 @@ /// The return type must be the same. static bool interp__builtin_arithmetic_fence(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, - const Function *Func) { - const Expr *E = S.Current->getExpr(OpPC); - const CallExpr *CE = cast(E); - QualType ReturnType = CE->getType(); + const Function *Func, + const CallExpr *Call) { + QualType ReturnType = Call->getType(); // TODO: Support vector and complex types. if (!ReturnType->isFloatingType()) @@ -316,7 +314,8 @@ return true; } -bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F) { +bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F, + const CallExpr *Call) { InterpFrame *Frame = S.Current; APValue Dummy; @@ -410,7 +409,7 @@ return Ret(S, OpPC, Dummy); break; case Builtin::BI__builtin_isfpclass: - if (interp__builtin_isfpclass(S, OpPC, Frame, F)) + if (interp__builtin_isfpclass(S, OpPC, Frame, F, Call)) return Ret(S, OpPC, Dummy); break; case Builtin::BI__builtin_fpclassify: @@ -427,7 +426,7 @@ break; case Builtin::BI__arithmetic_fence: - if (interp__builtin_arithmetic_fence(S, OpPC, Frame, F)) + if (interp__builtin_arithmetic_fence(S, OpPC, Frame, F, Call)) return Ret(S, OpPC, Dummy); break; Index: clang/lib/AST/Interp/Opcodes.td =================================================================== --- clang/lib/AST/Interp/Opcodes.td +++ clang/lib/AST/Interp/Opcodes.td @@ -52,6 +52,7 @@ def ArgRoundingMode : ArgType { let Name = "llvm::RoundingMode"; } def ArgLETD: ArgType { let Name = "const LifetimeExtendedTemporaryDecl *"; } def ArgCastKind : ArgType { let Name = "CastKind"; } +def ArgCallExpr : ArgType { let Name = "const CallExpr *"; } //===----------------------------------------------------------------------===// // Classes of types instructions operate on. @@ -188,7 +189,7 @@ } def CallBI : Opcode { - let Args = [ArgFunction]; + let Args = [ArgFunction, ArgCallExpr]; let Types = []; }