[PATCH] D72993: [NFC][Codegen] Use MaybeAlign + APInt::getLimitedValue() when creating Alignment attr

2020-01-20 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet accepted this revision.
gchatelet added a comment.
This revision is now accepted and ready to land.

Thx!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72993



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


[PATCH] D72984: [TableGen] Use a table to lookup MVE intrinsic names

2020-01-20 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham accepted this revision.
simon_tatham added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72984



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


[PATCH] D73020: [Sema] Perform call checking when building CXXNewExpr

2020-01-20 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision.
lebedev.ri added reviewers: rsmith, erichkeane, aaron.ballman, jdoerfert.
lebedev.ri added a project: clang.
lebedev.ri added a parent revision: D73019: [Sema] Don't disallow placing 
`__attribute__((alloc_align(param_idx)))` on `std::align_val_t`-typed 
parameters.

There was even a TODO for this.
The main motivation is to make use of call-site based
`__attribute__((alloc_align(param_idx)))` validation (D72996 
).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73020

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp


Index: clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
===
--- clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
+++ clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
@@ -30,10 +30,8 @@
 
 void *ptr_variable(int align) { return new (std::align_val_t(align)) A; }
 void *ptr_align16() { return new (std::align_val_t(16)) A; }
-void *ptr_align15() { return new (std::align_val_t(15)) A; }
+void *ptr_align15() { return new (std::align_val_t(15)) A; } // expected-error 
{{requested alignment is not a power of 2}}
 
 std::align_val_t align_variable(int align) { return std::align_val_t(align); }
 std::align_val_t align_align16() { return std::align_val_t(16); }
 std::align_val_t align_align15() { return std::align_val_t(15); }
-
-// expected-no-diagnostics
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -2078,10 +2078,15 @@
 if (!AllPlaceArgs.empty())
   PlacementArgs = AllPlaceArgs;
 
-// FIXME: This is wrong: PlacementArgs misses out the first (size) 
argument.
-DiagnoseSentinelCalls(OperatorNew, PlacementLParen, PlacementArgs);
+llvm::SmallVector CallArgs;
+CallArgs.reserve(1 + PlacementArgs.size());
+CallArgs.emplace_back(nullptr); // FIXME: size argument.
+CallArgs.insert(CallArgs.end(), PlacementArgs.begin(), 
PlacementArgs.end());
 
