[PATCH] D112718: Add intrinsics and builtins for PTX atomics with semantic orders

2022-01-09 Thread Tadej Ciglarič via Phabricator via cfe-commits
t4c1 added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsNVPTX.def:1057
+
+BUILTIN(__nvvm_atom_xchg_global_i, "iiD*i", "n")
+TARGET_BUILTIN(__nvvm_atom_cta_xchg_global_i, "iiD*i", "n", SM_60)

tra wrote:
> t4c1 wrote:
> > tra wrote:
> > > We need to figure out how address-space-specific builtins are supposed to 
> > > work.
> > > Right now two competing approaches.
> > > 
> > > This patch declares builtins with generic pointer as an argument, but, 
> > > according to the test, expects to be used with the AS-specific pointer.
> > > It probably does not catch a wrong-AS pointer passed as an argument, 
> > > either.
> > > It does happen to work, but I think it's mostly due to the fact that LLVM 
> > > intrinsics are overloaded and we happen to end up addrspacecast'ing  
> > > things correctly if the builtin gets the right kind of pointer.
> > > 
> > > The other approach is to declare the pointer with the expected AS. E.g:
> > > > TARGET_BUILTIN(__nvvm_mbarrier_init_shared, "vWi*3i", "", 
> > > > AND(SM_80,PTX70))
> > > 
> > > IMO, this is the correct way to do it, but it is also rather inconvenient 
> > > to use from CUDA code as it operates on generic pointers.
> > > 
> > > @jdoerfert - WDYT?
> > >TARGET_BUILTIN(__nvvm_mbarrier_init_shared, "vWi*3i", "", AND(SM_80,PTX70))
> > >IMO, this is the correct way to do it, but it is also rather inconvenient 
> > >to use from CUDA code as it operates on generic pointers.
> > 
> > I tried doing this, however it is also completely unusable from OpenCL code 
> > (which is our use case). Trying to use it gives you errors about how 
> > casting pointers to different address spaces  - for example from local to 
> > AS3 is not allowed.
> Hmm. It should've worked. It would need the same explicit cast to a pointer 
> in AS(3) as in your tests, but it would safeguard against attempts to pass it 
> a generic pointer. E.g. https://godbolt.org/z/qE6oxzheM
> 
> Explicit casting to AS(X) for AS-specific variants is annoying, but it's 
> probably unavoidable at the moment regardless of whether we declare the 
> pointer argument to be AS-specific or not.  LLVM will not always be able to 
> infer that a pointer is in particular AS.
> Using specific AS in the declaration has a minor benefit of safeguarding at 
> compile time against unintentional use of generic pointers.
> 
> Ideally we may want to convert generic variant of the builtin to AS-specific 
> one, if LLVM does know the AS. We currently do this for loads/stores, but not 
> for other instructions.
> 
Well, it does not work. See: https://godbolt.org/z/vM6bKncc4. Declaring the 
pointer to be in generic AS is the only way I got it to work. If you know a way 
to call a builtin declared with AS numbers in OpenCL, I am happy to do that 
instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112718

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


[PATCH] D116577: [clang-tidy] Added "boost-use-range-based-for-loop" check

2022-01-09 Thread Denis Mikhailov via Phabricator via cfe-commits
denzor200 marked an inline comment as done.
denzor200 added inline comments.



Comment at: clang-tools-extra/clang-tidy/boost/CMakeLists.txt:8
   BoostTidyModule.cpp
+  UseRangeBasedForLoopCheck.cpp
   UseToStringCheck.cpp

LegalizeAdulthood wrote:
> I am wondering if this check is better placed in the modernize module?
> Maybe as an enhancement to the existing `modernize-loop-convert`?
I vote against the "modernize" section for this check. See arguments above. 



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/boost-use-range-based-for-loop.rst:30
+-
+* Client code that use ``BOOST_FOREACH`` with "``std::pair`` of iterators" or 
with "Null-terminated strings (``char`` and ``wchar_t``)" or some other 
sequence types (everything that is not declared in the list "convertible 
correctly" above) will produce broken code (compilation error).
+

LegalizeAdulthood wrote:
> Eugene.Zelenko wrote:
> > Please separate with newline and follow 80 character limit. Also closing 
> > quote for `Null-terminated strings` is missing.
> It would be better to detect known failure cases in the matcher and not issue 
> a fixit but perhaps issue a diagnostic.
I do not understand how I can determine type of expression `list_int` (for 
example) at the preprocessing stage. This trick was not found in any of the 
existing checks.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/boost-use-range-based-for-loop.rst:47
+
+* First argument of the ``BOOST_FOREACH`` macro must be only new identifier 
definition, all other will produce a compilation error after migration.
+

LegalizeAdulthood wrote:
> Can't you detect this in the matcher and not issue a fixit in that case?
Yes, i can just parse the string token `char c` into mini AST and then 
determine if this is a variable declaration.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116577

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


[PATCH] D116216: Prevent adding module flag - amdgpu_hostcall multiple times.

2022-01-09 Thread praveen velliengiri via Phabricator via cfe-commits
pvellien updated this revision to Diff 398519.
pvellien added a comment.
Herald added subscribers: kerbowa, nhaehnle, jvesely.

@lebedev.ri updated with test-cases.


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

https://reviews.llvm.org/D116216

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCUDA/amdgpu-asan-noprintf.cu
  clang/test/CodeGenCUDA/amdgpu-asan.cu


Index: clang/test/CodeGenCUDA/amdgpu-asan.cu
===
--- clang/test/CodeGenCUDA/amdgpu-asan.cu
+++ clang/test/CodeGenCUDA/amdgpu-asan.cu
@@ -30,5 +30,16 @@
 // MFCHECK: !llvm.module.flags = !{![[FLAG1:[0-9]+]], ![[FLAG2:[0-9]+]]}
 // MFCHECK: ![[FLAG1]] = !{i32 4, !"amdgpu_hostcall", i32 1}
 
+// CHECK: !llvm.module.flags = !{![[FLAG1:[0-9]+]], ![[FLAG2:[0-9]+]]}
+// CHECK: ![[FLAG1]] = !{i32 4, !"amdgpu_hostcall", i32 1}
 // CHECK-NOT: @__amdgpu_device_library_preserve_asan_functions
 // CHECK-NOT: @__asan_report_load1
+
+#include "Inputs/cuda.h"
+__device__ void non_kernel() {
+  printf("sanitized device function");
+}
+
+__global__ void kernel() {
+  non_kernel();
+}
Index: clang/test/CodeGenCUDA/amdgpu-asan-noprintf.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/amdgpu-asan-noprintf.cu
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=amdgcn-amd-amdhsa \
+// RUN:   -fcuda-is-device -target-cpu gfx906 -fsanitize=address \
+// RUN:   -O3 -x hip | FileCheck -check-prefixes=MFCHECK %s
+
+// MFCHECK: !llvm.module.flags = !{![[FLAG1:[0-9]+]], ![[FLAG2:[0-9]+]]}
+// MFCHECK: ![[FLAG1]] = !{i32 4, !"amdgpu_hostcall", i32 1}
+
+// Test to check hostcall module flag metadata is generated
+// without a call to printf when compiled with -fsanitize=address.
+#include "Inputs/cuda.h"
+__global__ void sanitize_kernel() {
+}
+
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -565,7 +565,9 @@
 "__amdgpu_device_library_preserve_asan_functions_ptr", nullptr,
 llvm::GlobalVariable::NotThreadLocal);
 addCompilerUsedGlobal(Var);
-getModule().addModuleFlag(llvm::Module::Override, "amdgpu_hostcall", 1);
+if (!getModule().getModuleFlag("amdgpu_hostcall")) {
+  getModule().addModuleFlag(llvm::Module::Override, "amdgpu_hostcall", 1);
+}
   }
 
   emitLLVMUsed();


Index: clang/test/CodeGenCUDA/amdgpu-asan.cu
===
--- clang/test/CodeGenCUDA/amdgpu-asan.cu
+++ clang/test/CodeGenCUDA/amdgpu-asan.cu
@@ -30,5 +30,16 @@
 // MFCHECK: !llvm.module.flags = !{![[FLAG1:[0-9]+]], ![[FLAG2:[0-9]+]]}
 // MFCHECK: ![[FLAG1]] = !{i32 4, !"amdgpu_hostcall", i32 1}
 
+// CHECK: !llvm.module.flags = !{![[FLAG1:[0-9]+]], ![[FLAG2:[0-9]+]]}
+// CHECK: ![[FLAG1]] = !{i32 4, !"amdgpu_hostcall", i32 1}
 // CHECK-NOT: @__amdgpu_device_library_preserve_asan_functions
 // CHECK-NOT: @__asan_report_load1
+
+#include "Inputs/cuda.h"
+__device__ void non_kernel() {
+  printf("sanitized device function");
+}
+
+__global__ void kernel() {
+  non_kernel();
+}
Index: clang/test/CodeGenCUDA/amdgpu-asan-noprintf.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/amdgpu-asan-noprintf.cu
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=amdgcn-amd-amdhsa \
+// RUN:   -fcuda-is-device -target-cpu gfx906 -fsanitize=address \
+// RUN:   -O3 -x hip | FileCheck -check-prefixes=MFCHECK %s
+
+// MFCHECK: !llvm.module.flags = !{![[FLAG1:[0-9]+]], ![[FLAG2:[0-9]+]]}
+// MFCHECK: ![[FLAG1]] = !{i32 4, !"amdgpu_hostcall", i32 1}
+
+// Test to check hostcall module flag metadata is generated
+// without a call to printf when compiled with -fsanitize=address.
+#include "Inputs/cuda.h"
+__global__ void sanitize_kernel() {
+}
+
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -565,7 +565,9 @@
 "__amdgpu_device_library_preserve_asan_functions_ptr", nullptr,
 llvm::GlobalVariable::NotThreadLocal);
 addCompilerUsedGlobal(Var);
-getModule().addModuleFlag(llvm::Module::Override, "amdgpu_hostcall", 1);
+if (!getModule().getModuleFlag("amdgpu_hostcall")) {
+  getModule().addModuleFlag(llvm::Module::Override, "amdgpu_hostcall", 1);
+}
   }
 
   emitLLVMUsed();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116577: [clang-tidy] Added "boost-use-range-based-for-loop" check

2022-01-09 Thread Denis Mikhailov via Phabricator via cfe-commits
denzor200 updated this revision to Diff 398517.
denzor200 added a comment.

clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116577

Files:
  clang-tools-extra/clang-tidy/boost/BoostTidyModule.cpp
  clang-tools-extra/clang-tidy/boost/CMakeLists.txt
  clang-tools-extra/clang-tidy/boost/UseRangeBasedForLoopCheck.cpp
  clang-tools-extra/clang-tidy/boost/UseRangeBasedForLoopCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/boost-use-range-based-for-loop.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/boost-use-range-based-for-loop.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/boost-use-range-based-for-loop.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/boost-use-range-based-for-loop.cpp
@@ -0,0 +1,39 @@
+// RUN: %check_clang_tidy %s boost-use-range-based-for-loop %t
+
+namespace std {
+template 
+class list {};
+}
+
+#define BOOST_FOREACH(VAR, COL) while(true)
+
+void test_range_based_for_loop()
+{
+  std::list list_int;
+  BOOST_FOREACH( int i, list_int ) {
+// do something with i
+  }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead of BOOST_FOREACH [boost-use-range-based-for-loop]
+  // CHECK-FIXES: for(int i : list_int ) {
+
+  short array_short[] = {1,2,3};
+  BOOST_FOREACH(int
+val, array_short) {
+/// The short was implicitly converted to an int
+  }
+  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based
+  // CHECK-FIXES: for(int val : array_short) {
+}
+
+#define foreach_ BOOST_FOREACH
+
+void test_range_based_for_loop_prettier()
+{
+  std::list list_int;
+  foreach_( int i, list_int ) {
+// do something with i
+  }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based 
+  // CHECK-FIXES: for(int i : list_int ) {
+}
+
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -51,6 +51,7 @@
`android-cloexec-pipe2 `_,
`android-cloexec-socket `_,
`android-comparison-in-temp-failure-retry `_,
+   `boost-use-range-based-for-loop `_, "Yes"
`boost-use-to-string `_, "Yes"
`bugprone-argument-comment `_, "Yes"
`bugprone-assert-side-effect `_,
Index: clang-tools-extra/docs/clang-tidy/checks/boost-use-range-based-for-loop.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/boost-use-range-based-for-loop.rst
@@ -0,0 +1,79 @@
+.. title:: clang-tidy - boost-use-range-based-for-loop
+
+boost-use-range-based-for-loop
+==
+
+This check converts ``BOOST_FOREACH(..., ...)`` loops to use the new
+range-based loops in C++11.
+
+Two kinds of loops can be converted correctly:
+
+-  Loops over arrays.
+-  Loops over STL containers.
+
+Before:
+
+.. code-block:: c++
+
+std::list list_int( /*...*/ );
+BOOST_FOREACH( int i, list_int )
+{
+// do something with i
+}
+
+After:
+
+.. code-block:: c++
+
+std::list list_int( /*...*/ );
+for( int i: list_int )
+{
+// do something with i
+}
+
+Known Limitations
+-
+* Client code that use ``BOOST_FOREACH`` with:
+
+ - ``std::pair`` of iterators;
+ - Null-terminated strings (``char`` and ``wchar_t``);
+ - Some other undefined sequence types
+
+will produce broken code (compilation error). Please see list of correctly
+convertible loops above.
+
+.. code-block:: c++
+
+const char* cstr = "Hello world";
+BOOST_FOREACH( char c, cstr )
+{
+// do something with c
+}
+
+// Will be changed to
+const char* cstr = "Hello world";
+for( char c: cstr ) // won't compile
+{
+// do something with c
+}
+
+* First argument of the ``BOOST_FOREACH`` macro must be only new identifier
+  definition, all other will produce a compilation error after migration.
+
+.. code-block:: c++
+
+std::list list_int( /*...*/ );
+int i;
+BOOST_FOREACH( i, list_int )
+{
+// do something with i
+}
+
+// Will be changed to
+std::list list_int( /*...*/ );
+int i;
+for( i: list_int ) // won't compile
+{
+// do something with i
+}
+
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -76,6 +76,12 @@
 New checks
 ^^
 
+- New :doc:`boost-use-range-based-for-loop
+  ` check.
+
+  This check converts ``BOOST_FOREACH(..., ...)`` loops to use the new
+  range-based loops in C++11.
+
 - New :doc:`bugprone-stringview-nullptr
   ` check.
 

[PATCH] D116577: [clang-tidy] Added "boost-use-range-based-for-loop" check

