[PATCH] D73354: clang-format: insert trailing commas into containers.

2020-01-27 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I'm a little uncomfortable about all the tests changing, and I'm unsure if we 
should be changing the default behaviour.

The rules in the past here was to show that this is part of a public style 
guide. The assumption here is google style wants this. Could you please point 
to that documentation so at least there is some comeback when we break the 
world.




Comment at: clang/lib/Format/Format.cpp:956
 GoogleStyle.CommentPragmas = "(taze:|^/[ \t]*<|tslint:|@see)";
+GoogleStyle.InsertTrailingCommas = FormatStyle::TCS_Wrapped;
 GoogleStyle.MaxEmptyLinesToKeep = 3;

Are you sure the right decision is to make this on by default for something 
that's going to insert the comma? is this in google's javascript style guide?

I think this could cause clang-format to suddenly start adding lost of commas 
(as we see  with the tests)



Comment at: clang/lib/Format/Format.cpp:1477
 
+/// TrailingCommaInserter inserts trailing commas into container literals.
+/// E.g.:

sammccall wrote:
> Inlining this in format.cpp seems worse than having passes in their own 
> files, but is the pattern so far. Ugh, up to you.
Actually I think there is precedent to put TokenAnalyzers in their own class, I 
don't think it should be in Format.cpp



Comment at: clang/unittests/Format/FormatTestJS.cpp:1229
"  (param): param is {\n"
-   "a: SomeType\n"
+   "a: SomeType;\n"
"  }&ABC => 1)\n"

is this correct?



Comment at: clang/unittests/Format/FormatTestJS.cpp:1701
   verifyFormat("type X = {\n"
-   "  y: number\n"
+   "  y: number;\n"
"};\n"

is this correct?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73354



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


[clang-tools-extra] 70f4c6e - [clan-tidy] Fix false positive in bugprone-infinite-loop

2020-01-27 Thread Adam Balogh via cfe-commits

Author: Adam Balogh
Date: 2020-01-27T10:13:55+01:00
New Revision: 70f4c6e7b14f225f9628fbdab3620ce037613351

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

LOG: [clan-tidy] Fix false positive in bugprone-infinite-loop

The checker bugprone-infinite-loop does not track changes of
variables in the initialization expression of a variable
declared inside the condition of the while statement. This
leads to false positives, similarly to the one in the bug
report https://bugs.llvm.org/show_bug.cgi?id=44618. This
patch fixes this issue by enabling tracking of the variables
of this expression as well.

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
index 81ae45a00896..c771ba81b250 100644
--- a/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
@@ -170,17 +170,33 @@ void InfiniteLoopCheck::check(const 
MatchFinder::MatchResult &Result) {
   const auto *LoopStmt = Result.Nodes.getNodeAs("loop-stmt");
   const auto *Func = Result.Nodes.getNodeAs("func");
 
+  bool ShouldHaveConditionVariables = true;
+  if (const auto *While = dyn_cast(LoopStmt)) {
+if (const VarDecl *LoopVarDecl = While->getConditionVariable()) {
+  if (const Expr *Init = LoopVarDecl->getInit()) {
+ShouldHaveConditionVariables = false;
+Cond = Init;
+  }
+}
+  }
+
   if (isAtLeastOneCondVarChanged(Func, LoopStmt, Cond, Result.Context))
 return;
 
   std::string CondVarNames = getCondVarNames(Cond);
-  if (CondVarNames.empty())
+  if (ShouldHaveConditionVariables && CondVarNames.empty())
 return;
 
-  diag(LoopStmt->getBeginLoc(),
-   "this loop is infinite; none of its condition variables (%0)"
-   " are updated in the loop body")
+  if (CondVarNames.empty()) {
+diag(LoopStmt->getBeginLoc(),
+ "this loop is infinite; it does not check any variables in the"
+ " condition");
+  } else {
+diag(LoopStmt->getBeginLoc(),
+ "this loop is infinite; none of its condition variables (%0)"
+ " are updated in the loop body")
   << CondVarNames;
+  }
 }
 
 } // namespace bugprone

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
index 33d94820b0f6..d89bdadf0212 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
@@ -4,10 +4,20 @@ void simple_infinite_loop1() {
   int i = 0;
   int j = 0;
   while (i < 10) {
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of 
its condition variables (i) are updated in the loop body 
[bugprone-infinite-loop]
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of 
its condition variables (i) are updated in the loop body 
[bugprone-infinite-loop]
 j++;
   }
 
+  while (int k = 10) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; it does 
not check any variables in the condition [bugprone-infinite-loop]
+j--;
+  }
+
+  while (int k = 10) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; it does 
not check any variables in the condition [bugprone-infinite-loop]
+k--;
+  }
+
   do {
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of 
its condition variables (i) are updated in the loop body 
[bugprone-infinite-loop]
 j++;
@@ -27,6 +37,16 @@ void simple_infinite_loop2() {
 j++;
   }
 
+  while (int k = Limit) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of 
its condition variables (Limit) are updated in the loop body 
[bugprone-infinite-loop]
+j--;
+  }
+
+  while (int k = Limit) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of 
its condition variables (Limit) are updated in the loop body 
[bugprone-infinite-loop]
+k--;
+  }
+
   do {
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of 
its condition variables (i, Limit) are updated in the loop body 
[bugprone-infinite-loop]
 j++;
@@ -44,6 +64,22 @@ void simple_not_infinite1() {
 // Not an error since 'Limit' is updated.
 Limit--;
   }
+
+  while (Limit--) {
+// Not an error since 'Limit' is updated.
+i++;
+  }
+
+  while (int k = Limit) {
+// Not an error since 'Limit' is updated.
+Limit--;
+  }
+
+  w

[PATCH] D73441: [clang-tidy] Fix bugprone-use-after-move when move is in noexcept operator

2020-01-27 Thread Nathan James via Phabricator via cfe-commits
njames93 marked 2 inline comments as done.
njames93 added inline comments.



Comment at: clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp:387
+   unless(inDecltypeOrTemplateArg()),
+   unless(hasAncestor(cxxNoexceptExpr(
   .bind("call-move");

gribozavr2 wrote:
> Quuxplusone wrote:
> > What about `sizeof`, `alignof`, `requires`, `typeid`, and other such 
> > unevaluated contexts? Shouldn't there be a common way to spell "this 
> > expression is unevaluated"? (I don't know if there is or not.)
> +1 to adding handling and tests for other unevaluated contexts.
I think i can write a matcher that will detect that



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp:1276
+namespace PR44667 {
+#define REQUIRE(expr) (void)(expr);
+struct S {};

gribozavr2 wrote:
> Is the macro a necessary part of this test? If not, can it be removed?
I like to stick to the bug report as much as possible


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73441



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


[PATCH] D73270: [clang-tidy] Fix false positive in bugprone-infinite-loop

2020-01-27 Thread Balogh, Ádám via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG70f4c6e7b14f: [clan-tidy] Fix false positive in 
bugprone-infinite-loop (authored by baloghadamsoftware).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73270

Files:
  clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
@@ -4,10 +4,20 @@
   int i = 0;
   int j = 0;
   while (i < 10) {
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of its condition variables (i) are updated in the loop body [bugprone-infinite-loop]
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of its condition variables (i) are updated in the loop body [bugprone-infinite-loop]
 j++;
   }
 
+  while (int k = 10) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; it does not check any variables in the condition [bugprone-infinite-loop]
+j--;
+  }
+
+  while (int k = 10) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; it does not check any variables in the condition [bugprone-infinite-loop]
+k--;
+  }
+
   do {
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of its condition variables (i) are updated in the loop body [bugprone-infinite-loop]
 j++;
@@ -27,6 +37,16 @@
 j++;
   }
 
+  while (int k = Limit) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of its condition variables (Limit) are updated in the loop body [bugprone-infinite-loop]
+j--;
+  }
+
+  while (int k = Limit) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of its condition variables (Limit) are updated in the loop body [bugprone-infinite-loop]
+k--;
+  }
+
   do {
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of its condition variables (i, Limit) are updated in the loop body [bugprone-infinite-loop]
 j++;
@@ -44,6 +64,22 @@
 // Not an error since 'Limit' is updated.
 Limit--;
   }
+
+  while (Limit--) {
+// Not an error since 'Limit' is updated.
+i++;
+  }
+
+  while (int k = Limit) {
+// Not an error since 'Limit' is updated.
+Limit--;
+  }
+
+  while (int k = Limit--) {
+// Not an error since 'Limit' is updated.
+i++;
+  }
+
   do {
 Limit--;
   } while (i < Limit);
Index: clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
@@ -170,17 +170,33 @@
   const auto *LoopStmt = Result.Nodes.getNodeAs("loop-stmt");
   const auto *Func = Result.Nodes.getNodeAs("func");
 
+  bool ShouldHaveConditionVariables = true;
+  if (const auto *While = dyn_cast(LoopStmt)) {
+if (const VarDecl *LoopVarDecl = While->getConditionVariable()) {
+  if (const Expr *Init = LoopVarDecl->getInit()) {
+ShouldHaveConditionVariables = false;
+Cond = Init;
+  }
+}
+  }
+
   if (isAtLeastOneCondVarChanged(Func, LoopStmt, Cond, Result.Context))
 return;
 
   std::string CondVarNames = getCondVarNames(Cond);
-  if (CondVarNames.empty())
+  if (ShouldHaveConditionVariables && CondVarNames.empty())
 return;
 
-  diag(LoopStmt->getBeginLoc(),
-   "this loop is infinite; none of its condition variables (%0)"
-   " are updated in the loop body")
+  if (CondVarNames.empty()) {
+diag(LoopStmt->getBeginLoc(),
+ "this loop is infinite; it does not check any variables in the"
+ " condition");
+  } else {
+diag(LoopStmt->getBeginLoc(),
+ "this loop is infinite; none of its condition variables (%0)"
+ " are updated in the loop body")
   << CondVarNames;
+  }
 }
 
 } // namespace bugprone
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72829: Implement -fsemantic-interposition

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

Improve & comment examples


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72829

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/semantic-interposition.c
  clang/test/Driver/clang_f_opts.c
  llvm/include/llvm/IR/GlobalValue.h
  llvm/include/llvm/IR/Module.h
  llvm/lib/IR/Globals.cpp
  llvm/lib/IR/Module.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/test/Transforms/Inline/inline-semantic-interposition.ll
  llvm/test/Verifier/module-flags-semantic-interposition.ll

Index: llvm/test/Verifier/module-flags-semantic-interposition.ll
===
--- /dev/null
+++ llvm/test/Verifier/module-flags-semantic-interposition.ll
@@ -0,0 +1,12 @@
+; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@foo = dso_local global i32 1, align 4
+
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 1, !"SemanticInterposition", float 1.}
+
+; CHECK: SemanticInterposition metadata requires constant integer argument
Index: llvm/test/Transforms/Inline/inline-semantic-interposition.ll
===
--- /dev/null
+++ llvm/test/Transforms/Inline/inline-semantic-interposition.ll
@@ -0,0 +1,26 @@
+; Check that @callee1 gets inlined while @callee2 is not, because of
+; SemanticInterposition.
+
+; RUN: opt < %s -inline  -S | FileCheck %s
+
+define internal i32 @callee1(i32 %A) {
+  ret i32 %A
+}
+
+define i32 @callee2(i32 %A) {
+  ret i32 %A
+}
+
+; CHECK-LABEL: @caller
+define i32 @caller(i32 %A) {
+; CHECK-NOT: call i32 @callee1(i32 %A)
+  %A1 = call i32 @callee1(i32 %A)
+; CHECK: %A2 = call i32 @callee2(i32 %A)
+  %A2 = call i32 @callee2(i32 %A)
+; CHECK: add i32 %A, %A2
+  %R = add i32 %A1, %A2
+  ret i32 %R
+}
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"SemanticInterposition", i32 1}
Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -1476,6 +1476,13 @@
"'Linker Options' named metadata no longer supported");
   }
 
+  if (ID->getString() == "SemanticInterposition") {
+ConstantInt *Value =
+mdconst::dyn_extract_or_null(Op->getOperand(2));
+Assert(Value,
+   "SemanticInterposition metadata requires constant integer argument");
+  }
+
   if (ID->getString() == "CG Profile") {
 for (const MDOperand &MDO : cast(Op->getOperand(2))->operands())
   visitModuleFlagCGProfileEntry(MDO);
Index: llvm/lib/IR/Module.cpp
===
--- llvm/lib/IR/Module.cpp
+++ llvm/lib/IR/Module.cpp
@@ -554,6 +554,20 @@
: getModuleFlag("ProfileSummary"));
 }
 
+bool Module::getSemanticInterposition() const {
+  Metadata *MF = getModuleFlag("SemanticInterposition");
+
+  auto *Val = cast_or_null(MF);
+  if (!Val)
+return false;
+
+  return cast(Val->getValue())->getZExtValue();
+}
+
+void Module::setSemanticInterposition(bool SI) {
+  addModuleFlag(ModFlagBehavior::Error, "SemanticInterposition", SI);
+}
+
 void Module::setOwnedMemoryBuffer(std::unique_ptr MB) {
   OwnedMemoryBuffer = std::move(MB);
 }
Index: llvm/lib/IR/Globals.cpp
===
--- llvm/lib/IR/Globals.cpp
+++ llvm/lib/IR/Globals.cpp
@@ -94,6 +94,13 @@
   llvm_unreachable("not a global");
 }
 
