Lines Matching refs:S
29 static bool RetValue(InterpState &S, CodePtr &Pt, APValue &Result) { in RetValue() argument
37 static bool Jmp(InterpState &S, CodePtr &PC, int32_t Offset) { in Jmp() argument
42 static bool Jt(InterpState &S, CodePtr &PC, int32_t Offset) { in Jt() argument
43 if (S.Stk.pop<bool>()) { in Jt()
49 static bool Jf(InterpState &S, CodePtr &PC, int32_t Offset) { in Jf() argument
50 if (!S.Stk.pop<bool>()) { in Jf()
56 static void diagnoseNonConstVariable(InterpState &S, CodePtr OpPC, in diagnoseNonConstVariable() argument
58 if (!S.getLangOpts().CPlusPlus) in diagnoseNonConstVariable()
61 const SourceInfo &Loc = S.Current->getSource(OpPC); in diagnoseNonConstVariable()
64 S.FFDiag(Loc, diag::note_constexpr_ltor_non_const_int, 1) << VD; in diagnoseNonConstVariable()
66 S.FFDiag(Loc, in diagnoseNonConstVariable()
67 S.getLangOpts().CPlusPlus11 in diagnoseNonConstVariable()
72 S.Note(VD->getLocation(), diag::note_declared_at); in diagnoseNonConstVariable()
75 static bool CheckActive(InterpState &S, CodePtr OpPC, const Pointer &Ptr, in CheckActive() argument
101 const SourceInfo &Loc = S.Current->getSource(OpPC); in CheckActive()
102 S.FFDiag(Loc, diag::note_constexpr_access_inactive_union_member) in CheckActive()
107 static bool CheckTemporary(InterpState &S, CodePtr OpPC, const Pointer &Ptr, in CheckTemporary() argument
116 if (S.P.getCurrentDecl() == ID) in CheckTemporary()
119 const SourceInfo &E = S.Current->getSource(OpPC); in CheckTemporary()
120 S.FFDiag(E, diag::note_constexpr_access_static_temporary, 1) << AK; in CheckTemporary()
121 S.Note(Ptr.getDeclLoc(), diag::note_constexpr_temporary_here); in CheckTemporary()
127 static bool CheckGlobal(InterpState &S, CodePtr OpPC, const Pointer &Ptr) { in CheckGlobal() argument
132 if (S.P.getCurrentDecl() == ID) in CheckGlobal()
135 S.FFDiag(S.Current->getLocation(OpPC), diag::note_constexpr_modify_global); in CheckGlobal()
143 static void popArg(InterpState &S, const Expr *Arg) { in popArg() argument
144 PrimType Ty = S.getContext().classify(Arg->getType()).value_or(PT_Ptr); in popArg()
145 TYPE_SWITCH(Ty, S.Stk.discard<T>()); in popArg()
148 void cleanupAfterFunctionCall(InterpState &S, CodePtr OpPC) { in cleanupAfterFunctionCall() argument
149 assert(S.Current); in cleanupAfterFunctionCall()
150 const Function *CurFunc = S.Current->getFunction(); in cleanupAfterFunctionCall()
160 cast<CallExpr>(S.Current->Caller->getExpr(S.Current->getRetPC())); in cleanupAfterFunctionCall()
163 popArg(S, A); in cleanupAfterFunctionCall()
168 if (S.Current->Caller && CurFunc->isVariadic()) { in cleanupAfterFunctionCall()
173 cast<CallExpr>(S.Current->Caller->getExpr(S.Current->getRetPC())); in cleanupAfterFunctionCall()
179 popArg(S, A); in cleanupAfterFunctionCall()
184 S.Current->popArgs(); in cleanupAfterFunctionCall()
187 bool CheckExtern(InterpState &S, CodePtr OpPC, const Pointer &Ptr) { in CheckExtern() argument
191 if (!S.checkingPotentialConstantExpression() && S.getLangOpts().CPlusPlus) { in CheckExtern()
193 diagnoseNonConstVariable(S, OpPC, VD); in CheckExtern()
198 bool CheckArray(InterpState &S, CodePtr OpPC, const Pointer &Ptr) { in CheckArray() argument
201 const SourceInfo &E = S.Current->getSource(OpPC); in CheckArray()
202 S.FFDiag(E, diag::note_constexpr_unsized_array_indexed); in CheckArray()
206 bool CheckLive(InterpState &S, CodePtr OpPC, const Pointer &Ptr, in CheckLive() argument
209 const auto &Src = S.Current->getSource(OpPC); in CheckLive()
212 S.FFDiag(Src, diag::note_constexpr_null_subobject) << CSK_Field; in CheckLive()
214 S.FFDiag(Src, diag::note_constexpr_access_null) << AK; in CheckLive()
220 const auto &Src = S.Current->getSource(OpPC); in CheckLive()
223 S.FFDiag(Src, diag::note_constexpr_lifetime_ended, 1) << AK << !IsTemp; in CheckLive()
226 S.Note(Ptr.getDeclLoc(), diag::note_constexpr_temporary_here); in CheckLive()
228 S.Note(Ptr.getDeclLoc(), diag::note_declared_at); in CheckLive()
236 bool CheckConstant(InterpState &S, CodePtr OpPC, const Descriptor *Desc) { in CheckConstant() argument
239 auto IsConstType = [&S](const VarDecl *VD) -> bool { in CheckConstant()
243 if (S.getLangOpts().CPlusPlus && !S.getLangOpts().CPlusPlus11) in CheckConstant()
262 diagnoseNonConstVariable(S, OpPC, VD); in CheckConstant()
263 return S.inConstantContext(); in CheckConstant()
270 static bool CheckConstant(InterpState &S, CodePtr OpPC, const Pointer &Ptr) { in CheckConstant() argument
271 return CheckConstant(S, OpPC, Ptr.getDeclDesc()); in CheckConstant()
274 bool CheckDummy(InterpState &S, CodePtr OpPC, const Pointer &Ptr) { in CheckDummy() argument
278 bool CheckNull(InterpState &S, CodePtr OpPC, const Pointer &Ptr, in CheckNull() argument
282 const SourceInfo &Loc = S.Current->getSource(OpPC); in CheckNull()
283 S.FFDiag(Loc, diag::note_constexpr_null_subobject) << CSK; in CheckNull()
287 bool CheckRange(InterpState &S, CodePtr OpPC, const Pointer &Ptr, in CheckRange() argument
291 const SourceInfo &Loc = S.Current->getSource(OpPC); in CheckRange()
292 S.FFDiag(Loc, diag::note_constexpr_access_past_end) << AK; in CheckRange()
296 bool CheckRange(InterpState &S, CodePtr OpPC, const Pointer &Ptr, in CheckRange() argument
300 const SourceInfo &Loc = S.Current->getSource(OpPC); in CheckRange()
301 S.FFDiag(Loc, diag::note_constexpr_past_end_subobject) << CSK; in CheckRange()
305 bool CheckSubobject(InterpState &S, CodePtr OpPC, const Pointer &Ptr, in CheckSubobject() argument
310 const SourceInfo &Loc = S.Current->getSource(OpPC); in CheckSubobject()
311 S.FFDiag(Loc, diag::note_constexpr_past_end_subobject) << CSK; in CheckSubobject()
315 bool CheckConst(InterpState &S, CodePtr OpPC, const Pointer &Ptr) { in CheckConst() argument
322 if (const Function *Func = S.Current->getFunction(); in CheckConst()
324 Ptr.block() == S.Current->getThis().block()) { in CheckConst()
329 const SourceInfo &Loc = S.Current->getSource(OpPC); in CheckConst()
330 S.FFDiag(Loc, diag::note_constexpr_modify_const_type) << Ty; in CheckConst()
334 bool CheckMutable(InterpState &S, CodePtr OpPC, const Pointer &Ptr) { in CheckMutable() argument
340 const SourceInfo &Loc = S.Current->getSource(OpPC); in CheckMutable()
342 S.FFDiag(Loc, diag::note_constexpr_access_mutable, 1) << AK_Read << Field; in CheckMutable()
343 S.Note(Field->getLocation(), diag::note_declared_at); in CheckMutable()
347 bool CheckInitialized(InterpState &S, CodePtr OpPC, const Pointer &Ptr, in CheckInitialized() argument
352 if (!S.checkingPotentialConstantExpression()) { in CheckInitialized()
353 S.FFDiag(S.Current->getSource(OpPC), diag::note_constexpr_access_uninit) in CheckInitialized()
354 << AK << /*uninitialized=*/true << S.Current->getRange(OpPC); in CheckInitialized()
359 bool CheckLoad(InterpState &S, CodePtr OpPC, const Pointer &Ptr) { in CheckLoad() argument
360 if (!CheckLive(S, OpPC, Ptr, AK_Read)) in CheckLoad()
362 if (!CheckConstant(S, OpPC, Ptr)) in CheckLoad()
365 if (!CheckDummy(S, OpPC, Ptr)) in CheckLoad()
367 if (!CheckExtern(S, OpPC, Ptr)) in CheckLoad()
369 if (!CheckRange(S, OpPC, Ptr, AK_Read)) in CheckLoad()
371 if (!CheckInitialized(S, OpPC, Ptr, AK_Read)) in CheckLoad()
373 if (!CheckActive(S, OpPC, Ptr, AK_Read)) in CheckLoad()
375 if (!CheckTemporary(S, OpPC, Ptr, AK_Read)) in CheckLoad()
377 if (!CheckMutable(S, OpPC, Ptr)) in CheckLoad()
382 bool CheckStore(InterpState &S, CodePtr OpPC, const Pointer &Ptr) { in CheckStore() argument
383 if (!CheckLive(S, OpPC, Ptr, AK_Assign)) in CheckStore()
385 if (!CheckExtern(S, OpPC, Ptr)) in CheckStore()
387 if (!CheckRange(S, OpPC, Ptr, AK_Assign)) in CheckStore()
389 if (!CheckGlobal(S, OpPC, Ptr)) in CheckStore()
391 if (!CheckConst(S, OpPC, Ptr)) in CheckStore()
396 bool CheckInvoke(InterpState &S, CodePtr OpPC, const Pointer &Ptr) { in CheckInvoke() argument
397 if (!CheckLive(S, OpPC, Ptr, AK_MemberCall)) in CheckInvoke()
399 if (!CheckExtern(S, OpPC, Ptr)) in CheckInvoke()
401 if (!CheckRange(S, OpPC, Ptr, AK_MemberCall)) in CheckInvoke()
406 bool CheckInit(InterpState &S, CodePtr OpPC, const Pointer &Ptr) { in CheckInit() argument
407 if (!CheckLive(S, OpPC, Ptr, AK_Assign)) in CheckInit()
409 if (!CheckRange(S, OpPC, Ptr, AK_Assign)) in CheckInit()
414 bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) { in CheckCallable() argument
416 if (F->isVirtual() && !S.getLangOpts().CPlusPlus20) { in CheckCallable()
417 const SourceLocation &Loc = S.Current->getLocation(OpPC); in CheckCallable()
418 S.CCEDiag(Loc, diag::note_constexpr_virtual_call); in CheckCallable()
423 const SourceLocation &Loc = S.Current->getLocation(OpPC); in CheckCallable()
424 if (S.getLangOpts().CPlusPlus11) { in CheckCallable()
440 S.FFDiag(Loc, diag::note_constexpr_invalid_inhctor, 1) in CheckCallable()
442 S.Note(DiagDecl->getLocation(), diag::note_declared_at); in CheckCallable()
447 if (!DiagDecl->isDefined() && S.checkingPotentialConstantExpression()) in CheckCallable()
450 S.FFDiag(Loc, diag::note_constexpr_invalid_function, 1) in CheckCallable()
452 S.Note(DiagDecl->getLocation(), diag::note_declared_at); in CheckCallable()
455 S.FFDiag(Loc, diag::note_invalid_subexpr_in_const_expr); in CheckCallable()
463 bool CheckCallDepth(InterpState &S, CodePtr OpPC) { in CheckCallDepth() argument
464 if ((S.Current->getDepth() + 1) > S.getLangOpts().ConstexprCallDepth) { in CheckCallDepth()
465 S.FFDiag(S.Current->getSource(OpPC), in CheckCallDepth()
467 << S.getLangOpts().ConstexprCallDepth; in CheckCallDepth()
474 bool CheckThis(InterpState &S, CodePtr OpPC, const Pointer &This) { in CheckThis() argument
478 const SourceInfo &Loc = S.Current->getSource(OpPC); in CheckThis()
484 if (S.getLangOpts().CPlusPlus11) in CheckThis()
485 S.FFDiag(Loc, diag::note_constexpr_this) << IsImplicit; in CheckThis()
487 S.FFDiag(Loc); in CheckThis()
492 bool CheckPure(InterpState &S, CodePtr OpPC, const CXXMethodDecl *MD) { in CheckPure() argument
495 const SourceInfo &E = S.Current->getSource(OpPC); in CheckPure()
496 S.FFDiag(E, diag::note_constexpr_pure_virtual_call, 1) << MD; in CheckPure()
497 S.Note(MD->getLocation(), diag::note_declared_at); in CheckPure()
501 bool CheckPotentialReinterpretCast(InterpState &S, CodePtr OpPC, in CheckPotentialReinterpretCast() argument
503 if (!S.inConstantContext()) in CheckPotentialReinterpretCast()
506 const SourceInfo &E = S.Current->getSource(OpPC); in CheckPotentialReinterpretCast()
507 S.CCEDiag(E, diag::note_constexpr_invalid_cast) in CheckPotentialReinterpretCast()
508 << 2 << S.getLangOpts().CPlusPlus << S.Current->getRange(OpPC); in CheckPotentialReinterpretCast()
512 bool CheckFloatResult(InterpState &S, CodePtr OpPC, const Floating &Result, in CheckFloatResult() argument
514 const SourceInfo &E = S.Current->getSource(OpPC); in CheckFloatResult()
521 S.CCEDiag(E, diag::note_constexpr_float_arithmetic) in CheckFloatResult()
522 << /*NaN=*/true << S.Current->getRange(OpPC); in CheckFloatResult()
523 return S.noteUndefinedBehavior(); in CheckFloatResult()
528 if (S.inConstantContext()) in CheckFloatResult()
531 FPOptions FPO = E.asExpr()->getFPFeaturesInEffect(S.Ctx.getLangOpts()); in CheckFloatResult()
537 S.FFDiag(E, diag::note_constexpr_dynamic_rounding); in CheckFloatResult()
545 S.FFDiag(E, diag::note_constexpr_float_arithmetic_strict); in CheckFloatResult()
552 S.FFDiag(E); in CheckFloatResult()
561 bool CheckDeclRef(InterpState &S, CodePtr OpPC, const DeclRefExpr *DR) { in CheckDeclRef() argument
563 const SourceInfo &E = S.Current->getSource(OpPC); in CheckDeclRef()
566 if (S.getLangOpts().CPlusPlus11) { in CheckDeclRef()
567 S.FFDiag(E, diag::note_constexpr_function_param_value_unknown) << D; in CheckDeclRef()
568 S.Note(D->getLocation(), diag::note_declared_at) << D->getSourceRange(); in CheckDeclRef()
570 S.FFDiag(E); in CheckDeclRef()
574 diagnoseNonConstVariable(S, OpPC, VD); in CheckDeclRef()
580 S.FFDiag(E, diag::note_constexpr_var_init_unknown, 1) << VD; in CheckDeclRef()
581 S.Note(VD->getLocation(), diag::note_declared_at) << VD->getSourceRange(); in CheckDeclRef()
589 bool Interpret(InterpState &S, APValue &Result) { in Interpret() argument
594 const InterpFrame *StartFrame = S.Current; in Interpret()
595 assert(!S.Current->isRoot()); in Interpret()
596 CodePtr PC = S.Current->getPC(); in Interpret()