2022-01-09 Thread Denis Mikhailov via Phabricator via cfe-commits
denzor200 updated this revision to Diff 398516.
denzor200 marked 9 inline comments as done.
denzor200 added a comment.

review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116577

Files:
  clang-tools-extra/clang-tidy/boost/BoostTidyModule.cpp
  clang-tools-extra/clang-tidy/boost/CMakeLists.txt
  clang-tools-extra/clang-tidy/boost/UseRangeBasedForLoopCheck.cpp
  clang-tools-extra/clang-tidy/boost/UseRangeBasedForLoopCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/boost-use-range-based-for-loop.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/boost-use-range-based-for-loop.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/boost-use-range-based-for-loop.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/boost-use-range-based-for-loop.cpp
@@ -0,0 +1,39 @@
+// RUN: %check_clang_tidy %s boost-use-range-based-for-loop %t
+
+namespace std {
+template 
+class list {};
+}
+
+#define BOOST_FOREACH(VAR, COL) while(true)
+
+void test_range_based_for_loop()
+{
+  std::list list_int;
+  BOOST_FOREACH( int i, list_int ) {
+// do something with i
+  }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead of BOOST_FOREACH [boost-use-range-based-for-loop]
+  // CHECK-FIXES: for(int i : list_int ) {
+
+  short array_short[] = {1,2,3};
+  BOOST_FOREACH(int
+val, array_short) {
+/// The short was implicitly converted to an int
+  }
+  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based
+  // CHECK-FIXES: for(int val : array_short) {
+}
+
+#define foreach_ BOOST_FOREACH
+
+void test_range_based_for_loop_prettier()
+{
+  std::list list_int;
+  foreach_( int i, list_int ) {
+// do something with i
+  }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based 
+  // CHECK-FIXES: for(int i : list_int ) {
+}
+
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -51,6 +51,7 @@
`android-cloexec-pipe2 `_,
`android-cloexec-socket `_,
`android-comparison-in-temp-failure-retry `_,
+   `boost-use-range-based-for-loop `_, "Yes"
`boost-use-to-string `_, "Yes"
`bugprone-argument-comment `_, "Yes"
`bugprone-assert-side-effect `_,
Index: clang-tools-extra/docs/clang-tidy/checks/boost-use-range-based-for-loop.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/boost-use-range-based-for-loop.rst
@@ -0,0 +1,79 @@
+.. title:: clang-tidy - boost-use-range-based-for-loop
+
+boost-use-range-based-for-loop
+==
+
+This check converts ``BOOST_FOREACH(..., ...)`` loops to use the new
+range-based loops in C++11.
+
+Two kinds of loops can be converted correctly:
+
+-  Loops over arrays.
+-  Loops over STL containers.
+
+Before:
+
+.. code-block:: c++
+
+std::list list_int( /*...*/ );
+BOOST_FOREACH( int i, list_int )
+{
+// do something with i
+}
+
+After:
+
+.. code-block:: c++
+
+std::list list_int( /*...*/ );
+for( int i: list_int )
+{
+// do something with i
+}
+
+Known Limitations
+-
+* Client code that use ``BOOST_FOREACH`` with:
+
+ - ``std::pair`` of iterators;
+ - Null-terminated strings (``char`` and ``wchar_t``);
+ - Some other undefined sequence types
+
+will produce broken code (compilation error). Please see list of correctly
+convertible loops above.
+
+.. code-block:: c++
+
+const char* cstr = "Hello world";
+BOOST_FOREACH( char c, cstr )
+{
+// do something with c
+}
+
+// Will be changed to
+const char* cstr = "Hello world";
+for( char c: cstr ) // won't compile
+{
+// do something with c
+}
+
+* First argument of the ``BOOST_FOREACH`` macro must be only new identifier
+  definition, all other will produce a compilation error after migration.
+
+.. code-block:: c++
+
+std::list list_int( /*...*/ );
+int i;
+BOOST_FOREACH( i, list_int )
+{
+// do something with i
+}
+
+// Will be changed to
+std::list list_int( /*...*/ );
+int i;
+for( i: list_int ) // won't compile
+{
+// do something with i
+}
+
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -76,6 +76,12 @@
 New checks
 ^^
 
+- New :doc:`boost-use-range-based-for-loop
+  ` check.
+
+  This check converts ``BOOST_FOREACH(..., ...)`` loops to use the new
+  range-based loops in C++11.
+
 - New 

[PATCH] D116834: [clang][dataflow] Change `transfer` function to update lattice element in place.

2022-01-09 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev accepted this revision.
sgatev added inline comments.
This revision is now accepted and ready to land.



Comment at: 
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp:167
 