+bool GlobalValue::isInterposable() const {
+  if (isInterposableLinkage(getLinkage()))
+return true;
+  return getParent() && getParent()->getSemanticInterposition() &&
+ !isDSOLocal();
+}
+
 unsigned GlobalValue::getAlignment() const {
   if (auto *GA = dyn_cast(this)) {
 // In general we cannot compute this at the IR level, but we try.
Index: llvm/include/llvm/IR/Module.h
===
--- llvm/include/llvm/IR/Module.h
+++ llvm/include/llvm/IR/Module.h
@@ -848,6 +848,12 @@
   Metadata *getProfileSummary(bool IsCS);
   /// @}
 
+  /// Returns whether semantic interposition is to be respected.
+  bool getSemanticInterposition() const;
+
+  /// Set whether semantic interposition is to be respected.
+  void setSemanticInterposition(bool);
+
   /// Returns true if PLT should be avoided for RTLib calls.
   bool getRtLibUseGOT() const;
 
Index: llvm/include/llvm/IR/GlobalValue.h
===
--- llvm/include/llvm/IR/GlobalValue.h
+++ llvm/include/llvm/IR/GlobalValue.h
@@ -426,

[PATCH] D72829: Implement -fsemantic-interposition

2020-01-27 Thread serge via Phabricator via cfe-commits
serge-sans-paille marked 2 inline comments as done.
serge-sans-paille added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2685
+  if (Args.hasArg(OPT_fsemantic_interposition))
+Opts.SemanticInterposition = 1;
+

MaskRay wrote:
> ` Opts.SemanticInterposition = Args.hasArg(OPT_fsemantic_interposition);`
That was on purpose, so that we're backward compatible with existing situation. 
Without the flag, the genrated .ll doesn't differ. That's less explicit though. 
Does it make sense to you?



Comment at: llvm/test/Transforms/Inline/inline-semantic-interposition.ll:1
+; RUN: opt < %s -inline  -S | FileCheck %s
+

MaskRay wrote:
> excess space
> 
> Add a comment what happened here.
I'm not sure about the excess space comment, but comment added.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72829



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


[PATCH] D73270: [clang-tidy] Fix false positive in bugprone-infinite-loop

2020-01-27 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

Should I also commit it to the release 10.0 branch? This is a bugfix so it 
should be fixed in the release, I think. I added a dependency between this bug 
and the 10.0.0 release blockers. Is that enough?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73270



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


[PATCH] D73418: [WPD] Emit vcall_visibility metadata for MicrosoftCXXABI

2020-01-27 Thread Eugene Leviant via Phabricator via cfe-commits
evgeny777 accepted this revision.
evgeny777 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/D73418/new/

https://reviews.llvm.org/D73418



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


[PATCH] D73449: [Alignment][NFC] Use Align with CreateAlignedLoad

2020-01-27 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet created this revision.
gchatelet added a reviewer: courbet.
Herald added a reviewer: bollu.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.

This is patch is part of a series to introduce an Alignment type.
See this thread for context: 
http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73449

Files:
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGCXX.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
  polly/lib/CodeGen/BlockGenerators.cpp

Index: polly/lib/CodeGen/BlockGenerators.cpp
===
--- polly/lib/CodeGen/BlockGenerators.cpp
+++ polly/lib/CodeGen/BlockGenerators.cpp
@@ -316,8 +316,8 @@
 
   Value *NewPointer =
   generateLocationAccessed(Stmt, Load, BBMap, LTS, NewAccesses);
-  Value *ScalarLoad = Builder.CreateAlignedLoad(
-  NewPointer, Load->getAlignment(), Load->getName() + "_p_scalar_");
+  Value *ScalarLoad = Builder.CreateAlignedLoad(NewPointer, Load->getAlign(),
+Load->getName() + "_p_scalar_");
 
   if (PollyDebugPrinting)
 RuntimeDebugBuilder::createCPUPrinter(Builder, "Load from ", NewPointer,
Index: llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
===
--- llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
+++ llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
@@ -517,8 +517,8 @@
 
   LoadInst *createColumnLoad(Value *ColumnPtr, Type *EltType,
  IRBuilder<> Builder) {
-unsigned Align = DL.getABITypeAlignment(EltType);
-return Builder.CreateAlignedLoad(ColumnPtr, Align, "col.load");
+return Builder.CreateAlignedLoad(
+ColumnPtr, Align(DL.getABITypeAlignment(EltType)), "col.load");
   }
 
   StoreInst *createColumnStore(Value *ColumnValue, Value *ColumnPtr,
Index: llvm/include/llvm/IR/IRBuilder.h
===
--- llvm/include/llvm/IR/IRBuilder.h
+++ llvm/include/llvm/IR/IRBuilder.h
@@ -1819,19 +1819,27 @@
   }
 
   // Deprecated [opaque pointer types]
-  LoadInst *CreateAlignedLoad(Value *Ptr, unsigned Align, const char *Name) {
+  LLVM_ATTRIBUTE_DEPRECATED(LoadInst *CreateAlignedLoad(Value *Ptr,
+unsigned Align,
+const char *Name),
+"Use the version that takes MaybeAlign instead") {
 return CreateAlignedLoad(Ptr->getType()->getPointerElementType(), Ptr,
  MaybeAlign(Align), Name);
   }
   // Deprecated [opaque pointer types]
-  LoadInst *CreateAlignedLoad(Value *Ptr, unsigned Align,
-  const Twine &Name = "") {
+  LLVM_ATTRIBUTE_DEPRECATED(LoadInst *CreateAlignedLoad(Value *Ptr,
+unsigned Align,
+const Twine &Name = ""),
+"Use the version that takes MaybeAlign instead") {
 return CreateAlignedLoad(Ptr->getType()->getPointerElementType(), Ptr,
  MaybeAlign(Align), Name);
   }
   // Deprecated [opaque pointer types]
-  LoadInst *CreateAlignedLoad(Value *Ptr, unsigned Align, bool isVolatile,
-  const Twine &Name = "") {
+  LLVM_ATTRIBUTE_DEPRECATED(LoadInst *CreateAlignedLoad(Value *Ptr,
+unsigned Align,
+bool isVolatile,
+const Twine &Name = ""),
+"Use the version that takes MaybeAlign instead") {
 return CreateAlignedLoad(Ptr->getType()->getPointerElementType(), Ptr,
  MaybeAlign(Align), isVolatile, Name);
   }
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -4414,7 +4414,7 @@
 
   // Otherwise, it should be an alloca instruction, as set up in save().
   auto alloca = cast(value.getPointer());
-  return CGF.Builder.CreateAlignedLoad(alloca, alloca->getAlignment());
+  return CGF.Builder.CreateAlignedLoad(alloca, alloca->getAlign());
 }
 
 }  // end namespace CodeGen
Index: clang/lib/CodeGen/CGCXX.cpp
===
--- clang/lib/CodeGen/CGCXX.cpp
+++ clang/lib/CodeGen/CGCXX.cpp
@@ -263,8 +263,8 @@
  AddressPoint.AddressPointIndex;
   llvm::Value *VFuncPtr =
 CGF.Bu

[PATCH] D72829: Implement -fsemantic-interposition

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

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

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

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

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


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72829



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


[PATCH] D73450: [clangd] Add a symbol-name-based blacklist for rename.

2020-01-27 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, 
mgorny.
Herald added a project: clang.

This patch adds a simple mechanism to disallow global rename
on std symbols. We might extend it to other symbols, e.g. protobuf.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73450

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/refactor/RenameBlacklist.cpp
  clang-tools-extra/clangd/refactor/RenameBlacklist.h
  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
@@ -383,12 +383,12 @@
 
   // Typedef.
   R"cpp(
-namespace std {
+namespace ns {
 class basic_string {};
 typedef basic_string [[s^tring]];
-} // namespace std
+} // namespace ns
 
-std::[[s^tring]] foo();
+ns::[[s^tring]] foo();
   )cpp",
 
   // Variable.
@@ -450,7 +450,7 @@
 for (const auto &RenamePos : Code.points()) {
   auto RenameResult =
   rename({RenamePos, NewName, AST, testPath(TU.Filename)});
-  ASSERT_TRUE(bool(RenameResult)) << RenameResult.takeError();
+  ASSERT_TRUE(bool(RenameResult)) << RenameResult.takeError() << T;
   ASSERT_EQ(1u, RenameResult->size());
   EXPECT_EQ(applyEdits(std::move(*RenameResult)).front().second,
 expectedResult(Code, NewName));
@@ -539,6 +539,13 @@
  void fo^o() {})cpp",
"used outside main file", !HeaderFile, nullptr /*no index*/},
 
+  {R"cpp(// disallow rename on blacklisted symbols (e.g. std symbols)
+ namespace std {
+ class str^ing {};
+ }
+   )cpp",
+   "not a supported kind", !HeaderFile, Index},
+
   {R"cpp(
  void foo(int);
  void foo(char);
Index: clang-tools-extra/clangd/refactor/RenameBlacklist.h
===
--- /dev/null
+++ clang-tools-extra/clangd/refactor/RenameBlacklist.h
@@ -0,0 +1,24 @@
+//===--- RenameBlacklist.h -  *- C++-*-===//
+//
+// 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
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_REFACTOR_RENAME_BLACKLIST_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_REFACTOR_RENAME_BLACKLIST_H
+
+#include "clang/AST/Decl.h"
+#include "llvm/ADT/DenseSet.h"
+
+namespace clang {
+namespace clangd {
+
+// Returns true if the given decl is disallowed for rename.
+bool isRenameBlacklisted(const NamedDecl &RenameDecl);
+
+} // namespace clangd
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_REFACTOR_RENAME_BLACKLIST_H
Index: clang-tools-extra/clangd/refactor/RenameBlacklist.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/refactor/RenameBlacklist.cpp
@@ -0,0 +1,24 @@
+//===--- RenameBlacklist.cpp -  --*- C++-*-===//
+//
+// 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 "refactor/RenameBlacklist.h"
+
+namespace clang {
+namespace clangd {
+
+bool isRenameBlacklisted(const NamedDecl &RenameDecl) {
+  static const auto *StdSymbols = new llvm::DenseSet({
+#define SYMBOL(Name, NameSpace, Header) {#NameSpace #Name},
+#include "StdSymbolMap.inc"
+#undef SYMBOL
+  });
+  return StdSymbols->count(RenameDecl.getQualifiedNameAsString());
+}
+
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -14,6 +14,7 @@
 #include "Selection.h"
 #include "SourceCode.h"
 #include "index/SymbolCollector.h"
+#include "refactor/RenameBlacklist.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/SourceLocation.h"
@@ -105,7 +106,7 @@
   AmbiguousSymbol,
 };
 
-llvm::Optional renameable(const Decl &RenameDecl,
+llvm::Optional renameable(const NamedDecl &RenameDecl,
   StringRef MainFilePath,
   const SymbolIndex *Index,
   bool CrossFil

[PATCH] D73451: [clangd] Update the include mappings for std symbols.

2020-01-27 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.

Use the latest offline version of cppreference.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73451

Files:
  clang-tools-extra/clangd/CSymbolMap.inc
  clang-tools-extra/clangd/StdSymbolMap.inc
  clang-tools-extra/clangd/include-mapping/cppreference_parser.py

Index: clang-tools-extra/clangd/include-mapping/cppreference_parser.py
===
--- clang-tools-extra/clangd/include-mapping/cppreference_parser.py
+++ clang-tools-extra/clangd/include-mapping/cppreference_parser.py
@@ -112,6 +112,8 @@
 
 
 def _ReadSymbolPage(path, name):
+  if not os.path.isfile(path):
+return []
   with open(path) as f:
 return _ParseSymbolPage(f.read(), name)
 
Index: clang-tools-extra/clangd/StdSymbolMap.inc
===
--- clang-tools-extra/clangd/StdSymbolMap.inc
+++ clang-tools-extra/clangd/StdSymbolMap.inc
@@ -5,7 +5,7 @@
 //
 // Automatically generated file, DO NOT EDIT!
 //
-// Generated from cppreference offline HTML book (modified on 2018-10-28).
+// Generated from cppreference offline HTML book (modified on 2019-06-07).
 //===--===//
 
 SYMBOL(Assignable, std::, )
@@ -43,7 +43,11 @@
 SYMBOL(_Exit, std::, )
 SYMBOL(accumulate, std::, )
 SYMBOL(acos, std::, )
+SYMBOL(acosf, std::, )
 SYMBOL(acosh, std::, )
+SYMBOL(acoshf, std::, )
+SYMBOL(acoshl, std::, )
+SYMBOL(acosl, std::, )
 SYMBOL(add_const, std::, )
 SYMBOL(add_const_t, std::, )
 SYMBOL(add_cv, std::, )
@@ -73,6 +77,7 @@
 SYMBOL(alignment_of_v, std::, )
 SYMBOL(all_of, std::, )
 SYMBOL(allocate_shared, std::, )
+SYMBOL(allocate_shared_default_init, std::, )
 SYMBOL(allocator, std::, )
 SYMBOL(allocator_arg, std::, )
 SYMBOL(allocator_arg_t, std::, )
@@ -85,12 +90,23 @@
 SYMBOL(as_const, std::, )
 SYMBOL(asctime, std::, )
 SYMBOL(asin, std::, )
+SYMBOL(asinf, std::, )
 SYMBOL(asinh, std::, )
+SYMBOL(asinhf, std::, )
+SYMBOL(asinhl, std::, )
+SYMBOL(asinl, std::, )
+SYMBOL(assume_aligned, std::, )
 SYMBOL(async, std::, )
 SYMBOL(at_quick_exit, std::, )
 SYMBOL(atan, std::, )
 SYMBOL(atan2, std::, )
+SYMBOL(atan2f, std::, )
+SYMBOL(atan2l, std::, )
+SYMBOL(atanf, std::, )
 SYMBOL(atanh, std::, )
+SYMBOL(atanhf, std::, )
+SYMBOL(atanhl, std::, )
+SYMBOL(atanl, std::, )
 SYMBOL(atexit, std::, )
 SYMBOL(atof, std::, )
 SYMBOL(atoi, std::, )
@@ -127,7 +143,6 @@
 SYMBOL(atomic_store_explicit, std::, )
 SYMBOL(atomic_thread_fence, std::, )
 SYMBOL(atto, std::, )
-SYMBOL(auto_ptr, std::, )
 SYMBOL(back_insert_iterator, std::, )
 SYMBOL(back_inserter, std::, )
 SYMBOL(bad_alloc, std::, )
@@ -164,6 +179,7 @@
 SYMBOL(bidirectional_iterator_tag, std::, )
 SYMBOL(binary_search, std::, )
 SYMBOL(bind, std::, )
+SYMBOL(bind_front, std::, )
 SYMBOL(binomial_distribution, std::, )
 SYMBOL(bit_and, std::, )
 SYMBOL(bit_cast, std::, )
@@ -180,13 +196,18 @@
 SYMBOL(byte, std::, )
 SYMBOL(c16rtomb, std::, )
 SYMBOL(c32rtomb, std::, )
+SYMBOL(c8rtomb, std::, )
 SYMBOL(call_once, std::, )
 SYMBOL(calloc, std::, )
 SYMBOL(cauchy_distribution, std::, )
 SYMBOL(cbegin, std::, )
 SYMBOL(cbrt, std::, )
+SYMBOL(cbrtf, std::, )
+SYMBOL(cbrtl, std::, )
 SYMBOL(ceil, std::, )
 SYMBOL(ceil2, std::, )
+SYMBOL(ceilf, std::, )
+SYMBOL(ceill, std::, )
 SYMBOL(cend, std::, )
 SYMBOL(centi, std::, )
 SYMBOL(cerr, std::, )
@@ -225,14 +246,21 @@
 SYMBOL(conjunction, std::, )
 SYMBOL(conjunction_v, std::, )
 SYMBOL(const_pointer_cast, std::, )
+SYMBOL(contiguous_iterator_tag, std::, )
 SYMBOL(contract_violation, std::, )
 SYMBOL(copy, std::, )
 SYMBOL(copy_backward, std::, )
 SYMBOL(copy_if, std::, )
 SYMBOL(copy_n, std::, )
 SYMBOL(copysign, std::, )
+SYMBOL(copysignf, std::, )
+SYMBOL(copysignl, std::, )
 SYMBOL(cos, std::, )
+SYMBOL(cosf, std::, )
 SYMBOL(cosh, std::, )
+SYMBOL(coshf, std::, )
+SYMBOL(coshl, std::, )
+SYMBOL(cosl, std::, )
 SYMBOL(count, std::, )
 SYMBOL(count_if, std::, )
 SYMBOL(cout, std::, )
@@ -296,8 +324,14 @@
 SYMBOL(equal, std::, )
 SYMBOL(equal_range, std::, )
 SYMBOL(equal_to, std::, )
+SYMBOL(erase, std::, )
+SYMBOL(erase_if, std::, )
 SYMBOL(erf, std::, )
 SYMBOL(erfc, std::, )
+SYMBOL(erfcf, std::, )
+SYMBOL(erfcl, std::, )
+SYMBOL(erff, std::, )
+SYMBOL(erfl, std::, )
 SYMBOL(errc, std::, )
 SYMBOL(error_category, std::, )
 SYMBOL(error_code, std::, )
@@ -310,14 +344,25 @@
 SYMBOL(exit, std::, )
 SYMBOL(exp, std::, )
 SYMBOL(exp2, std::, )
+SYMBOL(exp2f, std::, )
+SYMBOL(exp2l, std::, )
+SYMBOL(expf, std::, )
+SYMBOL(expl, std::, )
 SYMBOL(expm1, std::, )
+SYMBOL(expm1f, std::, )
+SYMBOL(expm1l, std::, )
 SYMBOL(exponential_distribution, std::, )
 SYMBOL(extent, std::, )
 SYMBOL(extent_v, std::, )
 SYMBOL(extreme_value_distribution, std::, )
+SYMBOL(fabs, std::, )
+SYMBOL(fabsf, std::, )
+SYMB

[clang] 07c9d53 - [Alignment][NFC] Use Align with CreateAlignedLoad

2020-01-27 Thread Guillaume Chatelet via cfe-commits

Author: Guillaume Chatelet
Date: 2020-01-27T10:58:36+01:00
New Revision: 07c9d5326648802560adbc1b1b61316c7d3c406d

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

LOG: [Alignment][NFC] Use Align with CreateAlignedLoad

Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: 
http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790

Reviewers: courbet, bollu

Subscribers: hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 


Modified: 
clang/lib/CodeGen/CGBuilder.h
clang/lib/CodeGen/CGCXX.cpp
clang/lib/CodeGen/CodeGenFunction.h
llvm/include/llvm/IR/IRBuilder.h
llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
polly/lib/CodeGen/BlockGenerators.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuilder.h b/clang/lib/CodeGen/CGBuilder.h
index 049e1d4b7552..e736e83a8c66 100644
--- a/clang/lib/CodeGen/CGBuilder.h
+++ b/clang/lib/CodeGen/CGBuilder.h
@@ -68,38 +68,34 @@ class CGBuilderTy : public CGBuilderBaseTy {
   // take an alignment.
   llvm::LoadInst *CreateLoad(Address Addr, const llvm::Twine &Name = "") {
 return CreateAlignedLoad(Addr.getPointer(),
- Addr.getAlignment().getQuantity(),
- Name);
+ Addr.getAlignment().getAsAlign(), Name);
   }
   llvm::LoadInst *CreateLoad(Address Addr, const char *Name) {
 // This overload is required to prevent string literals from
 // ending up in the IsVolatile overload.
 return CreateAlignedLoad(Addr.getPointer(),
- Addr.getAlignment().getQuantity(),
- Name);
+ Addr.getAlignment().getAsAlign(), Name);
   }
   llvm::LoadInst *CreateLoad(Address Addr, bool IsVolatile,
  const llvm::Twine &Name = "") {
-return CreateAlignedLoad(Addr.getPointer(),
- Addr.getAlignment().getQuantity(),
- IsVolatile,
- Name);
+return CreateAlignedLoad(
+Addr.getPointer(), Addr.getAlignment().getAsAlign(), IsVolatile, Name);
   }
 
   using CGBuilderBaseTy::CreateAlignedLoad;
   llvm::LoadInst *CreateAlignedLoad(llvm::Value *Addr, CharUnits Align,
 const llvm::Twine &Name = "") {
-return CreateAlignedLoad(Addr, Align.getQuantity(), Name);
+return CreateAlignedLoad(Addr, Align.getAsAlign(), Name);
   }
   llvm::LoadInst *CreateAlignedLoad(llvm::Value *Addr, CharUnits Align,
 const char *Name) {
-return CreateAlignedLoad(Addr, Align.getQuantity(), Name);
+return CreateAlignedLoad(Addr, Align.getAsAlign(), Name);
   }
   llvm::LoadInst *CreateAlignedLoad(llvm::Type *Ty, llvm::Value *Addr,
 CharUnits Align,
 const llvm::Twine &Name = "") {
 assert(Addr->getType()->getPointerElementType() == Ty);
-return CreateAlignedLoad(Addr, Align.getQuantity(), Name);
+return CreateAlignedLoad(Addr, Align.getAsAlign(), Name);
   }
 
   // Note that we intentionally hide the CreateStore APIs that don't

diff  --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp
index 1928e0df3809..a4bd2c6d5da0 100644
--- a/clang/lib/CodeGen/CGCXX.cpp
+++ b/clang/lib/CodeGen/CGCXX.cpp
@@ -263,8 +263,8 @@ static CGCallee BuildAppleKextVirtualCall(CodeGenFunction 
&CGF,
  AddressPoint.AddressPointIndex;
   llvm::Value *VFuncPtr =
 CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfnkxt");
-  llvm::Value *VFunc =
-CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.PointerAlignInBytes);
+  llvm::Value *VFunc = CGF.Builder.CreateAlignedLoad(
+  VFuncPtr, llvm::Align(CGF.PointerAlignInBytes));
   CGCallee Callee(GD, VFunc);
   return Callee;
 }

diff  --git a/clang/lib/CodeGen/CodeGenFunction.h 
b/clang/lib/CodeGen/CodeGenFunction.h
index e4f60330bcc5..f48d8a4cc366 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -4414,7 +4414,7 @@ inline llvm::Value 
*DominatingLLVMValue::restore(CodeGenFunction &CGF,
 
   // Otherwise, it should be an alloca instruction, as set up in save().
   auto alloca = cast(value.getPointer());
-  return CGF.Builder.CreateAlignedLoad(alloca, alloca->getAlignment());
+  return CGF.Builder.CreateAlignedLoad(alloca, alloca->getAlign());
 }
 
 }  // end namespace CodeGen

diff  --git a/llvm/include/llvm/IR/IRBuilder.h 
b/llvm/include/llvm/IR/IRBuilder.h
index 7d75cd68bea0..5a290464739e 100644
---

[PATCH] D73449: [Alignment][NFC] Use Align with CreateAlignedLoad

2020-01-27 Thread Guillaume Chatelet via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG07c9d5326648: [Alignment][NFC] Use Align with 
CreateAlignedLoad (authored by gchatelet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73449

Files:
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGCXX.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
  polly/lib/CodeGen/BlockGenerators.cpp

Index: polly/lib/CodeGen/BlockGenerators.cpp
===
--- polly/lib/CodeGen/BlockGenerators.cpp
+++ polly/lib/CodeGen/BlockGenerators.cpp
@@ -316,8 +316,8 @@
 
   Value *NewPointer =
   generateLocationAccessed(Stmt, Load, BBMap, LTS, NewAccesses);
-  Value *ScalarLoad = Builder.CreateAlignedLoad(
-  NewPointer, Load->getAlignment(), Load->getName() + "_p_scalar_");
+  Value *ScalarLoad = Builder.CreateAlignedLoad(NewPointer, Load->getAlign(),
+Load->getName() + "_p_scalar_");
 
   if (PollyDebugPrinting)
 RuntimeDebugBuilder::createCPUPrinter(Builder, "Load from ", NewPointer,
Index: llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
===
--- llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
+++ llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
@@ -517,8 +517,8 @@
 
   LoadInst *createColumnLoad(Value *ColumnPtr, Type *EltType,
  IRBuilder<> Builder) {
-unsigned Align = DL.getABITypeAlignment(EltType);
-return Builder.CreateAlignedLoad(ColumnPtr, Align, "col.load");
+return Builder.CreateAlignedLoad(
+ColumnPtr, Align(DL.getABITypeAlignment(EltType)), "col.load");
   }
 
   StoreInst *createColumnStore(Value *ColumnValue, Value *ColumnPtr,
Index: llvm/include/llvm/IR/IRBuilder.h
===
--- llvm/include/llvm/IR/IRBuilder.h
+++ llvm/include/llvm/IR/IRBuilder.h
@@ -1819,19 +1819,27 @@
   }
 
   // Deprecated [opaque pointer types]
-  LoadInst *CreateAlignedLoad(Value *Ptr, unsigned Align, const char *Name) {
+  LLVM_ATTRIBUTE_DEPRECATED(LoadInst *CreateAlignedLoad(Value *Ptr,
+unsigned Align,
+const char *Name),
+"Use the version that takes MaybeAlign instead") {
 return CreateAlignedLoad(Ptr->getType()->getPointerElementType(), Ptr,
  MaybeAlign(Align), Name);
   }
   // Deprecated [opaque pointer types]
-  LoadInst *CreateAlignedLoad(Value *Ptr, unsigned Align,
-  const Twine &Name = "") {
+  LLVM_ATTRIBUTE_DEPRECATED(LoadInst *CreateAlignedLoad(Value *Ptr,
+unsigned Align,
+const Twine &Name = ""),
+"Use the version that takes MaybeAlign instead") {
 return CreateAlignedLoad(Ptr->getType()->getPointerElementType(), Ptr,
  MaybeAlign(Align), Name);
   }
   // Deprecated [opaque pointer types]
-  LoadInst *CreateAlignedLoad(Value *Ptr, unsigned Align, bool isVolatile,
-  const Twine &Name = "") {
+  LLVM_ATTRIBUTE_DEPRECATED(LoadInst *CreateAlignedLoad(Value *Ptr,
+unsigned Align,
+bool isVolatile,
+const Twine &Name = ""),
+"Use the version that takes MaybeAlign instead") {
 return CreateAlignedLoad(Ptr->getType()->getPointerElementType(), Ptr,
  MaybeAlign(Align), isVolatile, Name);
   }
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -4414,7 +4414,7 @@
 
   // Otherwise, it should be an alloca instruction, as set up in save().
   auto alloca = cast(value.getPointer());
-  return CGF.Builder.CreateAlignedLoad(alloca, alloca->getAlignment());
+  return CGF.Builder.CreateAlignedLoad(alloca, alloca->getAlign());
 }
 
 }  // end namespace CodeGen
Index: clang/lib/CodeGen/CGCXX.cpp
===
--- clang/lib/CodeGen/CGCXX.cpp
+++ clang/lib/CodeGen/CGCXX.cpp
@@ -263,8 +263,8 @@
  AddressPoint.AddressPointIndex;
   llvm::Value *VFuncPtr =
 CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfnkxt");
-  llvm::Value *VFunc =
-CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.PointerAlignInBytes);
+  llvm::Value *VFunc = CGF.Builder

[PATCH] D73450: [clangd] Add a symbol-name-based blacklist for rename.

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

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

{icon times-circle color=red} clang-tidy: fail. clang-tidy found 0 errors and 1 
warnings 
.
 1 of them are added as review comments below (why? 
).

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

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


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73450



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


[PATCH] D73270: [clang-tidy] Fix false positive in bugprone-infinite-loop

2020-01-27 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

Please talk to Hans Wennborg  about cherry-picking this 
change into the release. I think it is a safe change, if Hans needs that sort 
of review from someone.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73270



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


[PATCH] D73441: [clang-tidy] Fix bugprone-use-after-move when move is in noexcept operator

2020-01-27 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp:1276
+namespace PR44667 {
+#define REQUIRE(expr) (void)(expr);
+struct S {};

njames93 wrote:
> gribozavr2 wrote:
> > Is the macro a necessary part of this test? If not, can it be removed?
> I like to stick to the bug report as much as possible
This is not generally the policy in LLVM and Clang. We prefer minimal 
reproducers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73441



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


[PATCH] D73453: Preserve -nostdinc and --sysroot when calling query driver

2020-01-27 Thread Tobias Pisani via Phabricator via cfe-commits
topisani created this revision.
topisani added reviewers: kadircet, klimek.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, 
ilya-biryukov.
Herald added a project: clang.

Solves this issue: https://github.com/clangd/clangd/issues/157

This is my first contribution to an llvm project, so I hope I'm doing it right!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D73453

Files:
  clang-tools-extra/clangd/QueryDriverDatabase.cpp


Index: clang-tools-extra/clangd/QueryDriverDatabase.cpp
===
--- clang-tools-extra/clangd/QueryDriverDatabase.cpp
+++ clang-tools-extra/clangd/QueryDriverDatabase.cpp
@@ -85,9 +85,10 @@
   return SystemIncludes;
 }
 
-std::vector extractSystemIncludes(PathRef Driver,
-   llvm::StringRef Lang,
-   llvm::Regex &QueryDriverRegex) {
+std::vector
+extractSystemIncludes(PathRef Driver, llvm::StringRef Lang,
+  llvm::ArrayRef PreservedArgs,
+  llvm::Regex &QueryDriverRegex) {
   trace::Span Tracer("Extract system includes");
   SPAN_ATTACH(Tracer, "driver", Driver);
   SPAN_ATTACH(Tracer, "lang", Lang);
@@ -120,14 +121,15 @@
   llvm::Optional Redirects[] = {
   {""}, {""}, llvm::StringRef(StdErrPath)};
 
-  // Should we also preserve flags like "-sysroot", "-nostdinc" ?
-  const llvm::StringRef Args[] = {Driver, "-E", "-x", Lang, "-", "-v"};
+  llvm::SmallVector Args = {Driver, "-E", "-x",
+ Lang,   "-",  "-v"};
+  llvm::copy(PreservedArgs, std::back_inserter(Args));
 
   if (int RC = llvm::sys::ExecuteAndWait(Driver, Args, /*Env=*/llvm::None,
  Redirects)) {
 elog("System include extraction: driver execution failed with return code: 
"
- "{0}",
- llvm::to_string(RC));
+ "{0}. Driver: {1}, args: [{2}]",
+ llvm::to_string(RC), Driver, llvm::join(Args, ", "));
 return {};
   }
 
@@ -218,12 +220,20 @@
   return Cmd;
 
 llvm::StringRef Lang;
+llvm::SmallVector PreservedArgs;
 for (size_t I = 0, E = Cmd->CommandLine.size(); I < E; ++I) {
   llvm::StringRef Arg = Cmd->CommandLine[I];
   if (Arg == "-x" && I + 1 < E)
 Lang = Cmd->CommandLine[I + 1];
   else if (Arg.startswith("-x"))
 Lang = Arg.drop_front(2).trim();
+  else if (Arg == "-nostdinc")
+PreservedArgs.push_back(Arg);
+  else if (Arg == "--sysroot" && I + 1 < E) {
+PreservedArgs.push_back(Arg);
+PreservedArgs.push_back(Cmd->CommandLine[I + 1]);
+  } else if (Arg.startswith("--sysroot="))
+PreservedArgs.push_back(Arg);
 }
 if (Lang.empty()) {
   llvm::StringRef Ext = llvm::sys::path::extension(File).trim('.');
@@ -247,8 +257,8 @@
   if (It != DriverToIncludesCache.end())
 SystemIncludes = It->second;
   else
-DriverToIncludesCache[Key] = SystemIncludes =
-extractSystemIncludes(Key.first, Key.second, QueryDriverRegex);
+DriverToIncludesCache[Key] = SystemIncludes = extractSystemIncludes(
+Key.first, Key.second, PreservedArgs, QueryDriverRegex);
 }
 
 return addSystemIncludes(*Cmd, SystemIncludes);
@@ -278,7 +288,7 @@
   if (QueryDriverGlobs.empty())
 return Base;
   return std::make_unique(QueryDriverGlobs,
-std::move(Base));
+   std::move(Base));
 }
 
 } // namespace clangd


Index: clang-tools-extra/clangd/QueryDriverDatabase.cpp
===
--- clang-tools-extra/clangd/QueryDriverDatabase.cpp
+++ clang-tools-extra/clangd/QueryDriverDatabase.cpp
@@ -85,9 +85,10 @@
   return SystemIncludes;
 }
 
-std::vector extractSystemIncludes(PathRef Driver,
-   llvm::StringRef Lang,
-   llvm::Regex &QueryDriverRegex) {
+std::vector
+extractSystemIncludes(PathRef Driver, llvm::StringRef Lang,
+  llvm::ArrayRef PreservedArgs,
+  llvm::Regex &QueryDriverRegex) {
   trace::Span Tracer("Extract system includes");
   SPAN_ATTACH(Tracer, "driver", Driver);
   SPAN_ATTACH(Tracer, "lang", Lang);
@@ -120,14 +121,15 @@
   llvm::Optional Redirects[] = {
   {""}, {""}, llvm::StringRef(StdErrPath)};
 
-  // Should we also preserve flags like "-sysroot", "-nostdinc" ?
-  const llvm::StringRef Args[] = {Driver, "-E", "-x", Lang, "-", "-v"};
+  llvm::SmallVector Args = {Driver, "-E", "-x",
+ Lang,   "-",  "-v"};
+  llvm::copy(PreservedArgs, std::back_inserter(Args));
 
   if (int RC = llvm::sys::ExecuteAndWait(Driver, Args, /*Env=*/llvm::None,
  Redirects)) {
 elog("System include e

[PATCH] D71966: [Wdocumentation][RFC] Improve identifier's of \param

2020-01-27 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

In D71966#1840957 , @Mordante wrote:

> So if I understand correctly:
>
> - `getParamNameAsWritten` will become `getArgText`
> - The `getParamName` will do the translation from the name in the 
> documentation to the name in the current function declaration. If the 
> parameter index is invalid the function will fail (with an assertion error) 
> and not fallback to call `getArgText`.


Yes, that would be my preference. Thanks!




Comment at: clang/include/clang-c/Documentation.h:383
 CINDEX_LINKAGE
-CXString clang_ParamCommandComment_getParamName(CXComment Comment);
 

Mordante wrote:
> gribozavr2 wrote:
> > Mordante wrote:
> > > gribozavr2 wrote:
> > > > Please don't modify existing APIs in libclang -- it provides a stable 
> > > > API and ABI, and what has shipped, can't be changed. New functionality 
> > > > has to be exposed as new functions, while old functions should be kept 
> > > > working to the extent possible. It means that the resulting API can be 
> > > > subpar, but oh well, a stable ABI is a contract of libclang.
> > > I thought I had read this API was allowed to change, but required adding 
> > > information to the release notes. (I can't find it quickly.)
> > > I'll undo the changes to the existing functions and add new functions 
> > > instead.
> > > I thought I had read this API was allowed to change
> > 
> > It would be interesting to find that doc. As far as I understand, libclang 
> > has a strict API & ABI stability rule.
> > 
> > > I'll undo the changes to the existing functions and add new functions 
> > > instead.
> > 
> > Thanks!
> > 
> >> I thought I had read this API was allowed to change
> > It would be interesting to find that doc. As far as I understand, libclang 
> > has a strict API & ABI stability rule.
> My interpretation of http://llvm.org/docs/DeveloperPolicy.html#c-api-changes 
> gave me this impression.
I see. Index.h explains the policy for libclang: 
https://github.com/llvm/llvm-project/blob/master/clang/include/clang-c/Index.h#L32-L33

If you feel like doing so, feel free to submit a patch for the developer policy 
to clarify libclang stability guarantees.


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

https://reviews.llvm.org/D71966



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


[PATCH] D73451: [clangd] Update the include mappings for std symbols.

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

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

{icon times-circle color=red} clang-tidy: fail. clang-tidy found 15 errors and 
0 warnings 
.
 15 of them are added as review comments below (why? 
).

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

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


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73451



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


[PATCH] D73441: [clang-tidy] Fix bugprone-use-after-move when move is in noexcept operator

2020-01-27 Thread Nathan James via Phabricator via cfe-commits
njames93 marked 3 inline comments as done.
njames93 added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp:1276
+namespace PR44667 {
+#define REQUIRE(expr) (void)(expr);
+struct S {};

gribozavr2 wrote:
> njames93 wrote:
> > gribozavr2 wrote:
> > > Is the macro a necessary part of this test? If not, can it be removed?
> > I like to stick to the bug report as much as possible
> This is not generally the policy in LLVM and Clang. We prefer minimal 
> reproducers.
I've kept it minimal, the REQUIRE definition is just to suppress other warnings 
about unused expressions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73441



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


[PATCH] D73441: [clang-tidy] Fix bugprone-use-after-move when move is in noexcept operator

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

- added more unevaluated context checks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73441

Files:
  clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
@@ -1271,3 +1271,28 @@
   }
 };
 }
+
+namespace PR44667 {
+#define REQUIRE(expr) (void)(expr);
+struct S {};
+
+void foo() {
+  S s;
+  REQUIRE(noexcept(S{std::move(s)}));
+  S other{std::move(s)};
+}
+void otherUnevaluated(){
+  S s;
+  REQUIRE(sizeof(S{std::move(s)}) > 8);
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wgnu-alignof-expression"
+  REQUIRE(alignof(S{std::move(s)}) > 8);
+#pragma clang diagnostic pop
+
+  // error: you need to include  before using the 'typeid' operator
+  // REQUIRE(typeid(S{std::move(s)}).name());
+
+  S other{std::move(s)};
+}
+} // namespace PR44667
Index: clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
@@ -8,6 +8,10 @@
 
 #include "UseAfterMoveCheck.h"
 
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
+#include "clang/AST/ExprConcepts.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Analysis/CFG.h"
 #include "clang/Lex/Lexer.h"
 
@@ -23,6 +27,22 @@
 
 namespace {
 
+AST_MATCHER(Expr, hasUnevaluatedContext){
+  if (isa(Node) || isa(Node)) return true;
+  if (const auto *UnaryExpr = dyn_cast(&Node)){
+switch (UnaryExpr->getKind()){
+  case UETT_SizeOf:
+  case UETT_AlignOf: return true;
+  default:
+  return false;
+}
+  }
+  if (const auto *TypeIDExpr = dyn_cast(&Node)){
+return !TypeIDExpr->isPotentiallyEvaluated();
+  }
+  return false;
+}
+
 /// Contains information about a use-after-move.
 struct UseAfterMove {
   // The DeclRefExpr that constituted the use of the object.
@@ -77,7 +97,8 @@
 static StatementMatcher inDecltypeOrTemplateArg() {
   return anyOf(hasAncestor(typeLoc()),
hasAncestor(declRefExpr(
-   
to(functionDecl(ast_matchers::isTemplateInstantiation());
+   to(functionDecl(ast_matchers::isTemplateInstantiation(),
+   hasAncestor(expr(hasUnevaluatedContext(;
 }
 
 UseAfterMoveFinder::UseAfterMoveFinder(ASTContext *TheContext)


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
@@ -1271,3 +1271,28 @@
   }
 };
 }
+
+namespace PR44667 {
+#define REQUIRE(expr) (void)(expr);
+struct S {};
+
+void foo() {
+  S s;
+  REQUIRE(noexcept(S{std::move(s)}));
+  S other{std::move(s)};
+}
+void otherUnevaluated(){
+  S s;
+  REQUIRE(sizeof(S{std::move(s)}) > 8);
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wgnu-alignof-expression"
+  REQUIRE(alignof(S{std::move(s)}) > 8);
+#pragma clang diagnostic pop
+
+  // error: you need to include  before using the 'typeid' operator
+  // REQUIRE(typeid(S{std::move(s)}).name());
+
+  S other{std::move(s)};
+}
+} // namespace PR44667
Index: clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
@@ -8,6 +8,10 @@
 
 #include "UseAfterMoveCheck.h"
 
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
+#include "clang/AST/ExprConcepts.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Analysis/CFG.h"
 #include "clang/Lex/Lexer.h"
 
@@ -23,6 +27,22 @@
 
 namespace {
 
+AST_MATCHER(Expr, hasUnevaluatedContext){
+  if (isa(Node) || isa(Node)) return true;
+  if (const auto *UnaryExpr = dyn_cast(&Node)){
+switch (UnaryExpr->getKind()){
+  case UETT_SizeOf:
+  case UETT_AlignOf: return true;
+  default:
+  return false;
+}
+  }
+  if (const auto *TypeIDExpr = dyn_cast(&Node)){
+return !TypeIDExpr->isPotentiallyEvaluated();
+  }
+  return false;
+}
+
 /// Contains information about a use-after-move.
 struct UseAfterMove {
   // The DeclRefExpr that constituted the use of the object.
@@ -77,7 +97,8 @@
 static StatementMatcher inDecltypeOrTemplateArg() {
   return anyOf(hasAncestor(typeLoc()),
  

[PATCH] D73441: [clang-tidy] Fix bugprone-use-after-move when move is in noexcept operator

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

- Elide braces


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73441

Files:
  clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
@@ -1271,3 +1271,28 @@
   }
 };
 }
+
+namespace PR44667 {
+#define REQUIRE(expr) (void)(expr);
+struct S {};
+
+void foo() {
+  S s;
+  REQUIRE(noexcept(S{std::move(s)}));
+  S other{std::move(s)};
+}
+void otherUnevaluated(){
+  S s;
+  REQUIRE(sizeof(S{std::move(s)}) > 8);
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wgnu-alignof-expression"
+  REQUIRE(alignof(S{std::move(s)}) > 8);
+#pragma clang diagnostic pop
+
+  // error: you need to include  before using the 'typeid' operator
+  // REQUIRE(typeid(S{std::move(s)}).name());
+
+  S other{std::move(s)};
+}
+} // namespace PR44667
Index: clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
@@ -8,6 +8,10 @@
 
 #include "UseAfterMoveCheck.h"
 
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
+#include "clang/AST/ExprConcepts.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Analysis/CFG.h"
 #include "clang/Lex/Lexer.h"
 
@@ -23,6 +27,21 @@
 
 namespace {
 
+AST_MATCHER(Expr, hasUnevaluatedContext){
+  if (isa(Node) || isa(Node)) return true;
+  if (const auto *UnaryExpr = dyn_cast(&Node)){
+switch (UnaryExpr->getKind()){
+  case UETT_SizeOf:
+  case UETT_AlignOf: return true;
+  default:
+  return false;
+}
+  }
+  if (const auto *TypeIDExpr = dyn_cast(&Node))
+return !TypeIDExpr->isPotentiallyEvaluated();
+  return false;
+}
+
 /// Contains information about a use-after-move.
 struct UseAfterMove {
   // The DeclRefExpr that constituted the use of the object.
@@ -77,7 +96,8 @@
 static StatementMatcher inDecltypeOrTemplateArg() {
   return anyOf(hasAncestor(typeLoc()),
hasAncestor(declRefExpr(
-   
to(functionDecl(ast_matchers::isTemplateInstantiation());
+   to(functionDecl(ast_matchers::isTemplateInstantiation(),
+   hasAncestor(expr(hasUnevaluatedContext(;
 }
 
 UseAfterMoveFinder::UseAfterMoveFinder(ASTContext *TheContext)


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
@@ -1271,3 +1271,28 @@
   }
 };
 }
+
+namespace PR44667 {
+#define REQUIRE(expr) (void)(expr);
+struct S {};
+
+void foo() {
+  S s;
+  REQUIRE(noexcept(S{std::move(s)}));
+  S other{std::move(s)};
+}
+void otherUnevaluated(){
+  S s;
+  REQUIRE(sizeof(S{std::move(s)}) > 8);
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wgnu-alignof-expression"
+  REQUIRE(alignof(S{std::move(s)}) > 8);
+#pragma clang diagnostic pop
+
+  // error: you need to include  before using the 'typeid' operator
+  // REQUIRE(typeid(S{std::move(s)}).name());
+
+  S other{std::move(s)};
+}
+} // namespace PR44667
Index: clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
@@ -8,6 +8,10 @@
 
 #include "UseAfterMoveCheck.h"
 
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
+#include "clang/AST/ExprConcepts.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Analysis/CFG.h"
 #include "clang/Lex/Lexer.h"
 
@@ -23,6 +27,21 @@
 
 namespace {
 
+AST_MATCHER(Expr, hasUnevaluatedContext){
+  if (isa(Node) || isa(Node)) return true;
+  if (const auto *UnaryExpr = dyn_cast(&Node)){
+switch (UnaryExpr->getKind()){
+  case UETT_SizeOf:
+  case UETT_AlignOf: return true;
+  default:
+  return false;
+}
+  }
+  if (const auto *TypeIDExpr = dyn_cast(&Node))
+return !TypeIDExpr->isPotentiallyEvaluated();
+  return false;
+}
+
 /// Contains information about a use-after-move.
 struct UseAfterMove {
   // The DeclRefExpr that constituted the use of the object.
@@ -77,7 +96,8 @@
 static StatementMatcher inDecltypeOrTemplateArg() {
   return anyOf(hasAncestor(typeLoc()),
hasAncestor(declRefExpr(
- 

[PATCH] D71460: [OpenCL] Fix support for cl_khr_mipmap_image_writes

2020-01-27 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin updated this revision to Diff 240510.

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

https://reviews.llvm.org/D71460

Files:
  clang/include/clang/Basic/OpenCLExtensions.def
  clang/lib/Headers/opencl-c.h
  clang/test/SemaOpenCL/extension-version.cl


Index: clang/test/SemaOpenCL/extension-version.cl
===
--- clang/test/SemaOpenCL/extension-version.cl
+++ clang/test/SemaOpenCL/extension-version.cl
@@ -243,6 +243,18 @@
 #pragma OPENCL EXTENSION cl_khr_mipmap_image : enable
 
 #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_mipmap_image_writes
+#error "Missing cl_khr_mipmap_image_writes define"
+#endif
+#else
+#ifdef cl_khr_mipmap_image_writes
+#error "Incorrect cl_khr_mipmap_image_writes define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 
'cl_khr_mipmap_image_writes' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : enable
+
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
 #ifndef cl_khr_srgb_image_writes
 #error "Missing cl_khr_srgb_image_writes define"
 #endif
Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -14682,7 +14682,7 @@
 
 // OpenCL Extension v2.0 s9.18 - Mipmaps
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
-#ifdef cl_khr_mipmap_image
+#if defined(cl_khr_mipmap_image_writes)
 void __ovld write_imagef(write_only image1d_t image, int coord, int lod, 
float4 color);
 void __ovld write_imagei(write_only image1d_t image, int coord, int lod, int4 
color);
 void __ovld write_imageui(write_only image1d_t image, int coord, int lod, 
uint4 color);
@@ -14699,15 +14699,16 @@
 void __ovld write_imagei(write_only image2d_array_t image_array, int4 coord, 
int lod, int4 color);
 void __ovld write_imageui(write_only image2d_array_t image_array, int4 coord, 
int lod, uint4 color);
 
-void __ovld write_imagef(write_only image2d_depth_t image, int2 coord, int 
lod, float color);
-void __ovld write_imagef(write_only image2d_array_depth_t image, int4 coord, 
int lod, float color);
+void __ovld write_imagef(write_only image2d_depth_t image, int2 coord, int 
lod, float depth);
+void __ovld write_imagef(write_only image2d_array_depth_t image, int4 coord, 
int lod, float depth);
 
 #ifdef cl_khr_3d_image_writes
 void __ovld write_imagef(write_only image3d_t image, int4 coord, int lod, 
float4 color);
 void __ovld write_imagei(write_only image3d_t image, int4 coord, int lod, int4 
color);
 void __ovld write_imageui(write_only image3d_t image, int4 coord, int lod, 
uint4 color);
-#endif
-#endif //cl_khr_mipmap_image
+#endif //cl_khr_3d_image_writes
+
+#endif //defined(cl_khr_mipmap_image_writes)
 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_2_0)
 
 // Image write functions for half4 type
@@ -14756,7 +14757,7 @@
 #endif //cl_khr_depth_images
 
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
-#ifdef cl_khr_mipmap_image
+#if defined(cl_khr_mipmap_image_writes)
 void __ovld write_imagef(read_write image1d_t image, int coord, int lod, 
float4 color);
 void __ovld write_imagei(read_write image1d_t image, int coord, int lod, int4 
color);
 void __ovld write_imageui(read_write image1d_t image, int coord, int lod, 
uint4 color);
@@ -14780,8 +14781,9 @@
 void __ovld write_imagef(read_write image3d_t image, int4 coord, int lod, 
float4 color);
 void __ovld write_imagei(read_write image3d_t image, int4 coord, int lod, int4 
color);
 void __ovld write_imageui(read_write image3d_t image, int4 coord, int lod, 
uint4 color);
-#endif
-#endif //cl_khr_mipmap_image
+#endif //cl_khr_3d_image_writes
+
+#endif //cl_khr_mipmap_image_writes
 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_2_0)
 
 // Image write functions for half4 type
Index: clang/include/clang/Basic/OpenCLExtensions.def
===
--- clang/include/clang/Basic/OpenCLExtensions.def
+++ clang/include/clang/Basic/OpenCLExtensions.def
@@ -70,6 +70,7 @@
 OPENCLEXT_INTERNAL(cl_khr_egl_event, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_egl_image, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_mipmap_image, 200, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_mipmap_image_writes, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_srgb_image_writes, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_subgroups, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_terminate_context, 200, ~0U)


Index: clang/test/SemaOpenCL/extension-version.cl
===
--- clang/test/SemaOpenCL/extension-version.cl
+++ clang/test/SemaOpenCL/extension-version.cl
@@ -243,6 +243,18 @@
 #pragma OPENCL EXTENSION cl_khr_mipmap_image : enable
 
 #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#ifndef

[PATCH] D73413: [clang-tidy] Add check to detect external definitions with no header declaration

2020-01-27 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

Thank you for the contribution! I didn't review the code thoroughly yet, only 
the tests.




Comment at: 
clang-tools-extra/clang-tidy/misc/MissingHeaderFileDeclarationCheck.cpp:29
+
+  bool isHeader() const {
+return llvm::StringSwitch(Extension)

I think we should consider any file other than the main file to be a header 
(anything brought in by `#include`). Projects have lots of different convention 
-- for example, LLVM uses a `.inc` extension for some generated files and 
x-macro files. The standard library does not have any extensions at all (and 
I'm sure some projects imitate that) etc.



Comment at: 
clang-tools-extra/clang-tidy/misc/MissingHeaderFileDeclarationCheck.cpp:75
+  continue;
+if (AnyHeader || File->NamePart.equals_lower(ThisFile->NamePart))
+  return; // Found a good candidate for matching decl

This heuristic should be a lot more complex. In practice people have more 
complex naming conventions (for example, in Clang, Sema.h corresponds to many 
files named SemaSomethingSomething.cpp).

I think there is a high chance that checking only a header with a matching name 
will satisfy too few projects to be worth implementing.

On the other hand, if you could use C++ or Clang modules to narrow down the 
list of headers where the declaration should appear, that would be a much 
stronger signal.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/misc-missing-header-file-declaration.rst:14
+   
+   If set to `1` the check will look in any header file for a matching
+   declaration.

Unclear what happens when CheckAnyHeader=0.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/Inputs/misc-missing-header-file-declaration/misc-missing-header-file-declaration.cpp.tmp.h:22
+extern void nS();
+} // namespace ns2
+

Need a test for a template defined in a header (shouldn't produce a warning).

Need a test for an inline function defined in a header (also no warning).

Need a test for a static function defined in a header (should produce no 
warning, but it is bad for other reasons, however I think they are out of scope 
for this checker).

Need a test for an anonymous namespace in a header (no warning).



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/misc-missing-header-file-declaration.cpp:1
+// RUN: %check_clang_tidy %s misc-missing-header-file-declaration %t -- \
+// RUN: -- -I%S/Inputs/misc-missing-header-file-declaration

Need lots of tests for classes, out-of-line member declarations, member 
templates, out-of-line member templates, class templates, variable templates 
etc.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/misc-missing-header-file-declaration.cpp:80
+void templateFuncNoHeader() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Function 'templateFuncNoHeader' is 
defined with external linkage
+

Need a test for a template in an anonymous namespace.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73413



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


[PATCH] D71460: [OpenCL] Fix support for cl_khr_mipmap_image_writes

2020-01-27 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin marked 2 inline comments as done.
AlexeySotkin added inline comments.



Comment at: clang/lib/Headers/opencl-c.h:14686
+#if defined(cl_khr_mipmap_image_writes)
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : begin
 void __ovld write_imagef(write_only image1d_t image, int coord, int lod, 
float4 color);

Anastasia wrote:
> AlexeySotkin wrote:
> > Anastasia wrote:
> > > Do we actually need pragma for this extension? I.e. does it need to 
> > > activate any special mode in the compiler?
> > I'm not aware of any special mode required for this extension. These 
> > begin/end pragma lines were added to disable the extension by default as it 
> > is [[ 
> > https://github.com/KhronosGroup/OpenCL-Docs/blob/master/ext/introduction.asciidoc#compiler-directives-for-optional-extensions
> >  | required ]] by the OpenCL extension spec. Is there any other mechanism 
> > which should be used for this purpose?
> > Probably, we should do the same for `cl_khr_mipmap_image`(and maybe 
> > others?), because with the current compiler, built-ins from this extension 
> > can be compiled successfully even if `#pragma OPENCL EXTENSION 
> > cl_khr_mipmap_image : disable` is specified. See 
> > https://godbolt.org/z/fNEWuG
> What I am saying is that `pragma` is only typically used to activate some 
> special mode in the compiler. If we don't need to activate anything perhaps 
> we don't need to add `pragma` at all? It simplifies compiler and application 
> code too. Would regular include mechanisms be enough to guard the 
> availability of those functions?
> 
> Maybe this thread will help to understand the topic better: 
> https://github.com/KhronosGroup/OpenCL-Docs/issues/82
I think you are right. I have removed the pragma.


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

https://reviews.llvm.org/D71460



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


[PATCH] D73450: [clangd] Add a symbol-name-based blacklist for rename.

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



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:138
 IsMainFileOnly = false;
-  bool IsIndexable =
-  isa(RenameDecl) &&
-  SymbolCollector::shouldCollectSymbol(
-  cast(RenameDecl), RenameDecl.getASTContext(),
-  SymbolCollector::Options(), IsMainFileOnly);
+  bool IsIndexable = SymbolCollector::shouldCollectSymbol(
+  RenameDecl, RenameDecl.getASTContext(), SymbolCollector::Options(),

nit: maybe just `if (!shouldCollectSymbol...) return nonindexable;` ?



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:466
 
   auto DeclsUnderCursor = locateDeclAt(AST, IdentifierToken->location());
   if (DeclsUnderCursor.empty())

`locateDeclAt` is already working on `NamedDecl`s but returning a set of 
`Decl`s could you rather update that helper to return a set of `NamedDecl`s 
instead?



Comment at: clang-tools-extra/clangd/refactor/RenameBlacklist.cpp:14
+
+bool isRenameBlacklisted(const NamedDecl &RenameDecl) {
+  static const auto *StdSymbols = new llvm::DenseSet({

I don't think there's much value in having that in its own file, could you move 
it into the rename.cpp ?



Comment at: clang-tools-extra/clangd/unittests/RenameTests.cpp:453
   rename({RenamePos, NewName, AST, testPath(TU.Filename)});
-  ASSERT_TRUE(bool(RenameResult)) << RenameResult.takeError();
+  ASSERT_TRUE(bool(RenameResult)) << RenameResult.takeError() << T;
   ASSERT_EQ(1u, RenameResult->size());

maybe `SCOPEDT_TRACE(T)` instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73450



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


[PATCH] D73451: [clangd] Update the include mappings for std symbols.

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

we seem to be missing some symbols now, like `polymorphic_allocator` 
`random_shuffle` `gets` etc. and there seems to be a functional change to the 
parser. Are they intentional, if so why?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73451



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


[PATCH] D73441: [clang-tidy] Fix bugprone-use-after-move when move is in noexcept operator

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

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

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

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

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


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73441



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


[PATCH] D73441: [clang-tidy] Fix bugprone-use-after-move when move is in noexcept operator

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

- Fix formatting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73441

Files:
  clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
@@ -1271,3 +1271,28 @@
   }
 };
 }
+
+namespace PR44667 {
+#define REQUIRE(expr) (void)(expr);
+struct S {};
+
+void foo() {
+  S s;
+  REQUIRE(noexcept(S{std::move(s)}));
+  S other{std::move(s)};
+}
+void otherUnevaluated(){
+  S s;
+  REQUIRE(sizeof(S{std::move(s)}) > 8);
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wgnu-alignof-expression"
+  REQUIRE(alignof(S{std::move(s)}) > 8);
+#pragma clang diagnostic pop
+
+  // error: you need to include  before using the 'typeid' operator
+  // REQUIRE(typeid(S{std::move(s)}).name());
+
+  S other{std::move(s)};
+}
+} // namespace PR44667
Index: clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
@@ -8,6 +8,10 @@
 
 #include "UseAfterMoveCheck.h"
 
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
+#include "clang/AST/ExprConcepts.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Analysis/CFG.h"
 #include "clang/Lex/Lexer.h"
 
@@ -23,6 +27,23 @@
 
 namespace {
 
+AST_MATCHER(Expr, hasUnevaluatedContext) {
+  if (isa(Node) || isa(Node))
+return true;
+  if (const auto *UnaryExpr = dyn_cast(&Node)) {
+switch (UnaryExpr->getKind()) {
+case UETT_SizeOf:
+case UETT_AlignOf:
+  return true;
+default:
+  return false;
+}
+  }
+  if (const auto *TypeIDExpr = dyn_cast(&Node))
+return !TypeIDExpr->isPotentiallyEvaluated();
+  return false;
+}
+
 /// Contains information about a use-after-move.
 struct UseAfterMove {
   // The DeclRefExpr that constituted the use of the object.
@@ -77,7 +98,8 @@
 static StatementMatcher inDecltypeOrTemplateArg() {
   return anyOf(hasAncestor(typeLoc()),
hasAncestor(declRefExpr(
-   
to(functionDecl(ast_matchers::isTemplateInstantiation());
+   to(functionDecl(ast_matchers::isTemplateInstantiation(),
+   hasAncestor(expr(hasUnevaluatedContext(;
 }
 
 UseAfterMoveFinder::UseAfterMoveFinder(ASTContext *TheContext)


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
@@ -1271,3 +1271,28 @@
   }
 };
 }
+
+namespace PR44667 {
+#define REQUIRE(expr) (void)(expr);
+struct S {};
+
+void foo() {
+  S s;
+  REQUIRE(noexcept(S{std::move(s)}));
+  S other{std::move(s)};
+}
+void otherUnevaluated(){
+  S s;
+  REQUIRE(sizeof(S{std::move(s)}) > 8);
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wgnu-alignof-expression"
+  REQUIRE(alignof(S{std::move(s)}) > 8);
+#pragma clang diagnostic pop
+
+  // error: you need to include  before using the 'typeid' operator
+  // REQUIRE(typeid(S{std::move(s)}).name());
+
+  S other{std::move(s)};
+}
+} // namespace PR44667
Index: clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
@@ -8,6 +8,10 @@
 
 #include "UseAfterMoveCheck.h"
 
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
+#include "clang/AST/ExprConcepts.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Analysis/CFG.h"
 #include "clang/Lex/Lexer.h"
 
@@ -23,6 +27,23 @@
 
 namespace {
 
+AST_MATCHER(Expr, hasUnevaluatedContext) {
+  if (isa(Node) || isa(Node))
+return true;
+  if (const auto *UnaryExpr = dyn_cast(&Node)) {
+switch (UnaryExpr->getKind()) {
+case UETT_SizeOf:
+case UETT_AlignOf:
+  return true;
+default:
+  return false;
+}
+  }
+  if (const auto *TypeIDExpr = dyn_cast(&Node))
+return !TypeIDExpr->isPotentiallyEvaluated();
+  return false;
+}
+
 /// Contains information about a use-after-move.
 struct UseAfterMove {
   // The DeclRefExpr that constituted the use of the object.
@@ -77,7 +98,8 @@
 static StatementMatcher inDecltypeOrTemplateArg() {
   return anyOf(hasAncestor(typeLoc()),
hasAnce

[PATCH] D73441: [clang-tidy] Fix bugprone-use-after-move when move is in noexcept operator

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

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

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

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

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


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73441



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


[PATCH] D73413: [clang-tidy] Add check to detect external definitions with no header declaration

2020-01-27 Thread Nathan James via Phabricator via cfe-commits
njames93 marked 2 inline comments as done.
njames93 added a comment.

I'll work up those other test cases




Comment at: 
clang-tools-extra/clang-tidy/misc/MissingHeaderFileDeclarationCheck.cpp:29
+
+  bool isHeader() const {
+return llvm::StringSwitch(Extension)

gribozavr2 wrote:
> I think we should consider any file other than the main file to be a header 
> (anything brought in by `#include`). Projects have lots of different 
> convention -- for example, LLVM uses a `.inc` extension for some generated 
> files and x-macro files. The standard library does not have any extensions at 
> all (and I'm sure some projects imitate that) etc.
I agree in part, but there is one case that I didn't want to happen and that is 
when clang-tidy is ran as a text editor plugin. Often it will blindly treat the 
current open file as the main file which would lead to a lot of false 
positives, Would a better metric being matching on file extensions not 
corresponding to source files (c, cc, cxx, cpp)?



Comment at: 
clang-tools-extra/clang-tidy/misc/MissingHeaderFileDeclarationCheck.cpp:75
+  continue;
+if (AnyHeader || File->NamePart.equals_lower(ThisFile->NamePart))
+  return; // Found a good candidate for matching decl

gribozavr2 wrote:
> This heuristic should be a lot more complex. In practice people have more 
> complex naming conventions (for example, in Clang, Sema.h corresponds to many 
> files named SemaSomethingSomething.cpp).
> 
> I think there is a high chance that checking only a header with a matching 
> name will satisfy too few projects to be worth implementing.
> 
> On the other hand, if you could use C++ or Clang modules to narrow down the 
> list of headers where the declaration should appear, that would be a much 
> stronger signal.
That is the reason I added the CheckAnyHeader option. For small projects the 
matching name would be usually be enough, but for big complex projects there is 
no feasible check that would work. Falling back to making sure every external 
definition has a declaration in at least one header will always be a good 
warning


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73413



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


[PATCH] D73457: [Clang] Warn about 'z' printf modifier in old MSVC.

2020-01-27 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: aaron.ballman, lebedev.ri.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The 'z' length modifier, signalling that an integer format specifier
takes a `size_t` sized integer, is only supported by the C library of
MSVC 2015 and later. Earlier versions don't recognize the 'z' at all,
and respond to `printf("%zu", x)` by just printing "zu".

So, if the MS compatibility version is set to something specific which
is earlier than 2015, it's useful to warn about 'z' modifiers in
printf format strings we check.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73457

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/lib/AST/FormatString.cpp
  clang/test/Sema/format-strings-ms.c


Index: clang/test/Sema/format-strings-ms.c
===
--- clang/test/Sema/format-strings-ms.c
+++ clang/test/Sema/format-strings-ms.c
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility 
-triple=i386-pc-win32 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility 
-triple=i386-pc-win32 -fms-compatibility-version=19 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility 
-triple=i386-pc-win32 -fms-compatibility-version=18 -DNO_z_MODIFIER %s
 // RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility 
-triple=i386-pc-win32 -Wformat-non-iso -DNON_ISO_WARNING %s
 
 int printf(const char *format, ...) __attribute__((format(printf, 1, 2)));
@@ -85,4 +87,11 @@
   scanf("%Z", p); // expected-warning{{invalid conversion specifier 'Z'}}
 }
 
+void size_t_test(size_t s) {
+  printf("%zu", s);
+#ifdef NO_z_MODIFIER
+  // expected-warning@-2 {{length modifier 'z' results in undefined behavior 
or no effect with 'u' conversion specifier}}
+#endif
+}
+
 #endif
Index: clang/lib/AST/FormatString.cpp
===
--- clang/lib/AST/FormatString.cpp
+++ clang/lib/AST/FormatString.cpp
@@ -748,6 +748,16 @@
 case LengthModifier::AsIntMax:
 case LengthModifier::AsSizeT:
 case LengthModifier::AsPtrDiff:
+  if (LM.getKind() == LengthModifier::AsSizeT &&
+  Target.getTriple().isOSMSVCRT() &&
+  LO.isMSCompatibilityVersionSpecified() &&
+  !LO.isCompatibleWithMSVC(LangOptions::MSVC2015)) {
+// The standard libraries before MSVC2015 didn't support the 'z' length
+// modifier for size_t. So if the MS compatibility version is specified
+// and less than that, reject.
+return false;
+  }
+
   switch (CS.getKind()) {
 case ConversionSpecifier::dArg:
 case ConversionSpecifier::DArg:
Index: clang/include/clang/Basic/LangOptions.h
===
--- clang/include/clang/Basic/LangOptions.h
+++ clang/include/clang/Basic/LangOptions.h
@@ -328,6 +328,10 @@
!ObjCSubscriptingLegacyRuntime;
   }
 
+  bool isMSCompatibilityVersionSpecified() const {
+return MSCompatibilityVersion != 0;
+  }
+
   bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const {
 return MSCompatibilityVersion >= MajorVersion * 10U;
   }


Index: clang/test/Sema/format-strings-ms.c
===
--- clang/test/Sema/format-strings-ms.c
+++ clang/test/Sema/format-strings-ms.c
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility -triple=i386-pc-win32 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility -triple=i386-pc-win32 -fms-compatibility-version=19 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility -triple=i386-pc-win32 -fms-compatibility-version=18 -DNO_z_MODIFIER %s
 // RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility -triple=i386-pc-win32 -Wformat-non-iso -DNON_ISO_WARNING %s
 
 int printf(const char *format, ...) __attribute__((format(printf, 1, 2)));
@@ -85,4 +87,11 @@
   scanf("%Z", p); // expected-warning{{invalid conversion specifier 'Z'}}
 }
 
+void size_t_test(size_t s) {
+  printf("%zu", s);
+#ifdef NO_z_MODIFIER
+  // expected-warning@-2 {{length modifier 'z' results in undefined behavior or no effect with 'u' conversion specifier}}
+#endif
+}
+
 #endif
Index: clang/lib/AST/FormatString.cpp
===
--- clang/lib/AST/FormatString.cpp
+++ clang/lib/AST/FormatString.cpp
@@ -748,6 +748,16 @@
 case LengthModifier::AsIntMax:
 case LengthModifier::AsSizeT:
 case LengthModifier::AsPtrDiff:
+  if (LM.getKind() == LengthModifier::AsSizeT &&
+  Target.getTriple().isOSMSVCRT() &&
+  LO.isMSCompatibilityVersionSpecified() &&
+  !LO.isCompatibleWithMSVC(LangOptions::MSVC2015)) {
+// The standard libraries before MSVC2015 didn't support the 'z' length
+// modifier for size_t. So if the MS compatibility version is specified
+// and less th

[PATCH] D73441: [clang-tidy] Fix bugprone-use-after-move when move is in noexcept operator

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

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

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

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

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


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73441



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


[clang] 0a57d14 - [ASTMatchers] Fix parent traversal with InitListExpr

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

Author: Stephen Kelly
Date: 2020-01-27T11:19:59Z
New Revision: 0a57d14abf99333fbfab15fb918a863aa391

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

LOG: [ASTMatchers] Fix parent traversal with InitListExpr

Children of InitListExpr are traversed twice by RAV, so this code
populates a vector to represent the possibly-multiple parents (in
reality in this situation the parent is the same and is therefore
de-duplicated).

Added: 


Modified: 
clang/lib/AST/ParentMapContext.cpp
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Removed: 




diff  --git a/clang/lib/AST/ParentMapContext.cpp 
b/clang/lib/AST/ParentMapContext.cpp
index 6a22e687ff57..e74e9909a606 100644
--- a/clang/lib/AST/ParentMapContext.cpp
+++ b/clang/lib/AST/ParentMapContext.cpp
@@ -133,8 +133,8 @@ class ParentMapContext::ParentMap {
 return getDynNodeFromMap(Node, OtherParents);
   }
 
-  ast_type_traits::DynTypedNode
-  AscendIgnoreUnlessSpelledInSource(const Expr *E, const Expr *Child) {
+  DynTypedNodeList AscendIgnoreUnlessSpelledInSource(const Expr *E,
+ const Expr *Child) {
 
 auto ShouldSkip = [](const Expr *E, const Expr *Child) {
   if (isa(E))
@@ -179,8 +179,11 @@ class ParentMapContext::ParentMap {
   if (It == PointerParents.end())
 break;
   const auto *S = It->second.dyn_cast();
-  if (!S)
+  if (!S) {
+if (auto *Vec = It->second.dyn_cast())
+  return llvm::makeArrayRef(*Vec);
 return getSingleDynTypedNodeFromParentMap(It->second);
+  }
   const auto *P = dyn_cast(S);
   if (!P)
 return ast_type_traits::DynTypedNode::create(*S);

diff  --git a/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
index 2143bb4965bb..b1f070bd8411 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1744,6 +1744,16 @@ void foo()
   Code,
   traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
integerLiteral(equals(3), hasParent(varDecl(hasName("i")));
+
+  Code = R"cpp(
+const char *SomeString{"str"};
+)cpp";
+  EXPECT_TRUE(matches(Code, traverse(ast_type_traits::TK_AsIs,
+ stringLiteral(hasParent(implicitCastExpr(
+ hasParent(initListExpr(;
+  EXPECT_TRUE(
+  matches(Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+ stringLiteral(hasParent(initListExpr());
 }
 
 template 



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


[PATCH] D73451: [clangd] Update the include mappings for std symbols.

2020-01-27 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 240520.
hokein added a comment.

refine the code to avoid confusion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73451

Files:
  clang-tools-extra/clangd/CSymbolMap.inc
  clang-tools-extra/clangd/StdSymbolMap.inc
  clang-tools-extra/clangd/include-mapping/cppreference_parser.py

Index: clang-tools-extra/clangd/include-mapping/cppreference_parser.py
===
--- clang-tools-extra/clangd/include-mapping/cppreference_parser.py
+++ clang-tools-extra/clangd/include-mapping/cppreference_parser.py
@@ -138,8 +138,10 @@
   if variant:
 continue
   path = os.path.join(root_dir, symbol_page_path)
-  results.append((symbol_name,
-  pool.apply_async(_ReadSymbolPage, (path, symbol_name
+  # We might encounter inavlid links from cppreference page, ignore them
+  if os.path.isfile(path):
+results.append((symbol_name,
+pool.apply_async(_ReadSymbolPage, (path, symbol_name
 
 # Build map from symbol name to a set of headers.
 symbol_headers = collections.defaultdict(set)
Index: clang-tools-extra/clangd/StdSymbolMap.inc
===
--- clang-tools-extra/clangd/StdSymbolMap.inc
+++ clang-tools-extra/clangd/StdSymbolMap.inc
@@ -5,7 +5,7 @@
 //
 // Automatically generated file, DO NOT EDIT!
 //
-// Generated from cppreference offline HTML book (modified on 2018-10-28).
+// Generated from cppreference offline HTML book (modified on 2019-06-07).
 //===--===//
 
 SYMBOL(Assignable, std::, )
@@ -43,7 +43,11 @@
 SYMBOL(_Exit, std::, )
 SYMBOL(accumulate, std::, )
 SYMBOL(acos, std::, )
+SYMBOL(acosf, std::, )
 SYMBOL(acosh, std::, )
+SYMBOL(acoshf, std::, )
+SYMBOL(acoshl, std::, )
+SYMBOL(acosl, std::, )
 SYMBOL(add_const, std::, )
 SYMBOL(add_const_t, std::, )
 SYMBOL(add_cv, std::, )
@@ -73,6 +77,7 @@
 SYMBOL(alignment_of_v, std::, )
 SYMBOL(all_of, std::, )
 SYMBOL(allocate_shared, std::, )
+SYMBOL(allocate_shared_default_init, std::, )
 SYMBOL(allocator, std::, )
 SYMBOL(allocator_arg, std::, )
 SYMBOL(allocator_arg_t, std::, )
@@ -85,12 +90,23 @@
 SYMBOL(as_const, std::, )
 SYMBOL(asctime, std::, )
 SYMBOL(asin, std::, )
+SYMBOL(asinf, std::, )
 SYMBOL(asinh, std::, )
+SYMBOL(asinhf, std::, )
+SYMBOL(asinhl, std::, )
+SYMBOL(asinl, std::, )
+SYMBOL(assume_aligned, std::, )
 SYMBOL(async, std::, )
 SYMBOL(at_quick_exit, std::, )
 SYMBOL(atan, std::, )
 SYMBOL(atan2, std::, )
+SYMBOL(atan2f, std::, )
+SYMBOL(atan2l, std::, )
+SYMBOL(atanf, std::, )
 SYMBOL(atanh, std::, )
+SYMBOL(atanhf, std::, )
+SYMBOL(atanhl, std::, )
+SYMBOL(atanl, std::, )
 SYMBOL(atexit, std::, )
 SYMBOL(atof, std::, )
 SYMBOL(atoi, std::, )
@@ -127,7 +143,6 @@
 SYMBOL(atomic_store_explicit, std::, )
 SYMBOL(atomic_thread_fence, std::, )
 SYMBOL(atto, std::, )
-SYMBOL(auto_ptr, std::, )
 SYMBOL(back_insert_iterator, std::, )
 SYMBOL(back_inserter, std::, )
 SYMBOL(bad_alloc, std::, )
@@ -164,6 +179,7 @@
 SYMBOL(bidirectional_iterator_tag, std::, )
 SYMBOL(binary_search, std::, )
 SYMBOL(bind, std::, )
+SYMBOL(bind_front, std::, )
 SYMBOL(binomial_distribution, std::, )
 SYMBOL(bit_and, std::, )
 SYMBOL(bit_cast, std::, )
@@ -180,13 +196,18 @@
 SYMBOL(byte, std::, )
 SYMBOL(c16rtomb, std::, )
 SYMBOL(c32rtomb, std::, )
+SYMBOL(c8rtomb, std::, )
 SYMBOL(call_once, std::, )
 SYMBOL(calloc, std::, )
 SYMBOL(cauchy_distribution, std::, )
 SYMBOL(cbegin, std::, )
 SYMBOL(cbrt, std::, )
+SYMBOL(cbrtf, std::, )
+SYMBOL(cbrtl, std::, )
 SYMBOL(ceil, std::, )
 SYMBOL(ceil2, std::, )
+SYMBOL(ceilf, std::, )
+SYMBOL(ceill, std::, )
 SYMBOL(cend, std::, )
 SYMBOL(centi, std::, )
 SYMBOL(cerr, std::, )
@@ -225,14 +246,21 @@
 SYMBOL(conjunction, std::, )
 SYMBOL(conjunction_v, std::, )
 SYMBOL(const_pointer_cast, std::, )
+SYMBOL(contiguous_iterator_tag, std::, )
 SYMBOL(contract_violation, std::, )
 SYMBOL(copy, std::, )
 SYMBOL(copy_backward, std::, )
 SYMBOL(copy_if, std::, )
 SYMBOL(copy_n, std::, )
 SYMBOL(copysign, std::, )
+SYMBOL(copysignf, std::, )
+SYMBOL(copysignl, std::, )
 SYMBOL(cos, std::, )
+SYMBOL(cosf, std::, )
 SYMBOL(cosh, std::, )
+SYMBOL(coshf, std::, )
+SYMBOL(coshl, std::, )
+SYMBOL(cosl, std::, )
 SYMBOL(count, std::, )
 SYMBOL(count_if, std::, )
 SYMBOL(cout, std::, )
@@ -296,8 +324,14 @@
 SYMBOL(equal, std::, )
 SYMBOL(equal_range, std::, )
 SYMBOL(equal_to, std::, )
+SYMBOL(erase, std::, )
+SYMBOL(erase_if, std::, )
 SYMBOL(erf, std::, )
 SYMBOL(erfc, std::, )
+SYMBOL(erfcf, std::, )
+SYMBOL(erfcl, std::, )
+SYMBOL(erff, std::, )
+SYMBOL(erfl, std::, )
 SYMBOL(errc, std::, )
 SYMBOL(error_category, std::, )
 SYMBOL(error_code, std::, )
@@ -310,14 +344,25 @@
 SYMBOL(exit, std::, )
 SYMBOL(exp, std::, )
 SYMBOL(exp2, std::, )
+SYMBOL(exp2f, std::, )

[PATCH] D73451: [clangd] Update the include mappings for std symbols.

2020-01-27 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D73451#1841510 , @kadircet wrote:

> we seem to be missing some symbols now, like `polymorphic_allocator` 
> `random_shuffle` `gets` etc.


yeap, two majoir reasons:

- some symbols  
are deprecated/removed in new C++ standard, e.g. random_shuffle is removed in 
C++17
- missing information in cppreference page, e.g. there is no header section for 
`polymorphic_allocator` in the offline cppreference page :(

Regarding those deprecated symbols, we could handle them according to  which 
C++ standard we are using, as we have enough information from cppreferences 
, but it needs 
some work, and is low priority.

> and there seems to be a functional change to the parser. Are they 
> intentional, if so why?

The change should be NFC, it just makes the parser more robust on invalid 
links, the new version of the cppreference have invalid links on the symbol 
index page.
updated the code to make it clearer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73451



___
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-27 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard added a comment.

> It will require changing all possible initializations, with a sensible value.

Where are you seeing multiple initializations? It looks like all of the logic 
for struct layout happens in `CGRecordLowering::lower`, we might need to add a 
pass there to calculate the valid access widths for bitfields.

> And either way, codegen will also need to change, to define the address, it 
> must know if it is volatile or not.

The difference is that codegen only needs to change to check if the access is 
volatile, and select the correct offset and size already calculated during 
struct layout.

> perhaps we can leave it as a TODO to move it there?

I'm less concerned about the performance impact of this, and more about making 
this code harder to understand by spreading the logic across multiple different 
phases of compilation. This has been broken for years, I'd rather we fix it 
properly, than add a TODO which will never get done.


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] D73451: [clangd] Update the include mappings for std symbols.

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

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

{icon times-circle color=red} clang-tidy: fail. clang-tidy found 15 errors and 
0 warnings 
.
 15 of them are added as review comments below (why? 
).

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

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


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73451



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


[PATCH] D73451: [clangd] Update the include mappings for std symbols.

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

In D73451#1841595 , @hokein wrote:

> In D73451#1841510 , @kadircet wrote:
>
> > we seem to be missing some symbols now, like `polymorphic_allocator` 
> > `random_shuffle` `gets` etc.
>
>
> yeap, two majoir reasons:
>
> - some symbols  
> are deprecated/removed in new C++ standard, e.g. random_shuffle is removed in 
> C++17
> - missing information in cppreference page, e.g. there is no header section 
> for `polymorphic_allocator` in the offline cppreference page :(
>
>   Regarding those deprecated symbols, we could handle them according to  
> which C++ standard we are using, as we have enough information from 
> cppreferences , 
> but it needs some work, and is low priority.


Ah I see, it is sad that cppreference just deletes those from symbol index, 
instead of marking them as `delete after c++XX`, I am not sure when the symbols 
introduced by this patch are added(but it is likely that they are introduced 
with c++20), so I think losing existing symbols
has a worse effect than not having information regarding c++20 symbols. Because 
these are symbols that are likely to be used by current c++ developers and 
supported by clangd, and it will be a regression to drop those, whereas the 
newly introduced symbols are already
missing.

So maybe postpone this update until we implement parsing of zombie_names page 
as well, also please file a bug either way so that we don't lose track.

> 
> 
>> and there seems to be a functional change to the parser. Are they 
>> intentional, if so why?
> 
> The change should be NFC, it just makes the parser more robust on invalid 
> links, the new version of the cppreference have invalid links on the symbol 
> index page.
>  updated the code to make it clearer.

maybe separate that out into a different patch so that it stands out?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73451



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


[clang] 36a8f7f - [clang-format] Handle escaped " in C# string-literals

2020-01-27 Thread Krasimir Georgiev via cfe-commits

Author: Krasimir Georgiev
Date: 2020-01-27T12:57:20+01:00
New Revision: 36a8f7f6d8f5a9620b1a091e54abacb517ecfbba

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

LOG: [clang-format] Handle escaped " in C# string-literals

Reviewers: krasimir

Reviewed By: krasimir

Subscribers: klimek, MyDeveloperDay

Tags: #clang-format

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Format/FormatTokenLexer.cpp 
b/clang/lib/Format/FormatTokenLexer.cpp
index 9c9fee2b0c32..d8dfe17fb89c 100644
--- a/clang/lib/Format/FormatTokenLexer.cpp
+++ b/clang/lib/Format/FormatTokenLexer.cpp
@@ -184,15 +184,33 @@ bool FormatTokenLexer::tryMergeJSPrivateIdentifier() {
 bool FormatTokenLexer::tryMergeCSharpVerbatimStringLiteral() {
   if (Tokens.size() < 2)
 return false;
-  auto &At = *(Tokens.end() - 2);
+
   auto &String = *(Tokens.end() - 1);
+  if (!String->is(tok::string_literal))
+return false;
+
+  // verbatim strings could contain "" which C# sees as an escaped ".
+  // @"""Hello""" will have been tokenized as @"" "Hello" "" and needs
+  // merging into a single string literal.
+  auto &CSharpStringLiteral = *(Tokens.end() - 2);
+  if (CSharpStringLiteral->Type == TT_CSharpStringLiteral &&
+  (CSharpStringLiteral->TokenText.startswith(R"(@")") ||
+   CSharpStringLiteral->TokenText.startswith(R"($@")"))) {
+CSharpStringLiteral->TokenText = StringRef(
+CSharpStringLiteral->TokenText.begin(),
+String->TokenText.end() - CSharpStringLiteral->TokenText.begin());
+CSharpStringLiteral->ColumnWidth += String->ColumnWidth;
+Tokens.erase(Tokens.end() - 1);
+return true;
+  }
+
+  auto &At = *(Tokens.end() - 2);
 
-  // Look for $"aa" @"aa".
-  if (!(At->is(tok::at) || At->TokenText == "$") ||
-  !String->is(tok::string_literal))
+  // Look for @"aa" or $"aa".
+  if (!(At->is(tok::at) || At->TokenText == "$"))
 return false;
 
-  if (Tokens.size() >= 2 && At->is(tok::at)) {
+  if (Tokens.size() > 2 && At->is(tok::at)) {
 auto &Dollar = *(Tokens.end() - 3);
 if (Dollar->TokenText == "$") {
   // This looks like $@"a" so we need to combine all 3 tokens.

diff  --git a/clang/unittests/Format/FormatTestCSharp.cpp 
b/clang/unittests/Format/FormatTestCSharp.cpp
index 90d05ad679a7..f777d319ea40 100644
--- a/clang/unittests/Format/FormatTestCSharp.cpp
+++ b/clang/unittests/Format/FormatTestCSharp.cpp
@@ -409,5 +409,13 @@ TEST_F(FormatTestCSharp, CSharpSpaceAfterCStyleCast) {
   verifyFormat("(int) x / y;", Style);
 }
 
+TEST_F(FormatTestCSharp, CSharpEscapedQuotesInVerbatimStrings) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+
+  verifyFormat(R"(string str = @)", Style);
+  verifyFormat(R"(string str = @"""Hello world""")", Style);
+  verifyFormat(R"(string str = $@"""Hello {friend}""")", Style);
+}
+
 } // namespace format
 } // end namespace clang



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


[PATCH] D73353: [clang-format] Handle escaped " in C# string-literals

2020-01-27 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG36a8f7f6d8f5: [clang-format] Handle escaped " in C# 
string-literals (authored by krasimir).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73353

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


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -409,5 +409,13 @@
   verifyFormat("(int) x / y;", Style);
 }
 
+TEST_F(FormatTestCSharp, CSharpEscapedQuotesInVerbatimStrings) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+
+  verifyFormat(R"(string str = @)", Style);
+  verifyFormat(R"(string str = @"""Hello world""")", Style);
+  verifyFormat(R"(string str = $@"""Hello {friend}""")", Style);
+}
+
 } // namespace format
 } // end namespace clang
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -184,15 +184,33 @@
 bool FormatTokenLexer::tryMergeCSharpVerbatimStringLiteral() {
   if (Tokens.size() < 2)
 return false;
-  auto &At = *(Tokens.end() - 2);
+
   auto &String = *(Tokens.end() - 1);
+  if (!String->is(tok::string_literal))
+return false;
+
+  // verbatim strings could contain "" which C# sees as an escaped ".
+  // @"""Hello""" will have been tokenized as @"" "Hello" "" and needs
+  // merging into a single string literal.
+  auto &CSharpStringLiteral = *(Tokens.end() - 2);
+  if (CSharpStringLiteral->Type == TT_CSharpStringLiteral &&
+  (CSharpStringLiteral->TokenText.startswith(R"(@")") ||
+   CSharpStringLiteral->TokenText.startswith(R"($@")"))) {
+CSharpStringLiteral->TokenText = StringRef(
+CSharpStringLiteral->TokenText.begin(),
+String->TokenText.end() - CSharpStringLiteral->TokenText.begin());
+CSharpStringLiteral->ColumnWidth += String->ColumnWidth;
+Tokens.erase(Tokens.end() - 1);
+return true;
+  }
+
+  auto &At = *(Tokens.end() - 2);
 
-  // Look for $"aa" @"aa".
-  if (!(At->is(tok::at) || At->TokenText == "$") ||
-  !String->is(tok::string_literal))
+  // Look for @"aa" or $"aa".
+  if (!(At->is(tok::at) || At->TokenText == "$"))
 return false;
 
-  if (Tokens.size() >= 2 && At->is(tok::at)) {
+  if (Tokens.size() > 2 && At->is(tok::at)) {
 auto &Dollar = *(Tokens.end() - 3);
 if (Dollar->TokenText == "$") {
   // This looks like $@"a" so we need to combine all 3 tokens.


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -409,5 +409,13 @@
   verifyFormat("(int) x / y;", Style);
 }
 
+TEST_F(FormatTestCSharp, CSharpEscapedQuotesInVerbatimStrings) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+
+  verifyFormat(R"(string str = @)", Style);
+  verifyFormat(R"(string str = @"""Hello world""")", Style);
+  verifyFormat(R"(string str = $@"""Hello {friend}""")", Style);
+}
+
 } // namespace format
 } // end namespace clang
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -184,15 +184,33 @@
 bool FormatTokenLexer::tryMergeCSharpVerbatimStringLiteral() {
   if (Tokens.size() < 2)
 return false;
-  auto &At = *(Tokens.end() - 2);
+
   auto &String = *(Tokens.end() - 1);
+  if (!String->is(tok::string_literal))
+return false;
+
+  // verbatim strings could contain "" which C# sees as an escaped ".
+  // @"""Hello""" will have been tokenized as @"" "Hello" "" and needs
+  // merging into a single string literal.
+  auto &CSharpStringLiteral = *(Tokens.end() - 2);
+  if (CSharpStringLiteral->Type == TT_CSharpStringLiteral &&
+  (CSharpStringLiteral->TokenText.startswith(R"(@")") ||
+   CSharpStringLiteral->TokenText.startswith(R"($@")"))) {
+CSharpStringLiteral->TokenText = StringRef(
+CSharpStringLiteral->TokenText.begin(),
+String->TokenText.end() - CSharpStringLiteral->TokenText.begin());
+CSharpStringLiteral->ColumnWidth += String->ColumnWidth;
+Tokens.erase(Tokens.end() - 1);
+return true;
+  }
+
+  auto &At = *(Tokens.end() - 2);
 
-  // Look for $"aa" @"aa".
-  if (!(At->is(tok::at) || At->TokenText == "$") ||
-  !String->is(tok::string_literal))
+  // Look for @"aa" or $"aa".
+  if (!(At->is(tok::at) || At->TokenText == "$"))
 return false;
 
-  if (Tokens.size() >= 2 && At->is(t

[PATCH] D73354: clang-format: insert trailing commas into containers.

2020-01-27 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

An alternative approach (I'm not endorsing this) that would *in theory* 
circumvent non-idempotency issue (but would be more fiddly~fiddly to implement 
and spill across different layers of the formatter):
This is just a rough idea and can have multiple issues in itself. In general 
the trick is that if we can teach the token penalty computer and the format 
outputter about this, we should be able to use it together with other 
formatting decisions.

- add a new synthetic (annotated) token type, something like 
TT_PossiblyMissingTrailingComma, that would capture the length-0 text range 
where this could be inserted;
- use the algorithm here to splay it into the annotated token stream;
- mark it so that no newline can be inserted before such a token
- modify the penalty calculation algorithm to penalize for inserting a newline 
after this token: if we're inserting a newline after this token and if this 
token was inserted at a position at or past the maximal number of columns, add 
a PenaltyExcessCharacter for it.
- during outputting, if this token is followed by a newline, output it as `,`; 
otherwise output it as an empty string or do not output it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73354



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


[PATCH] D73413: [clang-tidy] Add check to detect external definitions with no header declaration

2020-01-27 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/misc/MissingHeaderFileDeclarationCheck.cpp:29
+
+  bool isHeader() const {
+return llvm::StringSwitch(Extension)

njames93 wrote:
> gribozavr2 wrote:
> > I think we should consider any file other than the main file to be a header 
> > (anything brought in by `#include`). Projects have lots of different 
> > convention -- for example, LLVM uses a `.inc` extension for some generated 
> > files and x-macro files. The standard library does not have any extensions 
> > at all (and I'm sure some projects imitate that) etc.
> I agree in part, but there is one case that I didn't want to happen and that 
> is when clang-tidy is ran as a text editor plugin. Often it will blindly 
> treat the current open file as the main file which would lead to a lot of 
> false positives, Would a better metric being matching on file extensions not 
> corresponding to source files (c, cc, cxx, cpp)?
> I agree in part, but there is one case that I didn't want to happen and that 
> is when clang-tidy is ran as a text editor plugin.

Does that really happen? That sounds like broken editor integration to me, 
because this is not how C++ without modules works...

> Would a better metric being matching on file extensions not corresponding to 
> source files (c, cc, cxx, cpp)?

Yes, I think that would be better, if we have to sniff file extensions.



Comment at: 
clang-tools-extra/clang-tidy/misc/MissingHeaderFileDeclarationCheck.cpp:75
+  continue;
+if (AnyHeader || File->NamePart.equals_lower(ThisFile->NamePart))
+  return; // Found a good candidate for matching decl

njames93 wrote:
> gribozavr2 wrote:
> > This heuristic should be a lot more complex. In practice people have more 
> > complex naming conventions (for example, in Clang, Sema.h corresponds to 
> > many files named SemaSomethingSomething.cpp).
> > 
> > I think there is a high chance that checking only a header with a matching 
> > name will satisfy too few projects to be worth implementing.
> > 
> > On the other hand, if you could use C++ or Clang modules to narrow down the 
> > list of headers where the declaration should appear, that would be a much 
> > stronger signal.
> That is the reason I added the CheckAnyHeader option. For small projects the 
> matching name would be usually be enough, but for big complex projects there 
> is no feasible check that would work. Falling back to making sure every 
> external definition has a declaration in at least one header will always be a 
> good warning
That's the thing -- due to the lack of consistency in projects and style guides 
for C++, I think most projects will have to turn on CheckAnyHeader. We get 
implementation complexity in ClangTidy, false positives in high-profile 
projects, force users to configure ClangTidy to work well for their projects 
(unless we set CheckAnyHeader=1 by default... which then nobody would flip back 
to zero), and little benefit for end users.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73413



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


[PATCH] D73441: [clang-tidy] Fix bugprone-use-after-move when move is in noexcept operator

2020-01-27 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added a comment.
This revision is now accepted and ready to land.

LGTM with fixes to the test.




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp:1276
+namespace PR44667 {
+#define REQUIRE(expr) (void)(expr);
+struct S {};

njames93 wrote:
> gribozavr2 wrote:
> > njames93 wrote:
> > > gribozavr2 wrote:
> > > > Is the macro a necessary part of this test? If not, can it be removed?
> > > I like to stick to the bug report as much as possible
> > This is not generally the policy in LLVM and Clang. We prefer minimal 
> > reproducers.
> I've kept it minimal, the REQUIRE definition is just to suppress other 
> warnings about unused expressions
Adding `(void)` should do the trick.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp:1279
+
+void foo() {
+  S s;

I'm not sure why `foo` and `otherUnenvaluated` are separate functions. If you 
want to separate them, I think it would make more sense to put each operator 
into a separate function then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73441



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


[PATCH] D73450: [clangd] Add a symbol-name-based blacklist for rename.

2020-01-27 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 240528.
hokein marked 5 inline comments as done.
hokein added a comment.

address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73450

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
@@ -383,12 +383,12 @@
 
   // Typedef.
   R"cpp(
-namespace std {
+namespace ns {
 class basic_string {};
 typedef basic_string [[s^tring]];
-} // namespace std
+} // namespace ns
 
-std::[[s^tring]] foo();
+ns::[[s^tring]] foo();
   )cpp",
 
   // Variable.
@@ -539,6 +539,13 @@
  void fo^o() {})cpp",
"used outside main file", !HeaderFile, nullptr /*no index*/},
 
+  {R"cpp(// disallow rename on blacklisted symbols (e.g. std symbols)
+ namespace std {
+ class str^ing {};
+ }
+   )cpp",
+   "not a supported kind", !HeaderFile, Index},
+
   {R"cpp(
  void foo(int);
  void foo(char);
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -96,6 +96,15 @@
   return Result;
 }
 
+bool isBlacklisted(const NamedDecl &RenameDecl) {
+  static const auto *StdSymbols = new llvm::DenseSet({
+#define SYMBOL(Name, NameSpace, Header) {#NameSpace #Name},
+#include "StdSymbolMap.inc"
+#undef SYMBOL
+  });
+  return StdSymbols->count(RenameDecl.getQualifiedNameAsString());
+}
+
 enum ReasonToReject {
   NoSymbolFound,
   NoIndexProvided,
@@ -105,7 +114,7 @@
   AmbiguousSymbol,
 };
 
-llvm::Optional renameable(const Decl &RenameDecl,
+llvm::Optional renameable(const NamedDecl &RenameDecl,
   StringRef MainFilePath,
   const SymbolIndex *Index,
   bool CrossFile) {
@@ -120,6 +129,9 @@
   if (RenameDecl.getParentFunctionOrMethod())
 return None;
 
+  if (isBlacklisted(RenameDecl))
+return ReasonToReject::UnsupportedSymbol;
+
   // Check whether the symbol being rename is indexable.
   auto &ASTCtx = RenameDecl.getASTContext();
   bool MainFileIsHeader = isHeaderFile(MainFilePath, ASTCtx.getLangOpts());
@@ -131,11 +143,9 @@
 IsMainFileOnly = false;
   else if (!DeclaredInMainFile)
 IsMainFileOnly = false;
-  bool IsIndexable =
-  isa(RenameDecl) &&
-  SymbolCollector::shouldCollectSymbol(
-  cast(RenameDecl), RenameDecl.getASTContext(),
-  SymbolCollector::Options(), IsMainFileOnly);
+  bool IsIndexable = SymbolCollector::shouldCollectSymbol(
+  RenameDecl, RenameDecl.getASTContext(), SymbolCollector::Options(),
+  IsMainFileOnly);
   if (!IsIndexable) // If the symbol is not indexable, we disallow rename.
 return ReasonToReject::NonIndexable;
 
@@ -222,7 +232,6 @@
   llvm::DenseSet TargetIDs;
   for (auto &USR : RenameUSRs)
 TargetIDs.insert(SymbolID(USR));
-
   std::vector Results;
   for (Decl *TopLevelDecl : AST.getLocalTopLevelDecls()) {
 findExplicitReferences(TopLevelDecl, [&](ReferenceLoc Ref) {
@@ -467,13 +476,13 @@
   if (DeclsUnderCursor.size() > 1)
 return makeError(ReasonToReject::AmbiguousSymbol);
 
-  const auto *RenameDecl = llvm::dyn_cast(*DeclsUnderCursor.begin());
+  const auto *RenameDecl = llvm::dyn_cast(
+  (*DeclsUnderCursor.begin())->getCanonicalDecl());
   if (!RenameDecl)
 return makeError(ReasonToReject::UnsupportedSymbol);
 
-  auto Reject =
-  renameable(*RenameDecl->getCanonicalDecl(), RInputs.MainFilePath,
- RInputs.Index, RInputs.AllowCrossFile);
+  auto Reject = renameable(*RenameDecl, RInputs.MainFilePath, RInputs.Index,
+   RInputs.AllowCrossFile);
   if (Reject)
 return makeError(*Reject);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73450: [clangd] Add a symbol-name-based blacklist for rename.

2020-01-27 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 240529.
hokein added a comment.

update the code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73450

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
@@ -383,12 +383,12 @@
 
   // Typedef.
   R"cpp(
-namespace std {
+namespace ns {
 class basic_string {};
 typedef basic_string [[s^tring]];
-} // namespace std
+} // namespace ns
 
-std::[[s^tring]] foo();
+ns::[[s^tring]] foo();
   )cpp",
 
   // Variable.
@@ -539,6 +539,13 @@
  void fo^o() {})cpp",
"used outside main file", !HeaderFile, nullptr /*no index*/},
 
+  {R"cpp(// disallow rename on blacklisted symbols (e.g. std symbols)
+ namespace std {
+ class str^ing {};
+ }
+   )cpp",
+   "not a supported kind", !HeaderFile, Index},
+
   {R"cpp(
  void foo(int);
  void foo(char);
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -96,6 +96,15 @@
   return Result;
 }
 
+bool isBlacklisted(const NamedDecl &RenameDecl) {
+  static const auto *StdSymbols = new llvm::DenseSet({
+#define SYMBOL(Name, NameSpace, Header) {#NameSpace #Name},
+#include "StdSymbolMap.inc"
+#undef SYMBOL
+  });
+  return StdSymbols->count(RenameDecl.getQualifiedNameAsString());
+}
+
 enum ReasonToReject {
   NoSymbolFound,
   NoIndexProvided,
@@ -105,7 +114,7 @@
   AmbiguousSymbol,
 };
 
-llvm::Optional renameable(const Decl &RenameDecl,
+llvm::Optional renameable(const NamedDecl &RenameDecl,
   StringRef MainFilePath,
   const SymbolIndex *Index,
   bool CrossFile) {
@@ -120,6 +129,9 @@
   if (RenameDecl.getParentFunctionOrMethod())
 return None;
 
+  if (isBlacklisted(RenameDecl))
+return ReasonToReject::UnsupportedSymbol;
+
   // Check whether the symbol being rename is indexable.
   auto &ASTCtx = RenameDecl.getASTContext();
   bool MainFileIsHeader = isHeaderFile(MainFilePath, ASTCtx.getLangOpts());
@@ -131,12 +143,9 @@
 IsMainFileOnly = false;
   else if (!DeclaredInMainFile)
 IsMainFileOnly = false;
-  bool IsIndexable =
-  isa(RenameDecl) &&
-  SymbolCollector::shouldCollectSymbol(
-  cast(RenameDecl), RenameDecl.getASTContext(),
-  SymbolCollector::Options(), IsMainFileOnly);
-  if (!IsIndexable) // If the symbol is not indexable, we disallow rename.
+  if (!SymbolCollector::shouldCollectSymbol(
+  RenameDecl, RenameDecl.getASTContext(), SymbolCollector::Options(),
+  IsMainFileOnly)) // If the symbol is not indexable, we disallow rename.
 return ReasonToReject::NonIndexable;
 
   if (!CrossFile) {
@@ -222,7 +231,6 @@
   llvm::DenseSet TargetIDs;
   for (auto &USR : RenameUSRs)
 TargetIDs.insert(SymbolID(USR));
-
   std::vector Results;
   for (Decl *TopLevelDecl : AST.getLocalTopLevelDecls()) {
 findExplicitReferences(TopLevelDecl, [&](ReferenceLoc Ref) {
@@ -467,13 +475,13 @@
   if (DeclsUnderCursor.size() > 1)
 return makeError(ReasonToReject::AmbiguousSymbol);
 
-  const auto *RenameDecl = llvm::dyn_cast(*DeclsUnderCursor.begin());
+  const auto *RenameDecl = llvm::dyn_cast(
+  (*DeclsUnderCursor.begin())->getCanonicalDecl());
   if (!RenameDecl)
 return makeError(ReasonToReject::UnsupportedSymbol);
 
-  auto Reject =
-  renameable(*RenameDecl->getCanonicalDecl(), RInputs.MainFilePath,
- RInputs.Index, RInputs.AllowCrossFile);
+  auto Reject = renameable(*RenameDecl, RInputs.MainFilePath, RInputs.Index,
+   RInputs.AllowCrossFile);
   if (Reject)
 return makeError(*Reject);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73450: [clangd] Add a symbol-name-based blacklist for rename.

2020-01-27 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:466
 
   auto DeclsUnderCursor = locateDeclAt(AST, IdentifierToken->location());
   if (DeclsUnderCursor.empty())

kadircet wrote:
> `locateDeclAt` is already working on `NamedDecl`s but returning a set of 
> `Decl`s could you rather update that helper to return a set of `NamedDecl`s 
> instead?
I think the main problem is that `NamedDecl->getCanonicalDecl()` returns a 
`Decl*`, which we need to do a `dyn_cast`.



Comment at: clang-tools-extra/clangd/refactor/RenameBlacklist.cpp:14
+
+bool isRenameBlacklisted(const NamedDecl &RenameDecl) {
+  static const auto *StdSymbols = new llvm::DenseSet({

kadircet wrote:
> I don't think there's much value in having that in its own file, could you 
> move it into the rename.cpp ?
I thought we will extend this in the near future, moved to rename.cpp now as it 
is pretty short.



Comment at: clang-tools-extra/clangd/unittests/RenameTests.cpp:453
   rename({RenamePos, NewName, AST, testPath(TU.Filename)});
-  ASSERT_TRUE(bool(RenameResult)) << RenameResult.takeError();
+  ASSERT_TRUE(bool(RenameResult)) << RenameResult.takeError() << T;
   ASSERT_EQ(1u, RenameResult->size());

kadircet wrote:
> maybe `SCOPEDT_TRACE(T)` instead?
good point, reverted the change in this patch, and  will do this in a separate 
patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73450



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


[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates

2020-01-27 Thread Awanish Pandey via Phabricator via cfe-commits
awpandey created this revision.
awpandey added reviewers: probinson, aprantl, dblaikie.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.

This patch provides support for //DW_AT_default_value// based on template 
parameter is default parameter or not.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73462

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-template-parameter.cpp
  llvm/include/llvm/IR/DIBuilder.h
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/MetadataLoader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/DebugInfoMetadata.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/test/DebugInfo/X86/debug-info-template-parameter.ll
  llvm/unittests/IR/MetadataTest.cpp

Index: llvm/unittests/IR/MetadataTest.cpp
===
--- llvm/unittests/IR/MetadataTest.cpp
+++ llvm/unittests/IR/MetadataTest.cpp
@@ -2077,16 +2077,16 @@
   StringRef Name = "template";
   DIType *Type = getBasicType("basic");
 
-  auto *N = DITemplateTypeParameter::get(Context, Name, Type);
+  auto *N = DITemplateTypeParameter::get(Context, Name, Type, false);
 
   EXPECT_EQ(dwarf::DW_TAG_template_type_parameter, N->getTag());
   EXPECT_EQ(Name, N->getName());
   EXPECT_EQ(Type, N->getType());
-  EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type));
+  EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type, false));
 
-  EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type));
-  EXPECT_NE(N,
-DITemplateTypeParameter::get(Context, Name, getBasicType("other")));
+  EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type, false));
+  EXPECT_NE(N, DITemplateTypeParameter::get(Context, Name,
+getBasicType("other"), false));
 
   TempDITemplateTypeParameter Temp = N->clone();
   EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
Index: llvm/test/DebugInfo/X86/debug-info-template-parameter.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/debug-info-template-parameter.ll
@@ -0,0 +1,106 @@
+; RUN: %llc_dwarf  %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s
+
+; C++ source to regenerate:
+
+;template 
+;class foo {
+;};
+;
+;int main() {
+; foo f1;
+; foo f2;
+; foo<> f3;
+; return 0;
+;}
+
+; $ clang++ -O0 -g -gdwarf-5 debug-info-template-align.cpp -c
+
+; CHECK: .debug_abbrev contents:
+; CHECK: DW_AT_default_value DW_FORM_flag_present
+
+; CHECK: DW_AT_name {{.*}} "foo"
+; CHECK: DW_AT_type {{.*}} "int"
+; CHECK-NEXT: DW_AT_name {{.*}} "T"
+; CHECK-NOT: DW_AT_default_value
+; CHECK: DW_AT_type {{.*}} "int"
+; CHECK-NEXT: DW_AT_name {{.*}} "T1"
+; CHECK-NEXT: DW_AT_default_value {{.*}} (true)
+
+; CHECK: DW_AT_name {{.*}} "foo"
+; CHECK: DW_AT_type {{.*}} "float"
+; CHECK-NEXT: DW_AT_name {{.*}} "T"
+; CHECK-NOT: DW_AT_default_value
+; CHECK: DW_AT_type {{.*}} "int"
+; CHECK-NEXT: DW_AT_name {{.*}} "T1"
+; CHECK-NEXT: DW_AT_default_value {{.*}} (true)
+
+; CHECK: DW_AT_name {{.*}} "foo"
+; CHECK: DW_AT_type {{.*}} "char"
+; CHECK-NEXT: DW_AT_name {{.*}} "T"
+; CHECK-NEXT: DW_AT_default_value {{.*}} (true)
+; CHECK: DW_AT_type {{.*}} "int"
+; CHECK-NEXT: DW_AT_name {{.*}} "T1"
+; CHECK-NEXT: DW_AT_default_value {{.*}} (true)
+; ModuleID = '/dir/test.cpp'
+source_filename = "/dir/test.cpp"
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+%class.foo = type { i8 }
+%class.foo.0 = type { i8 }
+%class.foo.1 = type { i8 }
+
+; Function Attrs: noinline norecurse nounwind optnone uwtable
+define dso_local i32 @main() #0 !dbg !7 {
+entry:
+  %retval = alloca i32, align 4
+  %f1 = alloca %class.foo, align 1
+  %f2 = alloca %class.foo.0, align 1
+  %f3 = alloca %class.foo.1, align 1
+  store i32 0, i32* %retval, align 4
+  call void @llvm.dbg.declare(metadata %class.foo* %f1, metadata !11, metadata !DIExpression()), !dbg !16
+  call void @llvm.dbg.declare(metadata %class.foo.0* %f2, metadata !17, metadata !DIExpression()), !dbg !22
+  call void @llvm.dbg.declare(metadata %class.foo.1* %f3, metadata !23, metadata !DIExpression()), !dbg !28
+  ret i32 0, !dbg !29
+}
+
+; Function Attrs: nounwind readnone speculatable willreturn
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
+
+attributes #0 = { noinline norecurse nounwind optnone uwtable }
+attributes #1 = { nounwind readnone speculatable willreturn }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5}
+!llvm.ident = !{!6}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 10.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums:

[PATCH] D73453: Preserve -nostdinc and --sysroot when calling query driver

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

Hi @topisani, thanks for working on clangd!

Yes that bug fell through the cracks since the logs proposed in the comments 
were not making use of `-query-driver` option. Do you mind adding some logs to 
the bug report, without your patch so that we can clearly see its effect.

Initially we left it out, because it is always hairy to parse command line 
options textually, and also kind of unclear why clang wouldn't pick it up 
itself once you have `isysroot` or `sysroot` set, with extra logs we can be 
sure there are
no bugs in clang/clangd side, and it is just about a custom logic in the driver 
you are using.

We also need some tests, could you add some to 
`test/system-include-extractor.test` ?




Comment at: clang-tools-extra/clangd/QueryDriverDatabase.cpp:230
 Lang = Arg.drop_front(2).trim();
+  else if (Arg == "-nostdinc")
+PreservedArgs.push_back(Arg);

we should also handle `-nobuiltininc`, `--no-standard-includes` and 
`-nostdinc++`.



Comment at: clang-tools-extra/clangd/QueryDriverDatabase.cpp:232
+PreservedArgs.push_back(Arg);
+  else if (Arg == "--sysroot" && I + 1 < E) {
+PreservedArgs.push_back(Arg);

could you also handle `isysroot` ?



Comment at: clang-tools-extra/clangd/QueryDriverDatabase.cpp:260
   else
-DriverToIncludesCache[Key] = SystemIncludes =
-extractSystemIncludes(Key.first, Key.second, QueryDriverRegex);
+DriverToIncludesCache[Key] = SystemIncludes = extractSystemIncludes(
+Key.first, Key.second, PreservedArgs, QueryDriverRegex);

let's pass the `Cmd->CommandLine` to `extractSystemIncludes` and perform the 
preservation logic there, so that we only do it once.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D73453



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


[PATCH] D73413: [clang-tidy] Add check to detect external definitions with no header declaration

2020-01-27 Thread Nathan James via Phabricator via cfe-commits
njames93 marked 2 inline comments as done.
njames93 added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/misc/MissingHeaderFileDeclarationCheck.cpp:29
+
+  bool isHeader() const {
+return llvm::StringSwitch(Extension)

gribozavr2 wrote:
> njames93 wrote:
> > gribozavr2 wrote:
> > > I think we should consider any file other than the main file to be a 
> > > header (anything brought in by `#include`). Projects have lots of 
> > > different convention -- for example, LLVM uses a `.inc` extension for 
> > > some generated files and x-macro files. The standard library does not 
> > > have any extensions at all (and I'm sure some projects imitate that) etc.
> > I agree in part, but there is one case that I didn't want to happen and 
> > that is when clang-tidy is ran as a text editor plugin. Often it will 
> > blindly treat the current open file as the main file which would lead to a 
> > lot of false positives, Would a better metric being matching on file 
> > extensions not corresponding to source files (c, cc, cxx, cpp)?
> > I agree in part, but there is one case that I didn't want to happen and 
> > that is when clang-tidy is ran as a text editor plugin.
> 
> Does that really happen? That sounds like broken editor integration to me, 
> because this is not how C++ without modules works...
> 
> > Would a better metric being matching on file extensions not corresponding 
> > to source files (c, cc, cxx, cpp)?
> 
> Yes, I think that would be better, if we have to sniff file extensions.
Well it depends on the editor and language server, I know that if you have a 
valid compile commands clangd will look for the best source file to compile 
against. But I feel that there would be some basic editors which will blindly 
run clang-tidy against the open file. There is also the case of header only 
libraries that people want to get code analysis on, not sure if they maybe 
create a proxy file to include the header though.



Comment at: 
clang-tools-extra/clang-tidy/misc/MissingHeaderFileDeclarationCheck.cpp:75
+  continue;
+if (AnyHeader || File->NamePart.equals_lower(ThisFile->NamePart))
+  return; // Found a good candidate for matching decl

gribozavr2 wrote:
> njames93 wrote:
> > gribozavr2 wrote:
> > > This heuristic should be a lot more complex. In practice people have more 
> > > complex naming conventions (for example, in Clang, Sema.h corresponds to 
> > > many files named SemaSomethingSomething.cpp).
> > > 
> > > I think there is a high chance that checking only a header with a 
> > > matching name will satisfy too few projects to be worth implementing.
> > > 
> > > On the other hand, if you could use C++ or Clang modules to narrow down 
> > > the list of headers where the declaration should appear, that would be a 
> > > much stronger signal.
> > That is the reason I added the CheckAnyHeader option. For small projects 
> > the matching name would be usually be enough, but for big complex projects 
> > there is no feasible check that would work. Falling back to making sure 
> > every external definition has a declaration in at least one header will 
> > always be a good warning
> That's the thing -- due to the lack of consistency in projects and style 
> guides for C++, I think most projects will have to turn on CheckAnyHeader. We 
> get implementation complexity in ClangTidy, false positives in high-profile 
> projects, force users to configure ClangTidy to work well for their projects 
> (unless we set CheckAnyHeader=1 by default... which then nobody would flip 
> back to zero), and little benefit for end users.
Would you say the best way would be check if the source file name starts with 
the header file name by default. Or is that very specific to Clang?

```
/// 
#include "SomeHeader.h"
```
This file would check for declarations in `SomeHeader.h`

Or maybe check if the header file name starts with the source file?

```
/// 
#include "SomeHeaderImpl.h"
```
This file would check for declarations in `SomeHeaderImpl.h`.
Or even check both?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73413



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


[PATCH] D73380: [clang] Annotating C++'s `operator new` with more attributes

2020-01-27 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 240530.
lebedev.ri marked an inline comment as done.
lebedev.ri added a comment.

For the sake of forward progress, remove overly optimistic alignment 
annotation, and replace it with FIXME.
I have some ideas how to deal with that, but i'd prefer to deal with all the 
simple stuff first.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73380

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Decl.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/AST/ast-dump-stmt-json.cpp
  clang/test/Analysis/new-ctor-malloc.cpp
  clang/test/Analysis/new-ctor-null-throw.cpp
  clang/test/Analysis/new-ctor-null.cpp
  clang/test/CodeGenCXX/align-avx-complete-objects.cpp
  clang/test/CodeGenCXX/arm.cpp
  clang/test/CodeGenCXX/builtin-calling-conv.cpp
  clang/test/CodeGenCXX/builtin-is-constant-evaluated.cpp
  clang/test/CodeGenCXX/builtin-operator-new-delete.cpp
  clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
  clang/test/CodeGenCXX/cxx11-initializer-array-new.cpp
  clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
  clang/test/CodeGenCXX/delete-two-arg.cpp
  clang/test/CodeGenCXX/dllexport.cpp
  clang/test/CodeGenCXX/dllimport.cpp
  clang/test/CodeGenCXX/exceptions.cpp
  clang/test/CodeGenCXX/goto.cpp
  clang/test/CodeGenCXX/microsoft-abi-array-cookies.cpp
  clang/test/CodeGenCXX/mips-size_t-ptrdiff_t.cpp
  clang/test/CodeGenCXX/multi-dim-operator-new.cpp
  clang/test/CodeGenCXX/new-alias.cpp
  clang/test/CodeGenCXX/new-array-init.cpp
  clang/test/CodeGenCXX/new-overflow.cpp
  clang/test/CodeGenCXX/new.cpp
  clang/test/CodeGenCXX/operator-new.cpp
  clang/test/CodeGenCXX/runtime-dllstorage.cpp
  clang/test/CodeGenCXX/static-init.cpp
  clang/test/CodeGenCoroutines/coro-alloc.cpp
  clang/test/CodeGenCoroutines/coro-cleanup.cpp
  clang/test/CodeGenCoroutines/coro-gro-nrvo.cpp
  clang/test/CodeGenCoroutines/coro-gro.cpp
  clang/test/CodeGenCoroutines/coro-return.cpp
  clang/test/CodeGenObjCXX/arc-new-delete.mm
  clang/test/CodeGenObjCXX/copy.mm
  clang/test/SemaCXX/builtin-operator-new-delete.cpp
  clang/test/SemaCXX/new-delete.cpp

Index: clang/test/SemaCXX/new-delete.cpp
===
--- clang/test/SemaCXX/new-delete.cpp
+++ clang/test/SemaCXX/new-delete.cpp
@@ -27,7 +27,7 @@
 
 __attribute__((used))
 inline void *operator new(size_t) { // no warning, due to __attribute__((used))
-  return 0;
+  return 0; // expected-warning {{null returned from function that requires a non-null return value}}
 }
 
 // PR5823
@@ -53,9 +53,9 @@
   pi = ::new int;
   U *pu = new (ps) U;
   V *pv = new (ps) V;
-  
+
   pi = new (S(1.0f, 2)) int;
-  
+
   (void)new int[true];
 
   // PR7147
@@ -329,7 +329,7 @@
 
 void f() {
   (void)new int[10](1, 2); // expected-error {{array 'new' cannot have initialization arguments}}
-  
+
   typedef int T[10];
   (void)new T(1, 2); // expected-error {{array 'new' cannot have initialization arguments}}
 }
@@ -363,7 +363,7 @@
   void operator delete(void* p); // expected-note {{declared private here}}
 };
 
-void test(S1* s1, S2* s2) { 
+void test(S1* s1, S2* s2) {
   delete s1;
   delete s2; // expected-error {{is a private member}}
   (void)new S1();
@@ -397,7 +397,7 @@
 
 // 
 namespace Instantiate {
-  template struct X { 
+  template struct X {
 operator T*();
   };
 
Index: clang/test/SemaCXX/builtin-operator-new-delete.cpp
===
--- clang/test/SemaCXX/builtin-operator-new-delete.cpp
+++ clang/test/SemaCXX/builtin-operator-new-delete.cpp
@@ -75,7 +75,7 @@
 
 void test_arg_types() {
   __builtin_operator_new(NP);  // expected-error {{no matching function for call to 'operator new'}}
-  __builtin_operator_new(NP, std::align_val_t(0)); // expected-error {{no matching function for call to 'operator new'}}}
+  __builtin_operator_new(NP, std::align_val_t(0)); // expected-error {{no matching function for call to 'operator new'}}
 }
 void test_return_type() {
   int w = __builtin_operator_new(42);// expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'void *'}}
Index: clang/test/CodeGenObjCXX/copy.mm
===
--- clang/test/CodeGenObjCXX/copy.mm
+++ clang/test/CodeGenObjCXX/copy.mm
@@ -11,7 +11,7 @@
   // CHECK:  alloca
   // CHECK-NEXT: getelementptr
   // CHECK-NEXT: store
-  // CHECK-NEXT: call i8* @_Znwm(
+  // CHECK-NEXT: [[CALL:%.*]] = call noalias nonnull i8* @_Znwm(
   // CHECK-NEXT: bitcast
   // CHECK-NEXT: bitcast
   // CHECK-NEXT: bitcast
Index: clang/test/CodeGenObjCXX/arc-new-delete.mm
===
--- clang/test/CodeGenObjCXX/arc-

[PATCH] D73450: [clangd] Add a symbol-name-based blacklist for rename.

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

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

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

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

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


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73450



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


[PATCH] D73450: [clangd] Add a symbol-name-based blacklist for rename.

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

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

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

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

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


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73450



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


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

2020-01-27 Thread Jaydeep Chauhan via Phabricator via cfe-commits
Jac1494 marked an inline comment as done.
Jac1494 added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:4598
+  if (!(DebugKind == clang::codegenoptions::FullDebugInfo))
+return;
 

aprantl wrote:
> nit: 
> 
> ```
> if (DebugKind < clang::codegenoptions::FullDebugInfo)
>   return
> 
> ```
@aprantl thanks for suggestion , change is updated.


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

https://reviews.llvm.org/D71451



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


[PATCH] D73463: [clangd] use SCOPED_TRACE to better trace the testcase in test failure, NFC

2020-01-27 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/D73463

Files:
  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
@@ -442,6 +442,7 @@
   )cpp",
   };
   for (llvm::StringRef T : Tests) {
+SCOPED_TRACE(T);
 Annotations Code(T);
 auto TU = TestTU::withCode(Code.code());
 TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
@@ -560,6 +561,7 @@
   };
 
   for (const auto& Case : Cases) {
+SCOPED_TRACE(Case.Code);
 Annotations T(Case.Code);
 TestTU TU = TestTU::withCode(T.code());
 TU.HeaderCode = CommonHeader;
@@ -886,6 +888,7 @@
   };
 
   for (const auto& T : Cases) {
+SCOPED_TRACE(T.FooH);
 Annotations FooH(T.FooH);
 Annotations FooCC(T.FooCC);
 std::string FooHPath = testPath("foo.h");
@@ -1012,6 +1015,7 @@
   LangOptions LangOpts;
   LangOpts.CPlusPlus = true;
   for (const auto &T : Tests) {
+SCOPED_TRACE(T.DraftCode);
 Annotations Draft(T.DraftCode);
 auto ActualRanges = adjustRenameRanges(
 Draft.code(), "x", Annotations(T.IndexedCode).ranges(), LangOpts);
@@ -1019,8 +1023,7 @@
EXPECT_THAT(Draft.ranges(), testing::IsEmpty());
 else
   EXPECT_THAT(Draft.ranges(),
-  testing::UnorderedElementsAreArray(*ActualRanges))
-  << T.DraftCode;
+  testing::UnorderedElementsAreArray(*ActualRanges));
   }
 }
 
@@ -1127,6 +1130,7 @@
 }
   };
   for (const auto &T : Tests) {
+SCOPED_TRACE(T.IndexedCode);
 auto Lexed = Annotations(T.LexedCode);
 auto LexedRanges = Lexed.ranges();
 std::vector ExpectedMatches;
@@ -1143,8 +1147,7 @@
 if (!Mapped)
   EXPECT_THAT(ExpectedMatches, IsEmpty());
 else
-  EXPECT_THAT(ExpectedMatches, UnorderedElementsAreArray(*Mapped))
-  << T.IndexedCode;
+  EXPECT_THAT(ExpectedMatches, UnorderedElementsAreArray(*Mapped));
   }
 }
 
@@ -1247,13 +1250,14 @@
 },
   };
   for (const auto &T : Tests) {
+SCOPED_TRACE(T.RangeCode);
 Annotations C(T.RangeCode);
 std::vector MappedIndex;
 for (size_t I = 0; I < C.ranges("lex").size(); ++I)
   MappedIndex.push_back(I);
 EXPECT_EQ(renameRangeAdjustmentCost(C.ranges("idx"), C.ranges("lex"),
 MappedIndex),
-  T.ExpectedCost) << T.RangeCode;
+  T.ExpectedCost);
   }
 }
 


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -442,6 +442,7 @@
   )cpp",
   };
   for (llvm::StringRef T : Tests) {
+SCOPED_TRACE(T);
 Annotations Code(T);
 auto TU = TestTU::withCode(Code.code());
 TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
@@ -560,6 +561,7 @@
   };
 
   for (const auto& Case : Cases) {
+SCOPED_TRACE(Case.Code);
 Annotations T(Case.Code);
 TestTU TU = TestTU::withCode(T.code());
 TU.HeaderCode = CommonHeader;
@@ -886,6 +888,7 @@
   };
 
   for (const auto& T : Cases) {
+SCOPED_TRACE(T.FooH);
 Annotations FooH(T.FooH);
 Annotations FooCC(T.FooCC);
 std::string FooHPath = testPath("foo.h");
@@ -1012,6 +1015,7 @@
   LangOptions LangOpts;
   LangOpts.CPlusPlus = true;
   for (const auto &T : Tests) {
+SCOPED_TRACE(T.DraftCode);
 Annotations Draft(T.DraftCode);
 auto ActualRanges = adjustRenameRanges(
 Draft.code(), "x", Annotations(T.IndexedCode).ranges(), LangOpts);
@@ -1019,8 +1023,7 @@
EXPECT_THAT(Draft.ranges(), testing::IsEmpty());
 else
   EXPECT_THAT(Draft.ranges(),
-  testing::UnorderedElementsAreArray(*ActualRanges))
-  << T.DraftCode;
+  testing::UnorderedElementsAreArray(*ActualRanges));
   }
 }
 
@@ -1127,6 +1130,7 @@
 }
   };
   for (const auto &T : Tests) {
+SCOPED_TRACE(T.IndexedCode);
 auto Lexed = Annotations(T.LexedCode);
 auto LexedRanges = Lexed.ranges();
 std::vector ExpectedMatches;
@@ -1143,8 +1147,7 @@
 if (!Mapped)
   EXPECT_THAT(ExpectedMatches, IsEmpty());
 else
-  EXPECT_THAT(ExpectedMatches, UnorderedElementsAreArray(*Mapped))
-  << T.IndexedCode;
+  EXPECT_THAT(ExpectedMatches, UnorderedElementsAreArray(*Mapped));
   }
 }
 
@@ -1247,13 +1250,14 @@
 },
   };
   for (const auto &T : Tests) {
+SCOPED_TRACE(T.RangeCode);
 Annotations C(T.RangeCode);
 std::vector MappedIndex;
 for (size_t I = 0; I < C.ranges("lex").size(); ++I)
   MappedIndex.push_back(I);
 

[PATCH] D73464: [clang] Add TagDecl AST matcher

2020-01-27 Thread Karasev Nikita via Phabricator via cfe-commits
f00kat created this revision.
f00kat added reviewers: aaron.ballman, alexfh, hokein, JonasToth.
f00kat added a project: clang.
Herald added a subscriber: cfe-commits.

In this case https://reviews.llvm.org/D73090#1840501 @aaron.ballman suggest to 
add new AST matcher for tagDecl to avoid using recordDecl and enumDecl together.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73464

Files:
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -184,6 +184,13 @@
   EXPECT_TRUE(notMatches("enum X {};", Matcher));
 }
 
+TEST(TagDecl, MatchesTagDecls) {
+  EXPECT_TRUE(matches("struct X {};", tagDecl(hasName("X";
+  EXPECT_TRUE(matches("class C {};", tagDecl(hasName("C";
+  EXPECT_TRUE(matches("union U {};", tagDecl(hasName("U";
+  EXPECT_TRUE(matches("enum E {};", tagDecl(hasName("E";
+}
+
 TEST(Matcher, UnresolvedLookupExpr) {
   // FIXME: The test is known to be broken on Windows with delayed template
   // parsing.
Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2504,6 +2504,13 @@
   EXPECT_TRUE(notMatches("enum X {};", enumDecl(isScoped(;
 }
 
+TEST(TagDeclKind, MatchesTagDeclKind) {
+  EXPECT_TRUE(matches("struct X {};", tagDecl(isStruct(;
+  EXPECT_TRUE(matches("class C {};", tagDecl(isClass(;
+  EXPECT_TRUE(matches("union U {};", tagDecl(isUnion(;
+  EXPECT_TRUE(matches("enum E {};", tagDecl(isEnum(;
+}
+
 TEST(HasTrailingReturn, MatchesTrailingReturn) {
   EXPECT_TRUE(matches("auto Y() -> int { return 0; }",
   functionDecl(hasTrailingReturn(;
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -208,6 +208,8 @@
   REGISTER_MATCHER(doStmt);
   REGISTER_MATCHER(eachOf);
   REGISTER_MATCHER(elaboratedType);
+  REGISTER_MATCHER(tagDecl);
+  REGISTER_MATCHER(tagType);
   REGISTER_MATCHER(enumConstantDecl);
   REGISTER_MATCHER(enumDecl);
   REGISTER_MATCHER(enumType);
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -647,6 +647,7 @@
 const internal::VariadicDynCastAllOfMatcher enumDecl;
 const internal::VariadicDynCastAllOfMatcher
 enumConstantDecl;
+const internal::VariadicDynCastAllOfMatcher tagDecl;
 const internal::VariadicDynCastAllOfMatcher cxxMethodDecl;
 const internal::VariadicDynCastAllOfMatcher
 cxxConversionDecl;
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -1194,6 +1194,20 @@
 extern const internal::VariadicDynCastAllOfMatcher
 enumConstantDecl;
 
+/// Matches tag declarations.
+///
+/// Example matches X, Z, U, S, E
+/// \code
+///   class X;
+///   template class Z {};
+///   struct S {};
+///   union U {};
+///   enum E {
+/// A, B, C
+///   };
+/// \endcode
+extern const internal::VariadicDynCastAllOfMatcher tagDecl;
+
 /// Matches method declarations.
 ///
 /// Example matches y
@@ -4845,42 +4859,58 @@
   return InnerMatcher.matches(Node.getType(), Finder, Builder);
 }
 
-/// Matches RecordDecl object that are spelled with "struct."
+/// Matches TagDecl object that are spelled with "struct."
 ///
-/// Example matches S, but not C or U.
+/// Example matches S, but not C, U or E.
 /// \code
 ///   struct S {};
 ///   class C {};
 ///   union U {};
+///   enum E {};
 /// \endcode
-AST_MATCHER(RecordDecl, isStruct) {
+AST_MATCHER(TagDecl, isStruct) {
   return Node.isStruct();
 }
 
-/// Matches RecordDecl object that are spelled with "union."
+/// Matches TagDecl object that are spelled with "union."
 ///
-/// Example matches U, but not C or S.
+/// Example matches U, but not C, S or E.
 /// \code
 ///   struct S {};
 ///   class C {};
 ///   union U {};
+///   enum E {};
 /// \endcode
-AST_MATCHER(RecordDecl, isUnion) {
+AST_MATCHER(TagDecl, isUnion) {
   return Node.isUnion();
 }
 
-/// Matches RecordDecl object that are spelled with "class."
+/// Matches TagDecl object that are spelled with "class."
 ///
-/// Example matches C, but not S or U.
+/// Examp

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

2020-01-27 Thread Jaydeep Chauhan via Phabricator via cfe-commits
Jac1494 added a comment.

In D71451#1817334 , @aprantl wrote:

> In D71451#1816269 , @Jac1494 wrote:
>
> > ping
>
>
> I'd be curious to the answer to David's questions. If the size increase is 
> because of unused extern variables coming in from libc or something then it 
> doesn't seem worth the cost.


@aprantl now size of clang is same with this change (D71451 
 and D71599 ).


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

https://reviews.llvm.org/D71451



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


[PATCH] D73463: [clangd] use SCOPED_TRACE to better trace the testcase in test failure, NFC

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

{icon times-circle color=red} Unit tests: fail. 62207 tests passed, 1 failed 
and 815 were skipped.

  failed: 
libc++.std/thread/thread_mutex/thread_mutex_requirements/thread_mutex_requirements_mutex/thread_mutex_recursive/lock.pass.cpp

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

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

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


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73463



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


[PATCH] D73441: [clang-tidy] Fix bugprone-use-after-move when move is in noexcept operator

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

- Fix nits in test cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73441

Files:
  clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
@@ -1270,4 +1270,32 @@
 C c;
   }
 };
+} // namespace PR33020
+
+namespace UnevalContext {
+struct Foo {};
+void noExcept() {
+  Foo Bar;
+  (void) noexcept(Foo{std::move(Bar)});
+  Foo Other{std::move(Bar)};
 }
+void sizeOf() {
+  Foo Bar;
+  (void)sizeof(Foo{std::move(Bar)});
+  Foo Other{std::move(Bar)};
+}
+void alignOf() {
+  Foo Bar;
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wgnu-alignof-expression"
+  (void)alignof(Foo{std::move(Bar)});
+#pragma clang diagnostic pop
+  Foo Other{std::move(Bar)};
+}
+void typeId() {
+  Foo Bar;
+  // error: you need to include  before using the 'typeid' operator
+  // (void) typeid(Foo{std::move(Bar)}).name();
+  Foo Other{std::move(Bar)};
+}
+} // namespace UnevalContext
Index: clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
@@ -8,6 +8,10 @@
 
 #include "UseAfterMoveCheck.h"
 
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
+#include "clang/AST/ExprConcepts.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Analysis/CFG.h"
 #include "clang/Lex/Lexer.h"
 
@@ -23,6 +27,23 @@
 
 namespace {
 
+AST_MATCHER(Expr, hasUnevaluatedContext) {
+  if (isa(Node) || isa(Node))
+return true;
+  if (const auto *UnaryExpr = dyn_cast(&Node)) {
+switch (UnaryExpr->getKind()) {
+case UETT_SizeOf:
+case UETT_AlignOf:
+  return true;
+default:
+  return false;
+}
+  }
+  if (const auto *TypeIDExpr = dyn_cast(&Node))
+return !TypeIDExpr->isPotentiallyEvaluated();
+  return false;
+}
+
 /// Contains information about a use-after-move.
 struct UseAfterMove {
   // The DeclRefExpr that constituted the use of the object.
@@ -77,7 +98,8 @@
 static StatementMatcher inDecltypeOrTemplateArg() {
   return anyOf(hasAncestor(typeLoc()),
hasAncestor(declRefExpr(
-   
to(functionDecl(ast_matchers::isTemplateInstantiation());
+   to(functionDecl(ast_matchers::isTemplateInstantiation(),
+   hasAncestor(expr(hasUnevaluatedContext(;
 }
 
 UseAfterMoveFinder::UseAfterMoveFinder(ASTContext *TheContext)


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
@@ -1270,4 +1270,32 @@
 C c;
   }
 };
+} // namespace PR33020
+
+namespace UnevalContext {
+struct Foo {};
+void noExcept() {
+  Foo Bar;
+  (void) noexcept(Foo{std::move(Bar)});
+  Foo Other{std::move(Bar)};
 }
+void sizeOf() {
+  Foo Bar;
+  (void)sizeof(Foo{std::move(Bar)});
+  Foo Other{std::move(Bar)};
+}
+void alignOf() {
+  Foo Bar;
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wgnu-alignof-expression"
+  (void)alignof(Foo{std::move(Bar)});
+#pragma clang diagnostic pop
+  Foo Other{std::move(Bar)};
+}
+void typeId() {
+  Foo Bar;
+  // error: you need to include  before using the 'typeid' operator
+  // (void) typeid(Foo{std::move(Bar)}).name();
+  Foo Other{std::move(Bar)};
+}
+} // namespace UnevalContext
Index: clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
@@ -8,6 +8,10 @@
 
 #include "UseAfterMoveCheck.h"
 
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
+#include "clang/AST/ExprConcepts.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Analysis/CFG.h"
 #include "clang/Lex/Lexer.h"
 
@@ -23,6 +27,23 @@
 
 namespace {
 
+AST_MATCHER(Expr, hasUnevaluatedContext) {
+  if (isa(Node) || isa(Node))
+return true;
+  if (const auto *UnaryExpr = dyn_cast(&Node)) {
+switch (UnaryExpr->getKind()) {
+case UETT_SizeOf:
+case UETT_AlignOf:
+  return true;
+default:
+  return false;
+}
+  }
+  if (const auto *TypeIDExpr = dyn_cast(&Node))
+return !TypeIDExpr->isPotentiallyEvaluated();
+  return fal

[PATCH] D73098: [clang-tidy] readability-identifier-naming disregards parameters restrictions on main like functions

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



Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:340
+return false;
+  if (FDecl->getAccess() == AS_private || FDecl->getAccess() == AS_protected)
+return false;

aaron.ballman wrote:
> I'd flip the logic to `!= AS_public` to be more clear that we only care about 
> public members.
What do you think about AS_none, its a weird case and shall i ignore it. I'm 
guessing all functions not in a class are implicitly declared to be public.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73098



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


Re: [clang-tools-extra] 58592f6 - Include for std::abort() in clangd

2020-01-27 Thread Hans Wennborg via cfe-commits
Merged to 10.x in 23d93923900834dd873cde2ea54f7c3a0e071802

On Fri, Jan 24, 2020 at 11:53 AM Dimitry Andric via cfe-commits
 wrote:
>
>
> Author: Dimitry Andric
> Date: 2020-01-24T20:52:37+01:00
> New Revision: 58592f6c49249293f79698cfcb31dba532e12603
>
> URL: 
> https://github.com/llvm/llvm-project/commit/58592f6c49249293f79698cfcb31dba532e12603
> DIFF: 
> https://github.com/llvm/llvm-project/commit/58592f6c49249293f79698cfcb31dba532e12603.diff
>
> LOG: Include  for std::abort() in clangd
>
> This fixes a "not a member of 'std'" error with e.g. Fedora 32.
>
> Closes: #105
>
> Added:
>
>
> Modified:
> clang-tools-extra/clangd/Shutdown.cpp
>
> Removed:
>
>
>
> 
> diff  --git a/clang-tools-extra/clangd/Shutdown.cpp 
> b/clang-tools-extra/clangd/Shutdown.cpp
> index dfea46d8dfeb..36d977570a4f 100644
> --- a/clang-tools-extra/clangd/Shutdown.cpp
> +++ b/clang-tools-extra/clangd/Shutdown.cpp
> @@ -9,6 +9,7 @@
>  #include "Shutdown.h"
>
>  #include 
> +#include 
>  #include 
>
>  namespace clang {
>
>
>
> ___
> 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


[PATCH] D73271: [clang][CodeComplete] Support for designated initializers

2020-01-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 240551.
kadircet marked 7 inline comments as done.
kadircet added a comment.

- Propogate types in more cases
- Add more tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73271

Files:
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseInit.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/desig-init.cpp

Index: clang/test/CodeCompletion/desig-init.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/desig-init.cpp
@@ -0,0 +1,54 @@
+struct Base {
+  int t;
+};
+struct Foo : public Base {
+  int x;
+  Base b;
+  void foo();
+};
+
+void foo() {
+  Foo F{.x = 2, .b.t = 0};
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:11:10 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC1 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:11:18 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC1 %s
+  // CHECK-CC1: COMPLETION: b : [#Base#]b
+  // CHECK-CC1-NEXT: COMPLETION: x : [#int#]x
+  // CHECK-CC1-NOT: foo
+  // CHECK-CC1-NOT: t
+
+  // FIXME: Handle nested designators
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:11:20 %s -o - | count 0
+
+  Base B = {.t = 2};
+  auto z = [](Base B) {};
+  z({.t = 1});
+  z(Base{.t = 2});
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:22:14 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC2 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:24:7 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC2 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:25:11 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC2 %s
+  // CHECK-CC2: COMPLETION: t : [#int#]t
+}
+
+// Handle templates
+template 
+struct Test { T x; };
+template <>
+struct Test {
+  int x;
+  char y;
+};
+void bar() {
+  Test T{.x = 2};
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:41:17 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC3 %s
+  // CHECK-CC3: COMPLETION: x : [#T#]x
+  Test X{.x = 2};
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:44:16 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC4 %s
+  // CHECK-CC4: COMPLETION: x : [#int#]x
+  // CHECK-CC4-NEXT: COMPLETION: y : [#char#]y
+}
+
+template 
+void aux() {
+  Test X{.x = T(2)};
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:52:14 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC3 %s
+}
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -13,6 +13,8 @@
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
+#include "clang/AST/DeclTemplate.h"
+#include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/ExprObjC.h"
 #include "clang/AST/QualTypeNames.h"
@@ -23,11 +25,14 @@
 #include "clang/Lex/MacroInfo.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
+#include "clang/Sema/Designator.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Overload.h"
 #include "clang/Sema/Scope.h"
 #include "clang/Sema/ScopeInfo.h"
+#include "clang/Sema/Sema.h"
 #include "clang/Sema/SemaInternal.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/SmallBitVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
@@ -36,6 +41,7 @@
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/ADT/iterator_range.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -4723,6 +4729,23 @@
   }
 }
 
+// Returns the RecordDecl inside the BaseType, falling back to primary template
+// in case of specializations. Since we might not have a decl for the
+// instantiation/specialization yet, e.g. dependent code.
+static RecordDecl *getAsRecordDecl(const QualType BaseType) {
+  if (auto *RD = BaseType->getAsRecordDecl())
+return RD;
+
+  if (const auto *TST = BaseType->getAs()) {
+if (const auto *TD = dyn_cast_or_null(
+TST->getTemplateName().getAsTemplateDecl())) {
+  return TD->getTemplatedDecl();
+}
+  }
+
+  return nullptr;
+}
+
 void Sema::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base,
Expr *OtherOpBase,
SourceLocation OpLoc, bool IsArrow,
@@ -4771,6 +4794,8 @@
 Base = ConvertedBase.get();
 
 QualType BaseType = Base->getType();
+if (Base

[PATCH] D73441: [clang-tidy] Fix bugprone-use-after-move when move is in noexcept operator

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

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

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

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

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


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73441



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


[PATCH] D73271: [clang][CodeComplete] Support for designated initializers

2020-01-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet marked 7 inline comments as done.
kadircet added inline comments.



Comment at: clang/lib/Parse/ParseDecl.cpp:2463
 
+PreferredType.enterVariableInit(Tok.getLocation(), ThisDecl);
 ExprResult Init(ParseBraceInitializer());

sammccall wrote:
> oops, I missed where this was happening.
> 
> There are lots of non-vardecl cases where we might use a designated init.
> We won't necessarily know the type in all of them, but it'd be good to at 
> least cover the cases where we do. (Particularly `ty{...}`)
see tests for more cases we handle



Comment at: clang/lib/Parse/ParseInit.cpp:162
+ExprResult Parser::ParseInitializerWithPotentialDesignator(
+llvm::function_ref CodeCompleteCB) {
 

sammccall wrote:
> This callback stuff doesn't seem so idiomatic in the parser from what I've 
> seen - can we be a bit more direct and just pass the location?
it is not just the location though, we are also lacking the information 
regarding initializers seen so far. there are other occurrences of this 
callback mechanisms while parsing parenthesized expressions, for similar 
reasons, lacking the bigger picture. I think it is better to keep those element 
parsing functions unaware of the outer state, since they mostly don't care or 
depend on it.



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:4731
 
+static RecordDecl *getAsRecordDecl(const QualType BaseType) {
+  if (const RecordType *Record = BaseType->getAs())

sammccall wrote:
> sammccall wrote:
> > this needs a name and/or comment to describe how it falls back to the 
> > primary template if the decl for the specialization isn't known.
> > (From the name, you can't tel how it's different from Type::getRecordDecl)
> as discussed offline, this doesn't handle null, neither does the new caller
handling it in the new caller instead, as discussed previous caller technically 
can't have an incomplete type when it reaches this code path.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73271



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


[clang] af954e4 - [WPD] Emit vcall_visibility metadata for MicrosoftCXXABI

2020-01-27 Thread Teresa Johnson via cfe-commits

Author: Teresa Johnson
Date: 2020-01-27T06:22:24-08:00
New Revision: af954e441a5170a75687699d91d85e0692929d43

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

LOG: [WPD] Emit vcall_visibility metadata for MicrosoftCXXABI

Summary:
The MicrosoftCXXABI uses a separate mechanism for emitting vtable
type metadata, and thus didn't pick up the change from D71907
to emit the vcall_visibility metadata under -fwhole-program-vtables.

I believe this is the cause of a Windows bot failure when I committed
follow on change D71913 that required a revert. The failure occurred
in a CFI test that was expecting to not abort because it expected a
devirtualization to occur, and without the necessary vcall_visibility
metadata we would not get devirtualization.

Note in the equivalent code in CodeGenModule::EmitVTableTypeMetadata
(used by the ItaniumCXXABI), we also emit the vcall_visibility metadata
when Virtual Function Elimination is enabled. Since I am not as familiar
with the details of that optimization, I have marked that as a TODO and
am only inserting under -fwhole-program-vtables.

Reviewers: evgeny777

Subscribers: Prazek, ostannard, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/CodeGen/MicrosoftCXXABI.cpp
clang/test/CodeGenCXX/vcall-visibility-metadata.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp 
b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
index aff46135705a..b083a5893cf7 100644
--- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1621,6 +1621,15 @@ void MicrosoftCXXABI::emitVTableTypeMetadata(const 
VPtrInfo &Info,
   if (!CGM.getCodeGenOpts().LTOUnit)
 return;
 
+  // TODO: Should VirtualFunctionElimination also be supported here?
+  // See similar handling in CodeGenModule::EmitVTableTypeMetadata.
+  if (CGM.getCodeGenOpts().WholeProgramVTables) {
+llvm::GlobalObject::VCallVisibility TypeVis =
+CGM.GetVCallVisibilityLevel(RD);
+if (TypeVis != llvm::GlobalObject::VCallVisibilityPublic)
+  VTable->setVCallVisibilityMetadata(TypeVis);
+  }
+
   // The location of the first virtual function pointer in the virtual table,
   // aka the "address point" on Itanium. This is at offset 0 if RTTI is
   // disabled, or sizeof(void*) if RTTI is enabled.

diff  --git a/clang/test/CodeGenCXX/vcall-visibility-metadata.cpp 
b/clang/test/CodeGenCXX/vcall-visibility-metadata.cpp
index b770ad767fc2..84d9a2196309 100644
--- a/clang/test/CodeGenCXX/vcall-visibility-metadata.cpp
+++ b/clang/test/CodeGenCXX/vcall-visibility-metadata.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -flto -flto-unit -triple x86_64-unknown-linux -emit-llvm 
-fvirtual-function-elimination -fwhole-program-vtables -o - %s | FileCheck %s 
--check-prefix=CHECK --check-prefix=CHECK-VFE
 // RUN: %clang_cc1 -flto -flto-unit -triple x86_64-unknown-linux -emit-llvm 
-fwhole-program-vtables -o - %s | FileCheck %s --check-prefix=CHECK 
--check-prefix=CHECK-NOVFE
+// RUN: %clang_cc1 -flto -flto-unit -triple x86_64-pc-windows-msvc -emit-llvm 
-fwhole-program-vtables -o - %s | FileCheck %s --check-prefix=CHECK-MS 
--check-prefix=CHECK-NOVFE
 
 // Check that in ThinLTO we also get vcall_visibility summary entries in the 
bitcode
 // RUN: %clang_cc1 -flto=thin -flto-unit -triple x86_64-unknown-linux 
-emit-llvm-bc -fwhole-program-vtables -o - %s | llvm-dis -o - | FileCheck %s 
--check-prefix=CHECK --check-prefix=CHECK-NOVFE --check-prefix=CHECK-SUMMARY
@@ -8,6 +9,7 @@
 // Anonymous namespace.
 namespace {
 // CHECK: @_ZTVN12_GLOBAL__N_11AE = {{.*}} !vcall_visibility [[VIS_TU:![0-9]+]]
+// CHECK-MS: @anon.{{.*}} = private unnamed_addr constant 
{{.*}}struct.(anonymous namespace)::A{{.*}} !vcall_visibility [[VIS_TU:![0-9]+]]
 struct A {
   A() {}
   virtual int f() { return 1; }
@@ -20,6 +22,7 @@ void *construct_A() {
 
 // Hidden visibility.
 // CHECK: @_ZTV1B = {{.*}} !vcall_visibility [[VIS_DSO:![0-9]+]]
+// CHECK-MS: @anon.{{.*}} = private unnamed_addr constant {{.*}}struct.B{{.*}} 
!vcall_visibility [[VIS_DSO:![0-9]+]]
 struct __attribute__((visibility("hidden"))) B {
   B() {}
   virtual int f() { return 1; }
@@ -31,6 +34,8 @@ B *construct_B() {
 
 // Default visibility.
 // CHECK-NOT: @_ZTV1C = {{.*}} !vcall_visibility
+// On MS default is hidden
+// CHECK-MS: @anon.{{.*}} = private unnamed_addr constant {{.*}}struct.C{{.*}} 
!vcall_visibility [[VIS_DSO]]
 struct __attribute__((visibility("default"))) C {
   C() {}
   virtual int f() { return 1; }
@@ -42,6 +47,7 @@ C *construct_C() {
 
 // Hidden visibility, public LTO visibility.
 // CHECK-NOT: @_ZTV1D = {{.*}} !vcall_visibility
+// CHECK-MS-NOT: @anon.{{.*}} = private unnamed_addr constant 
{{.*}}struct.D{{.*}} !vcall_visibility
 struct __at

[PATCH] D73418: [WPD] Emit vcall_visibility metadata for MicrosoftCXXABI

2020-01-27 Thread Teresa Johnson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaf954e441a51: [WPD] Emit vcall_visibility metadata for 
MicrosoftCXXABI (authored by tejohnson).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73418

Files:
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/test/CodeGenCXX/vcall-visibility-metadata.cpp


Index: clang/test/CodeGenCXX/vcall-visibility-metadata.cpp
===
--- clang/test/CodeGenCXX/vcall-visibility-metadata.cpp
+++ clang/test/CodeGenCXX/vcall-visibility-metadata.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -flto -flto-unit -triple x86_64-unknown-linux -emit-llvm 
-fvirtual-function-elimination -fwhole-program-vtables -o - %s | FileCheck %s 
--check-prefix=CHECK --check-prefix=CHECK-VFE
 // RUN: %clang_cc1 -flto -flto-unit -triple x86_64-unknown-linux -emit-llvm 
-fwhole-program-vtables -o - %s | FileCheck %s --check-prefix=CHECK 
--check-prefix=CHECK-NOVFE
+// RUN: %clang_cc1 -flto -flto-unit -triple x86_64-pc-windows-msvc -emit-llvm 
-fwhole-program-vtables -o - %s | FileCheck %s --check-prefix=CHECK-MS 
--check-prefix=CHECK-NOVFE
 
 // Check that in ThinLTO we also get vcall_visibility summary entries in the 
bitcode
 // RUN: %clang_cc1 -flto=thin -flto-unit -triple x86_64-unknown-linux 
-emit-llvm-bc -fwhole-program-vtables -o - %s | llvm-dis -o - | FileCheck %s 
--check-prefix=CHECK --check-prefix=CHECK-NOVFE --check-prefix=CHECK-SUMMARY
@@ -8,6 +9,7 @@
 // Anonymous namespace.
 namespace {
 // CHECK: @_ZTVN12_GLOBAL__N_11AE = {{.*}} !vcall_visibility [[VIS_TU:![0-9]+]]
+// CHECK-MS: @anon.{{.*}} = private unnamed_addr constant 
{{.*}}struct.(anonymous namespace)::A{{.*}} !vcall_visibility [[VIS_TU:![0-9]+]]
 struct A {
   A() {}
   virtual int f() { return 1; }
@@ -20,6 +22,7 @@
 
 // Hidden visibility.
 // CHECK: @_ZTV1B = {{.*}} !vcall_visibility [[VIS_DSO:![0-9]+]]
+// CHECK-MS: @anon.{{.*}} = private unnamed_addr constant {{.*}}struct.B{{.*}} 
!vcall_visibility [[VIS_DSO:![0-9]+]]
 struct __attribute__((visibility("hidden"))) B {
   B() {}
   virtual int f() { return 1; }
@@ -31,6 +34,8 @@
 
 // Default visibility.
 // CHECK-NOT: @_ZTV1C = {{.*}} !vcall_visibility
+// On MS default is hidden
+// CHECK-MS: @anon.{{.*}} = private unnamed_addr constant {{.*}}struct.C{{.*}} 
!vcall_visibility [[VIS_DSO]]
 struct __attribute__((visibility("default"))) C {
   C() {}
   virtual int f() { return 1; }
@@ -42,6 +47,7 @@
 
 // Hidden visibility, public LTO visibility.
 // CHECK-NOT: @_ZTV1D = {{.*}} !vcall_visibility
+// CHECK-MS-NOT: @anon.{{.*}} = private unnamed_addr constant 
{{.*}}struct.D{{.*}} !vcall_visibility
 struct __attribute__((visibility("hidden"))) [[clang::lto_visibility_public]] 
D {
   D() {}
   virtual int f() { return 1; }
@@ -53,6 +59,8 @@
 
 // Hidden visibility, but inherits from class with default visibility.
 // CHECK-NOT: @_ZTV1E = {{.*}} !vcall_visibility
+// On MS default is hidden
+// CHECK-MS: @anon.{{.*}} = private unnamed_addr constant {{.*}}struct.E{{.*}} 
!vcall_visibility [[VIS_DSO]]
 struct __attribute__((visibility("hidden"))) E : C {
   E() {}
   virtual int f() { return 1; }
@@ -64,6 +72,8 @@
 
 // Anonymous namespace, but inherits from class with default visibility.
 // CHECK-NOT: @_ZTVN12_GLOBAL__N_11FE = {{.*}} !vcall_visibility
+// On MS default is hidden
+// CHECK-MS: @anon.{{.*}} = private unnamed_addr constant 
{{.*}}struct.(anonymous namespace)::F{{.*}} !vcall_visibility [[VIS_DSO]]
 namespace {
 struct __attribute__((visibility("hidden"))) F : C {
   F() {}
@@ -77,6 +87,7 @@
 
 // Anonymous namespace, but inherits from class with hidden visibility.
 // CHECK: @_ZTVN12_GLOBAL__N_11GE = {{.*}} !vcall_visibility 
[[VIS_DSO:![0-9]+]]
+// CHECK-MS: @anon.{{.*}} = private unnamed_addr constant 
{{.*}}struct.(anonymous namespace)::G{{.*}} !vcall_visibility [[VIS_DSO]]
 namespace {
 struct __attribute__((visibility("hidden"))) G : B {
   G() {}
@@ -87,6 +98,8 @@
   return new G();
 }
 
+// CHECK-MS-DAG: [[VIS_DSO]] = !{i64 1}
+// CHECK-MS-DAG: [[VIS_TU]] = !{i64 2}
 // CHECK-DAG: [[VIS_DSO]] = !{i64 1}
 // CHECK-DAG: [[VIS_TU]] = !{i64 2}
 // CHECK-VFE-DAG: !{i32 1, !"Virtual Function Elim", i32 1}
Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1621,6 +1621,15 @@
   if (!CGM.getCodeGenOpts().LTOUnit)
 return;
 
+  // TODO: Should VirtualFunctionElimination also be supported here?
+  // See similar handling in CodeGenModule::EmitVTableTypeMetadata.
+  if (CGM.getCodeGenOpts().WholeProgramVTables) {
+llvm::GlobalObject::VCallVisibility TypeVis =
+CGM.GetVCallVisibilityLevel(RD);
+if (TypeVis != llvm::GlobalObject::VCallVisibilityPublic)
+  VTable->setVCallVisibilityMetadata(TypeVis);
+  }
+
   // The loca

[PATCH] D72705: [clang][checkers] Added new checker 'alpha.unix.ErrorReturn'.

2020-01-27 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

Please consider the following test cases:

  void test_NullCorrectCheck3() {
void *P = aligned_alloc(4, 8);
use(*P); // A developer inserted this line before the check by mistake. 
This will be a null pointer dereference.
if (P == NULL) {
}
  }

Or:

  void test_NullCorrectCheck3() {
void *P = aligned_alloc(4, 8);
if (dice()) { // A deloper introduced a new branch, but by mistake, before 
the check.
  if (P == NULL) {
use(*P);
  }
} else {
 use(*P); // No check in this branch, thus a null pointer dereference.
}
  }

False positive (or not?):

  void g(void*); // Unknown function
  
  void test_NullBadCheck1() {
void *P = aligned_alloc(4, 8);
g(P); // If g() checks its parameter for null, then false positive. If not, 
then true positive.
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72705



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


[PATCH] D73344: [clangd][Hover] Handle uninstantiated templates

2020-01-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 240559.
kadircet marked 3 inline comments as done.
kadircet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73344

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -554,6 +554,25 @@
 HI.Name = "Foo";
 HI.Kind = index::SymbolKind::Class;
   }},
+  {// Falls back to primary template, when the type is not instantiated.
+   R"cpp(
+  // comment from primary
+  template  class Foo {};
+  // comment from specialization
+  template  class Foo {};
+  void foo() {
+[[Fo^o]] *x = nullptr;
+  }
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "Foo";
+ HI.Kind = index::SymbolKind::Class;
+ HI.NamespaceScope = "";
+ HI.Definition = "template <> class Foo";
+ // FIXME: Maybe force instantiation to make use of real template
+ // pattern.
+ HI.Documentation = "comment from primary";
+   }},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -26,6 +26,7 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/AST/Type.h"
+#include "clang/Basic/Specifiers.h"
 #include "clang/Index/IndexSymbol.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
@@ -205,15 +206,23 @@
 // Returns the decl that should be used for querying comments, either from 
index
 // or AST.
 const NamedDecl *getDeclForComment(const NamedDecl *D) {
-  if (auto *CTSD = llvm::dyn_cast(D))
-if (!CTSD->isExplicitInstantiationOrSpecialization())
-  return CTSD->getTemplateInstantiationPattern();
-  if (auto *VTSD = llvm::dyn_cast(D))
-if (!VTSD->isExplicitInstantiationOrSpecialization())
-  return VTSD->getTemplateInstantiationPattern();
-  if (auto *FD = D->getAsFunction())
-if (FD->isTemplateInstantiation())
-  return FD->getTemplateInstantiationPattern();
+  if (const auto *TSD = llvm::dyn_cast(D)) {
+// Template may not be instantiated e.g. if the type didn't need to be
+// complete; fallback to primary template.
+if (TSD->getTemplateSpecializationKind() == TSK_Undeclared)
+  return TSD->getSpecializedTemplate();
+if (const auto *TIP = TSD->getTemplateInstantiationPattern())
+  return TIP;
+  }
+  if (const auto *TSD = llvm::dyn_cast(D)) {
+if (TSD->getTemplateSpecializationKind() == TSK_Undeclared)
+  return TSD->getSpecializedTemplate();
+if (const auto *TIP = TSD->getTemplateInstantiationPattern())
+  return TIP;
+  }
+  if (const auto *FD = D->getAsFunction())
+if (const auto *TIP = FD->getTemplateInstantiationPattern())
+  return TIP;
   return D;
 }
 


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -554,6 +554,25 @@
 HI.Name = "Foo";
 HI.Kind = index::SymbolKind::Class;
   }},
+  {// Falls back to primary template, when the type is not instantiated.
+   R"cpp(
+  // comment from primary
+  template  class Foo {};
+  // comment from specialization
+  template  class Foo {};
+  void foo() {
+[[Fo^o]] *x = nullptr;
+  }
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "Foo";
+ HI.Kind = index::SymbolKind::Class;
+ HI.NamespaceScope = "";
+ HI.Definition = "template <> class Foo";
+ // FIXME: Maybe force instantiation to make use of real template
+ // pattern.
+ HI.Documentation = "comment from primary";
+   }},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -26,6 +26,7 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/AST/Type.h"
+#include "clang/Basic/Specifiers.h"
 #include "clang/Index/IndexSymbol.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
@@ -205,15 +206,23 @@
 // Returns the decl that should be used for querying comments, either from index
 // or AST.
 const NamedDecl *getDeclForComment(const NamedDecl 

[PATCH] D73300: [clang-tidy] Add library for clang-tidy main function

2020-01-27 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: clang-tools-extra/clang-tidy/tool/CMakeLists.txt:22
+  clangToolingCore
+  )
+

Normally we have a single cmake target per CMakeLists.txt. Maybe the library 
could be in clang-tidy/lib and clang-tidy/tool could use it? Then you wouldn't 
need the LLVM_OPTIONAL_SOURCES hack and it'd be all a bit nicer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73300



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


[PATCH] D73354: clang-format: insert trailing commas into containers.

2020-01-27 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

FYI maybe related D33029: [clang-format] add option for dangling parenthesis 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73354



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


[PATCH] D73369: [clangd] Simplify "preferred" vs "definition" logic a bit in XRefs AST code.

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



Comment at: clang-tools-extra/clangd/XRefs.cpp:257
 const NamedDecl *Def = getDefinition(D);
-const NamedDecl *Preferred = Def ? Def : D;
+if (const NamedDecl *C = llvm::dyn_cast(D->getCanonicalDecl()))
+  D = C;

Is it possible for this check to ever fail? I think it is safe to just perform 
a `llvm::cast` instead of `dyn_cast`.
also why not perform this before getting definition?



Comment at: clang-tools-extra/clangd/XRefs.cpp:278
 Result.back().PreferredDeclaration = *Loc;
-// Preferred is always a definition if possible, so this check works.
-if (Def == Preferred)
-  Result.back().Definition = *Loc;
+if (Def)
+  Result.back().Definition = makeLocation(

maybe inline `getDefinition` to here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73369



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


[PATCH] D73202: Make AST reading work better with LLVM_APPEND_VC_REV=NO

2020-01-27 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

rnk, could you maybe take a look?


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

https://reviews.llvm.org/D73202



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


[PATCH] D73098: [clang-tidy] readability-identifier-naming disregards parameters restrictions on main like functions

2020-01-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:340
+return false;
+  if (FDecl->getAccess() == AS_private || FDecl->getAccess() == AS_protected)
+return false;

njames93 wrote:
> aaron.ballman wrote:
> > I'd flip the logic to `!= AS_public` to be more clear that we only care 
> > about public members.
> What do you think about AS_none, its a weird case and shall i ignore it. I'm 
> guessing all functions not in a class are implicitly declared to be public.
Good catch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73098



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


[PATCH] D73369: [clangd] Simplify "preferred" vs "definition" logic a bit in XRefs AST code.

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

also please fix clang-tidy and format warnings


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73369



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


[PATCH] D73413: [clang-tidy] Add check to detect external definitions with no header declaration

2020-01-27 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/misc/MissingHeaderFileDeclarationCheck.cpp:75
+  continue;
+if (AnyHeader || File->NamePart.equals_lower(ThisFile->NamePart))
+  return; // Found a good candidate for matching decl

njames93 wrote:
> gribozavr2 wrote:
> > njames93 wrote:
> > > gribozavr2 wrote:
> > > > This heuristic should be a lot more complex. In practice people have 
> > > > more complex naming conventions (for example, in Clang, Sema.h 
> > > > corresponds to many files named SemaSomethingSomething.cpp).
> > > > 
> > > > I think there is a high chance that checking only a header with a 
> > > > matching name will satisfy too few projects to be worth implementing.
> > > > 
> > > > On the other hand, if you could use C++ or Clang modules to narrow down 
> > > > the list of headers where the declaration should appear, that would be 
> > > > a much stronger signal.
> > > That is the reason I added the CheckAnyHeader option. For small projects 
> > > the matching name would be usually be enough, but for big complex 
> > > projects there is no feasible check that would work. Falling back to 
> > > making sure every external definition has a declaration in at least one 
> > > header will always be a good warning
> > That's the thing -- due to the lack of consistency in projects and style 
> > guides for C++, I think most projects will have to turn on CheckAnyHeader. 
> > We get implementation complexity in ClangTidy, false positives in 
> > high-profile projects, force users to configure ClangTidy to work well for 
> > their projects (unless we set CheckAnyHeader=1 by default... which then 
> > nobody would flip back to zero), and little benefit for end users.
> Would you say the best way would be check if the source file name starts with 
> the header file name by default. Or is that very specific to Clang?
> 
> ```
> /// 
> #include "SomeHeader.h"
> ```
> This file would check for declarations in `SomeHeader.h`
> 
> Or maybe check if the header file name starts with the source file?
> 
> ```
> /// 
> #include "SomeHeaderImpl.h"
> ```
> This file would check for declarations in `SomeHeaderImpl.h`.
> Or even check both?
> Would you say the best way would be check if the source file name starts with 
> the header file name by default. Or is that very specific to Clang?

I don't think it is too specific, it should cover many projects I think.

> Or maybe check if the header file name starts with the source file?

Seems like an unusual case to me, but I'm willing to be convinced otherwise.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73413



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


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

2020-01-27 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

Could you please rebase the patch against current master?
The commit "4aea70ed3292 
: [FPEnv] 
Extended FPOptions with new attributes" changed layout of FPOptions, which 
affects your patch.


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] D73271: [clang][CodeComplete] Support for designated initializers

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

{icon times-circle color=red} Unit tests: fail. 62159 tests passed, 5 failed 
and 811 were skipped.

  failed: libc++.std/language_support/cmp/cmp_partialord/partialord.pass.cpp
  failed: libc++.std/language_support/cmp/cmp_strongeq/cmp.strongeq.pass.cpp
  failed: libc++.std/language_support/cmp/cmp_strongord/strongord.pass.cpp
  failed: libc++.std/language_support/cmp/cmp_weakeq/cmp.weakeq.pass.cpp
  failed: libc++.std/language_support/cmp/cmp_weakord/weakord.pass.cpp

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

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

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


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73271



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


[PATCH] D72703: Add a warning, flags and pragmas to limit the number of pre-processor tokens in a translation unit

2020-01-27 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

> FWIW, I'm not ecstatic about `max_tokens_here`, I thought `max_tokens_lexed` 
> had a nicer ring to it. /peanut.

I mainly like the clarity in the difference between _here and _total. With 
_lexed, I feel that would not be as clear.


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

https://reviews.llvm.org/D72703



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


[clang] 739b410 - Add a warning, flags and pragmas to limit the number of pre-processor tokens in a translation unit

2020-01-27 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-01-27T16:04:17+01:00
New Revision: 739b410f1ff51d507830774320c2db3a80d8610d

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

LOG: Add a warning, flags and pragmas to limit the number of pre-processor 
tokens in a translation unit

See
https://docs.google.com/document/d/1xMkTZMKx9llnMPgso0jrx3ankI4cv60xeZ0y4ksf4wc/preview
for background discussion.

This adds a warning, flags and pragmas to limit the number of
pre-processor tokens either at a certain point in a translation unit, or
overall.

The idea is that this would allow projects to limit the size of certain
widely included headers, or for translation units overall, as a way to
insert backstops for header bloat and prevent compile-time regressions.

Differential revision: https://reviews.llvm.org/D72703

Added: 
clang/test/Parser/max-tokens.cpp

Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Driver/Options.td
clang/include/clang/Lex/Preprocessor.h
clang/include/clang/Parse/Parser.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Lex/Preprocessor.cpp
clang/lib/Parse/ParsePragma.cpp
clang/lib/Parse/Parser.cpp
clang/test/Driver/autocomplete.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index a15fb908c537..d98ca36b22c7 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1149,3 +1149,32 @@ def CrossTU : DiagGroup<"ctu">;
 def CTADMaybeUnsupported : DiagGroup<"ctad-maybe-unsupported">;
 
 def FortifySource : DiagGroup<"fortify-source">;
+
+def MaxTokens : DiagGroup<"max-tokens"> {
+  code Documentation = [{
+The warning is issued if the number of pre-processor tokens exceeds
+the token limit, which can be set in three ways:
+
+1. As a limit at a specific point in a file, using the ``clang 
max_tokens_here``
+  pragma:
+
+   .. code-block: c++
+  #pragma clang max_tokens_here 1234
+
+2. As a per-translation unit limit, using the ``-fmax-tokens`` command-line
+   flag:
+
+   .. code-block: console
+  clang -c a.cpp -fmax-tokens 1234
+
+3. As a per-translation unit limit using the ``clang max_tokens_total`` pragma,
+   which works like and overrides the ``-fmax-tokens`` flag:
+
+   .. code-block: c++
+  #pragma clang max_file_tokens 1234
+
+These limits can be helpful in limiting code growth through included files.
+
+Setting a token limit of zero means no limit.
+}];
+}

diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 04b103e3087a..86613307ee27 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1046,6 +1046,8 @@ def warn_pragma_expected_section_label_or_name : Warning<
 def warn_pragma_expected_init_seg : Warning<
   "expected 'compiler', 'lib', 'user', or a string literal for the section 
name in '#pragma %0' - ignored">,
   InGroup;
+
+def err_pragma_expected_integer : Error<"expected an integer argument in 
'#pragma %0'">;
 def warn_pragma_expected_integer : Warning<
   "expected integer between %0 and %1 inclusive in '#pragma %2' - ignored">,
   InGroup;
@@ -1375,4 +1377,14 @@ def err_placeholder_expected_auto_or_decltype_auto : 
Error<
   "expected 'auto' or 'decltype(auto)' after concept name">;
 }
 
+def warn_max_tokens : Warning<
+  "the number of preprocessor source tokens (%0) exceeds this token limit 
(%1)">,
+  InGroup;
+
+def warn_max_tokens_total : Warning<
+  "the total number of preprocessor source tokens (%0) exceeds the token limit 
(%1)">,
+  InGroup;
+
+def note_max_tokens_total_override : Note<"total token limit set here">;
+
 } // end of Parser diagnostics

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 3319a3123976..f7fa0151d397 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -344,6 +344,8 @@ LANGOPT(PaddingOnUnsignedFixedPoint, 1, 0,
 
 LANGOPT(RegisterStaticDestructors, 1, 1, "Register C++ static destructors")
 
+COMPATIBLE_VALUE_LANGOPT(MaxTokens, 32, 0, "Max number of tokens per TU or 0")
+
 #undef LANGOPT
 #undef COMPATIBLE_LANGOPT
 #undef BENIGN_LANGOPT

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 80d774e64ee0..650da3ae6462 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -646,6 +646,9 @@ def emit_merged_ifs : Flag<["-"], "emit-merged-ifs">,
 def interf

[PATCH] D72703: Add a warning, flags and pragmas to limit the number of pre-processor tokens in a translation unit

2020-01-27 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG739b410f1ff5: Add a warning, flags and pragmas to limit the 
number of pre-processor tokens in… (authored by hans).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D72703?vs=239944&id=240568#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72703

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Parse/Parser.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/Driver/autocomplete.c
  clang/test/Parser/max-tokens.cpp

Index: clang/test/Parser/max-tokens.cpp
===
--- /dev/null
+++ clang/test/Parser/max-tokens.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS  -fmax-tokens 2
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS_OVERRIDE -fmax-tokens 9
+
+int x, y, z;
+
+#pragma clang max_tokens_here // expected-error  {{missing argument to '#pragma clang max_tokens_here'; expected integer}}
+#pragma clang max_tokens_here foo // expected-error  {{expected an integer argument in '#pragma clang max_tokens_here'}}
+#pragma clang max_tokens_here 123 456 // expected-warning{{extra tokens at end of '#pragma clang max_tokens_here' - ignored}}
+
+#pragma clang max_tokens_here 1 // expected-warning{{the number of preprocessor source tokens (7) exceeds this token limit (1)}}
+
+
+#pragma clang max_tokens_total // expected-error{{missing argument to '#pragma clang max_tokens_total'; expected integer}}
+#pragma clang max_tokens_total foo // expected-error{{expected an integer argument in '#pragma clang max_tokens_total'}}
+#pragma clang max_tokens_total 123 456 // expected-warning{{extra tokens at end of '#pragma clang max_tokens_total' - ignored}}
+
+#ifdef MAX_TOKENS_OVERRIDE
+#pragma clang max_tokens_total 3 // expected-warning@+4{{the total number of preprocessor source tokens (8) exceeds the token limit (3)}}
+// expected-note@-1{{total token limit set here}}
+#elif MAX_TOKENS
+// expected-warning@+1{{the total number of preprocessor source tokens (8) exceeds the token limit (2)}}
+#endif
Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/test/Driver/autocomplete.c
@@ -99,6 +99,7 @@
 // WARNING-NEXT: -Wmain-return-type
 // WARNING-NEXT: -Wmalformed-warning-check
 // WARNING-NEXT: -Wmany-braces-around-scalar-init
+// WARNING-NEXT: -Wmax-tokens
 // WARNING-NEXT: -Wmax-unsigned-zero
 // RUN: %clang --autocomplete=-Wno-invalid-pp- | FileCheck %s -check-prefix=NOWARNING
 // NOWARNING: -Wno-invalid-pp-token
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -650,6 +650,16 @@
 return false;
 
   case tok::eof:
+// Check whether -fmax-tokens was reached.
+if (PP.getMaxTokens() != 0 && PP.getTokenCount() > PP.getMaxTokens()) {
+  PP.Diag(Tok.getLocation(), diag::warn_max_tokens_total)
+  << PP.getTokenCount() << PP.getMaxTokens();
+  SourceLocation OverrideLoc = PP.getMaxTokensOverrideLoc();
+  if (OverrideLoc.isValid()) {
+PP.Diag(OverrideLoc, diag::note_max_tokens_total_override);
+  }
+}
+
 // Late template parsing can begin.
 if (getLangOpts().DelayedTemplateParsing)
   Actions.SetLateTemplateParser(LateTemplateParserCallback,
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -262,6 +262,18 @@
   ParsedAttributes AttributesForPragmaAttribute;
 };
 
+struct PragmaMaxTokensHereHandler : public PragmaHandler {
+  PragmaMaxTokensHereHandler() : PragmaHandler("max_tokens_here") {}
+  void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
+Token &FirstToken) override;
+};
+
+struct PragmaMaxTokensTotalHandler : public PragmaHandler {
+  PragmaMaxTokensTotalHandler() : PragmaHandler("max_tokens_total") {}
+  void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
+Token &FirstToken) override;
+};
+
 }  // end namespace
 
 void Parser::initializePragmaHandlers() {
@@ -382,6 +394,12 @@
   AttributePragmaHandler =
   std::make_unique(AttrFactory);
   PP.AddPragmaHandler("clang", AttributePragmaHandler.get());
+
+  MaxTokensHe

[PATCH] D73464: [clang] Add TagDecl AST matcher

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

You should also regenerate the AST matcher documentation by running 
`clang\docs\tools\dump_ast_matchers.py`




Comment at: clang/lib/ASTMatchers/Dynamic/Registry.cpp:211-212
   REGISTER_MATCHER(elaboratedType);
+  REGISTER_MATCHER(tagDecl);
+  REGISTER_MATCHER(tagType);
   REGISTER_MATCHER(enumConstantDecl);

Please keep this list in alphabetical order.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73464



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


[PATCH] D73450: [clangd] Add a symbol-name-based blacklist for rename.

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



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:466
 
   auto DeclsUnderCursor = locateDeclAt(AST, IdentifierToken->location());
   if (DeclsUnderCursor.empty())

hokein wrote:
> kadircet wrote:
> > `locateDeclAt` is already working on `NamedDecl`s but returning a set of 
> > `Decl`s could you rather update that helper to return a set of `NamedDecl`s 
> > instead?
> I think the main problem is that `NamedDecl->getCanonicalDecl()` returns a 
> `Decl*`, which we need to do a `dyn_cast`.
ah right, but still it should be safe to perform just an `llvm:cast` here, as a 
`NamedDecl` shouldn't have an `unnamed` decl as its canonical declaration.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:148
+  RenameDecl, RenameDecl.getASTContext(), SymbolCollector::Options(),
+  IsMainFileOnly)) // If the symbol is not indexable, we disallow rename.
 return ReasonToReject::NonIndexable;

maybe move comment to be above if statement, and clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73450



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


[PATCH] D73439: [ASTMatchers] Add cxxNoexceptExpr AST matcher

2020-01-27 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 aside from some minor nits.




Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:1831
+/// \code
+///   void nothrow() noexcpet;
+///   void throws();

typo -- `noexcept`



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:1835
+///   bool b = noexcept(throws())
+/// \endcode
+/// cxxNoexceptExpr()

Can you also add this as an example:
```
void func() noexcept(noexcept(1 + 1));
```
to make it clear that this matches `noexcept(1 + 1)` but not 
`noexcept(noexcept(...))`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73439



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


[PATCH] D73367: [clangd] Go-to-definition on 'override' jumps to overridden method(s)

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

please fix clang-format and tidy warnings




Comment at: clang-tools-extra/clangd/XRefs.cpp:287
+// We may be overridding multiple methods - offer them all.
+for (const NamedDecl* ND : CMD->overridden_methods()) {
+  AddResultDecl(ND);

when do we have `OverrideAttribute` but no `overriden_methods` ? It looks like

```
struct Foo { virtual void foo(); };
struct Bar {
  void foo() override;
  void bar() override;
};
```

`Bar::bar` doesn't seem to have `OverrideAttr` set for example:
```
|-CXXMethodDecl 0x8e57e88  col:8 bar 'void ()'
|-CXXMethodDecl 0x8e57fa0  col:8 foo 'void ()'
| |-Overrides: [ 0x8e57668 Foo::foo 'void ()' ]
  | `-OverrideAttr 0x8e58040 
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73367



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


[clang] 02656f2 - clang-format: [JS] options for arrow functions.

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

Author: Martin Probst
Date: 2020-01-27T16:27:25+01:00
New Revision: 02656f29abda4eedd22e3b2b30bf2f422983514e

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

LOG: clang-format: [JS] options for arrow functions.

Summary:
clang-format currently always wraps the body of non-empty arrow
functions:

const x = () => {
  z();
};

This change implements support for the `AllowShortLambdasOnASingleLine`
style options, controlling the indent style for arrow function bodies
that have one or fewer statements. SLS_All puts all on a single line,
SLS_Inline only arrow functions used in an inline position.

const x = () => { z(); };

Multi-statement arrow functions continue to be wrapped. Function
expressions (`a = function() {}`) and function/method declarations are
unaffected as well.

Reviewers: krasimir

Subscribers: cfe-commits

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index a962e32f66b0..bc9551756bee 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -939,6 +939,8 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind 
Language) {
 GoogleStyle.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
 GoogleStyle.AlignOperands = false;
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
+// TODO: still under discussion whether to switch to SLS_All.
+GoogleStyle.AllowShortLambdasOnASingleLine = FormatStyle::SLS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
 // taze:, triple slash directives (`/// <...`), tslint:, and @see, which is

diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 723dc5c7ba88..8f9a29ab2f29 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3144,6 +3144,26 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine 
&Line,
   // JavaScript top-level enum key/value pairs are put on separate lines
   // instead of bin-packing.
   return true;
+if (Right.is(tok::r_brace) && Left.is(tok::l_brace) && Left.Previous &&
+Left.Previous->is(TT_JsFatArrow)) {
+  // JS arrow function (=> {...}).
+  switch (Style.AllowShortLambdasOnASingleLine) {
+  case FormatStyle::SLS_All:
+return false;
+  case FormatStyle::SLS_None:
+return true;
+  case FormatStyle::SLS_Empty:
+return !Left.Children.empty();
+  case FormatStyle::SLS_Inline:
+// allow one-lining inline (e.g. in function call args) and empty arrow
+// functions.
+return (Left.NestingLevel == 0 && Line.Level == 0) &&
+   !Left.Children.empty();
+  default:
+break;
+  }
+}
+
 if (Right.is(tok::r_brace) && Left.is(tok::l_brace) &&
 !Left.Children.empty())
   // Support AllowShortFunctionsOnASingleLine for JavaScript.

diff  --git a/clang/unittests/Format/FormatTestJS.cpp 
b/clang/unittests/Format/FormatTestJS.cpp
index ef3c6361355a..3c104b7aadbe 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -459,8 +459,9 @@ TEST_F(FormatTestJS, ContainerLiterals) {
   // Arrow functions in object literals.
   verifyFormat("var x = {\n"
"  y: (a) => {\n"
+   "x();\n"
"return a;\n"
-   "  }\n"
+   "  },\n"
"};");
   verifyFormat("var x = {y: (a) => a};");
 
@@ -486,7 +487,8 @@ TEST_F(FormatTestJS, ContainerLiterals) {
 
   // Object literals can leave out labels.
   verifyFormat("f({a}, () => {\n"
-   "  g();  //\n"
+   "  x;\n"
+   "  g();\n"
"});");
 
   // Keys can be quoted.
@@ -1112,8 +1114,9 @@ TEST_F(FormatTestJS, MultipleFunctionLiterals) {
 
 TEST_F(FormatTestJS, ArrowFunctions) {
   verifyFormat("var x = (a) => {\n"
+   "  x;\n"
"  return a;\n"
-   "};");
+   "};\n");
   verifyFormat("var x = (a) => {\n"
"  function y() {\n"
"return 42;\n"
@@ -1121,6 +1124,7 @@ TEST_F(FormatTestJS, ArrowFunctions) {
"  return a;\n"
"};");
   verifyFormat("var x = (a: type): {some: type} => {\n"
+   "  y;\n"
"  return a;\n"
"};");
   verifyFormat("var x = (a) => a;");
@@ -1147,10 +1151,41 @@ TEST_F(FormatTestJS, ArrowFunctions) {
"// break\n"
  

[PATCH] D73335: clang-format: [JS] options for arrow functions.

2020-01-27 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG02656f29abda: clang-format: [JS] options for arrow 
functions. (authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D73335?vs=240202&id=240575#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73335

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

Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -459,8 +459,9 @@
   // Arrow functions in object literals.
   verifyFormat("var x = {\n"
"  y: (a) => {\n"
+   "x();\n"
"return a;\n"
-   "  }\n"
+   "  },\n"
"};");
   verifyFormat("var x = {y: (a) => a};");
 
@@ -486,7 +487,8 @@
 
   // Object literals can leave out labels.
   verifyFormat("f({a}, () => {\n"
-   "  g();  //\n"
+   "  x;\n"
+   "  g();\n"
"});");
 
   // Keys can be quoted.
@@ -1112,8 +1114,9 @@
 
 TEST_F(FormatTestJS, ArrowFunctions) {
   verifyFormat("var x = (a) => {\n"
+   "  x;\n"
"  return a;\n"
-   "};");
+   "};\n");
   verifyFormat("var x = (a) => {\n"
"  function y() {\n"
"return 42;\n"
@@ -1121,6 +1124,7 @@
"  return a;\n"
"};");
   verifyFormat("var x = (a: type): {some: type} => {\n"
+   "  y;\n"
"  return a;\n"
"};");
   verifyFormat("var x = (a) => a;");
@@ -1147,10 +1151,41 @@
"// break\n"
");");
   verifyFormat("const f = (x: string|null): string|null => {\n"
+   "  y;\n"
"  return x;\n"
"}\n");
 }
 
+TEST_F(FormatTestJS, ArrowFunctionStyle) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript);
+  Style.AllowShortLambdasOnASingleLine = FormatStyle::SLS_All;
+  verifyFormat("const arr = () => { x; };", Style);
+  verifyFormat("const arrInlineAll = () => {};", Style);
+  Style.AllowShortLambdasOnASingleLine = FormatStyle::SLS_None;
+  verifyFormat("const arr = () => {\n"
+   "  x;\n"
+   "};",
+   Style);
+  verifyFormat("const arrInlineNone = () => {\n"
+   "};",
+   Style);
+  Style.AllowShortLambdasOnASingleLine = FormatStyle::SLS_Empty;
+  verifyFormat("const arr = () => {\n"
+   "  x;\n"
+   "};",
+   Style);
+  verifyFormat("const arrInlineEmpty = () => {};",
+   Style);
+  Style.AllowShortLambdasOnASingleLine = FormatStyle::SLS_Inline;
+  verifyFormat("const arr = () => {\n"
+   "  x;\n"
+   "};",
+   Style);
+  verifyFormat("foo(() => {});",
+   Style);
+  verifyFormat("const arrInlineInline = () => {};", Style);
+}
+
 TEST_F(FormatTestJS, ReturnStatements) {
   verifyFormat("function() {\n"
"  return [hello, world];\n"
@@ -1711,10 +1746,12 @@
 TEST_F(FormatTestJS, RemoveEmptyLinesInArrowFunctions) {
   verifyFormat("x = () => {\n"
"  foo();\n"
+   "  bar();\n"
"};\n",
"x = () => {\n"
"\n"
"  foo();\n"
+   "  bar();\n"
"\n"
"};\n");
 }
@@ -1791,6 +1828,10 @@
"];");
   verifyFormat("export default [];");
   verifyFormat("export default () => {};");
+  verifyFormat("export default () => {\n"
+   "  x;\n"
+   "  x;\n"
+   "};");
   verifyFormat("export interface Foo {\n"
"  foo: number;\n"
"}\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3144,6 +3144,26 @@
   // JavaScript top-level enum key/value pairs are put on separate lines
   // instead of bin-packing.
   return true;
+if (Right.is(tok::r_brace) && Left.is(tok::l_brace) && Left.Previous &&
+Left.Previous->is(TT_JsFatArrow)) {
+  // JS arrow function (=> {...}).
+  switch (Style.AllowShortLambdasOnASingleLine) {
+  case FormatStyle::SLS_All:
+return false;
+  case FormatStyle::SLS_None:
+return true;
+  case FormatStyle::SLS_Empty:
+return !Left.Children.empty();
+  case FormatStyle::SLS_Inline:
+// allow one-lining inline (e.g. in function call args) and empty arrow
+// functions.
+return (Left.NestingLevel == 0 && Line.Level == 0) &&
+   !Left.Children.empty

[PATCH] D73344: [clangd][Hover] Handle uninstantiated templates

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

{icon times-circle color=red} Unit tests: fail. 62158 tests passed, 5 failed 
and 811 were skipped.

  failed: libc++.std/language_support/cmp/cmp_partialord/partialord.pass.cpp
  failed: libc++.std/language_support/cmp/cmp_strongeq/cmp.strongeq.pass.cpp
  failed: libc++.std/language_support/cmp/cmp_strongord/strongord.pass.cpp
  failed: libc++.std/language_support/cmp/cmp_weakeq/cmp.weakeq.pass.cpp
  failed: libc++.std/language_support/cmp/cmp_weakord/weakord.pass.cpp

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

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

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


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73344



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


[PATCH] D72553: [clang-tidy] Add performance-prefer-preincrement check

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



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/performance-prefer-pre-increment-disable-cpp-opcalls.cpp:44
+};
+
+void foo() {

njames93 wrote:
> JonasToth wrote:
> > Test-cases that I would like to see:
> > 
> > - only the post-fix operator is overloaded for the class --> best-case this 
> > is detected and a fix is not provided
> > - iterator-inheritance: the base-class provides the operator-overloads --> 
> > does matching work? There might be an implicit cast for example
> > - the iterator-type is type-dependent --> maybe fixing should not be done 
> > or even the warning should not be emitted, because there might be only a 
> > post-fix available in some instantiations (see point 1). I do mean 
> > something like this `template  void f() { T::iterator it; it++; 
> > }`
> There are test cases for only post fix operator overloading. basically it 
> doesn't warn or provided a fix it as that isn't valid. I feel like there 
> could be a seperate check that detects classes that overload operator++(int) 
> but not operator++() but thats not what this check is for.
> I'll take a look at the other cases tomorrow
Currently the base class provided operator overloads match normally.

For template dependent code it gets a little hazy. Basically if the type isn't 
known the operator will always appear as a `UnaryOperator`, maybe its safest to 
proceed by disabling fixes if the type isn't known, and maybe add an option to 
override that behaviour, WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72553



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


[PATCH] D73300: [clang-tidy] Add library for clang-tidy main function

2020-01-27 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin marked an inline comment as done.
DmitryPolukhin added inline comments.



Comment at: clang-tools-extra/clang-tidy/tool/CMakeLists.txt:22
+  clangToolingCore
+  )
+

thakis wrote:
> Normally we have a single cmake target per CMakeLists.txt. Maybe the library 
> could be in clang-tidy/lib and clang-tidy/tool could use it? Then you 
> wouldn't need the LLVM_OPTIONAL_SOURCES hack and it'd be all a bit nicer.
I'll prepare patch with files move if you think it worths doing. I see multiple 
targets in several CMakeLists.txt:
```
llvm-project> grep LLVM_OPTIONAL_SOURCES ./ -r
./clang-tools-extra/clang-tidy/tool/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES 
ClangTidyMain.cpp ClangTidyToolMain.cpp)
./clang-tools-extra/clangd/xpc/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES 
Conversion.cpp XPCTransport.cpp)
./clang/tools/clang-fuzzer/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES
./clang/tools/clang-fuzzer/CMakeLists.txt:  set(LLVM_OPTIONAL_SOURCES 
${LLVM_OPTIONAL_SOURCES} ${PROTO_SRCS})
./clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES
 proto_to_cxx.cpp proto_to_cxx_main.cpp
./clang/tools/clang-fuzzer/proto-to-llvm/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES
 loop_proto_to_llvm.cpp loop_proto_to_llvm_main.cpp)
./lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt:  list(APPEND 
LLVM_OPTIONAL_SOURCES
./lldb/source/Symbol/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES 
LocateSymbolFileMacOSX.cpp)
./lldb/tools/debugserver/source/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES 
${lldbDebugserverCommonSources})
./llvm/cmake/modules/AddLLVM.cmake:set(LLVM_OPTIONAL_SOURCES 
${ARG_DUMMY_MAIN})
./llvm/cmake/modules/AddLLVM.cmake:set(LLVM_OPTIONAL_SOURCES 
${ARG_DUMMY_MAIN})
./llvm/cmake/modules/LLVMProcessSources.cmake:  list(FIND 
LLVM_OPTIONAL_SOURCES ${entry} idx)
./llvm/unittests/Passes/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES 
PluginsTest.cpp TestPlugin.cpp)
./llvm/unittests/Support/DynamicLibrary/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES
 ExportedFuncs.cpp PipSqueak.cpp)
./mlir/lib/EDSC/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES
./mlir/lib/Support/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES
./mlir/test/lib/TestDialect/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES
./mlir/test/mlir-cpu-runner/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES
./mlir/tools/mlir-cuda-runner/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES
./mlir/tools/mlir-opt/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73300



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


[PATCH] D72553: [clang-tidy] Add performance-prefer-preincrement check

2020-01-27 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 240584.
njames93 marked an inline comment as done.
njames93 added a comment.

- Added test case when the inc and dec operators are found in a base class


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72553

Files:
  clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
  clang-tools-extra/clang-tidy/performance/CMakeLists.txt
  clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
  clang-tools-extra/clang-tidy/performance/PreferPreIncrementCheck.cpp
  clang-tools-extra/clang-tidy/performance/PreferPreIncrementCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/llvm-prefer-pre-increment.rst
  clang-tools-extra/docs/clang-tidy/checks/performance-prefer-pre-increment.rst
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/performance-prefer-pre-increment/iterator.h
  
clang-tools-extra/test/clang-tidy/checkers/performance-prefer-pre-increment-disable-cpp-opcalls.cpp
  clang-tools-extra/test/clang-tidy/checkers/performance-prefer-pre-increment.c
  
clang-tools-extra/test/clang-tidy/checkers/performance-prefer-pre-increment.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/performance-prefer-pre-increment.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/performance-prefer-pre-increment.cpp
@@ -0,0 +1,55 @@
+// RUN: %check_clang_tidy %s performance-prefer-pre-increment %t -- -- \
+// RUN: -I%S/Inputs/performance-prefer-pre-increment
+
+#include "iterator.h"
+
+class IntIterator : public Iterator{
+  using Iterator::Iterator;
+};
+
+void foo() {
+  int Array[32];
+  Iterator It(&Array[0]);
+  It++; // fooNormal
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Use pre-increment instead of post-increment
+  // CHECK-FIXES: {{^}}  ++It; // fooNormal
+  It--; // fooNormal
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Use pre-decrement instead of post-decrement
+  // CHECK-FIXES: {{^}}  --It; // fooNormal
+  (*It)++; // fooNormal
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Use pre-increment instead of post-increment
+  // CHECK-FIXES: {{^}}  ++(*It); // fooNormal
+  (*It)--; // fooNormal
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Use pre-decrement instead of post-decrement
+  // CHECK-FIXES: {{^}}  --(*It); // fooNormal
+  *It++; // fooNormal
+  *It--; // fooNormal
+
+  PostfixIterator PfIt(&Array[0]);
+  PfIt++; // fooPostfix
+  PfIt--; // fooPostfix
+  (*PfIt)++; // fooPostfix
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Use pre-increment instead of post-increment
+  // CHECK-FIXES: {{^}}  ++(*PfIt); // fooPostfix
+  (*PfIt)--; // fooPostfix
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Use pre-decrement instead of post-decrement
+  // CHECK-FIXES: {{^}}  --(*PfIt); // fooPostfix
+  *PfIt++; // fooPostfix
+  *PfIt--; // fooPostfix
+
+  IntIterator IntIt(&Array[0]);
+  IntIt++;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Use pre-increment instead of post-increment
+  // CHECK-FIXES: {{^}}  ++IntIt;
+  IntIt--;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Use pre-decrement instead of post-decrement
+  // CHECK-FIXES: {{^}}  --IntIt;
+  (*IntIt)++;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Use pre-increment instead of post-increment
+  // CHECK-FIXES: {{^}}  ++(*IntIt);
+  (*IntIt)--;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Use pre-decrement instead of post-decrement
+  // CHECK-FIXES: {{^}}  --(*IntIt);
+  *IntIt++;
+  *IntIt--;
+}
Index: clang-tools-extra/test/clang-tidy/checkers/performance-prefer-pre-increment.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/performance-prefer-pre-increment.c
@@ -0,0 +1,128 @@
+// RUN: %check_clang_tidy %s performance-prefer-pre-increment %t
+
+#define INC(X) X++
+#define DEC(X) X--
+
+void foo(int A) {
+  for (int I = 0; I < 10; I++) {
+// CHECK-MESSAGES: [[@LINE-1]]:27: warning: Use pre-increment instead of post-increment
+// CHECK-FIXES: {{^}}  for (int I = 0; I < 10; ++I) {
+  }
+  for (int I = 0; I < 10; ++I) {
+// CHECK-MESSAGES-NOT: [[@LINE-1]]:{{\d*}}: warning: Use pre-increment instead of post-increment
+  }
+  for (int I = 0; I < 10; A = I++) {
+// CHECK-MESSAGES-NOT: [[@LINE-1]]:{{\d*}}: warning: Use pre-increment instead of post-increment
+  }
+
+  for (int I = 10; I < 0; I--) {
+// CHECK-MESSAGES: [[@LINE-1]]:27: warning: Use pre-decrement instead of post-decrement
+// CHECK-FIXES: {{^}}  for (int I = 10; I < 0; --I) {
+  }
+  for (int I = 10; I < 0; --I) {
+// CHECK-MESSAGES-NOT: [[@LINE-1]]:{{\d*}}: warning: Use pre-decrement instead of post-decrement
+  }
+  for (int I = 10; I < 0; A = I--) {
+// CHECK-MESSAGES-NOT: [[@LINE-1]]:{{\d*}}: warning: Use pre-decrement instead of post-decrement
+  }
+
+  for (int I = 0; I < 10; I

[PATCH] D73457: [Clang] Warn about 'z' printf modifier in old MSVC.

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



Comment at: clang/lib/AST/FormatString.cpp:754
+  LO.isMSCompatibilityVersionSpecified() &&
+  !LO.isCompatibleWithMSVC(LangOptions::MSVC2015)) {
+// The standard libraries before MSVC2015 didn't support the 'z' length

I'd rather not see `isMSCompatibilityVersionSpecified()` be introduced, but 
instead make `isCompatibleWithMSVC()` do the right thing when it's not 
specified.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73457



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


[clang] 2f63d54 - Restore "[LTO/WPD] Enable aggressive WPD under LTO option"

2020-01-27 Thread Teresa Johnson via cfe-commits

Author: Teresa Johnson
Date: 2020-01-27T07:55:05-08:00
New Revision: 2f63d549f1e1edd165392837aaa53f569f7fb88d

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

LOG: Restore "[LTO/WPD] Enable aggressive WPD under LTO option"

This restores 59733525d37cf9ad88b5021b33ecdbaf2e18911c (D71913), along
with bot fix 19c76989bb505c3117730c47df85fd3800ea2767.

The bot failure should be fixed by D73418, committed as
af954e441a5170a75687699d91d85e0692929d43.

I also added a fix for non-x86 bot failures by requiring x86 in new test
lld/test/ELF/lto/devirt_vcall_vis_public.ll.

Added: 
clang/test/CodeGenCXX/thinlto-distributed-type-metadata.cpp
lld/test/ELF/lto/devirt_vcall_vis_public.ll
llvm/test/ThinLTO/X86/devirt_vcall_vis_hidden.ll
llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll
llvm/test/tools/gold/X86/devirt_vcall_vis_public.ll

Modified: 
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/CodeGen/CGClass.cpp
clang/lib/CodeGen/CGVTables.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
clang/test/CodeGenCXX/cfi-mfcall.cpp
clang/test/CodeGenCXX/lto-visibility-inference.cpp
clang/test/CodeGenCXX/type-metadata.cpp
lld/ELF/Config.h
lld/ELF/Driver.cpp
lld/ELF/LTO.cpp
lld/ELF/Options.td
llvm/include/llvm/LTO/Config.h
llvm/include/llvm/Transforms/IPO.h
llvm/include/llvm/Transforms/IPO/LowerTypeTests.h
llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h
llvm/lib/LTO/LTO.cpp
llvm/lib/LTO/LTOCodeGenerator.cpp
llvm/lib/LTO/ThinLTOCodeGenerator.cpp
llvm/lib/Transforms/IPO/LowerTypeTests.cpp
llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
llvm/test/ThinLTO/X86/cache-typeid-resolutions.ll
llvm/test/ThinLTO/X86/cfi-devirt.ll
llvm/test/ThinLTO/X86/devirt-after-icp.ll
llvm/test/ThinLTO/X86/devirt.ll
llvm/test/ThinLTO/X86/devirt2.ll
llvm/test/ThinLTO/X86/devirt_alias.ll
llvm/test/ThinLTO/X86/devirt_available_externally.ll
llvm/test/ThinLTO/X86/devirt_external_comdat_same_guid.ll
llvm/test/ThinLTO/X86/devirt_promote.ll
llvm/test/ThinLTO/X86/devirt_promote_legacy.ll
llvm/test/ThinLTO/X86/devirt_single_hybrid.ll
llvm/test/Transforms/WholeProgramDevirt/bad-read-from-vtable.ll
llvm/test/Transforms/WholeProgramDevirt/branch-funnel-threshold.ll
llvm/test/Transforms/WholeProgramDevirt/branch-funnel.ll
llvm/test/Transforms/WholeProgramDevirt/constant-arg.ll
llvm/test/Transforms/WholeProgramDevirt/devirt-single-impl-check.ll
llvm/test/Transforms/WholeProgramDevirt/devirt-single-impl.ll
llvm/test/Transforms/WholeProgramDevirt/devirt-single-impl2.ll
llvm/test/Transforms/WholeProgramDevirt/expand-check.ll
llvm/test/Transforms/WholeProgramDevirt/export-nothing.ll
llvm/test/Transforms/WholeProgramDevirt/export-single-impl.ll
llvm/test/Transforms/WholeProgramDevirt/export-uniform-ret-val.ll
llvm/test/Transforms/WholeProgramDevirt/export-unique-ret-val.ll
llvm/test/Transforms/WholeProgramDevirt/export-unsuccessful-checked.ll
llvm/test/Transforms/WholeProgramDevirt/export-vcp.ll
llvm/test/Transforms/WholeProgramDevirt/non-constant-vtable.ll
llvm/test/Transforms/WholeProgramDevirt/pointer-vtable.ll
llvm/test/Transforms/WholeProgramDevirt/soa-vtable.ll
llvm/test/Transforms/WholeProgramDevirt/struct-vtable.ll
llvm/test/Transforms/WholeProgramDevirt/uniform-retval-invoke.ll
llvm/test/Transforms/WholeProgramDevirt/uniform-retval.ll
llvm/test/Transforms/WholeProgramDevirt/unique-retval.ll
llvm/test/Transforms/WholeProgramDevirt/vcp-accesses-memory.ll
llvm/test/Transforms/WholeProgramDevirt/vcp-decl.ll
llvm/test/Transforms/WholeProgramDevirt/vcp-no-this.ll
llvm/test/Transforms/WholeProgramDevirt/vcp-non-constant-arg.ll
llvm/test/Transforms/WholeProgramDevirt/vcp-too-wide-ints.ll
llvm/test/Transforms/WholeProgramDevirt/vcp-type-mismatch.ll
llvm/test/Transforms/WholeProgramDevirt/vcp-uses-this.ll
llvm/test/Transforms/WholeProgramDevirt/virtual-const-prop-begin.ll
llvm/test/Transforms/WholeProgramDevirt/virtual-const-prop-check.ll
llvm/test/Transforms/WholeProgramDevirt/virtual-const-prop-end.ll
llvm/test/Transforms/WholeProgramDevirt/vtable-decl.ll
llvm/tools/gold/gold-plugin.cpp
llvm/tools/opt/opt.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index f379c103b694..6eff6bd7b7c2 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -51,6 +51,7 @@
 #include "llvm/Transforms/Coroutines.h"
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Transforms/IPO/AlwaysInliner.h"
+#include "llvm/Transforms/IP

[clang-tools-extra] 60249c2 - [clangd] Only re-open files if their flags changed

2020-01-27 Thread David Goldman via cfe-commits

Author: David Goldman
Date: 2020-01-27T10:58:20-05:00
New Revision: 60249c2c3b9e268af6ade0a4be3c883d7d567940

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

LOG: [clangd] Only re-open files if their flags changed

Reviewers: sammccall

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdLSPServer.h
clang-tools-extra/clangd/test/did-change-configuration-params.test

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 0f87a81227a9..982e05f68fdd 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -1126,10 +1126,8 @@ void ClangdLSPServer::onResolveTypeHierarchy(
 void ClangdLSPServer::applyConfiguration(
 const ConfigurationSettings &Settings) {
   // Per-file update to the compilation database.
-  bool ShouldReparseOpenFiles = false;
+  llvm::StringSet<> ModifiedFiles;
   for (auto &Entry : Settings.compilationDatabaseChanges) {
-/// The opened files need to be reparsed only when some existing
-/// entries are changed.
 PathRef File = Entry.first;
 auto Old = CDB->getCompileCommand(File);
 auto New =
@@ -1138,11 +1136,11 @@ void ClangdLSPServer::applyConfiguration(
 /*Output=*/"");
 if (Old != New) {
   CDB->setCompileCommand(File, std::move(New));
-  ShouldReparseOpenFiles = true;
+  ModifiedFiles.insert(File);
 }
   }
-  if (ShouldReparseOpenFiles)
-reparseOpenedFiles();
+
+  reparseOpenedFiles(ModifiedFiles);
 }
 
 void ClangdLSPServer::publishSemanticHighlighting(
@@ -1463,10 +1461,15 @@ void ClangdLSPServer::onFileUpdated(PathRef File, const 
TUStatus &Status) {
   notify("textDocument/clangd.fileStatus", Status.render(File));
 }
 
-void ClangdLSPServer::reparseOpenedFiles() {
+void ClangdLSPServer::reparseOpenedFiles(
+const llvm::StringSet<> &ModifiedFiles) {
+  if (ModifiedFiles.empty())
+return;
+  // Reparse only opened files that were modified.
   for (const Path &FilePath : DraftMgr.getActiveFiles())
-Server->addDocument(FilePath, *DraftMgr.getDraft(FilePath),
-WantDiagnostics::Auto);
+if (ModifiedFiles.find(FilePath) != ModifiedFiles.end())
+  Server->addDocument(FilePath, *DraftMgr.getDraft(FilePath),
+  WantDiagnostics::Auto);
 }
 
 } // namespace clangd

diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.h 
b/clang-tools-extra/clangd/ClangdLSPServer.h
index c436f7114610..a186d05f08f9 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.h
+++ b/clang-tools-extra/clangd/ClangdLSPServer.h
@@ -20,6 +20,7 @@
 #include "Transport.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringSet.h"
 #include 
 
 namespace clang {
@@ -123,10 +124,10 @@ class ClangdLSPServer : private ClangdServer::Callbacks {
   /// produce '->' and '::', respectively.
   bool shouldRunCompletion(const CompletionParams &Params) const;
 
-  /// Forces a reparse of all currently opened files.  As a result, this method
-  /// may be very expensive.  This method is normally called when the
-  /// compilation database is changed.
-  void reparseOpenedFiles();
+  /// Forces a reparse of all currently opened files which were modified. As a
+  /// result, this method may be very expensive. This method is normally called
+  /// when the compilation database is changed.
+  void reparseOpenedFiles(const llvm::StringSet<> &ModifiedFiles);
   void applyConfiguration(const ConfigurationSettings &Settings);
 
   /// Sends a "publishSemanticHighlighting" notification to the LSP client.

diff  --git 
a/clang-tools-extra/clangd/test/did-change-configuration-params.test 
b/clang-tools-extra/clangd/test/did-change-configuration-params.test
index bd8ffafcd592..6f9b537e5414 100644
--- a/clang-tools-extra/clangd/test/did-change-configuration-params.test
+++ b/clang-tools-extra/clangd/test/did-change-configuration-params.test
@@ -46,8 +46,6 @@
 # ERR: Updating file {{.*}}foo.c with command
 # ERR: [{{.*}}clangd-test2]
 # ERR: clang -c foo.c -Wall -Werror
-# Don't reparse the second file:
-# ERR: Skipping rebuild of the AST for {{.*}}bar.c
 ---
 {"jsonrpc":"2.0","id":5,"method":"shutdown"}
 ---



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


[PATCH] D72553: [clang-tidy] Add performance-prefer-preincrement check

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

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

{icon times-circle color=red} clang-tidy: fail. clang-tidy found 0 errors and 1 
warnings 
.
 0 of them are added as review comments below (why? 
).

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

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


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72553



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


[PATCH] D72647: [clangd] Only re-open files if their flags changed

2020-01-27 Thread David Goldman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG60249c2c3b9e: [clangd] Only re-open files if their flags 
changed (authored by dgoldman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72647

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/test/did-change-configuration-params.test


Index: clang-tools-extra/clangd/test/did-change-configuration-params.test
===
--- clang-tools-extra/clangd/test/did-change-configuration-params.test
+++ clang-tools-extra/clangd/test/did-change-configuration-params.test
@@ -46,8 +46,6 @@
 # ERR: Updating file {{.*}}foo.c with command
 # ERR: [{{.*}}clangd-test2]
 # ERR: clang -c foo.c -Wall -Werror
-# Don't reparse the second file:
-# ERR: Skipping rebuild of the AST for {{.*}}bar.c
 ---
 {"jsonrpc":"2.0","id":5,"method":"shutdown"}
 ---
Index: clang-tools-extra/clangd/ClangdLSPServer.h
===
--- clang-tools-extra/clangd/ClangdLSPServer.h
+++ clang-tools-extra/clangd/ClangdLSPServer.h
@@ -20,6 +20,7 @@
 #include "Transport.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringSet.h"
 #include 
 
 namespace clang {
@@ -123,10 +124,10 @@
   /// produce '->' and '::', respectively.
   bool shouldRunCompletion(const CompletionParams &Params) const;
 
-  /// Forces a reparse of all currently opened files.  As a result, this method
-  /// may be very expensive.  This method is normally called when the
-  /// compilation database is changed.
-  void reparseOpenedFiles();
+  /// Forces a reparse of all currently opened files which were modified. As a
+  /// result, this method may be very expensive. This method is normally called
+  /// when the compilation database is changed.
+  void reparseOpenedFiles(const llvm::StringSet<> &ModifiedFiles);
   void applyConfiguration(const ConfigurationSettings &Settings);
 
   /// Sends a "publishSemanticHighlighting" notification to the LSP client.
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -1126,10 +1126,8 @@
 void ClangdLSPServer::applyConfiguration(
 const ConfigurationSettings &Settings) {
   // Per-file update to the compilation database.
-  bool ShouldReparseOpenFiles = false;
+  llvm::StringSet<> ModifiedFiles;
   for (auto &Entry : Settings.compilationDatabaseChanges) {
-/// The opened files need to be reparsed only when some existing
-/// entries are changed.
 PathRef File = Entry.first;
 auto Old = CDB->getCompileCommand(File);
 auto New =
@@ -1138,11 +1136,11 @@
 /*Output=*/"");
 if (Old != New) {
   CDB->setCompileCommand(File, std::move(New));
-  ShouldReparseOpenFiles = true;
+  ModifiedFiles.insert(File);
 }
   }
-  if (ShouldReparseOpenFiles)
-reparseOpenedFiles();
+
+  reparseOpenedFiles(ModifiedFiles);
 }
 
 void ClangdLSPServer::publishSemanticHighlighting(
@@ -1463,10 +1461,15 @@
   notify("textDocument/clangd.fileStatus", Status.render(File));
 }
 
-void ClangdLSPServer::reparseOpenedFiles() {
+void ClangdLSPServer::reparseOpenedFiles(
+const llvm::StringSet<> &ModifiedFiles) {
+  if (ModifiedFiles.empty())
+return;
+  // Reparse only opened files that were modified.
   for (const Path &FilePath : DraftMgr.getActiveFiles())
-Server->addDocument(FilePath, *DraftMgr.getDraft(FilePath),
-WantDiagnostics::Auto);
+if (ModifiedFiles.find(FilePath) != ModifiedFiles.end())
+  Server->addDocument(FilePath, *DraftMgr.getDraft(FilePath),
+  WantDiagnostics::Auto);
 }
 
 } // namespace clangd


Index: clang-tools-extra/clangd/test/did-change-configuration-params.test
===
--- clang-tools-extra/clangd/test/did-change-configuration-params.test
+++ clang-tools-extra/clangd/test/did-change-configuration-params.test
@@ -46,8 +46,6 @@
 # ERR: Updating file {{.*}}foo.c with command
 # ERR: [{{.*}}clangd-test2]
 # ERR: clang -c foo.c -Wall -Werror
-# Don't reparse the second file:
-# ERR: Skipping rebuild of the AST for {{.*}}bar.c
 ---
 {"jsonrpc":"2.0","id":5,"method":"shutdown"}
 ---
Index: clang-tools-extra/clangd/ClangdLSPServer.h
===
--- clang-tools-extra/clangd/ClangdLSPServer.h
+++ clang-tools-extra/clangd/ClangdLSPServer.h
@@ -20,6 +20,7 @@
 #include "Transport.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringSet.h"
 #include 
 
 namespace clang {
@@ -123,10

Getting started

2020-01-27 Thread Anshil Gandhi via cfe-commits
Hi everyone,

My name is Anshil Gandhi and I am currently in my third year of BSc double
majoring in Computing Science and Mathematics. I am interested in
developing the clang frontend, C++ 1x features implementation in
particular. I have cloned the git repository of llvm and explored through
various features of clang, however I am not sure how to familarize myself
with the project organization. I will appreciate any pointers on how to get
started. Thanks in advance!

Kind regards,

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


[PATCH] D71920: [AST] Refactor propagation of dependency bits. NFC

2020-01-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 240604.
ilya-biryukov added a comment.

- Use DependencyFlags for TemplateName and NestedNameSpecifier


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71920

Files:
  clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
  clang/include/clang/AST/DependencyFlags.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/NestedNameSpecifier.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/AST/TemplateName.h
  clang/include/clang/AST/Type.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/ExprObjC.cpp
  clang/lib/AST/NestedNameSpecifier.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TemplateName.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp

Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -511,10 +511,23 @@
 void ASTStmtReader::VisitExpr(Expr *E) {
   VisitStmt(E);
   E->setType(Record.readType());
-  E->setTypeDependent(Record.readInt());
-  E->setValueDependent(Record.readInt());
-  E->setInstantiationDependent(Record.readInt());
-  E->ExprBits.ContainsUnexpandedParameterPack = Record.readInt();
+
+  // FIXME: write and read all DependentFlags with a single call.
+  bool TypeDependent = Record.readInt();
+  bool ValueDependent = Record.readInt();
+  bool InstantiationDependent = Record.readInt();
+  bool ContainsUnexpandedTemplateParameters = Record.readInt();
+  DependencyFlags Deps = DependencyFlags::None;
+  if (TypeDependent)
+Deps |= DependencyFlags::Type;
+  if (ValueDependent)
+Deps |= DependencyFlags::Value;
+  if (InstantiationDependent)
+Deps |= DependencyFlags::Instantiation;
+  if (ContainsUnexpandedTemplateParameters)
+Deps |= DependencyFlags::UnexpandedPack;
+  E->setDependencies(Deps);
+
   E->setValueKind(static_cast(Record.readInt()));
   E->setObjectKind(static_cast(Record.readInt()));
   assert(Record.getIdx() == NumExprFields &&
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -12694,9 +12694,7 @@
   // base classes.
   CallExpr *CE = CallExpr::Create(Context, Fn, Args, Context.DependentTy,
   VK_RValue, RParenLoc);
-  CE->setTypeDependent(true);
-  CE->setValueDependent(true);
-  CE->setInstantiationDependent(true);
+  CE->addDependencies(DependencyFlags::TypeValueInstantiation);
   *Result = CE;
   return true;
 }
Index: clang/lib/AST/TemplateName.cpp
===
--- clang/lib/AST/TemplateName.cpp
+++ clang/lib/AST/TemplateName.cpp
@@ -13,6 +13,7 @@
 #include "clang/AST/TemplateName.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/AST/DependencyFlags.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/AST/TemplateBase.h"
@@ -168,52 +169,50 @@
   return TemplateName(Decl);
 }
 
-bool TemplateName::isDependent() const {
+DependencyFlags TemplateName::getDependencies() const {
+  DependencyFlags F = DependencyFlags::None;
+  if (QualifiedTemplateName *QTN = getAsQualifiedTemplateName()) {
+F |= turnNestedNameSpecifierToNameDependencies(
+QTN->getQualifier()->getDependencies());
+  } else if (DependentTemplateName *DTN = getAsDependentTemplateName()) {
+if (DTN->getQualifier())
+  F |= turnNestedNameSpecifierToNameDependencies(
+  DTN->getQualifier()->getDependencies());
+  }
+
   if (TemplateDecl *Template = getAsTemplateDecl()) {
-if (isa(Template))
-  return true;
+if (auto *TTP = dyn_cast(Template)) {
+  F |= DependencyFlags::TypeValueInstantiation;
+  if (TTP->isParameterPack())
+F |= DependencyFlags::UnexpandedPack;
+}
 // FIXME: Hack, getDeclContext() can be null if Template is still
 // initializing due to PCH reading, so we check it before using it.
 // Should probably modify TemplateSpecializationType to allow constructing
 // it without the isDependent() checking.
-return Template->getDeclContext() &&
-   Template->getDeclContext()->isDependentContext();
+if (Template->getDeclContext() &&
+Template->getDeclContext()->isDependentContext())
+  F |= DependencyFlags::TypeValueInstantiation;
+  } else {
+assert(!getAsOverloadedTemplate() &&
+   "overloaded templates shouldn't survive to here");
+F |= DependencyFlags::TypeValueInstantiation;
   }
+  if (getAsSubstTemplateTemplateParmPack() != nullptr)
+F |= DependencyFlags::UnexpandedPack;
+  return F;
+}
 
-  as

[PATCH] D73354: clang-format: insert trailing commas into containers.

2020-01-27 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: clang/lib/Format/Format.cpp:1482
+/// ];
+class TrailingCommaInserter : public TokenAnalyzer {
+public:

sammccall wrote:
> Worth a comment (somewhere) about the fact that this never rewraps, in 
> particular if the line is long, for simplicity.
> 
> Another policy that occurred to me: don't insert the comma if you're exactly 
> at the line limit.
+1 for "Another policy that occurred to me: don't insert the comma if you're 
exactly at the line limit." (or //over// the column limit). Seems like that 
would be enough to keep it idempotent.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73354



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


[PATCH] D71018: [ASTImporter] Improved import of TypeSourceInfo (TypeLoc)

2020-01-27 Thread Gabor Marton via Phabricator via cfe-commits
martong edited reviewers, added: teemperor; removed: a.sidorin.
martong added a comment.
Herald added a reviewer: a.sidorin.

@teemperor , @shafik
Guys, could you please take a look on this patch? I don't think that type 
locations could have any effects on LLDB, but one may never know, so, it is 
better to have your review too.
Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71018



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


  1   2   3   >