diff --git a/CodeGenerator.cpp b/CodeGenerator.cpp index ec175c46..759249de 100644 --- a/CodeGenerator.cpp +++ b/CodeGenerator.cpp @@ -589,6 +589,12 @@ static std::optional GetFieldDeclNameForLambda(const FieldDecl& } //----------------------------------------------------------------------------- +void CodeGenerator::InsertArg(const SourceLocExpr* stmt) +{ + mOutputFormatHelper.Append(stmt->getBuiltinStr(), "()"sv); +} +//----------------------------------------------------------------------------- + void CodeGenerator::InsertArg(const MemberExpr* stmt) { const auto* base = stmt->getBase(); diff --git a/CodeGeneratorTypes.h b/CodeGeneratorTypes.h index 588274c7..f80f891a 100644 --- a/CodeGeneratorTypes.h +++ b/CodeGeneratorTypes.h @@ -130,6 +130,7 @@ SUPPORTED_STMT(AttributedStmt) SUPPORTED_STMT(ConceptSpecializationExpr) SUPPORTED_STMT(RequiresExpr) SUPPORTED_STMT(StmtExpr) +SUPPORTED_STMT(SourceLocExpr) SUPPORTED_STMT(CppInsightsCommentStmt) #undef IGNORED_DECL diff --git a/tests/Issue598.cpp b/tests/Issue598.cpp new file mode 100644 index 00000000..4c074672 --- /dev/null +++ b/tests/Issue598.cpp @@ -0,0 +1,7 @@ +// cmdline:-std=c++20 + +#include + +auto s = std::source_location::current(); + +auto X = __builtin_LINE(); diff --git a/tests/Issue598.expect b/tests/Issue598.expect new file mode 100644 index 00000000..d0261c1e --- /dev/null +++ b/tests/Issue598.expect @@ -0,0 +1,9 @@ +// cmdline:-std=c++20 + +#include + +std::source_location s = std::source_location::current(__builtin_source_location()); + + +unsigned int X = __builtin_LINE(); +