[PATCH] D129420: [clang-tidy] Initialize boolean variables with 'false' in cppcoreguidelines-init-variables' fix-it

2022-07-09 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny created this revision.
SimplyDanny added a reviewer: aaron.ballman.
Herald added subscribers: carlosgalvezp, shchenz, kbarton, xazax.hun, nemanjai.
Herald added a project: All.
SimplyDanny requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

In case of a variable with a built-in boolean type, `false` is a better fit to 
default-initialize it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129420

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp
@@ -64,7 +64,7 @@
 
   bool b;
   // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: variable 'b' is not initialized 
[cppcoreguidelines-init-variables]
-  // CHECK-FIXES: {{^}}  bool b = 0;{{$}}
+  // CHECK-FIXES: {{^}}  bool b = false;{{$}}
   bool bval = true;
 
   const char *ptr;
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
@@ -84,6 +84,8 @@
 
   if (TypePtr->isEnumeralType())
 InitializationString = nullptr;
+  else if (TypePtr->isBooleanType())
+InitializationString = " = false";
   else if (TypePtr->isIntegerType())
 InitializationString = " = 0";
   else if (TypePtr->isFloatingType()) {


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp
@@ -64,7 +64,7 @@
 
   bool b;
   // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: variable 'b' is not initialized [cppcoreguidelines-init-variables]
-  // CHECK-FIXES: {{^}}  bool b = 0;{{$}}
+  // CHECK-FIXES: {{^}}  bool b = false;{{$}}
   bool bval = true;
 
   const char *ptr;
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
@@ -84,6 +84,8 @@
 
   if (TypePtr->isEnumeralType())
 InitializationString = nullptr;
+  else if (TypePtr->isBooleanType())
+InitializationString = " = false";
   else if (TypePtr->isIntegerType())
 InitializationString = " = 0";
   else if (TypePtr->isFloatingType()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129420: [clang-tidy] Initialize boolean variables with 'false' in cppcoreguidelines-init-variables' fix-it

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

This is a potential fix for this issue 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129420

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


[PATCH] D129420: [clang-tidy] Initialize boolean variables with 'false' in cppcoreguidelines-init-variables' fix-it

2022-07-09 Thread Danny Mösch via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG33e212954430: [clang-tidy] Initialize boolean variables with 
`false` in cppcoreguidelines… (authored by SimplyDanny).

Changed prior to commit:
  https://reviews.llvm.org/D129420?vs=443429&id=443434#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129420

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp
@@ -64,7 +64,7 @@
 
   bool b;
   // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: variable 'b' is not initialized 
[cppcoreguidelines-init-variables]
-  // CHECK-FIXES: {{^}}  bool b = 0;{{$}}
+  // CHECK-FIXES: {{^}}  bool b = false;{{$}}
   bool bval = true;
 
   const char *ptr;
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -247,6 +247,10 @@
   ` to simplify 
expressions
   using DeMorgan's Theorem.
 
+- Made the fix-it of :doc:`cppcoreguidelines-init-variables
+  ` use ``false`` to 
initialize
+  boolean variables.
+
 Removed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
@@ -84,6 +84,8 @@
 
   if (TypePtr->isEnumeralType())
 InitializationString = nullptr;
+  else if (TypePtr->isBooleanType())
+InitializationString = " = false";
   else if (TypePtr->isIntegerType())
 InitializationString = " = 0";
   else if (TypePtr->isFloatingType()) {


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp
@@ -64,7 +64,7 @@
 
   bool b;
   // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: variable 'b' is not initialized [cppcoreguidelines-init-variables]
-  // CHECK-FIXES: {{^}}  bool b = 0;{{$}}
+  // CHECK-FIXES: {{^}}  bool b = false;{{$}}
   bool bval = true;
 
   const char *ptr;
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -247,6 +247,10 @@
   ` to simplify expressions
   using DeMorgan's Theorem.
 
+- Made the fix-it of :doc:`cppcoreguidelines-init-variables
+  ` use ``false`` to initialize
+  boolean variables.
+
 Removed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
@@ -84,6 +84,8 @@
 
   if (TypePtr->isEnumeralType())
 InitializationString = nullptr;
+  else if (TypePtr->isBooleanType())
+InitializationString = " = false";
   else if (TypePtr->isIntegerType())
 InitializationString = " = 0";
   else if (TypePtr->isFloatingType()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129420: [clang-tidy] Initialize boolean variables with 'false' in cppcoreguidelines-init-variables' fix-it

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

In D129420#3640482 , @njames93 wrote:

> Can you add a line to release notes about this fix then LGTM

Sure. Thank you for the fast review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129420

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


[PATCH] D129420: [clang-tidy] Initialize boolean variables with 'false' in cppcoreguidelines-init-variables' fix-it

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



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:250-253
+- Made the fix-it of :doc:`cppcoreguidelines-init-variables
+  ` use ``false`` to 
initialize
+  boolean variables.
+

njames93 wrote:
> Sorry I should've mentioned, we keep this list in alphabetical order(for the 
> names of the checks).
> Can you push a patch to move this into its correct place(no need for a review 
> and commit as NFC)
Ah sorry. I could have noticed that. Fixed in [[ 
https://github.com/llvm/llvm-project/commit/963192228b05e3bce86cf520e2bda5f069be9894
 | this commit ]].


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129420

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


[PATCH] D122544: Utilize comparison operation implemented in APInt

2022-03-27 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny created this revision.
SimplyDanny added a reviewer: njames93.
Herald added a subscriber: carlosgalvezp.
Herald added a project: All.
SimplyDanny requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

This is a fix for #53963.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122544

Files:
  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
@@ -172,7 +172,10 @@
 template 
 int Bar() { T A[5]; return sizeof(A[0]) / sizeof(T); }
 // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: suspicious usage of sizeof 
pointer 'sizeof(T)/sizeof(T)'
-int Test3() { return Foo<42>() + Bar(); }
+template <__int128_t N> 
+bool Baz() { return sizeof(A) < N; }
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: suspicious comparison of 
'sizeof(expr)' to a constant
+int Test3() { return Foo<42>() + Bar() + Baz<-1>(); }
 
 static const char* kABC = "abc";
 static const wchar_t* kDEF = L"def";
Index: clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
@@ -20,7 +20,7 @@
 namespace {
 
 AST_MATCHER_P(IntegerLiteral, isBiggerThan, unsigned, N) {
-  return Node.getValue().getZExtValue() > N;
+  return Node.getValue().ugt(N);
 }
 
 AST_MATCHER_P2(Expr, hasSizeOfDescendant, int, Depth,


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
@@ -172,7 +172,10 @@
 template 
 int Bar() { T A[5]; return sizeof(A[0]) / sizeof(T); }
 // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: suspicious usage of sizeof pointer 'sizeof(T)/sizeof(T)'
-int Test3() { return Foo<42>() + Bar(); }
+template <__int128_t N> 
+bool Baz() { return sizeof(A) < N; }
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: suspicious comparison of 'sizeof(expr)' to a constant
+int Test3() { return Foo<42>() + Bar() + Baz<-1>(); }
 
 static const char* kABC = "abc";
 static const wchar_t* kDEF = L"def";
Index: clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
@@ -20,7 +20,7 @@
 namespace {
 
 AST_MATCHER_P(IntegerLiteral, isBiggerThan, unsigned, N) {
-  return Node.getValue().getZExtValue() > N;
+  return Node.getValue().ugt(N);
 }
 
 AST_MATCHER_P2(Expr, hasSizeOfDescendant, int, Depth,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D122544: Utilize comparison operation implemented in APInt

2022-03-28 Thread Danny Mösch via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGff60af91ac0b: [clang-tidy] Utilize comparison operation 
implemented in APInt (authored by SimplyDanny).

Changed prior to commit:
  https://reviews.llvm.org/D122544?vs=418450&id=418709#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122544

Files:
  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
@@ -172,7 +172,10 @@
 template 
 int Bar() { T A[5]; return sizeof(A[0]) / sizeof(T); }
 // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: suspicious usage of sizeof 
pointer 'sizeof(T)/sizeof(T)'
-int Test3() { return Foo<42>() + Bar(); }
+template <__int128_t N> 
+bool Baz() { return sizeof(A) < N; }
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: suspicious comparison of 
'sizeof(expr)' to a constant
+int Test3() { return Foo<42>() + Bar() + Baz<-1>(); }
 
 static const char* kABC = "abc";
 static const wchar_t* kDEF = L"def";
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -122,6 +122,9 @@
 - Fixed a false positive in :doc:`misc-redundant-expression 
`
   involving overloaded comparison operators.
 
+- Fixed a crash in :doc:`bugprone-sizeof-expression 
` when
+  `sizeof(...)` is compared agains a `__int128_t`.
+
 Removed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
@@ -20,7 +20,7 @@
 namespace {
 
 AST_MATCHER_P(IntegerLiteral, isBiggerThan, unsigned, N) {
-  return Node.getValue().getZExtValue() > N;
+  return Node.getValue().ugt(N);
 }
 
 AST_MATCHER_P2(Expr, hasSizeOfDescendant, int, Depth,


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
@@ -172,7 +172,10 @@
 template 
 int Bar() { T A[5]; return sizeof(A[0]) / sizeof(T); }
 // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: suspicious usage of sizeof pointer 'sizeof(T)/sizeof(T)'
-int Test3() { return Foo<42>() + Bar(); }
+template <__int128_t N> 
+bool Baz() { return sizeof(A) < N; }
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: suspicious comparison of 'sizeof(expr)' to a constant
+int Test3() { return Foo<42>() + Bar() + Baz<-1>(); }
 
 static const char* kABC = "abc";
 static const wchar_t* kDEF = L"def";
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -122,6 +122,9 @@
 - Fixed a false positive in :doc:`misc-redundant-expression `
   involving overloaded comparison operators.
 
+- Fixed a crash in :doc:`bugprone-sizeof-expression ` when
+  `sizeof(...)` is compared agains a `__int128_t`.
+
 Removed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
@@ -20,7 +20,7 @@
 namespace {
 
 AST_MATCHER_P(IntegerLiteral, isBiggerThan, unsigned, N) {
-  return Node.getValue().getZExtValue() > N;
+  return Node.getValue().ugt(N);
 }
 
 AST_MATCHER_P2(Expr, hasSizeOfDescendant, int, Depth,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D122544: Utilize comparison operation implemented in APInt

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

In D122544#3411226 , @aaron.ballman 
wrote:

> LGTM! Can you also add a release note for the fix?
>
> I'm happy to land this on your behalf if you'd prefer, but given that you've 
> had several quality commits already, you might want to consider asking for 
> your commit privileges: 
> https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access.

Thank you for the review and the recommendation to become a committer! I have 
just been granted the privileges and have landed the change on the main branch 
including a mention of the fix in the release notes. I hope this is all right.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122544

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


[PATCH] D122544: Utilize comparison operation implemented in APInt

2022-03-29 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp:175
 // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: suspicious usage of sizeof 
pointer 'sizeof(T)/sizeof(T)'
-int Test3() { return Foo<42>() + Bar(); }
+template <__int128_t N> 
+bool Baz() { return sizeof(A) < N; }

aaron.ballman wrote:
> aaronpuchert wrote:
> > This causes test failures on 32-bit architectures:
> > ```
> > /home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/tools/clang/tools/extra/test/clang-tidy/checkers/Output/bugprone-sizeof-expression.cpp.tmp.cpp:175:11:
> >  error: unknown type name '__int128_t' [clang-diagnostic-error]
> > template <__int128_t N> 
> >   ^
> > ```
> > 
> > It's probably best to wrap this in `#ifdef __SIZEOF_INT128__` lest we 
> > disable the entire test on the affected platforms.
> Good catch! @SimplyDanny, can you fix up the test?
Sure. I will fix it. Sorry for the issue ...

What is the process in this case? Push the fix directly to main or go the 
normal path via Phabricator review?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122544

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


[PATCH] D122544: Utilize comparison operation implemented in APInt

2022-03-29 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny marked 3 inline comments as done.
SimplyDanny added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp:175
 // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: suspicious usage of sizeof 
pointer 'sizeof(T)/sizeof(T)'
-int Test3() { return Foo<42>() + Bar(); }
+template <__int128_t N> 
+bool Baz() { return sizeof(A) < N; }

aaron.ballman wrote:
> SimplyDanny wrote:
> > aaron.ballman wrote:
> > > aaronpuchert wrote:
> > > > This causes test failures on 32-bit architectures:
> > > > ```
> > > > /home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/tools/clang/tools/extra/test/clang-tidy/checkers/Output/bugprone-sizeof-expression.cpp.tmp.cpp:175:11:
> > > >  error: unknown type name '__int128_t' [clang-diagnostic-error]
> > > > template <__int128_t N> 
> > > >   ^
> > > > ```
> > > > 
> > > > It's probably best to wrap this in `#ifdef __SIZEOF_INT128__` lest we 
> > > > disable the entire test on the affected platforms.
> > > Good catch! @SimplyDanny, can you fix up the test?
> > Sure. I will fix it. Sorry for the issue ...
> > 
> > What is the process in this case? Push the fix directly to main or go the 
> > normal path via Phabricator review?
> When fixing a broken test, you can generally push directly to main. (And if 
> the fix requires thought, it's usually best to revert the broken commit from 
> main until you have the test fixed, then push the fixed commit back to main).
Done. Fix is [[ https://reviews.llvm.org/rGf10cee91ae07 | here ]].


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122544

___
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] D129596: [clang-tidy] Avoid extra parentheses around MemberExpr

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

alexfh, aaron.ballman, njames93, LegalizeAdulthood

Could anyone give some feedback, please?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129596

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


[PATCH] D129596: [clang-tidy] Avoid extra parentheses around MemberExpr

2022-07-26 Thread Danny Mösch via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0734c02b34e4: [clang-tidy] Avoid extra parentheses around 
MemberExpr (authored by SimplyDanny).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129596

Files:
  clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
@@ -144,3 +144,14 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: 'data' should be used for 
accessing the data pointer instead of taking the address of the 0-th element 
[readability-container-data-pointer]
   // CHECK-FIXES: {{^  }}return (**v)->data();{{$}}
 }
+
+struct VectorHolder {
+  std::vector v;
+};
+
+int *r() {
+  VectorHolder holder;
+  return &holder.v[0];
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: 'data' should be used for 
accessing the data pointer instead of taking the address of the 0-th element 
[readability-container-data-pointer]
+  // CHECK-FIXES: {{^  }}return holder.v.data();{{$}}
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -255,6 +255,9 @@
   ` when a pure virtual 
function
   overrided has a const return type. Removed the fix for a virtual function.
 
+- Skipped addition of extra parentheses around member accesses (``a.b``) in 
fix-it for
+  :doc:`readability-container-data-pointer 
`.
+
 - Fixed incorrect suggestions for :doc:`readability-container-size-empty
   ` when smart pointers 
are involved.
 
Index: clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
@@ -98,7 +98,8 @@
   Lexer::getSourceText(CharSourceRange::getTokenRange(SrcRange),
*Result.SourceManager, getLangOpts())};
 
-  if (!isa(CE))
+  if (!isa(CE))
 ReplacementText = "(" + ReplacementText + ")";
 
   if (CE->getType()->isPointerType())


Index: clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
@@ -144,3 +144,14 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: 'data' should be used for accessing the data pointer instead of taking the address of the 0-th element [readability-container-data-pointer]
   // CHECK-FIXES: {{^  }}return (**v)->data();{{$}}
 }
+
+struct VectorHolder {
+  std::vector v;
+};
+
+int *r() {
+  VectorHolder holder;
+  return &holder.v[0];
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: 'data' should be used for accessing the data pointer instead of taking the address of the 0-th element [readability-container-data-pointer]
+  // CHECK-FIXES: {{^  }}return holder.v.data();{{$}}
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -255,6 +255,9 @@
   ` when a pure virtual function
   overrided has a const return type. Removed the fix for a virtual function.
 
+- Skipped addition of extra parentheses around member accesses (``a.b``) in fix-it for
+  :doc:`readability-container-data-pointer `.
+
 - Fixed incorrect suggestions for :doc:`readability-container-size-empty
   ` when smart pointers are involved.
 
Index: clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
@@ -98,7 +98,8 @@
   Lexer::getSourceText(CharSourceRange::getTokenRange(SrcRange),
*Result.SourceManager, getLangOpts())};
 
-  if (!isa(CE))
+  if (!isa(CE))
 ReplacementText = "(" + ReplacementText + ")";
 
   if (CE->getType()->isPointerType())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D130799: [clang] Keep declaration name info in DeclRefExpr

2022-07-29 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny created this revision.
SimplyDanny added a reviewer: yvvan.
Herald added a subscriber: arphaman.
Herald added a project: All.
SimplyDanny requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Without it `getCXXOperatorNameRange` returns a wrong range. This commit reverts 
the test references changed in e818ce0e060901be98eb1b043ca581c746171085 
 and 
4e94f6653150511de434fa7e29b684ae7f0e52b6 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130799

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/Index/annotate-operator-call-expr.cpp
  clang/test/Index/cursor-ref-names.cpp

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{{(\Q SingleRefName=[19:9 - 19:12] RefName=[19:9 - 19:10] RefName=[19:11 - 19:12]\E)?}} Extent=[19:5 - 19:12]
+// 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: DeclRefExpr=inst:17:9 Extent=[19:5 - 19:9]
-// CHECK: cursor-ref-names.cpp:19:9: DeclRefExpr=operator[]:4:9 Extent=[19:9 - 19:10]
+// 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: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] CallExpr=operator():3:7
-// CHECK1: Punctuation: ")" [7:7 - 7:8] CallExpr=operator():3:7
+// 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: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] CallExpr=operator():3:7
+// CHECK2: Punctuation: "(" [8:6 - 8:7] DeclRefExpr=operator():3:7 RefName=[8:6 - 8:7] RefName=[8:12 - 8:13]
 // CHECK2: Identifier: "index" [8:7 - 8:12] DeclRefExpr=index:6:27
-// CHECK2: Punctuation: ")" [8:12 - 8:13] CallExpr=operator():3:7
+// CHECK2: Punctuation: ")" [8:12 - 8:13] DeclRefExpr=operator():3:7 RefName=[8:6 - 8:7] RefName=[8:12 - 8:13]
 // 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] CallExpr=operator[]:2:7
+// CHECK3: Punctuation: "[" [10:6 - 10:7] DeclRefExpr=operator[]:2:7 RefName=[10:6 - 10:7] RefName=[10:12 - 10:13]
 // CHECK3: Identifier: "index" [10:7 - 10:12] DeclRefExpr=index:6:27
-// CHECK3: Punctuation: "]" [10:12 - 10:13] CallExpr=operator[]:2:7
+// CHECK3: Punctuation: "]" [10:12 - 10:13] DeclRefExpr=operator[]:2:7 RefName=[10:6 - 10:7] RefName=[10:12 - 10:13]
 // 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: Punctuation: "[" [11:6 - 11:7] CallExpr=operator[]:2:7
+// CHECK4: Punctuation: "[" [11:6 - 11:7] DeclRefExpr=operator[]:2:7 RefName=[11:6 - 11:7] RefName=[11:20 - 11:21]
 // CHECK4: Identifier: "index" [11:7 - 11:12] DeclRefExpr=index:6:27
 // CHECK4: Punctuation: "+" [11:13 - 11:14] BinaryOperator=
 // CHECK4: Identifier: "index" [11:15 -

[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] D121078: Replace links to archived mailing lists by links to Discourse forums

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

I'm happy that you found a reasonable compromise. I like it too. ;)

Now, I ask you to help me a little bit with the workflow and the test failures. 
The review comments are all taken care of as far as I see. One reviewer 
approved the changes, others are still in a "needs changes"  or an undecided 
state. Are approvals of all reviewers required? I guess, the test failures have 
nothing to do with my changes, or have they? Can we just ignore them if they 
are unrelated?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121078

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


[PATCH] D121078: Replace links to archived mailing lists by links to Discourse forums

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

In D121078#3373139 , @philnik wrote:

> In D121078#3373081 , @SimplyDanny 
> wrote:
>
>> I'm happy that you found a reasonable compromise. I like it too. ;)
>>
>> Now, I ask you to help me a little bit with the workflow and the test 
>> failures. The review comments are all taken care of as far as I see. One 
>> reviewer approved the changes, others are still in a "needs changes"  or an 
>> undecided state. Are approvals of all reviewers required? I guess, the test 
>> failures have nothing to do with my changes, or have they? Can we just 
>> ignore them if they are unrelated?
>
> Please wait for libunwind and libc++ approval. I won't approve, because I'm 
> not familiar with the documentation stuff.
> If the test failures are unrelated you can ignore them.

Okay, I'll wait a few more days and probably ping people again if there is no 
response until then,

In D121078#3373128 , @aaron.ballman 
wrote:

> Btw, do you have commit rights for the project? If not, what name and email 
> address would you like used for patch attribution?

I don't have commit rights. Please use "Danny Mösch" with the email address 
"danny.moe...@icloud.com". Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121078

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


[PATCH] D120187: [clang-tidy] Allow newline characters as separators for checks in Clang-Tidy configurations

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

In D120187#3375610 , @aaron.ballman 
wrote:

> LGTM, but please wait a day or two before landing in case @njames93 has 
> further concerns.

Would you merge the changes, @aaron.ballman? Seems like there are no objections 
from others. Please use the commit details mentioned here 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120187

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


[PATCH] D121078: Replace links to archived mailing lists by links to Discourse forums

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

@tonic, can you please have another look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121078

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


[PATCH] D129596: [clang-tidy] Avoid extra parentheses around MemberExpr

2022-07-12 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny created this revision.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a project: All.
SimplyDanny requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Fixes https://github.com/llvm/llvm-project/issues/55025.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129596

Files:
  clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
@@ -144,3 +144,14 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: 'data' should be used for 
accessing the data pointer instead of taking the address of the 0-th element 
[readability-container-data-pointer]
   // CHECK-FIXES: {{^  }}return (**v)->data();{{$}}
 }
+
+struct VectorHolder {
+  std::vector v;
+};
+
+int *r() {
+  VectorHolder holder;
+  return &holder.v[0];
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: 'data' should be used for 
accessing the data pointer instead of taking the address of the 0-th element 
[readability-container-data-pointer]
+  // CHECK-FIXES: {{^  }}return holder.v.data();{{$}}
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -240,6 +240,9 @@
   ` when a pure virtual 
function
   overrided has a const return type. Removed the fix for a virtual function.
 
+- Skipped addition of extra parentheses around member accesses (``a.b``) in 
fix-it for
+  :doc:`readability-container-data-pointer 
`.
+
 - Fixed incorrect suggestions for :doc:`readability-container-size-empty
   ` when smart pointers 
are involved.
 
Index: clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
@@ -98,7 +98,8 @@
   Lexer::getSourceText(CharSourceRange::getTokenRange(SrcRange),
*Result.SourceManager, getLangOpts())};
 
-  if (!isa(CE))
+  if (!isa(CE))
 ReplacementText = "(" + ReplacementText + ")";
 
   if (CE->getType()->isPointerType())


Index: clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
@@ -144,3 +144,14 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: 'data' should be used for accessing the data pointer instead of taking the address of the 0-th element [readability-container-data-pointer]
   // CHECK-FIXES: {{^  }}return (**v)->data();{{$}}
 }
+
+struct VectorHolder {
+  std::vector v;
+};
+
+int *r() {
+  VectorHolder holder;
+  return &holder.v[0];
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: 'data' should be used for accessing the data pointer instead of taking the address of the 0-th element [readability-container-data-pointer]
+  // CHECK-FIXES: {{^  }}return holder.v.data();{{$}}
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -240,6 +240,9 @@
   ` when a pure virtual function
   overrided has a const return type. Removed the fix for a virtual function.
 
+- Skipped addition of extra parentheses around member accesses (``a.b``) in fix-it for
+  :doc:`readability-container-data-pointer `.
+
 - Fixed incorrect suggestions for :doc:`readability-container-size-empty
   ` when smart pointers are involved.
 
Index: clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
@@ -98,7 +98,8 @@
   Lexer::getSourceText(CharSourceRange::getTokenRange(SrcRange),
*Result.SourceManager, getLangOpts())};
 
-  if (!isa(CE))
+  if (!isa(CE))
 ReplacementText = "(" + ReplacementText + ")";
 
   if (CE->getType()->isPointerType())
___
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-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-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 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] D120187: [clang-tidy] Allow newline characters as separators for checks in Clang-Tidy configurations

2022-02-19 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny created this revision.
SimplyDanny added a reviewer: alexfh.
Herald added subscribers: carlosgalvezp, xazax.hun.
SimplyDanny requested review of this revision.
Herald added subscribers: cfe-commits, aheejin.
Herald added a project: clang-tools-extra.

This is a fix for #53737. In addition to commas, newline characters are 
considered as separators of checks.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120187

Files:
  .clang-tidy
  clang-tools-extra/clang-tidy/GlobList.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
  clang-tools-extra/unittests/clang-tidy/GlobListTest.cpp


Index: clang-tools-extra/unittests/clang-tidy/GlobListTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/GlobListTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/GlobListTest.cpp
@@ -104,5 +104,18 @@
   EXPECT_TRUE(Filter.contains("asdfqwEasdf"));
 }
 
+TYPED_TEST(GlobListTest, NewlineCharactersAsSeparators) {
+  TypeParam Filter("a*  \n b,\n-c*,dd");
+
+  EXPECT_FALSE(Filter.contains(""));
+  EXPECT_TRUE(Filter.contains("aaa"));
+  EXPECT_TRUE(Filter.contains("b"));
+  EXPECT_FALSE(Filter.contains("c"));
+  EXPECT_FALSE(Filter.contains("ccc"));
+  EXPECT_FALSE(Filter.contains("d"));
+  EXPECT_TRUE(Filter.contains("dd"));
+  EXPECT_FALSE(Filter.contains("ddd"));
+}
+
 } // namespace tidy
 } // namespace clang
Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -86,6 +86,20 @@
   EXPECT_EQ("some.user", *Options->User);
 }
 
+TEST(ParseConfiguration, ChecksSeparatedByNewlines) {
+  auto MemoryBuffer = llvm::MemoryBufferRef("Checks: >\n"
+"  -*,misc-*\n"
+"  llvm-*\n"
+"  -clang-*,\n"
+"  google-*",
+"Options");
+
+  auto Options = parseConfiguration(MemoryBuffer);
+
+  EXPECT_TRUE(!!Options);
+  EXPECT_EQ("-*,misc-*\nllvm-*\n-clang-*,\ngoogle-*\n", *Options->Checks);
+}
+
 TEST(ParseConfiguration, MergeConfigurations) {
   llvm::ErrorOr Options1 =
   parseConfiguration(llvm::MemoryBufferRef(R"(
Index: clang-tools-extra/clang-tidy/GlobList.cpp
===
--- clang-tools-extra/clang-tidy/GlobList.cpp
+++ clang-tools-extra/clang-tidy/GlobList.cpp
@@ -27,7 +27,8 @@
 // Converts first glob from the comma-separated list of globs to Regex and
 // removes it and the trailing comma from the GlobList.
 static llvm::Regex consumeGlob(StringRef &GlobList) {
-  StringRef UntrimmedGlob = GlobList.substr(0, GlobList.find(','));
+  auto NextSplitIndex = std::min(GlobList.find(','), GlobList.find('\n'));
+  StringRef UntrimmedGlob = GlobList.substr(0, NextSplitIndex);
   StringRef Glob = UntrimmedGlob.trim();
   GlobList = GlobList.substr(UntrimmedGlob.size() + 1);
   SmallString<128> RegexText("^");
@@ -44,7 +45,7 @@
 }
 
 GlobList::GlobList(StringRef Globs, bool KeepNegativeGlobs /* =true */) {
-  Items.reserve(Globs.count(',') + 1);
+  Items.reserve(Globs.count(',') + Globs.count('\n') + 1);
   do {
 GlobListItem Item;
 Item.IsPositive = !consumeNegativeIndicator(Globs);
Index: .clang-tidy
===
--- .clang-tidy
+++ .clang-tidy
@@ -1,4 +1,13 @@
-Checks: 
'-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-misc-no-recursion,readability-identifier-naming'
+Checks: |
+  -*
+  clang-diagnostic-*
+  llvm-*
+  misc-*
+  -misc-unused-parameters
+  -misc-non-private-member-variables-in-classes
+  -misc-no-recursion
+  readability-identifier-naming
+
 CheckOptions:
   - key: readability-identifier-naming.ClassCase
 value:   CamelCase


Index: clang-tools-extra/unittests/clang-tidy/GlobListTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/GlobListTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/GlobListTest.cpp
@@ -104,5 +104,18 @@
   EXPECT_TRUE(Filter.contains("asdfqwEasdf"));
 }
 
+TYPED_TEST(GlobListTest, NewlineCharactersAsSeparators) {
+  TypeParam Filter("a*  \n b,\n-c*,dd");
+
+  EXPECT_FALSE(Filter.contains(""));
+  EXPECT_TRUE(Filter.contains("aaa"));
+  EXPECT_TRUE(Filter.contains("b"));
+  EXPECT_FALSE(Filter.contains("c"));
+  EXPECT_FALSE(Filter.contains("ccc"));
+  EXPECT_FALSE(Filter.contains("d"));
+  EXPECT_TRUE(Filter.contains("dd"));
+  EXPECT_FALSE(Filter.contains("ddd"));
+}
+
 } // namespace tidy
 } // namespace clang
Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
=

[PATCH] D120187: [clang-tidy] Allow newline characters as separators for checks in Clang-Tidy configurations

2022-02-19 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny updated this revision to Diff 410102.
SimplyDanny added a comment.

Update according to comments in review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120187

Files:
  clang-tools-extra/clang-tidy/GlobList.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
  clang-tools-extra/unittests/clang-tidy/GlobListTest.cpp


Index: clang-tools-extra/unittests/clang-tidy/GlobListTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/GlobListTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/GlobListTest.cpp
@@ -104,5 +104,18 @@
   EXPECT_TRUE(Filter.contains("asdfqwEasdf"));
 }
 
+TYPED_TEST(GlobListTest, NewlineCharactersAsSeparators) {
+  TypeParam Filter("a*  \n b,\n-c*,dd");
+
+  EXPECT_FALSE(Filter.contains(""));
+  EXPECT_TRUE(Filter.contains("aaa"));
+  EXPECT_TRUE(Filter.contains("b"));
+  EXPECT_FALSE(Filter.contains("c"));
+  EXPECT_FALSE(Filter.contains("ccc"));
+  EXPECT_FALSE(Filter.contains("d"));
+  EXPECT_TRUE(Filter.contains("dd"));
+  EXPECT_FALSE(Filter.contains("ddd"));
+}
+
 } // namespace tidy
 } // namespace clang
Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -86,6 +86,20 @@
   EXPECT_EQ("some.user", *Options->User);
 }
 
+TEST(ParseConfiguration, ChecksSeparatedByNewlines) {
+  auto MemoryBuffer = llvm::MemoryBufferRef("Checks: |\n"
+"  -*,misc-*\n"
+"  llvm-*\n"
+"  -clang-*,\n"
+"  google-*",
+"Options");
+
+  auto Options = parseConfiguration(MemoryBuffer);
+
+  EXPECT_TRUE(!!Options);
+  EXPECT_EQ("-*,misc-*\nllvm-*\n-clang-*,\ngoogle-*\n", *Options->Checks);
+}
+
 TEST(ParseConfiguration, MergeConfigurations) {
   llvm::ErrorOr Options1 =
   parseConfiguration(llvm::MemoryBufferRef(R"(
Index: clang-tools-extra/clang-tidy/GlobList.cpp
===
--- clang-tools-extra/clang-tidy/GlobList.cpp
+++ clang-tools-extra/clang-tidy/GlobList.cpp
@@ -27,7 +27,7 @@
 // Converts first glob from the comma-separated list of globs to Regex and
 // removes it and the trailing comma from the GlobList.
 static llvm::Regex consumeGlob(StringRef &GlobList) {
-  StringRef UntrimmedGlob = GlobList.substr(0, GlobList.find(','));
+  StringRef UntrimmedGlob = GlobList.substr(0, GlobList.find_first_of(",\n"));
   StringRef Glob = UntrimmedGlob.trim();
   GlobList = GlobList.substr(UntrimmedGlob.size() + 1);
   SmallString<128> RegexText("^");
@@ -44,7 +44,7 @@
 }
 
 GlobList::GlobList(StringRef Globs, bool KeepNegativeGlobs /* =true */) {
-  Items.reserve(Globs.count(',') + 1);
+  Items.reserve(Globs.count(',') + Globs.count('\n') + 1);
   do {
 GlobListItem Item;
 Item.IsPositive = !consumeNegativeIndicator(Globs);


Index: clang-tools-extra/unittests/clang-tidy/GlobListTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/GlobListTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/GlobListTest.cpp
@@ -104,5 +104,18 @@
   EXPECT_TRUE(Filter.contains("asdfqwEasdf"));
 }
 
+TYPED_TEST(GlobListTest, NewlineCharactersAsSeparators) {
+  TypeParam Filter("a*  \n b,\n-c*,dd");
+
+  EXPECT_FALSE(Filter.contains(""));
+  EXPECT_TRUE(Filter.contains("aaa"));
+  EXPECT_TRUE(Filter.contains("b"));
+  EXPECT_FALSE(Filter.contains("c"));
+  EXPECT_FALSE(Filter.contains("ccc"));
+  EXPECT_FALSE(Filter.contains("d"));
+  EXPECT_TRUE(Filter.contains("dd"));
+  EXPECT_FALSE(Filter.contains("ddd"));
+}
+
 } // namespace tidy
 } // namespace clang
Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -86,6 +86,20 @@
   EXPECT_EQ("some.user", *Options->User);
 }
 
+TEST(ParseConfiguration, ChecksSeparatedByNewlines) {
+  auto MemoryBuffer = llvm::MemoryBufferRef("Checks: |\n"
+"  -*,misc-*\n"
+"  llvm-*\n"
+"  -clang-*,\n"
+"  google-*",
+"Options");
+
+  auto Options = parseConfiguration(MemoryBuffer);
+
+  EXPECT_TRUE(!!Options);
+  EXPECT_EQ("-*,misc-*\nllvm-*\n-clang-*,\ngoogle-*\n", *Options->Checks);
+}
+
 TEST(ParseConfiguration, Merg

[PATCH] D120187: [clang-tidy] Allow newline characters as separators for checks in Clang-Tidy configurations

2022-02-19 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny marked 2 inline comments as done.
SimplyDanny added inline comments.



Comment at: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp:100
+  EXPECT_TRUE(!!Options);
+  EXPECT_EQ("-*,misc-*\nllvm-*\n-clang-*,\ngoogle-*\n", *Options->Checks);
+}

njames93 wrote:
> This seems like a shortcoming in llvms YAML parser. Isn't the fold character 
> `>` supposed to replace newlines with spaces and strip trailing ws
> ```lang=c++
> "-*,misc-* llvm-* -clang-* google-*"
> ```
> Using the pipe `|` instead should yield the output you are currently 
> expecting,
That's true. `>` should actually not work without a comma after each check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120187

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


[PATCH] D120187: [clang-tidy] Allow newline characters as separators for checks in Clang-Tidy configurations

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



Comment at: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp:100
+  EXPECT_TRUE(!!Options);
+  EXPECT_EQ("-*,misc-*\nllvm-*\n-clang-*,\ngoogle-*\n", *Options->Checks);
+}

SimplyDanny wrote:
> njames93 wrote:
> > This seems like a shortcoming in llvms YAML parser. Isn't the fold 
> > character `>` supposed to replace newlines with spaces and strip trailing ws
> > ```lang=c++
> > "-*,misc-* llvm-* -clang-* google-*"
> > ```
> > Using the pipe `|` instead should yield the output you are currently 
> > expecting,
> That's true. `>` should actually not work without a comma after each check.
`YAMLParser.h` mentions that "Multi-line literal folding" is not yet 
implemented.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120187

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


[PATCH] D121078: Replace links to archived mailing lists by links to Discourse forums

2022-03-06 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny created this revision.
SimplyDanny added a reviewer: tonic.
Herald added subscribers: libcxx-commits, arphaman.
Herald added a reviewer: sscalpone.
Herald added projects: libunwind, Flang, All.
Herald added a reviewer: libunwind.
SimplyDanny requested review of this revision.
Herald added subscribers: cfe-commits, llvm-commits, lldb-commits, Sanitizers, 
jdoerfert.
Herald added projects: clang, Sanitizers, LLDB, libc++, LLVM, clang-tools-extra.
Herald added a reviewer: libc++.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121078

Files:
  clang-tools-extra/README.txt
  clang/README.txt
  clang/www/analyzer/menu.html.incl
  clang/www/demo/index.cgi
  clang/www/menu.html.incl
  compiler-rt/www/menu.html.incl
  flang/docs/GettingInvolved.md
  libcxx/docs/index.rst
  libunwind/docs/index.rst
  lldb/docs/index.rst
  llvm/docs/Contributing.rst
  llvm/docs/ExtendingLLVM.rst
  llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl10.rst

Index: llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl10.rst
===
--- llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl10.rst
+++ llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl10.rst
@@ -87,8 +87,8 @@
 Have fun - try doing something crazy and unusual. Building a language
 like everyone else always has, is much less fun than trying something a
 little crazy or off the wall and seeing how it turns out. If you get
-stuck or want to talk about it, feel free to email the `llvm-dev mailing
-list `_: it has lots
+stuck or want to talk about it, feel free to open a thread in the `LLVM
+forum `_: it has lots
 of people who are interested in languages and are often willing to help
 out.
 
@@ -166,9 +166,8 @@
 IR does not itself guarantee safety. The LLVM IR allows unsafe pointer
 casts, use after free bugs, buffer over-runs, and a variety of other
 problems. Safety needs to be implemented as a layer on top of LLVM and,
-conveniently, several groups have investigated this. Ask on the `llvm-dev
-mailing list `_ if
-you are interested in more details.
+conveniently, several groups have investigated this. Ask in the `LLVM
+forum `_ if you are interested in more details.
 
 Language-Specific Optimizations
 ---
Index: llvm/docs/ExtendingLLVM.rst
===
--- llvm/docs/ExtendingLLVM.rst
+++ llvm/docs/ExtendingLLVM.rst
@@ -14,8 +14,8 @@
 When you come to this realization, stop and think. Do you really need to extend
 LLVM? Is it a new fundamental capability that LLVM does not support at its
 current incarnation or can it be synthesized from already pre-existing LLVM
-elements? If you are not sure, ask on the `LLVM-dev
-`_ list. The reason is that
+elements? If you are not sure, ask in the `LLVM forum
+`_ list. The reason is that
 extending LLVM will get involved as you need to update all the different passes
 that you intend to use with your extension, and there are ``many`` LLVM analyses
 and transformations, so it may be quite a bit of work.
Index: llvm/docs/Contributing.rst
===
--- llvm/docs/Contributing.rst
+++ llvm/docs/Contributing.rst
@@ -147,7 +147,7 @@
 
   .. __: http://www.aosabook.org/en/llvm.html
 
-.. _Developer's List (llvm-dev): http://lists.llvm.org/mailman/listinfo/llvm-dev
+.. _Forum: https://discourse.llvm.org
 .. _irc.oftc.net: irc://irc.oftc.net/llvm
 .. _beginner: https://github.com/llvm/llvm-project/issues?q=is%3Aopen+is%3Aissue+label%3Abeginner
 .. _bug tracker: https://github.com/llvm/llvm-project/issues
@@ -155,4 +155,3 @@
 .. _git-clang-format: https://reviews.llvm.org/source/llvm-github/browse/main/clang/tools/clang-format/git-clang-format
 .. _LLVM's Phabricator: https://reviews.llvm.org/
 .. _LLVM's Open Projects page: https://llvm.org/OpenProjects.html#what
-.. _LLVM Developer's mailing list: http://lists.llvm.org/mailman/listinfo/llvm-dev
Index: lldb/docs/index.rst
===
--- lldb/docs/index.rst
+++ lldb/docs/index.rst
@@ -102,10 +102,10 @@
 
 See the :doc:`LLDB Build Page ` for build instructions.
 
-Discussions about LLDB should go to the `lldb-dev
-`__ mailing list. Commit
+Discussions about LLDB should go to the `LLDB forum
+`__. Commit
 messages are automatically sent to the `lldb-commits
-`__ mailing list , and
+`__ mailing list, and
 this is also the preferred mailing list for patch submissions.
 
 See the :doc:`Projects page

[PATCH] D120187: [clang-tidy] Allow newline characters as separators for checks in Clang-Tidy configurations

2022-03-06 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny added a comment.
Herald added a project: All.

What else can be done to get this change approved, @njames93?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120187

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


[PATCH] D121078: Replace links to archived mailing lists by links to Discourse forums

2022-03-07 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny updated this revision to Diff 413630.
SimplyDanny marked 9 inline comments as done.
SimplyDanny added a comment.

Updated revision according to review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121078

Files:
  clang-tools-extra/README.txt
  clang/README.txt
  clang/www/analyzer/menu.html.incl
  clang/www/demo/index.cgi
  clang/www/menu.html.incl
  compiler-rt/www/menu.html.incl
  flang/docs/GettingInvolved.md
  libcxx/docs/index.rst
  libunwind/docs/index.rst
  lldb/docs/index.rst
  llvm/docs/Contributing.rst
  llvm/docs/ExtendingLLVM.rst
  llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl10.rst

Index: llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl10.rst
===
--- llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl10.rst
+++ llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl10.rst
@@ -87,10 +87,9 @@
 Have fun - try doing something crazy and unusual. Building a language
 like everyone else always has, is much less fun than trying something a
 little crazy or off the wall and seeing how it turns out. If you get
-stuck or want to talk about it, feel free to email the `llvm-dev mailing
-list `_: it has lots
-of people who are interested in languages and are often willing to help
-out.
+stuck or want to talk about it, please post on the `LLVM forums 
+`_: it has lots of people who are interested
+in languages and are often willing to help out.
 
 Before we end this tutorial, I want to talk about some "tips and tricks"
 for generating LLVM IR. These are some of the more subtle things that
@@ -166,9 +165,8 @@
 IR does not itself guarantee safety. The LLVM IR allows unsafe pointer
 casts, use after free bugs, buffer over-runs, and a variety of other
 problems. Safety needs to be implemented as a layer on top of LLVM and,
-conveniently, several groups have investigated this. Ask on the `llvm-dev
-mailing list `_ if
-you are interested in more details.
+conveniently, several groups have investigated this. Ask on the `LLVM
+forums `_ if you are interested in more details.
 
 Language-Specific Optimizations
 ---
Index: llvm/docs/ExtendingLLVM.rst
===
--- llvm/docs/ExtendingLLVM.rst
+++ llvm/docs/ExtendingLLVM.rst
@@ -14,8 +14,8 @@
 When you come to this realization, stop and think. Do you really need to extend
 LLVM? Is it a new fundamental capability that LLVM does not support at its
 current incarnation or can it be synthesized from already pre-existing LLVM
-elements? If you are not sure, ask on the `LLVM-dev
-`_ list. The reason is that
+elements? If you are not sure, ask on the `LLVM forums
+`_. The reason is that
 extending LLVM will get involved as you need to update all the different passes
 that you intend to use with your extension, and there are ``many`` LLVM analyses
 and transformations, so it may be quite a bit of work.
Index: llvm/docs/Contributing.rst
===
--- llvm/docs/Contributing.rst
+++ llvm/docs/Contributing.rst
@@ -147,7 +147,7 @@
 
   .. __: http://www.aosabook.org/en/llvm.html
 
-.. _Developer's List (llvm-dev): http://lists.llvm.org/mailman/listinfo/llvm-dev
+.. _Forum: https://discourse.llvm.org
 .. _irc.oftc.net: irc://irc.oftc.net/llvm
 .. _beginner: https://github.com/llvm/llvm-project/issues?q=is%3Aopen+is%3Aissue+label%3Abeginner
 .. _bug tracker: https://github.com/llvm/llvm-project/issues
@@ -155,4 +155,3 @@
 .. _git-clang-format: https://reviews.llvm.org/source/llvm-github/browse/main/clang/tools/clang-format/git-clang-format
 .. _LLVM's Phabricator: https://reviews.llvm.org/
 .. _LLVM's Open Projects page: https://llvm.org/OpenProjects.html#what
-.. _LLVM Developer's mailing list: http://lists.llvm.org/mailman/listinfo/llvm-dev
Index: lldb/docs/index.rst
===
--- lldb/docs/index.rst
+++ lldb/docs/index.rst
@@ -102,10 +102,10 @@
 
 See the :doc:`LLDB Build Page ` for build instructions.
 
-Discussions about LLDB should go to the `lldb-dev
-`__ mailing list. Commit
+Discussions about LLDB should go to the `LLDB forum
+`__. Commit
 messages are automatically sent to the `lldb-commits
-`__ mailing list , and
+`__ mailing list, and
 this is also the preferred mailing list for patch submissions.
 
 See the :doc:`Projects page ` if you are looking for some
Index: libunwi

[PATCH] D121078: Replace links to archived mailing lists by links to Discourse forums

2022-03-07 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny added inline comments.



Comment at: clang/README.txt:22
 If you have questions or comments about Clang, a great place to discuss them is
-on the Clang development mailing list:
-  http://lists.llvm.org/mailman/listinfo/cfe-dev
+in the Clang forum:
+  https://discourse.llvm.org/c/clang/

tonic wrote:
> Should this be "on" the Clang forum? Versus in. 
You tell me. 😉 I'm not a native speaker.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121078

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


[PATCH] D121078: Replace links to archived mailing lists by links to Discourse forums

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

In D121078#3363856 , @aaron.ballman 
wrote:

> I think we need to retain *some* references to the existing mailing list 
> archives. The migration to Discourse worked fairly well, but there were still 
> data migration issues.  For example:

Do you have some prominent places in mind where the archives should be 
mentioned? For me as someone who just started to get a bit more involved into 
LLVM, the archives are not very helpful. There is no way to search for threads 
as far as I know. That means it is very hard to find anything specific. That is 
why I actually came up with this change in the first place: Getting rid of 
references to the "old' mailing lists which are just not helpful for beginners.

In D121078#3363856 , @aaron.ballman 
wrote:

> Also, the commits mailing lists are still hosted by mailman and remain 
> relevant to the community for the foreseeable future.

I tried to keep them in all places and just replaced the "-dev" lists by 
references to the forum(s). Have you found a link to a commits mailing list 
which I removed unintentionally?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121078

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


[PATCH] D121078: Replace links to archived mailing lists by links to Discourse forums

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

Removed duplicate target names.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121078

Files:
  clang-tools-extra/README.txt
  clang/README.txt
  clang/www/analyzer/menu.html.incl
  clang/www/demo/index.cgi
  clang/www/menu.html.incl
  compiler-rt/www/menu.html.incl
  flang/docs/GettingInvolved.md
  libcxx/docs/index.rst
  libunwind/docs/index.rst
  lldb/docs/index.rst
  llvm/docs/Contributing.rst
  llvm/docs/ExtendingLLVM.rst
  llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl10.rst

Index: llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl10.rst
===
--- llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl10.rst
+++ llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl10.rst
@@ -87,10 +87,9 @@
 Have fun - try doing something crazy and unusual. Building a language
 like everyone else always has, is much less fun than trying something a
 little crazy or off the wall and seeing how it turns out. If you get
-stuck or want to talk about it, feel free to email the `llvm-dev mailing
-list `_: it has lots
-of people who are interested in languages and are often willing to help
-out.
+stuck or want to talk about it, please post on the `LLVM forums 
+`_: it has lots of people who are interested
+in languages and are often willing to help out.
 
 Before we end this tutorial, I want to talk about some "tips and tricks"
 for generating LLVM IR. These are some of the more subtle things that
@@ -166,9 +165,8 @@
 IR does not itself guarantee safety. The LLVM IR allows unsafe pointer
 casts, use after free bugs, buffer over-runs, and a variety of other
 problems. Safety needs to be implemented as a layer on top of LLVM and,
-conveniently, several groups have investigated this. Ask on the `llvm-dev
-mailing list `_ if
-you are interested in more details.
+conveniently, several groups have investigated this. Ask on the `LLVM
+forums `_ if you are interested in more details.
 
 Language-Specific Optimizations
 ---
Index: llvm/docs/ExtendingLLVM.rst
===
--- llvm/docs/ExtendingLLVM.rst
+++ llvm/docs/ExtendingLLVM.rst
@@ -14,8 +14,8 @@
 When you come to this realization, stop and think. Do you really need to extend
 LLVM? Is it a new fundamental capability that LLVM does not support at its
 current incarnation or can it be synthesized from already pre-existing LLVM
-elements? If you are not sure, ask on the `LLVM-dev
-`_ list. The reason is that
+elements? If you are not sure, ask on the `LLVM forums
+`_. The reason is that
 extending LLVM will get involved as you need to update all the different passes
 that you intend to use with your extension, and there are ``many`` LLVM analyses
 and transformations, so it may be quite a bit of work.
Index: llvm/docs/Contributing.rst
===
--- llvm/docs/Contributing.rst
+++ llvm/docs/Contributing.rst
@@ -147,7 +147,7 @@
 
   .. __: http://www.aosabook.org/en/llvm.html
 
-.. _Developer's List (llvm-dev): http://lists.llvm.org/mailman/listinfo/llvm-dev
+.. _Forum: https://discourse.llvm.org
 .. _irc.oftc.net: irc://irc.oftc.net/llvm
 .. _beginner: https://github.com/llvm/llvm-project/issues?q=is%3Aopen+is%3Aissue+label%3Abeginner
 .. _bug tracker: https://github.com/llvm/llvm-project/issues
@@ -155,4 +155,3 @@
 .. _git-clang-format: https://reviews.llvm.org/source/llvm-github/browse/main/clang/tools/clang-format/git-clang-format
 .. _LLVM's Phabricator: https://reviews.llvm.org/
 .. _LLVM's Open Projects page: https://llvm.org/OpenProjects.html#what
-.. _LLVM Developer's mailing list: http://lists.llvm.org/mailman/listinfo/llvm-dev
Index: lldb/docs/index.rst
===
--- lldb/docs/index.rst
+++ lldb/docs/index.rst
@@ -102,10 +102,10 @@
 
 See the :doc:`LLDB Build Page ` for build instructions.
 
-Discussions about LLDB should go to the `lldb-dev
-`__ mailing list. Commit
+Discussions about LLDB should go to the `LLDB forum
+`__. Commit
 messages are automatically sent to the `lldb-commits
-`__ mailing list , and
+`__ mailing list, and
 this is also the preferred mailing list for patch submissions.
 
 See the :doc:`Projects page ` if you are looking for some
Index: libunwind/docs/index.rst
===