Author: Timm Bäder Date: 2023-09-09T07:28:50+02:00 New Revision: f8074942c5a6f266abb1c4d1465a4d8115b22d43
URL: https://github.com/llvm/llvm-project/commit/f8074942c5a6f266abb1c4d1465a4d8115b22d43 DIFF: https://github.com/llvm/llvm-project/commit/f8074942c5a6f266abb1c4d1465a4d8115b22d43.diff LOG: [clang][Interp] Fix SourceLocExpr used in CXXDefaultInitExprs ... when initializing. Fixes a problem pointed out in https://reviews.llvm.org/D156045/ Added: Modified: clang/lib/AST/Interp/ByteCodeExprGen.cpp clang/test/AST/Interp/builtin-functions.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp index 77334268df1c14b..17cf15d8676eb86 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -2152,12 +2152,11 @@ bool ByteCodeExprGen<Emitter>::VisitCXXMemberCallExpr( template <class Emitter> bool ByteCodeExprGen<Emitter>::VisitCXXDefaultInitExpr( const CXXDefaultInitExpr *E) { - + SourceLocScope<Emitter> SLS(this, E); if (Initializing) return this->visitInitializer(E->getExpr()); assert(classify(E->getType())); - SourceLocScope<Emitter> SLS(this, E); return this->visit(E->getExpr()); } diff --git a/clang/test/AST/Interp/builtin-functions.cpp b/clang/test/AST/Interp/builtin-functions.cpp index 52ecee536938f3f..cd4ad010af12220 100644 --- a/clang/test/AST/Interp/builtin-functions.cpp +++ b/clang/test/AST/Interp/builtin-functions.cpp @@ -248,4 +248,15 @@ namespace SourceLocation { }; static_assert(Foo{}.a == __LINE__, ""); + + struct AA { + int n = __builtin_LINE(); + }; + struct B { + AA a = {}; + }; + constexpr void f() { + constexpr B c = {}; + static_assert(c.a.n == __LINE__ - 1, ""); + } } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits