[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
Fri Nov 22 08:31:34 PST 2024
https://github.com/a-tarasyuk created https://github.com/llvm/llvm-project/pull/117345
Fixes #116928
>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] [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 &)'
+}
+}
More information about the cfe-commits
mailing list