[clang] [Clang] Fix wrong call location of `DefaultArgExpr`. (PR #119212)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 9 06:34:37 PST 2024
https://github.com/16bit-ykiko updated https://github.com/llvm/llvm-project/pull/119212
>From 64dcfdfd0a87d6ca5bfcfe5f5a8e5204c24a26d2 Mon Sep 17 00:00:00 2001
From: ykiko <ykikoykikoykiko at gmail.com>
Date: Mon, 9 Dec 2024 21:56:58 +0800
Subject: [PATCH 1/3] Fix call location of `DefaultArgExpr`.
---
clang/lib/Sema/SemaExpr.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 14564b99de44c5..9b543d6484b85c 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5948,7 +5948,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
SmallVector<Expr *, 8> AllArgs;
VariadicCallType CallType = getVariadicCallType(FDecl, Proto, Fn);
- Invalid = GatherArgumentsForCall(Call->getBeginLoc(), FDecl, Proto, 0, Args,
+ Invalid = GatherArgumentsForCall(Call->getExprLoc(), FDecl, Proto, 0, Args,
AllArgs, CallType);
if (Invalid)
return true;
>From 07475f1289ea30c7d228ba448c4a5071d4b672ea Mon Sep 17 00:00:00 2001
From: ykiko <ykikoykikoykiko at gmail.com>
Date: Mon, 9 Dec 2024 22:26:04 +0800
Subject: [PATCH 2/3] Add release note and test.
---
clang/docs/ReleaseNotes.rst | 2 ++
clang/test/SemaCXX/source_location.cpp | 18 ++++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7d846f1d447d16..785bacef67a65d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -695,6 +695,8 @@ Bug Fixes to Compiler Builtins
- Fix ``__has_builtin`` incorrectly returning ``false`` for some C++ type traits. (#GH111477)
+- Fix ``__builtin_source_location`` incorrectly returning wrong column for method chains. (#GH119129)
+
Bug Fixes to Attribute Support
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/test/SemaCXX/source_location.cpp b/clang/test/SemaCXX/source_location.cpp
index 8b3a5d8dd3327d..f62b9627ec0592 100644
--- a/clang/test/SemaCXX/source_location.cpp
+++ b/clang/test/SemaCXX/source_location.cpp
@@ -1012,3 +1012,21 @@ int h = Var<int>;
}
+
+namespace GH119129 {
+struct X{
+ constexpr int foo(std::source_location loc = std::source_location::current()) {
+ return loc.line();
+ }
+};
+static_assert(X{}.foo() == __LINE__);
+static_assert(X{}.
+ foo() ==__LINE__);
+static_assert(X{}.
+
+
+ foo() ==__LINE__);
+#line 10000
+static_assert(X{}.
+ foo() == 10001);
+}
\ No newline at end of file
>From e253d079b2b964c71c8e406229ac74079b76b1be Mon Sep 17 00:00:00 2001
From: ykiko <ykikoykikoykiko at gmail.com>
Date: Mon, 9 Dec 2024 22:34:20 +0800
Subject: [PATCH 3/3] Add eof.
---
clang/test/SemaCXX/source_location.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/clang/test/SemaCXX/source_location.cpp b/clang/test/SemaCXX/source_location.cpp
index f62b9627ec0592..069a9004927a9f 100644
--- a/clang/test/SemaCXX/source_location.cpp
+++ b/clang/test/SemaCXX/source_location.cpp
@@ -1021,12 +1021,12 @@ struct X{
};
static_assert(X{}.foo() == __LINE__);
static_assert(X{}.
- foo() ==__LINE__);
+ foo() == __LINE__);
static_assert(X{}.
- foo() ==__LINE__);
+ foo() == __LINE__);
#line 10000
static_assert(X{}.
foo() == 10001);
-}
\ No newline at end of file
+}
More information about the cfe-commits
mailing list