Skip to content

[Clang] use begin member expr location for call expr with deducing this #117345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 26, 2024

Conversation

a-tarasyuk
Copy link
Member

Fixes #116928

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Nov 22, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 22, 2024

@llvm/pr-subscribers-clang

Author: Oleksandr T. (a-tarasyuk)

Changes

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

Copy link
Contributor

@zyn0217 zyn0217 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo a release note.

@a-tarasyuk
Copy link
Member Author

@zyn0217 thanks for the review. I've added a release note.

@a-tarasyuk a-tarasyuk requested a review from zyn0217 November 26, 2024 10:19
@cor3ntin cor3ntin merged commit eb5d69c into llvm:main Nov 26, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CallExpr has incorrect begin location with "deducing this"
4 participants