[clang] [Clang] use begin member expr location for call expr with deducing this (PR #117345)

via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 22 08:33:01 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Oleksandr T. (a-tarasyuk)

<details>
<summary>Changes</summary>

Fixes #<!-- -->116928

---
Full diff: https://github.com/llvm/llvm-project/pull/117345.diff


2 Files Affected:

- (modified) clang/lib/Sema/SemaOverload.cpp (+1-1) 
- (added) clang/test/AST/ast-dump-cxx2b-deducing-this.cpp (+15) 


``````````diff
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 &)'
+}
+}

``````````

</details>


https://github.com/llvm/llvm-project/pull/117345


More information about the cfe-commits mailing list