@@ -551,8 +551,8 @@ bool CheckInitialized(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
551
551
552
552
if (const auto *VD = Ptr .getDeclDesc ()->asVarDecl ();
553
553
VD && (VD->isConstexpr () || VD->hasGlobalStorage ())) {
554
- const SourceInfo &Loc = S.Current ->getSource (OpPC);
555
554
if (VD->getAnyInitializer ()) {
555
+ const SourceInfo &Loc = S.Current ->getSource (OpPC);
556
556
S.FFDiag (Loc, diag::note_constexpr_var_init_non_constant, 1 ) << VD;
557
557
S.Note (VD->getLocation (), diag::note_declared_at);
558
558
} else {
@@ -722,7 +722,6 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
722
722
if (F->isLambdaStaticInvoker ())
723
723
return true ;
724
724
725
- const SourceLocation &Loc = S.Current ->getLocation (OpPC);
726
725
if (S.getLangOpts ().CPlusPlus11 ) {
727
726
const FunctionDecl *DiagDecl = F->getDecl ();
728
727
@@ -748,7 +747,8 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
748
747
// or an inheriting constructor, we should be much more explicit about why
749
748
// it's not constexpr.
750
749
if (CD && CD->isInheritingConstructor ()) {
751
- S.FFDiag (Loc, diag::note_constexpr_invalid_inhctor, 1 )
750
+ S.FFDiag (S.Current ->getLocation (OpPC),
751
+ diag::note_constexpr_invalid_inhctor, 1 )
752
752
<< CD->getInheritedConstructor ().getConstructor ()->getParent ();
753
753
S.Note (DiagDecl->getLocation (), diag::note_declared_at);
754
754
} else {
@@ -766,7 +766,8 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
766
766
DiagDecl->hasBody ())
767
767
return false ;
768
768
769
- S.FFDiag (Loc, diag::note_constexpr_invalid_function, 1 )
769
+ S.FFDiag (S.Current ->getLocation (OpPC),
770
+ diag::note_constexpr_invalid_function, 1 )
770
771
<< DiagDecl->isConstexpr () << (bool )CD << DiagDecl;
771
772
772
773
if (DiagDecl->getDefinition ())
@@ -776,7 +777,8 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
776
777
S.Note (DiagDecl->getLocation (), diag::note_declared_at);
777
778
}
778
779
} else {
779
- S.FFDiag (Loc, diag::note_invalid_subexpr_in_const_expr);
780
+ S.FFDiag (S.Current ->getLocation (OpPC),
781
+ diag::note_invalid_subexpr_in_const_expr);
780
782
}
781
783
782
784
return false ;
@@ -980,11 +982,6 @@ bool CheckNonNullArgs(InterpState &S, CodePtr OpPC, const Function *F,
980
982
return true ;
981
983
}
982
984
983
- // FIXME: This is similar to code we already have in Compiler.cpp.
984
- // I think it makes sense to instead add the field and base destruction stuff
985
- // to the destructor Function itself. Then destroying a record would really
986
- // _just_ be calling its destructor. That would also help with the diagnostic
987
- // difference when the destructor or a field/base fails.
988
985
static bool runRecordDestructor (InterpState &S, CodePtr OpPC,
989
986
const Pointer &BasePtr,
990
987
const Descriptor *Desc) {
@@ -1095,8 +1092,8 @@ bool Free(InterpState &S, CodePtr OpPC, bool DeleteIsArrayForm,
1095
1092
1096
1093
// For a class type with a virtual destructor, the selected operator delete
1097
1094
// is the one looked up when building the destructor.
1098
- QualType AllocType = Ptr .getType ();
1099
1095
if (!DeleteIsArrayForm && !IsGlobalDelete) {
1096
+ QualType AllocType = Ptr .getType ();
1100
1097
auto getVirtualOperatorDelete = [](QualType T) -> const FunctionDecl * {
1101
1098
if (const CXXRecordDecl *RD = T->getAsCXXRecordDecl ())
1102
1099
if (const CXXDestructorDecl *DD = RD->getDestructor ())
0 commit comments