[PATCH] D72041: [clangd] Handle go-to-definition in macro invocations where the target appears in the expansion multiple times

2019-12-31 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

I like the goal here, a few high-level comments:

- it seems unfortunate to solve this mostly in xrefs rather than mostly in 
SelectionTree. All the other clients potentially want this behavior.
- the allSelectedNodes API on SelectionTree feels non-orthogonal: it's only 
meaningful here because the input happened to be a point and thus touches a 
single token and therefore node. If the input was a range, then this API 
doesn't help, because it loses the sense of "topmost" node.
- maybe the function we want walks down the tree as if finding the common 
ancestor, but may descend to return the roots of multiple subtrees if they are 
located in distinct expansions of the same macro arg
- or maybe we just want to treat non-first expansions as not-selected? That 
would about this issue I think

(BTW, Haojian is out the first few weeks of Jan. I'm still technically OOO, 
back later this week)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72041



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


[PATCH] D54943: [clang-tidy] implement const-transformation for cppcoreguidelines-const-correctness

2019-12-31 Thread Florin Iucha via Phabricator via cfe-commits
0x8000- added a comment.

F11163406: 0001-Add-extra-tests.patch  
shows a couple of false positives.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54943



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


[PATCH] D72041: [clangd] Handle go-to-definition in macro invocations where the target appears in the expansion multiple times

2019-12-31 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61162 tests passed, 0 failed 
and 728 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72041



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


[PATCH] D72041: [clangd] Handle go-to-definition in macro invocations where the target appears in the expansion multiple times

2019-12-31 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
nridge added a reviewer: hokein.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72041

Files:
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/Selection.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -349,7 +349,18 @@
#define ADDRESSOF(X) 
int *j = ADDRESSOF(^i);
   )cpp",
-
+  R"cpp(// Macro argument appearing multiple times in expansion
+#define VALIDATE_TYPE(x) (void)x;
+#define ASSERT(expr)   \
+  do { \
+VALIDATE_TYPE(expr);   \
+if (!expr);\
+  } while (false)
+bool [[waldo]]() { return true; }
+void foo() {
+  ASSERT(wa^ldo());
+}
+  )cpp",
   R"cpp(// Symbol concatenated inside macro (not supported)
int *pi;
#define POINTER(X) p # X;
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -140,6 +140,28 @@
 auto Decls = targetDecl(N->ASTNode, Relations);
 Result.assign(Decls.begin(), Decls.end());
   }
+  // If the common ancestor didn't have a target, the individual selected
+  // nodes still might. This can happen if the selection is in a macro
+  // invocation and is over a token that appears in multiple places in
+  // the macro expansion. As long as all occurrences map to the same target,
+  // return that target.
+  if (Result.empty()) {
+auto SelectedNodes = Selection.allSelectedNodes();
+if (SelectedNodes.size() <= 1)
+  return {};
+for (const SelectionTree::Node *N : SelectedNodes) {
+  auto Decls = targetDecl(N->ASTNode, Relations);
+  if (Decls.size() != 1) {
+return Result;
+  }
+  auto Candidate = Decls[0];
+  if (Result.empty()) {
+Result.push_back(Decls[0]);
+  } else if (Result[0] != Candidate) {
+return {};
+  }
+}
+  }
   return Result;
 }
 
Index: clang-tools-extra/clangd/Selection.h
===
--- clang-tools-extra/clangd/Selection.h
+++ clang-tools-extra/clangd/Selection.h
@@ -103,15 +103,15 @@
 Selection Selected;
 // Walk up the AST to get the DeclContext of this Node,
 // which is not the node itself.
-const DeclContext& getDeclContext() const;
+const DeclContext () const;
 // Printable node kind, like "CXXRecordDecl" or "AutoTypeLoc".
 std::string kind() const;
 // If this node is a wrapper with no syntax (e.g. implicit cast), return
 // its contents. (If multiple wrappers are present, unwraps all of them).
-const Node& ignoreImplicit() const;
+const Node () const;
 // If this node is inside a wrapper with no syntax (e.g. implicit cast),
 // return that wrapper. (If multiple are present, unwraps all of them).
-const Node& outerImplicit() const;
+const Node () const;
   };
   // The most specific common ancestor of all the selected nodes.
   // Returns nullptr if the common ancestor is the root.
@@ -119,6 +119,9 @@
   const Node *commonAncestor() const;
   // The selection node corresponding to TranslationUnitDecl.
   const Node () const { return *Root; }
+  // Get all individual selected nodes, in case the caller wants something
+  // other than their common ancestor.
+  std::vector allSelectedNodes() const;
 
 private:
   std::deque Nodes; // Stable-pointer storage.
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -52,8 +52,7 @@
 // On traversing an AST node, its token range is erased from the unclaimed set.
 // The tokens actually removed are associated with that node, and hit-tested
 // against the selection to determine whether the node is selected.
-template 
-class IntervalSet {
+template  class IntervalSet {
 public:
   IntervalSet(llvm::ArrayRef Range) { UnclaimedRanges.insert(Range); }
 
@@ -78,7 +77,7 @@
   --Overlap.first;
   // ...unless B isn't selected at all.
   if (Overlap.first->end() <= Claim.begin())
-  ++Overlap.first;
+++Overlap.first;
 }
 if (Overlap.first == Overlap.second)
   return Out;
@@ -118,8 +117,7 @@
   };
 
   // Disjoint sorted unclaimed ranges of expanded tokens.
-  std::set, RangeLess>
-  UnclaimedRanges;
+  std::set, RangeLess> UnclaimedRanges;
 };
 
 // Sentinel value for 

[PATCH] D71037: [Diagnostic] Add ftabstop to -Wmisleading-indentation

2019-12-31 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D71037#1799792 , @mstorsjo wrote:

> This broke my builds.


I pushed a revert for this for now, to unbreak things.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71037



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


[PATCH] D71499: Add builtins for aligning and checking alignment of pointers and integers

2019-12-31 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61165 tests passed, 0 failed 
and 728 were skipped.

{icon times-circle color=red} clang-tidy: fail. Please fix clang-tidy findings 
.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71499



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


[PATCH] D71963: clang-tidy doc: Add the severities description

2019-12-31 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru abandoned this revision.
sylvestre.ledru added a comment.

ok, thanks!
I will remove them tomorrow or the next day.

Do you have any guidance about the next steps to add them back?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71963



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


[PATCH] D71499: Add builtins for aligning and checking alignment of pointers and integers

2019-12-31 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson updated this revision to Diff 235724.
arichardson marked 9 inline comments as done.
arichardson added a comment.

- Address feedback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71499

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtin-align-array.c
  clang/test/CodeGen/builtin-align.c
  clang/test/Sema/builtin-align.c
  clang/test/SemaCXX/builtin-align-cxx.cpp

Index: clang/test/SemaCXX/builtin-align-cxx.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/builtin-align-cxx.cpp
@@ -0,0 +1,236 @@
+// C++-specific checks for the alignment builtins
+// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -std=c++11 -o - %s -fsyntax-only -verify
+
+// Check that we don't crash when using dependent types in __builtin_align:
+template 
+void *c(void *d) { // expected-note{{candidate template ignored}}
+  return __builtin_align_down(d, b);
+}
+
+struct x {};
+x foo;
+void test(void *value) {
+  c(value);
+  c(value); // expected-error{{no matching function for call to 'c'}}
+}
+
+template 
+void test_templated_arguments() {
+  T array[ArraySize];   // expected-error{{variable has incomplete type 'fwddecl'}}
+  static_assert(__is_same(decltype(__builtin_align_up(array, Alignment)), T *), // expected-error{{requested alignment is not a power of 2}}
+"return type should be the decayed array type");
+  static_assert(__is_same(decltype(__builtin_align_down(array, Alignment)), T *),
+"return type should be the decayed array type");
+  static_assert(__is_same(decltype(__builtin_is_aligned(array, Alignment)), bool),
+"return type should be bool");
+  T *x1 = __builtin_align_up(array, Alignment);
+  T *x2 = __builtin_align_down(array, Alignment);
+  bool x3 = __builtin_align_up(array, Alignment);
+}
+
+void test() {
+  test_templated_arguments(); // fine
+  test_templated_arguments();
+  // expected-note@-1{{in instantiation of function template specialization 'test_templated_arguments'}}
+  // expected-note@-2{{forward declaration of 'fwddecl'}}
+  test_templated_arguments(); // invalid alignment value
+  // expected-note@-1{{in instantiation of function template specialization 'test_templated_arguments'}}
+}
+
+template 
+void test_incorrect_alignment_without_instatiation(T value) {
+  int array[32];
+  static_assert(__is_same(decltype(__builtin_align_up(array, 31)), int *), // expected-error{{requested alignment is not a power of 2}}
+"return type should be the decayed array type");
+  static_assert(__is_same(decltype(__builtin_align_down(array, 7)), int *), // expected-error{{requested alignment is not a power of 2}}
+"return type should be the decayed array type");
+  static_assert(__is_same(decltype(__builtin_is_aligned(array, -1)), bool), // expected-error{{requested alignment must be 1 or greater}}
+"return type should be bool");
+  __builtin_align_up(array);   // expected-error{{too few arguments to function call, expected 2, have 1}}
+  __builtin_align_up(array, 31);   // expected-error{{requested alignment is not a power of 2}}
+  __builtin_align_down(array, 31); // expected-error{{requested alignment is not a power of 2}}
+  __builtin_align_up(array, 31);   // expected-error{{requested alignment is not a power of 2}}
+  __builtin_align_up(value, 31);   // This shouldn't want since the type is dependent
+  __builtin_align_up(value);   // Same here
+}
+
+// The original fix for the issue above broke some legitimate code.
+// Here is a regression test:
+typedef __SIZE_TYPE__ size_t;
+void *allocate_impl(size_t size);
+template 
+T *allocate() {
+  constexpr size_t allocation_size =
+  __builtin_align_up(sizeof(T), sizeof(void *));
+  return static_cast(
+  __builtin_assume_aligned(allocate_impl(allocation_size), sizeof(void *)));
+}
+struct Foo {
+  int value;
+};
+void *test2() {
+  return allocate();
+}
+
+// Check that pointers-to-members cannot be used:
+class MemPtr {
+public:
+  int data;
+  void func();
+  virtual void vfunc();
+};
+void test_member_ptr() {
+  __builtin_align_up(::data, 64);// expected-error{{operand of type 'int MemPtr::*' where arithmetic or pointer type is required}}
+  __builtin_align_down(::func, 64);  // expected-error{{operand of type 'void (MemPtr::*)()' where arithmetic or pointer type is required}}
+  __builtin_is_aligned(::vfunc, 64); // expected-error{{operand of type 'void (MemPtr::*)()' where arithmetic or pointer type is required}}
+}
+
+void 

[clang] 8be5a0f - [OPENMP]Emit artificial threprivate vars as threadlocal, if possible.

2019-12-31 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2019-12-31T14:11:36-05:00
New Revision: 8be5a0fe12bb9114bb82986b1dcb9205699aa085

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

LOG: [OPENMP]Emit artificial threprivate vars as threadlocal, if possible.

