[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-07-17 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny created this revision.
Herald added subscribers: usaxena95, kadircet.
Herald added a project: All.
SimplyDanny requested review of this revision.
Herald added subscribers: cfe-commits, ilya-biryukov.
Herald added projects: clang, clang-tools-extra.

Without the "found declaration" it is later not possible to know where the 
operator declaration
was brought into the scope calling it.

The initial motivation for this fix came from #55095. However, this also has an 
influence on
`clang -ast-dump` which now prints a `UsingShadow` attribute for operators only 
visible through
`using` statements. Also, clangd now correctly references the `using` statement 
instead of the
operator directly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129973

Files:
  clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp


Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -4675,6 +4675,9 @@
   EXPECT_TRUE(notMatches(
 "namespace a { void f(); } using a::f; void g() { a::f(); }",
 declRefExpr(throughUsingDecl(anything();
+  EXPECT_TRUE(matches(
+"struct S {}; namespace a { int operator+(S s1, S s2) { return 0; }; } 
using a::operator+; int g() { S a, b; return a + b; }",
+declRefExpr(throughUsingDecl(anything();
 }
 
 TEST(SingleDecl, IsSingleDecl) {
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -63,8 +63,10 @@
   // being used.
   if (FoundDecl != Fn && S.DiagnoseUseOfDecl(Fn, Loc))
 return ExprError();
-  DeclRefExpr *DRE = new (S.Context)
-  DeclRefExpr(S.Context, Fn, false, Fn->getType(), VK_LValue, Loc, 
LocInfo);
+  DeclRefExpr *DRE =
+  DeclRefExpr::Create(S.Context, Fn->getQualifierLoc(), Loc, Fn, false,
+  Loc, Fn->getType(),  VK_LValue,
+  FoundDecl);
   if (HadMultipleCandidates)
 DRE->setHadMultipleCandidates(true);
 
Index: clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.cpp
@@ -210,3 +210,14 @@
 // We used to report Q unsued, because we only checked the first template
 // argument.
 Bar *bar;
+
+namespace internal { 
+  struct S {};
+  int operator+(S s1, S s2) { return 0; };
+} 
+
+// Make sure this statement is not reported as unused.
+using internal::operator+; 
+using internal::S;
+
+int j() { return S() + S(); }


Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -4675,6 +4675,9 @@
   EXPECT_TRUE(notMatches(
 "namespace a { void f(); } using a::f; void g() { a::f(); }",
 declRefExpr(throughUsingDecl(anything();
+  EXPECT_TRUE(matches(
+"struct S {}; namespace a { int operator+(S s1, S s2) { return 0; }; } using a::operator+; int g() { S a, b; return a + b; }",
+declRefExpr(throughUsingDecl(anything();
 }
 
 TEST(SingleDecl, IsSingleDecl) {
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -63,8 +63,10 @@
   // being used.
   if (FoundDecl != Fn && S.DiagnoseUseOfDecl(Fn, Loc))
 return ExprError();
-  DeclRefExpr *DRE = new (S.Context)
-  DeclRefExpr(S.Context, Fn, false, Fn->getType(), VK_LValue, Loc, LocInfo);
+  DeclRefExpr *DRE =
+  DeclRefExpr::Create(S.Context, Fn->getQualifierLoc(), Loc, Fn, false,
+  Loc, Fn->getType(),  VK_LValue,
+  FoundDecl);
   if (HadMultipleCandidates)
 DRE->setHadMultipleCandidates(true);
 
Index: clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.cpp
@@ -210,3 +210,14 @@
 // We used to report Q unsued, because we only checked the first template
 // argument.
 Bar *bar;
+
+namespace internal { 
+  struct S {};
+  int operator+(S s1, S s2) { return 0; };
+} 
+
+// Make sure this statement is not reported as unused.
+using internal::operator+; 
+using internal::S;
+
+int j() { return S() + S(); }
__

[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-07-18 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

Thank you for working on this.

It looks like there are some pre-commit test failures, did you confirm whether 
they were related to your change or not?

Also you mentioned that this changes the output of `-ast-dump` it might be 
worth adding a test to capture this behavior change.




Comment at: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:4679
+  EXPECT_TRUE(matches(
+"struct S {}; namespace a { int operator+(S s1, S s2) { return 0; }; } 
using a::operator+; int g() { S a, b; return a + b; }",
+declRefExpr(throughUsingDecl(anything();

You have a trailing `;` after the definition of `a::operator+` please remove it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129973/new/

https://reviews.llvm.org/D129973

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-07-21 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny updated this revision to Diff 446592.
SimplyDanny added a comment.
Herald added a subscriber: arphaman.

Added a test for the AST dump and updated some test references.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129973/new/

https://reviews.llvm.org/D129973

Files:
  clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/AST/ast-dump-overloaded-operators.cpp
  clang/test/Index/annotate-operator-call-expr.cpp
  clang/test/Index/cursor-ref-names.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -4675,6 +4675,9 @@
   EXPECT_TRUE(notMatches(
 "namespace a { void f(); } using a::f; void g() { a::f(); }",
 declRefExpr(throughUsingDecl(anything();
+  EXPECT_TRUE(matches(
+"struct S {}; namespace a { int operator+(S s1, S s2); } using a::operator+; int g() { return S() + S(); }",
+declRefExpr(throughUsingDecl(anything();
 }
 
 TEST(SingleDecl, IsSingleDecl) {
Index: clang/test/Index/cursor-ref-names.cpp
===
--- clang/test/Index/cursor-ref-names.cpp
+++ clang/test/Index/cursor-ref-names.cpp
@@ -33,9 +33,9 @@
 // CHECK: cursor-ref-names.cpp:18:5: CallExpr=func:8:10 Extent=[18:5 - 18:16]
 // CHECK: cursor-ref-names.cpp:18:10: MemberRefExpr=func:8:10 SingleRefName=[18:10 - 18:14] RefName=[18:10 - 18:14] Extent=[18:5 - 18:14]
 // CHECK: cursor-ref-names.cpp:18:5: DeclRefExpr=inst:17:9 Extent=[18:5 - 18:9]
-// CHECK: cursor-ref-names.cpp:19:5: CallExpr=operator[]:4:9 SingleRefName=[19:9 - 19:12] RefName=[19:9 - 19:10] RefName=[19:11 - 19:12] Extent=[19:5 - 19:12]
+// CHECK: cursor-ref-names.cpp:19:5: CallExpr=operator[]:4:9 Extent=[19:5 - 19:12] 
 // CHECK: cursor-ref-names.cpp:19:5: DeclRefExpr=inst:17:9 Extent=[19:5 - 19:9]
-// CHECK: cursor-ref-names.cpp:19:9: DeclRefExpr=operator[]:4:9 RefName=[19:9 - 19:10] RefName=[19:11 - 19:12] Extent=[19:9 - 19:12]
+// CHECK: cursor-ref-names.cpp:19:9: DeclRefExpr=operator[]:4:9 Extent=[19:9 - 19:10]
 // CHECK: cursor-ref-names.cpp:20:5: CallExpr=operator[]:4:9 Extent=[20:5 - 20:23]
 // CHECK: cursor-ref-names.cpp:20:10: MemberRefExpr=operator[]:4:9 SingleRefName=[20:10 - 20:20] RefName=[20:10 - 20:18] RefName=[20:18 - 20:19] RefName=[20:19 - 20:20] Extent=[20:5 - 20:20]
 // CHECK: cursor-ref-names.cpp:20:5: DeclRefExpr=inst:17:9 Extent=[20:5 - 20:9]
Index: clang/test/Index/annotate-operator-call-expr.cpp
===
--- clang/test/Index/annotate-operator-call-expr.cpp
+++ clang/test/Index/annotate-operator-call-expr.cpp
@@ -17,68 +17,68 @@
 
 // RUN: c-index-test -test-annotate-tokens=%s:7:1:7:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK1
 // CHECK1: Identifier: "foo" [7:3 - 7:6] DeclRefExpr=foo:6:18
-// CHECK1: Punctuation: "(" [7:6 - 7:7] DeclRefExpr=operator():3:7 RefName=[7:6 - 7:7] RefName=[7:7 - 7:8]
-// CHECK1: Punctuation: ")" [7:7 - 7:8] DeclRefExpr=operator():3:7 RefName=[7:6 - 7:7] RefName=[7:7 - 7:8]
+// CHECK1: Punctuation: "(" [7:6 - 7:7] CallExpr=operator():3:7
+// CHECK1: Punctuation: ")" [7:7 - 7:8] CallExpr=operator():3:7
 // CHECK1: Punctuation: ";" [7:8 - 7:9] CompoundStmt=
 
 // RUN: c-index-test -test-annotate-tokens=%s:8:1:8:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK2
-// CHECK2: Punctuation: "(" [8:6 - 8:7] DeclRefExpr=operator():3:7 RefName=[8:6 - 8:7] RefName=[8:12 - 8:13]
+// CHECK2: Punctuation: "(" [8:6 - 8:7] CallExpr=operator():3:7
 // CHECK2: Identifier: "index" [8:7 - 8:12] DeclRefExpr=index:6:27
-// CHECK2: Punctuation: ")" [8:12 - 8:13] DeclRefExpr=operator():3:7 RefName=[8:6 - 8:7] RefName=[8:12 - 8:13]
+// CHECK2: Punctuation: ")" [8:12 - 8:13] CallExpr=operator():3:7
 // CHECK2: Punctuation: ";" [8:13 - 8:14] CompoundStmt=
 
 // RUN: c-index-test -test-annotate-tokens=%s:10:1:10:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK3
 // CHECK3: Identifier: "foo" [10:3 - 10:6] DeclRefExpr=foo:6:18
-// CHECK3: Punctuation: "[" [10:6 - 10:7] DeclRefExpr=operator[]:2:7 RefName=[10:6 - 10:7] RefName=[10:12 - 10:13]
+// CHECK3: Punctuation: "[" [10:6 - 10:7] CallExpr=operator[]:2:7
 // CHECK3: Identifier: "index" [10:7 - 10:12] DeclRefExpr=index:6:27
-// CHECK3: Punctuation: "]" [10:12 - 10:13] DeclRefExpr=operator[]:2:7 RefName=[10:6 - 10:7] RefName=[10:12 - 10:13]
+// CHECK3: Punctuation: "]" [10:12 - 10:13] CallExpr=operator[]:2:7
 // CHECK3: Punctuation: ";" [10:13 - 10:14] CompoundStmt=
 
 // RUN: c-index-test -test-annotate-tokens=%s:11:1:11:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK4
 // CHECK4: Identifier: "f

[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-07-21 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny marked an inline comment as done.
SimplyDanny added inline comments.



Comment at: clang/test/Index/annotate-operator-call-expr.cpp:21
+// CHECK1: Punctuation: "(" [7:6 - 7:7] CallExpr=operator():3:7
+// CHECK1: Punctuation: ")" [7:7 - 7:8] CallExpr=operator():3:7
 // CHECK1: Punctuation: ";" [7:8 - 7:9] CompoundStmt=

I updated the test expectation without actually knowing whether the test 
references are correct(er) now. There seems to be some loss of information and 
some `CallExpr`s are now seen as `DeclRefExpr`s. Please tell me if these 
changes are okay. I rather made them to have a basis for discussions.



Comment at: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:4679
+  EXPECT_TRUE(matches(
+"struct S {}; namespace a { int operator+(S s1, S s2) { return 0; }; } 
using a::operator+; int g() { S a, b; return a + b; }",
+declRefExpr(throughUsingDecl(anything();

shafik wrote:
> You have a trailing `;` after the definition of `a::operator+` please remove 
> it.
Made it a declaration which is sufficient for the test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129973/new/

https://reviews.llvm.org/D129973

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-07-21 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny marked an inline comment as done.
SimplyDanny added inline comments.



Comment at: clang/test/AST/ast-dump-overloaded-operators.cpp:65
+// CHECK-NEXT:   |-ImplicitCastExpr {{.*}}  'void (*)(E, E)' 

+// CHECK-NEXT:   | `-DeclRefExpr {{.*}}  'void (E, E)' lvalue 
Function {{.*}} 'operator-' 'void (E, E)' (UsingShadow {{.*}} 'operator-')
+// CHECK-NEXT:   |-CXXScalarValueInitExpr {{.*}}  'E'

This verifies the AST dump. The new part is the `UsingShadow` at the end of 
this line.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129973/new/

https://reviews.llvm.org/D129973

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-07-21 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny updated this revision to Diff 446629.
SimplyDanny added a comment.

Rebased commit onto current main branch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129973/new/

https://reviews.llvm.org/D129973

Files:
  clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/AST/ast-dump-overloaded-operators.cpp
  clang/test/Index/annotate-operator-call-expr.cpp
  clang/test/Index/cursor-ref-names.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -4675,6 +4675,9 @@
   EXPECT_TRUE(notMatches(
 "namespace a { void f(); } using a::f; void g() { a::f(); }",
 declRefExpr(throughUsingDecl(anything();
+  EXPECT_TRUE(matches(
+"struct S {}; namespace a { int operator+(S s1, S s2); } using a::operator+; int g() { return S() + S(); }",
+declRefExpr(throughUsingDecl(anything();
 }
 
 TEST(SingleDecl, IsSingleDecl) {
Index: clang/test/Index/cursor-ref-names.cpp
===
--- clang/test/Index/cursor-ref-names.cpp
+++ clang/test/Index/cursor-ref-names.cpp
@@ -33,9 +33,9 @@
 // CHECK: cursor-ref-names.cpp:18:5: CallExpr=func:8:10 Extent=[18:5 - 18:16]
 // CHECK: cursor-ref-names.cpp:18:10: MemberRefExpr=func:8:10 SingleRefName=[18:10 - 18:14] RefName=[18:10 - 18:14] Extent=[18:5 - 18:14]
 // CHECK: cursor-ref-names.cpp:18:5: DeclRefExpr=inst:17:9 Extent=[18:5 - 18:9]
-// CHECK: cursor-ref-names.cpp:19:5: CallExpr=operator[]:4:9 SingleRefName=[19:9 - 19:12] RefName=[19:9 - 19:10] RefName=[19:11 - 19:12] Extent=[19:5 - 19:12]
+// CHECK: cursor-ref-names.cpp:19:5: CallExpr=operator[]:4:9 Extent=[19:5 - 19:12] 
 // CHECK: cursor-ref-names.cpp:19:5: DeclRefExpr=inst:17:9 Extent=[19:5 - 19:9]
-// CHECK: cursor-ref-names.cpp:19:9: DeclRefExpr=operator[]:4:9 RefName=[19:9 - 19:10] RefName=[19:11 - 19:12] Extent=[19:9 - 19:12]
+// CHECK: cursor-ref-names.cpp:19:9: DeclRefExpr=operator[]:4:9 Extent=[19:9 - 19:10]
 // CHECK: cursor-ref-names.cpp:20:5: CallExpr=operator[]:4:9 Extent=[20:5 - 20:23]
 // CHECK: cursor-ref-names.cpp:20:10: MemberRefExpr=operator[]:4:9 SingleRefName=[20:10 - 20:20] RefName=[20:10 - 20:18] RefName=[20:18 - 20:19] RefName=[20:19 - 20:20] Extent=[20:5 - 20:20]
 // CHECK: cursor-ref-names.cpp:20:5: DeclRefExpr=inst:17:9 Extent=[20:5 - 20:9]
Index: clang/test/Index/annotate-operator-call-expr.cpp
===
--- clang/test/Index/annotate-operator-call-expr.cpp
+++ clang/test/Index/annotate-operator-call-expr.cpp
@@ -17,68 +17,68 @@
 
 // RUN: c-index-test -test-annotate-tokens=%s:7:1:7:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK1
 // CHECK1: Identifier: "foo" [7:3 - 7:6] DeclRefExpr=foo:6:18
-// CHECK1: Punctuation: "(" [7:6 - 7:7] DeclRefExpr=operator():3:7 RefName=[7:6 - 7:7] RefName=[7:7 - 7:8]
-// CHECK1: Punctuation: ")" [7:7 - 7:8] DeclRefExpr=operator():3:7 RefName=[7:6 - 7:7] RefName=[7:7 - 7:8]
+// CHECK1: Punctuation: "(" [7:6 - 7:7] CallExpr=operator():3:7
+// CHECK1: Punctuation: ")" [7:7 - 7:8] CallExpr=operator():3:7
 // CHECK1: Punctuation: ";" [7:8 - 7:9] CompoundStmt=
 
 // RUN: c-index-test -test-annotate-tokens=%s:8:1:8:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK2
-// CHECK2: Punctuation: "(" [8:6 - 8:7] DeclRefExpr=operator():3:7 RefName=[8:6 - 8:7] RefName=[8:12 - 8:13]
+// CHECK2: Punctuation: "(" [8:6 - 8:7] CallExpr=operator():3:7
 // CHECK2: Identifier: "index" [8:7 - 8:12] DeclRefExpr=index:6:27
-// CHECK2: Punctuation: ")" [8:12 - 8:13] DeclRefExpr=operator():3:7 RefName=[8:6 - 8:7] RefName=[8:12 - 8:13]
+// CHECK2: Punctuation: ")" [8:12 - 8:13] CallExpr=operator():3:7
 // CHECK2: Punctuation: ";" [8:13 - 8:14] CompoundStmt=
 
 // RUN: c-index-test -test-annotate-tokens=%s:10:1:10:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK3
 // CHECK3: Identifier: "foo" [10:3 - 10:6] DeclRefExpr=foo:6:18
-// CHECK3: Punctuation: "[" [10:6 - 10:7] DeclRefExpr=operator[]:2:7 RefName=[10:6 - 10:7] RefName=[10:12 - 10:13]
+// CHECK3: Punctuation: "[" [10:6 - 10:7] CallExpr=operator[]:2:7
 // CHECK3: Identifier: "index" [10:7 - 10:12] DeclRefExpr=index:6:27
-// CHECK3: Punctuation: "]" [10:12 - 10:13] DeclRefExpr=operator[]:2:7 RefName=[10:6 - 10:7] RefName=[10:12 - 10:13]
+// CHECK3: Punctuation: "]" [10:12 - 10:13] CallExpr=operator[]:2:7
 // CHECK3: Punctuation: ";" [10:13 - 10:14] CompoundStmt=
 
 // RUN: c-index-test -test-annotate-tokens=%s:11:1:11:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK4
 // CHECK4: Identifier: "foo" [11:3 - 11:6] DeclRefExpr=foo:6:18
-// CHECK4: Punctuati

[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-07-21 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny updated this revision to Diff 446718.
SimplyDanny added a comment.

Fixed formatting.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129973/new/

https://reviews.llvm.org/D129973

Files:
  clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/AST/ast-dump-overloaded-operators.cpp
  clang/test/Index/annotate-operator-call-expr.cpp
  clang/test/Index/cursor-ref-names.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -4675,6 +4675,9 @@
   EXPECT_TRUE(notMatches(
 "namespace a { void f(); } using a::f; void g() { a::f(); }",
 declRefExpr(throughUsingDecl(anything();
+  EXPECT_TRUE(matches("struct S {}; namespace a { int operator+(S s1, S s2); } "
+  "using a::operator+; int g() { return S() + S(); }",
+  declRefExpr(throughUsingDecl(anything();
 }
 
 TEST(SingleDecl, IsSingleDecl) {
Index: clang/test/Index/cursor-ref-names.cpp
===
--- clang/test/Index/cursor-ref-names.cpp
+++ clang/test/Index/cursor-ref-names.cpp
@@ -33,9 +33,9 @@
 // CHECK: cursor-ref-names.cpp:18:5: CallExpr=func:8:10 Extent=[18:5 - 18:16]
 // CHECK: cursor-ref-names.cpp:18:10: MemberRefExpr=func:8:10 SingleRefName=[18:10 - 18:14] RefName=[18:10 - 18:14] Extent=[18:5 - 18:14]
 // CHECK: cursor-ref-names.cpp:18:5: DeclRefExpr=inst:17:9 Extent=[18:5 - 18:9]
-// CHECK: cursor-ref-names.cpp:19:5: CallExpr=operator[]:4:9 SingleRefName=[19:9 - 19:12] RefName=[19:9 - 19:10] RefName=[19:11 - 19:12] Extent=[19:5 - 19:12]
+// CHECK: cursor-ref-names.cpp:19:5: CallExpr=operator[]:4:9 Extent=[19:5 - 19:12] 
 // CHECK: cursor-ref-names.cpp:19:5: DeclRefExpr=inst:17:9 Extent=[19:5 - 19:9]
-// CHECK: cursor-ref-names.cpp:19:9: DeclRefExpr=operator[]:4:9 RefName=[19:9 - 19:10] RefName=[19:11 - 19:12] Extent=[19:9 - 19:12]
+// CHECK: cursor-ref-names.cpp:19:9: DeclRefExpr=operator[]:4:9 Extent=[19:9 - 19:10]
 // CHECK: cursor-ref-names.cpp:20:5: CallExpr=operator[]:4:9 Extent=[20:5 - 20:23]
 // CHECK: cursor-ref-names.cpp:20:10: MemberRefExpr=operator[]:4:9 SingleRefName=[20:10 - 20:20] RefName=[20:10 - 20:18] RefName=[20:18 - 20:19] RefName=[20:19 - 20:20] Extent=[20:5 - 20:20]
 // CHECK: cursor-ref-names.cpp:20:5: DeclRefExpr=inst:17:9 Extent=[20:5 - 20:9]
Index: clang/test/Index/annotate-operator-call-expr.cpp
===
--- clang/test/Index/annotate-operator-call-expr.cpp
+++ clang/test/Index/annotate-operator-call-expr.cpp
@@ -17,68 +17,68 @@
 
 // RUN: c-index-test -test-annotate-tokens=%s:7:1:7:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK1
 // CHECK1: Identifier: "foo" [7:3 - 7:6] DeclRefExpr=foo:6:18
-// CHECK1: Punctuation: "(" [7:6 - 7:7] DeclRefExpr=operator():3:7 RefName=[7:6 - 7:7] RefName=[7:7 - 7:8]
-// CHECK1: Punctuation: ")" [7:7 - 7:8] DeclRefExpr=operator():3:7 RefName=[7:6 - 7:7] RefName=[7:7 - 7:8]
+// CHECK1: Punctuation: "(" [7:6 - 7:7] CallExpr=operator():3:7
+// CHECK1: Punctuation: ")" [7:7 - 7:8] CallExpr=operator():3:7
 // CHECK1: Punctuation: ";" [7:8 - 7:9] CompoundStmt=
 
 // RUN: c-index-test -test-annotate-tokens=%s:8:1:8:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK2
-// CHECK2: Punctuation: "(" [8:6 - 8:7] DeclRefExpr=operator():3:7 RefName=[8:6 - 8:7] RefName=[8:12 - 8:13]
+// CHECK2: Punctuation: "(" [8:6 - 8:7] CallExpr=operator():3:7
 // CHECK2: Identifier: "index" [8:7 - 8:12] DeclRefExpr=index:6:27
-// CHECK2: Punctuation: ")" [8:12 - 8:13] DeclRefExpr=operator():3:7 RefName=[8:6 - 8:7] RefName=[8:12 - 8:13]
+// CHECK2: Punctuation: ")" [8:12 - 8:13] CallExpr=operator():3:7
 // CHECK2: Punctuation: ";" [8:13 - 8:14] CompoundStmt=
 
 // RUN: c-index-test -test-annotate-tokens=%s:10:1:10:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK3
 // CHECK3: Identifier: "foo" [10:3 - 10:6] DeclRefExpr=foo:6:18
-// CHECK3: Punctuation: "[" [10:6 - 10:7] DeclRefExpr=operator[]:2:7 RefName=[10:6 - 10:7] RefName=[10:12 - 10:13]
+// CHECK3: Punctuation: "[" [10:6 - 10:7] CallExpr=operator[]:2:7
 // CHECK3: Identifier: "index" [10:7 - 10:12] DeclRefExpr=index:6:27
-// CHECK3: Punctuation: "]" [10:12 - 10:13] DeclRefExpr=operator[]:2:7 RefName=[10:6 - 10:7] RefName=[10:12 - 10:13]
+// CHECK3: Punctuation: "]" [10:12 - 10:13] CallExpr=operator[]:2:7
 // CHECK3: Punctuation: ";" [10:13 - 10:14] CompoundStmt=
 
 // RUN: c-index-test -test-annotate-tokens=%s:11:1:11:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK4
 // CHECK4: Identifier: "foo" [11:3 - 11:6] DeclRefExpr=foo:6:18
-// CH

[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-07-22 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/test/Index/annotate-operator-call-expr.cpp:21
+// CHECK1: Punctuation: "(" [7:6 - 7:7] CallExpr=operator():3:7
+// CHECK1: Punctuation: ")" [7:7 - 7:8] CallExpr=operator():3:7
 // CHECK1: Punctuation: ";" [7:8 - 7:9] CompoundStmt=

SimplyDanny wrote:
> I updated the test expectation without actually knowing whether the test 
> references are correct(er) now. There seems to be some loss of information 
> and some `CallExpr`s are now seen as `DeclRefExpr`s. Please tell me if these 
> changes are okay. I rather made them to have a basis for discussions.
`DeclRerExpr`  to `CallExpr` looks right.



Comment at: clang/test/Index/cursor-ref-names.cpp:36
 // CHECK: cursor-ref-names.cpp:18:5: DeclRefExpr=inst:17:9 Extent=[18:5 - 18:9]
-// CHECK: cursor-ref-names.cpp:19:5: CallExpr=operator[]:4:9 
SingleRefName=[19:9 - 19:12] RefName=[19:9 - 19:10] RefName=[19:11 - 19:12] 
Extent=[19:5 - 19:12]
+// CHECK: cursor-ref-names.cpp:19:5: CallExpr=operator[]:4:9 Extent=[19:5 - 
19:12] 
 // CHECK: cursor-ref-names.cpp:19:5: DeclRefExpr=inst:17:9 Extent=[19:5 - 19:9]

It looks like we lost some information here but I am not sure if that is 
expected or not. 

AFAIK CIndex is supported on a best effort basis, I think this is ok.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129973/new/

https://reviews.llvm.org/D129973

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-07-22 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny added a comment.

Thank you for the review! Before I push the change into main I may add an entry 
to `clang/docs/ReleaseNotes.rst`, right?

And do you agree that the test failures are unrelated to my change? It looks 
like they are all located in `libomptarget` caused by a linker error.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129973/new/

https://reviews.llvm.org/D129973

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-07-25 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny added a comment.

In D129973#3673094 , @SimplyDanny 
wrote:

> Thank you for the review! Before I push the change into main I may add an 
> entry to `clang/docs/ReleaseNotes.rst`, right?
>
> And do you agree that the test failures are unrelated to my change? It looks 
> like they are all located in `libomptarget` caused by a linker error.

@shafik: Could you give one last feedback on this?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129973/new/

https://reviews.llvm.org/D129973

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-07-25 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

In D129973#3673094 , @SimplyDanny 
wrote:

> Thank you for the review! Before I push the change into main I may add an 
> entry to `clang/docs/ReleaseNotes.rst`, right?

Yes, please add an entry in the release notes.

> And do you agree that the test failures are unrelated to my change? It looks 
> like they are all located in `libomptarget` caused by a linker error.

They don't look related but as always you should be ready to revert if any of 
the builds break in a way that you can't fix quickly.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129973/new/

https://reviews.llvm.org/D129973

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-07-26 Thread Danny Mösch via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4e94f6653150: [clang] Pass FoundDecl to DeclRefExpr creator 
for operator overloads (authored by SimplyDanny).

Changed prior to commit:
  https://reviews.llvm.org/D129973?vs=446718&id=447796#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129973/new/

https://reviews.llvm.org/D129973

Files:
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.cpp
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaOverload.cpp
  clang/test/AST/ast-dump-overloaded-operators.cpp
  clang/test/Index/annotate-operator-call-expr.cpp
  clang/test/Index/cursor-ref-names.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -4675,6 +4675,9 @@
   EXPECT_TRUE(notMatches(
 "namespace a { void f(); } using a::f; void g() { a::f(); }",
 declRefExpr(throughUsingDecl(anything();
+  EXPECT_TRUE(matches("struct S {}; namespace a { int operator+(S s1, S s2); } "
+  "using a::operator+; int g() { return S() + S(); }",
+  declRefExpr(throughUsingDecl(anything();
 }
 
 TEST(SingleDecl, IsSingleDecl) {
Index: clang/test/Index/cursor-ref-names.cpp
===
--- clang/test/Index/cursor-ref-names.cpp
+++ clang/test/Index/cursor-ref-names.cpp
@@ -33,9 +33,9 @@
 // CHECK: cursor-ref-names.cpp:18:5: CallExpr=func:8:10 Extent=[18:5 - 18:16]
 // CHECK: cursor-ref-names.cpp:18:10: MemberRefExpr=func:8:10 SingleRefName=[18:10 - 18:14] RefName=[18:10 - 18:14] Extent=[18:5 - 18:14]
 // CHECK: cursor-ref-names.cpp:18:5: DeclRefExpr=inst:17:9 Extent=[18:5 - 18:9]
-// CHECK: cursor-ref-names.cpp:19:5: CallExpr=operator[]:4:9 SingleRefName=[19:9 - 19:12] RefName=[19:9 - 19:10] RefName=[19:11 - 19:12] Extent=[19:5 - 19:12]
+// CHECK: cursor-ref-names.cpp:19:5: CallExpr=operator[]:4:9 Extent=[19:5 - 19:12] 
 // CHECK: cursor-ref-names.cpp:19:5: DeclRefExpr=inst:17:9 Extent=[19:5 - 19:9]
-// CHECK: cursor-ref-names.cpp:19:9: DeclRefExpr=operator[]:4:9 RefName=[19:9 - 19:10] RefName=[19:11 - 19:12] Extent=[19:9 - 19:12]
+// CHECK: cursor-ref-names.cpp:19:9: DeclRefExpr=operator[]:4:9 Extent=[19:9 - 19:10]
 // CHECK: cursor-ref-names.cpp:20:5: CallExpr=operator[]:4:9 Extent=[20:5 - 20:23]
 // CHECK: cursor-ref-names.cpp:20:10: MemberRefExpr=operator[]:4:9 SingleRefName=[20:10 - 20:20] RefName=[20:10 - 20:18] RefName=[20:18 - 20:19] RefName=[20:19 - 20:20] Extent=[20:5 - 20:20]
 // CHECK: cursor-ref-names.cpp:20:5: DeclRefExpr=inst:17:9 Extent=[20:5 - 20:9]
Index: clang/test/Index/annotate-operator-call-expr.cpp
===
--- clang/test/Index/annotate-operator-call-expr.cpp
+++ clang/test/Index/annotate-operator-call-expr.cpp
@@ -17,68 +17,68 @@
 
 // RUN: c-index-test -test-annotate-tokens=%s:7:1:7:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK1
 // CHECK1: Identifier: "foo" [7:3 - 7:6] DeclRefExpr=foo:6:18
-// CHECK1: Punctuation: "(" [7:6 - 7:7] DeclRefExpr=operator():3:7 RefName=[7:6 - 7:7] RefName=[7:7 - 7:8]
-// CHECK1: Punctuation: ")" [7:7 - 7:8] DeclRefExpr=operator():3:7 RefName=[7:6 - 7:7] RefName=[7:7 - 7:8]
+// CHECK1: Punctuation: "(" [7:6 - 7:7] CallExpr=operator():3:7
+// CHECK1: Punctuation: ")" [7:7 - 7:8] CallExpr=operator():3:7
 // CHECK1: Punctuation: ";" [7:8 - 7:9] CompoundStmt=
 
 // RUN: c-index-test -test-annotate-tokens=%s:8:1:8:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK2
-// CHECK2: Punctuation: "(" [8:6 - 8:7] DeclRefExpr=operator():3:7 RefName=[8:6 - 8:7] RefName=[8:12 - 8:13]
+// CHECK2: Punctuation: "(" [8:6 - 8:7] CallExpr=operator():3:7
 // CHECK2: Identifier: "index" [8:7 - 8:12] DeclRefExpr=index:6:27
-// CHECK2: Punctuation: ")" [8:12 - 8:13] DeclRefExpr=operator():3:7 RefName=[8:6 - 8:7] RefName=[8:12 - 8:13]
+// CHECK2: Punctuation: ")" [8:12 - 8:13] CallExpr=operator():3:7
 // CHECK2: Punctuation: ";" [8:13 - 8:14] CompoundStmt=
 
 // RUN: c-index-test -test-annotate-tokens=%s:10:1:10:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK3
 // CHECK3: Identifier: "foo" [10:3 - 10:6] DeclRefExpr=foo:6:18
-// CHECK3: Punctuation: "[" [10:6 - 10:7] DeclRefExpr=operator[]:2:7 RefName=[10:6 - 10:7] RefName=[10:12 - 10:13]
+// CHECK3: Punctuation: "[" [10:6 - 10:7] CallExpr=operator[]:2:7
 // CHECK3: Identifier: "index" [10:7 - 10:12] DeclRefExpr=index:6:27
-// CHECK3: Punctuation: "]" [10:12 - 10:13] DeclRefExpr=operator[]:2:7 RefName=[10:6 - 10:7] RefName=[10:12 - 10:13]
+// CHECK3

[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-07-28 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

With this change we don't pass "LocInfo" directly and it seems to break the 
locations when calling "getCXXOperatorNameRange" for this DeclRefExpr later on. 
Please fix it. You can introduce another "Create" static method for DeclRefExpr 
that accepts LocInfo and passes it to the DeclarationNameInfo constructor.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129973/new/

https://reviews.llvm.org/D129973

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-07-29 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny added a comment.

In D129973#3684940 , @yvvan wrote:

> With this change we don't pass "LocInfo" directly and it seems to break the 
> locations when calling "getCXXOperatorNameRange" for this DeclRefExpr later 
> on. Please fix it. You can introduce another "Create" static method for 
> DeclRefExpr that accepts LocInfo and passes it to the DeclarationNameInfo 
> constructor.

Thank you for the hint! This indeed "fixes" the test references so that they 
can be reverted to their original state. This is done in D130799 
.

Instead of a new `create` method or a new constructor (there are already quite 
a lot of them with complex signatures), I created a `DeclarationNameInfo` and 
passed it to one of the existing creators.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129973/new/

https://reviews.llvm.org/D129973

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-07-29 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

In D129973#3688329 , @SimplyDanny 
wrote:

> In D129973#3684940 , @yvvan wrote:
>
>> With this change we don't pass "LocInfo" directly and it seems to break the 
>> locations when calling "getCXXOperatorNameRange" for this DeclRefExpr later 
>> on. Please fix it. You can introduce another "Create" static method for 
>> DeclRefExpr that accepts LocInfo and passes it to the DeclarationNameInfo 
>> constructor.
>
> Thank you for the hint! This indeed "fixes" the test references so that they 
> can be reverted to their original state. This is done in D130799 
> .
>
> Instead of a new `create` method or a new constructor (there are already 
> quite a lot of them with complex signatures), I created a 
> `DeclarationNameInfo` and passed it to one of the existing creators.

Thank you!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129973/new/

https://reviews.llvm.org/D129973

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-08-03 Thread joanahalili via Phabricator via cfe-commits
joanahalili added a comment.

Heads up: This commit causes clang crashes on our end. We are currently working 
on a reproducer and will post it as soon as its ready.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129973/new/

https://reviews.llvm.org/D129973

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-08-03 Thread joanahalili via Phabricator via cfe-commits
joanahalili added a comment.

In D129973#3696189 , @joanahalili 
wrote:

> Heads up: This commit causes clang crashes on our end. We are currently 
> working on a reproducer and will post it as soon as its ready.

Here is the reduced code:

  template  struct b {
template  void ab(c);
template  void ad(c p1) { ab(d()(p1)); }
a d();
  };
  template  struct f {
using aa = e;
template  struct j {
  g ag;
  template  auto operator()(h... p1) -> decltype(ag(p1...));
};
using ai = b>;
template  void ad(c p1) { i.ad(p1); }
ai i;
  };
  template  struct l {
int k(const c &);
struct n {
  int operator()(const c &) const;
};
using m = f;
m aj;
  };
  template  int l::k(const c &p1) { aj.ad(p1); }
  template 
  int l::n::operator()(const c &) const {}
  template class l;

This commit causes a compiler crash for this code. It however successfully 
builds with the previous commit compiler. 
Here is also a link comparing released clang with clang trunk where trunk is 
crashing and the released version is not: https://godbolt.org/z/fdbo74c54


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129973/new/

https://reviews.llvm.org/D129973

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-08-04 Thread Asmaa via Phabricator via cfe-commits
asmok-g added a comment.

This is also causing a compilation error in some google third-party code. 
Compiling with older clang doesn't give that error. Error:

  error: no matching function for call to object of type 
'key_compare_adapter::IntervalLess>::checked_compare'
  comp(__trans_tmp_3, k);
  ^~~~
  /tmp/pre.ii:85:5: note: in instantiation of function template specialization 
'btree_node::IntervalLess>>::linear_search_impl::IntervalLess>::checked_compare>' 
requested here
  linear_search_impl(k, 0, 0, comp,
  ^
  /tmp/pre.ii:76:32: note: in instantiation of function template specialization 
'btree_node::IntervalLess>>::linear_search::IntervalLess>::checked_compare>' 
requested here
  use_linear_search::value ? linear_search(k, comp) : binary_search(k, 
comp);
 ^
  /tmp/pre.ii:123:15: note: in instantiation of function template 
specialization 
'btree_node::IntervalLess>>::lower_bound' 
requested here
iter.node_->lower_bound(key, key_comp());
^
  /tmp/pre.ii:111:51: note: in instantiation of function template 
specialization 
'btree::IntervalLess>>::internal_lower_bound'
 requested here
template  void lower_bound(K key) { internal_lower_bound(key); }
^
  /tmp/pre.ii:133:37: note: in instantiation of function template 
specialization 
'btree::IntervalLess>>::lower_bound' 
requested here
void lower_bound(int key) { tree_.lower_bound(key); }
  ^
  /tmp/pre.ii:164:14: note: in instantiation of member function 
'btree_container::IntervalLess>>>::lower_bound'
 requested here
intervals_.lower_bound(0);
   ^
  /tmp/pre.ii:158:16: note: in instantiation of member function 
'QuicIntervalSet::Add' requested here
void Add() { Add(value_type(Add_min, Add_max)); }
 ^
  /tmp/pre.ii:190:34: note: in instantiation of member function 
'QuicIntervalSet::Add' requested here
unacked_frame_headers_offsets_.Add();
   ^
  /tmp/pre.ii:44:10: note: candidate template ignored: substitution failure 
[with T = QuicInterval, U = int]
  void operator()(T lhs, U rhs) {

I attached the preprocessed file for the case F24012260: pre.ii 
.

The commande to reproduce is: `clang -msse4.2 -O1 -fsized-deallocation 
-std=gnu++17 -c pre.ii`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129973/new/

https://reviews.llvm.org/D129973

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-08-04 Thread Bogdan Graur via Phabricator via cfe-commits
bgraur added a comment.

@SimplyDanny given the reports from @joanahalili and @asmok-g are you 
considering a revert for this patch?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129973/new/

https://reviews.llvm.org/D129973

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-08-04 Thread Bogdan Graur via Phabricator via cfe-commits
bgraur added a subscriber: tstellar.
bgraur added a comment.

@tstellar FYI the clang crash report from @joanahalili and the new compilation 
errors report from @asmok-g, both introduced by this patch.
Is a revert warranted here?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129973/new/

https://reviews.llvm.org/D129973

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-08-04 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

Reverting for @bgraur as he's having some issues with his commit access ATM. To 
sum up the reproducer attached by @joanahalili triggers a crash 
https://reviews.llvm.org/rG4e94f6653150511de434fa7e29b684ae7f0e52b6 with stack 
trace and error:

  $ ~/repos/llvm/build/bin/clang -xc++ -c a.cc
  a.cc:3:38: error: cannot compile this l-value expression yet
template  void ad(c p1) { ab(d()(p1)); }
   ^~
  Unexpected placeholder builtin type!
  UNREACHABLE executed at 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/CodeGen/CodeGenTypes.cpp:641!
  PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ 
and include the crash backtrace, preprocessed source, and associated run script.
  Stack dump:
  0.  Program arguments: 
/usr/local/google/home/kadircet/repos/llvm/build/bin/clang -xc++ -c a.cc
  1.   parser at end of file
  2.  Per-file LLVM IR generation
  3.  a.cc:3:27: Generating code for declaration 'b::n>::j::n>>::ad'
   #0 0x064fb563 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
/usr/local/google/home/kadircet/repos/llvm/llvm/lib/Support/Unix/Signals.inc:569:13
   #1 0x064f92fe llvm::sys::RunSignalHandlers() 
/usr/local/google/home/kadircet/repos/llvm/llvm/lib/Support/Signals.cpp:104:18
   #2 0x0645f823 (anonymous 
namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) 
/usr/local/google/home/kadircet/repos/llvm/llvm/lib/Support/CrashRecoveryContext.cpp:76:5
   #3 0x0645f9de CrashRecoverySignalHandler(int) 
/usr/local/google/home/kadircet/repos/llvm/llvm/lib/Support/CrashRecoveryContext.cpp:390:1
   #4 0x7f8c235bf200 __restore_rt 
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12200)
   #5 0x7f8c2302c8a1 raise ./signal/../sysdeps/unix/sysv/linux/raise.c:50:1
   #6 0x7f8c23016546 abort ./stdlib/abort.c:81:7
   #7 0x06465531 
(/usr/local/google/home/kadircet/repos/llvm/build/bin/clang+0x6465531)
   #8 0x0689b09f 
(/usr/local/google/home/kadircet/repos/llvm/build/bin/clang+0x689b09f)
   #9 0x068be0f1 
clang::CodeGen::CodeGenFunction::EmitUnsupportedLValue(clang::Expr const*, char 
const*) 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/CodeGen/CGExpr.cpp:1250:22
  #10 0x068b4703 
clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*) 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/CodeGen/CGExpr.cpp:0:19
  #11 0x068d3fab isSimple 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/CodeGen/CGValue.h:265:41
  #12 0x068d3fab getPointer 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/CodeGen/CGValue.h:338:5
  #13 0x068d3fab 
clang::CodeGen::CodeGenFunction::EmitCallee(clang::Expr const*) 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/CodeGen/CGExpr.cpp:5131:31
  #14 0x068d3c72 isBuiltin 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/CodeGen/CGCall.h:151:12
  #15 0x068d3c72 
clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*, 
clang::CodeGen::ReturnValueSlot) 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/CodeGen/CGExpr.cpp:5014:14
  #16 0x069e0518 getInt 
/usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/ADT/PointerIntPair.h:62:57
  #17 0x069e0518 isScalar 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/CodeGen/CGValue.h:54:37
  #18 0x069e0518 getScalarVal 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/CodeGen/CGValue.h:62:5
  #19 0x069e0518 (anonymous 
namespace)::ScalarExprEmitter::VisitCallExpr(clang::CallExpr const*) 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/CodeGen/CGExprScalar.cpp:578:36
  #20 0x069e1338 Visit 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/CodeGen/CGExprScalar.cpp:408:52
  #21 0x069e1338 (anonymous 
namespace)::ScalarExprEmitter::VisitExprWithCleanups(clang::ExprWithCleanups*) 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/CodeGen/CGExprScalar.cpp:2447:14
  #22 0x069d1128 Visit 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/CodeGen/CGExprScalar.cpp:408:52
  #23 0x069d1128 
clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/CodeGen/CGExprScalar.cpp:4874:8
  #24 0x068b3a47 PointerIntPair 
/usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/ADT/PointerIntPair.h:49:12
  #25 0x068b3a47 RValue 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/CodeGen/CGValue.h:39:7
  #26 0x068b3a47 get 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/CodeGen/CGValue.h:90:12
  #27 0x068b3a47 
clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, 
clang::CodeGen::AggValueSlot, bool) 
/usr/local/google/home/kadircet/repos/llvm/clang/lib/CodeGen/CGExpr.cpp:217:12
  #28 0x068b39d1 
clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) 
/usr/

[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-08-04 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

Reverted in df48e3fbcc8be1f4c04bd97517d12e662f54de75 
, 
@tstellar it needs to be cherry-picked into release branch as well.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129973/new/

https://reviews.llvm.org/D129973

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-08-04 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

In D129973#3699055 , @kadircet wrote:

> Reverted in df48e3fbcc8be1f4c04bd97517d12e662f54de75 
> , 
> @tstellar it needs to be cherry-picked into release branch as well.

Thanks for letting me know, I will make sure this gets backported: 
https://github.com/llvm/llvm-project/issues/56928


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129973/new/

https://reviews.llvm.org/D129973

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-08-09 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

FWIW this also causes a `static_assert` failure while building ROOT 
:

  In file included from 
/home/jhahnfel/ROOT/src/tmva/tmva/src/DNN/Architectures/Cpu/CpuBuffer.cxx:17:
  In file included from 
/opt/rh/gcc-toolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/memory:77:
  In file included from 
/opt/rh/gcc-toolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/bits/shared_ptr.h:53:
  
/opt/rh/gcc-toolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/bits/shared_ptr_base.h:1110:4:
 error: static assertion failed due to requirement 
'__is_invocable::TDestructor &, double 
**&>::value': deleter expression d(p) is well-formed
static_assert(__is_invocable<_Deleter&, _Yp*&>::value,
^ ~~~
  
/opt/rh/gcc-toolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/bits/shared_ptr.h:178:11:
 note: in instantiation of function template specialization 
'std::__shared_ptr::__shared_ptr::TDestructor, void>' requested here
  : __shared_ptr<_Tp>(__p, std::move(__d)) { }
^
  
/home/jhahnfel/ROOT/src/tmva/tmva/src/DNN/Architectures/Cpu/CpuBuffer.cxx:42:14:
 note: in instantiation of function template specialization 
'std::shared_ptr::shared_ptr::TDestructor, void>' requested here
 fBuffer = std::shared_ptr(pointer, fDestructor);
   ^

After the revert, at least this issue is gone when building with current `main`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129973/new/

https://reviews.llvm.org/D129973

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-08-09 Thread vient via Phabricator via cfe-commits
vient added a comment.

FWIW this also causes compilation error on correct code using Boost: 
https://github.com/llvm/llvm-project/issues/56878


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129973/new/

https://reviews.llvm.org/D129973

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-08-09 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

The revert doesn't apply cleanly, can someone try to fix it up: 
https://github.com/llvm/llvm-project/issues/56928#issuecomment-1205483442


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129973/new/

https://reviews.llvm.org/D129973

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits