[PATCH] D80905: [analyzer] Introduce weak dependencies to express *preferred* checker callback evaluation order

2020-05-31 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, martong, balazske, xazax.hun, rnkovacs, 
baloghadamsoftware, dcoughlin.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, ASDenysPetrov, steakhal, Charusso, 
gamesh411, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, szepet, whisperity.
Szelethus added a parent revision: D80901: [analyzer][NFC] Change checker 
dependency unit tests to check for the registration order.
Szelethus added a child revision: D78126: [analyzer][NFC] Don't allow 
dependency checkers to emit diagnostics.

Checker dependencies were added D54438  to 
solve a bug where the checker names were incorrectly registered, for example, 
InnerPointerChecker would incorrectly emit diagnostics under the name 
MallocChecker, or vice versa [1]. Since the system over the course of about a 
year matured, our expectations of what a role of a dependency and a dependent 
checker should be crystallized a bit more -- D77474 
 and its summary, as well as a variety of 
patches in the stack demonstrates how we try to keep dependencies to play a 
purely modeling role. In fact, D78126  
outright forbids diagnostics under a dependency checkers name.

These dependencies ensured the registration order and enabling only when all 
dependencies are satisfied. This was a very "strong" contract however, that 
doesn't fit the dependency added in D79420 . 
As its summary suggests, this relation is directly in between diagnostics, not 
modeling -- we'd prefer a more specific warning over a general one.

To support this, I added a new dependency kind, weak dependencies. These are 
not as strict of a contract, they only express a preference in registration 
order. If a weak dependency isn't satisfied, the checker may still be enabled, 
but if it is, checker registration, and transitively, checker callback 
evaluation order is ensured.

If you are not familiar with the TableGen changes, a rather short description 
can be found in the summary of D75360 . A 
lengthier one is in D58065 . Of course, this 
is a rather rarely touched part of the analyzer and I'm happy to spill the 
beans if any part of it is unclear!

[1] https://www.youtube.com/watch?v=eqKeqHRAhQM


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80905

Files:
  clang/include/clang/StaticAnalyzer/Checkers/CheckerBase.td
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
  clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
  clang/test/Analysis/weak-dependencies.c
  clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
  clang/utils/TableGen/ClangSACheckersEmitter.cpp

Index: clang/utils/TableGen/ClangSACheckersEmitter.cpp
===
--- clang/utils/TableGen/ClangSACheckersEmitter.cpp
+++ clang/utils/TableGen/ClangSACheckersEmitter.cpp
@@ -282,6 +282,31 @@
   OS << "\n"
 "#endif // GET_CHECKER_DEPENDENCIES\n";
 
+  // Emit weak dependencies.
+  //
+  // CHECKER_DEPENDENCY(FULLNAME, DEPENDENCY)
+  //   - FULLNAME: The full name of the checker that is supposed to be
+  // registered first.
+  //   - DEPENDENCY: The full name of the checker FULLNAME weak depends on.
+  OS << "\n"
+"#ifdef GET_CHECKER_WEAK_DEPENDENCIES\n";
+  for (const Record *Checker : checkers) {
+if (Checker->isValueUnset("WeakDependencies"))
+  continue;
+
+for (const Record *Dependency :
+ Checker->getValueAsListOfDefs("WeakDependencies")) {
+  OS << "CHECKER_WEAK_DEPENDENCY(";
+  OS << '\"';
+  OS.write_escaped(getCheckerFullName(Checker)) << "\", ";
+  OS << '\"';
+  OS.write_escaped(getCheckerFullName(Dependency)) << '\"';
+  OS << ")\n";
+}
+  }
+  OS << "\n"
+"#endif // GET_CHECKER_WEAK_DEPENDENCIES\n";
+
   // Emit a package option.
   //
   // CHECKER_OPTION(OPTIONTYPE, CHECKERNAME, OPTIONNAME, DESCRIPTION, DEFAULT)
Index: clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
===
--- clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
+++ clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
@@ -171,6 +171,298 @@
   EXPECT_TRUE(runCheckerOnCode("void f() {int i;}", Diags));
   EXPECT_EQ(Diags, "custom.RegistrationOrder:custom.RegistrationOrder\n");
 }
