diff --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h index afc5f24baf73a..1eda38e9fa5b1 100644 --- a/clang/lib/AST/Interp/Interp.h +++ b/clang/lib/AST/Interp/Interp.h @@ -1486,28 +1486,29 @@ inline bool ArrayElemPtrPop(InterpState &S, CodePtr OpPC) { return NarrowPtr(S, OpPC); } -inline bool CheckGlobalCtor(InterpState &S, CodePtr &PC) { +inline bool CheckGlobalCtor(InterpState &S, CodePtr OpPC) { const Pointer &Obj = S.Stk.peek(); - return CheckCtorCall(S, PC, Obj); + return CheckCtorCall(S, OpPC, Obj); } -inline bool Call(InterpState &S, CodePtr &PC, const Function *Func) { +inline bool Call(InterpState &S, CodePtr OpPC, const Function *Func) { if (Func->hasThisPointer()) { size_t ThisOffset = Func->getArgSize() + (Func->hasRVO() ? primSize(PT_Ptr) : 0); + const Pointer &ThisPtr = S.Stk.peek(ThisOffset); - if (!CheckInvoke(S, PC, ThisPtr)) + if (!CheckInvoke(S, OpPC, ThisPtr)) return false; if (S.checkingPotentialConstantExpression()) return false; } - if (!CheckCallable(S, PC, Func)) + if (!CheckCallable(S, OpPC, Func)) return false; - auto NewFrame = std::make_unique(S, Func, PC); + auto NewFrame = std::make_unique(S, Func, OpPC); InterpFrame *FrameBefore = S.Current; S.Current = NewFrame.get(); @@ -1541,14 +1542,14 @@ inline bool CallBI(InterpState &S, CodePtr &PC, const Function *Func) { return false; } -inline bool CallPtr(InterpState &S, CodePtr &PC) { +inline bool CallPtr(InterpState &S, CodePtr OpPC) { const FunctionPointer &FuncPtr = S.Stk.pop(); const Function *F = FuncPtr.getFunction(); if (!F || !F->isConstexpr()) return false; - return Call(S, PC, F); + return Call(S, OpPC, F); } inline bool GetFnPtr(InterpState &S, CodePtr &PC, const Function *Func) { diff --git a/clang/lib/AST/Interp/Opcodes.td b/clang/lib/AST/Interp/Opcodes.td index f3662dcd6f430..ed0774a788333 100644 --- a/clang/lib/AST/Interp/Opcodes.td +++ b/clang/lib/AST/Interp/Opcodes.td @@ -179,19 +179,16 @@ def NoRet : Opcode {} def Call : Opcode { let Args = [ArgFunction]; let Types = []; - let ChangesPC = 1; } def CallBI : Opcode { let Args = [ArgFunction]; let Types = []; - let ChangesPC = 1; } def CallPtr : Opcode { let Args = []; let Types = []; - let ChangesPC = 1; } //===----------------------------------------------------------------------===//