-// FIXME: Missing call to CheckFunctionCall or equivalent
+DiagnoseSentinelCalls(OperatorNew, PlacementLParen, CallArgs);
+
+checkCall(OperatorNew, Proto, /*ThisArg=*/nullptr, CallArgs,
+  /*IsMemberFunction=*/false, StartLoc, Range, CallType);
 
 // Warn if the type is over-aligned and is being allocated by (unaligned)
 // global operator new.
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4476,7 +4476,7 @@
   if (FDecl && FDecl->hasAttr()) {
 auto *AA = FDecl->getAttr();
 const Expr *Arg = Args[AA->getParamIndex().getASTIndex()];
-if (!Arg->isTypeDependent() && !Arg->isValueDependent()) {
+if (Arg && !Arg->isTypeDependent() && !Arg->isValueDependent()) {
   llvm::APSInt I(64);
   if (Arg->isIntegerConstantExpr(I, Context)) {
 if (!I.isPowerOf2()) {
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -14460,8 +14460,10 @@
 const Expr *E,
 llvm::APSInt *Value,
 SourceLocation *Loc) {
-  if (!E->getType()->isIntegralOrUnscopedEnumerationType()) {
-if (Loc) *Loc = E->getExprLoc();
+  if (!E->getType()->isIntegralOrUnscopedEnumerationType() &&
+  !E->getType()->isAlignValT()) {
+if (Loc)
+  *Loc = E->getExprLoc();
 return false;
   }
 
@@ -14593,7 +14595,8 @@
   ArgVector ArgValues(Args.size());
   for (ArrayRef::iterator I = Args.begin(), E = Args.end();
I != E; ++I) {
-if ((*I)->isValueDependent() ||
+// Arg can be null in malformed code.
+if (!*I || (*I)->isValueDependent() ||
 !Evaluate(ArgValues[I - Args.begin()], Info, *I) ||
 Info.EvalStatus.HasSideEffects)
   // If evaluation fails, throw away the argument entirely.


Index: clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
===
--- clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
+++ clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
@@ -30,10 +30,8 @@
 
 void *ptr_variable(int align) { return new (std::align_val_t(align)) A; }
 void *ptr_align16() { return new (std::align_val_t(16)) A; }
-void *ptr_align15() { return new (std::align_val_t(15)) A; }
+void *ptr_align15() { return new (std::align_val_t(15)) A; } // expected-error {{requested alignment is not a power of 2}}
 
 std::align_val_t align_variable(int align) { return std::align_val_t(align); }
 std::align

[PATCH] D73019: [Sema] Don't disallow placing `__attribute__((alloc_align(param_idx)))` on `std::align_val_t`-typed parameters

2020-01-20 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision.
lebedev.ri added reviewers: erichkeane, rsmith, aaron.ballman, jdoerfert.
lebedev.ri added a project: clang.
lebedev.ri added a parent revision: D73006: [Codegen] If reasonable, 
materialize clang's `AllocAlignAttr` as llvm's Alignment Attribute on call-site 
function return value.
lebedev.ri added a child revision: D73020: [Sema] Perform call checking when 
building CXXNewExpr.

I kind-of understand why it is restricted to integer-typed arguments,
for general enum's the value passed is not nessesairly the alignment implied,
although one might say that user would know best.

But we clearly should whitelist `std::align_val_t`,
which is just a thin wrapper over `std::size_t`,
and is the C++ standard way of specifying alignment.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73019

Files:
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp


Index: clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -std=c++11  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -faligned-allocation -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++17  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++17 -faligned-allocation -fsyntax-only -verify %s
+
+namespace std {
+typedef __SIZE_TYPE__ size_t;
+struct nothrow_t {};
+#if __cplusplus >= 201103L
+enum class align_val_t : size_t {};
+#else
+enum align_val_t {
+// We can't force an underlying type when targeting windows.
+#ifndef _WIN32
+  __zero = 0,
+  __max = (size_t)-1
+#endif
+};
+#endif
+} // namespace std
+
+void *operator new(std::size_t count, std::align_val_t al) 
__attribute__((alloc_align(2)));
+
+#define OVERALIGNED alignas(__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2)
+
+struct OVERALIGNED A {
+  A();
+  int n[128];
+};
+
+void *ptr_variable(int align) { return new (std::align_val_t(align)) A; }
+void *ptr_align16() { return new (std::align_val_t(16)) A; }
+void *ptr_align15() { return new (std::align_val_t(15)) A; }
+
+std::align_val_t align_variable(int align) { return std::align_val_t(align); }
+std::align_val_t align_align16() { return std::align_val_t(16); }
+std::align_val_t align_align15() { return std::align_val_t(15); }
+
+// expected-no-diagnostics
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -1669,7 +1669,8 @@
 return;
 
   QualType Ty = getFunctionOrMethodParamType(D, Idx.getASTIndex());
-  if (!Ty->isDependentType() && !Ty->isIntegralType(Context)) {
+  if (!Ty->isDependentType() && !Ty->isIntegralType(Context) &&
+  !Ty->isAlignValT()) {
 Diag(ParamExpr->getBeginLoc(), diag::err_attribute_integers_only)
 << &TmpAttr
 << FuncDecl->getParamDecl(Idx.getASTIndex())->getSourceRange();


Index: clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -std=c++11  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -faligned-allocation -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++17  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++17 -faligned-allocation -fsyntax-only -verify %s
+
+namespace std {
+typedef __SIZE_TYPE__ size_t;
+struct nothrow_t {};
+#if __cplusplus >= 201103L
+enum class align_val_t : size_t {};
+#else
+enum align_val_t {
+// We can't force an underlying type when targeting windows.
+#ifndef _WIN32
+  __zero = 0,
+  __max = (size_t)-1
+#endif
+};
+#endif
+} // namespace std
+
+void *operator new(std::size_t count, std::align_val_t al) __attribute__((alloc_align(2)));
+
+#define OVERALIGNED alignas(__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2)
+
+struct OVERALIGNED A {
+  A();
+  int n[128];
+};
+
+void *ptr_variable(int align) { return new (std::align_val_t(align)) A; }
+void *ptr_align16() { return new (std::align_val_t(16)) A; }
+void *ptr_align15() { return new (std::align_val_t(15)) A; }
+
+std::align_val_t align_variable(int align) { return std::align_val_t(align); }
+std::align_val_t align_align16() { return std::align_val_t(16); }
+std::align_val_t align_align15() { return std::align_val_t(15); }
+
+// expected-no-diagnostics
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -1669,7 +1669,8 @@
 return;
 
   QualType Ty = getFunctionOrMethodParamType(D, Idx.getASTIndex());
-  if (!Ty->isDependentType() && !Ty->isIntegralType(Context)) {
+  if (!Ty->isDependentType() && !Ty->isIntegralType(Context) &&
+ 

[PATCH] D73020: [Sema] Perform call checking when building CXXNewExpr

2020-01-20 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri planned changes to this revision.
lebedev.ri added a comment.

Ah right, hmm, posted too soon.
I actually need to synthesize the size/align arguments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73020



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


[PATCH] D71607: [clang-tidy] Add unsigned subtraction warning, with suggestion to convert to unsigned literals.

2020-01-20 Thread Jeffrey Sorensen via Phabricator via cfe-commits
sorenj added a comment.

So, I ran this check against the cxx directory of llvm, it fired 5 times so 
let's look at the context and disucss:

There are two identical spots in locale.cpp, the first is around line 2717

  uint16_t t = static_cast(
   0xD800
 | wc & 0x1F) >> 16) - 1) << 6)
 |   ((wc & 0x00FC00) >> 10));
   

the fact that a signed value is being right shifted here surprises me, but 
looking earlier there's a branch for wc < 0x01 so we are safe here against 
wc being 0. So this is a false diagnostic. Still, wc is a uint32_t, it's the 
0x1f that converts it to signed. Probably should be 0x1fu? Will still 
false-alarm on this code though unless you use - 1u to make the whole thing 
unsigned end to end.

the third is in memory.cc

  void*
  align(size_t alignment, size_t size, void*& ptr, size_t& space)
  {
  void* r = nullptr;
  if (size <= space)
  {
  char* p1 = static_cast(ptr);
  char* p2 = reinterpret_cast(reinterpret_cast(p1 + 
(alignment - 1)) & -alignment);

here it doesn't make sense for alignment to be zero, and the & -alignment will 
be zero anyway, so false alarm although some check for alignment > 0 might be 
an improvement

The last two are in valarray.cpp lines 35 and 43, I've copied a large excerpt 
here

  void
  gslice::__init(size_t __start)
  {
  valarray __indices(__size_.size());
  size_t __k = __size_.size() != 0;
  for (size_t __i = 0; __i < __size_.size(); ++__i)
  __k *= __size_[__i];
  __1d_.resize(__k);
  if (__1d_.size())
  {
  __k = 0;
  __1d_[__k] = __start;
  while (true)
  {
  size_t __i = __indices.size() - 1;
  while (true)
  {
  if (++__indices[__i] < __size_[__i])
  {
  ++__k;
  __1d_[__k] = __1d_[__k-1] + __stride_[__i];
  for (size_t __j = __i + 1; __j != __indices.size(); ++__j)
  __1d_[__k] -= __stride_[__j] * (__size_[__j] - 1);
  break;
  }
  else
  

with some looking I can see that `__indices.size()` has to be non-zero. It's 
less clear to me that `size_[__j]` is strictly positive here and there should 
probably be some guard against underflow there.

That's a firing rate of about 5/12K lines of code, but I wonder if I were to 
send patches for these 3 files that silence the warning I wonder how many would 
be approved.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71607



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


[PATCH] D72715: [clang][CodeComplete] Propogate printing policy to FunctionDecl

2020-01-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a subscriber: kuhnel.
hokein added a comment.
This revision is now accepted and ready to land.

@kuhnel, I think we should exclude from running clang-format on lint test files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72715



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


[PATCH] D72746: [clangd] Add a flag for implicit references in the Index

2020-01-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

In D72746#1827608 , @kbobyrev wrote:

> I started using TokenBuffer, but I ran into the following issue: when I'm
>  creating `TokenBuffer` and `TokenCollector`, they do not contain any tokens.
>  `Preprocessor` does not seem to have a non-null Lexer instance, 
> `TokenWatcher`
>  (set in `TokenCollector`) is not triggered anywhere and neither is
>  `Lexer::Lex`. I don't have much familiarity with the code and I looked at the
>  other usages of `TokenBuffer` but didn't figure out what's wrong with the 
> code
>  in this patch. I suspect the lexer in Preprocessor should be re-initialized
>  somehow? I'm certainly missing something here.


right, I forgot that `TokenCollector` must be constructed before starting to 
process the file, and unfortunately in some
code paths we create a `SymbolCollector` long after parsing the file. You can 
make use of `syntax::Tokenize` for now,
as we only care about SpelledTokens in the file. Please leave a TODO though 
saying that, we should rather pass one from
the caller of SymbolCollector.

Sorry for the inconvenience.




Comment at: clang-tools-extra/clangd/index/Ref.h:36
+  // one below.
+  Implicit = 1 << 3,
+  All = Declaration | Definition | Reference | Implicit,

kbobyrev wrote:
> kadircet wrote:
> > kadircet wrote:
> > > instead of doing that, could we rather de-couple two enums completely and 
> > > have a `symbolRoleToRefKind`(and vice-versa) method instead(we already 
> > > have some customization in `toRefKind` now) ?
> > > 
> > > as current change increases the risk of overlapping in future(e.g. 
> > > someone might change symbolrole::declaration and cause 
> > > failures/regressions in clangd)
> > note that this would also require a bump to version of `on-disk` index in 
> > clangd/index/Serialization.cpp, as old information regarding `RefKind` 
> > won't be usable anymore.
> > instead of doing that, could we rather de-couple two enums completely and 
> > have a symbolRoleToRefKind(and vice-versa) method instead(we already have 
> > some customization in toRefKind now) ?
> > as current change increases the risk of overlapping in future(e.g. someone 
> > might change symbolrole::declaration and cause failures/regressions in 
> > clangd)
> 
> Makes sense, will do!
> 
> > note that this would also require a bump to version of on-disk index in 
> > clangd/index/Serialization.cpp, as old information regarding RefKind won't 
> > be usable anymore.
> 
> I checked the Serialization code and the serialization code should be OK as 
> long as `RefKind` stays one byte. Can you please elaborate on this?
> 
> Do you mean that the index should be generated again after this change 
> because it would no longer be valid? (this one I understand)
> Or do you mean there should be some other change in the code for me to do to 
> land this patch?
> Do you mean that the index should be generated again after this change 
> because it would no longer be valid? (this one I understand)

yes i meant this


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72746



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


[clang-tools-extra] 61b5634 - [clangd] Remove a stale FIXME, NFC.

2020-01-20 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-01-20T12:07:30+01:00
New Revision: 61b563408012d17e7e619dedfefac5f38dc2d1d9

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

LOG: [clangd] Remove a stale FIXME, NFC.

Added: 


Modified: 
clang-tools-extra/clangd/refactor/Rename.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index 9984891f0f5b..80917e1abb27 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -335,8 +335,6 @@ findOccurrencesOutsideFile(const NamedDecl &RenameDecl,
 // as the file content we rename on, and fallback to file content on disk if
 // there is no dirty buffer.
 //
-// FIXME: Add range patching heuristics to detect staleness of the index, and
-// report to users.
 // FIXME: Our index may return implicit references, which are not eligible for
 // rename, we should filter out these references.
 llvm::Expected renameOutsideFile(



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


[clang] 514e3c3 - Add missing tests for parent traversal

2020-01-20 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2020-01-20T11:18:35Z
New Revision: 514e3c3694a3457ea5c1b89420246fd845791afd

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

LOG: Add missing tests for parent traversal

Added: 


Modified: 
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Removed: 




diff  --git a/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
index b0696fdb8a75..27f446467fa3 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1633,6 +1633,15 @@ void foo()
   traverse(ast_type_traits::TK_IgnoreImplicitCastsAndParentheses,
Matcher)));
 
+  auto ParentMatcher = floatLiteral(hasParent(varDecl(hasName("i";
+
+  EXPECT_TRUE(
+  notMatches(VarDeclCode, traverse(ast_type_traits::TK_AsIs, 
ParentMatcher)));
+  EXPECT_TRUE(
+  matches(VarDeclCode,
+  traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+   ParentMatcher)));
+
   EXPECT_TRUE(
   matches(VarDeclCode, decl(traverse(ast_type_traits::TK_AsIs,
  anyOf(cxxRecordDecl(), varDecl());
@@ -1714,6 +1723,13 @@ void bar()
   functionDecl(hasName("foo"), traverse(ast_type_traits::TK_AsIs,
 hasDescendant(floatLiteral());
 
+  EXPECT_TRUE(
+  notMatches(Code, traverse(ast_type_traits::TK_AsIs, 
floatLiteral(hasParent(callExpr(callee(functionDecl(hasName("foo");
+  EXPECT_TRUE(
+  matches(Code,
+  traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+   
floatLiteral(hasParent(callExpr(callee(functionDecl(hasName("foo");
+
   Code = R"cpp(
 void foo()
 {
@@ -1724,6 +1740,10 @@ void foo()
   matches(Code,
   traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
varDecl(hasInitializer(integerLiteral(equals(3)));
+  EXPECT_TRUE(
+  matches(Code,
+  traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+   integerLiteral(equals(3), 
hasParent(varDecl(hasName("i")));
 }
 
 template 
@@ -1905,12 +1925,21 @@ void func14() {
  returnStmt(forFunction(functionDecl(hasName("func1"))),
 hasReturnValue(integerLiteral(equals(42)));
 
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+integerLiteral(equals(42), 
hasParent(returnStmt(forFunction(functionDecl(hasName("func1"))
+ )));
+
   EXPECT_TRUE(matches(
   Code,
   traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
returnStmt(forFunction(functionDecl(hasName("func2"))),
   hasReturnValue(cxxTemporaryObjectExpr(
   hasArgument(0, integerLiteral(equals(42);
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+integerLiteral(equals(42), 
hasParent(cxxTemporaryObjectExpr(hasParent(returnStmt(forFunction(functionDecl(hasName("func2")));
 
   EXPECT_TRUE(matches(
   Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
@@ -1919,6 +1948,10 @@ void func14() {
 cxxFunctionalCastExpr(hasSourceExpression(
 integerLiteral(equals(42);
 
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+integerLiteral(equals(42), 
hasParent(cxxFunctionalCastExpr(hasParent(returnStmt(forFunction(functionDecl(hasName("func3"
 )));
+
   EXPECT_TRUE(matches(
   Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
  returnStmt(forFunction(functionDecl(hasName("func4"))),
@@ -1957,18 +1990,32 @@ void func14() {
 hasReturnValue(
 
declRefExpr(to(varDecl(hasName("a");
 
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+declRefExpr(to(varDecl(hasName("a"))), 
hasParent(returnStmt(forFunction(functionDecl(hasName("func10");
+
   EXPECT_TRUE(matches(
   Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
  returnStmt(forFunction(functionDecl(hasName("func11"))),
 hasReturnValue(
 
declRefExpr(to(varDecl(hasName("b");
 
+  EXPECT_TRUE(matches(
+  Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+declRefE

[clang] 122443a - Compare traversal for memoization before bound nodes container

2020-01-20 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2020-01-20T11:20:04Z
New Revision: 122443a950521c5d99a0d0479daf57fbd1de2ac2

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

LOG: Compare traversal for memoization before bound nodes container

Added: 


Modified: 
clang/lib/ASTMatchers/ASTMatchFinder.cpp

Removed: 




diff  --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp 
b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
index 0d1f713db8d3..39a3d8e3750c 100644
--- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -62,9 +62,9 @@ struct MatchKey {
   ast_type_traits::TraversalKind Traversal = ast_type_traits::TK_AsIs;
 
   bool operator<(const MatchKey &Other) const {
-return std::tie(MatcherID, Node, BoundNodes, Traversal) <
-   std::tie(Other.MatcherID, Other.Node, Other.BoundNodes,
-Other.Traversal);
+return std::tie(Traversal, MatcherID, Node, BoundNodes) <
+   std::tie(Other.Traversal, Other.MatcherID, Other.Node,
+Other.BoundNodes);
   }
 };
 



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


[clang-tools-extra] 1f946ee - [clang][CodeComplete] Propogate printing policy to FunctionDecl

2020-01-20 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-01-20T12:20:20+01:00
New Revision: 1f946ee2faba5395a04a081fbe561e3d91aa2b3d

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

LOG: [clang][CodeComplete] Propogate printing policy to FunctionDecl

Summary:
Printing policy was not propogated to functiondecls when creating a
completion string which resulted in canonical template parameters like
`foo`. This patch propogates printing policy to those as
well.

Fixes https://github.com/clangd/clangd/issues/76

Reviewers: ilya-biryukov

Subscribers: jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

Added: 
clang/test/CodeCompletion/ctor-signature.cpp

Modified: 
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
clang/lib/Sema/SemaCodeComplete.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp 
b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
index 8017fc98b8ef..d76508834efd 100644
--- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -2297,6 +2297,15 @@ TEST(CompletionTest, DeprecatedResults) {
AllOf(Named("TestClangc"), Deprecated(;
 }
 
+TEST(SignatureHelpTest, PartialSpec) {
+  const auto Results = signatures(R"cpp(
+  template  struct Foo {};
+  template  struct Foo { Foo(T); };
+  Foo F(^);)cpp");
+  EXPECT_THAT(Results.signatures, Contains(Sig("Foo([[T]])")));
+  EXPECT_EQ(0, Results.activeParameter);
+}
+
 TEST(SignatureHelpTest, InsideArgument) {
   {
 const auto Results = signatures(R"cpp(

diff  --git a/clang/lib/Sema/SemaCodeComplete.cpp 
b/clang/lib/Sema/SemaCodeComplete.cpp
index 7260977c634d..3348067a7669 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -37,6 +37,7 @@
 #include "llvm/ADT/Twine.h"
 #include "llvm/ADT/iterator_range.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 #include 
@@ -3705,8 +3706,11 @@ 
CodeCompleteConsumer::OverloadCandidate::CreateSignatureString(
 Result.addBriefComment(RC->getBriefText(S.getASTContext()));
 }
 AddResultTypeChunk(S.Context, Policy, FDecl, QualType(), Result);
-Result.AddTextChunk(
-Result.getAllocator().CopyString(FDecl->getNameAsString()));
+
+std::string Name;
+llvm::raw_string_ostream OS(Name);
+FDecl->getDeclName().print(OS, Policy);
+Result.AddTextChunk(Result.getAllocator().CopyString(OS.str()));
   } else {
 Result.AddResultTypeChunk(Result.getAllocator().CopyString(
 Proto->getReturnType().getAsString(Policy)));

diff  --git a/clang/test/CodeCompletion/ctor-signature.cpp 
b/clang/test/CodeCompletion/ctor-signature.cpp
new file mode 100644
index ..4dbd92300566
--- /dev/null
+++ b/clang/test/CodeCompletion/ctor-signature.cpp
@@ -0,0 +1,17 @@
+template 
+struct Foo {};
+template 
+struct Foo { Foo(T); };
+
+void foo() {
+  Foo();
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:7:12 %s -o - | 
FileCheck -check-prefix=CHECK-CC1 %s
+  // CHECK-CC1: OVERLOAD: Foo()
+  // CHECK-CC1: OVERLOAD: Foo(<#const Foo &#>)
+  // CHECK-CC1: OVERLOAD: Foo(<#Foo &&#>
+  Foo(3);
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:12:14 %s -o - | 
FileCheck -check-prefix=CHECK-CC2 %s
+  // CHECK-CC2: OVERLOAD: Foo(<#int#>)
+  // CHECK-CC2: OVERLOAD: Foo(<#const Foo &#>)
+  // CHECK-CC2: OVERLOAD: Foo(<#Foo &&#>
+}



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


[PATCH] D73025: [AArch64][SVE] Add first-faulting load intrinsic

2020-01-20 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin created this revision.
kmclaughlin added reviewers: sdesmalen, efriedma, andwar, dancgr.
Herald added subscribers: psnobl, rkruppe, hiraditya, kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
Herald added a project: LLVM.
kmclaughlin added a parent revision: D71698: [AArch64][SVE] Add intrinsic for 
non-faulting loads.

Implements the llvm.aarch64.sve.ldff1 intrinsic and DAG
combine rules for first-faulting loads with sign & zero extends


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73025

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-loads-ff.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-loads-ff.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-loads-ff.ll
@@ -0,0 +1,220 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
+
+;
+; LDFF1B
+;
+
+define  @ldff1b( %pg, i8* %a) {
+; CHECK-LABEL: ldff1b:
+; CHECK: ldff1b { z0.b }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv16i8( %pg, i8* %a)
+  ret  %load
+}
+
+define  @ldff1b_h( %pg, i8* %a) {
+; CHECK-LABEL: ldff1b_h:
+; CHECK: ldff1b { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv8i8( %pg, i8* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldff1b_s( %pg, i8* %a) {
+; CHECK-LABEL: ldff1b_s:
+; CHECK: ldff1b { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv4i8( %pg, i8* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldff1b_d( %pg, i8* %a) {
+; CHECK-LABEL: ldff1b_d:
+; CHECK: ldff1b { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv2i8( %pg, i8* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+;
+; LDFF1SB
+;
+
+define  @ldff1sb_h( %pg, i8* %a) {
+; CHECK-LABEL: ldff1sb_h:
+; CHECK: ldff1sb { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv8i8( %pg, i8* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldff1sb_s( %pg, i8* %a) {
+; CHECK-LABEL: ldff1sb_s:
+; CHECK: ldff1sb { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv4i8( %pg, i8* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldff1sb_d( %pg, i8* %a) {
+; CHECK-LABEL: ldff1sb_d:
+; CHECK: ldff1sb { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv2i8( %pg, i8* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+;
+; LDFF1H
+;
+
+define  @ldff1h( %pg, i16* %a) {
+; CHECK-LABEL: ldff1h:
+; CHECK: ldff1h { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv8i16( %pg, i16* %a)
+  ret  %load
+}
+
+define  @ldff1h_s( %pg, i16* %a) {
+; CHECK-LABEL: ldff1h_s:
+; CHECK: ldff1h { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv4i16( %pg, i16* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldff1h_d( %pg, i16* %a) {
+; CHECK-LABEL: ldff1h_d:
+; CHECK: ldff1h { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv2i16( %pg, i16* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldff1h_f16( %pg, half* %a) {
+; CHECK-LABEL: ldff1h_f16:
+; CHECK: ldff1h { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv8f16( %pg, half* %a)
+  ret  %load
+}
+
+;
+; LDFF1SH
+;
+
+define  @ldff1sh_s( %pg, i16* %a) {
+; CHECK-LABEL: ldff1sh_s:
+; CHECK: ldff1sh { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv4i16( %pg, i16* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldff1sh_d( %pg, i16* %a) {
+; CHECK-LABEL: ldff1sh_d:
+; CHECK: ldff1sh { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv2i16( %pg, i16* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+;
+; LDFF1W
+;
+
+define  @ldff1w( %pg, i32* %a) {
+; CHECK-LABEL: ldff1w:
+; CHECK: ldff1w { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv4i32( %pg, i32* %a)
+  ret  %load
+}
+
+define  @ldff1w_d( %pg, i32* %a) {
+; CHECK-LABEL: ldff1w_d:
+; CHECK: ldff1w { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv2i32( %pg, i32* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldff1w_f32( %pg, float* %a) {
+; CHECK-LABEL: ldff1w_f32:
+; CHECK: ldff1w { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv4f32( %pg, float* %a)
+  ret  %load
+}
+
+define  @ldff1w_2f32( %pg, float* %a) {
+; CHECK-LABEL: ldff1w_2f32:
+; CHECK: ldff1w { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv2f32( %pg, float* %a)
+  ret  %load
+}
+
+;
+; LDFF1SW
+;

[PATCH] D73026: clang-format: [JS] fix `??` opreator wrapping.

2020-01-20 Thread Martin Probst via Phabricator via cfe-commits
mprobst created this revision.
mprobst added a reviewer: krasimir.
Herald added a project: clang.

clang-format currently treats the nullish coalescing operator `??` like
the ternary operator. That causes multiple nullish terms to be each
indented relative to the last `??`, as they would in a ternary.

The `??` operator is often used in chains though, and as such more
similar to other binary operators, such as `||`. So to fix the indent,
set its token type to `||`, so it inherits the same treatment.

This opens up the question of operator precedence. However, `??` is
required to be parenthesized when mixed with `||` and `&&`, so this is
not a problem that can come up in syntactically legal code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73026

Files:
  clang/lib/Format/FormatTokenLexer.cpp
  clang/unittests/Format/FormatTestJS.cpp


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -2294,6 +2294,11 @@
 
 TEST_F(FormatTestJS, NullishCoalescingOperator) {
   verifyFormat("const val = something ?? 'some other default';\n");
+  verifyFormat(
+  "const val = something ?? otherDefault ??\n"
+  "evenMore ?? evenMore;\n",
+  "const val = something ?? otherDefault ?? evenMore ?? evenMore;\n",
+  getGoogleJSStyleWithColumns(40));
 }
 
 TEST_F(FormatTestJS, Conditional) {
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -120,8 +120,11 @@
   Tokens.back()->Tok.setKind(tok::starequal);
   return;
 }
-if (tryMergeTokens(JSNullishOperator, TT_JsNullishCoalescingOperator))
+if (tryMergeTokens(JSNullishOperator, TT_JsNullishCoalescingOperator)) {
+  // Treat like the "||" operator (as opposed to the ternary ?).
+  Tokens.back()->Tok.setKind(tok::pipepipe);
   return;
+}
 if (tryMergeTokens(JSNullPropagatingOperator,
TT_JsNullPropagatingOperator)) {
   // Treat like a regular "." access.


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -2294,6 +2294,11 @@
 
 TEST_F(FormatTestJS, NullishCoalescingOperator) {
   verifyFormat("const val = something ?? 'some other default';\n");
+  verifyFormat(
+  "const val = something ?? otherDefault ??\n"
+  "evenMore ?? evenMore;\n",
+  "const val = something ?? otherDefault ?? evenMore ?? evenMore;\n",
+  getGoogleJSStyleWithColumns(40));
 }
 
 TEST_F(FormatTestJS, Conditional) {
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -120,8 +120,11 @@
   Tokens.back()->Tok.setKind(tok::starequal);
   return;
 }
-if (tryMergeTokens(JSNullishOperator, TT_JsNullishCoalescingOperator))
+if (tryMergeTokens(JSNullishOperator, TT_JsNullishCoalescingOperator)) {
+  // Treat like the "||" operator (as opposed to the ternary ?).
+  Tokens.back()->Tok.setKind(tok::pipepipe);
   return;
+}
 if (tryMergeTokens(JSNullPropagatingOperator,
TT_JsNullPropagatingOperator)) {
   // Treat like a regular "." access.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72897: List implicit operator== after implicit destructors in a vtable.

2020-01-20 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

@rsmith This is failing on 
http://lab.llvm.org:8011/builders/llvm-clang-win-x-armv7l/builds/3169 - please 
can you take a look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72897



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


[PATCH] D72715: [clang][CodeComplete] Propogate printing policy to FunctionDecl

2020-01-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1f946ee2faba: [clang][CodeComplete] Propogate printing 
policy to FunctionDecl (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72715

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/ctor-signature.cpp


Index: clang/test/CodeCompletion/ctor-signature.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/ctor-signature.cpp
@@ -0,0 +1,17 @@
+template 
+struct Foo {};
+template 
+struct Foo { Foo(T); };
+
+void foo() {
+  Foo();
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:7:12 %s -o - | 
FileCheck -check-prefix=CHECK-CC1 %s
+  // CHECK-CC1: OVERLOAD: Foo()
+  // CHECK-CC1: OVERLOAD: Foo(<#const Foo &#>)
+  // CHECK-CC1: OVERLOAD: Foo(<#Foo &&#>
+  Foo(3);
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:12:14 %s -o - | 
FileCheck -check-prefix=CHECK-CC2 %s
+  // CHECK-CC2: OVERLOAD: Foo(<#int#>)
+  // CHECK-CC2: OVERLOAD: Foo(<#const Foo &#>)
+  // CHECK-CC2: OVERLOAD: Foo(<#Foo &&#>
+}
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -37,6 +37,7 @@
 #include "llvm/ADT/Twine.h"
 #include "llvm/ADT/iterator_range.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 #include 
@@ -3705,8 +3706,11 @@
 Result.addBriefComment(RC->getBriefText(S.getASTContext()));
 }
 AddResultTypeChunk(S.Context, Policy, FDecl, QualType(), Result);
-Result.AddTextChunk(
-Result.getAllocator().CopyString(FDecl->getNameAsString()));
+
+std::string Name;
+llvm::raw_string_ostream OS(Name);
+FDecl->getDeclName().print(OS, Policy);
+Result.AddTextChunk(Result.getAllocator().CopyString(OS.str()));
   } else {
 Result.AddResultTypeChunk(Result.getAllocator().CopyString(
 Proto->getReturnType().getAsString(Policy)));
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -2297,6 +2297,15 @@
AllOf(Named("TestClangc"), Deprecated(;
 }
 
+TEST(SignatureHelpTest, PartialSpec) {
+  const auto Results = signatures(R"cpp(
+  template  struct Foo {};
+  template  struct Foo { Foo(T); };
+  Foo F(^);)cpp");
+  EXPECT_THAT(Results.signatures, Contains(Sig("Foo([[T]])")));
+  EXPECT_EQ(0, Results.activeParameter);
+}
+
 TEST(SignatureHelpTest, InsideArgument) {
   {
 const auto Results = signatures(R"cpp(


Index: clang/test/CodeCompletion/ctor-signature.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/ctor-signature.cpp
@@ -0,0 +1,17 @@
+template 
+struct Foo {};
+template 
+struct Foo { Foo(T); };
+
+void foo() {
+  Foo();
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:7:12 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // CHECK-CC1: OVERLOAD: Foo()
+  // CHECK-CC1: OVERLOAD: Foo(<#const Foo &#>)
+  // CHECK-CC1: OVERLOAD: Foo(<#Foo &&#>
+  Foo(3);
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:12:14 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+  // CHECK-CC2: OVERLOAD: Foo(<#int#>)
+  // CHECK-CC2: OVERLOAD: Foo(<#const Foo &#>)
+  // CHECK-CC2: OVERLOAD: Foo(<#Foo &&#>
+}
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -37,6 +37,7 @@
 #include "llvm/ADT/Twine.h"
 #include "llvm/ADT/iterator_range.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 #include 
@@ -3705,8 +3706,11 @@
 Result.addBriefComment(RC->getBriefText(S.getASTContext()));
 }
 AddResultTypeChunk(S.Context, Policy, FDecl, QualType(), Result);
-Result.AddTextChunk(
-Result.getAllocator().CopyString(FDecl->getNameAsString()));
+
+std::string Name;
+llvm::raw_string_ostream OS(Name);
+FDecl->getDeclName().print(OS, Policy);
+Result.AddTextChunk(Result.getAllocator().CopyString(OS.str()));
   } else {
 Result.AddResultTypeChunk(Result.getAllocator().CopyString(
 Proto->getReturnType().getAsString(Policy)));
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -2297,6 +2297,15 @@
 

[clang] 8248190 - Fix clang-formatting for recent commits

2020-01-20 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2020-01-20T11:38:23Z
New Revision: 8248190a730cd62850afe9bef731ce6726778b4b

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

LOG: Fix clang-formatting for recent commits

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 39a3d8e3750c..f62c7ab5ed04 100644
--- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -64,7 +64,7 @@ struct MatchKey {
   bool operator<(const MatchKey &Other) const {
 return std::tie(Traversal, MatcherID, Node, BoundNodes) <
std::tie(Other.Traversal, Other.MatcherID, Other.Node,
-Other.BoundNodes);
+Other.BoundNodes);
   }
 };
 

diff  --git a/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
index 27f446467fa3..2143bb4965bb 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1635,12 +1635,11 @@ void foo()
 
   auto ParentMatcher = floatLiteral(hasParent(varDecl(hasName("i";
 
-  EXPECT_TRUE(
-  notMatches(VarDeclCode, traverse(ast_type_traits::TK_AsIs, 
ParentMatcher)));
-  EXPECT_TRUE(
-  matches(VarDeclCode,
-  traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
-   ParentMatcher)));
+  EXPECT_TRUE(notMatches(VarDeclCode,
+ traverse(ast_type_traits::TK_AsIs, ParentMatcher)));
+  EXPECT_TRUE(matches(VarDeclCode,
+  traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+   ParentMatcher)));
 
   EXPECT_TRUE(
   matches(VarDeclCode, decl(traverse(ast_type_traits::TK_AsIs,
@@ -1723,12 +1722,13 @@ void bar()
   functionDecl(hasName("foo"), traverse(ast_type_traits::TK_AsIs,
 hasDescendant(floatLiteral());
 
+  EXPECT_TRUE(notMatches(Code, traverse(ast_type_traits::TK_AsIs,
+floatLiteral(hasParent(callExpr(callee(
+
functionDecl(hasName("foo");
   EXPECT_TRUE(
-  notMatches(Code, traverse(ast_type_traits::TK_AsIs, 
floatLiteral(hasParent(callExpr(callee(functionDecl(hasName("foo");
-  EXPECT_TRUE(
-  matches(Code,
-  traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
-   
floatLiteral(hasParent(callExpr(callee(functionDecl(hasName("foo");
+  matches(Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+ floatLiteral(hasParent(callExpr(
+ callee(functionDecl(hasName("foo");
 
   Code = R"cpp(
 void foo()
@@ -1740,10 +1740,10 @@ void foo()
   matches(Code,
   traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
varDecl(hasInitializer(integerLiteral(equals(3)));
-  EXPECT_TRUE(
-  matches(Code,
-  traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
-   integerLiteral(equals(3), 
hasParent(varDecl(hasName("i")));
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+   integerLiteral(equals(3), hasParent(varDecl(hasName("i")));
 }
 
 template 
@@ -1927,8 +1927,9 @@ void func14() {
 
   EXPECT_TRUE(matches(
   Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
-integerLiteral(equals(42), 
hasParent(returnStmt(forFunction(functionDecl(hasName("func1"))
- )));
+ integerLiteral(equals(42),
+hasParent(returnStmt(forFunction(
+functionDecl(hasName("func1");
 
   EXPECT_TRUE(matches(
   Code,
@@ -1939,7 +1940,10 @@ void func14() {
   EXPECT_TRUE(matches(
   Code,
   traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
-integerLiteral(equals(42), 
hasParent(cxxTemporaryObjectExpr(hasParent(returnStmt(forFunction(functionDecl(hasName("func2")));
+   integerLiteral(
+   equals(42),
+   hasParent(cxxTemporaryObjectExpr(hasParent(returnStmt(
+   forFunction(functionDecl(hasName("func2")));
 
   EXPECT_TRUE(matches(
   Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
@@ -1949,8 +1953,12 @@ void func14() {
 integerLiteral(equals(42);

[PATCH] D72638: [clangd] Fix rename for explicit destructor calls

2020-01-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

looks good, thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72638



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


[PATCH] D72638: [clangd] Fix rename for explicit destructor calls

2020-01-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/unittests/FindTargetTests.cpp:887
+   public:
+ $1^operator int();
+   };

could you rather have a conversion operator to a tag (like `struct Bar`), with 
a fixme of course mentionining the issue you have in clangd bug tracker(not a 
link but rather a short description)



Comment at: clang-tools-extra/clangd/unittests/FindTargetTests.cpp:905
+   public:
+ ~$1^Foo() {}
+

this actually looks troublesome, since we are not returning the functiondecl 
anymore(also for references to it as well), even though it is explicitly 
spelled in the source code.
I suppose it is OK to keep that behavior for now, as there are no callers 
caring about those typednames yet.

just thinking out loud:
In case we start to have such clients, it might be more principled to report 
`$1~$2Foo` in here(I know it is the old behavior :/ )  and handle those 
differently in the callers' with
custom needs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72638



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


[clang] 9a3ff47 - Fix the invisible-traversal to ignore more nodes

2020-01-20 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2020-01-20T11:59:13Z
New Revision: 9a3ff478235ccbda23df01a99c5a86eedba54cac

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

LOG: Fix the invisible-traversal to ignore more nodes

Added: 


Modified: 
clang/lib/AST/Expr.cpp
clang/unittests/AST/ASTTraverserTest.cpp

Removed: 




diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 835198958766..20505b21b15c 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -2900,6 +2900,12 @@ static Expr *IgnoreImplicitAsWrittenSingleStep(Expr *E) {
   return IgnoreImplicitSingleStep(E);
 }
 
+static Expr *IgnoreParensOnlySingleStep(Expr *E) {
+  if (auto *PE = dyn_cast(E))
+return PE->getSubExpr();
+  return E;
+}
+
 static Expr *IgnoreParensSingleStep(Expr *E) {
   if (auto *PE = dyn_cast(E))
 return PE->getSubExpr();
@@ -3026,7 +3032,8 @@ Expr *Expr::IgnoreUnlessSpelledInSource() {
   Expr *LastE = nullptr;
   while (E != LastE) {
 LastE = E;
-E = E->IgnoreParenImpCasts();
+E = IgnoreExprNodes(E, IgnoreImplicitSingleStep, IgnoreImpCastsSingleStep,
+IgnoreParensOnlySingleStep);
 
 auto SR = E->getSourceRange();
 

diff  --git a/clang/unittests/AST/ASTTraverserTest.cpp 
b/clang/unittests/AST/ASTTraverserTest.cpp
index 88921a002053..a8f254fb70cd 100644
--- a/clang/unittests/AST/ASTTraverserTest.cpp
+++ b/clang/unittests/AST/ASTTraverserTest.cpp
@@ -260,7 +260,90 @@ TemplateArgument
 19u);
 }
 
-TEST(Traverse, IgnoreUnlessSpelledInSource) {
+TEST(Traverse, IgnoreUnlessSpelledInSourceStructs) {
+  auto AST = buildASTFromCode(R"cpp(
+
+struct MyStruct {
+  MyStruct();
+  MyStruct(int i) {
+MyStruct();
+  }
+  ~MyStruct();
+};
+
+)cpp");
+
+  auto BN = ast_matchers::match(
+  cxxConstructorDecl(hasName("MyStruct"),
+ hasParameter(0, parmVarDecl(hasType(isInteger()
+  .bind("ctor"),
+  AST->getASTContext());
+  EXPECT_EQ(BN.size(), 1u);
+
+  EXPECT_EQ(dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+  BN[0].getNodeAs("ctor")),
+R"cpp(
+CXXConstructorDecl 'MyStruct'
+|-ParmVarDecl 'i'
+`-CompoundStmt
+  `-CXXTemporaryObjectExpr
+)cpp");
+
+  EXPECT_EQ(
+  dumpASTString(ast_type_traits::TK_AsIs, BN[0].getNodeAs("ctor")),
+  R"cpp(
+CXXConstructorDecl 'MyStruct'
+|-ParmVarDecl 'i'
+`-CompoundStmt
+  `-ExprWithCleanups
+`-CXXBindTemporaryExpr
+  `-CXXTemporaryObjectExpr
+)cpp");
+}
+
+TEST(Traverse, IgnoreUnlessSpelledInSourceReturnStruct) {
+
+  auto AST = buildASTFromCode(R"cpp(
+struct Retval {
+  Retval() {}
+  ~Retval() {}
+};
+
+Retval someFun();
+
+void foo()
+{
+someFun();
+}
+)cpp");
+
+  auto BN = ast_matchers::match(functionDecl(hasName("foo")).bind("fn"),
+AST->getASTContext());
+  EXPECT_EQ(BN.size(), 1u);
+
+  EXPECT_EQ(dumpASTString(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+  BN[0].getNodeAs("fn")),
+R"cpp(
+FunctionDecl 'foo'
+`-CompoundStmt
+  `-CallExpr
+`-DeclRefExpr 'someFun'
+)cpp");
+
+  EXPECT_EQ(
+  dumpASTString(ast_type_traits::TK_AsIs, BN[0].getNodeAs("fn")),
+  R"cpp(
+FunctionDecl 'foo'
+`-CompoundStmt
+  `-ExprWithCleanups
+`-CXXBindTemporaryExpr
+  `-CallExpr
+`-ImplicitCastExpr
+  `-DeclRefExpr 'someFun'
+)cpp");
+}
+
+TEST(Traverse, IgnoreUnlessSpelledInSourceReturns) {
 
   auto AST = buildASTFromCode(R"cpp(
 



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


[PATCH] D72715: [clang][CodeComplete] Propogate printing policy to FunctionDecl

2020-01-20 Thread Christian Kühnel via Phabricator via cfe-commits
kuhnel added a comment.

thx for the feedback, I created an issue for this: 
https://github.com/google/llvm-premerge-checks/issues/98


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72715



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


[PATCH] D73028: Extract ExprTraversal class from Expr

2020-01-20 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.

The current implementations are concerned with descending through the
AST.  An addition to the API will be concerned with ascending through
the AST in different traversal modes.  Keep both in the same class to
ensure that they are kept in sync.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73028

Files:
  clang/include/clang/AST/ExprTraversal.h
  clang/lib/AST/CMakeLists.txt
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprTraversal.cpp

Index: clang/lib/AST/ExprTraversal.cpp
===
--- /dev/null
+++ clang/lib/AST/ExprTraversal.cpp
@@ -0,0 +1,255 @@
+//===--- ExprTraversal.cpp - Expression AST Node Implementation ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements Expr traversal.
+//
+//===--===//
+
+#include "clang/AST/ExprTraversal.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
+
+
+using namespace clang;
+
+static Expr *IgnoreImpCastsSingleStep(Expr *E) {
+  if (auto *ICE = dyn_cast(E))
+return ICE->getSubExpr();
+
+  if (auto *FE = dyn_cast(E))
+return FE->getSubExpr();
+
+  return E;
+}
+
+static Expr *IgnoreImpCastsExtraSingleStep(Expr *E) {
+  // FIXME: Skip MaterializeTemporaryExpr and SubstNonTypeTemplateParmExpr in
+  // addition to what IgnoreImpCasts() skips to account for the current
+  // behaviour of IgnoreParenImpCasts().
+  Expr *SubE = IgnoreImpCastsSingleStep(E);
+  if (SubE != E)
+return SubE;
+
+  if (auto *MTE = dyn_cast(E))
+return MTE->getSubExpr();
+
+  if (auto *NTTP = dyn_cast(E))
+return NTTP->getReplacement();
+
+  return E;
+}
+
+static Expr *IgnoreCastsSingleStep(Expr *E) {
+  if (auto *CE = dyn_cast(E))
+return CE->getSubExpr();
+
+  if (auto *FE = dyn_cast(E))
+return FE->getSubExpr();
+
+  if (auto *MTE = dyn_cast(E))
+return MTE->getSubExpr();
+
+  if (auto *NTTP = dyn_cast(E))
+return NTTP->getReplacement();
+
+  return E;
+}
+
+static Expr *IgnoreLValueCastsSingleStep(Expr *E) {
+  // Skip what IgnoreCastsSingleStep skips, except that only
+  // lvalue-to-rvalue casts are skipped.
+  if (auto *CE = dyn_cast(E))
+if (CE->getCastKind() != CK_LValueToRValue)
+  return E;
+
+  return IgnoreCastsSingleStep(E);
+}
+
+static Expr *IgnoreBaseCastsSingleStep(Expr *E) {
+  if (auto *CE = dyn_cast(E))
+if (CE->getCastKind() == CK_DerivedToBase ||
+CE->getCastKind() == CK_UncheckedDerivedToBase ||
+CE->getCastKind() == CK_NoOp)
+  return CE->getSubExpr();
+
+  return E;
+}
+
+static Expr *IgnoreImplicitSingleStep(Expr *E) {
+  Expr *SubE = IgnoreImpCastsSingleStep(E);
+  if (SubE != E)
+return SubE;
+
+  if (auto *MTE = dyn_cast(E))
+return MTE->getSubExpr();
+
+  if (auto *BTE = dyn_cast(E))
+return BTE->getSubExpr();
+
+  return E;
+}
+
+static Expr *IgnoreImplicitAsWrittenSingleStep(Expr *E) {
+  if (auto *ICE = dyn_cast(E))
+return ICE->getSubExprAsWritten();
+
+  return IgnoreImplicitSingleStep(E);
+}
+
+static Expr *IgnoreParensOnlySingleStep(Expr *E) {
+  if (auto *PE = dyn_cast(E))
+return PE->getSubExpr();
+  return E;
+}
+
+static Expr *IgnoreParensSingleStep(Expr *E) {
+  if (auto *PE = dyn_cast(E))
+return PE->getSubExpr();
+
+  if (auto *UO = dyn_cast(E)) {
+if (UO->getOpcode() == UO_Extension)
+  return UO->getSubExpr();
+  }
+
+  else if (auto *GSE = dyn_cast(E)) {
+if (!GSE->isResultDependent())
+  return GSE->getResultExpr();
+  }
+
+  else if (auto *CE = dyn_cast(E)) {
+if (!CE->isConditionDependent())
+  return CE->getChosenSubExpr();
+  }
+
+  else if (auto *CE = dyn_cast(E))
+return CE->getSubExpr();
+
+  return E;
+}
+
+static Expr *IgnoreNoopCastsSingleStep(const ASTContext &Ctx, Expr *E) {
+  if (auto *CE = dyn_cast(E)) {
+// We ignore integer <-> casts that are of the same width, ptr<->ptr and
+// ptr<->int casts of the same width. We also ignore all identity casts.
+Expr *SubExpr = CE->getSubExpr();
+bool IsIdentityCast =
+Ctx.hasSameUnqualifiedType(E->getType(), SubExpr->getType());
+bool IsSameWidthCast =
+(E->getType()->isPointerType() || E->getType()->isIntegralType(Ctx)) &&
+(SubExpr->getType()->isPointerType() ||
+ SubExpr->getType()->isIntegralType(Ctx)) &&
+(Ctx.getTypeSize(E->getType()) == Ctx.getTypeSize(SubExpr->getType()));
+
+if (IsIdentityCast || IsSameWidthCast)
+  return SubExpr;
+  }
+
+  else if (auto *NTTP = dyn_cast(E))
+return NTTP->getReplacement();
+
+ 

[PATCH] D73029: Extend ExprTraversal class with acending traversal

2020-01-20 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This allows ASTContext to store only one parent map, rather than storing
an entire parent map for each traversal mode used.

This is therefore a partial revert of commit 0a717d5b 
 (Make it 
possible
control matcher traversal kind with ASTContext, 2019-12-06).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73029

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/ExprTraversal.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ExprTraversal.cpp

Index: clang/lib/AST/ExprTraversal.cpp
===
--- clang/lib/AST/ExprTraversal.cpp
+++ clang/lib/AST/ExprTraversal.cpp
@@ -253,3 +253,41 @@
 
   return E;
 }
+
+bool ExprTraversal::AscendSkipUnlessSpelledInSource(const Expr *E, const Expr* Child) {
+  if (isa(E))
+return true;
+
+  if (isa(E))
+return true;
+
+  if (isa(E))
+return true;
+
+  if (isa(E))
+return true;
+
+  if (isa(E))
+return true;
+
+  if (isa(E))
+return true;
+
+  auto SR = Child->getSourceRange();
+
+  if (auto *C = dyn_cast(E)) {
+if (C->getSourceRange() == SR || !isa(C))
+  return true;
+  }
+
+  if (auto *C = dyn_cast(E)) {
+if (C->getSourceRange() == SR)
+  return true;
+  }
+
+  if (auto *C = dyn_cast(E)) {
+if (C->getSourceRange() == SR)
+  return true;
+  }
+  return false;
+}
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -31,6 +31,7 @@
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/ExprTraversal.h"
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/Mangle.h"
 #include "clang/AST/MangleNumberingContext.h"
@@ -1059,16 +1060,42 @@
 }
   }
 
-  DynTypedNodeList getParents(const ast_type_traits::DynTypedNode &Node) {
-if (Node.getNodeKind().hasPointerIdentity())
-  return getDynNodeFromMap(Node.getMemoizationData(), PointerParents);
+  DynTypedNodeList getParents(ast_type_traits::TraversalKind TK, const ast_type_traits::DynTypedNode &Node) {
+if (Node.getNodeKind().hasPointerIdentity()) {
+  auto ParentList = getDynNodeFromMap(Node.getMemoizationData(), PointerParents);
+  if (ParentList.size() == 1 && TK == ast_type_traits::TK_IgnoreUnlessSpelledInSource) {
+const Expr* E = ParentList[0].get();
+const Expr* Child = Node.get();
+if (E && Child)
+  return AscendIgnoreUnlessSpelledInSource(E, Child);
+  }
+  return ParentList;
+}
 return getDynNodeFromMap(Node, OtherParents);
   }
+
+  ast_type_traits::DynTypedNode AscendIgnoreUnlessSpelledInSource(const Expr* E, const Expr* Child)
+  {
+while (ExprTraversal::AscendSkipUnlessSpelledInSource(E, Child)) {
+  auto It = PointerParents.find(E);
+  if (It == PointerParents.end())
+break;
+  auto *S = It->second.dyn_cast();
+  if (!S)
+return getSingleDynTypedNodeFromParentMap(It->second);
+  auto *P = dyn_cast(S);
+  if (!P)
+return ast_type_traits::DynTypedNode::create(*S);
+  Child = E;
+  E = P;
+}
+return ast_type_traits::DynTypedNode::create(*E);
+  }
 };
 
 void ASTContext::setTraversalScope(const std::vector &TopLevelDecls) {
   TraversalScope = TopLevelDecls;
-  Parents.clear();
+  Parents.reset();
 }
 
 void ASTContext::AddDeallocation(void (*Callback)(void *), void *Data) const {
@@ -10536,8 +10563,8 @@
 class ASTContext::ParentMap::ASTVisitor
 : public RecursiveASTVisitor {
 public:
-  ASTVisitor(ParentMap &Map, ASTContext &Context)
-  : Map(Map), Context(Context) {}
+  ASTVisitor(ParentMap &Map)
+  : Map(Map) {}
 
 private:
   friend class RecursiveASTVisitor;
@@ -10607,11 +10634,8 @@
   }
 
   bool TraverseStmt(Stmt *StmtNode) {
-Stmt *FilteredNode = StmtNode;
-if (auto *ExprNode = dyn_cast_or_null(FilteredNode))
-  FilteredNode = Context.traverseIgnored(ExprNode);
-return TraverseNode(FilteredNode, FilteredNode,
-[&] { return VisitorBase::TraverseStmt(FilteredNode); },
+return TraverseNode(StmtNode, StmtNode,
+[&] { return VisitorBase::TraverseStmt(StmtNode); },
 &Map.PointerParents);
   }
 
@@ -10630,22 +10654,20 @@
   }
 
   ParentMap ⤅
-  ASTContext &Context;
   llvm::SmallVector ParentStack;
 };
 
 ASTContext::ParentMap::ParentMap(ASTContext &Ctx) {
-  ASTVisitor(*this, Ctx).TraverseAST(Ctx);
+  ASTVisitor(*this).TraverseAST(Ctx);
 }
 
 ASTContext::DynTypedNodeList
 ASTContext::getParents(const ast_type_traits::DynTypedNode &Node) {
-  std::unique_ptr &P = Parents[Traversal];
-  if (!P)
+  if (!Parents)
 // We build the par

[PATCH] D73029: Extend ExprTraversal class with acending traversal

2020-01-20 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 239075.
steveire added a comment.

Format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73029

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/ExprTraversal.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ExprTraversal.cpp

Index: clang/lib/AST/ExprTraversal.cpp
===
--- clang/lib/AST/ExprTraversal.cpp
+++ clang/lib/AST/ExprTraversal.cpp
@@ -252,3 +252,42 @@
 
   return E;
 }
+
+bool ExprTraversal::AscendSkipUnlessSpelledInSource(const Expr *E,
+const Expr *Child) {
+  if (isa(E))
+return true;
+
+  if (isa(E))
+return true;
+
+  if (isa(E))
+return true;
+
+  if (isa(E))
+return true;
+
+  if (isa(E))
+return true;
+
+  if (isa(E))
+return true;
+
+  auto SR = Child->getSourceRange();
+
+  if (auto *C = dyn_cast(E)) {
+if (C->getSourceRange() == SR || !isa(C))
+  return true;
+  }
+
+  if (auto *C = dyn_cast(E)) {
+if (C->getSourceRange() == SR)
+  return true;
+  }
+
+  if (auto *C = dyn_cast(E)) {
+if (C->getSourceRange() == SR)
+  return true;
+  }
+  return false;
+}
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -31,6 +31,7 @@
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/ExprTraversal.h"
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/Mangle.h"
 #include "clang/AST/MangleNumberingContext.h"
@@ -1059,16 +1060,45 @@
 }
   }
 
-  DynTypedNodeList getParents(const ast_type_traits::DynTypedNode &Node) {
-if (Node.getNodeKind().hasPointerIdentity())
-  return getDynNodeFromMap(Node.getMemoizationData(), PointerParents);
+  DynTypedNodeList getParents(ast_type_traits::TraversalKind TK,
+  const ast_type_traits::DynTypedNode &Node) {
+if (Node.getNodeKind().hasPointerIdentity()) {
+  auto ParentList =
+  getDynNodeFromMap(Node.getMemoizationData(), PointerParents);
+  if (ParentList.size() == 1 &&
+  TK == ast_type_traits::TK_IgnoreUnlessSpelledInSource) {
+const Expr *E = ParentList[0].get();
+const Expr *Child = Node.get();
+if (E && Child)
+  return AscendIgnoreUnlessSpelledInSource(E, Child);
+  }
+  return ParentList;
+}
 return getDynNodeFromMap(Node, OtherParents);
   }
+
+  ast_type_traits::DynTypedNode
+  AscendIgnoreUnlessSpelledInSource(const Expr *E, const Expr *Child) {
+while (ExprTraversal::AscendSkipUnlessSpelledInSource(E, Child)) {
+  auto It = PointerParents.find(E);
+  if (It == PointerParents.end())
+break;
+  auto *S = It->second.dyn_cast();
+  if (!S)
+return getSingleDynTypedNodeFromParentMap(It->second);
+  auto *P = dyn_cast(S);
+  if (!P)
+return ast_type_traits::DynTypedNode::create(*S);
+  Child = E;
+  E = P;
+}
+return ast_type_traits::DynTypedNode::create(*E);
+  }
 };
 
 void ASTContext::setTraversalScope(const std::vector &TopLevelDecls) {
   TraversalScope = TopLevelDecls;
-  Parents.clear();
+  Parents.reset();
 }
 
 void ASTContext::AddDeallocation(void (*Callback)(void *), void *Data) const {
@@ -10536,8 +10566,7 @@
 class ASTContext::ParentMap::ASTVisitor
 : public RecursiveASTVisitor {
 public:
-  ASTVisitor(ParentMap &Map, ASTContext &Context)
-  : Map(Map), Context(Context) {}
+  ASTVisitor(ParentMap &Map) : Map(Map) {}
 
 private:
   friend class RecursiveASTVisitor;
@@ -10607,11 +10636,8 @@
   }
 
   bool TraverseStmt(Stmt *StmtNode) {
-Stmt *FilteredNode = StmtNode;
-if (auto *ExprNode = dyn_cast_or_null(FilteredNode))
-  FilteredNode = Context.traverseIgnored(ExprNode);
-return TraverseNode(FilteredNode, FilteredNode,
-[&] { return VisitorBase::TraverseStmt(FilteredNode); },
+return TraverseNode(StmtNode, StmtNode,
+[&] { return VisitorBase::TraverseStmt(StmtNode); },
 &Map.PointerParents);
   }
 
@@ -10630,22 +10656,20 @@
   }
 
   ParentMap ⤅
-  ASTContext &Context;
   llvm::SmallVector ParentStack;
 };
 
 ASTContext::ParentMap::ParentMap(ASTContext &Ctx) {
-  ASTVisitor(*this, Ctx).TraverseAST(Ctx);
+  ASTVisitor(*this).TraverseAST(Ctx);
 }
 
 ASTContext::DynTypedNodeList
 ASTContext::getParents(const ast_type_traits::DynTypedNode &Node) {
-  std::unique_ptr &P = Parents[Traversal];
-  if (!P)
+  if (!Parents)
 // We build the parent map for the traversal scope (usually whole TU), as
 // hasAncestor can escape any subtree.
-P = std::make_unique(*this);
-  return P->getParents(Node);
+Parents = std::make_unique(*this);
+  return Parents->getPare

[PATCH] D73028: Extract ExprTraversal class from Expr

2020-01-20 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 239072.
steveire added a comment.

Format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73028

Files:
  clang/include/clang/AST/ExprTraversal.h
  clang/lib/AST/CMakeLists.txt
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprTraversal.cpp

Index: clang/lib/AST/ExprTraversal.cpp
===
--- /dev/null
+++ clang/lib/AST/ExprTraversal.cpp
@@ -0,0 +1,254 @@
+//===--- ExprTraversal.cpp - Expression AST Node Implementation ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements Expr traversal.
+//
+//===--===//
+
+#include "clang/AST/ExprTraversal.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
+
+using namespace clang;
+
+static Expr *IgnoreImpCastsSingleStep(Expr *E) {
+  if (auto *ICE = dyn_cast(E))
+return ICE->getSubExpr();
+
+  if (auto *FE = dyn_cast(E))
+return FE->getSubExpr();
+
+  return E;
+}
+
+static Expr *IgnoreImpCastsExtraSingleStep(Expr *E) {
+  // FIXME: Skip MaterializeTemporaryExpr and SubstNonTypeTemplateParmExpr in
+  // addition to what IgnoreImpCasts() skips to account for the current
+  // behaviour of IgnoreParenImpCasts().
+  Expr *SubE = IgnoreImpCastsSingleStep(E);
+  if (SubE != E)
+return SubE;
+
+  if (auto *MTE = dyn_cast(E))
+return MTE->getSubExpr();
+
+  if (auto *NTTP = dyn_cast(E))
+return NTTP->getReplacement();
+
+  return E;
+}
+
+static Expr *IgnoreCastsSingleStep(Expr *E) {
+  if (auto *CE = dyn_cast(E))
+return CE->getSubExpr();
+
+  if (auto *FE = dyn_cast(E))
+return FE->getSubExpr();
+
+  if (auto *MTE = dyn_cast(E))
+return MTE->getSubExpr();
+
+  if (auto *NTTP = dyn_cast(E))
+return NTTP->getReplacement();
+
+  return E;
+}
+
+static Expr *IgnoreLValueCastsSingleStep(Expr *E) {
+  // Skip what IgnoreCastsSingleStep skips, except that only
+  // lvalue-to-rvalue casts are skipped.
+  if (auto *CE = dyn_cast(E))
+if (CE->getCastKind() != CK_LValueToRValue)
+  return E;
+
+  return IgnoreCastsSingleStep(E);
+}
+
+static Expr *IgnoreBaseCastsSingleStep(Expr *E) {
+  if (auto *CE = dyn_cast(E))
+if (CE->getCastKind() == CK_DerivedToBase ||
+CE->getCastKind() == CK_UncheckedDerivedToBase ||
+CE->getCastKind() == CK_NoOp)
+  return CE->getSubExpr();
+
+  return E;
+}
+
+static Expr *IgnoreImplicitSingleStep(Expr *E) {
+  Expr *SubE = IgnoreImpCastsSingleStep(E);
+  if (SubE != E)
+return SubE;
+
+  if (auto *MTE = dyn_cast(E))
+return MTE->getSubExpr();
+
+  if (auto *BTE = dyn_cast(E))
+return BTE->getSubExpr();
+
+  return E;
+}
+
+static Expr *IgnoreImplicitAsWrittenSingleStep(Expr *E) {
+  if (auto *ICE = dyn_cast(E))
+return ICE->getSubExprAsWritten();
+
+  return IgnoreImplicitSingleStep(E);
+}
+
+static Expr *IgnoreParensOnlySingleStep(Expr *E) {
+  if (auto *PE = dyn_cast(E))
+return PE->getSubExpr();
+  return E;
+}
+
+static Expr *IgnoreParensSingleStep(Expr *E) {
+  if (auto *PE = dyn_cast(E))
+return PE->getSubExpr();
+
+  if (auto *UO = dyn_cast(E)) {
+if (UO->getOpcode() == UO_Extension)
+  return UO->getSubExpr();
+  }
+
+  else if (auto *GSE = dyn_cast(E)) {
+if (!GSE->isResultDependent())
+  return GSE->getResultExpr();
+  }
+
+  else if (auto *CE = dyn_cast(E)) {
+if (!CE->isConditionDependent())
+  return CE->getChosenSubExpr();
+  }
+
+  else if (auto *CE = dyn_cast(E))
+return CE->getSubExpr();
+
+  return E;
+}
+
+static Expr *IgnoreNoopCastsSingleStep(const ASTContext &Ctx, Expr *E) {
+  if (auto *CE = dyn_cast(E)) {
+// We ignore integer <-> casts that are of the same width, ptr<->ptr and
+// ptr<->int casts of the same width. We also ignore all identity casts.
+Expr *SubExpr = CE->getSubExpr();
+bool IsIdentityCast =
+Ctx.hasSameUnqualifiedType(E->getType(), SubExpr->getType());
+bool IsSameWidthCast =
+(E->getType()->isPointerType() || E->getType()->isIntegralType(Ctx)) &&
+(SubExpr->getType()->isPointerType() ||
+ SubExpr->getType()->isIntegralType(Ctx)) &&
+(Ctx.getTypeSize(E->getType()) == Ctx.getTypeSize(SubExpr->getType()));
+
+if (IsIdentityCast || IsSameWidthCast)
+  return SubExpr;
+  }
+
+  else if (auto *NTTP = dyn_cast(E))
+return NTTP->getReplacement();
+
+  return E;
+}
+
+static Expr *IgnoreExprNodesImpl(Expr *E) { return E; }
+template 
+static Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
+  return IgnoreExprNodesImpl(Fn(E), std::forward(Fns)...);
+}
+
+/// Given an expression E and 

Re: [clang] 122443a - Compare traversal for memoization before bound nodes container

2020-01-20 Thread Aaron Ballman via cfe-commits
On Mon, Jan 20, 2020 at 6:20 AM Stephen Kelly via cfe-commits
 wrote:
>
>
> Author: Stephen Kelly
> Date: 2020-01-20T11:20:04Z
> New Revision: 122443a950521c5d99a0d0479daf57fbd1de2ac2
>
> URL: 
> https://github.com/llvm/llvm-project/commit/122443a950521c5d99a0d0479daf57fbd1de2ac2
> DIFF: 
> https://github.com/llvm/llvm-project/commit/122443a950521c5d99a0d0479daf57fbd1de2ac2.diff
>
> LOG: Compare traversal for memoization before bound nodes container

Is this change missing test cases, or was there existing coverage that
was broken which this change is fixing?

~Aaron

>
> Added:
>
>
> Modified:
> clang/lib/ASTMatchers/ASTMatchFinder.cpp
>
> Removed:
>
>
>
> 
> diff  --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp 
> b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
> index 0d1f713db8d3..39a3d8e3750c 100644
> --- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp
> +++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
> @@ -62,9 +62,9 @@ struct MatchKey {
>ast_type_traits::TraversalKind Traversal = ast_type_traits::TK_AsIs;
>
>bool operator<(const MatchKey &Other) const {
> -return std::tie(MatcherID, Node, BoundNodes, Traversal) <
> -   std::tie(Other.MatcherID, Other.Node, Other.BoundNodes,
> -Other.Traversal);
> +return std::tie(Traversal, MatcherID, Node, BoundNodes) <
> +   std::tie(Other.Traversal, Other.MatcherID, Other.Node,
> +Other.BoundNodes);
>}
>  };
>
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang] 122443a - Compare traversal for memoization before bound nodes container

2020-01-20 Thread Stephen Kelly via cfe-commits


On 20/01/2020 12:42, Aaron Ballman wrote:

On Mon, Jan 20, 2020 at 6:20 AM Stephen Kelly via cfe-commits
 wrote:


Author: Stephen Kelly
Date: 2020-01-20T11:20:04Z
New Revision: 122443a950521c5d99a0d0479daf57fbd1de2ac2

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

LOG: Compare traversal for memoization before bound nodes container

Is this change missing test cases, or was there existing coverage that
was broken which this change is fixing?



Sorry, I should have labelled it NFC.

There's no missing test cases or brokenness. This change is made on the 
basis that comparing the enum is cheaper than comparing the container of 
bound nodes.


Thanks,

Stephen.


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


Re: [clang] 122443a - Compare traversal for memoization before bound nodes container

2020-01-20 Thread Aaron Ballman via cfe-commits
On Mon, Jan 20, 2020 at 7:56 AM Stephen Kelly  wrote:
>
>
> On 20/01/2020 12:42, Aaron Ballman wrote:
> > On Mon, Jan 20, 2020 at 6:20 AM Stephen Kelly via cfe-commits
> >  wrote:
> >>
> >> Author: Stephen Kelly
> >> Date: 2020-01-20T11:20:04Z
> >> New Revision: 122443a950521c5d99a0d0479daf57fbd1de2ac2
> >>
> >> URL: 
> >> https://github.com/llvm/llvm-project/commit/122443a950521c5d99a0d0479daf57fbd1de2ac2
> >> DIFF: 
> >> https://github.com/llvm/llvm-project/commit/122443a950521c5d99a0d0479daf57fbd1de2ac2.diff
> >>
> >> LOG: Compare traversal for memoization before bound nodes container
> > Is this change missing test cases, or was there existing coverage that
> > was broken which this change is fixing?
>
>
> Sorry, I should have labelled it NFC.
>
> There's no missing test cases or brokenness. This change is made on the
> basis that comparing the enum is cheaper than comparing the container of
> bound nodes.

Ah, okay, that makes plenty of sense. Thank you for clarifying that it
was NFC (change LGTM)!

~Aaron

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


[PATCH] D71698: [AArch64][SVE] Add intrinsic for non-faulting loads

2020-01-20 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:12460
 
-  if ((SignExtSrcVT != GLD1SrcMemVT) || !Src.hasOneUse())
+  unsigned OpNum = NewOpc == AArch64ISD::LDNF1S ? 3 : 4;
+  EVT LD1SrcMemVT = cast(Src->getOperand(OpNum))->getVT();

Move the assignment of `MemVTOpNum` to the switch statement above instead of 
special-casing it here?



Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:12461
+  unsigned OpNum = NewOpc == AArch64ISD::LDNF1S ? 3 : 4;
+  EVT LD1SrcMemVT = cast(Src->getOperand(OpNum))->getVT();
+

nit: `s/LD1SrcMemVT/SrcMemVT/`



Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:12469
+
+  SmallVector Ops = {Src->getOperand(0), Src->getOperand(1),
+ Src->getOperand(2), Src->getOperand(3)};

Better make the default '5' if there is a large likelihood of there being 5 
default values.



Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:12469
+
+  SmallVector Ops = {Src->getOperand(0), Src->getOperand(1),
+ Src->getOperand(2), Src->getOperand(3)};

sdesmalen wrote:
> Better make the default '5' if there is a large likelihood of there being 5 
> default values.
Instead of special -casing LDNF1S below, you can write this as:

  SmallVector Ops;
  for(unsigned I=0; IgetNumOperands(); ++I)
Ops.push_back(Src->getOperand(I));


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

https://reviews.llvm.org/D71698



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


[PATCH] D73035: [clangd] Avoid redundant testcases in rename unittest, NFC.

2020-01-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73035

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -722,7 +722,7 @@
 void onDiagnosticsReady(PathRef File,
 std::vector Diagnostics) override {}
   } DiagConsumer;
-  // rename is runnning on the "^" point in FooH, and "[[]]" ranges are the
+  // rename is runnning on all "^" points in FooH, and "[[]]" ranges are the
   // expected rename occurrences.
   struct Case {
 llvm::StringRef FooH;
@@ -763,28 +763,10 @@
   )cpp",
   },
   {
-  // Constructor.
+  // rename on constructor and destructor.
   R"cpp(
 class [[Foo]] {
   [[^Foo]]();
-  ~[[Foo]]();
-};
-  )cpp",
-  R"cpp(
-#include "foo.h"
-[[Foo]]::[[Foo]]() {}
-[[Foo]]::~[[Foo]]() {}
-
-void func() {
-  [[Foo]] foo;
-}
-  )cpp",
-  },
-  {
-  // Destructor (selecting before the identifier).
-  R"cpp(
-class [[Foo]] {
-  [[Foo]]();
   ~[[Foo^]]();
 };
   )cpp",
@@ -891,12 +873,15 @@
 runAddDocument(Server, FooCCPath, FooCC.code());
 
 llvm::StringRef NewName = "NewName";
-auto FileEditsList =
-llvm::cantFail(runRename(Server, FooHPath, FooH.point(), NewName));
-EXPECT_THAT(applyEdits(std::move(FileEditsList)),
-UnorderedElementsAre(
-Pair(Eq(FooHPath), Eq(expectedResult(T.FooH, NewName))),
-Pair(Eq(FooCCPath), Eq(expectedResult(T.FooCC, 
NewName);
+for (const auto &RenamePos : FooH.points()) {
+  auto FileEditsList =
+  llvm::cantFail(runRename(Server, FooHPath, RenamePos, NewName));
+  EXPECT_THAT(
+  applyEdits(std::move(FileEditsList)),
+  UnorderedElementsAre(
+  Pair(Eq(FooHPath), Eq(expectedResult(T.FooH, NewName))),
+  Pair(Eq(FooCCPath), Eq(expectedResult(T.FooCC, NewName);
+}
   }
 }
 
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -215,7 +215,7 @@
   // getUSRsForDeclaration will find other related symbols, e.g. virtual and 
its
   // overriddens, primary template and all explicit specializations.
   // FIXME: Get rid of the remaining tooling APIs.
-  const auto RenameDecl =
+  const auto *RenameDecl =
   ND.getDescribedTemplate() ? ND.getDescribedTemplate() : &ND;
   std::vector RenameUSRs =
   tooling::getUSRsForDeclaration(RenameDecl, AST.getASTContext());


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -722,7 +722,7 @@
 void onDiagnosticsReady(PathRef File,
 std::vector Diagnostics) override {}
   } DiagConsumer;
-  // rename is runnning on the "^" point in FooH, and "[[]]" ranges are the
+  // rename is runnning on all "^" points in FooH, and "[[]]" ranges are the
   // expected rename occurrences.
   struct Case {
 llvm::StringRef FooH;
@@ -763,28 +763,10 @@
   )cpp",
   },
   {
-  // Constructor.
+  // rename on constructor and destructor.
   R"cpp(
 class [[Foo]] {
   [[^Foo]]();
-  ~[[Foo]]();
-};
-  )cpp",
-  R"cpp(
-#include "foo.h"
-[[Foo]]::[[Foo]]() {}
-[[Foo]]::~[[Foo]]() {}
-
-void func() {
-  [[Foo]] foo;
-}
-  )cpp",
-  },
-  {
-  // Destructor (selecting before the identifier).
-  R"cpp(
-class [[Foo]] {
-  [[Foo]]();
   ~[[Foo^]]();
 };
   )cpp",
@@ -891,12 +873,15 @@
 runAddDocument(Server, FooCCPath, FooCC.code());
 
 llvm::StringRef NewName = "NewName";
-auto FileEditsList =
-llvm::cantFail(runRename(Server, FooHPath, FooH.point(), NewName));
-EXPECT_THAT(applyEdits(std::move(FileEditsList)),
-UnorderedElementsAre(
-Pair(Eq(FooHPath), Eq(expectedResult(T.FooH, NewName))),
-Pair(Eq(FooCCPath), Eq(expectedResult(T.FooCC, NewName);
+for (const auto &RenamePos : FooH.points()) {
+  auto FileEditsList =
+  llvm::cantFail(runRena

[PATCH] D72934: [ARM,MVE] Support immediate vbicq,vorrq,vmvnq intrinsics.

2020-01-20 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a comment.

What is the reason that this can't be lowered in tablegen, in the same way as 
the VMOVimm's are?

For vbic vs vmovlb, the vmovlb does include a free register move, so may under 
some circumstances be slightly better. Like you say, it's mostly benign, but 
may be worth updating the MVE_VMOVL patterns.

Do you have any tests for what would be invalid bic values under MVE?




Comment at: llvm/lib/Target/ARM/ARMISelLowering.cpp:12181
   BVN->isConstantSplat(SplatBits, SplatUndef, SplatBitSize, HasAnyUndefs)) 
{
 if (SplatBitSize <= 64) {
   EVT VbicVT;

This is OK because we are passing OtherModImm to isVMOVModifiedImm, and MVE 
supports the same patterns as NEON?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72934



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


[PATCH] D73035: [clangd] Avoid redundant testcases in rename unittest, NFC.

2020-01-20 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

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

{icon question-circle color=gray} clang-tidy: unknown.

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

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



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73035



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


[PATCH] D73037: Add a way to set traversal mode in clang-query

2020-01-20 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73037

Files:
  clang-tools-extra/clang-query/Query.cpp
  clang-tools-extra/clang-query/Query.h
  clang-tools-extra/clang-query/QueryParser.cpp
  clang-tools-extra/clang-query/QueryParser.h
  clang-tools-extra/clang-query/QuerySession.h
  clang-tools-extra/unittests/clang-query/QueryParserTest.cpp

Index: clang-tools-extra/unittests/clang-query/QueryParserTest.cpp
===
--- clang-tools-extra/unittests/clang-query/QueryParserTest.cpp
+++ clang-tools-extra/unittests/clang-query/QueryParserTest.cpp
@@ -110,6 +110,11 @@
   ASSERT_TRUE(isa >(Q));
   EXPECT_EQ(&QuerySession::BindRoot, cast >(Q)->Var);
   EXPECT_EQ(true, cast >(Q)->Value);
+
+  Q = parse("set traversal AsIs");
+  ASSERT_TRUE(isa >(Q));
+  EXPECT_EQ(&QuerySession::TK, cast >(Q)->Var);
+  EXPECT_EQ(ast_type_traits::TK_AsIs, cast >(Q)->Value);
 }
 
 TEST_F(QueryParserTest, Match) {
@@ -197,6 +202,11 @@
   EXPECT_EQ("utput ", Comps[0].TypedText);
   EXPECT_EQ("output", Comps[0].DisplayText);
 
+  Comps = QueryParser::complete("set t", 5, QS);
+  ASSERT_EQ(1u, Comps.size());
+  EXPECT_EQ("raversal ", Comps[0].TypedText);
+  EXPECT_EQ("traversal", Comps[0].DisplayText);
+
   Comps = QueryParser::complete("enable ", 7, QS);
   ASSERT_EQ(1u, Comps.size());
   EXPECT_EQ("output ", Comps[0].TypedText);
@@ -214,6 +224,16 @@
   EXPECT_EQ("dump ", Comps[3].TypedText);
   EXPECT_EQ("dump", Comps[3].DisplayText);
 
+  Comps = QueryParser::complete("set traversal ", 14, QS);
+  ASSERT_EQ(3u, Comps.size());
+
+  EXPECT_EQ("AsIs ", Comps[0].TypedText);
+  EXPECT_EQ("AsIs", Comps[0].DisplayText);
+  EXPECT_EQ("IgnoreImplicitCastsAndParentheses ", Comps[1].TypedText);
+  EXPECT_EQ("IgnoreImplicitCastsAndParentheses", Comps[1].DisplayText);
+  EXPECT_EQ("IgnoreUnlessSpelledInSource ", Comps[2].TypedText);
+  EXPECT_EQ("IgnoreUnlessSpelledInSource", Comps[2].DisplayText);
+
   Comps = QueryParser::complete("match while", 11, QS);
   ASSERT_EQ(1u, Comps.size());
   EXPECT_EQ("Stmt(", Comps[0].TypedText);
Index: clang-tools-extra/clang-query/QuerySession.h
===
--- clang-tools-extra/clang-query/QuerySession.h
+++ clang-tools-extra/clang-query/QuerySession.h
@@ -9,6 +9,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_SESSION_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_SESSION_H
 
+#include "clang/AST/ASTTypeTraits.h"
 #include "clang/ASTMatchers/Dynamic/VariantValue.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringMap.h"
@@ -25,7 +26,7 @@
   QuerySession(llvm::ArrayRef> ASTs)
   : ASTs(ASTs), PrintOutput(false), DiagOutput(true),
 DetailedASTOutput(false), BindRoot(true), PrintMatcher(false),
-Terminate(false) {}
+Terminate(false), TK(ast_type_traits::TK_IgnoreUnlessSpelledInSource) {}
 
   llvm::ArrayRef> ASTs;
 
@@ -36,6 +37,8 @@
   bool BindRoot;
   bool PrintMatcher;
   bool Terminate;
+
+  ast_type_traits::TraversalKind TK;
   llvm::StringMap NamedValues;
 };
 
Index: clang-tools-extra/clang-query/QueryParser.h
===
--- clang-tools-extra/clang-query/QueryParser.h
+++ clang-tools-extra/clang-query/QueryParser.h
@@ -43,6 +43,8 @@
   template  struct LexOrCompleteWord;
 
   QueryRef parseSetBool(bool QuerySession::*Var);
+  QueryRef
+  parseSetTraversalKind(ast_type_traits::TraversalKind QuerySession::*Var);
   template  QueryRef parseSetOutputKind();
   QueryRef completeMatcherExpression();
 
Index: clang-tools-extra/clang-query/QueryParser.cpp
===
--- clang-tools-extra/clang-query/QueryParser.cpp
+++ clang-tools-extra/clang-query/QueryParser.cpp
@@ -127,6 +127,24 @@
   llvm_unreachable("Invalid output kind");
 }
 
+QueryRef QueryParser::parseSetTraversalKind(
+ast_type_traits::TraversalKind QuerySession::*Var) {
+  StringRef ValStr;
+  unsigned Value =
+  LexOrCompleteWord(this, ValStr)
+  .Case("AsIs", ast_type_traits::TK_AsIs)
+  .Case("IgnoreImplicitCastsAndParentheses",
+ast_type_traits::TK_IgnoreImplicitCastsAndParentheses)
+  .Case("IgnoreUnlessSpelledInSource",
+ast_type_traits::TK_IgnoreUnlessSpelledInSource)
+  .Default(~0u);
+  if (Value == ~0u) {
+return new InvalidQuery("expected traversal kind, got '" + ValStr + "'");
+  }
+  return new SetQuery(
+  Var, static_cast(Value));
+}
+
 QueryRef QueryParser::endQuery(QueryRef Q) {
   StringRef Extra = Line;
   StringRef ExtraTrimmed = Extra.drop_while(
@@ -170,7 +188,8 @@
   PQV_Invalid,
   PQV_Output,
   PQV_BindRoot,
-  PQV_PrintMatcher
+  PQV_PrintMatcher,
+  PQV_Traversal
 };
 
 QueryRef makeInvalidQueryFromDiagnostics(c

[PATCH] D71451: Support to emit extern variables debuginfo with "-fstandalone-debug"

2020-01-20 Thread Jaydeep Chauhan via Phabricator via cfe-commits
Jac1494 updated this revision to Diff 239089.

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

https://reviews.llvm.org/D71451

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/CodeGen/CGDebugInfo.cpp


Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4619,6 +4619,8 @@
   assert(CGM.getCodeGenOpts().hasReducedDebugInfo());
   if (D->hasAttr())
 return;
+  if (DebugKind < clang::codegenoptions::FullDebugInfo)
+return;
 
   auto Align = getDeclAlignIfRequired(D, CGM.getContext());
   llvm::DIFile *Unit = getOrCreateFile(D->getLocation());
Index: clang/include/clang/Basic/TargetInfo.h
===
--- clang/include/clang/Basic/TargetInfo.h
+++ clang/include/clang/Basic/TargetInfo.h
@@ -1388,7 +1388,7 @@
   virtual void setAuxTarget(const TargetInfo *Aux) {}
 
   /// Whether target allows debuginfo types for decl only variables.
-  virtual bool allowDebugInfoForExternalVar() const { return false; }
+  virtual bool allowDebugInfoForExternalVar() const { return true; }
 
 protected:
   /// Copy type and layout related info.


Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4619,6 +4619,8 @@
   assert(CGM.getCodeGenOpts().hasReducedDebugInfo());
   if (D->hasAttr())
 return;
+  if (DebugKind < clang::codegenoptions::FullDebugInfo)
+return;
 
   auto Align = getDeclAlignIfRequired(D, CGM.getContext());
   llvm::DIFile *Unit = getOrCreateFile(D->getLocation());
Index: clang/include/clang/Basic/TargetInfo.h
===
--- clang/include/clang/Basic/TargetInfo.h
+++ clang/include/clang/Basic/TargetInfo.h
@@ -1388,7 +1388,7 @@
   virtual void setAuxTarget(const TargetInfo *Aux) {}
 
   /// Whether target allows debuginfo types for decl only variables.
-  virtual bool allowDebugInfoForExternalVar() const { return false; }
+  virtual bool allowDebugInfoForExternalVar() const { return true; }
 
 protected:
   /// Copy type and layout related info.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72934: [ARM,MVE] Support immediate vbicq,vorrq,vmvnq intrinsics.

2020-01-20 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham marked 2 inline comments as done.
simon_tatham added a comment.

In D72934#1829331 , @dmgreen wrote:

> What is the reason that this can't be lowered in tablegen, in the same way as 
> the VMOVimm's are?


In NEON, immediate VBIC is represented as a single MC instruction, which takes 
its immediate operand already encoded into the NEON format (8 data bits, op and 
cmode). That's the same format that `ARMISD::VBICIMM` has encoded the operand 
in after lowering. So you only need one tablegen pattern, which passes the 
immediate through unchanged between the input and output SDNode types.

In MVE, immediate VBIC is represented as four separate MC instructions, for an 
8-bit immediate shifted left by 0, 8, 16 or 24 bits. Each one takes the 
immediate operand in the 'natural' form, i.e. the numerical value that would be 
combined into the vector lane and shown in assembly. For example, 
`MVE_VBICIZ16v4i32` takes an operand such as `0xab` which NEON VBIC would 
represent as `0xab | (control bits << 8)`. So the C++ isel code I've written 
has to undo the NEON encoding and turn it back into the 'natural' immediate 
value plus a choice of which MVE opcode to use.

I suppose an alternative would be to rework the MC representation of MVE 
VBIC/VORR so that they look more like the NEON versions. I don't exactly know 
why MVE was done differently in the first place (the commit here has my name on 
it, but it was a team effort). One possibility is that the pseudo-instruction 
reversed forms `vand` and `vorn` might be hard to represent that way, but I 
don't know.

> Do you have any tests for what would be invalid bic values under MVE?

True, I suppose I could provide some immediates that are valid for other 
`VMOVModImmType`s, like `0xabff`, and make sure nothing goes wrong.




Comment at: llvm/lib/Target/ARM/ARMISelLowering.cpp:12181
   BVN->isConstantSplat(SplatBits, SplatUndef, SplatBitSize, HasAnyUndefs)) 
{
 if (SplatBitSize <= 64) {
   EVT VbicVT;

dmgreen wrote:
> This is OK because we are passing OtherModImm to isVMOVModifiedImm, and MVE 
> supports the same patterns as NEON?
Yes: `OtherModImm` only matches values of the form '8-bit number shifted left 
by a multiple of 8 bits', which is just what MVE VBIC and VORR take as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72934



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


[PATCH] D72675: [Clang][Driver] Fix -ffast-math/-ffp-contract interaction

2020-01-20 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a comment.

In D72675#1827893 , @wristow wrote:

> How to handle this seems like an implementation question.  The code here is 
> just deciding whether or not we intend to pass "-ffast-math" to cc1 (it isn't 
> directly defining `__FAST_MATH__`).  If we do pass it to cc1, then 
> "clang/lib/Frontend/InitPreprocessor.cpp" will pre-define `__FAST_MATH__`:
>
>   if (LangOpts.FastMath)
> Builder.defineMacro("__FAST_MATH__");
>   
>
> It seems to me that a straightforward way to deal with this question is to 
> make the above test more elaborate (that is, if `LangOpts.FastMath` is set, 
> OR whatever the appropriate subset of fast-math switches are set).  If we do 
> that, we don't need to deal with the "umbrella" aspect of "-ffast-math", 
> which gets messy.
>
> Which is to say the approach here can stay the same as it currently is 
> (`-ffp-contract=off/on` suppressing the passing of "-ffast-math" to cc1).  
> Although the comment about `__FAST_MATH__` here in "Clang.cpp" should be 
> changed, if we take this approach.


That sounds fine to me, so could update that comment/this patch.

Let's give this a couple of days after updating to see if anyone else has 
feedback though. I'm never exactly sure what our responsibility is with respect 
to gcc compatibility.


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

https://reviews.llvm.org/D72675



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


[PATCH] D72934: [ARM,MVE] Support immediate vbicq,vorrq,vmvnq intrinsics.

2020-01-20 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a comment.

In D72934#1829387 , @simon_tatham 
wrote:

> In D72934#1829331 , @dmgreen wrote:
>
> > What is the reason that this can't be lowered in tablegen, in the same way 
> > as the VMOVimm's are?
>
>
> In NEON, immediate VBIC is represented as a single MC instruction, which 
> takes its immediate operand already encoded into the NEON format (8 data 
> bits, op and cmode). That's the same format that `ARMISD::VBICIMM` has 
> encoded the operand in after lowering. So you only need one tablegen pattern, 
> which passes the immediate through unchanged between the input and output 
> SDNode types.
>
> In MVE, immediate VBIC is represented as four separate MC instructions, for 
> an 8-bit immediate shifted left by 0, 8, 16 or 24 bits. Each one takes the 
> immediate operand in the 'natural' form, i.e. the numerical value that would 
> be combined into the vector lane and shown in assembly. For example, 
> `MVE_VBICIZ16v4i32` takes an operand such as `0xab` which NEON VBIC would 
> represent as `0xab | (control bits << 8)`. So the C++ isel code I've written 
> has to undo the NEON encoding and turn it back into the 'natural' immediate 
> value plus a choice of which MVE opcode to use.
>
> I suppose an alternative would be to rework the MC representation of MVE 
> VBIC/VORR so that they look more like the NEON versions. I don't exactly know 
> why MVE was done differently in the first place (the commit here has my name 
> on it, but it was a team effort). One possibility is that the 
> pseudo-instruction reversed forms `vand` and `vorn` might be hard to 
> represent that way, but I don't know.


I believe that the downstream VMOVimm's were rewritten like this when the other 
BUILDVECTOR handling was added by DavidS.  If it is possible to structure this 
way for BIC's too, it sounds like it might be a little cleaner.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72934



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


[PATCH] D71001: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2020-01-20 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 5 inline comments as done.
baloghadamsoftware added a comment.

Hello,

Thank you for your useful comments. I think I fixed them all now.


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

https://reviews.llvm.org/D71001



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


[PATCH] D71001: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2020-01-20 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 239103.
baloghadamsoftware added a comment.

Updated according to the comments.


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

https://reviews.llvm.org/D71001

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  
clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-misplaced-pointer-arithmetic-in-alloc.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.c
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
@@ -0,0 +1,53 @@
+// RUN: %check_clang_tidy %s bugprone-misplaced-pointer-arithmetic-in-alloc %t
+
+class C {
+  int num;
+public:
+  explicit C(int n) : num(n) {}
+};
+
+void bad_new(int n, int m) {
+  C *p = new C(n) + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: C *p = new C(n + 10);
+
+  p = new C(n) - 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: p = new C(n - 10);
+
+  p = new C(n) + m;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: p = new C(n + m);
+
+  p = new C(n) - (m + 10);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: p = new C(n - (m + 10));
+
+  p = new C(n) - m + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: p = new C(n - m) + 10;
+  // FIXME: Should be p = new C(n - m + 10);
+}
+
+void bad_new_array(int n, int m) {
+  char *p = new char[n] + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: char *p = new char[n + 10];
+
+  p = new char[n] - 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: p = new char[n - 10];
+
+  p = new char[n] + m;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: p = new char[n + m];
+
+  p = new char[n] - (m + 10);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: p = new char[n - (m + 10)];
+
+  p = new char[n] - m + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: p = new char[n - m] + 10;
+  // FIXME: should be p = new char[n - m + 10];
+}
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.c
@@ -0,0 +1,56 @@
+// RUN: %check_clang_tidy %s bugprone-misplaced-pointer-arithmetic-in-alloc %t
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void *alloca(size_t);
+void *calloc(size_t, size_t);
+void *realloc(void *, size_t);
+
+void bad_malloc(int n) {
+  char *p = (char *)malloc(n) + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: arithmetic operation is applied to the result of malloc() instead of its size-like argument
+  // CHECK-FIXES: char *p = (char *)malloc(n + 10);
+
+  p = (char *)malloc(n) - 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of malloc() instead of its size-like argument
+  // CHECK-FIXES: p = (char *)malloc(n - 10);
+
+  p = (char *)malloc(n) + n;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of malloc() instead of its size-like argument
+  // CHECK-FIXES: p = (char *)malloc(n + n);
+
+  p = (char *)malloc(n) - (n + 10);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic 

[PATCH] D72830: [ARM][MVE][Intrinsics] Take abs() of VMINNMAQ, VMAXNMAQ intrinsics' first arguments.

2020-01-20 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM updated this revision to Diff 239112.
MarkMurrayARM added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72830

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/test/CodeGen/arm-mve-intrinsics/vmaxnmaq.c
  clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmaq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll
===
--- llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll
@@ -7,9 +7,10 @@
 ; CHECK-NEXT:vminnma.f16 q0, q1
 ; CHECK-NEXT:bx lr
 entry:
-  %0 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %b)
-  %1 = tail call <8 x half> @llvm.minnum.v8f16(<8 x half> %a, <8 x half> %0)
-  ret <8 x half> %1
+  %0 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %a)
+  %1 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %b)
+  %2 = tail call <8 x half> @llvm.minnum.v8f16(<8 x half> %0, <8 x half> %1)
+  ret <8 x half> %2
 }
 
 declare <8 x half> @llvm.fabs.v8f16(<8 x half>) #1
@@ -22,9 +23,10 @@
 ; CHECK-NEXT:vminnma.f32 q0, q1
 ; CHECK-NEXT:bx lr
 entry:
-  %0 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %b)
-  %1 = tail call <4 x float> @llvm.minnum.v4f32(<4 x float> %a, <4 x float> %0)
-  ret <4 x float> %1
+  %0 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %a)
+  %1 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %b)
+  %2 = tail call <4 x float> @llvm.minnum.v4f32(<4 x float> %0, <4 x float> %1)
+  ret <4 x float> %2
 }
 
 declare <4 x float> @llvm.fabs.v4f32(<4 x float>) #1
Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmaq.ll
===
--- llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmaq.ll
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmaq.ll
@@ -7,9 +7,10 @@
 ; CHECK-NEXT:vmaxnma.f16 q0, q1
 ; CHECK-NEXT:bx lr
 entry:
-  %0 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %b)
-  %1 = tail call <8 x half> @llvm.maxnum.v8f16(<8 x half> %a, <8 x half> %0)
-  ret <8 x half> %1
+  %0 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %a)
+  %1 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %b)
+  %2 = tail call <8 x half> @llvm.maxnum.v8f16(<8 x half> %0, <8 x half> %1)
+  ret <8 x half> %2
 }
 
 declare <8 x half> @llvm.fabs.v8f16(<8 x half>) #1
@@ -22,9 +23,10 @@
 ; CHECK-NEXT:vmaxnma.f32 q0, q1
 ; CHECK-NEXT:bx lr
 entry:
-  %0 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %b)
-  %1 = tail call <4 x float> @llvm.maxnum.v4f32(<4 x float> %a, <4 x float> %0)
-  ret <4 x float> %1
+  %0 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %a)
+  %1 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %b)
+  %2 = tail call <4 x float> @llvm.maxnum.v4f32(<4 x float> %0, <4 x float> %1)
+  ret <4 x float> %2
 }
 
 declare <4 x float> @llvm.fabs.v4f32(<4 x float>) #1
Index: llvm/lib/Target/ARM/ARMInstrMVE.td
===
--- llvm/lib/Target/ARM/ARMInstrMVE.td
+++ llvm/lib/Target/ARM/ARMInstrMVE.td
@@ -3655,7 +3655,8 @@
 
   let Predicates = [HasMVEInt] in {
 // Unpredicated v(max|min)nma
-def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qd), (fabs (VTI.Vec MQPR:$Qm,
+def : Pat<(VTI.Vec (unpred_op (fabs (VTI.Vec MQPR:$Qd)),
+  (fabs (VTI.Vec MQPR:$Qm,
   (VTI.Vec (Inst (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm)))>;
 
 // Predicated v(max|min)nma
Index: clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
===
--- clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
+++ clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
@@ -6,9 +6,10 @@
 
 // CHECK-LABEL: @test_vminnmaq_f16(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> [[B:%.*]])
-// CHECK-NEXT:[[TMP1:%.*]] = tail call <8 x half> @llvm.minnum.v8f16(<8 x half> [[A:%.*]], <8 x half> [[TMP0]])
-// CHECK-NEXT:ret <8 x half> [[TMP1]]
+// CHECK-NEXT:[[TMP0:%.*]] = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> [[A:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> [[B:%.*]])
+// CHECK-NEXT:[[TMP2:%.*]] = tail call <8 x half> @llvm.minnum.v8f16(<8 x half> [[TMP0]], <8 x half> [[TMP1]])
+// CHECK-NEXT:ret <8 x half> [[TMP2]]
 //
 float16x8_t test_vminnmaq_f16(float16x8_t a, float16x8_t b)
 {
@@ -21,9 +22,10 @@
 
 // CHECK-LABEL: @test_vminnmaq_f32(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> [[B:%.*]])
-// CHECK-NEXT:[[TMP1:%.*]] = tail call <4 x float> @llvm.minnum.v4f32(<4 x float> [[A:%.*]], <4 x f

[clang] b10a0eb - [ARM][MVE][Intrinsics] Take abs() of VMINNMAQ, VMAXNMAQ intrinsics' first arguments.

2020-01-20 Thread Mark Murray via cfe-commits

Author: Mark Murray
Date: 2020-01-20T14:33:26Z
New Revision: b10a0eb04adfc4186cc6198cf8231358b2b04d89

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

LOG: [ARM][MVE][Intrinsics] Take abs() of VMINNMAQ, VMAXNMAQ intrinsics' first 
arguments.

Summary: Fix VMINNMAQ, VMAXNMAQ intrinsics; BOTH arguments have the absolute 
values taken.

Reviewers: dmgreen, simon_tatham

Subscribers: kristof.beyls, hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 


Modified: 
clang/include/clang/Basic/arm_mve.td
clang/test/CodeGen/arm-mve-intrinsics/vmaxnmaq.c
clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
llvm/lib/Target/ARM/ARMInstrMVE.td
llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmaq.ll
llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll

Removed: 




diff  --git a/clang/include/clang/Basic/arm_mve.td 
b/clang/include/clang/Basic/arm_mve.td
index a348713b2aa3..d28f97390614 100644
--- a/clang/include/clang/Basic/arm_mve.td
+++ b/clang/include/clang/Basic/arm_mve.td
@@ -307,10 +307,12 @@ let params = T.Float in {
  (IRIntBase<"maxnum", [Vector]> $a, $b)>;
   def vminnmaq: Intrinsic
-   $a, (IRIntBase<"fabs", [Vector]> $b))>;
+   (IRIntBase<"fabs", [Vector]> $a),
+   (IRIntBase<"fabs", [Vector]> $b))>;
   def vmaxnmaq: Intrinsic
-   $a, (IRIntBase<"fabs", [Vector]> $b))>;
+   (IRIntBase<"fabs", [Vector]> $a),
+   (IRIntBase<"fabs", [Vector]> $b))>;
 }
 
 def vpselq: Intrinsic @llvm.fabs.v8f16(<8 x 
half> [[B:%.*]])
-// CHECK-NEXT:[[TMP1:%.*]] = tail call <8 x half> @llvm.maxnum.v8f16(<8 x 
half> [[A:%.*]], <8 x half> [[TMP0]])
-// CHECK-NEXT:ret <8 x half> [[TMP1]]
+// CHECK-NEXT:[[TMP0:%.*]] = tail call <8 x half> @llvm.fabs.v8f16(<8 x 
half> [[A:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call <8 x half> @llvm.fabs.v8f16(<8 x 
half> [[B:%.*]])
+// CHECK-NEXT:[[TMP2:%.*]] = tail call <8 x half> @llvm.maxnum.v8f16(<8 x 
half> [[TMP0]], <8 x half> [[TMP1]])
+// CHECK-NEXT:ret <8 x half> [[TMP2]]
 //
 float16x8_t test_vmaxnmaq_f16(float16x8_t a, float16x8_t b)
 {
@@ -21,9 +22,10 @@ float16x8_t test_vmaxnmaq_f16(float16x8_t a, float16x8_t b)
 
 // CHECK-LABEL: @test_vmaxnmaq_f32(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = tail call <4 x float> @llvm.fabs.v4f32(<4 x 
float> [[B:%.*]])
-// CHECK-NEXT:[[TMP1:%.*]] = tail call <4 x float> @llvm.maxnum.v4f32(<4 x 
float> [[A:%.*]], <4 x float> [[TMP0]])
-// CHECK-NEXT:ret <4 x float> [[TMP1]]
+// CHECK-NEXT:[[TMP0:%.*]] = tail call <4 x float> @llvm.fabs.v4f32(<4 x 
float> [[A:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call <4 x float> @llvm.fabs.v4f32(<4 x 
float> [[B:%.*]])
+// CHECK-NEXT:[[TMP2:%.*]] = tail call <4 x float> @llvm.maxnum.v4f32(<4 x 
float> [[TMP0]], <4 x float> [[TMP1]])
+// CHECK-NEXT:ret <4 x float> [[TMP2]]
 //
 float32x4_t test_vmaxnmaq_f32(float32x4_t a, float32x4_t b)
 {

diff  --git a/clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c 
b/clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
index e16ede06f691..955e8feab52a 100644
--- a/clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
+++ b/clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
@@ -6,9 +6,10 @@
 
 // CHECK-LABEL: @test_vminnmaq_f16(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = tail call <8 x half> @llvm.fabs.v8f16(<8 x 
half> [[B:%.*]])
-// CHECK-NEXT:[[TMP1:%.*]] = tail call <8 x half> @llvm.minnum.v8f16(<8 x 
half> [[A:%.*]], <8 x half> [[TMP0]])
-// CHECK-NEXT:ret <8 x half> [[TMP1]]
+// CHECK-NEXT:[[TMP0:%.*]] = tail call <8 x half> @llvm.fabs.v8f16(<8 x 
half> [[A:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call <8 x half> @llvm.fabs.v8f16(<8 x 
half> [[B:%.*]])
+// CHECK-NEXT:[[TMP2:%.*]] = tail call <8 x half> @llvm.minnum.v8f16(<8 x 
half> [[TMP0]], <8 x half> [[TMP1]])
+// CHECK-NEXT:ret <8 x half> [[TMP2]]
 //
 float16x8_t test_vminnmaq_f16(float16x8_t a, float16x8_t b)
 {
@@ -21,9 +22,10 @@ float16x8_t test_vminnmaq_f16(float16x8_t a, float16x8_t b)
 
 // CHECK-LABEL: @test_vminnmaq_f32(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = tail call <4 x float> @llvm.fabs.v4f32(<4 x 
float> [[B:%.*]])
-// CHECK-NEXT:[[TMP1:%.*]] = tail call <4 x float> @llvm.minnum.v4f32(<4 x 
float> [[A:%.*]], <4 x float> [[TMP0]])
-// CHECK-NEXT:ret <4 x float> [[TMP1]]
+// CHECK-NEXT:[[TMP0:%.*]] = tail call <4 x float> @llvm.fabs.v4f32(<4 x 
float> [[A:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call <4 x float> @llvm.fabs.v4f32(<4 x 
float> [[B:%.*]

[PATCH] D72830: [ARM][MVE][Intrinsics] Take abs() of VMINNMAQ, VMAXNMAQ intrinsics' first arguments.

2020-01-20 Thread Mark Murray via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb10a0eb04adf: [ARM][MVE][Intrinsics] Take abs() of VMINNMAQ, 
VMAXNMAQ intrinsics' first… (authored by MarkMurrayARM).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72830

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/test/CodeGen/arm-mve-intrinsics/vmaxnmaq.c
  clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmaq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll
===
--- llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll
@@ -7,9 +7,10 @@
 ; CHECK-NEXT:vminnma.f16 q0, q1
 ; CHECK-NEXT:bx lr
 entry:
-  %0 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %b)
-  %1 = tail call <8 x half> @llvm.minnum.v8f16(<8 x half> %a, <8 x half> %0)
-  ret <8 x half> %1
+  %0 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %a)
+  %1 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %b)
+  %2 = tail call <8 x half> @llvm.minnum.v8f16(<8 x half> %0, <8 x half> %1)
+  ret <8 x half> %2
 }
 
 declare <8 x half> @llvm.fabs.v8f16(<8 x half>) #1
@@ -22,9 +23,10 @@
 ; CHECK-NEXT:vminnma.f32 q0, q1
 ; CHECK-NEXT:bx lr
 entry:
-  %0 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %b)
-  %1 = tail call <4 x float> @llvm.minnum.v4f32(<4 x float> %a, <4 x float> %0)
-  ret <4 x float> %1
+  %0 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %a)
+  %1 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %b)
+  %2 = tail call <4 x float> @llvm.minnum.v4f32(<4 x float> %0, <4 x float> %1)
+  ret <4 x float> %2
 }
 
 declare <4 x float> @llvm.fabs.v4f32(<4 x float>) #1
Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmaq.ll
===
--- llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmaq.ll
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmaq.ll
@@ -7,9 +7,10 @@
 ; CHECK-NEXT:vmaxnma.f16 q0, q1
 ; CHECK-NEXT:bx lr
 entry:
-  %0 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %b)
-  %1 = tail call <8 x half> @llvm.maxnum.v8f16(<8 x half> %a, <8 x half> %0)
-  ret <8 x half> %1
+  %0 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %a)
+  %1 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %b)
+  %2 = tail call <8 x half> @llvm.maxnum.v8f16(<8 x half> %0, <8 x half> %1)
+  ret <8 x half> %2
 }
 
 declare <8 x half> @llvm.fabs.v8f16(<8 x half>) #1
@@ -22,9 +23,10 @@
 ; CHECK-NEXT:vmaxnma.f32 q0, q1
 ; CHECK-NEXT:bx lr
 entry:
-  %0 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %b)
-  %1 = tail call <4 x float> @llvm.maxnum.v4f32(<4 x float> %a, <4 x float> %0)
-  ret <4 x float> %1
+  %0 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %a)
+  %1 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %b)
+  %2 = tail call <4 x float> @llvm.maxnum.v4f32(<4 x float> %0, <4 x float> %1)
+  ret <4 x float> %2
 }
 
 declare <4 x float> @llvm.fabs.v4f32(<4 x float>) #1
Index: llvm/lib/Target/ARM/ARMInstrMVE.td
===
--- llvm/lib/Target/ARM/ARMInstrMVE.td
+++ llvm/lib/Target/ARM/ARMInstrMVE.td
@@ -3655,7 +3655,8 @@
 
   let Predicates = [HasMVEInt] in {
 // Unpredicated v(max|min)nma
-def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qd), (fabs (VTI.Vec MQPR:$Qm,
+def : Pat<(VTI.Vec (unpred_op (fabs (VTI.Vec MQPR:$Qd)),
+  (fabs (VTI.Vec MQPR:$Qm,
   (VTI.Vec (Inst (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm)))>;
 
 // Predicated v(max|min)nma
Index: clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
===
--- clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
+++ clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
@@ -6,9 +6,10 @@
 
 // CHECK-LABEL: @test_vminnmaq_f16(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> [[B:%.*]])
-// CHECK-NEXT:[[TMP1:%.*]] = tail call <8 x half> @llvm.minnum.v8f16(<8 x half> [[A:%.*]], <8 x half> [[TMP0]])
-// CHECK-NEXT:ret <8 x half> [[TMP1]]
+// CHECK-NEXT:[[TMP0:%.*]] = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> [[A:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> [[B:%.*]])
+// CHECK-NEXT:[[TMP2:%.*]] = tail call <8 x half> @llvm.minnum.v8f16(<8 x half> [[TMP0]], <8 x half> [[TMP1]])
+// CHECK-NEXT:ret <8 x half> [[TMP2]]
 //
 float16x8_t test_vminnmaq_f16(float16x8_t a, float16x8_t b)
 {
@@ -21,9 +22,10 @@
 
 // CHECK-LABEL: @test_vminnmaq_f32(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = tail call <4 x float> @llvm.fabs.v4f32(<4 x flo

[PATCH] D71451: Support to emit extern variables debuginfo with "-fstandalone-debug"

2020-01-20 Thread Jaydeep Chauhan via Phabricator via cfe-commits
Jac1494 updated this revision to Diff 239115.

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

https://reviews.llvm.org/D71451

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-extern-variable-basic.c
  clang/test/CodeGen/debug-info-extern-variable-unused.c


Index: clang/test/CodeGen/debug-info-extern-variable-unused.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-extern-variable-unused.c
@@ -0,0 +1,10 @@
+// RUN: %clang -emit-llvm -S -g -fstandalone-debug %s -o - | FileCheck %s
+
+extern int i;
+int foo() {
+  extern int j;
+  return 0;
+}
+
+// CHECK-NOT: distinct !DIGlobalVariable(name: "i"
+// CHECK-NOT: distinct !DIGlobalVariable(name: "j"
Index: clang/test/CodeGen/debug-info-extern-variable-basic.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-extern-variable-basic.c
@@ -0,0 +1,10 @@
+// RUN: %clang -emit-llvm -S -g -fstandalone-debug %s -o - | FileCheck %s
+
+extern int i;
+int foo() {
+  extern int j;
+  return i+j;
+}
+
+// CHECK: distinct !DIGlobalVariable(name: "i"
+// CHECK: distinct !DIGlobalVariable(name: "j"
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4619,6 +4619,8 @@
   assert(CGM.getCodeGenOpts().hasReducedDebugInfo());
   if (D->hasAttr())
 return;
+  if (DebugKind < clang::codegenoptions::FullDebugInfo)
+return;
 
   auto Align = getDeclAlignIfRequired(D, CGM.getContext());
   llvm::DIFile *Unit = getOrCreateFile(D->getLocation());
Index: clang/include/clang/Basic/TargetInfo.h
===
--- clang/include/clang/Basic/TargetInfo.h
+++ clang/include/clang/Basic/TargetInfo.h
@@ -1388,7 +1388,7 @@
   virtual void setAuxTarget(const TargetInfo *Aux) {}
 
   /// Whether target allows debuginfo types for decl only variables.
-  virtual bool allowDebugInfoForExternalVar() const { return false; }
+  virtual bool allowDebugInfoForExternalVar() const { return true; }
 
 protected:
   /// Copy type and layout related info.


Index: clang/test/CodeGen/debug-info-extern-variable-unused.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-extern-variable-unused.c
@@ -0,0 +1,10 @@
+// RUN: %clang -emit-llvm -S -g -fstandalone-debug %s -o - | FileCheck %s
+
+extern int i;
+int foo() {
+  extern int j;
+  return 0;
+}
+
+// CHECK-NOT: distinct !DIGlobalVariable(name: "i"
+// CHECK-NOT: distinct !DIGlobalVariable(name: "j"
Index: clang/test/CodeGen/debug-info-extern-variable-basic.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-extern-variable-basic.c
@@ -0,0 +1,10 @@
+// RUN: %clang -emit-llvm -S -g -fstandalone-debug %s -o - | FileCheck %s
+
+extern int i;
+int foo() {
+  extern int j;
+  return i+j;
+}
+
+// CHECK: distinct !DIGlobalVariable(name: "i"
+// CHECK: distinct !DIGlobalVariable(name: "j"
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4619,6 +4619,8 @@
   assert(CGM.getCodeGenOpts().hasReducedDebugInfo());
   if (D->hasAttr())
 return;
+  if (DebugKind < clang::codegenoptions::FullDebugInfo)
+return;
 
   auto Align = getDeclAlignIfRequired(D, CGM.getContext());
   llvm::DIFile *Unit = getOrCreateFile(D->getLocation());
Index: clang/include/clang/Basic/TargetInfo.h
===
--- clang/include/clang/Basic/TargetInfo.h
+++ clang/include/clang/Basic/TargetInfo.h
@@ -1388,7 +1388,7 @@
   virtual void setAuxTarget(const TargetInfo *Aux) {}
 
   /// Whether target allows debuginfo types for decl only variables.
-  virtual bool allowDebugInfoForExternalVar() const { return false; }
+  virtual bool allowDebugInfoForExternalVar() const { return true; }
 
 protected:
   /// Copy type and layout related info.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72755: [RISCV] Pass target-abi via module flag metadata

2020-01-20 Thread Sam Elliott via Phabricator via cfe-commits
lenary accepted this revision.
lenary added a comment.
This revision is now accepted and ready to land.

LGTM, Thank You!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72755



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


[PATCH] D71512: [clang-format] Fix short block when braking after control statement

2020-01-20 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay requested changes to this revision.
MyDeveloperDay added a comment.
This revision now requires changes to proceed.

In D71512#1815512 , @Bouska wrote:

> Ping @MyDeveloperDay @klimek







Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:344
-  return MergedLines;
-}
 // Don't merge block with left brace wrapped after ObjC special blocks

I just can't understand how we are free to just remove a chunk of code. Why is 
this not being some sort of 


```
if (Style.AllowShortBlocksOnASingleLine)
```

You are just not giving a convincing argument that this is a safe change 
without us having to go in a debug the original problem ourselves.



Comment at: clang/unittests/Format/FormatTest.cpp:662
"{\n"
-   "  ff();\n"
"}",

I'm just not comfortable with changing tests, code can still be written in the 
way it was before, and I cannot tell what it would now be, I believe tests 
should be additive


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

https://reviews.llvm.org/D71512



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


[PATCH] D72488: [clang-tidy] Add check for CERT-OOP57-CPP

2020-01-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Btw, do you need me to commit this on your behalf, or have you obtained your 
commit privileges?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72488



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


[PATCH] D73007: [Sema] Avoid Wrange-loop-analysis false positives

2020-01-20 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! Do you think this should also be pushed onto the release branch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73007



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


[PATCH] D71607: [clang-tidy] Add unsigned subtraction warning, with suggestion to convert to unsigned literals.

2020-01-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D71607#1828055 , @sorenj wrote:

> Okay, but as you can see the majority of my test cases are intentionally 
> false negatives `- -Wsign-conversion` triggers so often than many people 
> don't use it.


Then we should be addressing that issue rather than duplicating the 
functionality, no?

> And, `unsigned x = 2;` does not trigger a sign conversion warning despite 
> there being a conversion form 2 to 2u.

That should *not* trigger a sign conversion warning because there is no sign 
conversion. We know the exact value of the RHS and can see that it does not 
change signs.

> This check is targeting a very specific but frequent case of functions that 
> do not guard against containers that might be empty.

We should consider a better name for the check then and limit its utility to 
those cases. Truthfully, I think that check would be quite useful, but it would 
almost certainly be a clang static analyzer check to handle control and data 
flow. e.g., such a check should be able to handle these situations:

  size_t count1 = some_container.size() - 1; // Bad if empty
  size_t num_elements = some_container.size();
  size_t count2 = num_elements - 1; // Bad if empty
  if (num_element)
size_t count3 = num_elements - 1; // Just fine
  size_t count4 = std::size(some_container) - 1; // Bad if empty
  size_t count5 = std::distance(some_container.begin(), some_container.end()) - 
1; // Bad if empty? (Note, there's no type-based sign conversion here)
  
  num_elements + 1;
  size_t count6 = num_elements - 1; // Just fine



> Regarding the false positives - I think you are focusing on the semantics of 
> the fix-it which is literally a no-op. The code before and after may be just 
> as wrong, but the salience of the implied conversion is a bit higher. Maybe 
> that's not a good idea for a change that may be applied automatically, even 
> if safe.
> 
> In short I'm not sure if you are objecting the principle here, or the 
> implementation.

A bit of both. I don't think clang-tidy should get a -Wsign-conversion check -- 
the frontend handles that, and if there are deficiencies with that handling, we 
should address those. However, a check that's focused solely on container and 
container-like situations where an empty container would cause problems seems 
like a very interesting check that has value. I'm not certain that implementing 
it in clang-tidy would catch the cases with a reasonable false-positive rate, 
but it seems like it wouldn't be bad as a static analyzer check instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71607



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


[clang-tools-extra] 3de9a5d - [clangd] Avoid redundant testcases in rename unittest, NFC.

2020-01-20 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-01-20T17:01:05+01:00
New Revision: 3de9a5db629ac9d633576513d025a8f038a3cdec

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

LOG: [clangd] Avoid redundant testcases in rename unittest, NFC.

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/Rename.cpp
clang-tools-extra/clangd/unittests/RenameTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index 80917e1abb27..9518d848eff5 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -215,7 +215,7 @@ std::vector 
findOccurrencesWithinFile(ParsedAST &AST,
   // getUSRsForDeclaration will find other related symbols, e.g. virtual and 
its
   // overriddens, primary template and all explicit specializations.
   // FIXME: Get rid of the remaining tooling APIs.
-  const auto RenameDecl =
+  const auto *RenameDecl =
   ND.getDescribedTemplate() ? ND.getDescribedTemplate() : &ND;
   std::vector RenameUSRs =
   tooling::getUSRsForDeclaration(RenameDecl, AST.getASTContext());

diff  --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp 
b/clang-tools-extra/clangd/unittests/RenameTests.cpp
index 6ced22bf3515..80930b9096d4 100644
--- a/clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ b/clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -722,7 +722,7 @@ TEST(CrossFileRenameTests, WithUpToDateIndex) {
 void onDiagnosticsReady(PathRef File,
 std::vector Diagnostics) override {}
   } DiagConsumer;
-  // rename is runnning on the "^" point in FooH, and "[[]]" ranges are the
+  // rename is runnning on all "^" points in FooH, and "[[]]" ranges are the
   // expected rename occurrences.
   struct Case {
 llvm::StringRef FooH;
@@ -763,28 +763,10 @@ TEST(CrossFileRenameTests, WithUpToDateIndex) {
   )cpp",
   },
   {
-  // Constructor.
+  // rename on constructor and destructor.
   R"cpp(
 class [[Foo]] {
   [[^Foo]]();
-  ~[[Foo]]();
-};
-  )cpp",
-  R"cpp(
-#include "foo.h"
-[[Foo]]::[[Foo]]() {}
-[[Foo]]::~[[Foo]]() {}
-
-void func() {
-  [[Foo]] foo;
-}
-  )cpp",
-  },
-  {
-  // Destructor (selecting before the identifier).
-  R"cpp(
-class [[Foo]] {
-  [[Foo]]();
   ~[[Foo^]]();
 };
   )cpp",
@@ -891,12 +873,15 @@ TEST(CrossFileRenameTests, WithUpToDateIndex) {
 runAddDocument(Server, FooCCPath, FooCC.code());
 
 llvm::StringRef NewName = "NewName";
-auto FileEditsList =
-llvm::cantFail(runRename(Server, FooHPath, FooH.point(), NewName));
-EXPECT_THAT(applyEdits(std::move(FileEditsList)),
-UnorderedElementsAre(
-Pair(Eq(FooHPath), Eq(expectedResult(T.FooH, NewName))),
-Pair(Eq(FooCCPath), Eq(expectedResult(T.FooCC, 
NewName);
+for (const auto &RenamePos : FooH.points()) {
+  auto FileEditsList =
+  llvm::cantFail(runRename(Server, FooHPath, RenamePos, NewName));
+  EXPECT_THAT(
+  applyEdits(std::move(FileEditsList)),
+  UnorderedElementsAre(
+  Pair(Eq(FooHPath), Eq(expectedResult(T.FooH, NewName))),
+  Pair(Eq(FooCCPath), Eq(expectedResult(T.FooCC, NewName);
+}
   }
 }
 



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


[PATCH] D73035: [clangd] Avoid redundant testcases in rename unittest, NFC.

2020-01-20 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3de9a5db629a: [clangd] Avoid redundant testcases in rename 
unittest, NFC. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73035

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -722,7 +722,7 @@
 void onDiagnosticsReady(PathRef File,
 std::vector Diagnostics) override {}
   } DiagConsumer;
-  // rename is runnning on the "^" point in FooH, and "[[]]" ranges are the
+  // rename is runnning on all "^" points in FooH, and "[[]]" ranges are the
   // expected rename occurrences.
   struct Case {
 llvm::StringRef FooH;
@@ -763,28 +763,10 @@
   )cpp",
   },
   {
-  // Constructor.
+  // rename on constructor and destructor.
   R"cpp(
 class [[Foo]] {
   [[^Foo]]();
-  ~[[Foo]]();
-};
-  )cpp",
-  R"cpp(
-#include "foo.h"
-[[Foo]]::[[Foo]]() {}
-[[Foo]]::~[[Foo]]() {}
-
-void func() {
-  [[Foo]] foo;
-}
-  )cpp",
-  },
-  {
-  // Destructor (selecting before the identifier).
-  R"cpp(
-class [[Foo]] {
-  [[Foo]]();
   ~[[Foo^]]();
 };
   )cpp",
@@ -891,12 +873,15 @@
 runAddDocument(Server, FooCCPath, FooCC.code());
 
 llvm::StringRef NewName = "NewName";
-auto FileEditsList =
-llvm::cantFail(runRename(Server, FooHPath, FooH.point(), NewName));
-EXPECT_THAT(applyEdits(std::move(FileEditsList)),
-UnorderedElementsAre(
-Pair(Eq(FooHPath), Eq(expectedResult(T.FooH, NewName))),
-Pair(Eq(FooCCPath), Eq(expectedResult(T.FooCC, 
NewName);
+for (const auto &RenamePos : FooH.points()) {
+  auto FileEditsList =
+  llvm::cantFail(runRename(Server, FooHPath, RenamePos, NewName));
+  EXPECT_THAT(
+  applyEdits(std::move(FileEditsList)),
+  UnorderedElementsAre(
+  Pair(Eq(FooHPath), Eq(expectedResult(T.FooH, NewName))),
+  Pair(Eq(FooCCPath), Eq(expectedResult(T.FooCC, NewName);
+}
   }
 }
 
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -215,7 +215,7 @@
   // getUSRsForDeclaration will find other related symbols, e.g. virtual and 
its
   // overriddens, primary template and all explicit specializations.
   // FIXME: Get rid of the remaining tooling APIs.
-  const auto RenameDecl =
+  const auto *RenameDecl =
   ND.getDescribedTemplate() ? ND.getDescribedTemplate() : &ND;
   std::vector RenameUSRs =
   tooling::getUSRsForDeclaration(RenameDecl, AST.getASTContext());


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -722,7 +722,7 @@
 void onDiagnosticsReady(PathRef File,
 std::vector Diagnostics) override {}
   } DiagConsumer;
-  // rename is runnning on the "^" point in FooH, and "[[]]" ranges are the
+  // rename is runnning on all "^" points in FooH, and "[[]]" ranges are the
   // expected rename occurrences.
   struct Case {
 llvm::StringRef FooH;
@@ -763,28 +763,10 @@
   )cpp",
   },
   {
-  // Constructor.
+  // rename on constructor and destructor.
   R"cpp(
 class [[Foo]] {
   [[^Foo]]();
-  ~[[Foo]]();
-};
-  )cpp",
-  R"cpp(
-#include "foo.h"
-[[Foo]]::[[Foo]]() {}
-[[Foo]]::~[[Foo]]() {}
-
-void func() {
-  [[Foo]] foo;
-}
-  )cpp",
-  },
-  {
-  // Destructor (selecting before the identifier).
-  R"cpp(
-class [[Foo]] {
-  [[Foo]]();
   ~[[Foo^]]();
 };
   )cpp",
@@ -891,12 +873,15 @@
 runAddDocument(Server, FooCCPath, FooCC.code());
 
 llvm::StringRef NewName = "NewName";
-auto FileEditsList =
-llvm::cantFail(runRename(Server, FooHPath, FooH.point(), NewName));
-EXPECT_THAT(applyEdits(std::move(FileEditsList)),
-UnorderedElementsAre(
-Pair(Eq(FooHPath), Eq(expectedResult(T.FooH, NewName))),
-Pair(Eq(FooCCPath), Eq(expectedResult(T.FooCC, NewName);
+for (const auto &RenamePos 

[clang] 4c9d691 - clang-format: [JS] fix `??` opreator wrapping.

2020-01-20 Thread Martin Probst via cfe-commits

Author: Martin Probst
Date: 2020-01-20T17:07:14+01:00
New Revision: 4c9d6914453d970b7b8202b7efd7524b2f0a72ac

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

LOG: clang-format: [JS] fix `??` opreator wrapping.

Summary:
clang-format currently treats the nullish coalescing operator `??` like
the ternary operator. That causes multiple nullish terms to be each
indented relative to the last `??`, as they would in a ternary.

The `??` operator is often used in chains though, and as such more
similar to other binary operators, such as `||`. So to fix the indent,
set its token type to `||`, so it inherits the same treatment.

This opens up the question of operator precedence. However, `??` is
required to be parenthesized when mixed with `||` and `&&`, so this is
not a problem that can come up in syntactically legal code.

Reviewers: krasimir

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Format/FormatTokenLexer.cpp
clang/unittests/Format/FormatTestJS.cpp

Removed: 




diff  --git a/clang/lib/Format/FormatTokenLexer.cpp 
b/clang/lib/Format/FormatTokenLexer.cpp
index ef20ba884fb3..9c9fee2b0c32 100644
--- a/clang/lib/Format/FormatTokenLexer.cpp
+++ b/clang/lib/Format/FormatTokenLexer.cpp
@@ -120,8 +120,11 @@ void FormatTokenLexer::tryMergePreviousTokens() {
   Tokens.back()->Tok.setKind(tok::starequal);
   return;
 }
-if (tryMergeTokens(JSNullishOperator, TT_JsNullishCoalescingOperator))
+if (tryMergeTokens(JSNullishOperator, TT_JsNullishCoalescingOperator)) {
+  // Treat like the "||" operator (as opposed to the ternary ?).
+  Tokens.back()->Tok.setKind(tok::pipepipe);
   return;
+}
 if (tryMergeTokens(JSNullPropagatingOperator,
TT_JsNullPropagatingOperator)) {
   // Treat like a regular "." access.

diff  --git a/clang/unittests/Format/FormatTestJS.cpp 
b/clang/unittests/Format/FormatTestJS.cpp
index ffeb53d9a33c..ef3c6361355a 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -2294,6 +2294,11 @@ TEST_F(FormatTestJS, NullPropagatingOperator) {
 
 TEST_F(FormatTestJS, NullishCoalescingOperator) {
   verifyFormat("const val = something ?? 'some other default';\n");
+  verifyFormat(
+  "const val = something ?? otherDefault ??\n"
+  "evenMore ?? evenMore;\n",
+  "const val = something ?? otherDefault ?? evenMore ?? evenMore;\n",
+  getGoogleJSStyleWithColumns(40));
 }
 
 TEST_F(FormatTestJS, Conditional) {



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


[PATCH] D73026: clang-format: [JS] fix `??` opreator wrapping.

2020-01-20 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4c9d6914453d: clang-format: [JS] fix `??` opreator wrapping. 
(authored by mprobst).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73026

Files:
  clang/lib/Format/FormatTokenLexer.cpp
  clang/unittests/Format/FormatTestJS.cpp


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -2294,6 +2294,11 @@
 
 TEST_F(FormatTestJS, NullishCoalescingOperator) {
   verifyFormat("const val = something ?? 'some other default';\n");
+  verifyFormat(
+  "const val = something ?? otherDefault ??\n"
+  "evenMore ?? evenMore;\n",
+  "const val = something ?? otherDefault ?? evenMore ?? evenMore;\n",
+  getGoogleJSStyleWithColumns(40));
 }
 
 TEST_F(FormatTestJS, Conditional) {
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -120,8 +120,11 @@
   Tokens.back()->Tok.setKind(tok::starequal);
   return;
 }
-if (tryMergeTokens(JSNullishOperator, TT_JsNullishCoalescingOperator))
+if (tryMergeTokens(JSNullishOperator, TT_JsNullishCoalescingOperator)) {
+  // Treat like the "||" operator (as opposed to the ternary ?).
+  Tokens.back()->Tok.setKind(tok::pipepipe);
   return;
+}
 if (tryMergeTokens(JSNullPropagatingOperator,
TT_JsNullPropagatingOperator)) {
   // Treat like a regular "." access.


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -2294,6 +2294,11 @@
 
 TEST_F(FormatTestJS, NullishCoalescingOperator) {
   verifyFormat("const val = something ?? 'some other default';\n");
+  verifyFormat(
+  "const val = something ?? otherDefault ??\n"
+  "evenMore ?? evenMore;\n",
+  "const val = something ?? otherDefault ?? evenMore ?? evenMore;\n",
+  getGoogleJSStyleWithColumns(40));
 }
 
 TEST_F(FormatTestJS, Conditional) {
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -120,8 +120,11 @@
   Tokens.back()->Tok.setKind(tok::starequal);
   return;
 }
-if (tryMergeTokens(JSNullishOperator, TT_JsNullishCoalescingOperator))
+if (tryMergeTokens(JSNullishOperator, TT_JsNullishCoalescingOperator)) {
+  // Treat like the "||" operator (as opposed to the ternary ?).
+  Tokens.back()->Tok.setKind(tok::pipepipe);
   return;
+}
 if (tryMergeTokens(JSNullPropagatingOperator,
TT_JsNullPropagatingOperator)) {
   // Treat like a regular "." access.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


patch via mailing list: Use getLocation() in too few/many arguments diagnostic

2020-01-20 Thread John Marshall via cfe-commits
This small patch improves the diagnostics when calling a function with the 
wrong number of arguments. For example, given

int
foo(int a, int b);

int bar() { return foo(1); }

The existing compiler shows the error message and a note for "foo declared 
here" showing only the "int" line. Ideally it would show the line containing 
the word "foo" instead, which it does after this patch. Also if the function 
declaration starts with some incidental macro, a trace of macro expansion is 
shown which is likely irrelevant. See for example 
https://github.com/samtools/htslib/issues/1013 and PR#23564.

I have not contributed to LLVM before and I am unfamiliar with the difference 
between getBeginLoc() and getLocation() and the implications of using each. 
However this patch does fix PR#23564 and perhaps this fix would be mostly a 
no-brainer for those who are familiar with the code and these two location 
functions in particular?

Thanks,

John


commit 12c8979abaf40aa76c6769d6270f3565d71f3011
Author: John Marshall 
Date:   Mon Jan 20 14:58:14 2020 +

Use getLocation() in too few/many arguments diagnostic

Use the more accurate location when emitting the location of the
function being called's prototype in diagnostics emitted when calling
a function with an incorrect number of arguments.

In particular, avoids showing a trace of irrelevant macro expansions
for "MY_EXPORT static int AwesomeFunction(int, int);". Fixes PR#23564.

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index ea4b93ee6a5..19dfc7c7fd7 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5194,7 +5194,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
 
   // Emit the location of the prototype.
   if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
-Diag(FDecl->getBeginLoc(), diag::note_callee_decl) << FDecl;
+Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
 
   return true;
 }
@@ -5239,7 +5239,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
 
   // Emit the location of the prototype.
   if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
-Diag(FDecl->getBeginLoc(), diag::note_callee_decl) << FDecl;
+Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
 
   // This deletes the extra arguments.
   Call->shrinkNumArgs(NumParams);

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


[PATCH] D73007: [Sema] Avoid Wrange-loop-analysis false positives

2020-01-20 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

As I wrote on the bug , I think we 
should only suppress one of the warnings in templates (and maybe always):

  :18:22: warning: loop variable '_' is always a copy because the range 
of type 'const Rng' does not return a reference [-Wrange-loop-analysis]
  for (const auto& _ : t)
   ^
  :26:5: note: in instantiation of function template specialization 
'f' requested here
  f(Rng{});
  ^
  :18:10: note: use non-reference type 'int'
  for (const auto& _ : t)
   ^~~

However, I think we shouldn't suppress the other:

  :18:21: warning: loop variable '_' of type 'const X' creates a copy 
from type 'const X' [-Wrange-loop-analysis]
  for (const auto _ : t)
  ^
  :25:5: note: in instantiation of function template specialization 
'f' requested here
  f(array);
  ^
  :18:10: note: use reference type 'const X &' to prevent copying
  for (const auto _ : t)
   ^~
  &

This generates a bunch of unneeded non-trivial copies, and I think we want to 
warn about that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73007



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


[clang] 3663563 - [OPENMP]Fix PR44578: crash in target construct with captured global.

2020-01-20 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-01-20T11:10:17-05:00
New Revision: 366356361cf3abf97fbcfe9a0467b1ed1610401f

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

LOG: [OPENMP]Fix PR44578: crash in target construct with captured global.

Target regions have implicit outer region which may erroneously capture
some globals when it should not. It may lead to a compiler crash at the
compile time.

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/target_depend_codegen.cpp
clang/test/OpenMP/target_messages.cpp
clang/test/OpenMP/target_parallel_depend_codegen.cpp
clang/test/OpenMP/target_parallel_for_depend_codegen.cpp
clang/test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
clang/test/OpenMP/target_simd_depend_codegen.cpp
clang/test/OpenMP/target_teams_depend_codegen.cpp
clang/test/OpenMP/target_teams_distribute_depend_codegen.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp

clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
clang/test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 2fb758bc75d6..6e3ae96b3afc 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -9681,7 +9681,8 @@ class Sema final {
   /// Check if the specified variable is captured  by 'target' directive.
   /// \param Level Relative level of nested OpenMP construct for that the check
   /// is performed.
-  bool isOpenMPTargetCapturedDecl(const ValueDecl *D, unsigned Level) const;
+  bool isOpenMPTargetCapturedDecl(const ValueDecl *D, unsigned Level,
+  unsigned CaptureLevel) const;
 
   ExprResult PerformOpenMPImplicitIntegerConversion(SourceLocation OpLoc,
 Expr *Op);

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index ea4b93ee6a5a..67b68ffb5eda 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16280,8 +16280,10 @@ bool Sema::tryCaptureVariable(
   captureVariablyModifiedType(Context, QTy, OuterRSI);
 }
   }
-  bool IsTargetCap = !IsOpenMPPrivateDecl &&
- isOpenMPTargetCapturedDecl(Var, RSI->OpenMPLevel);
+  bool IsTargetCap =
+  !IsOpenMPPrivateDecl &&
+  isOpenMPTargetCapturedDecl(Var, RSI->OpenMPLevel,
+ RSI->OpenMPCaptureLevel);
   // When we detect target captures we are looking from inside the
   // target region, therefore we need to propagate the capture from the
   // enclosing region. Therefore, the capture is not initially nested.

diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 3fce0e27e9b3..72afe63749ac 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -31,6 +31,7 @@
 #include "clang/Sema/SemaInternal.h"
 #include "llvm/ADT/IndexedMap.h"
 #include "llvm/ADT/PointerEmbeddedInt.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/Frontend/OpenMP/OMPConstants.h"
 using namespace clang;
 using namespace llvm::omp;
@@ -2010,7 +2011,23 @@ VarDecl *Sema::isOpenMPCapturedDecl(ValueDecl *D, bool 
CheckScopeInfo,
   //
   if (OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD))
 return nullptr;
-  return VD;
+  CapturedRegionScopeInfo *CSI = nullptr;
+  for (FunctionScopeInfo *FSI : llvm::drop_begin(
+   llvm::reverse(FunctionScopes),
+   CheckScopeInfo ? (FunctionScopes.size() - (StopAt + 1)) : 0)) {
+if (!isa(FSI))
+  return nullptr;
+if (auto *RSI = dyn_cast(FSI))
+  if (RSI->CapRegionKind == CR_OpenMP) {
+CSI = RSI;
+break;
+  }
+  }
+  SmallVector Regions;
+  getOpenMPCaptureRegions(Regions,
+  DSAStack->getDirective(CSI->OpenMPLevel));
+  if (Regions[CSI->OpenMPCaptureLevel] != OMPD_task)
+return VD;
 }
   }
 
@@ -2151,15 +2168,18 @@ void Sema::setOpenMPCaptureKind(FieldDecl *FD, const 
ValueDecl *D,
 FD->addAttr(OMPCaptureKindAttr::CreateImplicit(Context, OMPC));
 }
 
-bool Sema::isOpenMPTargetCapturedDecl(const ValueDecl *D,
-  unsigned Level) const {
+bool Sema::isOpenMPTargetCapturedDecl(const ValueDecl *D, unsigned Level,
+  unsigned CaptureLevel) const {
   assert(LangOpts.OpenMP && "OpenMP is not allowed");
   // Return true if the current level is no longer encl

[PATCH] D71566: New checks for fortified sprintf

2020-01-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:745-746
+def warn_fortify_source_format_overflow : Warning<
+  "'%0' will always overflow; destination buffer has size %1,"
+  " but format string expands to at least %2">,
+  InGroup;

I'm fine with the current wording because it's consistent with the existing 
diagnostics, but I wish we would quantify the size with units in these 
diagnostics. (e.g., mention that this is measured in bytes as opposed to 
anything else).



Comment at: clang/lib/Sema/SemaChecking.cpp:405-406
+  bool HandlePrintfSpecifier(const analyze_printf::PrintfSpecifier &FS,
+ const char *startSpecifier,
+ unsigned specifierLen) override {
+const analyze_format_string::OptionalAmount &FW = FS.getFieldWidth();

Naming nits: `StartSpecifier` and `SpecifierLen`. It looks like 
`startSpecifier` isn't used and the name can probably just be dropped.



Comment at: clang/lib/Sema/SemaChecking.cpp:436-437
+switch (FS.getConversionSpecifier().getKind()) {
+case analyze_format_string::ConversionSpecifier::pArg: // leading 0x
+  Size += 3;
+  break;

Why is size incremented by 3 here instead of 2 as above with a leading 0x?



Comment at: clang/lib/Sema/SemaChecking.cpp:448
+}
+Size -= specifierLen;
+return true;

Guard against wraparound?



Comment at: clang/lib/Sema/SemaChecking.cpp:489
+if (auto *Format = dyn_cast(FormatExpr)) {
+
+  if (!Format->isAscii() && !Format->isUTF8())

Spurious whitespace.



Comment at: clang/lib/Sema/SemaChecking.cpp:490
+
+  if (!Format->isAscii() && !Format->isUTF8())
+return;

We can handle UTF-8 format strings even when they contain non-ASCII characters?



Comment at: clang/lib/Sema/SemaChecking.cpp:8237
   H.DoneProcessing();
+
   } else if (Type == Sema::FST_Scanf) {

Spurious whitespace change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71566



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


[PATCH] D73007: [Sema] Avoid Wrange-loop-analysis false positives

2020-01-20 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a subscriber: hans.
xbolva00 added a comment.

Yes, but minimal fix is better for release branch, so @hans should merge it.

Handling your case probably needs more work and patches..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73007



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


[PATCH] D71698: [AArch64][SVE] Add intrinsic for non-faulting loads

2020-01-20 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 239144.
kmclaughlin added a comment.

- Some minor changes to performSignExtendInRegCombine to address comments from 
@sdesmalen


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

https://reviews.llvm.org/D71698

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll
@@ -0,0 +1,182 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
+
+define  @ldnf1b( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1b:
+; CHECK: ldnf1b { z0.b }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv16i8( %pg, i8* %a)
+  ret  %load
+}
+
+define  @ldnf1b_h( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1b_h:
+; CHECK: ldnf1b { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv8i8( %pg, i8* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sb_h( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1sb_h:
+; CHECK: ldnf1sb { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv8i8( %pg, i8* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1h( %pg, i16* %a) {
+; CHECK-LABEL: ldnf1h:
+; CHECK: ldnf1h { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv8i16( %pg, i16* %a)
+  ret  %load
+}
+
+define  @ldnf1h_f16( %pg, half* %a) {
+; CHECK-LABEL: ldnf1h_f16:
+; CHECK: ldnf1h { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv8f16( %pg, half* %a)
+  ret  %load
+}
+
+define  @ldnf1b_s( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1b_s:
+; CHECK: ldnf1b { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4i8( %pg, i8* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sb_s( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1sb_s:
+; CHECK: ldnf1sb { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4i8( %pg, i8* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1h_s( %pg, i16* %a) {
+; CHECK-LABEL: ldnf1h_s:
+; CHECK: ldnf1h { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4i16( %pg, i16* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sh_s( %pg, i16* %a) {
+; CHECK-LABEL: ldnf1sh_s:
+; CHECK: ldnf1sh { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4i16( %pg, i16* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1w( %pg, i32* %a) {
+; CHECK-LABEL: ldnf1w:
+; CHECK: ldnf1w { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4i32( %pg, i32* %a)
+  ret  %load
+}
+
+define  @ldnf1w_f32( %pg, float* %a) {
+; CHECK-LABEL: ldnf1w_f32:
+; CHECK: ldnf1w { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4f32( %pg, float* %a)
+  ret  %load
+}
+
+define  @ldnf1b_d( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1b_d:
+; CHECK: ldnf1b { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i8( %pg, i8* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sb_d( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1sb_d:
+; CHECK: ldnf1sb { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i8( %pg, i8* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1h_d( %pg, i16* %a) {
+; CHECK-LABEL: ldnf1h_d:
+; CHECK: ldnf1h { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i16( %pg, i16* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sh_d( %pg, i16* %a) {
+; CHECK-LABEL: ldnf1sh_d:
+; CHECK: ldnf1sh { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i16( %pg, i16* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1w_d( %pg, i32* %a) {
+; CHECK-LABEL: ldnf1w_d:
+; CHECK: ldnf1w { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i32( %pg, i32* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sw_d( %pg, i32* %a) {
+; CHECK-LABEL: ldnf1sw_d:
+; CHECK: ldnf1sw { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i32( %pg, i32* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1d( %pg, i64* %a) {
+; CHECK-LABEL: ldnf1d:
+; CHECK: ldnf1d { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i64( %pg, i64* %a)
+  ret  %load
+}
+
+define  @ldnf1d_f64( %pg, double* %a) {
+; CHECK-LABEL: ldnf1d_f64:
+; CHECK: ldnf1d { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve

[PATCH] D72932: [ARM] Follow AACPS standard for volatile bit-fields access width

2020-01-20 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard added a comment.

Why are you doing this in CodeGen, rather than adjusting the existing layout 
code in CGRecordLowering? Doing it this way will result in 
AdjustAAPCSBitfieldLValue being called for every access to the bitfield, rather 
than just once. This is probably more fragile too, because it's spreading the 
logic across multiple parts of the codebase, and has to undo some of the layout 
done by CGRecordLowering.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72932



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


[PATCH] D73052: [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

2020-01-20 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
njames93 retitled this revision from "First Draft" to "[clang-tidy] 
RenamerClangTidy now renames dependent member expr when the member can be 
resolved".
njames93 added reviewers: aaron.ballman, JonasToth, logan-5.
Herald added a subscriber: xazax.hun.
njames93 edited the summary of this revision.

take this code

  template
  class A{
int value;
A& operator=(const A& Other){
  value = Other.value;
  this->value = Other.value;
  return *this;
}
  };

Any explicit access to value is handled by the AST as a 
CXXDependentScopeMemberExpr. However we have enough information to be able to 
resolve that the explicit access is refering to `int value;`. The old behaviour 
of the RenamerClangTidy logic would be to ignore this access, This patch 
addresses this shortfall


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73052

Files:
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
@@ -134,4 +134,58 @@
 void foo() {
   Container container;
 }
-}; // namespace CtorInits
+} // namespace CtorInits
+
+namespace resolved_dependance {
+template 
+class A0 {
+  int value;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'value'
+  A0 &operator=(const A0 &Other) {
+value = Other.value;   // A0
+this->value = Other.value; // A0
+// CHECK-FIXES:  {{^}}Value = Other.Value;   // A0
+// CHECK-FIXES-NEXT: {{^}}this->Value = Other.Value; // A0
+return *this;
+  }
+};
+
+template 
+class A1 {
+  int value;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'value'
+  A1 &operator=(const A1 &Other) {
+value = Other.value;   // A1
+this->value = Other.value; // A1
+// CHECK-FIXES:  {{^}}Value = Other.Value;   // A1
+// CHECK-FIXES-NEXT: {{^}}this->Value = Other.Value; // A1
+return *this;
+  }
+};
+//create some instances to check it works
+A1 AInt{};
+A1 BInt = AInt;
+A1 AUnsigned{};
+A1 BUnsigned = AUnsigned;
+} //namespace resolved_dependance
+
+namespace unresolved_dependance {
+template 
+struct DependentBase {
+  int depValue;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'depValue'
+};
+
+template 
+struct Derived : DependentBase {
+  Derived &operator=(const Derived &Other) {
+this->depValue = Other.depValue;
+// CHECK-FIXES-NOT: {{^}}this->DepValue = Other.DepValue;
+return *this;
+  }
+};
+
+Derived AInt{};
+Derived BInt = AInt;
+
+} //namespace unresolved_dependance
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -91,6 +91,11 @@
 Changes in existing checks
 ^^
 
+- Improved :doc:'readability-identifier-naming
+  ` check.
+
+  Now able to rename member references in class template definitions with 
+  explicit access.
 
 Renamed checks
 ^^
Index: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -106,20 +106,22 @@
  this);
   Finder->addMatcher(typeLoc().bind("typeLoc"), this);
   Finder->addMatcher(nestedNameSpecifierLoc().bind("nestedNameLoc"), this);
+  auto MemberOrDependent =
+  expr(eachOf(memberExpr().bind("memberExpr"),
+  cxxDependentScopeMemberExpr().bind("depMemberExpr")));
   Finder->addMatcher(
   functionDecl(unless(cxxMethodDecl(isImplicit())),
-   hasBody(forEachDescendant(memberExpr().bind("memberExpr",
+   hasBody(forEachDescendant(MemberOrDependent))),
   this);
   Finder->addMatcher(
-  cxxConstructorDecl(
-  unless(isImplicit()),
-  forEachConstructorInitializer(
-  allOf(isWritten(), withInitializer(forEachDescendant(
- memberExpr().bind("memberExpr")),
+  cxxConstructorDecl(unless(isImplicit()),
+ forEachConstructorInitializer(allOf(
+ isWritten(), withInitializer(forEachDescendant(
+  MemberOrDependent),
+  this

[PATCH] D73052: [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

2020-01-20 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 239150.
njames93 added a comment.

- replace auto when type isnt explicit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73052

Files:
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
@@ -134,4 +134,58 @@
 void foo() {
   Container container;
 }
-}; // namespace CtorInits
+} // namespace CtorInits
+
+namespace resolved_dependance {
+template 
+class A0 {
+  int value;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'value'
+  A0 &operator=(const A0 &Other) {
+value = Other.value;   // A0
+this->value = Other.value; // A0
+// CHECK-FIXES:  {{^}}Value = Other.Value;   // A0
+// CHECK-FIXES-NEXT: {{^}}this->Value = Other.Value; // A0
+return *this;
+  }
+};
+
+template 
+class A1 {
+  int value;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'value'
+  A1 &operator=(const A1 &Other) {
+value = Other.value;   // A1
+this->value = Other.value; // A1
+// CHECK-FIXES:  {{^}}Value = Other.Value;   // A1
+// CHECK-FIXES-NEXT: {{^}}this->Value = Other.Value; // A1
+return *this;
+  }
+};
+//create some instances to check it works
+A1 AInt{};
+A1 BInt = AInt;
+A1 AUnsigned{};
+A1 BUnsigned = AUnsigned;
+} //namespace resolved_dependance
+
+namespace unresolved_dependance {
+template 
+struct DependentBase {
+  int depValue;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'depValue'
+};
+
+template 
+struct Derived : DependentBase {
+  Derived &operator=(const Derived &Other) {
+this->depValue = Other.depValue;
+// CHECK-FIXES-NOT: {{^}}this->DepValue = Other.DepValue;
+return *this;
+  }
+};
+
+Derived AInt{};
+Derived BInt = AInt;
+
+} //namespace unresolved_dependance
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -91,6 +91,11 @@
 Changes in existing checks
 ^^
 
+- Improved :doc:'readability-identifier-naming
+  ` check.
+
+  Now able to rename member references in class template definitions with 
+  explicit access.
 
 Renamed checks
 ^^
Index: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -106,20 +106,22 @@
  this);
   Finder->addMatcher(typeLoc().bind("typeLoc"), this);
   Finder->addMatcher(nestedNameSpecifierLoc().bind("nestedNameLoc"), this);
+  auto MemberOrDependent =
+  expr(eachOf(memberExpr().bind("memberExpr"),
+  cxxDependentScopeMemberExpr().bind("depMemberExpr")));
   Finder->addMatcher(
   functionDecl(unless(cxxMethodDecl(isImplicit())),
-   hasBody(forEachDescendant(memberExpr().bind("memberExpr",
+   hasBody(forEachDescendant(MemberOrDependent))),
   this);
   Finder->addMatcher(
-  cxxConstructorDecl(
-  unless(isImplicit()),
-  forEachConstructorInitializer(
-  allOf(isWritten(), withInitializer(forEachDescendant(
- memberExpr().bind("memberExpr")),
+  cxxConstructorDecl(unless(isImplicit()),
+ forEachConstructorInitializer(allOf(
+ isWritten(), withInitializer(forEachDescendant(
+  MemberOrDependent),
+  this);
+  Finder->addMatcher(
+  fieldDecl(hasInClassInitializer(forEachDescendant(MemberOrDependent))),
   this);
-  Finder->addMatcher(fieldDecl(hasInClassInitializer(
- forEachDescendant(memberExpr().bind("memberExpr",
- this);
 }
 
 void RenamerClangTidyCheck::registerPPCallbacks(
@@ -271,6 +273,29 @@
 return;
   }
 
+  if (const auto *DepMemberRef =
+  Result.Nodes.getNodeAs(
+  "depMemberExpr")) {
+QualType BaseType = DepMemberRef->isArrow()
+? DepMemberRef->getBaseType()->getPointeeType()
+: DepMemberRef->getBaseType();
+CXXRecordDecl *Base = BaseType.getTypePtr()->getAsCXXR

[PATCH] D72841: [RFC] Add support for pragma float_control, to control precision and exception behavior at the source level

2020-01-20 Thread Melanie Blower via Phabricator via cfe-commits
mibintc marked 2 inline comments as done.
mibintc added a comment.

Added inline reply




Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:111
 // the corresponding enum in the IR.
-static llvm::fp::RoundingMode ToConstrainedRoundingMD(
+llvm::fp::RoundingMode clang::ToConstrainedRoundingMD(
   LangOptions::FPRoundingModeKind Kind) {

sepavloff wrote:
> Is `clang::` necessary here? The file already has `using namespace clang;`.
Yes the clang:: is necessary here, without it there are undefined symbols at 
link time. the using modifies name lookup but not declaration. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841



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


[PATCH] D73052: [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

2020-01-20 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp:282
+: DepMemberRef->getBaseType();
+CXXRecordDecl *Base = BaseType.getTypePtr()->getAsCXXRecordDecl();
+if (!Base)

can `Base` be a `const` pointer?

In which case will this pointer be a `nullptr`? Your test-cases seem to 
exercise only cases where `Base` is not-null.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp:187
+};
+
+Derived AInt{};

Could you please provide a test-case with non-type template parameters as well?

Another question but maybe/most likely off topic: are how are member-pointers 
handled? Both for data and member-functions.
-> Maybe a test-case for such a situation would be good, as well? :)

Crème de la Crème would be if templated member-pointers are treated properly, 
too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73052



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


[clang-tools-extra] a42c3eb - [clang-tidy] Add check for CERT-OOP57-CPP

2020-01-20 Thread via cfe-commits

Author: Nathan
Date: 2020-01-20T17:09:03Z
New Revision: a42c3eb599cb3b83a07e6296d4ade213f1d74f0f

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

LOG: [clang-tidy] Add check for CERT-OOP57-CPP

Summary:
This is a very basic warning implementation of [[ 
https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP57-CPP.+Prefer+special+member+functions+and+overloaded+operators+to+C+Standard+Library+functions
 | Prefer special member functions and overloaded operators to C Standard 
Library functions ]]

It absolutely needs some fine tuning though.

Reviewers: alexfh, hokein, aaron.ballman, JonasToth

Reviewed By: aaron.ballman

Subscribers: merge_guards_bot, Eugene.Zelenko, mgorny, xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

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

Added: 
clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.h
clang-tools-extra/docs/clang-tidy/checks/cert-oop57-cpp.rst
clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp

Modified: 
clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
clang-tools-extra/clang-tidy/cert/CMakeLists.txt
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp 
b/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
index ab1fbbe94402..226526d31970 100644
--- a/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
@@ -25,6 +25,7 @@
 #include "FloatLoopCounter.h"
 #include "LimitedRandomnessCheck.h"
 #include "MutatingCopyCheck.h"
+#include "NonTrivialTypesLibcMemoryCallsCheck.h"
 #include "PostfixOperatorCheck.h"
 #include "ProperlySeededRandomGeneratorCheck.h"
 #include "SetLongJmpCheck.h"
@@ -73,6 +74,8 @@ class CERTModule : public ClangTidyModule {
 "cert-oop11-cpp");
 CheckFactories.registerCheck(
 "cert-oop54-cpp");
+CheckFactories.registerCheck(
+"cert-oop57-cpp");
 CheckFactories.registerCheck(
 "cert-oop58-cpp");
 

diff  --git a/clang-tools-extra/clang-tidy/cert/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/cert/CMakeLists.txt
index 66ea2a13acdd..91f329d2b034 100644
--- a/clang-tools-extra/clang-tidy/cert/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/cert/CMakeLists.txt
@@ -8,6 +8,7 @@ add_clang_library(clangTidyCERTModule
   FloatLoopCounter.cpp
   LimitedRandomnessCheck.cpp
   MutatingCopyCheck.cpp
+  NonTrivialTypesLibcMemoryCallsCheck.cpp
   PostfixOperatorCheck.cpp
   ProperlySeededRandomGeneratorCheck.cpp
   SetLongJmpCheck.cpp

diff  --git 
a/clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp 
b/clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
new file mode 100644
index ..a7bd38173eb0
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
@@ -0,0 +1,152 @@
+//===--- NonTrivialTypesLibcMemoryCallsCheck.cpp - clang-tidy --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "NonTrivialTypesLibcMemoryCallsCheck.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/Decl.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/ASTMatchers/ASTMatchersInternal.h"
+#include "clang/ASTMatchers/ASTMatchersMacros.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace cert {
+
+namespace {
+AST_MATCHER(CXXRecordDecl, isTriviallyDefaultConstructible) {
+  return Node.hasTrivialDefaultConstructor();
+}
+AST_MATCHER(CXXRecordDecl, isTriviallyCopyable) {
+  return Node.hasTrivialCopyAssignment() && Node.hasTrivialCopyConstructor();
+}
+AST_MATCHER_P(NamedDecl, hasAnyNameStdString, std::vector,
+  String) {
+  return ast_matchers::internal::HasNameMatcher(String).matchesNode(Node);
+}
+} // namespace
+
+static const char BuiltinMemSet[] = "::std::memset;"
+"::memset;";
+static const char BuiltinMemCpy[] = "::std::memcpy;"
+"::memcpy;"
+"::std::memmove;"
+"::memmove;"
+"::std::strcpy;"
+   

[PATCH] D72488: [clang-tidy] Add check for CERT-OOP57-CPP

2020-01-20 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa42c3eb599cb: [clang-tidy] Add check for CERT-OOP57-CPP 
(authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72488

Files:
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/clang-tidy/cert/CMakeLists.txt
  clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
  clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-oop57-cpp.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp
@@ -0,0 +1,90 @@
+// RUN: %check_clang_tidy %s cert-oop57-cpp %t -- \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: cert-oop57-cpp.MemSetNames, value: mymemset}, \
+// RUN:  {key: cert-oop57-cpp.MemCpyNames, value: mymemcpy}, \
+// RUN:  {key: cert-oop57-cpp.MemCmpNames, value: mymemcmp}]}' \
+// RUN: --
+
+void mymemset(void *, unsigned char, decltype(sizeof(int)));
+void mymemcpy(void *, const void *, decltype(sizeof(int)));
+int mymemcmp(const void *, const void *, decltype(sizeof(int)));
+
+namespace std {
+void memset(void *, unsigned char, decltype(sizeof(int)));
+void memcpy(void *, const void *, decltype(sizeof(int)));
+void memmove(void *, const void *, decltype(sizeof(int)));
+void strcpy(void *, const void *, decltype(sizeof(int)));
+int memcmp(const void *, const void *, decltype(sizeof(int)));
+int strcmp(const void *, const void *, decltype(sizeof(int)));
+} // namespace std
+
+struct Trivial {
+  int I;
+  int J;
+};
+
+struct NonTrivial {
+  int I;
+  int J;
+
+  NonTrivial() : I(0), J(0) {}
+  NonTrivial &operator=(const NonTrivial &Other) {
+I = Other.I;
+J = Other.J;
+return *this;
+  }
+
+  bool operator==(const Trivial &Other) const {
+return I == Other.I && J == Other.J;
+  }
+  bool operator!=(const Trivial &Other) const {
+return !(*this == Other);
+  }
+};
+
+void foo(const Trivial &Other) {
+  Trivial Data;
+  std::memset(&Data, 0, sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+  std::memset(&Data, 0, sizeof(Trivial));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+  std::memcpy(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'memcpy' on a non-trivially copyable class is undefined
+  std::memmove(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'memmove' on a non-trivially copyable class is undefined
+  std::strcpy(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'strcpy' on a non-trivially copyable class is undefined
+  std::memcmp(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: consider using comparison operators instead of calling 'memcmp'
+  std::strcmp(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: consider using comparison operators instead of calling 'strcmp'
+}
+
+void bar(const NonTrivial &Other) {
+  NonTrivial Data;
+  std::memset(&Data, 0, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+  // Check it detects sizeof(Type) as well as sizeof(Instantiation)
+  std::memset(&Data, 0, sizeof(NonTrivial));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+  std::memcpy(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memcpy' on a non-trivially copyable class is undefined
+  std::memmove(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memmove' on a non-trivially copyable class is undefined
+  std::strcpy(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'strcpy' on a non-trivially copyable class is undefined
+  std::memcmp(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: consider using comparison operators instead of calling 'memcmp'
+  std::strcmp(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: consider using comparison operators instead of calling 'strcmp'
+}
+
+void baz(const NonTrivial &Other) {
+  NonTrivial Data;
+  mymemset(&Data, 0, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'mymemset' on a non-trivially default constructible class is u

[PATCH] D71512: [clang-format] Fix short block when braking after control statement

2020-01-20 Thread Pablo Martin-Gomez via Phabricator via cfe-commits
Bouska marked an inline comment as done.
Bouska added inline comments.



Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:344
-  return MergedLines;
-}
 // Don't merge block with left brace wrapped after ObjC special blocks

MyDeveloperDay wrote:
> I just can't understand how we are free to just remove a chunk of code. Why 
> is this not being some sort of 
> 
> 
> ```
> if (Style.AllowShortBlocksOnASingleLine)
> ```
> 
> You are just not giving a convincing argument that this is a safe change 
> without us having to go in a debug the original problem ourselves.
This chunk of code only provides a bogus formatting and nothing else. So in 
order to fix the bug, I need to remove the whole block of code.

I wasn't clear on why this chunk of code created the bug, so let me explained. 
Let's take an example:
```
if (true)
{
doStuff();
}
```
with //Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Always// 
and //Style.AllowShortBlocksOnASingleLine != FormatStyle::SBS_Never//.

When formatting the first line, the control statement @ line 308 is going to 
fail (because //Style.BraceWrapping.AfterControlStatement != 
FormatStyle::BWACS_Always//) but the control statement @ line 322 is going to 
pass (because the second line is a left brace and the first token of the line 
is a //if//). As //Style.BraceWrapping.AfterControlStatement == 
FormatStyle::BWACS_Always//, //tryMergeSimpleBlock()// is going to handle the 
merging. There is two possible outcomes : either the block is simple and not 
too long and it can be merge in one line, or it is not and the whole block 
stays as it is. That line is then considered formated (due to the //return//).

When formatting the second line, the control statement @ line 332 (because the 
first and only token of the line is a left brace and the first token of the 
first line is a //if//) is going to pass and 
//Style.AllowShortBlocksOnASingleLine != FormatStyle::SBS_Never//, so we are 
going to redo //tryMergeSimpleBlock()// on the first line which failed the 
first time! So this is the part I understand, we are doing someting we already 
did. The part I don't understand is that this time //tryMergeSimpleBlock()// 
managed to merge the line (probably because of some changes on the annoted 
first line). As the merging worked, //MergedLines > 0// @ line 340 is true so 
//MergedLines// is decremented (as explained by the comment) and we end up with 
the block merged but without the control statement:
 ```
if (true)
{ doStuff(); }
```
Which is not the expected formating.

I think there might be another bug hidden somewhere in 
//tryMergeSimpleBlock()//.


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

https://reviews.llvm.org/D71512



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


[PATCH] D73052: [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

2020-01-20 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

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

{icon question-circle color=gray} clang-tidy: unknown.

{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-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73052



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


[PATCH] D72488: [clang-tidy] Add check for CERT-OOP57-CPP

2020-01-20 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 239153.
njames93 added a comment.

- rebase truck


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72488

Files:
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/clang-tidy/cert/CMakeLists.txt
  clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
  clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-oop57-cpp.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp
@@ -0,0 +1,90 @@
+// RUN: %check_clang_tidy %s cert-oop57-cpp %t -- \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: cert-oop57-cpp.MemSetNames, value: mymemset}, \
+// RUN:  {key: cert-oop57-cpp.MemCpyNames, value: mymemcpy}, \
+// RUN:  {key: cert-oop57-cpp.MemCmpNames, value: mymemcmp}]}' \
+// RUN: --
+
+void mymemset(void *, unsigned char, decltype(sizeof(int)));
+void mymemcpy(void *, const void *, decltype(sizeof(int)));
+int mymemcmp(const void *, const void *, decltype(sizeof(int)));
+
+namespace std {
+void memset(void *, unsigned char, decltype(sizeof(int)));
+void memcpy(void *, const void *, decltype(sizeof(int)));
+void memmove(void *, const void *, decltype(sizeof(int)));
+void strcpy(void *, const void *, decltype(sizeof(int)));
+int memcmp(const void *, const void *, decltype(sizeof(int)));
+int strcmp(const void *, const void *, decltype(sizeof(int)));
+} // namespace std
+
+struct Trivial {
+  int I;
+  int J;
+};
+
+struct NonTrivial {
+  int I;
+  int J;
+
+  NonTrivial() : I(0), J(0) {}
+  NonTrivial &operator=(const NonTrivial &Other) {
+I = Other.I;
+J = Other.J;
+return *this;
+  }
+
+  bool operator==(const Trivial &Other) const {
+return I == Other.I && J == Other.J;
+  }
+  bool operator!=(const Trivial &Other) const {
+return !(*this == Other);
+  }
+};
+
+void foo(const Trivial &Other) {
+  Trivial Data;
+  std::memset(&Data, 0, sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+  std::memset(&Data, 0, sizeof(Trivial));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+  std::memcpy(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'memcpy' on a non-trivially copyable class is undefined
+  std::memmove(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'memmove' on a non-trivially copyable class is undefined
+  std::strcpy(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'strcpy' on a non-trivially copyable class is undefined
+  std::memcmp(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: consider using comparison operators instead of calling 'memcmp'
+  std::strcmp(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: consider using comparison operators instead of calling 'strcmp'
+}
+
+void bar(const NonTrivial &Other) {
+  NonTrivial Data;
+  std::memset(&Data, 0, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+  // Check it detects sizeof(Type) as well as sizeof(Instantiation)
+  std::memset(&Data, 0, sizeof(NonTrivial));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+  std::memcpy(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memcpy' on a non-trivially copyable class is undefined
+  std::memmove(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memmove' on a non-trivially copyable class is undefined
+  std::strcpy(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'strcpy' on a non-trivially copyable class is undefined
+  std::memcmp(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: consider using comparison operators instead of calling 'memcmp'
+  std::strcmp(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: consider using comparison operators instead of calling 'strcmp'
+}
+
+void baz(const NonTrivial &Other) {
+  NonTrivial Data;
+  mymemset(&Data, 0, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'mymemset' on a non-trivially default constructible class is undefined
+  mymemcpy(&Data, &Other, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]

[PATCH] D44609: [Clang-Format] New option BeforeLambdaBody to manage lambda line break inside function parameter call (in Allman style)

2020-01-20 Thread Francois JEAN via Phabricator via cfe-commits
Wawha marked 2 inline comments as done.
Wawha added a comment.

Hello,
@klimek will you have time to review this patch? The current patch integrate 
the last remarks and also modification due to inline lambda.




Comment at: lib/Format/ContinuationIndenter.cpp:1179
+   Current.is(TT_LambdaLSquare;
   }
 

MyDeveloperDay wrote:
> oh boy... I have to say.. that I don't like these kinds of massive if 
> statements without some sort of comment.. as to what it's doing, it's so 
> hard, later on, to read through the various clauses and understand which bit 
> of functionality this section covers
I make some change in the last patch. Hope it's better.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D44609



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


[PATCH] D73052: [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

2020-01-20 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

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

{icon question-circle color=gray} clang-tidy: unknown.

{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-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73052



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


[PATCH] D62445: [test] Fix plugin tests

2020-01-20 Thread Mikhail Ramalho via Phabricator via cfe-commits
mikhail.ramalho added a comment.
Herald added a subscriber: Charusso.

Hi, I just found this revision.

Could you point out how can I run the CSA tests with Z3 as backend? We used to 
do `$ ninja check-clang-analyzer-z3`, however, it now fails and suggests:

   $ ninja check-clang-analyzer-z3
  ninja: error: unknown target 'check-clang-analyzer-z3', did you mean 
'check-clang-analysis-z3'?

`check-clang-analysis-z3` only runs one test though.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62445



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


[PATCH] D72488: [clang-tidy] Add check for CERT-OOP57-CPP

2020-01-20 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

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

{icon question-circle color=gray} clang-tidy: unknown.

{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-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72488



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


[PATCH] D73007: [Sema] Avoid Wrange-loop-analysis false positives

2020-01-20 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D73007#1829709 , @xbolva00 wrote:

> Yes, but minimal fix is better for release branch, so @hans should merge it.


I think `-Wall` shouldn't warn about reference types in a range-based for loop 
(unless it's the wrong type and inadvertently creates a copy).

> Handling your case probably needs more work and patches..

See my inline comments. The bug in itself is not terribly troublesome, this 
issue has existed in many previous releases. The problem is that the warning is 
now in `-Wall`, and I think we should be more conservative in `-Wall`.




Comment at: clang/lib/Sema/SemaStmt.cpp:2703-2704
 // suggest the const reference type that would do so.
 // For instance, given "for (const &Foo : Range)", suggest
 // "for (const Foo : Range)" to denote a copy is made for the loop.  If
 // possible, also suggest "for (const &Bar : Range)" if this type prevents

That's the part the bothers me.



Comment at: clang/lib/Sema/SemaStmt.cpp:2768-2778
 // The range always returns a copy, so a temporary is always created.
 // Suggest removing the reference from the loop variable.
 // If the type is a rvalue reference do not warn since that changes the
 // semantic of the code.
 SemaRef.Diag(VD->getLocation(), diag::warn_for_range_variable_always_copy)
 << VD << RangeInitType;
 QualType NonReferenceType = VariableType.getNonReferenceType();

We could either remove this part or group `warn_for_range_variable_always_copy` 
under a separate flag that's not in `-Wall`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73007



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


[PATCH] D72675: [Clang][Driver] Fix -ffast-math/-ffp-contract interaction

2020-01-20 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

I've had a quick look at GCC, and it seems there's a couple of different issues.

First of all, `-ffast-math` is a "collective" flag that has no separate meaning 
except setting a bunch of other flags.  Currently, these flags are:  
`-fno-math-errno`, ` -funsafe-math-optimizations` (which is itself a collective 
flag enabling `-fno-signed-zeros`, `-fno-trapping-math`, `-fassociative-math`, 
and `-freciprocal-math`),  `-ffinite-math-only`, `-fno-rounding-math`, 
`-fno-signaling-nans`, `-fcx-limited-range`, and  `-fexcess-precision=fast`.

When deciding whether to define `__FAST_MATH__`, GCC will not specifically look 
at whether or not the -ffast-math option itself was given, but whether the 
status of those other flags matches what would have been set by -ffast-math.  
However, it does not include all of the flags; currently only `-fmath-errno`, 
`-funsafe-math-optimizations`, `-fsigned-zeros`, `-ftrapping-math`, 
`-ffinite-math-only`,  and `-fexcess-precision` are checked, while 
`-fassociative-math`, `-freciprocal-math`, `-frounding-math`, 
`-fsignaling-nans`, and `-fcx-limited-range` are ignored.

I'm not sure whether this is deliberate (but it seems weird) or just a bug.  I 
can ask the GCC developers ...

A separate question is the interaction of `-ffast-math` with `-ffp-contract=`.  
Currently, there is no such interaction whatsoever in GCC: `-ffast-math` does 
not imply any particular `-ffp-contract=` setting, and vice versa the 
`-ffp-contract=` setting is not considered at all when defining 
`__FAST_MATH__`.  This seems at least internally consistent.


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

https://reviews.llvm.org/D72675



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


[PATCH] D71512: [clang-format] Fix short block when braking after control statement

2020-01-20 Thread Pablo Martin-Gomez via Phabricator via cfe-commits
Bouska marked an inline comment as done.
Bouska added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:662
"{\n"
-   "  ff();\n"
"}",

MyDeveloperDay wrote:
> I'm just not comfortable with changing tests, code can still be written in 
> the way it was before, and I cannot tell what it would now be, I believe 
> tests should be additive
Ok, I'll keep the original test and add two new ones.


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

https://reviews.llvm.org/D71512



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


[PATCH] D73056: [clangd] Fix DocumentOutline for concepts

2020-01-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: kbobyrev.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Fixes https://github.com/clangd/clangd/issues/256


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73056

Files:
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp


Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -449,6 +449,15 @@
 SymNameRange(Main.range("def");
 }
 
+TEST_F(DocumentSymbolsTest, Concepts) {
+  CDB.ExtraClangFlags = {"-std=c++2a"};
+  std::string FilePath = testPath("foo.cpp");
+  addFile(FilePath,
+  "template  concept C = requires(T t) { t.foo(); };");
+
+  EXPECT_THAT(getSymbols(FilePath), ElementsAre(WithName("C")));
+}
+
 TEST_F(DocumentSymbolsTest, ExternSymbol) {
   std::string FilePath = testPath("foo.cpp");
   addFile(testPath("foo.h"), R"cpp(
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -193,8 +193,11 @@
   enum class VisitKind { No, OnlyDecl, DeclAndChildren };
 
   void traverseDecl(Decl *D, std::vector &Results) {
-if (auto *Templ = llvm::dyn_cast(D))
-  D = Templ->getTemplatedDecl();
+if (auto *Templ = llvm::dyn_cast(D)) {
+  // TemplatedDecl might be null, e.g. concepts.
+  if (auto *TD = Templ->getTemplatedDecl())
+D = TD;
+}
 auto *ND = llvm::dyn_cast(D);
 if (!ND)
   return;


Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -449,6 +449,15 @@
 SymNameRange(Main.range("def");
 }
 
+TEST_F(DocumentSymbolsTest, Concepts) {
+  CDB.ExtraClangFlags = {"-std=c++2a"};
+  std::string FilePath = testPath("foo.cpp");
+  addFile(FilePath,
+  "template  concept C = requires(T t) { t.foo(); };");
+
+  EXPECT_THAT(getSymbols(FilePath), ElementsAre(WithName("C")));
+}
+
 TEST_F(DocumentSymbolsTest, ExternSymbol) {
   std::string FilePath = testPath("foo.cpp");
   addFile(testPath("foo.h"), R"cpp(
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -193,8 +193,11 @@
   enum class VisitKind { No, OnlyDecl, DeclAndChildren };
 
   void traverseDecl(Decl *D, std::vector &Results) {
-if (auto *Templ = llvm::dyn_cast(D))
-  D = Templ->getTemplatedDecl();
+if (auto *Templ = llvm::dyn_cast(D)) {
+  // TemplatedDecl might be null, e.g. concepts.
+  if (auto *TD = Templ->getTemplatedDecl())
+D = TD;
+}
 auto *ND = llvm::dyn_cast(D);
 if (!ND)
   return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72557: Add pretty printers for llvm::PointerIntPair and llvm::PointerUnion.

2020-01-20 Thread Christian Sigg via Phabricator via cfe-commits
csigg updated this revision to Diff 239160.
csigg added a comment.
Herald added a subscriber: wuzish.

Fix base. I'm so terrible at this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72557

Files:
  debuginfo-tests/llvm-prettyprinters/gdb/prettyprinters.cpp
  debuginfo-tests/llvm-prettyprinters/gdb/prettyprinters.gdb
  llvm/include/llvm/ADT/PointerIntPair.h
  llvm/utils/gdb-scripts/prettyprinters.py

Index: llvm/utils/gdb-scripts/prettyprinters.py
===
--- llvm/utils/gdb-scripts/prettyprinters.py
+++ llvm/utils/gdb-scripts/prettyprinters.py
@@ -2,6 +2,7 @@
 import sys
 
 import gdb.printing
+import gdb.types
 
 class Iterator:
   def __iter__(self):
@@ -315,6 +316,51 @@
   def to_string(self):
 return self.string_from_twine_object(self._val)
 
+def make_printer(string = None, children = None, hint = None):
+  """Create a printer from the parameters."""
+  class Printer : pass
+  printer = Printer()
+  if string:
+setattr(printer, 'to_string', lambda: string)
+  if children:
+setattr(printer, 'children', lambda: children)
+  if hint:
+setattr(printer, 'display_hint', lambda: hint)
+  return printer
+
+def get_pointer_int_pair(val):
+  """Get iterable with zero or single tuple from llvm::PointerIntPair."""
+  info_name = val.type.template_argument(4).strip_typedefs().name
+  try:
+enum_type = gdb.lookup_type(info_name + '::MaskAndShiftConstants')
+  except gdb.error:
+return
+  enum_dict = gdb.types.make_enum_dict(enum_type)
+  ptr_mask = enum_dict[info_name + '::PointerBitMask']
+  int_shift = enum_dict[info_name + '::IntShift']
+  int_mask = enum_dict[info_name + '::IntMask']
+  pair_union = val['Value']
+  pointer = (pair_union & ptr_mask)
+  value = ((pair_union >> int_shift) & int_mask)
+  yield (pointer, value)
+
+def make_pointer_int_pair_printer(val):
+  """Factory for an llvm::PointerIntPair printer."""
+  for (pointer, value) in get_pointer_int_pair(val):
+pointer_type = val.type.template_argument(0)
+value_type = val.type.template_argument(2)
+string = 'llvm::PointerIntPair<%s>' % pointer_type
+children = [('pointer', pointer.cast(pointer_type)), 
+('value', value.cast(value_type))]
+return make_printer(string, children)
+
+def make_pointer_union_printer(val):
+  """Factory for an llvm::PointerUnion printer."""
+  for (pointer, value) in get_pointer_int_pair(val['Val']):
+pointer_type = val.type.template_argument(int(value))
+string = 'llvm::PointerUnion containing %s' % pointer_type
+return make_printer(string, [('pointer', pointer.cast(pointer_type))])
+
 pp = gdb.printing.RegexpCollectionPrettyPrinter("LLVMSupport")
 pp.add_printer('llvm::SmallString', '^llvm::SmallString<.*>$', SmallStringPrinter)
 pp.add_printer('llvm::StringRef', '^llvm::StringRef$', StringRefPrinter)
@@ -324,4 +370,6 @@
 pp.add_printer('llvm::Optional', '^llvm::Optional<.*>$', OptionalPrinter)
 pp.add_printer('llvm::DenseMap', '^llvm::DenseMap<.*>$', DenseMapPrinter)
 pp.add_printer('llvm::Twine', '^llvm::Twine$', TwinePrinter)
+pp.add_printer('llvm::PointerIntPair', '^llvm::PointerIntPair<.*>$', make_pointer_int_pair_printer)
+pp.add_printer('llvm::PointerUnion', '^llvm::PointerUnion<.*>$', make_pointer_union_printer)
 gdb.printing.register_pretty_printer(gdb.current_objfile(), pp)
Index: llvm/include/llvm/ADT/PointerIntPair.h
===
--- llvm/include/llvm/ADT/PointerIntPair.h
+++ llvm/include/llvm/ADT/PointerIntPair.h
@@ -147,7 +147,7 @@
 "cannot use a pointer type that has all bits free");
   static_assert(IntBits <= PtrTraits::NumLowBitsAvailable,
 "PointerIntPair with integer size too large for pointer");
-  enum : uintptr_t {
+  enum MaskAndShiftConstants : uintptr_t {
 /// PointerBitMask - The bits that come from the pointer.
 PointerBitMask =
 ~(uintptr_t)(((intptr_t)1 << PtrTraits::NumLowBitsAvailable) - 1),
Index: debuginfo-tests/llvm-prettyprinters/gdb/prettyprinters.gdb
===
--- debuginfo-tests/llvm-prettyprinters/gdb/prettyprinters.gdb
+++ debuginfo-tests/llvm-prettyprinters/gdb/prettyprinters.gdb
@@ -39,3 +39,10 @@
 # CHECK: "\"foo\"\"bar\""
 p Twine
 
+# CHECK: llvm::PointerIntPair = {pointer = 0xabc, value = 1}
+p PointerIntPair
+
+# CHECK: llvm::PointerUnion containing int * = {pointer = 0xabc}
+p PointerUnion
+
+
Index: debuginfo-tests/llvm-prettyprinters/gdb/prettyprinters.cpp
===
--- debuginfo-tests/llvm-prettyprinters/gdb/prettyprinters.cpp
+++ debuginfo-tests/llvm-prettyprinters/gdb/prettyprinters.cpp
@@ -1,12 +1,15 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/PointerIntPair.h"
+#

[PATCH] D72557: Add pretty printers for llvm::PointerIntPair and llvm::PointerUnion.

2020-01-20 Thread Christian Sigg via Phabricator via cfe-commits
csigg added a comment.

Hi David. Thanks a lot for you review. I did another pass to switch to factory 
methods that catch exceptions without spewing common errors on the GDB console. 
Would you mind taking another quick peek? Thanks a lot for your patience!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72557



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


[PATCH] D73056: [clangd] Fix DocumentOutline for concepts

2020-01-20 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

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

{icon question-circle color=gray} clang-tidy: unknown.

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

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



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73056



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


[PATCH] D72675: [Clang][Driver] Fix -ffast-math/-ffp-contract interaction

2020-01-20 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

> I'm not sure whether this is deliberate (but it seems weird) or just a bug. I 
> can ask the GCC developers ...

Please do. If there's a rationale, we should know.


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

https://reviews.llvm.org/D72675



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


[PATCH] D73052: [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

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

- Added not type template test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73052

Files:
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
@@ -134,4 +134,86 @@
 void foo() {
   Container container;
 }
-}; // namespace CtorInits
+} // namespace CtorInits
+
+namespace resolved_dependance {
+template 
+struct A0 {
+  int value;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'value'
+  A0 &operator=(const A0 &Other) {
+value = Other.value;   // A0
+this->value = Other.value; // A0
+// CHECK-FIXES:  {{^}}Value = Other.Value;   // A0
+// CHECK-FIXES-NEXT: {{^}}this->Value = Other.Value; // A0
+return *this;
+  }
+  void outOfLineReset();
+};
+
+template 
+void A0::outOfLineReset() {
+  this->value -= value; // A0
+  // CHECK-FIXES: {{^}}  this->Value -= Value; // A0
+}
+
+template 
+struct A1 {
+  int value;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'value'
+  A1 &operator=(const A1 &Other) {
+value = Other.value;   // A1
+this->value = Other.value; // A1
+// CHECK-FIXES:  {{^}}Value = Other.Value;   // A1
+// CHECK-FIXES-NEXT: {{^}}this->Value = Other.Value; // A1
+return *this;
+  }
+  void outOfLineReset();
+};
+
+template 
+void A1::outOfLineReset() {
+  this->value -= value; // A1
+  // CHECK-FIXES: {{^}}  this->Value -= Value; // A1
+}
+
+template 
+struct A2 {
+  int value;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'value'
+  A2 &operator=(const A2 &Other) {
+value = Other.value;   // A2
+this->value = Other.value; // A2
+// CHECK-FIXES:  {{^}}Value = Other.Value;   // A2
+// CHECK-FIXES-NEXT: {{^}}this->Value = Other.Value; // A2
+return *this;
+  }
+};
+
+//create some instances to check it works
+A1 AInt{};
+A1 BInt = (AInt.outOfLineReset(), AInt);
+A1 AUnsigned{};
+A1 BUnsigned = AUnsigned;
+} //namespace resolved_dependance
+
+namespace unresolved_dependance {
+template 
+struct DependentBase {
+  int depValue;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'depValue'
+};
+
+template 
+struct Derived : DependentBase {
+  Derived &operator=(const Derived &Other) {
+this->depValue = Other.depValue;
+// CHECK-FIXES-NOT: {{^}}this->DepValue = Other.DepValue;
+return *this;
+  }
+};
+
+Derived AInt{};
+Derived BInt = AInt;
+
+} //namespace unresolved_dependance
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -97,6 +97,11 @@
 Changes in existing checks
 ^^
 
+- Improved :doc:'readability-identifier-naming
+  ` check.
+
+  Now able to rename member references in class template definitions with 
+  explicit access.
 
 Renamed checks
 ^^
Index: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -106,20 +106,22 @@
  this);
   Finder->addMatcher(typeLoc().bind("typeLoc"), this);
   Finder->addMatcher(nestedNameSpecifierLoc().bind("nestedNameLoc"), this);
+  auto MemberOrDependent =
+  expr(eachOf(memberExpr().bind("memberExpr"),
+  cxxDependentScopeMemberExpr().bind("depMemberExpr")));
   Finder->addMatcher(
   functionDecl(unless(cxxMethodDecl(isImplicit())),
-   hasBody(forEachDescendant(memberExpr().bind("memberExpr",
+   hasBody(forEachDescendant(MemberOrDependent))),
   this);
   Finder->addMatcher(
-  cxxConstructorDecl(
-  unless(isImplicit()),
-  forEachConstructorInitializer(
-  allOf(isWritten(), withInitializer(forEachDescendant(
- memberExpr().bind("memberExpr")),
+  cxxConstructorDecl(unless(isImplicit()),
+ forEachConstructorInitializer(allOf(
+ isWritten(), withInitializer(forEachDescendant(
+   

[PATCH] D73052: [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

2020-01-20 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp:282
+: DepMemberRef->getBaseType();
+CXXRecordDecl *Base = BaseType.getTypePtr()->getAsCXXRecordDecl();
+if (!Base)

JonasToth wrote:
> can `Base` be a `const` pointer?
> 
> In which case will this pointer be a `nullptr`? Your test-cases seem to 
> exercise only cases where `Base` is not-null.
Base can be a const pointer. However I don't think it can be a nullptr, but I 
put the check in there just in case it ever is, maybe an assert would be the 
correct solution.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp:187
+};
+
+Derived AInt{};

JonasToth wrote:
> Could you please provide a test-case with non-type template parameters as 
> well?
> 
> Another question but maybe/most likely off topic: are how are member-pointers 
> handled? Both for data and member-functions.
> -> Maybe a test-case for such a situation would be good, as well? :)
> 
> Crème de la Crème would be if templated member-pointers are treated properly, 
> too.
The test for non-type isn't strictly needed. in these test cases the template 
type isn't used but they still show up as dependent scope exprs. 

MemberPointers is something that this doesn't handle and probably something I 
wont add as you can have issues with specialisation meaning the member may not 
exist in a specialization 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73052



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


[PATCH] D72488: [clang-tidy] Add check for CERT-OOP57-CPP

2020-01-20 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/clang-tidy/checks/cert-oop57-cpp.rst:25
+   Default is an empty string.
+   The check will detect the following functions:
+   `std::memcpy`, `memcpy`, `std::memmove`, `memmove`, `std::strcpy`,

This should be in general documentation, not in option. Please enclose function 
names in double back-ticks.

Same for other similar statements below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72488



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


[PATCH] D72897: List implicit operator== after implicit destructors in a vtable.

2020-01-20 Thread Peter Smith via Phabricator via cfe-commits
peter.smith added a comment.

It is also failing on the other 32-bit arm bots, example 
http://lab.llvm.org:8011/builders/clang-cmake-armv7-quick/builds/13052/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Avirtual-compare.cpp
Looking at the failure

  // CHECK-SAME: @_ZThn8_N1AD1Ev 

and the output on an Arm machine

  $_ZThn4_N1AD1Ev = comdat any
  
  $_ZThn4_N1AD0Ev = comdat any
  
  $_ZThn4_N1AaSERKS_ = comdat any

It might be a 32-bit/64-bit specific expectation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72897



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


[PATCH] D68720: Support -fstack-clash-protection for x86

2020-01-20 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 239166.
serge-sans-paille added a comment.

- Harmonize esp/rsp usage as hinted by @craig.topper
- Fix argument detection


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68720

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/stack-clash-protection.c
  clang/test/Driver/stack-clash-protection.c
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/Target/X86/X86CallFrameOptimization.cpp
  llvm/lib/Target/X86/X86FrameLowering.cpp
  llvm/lib/Target/X86/X86FrameLowering.h
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.h
  llvm/lib/Target/X86/X86InstrCompiler.td
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/test/CodeGen/X86/stack-clash-dynamic-alloca.ll
  llvm/test/CodeGen/X86/stack-clash-large.ll
  llvm/test/CodeGen/X86/stack-clash-medium-natural-probes-mutliple-objects.ll
  llvm/test/CodeGen/X86/stack-clash-medium-natural-probes.ll
  llvm/test/CodeGen/X86/stack-clash-medium.ll
  llvm/test/CodeGen/X86/stack-clash-no-free-probe.ll
  llvm/test/CodeGen/X86/stack-clash-small.ll
  llvm/test/CodeGen/X86/stack-clash-unknown-call.ll

Index: llvm/test/CodeGen/X86/stack-clash-unknown-call.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/stack-clash-unknown-call.ll
@@ -0,0 +1,31 @@
+; RUN: llc < %s | FileCheck %s
+
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1 immarg);
+
+define void @foo() local_unnamed_addr #0 {
+
+;CHECK-LABEL: foo:
+;CHECK: # %bb.0:
+;CHECK-NEXT:	subq	$4096, %rsp # imm = 0x1000
+; it's important that we don't use the call as a probe here
+;CHECK-NEXT:	movq	$0, (%rsp)
+;CHECK-NEXT:	subq	$3912, %rsp # imm = 0xF48
+;CHECK-NEXT:	.cfi_def_cfa_offset 8016
+;CHECK-NEXT:	movq	%rsp, %rdi
+;CHECK-NEXT:	movl	$8000, %edx # imm = 0x1F40
+;CHECK-NEXT:	xorl	%esi, %esi
+;CHECK-NEXT:	callq	memset
+;CHECK-NEXT:	addq	$8008, %rsp # imm = 0x1F48
+;CHECK-NEXT:	.cfi_def_cfa_offset 8
+;CHECK-NEXT:	retq
+
+  %a = alloca i8, i64 8000, align 16
+  call void @llvm.memset.p0i8.i64(i8* align 16 %a, i8 0, i64 8000, i1 false)
+  ret void
+}
+
+attributes #0 =  {"probe-stack"="inline-asm"}
Index: llvm/test/CodeGen/X86/stack-clash-small.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/stack-clash-small.ll
@@ -0,0 +1,25 @@
+; RUN: llc < %s | FileCheck %s
+
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @foo() local_unnamed_addr #0 {
+; CHECK-LABEL: foo:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:  subq	$280, %rsp # imm = 0x118
+; CHECK-NEXT:  .cfi_def_cfa_offset 288
+; CHECK-NEXT:  movl	$1, 264(%rsp)
+; CHECK-NEXT:  movl	-128(%rsp), %eax
+; CHECK-NEXT:  addq	$280, %rsp # imm = 0x118
+; CHECK-NEXT:  .cfi_def_cfa_offset 8
+; CHECK-NEXT:  retq
+
+  %a = alloca i32, i64 100, align 16
+  %b = getelementptr inbounds i32, i32* %a, i64 98
+  store volatile i32 1, i32* %b
+  %c = load volatile i32, i32* %a
+  ret i32 %c
+}
+
+attributes #0 =  {"probe-stack"="inline-asm"}
Index: llvm/test/CodeGen/X86/stack-clash-no-free-probe.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/stack-clash-no-free-probe.ll
@@ -0,0 +1,27 @@
+; RUN: llc < %s | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @foo(i64 %i) local_unnamed_addr #0 {
+; CHECK-LABEL: foo:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:  subq	$4096, %rsp # imm = 0x1000
+; CHECK-NEXT:  movq	$0, (%rsp)
+; CHECK-NEXT:  subq	$3784, %rsp # imm = 0xEC8
+; CHECK-NEXT:  .cfi_def_cfa_offset 7888
+; CHECK-NEXT:  movl	$1, -128(%rsp,%rdi,4)
+; CHECK-NEXT:  movl	-128(%rsp), %eax
+; CHECK-NEXT:  addq	$7880, %rsp # imm = 0x1EC8
+; CHECK-NEXT:  .cfi_def_cfa_offset 8
+; CHECK-NEXT:  retq
+
+  %a = alloca i32, i32 2000, align 16
+  %b = getelementptr inbounds i32, i32* %a, i64 %i
+  store volatile i32 1, i32* %b
+  %c = load volatile i32, i32* %a
+  ret i32 %c
+}
+
+attributes #0 =  {"probe-stack"="inline-asm"}
+
Index: llvm/test/CodeGen/X86/stack-clash-medium.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/stack-clash-medium.ll
@@ -0

LLVM buildmaster will be updated and restarted tonight

2020-01-20 Thread Galina Kistanova via cfe-commits
 Hello everyone,

LLVM buildmaster will be updated and restarted after 5PM Pacific time today.

Thanks

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


[PATCH] D73052: [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

2020-01-20 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

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

{icon question-circle color=gray} clang-tidy: unknown.

{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-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73052



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


[PATCH] D73056: [clangd] Fix DocumentOutline for concepts

2020-01-20 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev accepted this revision.
kbobyrev 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/D73056/new/

https://reviews.llvm.org/D73056



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


[clang-tools-extra] fb3d915 - [clangd] Fix DocumentOutline for concepts

2020-01-20 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-01-20T20:20:27+01:00
New Revision: fb3d9153c01b9a560680465190d6ecd804e4c486

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

LOG: [clangd] Fix DocumentOutline for concepts

Summary: Fixes https://github.com/clangd/clangd/issues/256

Reviewers: kbobyrev

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/FindSymbols.cpp
clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FindSymbols.cpp 
b/clang-tools-extra/clangd/FindSymbols.cpp
index 4c92c8896b9d..1ce4222b5764 100644
--- a/clang-tools-extra/clangd/FindSymbols.cpp
+++ b/clang-tools-extra/clangd/FindSymbols.cpp
@@ -193,8 +193,11 @@ class DocumentOutline {
   enum class VisitKind { No, OnlyDecl, DeclAndChildren };
 
   void traverseDecl(Decl *D, std::vector &Results) {
-if (auto *Templ = llvm::dyn_cast(D))
-  D = Templ->getTemplatedDecl();
+if (auto *Templ = llvm::dyn_cast(D)) {
+  // TemplatedDecl might be null, e.g. concepts.
+  if (auto *TD = Templ->getTemplatedDecl())
+D = TD;
+}
 auto *ND = llvm::dyn_cast(D);
 if (!ND)
   return;

diff  --git a/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp 
b/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
index 8eebb190edae..eba920a7a452 100644
--- a/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -449,6 +449,15 @@ TEST_F(DocumentSymbolsTest, DeclarationDefinition) {
 SymNameRange(Main.range("def");
 }
 
+TEST_F(DocumentSymbolsTest, Concepts) {
+  CDB.ExtraClangFlags = {"-std=c++2a"};
+  std::string FilePath = testPath("foo.cpp");
+  addFile(FilePath,
+  "template  concept C = requires(T t) { t.foo(); };");
+
+  EXPECT_THAT(getSymbols(FilePath), ElementsAre(WithName("C")));
+}
+
 TEST_F(DocumentSymbolsTest, ExternSymbol) {
   std::string FilePath = testPath("foo.cpp");
   addFile(testPath("foo.h"), R"cpp(



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


[PATCH] D73060: [Clang] Fix expansion of response files in -Wp after integrated-cc1 change

2020-01-20 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea created this revision.
aganea added reviewers: hans, thakis, wenlei.
aganea added a project: clang.
Herald added a subscriber: cfe-commits.
aganea edited the summary of this revision.

After rGb4a99a061f517e60985667e39519f60186cbb469 
, passing 
a response file such as `-Wp,@a.rsp` wasn't working anymore because .rsp 
expansion happens inside clang's main() function.

I'm noticing along the way that explicit arguments in `-Wp` are parsed in the 
driver, whereas arguments inside a response file are parsed in the -cc1 tool. 
Is that the desired behavior? This was the previous behavior but I'm not sure 
it's the right behavior.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73060

Files:
  clang/include/clang/Driver/Driver.h
  clang/lib/Driver/Job.cpp
  clang/test/Driver/Wp-args.c
  clang/tools/driver/driver.cpp

Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -241,8 +241,6 @@
   *NumberSignPtr = '=';
 }
 
-static int ExecuteCC1Tool(ArrayRef argv);
-
 static void SetBackdoorDriverOutputsFromEnvVars(Driver &TheDriver) {
   // Handle CC_PRINT_OPTIONS and CC_PRINT_OPTIONS_FILE.
   TheDriver.CCPrintOptions = !!::getenv("CC_PRINT_OPTIONS");
@@ -318,7 +316,6 @@
   // Driver::CC1Main), we need to clean up the options usage count. The options
   // are currently global, and they might have been used previously by the
   // driver.
-  llvm::cl::ResetAllOptionOccurrences();
   StringRef Tool = argv[1];
   void *GetExecutablePathVP = (void *)(intptr_t) GetExecutablePath;
   if (Tool == "-cc1")
@@ -334,17 +331,13 @@
   return 1;
 }
 
-int main(int argc_, const char **argv_) {
-  noteBottomOfStack();
-  llvm::InitLLVM X(argc_, argv_);
-  SmallVector argv(argv_, argv_ + argc_);
-
-  if (llvm::sys::Process::FixupStandardFileDescriptors())
-return 1;
-
-  llvm::InitializeAllTargets();
+int ExecuteClangTool(SmallVectorImpl &argv) {
   auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(argv[0]);
 
+  static unsigned ReenteranceCount;
+  if (ReenteranceCount++)
+llvm::cl::ResetAllOptionOccurrences();
+
   llvm::BumpPtrAllocator A;
   llvm::StringSaver Saver(A);
 
@@ -480,7 +473,7 @@
   SetBackdoorDriverOutputsFromEnvVars(TheDriver);
 
   if (!UseNewCC1Process) {
-TheDriver.CC1Main = &ExecuteCC1Tool;
+TheDriver.CC1Main = &ExecuteClangTool;
 // Ensure the CC1Command actually catches cc1 crashes
 llvm::CrashRecoveryContext::Enable();
   }
@@ -543,3 +536,15 @@
   // failing command.
   return Res;
 }
+
+int main(int argc_, const char **argv_) {
+  noteBottomOfStack();
+  llvm::InitLLVM X(argc_, argv_);
+  SmallVector argv(argv_, argv_ + argc_);
+
+  if (llvm::sys::Process::FixupStandardFileDescriptors())
+return 1;
+
+  llvm::InitializeAllTargets();
+  return ExecuteClangTool(argv);
+}
Index: clang/test/Driver/Wp-args.c
===
--- clang/test/Driver/Wp-args.c
+++ clang/test/Driver/Wp-args.c
@@ -19,3 +19,9 @@
 // MMD: "-cc1"
 // MMD-NOT: -MMD
 // MMD: "-dependency-file" "Wp-args.d"
+
+// Ensure response files are properly expanded with -Wp
+// RUN: echo -rewrite-macros > %t.rsp
+// RUN: %clang -Wp,@%t.rsp -E %s | FileCheck -check-prefix RSP %s
+
+// RSP: inception
Index: clang/lib/Driver/Job.cpp
===
--- clang/lib/Driver/Job.cpp
+++ clang/lib/Driver/Job.cpp
@@ -384,7 +384,6 @@
   SmallVector Argv;
   Argv.push_back(getExecutable());
   Argv.append(getArguments().begin(), getArguments().end());
-  Argv.push_back(nullptr);
 
   // This flag simply indicates that the program couldn't start, which isn't
   // applicable here.
Index: clang/include/clang/Driver/Driver.h
===
--- clang/include/clang/Driver/Driver.h
+++ clang/include/clang/Driver/Driver.h
@@ -208,7 +208,7 @@
   /// When the clangDriver lib is used through clang.exe, this provides a
   /// shortcut for executing the -cc1 command-line directly, in the same
   /// process.
-  typedef int (*CC1ToolFunc)(ArrayRef argv);
+  typedef int (*CC1ToolFunc)(SmallVectorImpl &);
   CC1ToolFunc CC1Main = nullptr;
 
 private:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72932: [ARM] Follow AACPS standard for volatile bit-fields access width

2020-01-20 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio added a comment.

In D72932#1829716 , @ostannard wrote:

> Why are you doing this in CodeGen, rather than adjusting the existing layout 
> code in CGRecordLowering? Doing it this way will result in 
> AdjustAAPCSBitfieldLValue being called for every access to the bit-field, 
> rather than just once. This is probably more fragile too, because it's 
> spreading the logic across multiple parts of the codebase, and has to undo 
> some of the layout done by CGRecordLowering.


Only at CodeGen we definitely know if an access is volatile, due casts to 
volatile.
About undoing what the CGRecordLowering does, that can't be avoided. We only 
can compute if a given offset and width will touch outside the bit-field when 
all fields and padding are defined.
We could add special volatile access fields into CGBitFieldInfo and compute 
them at the end for CGRecordLowering::lower, but these fields would only be 
relevant to ARM. And they will need to be computed even if there are any 
volatile accesses.
I have no strong opinion about which is better, I can add the fields if that 
suites better.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72932



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


[PATCH] D73056: [clangd] Fix DocumentOutline for concepts

2020-01-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfb3d9153c01b: [clangd] Fix DocumentOutline for concepts 
(authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73056

Files:
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp


Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -449,6 +449,15 @@
 SymNameRange(Main.range("def");
 }
 
+TEST_F(DocumentSymbolsTest, Concepts) {
+  CDB.ExtraClangFlags = {"-std=c++2a"};
+  std::string FilePath = testPath("foo.cpp");
+  addFile(FilePath,
+  "template  concept C = requires(T t) { t.foo(); };");
+
+  EXPECT_THAT(getSymbols(FilePath), ElementsAre(WithName("C")));
+}
+
 TEST_F(DocumentSymbolsTest, ExternSymbol) {
   std::string FilePath = testPath("foo.cpp");
   addFile(testPath("foo.h"), R"cpp(
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -193,8 +193,11 @@
   enum class VisitKind { No, OnlyDecl, DeclAndChildren };
 
   void traverseDecl(Decl *D, std::vector &Results) {
-if (auto *Templ = llvm::dyn_cast(D))
-  D = Templ->getTemplatedDecl();
+if (auto *Templ = llvm::dyn_cast(D)) {
+  // TemplatedDecl might be null, e.g. concepts.
+  if (auto *TD = Templ->getTemplatedDecl())
+D = TD;
+}
 auto *ND = llvm::dyn_cast(D);
 if (!ND)
   return;


Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -449,6 +449,15 @@
 SymNameRange(Main.range("def");
 }
 
+TEST_F(DocumentSymbolsTest, Concepts) {
+  CDB.ExtraClangFlags = {"-std=c++2a"};
+  std::string FilePath = testPath("foo.cpp");
+  addFile(FilePath,
+  "template  concept C = requires(T t) { t.foo(); };");
+
+  EXPECT_THAT(getSymbols(FilePath), ElementsAre(WithName("C")));
+}
+
 TEST_F(DocumentSymbolsTest, ExternSymbol) {
   std::string FilePath = testPath("foo.cpp");
   addFile(testPath("foo.h"), R"cpp(
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -193,8 +193,11 @@
   enum class VisitKind { No, OnlyDecl, DeclAndChildren };
 
   void traverseDecl(Decl *D, std::vector &Results) {
-if (auto *Templ = llvm::dyn_cast(D))
-  D = Templ->getTemplatedDecl();
+if (auto *Templ = llvm::dyn_cast(D)) {
+  // TemplatedDecl might be null, e.g. concepts.
+  if (auto *TD = Templ->getTemplatedDecl())
+D = TD;
+}
 auto *ND = llvm::dyn_cast(D);
 if (!ND)
   return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73019: [Sema] Don't disallow placing `__attribute__((alloc_align(param_idx)))` on `std::align_val_t`-typed parameters

2020-01-20 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 239179.
lebedev.ri added a comment.

NFC, more tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73019

Files:
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp


Index: clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -std=c++11  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -faligned-allocation -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++14  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++14 -faligned-allocation -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++17  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++17 -faligned-allocation -fsyntax-only -verify %s
+
+namespace std {
+typedef __SIZE_TYPE__ size_t;
+struct nothrow_t {};
+#if __cplusplus >= 201103L
+enum class align_val_t : size_t {};
+#else
+enum align_val_t {
+// We can't force an underlying type when targeting windows.
+#ifndef _WIN32
+  __zero = 0,
+  __max = (size_t)-1
+#endif
+};
+#endif
+} // namespace std
+
+void *operator new(std::size_t count, std::align_val_t al) 
__attribute__((alloc_align(2)));
+
+#define OVERALIGNED alignas(__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2)
+
+struct OVERALIGNED A {
+  A();
+  int n[128];
+};
+
+void *ptr_variable(int align) { return new (std::align_val_t(align)) A; }
+void *ptr_align16() { return new (std::align_val_t(16)) A; }
+void *ptr_align15() { return new (std::align_val_t(15)) A; }
+
+struct alignas(128) S {
+  S() {}
+};
+
+void *alloc_overaligned_struct() {
+  return new S;
+}
+
+void *alloc_overaligned_struct_with_extra_variable_alignment(int align) {
+  return new (std::align_val_t(align)) S;
+}
+void *alloc_overaligned_struct_with_extra_256_alignment(int align) {
+  return new (std::align_val_t(256)) S;
+}
+void *alloc_overaligned_struct_with_extra_255_alignment(int align) {
+  return new (std::align_val_t(255)) S;
+}
+
+std::align_val_t align_variable(int align) { return std::align_val_t(align); }
+std::align_val_t align_align16() { return std::align_val_t(16); }
+std::align_val_t align_align15() { return std::align_val_t(15); }
+
+// expected-no-diagnostics
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -1669,7 +1669,8 @@
 return;
 
   QualType Ty = getFunctionOrMethodParamType(D, Idx.getASTIndex());
-  if (!Ty->isDependentType() && !Ty->isIntegralType(Context)) {
+  if (!Ty->isDependentType() && !Ty->isIntegralType(Context) &&
+  !Ty->isAlignValT()) {
 Diag(ParamExpr->getBeginLoc(), diag::err_attribute_integers_only)
 << &TmpAttr
 << FuncDecl->getParamDecl(Idx.getASTIndex())->getSourceRange();


Index: clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -std=c++11  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -faligned-allocation -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++14  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++14 -faligned-allocation -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++17  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++17 -faligned-allocation -fsyntax-only -verify %s
+
+namespace std {
+typedef __SIZE_TYPE__ size_t;
+struct nothrow_t {};
+#if __cplusplus >= 201103L
+enum class align_val_t : size_t {};
+#else
+enum align_val_t {
+// We can't force an underlying type when targeting windows.
+#ifndef _WIN32
+  __zero = 0,
+  __max = (size_t)-1
+#endif
+};
+#endif
+} // namespace std
+
+void *operator new(std::size_t count, std::align_val_t al) __attribute__((alloc_align(2)));
+
+#define OVERALIGNED alignas(__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2)
+
+struct OVERALIGNED A {
+  A();
+  int n[128];
+};
+
+void *ptr_variable(int align) { return new (std::align_val_t(align)) A; }
+void *ptr_align16() { return new (std::align_val_t(16)) A; }
+void *ptr_align15() { return new (std::align_val_t(15)) A; }
+
+struct alignas(128) S {
+  S() {}
+};
+
+void *alloc_overaligned_struct() {
+  return new S;
+}
+
+void *alloc_overaligned_struct_with_extra_variable_alignment(int align) {
+  return new (std::align_val_t(align)) S;
+}
+void *alloc_overaligned_struct_with_extra_256_alignment(int align) {
+  return new (std::align_val_t(256)) S;
+}
+void *alloc_overaligned_struct_with_extra_255_alignment(int align) {
+  return new (std::align_val_t(255)) S;
+}
+
+std::align_val_t align_variable(int align) { return std::align_va

[PATCH] D71124: [RISCV] support clang driver to select cpu

2020-01-20 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

In D71124#1792216 , @khchen wrote:

> The problem is how `-mcpu` interact with explicitly specified `-march` (or 
> target features).
>
> 1. in GCC, -mcpu is only used to chose the pipeline model,


I think you mean "in GCC, `-mtune` is only used to choose the pipeline model" 
(`-mcpu` is not documented in the RISC-V specific GCC options documentation 
).

Clang should attempt to maintain compatibility with GCC flags, but if they only 
implement `-mtune`, then we have a little more freedom to do something 
ergonomic with `-mcpu`.

I'll note that clang already has a large TODO around implementing `-mtune` in 
general, though the AArch64 backend seems to support it for some option choices.

> 
> 
> 2. I also read this 
> 
>  article talking about the X86 and ARM to handle those options.
>   - -march=X: Tells the compiler that X is the minimal architecture the 
> binary must run on.  The compiler is free to use architecture-specific 
> instructions.  This flag behaves differently on Arm and x86.  On Arm, -march 
> does not override -mtune, but on x86 -march will override both -mtune and 
> -mcpu.
>   - -mtune=X: Tells the compiler to optimize for microarchitecture X but does 
> not allow the compiler to change the ABI or make assumptions about available 
> instructions.  This flag has the more-or-less the same meaning on Arm and x86.
>   - -mcpu=X: On Arm, this flag is a combination of -march and -mtune.  It 
> simultaneously specifies the target architecture and optimizes for a given 
> microarchitecture. On x86 this flag is a deprecated synonym for -mtune.
> 
> So maybe it makes sense to treat those flags behaves differently on 
> different target .
> 3. I also tried llc to specific -mcpu and -attr (similar to -march, 
> target-feature) in ARM, -attr will over write the default target-feature in 
> -mcpu.
> 
>   on RISC-V, in sometime (or most?) we have same pipeline model but support 
> different extension combination,

I don't believe this to be correct. lowRISC's Ibex has a completely different 
pipeline model to rocket, and there are countless other RISC-V cores with 
different pipeline characteristics, including out-of-order pipeline 
implementations like BOOM. I don't think we can favour one particular 
scheduling model (beyond the generic ones we already default to).

> so I think maybe distinguishing the purpose of -mcpu and -march and make them 
> with no interaction is a good idea. (behavior is equal to GCC)

In LLVM, if you add `target-cpu` metadata to a function (which is added by 
clang, based on `-mcpu`), that function will have all the features of that CPU 
automatically added to it (as if you had used `-mattr` with all the features in 
the model). If you don't add that metadata, a generic scheduling model will be 
chosen. This suggests at the moment there can be no separation between `-mtune` 
and `-march` as there is in GCC (without changes to the target-independent 
parts of LLVM).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71124



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


[PATCH] D28955: [analyzer] Enable support for symbolic extension/truncation

2020-01-20 Thread Mikhail Ramalho via Phabricator via cfe-commits
mikhail.ramalho added a comment.

I can give some help here, but my time is quite limited as well :/

Let me at least rebase against master.


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

https://reviews.llvm.org/D28955



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


[PATCH] D68720: Support -fstack-clash-protection for x86

2020-01-20 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon times-circle color=red} Unit tests: fail. 62035 tests passed, 2 failed 
and 783 were skipped.

  failed: Clang.CodeGen/stack-clash-protection.c
  failed: Clang.Misc/warning-flags.c

{icon question-circle color=gray} clang-tidy: unknown.

{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-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68720



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


[PATCH] D73060: [Clang] Fix expansion of response files in -Wp after integrated-cc1 change

2020-01-20 Thread Wenlei He via Phabricator via cfe-commits
wenlei accepted this revision.
wenlei added a comment.
This revision is now accepted and ready to land.

> Is that the desired behavior? This was the previous behavior but I'm not sure 
> it's the right behavior.

Good point. It might be safer to keep that previous behavior though.

Thanks for the quick fix, LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73060



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


[PATCH] D73020: [Sema] Perform call checking when building CXXNewExpr

2020-01-20 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 239180.
lebedev.ri added a comment.

Not only do we need to 'insert' size implicit argument,
but we may need to insert alignment implicit argument.
And while for size we can only insert `nullptr`,
for alignment we can actually insert the correct value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73020

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp

Index: clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
===
--- clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
+++ clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
@@ -32,7 +32,7 @@
 
 void *ptr_variable(int align) { return new (std::align_val_t(align)) A; }
 void *ptr_align16() { return new (std::align_val_t(16)) A; }
-void *ptr_align15() { return new (std::align_val_t(15)) A; }
+void *ptr_align15() { return new (std::align_val_t(15)) A; } // expected-error {{requested alignment is not a power of 2}}
 
 struct alignas(128) S {
   S() {}
@@ -49,11 +49,9 @@
   return new (std::align_val_t(256)) S;
 }
 void *alloc_overaligned_struct_with_extra_255_alignment(int align) {
-  return new (std::align_val_t(255)) S;
+  return new (std::align_val_t(255)) S; // expected-error {{requested alignment is not a power of 2}}
 }
 
 std::align_val_t align_variable(int align) { return std::align_val_t(align); }
 std::align_val_t align_align16() { return std::align_val_t(16); }
 std::align_val_t align_align15() { return std::align_val_t(15); }
-
-// expected-no-diagnostics
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -2070,18 +2070,45 @@
 // arguments. Skip the first parameter because we don't have a corresponding
 // argument. Skip the second parameter too if we're passing in the
 // alignment; we've already filled it in.
+unsigned NumImplicitArgs = PassAlignment ? 2 : 1;
 if (GatherArgumentsForCall(PlacementLParen, OperatorNew, Proto,
-   PassAlignment ? 2 : 1, PlacementArgs,
-   AllPlaceArgs, CallType))
+   NumImplicitArgs, PlacementArgs, AllPlaceArgs,
+   CallType))
   return ExprError();
 
 if (!AllPlaceArgs.empty())
   PlacementArgs = AllPlaceArgs;
 
-// FIXME: This is wrong: PlacementArgs misses out the first (size) argument.
-DiagnoseSentinelCalls(OperatorNew, PlacementLParen, PlacementArgs);
+// We would like to perform some checking on the given `operator new` call,
+// but the PlacementArgs does not contain the implicit arguments,
+// namely allocation size and maybe allocation alignment, so we need to
+// conjure them. For size, we can't do anything better than just passing a
+// nullptr, but for alignment we can either also pass a nullptr, or actually
+// materialize the alignment we'll pass into the call.
+llvm::SmallVector CallArgs;
+CallArgs.reserve(NumImplicitArgs + PlacementArgs.size());
+CallArgs.emplace_back(nullptr);
+if (PassAlignment) {
+  // Let's actually synthesize the alignment argument.
+  QualType AlignValT = Context.getTypeDeclType(getStdAlignValT());
+  QualType SizeTy =
+  AlignValT->castAs()->getDecl()->getIntegerType();
+  auto *AlignmentLiteral = IntegerLiteral::Create(
+  Context,
+  llvm::APInt(Context.getTypeSize(SizeTy),
+  Alignment / Context.getCharWidth()),
+  SizeTy, SourceLocation());
+  auto *DesiredAlignmnet = ImplicitCastExpr::Create(
+  Context, AlignValT, CK_IntegralCast, AlignmentLiteral,
+  /*BasePath=*/nullptr, VK_RValue);
+  CallArgs.emplace_back(DesiredAlignmnet);
+}
+CallArgs.insert(CallArgs.end(), PlacementArgs.begin(), PlacementArgs.end());
 
-// FIXME: Missing call to CheckFunctionCall or equivalent
+DiagnoseSentinelCalls(OperatorNew, PlacementLParen, CallArgs);
+
+checkCall(OperatorNew, Proto, /*ThisArg=*/nullptr, CallArgs,
+  /*IsMemberFunction=*/false, StartLoc, Range, CallType);
 
 // Warn if the type is over-aligned and is being allocated by (unaligned)
 // global operator new.
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -14460,8 +14460,10 @@
 const Expr *E,
 llvm::APSInt *Value,
 SourceLocation *Loc) {
-  if (!E->getType()->isIntegralOrUnscopedEnumerationType()) {
-if (Loc) *Loc = E->getE

[PATCH] D72638: [clangd] Fix rename for explicit destructor calls

2020-01-20 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 239182.
kbobyrev marked 2 inline comments as done.
kbobyrev added a comment.

Modify the test to address the comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72638

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -265,6 +265,33 @@
 }
   )cpp",
 
+  // Destructor explicit call.
+  R"cpp(
+class [[F^oo]] {
+public:
+  ~[[^Foo]]();
+};
+
+[[Foo^]]::~[[^Foo]]() {}
+
+int main() {
+  [[Fo^o]] f;
+  f.~/*something*/[[^Foo]]();
+  f.~[[^Foo]]();
+}
+  )cpp",
+
+  // Derived destructor explicit call.
+  R"cpp(
+class [[Bas^e]] {};
+class Derived : public [[Bas^e]] {}
+
+int main() {
+  [[Bas^e]] *foo = new Derived();
+  foo->[[^Base]]::~[[^Base]]();
+}
+  )cpp",
+
   // CXXConstructor initializer list.
   R"cpp(
 class Baz {};
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -879,6 +879,56 @@
 "8: targets = {INT2}, decl\n"
 "9: targets = {NS}, decl\n"
 "10: targets = {ns}\n"},
+   // User-defined conversion operator.
+   {R"cpp(
+void foo() {
+   class $0^Bar {};
+   class $1^Foo {
+   public:
+ // FIXME: This should have only one reference to Bar.
+ $2^operator $3^$4^Bar();
+   };
+
+   $5^Foo $6^f;
+   $7^f.$8^operator $9^Bar();
+}
+)cpp",
+"0: targets = {Bar}, decl\n"
+"1: targets = {Foo}, decl\n"
+"2: targets = {foo()::Foo::operator Bar}, decl\n"
+"3: targets = {Bar}\n"
+"4: targets = {Bar}\n"
+"5: targets = {Foo}\n"
+"6: targets = {f}, decl\n"
+"7: targets = {f}\n"
+"8: targets = {foo()::Foo::operator Bar}\n"
+"9: targets = {Bar}\n"},
+   // Destructor.
+   {R"cpp(
+ void foo() {
+   class $0^Foo {
+   public:
+ ~$1^Foo() {}
+
+ void $2^destructMe() {
+   this->~$3^Foo();
+ }
+   };
+
+   $4^Foo $5^f;
+   $6^f.~ /*...*/ $7^Foo();
+ }
+   )cpp",
+"0: targets = {Foo}, decl\n"
+// FIXME: It's better to destructor's FunctionDecl instead of the type
+// itself (similar to constructor).
+"1: targets = {Foo}\n"
+"2: targets = {foo()::Foo::destructMe}, decl\n"
+"3: targets = {Foo}\n"
+"4: targets = {Foo}\n"
+"5: targets = {f}, decl\n"
+"6: targets = {f}\n"
+"7: targets = {Foo}\n"},
// cxx constructor initializer.
{R"cpp(
  class Base {};
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -596,6 +596,10 @@
 }
 
 void VisitMemberExpr(const MemberExpr *E) {
+  // Skip destructor calls to avoid duplication: TypeLoc within will be
+  // visited separately.
+  if (llvm::dyn_cast(E->getFoundDecl().getDecl()))
+return;
   Refs.push_back(ReferenceLoc{E->getQualifierLoc(),
   E->getMemberNameInfo().getLoc(),
   /*IsDecl=*/false,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73062: [analyzer] Simplify BoolAssignmentChecker

2020-01-20 Thread Mikhail Ramalho via Phabricator via cfe-commits
mikhail.ramalho created this revision.
mikhail.ramalho added a reviewer: NoQ.
Herald added subscribers: cfe-commits, Charusso.
Herald added a project: clang.
mikhail.ramalho retitled this revision from "Simplify BoolAssignmentChecker" to 
"[analyzer] Simplify BoolAssignmentChecker".
Herald added subscribers: dkrupp, donat.nagy, Szelethus, a.sidorin, szepet, 
baloghadamsoftware, xazax.hun.

Instead of checking the range manually, changed the checker to use 
assumeInclusiveRangeDual instead.

This patch was part of D28955 .


Repository:
  rC Clang

https://reviews.llvm.org/D73062

Files:
  clang/lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp
  clang/test/Analysis/bool-assignment.c
  clang/test/Analysis/dead-stores.m
  clang/test/Analysis/misc-ps-eager-assume.m

Index: clang/test/Analysis/misc-ps-eager-assume.m
===
--- clang/test/Analysis/misc-ps-eager-assume.m
+++ clang/test/Analysis/misc-ps-eager-assume.m
@@ -1,5 +1,4 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks %s
-// expected-no-diagnostics
 
 // Delta-reduced header stuff (needed for test cases).
 typedef signed char BOOL;
@@ -56,7 +55,7 @@
 void handle_symbolic_cast_in_condition(void) {
   NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
 
-  BOOL needsAnArray = [@"aString" isEqualToString:@"anotherString"];
+  BOOL needsAnArray = [@"aString" isEqualToString:@"anotherString"]; // expected-warning {{Assignment of a non-Boolean value}}
   NSMutableArray* array = needsAnArray ? [[NSMutableArray alloc] init] : 0;
   if(needsAnArray)
 [array release];
Index: clang/test/Analysis/dead-stores.m
===
--- clang/test/Analysis/dead-stores.m
+++ clang/test/Analysis/dead-stores.m
@@ -54,7 +54,7 @@
 - (void) bar_rbar8527823
 {
  @synchronized(self) {
-   BOOL isExec = baz_rdar8527823(); // no-warning
+   BOOL isExec = baz_rdar8527823(); // expected-warning {{Assignment of a non-Boolean value}}
if (isExec) foo_rdar8527823();
  }
 }
Index: clang/test/Analysis/bool-assignment.c
===
--- clang/test/Analysis/bool-assignment.c
+++ clang/test/Analysis/bool-assignment.c
@@ -43,11 +43,7 @@
 return;
   }
   if (y > 200 && y < 250) {
-#ifdef ANALYZER_CM_Z3
 BOOL x = y; // expected-warning {{Assignment of a non-Boolean value}}
-#else
-BOOL x = y; // no-warning
-#endif
 return;
   }
   if (y >= 127 && y < 150) {
Index: clang/lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp
@@ -70,8 +70,8 @@
   // Get the value of the right-hand side.  We only care about values
   // that are defined (UnknownVals and UndefinedVals are handled by other
   // checkers).
-  Optional DV = val.getAs();
-  if (!DV)
+  Optional NV = val.getAs();
+  if (!NV)
 return;
 
   // Check if the assigned value meets our criteria for correctness.  It must
@@ -79,78 +79,17 @@
   // the value is possibly < 0 (for a negative value) or greater than 1.
   ProgramStateRef state = C.getState();
   SValBuilder &svalBuilder = C.getSValBuilder();
+  BasicValueFactory &BVF = svalBuilder.getBasicValueFactory();
   ConstraintManager &CM = C.getConstraintManager();
 
-  // First, ensure that the value is >= 0.
-  DefinedSVal zeroVal = svalBuilder.makeIntVal(0, valTy);
-  SVal greaterThanOrEqualToZeroVal =
-svalBuilder.evalBinOp(state, BO_GE, *DV, zeroVal,
-  svalBuilder.getConditionType());
+  llvm::APSInt Zero = BVF.getValue(0, valTy);
+  llvm::APSInt One = BVF.getValue(1, valTy);
 
-  Optional greaterThanEqualToZero =
-  greaterThanOrEqualToZeroVal.getAs();
+  ProgramStateRef StIn, StOut;
+  std::tie(StIn, StOut) = CM.assumeInclusiveRangeDual(state, *NV, Zero, One);
 
-  if (!greaterThanEqualToZero) {
-// The SValBuilder cannot construct a valid SVal for this condition.
-// This means we cannot properly reason about it.
-return;
-  }
-
-  ProgramStateRef stateLT, stateGE;
-  std::tie(stateGE, stateLT) = CM.assumeDual(state, *greaterThanEqualToZero);
-
-  // Is it possible for the value to be less than zero?
-  if (stateLT) {
-// It is possible for the value to be less than zero.  We only
-// want to emit a warning, however, if that value is fully constrained.
-// If it it possible for the value to be >= 0, then essentially the
-// value is underconstrained and there is nothing left to be done.
-if (!stateGE)
-  emitReport(stateLT, C);
-
-// In either case, we are done.
-return;
-  }
-
-  // If we reach here, it must be the case that the value is constrained
-  // to only be >= 0.
-  assert(stateGE == state);
-
-  // At this point w

  1   2   >