It may improve performance for declare reduction constructs.

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/test/OpenMP/master_taskloop_reduction_codegen.cpp
clang/test/OpenMP/master_taskloop_simd_reduction_codegen.cpp
clang/test/OpenMP/parallel_master_taskloop_reduction_codegen.cpp
clang/test/OpenMP/parallel_master_taskloop_simd_reduction_codegen.cpp
clang/test/OpenMP/taskloop_reduction_codegen.cpp
clang/test/OpenMP/taskloop_simd_reduction_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 00f8fb570b33..59f352dcd4c8 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -3043,10 +3043,15 @@ Address 
CGOpenMPRuntime::getAddrOfArtificialThreadPrivate(CodeGenFunction ,
   QualType VarType,
   StringRef Name) {
   std::string Suffix = getName({"artificial", ""});
-  std::string CacheSuffix = getName({"cache", ""});
   llvm::Type *VarLVType = CGF.ConvertTypeForMem(VarType);
   llvm::Value *GAddr =
   getOrCreateInternalVariable(VarLVType, Twine(Name).concat(Suffix));
+  if (CGM.getLangOpts().OpenMP && CGM.getLangOpts().OpenMPUseTLS &&
+  CGM.getTarget().isTLSSupported()) {
+cast(GAddr)->setThreadLocal(/*Val=*/true);
+return Address(GAddr, CGM.getContext().getTypeAlignInChars(VarType));
+  }
+  std::string CacheSuffix = getName({"cache", ""});
   llvm::Value *Args[] = {
   emitUpdateLocation(CGF, SourceLocation()),
   getThreadID(CGF, SourceLocation()),
@@ -3060,7 +3065,7 @@ Address 
CGOpenMPRuntime::getAddrOfArtificialThreadPrivate(CodeGenFunction ,
   CGF.EmitRuntimeCall(
   createRuntimeFunction(OMPRTL__kmpc_threadprivate_cached), Args),
   VarLVType->getPointerTo(/*AddrSpace=*/0)),
-  CGM.getPointerAlign());
+  CGM.getContext().getTypeAlignInChars(VarType));
 }
 
 void CGOpenMPRuntime::emitIfClause(CodeGenFunction , const Expr *Cond,

diff  --git a/clang/test/OpenMP/master_taskloop_reduction_codegen.cpp 
b/clang/test/OpenMP/master_taskloop_reduction_codegen.cpp
index 59ac23f5e84f..70b8334e2f09 100644
--- a/clang/test/OpenMP/master_taskloop_reduction_codegen.cpp
+++ b/clang/test/OpenMP/master_taskloop_reduction_codegen.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -fopenmp -x c++ %s -verify -debug-info-kind=limited 
-emit-llvm -o - -triple powerpc64le-unknown-linux-gnu -std=c++98 | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ %s -verify -debug-info-kind=limited 
-emit-llvm -o - -triple powerpc64le-unknown-linux-gnu -fnoopenmp-use-tls 
-std=c++98 | FileCheck %s
 
-// RUN: %clang_cc1 -fopenmp-simd -x c++ %s -verify -debug-info-kind=limited 
-emit-llvm -o - -triple powerpc64le-unknown-linux-gnu -std=c++98 | FileCheck 
--check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ %s -verify -debug-info-kind=limited 
-emit-llvm -o - -triple powerpc64le-unknown-linux-gnu -fnoopenmp-use-tls 
-std=c++98 | FileCheck --check-prefix SIMD-ONLY0 %s
 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
 // expected-no-diagnostics
 

diff  --git a/clang/test/OpenMP/master_taskloop_simd_reduction_codegen.cpp 
b/clang/test/OpenMP/master_taskloop_simd_reduction_codegen.cpp
index ca0c0feccc83..1b8831039b94 100644
--- a/clang/test/OpenMP/master_taskloop_simd_reduction_codegen.cpp
+++ b/clang/test/OpenMP/master_taskloop_simd_reduction_codegen.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -fopenmp -x c++ %s -verify -debug-info-kind=limited 
-emit-llvm -o - -triple powerpc64le-unknown-linux-gnu -std=c++98 | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ %s -verify -debug-info-kind=limited 
-emit-llvm -o - -triple powerpc64le-unknown-linux-gnu -std=c++98 
-fnoopenmp-use-tls | FileCheck %s
 
-// RUN: %clang_cc1 -fopenmp-simd -x c++ %s -verify -debug-info-kind=limited 
-emit-llvm -o - -triple powerpc64le-unknown-linux-gnu -std=c++98 | FileCheck 
--check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ %s -verify -debug-info-kind=limited 
-emit-llvm -o - -triple powerpc64le-unknown-linux-gnu -std=c++98 
-fnoopenmp-use-tls | FileCheck --check-prefix SIMD-ONLY0 %s
 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
 // expected-no-diagnostics
 

diff  --git a/clang/test/OpenMP/parallel_master_taskloop_reduction_codegen.cpp 
b/clang/test/OpenMP/parallel_master_taskloop_reduction_codegen.cpp
index 7a0baa01b9ca..dc157ab7b360 100644
--- 

[PATCH] D72028: [CodeGen] Emit conj/conjf/confjl libcalls as fneg instructions if possible.

2019-12-31 Thread Craig Topper via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5e5a1d279096: [CodeGen] Emit conj/conjf/confjl libcalls as 
fneg instructions if possible. (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72028

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/complex-libcalls-2.c
  clang/test/CodeGen/complex-libcalls.c


Index: clang/test/CodeGen/complex-libcalls.c
===
--- clang/test/CodeGen/complex-libcalls.c
+++ clang/test/CodeGen/complex-libcalls.c
@@ -112,12 +112,10 @@
 
   conj(f);   conjf(f);  conjl(f);
 
-// NO__ERRNO: declare { double, double } @conj(double, double) 
[[READNONE:#[0-9]+]]
-// NO__ERRNO: declare <2 x float> @conjf(<2 x float>) [[READNONE]]
-// NO__ERRNO: declare { x86_fp80, x86_fp80 } @conjl({ x86_fp80, x86_fp80 }* 
byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
-// HAS_ERRNO: declare { double, double } @conj(double, double) 
[[READNONE:#[0-9]+]]
-// HAS_ERRNO: declare <2 x float> @conjf(<2 x float>) [[READNONE]]
-// HAS_ERRNO: declare { x86_fp80, x86_fp80 } @conjl({ x86_fp80, x86_fp80 }* 
byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
+// NO__ERRNO-NOT: .conj
+// NO__ERRNO-NOT: @conj
+// HAS_ERRNO-NOT: .conj
+// HAS_ERRNO-NOT: @conj
 
   clog(f);   clogf(f);  clogl(f);
 
@@ -133,7 +131,7 @@
 // NO__ERRNO: declare { double, double } @cproj(double, double) [[READNONE]]
 // NO__ERRNO: declare <2 x float> @cprojf(<2 x float>) [[READNONE]]
 // NO__ERRNO: declare { x86_fp80, x86_fp80 } @cprojl({ x86_fp80, x86_fp80 }* 
byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
-// HAS_ERRNO: declare { double, double } @cproj(double, double) [[READNONE]]
+// HAS_ERRNO: declare { double, double } @cproj(double, double) 
[[READNONE:#[0-9]+]]
 // HAS_ERRNO: declare <2 x float> @cprojf(<2 x float>) [[READNONE]]
 // HAS_ERRNO: declare { x86_fp80, x86_fp80 } @cprojl({ x86_fp80, x86_fp80 }* 
byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
 
Index: clang/test/CodeGen/complex-libcalls-2.c
===
--- /dev/null
+++ clang/test/CodeGen/complex-libcalls-2.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm
  %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm 
-fmath-errno %s | FileCheck %s
+
+float _Complex test_conjf(float _Complex x) {
+// CHECK-LABEL: @test_conjf(
+// CHECK: fneg float %x.imag
+  return conjf(x);
+}
+
+double _Complex test_conj(double _Complex x) {
+// CHECK-LABEL: @test_conj(
+// CHECK: fneg double %x.imag
+  return conj(x);
+}
+
+long double _Complex test_conjl(long double _Complex x) {
+// CHECK-LABEL: @test_conjl(
+// CHECK: fneg x86_fp80 %x.imag
+  return conjl(x);
+}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -1938,7 +1938,10 @@
   }
   case Builtin::BI__builtin_conj:
   case Builtin::BI__builtin_conjf:
-  case Builtin::BI__builtin_conjl: {
+  case Builtin::BI__builtin_conjl:
+  case Builtin::BIconj:
+  case Builtin::BIconjf:
+  case Builtin::BIconjl: {
 ComplexPairTy ComplexVal = EmitComplexExpr(E->getArg(0));
 Value *Real = ComplexVal.first;
 Value *Imag = ComplexVal.second;


Index: clang/test/CodeGen/complex-libcalls.c
===
--- clang/test/CodeGen/complex-libcalls.c
+++ clang/test/CodeGen/complex-libcalls.c
@@ -112,12 +112,10 @@
 
   conj(f);   conjf(f);  conjl(f);
 
-// NO__ERRNO: declare { double, double } @conj(double, double) [[READNONE:#[0-9]+]]
-// NO__ERRNO: declare <2 x float> @conjf(<2 x float>) [[READNONE]]
-// NO__ERRNO: declare { x86_fp80, x86_fp80 } @conjl({ x86_fp80, x86_fp80 }* byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
-// HAS_ERRNO: declare { double, double } @conj(double, double) [[READNONE:#[0-9]+]]
-// HAS_ERRNO: declare <2 x float> @conjf(<2 x float>) [[READNONE]]
-// HAS_ERRNO: declare { x86_fp80, x86_fp80 } @conjl({ x86_fp80, x86_fp80 }* byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
+// NO__ERRNO-NOT: .conj
+// NO__ERRNO-NOT: @conj
+// HAS_ERRNO-NOT: .conj
+// HAS_ERRNO-NOT: @conj
 
   clog(f);   clogf(f);  clogl(f);
 
@@ -133,7 +131,7 @@
 // NO__ERRNO: declare { double, double } @cproj(double, double) [[READNONE]]
 // NO__ERRNO: declare <2 x float> @cprojf(<2 x float>) [[READNONE]]
 // NO__ERRNO: declare { x86_fp80, x86_fp80 } @cprojl({ x86_fp80, x86_fp80 }* byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
-// HAS_ERRNO: declare { double, double } @cproj(double, double) [[READNONE]]
+// HAS_ERRNO: declare { double, double } @cproj(double, double) [[READNONE:#[0-9]+]]
 // HAS_ERRNO: 

[clang] 5e5a1d2 - [CodeGen] Emit conj/conjf/confjl libcalls as fneg instructions if possible.

2019-12-31 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2019-12-31T10:41:00-08:00
New Revision: 5e5a1d27909626169c15b8f63e10d22fcbdf88d9

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

LOG: [CodeGen] Emit conj/conjf/confjl libcalls as fneg instructions if possible.

We already recognize the __builtin versions of these, might as well
recognize the libcall version.

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

Added: 
clang/test/CodeGen/complex-libcalls-2.c

Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/complex-libcalls.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index fe0607bbd027..be02004bf54b 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -1938,7 +1938,10 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   }
   case Builtin::BI__builtin_conj:
   case Builtin::BI__builtin_conjf:
-  case Builtin::BI__builtin_conjl: {
+  case Builtin::BI__builtin_conjl:
+  case Builtin::BIconj:
+  case Builtin::BIconjf:
+  case Builtin::BIconjl: {
 ComplexPairTy ComplexVal = EmitComplexExpr(E->getArg(0));
 Value *Real = ComplexVal.first;
 Value *Imag = ComplexVal.second;

diff  --git a/clang/test/CodeGen/complex-libcalls-2.c 
b/clang/test/CodeGen/complex-libcalls-2.c
new file mode 100644
index ..1938cf460c91
--- /dev/null
+++ b/clang/test/CodeGen/complex-libcalls-2.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm
  %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm 
-fmath-errno %s | FileCheck %s
+
+float _Complex test_conjf(float _Complex x) {
+// CHECK-LABEL: @test_conjf(
+// CHECK: fneg float %x.imag
+  return conjf(x);
+}
+
+double _Complex test_conj(double _Complex x) {
+// CHECK-LABEL: @test_conj(
+// CHECK: fneg double %x.imag
+  return conj(x);
+}
+
+long double _Complex test_conjl(long double _Complex x) {
+// CHECK-LABEL: @test_conjl(
+// CHECK: fneg x86_fp80 %x.imag
+  return conjl(x);
+}

diff  --git a/clang/test/CodeGen/complex-libcalls.c 
b/clang/test/CodeGen/complex-libcalls.c
index 5690119e1013..248041788293 100644
--- a/clang/test/CodeGen/complex-libcalls.c
+++ b/clang/test/CodeGen/complex-libcalls.c
@@ -112,12 +112,10 @@ void foo(float f) {
 
   conj(f);   conjf(f);  conjl(f);
 
-// NO__ERRNO: declare { double, double } @conj(double, double) 
[[READNONE:#[0-9]+]]
-// NO__ERRNO: declare <2 x float> @conjf(<2 x float>) [[READNONE]]
-// NO__ERRNO: declare { x86_fp80, x86_fp80 } @conjl({ x86_fp80, x86_fp80 }* 
byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
-// HAS_ERRNO: declare { double, double } @conj(double, double) 
[[READNONE:#[0-9]+]]
-// HAS_ERRNO: declare <2 x float> @conjf(<2 x float>) [[READNONE]]
-// HAS_ERRNO: declare { x86_fp80, x86_fp80 } @conjl({ x86_fp80, x86_fp80 }* 
byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
+// NO__ERRNO-NOT: .conj
+// NO__ERRNO-NOT: @conj
+// HAS_ERRNO-NOT: .conj
+// HAS_ERRNO-NOT: @conj
 
   clog(f);   clogf(f);  clogl(f);
 
@@ -133,7 +131,7 @@ void foo(float f) {
 // NO__ERRNO: declare { double, double } @cproj(double, double) [[READNONE]]
 // NO__ERRNO: declare <2 x float> @cprojf(<2 x float>) [[READNONE]]
 // NO__ERRNO: declare { x86_fp80, x86_fp80 } @cprojl({ x86_fp80, x86_fp80 }* 
byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
-// HAS_ERRNO: declare { double, double } @cproj(double, double) [[READNONE]]
+// HAS_ERRNO: declare { double, double } @cproj(double, double) 
[[READNONE:#[0-9]+]]
 // HAS_ERRNO: declare <2 x float> @cprojf(<2 x float>) [[READNONE]]
 // HAS_ERRNO: declare { x86_fp80, x86_fp80 } @cprojl({ x86_fp80, x86_fp80 }* 
byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
 



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


[PATCH] D71963: clang-tidy doc: Add the severities description

2019-12-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D71963#1800087 , @sylvestre.ledru 
wrote:

> OK, do you want me to prepare a patch to remove the severities?
>  or to update the values using another list?


I think we should remove the severities from the table for now. The rest of the 
table looks fine to me and is a big improvement over the lists.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71963



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


[PATCH] D71963: clang-tidy doc: Add the severities description

2019-12-31 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

OK, do you want me to prepare a patch to remove the severities?
or to update the values using another list?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71963



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


[PATCH] D71963: clang-tidy doc: Add the severities description

2019-12-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D71963#1800056 , @sylvestre.ledru 
wrote:

> > I may have missed this in prior discussions, and if so, I'm sorry -- but 
> > why are we taking CodeChecker as the model for this?
>
> I went ahead and use it because:
>
> - it is there and maintained (I contributed to the list a few time)


There are other models that exist and are maintained.

> - it is pretty good from my experience (it is rare that I see the list of 
> checker/severity and disagree with the evaluation)

Other models are also pretty good.

> - it is a good start to trigger some discussions

Definitely agreed! However, I think an RFC would have been a less invasive 
approach to starting those discussions.

> - codechecker upstream is also involved in clang-tidy

As are other tools and coding standards.

For me personally, I like the idea of giving users some idea of the severity 
for any given check. I think it provides valuable information to users and is a 
good thing to document, but only when applied consistently across checks. If we 
can't find a consistent heuristic to use across all the coding standards and 
one-off checks we support, the utility of telling users about the severity is 
pretty hampered (or worse yet, gives a false sense of how bad a problem may 
be). I'd rather see the severity stuff reverted out of trunk until we've got 
some broader community agreement that 1) we want this feature, 2) we enumerate 
concrete steps for how to pick a severity for any given check, and 3) what to 
do when our severity differs from an external severity in the case of checkers 
for coding standards with that concept.

FWIW, I didn't notice this change was even proposed because it happened in a 
review about moving from a long list of checkers to one using tables and from 
what I can tell, it looks like the patch landed without that review being 
accepted (in fact, it seems to have landed with a code owner having marked it 
as requiring changes).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71963



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


[PATCH] D72028: [CodeGen] Emit conj/conjf/confjl libcalls as fneg instructions if possible.

2019-12-31 Thread Craig Topper via Phabricator via cfe-commits
craig.topper marked an inline comment as done.
craig.topper added inline comments.



Comment at: clang/test/CodeGen/complex-libcalls.c:115-118
+// NO__ERRNO-NOT: .conj
+// NO__ERRNO-NOT: @conj
+// HAS_ERRNO-NOT: .conj
+// HAS_ERRNO-NOT: @conj

spatel wrote:
> Could we use positive matches for "fneg" here rather than NOT lines? If so, 
> then do we need the new test file?
All of the CHECK lines are in the declaration part of the file after the 
function body. They aren’t checking the call site code. I could add new 
functions for the conj calls and check them earlier?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72028



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


[PATCH] D71963: clang-tidy doc: Add the severities description

2019-12-31 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

> I may have missed this in prior discussions, and if so, I'm sorry -- but why 
> are we taking CodeChecker as the model for this?

I went ahead and use it because:

- it is there and maintained (I contributed to the list a few time)
- it is pretty good from my experience (it is rare that I see the list of 
checker/severity and disagree with the evaluation)
- it is a good start to trigger some discussions
- codechecker upstream is also involved in clang-tidy




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71963



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


[PATCH] D71977: Implement additional traverse() overloads

2019-12-31 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG69bb99914f35: Implement additional traverse() overloads 
(authored by stephenkelly).

Changed prior to commit:
  https://reviews.llvm.org/D71977?vs=235520=235719#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71977

Files:
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1612,6 +1612,92 @@
   matches(VarDeclCode,
   traverse(ast_type_traits::TK_IgnoreImplicitCastsAndParentheses,
Matcher)));
+
+  EXPECT_TRUE(
+  matches(VarDeclCode, decl(traverse(ast_type_traits::TK_AsIs,
+ anyOf(cxxRecordDecl(), varDecl());
+
+  EXPECT_TRUE(matches(VarDeclCode,
+  floatLiteral(traverse(ast_type_traits::TK_AsIs,
+hasParent(implicitCastExpr());
+
+  EXPECT_TRUE(matches(
+  VarDeclCode,
+  floatLiteral(traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+hasParent(varDecl());
+
+  EXPECT_TRUE(
+  matches(VarDeclCode,
+  varDecl(traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+   unless(parmVarDecl());
+
+  EXPECT_TRUE(notMatches(
+  VarDeclCode,
+  varDecl(traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+   has(implicitCastExpr());
+
+  EXPECT_TRUE(matches(VarDeclCode, varDecl(traverse(ast_type_traits::TK_AsIs,
+has(implicitCastExpr());
+
+  EXPECT_TRUE(notMatches(
+  VarDeclCode,
+  varDecl(has(traverse(ast_type_traits::TK_AsIs, floatLiteral());
+
+  EXPECT_TRUE(matches(
+  VarDeclCode,
+  functionDecl(traverse(ast_type_traits::TK_AsIs, hasName("foo");
+
+  EXPECT_TRUE(matches(
+  VarDeclCode,
+  functionDecl(traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+hasName("foo");
+
+  EXPECT_TRUE(
+  matches(VarDeclCode, functionDecl(traverse(ast_type_traits::TK_AsIs,
+ hasAnyName("foo", "bar");
+
+  EXPECT_TRUE(matches(
+  VarDeclCode,
+  functionDecl(traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+hasAnyName("foo", "bar");
+
+  EXPECT_TRUE(
+  matches(R"cpp(
+void foo(int a)
+{
+  int i = 3.0 + a;
+}
+void bar()
+{
+  foo(7.0);
+}
+)cpp",
+  callExpr(traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+hasArgument(0, floatLiteral());
+
+  EXPECT_TRUE(
+  matches(R"cpp(
+void foo(int a)
+{
+  int i = 3.0 + a;
+}
+void bar()
+{
+  foo(7.0);
+}
+)cpp",
+  callExpr(traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+hasAnyArgument(floatLiteral());
+
+  EXPECT_TRUE(
+  matches(VarDeclCode,
+  varDecl(traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+   hasType(builtinType());
+
+  EXPECT_TRUE(matches(
+  VarDeclCode,
+  functionDecl(hasName("foo"), traverse(ast_type_traits::TK_AsIs,
+hasDescendant(floatLiteral());
 }
 
 TEST(Traversal, traverseMatcherNesting) {
Index: clang/include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -1199,6 +1199,24 @@
   }
 };
 
+template  class TraversalWrapper {
+public:
+  TraversalWrapper(ast_type_traits::TraversalKind TK,
+   const MatcherType )
+  : TK(TK), InnerMatcher(InnerMatcher) {}
+
+  template  operator Matcher() const {
+return internal::DynTypedMatcher::constructRestrictedWrapper(
+   new internal::TraversalMatcher(TK, InnerMatcher),
+   ast_type_traits::ASTNodeKind::getFromNodeKind())
+.template unconditionalConvertTo();
+  }
+
+private:
+  ast_type_traits::TraversalKind TK;
+  MatcherType InnerMatcher;
+};
+
 /// A PolymorphicMatcherWithParamN object can be
 /// created from N parameters p1, ..., pN (of type P1, ..., PN) and
 /// used as a Matcher where a MatcherT(p1, ..., pN)
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ 

[PATCH] D71976: Match code following lambdas when ignoring invisible nodes

2019-12-31 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd89c4cb93807: Match code following lambdas when ignoring 
invisible nodes (authored by stephenkelly).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71976

Files:
  clang/lib/ASTMatchers/ASTMatchFinder.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp


Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1760,6 +1760,7 @@
 
 void func14() {
   []  (TemplateType t, TemplateType u) { int e = t + u; 
};
+  float i = 42.0;
 }
 
 )cpp";
@@ -1849,6 +1850,11 @@
  lambdaExpr(
  forFunction(functionDecl(hasName("func14"))),
  
has(templateTypeParmDecl(hasName("TemplateType")));
+
+  EXPECT_TRUE(
+  matches(Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+ functionDecl(hasName("func14"),
+  hasDescendant(floatLiteral());
 }
 
 TEST(IgnoringImpCasts, MatchesImpCasts) {
Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp
===
--- clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -248,7 +248,7 @@
 if (!match(*Node->getBody()))
   return false;
 
-return false;
+return true;
   }
 
   bool shouldVisitTemplateInstantiations() const { return true; }


Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1760,6 +1760,7 @@
 
 void func14() {
   []  (TemplateType t, TemplateType u) { int e = t + u; };
+  float i = 42.0;
 }
 
 )cpp";
@@ -1849,6 +1850,11 @@
  lambdaExpr(
  forFunction(functionDecl(hasName("func14"))),
  has(templateTypeParmDecl(hasName("TemplateType")));
+
+  EXPECT_TRUE(
+  matches(Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+ functionDecl(hasName("func14"),
+  hasDescendant(floatLiteral());
 }
 
 TEST(IgnoringImpCasts, MatchesImpCasts) {
Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp
===
--- clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -248,7 +248,7 @@
 if (!match(*Node->getBody()))
   return false;
 
-return false;
+return true;
   }
 
   bool shouldVisitTemplateInstantiations() const { return true; }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 06fdbf3 - Unnest struct in Matcher implementation

2019-12-31 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2019-12-31T17:04:39Z
New Revision: 06fdbf3dafb76e54ea76e0eb5f690bc3d6773023

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

LOG: Unnest struct in Matcher implementation

This allows implementation of the traverse() matcher to surround
matchers like unless().

Added: 


Modified: 
clang/include/clang/ASTMatchers/ASTMatchersInternal.h

Removed: 




diff  --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h 
b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index 47fb5a79ffe6..dacb7a2da535 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -1129,6 +1129,23 @@ using HasDeclarationSupportedTypes =
  TemplateSpecializationType, TemplateTypeParmType, TypedefType,
  UnresolvedUsingType, ObjCIvarRefExpr>;
 
+template  class ArgumentAdapterT,
+  typename T, typename ToTypes>
+class ArgumentAdaptingMatcherFuncAdaptor {
+public:
+  explicit ArgumentAdaptingMatcherFuncAdaptor(const Matcher )
+  : InnerMatcher(InnerMatcher) {}
+
+  using ReturnTypes = ToTypes;
+
+  template  operator Matcher() const {
+return Matcher(new ArgumentAdapterT(InnerMatcher));
+  }
+
+private:
+  const Matcher InnerMatcher;
+};
+
 /// Converts a \c Matcher to a matcher of desired type \c To by
 /// "adapting" a \c To into a \c T.
 ///
@@ -1146,28 +1163,16 @@ template  
class ArgumentAdapterT,
   typename FromTypes = AdaptativeDefaultFromTypes,
   typename ToTypes = AdaptativeDefaultToTypes>
 struct ArgumentAdaptingMatcherFunc {
-  template  class Adaptor {
-  public:
-explicit Adaptor(const Matcher )
-: InnerMatcher(InnerMatcher) {}
-
-using ReturnTypes = ToTypes;
-
-template  operator Matcher() const {
-  return Matcher(new ArgumentAdapterT(InnerMatcher));
-}
-
-  private:
-const Matcher InnerMatcher;
-  };
-
   template 
-  static Adaptor create(const Matcher ) {
-return Adaptor(InnerMatcher);
+  static ArgumentAdaptingMatcherFuncAdaptor
+  create(const Matcher ) {
+return ArgumentAdaptingMatcherFuncAdaptor(
+InnerMatcher);
   }
 
   template 
-  Adaptor operator()(const Matcher ) const {
+  ArgumentAdaptingMatcherFuncAdaptor
+  operator()(const Matcher ) const {
 return create(InnerMatcher);
   }
 };



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


[clang] d89c4cb - Match code following lambdas when ignoring invisible nodes

2019-12-31 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2019-12-31T17:04:39Z
New Revision: d89c4cb938070a6de11e624984e5bd0e989fb334

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

LOG: Match code following lambdas when ignoring invisible nodes

Reviewers: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/ASTMatchers/ASTMatchFinder.cpp
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Removed: 




diff  --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp 
b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
index ab90c745791c..0d1f713db8d3 100644
--- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -248,7 +248,7 @@ class MatchChildASTVisitor
 if (!match(*Node->getBody()))
   return false;
 
-return false;
+return true;
   }
 
   bool shouldVisitTemplateInstantiations() const { return true; }

diff  --git a/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
index b9075927d745..03482e71fac4 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1760,6 +1760,7 @@ void func13() {
 
 void func14() {
   []  (TemplateType t, TemplateType u) { int e = t + u; 
};
+  float i = 42.0;
 }
 
 )cpp";
@@ -1849,6 +1850,11 @@ void func14() {
  lambdaExpr(
  forFunction(functionDecl(hasName("func14"))),
  
has(templateTypeParmDecl(hasName("TemplateType")));
+
+  EXPECT_TRUE(
+  matches(Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+ functionDecl(hasName("func14"),
+  hasDescendant(floatLiteral());
 }
 
 TEST(IgnoringImpCasts, MatchesImpCasts) {



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


[PATCH] D72014: [PowerPC]: Add powerpcspe target triple subarch component

2019-12-31 Thread Justin Hibbits via Phabricator via cfe-commits
jhibbits updated this revision to Diff 235716.
jhibbits added a comment.

Add triple unit test.  I chose freebsd as the OS since that's my environment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72014

Files:
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/test/Preprocessor/init.c
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/Support/Triple.cpp
  llvm/lib/Target/PowerPC/PPCSubtarget.cpp
  llvm/unittests/ADT/TripleTest.cpp

Index: llvm/unittests/ADT/TripleTest.cpp
===
--- llvm/unittests/ADT/TripleTest.cpp
+++ llvm/unittests/ADT/TripleTest.cpp
@@ -163,6 +163,13 @@
   EXPECT_EQ(Triple::UnknownOS, T.getOS());
   EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
 
+  T = Triple("powerpcspe-unknown-freebsd");
+  EXPECT_EQ(Triple::ppc, T.getArch());
+  EXPECT_EQ(Triple::PPCSubArch_spe, T.getSubArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::FreeBSD, T.getOS());
+  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
+
   T = Triple("arm-none-none-eabi");
   EXPECT_EQ(Triple::arm, T.getArch());
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
Index: llvm/lib/Target/PowerPC/PPCSubtarget.cpp
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+++ llvm/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -150,6 +150,9 @@
   TargetTriple.isMusl())
 SecurePlt = true;
 
+  if (TargetTriple.getSubArch() == Triple::PPCSubArch_spe)
+HasSPE = true;
+
   if (HasSPE && IsPPC64)
 report_fatal_error( "SPE is only supported for 32-bit targets.\n", false);
   if (HasSPE && (HasAltivec || HasQPX || HasVSX || HasFPU))
Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -389,7 +389,7 @@
 // FIXME: Do we need to support these?
 .Cases("i786", "i886", "i986", Triple::x86)
 .Cases("amd64", "x86_64", "x86_64h", Triple::x86_64)
-.Cases("powerpc", "ppc", "ppc32", Triple::ppc)
+.Cases("powerpc", "powerpcspe", "ppc", "ppc32", Triple::ppc)
 .Cases("powerpc64", "ppu", "ppc64", Triple::ppc64)
 .Cases("powerpc64le", "ppc64le", Triple::ppc64le)
 .Case("xscale", Triple::arm)
@@ -563,6 +563,9 @@
   (SubArchName.endswith("r6el") || SubArchName.endswith("r6")))
 return Triple::MipsSubArch_r6;
 
+  if (SubArchName == "powerpcspe")
+return Triple::PPCSubArch_spe;
+
   StringRef ARMSubArch = ARM::getCanonicalArchName(SubArchName);
 
   // For now, this is the small part. Early return.
Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -128,7 +128,9 @@
 KalimbaSubArch_v4,
 KalimbaSubArch_v5,
 
-MipsSubArch_r6
+MipsSubArch_r6,
+
+PPCSubArch_spe
   };
   enum VendorType {
 UnknownVendor,
Index: clang/test/Preprocessor/init.c
===
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -7617,6 +7617,7 @@
 // PPC32-LINUX-NOT: _CALL_LINUX
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-unknown-linux-gnu -target-feature +spe < /dev/null | FileCheck -match-full-lines -check-prefix PPC32-SPE %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpcspe-unknown-linux-gnu < /dev/null | FileCheck -match-full-lines -check-prefix PPC32-SPE %s
 //
 // PPC32-SPE:#define __NO_FPRS__ 1
 // PPC32-SPE:#define __SPE__ 1
Index: clang/lib/Basic/Targets/PPC.h
===
--- clang/lib/Basic/Targets/PPC.h
+++ clang/lib/Basic/Targets/PPC.h
@@ -87,8 +87,7 @@
 
   // Note: GCC recognizes the following additional cpus:
   //  401, 403, 405, 405fp, 440fp, 464, 464fp, 476, 476fp, 505, 740, 801,
-  //  821, 823, 8540, 8548, e300c2, e300c3, e500mc64, e6500, 860, cell,
-  //  titan, rs64.
+  //  821, 823, 8540, e300c2, e300c3, e500mc64, e6500, 860, cell, titan, rs64.
   bool isValidCPUName(StringRef Name) const override;
   void fillValidCPUList(SmallVectorImpl ) const override;
 
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -316,7 +316,8 @@
 .Case("pwr8", true)
 .Default(false);
 
-  Features["spe"] = llvm::StringSwitch(CPU)
+  Features["spe"] = getTriple().getSubArch() == llvm::Triple::PPCSubArch_spe ||
+llvm::StringSwitch(CPU)
 .Case("8548", true)
 .Case("e500", true)
 .Default(false);
___
cfe-commits mailing list

[PATCH] D71980: [clang-tidy] Disable Checks on If constexpr statements in template Instantiations for BugproneBranchClone and ReadabilityBracesAroundStatements

2019-12-31 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

I have a version with a new DiscaredStmt working, but it's currently lacking 
test cases, docs and it was pretty much made as a copy paste job from NullStmt 
so I'm not going to hurry up about trying to polish that one. The new lines and 
test cases patch I'll get done probably 2nd January now the booziness is 
beginning


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

https://reviews.llvm.org/D71980



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


[clang] ff429c5 - [OpenCL] Remove redundant foreach in OpenCLBuiltins.td; NFC

2019-12-31 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2019-12-31T15:30:02Z
New Revision: ff429c5eaf79529aacdc15582c90c0915080e082

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

LOG: [OpenCL] Remove redundant foreach in OpenCLBuiltins.td; NFC

Remove various `foreach` declarations where the iterator is used only
once.  This makes the .td file more compact.

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 72b72f60a662..d4c473e2a68f 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -979,25 +979,21 @@ foreach AS = [GlobalAS, LocalAS] in {
 //
 // OpenCL v1.1 s6.11.12, v1.2 s6.12.12, v2.0 s6.13.12 - Miscellaneous Vector 
Functions
 // --- Table 19 ---
-foreach name = ["shuffle"] in {
-  foreach VSize1 = [Vec2, Vec4, Vec8, Vec16] in {
-foreach VSize2 = [Vec2, Vec4, Vec8, Vec16] in {
-  def : Builtin,
-   GenericType<"TLAll" # VSize2.Name, TLAll, VSize2>,
-   GenericType<"TLAllUnsigned" # VSize1.Name, 
TLAllUnsigned, VSize1>],
-  Attr.Const>;
-}
+foreach VSize1 = [Vec2, Vec4, Vec8, Vec16] in {
+  foreach VSize2 = [Vec2, Vec4, Vec8, Vec16] in {
+def : Builtin<"shuffle", [GenericType<"TLAll" # VSize1.Name, TLAll, 
VSize1>,
+  GenericType<"TLAll" # VSize2.Name, TLAll, 
VSize2>,
+  GenericType<"TLAllUnsigned" # VSize1.Name, 
TLAllUnsigned, VSize1>],
+  Attr.Const>;
   }
 }
-foreach name = ["shuffle2"] in {
-  foreach VSize1 = [Vec2, Vec4, Vec8, Vec16] in {
-foreach VSize2 = [Vec2, Vec4, Vec8, Vec16] in {
-  def : Builtin,
-   GenericType<"TLAll" # VSize2.Name, TLAll, VSize2>,
-   GenericType<"TLAll" # VSize2.Name, TLAll, VSize2>,
-   GenericType<"TLAllUnsigned" # VSize1.Name, 
TLAllUnsigned, VSize1>],
-  Attr.Const>;
-}
+foreach VSize1 = [Vec2, Vec4, Vec8, Vec16] in {
+  foreach VSize2 = [Vec2, Vec4, Vec8, Vec16] in {
+def : Builtin<"shuffle2", [GenericType<"TLAll" # VSize1.Name, TLAll, 
VSize1>,
+   GenericType<"TLAll" # VSize2.Name, TLAll, 
VSize2>,
+   GenericType<"TLAll" # VSize2.Name, TLAll, 
VSize2>,
+   GenericType<"TLAllUnsigned" # VSize1.Name, 
TLAllUnsigned, VSize1>],
+  Attr.Const>;
   }
 }
 
@@ -1280,79 +1276,39 @@ let Extension = FuncExtKhrMipmapImage in {
   // Added to section 6.13.14.4.
   foreach aQual = ["WO"] in {
 foreach imgTy = [Image2d] in {
-  foreach name = ["write_imagef"] in {
-def : Builtin, VectorType, Int, VectorType]>;
-  }
-  foreach name = ["write_imagei"] in {
-def : Builtin, VectorType, Int, VectorType]>;
-  }
-  foreach name = ["write_imageui"] in {
-def : Builtin, VectorType, Int, VectorType]>;
-  }
-}
-foreach imgTy = [Image2dDepth] in {
-  foreach name = ["write_imagef"] in {
-def : Builtin, VectorType, Int, Float]>;
-  }
+  def : Builtin<"write_imagef", [Void, ImageType, 
VectorType, Int, VectorType]>;
+  def : Builtin<"write_imagei", [Void, ImageType, 
VectorType, Int, VectorType]>;
+  def : Builtin<"write_imageui", [Void, ImageType, 
VectorType, Int, VectorType]>;
 }
+def : Builtin<"write_imagef", [Void, ImageType, 
VectorType, Int, Float]>;
 foreach imgTy = [Image1d] in {
-  foreach name = ["write_imagef"] in {
-def : Builtin, Int, Int, 
VectorType]>;
-  }
-  foreach name = ["write_imagei"] in {
-def : Builtin, Int, Int, 
VectorType]>;
-  }
-  foreach name = ["write_imageui"] in {
-def : Builtin, Int, Int, 
VectorType]>;
-  }
+  def : Builtin<"write_imagef", [Void, ImageType, Int, Int, 
VectorType]>;
+  def : Builtin<"write_imagei", [Void, ImageType, Int, Int, 
VectorType]>;
+  def : Builtin<"write_imageui", [Void, ImageType, Int, Int, 
VectorType]>;
 }
 foreach imgTy = [Image1dArray] in {
-  foreach name = ["write_imagef"] in {
-def : Builtin, VectorType, Int, VectorType]>;
-  }
-  foreach name = ["write_imagei"] in {
-def : Builtin, VectorType, Int, VectorType]>;
-  }
-  foreach name = ["write_imageui"] in {
-def : Builtin, VectorType, Int, VectorType]>;
-  }
+  def : Builtin<"write_imagef", [Void, ImageType, 
VectorType, Int, VectorType]>;
+  def : Builtin<"write_imagei", [Void, ImageType, 
VectorType, Int, VectorType]>;
+  def : Builtin<"write_imageui", 

[PATCH] D72018: [attributes] [analyzer] Add an attribute to prevent checkers from modeling a function

2019-12-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

> What do you think? Is this reasonable or do you have any alternative ideas?

This seems like a very specialized attribute for the static analyzer and I'm 
not certain how much utility it adds, but that may be because I don't 
understand the analyzer requirements sufficiently yet. It seems as though this 
attribute is intended to suppress diagnostics within a certain function for a 
certain check, much like `gsl::suppress` does for the C++ Core Guidelines. Is 
that correct? If so, perhaps we should just reuse that attribute (but with a 
different spelling)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72018



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


[PATCH] D71963: clang-tidy doc: Add the severities description

2019-12-31 Thread Kim Viggedal via Phabricator via cfe-commits
vingeldal added a comment.

In D71963#1799956 , @aaron.ballman 
wrote:

> I may have missed this in prior discussions, and if so, I'm sorry -- but why 
> are we taking CodeChecker as the model for this? I'm not opposed to having 
> some notion of severity for our checks (basically every tool and many coding 
> standards have the same concept), but I am not certain why we would say 
> CodeChecker's way is the way we want clang-tidy to progress. Also, does this 
> tie in with the clang static analyzer checks, or is the severity stuff only 
> for clang-tidy?


Same thoughts here. In my opinion it would be preferable if Clang tidy doesn't 
make any promises about being aligned with CodeChecker severity levels.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71963



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


[PATCH] D71499: Add builtins for aligning and checking alignment of pointers and integers

2019-12-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:2844
+The builtins ``__builtin_align_up``, ``__builtin_align_down``, return their
+first argument aligned up/down to the next multiple of the second argument.
+The builtin ``__builtin_is_aligned`` returns whether the first argument is

Should explicitly specify whether the arguments are expressed in bytes or bits.



Comment at: clang/docs/LanguageExtensions.rst:2853
+
+If Clang can determined that the alignment is be not a power of two at
+compile-time, it will result in a compilation failure. If the alignment 
argument

determined -> determine
is be not -> is not



Comment at: clang/lib/AST/ExprConstant.cpp:8154
+static CharUnits getBaseAlignment(EvalInfo , const LValue ) {
+  if (const ValueDecl *VD = Value.Base.dyn_cast()) {
+return Info.Ctx.getDeclAlign(VD);

Can go with `const auto *` where the type is spelled out in the initialization 
like this (here and elsewhere).



Comment at: clang/lib/AST/ExprConstant.cpp:8156-8158
+  } else if (const Expr *E = Value.Base.dyn_cast()) {
+return GetAlignOfExpr(Info, E, UETT_AlignOf);
+  } else {

No `else` after a `return`.



Comment at: clang/lib/AST/ExprConstant.cpp:8173
+  }
+  const unsigned SrcWidth = Info.Ctx.getIntWidth(ForType);
+  APSInt MaxValue(APInt::getOneBitSet(SrcWidth, SrcWidth - 1));

Should drop the top-level `const` qualifier as that isn't an idiom we typically 
use for locals.



Comment at: clang/lib/AST/ExprConstant.cpp:10685
+if (Src.isLValue()) {
+  // If we evaluated a pointer, check the minimum known alignment
+  LValue Ptr;

Comment missing a full stop at the end.



Comment at: clang/lib/AST/ExprConstant.cpp:10720
+  return Error(E);
+assert(Src.isInt() && "Adjusting pointer alignment in IntExprEvaluator?");
+APSInt AlignedVal =

This assertion doesn't add much given the above line of code.



Comment at: clang/lib/AST/ExprConstant.cpp:10734
+  return Error(E);
+assert(Src.isInt() && "Adjusting pointer alignment in IntExprEvaluator?");
+APSInt AlignedVal =

Same here as above.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:14267
+QualType AstType = E->getArg(0)->getType();
+if (AstType->isArrayType()) {
+  Src = CGF.EmitArrayToPointerDecay(E->getArg(0)).getPointer();

Can elide braces.



Comment at: clang/lib/Sema/SemaChecking.cpp:224
+  SrcTy->isFunctionPointerType()) {
+// XXX: this is not quite the right error message since we don't allow
+// floating point types, or member pointers

Comment should probably be a FIXME unless you intend to address it as part of 
this patch. Also, the comment is missing a full stop (please check all comments 
in the patch as many of them are missing one).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71499



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


[PATCH] D72035: [analyzer][NFC] Use CallEvent checker callback in GenericTaintChecker

2019-12-31 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:385
+unsigned getNumArgs(const CallEvent ) {
+  return Call.getNumArgs() + static_cast(isa(Call));
 }

steakhal wrote:
> I'm not sure why should we adjust (//workaround//) the number of arguments of 
> `CXXInstanceCall`s calls, can someone explain it to me?
> 
> The same question raised for `getArg` too. 
Remove this :)

I think this is about this inconsistency with operator calls where one of 
{decl, expr} treats `this` as an argument, but the other doesn't. `CallEvent` 
automatically accounts for that (see `getAdjustedParameterIndex()` and 
`getASTArgumentIndex()` as they're overridden in various sub-classes of 
`CallEvent`).



Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:459
   // TODO: Add support for vfscanf & family.
-  .Case("fdopen", TaintPropagationRule({}, {ReturnValueIndex}))
-  .Case("fopen", TaintPropagationRule({}, {ReturnValueIndex}))
-  .Case("freopen", TaintPropagationRule({}, {ReturnValueIndex}))
-  .Case("getch", TaintPropagationRule({}, {ReturnValueIndex}))
-  .Case("getchar", TaintPropagationRule({}, {ReturnValueIndex}))
-  .Case("getchar_unlocked",
-TaintPropagationRule({}, {ReturnValueIndex}))
-  .Case("getenv", TaintPropagationRule({}, {ReturnValueIndex}))
-  .Case("gets", TaintPropagationRule({}, {0, ReturnValueIndex}))
-  .Case("scanf", TaintPropagationRule({}, {}, VariadicType::Dst, 1))
-  .Case("socket",
-TaintPropagationRule({}, {ReturnValueIndex}, 
VariadicType::None,
- InvalidArgIndex,
- ::postSocket))
-  .Case("wgetch", TaintPropagationRule({}, {ReturnValueIndex}))
+  .Case("fdopen", {{}, {ReturnValueIndex}})
+  .Case("fopen", {{}, {ReturnValueIndex}})

Pls eventually transform this into `CallDescriptionMap` ^.^



Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:590
+ CheckerContext ) {
+  const auto *OCE = dyn_cast(Call.getOriginExpr());
   if (OCE) {

steakhal wrote:
> I'm not sure if this is the right way.
You might want to cast `Call` to `CXXMemberOperatorCall` but i'm not sure it 
saves you anything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72035



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


[PATCH] D71980: [clang-tidy] Disable Checks on If constexpr statements in template Instantiations for BugproneBranchClone and ReadabilityBracesAroundStatements

2019-12-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM with newlines in the test files.


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

https://reviews.llvm.org/D71980



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


[PATCH] D71857: Fixes -Wrange-loop-analysis warnings

2019-12-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

It seems like some of the deductions are not spelling out the qualifiers or 
pointer/references explicitly in some cases, at least from my spot-checking. 
Can you go back through this patch to make sure we're getting those correct?




Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp:78
 return;
-  for (const auto  : DerivedDecl.methods()) {
+  for (auto Method : DerivedDecl.methods()) {
 // Virtual destructors are OK. We're ignoring constructors since they are

Shouldn't this deduce to `const auto *`?



Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:795
   if (const auto *Decl = Result.Nodes.getNodeAs("using")) {
-for (const auto  : Decl->shadows()) {
+for (auto Shadow : Decl->shadows()) {
   addUsage(NamingCheckFailures, Shadow->getTargetDecl(),

Same here.



Comment at: 
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp:75
 return false;
-  for (const auto  : call_inst->operand_values())
+  for (auto param : call_inst->operand_values())
 if (isRSAllocationPtrTy(param->getType()))

`auto *`?



Comment at: llvm/lib/Support/CommandLine.cpp:246
 if (SC == &*AllSubCommands) {
-  for (const auto  : RegisteredSubCommands) {
+  for (auto Sub : RegisteredSubCommands) {
 if (SC == Sub)

`auto *`?



Comment at: llvm/lib/Support/CommandLine.cpp:2115
 SmallVectorImpl> ) {
-  for (const auto  : SubMap) {
+  for (auto S : SubMap) {
 if (S->getName().empty())

`auto *`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71857



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


[PATCH] D71110: [clangd] A tool to evaluate cross-file rename.

2019-12-31 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added a comment.

For some reason, running this patch on a recent version of the source tree 
fails. The AST parsing fails with fatal diagnostics, but I can't understand why:

  E[15:14:33.084] source file unknown type name 'PathRef' is illformed: 1
  E[15:15:02.831] source file unknown type name 'NestedNameSpecifierLoc'; did 
you mean 'std::clang::NestedNameSpecifierLoc'? is illformed: 1
  E[15:14:02.912] source file unknown type name 'Location' is illformed: 1
  E[15:14:47.797] source file 'index' is not a class, namespace, or enumeration 
is illformed: 1
  E[15:14:17.658] source file no template named 'vector' in namespace 'std' is 
illformed: 1

I've had many unsuccessful attempts to track down the bug and use multiple 
different configurations (i.e. I thought something might be wrong with my index 
location or directory structure, so in the end I replicated the setup that I 
can infer from the code), but I still didn't manage to run the renames.

In order to make it easier for you to understand what went wrong I have logged 
my commands and output so that one could understand what happens. I've tried 
several versions of LLVM, the log is for the most recent one, 
https://github.com/kirillbobyrev/llvm-project/commit/c7dc4734d23f45f576ba5af2aae5be9dfa2d3643.
 I've made sure to run `check-all` to validate correctness of source tree and 
to generate all test files so that indexer does not crash. I've made sure that 
all the commands ran without any errors.

Because the output is quite verbose, I'm submitting another file which only 
lists the commands instead of the one with verbose output. If you need the full 
log, please let me know. Attached file: F11162505: log.txt 


Please let me know if I have done something incorrectly.




Comment at: clang-tools-extra/clangd/eval-rename/RenameMain.cpp:34
+static llvm::cl::opt
+Fix("fix", llvm::cl::desc("Apply the rename edits to disk files"),
+llvm::cl::init(false));

Maybe just `Apply`? `Fix` seems slightly confusing.



Comment at: clang-tools-extra/clangd/eval-rename/eval-rename.py:1
+#!/usr/bin/python
+"""

It probably makes sense to migrate this to Python 3 instead (shouldn't be too 
hard, from what I can see there are Python 2 print statements, but nothing else 
I can find).



Comment at: clang-tools-extra/clangd/eval-rename/eval-rename.py:11
+$ ninja -C build clangd-rename
+$ clang-tools-extra/clangd/eval-rename/eval-rename.py --index=llvm-index.idx 
--file=clang-tools-extra/clangd/eval-rename/symbol_to_rename.txt
+"""

Maybe some comments regarding what each field in `symbol_to_rename.txt` 
corresponds to and how it is parsed would be useful.



Comment at: clang-tools-extra/clangd/eval-rename/eval-rename.py:21
+
+RENAME_EXECUTOR='build/bin/clangd-rename'
+

Would be useful to add an argument to the build directory, I typically don't 
put `build/` into `llvm/`.



Comment at: clang-tools-extra/clangd/eval-rename/eval-rename.py:23
+
+def Run(cmd):
+  s = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

nit: `run`?



Comment at: clang-tools-extra/clangd/eval-rename/eval-rename.py:82
+success_cnt += 1
+  Run(['git', 'reset', '--hard'])
+  print 'Evaluated rename on %d symbols, %d symbol succeeded, go %s for 
failure logs' % (

`git reset --hard` might be dangerous if compile-commands are symlinked to the 
build directory: `ninja -C build` would re-generate them and `git reset --hard` 
will e.g. erase `add_subdirectory(eval-rename)` if it's not committed. Maybe 
this should be mentioned somewhere in the comments/user guide.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71110



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


[PATCH] D71963: clang-tidy doc: Add the severities description

2019-12-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I may have missed this in prior discussions, and if so, I'm sorry -- but why 
are we taking CodeChecker as the model for this? I'm not opposed to having some 
notion of severity for our checks (basically every tool and many coding 
standards have the same concept), but I am not certain why we would say 
CodeChecker's way is the way we want clang-tidy to progress. Also, does this 
tie in with the clang static analyzer checks, or is the severity stuff only for 
clang-tidy?




Comment at: clang-tools-extra/docs/clang-tidy/checks/list.rst:414
+
+- **STYLE**: A true positive indicates that the source code is against a 
specific coding guideline or could improve readability.
+  Example: LLVM Coding Guideline: Do not use else or else if after something 
that interrupts control flow (break, return, throw, continue).

vingeldal wrote:
> It seems like there is a bit of overlap between STYLE and LOW. They both 
> mention readability.
> Might I suggest that style could be only issues related to naming convention 
> and text formatting, like indentation, line breaks -like things that could be 
> clang format rules.
I'm not keen on "is against a specific coding guideline" because things like 
the CERT secure coding standard and HIC++ are both "coding guidelines" yet 
failures against them are almost invariably not stylistic.



Comment at: clang-tools-extra/docs/clang-tidy/checks/list.rst:417
+
+- **LOW**: A true positive indicates that the source code is hard to 
read/understand or could be easily optimized.
+  Example: Unused variables, Dead code.

"Hard to read/understand" code can also be based on style choices -- so how to 
differentiate between low and style checks?



Comment at: clang-tools-extra/docs/clang-tidy/checks/list.rst:423
+
+- **HIGH**: A true positive indicates that the source code will cause a 
run-time error.
+  Example of this category: out of bounds array access, division by zero, 
memory leak.

vingeldal wrote:
> Does something need to always result in division by zero to be of high 
> severity or is it enough that it introduces the possibility for division by 
> zero to occur?
"Run-time error" is a strange bar because any logical mistake in the code is a 
run-time error. However, we also don't want to limit high severity cases to 
only things that cause crashes because some kinds of crashes are not bad (like 
assertion failures) while other kinds of non-crashes are very bad (like 
dangerous uses of format specifiers that can lead to arbitrary code execution).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71963



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


[PATCH] D71982: [docs] Update path to clang-tools-extra

2019-12-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/docs/clang-tidy/Contributing.rst:66
 
-Once you are done, change to the ``llvm/tools/clang/tools/extra`` directory, 
and
+Once you are done, change to the ``llvm/clang-tools-extra`` directory, and
 let's start!

Jim wrote:
> I am no sure that "llvm/clang-tools-extra" should be replaced as 
> "llvm-project/clang-tools-extra".
> Maybe someone would confuse with "llvm", "llvm-project" and 
> "llvm-project/llvm"
Elsewhere we use `path/to/llvm/source`, which seems to be sufficiently clear.



Comment at: clang-tools-extra/docs/clang-tidy/Contributing.rst:78
 :program:`clang-tidy` source code resides in the
-``llvm/tools/clang/tools/extra`` directory and is structured as follows:
+``llvm/clang-tools-extra`` directory and is structured as follows:
 

`path/to/llvm/source` here as well.


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

https://reviews.llvm.org/D71982



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


[PATCH] D71846: [ASTMatchers] Fix for https://bugs.llvm.org/show_bug.cgi?id=44364

2019-12-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D71846#1798115 , @njames93 wrote:

> Sorry I didn't make it obvious with the test cases. The fix will never extend 
> the lifetime of variables either in the condition or declared in the else 
> block. It will only apply if the if is the last statement in its scope. 
> Though I should check back through the scope for any declarations that have 
> the same identifier as those in the if statement which would cause an error 
> if they were brought out of the if scope


Oh, thank you for the clarification, I hadn't picked up on that.




Comment at: clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp:21
 
+static const char ReturnStr[] = "return";
+static const char ContinueStr[] = "continue";

Hmm, I just realized we missed `co_return` for this check. That's a separate 
patch, though, so don't feel the need to change anything about this here.



Comment at: clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp:45
+const DeclRefExpr *findUsage(const Stmt *Node, int64_t DeclIdentifier) {
+  if (const auto *DeclRef = dyn_cast_or_null(Node)) {
+if (DeclRef->getDecl()->getID() == DeclIdentifier) {

The use of `dyn_cast_or_null` is suspicious in these methods -- if `Node` is 
null, then we'll get into the `else` clause and promptly dereference a null 
pointer. My guess is that these should be `dyn_cast` calls instead, but if 
`Node` can truly be null, that case should be handled.



Comment at: clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp:50
+  } else {
+for (const auto  : Node->children()) {
+  if (auto Result = findUsage(ChildNode, DeclIdentifier)) {

`const auto *`, no? (Same below.)



Comment at: clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp:51
+for (const auto  : Node->children()) {
+  if (auto Result = findUsage(ChildNode, DeclIdentifier)) {
+return Result;

`const auto *` for sure. (Same below.)



Comment at: clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp:77
+const DeclRefExpr *checkInitDeclUsageInElse(const IfStmt *If) {
+  auto InitDeclStmt = dyn_cast_or_null(If->getInit());
+  if (!InitDeclStmt)

`const auto *` (this comment applies throughout the patch -- we don't want to 
deduce qualifiers or pointer/references, so they should be spelled out 
explicitly.)



Comment at: clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp:86
+  llvm::SmallVector DeclIdentifiers;
+  for (const auto  : InitDeclStmt->decls()) {
+assert(isa(Decl) && "Init Decls must be a VarDecl");

`const auto *`, no?



Comment at: 
clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp:123
+Diag << tooling::fixit::createRemoval(ElseLoc);
+const auto LBrace = CS->getLBracLoc();
+const auto RBrace = CS->getRBracLoc();

Please don't use `auto` here as the type is not spelled out in the 
initialization. Also, drop the top-level `const` qualifier. Same elsewhere.



Comment at: 
clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp:161
+  if (!IsLastInScope && containsDeclInScope(Else)) {
+// warn, but don't attempt an autofix
+diag(ElseLoc, WarningMessage) << ControlFlowInterruptor;

warn -> Warn
and should have a full stop at the end of the comment. The same applies to the 
other instances of this comment.


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

https://reviews.llvm.org/D71846



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


[PATCH] D72028: [CodeGen] Emit conj/conjf/confjl libcalls as fneg instructions if possible.

2019-12-31 Thread Sanjay Patel via Phabricator via cfe-commits
spatel accepted this revision.
spatel added a comment.
This revision is now accepted and ready to land.

Code change LGTM - see inline for a question about the testing.




Comment at: clang/test/CodeGen/complex-libcalls.c:115-118
+// NO__ERRNO-NOT: .conj
+// NO__ERRNO-NOT: @conj
+// HAS_ERRNO-NOT: .conj
+// HAS_ERRNO-NOT: @conj

Could we use positive matches for "fneg" here rather than NOT lines? If so, 
then do we need the new test file?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72028



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


[PATCH] D71976: Match code following lambdas when ignoring invisible nodes

2019-12-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 assuming the behavioral change did not break anything in clang-tools-extra.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71976



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


[PATCH] D71977: Implement additional traverse() overloads

2019-12-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!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71977



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


[PATCH] D71857: Fixes -Wrange-loop-analysis warnings

2019-12-31 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: 
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp:22
 
 #include "lldb/Target/Process.h"
 #include "lldb/Utility/Log.h"

NFC patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71857



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


[PATCH] D54395: [clang-tidy] implement utility-function to add 'const' to variables

2019-12-31 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 235705.
JonasToth added a comment.

- clarify FIXME problem


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54395

Files:
  clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.cpp
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
  clang-tools-extra/clang-tidy/utils/FixItHintUtils.h
  clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
  clang-tools-extra/clang-tidy/utils/LexerUtils.h
  clang-tools-extra/unittests/clang-tidy/AddConstTest.cpp
  clang-tools-extra/unittests/clang-tidy/CMakeLists.txt

Index: clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
===
--- clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
+++ clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
@@ -7,6 +7,7 @@
 include_directories(${CLANG_LINT_SOURCE_DIR})
 
 add_extra_unittest(ClangTidyTests
+  AddConstTest.cpp
   ClangTidyDiagnosticConsumerTest.cpp
   ClangTidyOptionsTest.cpp
   IncludeInserterTest.cpp
Index: clang-tools-extra/unittests/clang-tidy/AddConstTest.cpp
===
--- /dev/null
+++ clang-tools-extra/unittests/clang-tidy/AddConstTest.cpp
@@ -0,0 +1,1009 @@
+#include "../clang-tidy/utils/FixItHintUtils.h"
+#include "ClangTidyTest.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace tidy {
+
+namespace {
+using namespace clang::ast_matchers;
+using namespace utils::fixit;
+
+template 
+class ConstTransform : public ClangTidyCheck {
+public:
+  ConstTransform(StringRef CheckName, ClangTidyContext *Context)
+  : ClangTidyCheck(CheckName, Context) {}
+
+  void registerMatchers(MatchFinder *Finder) override {
+Finder->addMatcher(varDecl(hasName("target")).bind("var"), this);
+  }
+
+  void check(const MatchFinder::MatchResult ) override {
+const auto *D = Result.Nodes.getNodeAs("var");
+using utils::fixit::addQualifierToVarDecl;
+Optional Fix = addQualifierToVarDecl(
+*D, *Result.Context, DeclSpec::TQ::TQ_const, CT, CP);
+auto Diag = diag(D->getBeginLoc(), "doing const transformation");
+if (Fix)
+  Diag << *Fix;
+  }
+};
+} // namespace
+
+namespace test {
+using PointeeLTransform =
+ConstTransform;
+using PointeeRTransform =
+ConstTransform;
+
+using ValueLTransform =
+ConstTransform;
+using ValueRTransform =
+ConstTransform;
+
+// 
+// Test Value-like types. Everything with indirection is done later.
+// 
+
+TEST(Values, Builtin) {
+  StringRef Snippet = "int target = 0;";
+
+  EXPECT_EQ("const int target = 0;", runCheckOnCode(Snippet));
+  EXPECT_EQ("const int target = 0;",
+runCheckOnCode(Snippet));
+
+  EXPECT_EQ("int const target = 0;", runCheckOnCode(Snippet));
+  EXPECT_EQ("int const target = 0;",
+runCheckOnCode(Snippet));
+}
+TEST(Values, TypedefBuiltin) {
+  StringRef T = "typedef int MyInt;";
+  StringRef S = "MyInt target = 0;";
+  auto Cat = [](StringRef S) { return (T + S).str(); };
+
+  EXPECT_EQ(Cat("const MyInt target = 0;"),
+runCheckOnCode(Cat(S)));
+  EXPECT_EQ(Cat("const MyInt target = 0;"),
+runCheckOnCode(Cat(S)));
+
+  EXPECT_EQ(Cat("MyInt const target = 0;"),
+runCheckOnCode(Cat(S)));
+  EXPECT_EQ(Cat("MyInt const target = 0;"),
+runCheckOnCode(Cat(S)));
+}
+TEST(Values, TypedefBuiltinPointer) {
+  StringRef T = "typedef int* MyInt;";
+  StringRef S = "MyInt target = nullptr;";
+  auto Cat = [](StringRef S) { return (T + S).str(); };
+
+  EXPECT_EQ(Cat("const MyInt target = nullptr;"),
+runCheckOnCode(Cat(S)));
+  EXPECT_EQ(Cat("const MyInt target = nullptr;"),
+runCheckOnCode(Cat(S)));
+
+  EXPECT_EQ(Cat("MyInt const target = nullptr;"),
+runCheckOnCode(Cat(S)));
+  EXPECT_EQ(Cat("MyInt const target = nullptr;"),
+runCheckOnCode(Cat(S)));
+}
+TEST(Values, UsingBuiltin) {
+  StringRef T = "using MyInt = int;";
+  StringRef S = "MyInt target = 0;";
+  auto Cat = [](StringRef S) { return (T + S).str(); };
+
+  EXPECT_EQ(Cat("const MyInt target = 0;"),
+runCheckOnCode(Cat(S)));
+  EXPECT_EQ(Cat("const MyInt target = 0;"),
+runCheckOnCode(Cat(S)));
+
+  EXPECT_EQ(Cat("MyInt const target = 0;"),
+runCheckOnCode(Cat(S)));
+  EXPECT_EQ(Cat("MyInt const target = 0;"),
+runCheckOnCode(Cat(S)));
+}
+TEST(Values, UsingBuiltinPointer) {
+  StringRef T = "using MyInt = int*;";
+  StringRef S = "MyInt 

[PATCH] D72035: [analyzer][NFC] Use CallEvent checker callback in GenericTaintChecker

2019-12-31 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:385
+unsigned getNumArgs(const CallEvent ) {
+  return Call.getNumArgs() + static_cast(isa(Call));
 }

I'm not sure why should we adjust (//workaround//) the number of arguments of 
`CXXInstanceCall`s calls, can someone explain it to me?

The same question raised for `getArg` too. 



Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:590
+ CheckerContext ) {
+  const auto *OCE = dyn_cast(Call.getOriginExpr());
   if (OCE) {

I'm not sure if this is the right way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72035



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


[PATCH] D72035: [analyzer][NFC] Use CallEvent checker callback in GenericTaintChecker

2019-12-31 Thread Balázs Benics via Phabricator via cfe-commits
steakhal created this revision.
steakhal added reviewers: NoQ, Szelethus, boga95.
steakhal added a project: clang.
Herald added subscribers: cfe-commits, Charusso, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun, whisperity.
steakhal added a parent revision: D71524: [analyzer] Support tainted objects in 
GenericTaintChecker.

Intended to be a non-functional change but it turned out **CallEvent** handles 
constructor calls unlike **CallExpr** which doesn't triggered for constructors.

All in all, this change shouldn't be observable since constructors are not yet 
propagating taintness like functions.
In the future constructors should propagate taintness as well.

This change includes:

- NFCi change all uses of the CallExpr to CallEvent
- NFC rename some functions, mark static them etc.
- NFC omit explicit TaintPropagationRule type in switches
- NFC apply some clang-tidy fixits


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72035

Files:
  clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp

Index: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
@@ -22,12 +22,15 @@
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
 #include "llvm/Support/Regex.h"
 #include "llvm/Support/YAMLTraits.h"
+
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -36,17 +39,15 @@
 using namespace taint;
 
 namespace {
-class GenericTaintChecker
-: public Checker, check::PreStmt> {
+class GenericTaintChecker : public Checker {
 public:
   static void *getTag() {
 static int Tag;
 return 
   }
 
-  void checkPostStmt(const CallExpr *CE, CheckerContext ) const;
-
-  void checkPreStmt(const CallExpr *CE, CheckerContext ) const;
+  void checkPreCall(const CallEvent , CheckerContext ) const;
+  void checkPostCall(const CallEvent , CheckerContext ) const;
 
   void printState(raw_ostream , ProgramStateRef State, const char *NL,
   const char *Sep) const override;
@@ -82,7 +83,7 @@
 
   /// Convert SignedArgVector to ArgVector.
   ArgVector convertToArgVector(CheckerManager , const std::string ,
-   SignedArgVector Args);
+   const SignedArgVector );
 
   /// Parse the config.
   void parseConfiguration(CheckerManager , const std::string ,
@@ -97,7 +98,8 @@
   mutable std::unique_ptr BT;
   void initBugType() const {
 if (!BT)
-  BT.reset(new BugType(this, "Use of Untrusted Data", "Untrusted Data"));
+  BT = std::make_unique(this, "Use of Untrusted Data",
+ "Untrusted Data");
   }
 
   struct FunctionData {
@@ -107,9 +109,10 @@
 FunctionData =(const FunctionData &) = delete;
 FunctionData =(FunctionData &&) = delete;
 
-static Optional create(const CallExpr *CE,
+static Optional create(const CallEvent ,
  const CheckerContext ) {
-  const FunctionDecl *FDecl = C.getCalleeDecl(CE);
+  assert(Call.getDecl());
+  const FunctionDecl *FDecl = Call.getDecl()->getAsFunction();
   if (!FDecl || (FDecl->getKind() != Decl::Function &&
  FDecl->getKind() != Decl::CXXMethod))
 return None;
@@ -133,39 +136,39 @@
 
   /// Catch taint related bugs. Check if tainted data is passed to a
   /// system call etc. Returns true on matching.
-  bool checkPre(const CallExpr *CE, const FunctionData ,
+  bool checkPre(const CallEvent , const FunctionData ,
 CheckerContext ) const;
 
   /// Add taint sources for extraction operator on pre-visit.
-  bool addOverloadedOpPre(const CallExpr *CE, CheckerContext ) const;
+  static bool addOverloadedOpPre(const CallEvent , CheckerContext );
 
   /// Add taint sources on a pre-visit. Returns true on matching.
-  bool addSourcesPre(const CallExpr *CE, const FunctionData ,
+  bool addSourcesPre(const CallEvent , const FunctionData ,
  CheckerContext ) const;
 
   /// Mark filter's arguments not tainted on a pre-visit. Returns true on
   /// matching.
-  bool addFiltersPre(const CallExpr *CE, const FunctionData ,
+  bool addFiltersPre(const CallEvent , const FunctionData ,
  CheckerContext ) const;
 
   /// Propagate taint generated at pre-visit. Returns true on matching.
-  bool propagateFromPre(const CallExpr *CE, CheckerContext ) const;
+  static bool propagateFromPre(const CallEvent , CheckerContext );
 
   /// Check if the region the expression evaluates to 

[PATCH] D71963: clang-tidy doc: Add the severities description

2019-12-31 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

@vingeldal Apologies, in that case. However, I would still claim that `style`  
(as a //potential// severity) has its purpose for Tidy checkers, not just for  
`clang-format`.

In D71963#1798871 , @vingeldal wrote:

> If severity levels must be exactly like they are currently defined in 
> CodeChecker then IMO that is a rather strong reason not to introduce them in 
> clang-tidy and just keep that stuff in CodeChecker.


This is exactly the reason why I urged @sylvestre.ledru in D36051 
 to mention that the levels were taken from 
CodeChecker's classification. Which, by all means, could be viewed as "just 
another" classification. @dkrupp will hopefully explain the decision making 
behind the classification when he is back from holidays - give it a week more 
or so.

I believe the severity categories and assigned severity levels in CodeChecker 
are also malleable. Discussion brings us forward if there is a chance of coming 
up with better ideas, it's just a little bit of JS and database wrangling to 
put in a new severity into CodeChecker's system.



CodeChecker actually uses a two-dimensional classification: I think severities 
indicate some sort of a relative "power" of the report itself - the higher the 
severity, the more likely the reported issue will actually cause trouble. I 
don't know the nitty-gritty for where the demarcation line is drawn between 
`low` and `medium`. My previous comment, as follows:

In D71963#1798829 , @whisperity wrote:

> A `low` diagnostics (and everything "above", assuming a(n at least) partial 
> ordering on severities) should mean the coding construct is problematic: 
> there is a chance -- perhaps once in a lifetime, perhaps not -- that doing 
> this will cause a real error. A `style` thing should mean [snip]. No **real** 
> "game-breaking" issue should ever arise from deciding on fixing or ignoring a 
> `style` check's output.


was to indicate that any border between `style` and, let's say, 
//whatever-else// on the other hand, should be very clear immediately - `style` 
issues are not something to react with a //"STOP THE WORLD!"// approach - in 
case of a CI hook, if a developer receives a `style` report on their 
to-be-added patch, sure please fix it before the commit, but in case a badly 
formatted code had already made it into the upstream repository, it's not 
urgent to have it fixed. (This is the same we do in LLVM, too, except that we 
don't really have patch-CIs yet, sadly.) This is what I meant with `style` 
being applicable for //some// Tidy checkers, not just format.

Another classification, orthogonal to severity used in CodeChecker is dubbed 
"checker profiles" 

 which assign checkers into, once again, arbitrarily named categories. When you 
run CodeChecker, you can do `--enable default --enable extreme --enable alpha` 
which will turn on every checker from the two categories, and the `alpha.` 
Clang-SA checker "group" or "namespace". These categories (or "profiles"), 
according to the comments in the file, were decided based on the "strength" of 
the **checker** (as opposed to the "strength" of the **report**), namely that 
checkers with higher false-positive rate (which directly translates to an 
inverse desire to even look at the reports) are grouped into "more extreme" 
categories. This is simply to give users a good enough "starting point" for 
their analysis, everyone can run the analyzers however they see fit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71963



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


[PATCH] D54395: [clang-tidy] implement utility-function to add 'const' to variables

2019-12-31 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 235704.
JonasToth added a comment.

- adjust skipLParens code slightly to remove redundant checks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54395

Files:
  clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.cpp
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
  clang-tools-extra/clang-tidy/utils/FixItHintUtils.h
  clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
  clang-tools-extra/clang-tidy/utils/LexerUtils.h
  clang-tools-extra/unittests/clang-tidy/AddConstTest.cpp
  clang-tools-extra/unittests/clang-tidy/CMakeLists.txt

Index: clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
===
--- clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
+++ clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
@@ -7,6 +7,7 @@
 include_directories(${CLANG_LINT_SOURCE_DIR})
 
 add_extra_unittest(ClangTidyTests
+  AddConstTest.cpp
   ClangTidyDiagnosticConsumerTest.cpp
   ClangTidyOptionsTest.cpp
   IncludeInserterTest.cpp
Index: clang-tools-extra/unittests/clang-tidy/AddConstTest.cpp
===
--- /dev/null
+++ clang-tools-extra/unittests/clang-tidy/AddConstTest.cpp
@@ -0,0 +1,1008 @@
+#include "../clang-tidy/utils/FixItHintUtils.h"
+#include "ClangTidyTest.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace tidy {
+
+namespace {
+using namespace clang::ast_matchers;
+using namespace utils::fixit;
+
+template 
+class ConstTransform : public ClangTidyCheck {
+public:
+  ConstTransform(StringRef CheckName, ClangTidyContext *Context)
+  : ClangTidyCheck(CheckName, Context) {}
+
+  void registerMatchers(MatchFinder *Finder) override {
+Finder->addMatcher(varDecl(hasName("target")).bind("var"), this);
+  }
+
+  void check(const MatchFinder::MatchResult ) override {
+const auto *D = Result.Nodes.getNodeAs("var");
+using utils::fixit::addQualifierToVarDecl;
+Optional Fix = addQualifierToVarDecl(
+*D, *Result.Context, DeclSpec::TQ::TQ_const, CT, CP);
+auto Diag = diag(D->getBeginLoc(), "doing const transformation");
+if (Fix)
+  Diag << *Fix;
+  }
+};
+} // namespace
+
+namespace test {
+using PointeeLTransform =
+ConstTransform;
+using PointeeRTransform =
+ConstTransform;
+
+using ValueLTransform =
+ConstTransform;
+using ValueRTransform =
+ConstTransform;
+
+// 
+// Test Value-like types. Everything with indirection is done later.
+// 
+
+TEST(Values, Builtin) {
+  StringRef Snippet = "int target = 0;";
+
+  EXPECT_EQ("const int target = 0;", runCheckOnCode(Snippet));
+  EXPECT_EQ("const int target = 0;",
+runCheckOnCode(Snippet));
+
+  EXPECT_EQ("int const target = 0;", runCheckOnCode(Snippet));
+  EXPECT_EQ("int const target = 0;",
+runCheckOnCode(Snippet));
+}
+TEST(Values, TypedefBuiltin) {
+  StringRef T = "typedef int MyInt;";
+  StringRef S = "MyInt target = 0;";
+  auto Cat = [](StringRef S) { return (T + S).str(); };
+
+  EXPECT_EQ(Cat("const MyInt target = 0;"),
+runCheckOnCode(Cat(S)));
+  EXPECT_EQ(Cat("const MyInt target = 0;"),
+runCheckOnCode(Cat(S)));
+
+  EXPECT_EQ(Cat("MyInt const target = 0;"),
+runCheckOnCode(Cat(S)));
+  EXPECT_EQ(Cat("MyInt const target = 0;"),
+runCheckOnCode(Cat(S)));
+}
+TEST(Values, TypedefBuiltinPointer) {
+  StringRef T = "typedef int* MyInt;";
+  StringRef S = "MyInt target = nullptr;";
+  auto Cat = [](StringRef S) { return (T + S).str(); };
+
+  EXPECT_EQ(Cat("const MyInt target = nullptr;"),
+runCheckOnCode(Cat(S)));
+  EXPECT_EQ(Cat("const MyInt target = nullptr;"),
+runCheckOnCode(Cat(S)));
+
+  EXPECT_EQ(Cat("MyInt const target = nullptr;"),
+runCheckOnCode(Cat(S)));
+  EXPECT_EQ(Cat("MyInt const target = nullptr;"),
+runCheckOnCode(Cat(S)));
+}
+TEST(Values, UsingBuiltin) {
+  StringRef T = "using MyInt = int;";
+  StringRef S = "MyInt target = 0;";
+  auto Cat = [](StringRef S) { return (T + S).str(); };
+
+  EXPECT_EQ(Cat("const MyInt target = 0;"),
+runCheckOnCode(Cat(S)));
+  EXPECT_EQ(Cat("const MyInt target = 0;"),
+runCheckOnCode(Cat(S)));
+
+  EXPECT_EQ(Cat("MyInt const target = 0;"),
+runCheckOnCode(Cat(S)));
+  EXPECT_EQ(Cat("MyInt const target = 0;"),
+runCheckOnCode(Cat(S)));
+}
+TEST(Values, UsingBuiltinPointer) {
+  StringRef T = "using MyInt 

[PATCH] D54395: [clang-tidy] implement utility-function to add 'const' to variables

2019-12-31 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 235703.
JonasToth added a comment.

- improve test situation and fix a crash coming from invalid source locations


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54395

Files:
  clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.cpp
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
  clang-tools-extra/clang-tidy/utils/FixItHintUtils.h
  clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
  clang-tools-extra/clang-tidy/utils/LexerUtils.h
  clang-tools-extra/unittests/clang-tidy/AddConstTest.cpp
  clang-tools-extra/unittests/clang-tidy/CMakeLists.txt

Index: clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
===
--- clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
+++ clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
@@ -7,6 +7,7 @@
 include_directories(${CLANG_LINT_SOURCE_DIR})
 
 add_extra_unittest(ClangTidyTests
+  AddConstTest.cpp
   ClangTidyDiagnosticConsumerTest.cpp
   ClangTidyOptionsTest.cpp
   IncludeInserterTest.cpp
Index: clang-tools-extra/unittests/clang-tidy/AddConstTest.cpp
===
--- /dev/null
+++ clang-tools-extra/unittests/clang-tidy/AddConstTest.cpp
@@ -0,0 +1,1008 @@
+#include "../clang-tidy/utils/FixItHintUtils.h"
+#include "ClangTidyTest.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace tidy {
+
+namespace {
+using namespace clang::ast_matchers;
+using namespace utils::fixit;
+
+template 
+class ConstTransform : public ClangTidyCheck {
+public:
+  ConstTransform(StringRef CheckName, ClangTidyContext *Context)
+  : ClangTidyCheck(CheckName, Context) {}
+
+  void registerMatchers(MatchFinder *Finder) override {
+Finder->addMatcher(varDecl(hasName("target")).bind("var"), this);
+  }
+
+  void check(const MatchFinder::MatchResult ) override {
+const auto *D = Result.Nodes.getNodeAs("var");
+using utils::fixit::addQualifierToVarDecl;
+Optional Fix = addQualifierToVarDecl(
+*D, *Result.Context, DeclSpec::TQ::TQ_const, CT, CP);
+auto Diag = diag(D->getBeginLoc(), "doing const transformation");
+if (Fix)
+  Diag << *Fix;
+  }
+};
+} // namespace
+
+namespace test {
+using PointeeLTransform =
+ConstTransform;
+using PointeeRTransform =
+ConstTransform;
+
+using ValueLTransform =
+ConstTransform;
+using ValueRTransform =
+ConstTransform;
+
+// 
+// Test Value-like types. Everything with indirection is done later.
+// 
+
+TEST(Values, Builtin) {
+  StringRef Snippet = "int target = 0;";
+
+  EXPECT_EQ("const int target = 0;", runCheckOnCode(Snippet));
+  EXPECT_EQ("const int target = 0;",
+runCheckOnCode(Snippet));
+
+  EXPECT_EQ("int const target = 0;", runCheckOnCode(Snippet));
+  EXPECT_EQ("int const target = 0;",
+runCheckOnCode(Snippet));
+}
+TEST(Values, TypedefBuiltin) {
+  StringRef T = "typedef int MyInt;";
+  StringRef S = "MyInt target = 0;";
+  auto Cat = [](StringRef S) { return (T + S).str(); };
+
+  EXPECT_EQ(Cat("const MyInt target = 0;"),
+runCheckOnCode(Cat(S)));
+  EXPECT_EQ(Cat("const MyInt target = 0;"),
+runCheckOnCode(Cat(S)));
+
+  EXPECT_EQ(Cat("MyInt const target = 0;"),
+runCheckOnCode(Cat(S)));
+  EXPECT_EQ(Cat("MyInt const target = 0;"),
+runCheckOnCode(Cat(S)));
+}
+TEST(Values, TypedefBuiltinPointer) {
+  StringRef T = "typedef int* MyInt;";
+  StringRef S = "MyInt target = nullptr;";
+  auto Cat = [](StringRef S) { return (T + S).str(); };
+
+  EXPECT_EQ(Cat("const MyInt target = nullptr;"),
+runCheckOnCode(Cat(S)));
+  EXPECT_EQ(Cat("const MyInt target = nullptr;"),
+runCheckOnCode(Cat(S)));
+
+  EXPECT_EQ(Cat("MyInt const target = nullptr;"),
+runCheckOnCode(Cat(S)));
+  EXPECT_EQ(Cat("MyInt const target = nullptr;"),
+runCheckOnCode(Cat(S)));
+}
+TEST(Values, UsingBuiltin) {
+  StringRef T = "using MyInt = int;";
+  StringRef S = "MyInt target = 0;";
+  auto Cat = [](StringRef S) { return (T + S).str(); };
+
+  EXPECT_EQ(Cat("const MyInt target = 0;"),
+runCheckOnCode(Cat(S)));
+  EXPECT_EQ(Cat("const MyInt target = 0;"),
+runCheckOnCode(Cat(S)));
+
+  EXPECT_EQ(Cat("MyInt const target = 0;"),
+runCheckOnCode(Cat(S)));
+  EXPECT_EQ(Cat("MyInt const target = 0;"),
+runCheckOnCode(Cat(S)));
+}
+TEST(Values, UsingBuiltinPointer) {
+  StringRef 

[PATCH] D71991: Fix external-names.c test when separator is \\

2019-12-31 Thread Michael Platings via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0c7ca82161b5: Fix external-names.c test when separator is \\ 
(authored by michaelplatings).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71991

Files:
  clang/test/VFS/external-names.c


Index: clang/test/VFS/external-names.c
===
--- clang/test/VFS/external-names.c
+++ clang/test/VFS/external-names.c
@@ -21,7 +21,7 @@
 // Diagnostics:
 
 // RUN: %clang_cc1 -I %t -ivfsoverlay %t.external.yaml -fsyntax-only %s 2>&1 | 
FileCheck -check-prefix=CHECK-DIAG-EXTERNAL %s
-// CHECK-DIAG-EXTERNAL: {{.*}}Inputs{{.}}external-names.h:{{[0-9]*:[0-9]*}}: 
warning: incompatible pointer
+// CHECK-DIAG-EXTERNAL: {{.*}}Inputs{{..?}}external-names.h:{{[0-9]*:[0-9]*}}: 
warning: incompatible pointer
 
 // RUN: %clang_cc1 -I %t -ivfsoverlay %t.yaml -fsyntax-only %s 2>&1 | 
FileCheck -check-prefix=CHECK-DIAG %s
 // CHECK-DIAG-NOT: Inputs
@@ -31,7 +31,7 @@
 
 // RUN: %clang_cc1 -I %t -ivfsoverlay %t.external.yaml -triple 
%itanium_abi_triple -debug-info-kind=limited -emit-llvm %s -o - | FileCheck 
-check-prefix=CHECK-DEBUG-EXTERNAL %s
 // CHECK-DEBUG-EXTERNAL: !DISubprogram({{.*}}file: ![[Num:[0-9]+]]
-// CHECK-DEBUG-EXTERNAL: ![[Num]] = !DIFile(filename: 
"{{[^"]*}}Inputs{{.}}external-names.h"
+// CHECK-DEBUG-EXTERNAL: ![[Num]] = !DIFile(filename: 
"{{[^"]*}}Inputs{{..?}}external-names.h"
 
 // RUN: %clang_cc1 -I %t -ivfsoverlay %t.yaml -triple %itanium_abi_triple 
-debug-info-kind=limited -emit-llvm %s -o - | FileCheck 
-check-prefix=CHECK-DEBUG %s
 // CHECK-DEBUG-NOT: Inputs
@@ -42,7 +42,7 @@
 // RUN: %clang_cc1 -D REINCLUDE -I %t -ivfsoverlay %t.external.yaml -Eonly %s 
-MTfoo -dependency-file %t.external.dep
 // RUN: echo "EOF" >> %t.external.dep
 // RUN: cat %t.external.dep | FileCheck --check-prefix=CHECK-DEP-EXTERNAL %s
-// CHECK-DEP-EXTERNAL: Inputs{{.}}external-names.h
+// CHECK-DEP-EXTERNAL: Inputs{{..?}}external-names.h
 // CHECK-DEP-EXTERNAL-NEXT: EOF
 
 // RUN: %clang_cc1 -D REINCLUDE -I %t -ivfsoverlay %t.yaml -Eonly %s -MTfoo 
-dependency-file %t.dep


Index: clang/test/VFS/external-names.c
===
--- clang/test/VFS/external-names.c
+++ clang/test/VFS/external-names.c
@@ -21,7 +21,7 @@
 // Diagnostics:
 
 // RUN: %clang_cc1 -I %t -ivfsoverlay %t.external.yaml -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-DIAG-EXTERNAL %s
-// CHECK-DIAG-EXTERNAL: {{.*}}Inputs{{.}}external-names.h:{{[0-9]*:[0-9]*}}: warning: incompatible pointer
+// CHECK-DIAG-EXTERNAL: {{.*}}Inputs{{..?}}external-names.h:{{[0-9]*:[0-9]*}}: warning: incompatible pointer
 
 // RUN: %clang_cc1 -I %t -ivfsoverlay %t.yaml -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-DIAG %s
 // CHECK-DIAG-NOT: Inputs
@@ -31,7 +31,7 @@
 
 // RUN: %clang_cc1 -I %t -ivfsoverlay %t.external.yaml -triple %itanium_abi_triple -debug-info-kind=limited -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-DEBUG-EXTERNAL %s
 // CHECK-DEBUG-EXTERNAL: !DISubprogram({{.*}}file: ![[Num:[0-9]+]]
-// CHECK-DEBUG-EXTERNAL: ![[Num]] = !DIFile(filename: "{{[^"]*}}Inputs{{.}}external-names.h"
+// CHECK-DEBUG-EXTERNAL: ![[Num]] = !DIFile(filename: "{{[^"]*}}Inputs{{..?}}external-names.h"
 
 // RUN: %clang_cc1 -I %t -ivfsoverlay %t.yaml -triple %itanium_abi_triple -debug-info-kind=limited -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-DEBUG %s
 // CHECK-DEBUG-NOT: Inputs
@@ -42,7 +42,7 @@
 // RUN: %clang_cc1 -D REINCLUDE -I %t -ivfsoverlay %t.external.yaml -Eonly %s -MTfoo -dependency-file %t.external.dep
 // RUN: echo "EOF" >> %t.external.dep
 // RUN: cat %t.external.dep | FileCheck --check-prefix=CHECK-DEP-EXTERNAL %s
-// CHECK-DEP-EXTERNAL: Inputs{{.}}external-names.h
+// CHECK-DEP-EXTERNAL: Inputs{{..?}}external-names.h
 // CHECK-DEP-EXTERNAL-NEXT: EOF
 
 // RUN: %clang_cc1 -D REINCLUDE -I %t -ivfsoverlay %t.yaml -Eonly %s -MTfoo -dependency-file %t.dep
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71991: Fix external-names.c test when separator is \\

2019-12-31 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings added a comment.

Thanks for accepting.
The repo is up to date. I guess the reason the failure hasn't happened with the 
build bots is that our downstream test setup differs somewhat from the norm - 
our test runner imports lit.discovery & lit.LitConfig directly rather than 
using the command line interface. I've had a hunt for what the exact difference 
might be but haven't been able to find it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71991



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


[clang] 0c7ca82 - Fix external-names.c test when separator is \\

2019-12-31 Thread Michael Platings via cfe-commits

Author: Michael Platings
Date: 2019-12-31T11:15:46Z
New Revision: 0c7ca82161b519856bb1d54e181b578dc067cd3e

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

LOG: Fix external-names.c test when separator is \\

This fixes the following failure:

C:\[...]\llvm\tools\clang\test\VFS\external-names.c:34:26: error: 
CHECK-DEBUG-EXTERNAL: expected string not found in input
// CHECK-DEBUG-EXTERNAL: ![[Num]] = !DIFile(filename: 
"{{[^"]*}}Inputs{{.}}external-names.h"
 ^
[...]
:42:54: note: possible intended match here
!10 = !DIFile(filename: 
"C:/[...]\\llvm\\tools\\clang\\test\\VFS\\Inputs\\external-names.h", directory: 
"")

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

Added: 


Modified: 
clang/test/VFS/external-names.c

Removed: 




diff  --git a/clang/test/VFS/external-names.c b/clang/test/VFS/external-names.c
index 0500611c3e40..7e24b5fdf063 100644
--- a/clang/test/VFS/external-names.c
+++ b/clang/test/VFS/external-names.c
@@ -21,7 +21,7 @@
 // Diagnostics:
 
 // RUN: %clang_cc1 -I %t -ivfsoverlay %t.external.yaml -fsyntax-only %s 2>&1 | 
FileCheck -check-prefix=CHECK-DIAG-EXTERNAL %s
-// CHECK-DIAG-EXTERNAL: {{.*}}Inputs{{.}}external-names.h:{{[0-9]*:[0-9]*}}: 
warning: incompatible pointer
+// CHECK-DIAG-EXTERNAL: {{.*}}Inputs{{..?}}external-names.h:{{[0-9]*:[0-9]*}}: 
warning: incompatible pointer
 
 // RUN: %clang_cc1 -I %t -ivfsoverlay %t.yaml -fsyntax-only %s 2>&1 | 
FileCheck -check-prefix=CHECK-DIAG %s
 // CHECK-DIAG-NOT: Inputs
@@ -31,7 +31,7 @@
 
 // RUN: %clang_cc1 -I %t -ivfsoverlay %t.external.yaml -triple 
%itanium_abi_triple -debug-info-kind=limited -emit-llvm %s -o - | FileCheck 
-check-prefix=CHECK-DEBUG-EXTERNAL %s
 // CHECK-DEBUG-EXTERNAL: !DISubprogram({{.*}}file: ![[Num:[0-9]+]]
-// CHECK-DEBUG-EXTERNAL: ![[Num]] = !DIFile(filename: 
"{{[^"]*}}Inputs{{.}}external-names.h"
+// CHECK-DEBUG-EXTERNAL: ![[Num]] = !DIFile(filename: 
"{{[^"]*}}Inputs{{..?}}external-names.h"
 
 // RUN: %clang_cc1 -I %t -ivfsoverlay %t.yaml -triple %itanium_abi_triple 
-debug-info-kind=limited -emit-llvm %s -o - | FileCheck 
-check-prefix=CHECK-DEBUG %s
 // CHECK-DEBUG-NOT: Inputs
@@ -42,7 +42,7 @@
 // RUN: %clang_cc1 -D REINCLUDE -I %t -ivfsoverlay %t.external.yaml -Eonly %s 
-MTfoo -dependency-file %t.external.dep
 // RUN: echo "EOF" >> %t.external.dep
 // RUN: cat %t.external.dep | FileCheck --check-prefix=CHECK-DEP-EXTERNAL %s
-// CHECK-DEP-EXTERNAL: Inputs{{.}}external-names.h
+// CHECK-DEP-EXTERNAL: Inputs{{..?}}external-names.h
 // CHECK-DEP-EXTERNAL-NEXT: EOF
 
 // RUN: %clang_cc1 -D REINCLUDE -I %t -ivfsoverlay %t.yaml -Eonly %s -MTfoo 
-dependency-file %t.dep



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


[PATCH] D36051: Move from a long list of checkers to tables

2019-12-31 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

Thanks. Fixed in 
https://github.com/llvm/llvm-project/commit/e8c9110b56b516a22b41e95e347bc141814ab87c


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D36051



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


[clang-tools-extra] e8c9110 - clang-tidy doc: modernize-make-unique has an autofix

2019-12-31 Thread Sylvestre Ledru via cfe-commits

Author: Sylvestre Ledru
Date: 2019-12-31T11:56:17+01:00
New Revision: e8c9110b56b516a22b41e95e347bc141814ab87c

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

LOG: clang-tidy doc: modernize-make-unique has an autofix

Added: 


Modified: 
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst 
b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index 08805ea248eb..7273f2f2c10a 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -202,7 +202,7 @@ Clang-Tidy Checks
`modernize-deprecated-ios-base-aliases 
`_, "Yes", "low"
`modernize-loop-convert `_, "Yes", "style"
`modernize-make-shared `_, "Yes", "low"
-   `modernize-make-unique `_, , "low"
+   `modernize-make-unique `_, "Yes", "low"
`modernize-pass-by-value `_, "Yes", "low"
`modernize-raw-string-literal `_, "Yes", 
"style"
`modernize-redundant-void-arg `_, "Yes", 
"style"



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


[PATCH] D36051: Move from a long list of checkers to tables

2019-12-31 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

In D36051#1799785 , @sylvestre.ledru 
wrote:

> @malcolm.parsons really? Oh, where is it implemented? 
>  
> https://github.com/llvm/llvm-project/blob/61504079515f76ca094bb836c4d53b41064220d6/clang-tools-extra/clang-tidy/modernize/MakeUniqueCheck.cpp
>  I didn't see it here


It is in `MakeSmartPtrCheck.{h,cpp}`, as `unique_ptr` and `shared_ptr` can be 
treated the same.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D36051



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


[PATCH] D71037: [Diagnostic] Add ftabstop to -Wmisleading-indentation

2019-12-31 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

This broke my builds. A configure test that tries to compile `int main (void) { 
for( int i = 0; i < 9; i++ ); return 0; }` (a single line source file), with 
`-Wall` enabled, now triggers failed asserts:

  clang-10: ../tools/clang/lib/Parse/ParseStmt.cpp:1236: static unsigned int 
{anonymous}::MisleadingIndentationChecker::getVisualIndentation(clang::SourceManager&,
 clang::SourceLocation): Assertion `FIDAndOffset.second > ColNo && "Column 
number smaller than file offset?"' failed.
  
  
  
  1.  oneline.c:1:49: current parser token 'return'
  2.  oneline.c:1:17: parsing function body 'main'
  3.  oneline.c:1:17: in compound statement ('{}')


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71037



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


[PATCH] D36051: Move from a long list of checkers to tables

2019-12-31 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

@malcolm.parsons really? Oh, where is it implemented? 
https://github.com/llvm/llvm-project/blob/61504079515f76ca094bb836c4d53b41064220d6/clang-tools-extra/clang-tidy/modernize/MakeUniqueCheck.cpp
I didn't see it here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D36051



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


[PATCH] D36051: Move from a long list of checkers to tables

2019-12-31 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added inline comments.



Comment at: clang-tools-extra/docs/clang-tidy/checks/list.rst:205
+   `modernize-make-shared `_, "Yes", "low"
+   `modernize-make-unique `_, , "low"
+   `modernize-pass-by-value `_, "Yes", "low"

modernize-make-unique offers fixes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D36051



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