diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -1824,7 +1824,7 @@ return false; } - if (!this->emitCallBI(Func, E)) + if (!this->emitCallBI(Func, E, E)) return false; QualType ReturnType = E->getCallReturnType(Ctx.getASTContext()); diff --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h --- a/clang/lib/AST/Interp/Interp.h +++ b/clang/lib/AST/Interp/Interp.h @@ -174,7 +174,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); enum class ArithOp { Add, Sub }; @@ -1741,13 +1742,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; } diff --git a/clang/lib/AST/Interp/InterpBuiltin.cpp b/clang/lib/AST/Interp/InterpBuiltin.cpp --- a/clang/lib/AST/Interp/InterpBuiltin.cpp +++ b/clang/lib/AST/Interp/InterpBuiltin.cpp @@ -240,10 +240,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))); @@ -300,7 +299,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; @@ -394,7 +394,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: diff --git a/clang/lib/AST/Interp/Opcodes.td b/clang/lib/AST/Interp/Opcodes.td --- a/clang/lib/AST/Interp/Opcodes.td +++ b/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 = []; }