[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
Tue Nov 26 00:29:02 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/3] [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/3] 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
 ^^^^^^^^^^^^^^^^^^^^^^^^^

>From 905be9c9b6e8d20f2849fab8d04dcd4709efac45 Mon Sep 17 00:00:00 2001
From: Oleksandr T <oleksandr.tarasiuk at outlook.com>
Date: Tue, 26 Nov 2024 10:27:12 +0200
Subject: [PATCH 3/3] move release note to a different category

---
 clang/docs/ReleaseNotes.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 49510392afb190..7ca53920de2d9a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -714,8 +714,6 @@ 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
 ^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -725,6 +723,8 @@ Bug Fixes to AST Handling
   sometimes incorrectly return null even if a comment was present. (#GH108145)
 - Clang now correctly parses the argument of the ``relates``, ``related``, ``relatesalso``,
   and ``relatedalso`` comment commands.
+- Clang now uses the location of the begin of the member expression for ``CallExpr``
+  involving deduced ``this``. (#GH116928)
 
 Miscellaneous Bug Fixes
 ^^^^^^^^^^^^^^^^^^^^^^^



More information about the cfe-commits mailing list