+
+//===--===//
+// Weak checker dependencies.
+//===--===//
+
+UNITTEST_CHECKER(WeakDep, "Weak")
+
+void addWeakDepCheckerBothEnabled(AnalysisASTConsumer ,
+  AnalyzerOptions ) {
+  AnOpts.CheckersAndPackages = {{"custom.Dep", 

[PATCH] D80800: Add an option to fully qualify classes and structs.

2020-05-31 Thread Jean-Baptiste Lespiau via Phabricator via cfe-commits
jblespiau marked an inline comment as done.
jblespiau added a comment.

I did spend a few hours, just building and finding how to run tests :(

I have a few additional questions, as I do not really understand what happen. 
In my initial idea, I wanted to modify the way QualType are printed, not really 
declarations, but I feel the logic is duplicated somewhere, and that both 
NamedDecl and Type are implementing the logic.




Comment at: clang/lib/AST/TypePrinter.cpp:326
+  if (Policy.FullyQualifiedName && Policy.GlobalScopeQualifiedName &&
+  T->isStructureOrClassType()) {
+OS << "::";

sammccall wrote:
> structure-or-class-type isn't quite the right check:
>  - enums and typedefs for instance should also be qualified.
>  - you're looking through sugar to the underlying type, which may not be what 
> you want
>  
> It's going to be hard to get this right from here... I suspect it's better to 
> fix where `FullyQualifiedName` is checked in DeclPrinter.
> This ultimately calls through to NamedDecl::printNestedNameSpecifier, which 
> is probably the right place to respect this option.
> (I don't totally understand what's meant to happen if SuppressScope is false 
> but FullyQualiifedName is also false, that calls through to 
> NestedNameSpecifier::print which you may want to also fix, or not)
There are several elements I do not understand (as you will see, I am 
completely lost).

1. I am trying to modify QualType::getAsString, and you suggest changing 
NamecDecl. I do not understand the relationship between Qualtype and NameDecl: 
I understand declaration within the context of C++:
https://www.dummies.com/programming/cpp/expressions-and-declarations-in-c-programming/
Thus, a Declaration will be made of several parts, some of which will be Type. 
Thus, for me, the change should not be in NameDecl but in Type, to also make 
sure the change is there both when we print a NameDecl and a type.. If we 
modify NameDecl, then, when printing a type through Type::getAsString, we won't 
get the global "::" specifier.
I have understood NamedDecl::printQualifiedName calls 
NamedDecl::printNestedNameSpecifier which calls the Type::print function, see
https://github.com/llvm-mirror/clang/blob/master/lib/AST/Decl.cpp#L1630

=> From that, I still understand I should modify how types are printed, not 
NamedDecl. I may completely be incorrect, and I am only looking to understand.

Thus, I feel my change is correcly placed, but we can change it to be:

  if (!Policy.SuppressScope && Policy.GlobalScopeQualifiedName &&
  (T->isStructureOrClassType() || T->isEnumeralType() ||
   isa(T))) {
OS << "::";
  }

Other remarks:
2. As documented:
```
  /// When true, print the fully qualified name of function declarations.
  /// This is the opposite of SuppressScope and thus overrules it.
  unsigned FullyQualifiedName : 1;
```

 FullyQualifiedName is only controlling the fully-qualification of functions.
https://github.com/llvm/llvm-project/blob/a2a3e9f0a6e91103a0d1fa73086dbdf109c48f69/clang/lib/AST/DeclPrinter.cpp#L625

So I do not think we have to follow this.

I think it is `SuppressScope` which controls whether it is fully qualified or 
not,:
https://github.com/llvm/llvm-project/blob/a2a3e9f0a6e91103a0d1fa73086dbdf109c48f69/clang/lib/AST/DeclPrinter.cpp#L629

If Policy.SuppressScope is False, then I understand it's fully qualified.

3. "you're looking through sugar to the underlying type, which may not be what 
you want": I do not understand "sugar" in that context. I have read this name 
in the code in clang, but still, I do not understand it. I only know 
https://en.wikipedia.org/wiki/Syntactic_sugar, which does not seem to apply 
here (Obviously, I am not a native English speaker).

For the testing:

Building and running


After > 90minutes of building with:
cmake -DLLVM_ENABLE_PROJECTS=clang -G "Unix Makefiles" ../llvm
make check-clang

It took me quite a while to find how to execute a single test file:

~/llvm-project/build/tools/clang/unittests/AST]
└──╼ make -j12 ASTTests && ./ASTTests --gtest_filter=NamedDeclPrinter*

did the job. 

- NamedDeclPrinterTest.cpp  feels strange for the tests, as what I am modifying 
is not NamedDecl, but Qualtype::getAsString. But given there is no 
TypeTest.cpp, maybe it's best location.


I must admit that I am struggling a lot to understand both the execution flow 
and the code itself :(



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

https://reviews.llvm.org/D80800



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


[PATCH] D80903: [analyzer] Ignore calculated indices of <= 0 in VLASizeChecker

2020-05-31 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers updated this revision to Diff 267534.
vabridgers added a comment.

Address some typos


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80903

Files:
  clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
  clang/test/Analysis/vla.c


Index: clang/test/Analysis/vla.c
===
--- clang/test/Analysis/vla.c
+++ clang/test/Analysis/vla.c
@@ -137,3 +137,17 @@
   clang_analyzer_eval(clang_analyzer_getExtent() == 2 * x * 4 * 
sizeof(int));
   // expected-warning@-1{{TRUE}}
 }
+
+// https://bugs.llvm.org/show_bug.cgi?id=46128
+// analyzer doesn't handle more than simple symbolic expressions.
+// Just don't crash.
+extern void foo(void);
+int a;
+void b() {
+  int c = a + 1;
+  for (;;) {
+int d[c];
+for (; 0 < c;)
+  foo();
+  }
+} // no-crash
Index: clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
@@ -126,6 +126,11 @@
   // Size overflow check does not work with symbolic expressions because a
   // overflow situation can not be detected easily.
   uint64_t IndexL = IndexLVal->getZExtValue();
+  // constraints are not solved for expressions with multiple
+  // symbols, so just bail on invalid indices at this point.
+  if (IndexL <= 0)
+return nullptr;
+
   assert(IndexL > 0 && "Index length should have been checked for zero.");
   if (KnownSize <= SizeMax / IndexL) {
 KnownSize *= IndexL;


Index: clang/test/Analysis/vla.c
===
--- clang/test/Analysis/vla.c
+++ clang/test/Analysis/vla.c
@@ -137,3 +137,17 @@
   clang_analyzer_eval(clang_analyzer_getExtent() == 2 * x * 4 * sizeof(int));
   // expected-warning@-1{{TRUE}}
 }
+
+// https://bugs.llvm.org/show_bug.cgi?id=46128
+// analyzer doesn't handle more than simple symbolic expressions.
+// Just don't crash.
+extern void foo(void);
+int a;
+void b() {
+  int c = a + 1;
+  for (;;) {
+int d[c];
+for (; 0 < c;)
+  foo();
+  }
+} // no-crash
Index: clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
@@ -126,6 +126,11 @@
   // Size overflow check does not work with symbolic expressions because a
   // overflow situation can not be detected easily.
   uint64_t IndexL = IndexLVal->getZExtValue();
+  // constraints are not solved for expressions with multiple
+  // symbols, so just bail on invalid indices at this point.
+  if (IndexL <= 0)
+return nullptr;
+
   assert(IndexL > 0 && "Index length should have been checked for zero.");
   if (KnownSize <= SizeMax / IndexL) {
 KnownSize *= IndexL;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80903: [analyzer] Ignore calculated indices of <= 0 in VLASizeChecker

2020-05-31 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers added a comment.

Not sure this is "correct", but it passes LITs with the new case, and it will 
at least get the discussion started :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80903



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


[PATCH] D80903: [analyzer] Ignore calculated indices of <= 0 in VLASizeChecker

2020-05-31 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers created this revision.
vabridgers added reviewers: balazske, NoQ, martong, baloghadamsoftware, 
Szelethus, gamesh411.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, donat.nagy, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, xazax.hun.
Herald added a project: clang.
vabridgers added a comment.

Not sure this is "correct", but it passes LITs with the new case, and it will 
at least get the discussion started :)


See https://bugs.llvm.org/show_bug.cgi?id=46128. The checker does not
yet comprehend constraints involving multiple symbols, so it's possible
to calculate a VLA size that's negative or 0. A LIT is added to catch
regressions, and this change simply bails if a VLA size of 0 or less is
calculated.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80903

Files:
  clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
  clang/test/Analysis/vla.c


Index: clang/test/Analysis/vla.c
===
--- clang/test/Analysis/vla.c
+++ clang/test/Analysis/vla.c
@@ -137,3 +137,17 @@
   clang_analyzer_eval(clang_analyzer_getExtent() == 2 * x * 4 * 
sizeof(int));
   // expected-warning@-1{{TRUE}}
 }
+
+// https://bugs.llvm.org/show_bug.cgi?id=46128
+// analyzer doesn't handle more than simple sybolic expressions.
+// Just don't crash.
+extern void foo(void);
+int a;
+void b() {
+  int c = a + 1;
+  for (;;) {
+int d[c];
+for (; 0 < c;)
+  foo();
+  }
+} // no-crash
Index: clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
@@ -126,6 +126,11 @@
   // Size overflow check does not work with symbolic expressions because a
   // overflow situation can not be detected easily.
   uint64_t IndexL = IndexLVal->getZExtValue();
+  // constraints are not solved for expressions with multiple
+  // symbols, so just bail on invalid indices at this point.
+  if (IndexL <= 0)
+return nullptr;
+
   assert(IndexL > 0 && "Index length should have been checked for zero.");
   if (KnownSize <= SizeMax / IndexL) {
 KnownSize *= IndexL;


Index: clang/test/Analysis/vla.c
===
--- clang/test/Analysis/vla.c
+++ clang/test/Analysis/vla.c
@@ -137,3 +137,17 @@
   clang_analyzer_eval(clang_analyzer_getExtent() == 2 * x * 4 * sizeof(int));
   // expected-warning@-1{{TRUE}}
 }
+
+// https://bugs.llvm.org/show_bug.cgi?id=46128
+// analyzer doesn't handle more than simple sybolic expressions.
+// Just don't crash.
+extern void foo(void);
+int a;
+void b() {
+  int c = a + 1;
+  for (;;) {
+int d[c];
+for (; 0 < c;)
+  foo();
+  }
+} // no-crash
Index: clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
@@ -126,6 +126,11 @@
   // Size overflow check does not work with symbolic expressions because a
   // overflow situation can not be detected easily.
   uint64_t IndexL = IndexLVal->getZExtValue();
+  // constraints are not solved for expressions with multiple
+  // symbols, so just bail on invalid indices at this point.
+  if (IndexL <= 0)
+return nullptr;
+
   assert(IndexL > 0 && "Index length should have been checked for zero.");
   if (KnownSize <= SizeMax / IndexL) {
 KnownSize *= IndexL;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79835: [Fuchsia] Rely on linker switch rather than dead code ref for profile runtime

2020-05-31 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Driver/ToolChains/Fuchsia.cpp:372
+   llvm::opt::ArgStringList ) const {
+  // Add linker option -u__llvm_profile_runtime to cause runtime
+  // initialization module to be linked in.

Thanks. I just realized `Linux::addProfileRTLibs` can be simplified.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79835



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


[clang] 92448fd - [Driver] Simplify Linux::addProfileRTLibs

2020-05-31 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-05-31T17:15:14-07:00
New Revision: 92448fd23daf966fe368eb8523d9c5a31797d5d8

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

LOG: [Driver] Simplify Linux::addProfileRTLibs

Added: 


Modified: 
clang/lib/Driver/ToolChains/Linux.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Linux.cpp 
b/clang/lib/Driver/ToolChains/Linux.cpp
index 99c23e71eb0c..8188c972f446 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -867,13 +867,9 @@ SanitizerMask Linux::getSupportedSanitizers() const {
 
 void Linux::addProfileRTLibs(const llvm::opt::ArgList ,
  llvm::opt::ArgStringList ) const {
-  bool Profile = needsProfileRT(Args);
-  if (!Profile && !needsGCovInstrumentation(Args))
-return;
-
   // Add linker option -u__llvm_profile_runtime to cause runtime
   // initialization module to be linked in.
-  if (Profile)
+  if (needsProfileRT(Args))
 CmdArgs.push_back(Args.MakeArgString(
 Twine("-u", llvm::getInstrProfRuntimeHookVarName(;
   ToolChain::addProfileRTLibs(Args, CmdArgs);



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


[PATCH] D79961: [PGO] Fix computation of fuction Hash

2020-05-31 Thread Alan Phipps via Phabricator via cfe-commits
alanphipps added a comment.

It looks like clang/test/Profile/Inputs/c-general.profdata.v5 is being read as 
v6 rather than v5.  Can you double check?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79961



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


[PATCH] D80897: [OpenMP] Initial support for std::complex in target regions

2020-05-31 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 267531.
jdoerfert added a comment.

Fix tests, add C support


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80897

Files:
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__clang_cuda_complex_builtins.h
  clang/lib/Headers/__clang_cuda_math.h
  clang/lib/Headers/openmp_wrappers/complex
  clang/lib/Headers/openmp_wrappers/complex.h
  clang/test/Headers/Inputs/include/cmath
  clang/test/Headers/Inputs/include/complex
  clang/test/Headers/Inputs/include/cstdlib
  clang/test/Headers/nvptx_device_math_complex.c
  clang/test/Headers/nvptx_device_math_complex.cpp

Index: clang/test/Headers/nvptx_device_math_complex.cpp
===
--- /dev/null
+++ clang/test/Headers/nvptx_device_math_complex.cpp
@@ -0,0 +1,27 @@
+// REQUIRES: nvptx-registered-target
+// RUN: %clang_cc1 -verify -internal-isystem %S/Inputs/include -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/Inputs/include -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -aux-triple powerpc64le-unknown-unknown -o - | FileCheck %s
+// expected-no-diagnostics
+
+#include 
+
+// CHECK-DAG: define {{.*}} @__mulsc3
+// CHECK-DAG: define {{.*}} @__muldc3
+// CHECK-DAG: define {{.*}} @__divsc3
+// CHECK-DAG: define {{.*}} @__divdc3
+
+// CHECK-DAG: call float @__nv_scalbnf(
+void test_scmplx(std::complex a) {
+#pragma omp target
+  {
+(void)(a * (a / a));
+  }
+}
+
+// CHECK-DAG: call double @__nv_scalbn(
+void test_dcmplx(std::complex a) {
+#pragma omp target
+  {
+(void)(a * (a / a));
+  }
+}
Index: clang/test/Headers/nvptx_device_math_complex.c
===
--- clang/test/Headers/nvptx_device_math_complex.c
+++ clang/test/Headers/nvptx_device_math_complex.c
@@ -1,10 +1,22 @@
 // REQUIRES: nvptx-registered-target
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -internal-isystem %S/Inputs/include -fopenmp -x c -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/Inputs/include -fopenmp -x c -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -aux-triple powerpc64le-unknown-unknown -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -internal-isystem %S/Inputs/include -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/Inputs/include -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -aux-triple powerpc64le-unknown-unknown -o - | FileCheck %s
 // expected-no-diagnostics
 
-// CHECK-DAG: call { float, float } @__divsc3(
-// CHECK-DAG: call { float, float } @__mulsc3(
+#ifdef __cplusplus
+#include 
+#else
+#include 
+#endif
+
+// CHECK-DAG: define {{.*}} @__mulsc3
+// CHECK-DAG: define {{.*}} @__muldc3
+// CHECK-DAG: define {{.*}} @__divsc3
+// CHECK-DAG: define {{.*}} @__divdc3
+
+// CHECK-DAG: call float @__nv_scalbnf(
 void test_scmplx(float _Complex a) {
 #pragma omp target
   {
@@ -12,9 +24,7 @@
   }
 }
 
-
-// CHECK-DAG: call { double, double } @__divdc3(
-// CHECK-DAG: call { double, double } @__muldc3(
+// CHECK-DAG: call double @__nv_scalbn(
 void test_dcmplx(double _Complex a) {
 #pragma omp target
   {
Index: clang/test/Headers/Inputs/include/cstdlib
===
--- clang/test/Headers/Inputs/include/cstdlib
+++ clang/test/Headers/Inputs/include/cstdlib
@@ -24,4 +24,8 @@
 abs(long long __x) { return __builtin_llabs (__x); }
 
 float fabs(float __x) { return __builtin_fabs(__x); }
+
+float abs(float __x) { return fabs(__x); }
+double abs(double __x) { return fabs(__x); }
+
 }
Index: clang/test/Headers/Inputs/include/complex
===

[PATCH] D80723: [PowerPC] Convert vec_splats functions to macros

2020-05-31 Thread Colin Samples via Phabricator via cfe-commits
vddvss updated this revision to Diff 267529.
vddvss marked an inline comment as done.
vddvss added a comment.

Updated revision to address @steven.zhang's good suggestion on the test case.

This also does `clang-format` on `altivec.h` to address the harbormaster 
failure, although I am inclined to do `/* clang-format off */`, since it is a 
lot less readable after running `clang-format`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80723

Files:
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/ppc-emmintrin.c
  clang/test/CodeGen/ppc-mmintrin.c
  clang/test/CodeGen/ppc-pmmintrin.c
  clang/test/CodeGen/ppc-smmintrin.c
  clang/test/CodeGen/ppc-tmmintrin.c
  clang/test/CodeGen/ppc-xmmintrin.c
  clang/test/CodeGen/pr44276.c

Index: clang/test/CodeGen/pr44276.c
===
--- /dev/null
+++ clang/test/CodeGen/pr44276.c
@@ -0,0 +1,22 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -target-cpu pwr8 %s -verify
+// expected-no-diagnostics
+
+// Check that this compiles
+
+#include 
+
+void test() {
+  static vector unsigned char a = vec_splats('1');
+  static vector signed char b = vec_splats((signed char)'1');
+  static vector unsigned short c = vec_splats((unsigned short)1U);
+  static vector signed short d = vec_splats((short)1);
+  static vector unsigned int e = vec_splats(1U);
+  static vector signed int f = vec_splats(1);
+  static vector float g = vec_splats(1.0f);
+  static vector unsigned long long h = vec_splats(1ULL);
+  static vector signed long long i = vec_splats(1LL);
+  static vector double j = vec_splats(1.0);
+  static vector unsigned __int128 k = vec_splats((__int128)1);
+  static vector signed __int128 l = vec_splats((__int128)1);
+}
Index: clang/test/CodeGen/ppc-xmmintrin.c
===
--- clang/test/CodeGen/ppc-xmmintrin.c
+++ clang/test/CodeGen/ppc-xmmintrin.c
@@ -1,4 +1,3 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // REQUIRES: powerpc-registered-target
 
 // RUN: %clang -S -emit-llvm -target powerpc64-unknown-linux-gnu -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
@@ -66,11 +65,13 @@
 // CHECK: store i64 {{[0-9a-zA-Z_%.]+}}, i64* {{[0-9a-zA-Z_%.]+}}, align 8
 // CHECK-NEXT: store i64 {{[0-9a-zA-Z_%.]+}}, i64* {{[0-9a-zA-Z_%.]+}}, align 8
 // CHECK-NEXT: [[REG25:[0-9a-zA-Z_%.]+]] = load i64, i64* {{[0-9a-zA-Z_%.]+}}, align 8
-// CHECK-NEXT: [[REG26:[0-9a-zA-Z_%.]+]] = call <2 x i64> @vec_splats(unsigned long long)(i64 [[REG25]])
+// CHECK-NEXT: [[REG26A:[0-9a-zA-Z_%.]+]] = insertelement <2 x i64> undef, i64 [[REG25]], i32 0
+// CHECK-NEXT: [[REG26:[0-9a-zA-Z_%.]+]]  = shufflevector <2 x i64> [[REG26A]], <2 x i64> undef, <2 x i32> zeroinitializer
 // CHECK-NEXT: [[REG27:[0-9a-zA-Z_%.]+]] = bitcast <2 x i64> [[REG26]] to <8 x i16>
 // CHECK-NEXT: store <8 x i16> [[REG27]], <8 x i16>* {{[0-9a-zA-Z_%.]+}}, align 16
 // CHECK-NEXT: [[REG28:[0-9a-zA-Z_%.]+]] = load i64, i64* {{[0-9a-zA-Z_%.]+}}, align 8
-// CHECK-NEXT: [[REG29:[0-9a-zA-Z_%.]+]] = call <2 x i64> @vec_splats(unsigned long long)(i64 [[REG28]])
+// CHECK-NEXT: [[REG29A:[0-9a-zA-Z_%.]+]] = insertelement <2 x i64> undef, i64 [[REG28]], i32 0
+// CHECK-NEXT: [[REG29:[0-9a-zA-Z_%.]+]]  = shufflevector <2 x i64> [[REG29A]], <2 x i64> undef, <2 x i32> zeroinitializer
 // CHECK-NEXT: [[REG30:[0-9a-zA-Z_%.]+]] = bitcast <2 x i64> [[REG29]] to <8 x i16>
 // CHECK-NEXT: store <8 x i16> [[REG30]], <8 x i16>* {{[0-9a-zA-Z_%.]+}}, align 16
 // CHECK-NEXT: [[REG31:[0-9a-zA-Z_%.]+]] = load <8 x i16>, <8 x i16>* {{[0-9a-zA-Z_%.]+}}, align 16
@@ -86,11 +87,13 @@
 // CHECK: store i64 {{[0-9a-zA-Z_%.]+}}, i64* {{[0-9a-zA-Z_%.]+}}, align 8
 // CHECK-NEXT: store i64 {{[0-9a-zA-Z_%.]+}}, i64* {{[0-9a-zA-Z_%.]+}}, align 8
 // CHECK-NEXT: [[REG37:[0-9a-zA-Z_%.]+]] = load i64, i64* {{[0-9a-zA-Z_%.]+}}, align 8
-// CHECK-NEXT: [[REG38:[0-9a-zA-Z_%.]+]] = call <2 x i64> @vec_splats(unsigned long long)(i64 [[REG37]])
+// CHECK-NEXT: [[REG38A:[0-9a-zA-Z_%.]+]] = insertelement <2 x i64> undef, i64 [[REG37]], i32 0
+// CHECK-NEXT: [[REG38:[0-9a-zA-Z_%.]+]]  = shufflevector <2 x i64> [[REG38A]], <2 x i64> undef, <2 x i32> zeroinitializer
 // CHECK-NEXT: [[REG39:[0-9a-zA-Z_%.]+]] = bitcast <2 x i64> [[REG38]] to <16 x i8>
 // CHECK-NEXT: store <16 x i8> [[REG39]], <16 x i8>* {{[0-9a-zA-Z_%.]+}}, align 16
 // CHECK-NEXT: [[REG40:[0-9a-zA-Z_%.]+]] = load i64, i64* {{[0-9a-zA-Z_%.]+}}, align 8
-// CHECK-NEXT: [[REG41:[0-9a-zA-Z_%.]+]] = call <2 x i64> @vec_splats(unsigned long long)(i64 [[REG40]])
+// CHECK-NEXT: [[REG41A:[0-9a-zA-Z_%.]+]] = insertelement <2 x i64> undef, i64 [[REG40]], i32 0
+// CHECK-NEXT: [[REG41:[0-9a-zA-Z_%.]+]]  = shufflevector <2 x i64> [[REG41A]], <2 x i64> undef, <2 x i32> zeroinitializer
 // CHECK-NEXT: [[REG42:[0-9a-zA-Z_%.]+]] = bitcast <2 x i64> 

[PATCH] D80900: [clangd] Use different FS in PreambleThread

2020-05-31 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
javed.absar, ilya-biryukov.
Herald added a project: clang.

As vfs::FileSystem is not threadsafe, we've introduced a data race when
PreambleThread started to run in async mode. As both ASTWorker and
PreambleWorker can concurrently work on the same FS.

This patch fixes that data race by propagating FSProvider into TUScheduler and
ASTWorker and making use of a new FS when issuing update to the PreambleThread.

This doesn't break our contract on FSProvider::getFileSystem, as it says the
active context will be client's context at the time of request and
ASTWorker::update is run with the context we've captured on
ClangdServer::AddDocument.

As for the operations, this implies preamble and ast threads can see different
versions of the filesystems. For example in presence of a snapshotted filesystem

- client makes an AddDocument request with FS at snapshot v1
- client then updates the FS to v2
- ASTWorker starts handling the update, caches the FS v1 in FileInputs, which 
is used for serving reads.
- Schedules a preamble update, this fetches a new FS from provider, which might 
yield v2. This says `might` as clients can handle this case by storing snapshot 
version in context.
- Preamble build finishes and clangd publishes diagnostics for FS v2.
- Client issues a read (e.g. go-to-def), clangd uses FS v1 for serving the 
request.

This can be overcome by 2 filesystems into TUScheduler in
ClangdServer::AddDocument, but I don't think it is an issue in practice
currently. As our beloved snapshotted filesystem provider stores the snapshot
version in context, and should always return the same FS for requests coming
from the same context.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80900

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
  clang-tools-extra/clangd/unittests/TestFS.h

Index: clang-tools-extra/clangd/unittests/TestFS.h
===
--- clang-tools-extra/clangd/unittests/TestFS.h
+++ clang-tools-extra/clangd/unittests/TestFS.h
@@ -31,11 +31,12 @@
 class MockFSProvider : public FileSystemProvider {
 public:
   IntrusiveRefCntPtr getFileSystem() const override {
-return buildTestFS(Files);
+return buildTestFS(Files, Timestamps);
   }
 
   // If relative paths are used, they are resolved with testPath().
   llvm::StringMap Files;
+  llvm::StringMap Timestamps;
 };
 
 // A Compilation database that returns a fixed set of compile flags.
Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -73,7 +73,7 @@
   ParseInputs getInputs(PathRef File, std::string Contents) {
 ParseInputs Inputs;
 Inputs.CompileCommand = *CDB.getCompileCommand(File);
-Inputs.FS = buildTestFS(Files, Timestamps);
+Inputs.FS = FSProvider.getFileSystem();
 Inputs.Contents = std::move(Contents);
 Inputs.Opts = ParseOptions();
 return Inputs;
@@ -149,8 +149,7 @@
std::move(CB));
   }
 
-  llvm::StringMap Files;
-  llvm::StringMap Timestamps;
+  MockFSProvider FSProvider;
   MockCompilationDatabase CDB;
 };
 
@@ -158,13 +157,13 @@
 TUSchedulerTests::DiagsCallbackKey;
 
 TEST_F(TUSchedulerTests, MissingFiles) {
-  TUScheduler S(CDB, optsForTest());
+  TUScheduler S(FSProvider, CDB, optsForTest());
 
   auto Added = testPath("added.cpp");
-  Files[Added] = "x";
+  FSProvider.Files[Added] = "x";
 
   auto Missing = testPath("missing.cpp");
-  Files[Missing] = "";
+  FSProvider.Files[Missing] = "";
 
   S.update(Added, getInputs(Added, "x"), WantDiagnostics::No);
 
@@ -205,7 +204,7 @@
 // To avoid a racy test, don't allow tasks to actually run on the worker
 // thread until we've scheduled them all.
 Notification Ready;
-TUScheduler S(CDB, optsForTest(), captureDiags());
+TUScheduler S(FSProvider, CDB, optsForTest(), captureDiags());
 auto Path = testPath("foo.cpp");
 updateWithDiags(S, Path, "", WantDiagnostics::Yes,
 [&](std::vector) { Ready.wait(); });
@@ -234,7 +233,7 @@
   {
 auto Opts = optsForTest();
 Opts.UpdateDebounce = DebouncePolicy::fixed(std::chrono::seconds(1));
-TUScheduler S(CDB, Opts, captureDiags());
+TUScheduler S(FSProvider, CDB, Opts, captureDiags());
 // FIXME: we could probably use timeouts lower than 1 second here.
 auto Path = testPath("foo.cpp");
 updateWithDiags(S, Path, "auto (debounced)", WantDiagnostics::Auto,
@@ -267,7 +266,7 @@
   std::vector DiagsSeen, ReadsSeen, ReadsCanceled;
   {
 Notification Proceed; // 

[PATCH] D80901: [analyzer][NFC] Change checker dependency unit tests to check for the registration order

2020-05-31 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, xazax.hun, baloghadamsoftware, martong, 
balazske, rnkovacs, vsavchenko, dcoughlin.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, ASDenysPetrov, steakhal, Charusso, 
gamesh411, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, szepet, whisperity.

Exactly what it says on the tin! "Strong" dependencies are mentioned in 
contrast to a new kind of dependency introduced in a followup patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80901

Files:
  clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp

Index: clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
===
--- clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
+++ clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
@@ -16,7 +16,9 @@
 #include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
 #include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/Support/raw_ostream.h"
 #include "gtest/gtest.h"
+#include 
 
 namespace clang {
 namespace ento {
@@ -60,7 +62,7 @@
 public:
   void checkLocation(SVal Loc, bool IsLoad, const Stmt *S,
  CheckerContext ) const {
-auto UnaryOp = dyn_cast(S);
+const auto *UnaryOp = dyn_cast(S);
 if (UnaryOp && !IsLoad) {
   EXPECT_FALSE(UnaryOp->isIncrementOp());
 }
@@ -85,62 +87,90 @@
 // Unsatisfied checker dependency
 //===--===//
 
-class PrerequisiteChecker : public Checker {
+class CheckerRegistrationOrderPrinter
+: public Checker> {
+  std::unique_ptr BT =
+  std::make_unique(this, "Registration order");
+
 public:
-  void checkASTCodeBody(const Decl *D, AnalysisManager ,
-BugReporter ) const {
-BR.EmitBasicReport(D, this, "Prerequisite", categories::LogicError,
-   "This is the prerequisite checker",
-   PathDiagnosticLocation(D, Mgr.getSourceManager()), {});
+  void checkPreStmt(const DeclStmt *DS, CheckerContext ) const {
+ExplodedNode *N = nullptr;
+N = C.generateErrorNode();
+llvm::SmallString<200> Buf;
+llvm::raw_svector_ostream OS(Buf);
+C.getAnalysisManager()
+.getCheckerManager()
+->getCheckerRegistry()
+.printEnabledCheckerList(OS);
+// Strip a newline off.
+auto R =
+std::make_unique(*BT, OS.str().drop_back(1), N);
+C.emitReport(std::move(R));
   }
 };
 
-void registerPrerequisiteChecker(CheckerManager ) {
-  mgr.registerChecker();
+void registerCheckerRegistrationOrderPrinter(CheckerManager ) {
+  mgr.registerChecker();
 }
 
-bool shouldRegisterPrerequisiteChecker(const CheckerManager ) {
-  return false;
+bool shouldRegisterCheckerRegistrationOrderPrinter(const CheckerManager ) {
+  return true;
 }
 
-class DependentChecker : public Checker {
-public:
-  void checkASTCodeBody(const Decl *D, AnalysisManager ,
-BugReporter ) const {
-BR.EmitBasicReport(D, this, "Dependent", categories::LogicError,
-   "This is the Dependent Checker",
-   PathDiagnosticLocation(D, Mgr.getSourceManager()), {});
+void addCheckerRegistrationOrderPrinter(CheckerRegistry ) {
+  Registry.addChecker(registerCheckerRegistrationOrderPrinter,
+  shouldRegisterCheckerRegistrationOrderPrinter,
+  "custom.RegistrationOrder", "Description", "", false);
+}
+
+#define UNITTEST_CHECKER(CHECKER_NAME, DIAG_MSG)   \
+  class CHECKER_NAME : public Checker> {  \
+std::unique_ptr BT =   \
+std::make_unique(this, DIAG_MSG);  \
+   \
+  public:  \
+void checkPreStmt(const DeclStmt *DS, CheckerContext ) const {}  \
+  };   \
+   \
+  void register##CHECKER_NAME(CheckerManager ) {   \
+mgr.registerChecker();   \
+  }\
+   \
+  bool shouldRegister##CHECKER_NAME(const CheckerManager ) {   \
+return true;   \
+  }\
+  void add##CHECKER_NAME(CheckerRegistry ) {  \
+Registry.addChecker(register##CHECKER_NAME, shouldRegister##CHECKER_NAME,  

[clang] 77e1181 - [analyzer] Add dumps to CheckerRegistry

2020-05-31 Thread Kirstóf Umann via cfe-commits

Author: Kirstóf Umann
Date: 2020-05-31T22:53:02+02:00
New Revision: 77e1181df446b54391acad08512b540e174cf6e6

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

LOG: [analyzer] Add dumps to CheckerRegistry

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h 
b/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
index 4e98ba2e10d2..c3494d0ebeef 100644
--- a/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
+++ b/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
@@ -13,6 +13,7 @@
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 
@@ -133,6 +134,9 @@ class CheckerRegistry {
   DevelopmentStatus == "released") &&
  "Invalid development status!");
 }
+
+LLVM_DUMP_METHOD void dump() const { dumpToStream(llvm::errs()); }
+LLVM_DUMP_METHOD void dumpToStream(llvm::raw_ostream ) const;
   };
 
   using CmdLineOptionList = llvm::SmallVector;
@@ -189,6 +193,9 @@ class CheckerRegistry {
 
 // Used for lower_bound.
 explicit CheckerInfo(StringRef FullName) : FullName(FullName) {}
+
+LLVM_DUMP_METHOD void dump() const { dumpToStream(llvm::errs()); }
+LLVM_DUMP_METHOD void dumpToStream(llvm::raw_ostream ) const;
   };
 
   using StateFromCmdLine = CheckerInfo::StateFromCmdLine;
@@ -206,6 +213,9 @@ class CheckerRegistry {
 }
 
 explicit PackageInfo(StringRef FullName) : FullName(FullName) {}
+
+LLVM_DUMP_METHOD void dump() const { dumpToStream(llvm::errs()); }
+LLVM_DUMP_METHOD void dumpToStream(llvm::raw_ostream ) const;
   };
 
   using PackageInfoList = llvm::SmallVector;

diff  --git a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp 
b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
index 62ac1ed252dd..f4d5db1e7a4b 100644
--- a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
+++ b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
@@ -27,6 +27,10 @@ using namespace clang;
 using namespace ento;
 using llvm::sys::DynamicLibrary;
 
+//===--===//
+// Utilities.
+//===--===//
+
 using RegisterCheckersFn = void (*)(CheckerRegistry &);
 
 static bool isCompatibleAPIVersion(const char *VersionString) {
@@ -86,6 +90,63 @@ static bool isInPackage(const CheckerRegistry::CheckerInfo 
,
   return false;
 }
 
+//===--===//
+// Methods of CmdLineOption, PackageInfo and CheckerInfo.
+//===--===//
+
+LLVM_DUMP_METHOD void
+CheckerRegistry::CmdLineOption::dumpToStream(llvm::raw_ostream ) const {
+  // The description can be just checked in Checkers.inc, the point here is to
+  // debug whether we succeeded in parsing it.
+  Out << OptionName << " (" << OptionType << ", "
+  << (IsHidden ? "hidden, " : "") << DevelopmentStatus << ") default: \""
+  << DefaultValStr;
+}
+
+static StringRef toString(CheckerRegistry::StateFromCmdLine Kind) {
+  switch (Kind) {
+  case CheckerRegistry::StateFromCmdLine::State_Disabled:
+return "Disabled";
+  case CheckerRegistry::StateFromCmdLine::State_Enabled:
+return "Enabled";
+  case CheckerRegistry::StateFromCmdLine::State_Unspecified:
+return "Unspecified";
+  }
+}
+
+LLVM_DUMP_METHOD void
+CheckerRegistry::CheckerInfo::dumpToStream(llvm::raw_ostream ) const {
+  // The description can be just checked in Checkers.inc, the point here is to
+  // debug whether we succeeded in parsing it. Same with documentation uri.
+  Out << FullName << " (" << toString(State) << (IsHidden ? ", hidden" : "")
+  << ")\n";
+  Out << "  Options:\n";
+  for (const CmdLineOption  : CmdLineOptions) {
+Out << "";
+Option.dumpToStream(Out);
+Out << '\n';
+  }
+  Out << "  Dependencies:\n";
+  for (const CheckerInfo *Dependency : Dependencies) {
+Out << "  " << Dependency->FullName << '\n';
+  }
+}
+
+LLVM_DUMP_METHOD void
+CheckerRegistry::PackageInfo::dumpToStream(llvm::raw_ostream ) const {
+  Out << FullName << "\n";
+  Out << "  Options:\n";
+  for (const CmdLineOption  : CmdLineOptions) {
+Out << "";
+Option.dumpToStream(Out);
+Out << '\n';
+  }
+}
+
+//===--===//
+// Methods of CheckerRegistry.
+//===--===//
+
 

[PATCH] D80300: [Driver] Add DEFAULT_DYLD_PREFIX and DEFAULT_RPATH to complement DEFAULT_SYSROOT

2020-05-31 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast marked 3 inline comments as done.
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:452
   CmdArgs.push_back("-dynamic-linker");
-  CmdArgs.push_back(Args.MakeArgString(Loader));
+  CmdArgs.push_back(Args.MakeArgString(Twine(D.DyldPrefix) +
+   ToolChain.getDynamicLinker(Args)));

hubert.reinterpretcast wrote:
> nemanjai wrote:
> > Is this just an orthogonal NFC change? If so, can you please commit it 
> > separately in an NFC commit?
> Yes; all of the other changes made around here disappeared during the 
> development process. Would it be okay to split it out on the commit instead 
> of updating the patch?
The NFC change has be separately committed under rGc15d5d12c625.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80300



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


[clang] c15d5d1 - [Driver] NFC: Use Twine temp to replace std::string local

2020-05-31 Thread Hubert Tong via cfe-commits

Author: Hubert Tong
Date: 2020-05-31T16:38:10-04:00
New Revision: c15d5d12c625df52bf82828a6af5ef2dfb6b4533

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

LOG: [Driver] NFC: Use Twine temp to replace std::string local

This patch replaces a `std::string` local used for a concatentation with
a `Twine` where the string was being passed into call.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 9a340142a242..ac9eb46dacb5 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -449,10 +449,9 @@ void tools::gnutools::Linker::ConstructJob(Compilation , 
const JobAction ,
   CmdArgs.push_back("-export-dynamic");
 
 if (!Args.hasArg(options::OPT_shared) && !IsStaticPIE) {
-  const std::string Loader =
-  D.DyldPrefix + ToolChain.getDynamicLinker(Args);
   CmdArgs.push_back("-dynamic-linker");
-  CmdArgs.push_back(Args.MakeArgString(Loader));
+  CmdArgs.push_back(Args.MakeArgString(Twine(D.DyldPrefix) +
+   ToolChain.getDynamicLinker(Args)));
 }
   }
 



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


[PATCH] D80897: [OpenMP] Initial support for std::complex in target regions

2020-05-31 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added reviewers: tra, hfinkel, ABataev, JonChesterfield.
Herald added subscribers: sstefan1, guansong, bollu, yaxunl, mgorny.
Herald added a project: clang.

This simply follows the scheme we have for other wrappers. It resolves
the current link problem, e.g., `__muldc3 not found`, when std::complex
operations are used on a device.

In "CUDA mode" this should allow simple complex operations to work in
target regions. Normal mode doesn't work because the globalization in
the std::complex operators is somehow broken. This will most likely not
allow complex make math function calls to work properly, e.g., sin, but
that is more complex (pan intended) anyway.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80897

Files:
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__clang_cuda_complex_builtins.h
  clang/lib/Headers/openmp_wrappers/complex
  clang/test/Headers/Inputs/include/complex
  clang/test/Headers/Inputs/include/cstdlib
  clang/test/Headers/Inputs/include/math.h
  clang/test/Headers/nvptx_device_math_complex.cpp

Index: clang/test/Headers/nvptx_device_math_complex.cpp
===
--- /dev/null
+++ clang/test/Headers/nvptx_device_math_complex.cpp
@@ -0,0 +1,25 @@
+// REQUIRES: nvptx-registered-target
+// RUN: %clang_cc1 -verify -internal-isystem %S/Inputs/include -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/Inputs/include -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -aux-triple powerpc64le-unknown-unknown -o - | FileCheck %s
+// expected-no-diagnostics
+
+#include 
+
+// CHECK-DAG: define {{.*}} @__mulsc3
+// CHECK-DAG: define {{.*}} @__muldc3
+// CHECK-DAG: define {{.*}} @__divsc3
+// CHECK-DAG: define {{.*}} @__divdc3
+
+void test_scmplx(std::complex a) {
+#pragma omp target
+  {
+(void)(a * (a / a));
+  }
+}
+
+void test_dcmplx(std::complex a) {
+#pragma omp target
+  {
+(void)(a * (a / a));
+  }
+}
Index: clang/test/Headers/Inputs/include/math.h
===
--- clang/test/Headers/Inputs/include/math.h
+++ clang/test/Headers/Inputs/include/math.h
@@ -107,6 +107,10 @@
 long lroundf(float __a);
 int max(int __a, int __b);
 int min(int __a, int __b);
+float max(float __a, float __b);
+float min(float __a, float __b);
+double max(double __a, double __b);
+double min(double __a, double __b);
 double modf(double __a, double *__b);
 float modff(float __a, float *__b);
 double nearbyint(double __a);
Index: clang/test/Headers/Inputs/include/cstdlib
===
--- clang/test/Headers/Inputs/include/cstdlib
+++ clang/test/Headers/Inputs/include/cstdlib
@@ -24,4 +24,8 @@
 abs(long long __x) { return __builtin_llabs (__x); }
 
 float fabs(float __x) { return __builtin_fabs(__x); }
+
+float abs(float __x) { return fabs(__x); }
+double abs(double __x) { return fabs(__x); }
+
 }
Index: clang/test/Headers/Inputs/include/complex
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/complex
@@ -0,0 +1,301 @@
+#pragma once
+
+#include 
+
+#define INFINITY (__builtin_inff())
+
+namespace std {
+
+// Taken from libc++
+template 
+class complex {
+public:
+  typedef _Tp value_type;
+
+private:
+  value_type __re_;
+  value_type __im_;
+
+public:
+  complex(const value_type &__re = value_type(), const value_type &__im = value_type())
+  : __re_(__re), __im_(__im) {}
+  template 
+  complex(const complex<_Xp> &__c)
+  : __re_(__c.real()), __im_(__c.imag()) {}
+
+  value_type real() const { return __re_; }
+  value_type imag() const { return __im_; }
+
+  void real(value_type __re) { __re_ = __re; }
+  void imag(value_type __im) { __im_ = __im; }
+
+  complex =(const value_type &__re) {
+__re_ = __re;
+__im_ = value_type();
+return *this;
+  }
+  complex +=(const value_type &__re) {
+__re_ += __re;
+return *this;
+  }
+  complex =(const value_type &__re) {
+__re_ -= __re;
+return *this;
+  }
+  complex *=(const value_type &__re) {
+__re_ *= __re;
+__im_ *= __re;
+return *this;
+  }
+  complex /=(const value_type &__re) {
+__re_ /= __re;
+__im_ /= __re;
+return *this;
+  }
+
+  template 
+  complex =(const complex<_Xp> &__c) {
+__re_ = __c.real();
+__im_ = __c.imag();
+return *this;
+  }
+  template 
+  complex +=(const complex<_Xp> &__c) {
+__re_ += __c.real();
+__im_ += __c.imag();
+return *this;
+  }
+  template 
+  complex =(const complex<_Xp> &__c) {
+__re_ -= __c.real();
+__im_ -= 

[PATCH] D80896: [clang-tidy][misc-redundant-expression] Fix crash on CXXFoldExpr

2020-05-31 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis updated this revision to Diff 267518.
zinovy.nis added a comment.

Fix formatting.


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

https://reviews.llvm.org/D80896

Files:
  clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
@@ -793,4 +793,10 @@
 return foo < GetFoo() && foo < maybe_foo;
   }
 };
+
+template 
+struct Bar2 {
+  static_assert(
+  (... && (sizeof(Values) > 0)) || (... && (sizeof(Values) < 0)));
+};
 }
Index: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -72,7 +72,8 @@
   Expr::const_child_iterator LeftIter = Left->child_begin();
   Expr::const_child_iterator RightIter = Right->child_begin();
   while (LeftIter != Left->child_end() && RightIter != Right->child_end()) {
-if (!areEquivalentExpr(dyn_cast(*LeftIter),
+if (*LeftIter && *RightIter &&
+!areEquivalentExpr(dyn_cast(*LeftIter),
dyn_cast(*RightIter)))
   return false;
 ++LeftIter;
@@ -117,6 +118,14 @@
   case Stmt::MemberExprClass:
 return cast(Left)->getMemberDecl() ==
cast(Right)->getMemberDecl();
+  case Stmt::CXXFoldExprClass: {
+const auto LeftLHS = cast(Left)->getLHS();
+const auto RightLHS = cast(Right)->getLHS();
+const auto LeftRHS = cast(Left)->getRHS();
+const auto RightRHS = cast(Right)->getRHS();
+return areEquivalentExpr(LeftLHS, RightLHS) &&
+   areEquivalentExpr(LeftRHS, RightRHS);
+  }
   case Stmt::CXXFunctionalCastExprClass:
   case Stmt::CStyleCastExprClass:
 return cast(Left)->getTypeAsWritten() ==


Index: clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
@@ -793,4 +793,10 @@
 return foo < GetFoo() && foo < maybe_foo;
   }
 };
+
+template 
+struct Bar2 {
+  static_assert(
+  (... && (sizeof(Values) > 0)) || (... && (sizeof(Values) < 0)));
+};
 }
Index: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -72,7 +72,8 @@
   Expr::const_child_iterator LeftIter = Left->child_begin();
   Expr::const_child_iterator RightIter = Right->child_begin();
   while (LeftIter != Left->child_end() && RightIter != Right->child_end()) {
-if (!areEquivalentExpr(dyn_cast(*LeftIter),
+if (*LeftIter && *RightIter &&
+!areEquivalentExpr(dyn_cast(*LeftIter),
dyn_cast(*RightIter)))
   return false;
 ++LeftIter;
@@ -117,6 +118,14 @@
   case Stmt::MemberExprClass:
 return cast(Left)->getMemberDecl() ==
cast(Right)->getMemberDecl();
+  case Stmt::CXXFoldExprClass: {
+const auto LeftLHS = cast(Left)->getLHS();
+const auto RightLHS = cast(Right)->getLHS();
+const auto LeftRHS = cast(Left)->getRHS();
+const auto RightRHS = cast(Right)->getRHS();
+return areEquivalentExpr(LeftLHS, RightLHS) &&
+   areEquivalentExpr(LeftRHS, RightRHS);
+  }
   case Stmt::CXXFunctionalCastExprClass:
   case Stmt::CStyleCastExprClass:
 return cast(Left)->getTypeAsWritten() ==
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80896: [clang-tidy][misc-redundant-expression] Fix crash on CXXFoldExpr

2020-05-31 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis created this revision.
zinovy.nis added a reviewer: etienneb.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

Fix for a crash from https://bugs.llvm.org/show_bug.cgi?id=44256

Bug: https://bugs.llvm.org/show_bug.cgi?id=44256


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80896

Files:
  clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
@@ -793,4 +793,10 @@
 return foo < GetFoo() && foo < maybe_foo;
   }
 };
+
+template 
+struct Bar2 {
+  static_assert(
+  (... && (sizeof(Values) > 0)) || (... && (sizeof(Values) < 0)));
+};
 }
Index: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -72,7 +72,7 @@
   Expr::const_child_iterator LeftIter = Left->child_begin();
   Expr::const_child_iterator RightIter = Right->child_begin();
   while (LeftIter != Left->child_end() && RightIter != Right->child_end()) {
-if (!areEquivalentExpr(dyn_cast(*LeftIter),
+if (*LeftIter && *RightIter && 
!areEquivalentExpr(dyn_cast(*LeftIter),
dyn_cast(*RightIter)))
   return false;
 ++LeftIter;
@@ -117,6 +117,13 @@
   case Stmt::MemberExprClass:
 return cast(Left)->getMemberDecl() ==
cast(Right)->getMemberDecl();
+  case Stmt::CXXFoldExprClass: {
+const auto LeftLHS = cast(Left)->getLHS();
+const auto RightLHS = cast(Right)->getLHS();
+const auto LeftRHS = cast(Left)->getRHS();
+const auto RightRHS = cast(Right)->getRHS();
+return areEquivalentExpr(LeftLHS, RightLHS) && areEquivalentExpr(LeftRHS, 
RightRHS);
+  }
   case Stmt::CXXFunctionalCastExprClass:
   case Stmt::CStyleCastExprClass:
 return cast(Left)->getTypeAsWritten() ==


Index: clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
@@ -793,4 +793,10 @@
 return foo < GetFoo() && foo < maybe_foo;
   }
 };
+
+template 
+struct Bar2 {
+  static_assert(
+  (... && (sizeof(Values) > 0)) || (... && (sizeof(Values) < 0)));
+};
 }
Index: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -72,7 +72,7 @@
   Expr::const_child_iterator LeftIter = Left->child_begin();
   Expr::const_child_iterator RightIter = Right->child_begin();
   while (LeftIter != Left->child_end() && RightIter != Right->child_end()) {
-if (!areEquivalentExpr(dyn_cast(*LeftIter),
+if (*LeftIter && *RightIter && !areEquivalentExpr(dyn_cast(*LeftIter),
dyn_cast(*RightIter)))
   return false;
 ++LeftIter;
@@ -117,6 +117,13 @@
   case Stmt::MemberExprClass:
 return cast(Left)->getMemberDecl() ==
cast(Right)->getMemberDecl();
+  case Stmt::CXXFoldExprClass: {
+const auto LeftLHS = cast(Left)->getLHS();
+const auto RightLHS = cast(Right)->getLHS();
+const auto LeftRHS = cast(Left)->getRHS();
+const auto RightRHS = cast(Right)->getRHS();
+return areEquivalentExpr(LeftLHS, RightLHS) && areEquivalentExpr(LeftRHS, RightRHS);
+  }
   case Stmt::CXXFunctionalCastExprClass:
   case Stmt::CStyleCastExprClass:
 return cast(Left)->getTypeAsWritten() ==
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80887: [clang-tidy] ignore builtin varargs from pro-type-vararg-check

2020-05-31 Thread Nathan James via Phabricator via cfe-commits
njames93 marked an inline comment as done.
njames93 added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp:21
 
+// FIXME: Add any more builtin variadics that shouldn't trigger this
+static constexpr StringRef AllowedVariadics[] = {

aaron.ballman wrote:
> njames93 wrote:
> > aaron.ballman wrote:
> > > How would we know which builtins should or should not trigger this? Can 
> > > we add that information to this comment (or, better yet, just fix the 
> > > fixme up front)?
> > Good point, its more a case that I don't know all the variadic builtins 
> > clang supports. Those ones I included are just the ones you find in the gcc 
> > documentation. Shall I just remove the Fixme completely, If there is 
> > another one that's been missed we can address that later
> Taking a look at Builtins.def shows quite a few more that likely should be 
> added to the list. I think we should probably have the initial commit 
> covering anything that's a C standard library function/macro that ends with 
> "." in its builtin type signature where the C API isn't variadic. For 
> instance, `__builtin_isfinite`, `__builtin_isinf`, etc. I'm fine if we don't 
> vet every builtin we support (that's a large amount of work), but we should 
> be able to cover the most common cases where there's a specification to 
> compare against.
```
BUILTIN(__builtin_isgreater , "i.", "Fnct")
BUILTIN(__builtin_isgreaterequal, "i.", "Fnct")
BUILTIN(__builtin_isless, "i.", "Fnct")
BUILTIN(__builtin_islessequal   , "i.", "Fnct")
BUILTIN(__builtin_islessgreater , "i.", "Fnct")
BUILTIN(__builtin_isunordered   , "i.", "Fnct")
BUILTIN(__builtin_fpclassify, "ii.", "Fnct")
BUILTIN(__builtin_isfinite,   "i.", "Fnct")
BUILTIN(__builtin_isinf,  "i.", "Fnct")
BUILTIN(__builtin_isinf_sign, "i.", "Fnct")
BUILTIN(__builtin_isnan,  "i.", "Fnct")
BUILTIN(__builtin_isnormal,   "i.", "Fnct")
BUILTIN(__builtin_signbit, "i.", "Fnct")
BUILTIN(__builtin_constant_p, "i.", "nctu")
BUILTIN(__builtin_classify_type, "i.", "nctu")
BUILTIN(__builtin_va_start, "vA.", "nt")
BUILTIN(__builtin_stdarg_start, "vA.", "nt")
BUILTIN(__builtin_assume_aligned, "v*vC*z.", "nc")
BUILTIN(__builtin_fprintf, "iP*cC*.", "Fp:1:")
BUILTIN(__builtin_printf, "icC*.", "Fp:0:")
BUILTIN(__builtin_snprintf, "ic*zcC*.", "nFp:2:")
BUILTIN(__builtin___snprintf_chk, "ic*zizcC*.", "Fp:4:")
BUILTIN(__builtin___sprintf_chk, "ic*izcC*.", "Fp:3:")
BUILTIN(__builtin___fprintf_chk, "iP*icC*.", "Fp:2:")
BUILTIN(__builtin___printf_chk, "iicC*.", "Fp:1:")
BUILTIN(__builtin_prefetch, "vvC*.", "nc")
BUILTIN(__builtin_shufflevector, "v."   , "nct")
BUILTIN(__builtin_convertvector, "v."   , "nct")
BUILTIN(__builtin_call_with_static_chain, "v.", "nt")
BUILTIN(__builtin_annotation, "v.", "tn")
BUILTIN(__builtin_add_overflow, "b.", "nt")
BUILTIN(__builtin_sub_overflow, "b.", "nt")
BUILTIN(__builtin_mul_overflow, "b.", "nt")
BUILTIN(__builtin_preserve_access_index, "v.", "t")
BUILTIN(__builtin_nontemporal_store, "v.", "t")
BUILTIN(__builtin_nontemporal_load, "v.", "t")
BUILTIN(__builtin_os_log_format_buffer_size, "zcC*.", "p:0:nut")
BUILTIN(__builtin_os_log_format, "v*v*cC*.", "p:0:nt")
BUILTIN(__builtin_ms_va_start, "vc*&.", "nt")```
That's all the variadics inside `Builtin.def` that are called `__builtin...`.
Would you suggest including all those apart from the va, print or format 
related ones


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80887



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


[PATCH] D80631: [clang-tidy] RenamerClangTidyChecks ignore builtin and command line macros

2020-05-31 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D80631#2065168 , @MaskRay wrote:

> `arc` adds many unneeded tags from Phabricator. You can drop `Reviewers:` 
> `Subscribers:` `Tags:` and the text `Summary:` with the following script:
>
>   arcfilter () {
> arc amend
> git log -1 --pretty=%B | awk '/Reviewers:|Subscribers:/{p=1} /Reviewed 
> By:|Differential Revision:/{p=0} !p && !/^Summary:$/ {sub(/^Summary: 
> /,"");print}' | git commit --amend --date=now -F -
>   }
>   
>
> `Reviewed By: ` is considered important by some people 
> (https://lists.llvm.org/pipermail/llvm-dev/2020-January/137889.html). You 
> should keep the tag. (I started to use `--date=now` because some people find 
> author date != committer date annoying. The committer date is usually what 
> people care.))


Thanks for this, got it working nicely here 
https://github.com/llvm/llvm-project/commit/5952125691571de9bd817551fb1baabe270e73f9


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80631



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


[PATCH] D80879: clang-tidy and clang-query wont crash with invalid command line options

2020-05-31 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG595212569157: clang-tidy and clang-query wont crash with 
invalid command line options (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80879

Files:
  clang-tools-extra/clang-query/tool/ClangQuery.cpp
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/test/clang-query/invalid-command-line.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/invalid-command-line.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/invalid-command-line.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/invalid-command-line.cpp
@@ -0,0 +1,4 @@
+// RUN: not clang-tidy --invalid-arg 2>&1 | FileCheck %s
+
+// CHECK: error: [CommonOptionsParser]: clang-tidy{{(\.exe)?}}: Unknown command line argument '--invalid-arg'.  Try: 'clang-tidy{{(\.exe)?}} --help'
+// CHECK-NEXT: clang-tidy{{(\.exe)?}}: Did you mean '--extra-arg'?
Index: clang-tools-extra/test/clang-query/invalid-command-line.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-query/invalid-command-line.cpp
@@ -0,0 +1,4 @@
+// RUN: not clang-query --invalid-arg 2>&1 | FileCheck %s
+
+// CHECK: error: [CommonOptionsParser]: clang-query{{(\.exe)?}}: Unknown command line argument '--invalid-arg'.  Try: 'clang-query{{(\.exe)?}} --help'
+// CHECK-NEXT: clang-query{{(\.exe)?}}: Did you mean '--extra-arg'?
Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -23,6 +23,7 @@
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/WithColor.h"
 
 using namespace clang::ast_matchers;
 using namespace clang::driver;
@@ -333,8 +334,14 @@
 
 int clangTidyMain(int argc, const char **argv) {
   llvm::InitLLVM X(argc, argv);
-  CommonOptionsParser OptionsParser(argc, argv, ClangTidyCategory,
-cl::ZeroOrMore);
+  llvm::Expected OptionsParser =
+  CommonOptionsParser::create(argc, argv, ClangTidyCategory,
+  cl::ZeroOrMore);
+  if (!OptionsParser) {
+llvm::WithColor::error() << llvm::toString(OptionsParser.takeError());
+return 1;
+  }
+
   llvm::IntrusiveRefCntPtr BaseFS(
   new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
 
@@ -365,7 +372,7 @@
   SmallString<256> ProfilePrefix = MakeAbsolute(StoreCheckProfile);
 
   StringRef FileName("dummy");
-  auto PathList = OptionsParser.getSourcePathList();
+  auto PathList = OptionsParser->getSourcePathList();
   if (!PathList.empty()) {
 FileName = PathList.front();
   }
@@ -433,7 +440,7 @@
   ClangTidyContext Context(std::move(OwningOptionsProvider),
AllowEnablingAnalyzerAlphaCheckers);
   std::vector Errors =
-  runClangTidy(Context, OptionsParser.getCompilations(), PathList, BaseFS,
+  runClangTidy(Context, OptionsParser->getCompilations(), PathList, BaseFS,
EnableCheckProfile, ProfilePrefix);
   bool FoundErrors = llvm::find_if(Errors, [](const ClangTidyError ) {
return E.DiagLevel == ClangTidyError::Error;
Index: clang-tools-extra/clang-query/tool/ClangQuery.cpp
===
--- clang-tools-extra/clang-query/tool/ClangQuery.cpp
+++ clang-tools-extra/clang-query/tool/ClangQuery.cpp
@@ -35,6 +35,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/WithColor.h"
 #include 
 #include 
 
@@ -86,7 +87,14 @@
 int main(int argc, const char **argv) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
 
-  CommonOptionsParser OptionsParser(argc, argv, ClangQueryCategory);
+  llvm::Expected OptionsParser =
+  CommonOptionsParser::create(argc, argv, ClangQueryCategory,
+  llvm::cl::OneOrMore);
+
+  if (!OptionsParser) {
+llvm::WithColor::error() << llvm::toString(OptionsParser.takeError());
+return 1;
+  }
 
   if (!Commands.empty() && !CommandFiles.empty()) {
 llvm::errs() << argv[0] << ": cannot specify both -c and -f\n";
@@ -99,8 +107,8 @@
 return 1;
   }
 
-  ClangTool Tool(OptionsParser.getCompilations(),
- OptionsParser.getSourcePathList());
+  ClangTool Tool(OptionsParser->getCompilations(),
+ OptionsParser->getSourcePathList());
   std::vector> ASTs;
   int Status = Tool.buildASTs(ASTs);
   int ASTStatus = 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D80879: clang-tidy and clang-query wont crash with invalid command line options

2020-05-31 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 267505.
njames93 added a comment.

Actually fix the windows builds


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80879

Files:
  clang-tools-extra/clang-query/tool/ClangQuery.cpp
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/test/clang-query/invalid-command-line.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/invalid-command-line.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/invalid-command-line.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/invalid-command-line.cpp
@@ -0,0 +1,4 @@
+// RUN: not clang-tidy --invalid-arg 2>&1 | FileCheck %s
+
+// CHECK: error: [CommonOptionsParser]: clang-tidy{{(\.exe)?}}: Unknown command line argument '--invalid-arg'.  Try: 'clang-tidy{{(\.exe)?}} --help'
+// CHECK-NEXT: clang-tidy{{(\.exe)?}}: Did you mean '--extra-arg'?
Index: clang-tools-extra/test/clang-query/invalid-command-line.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-query/invalid-command-line.cpp
@@ -0,0 +1,4 @@
+// RUN: not clang-query --invalid-arg 2>&1 | FileCheck %s
+
+// CHECK: error: [CommonOptionsParser]: clang-query{{(\.exe)?}}: Unknown command line argument '--invalid-arg'.  Try: 'clang-query{{(\.exe)?}} --help'
+// CHECK-NEXT: clang-query{{(\.exe)?}}: Did you mean '--extra-arg'?
Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -23,6 +23,7 @@
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/WithColor.h"
 
 using namespace clang::ast_matchers;
 using namespace clang::driver;
@@ -333,8 +334,14 @@
 
 int clangTidyMain(int argc, const char **argv) {
   llvm::InitLLVM X(argc, argv);
-  CommonOptionsParser OptionsParser(argc, argv, ClangTidyCategory,
-cl::ZeroOrMore);
+  llvm::Expected OptionsParser =
+  CommonOptionsParser::create(argc, argv, ClangTidyCategory,
+  cl::ZeroOrMore);
+  if (!OptionsParser) {
+llvm::WithColor::error() << llvm::toString(OptionsParser.takeError());
+return 1;
+  }
+
   llvm::IntrusiveRefCntPtr BaseFS(
   new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
 
@@ -365,7 +372,7 @@
   SmallString<256> ProfilePrefix = MakeAbsolute(StoreCheckProfile);
 
   StringRef FileName("dummy");
-  auto PathList = OptionsParser.getSourcePathList();
+  auto PathList = OptionsParser->getSourcePathList();
   if (!PathList.empty()) {
 FileName = PathList.front();
   }
@@ -433,7 +440,7 @@
   ClangTidyContext Context(std::move(OwningOptionsProvider),
AllowEnablingAnalyzerAlphaCheckers);
   std::vector Errors =
-  runClangTidy(Context, OptionsParser.getCompilations(), PathList, BaseFS,
+  runClangTidy(Context, OptionsParser->getCompilations(), PathList, BaseFS,
EnableCheckProfile, ProfilePrefix);
   bool FoundErrors = llvm::find_if(Errors, [](const ClangTidyError ) {
return E.DiagLevel == ClangTidyError::Error;
Index: clang-tools-extra/clang-query/tool/ClangQuery.cpp
===
--- clang-tools-extra/clang-query/tool/ClangQuery.cpp
+++ clang-tools-extra/clang-query/tool/ClangQuery.cpp
@@ -35,6 +35,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/WithColor.h"
 #include 
 #include 
 
@@ -86,7 +87,14 @@
 int main(int argc, const char **argv) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
 
-  CommonOptionsParser OptionsParser(argc, argv, ClangQueryCategory);
+  llvm::Expected OptionsParser =
+  CommonOptionsParser::create(argc, argv, ClangQueryCategory,
+  llvm::cl::OneOrMore);
+
+  if (!OptionsParser) {
+llvm::WithColor::error() << llvm::toString(OptionsParser.takeError());
+return 1;
+  }
 
   if (!Commands.empty() && !CommandFiles.empty()) {
 llvm::errs() << argv[0] << ": cannot specify both -c and -f\n";
@@ -99,8 +107,8 @@
 return 1;
   }
 
-  ClangTool Tool(OptionsParser.getCompilations(),
- OptionsParser.getSourcePathList());
+  ClangTool Tool(OptionsParser->getCompilations(),
+ OptionsParser->getSourcePathList());
   std::vector> ASTs;
   int Status = Tool.buildASTs(ASTs);
   int ASTStatus = 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 5952125 - clang-tidy and clang-query wont crash with invalid command line options

2020-05-31 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-05-31T17:41:29+01:00
New Revision: 5952125691571de9bd817551fb1baabe270e73f9

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

LOG: clang-tidy and clang-query wont crash with invalid command line options

Motivated by [[ https://bugs.llvm.org/show_bug.cgi?id=46141 | clang-tidy 
crashed for unknown command line argument. ]]

Reviewed By: aaron.ballman, thakis

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

Added: 
clang-tools-extra/test/clang-query/invalid-command-line.cpp
clang-tools-extra/test/clang-tidy/infrastructure/invalid-command-line.cpp

Modified: 
clang-tools-extra/clang-query/tool/ClangQuery.cpp
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-query/tool/ClangQuery.cpp 
b/clang-tools-extra/clang-query/tool/ClangQuery.cpp
index 5cfa0acf9120..0c471def2e14 100644
--- a/clang-tools-extra/clang-query/tool/ClangQuery.cpp
+++ b/clang-tools-extra/clang-query/tool/ClangQuery.cpp
@@ -35,6 +35,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/WithColor.h"
 #include 
 #include 
 
@@ -86,7 +87,14 @@ bool runCommandsInFile(const char *ExeName, std::string 
const ,
 int main(int argc, const char **argv) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
 
-  CommonOptionsParser OptionsParser(argc, argv, ClangQueryCategory);
+  llvm::Expected OptionsParser =
+  CommonOptionsParser::create(argc, argv, ClangQueryCategory,
+  llvm::cl::OneOrMore);
+
+  if (!OptionsParser) {
+llvm::WithColor::error() << llvm::toString(OptionsParser.takeError());
+return 1;
+  }
 
   if (!Commands.empty() && !CommandFiles.empty()) {
 llvm::errs() << argv[0] << ": cannot specify both -c and -f\n";
@@ -99,8 +107,8 @@ int main(int argc, const char **argv) {
 return 1;
   }
 
-  ClangTool Tool(OptionsParser.getCompilations(),
- OptionsParser.getSourcePathList());
+  ClangTool Tool(OptionsParser->getCompilations(),
+ OptionsParser->getSourcePathList());
   std::vector> ASTs;
   int Status = Tool.buildASTs(ASTs);
   int ASTStatus = 0;

diff  --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp 
b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
index 665d10026834..aca16b0d6d81 100644
--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -23,6 +23,7 @@
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/WithColor.h"
 
 using namespace clang::ast_matchers;
 using namespace clang::driver;
@@ -333,8 +334,14 @@ getVfsFromFile(const std::string ,
 
 int clangTidyMain(int argc, const char **argv) {
   llvm::InitLLVM X(argc, argv);
-  CommonOptionsParser OptionsParser(argc, argv, ClangTidyCategory,
-cl::ZeroOrMore);
+  llvm::Expected OptionsParser =
+  CommonOptionsParser::create(argc, argv, ClangTidyCategory,
+  cl::ZeroOrMore);
+  if (!OptionsParser) {
+llvm::WithColor::error() << llvm::toString(OptionsParser.takeError());
+return 1;
+  }
+
   llvm::IntrusiveRefCntPtr BaseFS(
   new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
 
@@ -365,7 +372,7 @@ int clangTidyMain(int argc, const char **argv) {
   SmallString<256> ProfilePrefix = MakeAbsolute(StoreCheckProfile);
 
   StringRef FileName("dummy");
-  auto PathList = OptionsParser.getSourcePathList();
+  auto PathList = OptionsParser->getSourcePathList();
   if (!PathList.empty()) {
 FileName = PathList.front();
   }
@@ -433,7 +440,7 @@ int clangTidyMain(int argc, const char **argv) {
   ClangTidyContext Context(std::move(OwningOptionsProvider),
AllowEnablingAnalyzerAlphaCheckers);
   std::vector Errors =
-  runClangTidy(Context, OptionsParser.getCompilations(), PathList, BaseFS,
+  runClangTidy(Context, OptionsParser->getCompilations(), PathList, BaseFS,
EnableCheckProfile, ProfilePrefix);
   bool FoundErrors = llvm::find_if(Errors, [](const ClangTidyError ) {
return E.DiagLevel == ClangTidyError::Error;

diff  --git a/clang-tools-extra/test/clang-query/invalid-command-line.cpp 
b/clang-tools-extra/test/clang-query/invalid-command-line.cpp
new file mode 100644
index ..901aad8c1f23
--- /dev/null
+++ b/clang-tools-extra/test/clang-query/invalid-command-line.cpp
@@ -0,0 +1,4 @@
+// RUN: not clang-query --invalid-arg 2>&1 | FileCheck %s
+
+// CHECK: error: [CommonOptionsParser]: clang-query{{(\.exe)?}}: Unknown 
command line argument '--invalid-arg'.  

[PATCH] D80879: clang-tidy and clang-query wont crash with invalid command line options

2020-05-31 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D80879#2065364 , @thakis wrote:

> Test fix looks good as far as I can tell. Landing and seeing what the bot 
> says is ok. It's fine for some of the bots to be red for a short while as 
> long as it isn't hours. Thanks!


I'm unsure about one part(the `CHECK-NEXT` lines, just wanna see what the pre 
merge bot says.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80879



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


[PATCH] D80887: [clang-tidy] ignore builtin varargs from pro-type-vararg-check

2020-05-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp:21
 
+// FIXME: Add any more builtin variadics that shouldn't trigger this
+static constexpr StringRef AllowedVariadics[] = {

njames93 wrote:
> aaron.ballman wrote:
> > How would we know which builtins should or should not trigger this? Can we 
> > add that information to this comment (or, better yet, just fix the fixme up 
> > front)?
> Good point, its more a case that I don't know all the variadic builtins clang 
> supports. Those ones I included are just the ones you find in the gcc 
> documentation. Shall I just remove the Fixme completely, If there is another 
> one that's been missed we can address that later
Taking a look at Builtins.def shows quite a few more that likely should be 
added to the list. I think we should probably have the initial commit covering 
anything that's a C standard library function/macro that ends with "." in its 
builtin type signature where the C API isn't variadic. For instance, 
`__builtin_isfinite`, `__builtin_isinf`, etc. I'm fine if we don't vet every 
builtin we support (that's a large amount of work), but we should be able to 
cover the most common cases where there's a specification to compare against.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80887



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


[PATCH] D80879: clang-tidy and clang-query wont crash with invalid command line options

2020-05-31 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.

Test fix looks good as far as I can tell. Landing and seeing what the bot says 
is ok. It's fine for some of the bots to be red for a short while as long as it 
isn't hours. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80879



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


[PATCH] D80879: clang-tidy and clang-query wont crash with invalid command line options

2020-05-31 Thread Nathan James via Phabricator via cfe-commits
njames93 reopened this revision.
njames93 added a comment.
This revision is now accepted and ready to land.

In D80879#2065350 , @thakis wrote:

> This breaks check-clang-tools on windows: 
> http://45.33.8.238/win/16485/step_8.txt
>
> Looks like you need to optionally allow a .exe suffix in the test. Please 
> take a look, and revert if it takes a while until you can fix.
>
> (I'm on a phone, else I'd fix myself.)


Just seen the buildbot, I've reverted it for now. Don't have windows to test so 
didnt want to fire away more breaking commits


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80879



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


[PATCH] D80879: clang-tidy and clang-query wont crash with invalid command line options

2020-05-31 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 267504.
njames93 added a comment.

Hopefully fix windows test cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80879

Files:
  clang-tools-extra/clang-query/tool/ClangQuery.cpp
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/test/clang-query/invalid-command-line.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/invalid-command-line.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/invalid-command-line.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/invalid-command-line.cpp
@@ -0,0 +1,4 @@
+// RUN: not clang-tidy --invalid-arg 2>&1 | FileCheck %s
+
+// CHECK: error: [CommonOptionsParser]: clang-tidy{{(\.exe)?}}: Unknown command line argument '--invalid-arg'.  Try: 'clang-tidy{{(\.exe)?}} --help'
+// CHECK-NEXT: clang-tidy: Did you mean '--extra-arg'?
Index: clang-tools-extra/test/clang-query/invalid-command-line.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-query/invalid-command-line.cpp
@@ -0,0 +1,4 @@
+// RUN: not clang-query --invalid-arg 2>&1 | FileCheck %s
+
+// CHECK: error: [CommonOptionsParser]: clang-query{{(\.exe)?}}: Unknown command line argument '--invalid-arg'.  Try: 'clang-query{{(\.exe)?}} --help'
+// CHECK-NEXT: clang-query: Did you mean '--extra-arg'?
Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -23,6 +23,7 @@
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/WithColor.h"
 
 using namespace clang::ast_matchers;
 using namespace clang::driver;
@@ -333,8 +334,14 @@
 
 int clangTidyMain(int argc, const char **argv) {
   llvm::InitLLVM X(argc, argv);
-  CommonOptionsParser OptionsParser(argc, argv, ClangTidyCategory,
-cl::ZeroOrMore);
+  llvm::Expected OptionsParser =
+  CommonOptionsParser::create(argc, argv, ClangTidyCategory,
+  cl::ZeroOrMore);
+  if (!OptionsParser) {
+llvm::WithColor::error() << llvm::toString(OptionsParser.takeError());
+return 1;
+  }
+
   llvm::IntrusiveRefCntPtr BaseFS(
   new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
 
@@ -365,7 +372,7 @@
   SmallString<256> ProfilePrefix = MakeAbsolute(StoreCheckProfile);
 
   StringRef FileName("dummy");
-  auto PathList = OptionsParser.getSourcePathList();
+  auto PathList = OptionsParser->getSourcePathList();
   if (!PathList.empty()) {
 FileName = PathList.front();
   }
@@ -433,7 +440,7 @@
   ClangTidyContext Context(std::move(OwningOptionsProvider),
AllowEnablingAnalyzerAlphaCheckers);
   std::vector Errors =
-  runClangTidy(Context, OptionsParser.getCompilations(), PathList, BaseFS,
+  runClangTidy(Context, OptionsParser->getCompilations(), PathList, BaseFS,
EnableCheckProfile, ProfilePrefix);
   bool FoundErrors = llvm::find_if(Errors, [](const ClangTidyError ) {
return E.DiagLevel == ClangTidyError::Error;
Index: clang-tools-extra/clang-query/tool/ClangQuery.cpp
===
--- clang-tools-extra/clang-query/tool/ClangQuery.cpp
+++ clang-tools-extra/clang-query/tool/ClangQuery.cpp
@@ -35,6 +35,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/WithColor.h"
 #include 
 #include 
 
@@ -86,7 +87,14 @@
 int main(int argc, const char **argv) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
 
-  CommonOptionsParser OptionsParser(argc, argv, ClangQueryCategory);
+  llvm::Expected OptionsParser =
+  CommonOptionsParser::create(argc, argv, ClangQueryCategory,
+  llvm::cl::OneOrMore);
+
+  if (!OptionsParser) {
+llvm::WithColor::error() << llvm::toString(OptionsParser.takeError());
+return 1;
+  }
 
   if (!Commands.empty() && !CommandFiles.empty()) {
 llvm::errs() << argv[0] << ": cannot specify both -c and -f\n";
@@ -99,8 +107,8 @@
 return 1;
   }
 
-  ClangTool Tool(OptionsParser.getCompilations(),
- OptionsParser.getSourcePathList());
+  ClangTool Tool(OptionsParser->getCompilations(),
+ OptionsParser->getSourcePathList());
   std::vector> ASTs;
   int Status = Tool.buildASTs(ASTs);
   int ASTStatus = 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80804: [AMDGPU] Introduce Clang builtins to be mapped to AMDGCN atomic inc/dec intrinsics

2020-05-31 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam added a comment.

Thank you @sameerds for the clarification. Sure, I will wait for @arsenm to 
review it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80804



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


[clang-tools-extra] f4b0ebb - Revert "clang-tidy and clang-query wont crash with invalid command line options"

2020-05-31 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-05-31T16:40:09+01:00
New Revision: f4b0ebb89b3086a2bdd8c7dd1f5d142fa09ca728

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

LOG: Revert "clang-tidy and clang-query wont crash with invalid command line 
options"

This reverts commit f23ddbe3c3ae5f40b99ba272afc3d16b800ba8b9.

Added: 


Modified: 
clang-tools-extra/clang-query/tool/ClangQuery.cpp
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp

Removed: 
clang-tools-extra/test/clang-query/invalid-command-line.cpp
clang-tools-extra/test/clang-tidy/infrastructure/invalid-command-line.cpp



diff  --git a/clang-tools-extra/clang-query/tool/ClangQuery.cpp 
b/clang-tools-extra/clang-query/tool/ClangQuery.cpp
index 0c471def2e14..5cfa0acf9120 100644
--- a/clang-tools-extra/clang-query/tool/ClangQuery.cpp
+++ b/clang-tools-extra/clang-query/tool/ClangQuery.cpp
@@ -35,7 +35,6 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Signals.h"
-#include "llvm/Support/WithColor.h"
 #include 
 #include 
 
@@ -87,14 +86,7 @@ bool runCommandsInFile(const char *ExeName, std::string 
const ,
 int main(int argc, const char **argv) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
 
-  llvm::Expected OptionsParser =
-  CommonOptionsParser::create(argc, argv, ClangQueryCategory,
-  llvm::cl::OneOrMore);
-
-  if (!OptionsParser) {
-llvm::WithColor::error() << llvm::toString(OptionsParser.takeError());
-return 1;
-  }
+  CommonOptionsParser OptionsParser(argc, argv, ClangQueryCategory);
 
   if (!Commands.empty() && !CommandFiles.empty()) {
 llvm::errs() << argv[0] << ": cannot specify both -c and -f\n";
@@ -107,8 +99,8 @@ int main(int argc, const char **argv) {
 return 1;
   }
 
-  ClangTool Tool(OptionsParser->getCompilations(),
- OptionsParser->getSourcePathList());
+  ClangTool Tool(OptionsParser.getCompilations(),
+ OptionsParser.getSourcePathList());
   std::vector> ASTs;
   int Status = Tool.buildASTs(ASTs);
   int ASTStatus = 0;

diff  --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp 
b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
index aca16b0d6d81..665d10026834 100644
--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -23,7 +23,6 @@
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
-#include "llvm/Support/WithColor.h"
 
 using namespace clang::ast_matchers;
 using namespace clang::driver;
@@ -334,14 +333,8 @@ getVfsFromFile(const std::string ,
 
 int clangTidyMain(int argc, const char **argv) {
   llvm::InitLLVM X(argc, argv);
-  llvm::Expected OptionsParser =
-  CommonOptionsParser::create(argc, argv, ClangTidyCategory,
-  cl::ZeroOrMore);
-  if (!OptionsParser) {
-llvm::WithColor::error() << llvm::toString(OptionsParser.takeError());
-return 1;
-  }
-
+  CommonOptionsParser OptionsParser(argc, argv, ClangTidyCategory,
+cl::ZeroOrMore);
   llvm::IntrusiveRefCntPtr BaseFS(
   new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
 
@@ -372,7 +365,7 @@ int clangTidyMain(int argc, const char **argv) {
   SmallString<256> ProfilePrefix = MakeAbsolute(StoreCheckProfile);
 
   StringRef FileName("dummy");
-  auto PathList = OptionsParser->getSourcePathList();
+  auto PathList = OptionsParser.getSourcePathList();
   if (!PathList.empty()) {
 FileName = PathList.front();
   }
@@ -440,7 +433,7 @@ int clangTidyMain(int argc, const char **argv) {
   ClangTidyContext Context(std::move(OwningOptionsProvider),
AllowEnablingAnalyzerAlphaCheckers);
   std::vector Errors =
-  runClangTidy(Context, OptionsParser->getCompilations(), PathList, BaseFS,
+  runClangTidy(Context, OptionsParser.getCompilations(), PathList, BaseFS,
EnableCheckProfile, ProfilePrefix);
   bool FoundErrors = llvm::find_if(Errors, [](const ClangTidyError ) {
return E.DiagLevel == ClangTidyError::Error;

diff  --git a/clang-tools-extra/test/clang-query/invalid-command-line.cpp 
b/clang-tools-extra/test/clang-query/invalid-command-line.cpp
deleted file mode 100644
index 10ab43198b4e..
--- a/clang-tools-extra/test/clang-query/invalid-command-line.cpp
+++ /dev/null
@@ -1,4 +0,0 @@
-// RUN: not clang-query --invalid-arg 2>&1 | FileCheck %s
-
-// CHECK: error: [CommonOptionsParser]: clang-query: Unknown command line 
argument '--invalid-arg'.  Try: 'clang-query --help'
-// CHECK-NEXT: clang-query: Did you mean '--extra-arg'?

diff  --git 

[PATCH] D80879: clang-tidy and clang-query wont crash with invalid command line options

2020-05-31 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This breaks check-clang-tools on windows: 
http://45.33.8.238/win/16485/step_8.txt

Looks like you need to optionally allow a .exe suffix in the test. Please take 
a look, and revert if it takes a while until you can fix.

(I'm on a phone, else I'd fix myself.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80879



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


[PATCH] D80879: clang-tidy and clang-query wont crash with invalid command line options

2020-05-31 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 267501.
njames93 added a comment.

Added test coverage.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80879

Files:
  clang-tools-extra/clang-query/tool/ClangQuery.cpp
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/test/clang-query/invalid-command-line.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/invalid-command-line.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/invalid-command-line.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/invalid-command-line.cpp
@@ -0,0 +1,4 @@
+// RUN: not clang-tidy --invalid-arg 2>&1 | FileCheck %s
+
+// CHECK: error: [CommonOptionsParser]: clang-tidy: Unknown command line argument '--invalid-arg'.  Try: 'clang-tidy --help'
+// CHECK-NEXT: clang-tidy: Did you mean '--extra-arg'?
Index: clang-tools-extra/test/clang-query/invalid-command-line.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-query/invalid-command-line.cpp
@@ -0,0 +1,4 @@
+// RUN: not clang-query --invalid-arg 2>&1 | FileCheck %s
+
+// CHECK: error: [CommonOptionsParser]: clang-query: Unknown command line argument '--invalid-arg'.  Try: 'clang-query --help'
+// CHECK-NEXT: clang-query: Did you mean '--extra-arg'?
Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -23,6 +23,7 @@
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/WithColor.h"
 
 using namespace clang::ast_matchers;
 using namespace clang::driver;
@@ -333,8 +334,14 @@
 
 int clangTidyMain(int argc, const char **argv) {
   llvm::InitLLVM X(argc, argv);
-  CommonOptionsParser OptionsParser(argc, argv, ClangTidyCategory,
-cl::ZeroOrMore);
+  llvm::Expected OptionsParser =
+  CommonOptionsParser::create(argc, argv, ClangTidyCategory,
+  cl::ZeroOrMore);
+  if (!OptionsParser) {
+llvm::WithColor::error() << llvm::toString(OptionsParser.takeError());
+return 1;
+  }
+
   llvm::IntrusiveRefCntPtr BaseFS(
   new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
 
@@ -365,7 +372,7 @@
   SmallString<256> ProfilePrefix = MakeAbsolute(StoreCheckProfile);
 
   StringRef FileName("dummy");
-  auto PathList = OptionsParser.getSourcePathList();
+  auto PathList = OptionsParser->getSourcePathList();
   if (!PathList.empty()) {
 FileName = PathList.front();
   }
@@ -433,7 +440,7 @@
   ClangTidyContext Context(std::move(OwningOptionsProvider),
AllowEnablingAnalyzerAlphaCheckers);
   std::vector Errors =
-  runClangTidy(Context, OptionsParser.getCompilations(), PathList, BaseFS,
+  runClangTidy(Context, OptionsParser->getCompilations(), PathList, BaseFS,
EnableCheckProfile, ProfilePrefix);
   bool FoundErrors = llvm::find_if(Errors, [](const ClangTidyError ) {
return E.DiagLevel == ClangTidyError::Error;
Index: clang-tools-extra/clang-query/tool/ClangQuery.cpp
===
--- clang-tools-extra/clang-query/tool/ClangQuery.cpp
+++ clang-tools-extra/clang-query/tool/ClangQuery.cpp
@@ -35,6 +35,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/WithColor.h"
 #include 
 #include 
 
@@ -86,7 +87,14 @@
 int main(int argc, const char **argv) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
 
-  CommonOptionsParser OptionsParser(argc, argv, ClangQueryCategory);
+  llvm::Expected OptionsParser =
+  CommonOptionsParser::create(argc, argv, ClangQueryCategory,
+  llvm::cl::OneOrMore);
+
+  if (!OptionsParser) {
+llvm::WithColor::error() << llvm::toString(OptionsParser.takeError());
+return 1;
+  }
 
   if (!Commands.empty() && !CommandFiles.empty()) {
 llvm::errs() << argv[0] << ": cannot specify both -c and -f\n";
@@ -99,8 +107,8 @@
 return 1;
   }
 
-  ClangTool Tool(OptionsParser.getCompilations(),
- OptionsParser.getSourcePathList());
+  ClangTool Tool(OptionsParser->getCompilations(),
+ OptionsParser->getSourcePathList());
   std::vector> ASTs;
   int Status = Tool.buildASTs(ASTs);
   int ASTStatus = 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80879: clang-tidy and clang-query wont crash with invalid command line options

2020-05-31 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf23ddbe3c3ae: clang-tidy and clang-query wont crash with 
invalid command line options (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80879

Files:
  clang-tools-extra/clang-query/tool/ClangQuery.cpp
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/test/clang-query/invalid-command-line.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/invalid-command-line.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/invalid-command-line.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/invalid-command-line.cpp
@@ -0,0 +1,4 @@
+// RUN: not clang-tidy --invalid-arg 2>&1 | FileCheck %s
+
+// CHECK: error: [CommonOptionsParser]: clang-tidy: Unknown command line argument '--invalid-arg'.  Try: 'clang-tidy --help'
+// CHECK-NEXT: clang-tidy: Did you mean '--extra-arg'?
Index: clang-tools-extra/test/clang-query/invalid-command-line.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-query/invalid-command-line.cpp
@@ -0,0 +1,4 @@
+// RUN: not clang-query --invalid-arg 2>&1 | FileCheck %s
+
+// CHECK: error: [CommonOptionsParser]: clang-query: Unknown command line argument '--invalid-arg'.  Try: 'clang-query --help'
+// CHECK-NEXT: clang-query: Did you mean '--extra-arg'?
Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -23,6 +23,7 @@
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/WithColor.h"
 
 using namespace clang::ast_matchers;
 using namespace clang::driver;
@@ -333,8 +334,14 @@
 
 int clangTidyMain(int argc, const char **argv) {
   llvm::InitLLVM X(argc, argv);
-  CommonOptionsParser OptionsParser(argc, argv, ClangTidyCategory,
-cl::ZeroOrMore);
+  llvm::Expected OptionsParser =
+  CommonOptionsParser::create(argc, argv, ClangTidyCategory,
+  cl::ZeroOrMore);
+  if (!OptionsParser) {
+llvm::WithColor::error() << llvm::toString(OptionsParser.takeError());
+return 1;
+  }
+
   llvm::IntrusiveRefCntPtr BaseFS(
   new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
 
@@ -365,7 +372,7 @@
   SmallString<256> ProfilePrefix = MakeAbsolute(StoreCheckProfile);
 
   StringRef FileName("dummy");
-  auto PathList = OptionsParser.getSourcePathList();
+  auto PathList = OptionsParser->getSourcePathList();
   if (!PathList.empty()) {
 FileName = PathList.front();
   }
@@ -433,7 +440,7 @@
   ClangTidyContext Context(std::move(OwningOptionsProvider),
AllowEnablingAnalyzerAlphaCheckers);
   std::vector Errors =
-  runClangTidy(Context, OptionsParser.getCompilations(), PathList, BaseFS,
+  runClangTidy(Context, OptionsParser->getCompilations(), PathList, BaseFS,
EnableCheckProfile, ProfilePrefix);
   bool FoundErrors = llvm::find_if(Errors, [](const ClangTidyError ) {
return E.DiagLevel == ClangTidyError::Error;
Index: clang-tools-extra/clang-query/tool/ClangQuery.cpp
===
--- clang-tools-extra/clang-query/tool/ClangQuery.cpp
+++ clang-tools-extra/clang-query/tool/ClangQuery.cpp
@@ -35,6 +35,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/WithColor.h"
 #include 
 #include 
 
@@ -86,7 +87,14 @@
 int main(int argc, const char **argv) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
 
-  CommonOptionsParser OptionsParser(argc, argv, ClangQueryCategory);
+  llvm::Expected OptionsParser =
+  CommonOptionsParser::create(argc, argv, ClangQueryCategory,
+  llvm::cl::OneOrMore);
+
+  if (!OptionsParser) {
+llvm::WithColor::error() << llvm::toString(OptionsParser.takeError());
+return 1;
+  }
 
   if (!Commands.empty() && !CommandFiles.empty()) {
 llvm::errs() << argv[0] << ": cannot specify both -c and -f\n";
@@ -99,8 +107,8 @@
 return 1;
   }
 
-  ClangTool Tool(OptionsParser.getCompilations(),
- OptionsParser.getSourcePathList());
+  ClangTool Tool(OptionsParser->getCompilations(),
+ OptionsParser->getSourcePathList());
   std::vector> ASTs;
   int Status = Tool.buildASTs(ASTs);
   int ASTStatus = 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] dfbfdc9 - [utils] update expected strings in tests; NFC

2020-05-31 Thread Sanjay Patel via cfe-commits

Author: Sanjay Patel
Date: 2020-05-31T11:07:22-04:00
New Revision: dfbfdc96f9e15be40c938cde9b159afd028bf4a2

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

LOG: [utils] update expected strings in tests; NFC

The script was changes with:
https://github.com/llvm/llvm-project/commit/bfdc2552664d6f0bb332a9c6a115877020f3c1df

Added: 


Modified: 
clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.expected

clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected

Removed: 




diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.expected 
b/clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.expected
index d6ba7ae09b62..6ea154286c15 100644
--- a/clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.expected
+++ b/clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.expected
@@ -8,10 +8,10 @@
 // CHECK-NEXT:[[B_ADDR:%.*]] = alloca i32, align 4
 // CHECK-NEXT:store i64 [[A:%.*]], i64* [[A_ADDR]], align 8
 // CHECK-NEXT:store i32 [[B:%.*]], i32* [[B_ADDR]], align 4
-// CHECK-NEXT:[[TMP0:%.*]] = load i64, i64* [[A_ADDR]], align 8
-// CHECK-NEXT:[[TMP1:%.*]] = load i32, i32* [[B_ADDR]], align 4
-// CHECK-NEXT:[[CONV:%.*]] = sext i32 [[TMP1]] to i64
-// CHECK-NEXT:[[ADD:%.*]] = add nsw i64 [[TMP0]], [[CONV]]
+// CHECK-NEXT:[[NAMELESS0:%.*]] = load i64, i64* [[A_ADDR]], align 8
+// CHECK-NEXT:[[NAMELESS1:%.*]] = load i32, i32* [[B_ADDR]], align 4
+// CHECK-NEXT:[[CONV:%.*]] = sext i32 [[NAMELESS1]] to i64
+// CHECK-NEXT:[[ADD:%.*]] = add nsw i64 [[NAMELESS0]], [[CONV]]
 // CHECK-NEXT:ret i64 [[ADD]]
 //
 long test(long a, int b) {
@@ -27,12 +27,12 @@ long test(long a, int b) {
 // CHECK-NEXT:store i64 [[A:%.*]], i64* [[A_ADDR]], align 8
 // CHECK-NEXT:store i32 [[B:%.*]], i32* [[B_ADDR]], align 4
 // CHECK-NEXT:store i32 [[C:%.*]], i32* [[C_ADDR]], align 4
-// CHECK-NEXT:[[TMP0:%.*]] = load i64, i64* [[A_ADDR]], align 8
-// CHECK-NEXT:[[TMP1:%.*]] = load i32, i32* [[B_ADDR]], align 4
-// CHECK-NEXT:[[CONV:%.*]] = sext i32 [[TMP1]] to i64
-// CHECK-NEXT:[[ADD:%.*]] = add nsw i64 [[TMP0]], [[CONV]]
-// CHECK-NEXT:[[TMP2:%.*]] = load i32, i32* [[C_ADDR]], align 4
-// CHECK-NEXT:[[CONV1:%.*]] = sext i32 [[TMP2]] to i64
+// CHECK-NEXT:[[NAMELESS0:%.*]] = load i64, i64* [[A_ADDR]], align 8
+// CHECK-NEXT:[[NAMELESS1:%.*]] = load i32, i32* [[B_ADDR]], align 4
+// CHECK-NEXT:[[CONV:%.*]] = sext i32 [[NAMELESS1]] to i64
+// CHECK-NEXT:[[ADD:%.*]] = add nsw i64 [[NAMELESS0]], [[CONV]]
+// CHECK-NEXT:[[NAMELESS2:%.*]] = load i32, i32* [[C_ADDR]], align 4
+// CHECK-NEXT:[[CONV1:%.*]] = sext i32 [[NAMELESS2]] to i64
 // CHECK-NEXT:[[ADD2:%.*]] = add nsw i64 [[ADD]], [[CONV1]]
 // CHECK-NEXT:ret i64 [[ADD2]]
 //

diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected
 
b/clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected
index 005b2f242747..dbe1296182aa 100644
--- 
a/clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected
+++ 
b/clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected
@@ -9,10 +9,10 @@
 // CHECK-NEXT:[[B_ADDR:%.*]] = alloca i32, align 4
 // CHECK-NEXT:store i64 [[A]], i64* [[A_ADDR]], align 8
 // CHECK-NEXT:store i32 [[B]], i32* [[B_ADDR]], align 4
-// CHECK-NEXT:[[TMP0:%.*]] = load i64, i64* [[A_ADDR]], align 8
-// CHECK-NEXT:[[TMP1:%.*]] = load i32, i32* [[B_ADDR]], align 4
-// CHECK-NEXT:[[CONV:%.*]] = sext i32 [[TMP1]] to i64
-// CHECK-NEXT:[[ADD:%.*]] = add nsw i64 [[TMP0]], [[CONV]]
+// CHECK-NEXT:[[NAMELESS0:%.*]] = load i64, i64* [[A_ADDR]], align 8
+// CHECK-NEXT:[[NAMELESS1:%.*]] = load i32, i32* [[B_ADDR]], align 4
+// CHECK-NEXT:[[CONV:%.*]] = sext i32 [[NAMELESS1]] to i64
+// CHECK-NEXT:[[ADD:%.*]] = add nsw i64 [[NAMELESS0]], [[CONV]]
 // CHECK-NEXT:ret i64 [[ADD]]
 //
 long test(long a, int b) {
@@ -29,12 +29,12 @@ long test(long a, int b) {
 // CHECK-NEXT:store i64 [[A]], i64* [[A_ADDR]], align 8
 // CHECK-NEXT:store i32 [[B]], i32* [[B_ADDR]], align 4
 // CHECK-NEXT:store i32 [[C]], i32* [[C_ADDR]], align 4
-// CHECK-NEXT:[[TMP0:%.*]] = load i64, i64* [[A_ADDR]], align 8
-// CHECK-NEXT:[[TMP1:%.*]] = load i32, i32* [[B_ADDR]], align 4
-// CHECK-NEXT:[[CONV:%.*]] = sext i32 [[TMP1]] to i64
-// CHECK-NEXT:[[ADD:%.*]] = add nsw i64 [[TMP0]], [[CONV]]
-// CHECK-NEXT:[[TMP2:%.*]] = load i32, i32* [[C_ADDR]], align 4
-// CHECK-NEXT:[[CONV1:%.*]] = sext i32 [[TMP2]] to i64
+// CHECK-NEXT:[[NAMELESS0:%.*]] = load i64, i64* [[A_ADDR]], align 8
+// CHECK-NEXT:[[NAMELESS1:%.*]] 

[clang-tools-extra] f23ddbe - clang-tidy and clang-query wont crash with invalid command line options

2020-05-31 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-05-31T16:01:41+01:00
New Revision: f23ddbe3c3ae5f40b99ba272afc3d16b800ba8b9

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

LOG: clang-tidy and clang-query wont crash with invalid command line options

Summary: Motivated by [[ https://bugs.llvm.org/show_bug.cgi?id=46141 | 
clang-tidy crashed for unknown command line argument. ]]

Reviewers: aaron.ballman, alexfh

Reviewed By: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

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

Added: 
clang-tools-extra/test/clang-query/invalid-command-line.cpp
clang-tools-extra/test/clang-tidy/infrastructure/invalid-command-line.cpp

Modified: 
clang-tools-extra/clang-query/tool/ClangQuery.cpp
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-query/tool/ClangQuery.cpp 
b/clang-tools-extra/clang-query/tool/ClangQuery.cpp
index 5cfa0acf9120..0c471def2e14 100644
--- a/clang-tools-extra/clang-query/tool/ClangQuery.cpp
+++ b/clang-tools-extra/clang-query/tool/ClangQuery.cpp
@@ -35,6 +35,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/WithColor.h"
 #include 
 #include 
 
@@ -86,7 +87,14 @@ bool runCommandsInFile(const char *ExeName, std::string 
const ,
 int main(int argc, const char **argv) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
 
-  CommonOptionsParser OptionsParser(argc, argv, ClangQueryCategory);
+  llvm::Expected OptionsParser =
+  CommonOptionsParser::create(argc, argv, ClangQueryCategory,
+  llvm::cl::OneOrMore);
+
+  if (!OptionsParser) {
+llvm::WithColor::error() << llvm::toString(OptionsParser.takeError());
+return 1;
+  }
 
   if (!Commands.empty() && !CommandFiles.empty()) {
 llvm::errs() << argv[0] << ": cannot specify both -c and -f\n";
@@ -99,8 +107,8 @@ int main(int argc, const char **argv) {
 return 1;
   }
 
-  ClangTool Tool(OptionsParser.getCompilations(),
- OptionsParser.getSourcePathList());
+  ClangTool Tool(OptionsParser->getCompilations(),
+ OptionsParser->getSourcePathList());
   std::vector> ASTs;
   int Status = Tool.buildASTs(ASTs);
   int ASTStatus = 0;

diff  --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp 
b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
index 665d10026834..aca16b0d6d81 100644
--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -23,6 +23,7 @@
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/WithColor.h"
 
 using namespace clang::ast_matchers;
 using namespace clang::driver;
@@ -333,8 +334,14 @@ getVfsFromFile(const std::string ,
 
 int clangTidyMain(int argc, const char **argv) {
   llvm::InitLLVM X(argc, argv);
-  CommonOptionsParser OptionsParser(argc, argv, ClangTidyCategory,
-cl::ZeroOrMore);
+  llvm::Expected OptionsParser =
+  CommonOptionsParser::create(argc, argv, ClangTidyCategory,
+  cl::ZeroOrMore);
+  if (!OptionsParser) {
+llvm::WithColor::error() << llvm::toString(OptionsParser.takeError());
+return 1;
+  }
+
   llvm::IntrusiveRefCntPtr BaseFS(
   new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
 
@@ -365,7 +372,7 @@ int clangTidyMain(int argc, const char **argv) {
   SmallString<256> ProfilePrefix = MakeAbsolute(StoreCheckProfile);
 
   StringRef FileName("dummy");
-  auto PathList = OptionsParser.getSourcePathList();
+  auto PathList = OptionsParser->getSourcePathList();
   if (!PathList.empty()) {
 FileName = PathList.front();
   }
@@ -433,7 +440,7 @@ int clangTidyMain(int argc, const char **argv) {
   ClangTidyContext Context(std::move(OwningOptionsProvider),
AllowEnablingAnalyzerAlphaCheckers);
   std::vector Errors =
-  runClangTidy(Context, OptionsParser.getCompilations(), PathList, BaseFS,
+  runClangTidy(Context, OptionsParser->getCompilations(), PathList, BaseFS,
EnableCheckProfile, ProfilePrefix);
   bool FoundErrors = llvm::find_if(Errors, [](const ClangTidyError ) {
return E.DiagLevel == ClangTidyError::Error;

diff  --git a/clang-tools-extra/test/clang-query/invalid-command-line.cpp 
b/clang-tools-extra/test/clang-query/invalid-command-line.cpp
new file mode 100644
index ..10ab43198b4e
--- /dev/null
+++ b/clang-tools-extra/test/clang-query/invalid-command-line.cpp
@@ -0,0 +1,4 @@
+// RUN: not clang-query --invalid-arg 2>&1 | FileCheck %s
+
+// CHECK: error: [CommonOptionsParser]: 

[PATCH] D80887: [clang-tidy] ignore builtin varargs from pro-type-vararg-check

2020-05-31 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 267497.
njames93 added a comment.

Remove unnecessary fixme.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80887

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
@@ -49,3 +49,11 @@
 }
 
 int my_vprintf(const char* format, va_list arg ); // OK to declare function 
taking va_list
+
+void ignoredBuiltinsTest() {
+  (void)__builtin_assume_aligned(0, 8);
+  (void)__builtin_constant_p(0);
+  (void)__builtin_fpclassify(0, 0, 0, 0, 0, 0.f);
+  (void)__builtin_isinf_sign(0.f);
+  (void)__builtin_prefetch(nullptr);
+}
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
@@ -18,11 +18,19 @@
 
 const internal::VariadicDynCastAllOfMatcher vAArgExpr;
 
+static constexpr StringRef AllowedVariadics[] = {
+"__builtin_constant_p", "__builtin_isinf_sign", "__builtin_assume_aligned",
+"__builtin_prefetch",   "__builtin_fpclassify",
+};
+
 void ProTypeVarargCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(vAArgExpr().bind("va_use"), this);
 
   Finder->addMatcher(
-  callExpr(callee(functionDecl(isVariadic(.bind("callvararg"), this);
+  callExpr(callee(functionDecl(isVariadic(),
+   unless(hasAnyName(AllowedVariadics)
+  .bind("callvararg"),
+  this);
 }
 
 static bool hasSingleVariadicArgumentWithValue(const CallExpr *C, uint64_t I) {


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
@@ -49,3 +49,11 @@
 }
 
 int my_vprintf(const char* format, va_list arg ); // OK to declare function taking va_list
+
+void ignoredBuiltinsTest() {
+  (void)__builtin_assume_aligned(0, 8);
+  (void)__builtin_constant_p(0);
+  (void)__builtin_fpclassify(0, 0, 0, 0, 0, 0.f);
+  (void)__builtin_isinf_sign(0.f);
+  (void)__builtin_prefetch(nullptr);
+}
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
@@ -18,11 +18,19 @@
 
 const internal::VariadicDynCastAllOfMatcher vAArgExpr;
 
+static constexpr StringRef AllowedVariadics[] = {
+"__builtin_constant_p", "__builtin_isinf_sign", "__builtin_assume_aligned",
+"__builtin_prefetch",   "__builtin_fpclassify",
+};
+
 void ProTypeVarargCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(vAArgExpr().bind("va_use"), this);
 
   Finder->addMatcher(
-  callExpr(callee(functionDecl(isVariadic(.bind("callvararg"), this);
+  callExpr(callee(functionDecl(isVariadic(),
+   unless(hasAnyName(AllowedVariadics)
+  .bind("callvararg"),
+  this);
 }
 
 static bool hasSingleVariadicArgumentWithValue(const CallExpr *C, uint64_t I) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80887: [clang-tidy] ignore builtin varargs from pro-type-vararg-check

2020-05-31 Thread Nathan James via Phabricator via cfe-commits
njames93 marked an inline comment as done.
njames93 added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp:21
 
+// FIXME: Add any more builtin variadics that shouldn't trigger this
+static constexpr StringRef AllowedVariadics[] = {

aaron.ballman wrote:
> How would we know which builtins should or should not trigger this? Can we 
> add that information to this comment (or, better yet, just fix the fixme up 
> front)?
Good point, its more a case that I don't know all the variadic builtins clang 
supports. Those ones I included are just the ones you find in the gcc 
documentation. Shall I just remove the Fixme completely, If there is another 
one that's been missed we can address that later


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80887



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


[PATCH] D80887: [clang-tidy] ignore builtin varargs from pro-type-vararg-check

2020-05-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp:21
 
+// FIXME: Add any more builtin variadics that shouldn't trigger this
+static constexpr StringRef AllowedVariadics[] = {

How would we know which builtins should or should not trigger this? Can we add 
that information to this comment (or, better yet, just fix the fixme up front)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80887



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


[PATCH] D80879: clang-tidy and clang-query wont crash with invalid command line options

2020-05-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, but can you add test coverage for this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80879



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


[PATCH] D80884: [ASTMatchers] Force c++ unittests to specify correct language standard

2020-05-31 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D80884#2065270 , @gribozavr2 wrote:

> This is an interesting question. Since Clang accepts certain constructs in 
> older C++ standard versions as extensions, shouldn't we test AST matchers in 
> those modes as well? I think it could be argued either way.


Clang accepts a lot of stuff for better or worse, my fist try at this was using 
`-pedantic-errors`, but that was throwing errors with gnu and microsoft 
extensions which would be a much more invasive fix to sort out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80884



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


[PATCH] D80887: [clang-tidy] ignore builtin varargs from pro-type-vararg-check

2020-05-31 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, alexfh, mgehre.
Herald added subscribers: cfe-commits, kbarton, xazax.hun, nemanjai.
Herald added a project: clang.

Disables the check from warning on some built in vararg functions, Address 
Clang-tidy should not consider __builtin_constant_p a variadic function. 



Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80887

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
@@ -49,3 +49,11 @@
 }
 
 int my_vprintf(const char* format, va_list arg ); // OK to declare function 
taking va_list
+
+void ignoredBuiltinsTest() {
+  (void)__builtin_assume_aligned(0, 8);
+  (void)__builtin_constant_p(0);
+  (void)__builtin_fpclassify(0, 0, 0, 0, 0, 0.f);
+  (void)__builtin_isinf_sign(0.f);
+  (void)__builtin_prefetch(nullptr);
+}
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
@@ -18,11 +18,20 @@
 
 const internal::VariadicDynCastAllOfMatcher vAArgExpr;
 
+// FIXME: Add any more builtin variadics that shouldn't trigger this
+static constexpr StringRef AllowedVariadics[] = {
+"__builtin_constant_p", "__builtin_isinf_sign", "__builtin_assume_aligned",
+"__builtin_prefetch",   "__builtin_fpclassify",
+};
+
 void ProTypeVarargCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(vAArgExpr().bind("va_use"), this);
 
   Finder->addMatcher(
-  callExpr(callee(functionDecl(isVariadic(.bind("callvararg"), this);
+  callExpr(callee(functionDecl(isVariadic(),
+   unless(hasAnyName(AllowedVariadics)
+  .bind("callvararg"),
+  this);
 }
 
 static bool hasSingleVariadicArgumentWithValue(const CallExpr *C, uint64_t I) {


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
@@ -49,3 +49,11 @@
 }
 
 int my_vprintf(const char* format, va_list arg ); // OK to declare function taking va_list
+
+void ignoredBuiltinsTest() {
+  (void)__builtin_assume_aligned(0, 8);
+  (void)__builtin_constant_p(0);
+  (void)__builtin_fpclassify(0, 0, 0, 0, 0, 0.f);
+  (void)__builtin_isinf_sign(0.f);
+  (void)__builtin_prefetch(nullptr);
+}
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
@@ -18,11 +18,20 @@
 
 const internal::VariadicDynCastAllOfMatcher vAArgExpr;
 
+// FIXME: Add any more builtin variadics that shouldn't trigger this
+static constexpr StringRef AllowedVariadics[] = {
+"__builtin_constant_p", "__builtin_isinf_sign", "__builtin_assume_aligned",
+"__builtin_prefetch",   "__builtin_fpclassify",
+};
+
 void ProTypeVarargCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(vAArgExpr().bind("va_use"), this);
 
   Finder->addMatcher(
-  callExpr(callee(functionDecl(isVariadic(.bind("callvararg"), this);
+  callExpr(callee(functionDecl(isVariadic(),
+   unless(hasAnyName(AllowedVariadics)
+  .bind("callvararg"),
+  this);
 }
 
 static bool hasSingleVariadicArgumentWithValue(const CallExpr *C, uint64_t I) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80884: [ASTMatchers] Force c++ unittests to specify correct language standard

2020-05-31 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

This is an interesting question. Since Clang accepts certain constructs in 
older C++ standard versions as extensions, shouldn't we test AST matchers in 
those modes as well? I think it could be argued either way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80884



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


[PATCH] D80884: [ASTMatchers] Force c++ unittests to specify correct language standard

2020-05-31 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

Approving since I think that it is probably too costly for tooling to try to 
handle such language extensions. We also don't have a principled way to know 
what "future" C++ feature is supported in a given language mode, so I think we 
would always have implementation and testing gaps because people implementing 
tooling won't know what features to even expect in ASTs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80884



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


[PATCH] D80884: [ASTMatchers] Force c++ unittests to specify correct language standard

2020-05-31 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: klimek, hokein, gribozavr, jvikstrom.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Force the unittests on c++ code for matchers to specify the correct standard.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80884

Files:
  clang/unittests/ASTMatchers/ASTMatchersTest.h
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -950,10 +950,14 @@
   "template\n"
   "template\n"
   "int Struct::field = 123;\n";
-  EXPECT_TRUE(matches(input, templateTypeParmDecl(hasName("T";
-  EXPECT_TRUE(matches(input, templateTypeParmDecl(hasName("T2";
-  EXPECT_TRUE(matches(input, templateTypeParmDecl(hasName("U";
-  EXPECT_TRUE(matches(input, templateTypeParmDecl(hasName("U2";
+  EXPECT_TRUE(
+  matches(input, templateTypeParmDecl(hasName("T")), LanguageMode::Cxx14));
+  EXPECT_TRUE(
+  matches(input, templateTypeParmDecl(hasName("T2")), LanguageMode::Cxx14));
+  EXPECT_TRUE(
+  matches(input, templateTypeParmDecl(hasName("U")), LanguageMode::Cxx14));
+  EXPECT_TRUE(
+  matches(input, templateTypeParmDecl(hasName("U2")), LanguageMode::Cxx14));
 }
 
 TEST(TemplateTypeParmDecl, ClassTemplatePartialSpecializationDecl) {
@@ -2061,113 +2065,146 @@
 
 )cpp";
 
-  EXPECT_TRUE(matches(
-  Code, traverse(TK_IgnoreUnlessSpelledInSource,
- returnStmt(forFunction(functionDecl(hasName("func1"))),
-hasReturnValue(integerLiteral(equals(42)));
+  EXPECT_TRUE(
+  matches(Code,
+  traverse(TK_IgnoreUnlessSpelledInSource,
+   returnStmt(forFunction(functionDecl(hasName("func1"))),
+  hasReturnValue(integerLiteral(equals(42),
+  LanguageMode::Cxx2a));
 
-  EXPECT_TRUE(matches(
-  Code, traverse(TK_IgnoreUnlessSpelledInSource,
- integerLiteral(equals(42),
-hasParent(returnStmt(forFunction(
-functionDecl(hasName("func1");
+  EXPECT_TRUE(
+  matches(Code,
+  traverse(TK_IgnoreUnlessSpelledInSource,
+   integerLiteral(equals(42),
+  hasParent(returnStmt(forFunction(
+  functionDecl(hasName("func1"))),
+  LanguageMode::Cxx2a));
 
   EXPECT_TRUE(matches(
   Code,
   traverse(TK_IgnoreUnlessSpelledInSource,
returnStmt(forFunction(functionDecl(hasName("func2"))),
   hasReturnValue(cxxTemporaryObjectExpr(
-  hasArgument(0, integerLiteral(equals(42);
+  hasArgument(0, integerLiteral(equals(42))),
+  LanguageMode::Cxx2a));
   EXPECT_TRUE(matches(
   Code,
-  traverse(TK_IgnoreUnlessSpelledInSource,
-   integerLiteral(
-   equals(42),
-   hasParent(cxxTemporaryObjectExpr(hasParent(returnStmt(
-   forFunction(functionDecl(hasName("func2")));
+  traverse(
+  TK_IgnoreUnlessSpelledInSource,
+  integerLiteral(equals(42),
+ hasParent(cxxTemporaryObjectExpr(hasParent(returnStmt(
+ forFunction(functionDecl(hasName("func2"),
+  LanguageMode::Cxx2a));
 
   EXPECT_TRUE(matches(
-  Code, traverse(TK_IgnoreUnlessSpelledInSource,
- returnStmt(forFunction(functionDecl(hasName("func3"))),
-hasReturnValue(
-cxxFunctionalCastExpr(hasSourceExpression(
-integerLiteral(equals(42);
+  Code,
+  traverse(
+  TK_IgnoreUnlessSpelledInSource,
+  returnStmt(forFunction(functionDecl(hasName("func3"))),
+ hasReturnValue(cxxFunctionalCastExpr(
+ hasSourceExpression(integerLiteral(equals(42))),
+  LanguageMode::Cxx2a));
 
   EXPECT_TRUE(matches(
   Code,
-  traverse(TK_IgnoreUnlessSpelledInSource,
-   integerLiteral(
-   equals(42),
-   hasParent(cxxFunctionalCastExpr(hasParent(returnStmt(
-   forFunction(functionDecl(hasName("func3")));
+  traverse(
+  TK_IgnoreUnlessSpelledInSource,
+  integerLiteral(equals(42),
+ hasParent(cxxFunctionalCastExpr(hasParent(returnStmt(
+ forFunction(functionDecl(hasName("func3"),
+  LanguageMode::Cxx2a));
 
-  

[PATCH] D80753: [clang-tidy] remove duplicate fixes of alias checkers

2020-05-31 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/infrastructure/duplicate-fixes-of-alias-checkers.cpp:4-8
+template 
+class initializer_list {
+public:
+  initializer_list() noexcept {}
+};

This isn't needed for the test case and can safely be removed.



Comment at: 
clang-tools-extra/test/clang-tidy/infrastructure/duplicate-fixes-of-alias-checkers.cpp:13-21
+  vector() = default;
+  vector(initializer_list) {}
+
+  void push_back(const T &) {}
+  void push_back(T &&) {}
+
+  template 

The 2 constructors can be removed as well as the destructor.



Comment at: llvm/include/llvm/ADT/StringMap.h:251-268
+  /// equal - check whether both of the containers are equal
+  bool operator==(const StringMap ) const {
+if (size() != RHS.size())
+  return false;
+
+for (const auto  : *this) {
+  auto FindInRHS = RHS.find(KeyValue.getKey());

This needs unit tests `llvm/unittests/ADT/StringMapTest.cpp`, also a small nit 
but could you add the corresponding `operator!=`


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

https://reviews.llvm.org/D80753



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