-  FunctionCallLattice transfer(const Stmt *S, const FunctionCallLattice ,
-   Environment ) {
-FunctionCallLattice R = E;
+  void transfer(const Stmt *S, FunctionCallLattice , Environment ) {
 if (auto *C = dyn_cast(S)) {

nit: let's call this `E` for consistency.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116834

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


[PATCH] D112113: [ObjC] type method metadata `_imp`, messenger routine at callsite with program address space

2022-01-09 Thread Matt Jacobson via Phabricator via cfe-commits
mhjacobson added a comment.

Happy new year!  If this change is acceptable, could someone please merge it 
for me?  (And if not, could someone point out what needs more work?)  Thanks 
for your help!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112113

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


[PATCH] D116577: [clang-tidy] Added "boost-use-range-based-for-loop" check

2022-01-09 Thread Denis Mikhailov via Phabricator via cfe-commits
denzor200 added a comment.

In D116577#3220757 , 
@LegalizeAdulthood wrote:

> I opened a similar issue for converting Qt's foreach to a range for loop 
> .
>
> However this check lands, it should be a simple generalization to have it 
> process Qt foreach loops as well, so perhaps a check name like 
> `modernize-foreach-to-range-for` would be better?

Generic code is a good practize, but i vote against the 
`modernize-foreach-to-range-for` check. My arguments:
-Not everyone uses //boost// and not everyone agrees to see "boost checks" in 
the already large //modernize// section. In the future, there will be a lot of 
these checks, not only `BOOST_FOREACH`. This is for example `Boost Assign`, 
`Boost Static Assert`, `Boost Format`, and so on, you can go on and on.
-All the same as above can be said about Qt.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116577

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


[PATCH] D116792: [AST] lookup in parent DeclContext for transparent DeclContext

2022-01-09 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D116792#3227379 , @erichkeane 
wrote:

> I had to do something similar for this at one point: 
> https://github.com/llvm/llvm-project/commit/90010c2e1d60c6a9a4a0b30a113d4dae2b7214eb
>
> I seem to remember hitting this assert, and from my end, I think I decided 
> even calling 'lookup' with the linkage spec to be a mistake (BTW, you might 
> consider updating that 'Encloses' for 'export' as well!).

Yeah, it is another bug for 'export'. I've tried to address it in 
https://reviews.llvm.org/D116911 with the same style.

> Is there any mechanism in the parent call of 'lookup' here to make it get the 
> right thing?

And 'lookup' is called in various places. For example, from the stack trace of 
the crash, we could find that the parent of call is 
`DeclareImplicitDeductionGuides`. And I tried to handle it in  
`DeclareImplicitDeductionGuides`, then the compiler would crash again at 
`LookupDirect` in `SemaLookup.cpp`. I feel it is not good to add checks for 
places to call `lookup`. I agree that it is odd to lookup in a transparent 
DeclContext. But I feel it is not bad to lookup in the enclosing context from 
the definition of transparent DeclContext. Any thoughts?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116792

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


[PATCH] D116911: [AST] Don't consider 'ExportDecl' when calculating DeclContext 'Encloses'

2022-01-09 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu created this revision.
ChuanqiXu added reviewers: erichkeane, rjmccall.
ChuanqiXu added a project: clang.
ChuanqiXu requested review of this revision.
Herald added a subscriber: cfe-commits.

This mimics the style of 
https://github.com/llvm/llvm-project/commit/90010c2e1d60c6a9a4a0b30a113d4dae2b7214eb.

Since ExportDecl and LinkageSpec are transparent DeclContext, they share some 
similarity. I've checked the test case linked in the revision would fail before 
this patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116911

Files:
  clang/lib/AST/DeclBase.cpp
  clang/test/SemaCXX/lookup-through-export.cpp


Index: clang/test/SemaCXX/lookup-through-export.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/lookup-through-export.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -std=c++20 %s -verify
+
+// expected-no-diagnostics
+export module X;
+export {
+  namespace A {
+  namespace B {
+  int bar;
+  }
+  } // namespace A
+  namespace C {
+  void foo() {
+using namespace A;
+(void)B::bar;
+  }
+  } // namespace C
+}
+
+export {
+  namespace D {
+  namespace E {
+  int bar;
+  }
+  } // namespace D
+  namespace F {
+  void foo() {
+using namespace D;
+(void)E::bar;
+  }
+  } // namespace F
+}
Index: clang/lib/AST/DeclBase.cpp
===
--- clang/lib/AST/DeclBase.cpp
+++ clang/lib/AST/DeclBase.cpp
@@ -1212,7 +1212,8 @@
 return getPrimaryContext()->Encloses(DC);
 
   for (; DC; DC = DC->getParent())
-if (!isa(DC) && DC->getPrimaryContext() == this)
+if (!isa(DC) && !isa(DC) &&
+DC->getPrimaryContext() == this)
   return true;
   return false;
 }


Index: clang/test/SemaCXX/lookup-through-export.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/lookup-through-export.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -std=c++20 %s -verify
+
+// expected-no-diagnostics
+export module X;
+export {
+  namespace A {
+  namespace B {
+  int bar;
+  }
+  } // namespace A
+  namespace C {
+  void foo() {
+using namespace A;
+(void)B::bar;
+  }
+  } // namespace C
+}
+
+export {
+  namespace D {
+  namespace E {
+  int bar;
+  }
+  } // namespace D
+  namespace F {
+  void foo() {
+using namespace D;
+(void)E::bar;
+  }
+  } // namespace F
+}
Index: clang/lib/AST/DeclBase.cpp
===
--- clang/lib/AST/DeclBase.cpp
+++ clang/lib/AST/DeclBase.cpp
@@ -1212,7 +1212,8 @@
 return getPrimaryContext()->Encloses(DC);
 
   for (; DC; DC = DC->getParent())
-if (!isa(DC) && DC->getPrimaryContext() == this)
+if (!isa(DC) && !isa(DC) &&
+DC->getPrimaryContext() == this)
   return true;
   return false;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116906: [OpenMP][AMDGPU] Optimize the linked in math libraries

2022-01-09 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

This fixes/hides the last remaining OvO failures with upstream on an AMD MI100 
compiled with -O3.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116906

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


[PATCH] D113140: [OpenMP][NFCI] Introduce the kernel environment for target regions

2022-01-09 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert abandoned this revision.
jdoerfert added a comment.

Split up, main content starts with D116908 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113140

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


[PATCH] D116910: [OpenMP][3/3] Introduce the KernelEnvironment into Clang tests

2022-01-09 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added reviewers: jhuber6, tianshilei1992, JonChesterfield.
Herald added subscribers: asavonic, guansong, bollu, yaxunl, jvesely.
jdoerfert requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Since Clang uses the OpenMP-IR-Builder to create kernels, the
introduction of the KernelEnvironment in the middle-end will require all
GPU tests to be updated. This was done mostly via the script.
Only test changes are include and no other Clang changes are expected.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116910

Files:
  clang/test/OpenMP/amdgcn_target_codegen.cpp
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_reduction_codegen.cpp
  clang/test/OpenMP/for_lastprivate_codegen.cpp
  clang/test/OpenMP/for_private_codegen.cpp
  clang/test/OpenMP/nvptx_SPMD_codegen.cpp
  clang/test/OpenMP/nvptx_data_sharing.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_force_full_runtime_SPMD_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_nested_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
  clang/test/OpenMP/nvptx_target_printf_codegen.c
  clang/test/OpenMP/nvptx_target_simd_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  
clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_simd_codegen.cpp
  clang/test/OpenMP/nvptx_teams_codegen.cpp
  clang/test/OpenMP/openmp_win_codegen.cpp
  clang/test/OpenMP/parallel_codegen.cpp
  clang/test/OpenMP/parallel_for_simd_aligned_codegen.cpp
  clang/test/OpenMP/parallel_private_codegen.cpp
  clang/test/OpenMP/parallel_reduction_codegen.cpp
  clang/test/OpenMP/parallel_sections_codegen.cpp
  clang/test/OpenMP/sections_lastprivate_codegen.cpp
  clang/test/OpenMP/sections_private_codegen.cpp
  clang/test/OpenMP/sections_reduction_codegen.cpp
  clang/test/OpenMP/single_private_codegen.cpp
  clang/test/OpenMP/target_data_map_codegen_hold.cpp
  clang/test/OpenMP/target_globals_codegen.cpp
  clang/test/OpenMP/target_map_codegen_hold.cpp
  clang/test/OpenMP/target_parallel_debug_codegen.cpp
  clang/test/OpenMP/target_parallel_for_debug_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_collapse_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_dist_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_proc_bind_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_reduction_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_reduction_codegen.cpp
  clang/test/OpenMP/taskgroup_codegen.cpp
  clang/test/OpenMP/teams_distribute_collapse_codegen.cpp
  clang/test/OpenMP/teams_distribute_lastprivate_codegen.cpp
  

[PATCH] D116509: [Builtins] Add missing the macro 'y' description in comments

2022-01-09 Thread Jim Lin 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 rG9b70ddaff6e1: [Builtins] Add missing the macro y 
description in comments (authored by Jim).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116509

Files:
  clang/include/clang/Basic/Builtins.def


Index: clang/include/clang/Basic/Builtins.def
===
--- clang/include/clang/Basic/Builtins.def
+++ clang/include/clang/Basic/Builtins.def
@@ -26,6 +26,7 @@
 //  i -> int
 //  h -> half (__fp16, OpenCL)
 //  x -> half (_Float16)
+//  y -> half (__bf16)
 //  f -> float
 //  d -> double
 //  z -> size_t


Index: clang/include/clang/Basic/Builtins.def
===
--- clang/include/clang/Basic/Builtins.def
+++ clang/include/clang/Basic/Builtins.def
@@ -26,6 +26,7 @@
 //  i -> int
 //  h -> half (__fp16, OpenCL)
 //  x -> half (_Float16)
+//  y -> half (__bf16)
 //  f -> float
 //  d -> double
 //  z -> size_t
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 9b70dda - [Builtins] Add missing the macro 'y' description in comments

2022-01-09 Thread Jim Lin via cfe-commits

Author: Jim Lin
Date: 2022-01-10T10:43:13+08:00
New Revision: 9b70ddaff6e1d1ffc538ac74aa43b4fd6f73bb02

URL: 
https://github.com/llvm/llvm-project/commit/9b70ddaff6e1d1ffc538ac74aa43b4fd6f73bb02
DIFF: 
https://github.com/llvm/llvm-project/commit/9b70ddaff6e1d1ffc538ac74aa43b4fd6f73bb02.diff

LOG: [Builtins] Add missing the macro 'y' description in comments

New type str 'y' added from D76077. But missed its description in
comments.

Reviewed By: stuij

Differential Revision: https://reviews.llvm.org/D116509

Added: 


Modified: 
clang/include/clang/Basic/Builtins.def

Removed: 




diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index f73efdde3e2b1..bfaa7e9f5a9fa 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -26,6 +26,7 @@
 //  i -> int
 //  h -> half (__fp16, OpenCL)
 //  x -> half (_Float16)
+//  y -> half (__bf16)
 //  f -> float
 //  d -> double
 //  z -> size_t



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


[PATCH] D116906: [OpenMP][AMDGPU] Optimize the linked in math libraries

2022-01-09 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added reviewers: JonChesterfield, jhuber6, ye-luo.
Herald added subscribers: kerbowa, guansong, bollu, t-tye, tpr, dstuttard, 
yaxunl, nhaehnle, jvesely, kzhuravl.
jdoerfert requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, wdng.
Herald added a project: clang.

Once we linked in math files, potentially even if we link in only other
"system libraries", we want to optimize the code again. This is not only
reasonable but also helps to hide various problems with the missing
attribute annotations in the math libraries.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116906

Files:
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp


Index: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -16,6 +16,7 @@
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/InputInfo.h"
 #include "clang/Driver/Options.h"
+#include "clang/Driver/Tool.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FormatAdapters.h"
@@ -95,9 +96,9 @@
 if (II.isFilename())
   CmdArgs.push_back(II.getFilename());
 
+  bool HasLibm = false;
   if (Args.hasArg(options::OPT_l)) {
 auto Lm = Args.getAllArgValues(options::OPT_l);
-bool HasLibm = false;
 for (auto  : Lm) {
   if (Lib == "m") {
 HasLibm = true;
@@ -143,6 +144,26 @@
   C.addCommand(std::make_unique(
   JA, *this, ResponseFileSupport::AtFileCurCP(), Exec, CmdArgs, Inputs,
   InputInfo(, Args.MakeArgString(OutputFileName;
+
+  // If we linked in libm definitions late we run another round of 
optimizations
+  // to inline the definitions and fold what is foldable.
+  if (HasLibm) {
+ArgStringList OptCmdArgs;
+const char *OptOutputFileName =
+getOutputFileName(C, OutputFilePrefix, "-linked-opt", "bc");
+addLLCOptArg(Args, OptCmdArgs);
+OptCmdArgs.push_back(OutputFileName);
+OptCmdArgs.push_back("-o");
+OptCmdArgs.push_back(OptOutputFileName);
+const char *OptExec =
+Args.MakeArgString(getToolChain().GetProgramPath("opt"));
+C.addCommand(std::make_unique(
+JA, *this, ResponseFileSupport::AtFileCurCP(), OptExec, OptCmdArgs,
+InputInfo(, Args.MakeArgString(OutputFileName)),
+InputInfo(, Args.MakeArgString(OptOutputFileName;
+OutputFileName = OptOutputFileName;
+  }
+
   return OutputFileName;
 }
 


Index: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -16,6 +16,7 @@
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/InputInfo.h"
 #include "clang/Driver/Options.h"
+#include "clang/Driver/Tool.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FormatAdapters.h"
@@ -95,9 +96,9 @@
 if (II.isFilename())
   CmdArgs.push_back(II.getFilename());
 
+  bool HasLibm = false;
   if (Args.hasArg(options::OPT_l)) {
 auto Lm = Args.getAllArgValues(options::OPT_l);
-bool HasLibm = false;
 for (auto  : Lm) {
   if (Lib == "m") {
 HasLibm = true;
@@ -143,6 +144,26 @@
   C.addCommand(std::make_unique(
   JA, *this, ResponseFileSupport::AtFileCurCP(), Exec, CmdArgs, Inputs,
   InputInfo(, Args.MakeArgString(OutputFileName;
+
+  // If we linked in libm definitions late we run another round of optimizations
+  // to inline the definitions and fold what is foldable.
+  if (HasLibm) {
+ArgStringList OptCmdArgs;
+const char *OptOutputFileName =
+getOutputFileName(C, OutputFilePrefix, "-linked-opt", "bc");
+addLLCOptArg(Args, OptCmdArgs);
+OptCmdArgs.push_back(OutputFileName);
+OptCmdArgs.push_back("-o");
+OptCmdArgs.push_back(OptOutputFileName);
+const char *OptExec =
+Args.MakeArgString(getToolChain().GetProgramPath("opt"));
+C.addCommand(std::make_unique(
+JA, *this, ResponseFileSupport::AtFileCurCP(), OptExec, OptCmdArgs,
+InputInfo(, Args.MakeArgString(OutputFileName)),
+InputInfo(, Args.MakeArgString(OptOutputFileName;
+OutputFileName = OptOutputFileName;
+  }
+
   return OutputFileName;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116514: [clangd] Add code action to generate a constructor for a C++ class

2022-01-09 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Shouldn't the constructors that need `std::move` also ensure the `` 
header is also included, or at least transitively included. We don't want to 
generate constructors that wont compile.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116514

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


[PATCH] D116904: Fix build failure with MSVC in C++20 mode

2022-01-09 Thread Evgeny Mandrikov via Phabricator via cfe-commits
Godin created this revision.
Godin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Without this patch when using CMAKE_CXX_STANDARD=20
and MSVC 19.30.30705.0 compilation fails with

clang\lib\Tooling\Syntax\Tree.cpp(347): error C2666: 
'clang::syntax::Tree::ChildIteratorBase::operator
 ==': 4 overloads have similar conversions
clang\lib\Tooling\Syntax\Tree.cpp(392): error C2666: 
'clang::syntax::Tree::ChildIteratorBase::operator
 ==': 4 overloads have similar conversions

Note that removed comment that
"iterator_facade_base requires == to be a member"
was made obsolete by change https://reviews.llvm.org/D78938


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116904

Files:
  clang/include/clang/Tooling/Syntax/Tree.h


Index: clang/include/clang/Tooling/Syntax/Tree.h
===
--- clang/include/clang/Tooling/Syntax/Tree.h
+++ clang/include/clang/Tooling/Syntax/Tree.h
@@ -181,7 +181,10 @@
 ChildIteratorBase() = default;
 explicit ChildIteratorBase(NodeT *N) : N(N) {}
 
-bool operator==(const DerivedT ) const { return O.N == N; }
+friend bool operator==(const DerivedT , const DerivedT ) {
+  return LHS.N == RHS.N;
+}
+
 NodeT *() const { return *N; }
 DerivedT ++() {
   N = N->getNextSibling();
@@ -269,14 +272,6 @@
   Node *LastChild = nullptr;
 };
 
-// Provide missing non_const == const overload.
-// iterator_facade_base requires == to be a member, but implicit conversions
-// don't work on the LHS of a member operator.
-inline bool operator==(const Tree::ConstChildIterator ,
-   const Tree::ConstChildIterator ) {
-  return A.operator==(B);
-}
-
 /// A list of Elements separated or terminated by a fixed token.
 ///
 /// This type models the following grammar construct:


Index: clang/include/clang/Tooling/Syntax/Tree.h
===
--- clang/include/clang/Tooling/Syntax/Tree.h
+++ clang/include/clang/Tooling/Syntax/Tree.h
@@ -181,7 +181,10 @@
 ChildIteratorBase() = default;
 explicit ChildIteratorBase(NodeT *N) : N(N) {}
 
-bool operator==(const DerivedT ) const { return O.N == N; }
+friend bool operator==(const DerivedT , const DerivedT ) {
+  return LHS.N == RHS.N;
+}
+
 NodeT *() const { return *N; }
 DerivedT ++() {
   N = N->getNextSibling();
@@ -269,14 +272,6 @@
   Node *LastChild = nullptr;
 };
 
-// Provide missing non_const == const overload.
-// iterator_facade_base requires == to be a member, but implicit conversions
-// don't work on the LHS of a member operator.
-inline bool operator==(const Tree::ConstChildIterator ,
-   const Tree::ConstChildIterator ) {
-  return A.operator==(B);
-}
-
 /// A list of Elements separated or terminated by a fixed token.
 ///
 /// This type models the following grammar construct:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116882: [docs] [clang] Small documentation change for compilation databases

2022-01-09 Thread Dave Butler via Phabricator via cfe-commits
croepha marked an inline comment as done.
croepha added inline comments.



Comment at: clang/docs/JSONCompilationDatabase.rst:33
+Clang has the ablity to generate compilation database fragments via
+the :option:`-MJ argument >`. You can contantinate those
+fragments together between ``[`` and ``]`` to create a compilation database.

joerg wrote:
> I think you mean "concatenate", but otherwise LGTM? 
Yes, thank you


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116882

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


[PATCH] D116882: [docs] [clang] Small documentation change for compilation databases

2022-01-09 Thread Dave Butler via Phabricator via cfe-commits
croepha updated this revision to Diff 398468.
croepha added a comment.

Fixed spelling


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116882

Files:
  clang/docs/JSONCompilationDatabase.rst


Index: clang/docs/JSONCompilationDatabase.rst
===
--- clang/docs/JSONCompilationDatabase.rst
+++ clang/docs/JSONCompilationDatabase.rst
@@ -29,6 +29,10 @@
 Supported Systems
 =
 
+Clang has the ablity to generate compilation database fragments via
+the :option:`-MJ argument >`. You can concatenate those
+fragments together between ``[`` and ``]`` to create a compilation database.
+
 Currently `CMake `_ (since 2.8.5) supports generation
 of compilation databases for Unix Makefile builds (Ninja builds in the
 works) with the option ``CMAKE_EXPORT_COMPILE_COMMANDS``.


Index: clang/docs/JSONCompilationDatabase.rst
===
--- clang/docs/JSONCompilationDatabase.rst
+++ clang/docs/JSONCompilationDatabase.rst
@@ -29,6 +29,10 @@
 Supported Systems
 =
 
+Clang has the ablity to generate compilation database fragments via
+the :option:`-MJ argument >`. You can concatenate those
+fragments together between ``[`` and ``]`` to create a compilation database.
+
 Currently `CMake `_ (since 2.8.5) supports generation
 of compilation databases for Unix Makefile builds (Ninja builds in the
 works) with the option ``CMAKE_EXPORT_COMPILE_COMMANDS``.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63324: [clang-tidy] Replace memcpy by std::copy

2022-01-09 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments.
Herald added a subscriber: carlosgalvezp.



Comment at: clang-tools-extra/clang-tidy/modernize/CMakeLists.txt:19
   ReplaceAutoPtrCheck.cpp
+  ReplaceMemcpyByStdCopy.cpp
   ReplaceRandomShuffleCheck.cpp

In English, it's more idiomatic to say "Replace `memcpy` with `std::copy`",
but perhaps an even better name for this check is `modernize-use-std-copy`.
This opens the door to future improvements that recognize hand-written
for loops that are essentially just invocations of `std::copy` or `std::copy_n`.
(Recently I was considering writing a check like that while reviewing some
code at work that was full of hand-written for loops that just copied elements
from one container to another.)



Comment at: clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.cpp:35
+   isExpansionInSystemHeader())),
+   isExpansionInMainFile())
+  .bind("memcpy_function");

I erroneously had this in some checks I had written; it prevents fixits
from being applied to user supplied header files and is undesirable.

I would suggest removing both the `isExpansionInSystemHeader` and
`isExpansionInMainFile` narrowing matchers.



Comment at: clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.cpp:70
+const CallExpr *MemcpyNode) {
+  const CharSourceRange FunctionNameSourceRange = 
CharSourceRange::getCharRange(
+  MemcpyNode->getBeginLoc(), MemcpyNode->getArg(0)->getBeginLoc());

In the clang code base, they prefer not to use `const` on local variables
unless the local is a pointer to a `const` object and even then, it's only
the pointed-to object that is declared `const` not the pointer itself.



Comment at: clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.cpp:78
+ const CallExpr *MemcpyNode) {
+  std::array arg;
+

LLVM naming convention is `CapCamelCase` for variables.
See here and variables declared on lines 85, 86, 91, etc.



Comment at: clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.cpp:91
+  // Create lambda that return SourceRange of an argument
+  auto getSourceRange = [MemcpyNode](uint8_t ArgCount) -> SourceRange {
+return SourceRange(MemcpyNode->getArg(ArgCount)->getBeginLoc(),

Prefer `int` over `uint8_t` here as there is no requirement for
a type of a specific bit width.  The explicit return type is also
unnecessary, but please consult the LLVM style guide to make
sure you're following any prescriptions for lambdas.

Additionally, `ArgCount` doesn't feel like the right name for this
parameter.  It's not the count of anything, it's an index into the
arguments, so just `Arg` feels better.



Comment at: clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.cpp:99
+
+  arg[2] = arg[1] + " + ((" + arg[2] + ") / sizeof(*(" + arg[1] + ")))";
+  Diag << FixItHint::CreateReplacement(getSourceRange(1), arg[2]);

I think it would be worthwhile to probe the AST of the argument here and see if 
it is
already of the form `N*sizeof(T)`.

This can probably be handled by enhancing the matchers on the argument so that 
you
aren't probing the AST in procedural code.



Comment at: clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.cpp:11
+#include "../utils/OptionsUtils.h"
+
+#include 

Eugene.Zelenko wrote:
> Please remove unnecessary empty line.
> Please remove unnecessary empty line.

Where is this in the LLVM coding style guide?



Comment at: clang-tools-extra/clang-tidy/modernize/ReplaceMemcpyByStdCopy.h:26
+  ReplaceMemcpyByStdCopy(StringRef Name, ClangTidyContext *Context);
+  virtual ~ReplaceMemcpyByStdCopy() {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;

Eugene.Zelenko wrote:
> Should be override and = default. See modernize-use-override and 
> modernize-use-equals-default.
> Should be override and = default

Why do you need to override it if you're just using the compiler's default?



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/modernize-replace-memcpy-by-stdcopy.rst:33
+
+Unlike ``std::copy`` that take an iterator on the last element of the source 
array, ``memcpy`` request the number of bytes to copy.
+In order to make the check working, it will convert the size parameter to an 
iterator by replacing it by ``source + (num / sizeof *source)``

Please use a line length in the `.rst` files that is consistent with the LLVM 
line length
for code files.


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

https://reviews.llvm.org/D63324

___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D116882: [docs] [clang] Small documentation change for compilation databases

2022-01-09 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg accepted this revision.
joerg added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/docs/JSONCompilationDatabase.rst:33
+Clang has the ablity to generate compilation database fragments via
+the :option:`-MJ argument >`. You can contantinate those
+fragments together between ``[`` and ``]`` to create a compilation database.

I think you mean "concatenate", but otherwise LGTM? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116882

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


[clang-tools-extra] 8afcfbf - Use true/false instead of 1/0 (NFC)

2022-01-09 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-01-09T12:21:06-08:00
New Revision: 8afcfbfb8fc1e53023ffac9d9bdc424248d6d2ff

URL: 
https://github.com/llvm/llvm-project/commit/8afcfbfb8fc1e53023ffac9d9bdc424248d6d2ff
DIFF: 
https://github.com/llvm/llvm-project/commit/8afcfbfb8fc1e53023ffac9d9bdc424248d6d2ff.diff

LOG: Use true/false instead of 1/0 (NFC)

Identified by modernize-use-bool-literals.

Added: 


Modified: 
clang-tools-extra/clangd/refactor/Rename.cpp
lld/COFF/Writer.cpp
lld/ELF/Arch/X86_64.cpp
lld/MachO/Arch/ARM.cpp
lld/MachO/InputSection.h
lldb/source/Host/common/Host.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Symbol/TypeSystem.cpp
lldb/source/Target/TraceInstructionDumper.cpp
polly/lib/Analysis/ScopDetection.cpp
polly/lib/CodeGen/PerfMonitor.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index 5e157db5900af..e092c677c57cf 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -906,7 +906,7 @@ llvm::Optional> 
getMappedRanges(ArrayRef Indexed,
 
   std::vector Best;
   size_t BestCost = std::numeric_limits::max();
-  bool HasMultiple = 0;
+  bool HasMultiple = false;
   std::vector ResultStorage;
   int Fuel = 1;
   findNearMiss(ResultStorage, Indexed, Lexed, 0, Fuel,

diff  --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index 0788f3519f4e0..4a41c541ee7f9 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -1246,7 +1246,7 @@ void Writer::mergeSections() {
 if (p.first == toName)
   continue;
 StringSet<> names;
-while (1) {
+while (true) {
   if (!names.insert(toName).second)
 fatal("/merge: cycle found for section '" + p.first + "'");
   auto i = config->merge.find(toName);

diff  --git a/lld/ELF/Arch/X86_64.cpp b/lld/ELF/Arch/X86_64.cpp
index 08591d8e5f06b..161e99e3ba3fb 100644
--- a/lld/ELF/Arch/X86_64.cpp
+++ b/lld/ELF/Arch/X86_64.cpp
@@ -282,12 +282,12 @@ bool X86_64::deleteFallThruJmpInsn(InputSection , 
InputFile *file,
   const unsigned sizeOfJmpCCInsn = 6;
   // To flip, there must be atleast one JmpCC and one direct jmp.
   if (is.getSize() < sizeOfDirectJmpInsn + sizeOfJmpCCInsn)
-return 0;
+return false;
 
   unsigned rbIndex =
   getRelocationWithOffset(is, (is.getSize() - sizeOfDirectJmpInsn - 4));
   if (rbIndex == is.relocations.size())
-return 0;
+return false;
 
   Relocation  = is.relocations[rbIndex];
 

diff  --git a/lld/MachO/Arch/ARM.cpp b/lld/MachO/Arch/ARM.cpp
index 42c7b89308684..4dda94d7b0f38 100644
--- a/lld/MachO/Arch/ARM.cpp
+++ b/lld/MachO/Arch/ARM.cpp
@@ -116,7 +116,7 @@ void ARM::relocateOne(uint8_t *loc, const Reloc , 
uint64_t value,
 return;
   } else if (isBlx && !defined->thumb) {
 Bitfield::set(base, 0xe); // unconditional BL
-Bitfield::set>(base, 1);
+Bitfield::set>(base, true);
 isBlx = false;
   }
 } else {

diff  --git a/lld/MachO/InputSection.h b/lld/MachO/InputSection.h
index fa137223c426f..58f794227b617 100644
--- a/lld/MachO/InputSection.h
+++ b/lld/MachO/InputSection.h
@@ -234,7 +234,9 @@ class WordLiteralInputSection final : public InputSection {
   bool isLive(uint64_t off) const override {
 return live[off >> power2LiteralSize];
   }
-  void markLive(uint64_t off) override { live[off >> power2LiteralSize] = 1; }
+  void markLive(uint64_t off) override {
+live[off >> power2LiteralSize] = true;
+  }
 
   static bool classof(const InputSection *isec) {
 return isec->kind() == WordLiteralKind;

diff  --git a/lldb/source/Host/common/Host.cpp 
b/lldb/source/Host/common/Host.cpp
index d14ebe99fd155..53a096c617dff 100644
--- a/lldb/source/Host/common/Host.cpp
+++ b/lldb/source/Host/common/Host.cpp
@@ -191,7 +191,7 @@ static thread_result_t 
MonitorChildProcessThreadFunction(void *arg) {
   ::sigaction(SIGUSR1, , nullptr);
 #endif // __linux__
 
-  while (1) {
+  while (true) {
 log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS);
 LLDB_LOGF(log, "%s ::waitpid (pid = %" PRIi32 ", , options = 
%i)...",
   function, pid, options);

diff  --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
index aa6306bef8b99..ff41f187ba9d0 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
@@ -889,8 +889,8 @@ 
AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread ,
   ThreadPlanSP ret_plan_sp;
   lldb::addr_t curr_pc = 

[clang] b12fd13 - Fix bugprone argument comments.

2022-01-09 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-01-09T12:21:02-08:00
New Revision: b12fd138127e368a5d78109bef77713c0bcd536e

URL: 
https://github.com/llvm/llvm-project/commit/b12fd138127e368a5d78109bef77713c0bcd536e
DIFF: 
https://github.com/llvm/llvm-project/commit/b12fd138127e368a5d78109bef77713c0bcd536e.diff

LOG: Fix bugprone argument comments.

Identified by bugprone-argument-comment.

Added: 


Modified: 

clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/SourceCode.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
lld/MachO/SyntheticSections.cpp
lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
lldb/source/Expression/DWARFExpression.cpp
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
lldb/source/Symbol/Function.cpp
lldb/source/Target/TraceInstructionDumper.cpp
lldb/source/Utility/Reproducer.cpp
polly/include/polly/ScopPass.h

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
index fa5e06c8e7b26..d6af020326eb0 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
@@ -173,11 +173,11 @@ void VirtualClassDestructorCheck::check(
  "destructor of %0 is private and prevents using the type")
 << MatchedClassOrStruct;
 diag(MatchedClassOrStruct->getLocation(),
- /*FixDescription=*/"make it public and virtual", DiagnosticIDs::Note)
+ /*Description=*/"make it public and virtual", DiagnosticIDs::Note)
 << changePrivateDestructorVisibilityTo(
"public", *Destructor, *Result.SourceManager, getLangOpts());
 diag(MatchedClassOrStruct->getLocation(),
- /*FixDescription=*/"make it protected", DiagnosticIDs::Note)
+ /*Description=*/"make it protected", DiagnosticIDs::Note)
 << changePrivateDestructorVisibilityTo(
"protected", *Destructor, *Result.SourceManager, getLangOpts());
 

diff  --git a/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
index 882d254c6d9ea..411d6db582436 100644
--- a/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
@@ -130,7 +130,7 @@ void DefinitionsInHeadersCheck::check(const 
MatchFinder::MatchResult ) {
 // inline is not allowed for main function.
 if (FD->isMain())
   return;
-diag(FD->getLocation(), /*FixDescription=*/"make as 'inline'",
+diag(FD->getLocation(), /*Description=*/"make as 'inline'",
  DiagnosticIDs::Note)
 << FixItHint::CreateInsertion(FD->getInnerLocStart(), "inline ");
   } else if (const auto *VD = dyn_cast(ND)) {

diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index 50388e08c30aa..d9165599fb9ab 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -420,7 +420,7 @@ struct CodeCompletionBuilder {
 SetDoc(C.IndexResult->Documentation);
   } else if (C.SemaResult) {
 const auto DocComment = getDocComment(*ASTCtx, *C.SemaResult,
-  /*CommentsFromHeader=*/false);
+  /*CommentsFromHeaders=*/false);
 SetDoc(formatDocumentation(*SemaCCS, DocComment));
   }
 }
@@ -959,9 +959,9 @@ class SignatureHelpCollector final : public 
CodeCompleteConsumer {
 paramIndexForArg(Candidate, SigHelp.activeParameter);
   }
 
-  const auto *CCS =
-  Candidate.CreateSignatureString(CurrentArg, S, *Allocator, CCTUInfo,
-  /*IncludeBriefComment=*/true, 
Braced);
+  const auto *CCS = Candidate.CreateSignatureString(
+  CurrentArg, S, *Allocator, CCTUInfo,
+  /*IncludeBriefComments=*/true, Braced);
   assert(CCS && "Expected the CodeCompletionString to be non-null");
   ScoredSignatures.push_back(processOverloadCandidate(
   Candidate, *CCS,

diff  --git a/clang-tools-extra/clangd/SourceCode.cpp 
b/clang-tools-extra/clangd/SourceCode.cpp
index f3a60d6419513..6f6d936ac3a7e 100644
--- a/clang-tools-extra/clangd/SourceCode.cpp
+++ b/clang-tools-extra/clangd/SourceCode.cpp
@@ -457,7 +457,7 @@ llvm::Expected 
sourceLocationInMainFile(const SourceManager ,
 Position P) {
   llvm::StringRef Code = SM.getBufferOrFake(SM.getMainFileID()).getBuffer();
   auto Offset =

[clang] ac2090d - [clang] Remove unused forward declarations (NFC)

2022-01-09 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-01-09T12:21:00-08:00
New Revision: ac2090d507a67d1e98594d081ce3951837d43f28

URL: 
https://github.com/llvm/llvm-project/commit/ac2090d507a67d1e98594d081ce3951837d43f28
DIFF: 
https://github.com/llvm/llvm-project/commit/ac2090d507a67d1e98594d081ce3951837d43f28.diff

LOG: [clang] Remove unused forward declarations (NFC)

Added: 


Modified: 
clang/include/clang/AST/ASTConcept.h
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/ASTImporterLookupTable.h
clang/include/clang/AST/Attr.h
clang/include/clang/AST/AttrIterator.h
clang/include/clang/AST/Decl.h
clang/include/clang/AST/DeclBase.h
clang/include/clang/AST/DeclCXX.h
clang/include/clang/AST/DeclarationName.h
clang/include/clang/AST/MangleNumberingContext.h
clang/include/clang/AST/PrettyDeclStackTrace.h
clang/include/clang/AST/PrettyPrinter.h
clang/include/clang/AST/TemplateBase.h
clang/include/clang/AST/TemplateName.h
clang/include/clang/Analysis/Analyses/CalledOnceCheck.h
clang/include/clang/Analysis/BodyFarm.h
clang/include/clang/Analysis/PathDiagnostic.h
clang/include/clang/Analysis/ProgramPoint.h
clang/include/clang/Basic/PartialDiagnostic.h
clang/include/clang/Basic/ProfileList.h
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/CodeGen/CodeGenABITypes.h
clang/include/clang/CodeGen/SwiftCallingConv.h
clang/include/clang/Driver/Util.h
clang/include/clang/Format/Format.h
clang/include/clang/Frontend/ASTConsumers.h
clang/include/clang/Frontend/CompilerInstance.h
clang/include/clang/Frontend/FrontendActions.h
clang/include/clang/Frontend/SerializedDiagnosticPrinter.h
clang/include/clang/Interpreter/Interpreter.h
clang/include/clang/Sema/AnalysisBasedWarnings.h
clang/include/clang/Sema/ExternalSemaSource.h
clang/include/clang/Sema/Initialization.h
clang/include/clang/Sema/ScopeInfo.h
clang/include/clang/Serialization/ASTReader.h
clang/include/clang/Serialization/ASTWriter.h
clang/include/clang/Serialization/GlobalModuleIndex.h
clang/include/clang/Serialization/PCHContainerOperations.h
clang/include/clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h
clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
clang/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h
clang/include/clang/StaticAnalyzer/Frontend/FrontendActions.h
clang/include/clang/Tooling/ASTDiff/ASTDiffInternal.h
clang/include/clang/Tooling/Refactoring/Rename/RenamingAction.h
clang/include/clang/Tooling/Refactoring/Rename/USRFindingAction.h
clang/include/clang/Tooling/Tooling.h
clang/tools/libclang/CXType.h

Removed: 




diff  --git a/clang/include/clang/AST/ASTConcept.h 
b/clang/include/clang/AST/ASTConcept.h
index c8a1dc83b8aae..25e00860060f0 100644
--- a/clang/include/clang/AST/ASTConcept.h
+++ b/clang/include/clang/AST/ASTConcept.h
@@ -22,7 +22,6 @@
 
 namespace clang {
 class ConceptDecl;
-class ConceptSpecializationExpr;
 
 /// The result of a constraint satisfaction check, containing the necessary
 /// information to diagnose an unsatisfied constraint.

diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 63f2c948c79bb..7a9e3a643d6f4 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -104,10 +104,8 @@ class DynTypedNodeList;
 class Expr;
 enum class FloatModeKind;
 class GlobalDecl;
-class ItaniumMangleContext;
 class MangleContext;
 class MangleNumberingContext;
-class MaterializeTemporaryExpr;
 class MemberSpecializationInfo;
 class Module;
 struct MSGuidDeclParts;
@@ -126,7 +124,6 @@ class ObjCTypeParamDecl;
 class OMPTraitInfo;
 struct ParsedTargetAttr;
 class Preprocessor;
-class Stmt;
 class StoredDeclsMap;
 class TargetAttr;
 class TargetInfo;

diff  --git a/clang/include/clang/AST/ASTImporterLookupTable.h 
b/clang/include/clang/AST/ASTImporterLookupTable.h
index 918c2b9e350cd..2dbc44c5dcd44 100644
--- a/clang/include/clang/AST/ASTImporterLookupTable.h
+++ b/clang/include/clang/AST/ASTImporterLookupTable.h
@@ -21,7 +21,6 @@
 
 namespace clang {
 
-class 

[PATCH] D91000: [clang-tidy] Add cert-msc24-c checker.

2022-01-09 Thread Fütő Gergely via Phabricator via cfe-commits
futogergely added a comment.

In D91000#3225369 , @balazske wrote:

> The functions `asctime` and `asctime_r` are discouraged according to CERT 
> MSC33-C rule. These could be added to this check as well. There is a clang SA 
> checker `SecuritySyntaxChecker` that contains other obsolete functions (and 
> the whole check looks like it can be done in clang-tidy).

The inclusion of CERT MSC33-C rule seems to be straightforward: check for 
asctime and asctime_r, and suggest asctime_s if Annex K is available, otherwise 
suggest strftime.

security.insecureAPI: the following functions could be added to the checker: 
bcmp, bcopy, bzero, getpw, mktemp, vfork, and if arc4random is available: 
drand48, erand48, jrand48, lcong48, lrand48, mrand48, nrand48, random, rand_r.
I think for now it is enough to issue a warning of using these functions, and 
not suggest a replacement. Should we add an option to the checker to also check 
for these functions?


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

https://reviews.llvm.org/D91000

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


[PATCH] D116736: [Clang] Add __builtin_reduce_or and __builtin_reduce_and

2022-01-09 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added reviewers: aaron.ballman, erichkeane.
fhahn added a comment.

LGTM, thanks!

> The last __builtin_reduce_add will be seperated into another one.

Are you planning on putting up a patch for this one as well? What makes add a 
bit different is that `‘llvm.vector.reduce.fadd.*’` can only perform reductions 
either in the original order or in an unspecified order. For the extension, we 
need a particular evaluation order (reduction tree adding adjacent element 
pairs). Technically this order is required for all reduction builtins, but for 
integers the order doesn't matter, same for min/max.




Comment at: clang/lib/Sema/SemaChecking.cpp:2235
 
-  // __builtin_reduce_xor supports vector of integers only.
-  case Builtin::BI__builtin_reduce_xor: {
+  // This builtins support vector of integers only.
+  case Builtin::BI__builtin_reduce_xor:

nit: Those  vectors 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116736

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


[PATCH] D113049: [AIX] Disable tests that fail because of no 64-bit XCOFF object file support

2022-01-09 Thread Jake Egan 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 rGfbf52caf58b3: [AIX] Disable tests that fail because of no 
64-bit XCOFF object file support (authored by Jake-Egan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113049

Files:
  clang/test/ASTMerge/codegen-body/test.c
  clang/test/ClangScanDeps/modules-full-by-mod-name.cpp
  clang/test/ClangScanDeps/resource_directory.c
  clang/test/lit.cfg.py
  llvm/test/LTO/X86/remangle_intrinsics.ll
  llvm/test/lit.cfg.py
  llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp

Index: llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
===
--- llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
+++ llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
@@ -1131,7 +1131,11 @@
   EXPECT_STREQ(String1, *Extracted3);
 }
 
+#if defined(_AIX) && defined(__64BIT__)
+TEST(DWARFDebugInfo, DISABLED_TestEmptyStringOffsets) {
+#else
 TEST(DWARFDebugInfo, TestEmptyStringOffsets) {
+#endif
   Triple Triple = getNormalizedDefaultTargetTriple();
   if (!isConfigurationSupported(Triple))
 GTEST_SKIP();
@@ -1160,7 +1164,11 @@
   DwarfContext->getDWARFObj().getStrOffsetsSection().Data.empty());
 }
 
+#if defined(_AIX) && defined(__64BIT__)
+TEST(DWARFDebugInfo, DISABLED_TestRelations) {
+#else
 TEST(DWARFDebugInfo, TestRelations) {
+#endif
   Triple Triple = getNormalizedDefaultTargetTriple();
   if (!isConfigurationSupported(Triple))
 GTEST_SKIP();
@@ -1347,7 +1355,11 @@
   EXPECT_FALSE(DefaultDie.getSibling().isValid());
 }
 
+#if defined(_AIX) && defined(__64BIT__)
+TEST(DWARFDebugInfo, DISABLED_TestChildIterators) {
+#else
 TEST(DWARFDebugInfo, TestChildIterators) {
+#endif
   Triple Triple = getNormalizedDefaultTargetTriple();
   if (!isConfigurationSupported(Triple))
 GTEST_SKIP();
@@ -1456,7 +1468,11 @@
   EXPECT_EQ(CUDie.begin(), CUDie.end());
 }
 
+#if defined(_AIX) && defined(__64BIT__)
+TEST(DWARFDebugInfo, DISABLED_TestAttributeIterators) {
+#else
 TEST(DWARFDebugInfo, TestAttributeIterators) {
+#endif
   Triple Triple = getNormalizedDefaultTargetTriple();
   if (!isConfigurationSupported(Triple))
 GTEST_SKIP();
@@ -1518,7 +1534,11 @@
   EXPECT_EQ(E, ++I);
 }
 
+#if defined(_AIX) && defined(__64BIT__)
+TEST(DWARFDebugInfo, DISABLED_TestFindRecurse) {
+#else
 TEST(DWARFDebugInfo, TestFindRecurse) {
+#endif
   Triple Triple = getNormalizedDefaultTargetTriple();
   if (!isConfigurationSupported(Triple))
 GTEST_SKIP();
@@ -1732,7 +1752,11 @@
   // Test
 }
 
+#if defined(_AIX) && defined(__64BIT__)
+TEST(DWARFDebugInfo, DISABLED_TestFindAttrs) {
+#else
 TEST(DWARFDebugInfo, TestFindAttrs) {
+#endif
   Triple Triple = getNormalizedDefaultTargetTriple();
   if (!isConfigurationSupported(Triple))
 GTEST_SKIP();
@@ -1795,7 +1819,11 @@
   EXPECT_EQ(DieMangled, toString(NameOpt, ""));
 }
 
+#if defined(_AIX) && defined(__64BIT__)
+TEST(DWARFDebugInfo, DISABLED_TestImplicitConstAbbrevs) {
+#else
 TEST(DWARFDebugInfo, TestImplicitConstAbbrevs) {
+#endif
   Triple Triple = getNormalizedDefaultTargetTriple();
   if (!isConfigurationSupported(Triple))
 GTEST_SKIP();
Index: llvm/test/lit.cfg.py
===
--- llvm/test/lit.cfg.py
+++ llvm/test/lit.cfg.py
@@ -405,3 +405,22 @@
 
 if "MemoryWithOrigins" in config.llvm_use_sanitizer:
 config.available_features.add('use_msan_with_origins')
+
+def exclude_unsupported_files_for_aix(dirname):
+   for filename in os.listdir(dirname):
+   source_path = os.path.join( dirname, filename)
+   if os.path.isdir(source_path):
+   continue
+   f = open(source_path, 'r')
+   try:
+  data = f.read()
+  # 64-bit object files are not supported on AIX, so exclude the tests.
+  if ('-emit-obj' in data or '-filetype=obj' in data) and '64' in config.target_triple:
+config.excludes += [ filename ]
+   finally:
+  f.close()
+
+if 'aix' in config.target_triple:
+for directory in ('/CodeGen/X86', '/DebugInfo', '/DebugInfo/X86', '/DebugInfo/Generic', '/LTO/X86', '/Linker'):
+exclude_unsupported_files_for_aix(config.test_source_root + directory)
+
Index: llvm/test/LTO/X86/remangle_intrinsics.ll
===
--- llvm/test/LTO/X86/remangle_intrinsics.ll
+++ llvm/test/LTO/X86/remangle_intrinsics.ll
@@ -1,3 +1,4 @@
+; UNSUPPORTED: powerpc64-ibm-aix
 ; RUN: llvm-as < %s > %t1
 ; RUN: llvm-as < %p/Inputs/remangle_intrinsics.ll > %t2
 ; RUN: llvm-lto %t1 %t2 | FileCheck %s
Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -243,3 +243,24 @@
 # Add a vendor-specific feature.
 if config.clang_vendor_uti:
   

[clang] fbf52ca - [AIX] Disable tests that fail because of no 64-bit XCOFF object file support

2022-01-09 Thread Jake Egan via cfe-commits

Author: Jake Egan
Date: 2022-01-09T12:25:24-05:00
New Revision: fbf52caf58b3270c84e1cd3f399345272cca09a1

URL: 
https://github.com/llvm/llvm-project/commit/fbf52caf58b3270c84e1cd3f399345272cca09a1
DIFF: 
https://github.com/llvm/llvm-project/commit/fbf52caf58b3270c84e1cd3f399345272cca09a1.diff

LOG: [AIX] Disable tests that fail because of no 64-bit XCOFF object file 
support

The modified tests fail because 64-bit XCOFF object files are not currently 
supported on AIX. This patch disables these tests on 64-bit AIX for now.

This patch is similar to D111887 except the failures on this patch are on a 
64-bit build.

Reviewed By: shchenz, #powerpc

Differential Revision: https://reviews.llvm.org/D113049

Added: 


Modified: 
clang/test/ASTMerge/codegen-body/test.c
clang/test/ClangScanDeps/modules-full-by-mod-name.cpp
clang/test/ClangScanDeps/resource_directory.c
clang/test/lit.cfg.py
llvm/test/LTO/X86/remangle_intrinsics.ll
llvm/test/lit.cfg.py
llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp

Removed: 




diff  --git a/clang/test/ASTMerge/codegen-body/test.c 
b/clang/test/ASTMerge/codegen-body/test.c
index 7232bf4164b58..fc5553facbd95 100644
--- a/clang/test/ASTMerge/codegen-body/test.c
+++ b/clang/test/ASTMerge/codegen-body/test.c
@@ -1,5 +1,5 @@
+// UNSUPPORTED: powerpc64-ibm-aix
 // RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/body1.c
 // RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/body2.c
 // RUN: %clang_cc1 -emit-obj -o /dev/null -ast-merge %t.1.ast -ast-merge 
%t.2.ast %s
 // expected-no-diagnostics
-

diff  --git a/clang/test/ClangScanDeps/modules-full-by-mod-name.cpp 
b/clang/test/ClangScanDeps/modules-full-by-mod-name.cpp
index cecc76840e1d5..e8a067a974d81 100644
--- a/clang/test/ClangScanDeps/modules-full-by-mod-name.cpp
+++ b/clang/test/ClangScanDeps/modules-full-by-mod-name.cpp
@@ -1,3 +1,4 @@
+// UNSUPPORTED: powerpc64-ibm-aix
 // RUN: rm -rf %t.dir
 // RUN: rm -rf %t.cdb
 // RUN: mkdir -p %t.dir

diff  --git a/clang/test/ClangScanDeps/resource_directory.c 
b/clang/test/ClangScanDeps/resource_directory.c
index 55d5d90bbcdea..b9e9d219541ba 100644
--- a/clang/test/ClangScanDeps/resource_directory.c
+++ b/clang/test/ClangScanDeps/resource_directory.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: powerpc64-ibm-aix
 // REQUIRES: shell
 
 // RUN: rm -rf %t && mkdir %t

diff  --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index a1a3bf6ee626d..a8efe6c593e98 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -243,3 +243,24 @@ def calculate_arch_features(arch_string):
 # Add a vendor-specific feature.
 if config.clang_vendor_uti:
 config.available_features.add('clang-vendor=' + config.clang_vendor_uti)
+
+def exclude_unsupported_files_for_aix(dirname):
+for filename in os.listdir(dirname):
+source_path = os.path.join( dirname, filename)
+if os.path.isdir(source_path):
+continue
+f = open(source_path, 'r', encoding='ISO-8859-1')
+try:
+   data = f.read()
+   # 64-bit object files are not supported on AIX, so exclude the 
tests.
+   if (any(option in data for option in ('-emit-obj', 
'-fmodule-format=obj', '-fintegrated-as')) and
+  '64' in config.target_triple):
+   config.excludes += [ filename ]
+finally:
+   f.close()
+
+if 'aix' in config.target_triple:
+for directory in ('/CodeGenCXX', '/Misc', '/Modules', '/PCH', '/Driver',
+  '/ASTMerge/anonymous-fields', 
'/ASTMerge/injected-class-name-decl'):
+exclude_unsupported_files_for_aix(config.test_source_root + directory)
+

diff  --git a/llvm/test/LTO/X86/remangle_intrinsics.ll 
b/llvm/test/LTO/X86/remangle_intrinsics.ll
index 112cace0403b9..523e78e5d30d9 100644
--- a/llvm/test/LTO/X86/remangle_intrinsics.ll
+++ b/llvm/test/LTO/X86/remangle_intrinsics.ll
@@ -1,3 +1,4 @@
+; UNSUPPORTED: powerpc64-ibm-aix
 ; RUN: llvm-as < %s > %t1
 ; RUN: llvm-as < %p/Inputs/remangle_intrinsics.ll > %t2
 ; RUN: llvm-lto %t1 %t2 | FileCheck %s

diff  --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index 0753b0483ef9c..9b80726df5c4a 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -405,3 +405,22 @@ def have_ld64_plugin_support():
 
 if "MemoryWithOrigins" in config.llvm_use_sanitizer:
 config.available_features.add('use_msan_with_origins')
+
+def exclude_unsupported_files_for_aix(dirname):
+   for filename in os.listdir(dirname):
+   source_path = os.path.join( dirname, filename)
+   if os.path.isdir(source_path):
+   continue
+   f = open(source_path, 'r')
+   try:
+  data = f.read()
+  # 64-bit object files are not supported on AIX, so exclude the tests.
+  if ('-emit-obj' in data or '-filetype=obj' in data) and '64' in 
config.target_triple:
+config.excludes += [ filename ]
+   finally:
+  

[PATCH] D114823: Filter string_view from the nullptr diagnosis of bugprone-string-constructor to prevent duplicate warnings with bugprone-stringview-nullptr

2022-01-09 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

I'm in 2 minds about this. This diagnostic is a good fit for this warning and 
shouldn't be removed. Likewise duplicate diagnostics from different checks is 
annoying. Maybe a better path forward would be to suppress the diagnostic if 
the `bugprone-stringview-nullptr` check is enabled. These kinds of intercheck 
dependencies are found in modernize-prefer-member-init check IIRC. You can just 
copy the impl from there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114823

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


[PATCH] D116875: [clang-tidy] Add performance-inefficient-array-traversal check

2022-01-09 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/performance/InefficientArrayTraversalCheck.cpp:63
+hasLHS(ToDecl),
+hasRHS(integerLiteral(equals(1)),
+ hasBody(BodyMatcher))

njames93 wrote:
> Thoughts on this, prefetchers are often able to detect strided access so is 
> forcing increment to be `1` removing potential functionality.
Theoretically  index changes may be other than 1. For example, in some 
electronic simulation each block/device store matrix indexes to contribute (but 
sparse, not dense, matrix is used). It'll be good idea to look on BLAS and 
LAPACK (through both are written in Fortran).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116875

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


[PATCH] D116316: [clang-format] Add an experimental option to remove optional control statement braces in LLVM C++ code

2022-01-09 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 398419.
owenpan added a comment.

Fixed a bug and added a test case.


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

https://reviews.llvm.org/D116316

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -18776,6 +18776,7 @@
   CHECK_PARSE_BOOL(ObjCSpaceBeforeProtocolList);
   CHECK_PARSE_BOOL(Cpp11BracedListStyle);
   CHECK_PARSE_BOOL(ReflowComments);
+  CHECK_PARSE_BOOL(RemoveBracesLLVM);
   CHECK_PARSE_BOOL(SortUsingDeclarations);
   CHECK_PARSE_BOOL(SpacesInParentheses);
   CHECK_PARSE_BOOL(SpacesInSquareBrackets);
@@ -23212,6 +23213,354 @@
Style);
 }
 
+TEST_F(FormatTest, RemoveBraces) {
+  FormatStyle Style = getLLVMStyle();
+  Style.RemoveBracesLLVM = true;
+
+  // The following eight test cases are fully-braced versions of the examples at
+  // "llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-
+  // statement-bodies-of-if-else-loop-statements".
+
+  // 1. Omit the braces, since the body is simple and clearly associated with
+  // the if.
+  verifyFormat("if (isa(D))\n"
+   "  handleFunctionDecl(D);\n"
+   "else if (isa(D))\n"
+   "  handleVarDecl(D);",
+   "if (isa(D)) {\n"
+   "  handleFunctionDecl(D);\n"
+   "} else if (isa(D)) {\n"
+   "  handleVarDecl(D);\n"
+   "}",
+   Style);
+
+  // 2. Here we document the condition itself and not the body.
+  verifyFormat("if (isa(D)) {\n"
+   "  // It is necessary that we explain the situation with this\n"
+   "  // surprisingly long comment, so it would be unclear\n"
+   "  // without the braces whether the following statement is in\n"
+   "  // the scope of the `if`.\n"
+   "  // Because the condition is documented, we can't really\n"
+   "  // hoist this comment that applies to the body above the\n"
+   "  // if.\n"
+   "  handleOtherDecl(D);\n"
+   "}",
+   Style);
+
+  // 3. Use braces on the outer `if` to avoid a potential dangling else
+  // situation.
+  verifyFormat("if (isa(D)) {\n"
+   "  for (auto *A : D.attrs())\n"
+   "if (shouldProcessAttr(A))\n"
+   "  handleAttr(A);\n"
+   "}",
+   "if (isa(D)) {\n"
+   "  for (auto *A : D.attrs()) {\n"
+   "if (shouldProcessAttr(A)) {\n"
+   "  handleAttr(A);\n"
+   "}\n"
+   "  }\n"
+   "}",
+   Style);
+
+  // 4. Use braces for the `if` block to keep it uniform with the else block.
+  verifyFormat("if (isa(D)) {\n"
+   "  handleFunctionDecl(D);\n"
+   "} else {\n"
+   "  // In this else case, it is necessary that we explain the\n"
+   "  // situation with this surprisingly long comment, so it\n"
+   "  // would be unclear without the braces whether the\n"
+   "  // following statement is in the scope of the `if`.\n"
+   "  handleOtherDecl(D);\n"
+   "}",
+   Style);
+
+  // 5. This should also omit braces.  The `for` loop contains only a single
+  // statement, so it shouldn't have braces.  The `if` also only contains a
+  // single simple statement (the for loop), so it also should omit braces.
+  verifyFormat("if (isa(D))\n"
+   "  for (auto *A : D.attrs())\n"
+   "handleAttr(A);",
+   "if (isa(D)) {\n"
+   "  for (auto *A : D.attrs()) {\n"
+   "handleAttr(A);\n"
+   "  }\n"
+   "}",
+   Style);
+
+  // 6. Use braces for the outer `if` since the nested `for` is braced.
+  verifyFormat("if (isa(D)) {\n"
+   "  for (auto *A : D.attrs()) {\n"
+   "// In this for loop body, it is necessary that we explain\n"
+   "// the situation with this surprisingly long comment,\n"
+   "// forcing braces on the `for` block.\n"
+   "handleAttr(A);\n"
+   "  }\n"
+   "}",
+   Style);
+
+  // 7. Use braces on the outer block because there are more than two levels of
+  // nesting.
+  verifyFormat("if (isa(D)) {\n"
+   "  for (auto *A : D.attrs())\n"
+   "for (ssize_t i : llvm::seq(count))\n"
+   "  

[PATCH] D99517: Implemented [[clang::musttail]] attribute for guaranteed tail calls.

2022-01-09 Thread Paweł Bylica via Phabricator via cfe-commits
chfast added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:5320
+  if (!(Cleanup && Cleanup->getCleanup()->isRedundantBeforeReturn()))
+CGM.ErrorUnsupported(MustTailCall, "tail call skipping over cleanups");
+}

I reported a related issue. I wander if this is easy to fix. 
https://github.com/llvm/llvm-project/issues/53087.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99517

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


[PATCH] D116316: [clang-format] Add an experimental option to remove optional control statement braces in LLVM C++ code

2022-01-09 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 398415.
owenpan added a comment.

- Braces should not be removed if the single-statement block might wrap or is 
already wrapped.
- Added test cases.
- Did a final round of cleanup.


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

https://reviews.llvm.org/D116316

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -18776,6 +18776,7 @@
   CHECK_PARSE_BOOL(ObjCSpaceBeforeProtocolList);
   CHECK_PARSE_BOOL(Cpp11BracedListStyle);
   CHECK_PARSE_BOOL(ReflowComments);
+  CHECK_PARSE_BOOL(RemoveBracesLLVM);
   CHECK_PARSE_BOOL(SortUsingDeclarations);
   CHECK_PARSE_BOOL(SpacesInParentheses);
   CHECK_PARSE_BOOL(SpacesInSquareBrackets);
@@ -23212,6 +23213,343 @@
Style);
 }
 
+TEST_F(FormatTest, RemoveBraces) {
+  FormatStyle Style = getLLVMStyle();
+  Style.RemoveBracesLLVM = true;
+
+  // The following eight test cases are fully-braced versions of the examples at
+  // "llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-
+  // statement-bodies-of-if-else-loop-statements".
+
+  // 1. Omit the braces, since the body is simple and clearly associated with
+  // the if.
+  verifyFormat("if (isa(D))\n"
+   "  handleFunctionDecl(D);\n"
+   "else if (isa(D))\n"
+   "  handleVarDecl(D);",
+   "if (isa(D)) {\n"
+   "  handleFunctionDecl(D);\n"
+   "} else if (isa(D)) {\n"
+   "  handleVarDecl(D);\n"
+   "}",
+   Style);
+
+  // 2. Here we document the condition itself and not the body.
+  verifyFormat("if (isa(D)) {\n"
+   "  // It is necessary that we explain the situation with this\n"
+   "  // surprisingly long comment, so it would be unclear\n"
+   "  // without the braces whether the following statement is in\n"
+   "  // the scope of the `if`.\n"
+   "  // Because the condition is documented, we can't really\n"
+   "  // hoist this comment that applies to the body above the\n"
+   "  // if.\n"
+   "  handleOtherDecl(D);\n"
+   "}",
+   Style);
+
+  // 3. Use braces on the outer `if` to avoid a potential dangling else
+  // situation.
+  verifyFormat("if (isa(D)) {\n"
+   "  for (auto *A : D.attrs())\n"
+   "if (shouldProcessAttr(A))\n"
+   "  handleAttr(A);\n"
+   "}",
+   "if (isa(D)) {\n"
+   "  for (auto *A : D.attrs()) {\n"
+   "if (shouldProcessAttr(A)) {\n"
+   "  handleAttr(A);\n"
+   "}\n"
+   "  }\n"
+   "}",
+   Style);
+
+  // 4. Use braces for the `if` block to keep it uniform with the else block.
+  verifyFormat("if (isa(D)) {\n"
+   "  handleFunctionDecl(D);\n"
+   "} else {\n"
+   "  // In this else case, it is necessary that we explain the\n"
+   "  // situation with this surprisingly long comment, so it\n"
+   "  // would be unclear without the braces whether the\n"
+   "  // following statement is in the scope of the `if`.\n"
+   "  handleOtherDecl(D);\n"
+   "}",
+   Style);
+
+  // 5. This should also omit braces.  The `for` loop contains only a single
+  // statement, so it shouldn't have braces.  The `if` also only contains a
+  // single simple statement (the for loop), so it also should omit braces.
+  verifyFormat("if (isa(D))\n"
+   "  for (auto *A : D.attrs())\n"
+   "handleAttr(A);",
+   "if (isa(D)) {\n"
+   "  for (auto *A : D.attrs()) {\n"
+   "handleAttr(A);\n"
+   "  }\n"
+   "}",
+   Style);
+
+  // 6. Use braces for the outer `if` since the nested `for` is braced.
+  verifyFormat("if (isa(D)) {\n"
+   "  for (auto *A : D.attrs()) {\n"
+   "// In this for loop body, it is necessary that we explain\n"
+   "// the situation with this surprisingly long comment,\n"
+   "// forcing braces on the `for` block.\n"
+   "handleAttr(A);\n"
+   "  }\n"
+   "}",
+   Style);
+
+  // 7. Use braces on the outer block because there are more than two levels of
+  // nesting.
+  verifyFormat("if (isa(D)) {\n"
+   "  

[PATCH] D116478: [clang-tidy] A comma-separated list of the names of functions or methods to be considered as not having side-effects

2022-01-09 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis updated this revision to Diff 398410.

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

https://reviews.llvm.org/D116478

Files:
  clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-assert-side-effect.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-assert-side-effect.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-assert-side-effect.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-assert-side-effect.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-assert-side-effect.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s bugprone-assert-side-effect %t -- -config="{CheckOptions: [{key: bugprone-assert-side-effect.CheckFunctionCalls, value: true}, {key: bugprone-assert-side-effect.AssertMacros, value: 'assert,assert2,my_assert,convoluted_assert,msvc_assert'}]}" -- -fexceptions
+// RUN: %check_clang_tidy %s bugprone-assert-side-effect %t -- -config="{CheckOptions: [{key: bugprone-assert-side-effect.CheckFunctionCalls, value: true}, {key: bugprone-assert-side-effect.AssertMacros, value: 'assert,assert2,my_assert,convoluted_assert,msvc_assert'}, {key: bugprone-assert-side-effect.IgnoredFunctions, value: 'badButIgnoredFunc'}]}" -- -fexceptions
 
 //===--- assert definition block --===//
 int abort() { return 0; }
@@ -46,6 +46,7 @@
 class MyClass {
 public:
   bool badFunc(int a, int b) { return a * b > 0; }
+  bool badButIgnoredFunc(int a, int b) { return a * b > 0; }
   bool goodFunc(int a, int b) const { return a * b > 0; }
 
   MyClass =(const MyClass ) { return *this; }
@@ -87,6 +88,7 @@
   MyClass mc;
   assert(mc.badFunc(0, 1));
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: side effect in assert() condition discarded in release builds
+  assert(mc.badButIgnoredFunc(0, 1));
   assert(mc.goodFunc(0, 1));
 
   MyClass mc2;
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-assert-side-effect.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone-assert-side-effect.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-assert-side-effect.rst
@@ -21,3 +21,8 @@
Whether to treat non-const member and non-member functions as they produce
side effects. Disabled by default because it can increase the number of false
positive warnings.
+
+.. option:: IgnoredFunctions
+
+   A comma-separated list of the names of functions or methods to be
+   considered as not having side-effects.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -145,7 +145,12 @@
 Changes in existing checks
 ^^
 
+- :doc:`bugprone-assert-side-effect `
+  check now supports a ``IgnoredFunctions`` option to explicitly consider the specified
+  functions or methods as not any having side-effects.
+
 - Removed default setting ``cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors = "true"``,
+  from :doc:`cppcoreguidelines-explicit-virtual-functions `
   to match the current state of the C++ Core Guidelines.
 
 - Updated :doc:`google-readability-casting
@@ -157,10 +162,10 @@
 
 - Fixed a false positive in :doc:`bugprone-throw-keyword-missing
   ` when creating an exception object
-  using placement new
+  using placement new.
 
 - :doc:`cppcoreguidelines-narrowing-conversions `
-  check now supports a `WarnOnIntegerToFloatingPointNarrowingConversion`
+  check now supports a ``WarnOnIntegerToFloatingPointNarrowingConversion``
   option to control whether to warn on narrowing integer to floating-point
   conversions.
 
Index: clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.h
===
--- clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.h
+++ clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.h
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_ASSERTSIDEEFFECTCHECK_H
 
 #include "../ClangTidyCheck.h"
+#include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include 
@@ -33,6 +34,7 @@
 /// can increase the number of false positive warnings.
 class AssertSideEffectCheck : public ClangTidyCheck {
 public:
+  using IgnoredFunctionType = llvm::SmallSet;
   AssertSideEffectCheck(StringRef Name, ClangTidyContext *Context);
   void storeOptions(ClangTidyOptions::OptionMap ) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
@@ -41,7 +43,9 @@
 private:
   const bool CheckFunctionCalls;
   const std::string RawAssertList;
+  const std::string 

[PATCH] D116478: [clang-tidy] A comma-separated list of the names of functions or methods to be considered as not having side-effects

2022-01-09 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis updated this revision to Diff 398409.
zinovy.nis marked 5 inline comments as done.

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

https://reviews.llvm.org/D116478

Files:
  clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-assert-side-effect.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-assert-side-effect.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-assert-side-effect.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-assert-side-effect.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-assert-side-effect.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s bugprone-assert-side-effect %t -- -config="{CheckOptions: [{key: bugprone-assert-side-effect.CheckFunctionCalls, value: true}, {key: bugprone-assert-side-effect.AssertMacros, value: 'assert,assert2,my_assert,convoluted_assert,msvc_assert'}]}" -- -fexceptions
+// RUN: %check_clang_tidy %s bugprone-assert-side-effect %t -- -config="{CheckOptions: [{key: bugprone-assert-side-effect.CheckFunctionCalls, value: true}, {key: bugprone-assert-side-effect.AssertMacros, value: 'assert,assert2,my_assert,convoluted_assert,msvc_assert'}, {key: bugprone-assert-side-effect.IgnoredFunctions, value: 'badButIgnoredFunc'}]}" -- -fexceptions
 
 //===--- assert definition block --===//
 int abort() { return 0; }
@@ -46,6 +46,7 @@
 class MyClass {
 public:
   bool badFunc(int a, int b) { return a * b > 0; }
+  bool badButIgnoredFunc(int a, int b) { return a * b > 0; }
   bool goodFunc(int a, int b) const { return a * b > 0; }
 
   MyClass =(const MyClass ) { return *this; }
@@ -87,6 +88,7 @@
   MyClass mc;
   assert(mc.badFunc(0, 1));
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: side effect in assert() condition discarded in release builds
+  assert(mc.badButIgnoredFunc(0, 1));
   assert(mc.goodFunc(0, 1));
 
   MyClass mc2;
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-assert-side-effect.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone-assert-side-effect.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-assert-side-effect.rst
@@ -21,3 +21,8 @@
Whether to treat non-const member and non-member functions as they produce
side effects. Disabled by default because it can increase the number of false
positive warnings.
+
+.. option:: IgnoredFunctions
+
+   A comma-separated list of the names of functions or methods to be
+   considered as not having side-effects.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -145,7 +145,12 @@
 Changes in existing checks
 ^^
 
+- :doc:`bugprone-assert-side-effect `
+  check now supports a ``IgnoredFunctions`` option to explicitly consider the specified
+  functions or methods as not any having side-effects.
+
 - Removed default setting ``cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors = "true"``,
+  from :doc:`cppcoreguidelines-explicit-virtual-functions `
   to match the current state of the C++ Core Guidelines.
 
 - Updated :doc:`google-readability-casting
@@ -157,10 +162,10 @@
 
 - Fixed a false positive in :doc:`bugprone-throw-keyword-missing
   ` when creating an exception object
-  using placement new
+  using placement new.
 
 - :doc:`cppcoreguidelines-narrowing-conversions `
-  check now supports a `WarnOnIntegerToFloatingPointNarrowingConversion`
+  check now supports a ``WarnOnIntegerToFloatingPointNarrowingConversion``
   option to control whether to warn on narrowing integer to floating-point
   conversions.
 
Index: clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.h
===
--- clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.h
+++ clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.h
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_ASSERTSIDEEFFECTCHECK_H
 
 #include "../ClangTidyCheck.h"
+#include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include 
@@ -33,6 +34,7 @@
 /// can increase the number of false positive warnings.
 class AssertSideEffectCheck : public ClangTidyCheck {
 public:
+  using IgnoredFunctionType = llvm::SmallSet;
   AssertSideEffectCheck(StringRef Name, ClangTidyContext *Context);
   void storeOptions(ClangTidyOptions::OptionMap ) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
@@ -41,7 +43,9 @@
 private:
   const bool CheckFunctionCalls;
   const std::string 

[PATCH] D116478: [clang-tidy] A comma-separated list of the names of functions or methods to be considered as not having side-effects

2022-01-09 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis updated this revision to Diff 398408.
zinovy.nis added a comment.

- ``FunctionException`` -> ``IgnoredFunctions``
- Fixed double ticks in rst docs.


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

https://reviews.llvm.org/D116478

Files:
  clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-assert-side-effect.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-assert-side-effect.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-assert-side-effect.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-assert-side-effect.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-assert-side-effect.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s bugprone-assert-side-effect %t -- -config="{CheckOptions: [{key: bugprone-assert-side-effect.CheckFunctionCalls, value: true}, {key: bugprone-assert-side-effect.AssertMacros, value: 'assert,assert2,my_assert,convoluted_assert,msvc_assert'}]}" -- -fexceptions
+// RUN: %check_clang_tidy %s bugprone-assert-side-effect %t -- -config="{CheckOptions: [{key: bugprone-assert-side-effect.CheckFunctionCalls, value: true}, {key: bugprone-assert-side-effect.AssertMacros, value: 'assert,assert2,my_assert,convoluted_assert,msvc_assert'}, {key: bugprone-assert-side-effect.IgnoredFunctions, value: 'badButIgnoredFunc'}]}" -- -fexceptions
 
 //===--- assert definition block --===//
 int abort() { return 0; }
@@ -46,6 +46,7 @@
 class MyClass {
 public:
   bool badFunc(int a, int b) { return a * b > 0; }
+  bool badButIgnoredFunc(int a, int b) { return a * b > 0; }
   bool goodFunc(int a, int b) const { return a * b > 0; }
 
   MyClass =(const MyClass ) { return *this; }
@@ -87,6 +88,7 @@
   MyClass mc;
   assert(mc.badFunc(0, 1));
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: side effect in assert() condition discarded in release builds
+  assert(mc.badButIgnoredFunc(0, 1));
   assert(mc.goodFunc(0, 1));
 
   MyClass mc2;
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-assert-side-effect.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone-assert-side-effect.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-assert-side-effect.rst
@@ -21,3 +21,8 @@
Whether to treat non-const member and non-member functions as they produce
side effects. Disabled by default because it can increase the number of false
positive warnings.
+
+.. option:: FunctionExceptions
+
+   A comma-separated list of the names of functions or methods to be
+   considered as not having side-effects.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -145,7 +145,12 @@
 Changes in existing checks
 ^^
 
+- :doc:`bugprone-assert-side-effect `
+  check now supports a ``IgnoredFunctions`` option to explicitly consider the specified
+  functions or methods as not any having side-effects.
+
 - Removed default setting ``cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors = "true"``,
+  from :doc:`cppcoreguidelines-explicit-virtual-functions `
   to match the current state of the C++ Core Guidelines.
 
 - Updated :doc:`google-readability-casting
@@ -157,10 +162,10 @@
 
 - Fixed a false positive in :doc:`bugprone-throw-keyword-missing
   ` when creating an exception object
-  using placement new
+  using placement new.
 
 - :doc:`cppcoreguidelines-narrowing-conversions `
-  check now supports a `WarnOnIntegerToFloatingPointNarrowingConversion`
+  check now supports a ``WarnOnIntegerToFloatingPointNarrowingConversion``
   option to control whether to warn on narrowing integer to floating-point
   conversions.
 
Index: clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.h
===
--- clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.h
+++ clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.h
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_ASSERTSIDEEFFECTCHECK_H
 
 #include "../ClangTidyCheck.h"
+#include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include 
@@ -33,6 +34,7 @@
 /// can increase the number of false positive warnings.
 class AssertSideEffectCheck : public ClangTidyCheck {
 public:
+  using IgnoredFunctionType = llvm::SmallSet;
   AssertSideEffectCheck(StringRef Name, ClangTidyContext *Context);
   void storeOptions(ClangTidyOptions::OptionMap ) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
@@ -41,7 +43,9 @@
 

[PATCH] D116882: [docs] [clang] Small documentation change for compilation databases

2022-01-09 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

https://sarcasm.github.io/notes/dev/compilation-database.html#clang


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116882

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


[PATCH] D116875: [clang-tidy] Add performance-inefficient-array-traversal check

2022-01-09 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/performance/InefficientArrayTraversalCheck.cpp:63
+hasLHS(ToDecl),
+hasRHS(integerLiteral(equals(1)),
+ hasBody(BodyMatcher))

Thoughts on this, prefetchers are often able to detect strided access so is 
forcing increment to be `1` removing potential functionality.



Comment at: 
clang-tools-extra/clang-tidy/performance/InefficientArrayTraversalCheck.cpp:91
+  diag(Array->getBeginLoc(),
+   "Nonsequential array traversal can harm performance");
+  diag(InnerLoopStmt->getBeginLoc(), "Row index %0 incremented in this loop",

Any ideas on a nicer way to say this? I feel like this message isn't as 
descriptive as I'd like, and non-native English speakers could struggle to 
understand it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116875

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


[PATCH] D116875: [clang-tidy] Add performance-inefficient-array-traversal check

2022-01-09 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 398404.
njames93 marked 4 inline comments as done.
njames93 added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116875

Files:
  clang-tools-extra/clang-tidy/performance/CMakeLists.txt
  clang-tools-extra/clang-tidy/performance/InefficientArrayTraversalCheck.cpp
  clang-tools-extra/clang-tidy/performance/InefficientArrayTraversalCheck.h
  clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/performance-inefficient-array-traversal.rst
  
clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-array-traversal.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-array-traversal.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-array-traversal.cpp
@@ -0,0 +1,84 @@
+// RUN: %check_clang_tidy %s performance-inefficient-array-traversal %t
+
+constexpr unsigned Rows = 10U;
+constexpr unsigned Cols = 16U;
+
+int Arr[Rows][Cols];
+int *PtrArr[Cols];
+int **Ptr;
+
+void foo();
+
+void warned() {
+  for (unsigned I = 0; I < Cols; ++I) {
+for (unsigned J = 0; J < Rows; ++J) {
+  Arr[J][I]++;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: Nonsequential array traversal can harm performance
+  // CHECK-MESSAGES: :[[@LINE-3]]:5: note: Row index 'J' incremented in this loop
+  // CHECK-MESSAGES: :[[@LINE-5]]:3: note: Column index 'I' incremented in this loop
+}
+  }
+  for (unsigned I = 0; I < Cols; ++I)
+for (unsigned J = 0; J < Rows; ++J)
+  Arr[J][I]++;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: Nonsequential array traversal can harm performance
+
+  // Ensure it works on array access that use pointers
+  for (unsigned I = 0; I < Cols; ++I)
+for (unsigned J = 0; J < Rows; ++J)
+  PtrArr[J][I]++;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: Nonsequential array traversal can harm performance
+
+  for (unsigned I = 0; I < Cols; ++I)
+for (unsigned J = 0; J < Rows; ++J)
+  Ptr[J][I]++;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: Nonsequential array traversal can harm performance
+
+  // Detect += 1 as the loop incriment
+  for (unsigned I = 0; I < Cols; I += 1)
+for (unsigned J = 0; J < Rows; J += 1)
+  Arr[J][I]++;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: Nonsequential array traversal can harm performance
+
+  // Still warn on this as calls inside the inner loop shouldn't complicate a fix.
+  for (unsigned I = 0; I < Cols; ++I) {
+for (unsigned J = 0; J < Rows; ++J) {
+  foo();
+  Arr[J][I]++;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: Nonsequential array traversal can harm performance
+  foo();
+}
+  }
+}
+
+void ignored() {
+  // Correct traversal.
+  for (unsigned I = 0; I < Rows; ++I) {
+for (unsigned J = 0; J < Cols; ++J) {
+  Arr[I][J]++;
+}
+  }
+  for (unsigned I = 0; I < Rows; ++I) {
+for (unsigned J = 0; J < Cols; ++J) {
+  PtrArr[I][J]++;
+}
+  }
+  // Don'w warn on these cases as extra code inside the outer loop could complicate a fix.
+  for (unsigned I = 0; I < Cols; ++I) {
+foo();
+for (unsigned J = 0; J < Rows; ++J) {
+  Arr[J][I]++;
+}
+  }
+  for (unsigned I = 0; I < Cols; ++I) {
+for (unsigned J = 0; J < Rows; ++J) {
+  Arr[J][I]++;
+}
+foo();
+  }
+
+  // Nested loop increments incorrect variable, don't warn on the traversal.
+  for (unsigned I = 0; I < Cols; ++I)
+for (unsigned J = 0; J < Rows; ++I)
+  Arr[J][I]++;
+}
Index: clang-tools-extra/docs/clang-tidy/checks/performance-inefficient-array-traversal.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/performance-inefficient-array-traversal.rst
@@ -0,0 +1,24 @@
+.. title:: clang-tidy - performance-inefficient-array-traversal
+
+performance-inefficient-array-traversal
+===
+
+Detects nested ``for`` loops used to traverse a 2D array where the row index
+is iterated on the inner loop.
+
+.. code-block:: c++
+
+   for (int X = 0; X < Columns; ++X)
+ for (int Y = 0; Y < Rows; ++Y)
+   Array[Y][X]++;
+
+This array access pattern results in nonsequential data access which is cache 
+unfriendly and can prevent auto vectorization optimizations.
+
+A much faster version of the above loop would be
+
+.. code-block:: c++
+
+   for (int Y = 0; Y < Rows; ++Y)
+ for (int X = 0; X < Columns; ++X)
+   Array[Y][X]++;
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ 

[PATCH] D116882: [docs] [clang] Small documentation change for compilation databases

2022-01-09 Thread Dave Butler via Phabricator via cfe-commits
croepha created this revision.
croepha requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We have an page dedicated to compliation databases including
various ways to generate them, but we don't mention that clang
has a built in method to do this.  This addresses that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116882

Files:
  clang/docs/JSONCompilationDatabase.rst


Index: clang/docs/JSONCompilationDatabase.rst
===
--- clang/docs/JSONCompilationDatabase.rst
+++ clang/docs/JSONCompilationDatabase.rst
@@ -29,6 +29,10 @@
 Supported Systems
 =
 
+Clang has the ablity to generate compilation database fragments via
+the :option:`-MJ argument >`. You can contantinate those
+fragments together between ``[`` and ``]`` to create a compilation database.
+
 Currently `CMake `_ (since 2.8.5) supports generation
 of compilation databases for Unix Makefile builds (Ninja builds in the
 works) with the option ``CMAKE_EXPORT_COMPILE_COMMANDS``.


Index: clang/docs/JSONCompilationDatabase.rst
===
--- clang/docs/JSONCompilationDatabase.rst
+++ clang/docs/JSONCompilationDatabase.rst
@@ -29,6 +29,10 @@
 Supported Systems
 =
 
+Clang has the ablity to generate compilation database fragments via
+the :option:`-MJ argument >`. You can contantinate those
+fragments together between ``[`` and ``]`` to create a compilation database.
+
 Currently `CMake `_ (since 2.8.5) supports generation
 of compilation databases for Unix Makefile builds (Ninja builds in the
 works) with the option ``CMAKE_EXPORT_COMPILE_COMMANDS``.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 80e2c58 - [clang] Remove redundant member initialization (NFC)

2022-01-09 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-01-09T00:19:51-08:00
New Revision: 80e2c587498a7b2bf14dde47a33a058da6e88a9a

URL: 
https://github.com/llvm/llvm-project/commit/80e2c587498a7b2bf14dde47a33a058da6e88a9a
DIFF: 
https://github.com/llvm/llvm-project/commit/80e2c587498a7b2bf14dde47a33a058da6e88a9a.diff

LOG: [clang] Remove redundant member initialization (NFC)

Identified with readability-redundant-member-init.

Added: 


Modified: 
clang/include/clang/AST/ASTConcept.h
clang/include/clang/ASTMatchers/Dynamic/Diagnostics.h
clang/include/clang/Basic/Diagnostic.h
clang/include/clang/Basic/PartialDiagnostic.h
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/ParsedAttr.h
clang/include/clang/Sema/ParsedTemplate.h
clang/lib/AST/MicrosoftCXXABI.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/utils/TableGen/MveEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTConcept.h 
b/clang/include/clang/AST/ASTConcept.h
index c9930844add80..c8a1dc83b8aae 100644
--- a/clang/include/clang/AST/ASTConcept.h
+++ b/clang/include/clang/AST/ASTConcept.h
@@ -132,8 +132,7 @@ class ConceptReference {
 NamedConcept(NamedConcept), ArgsAsWritten(ArgsAsWritten) {}
 
   ConceptReference()
-  : TemplateKWLoc(), FoundDecl(nullptr), NamedConcept(nullptr),
-ArgsAsWritten(nullptr) {}
+  : FoundDecl(nullptr), NamedConcept(nullptr), ArgsAsWritten(nullptr) {}
 
   const NestedNameSpecifierLoc () const {
 return NestedNameSpec;

diff  --git a/clang/include/clang/ASTMatchers/Dynamic/Diagnostics.h 
b/clang/include/clang/ASTMatchers/Dynamic/Diagnostics.h
index 25eb38e6435e0..3f6f364d65052 100644
--- a/clang/include/clang/ASTMatchers/Dynamic/Diagnostics.h
+++ b/clang/include/clang/ASTMatchers/Dynamic/Diagnostics.h
@@ -40,7 +40,7 @@ struct SourceRange {
 
 /// A VariantValue instance annotated with its parser context.
 struct ParserValue {
-  ParserValue() : Range() {}
+  ParserValue() {}
   StringRef Text;
   SourceRange Range;
   VariantValue Value;

diff  --git a/clang/include/clang/Basic/Diagnostic.h 
b/clang/include/clang/Basic/Diagnostic.h
index e5577e74fa639..6a80823d12422 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -1326,7 +1326,7 @@ class DiagnosticBuilder : public StreamingDiagnostic {
 public:
   /// Copy constructor.  When copied, this "takes" the diagnostic info from the
   /// input and neuters it.
-  DiagnosticBuilder(const DiagnosticBuilder ) : StreamingDiagnostic() {
+  DiagnosticBuilder(const DiagnosticBuilder ) {
 DiagObj = D.DiagObj;
 DiagStorage = D.DiagStorage;
 IsActive = D.IsActive;

diff  --git a/clang/include/clang/Basic/PartialDiagnostic.h 
b/clang/include/clang/Basic/PartialDiagnostic.h
index 9fb70bff7fee1..217441979869b 100644
--- a/clang/include/clang/Basic/PartialDiagnostic.h
+++ b/clang/include/clang/Basic/PartialDiagnostic.h
@@ -49,8 +49,7 @@ class PartialDiagnostic : public StreamingDiagnostic {
   PartialDiagnostic(unsigned DiagID, DiagStorageAllocator _)
   : StreamingDiagnostic(Allocator_), DiagID(DiagID) {}
 
-  PartialDiagnostic(const PartialDiagnostic )
-  : StreamingDiagnostic(), DiagID(Other.DiagID) {
+  PartialDiagnostic(const PartialDiagnostic ) : DiagID(Other.DiagID) {
 Allocator = Other.Allocator;
 if (Other.DiagStorage) {
   DiagStorage = getStorage();

diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index fd2221f030861..d266a0b37265c 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -1475,8 +1475,7 @@ class Parser : public CodeCompletionHandler {
   /// information that has been parsed prior to parsing declaration
   /// specifiers.
   struct ParsedTemplateInfo {
-ParsedTemplateInfo()
-  : Kind(NonTemplate), TemplateParams(nullptr), TemplateLoc() { }
+ParsedTemplateInfo() : Kind(NonTemplate), TemplateParams(nullptr) {}
 
 ParsedTemplateInfo(TemplateParameterLists *TemplateParams,
bool isSpecialization,

diff  --git a/clang/include/clang/Sema/ParsedAttr.h 
b/clang/include/clang/Sema/ParsedAttr.h
index 657cf9253c77c..4fa6f09d3321f 100644
--- a/clang/include/clang/Sema/ParsedAttr.h
+++ b/clang/include/clang/Sema/ParsedAttr.h
@@ -1080,7 +1080,7 @@ struct ParsedAttributesWithRange : ParsedAttributes {
   SourceRange Range;
 };
 struct ParsedAttributesViewWithRange : ParsedAttributesView {
-  ParsedAttributesViewWithRange() : ParsedAttributesView() {}
+  ParsedAttributesViewWithRange() {}
   void clearListOnly() {
 ParsedAttributesView::clearListOnly();
 Range = SourceRange();

diff  --git a/clang/include/clang/Sema/ParsedTemplate.h 
b/clang/include/clang/Sema/ParsedTemplate.h
index f0245b93c7eb2..72f91d0aa41a0 100644
--- a/clang/include/clang/Sema/ParsedTemplate.h
+++ 

[clang] 17d4bd3 - [clang] Fix bugprone argument comments (NFC)

2022-01-09 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-01-09T00:19:49-08:00
New Revision: 17d4bd3d788e53f7990d42b3e5d97d178ace9341

URL: 
https://github.com/llvm/llvm-project/commit/17d4bd3d788e53f7990d42b3e5d97d178ace9341
DIFF: 
https://github.com/llvm/llvm-project/commit/17d4bd3d788e53f7990d42b3e5d97d178ace9341.diff

LOG: [clang] Fix bugprone argument comments (NFC)

Identified with bugprone-argument-comment.

Added: 


Modified: 
clang/include/clang/AST/ExprConcepts.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/lib/AST/StmtOpenMP.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Parse/ParseExpr.cpp
clang/lib/Parse/ParseExprCXX.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Parse/ParseStmtAsm.cpp
clang/lib/Parse/ParseTemplate.cpp
clang/lib/Parse/Parser.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaExprObjC.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
clang/utils/TableGen/NeonEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ExprConcepts.h 
b/clang/include/clang/AST/ExprConcepts.h
index d56d427658705..6849b65b71c0c 100644
--- a/clang/include/clang/AST/ExprConcepts.h
+++ b/clang/include/clang/AST/ExprConcepts.h
@@ -413,12 +413,12 @@ class NestedRequirement : public Requirement {
   friend ASTStmtWriter;
 
   NestedRequirement(SubstitutionDiagnostic *SubstDiag) :
-  Requirement(RK_Nested, /*Dependent=*/false,
+  Requirement(RK_Nested, /*IsDependent=*/false,
   /*ContainsUnexpandedParameterPack*/false,
-  /*Satisfied=*/false), Value(SubstDiag) {}
+  /*IsSatisfied=*/false), Value(SubstDiag) {}
 
   NestedRequirement(Expr *Constraint) :
-  Requirement(RK_Nested, /*Dependent=*/true,
+  Requirement(RK_Nested, /*IsDependent=*/true,
   Constraint->containsUnexpandedParameterPack()),
   Value(Constraint) {
 assert(Constraint->isInstantiationDependent() &&

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 3ecbdc1eb77b0..6f3c0dc14867a 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -10312,7 +10312,7 @@ QualType 
ASTContext::getCorrespondingUnsignedType(QualType T) const {
 
   // For _BitInt, return an unsigned _BitInt with same width.
   if (const auto *EITy = T->getAs())
-return getBitIntType(/*IsUnsigned=*/true, EITy->getNumBits());
+return getBitIntType(/*Unsigned=*/true, EITy->getNumBits());
 
   // For enums, get the underlying integer type of the enum, and let the 
general
   // integer type signchanging code handle it.
@@ -10380,7 +10380,7 @@ QualType 
ASTContext::getCorrespondingSignedType(QualType T) const {
 
   // For _BitInt, return a signed _BitInt with same width.
   if (const auto *EITy = T->getAs())
-return getBitIntType(/*IsUnsigned=*/false, EITy->getNumBits());
+return getBitIntType(/*Unsigned=*/false, EITy->getNumBits());
 
   // For enums, get the underlying integer type of the enum, and let the 
general
   // integer type signchanging code handle it.

diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 5c8cb4274260f..da538aa332ffc 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -207,13 +207,13 @@ bool ByteCodeExprGen::VisitBinaryOperator(const 
BinaryOperator *BO) {
 
 template 
 bool ByteCodeExprGen::discard(const Expr *E) {
-  OptionScope Scope(this, /*discardResult=*/true);
+  OptionScope Scope(this, /*NewDiscardResult=*/true);
   return this->Visit(E);
 }
 
 template 
 bool ByteCodeExprGen::visit(const Expr *E) {
-  OptionScope Scope(this, /*discardResult=*/false);
+  OptionScope Scope(this, /*NewDiscardResult=*/false);
   return this->Visit(E);
 }
 

diff  --git a/clang/lib/AST/StmtOpenMP.cpp b/clang/lib/AST/StmtOpenMP.cpp
index b336a0637d5e4..8a9f73d3dbf0b 100644
--- a/clang/lib/AST/StmtOpenMP.cpp
+++ b/clang/lib/AST/StmtOpenMP.cpp
@@ -518,7 +518,7 @@ OMPSectionDirective *OMPSectionDirective::Create(const 
ASTContext ,
  bool HasCancel) {
   auto *Dir =
   createDirective(C, llvm::None, AssociatedStmt,
-   /*NumChildre=*/0, StartLoc, EndLoc);
+   /*NumChildren=*/0, StartLoc, 
EndLoc);
   Dir->setHasCancel(HasCancel);
   return Dir;
 }

diff  --git 

[clang] 4044666 - [clang] Use true/false instead of 1/0 (NFC)

2022-01-09 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-01-09T00:19:47-08:00
New Revision: 40446663c73831f166c4432edb2997d88fd167a9

URL: 
https://github.com/llvm/llvm-project/commit/40446663c73831f166c4432edb2997d88fd167a9
DIFF: 
https://github.com/llvm/llvm-project/commit/40446663c73831f166c4432edb2997d88fd167a9.diff

LOG: [clang] Use true/false instead of 1/0 (NFC)

Identified with modernize-use-bool-literals.

Added: 


Modified: 
clang/include/clang/AST/DeclCXX.h
clang/include/clang/AST/DeclContextInternals.h
clang/include/clang/AST/DeclTemplate.h
clang/include/clang/AST/ExprConcepts.h
clang/include/clang/AST/FormatString.h
clang/lib/ARCMigrate/Transforms.cpp
clang/lib/AST/Expr.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/PrintfFormatString.cpp
clang/lib/AST/VTableBuilder.cpp
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGObjC.cpp
clang/lib/CodeGen/CGVTables.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/Edit/RewriteObjCFoundationAPI.cpp
clang/lib/Format/DefinitionBlockSeparator.cpp
clang/lib/Format/UnwrappedLineParser.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Frontend/PrintPreprocessedOutput.cpp
clang/lib/Frontend/TextDiagnostic.cpp
clang/lib/Parse/ParseCXXInlineMethods.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Parse/ParseExpr.cpp
clang/lib/Parse/ParseInit.cpp
clang/lib/Parse/ParseObjc.cpp
clang/lib/Parse/ParseStmt.cpp
clang/lib/Parse/ParseStmtAsm.cpp
clang/lib/Parse/ParseTemplate.cpp
clang/lib/Parse/ParseTentative.cpp
clang/lib/Parse/Parser.cpp
clang/lib/Rewrite/HTMLRewrite.cpp
clang/lib/Sema/Scope.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/lib/Sema/SemaConcept.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index cc7bfc86a521d..309a60f43e4f6 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -3291,7 +3291,7 @@ class BaseUsingDecl : public NamedDecl {
 
 protected:
   BaseUsingDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N)
-  : NamedDecl(DK, DC, L, N), FirstUsingShadow(nullptr, 0) {}
+  : NamedDecl(DK, DC, L, N), FirstUsingShadow(nullptr, false) {}
 
 private:
   void anchor() override;

diff  --git a/clang/include/clang/AST/DeclContextInternals.h 
b/clang/include/clang/AST/DeclContextInternals.h
index 9899fc29b82d6..903cdb7bfcc82 100644
--- a/clang/include/clang/AST/DeclContextInternals.h
+++ b/clang/include/clang/AST/DeclContextInternals.h
@@ -90,7 +90,7 @@ class StoredDeclsList {
 
   StoredDeclsList(StoredDeclsList &) : Data(RHS.Data) {
 RHS.Data.setPointer(nullptr);
-RHS.Data.setInt(0);
+RHS.Data.setInt(false);
   }
 
   void MaybeDeallocList() {
@@ -114,7 +114,7 @@ class StoredDeclsList {
 
 Data = RHS.Data;
 RHS.Data.setPointer(nullptr);
-RHS.Data.setInt(0);
+RHS.Data.setInt(false);
 return *this;
   }
 
@@ -142,7 +142,7 @@ class StoredDeclsList {
   }
 
   void setHasExternalDecls() {
-Data.setInt(1);
+Data.setInt(true);
   }
 
   void remove(NamedDecl *D) {
@@ -155,7 +155,7 @@ class StoredDeclsList {
 erase_if([](NamedDecl *ND) { return ND->isFromASTFile(); });
 
 // Don't have any pending external decls any more.
-Data.setInt(0);
+Data.setInt(false);
   }
 
   void replaceExternalDecls(ArrayRef Decls) {
@@ -171,7 +171,7 @@ class StoredDeclsList {
 });
 
 // Don't have any pending external decls any more.
-Data.setInt(0);
+Data.setInt(false);
 
 if (Decls.empty())
   return;

diff  --git a/clang/include/clang/AST/DeclTemplate.h 
b/clang/include/clang/AST/DeclTemplate.h
index f7a2e3146d061..d216b359816e8 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -498,7 +498,7 @@ class FunctionTemplateSpecializationInfo final
   TemplateSpecializationKind TSK, const TemplateArgumentList *TemplateArgs,
   const ASTTemplateArgumentListInfo *TemplateArgsAsWritten,
   SourceLocation POI, MemberSpecializationInfo *MSInfo)
-  : Function(FD, MSInfo ? 1 : 0), Template(Template, TSK - 1),
+  : Function(FD, MSInfo ? true : false), Template(Template, TSK - 1),
 TemplateArguments(TemplateArgs),
 TemplateArgumentsAsWritten(TemplateArgsAsWritten),
 PointOfInstantiation(POI) {

diff  --git a/clang/include/clang/AST/ExprConcepts.h 
b/clang/include/clang/AST/ExprConcepts.h
index 1544c498ef662..d56d427658705 100644
--- a/clang/include/clang/AST/ExprConcepts.h
+++