[clang] [Clang] use begin member expr location for call expr with deducing this (PR #117345)
Oleksandr T. via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 25 04:59:26 PST 2024
https://github.com/a-tarasyuk updated https://github.com/llvm/llvm-project/pull/117345
>From c3480ca4f4f5b14185880c055613648ceb9f15be Mon Sep 17 00:00:00 2001
From: Oleksandr T <oleksandr.tarasiuk at outlook.com>
Date: Fri, 22 Nov 2024 18:29:52 +0200
Subject: [PATCH 1/2] [Clang] use begin member expression location for CallExpr
with deducing this
---
clang/lib/Sema/SemaOverload.cpp | 2 +-
clang/test/AST/ast-dump-cxx2b-deducing-this.cpp | 15 +++++++++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
create mode 100644 clang/test/AST/ast-dump-cxx2b-deducing-this.cpp
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index e4bf9aa521224b..4c9e37bd286dee 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -15565,7 +15565,7 @@ ExprResult Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
// Build the actual expression node.
ExprResult FnExpr =
CreateFunctionRefExpr(*this, Method, FoundDecl, MemExpr,
- HadMultipleCandidates, MemExpr->getExprLoc());
+ HadMultipleCandidates, MemExpr->getBeginLoc());
if (FnExpr.isInvalid())
return ExprError();
diff --git a/clang/test/AST/ast-dump-cxx2b-deducing-this.cpp b/clang/test/AST/ast-dump-cxx2b-deducing-this.cpp
new file mode 100644
index 00000000000000..04cff07376885a
--- /dev/null
+++ b/clang/test/AST/ast-dump-cxx2b-deducing-this.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++2b -ast-dump %s | FileCheck -strict-whitespace %s
+
+namespace GH116928 {
+struct S {
+ int f(this S&);
+};
+
+int main() {
+ S s;
+ int x = s.f();
+ // CHECK: CallExpr 0x{{[^ ]*}} <col:11, col:15> 'int
+ // CHECK-NEXT: |-ImplicitCastExpr 0x{{[^ ]*}} <col:11> 'int (*)(S &)' <FunctionToPointerDecay>
+ // CHECK-NEXT: | `-DeclRefExpr 0x{{[^ ]*}} <col:11> 'int (S &)' lvalue CXXMethod 0x{{[^ ]*}} 'f' 'int (S &)'
+}
+}
>From cf34775cd7d277beb96840ff88e1a588df261099 Mon Sep 17 00:00:00 2001
From: Oleksandr T <oleksandr.tarasiuk at outlook.com>
Date: Mon, 25 Nov 2024 14:58:30 +0200
Subject: [PATCH 2/2] add release note
---
clang/docs/ReleaseNotes.rst | 2 ++
1 file changed, 2 insertions(+)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 54145b28154eb4..49510392afb190 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -714,6 +714,8 @@ Bug Fixes to C++ Support
assumption if they also occur inside of a dependent lambda. (#GH114787)
- Clang now uses valid deduced type locations when diagnosing functions with trailing return type
missing placeholder return type. (#GH78694)
+- Clang now uses the location of the begin of the member expression for ``CallExpr``
+ involving deduced ``this``. (#GH116928)
Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
More information about the cfe-commits
mailing list