[PATCH] D88414: [clangd] Introduce memory dumping to FileIndex, FileSymbols and BackgroundIndex

2020-10-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D88414#2319161 , @kadircet wrote:

> In D88414#2317106 , @sammccall wrote:
>
>> Now there's lots of usage (which looks good!) i'm finding it a bit hard to 
>> keep track of what the tree will look like overall.
>>
>> At some point it'd be great to:
>>  a) bind this to an LSP extension so we can see it in editors
>
> i was also thinking about it and couldn't decide between a "custom command" 
> vs "code action".
>
> - the former gives a richer interaction, but requires every editor plugin to 
> implement support.
> - the latter is a little bit more restrictive but doesn't require a bunch of 
> extra work.
>
> I am happy to go with the "code action" approach initially. WDYT? (not in the 
> scope of this patch)

I'm pretty leery about code action because it's not at all context-sensitive 
(not even per-file).
That also doesn't give us any way to specify detail vs summary if we want that.
I'd suggest a custom LSP method (unless there's some reason to prefer 
`executeCommand`? Seems like additional indirection for no benefit).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88414

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


[PATCH] D89098: [clang] Fix returning the underlying VarDecl as top-level decl for VarTemplateDecl.

2020-10-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman, kristof.beyls.
Herald added a project: clang.
hokein requested review of this revision.

Given the following VarTemplateDecl AST,

  VarTemplateDecl col:26 X
  |-TemplateTypeParmDecl typename depth 0 index 0
  `-VarDecl X 'bool' cinit
`-CXXBoolLiteralExpr 'bool' true

previously, we returned the VarDecl as the top-level decl, which was not
correct, the top-level decl should be VarTemplateDecl.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89098

Files:
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
  clang/lib/Parse/ParseDecl.cpp


Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -2195,6 +2195,7 @@
 
   // Inform the current actions module that we just parsed this declarator.
   Decl *ThisDecl = nullptr;
+  VarTemplateDecl *VarTemplateD = nullptr;
   switch (TemplateInfo.Kind) {
   case ParsedTemplateInfo::NonTemplate:
 ThisDecl = Actions.ActOnDeclarator(getCurScope(), D);
@@ -2205,10 +2206,12 @@
 ThisDecl = Actions.ActOnTemplateDeclarator(getCurScope(),
*TemplateInfo.TemplateParams,
D);
-if (VarTemplateDecl *VT = dyn_cast_or_null(ThisDecl))
+if (VarTemplateDecl *VT = dyn_cast_or_null(ThisDecl)) {
   // Re-direct this decl to refer to the templated decl so that we can
   // initialize it.
   ThisDecl = VT->getTemplatedDecl();
+  VarTemplateD = VT;
+}
 break;
   }
   case ParsedTemplateInfo::ExplicitInstantiation: {
@@ -2385,8 +2388,7 @@
   }
 
   Actions.FinalizeDeclaration(ThisDecl);
-
-  return ThisDecl;
+  return VarTemplateD ? VarTemplateD : ThisDecl;
 }
 
 /// ParseSpecifierQualifierList
Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -104,6 +104,14 @@
   EXPECT_THAT(AST.getLocalTopLevelDecls(), ElementsAre(DeclNamed("main")));
 }
 
+TEST(ParsedASTTest, VarTemplateDecl) {
+  TestTU TU;
+  TU.Code = "template  bool X = true;";
+  auto AST = TU.build();
+  EXPECT_THAT(AST.getLocalTopLevelDecls(),
+  ElementsAre(AllOf(DeclNamed("X"), WithTemplateArgs("";
+}
+
 TEST(ParsedASTTest, DoesNotGetIncludedTopDecls) {
   TestTU TU;
   TU.HeaderCode = R"cpp(


Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -2195,6 +2195,7 @@
 
   // Inform the current actions module that we just parsed this declarator.
   Decl *ThisDecl = nullptr;
+  VarTemplateDecl *VarTemplateD = nullptr;
   switch (TemplateInfo.Kind) {
   case ParsedTemplateInfo::NonTemplate:
 ThisDecl = Actions.ActOnDeclarator(getCurScope(), D);
@@ -2205,10 +2206,12 @@
 ThisDecl = Actions.ActOnTemplateDeclarator(getCurScope(),
*TemplateInfo.TemplateParams,
D);
-if (VarTemplateDecl *VT = dyn_cast_or_null(ThisDecl))
+if (VarTemplateDecl *VT = dyn_cast_or_null(ThisDecl)) {
   // Re-direct this decl to refer to the templated decl so that we can
   // initialize it.
   ThisDecl = VT->getTemplatedDecl();
+  VarTemplateD = VT;
+}
 break;
   }
   case ParsedTemplateInfo::ExplicitInstantiation: {
@@ -2385,8 +2388,7 @@
   }
 
   Actions.FinalizeDeclaration(ThisDecl);
-
-  return ThisDecl;
+  return VarTemplateD ? VarTemplateD : ThisDecl;
 }
 
 /// ParseSpecifierQualifierList
Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -104,6 +104,14 @@
   EXPECT_THAT(AST.getLocalTopLevelDecls(), ElementsAre(DeclNamed("main")));
 }
 
+TEST(ParsedASTTest, VarTemplateDecl) {
+  TestTU TU;
+  TU.Code = "template  bool X = true;";
+  auto AST = TU.build();
+  EXPECT_THAT(AST.getLocalTopLevelDecls(),
+  ElementsAre(AllOf(DeclNamed("X"), WithTemplateArgs("";
+}
+
 TEST(ParsedASTTest, DoesNotGetIncludedTopDecls) {
   TestTU TU;
   TU.HeaderCode = R"cpp(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87279: [clang] Fix handling of physical registers in inline assembly operands.

2020-10-09 Thread Jonas Paulsson via Phabricator via cfe-commits
jonpa updated this revision to Diff 297136.
jonpa marked an inline comment as done.
jonpa added a comment.

Updated message string per review.


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

https://reviews.llvm.org/D87279

Files:
  clang/lib/CodeGen/CGStmt.cpp
  clang/test/CodeGen/systemz-inline-asm-02.c
  clang/test/CodeGen/systemz-inline-asm.c

Index: clang/test/CodeGen/systemz-inline-asm.c
===
--- clang/test/CodeGen/systemz-inline-asm.c
+++ clang/test/CodeGen/systemz-inline-asm.c
@@ -129,3 +129,17 @@
 // CHECK: [[RESULT:%.*]] = tail call fp128 asm "axbr $0, $2", "=f,0,f"(fp128 %f, fp128 %g)
 // CHECK: store fp128 [[RESULT]], fp128* [[DEST]]
 }
+
+// Test that there are no tied physreg uses. TwoAddress pass cannot deal with them.
+int test_physregs(void) {
+  // CHECK-LABEL: define signext i32 @test_physregs()
+  register int l __asm__("r7") = 0;
+
+  // CHECK: call i32 asm "lr $0, $1", "={r7},{r7}"
+  __asm__("lr %0, %1" : "+r"(l));
+
+  // CHECK: call i32 asm "$0 $1 $2", "={r7},{r7},{r7}"
+  __asm__("%0 %1 %2" : "+r"(l) : "r"(l));
+
+  return l;
+}
Index: clang/test/CodeGen/systemz-inline-asm-02.c
===
--- /dev/null
+++ clang/test/CodeGen/systemz-inline-asm-02.c
@@ -0,0 +1,13 @@
+// RUN: not %clang_cc1 -triple s390x-linux-gnu -O2 -emit-llvm -o - %s 2>&1 \
+// RUN:  | FileCheck %s
+// REQUIRES: systemz-registered-target
+
+// Test that an error is given if a physreg is defined by multiple operands.
+int test_physreg_defs(void) {
+  register int l __asm__("r7") = 0;
+
+  // CHECK: error: multiple outputs to hard register: r7
+  __asm__("" : "+r"(l), "=r"(l));
+
+  return l;
+}
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -21,6 +21,7 @@
 #include "clang/Basic/PrettyStackTrace.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetInfo.h"
+#include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/InlineAsm.h"
@@ -1836,7 +1837,8 @@
 static std::string
 AddVariableConstraints(const std::string &Constraint, const Expr &AsmExpr,
const TargetInfo &Target, CodeGenModule &CGM,
-   const AsmStmt &Stmt, const bool EarlyClobber) {
+   const AsmStmt &Stmt, const bool EarlyClobber,
+   std::string *GCCReg = nullptr) {
   const DeclRefExpr *AsmDeclRef = dyn_cast(&AsmExpr);
   if (!AsmDeclRef)
 return Constraint;
@@ -1861,6 +1863,8 @@
   }
   // Canonicalize the register here before returning it.
   Register = Target.getNormalizedGCCRegisterName(Register);
+  if (GCCReg != nullptr)
+*GCCReg = Register.str();
   return (EarlyClobber ? "&{" : "{") + Register.str() + "}";
 }
 
@@ -2059,6 +2063,9 @@
   // Keep track of out constraints for tied input operand.
   std::vector OutputConstraints;
 
+  // Keep track of defined physregs.
+  llvm::SmallSet PhysRegOutputs;
+
   // An inline asm can be marked readonly if it meets the following conditions:
   //  - it doesn't have any sideeffects
   //  - it doesn't clobber memory
@@ -2078,9 +2085,15 @@
 const Expr *OutExpr = S.getOutputExpr(i);
 OutExpr = OutExpr->IgnoreParenNoopCasts(getContext());
 
+std::string GCCReg;
 OutputConstraint = AddVariableConstraints(OutputConstraint, *OutExpr,
   getTarget(), CGM, S,
-  Info.earlyClobber());
+  Info.earlyClobber(),
+  &GCCReg);
+// Give an error on multiple outputs to same physreg.
+if (!GCCReg.empty() && !PhysRegOutputs.insert(GCCReg).second)
+  CGM.Error(S.getAsmLoc(), "multiple outputs to hard register: " + GCCReg);
+
 OutputConstraints.push_back(OutputConstraint);
 LValue Dest = EmitLValue(OutExpr);
 if (!Constraints.empty())
@@ -2167,7 +2180,8 @@
 LargestVectorWidth =
 std::max((uint64_t)LargestVectorWidth,
  VT->getPrimitiveSizeInBits().getKnownMinSize());
-  if (Info.allowsRegister())
+  // Don't tie physregs.
+  if (Info.allowsRegister() && GCCReg.empty())
 InOutConstraints += llvm::utostr(i);
   else
 InOutConstraints += OutputConstraint;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88417: [clangd] Record memory usages after each notification

2020-10-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D88417#2319307 , @kadircet wrote:

> Bad news, I was testing this with remote-index, hence background-index was 
> turned off. Unfortunately traversing all of the slabs in `FileSymbols` takes 
> quite a while in this case (~15ms for LLVM).
>
> I don't think it is feasible to do this on every notification now, as this 
> implies an extra 15ms latency for interactive requests like code 
> completion/signature help due to the delay between didChange notification and 
> codeCompletion request.

Yeah, 15ms is a lot.
Staring at the code, I think this is our unfortunate index allocation strategy: 
for each source file in the project, we have one slab allocator for symbols, 
one for refs, one for relations...
The factor of 3 is sad but the factor of 1 is what's killing us :-)

So we should fix that someday (DBMS?) but for now, let's back off to measuring 
once every several minutes.

The main problem I see is that we're almost guaranteed to be "unlucky" with the 
sample that way.
e.g. delay = 5 min. On startup there's some notification (initialized? 
didOpen?) that happens before any of the serious allocation and resets the 
counter.
So we won't have a realistic memory usage until we hit the 5 minute mark and 
profile again. If many sessions are <5min then our averages are going to be way 
off.

I can't think of a notification that is ubiquitous but only fires after serious 
work has happened. (Well, publishDiagnostics, but that goes in the wrong 
direction and so runs on the wrong thread).

What about something like a 5 minute throttle, but have ClangdLSPServer's 
constructor set the timestamp to now+1 minute? (Without profiling)




Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:152
+  trace::Span Tracer(Detailed ? "ProfileDetailed" : "ProfileBrief");
+  // Exit early if tracing is disabled.
+  if (!Tracer.Args)

I was about to complain that this doesn't work, but it actually does...

This wasn't the intended design of trace/span :-(
The idea was that `Args` would be null if the tracer dynamically wasn't 
interested in event details (e.g. an implementation like CSVMetricsTracer that 
doesn't record event payloads, or a sampling tracer).
In this case !Args would have false positives.

Do you mind adding an explicit trace::enabled() method to Trace.h instead, to 
be more explicit? I'd like to fix the Trace api.
(Else leave as-is and I can do this as a followup)



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:182
+Server.Server->profile(MT);
+trace::recordMemoryUsage(MT, "clangd_server");
 return true;

kadircet wrote:
> sammccall wrote:
> > (Sorry, I suspect we discussed this and I forgot)
> > Is there a reason at this point to put knowledge of the core metric in 
> > trace:: rather than define it here locally in ClangdLSPServer?
> > (Sorry, I suspect we discussed this and I forgot)
> 
> Not really.
> 
> > Is there a reason at this point to put knowledge of the core metric in 
> > trace:: rather than define it here locally in ClangdLSPServer?
> 
> `ClangdLSPServer` didnt feel like the appropriate place for that logic. 
> Moreover other embedders of ClangdServer could benefit from traversal logic 
> if it is defined in a lower level than ClangdLSPServer.
(Sorry, I guess D88413 was really the place for this discussion)

> ClangdLSPServer didnt feel like the appropriate place for that logic.

To me, putting this in ClangdLSPServer feels like "this isn't part of the 
central mission here, it could be split out for coherence/reuse".
Whereas putting it in support/Trace feels like "this is a layering violation".

> other embedders of ClangdServer could benefit from traversal logic

If exporting memorytree->metric with the path as the label is something we want 
to reuse, that could be a function in MemoryTree.h (taking the metric as 
parameter) or we can include the generic traversal function you proposed 
earlier. Even though they're both in Support, layering MemoryTree above Tracer 
seems more appropriate than the other way around.
My instinct is this is premature generalization and having a traversal in each 
embedder is fine, though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88417

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


[PATCH] D89098: [clang] Fix returning the underlying VarDecl as top-level decl for VarTemplateDecl.

2020-10-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Nice catch, LG with readability nits




Comment at: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp:107
 
+TEST(ParsedASTTest, VarTemplateDecl) {
+  TestTU TU;

(you could fold this into the above test if you want)



Comment at: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp:112
+  EXPECT_THAT(AST.getLocalTopLevelDecls(),
+  ElementsAre(AllOf(DeclNamed("X"), WithTemplateArgs("";
+}

Is WithTemplateArgs here testing what you want (args vs params)?
Seems like it would be clearer to assert on DeclKind



Comment at: clang/lib/Parse/ParseDecl.cpp:2212
   // initialize it.
   ThisDecl = VT->getTemplatedDecl();
+  VarTemplateD = VT;

The purpose of the renaming is less than obvious here.

Can we rename VarTemplateDecl to OuterDecl or so? (And change the type to Decl)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89098

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


[PATCH] D89098: [clang] Fix returning the underlying VarDecl as top-level decl for VarTemplateDecl.

2020-10-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Is this https://github.com/clangd/clangd/issues/554 ? :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89098

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


[clang-tools-extra] 2ff4493 - [clangd] Reduce availability of extract function

2020-10-09 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-10-09T10:12:48+02:00
New Revision: 2ff44935a5f56f755a4f47ad00ee0dec48e19832

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

LOG: [clangd] Reduce availability of extract function

This patch introduces hoisting detection logic into prepare state with
a partial AST traversal of the enclosing function.

We had some complaints from the users about this code action being almost always
available but failing most of the time. Hopefully this should reduce that noise.

The latency/correctness tradeoff is a bunch of hand-waving, but at least today
we don't have any other actions that are available on selection of statements,
so when we get to do the traversal it is quite likely that all the other checks
will bail out early. But this is still up for discussion, I am happy to abandon
the patch if you believe this is not practical.

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
clang-tools-extra/clangd/unittests/TweakTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
index 1ba8c3c1d9ff..18fe7bf39160 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
@@ -47,6 +47,7 @@
 
//===--===//
 
 #include "AST.h"
+#include "FindTarget.h"
 #include "ParsedAST.h"
 #include "Selection.h"
 #include "SourceCode.h"
@@ -54,6 +55,7 @@
 #include "support/Logger.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Stmt.h"
@@ -65,6 +67,8 @@
 #include "clang/Tooling/Refactoring/Extract/SourceExtraction.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator_range.h"
@@ -152,6 +156,9 @@ struct ExtractionZone {
   const FunctionDecl *EnclosingFunction = nullptr;
   // The half-open file range of the enclosing function.
   SourceRange EnclosingFuncRange;
+  // Set of statements that form the ExtractionZone.
+  llvm::DenseSet RootStmts;
+
   SourceLocation getInsertionPoint() const {
 return EnclosingFuncRange.getBegin();
   }
@@ -159,10 +166,45 @@ struct ExtractionZone {
   // The last root statement is important to decide where we need to insert a
   // semicolon after the extraction.
   const Node *getLastRootStmt() const { return Parent->Children.back(); }
-  void generateRootStmts();
 
-private:
-  llvm::DenseSet RootStmts;
+  // Checks if declarations inside extraction zone are accessed afterwards.
+  //
+  // This performs a partial AST traversal proportional to the size of the
+  // enclosing function, so it is possibly expensive.
+  bool requiresHoisting(const SourceManager &SM) const {
+// First find all the declarations that happened inside extraction zone.
+llvm::SmallSet DeclsInExtZone;
+for (auto *RootStmt : RootStmts) {
+  findExplicitReferences(RootStmt,
+ [&DeclsInExtZone](const ReferenceLoc &Loc) {
+   if (!Loc.IsDecl)
+ return;
+   DeclsInExtZone.insert(Loc.Targets.front());
+ });
+}
+// Early exit without performing expensive traversal below.
+if (DeclsInExtZone.empty())
+  return false;
+// Then make sure they are not used outside the zone.
+for (const auto *S : EnclosingFunction->getBody()->children()) {
+  if (SM.isBeforeInTranslationUnit(S->getSourceRange().getEnd(),
+   ZoneRange.getEnd()))
+continue;
+  bool HasPostUse = false;
+  findExplicitReferences(S, [&](const ReferenceLoc &Loc) {
+if (HasPostUse ||
+SM.isBeforeInTranslationUnit(Loc.NameLoc, ZoneRange.getEnd()))
+  return;
+HasPostUse =
+llvm::any_of(Loc.Targets, [&DeclsInExtZone](const Decl *Target) {
+  return DeclsInExtZone.contains(Target);
+});
+  });
+  if (HasPostUse)
+return true;
+}
+return false;
+  }
 };
 
 // Whether the code in the extraction zone is guaranteed to return, assuming
@@ -185,12 +227,6 @@ bool ExtractionZone::isRootStmt(const Stmt *S) const {
   return RootStmts.find(S) != RootStmts.end();
 }
 
-// Generate RootStmts set
-void ExtractionZone::generateRootStmts() {
-  fo

[PATCH] D85354: [clangd] Reduce availability of extract function

2020-10-09 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2ff44935a5f5: [clangd] Reduce availability of extract 
function (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85354

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -593,6 +593,8 @@
   EXPECT_EQ(apply("auto lam = [](){ [[int x;]] }; "), "unavailable");
   // Partial statements aren't extracted.
   EXPECT_THAT(apply("int [[x = 0]];"), "unavailable");
+  // FIXME: Support hoisting.
+  EXPECT_THAT(apply(" [[int a = 5;]] a++; "), "unavailable");
 
   // Ensure that end of Zone and Beginning of PostZone being adjacent doesn't
   // lead to break being included in the extraction zone.
@@ -600,8 +602,6 @@
   // FIXME: ExtractFunction should be unavailable inside loop construct
   // initializer/condition.
   EXPECT_THAT(apply(" for([[int i = 0;]];);"), HasSubstr("extracted"));
-  // Don't extract because needs hoisting.
-  EXPECT_THAT(apply(" [[int a = 5;]] a++; "), StartsWith("fail"));
   // Extract certain return
   EXPECT_THAT(apply(" if(true) [[{ return; }]] "), HasSubstr("extracted"));
   // Don't extract uncertain return
Index: clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
@@ -47,6 +47,7 @@
 //===--===//
 
 #include "AST.h"
+#include "FindTarget.h"
 #include "ParsedAST.h"
 #include "Selection.h"
 #include "SourceCode.h"
@@ -54,6 +55,7 @@
 #include "support/Logger.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Stmt.h"
@@ -65,6 +67,8 @@
 #include "clang/Tooling/Refactoring/Extract/SourceExtraction.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator_range.h"
@@ -152,6 +156,9 @@
   const FunctionDecl *EnclosingFunction = nullptr;
   // The half-open file range of the enclosing function.
   SourceRange EnclosingFuncRange;
+  // Set of statements that form the ExtractionZone.
+  llvm::DenseSet RootStmts;
+
   SourceLocation getInsertionPoint() const {
 return EnclosingFuncRange.getBegin();
   }
@@ -159,10 +166,45 @@
   // The last root statement is important to decide where we need to insert a
   // semicolon after the extraction.
   const Node *getLastRootStmt() const { return Parent->Children.back(); }
-  void generateRootStmts();
 
-private:
-  llvm::DenseSet RootStmts;
+  // Checks if declarations inside extraction zone are accessed afterwards.
+  //
+  // This performs a partial AST traversal proportional to the size of the
+  // enclosing function, so it is possibly expensive.
+  bool requiresHoisting(const SourceManager &SM) const {
+// First find all the declarations that happened inside extraction zone.
+llvm::SmallSet DeclsInExtZone;
+for (auto *RootStmt : RootStmts) {
+  findExplicitReferences(RootStmt,
+ [&DeclsInExtZone](const ReferenceLoc &Loc) {
+   if (!Loc.IsDecl)
+ return;
+   DeclsInExtZone.insert(Loc.Targets.front());
+ });
+}
+// Early exit without performing expensive traversal below.
+if (DeclsInExtZone.empty())
+  return false;
+// Then make sure they are not used outside the zone.
+for (const auto *S : EnclosingFunction->getBody()->children()) {
+  if (SM.isBeforeInTranslationUnit(S->getSourceRange().getEnd(),
+   ZoneRange.getEnd()))
+continue;
+  bool HasPostUse = false;
+  findExplicitReferences(S, [&](const ReferenceLoc &Loc) {
+if (HasPostUse ||
+SM.isBeforeInTranslationUnit(Loc.NameLoc, ZoneRange.getEnd()))
+  return;
+HasPostUse =
+llvm::any_of(Loc.Targets, [&DeclsInExtZone](const Decl *Target) {
+  return DeclsInExtZone.contains(Target);
+});
+  });
+  if (HasPostUse)
+return true;
+}
+return false;
+  }
 };
 
 // Whether the code in the extraction zone is guaranteed to return, assuming
@@ -

[PATCH] D88814: [clangd] Enable partial namespace matches for workspace symbols

2020-10-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.

Yeah, we can fairly easily make this tighter if it's noisy. My suspicion is 
people will rather complain about ranking than these results being totally 
irrelevant.
Nice that we now have workspace/symbols users that can send this feedback!




Comment at: clang-tools-extra/clangd/FindSymbols.cpp:47
+bool approximateScopeMatch(llvm::StringRef Scope, llvm::StringRef Query) {
+  // An empty query always matches the scope.
+  if (Query.empty())

there's no need for these to be special cases, the loop handles them correctly

It simplifies the asserts slightly, but seems like false economy


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88814

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


[PATCH] D88814: [clangd] Enable partial namespace matches for workspace symbols

2020-10-09 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 297142.
kadircet marked an inline comment as done.
kadircet added a comment.

- Move if checks into asserts.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88814

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

Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -126,28 +126,43 @@
   TU.AdditionalFiles["foo.h"] = R"cpp(
   namespace ans1 {
 int ai1;
-  namespace ans2 {
-int ai2;
-  }
+namespace ans2 {
+  int ai2;
+  namespace ans3 {
+int ai3;
+  }
+}
   }
   )cpp";
   TU.Code = R"cpp(
   #include "foo.h"
   )cpp";
   EXPECT_THAT(getSymbols(TU, "a"),
-  UnorderedElementsAre(QName("ans1"), QName("ans1::ai1"),
-   QName("ans1::ans2"),
-   QName("ans1::ans2::ai2")));
+  UnorderedElementsAre(
+  QName("ans1"), QName("ans1::ai1"), QName("ans1::ans2"),
+  QName("ans1::ans2::ai2"), QName("ans1::ans2::ans3"),
+  QName("ans1::ans2::ans3::ai3")));
   EXPECT_THAT(getSymbols(TU, "::"), ElementsAre(QName("ans1")));
   EXPECT_THAT(getSymbols(TU, "::a"), ElementsAre(QName("ans1")));
   EXPECT_THAT(getSymbols(TU, "ans1::"),
-  UnorderedElementsAre(QName("ans1::ai1"), QName("ans1::ans2")));
+  UnorderedElementsAre(QName("ans1::ai1"), QName("ans1::ans2"),
+   QName("ans1::ans2::ai2"),
+   QName("ans1::ans2::ans3"),
+   QName("ans1::ans2::ans3::ai3")));
+  EXPECT_THAT(getSymbols(TU, "ans2::"),
+  UnorderedElementsAre(QName("ans1::ans2::ai2"),
+   QName("ans1::ans2::ans3"),
+   QName("ans1::ans2::ans3::ai3")));
   EXPECT_THAT(getSymbols(TU, "::ans1"), ElementsAre(QName("ans1")));
   EXPECT_THAT(getSymbols(TU, "::ans1::"),
   UnorderedElementsAre(QName("ans1::ai1"), QName("ans1::ans2")));
   EXPECT_THAT(getSymbols(TU, "::ans1::ans2"), ElementsAre(QName("ans1::ans2")));
   EXPECT_THAT(getSymbols(TU, "::ans1::ans2::"),
-  ElementsAre(QName("ans1::ans2::ai2")));
+  ElementsAre(QName("ans1::ans2::ai2"), QName("ans1::ans2::ans3")));
+
+  // Ensure sub-sequence matching works.
+  EXPECT_THAT(getSymbols(TU, "ans1::ans3::ai"),
+  UnorderedElementsAre(QName("ans1::ans2::ans3::ai3")));
 }
 
 TEST(WorkspaceSymbols, AnonymousNamespace) {
@@ -256,6 +271,17 @@
   EXPECT_THAT(getSymbols(TU, "::"), ElementsAre(QName("func"), QName("ns")));
 }
 
+TEST(WorkspaceSymbols, RankingPartialNamespace) {
+  TestTU TU;
+  TU.Code = R"cpp(
+namespace ns1 {
+  namespace ns2 { struct Foo {}; }
+}
+namespace ns2 { struct FooB {}; })cpp";
+  EXPECT_THAT(getSymbols(TU, "ns2::f"),
+  ElementsAre(QName("ns2::FooB"), QName("ns1::ns2::Foo")));
+}
+
 TEST(WorkspaceSymbols, WithLimit) {
   TestTU TU;
   TU.AdditionalFiles["foo.h"] = R"cpp(
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -18,10 +18,14 @@
 #include "clang/Index/IndexDataConsumer.h"
 #include "clang/Index/IndexSymbol.h"
 #include "clang/Index/IndexingAction.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/ScopedPrinter.h"
+#include 
 
 #define DEBUG_TYPE "FindSymbols"
 
@@ -38,6 +42,21 @@
   }
 };
 
+// Returns true if \p Query can be found as a sub-sequence inside \p Scope.
+bool approximateScopeMatch(llvm::StringRef Scope, llvm::StringRef Query) {
+  assert(Scope.empty() || Scope.endswith("::"));
+  assert(Query.empty() || Query.endswith("::"));
+  while (!Scope.empty() && !Query.empty()) {
+auto Colons = Scope.find("::");
+assert(Colons != llvm::StringRef::npos);
+
+llvm::StringRef LeadingSpecifier = Scope.slice(0, Colons + 2);
+Scope = Scope.slice(Colons + 2, llvm::StringRef::npos);
+Query.consume_front(LeadingSpecifier);
+  }
+  return Query.empty();
+}
+
 } // namespace
 
 llvm::Expected indexToLSPLocation(const SymbolLocation &Loc,
@@ -71,44 +90,54 @@
   if (Query.empty() || !Index)
 return Result;
 
+  // Lookup for qualified names are performed as:
+  // - Exact namespaces are boosted by the index.
+  // - Approximate matches are (sub-scope match) included

[clang-tools-extra] 6f1a56d - [clangd] Enable partial namespace matches for workspace symbols

2020-10-09 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-10-09T10:20:41+02:00
New Revision: 6f1a56d37ac6a541f585846ab0734ab0bedc264f

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

LOG: [clangd] Enable partial namespace matches for workspace symbols

This will enable queries like "clangd::" to find symbols under clangd
namespace, without requiring full "clang::clangd::" qualification.

Since Fuzzyfind performs the search under all scopes and only boosts the symbols
from relevant namespaces, we might get symbols from non-matching namespaces.
This patch chooses to drop those as they clearly do not match the query.

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

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/FindSymbols.cpp 
b/clang-tools-extra/clangd/FindSymbols.cpp
index 8e21ae22dcd9..3169ffd98038 100644
--- a/clang-tools-extra/clangd/FindSymbols.cpp
+++ b/clang-tools-extra/clangd/FindSymbols.cpp
@@ -18,10 +18,14 @@
 #include "clang/Index/IndexDataConsumer.h"
 #include "clang/Index/IndexSymbol.h"
 #include "clang/Index/IndexingAction.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/ScopedPrinter.h"
+#include 
 
 #define DEBUG_TYPE "FindSymbols"
 
@@ -38,6 +42,21 @@ struct ScoredSymbolGreater {
   }
 };
 
+// Returns true if \p Query can be found as a sub-sequence inside \p Scope.
+bool approximateScopeMatch(llvm::StringRef Scope, llvm::StringRef Query) {
+  assert(Scope.empty() || Scope.endswith("::"));
+  assert(Query.empty() || Query.endswith("::"));
+  while (!Scope.empty() && !Query.empty()) {
+auto Colons = Scope.find("::");
+assert(Colons != llvm::StringRef::npos);
+
+llvm::StringRef LeadingSpecifier = Scope.slice(0, Colons + 2);
+Scope = Scope.slice(Colons + 2, llvm::StringRef::npos);
+Query.consume_front(LeadingSpecifier);
+  }
+  return Query.empty();
+}
+
 } // namespace
 
 llvm::Expected indexToLSPLocation(const SymbolLocation &Loc,
@@ -71,44 +90,54 @@ getWorkspaceSymbols(llvm::StringRef Query, int Limit,
   if (Query.empty() || !Index)
 return Result;
 
+  // Lookup for qualified names are performed as:
+  // - Exact namespaces are boosted by the index.
+  // - Approximate matches are (sub-scope match) included via AnyScope logic.
+  // - Non-matching namespaces (no sub-scope match) are post-filtered.
   auto Names = splitQualifiedName(Query);
 
   FuzzyFindRequest Req;
   Req.Query = std::string(Names.second);
 
-  // FuzzyFind doesn't want leading :: qualifier
-  bool IsGlobalQuery = Names.first.consume_front("::");
-  // Restrict results to the scope in the query string if present (global or
-  // not).
-  if (IsGlobalQuery || !Names.first.empty())
+  // FuzzyFind doesn't want leading :: qualifier.
+  auto HasLeadingColons = Names.first.consume_front("::");
+  // Limit the query to specific namespace if it is fully-qualified.
+  Req.AnyScope = !HasLeadingColons;
+  // Boost symbols from desired namespace.
+  if (HasLeadingColons || !Names.first.empty())
 Req.Scopes = {std::string(Names.first)};
-  else
-Req.AnyScope = true;
-  if (Limit)
+  if (Limit) {
 Req.Limit = Limit;
+// If we are boosting a specific scope allow more results to be retrieved,
+// since some symbols from preferred namespaces might not make the cut.
+if (Req.AnyScope && !Req.Scopes.empty())
+  *Req.Limit *= 5;
+  }
   TopN Top(
   Req.Limit ? *Req.Limit : std::numeric_limits::max());
   FuzzyMatcher Filter(Req.Query);
-  Index->fuzzyFind(Req, [HintPath, &Top, &Filter](const Symbol &Sym) {
+
+  Index->fuzzyFind(Req, [HintPath, &Top, &Filter, AnyScope = Req.AnyScope,
+ ReqScope = Names.first](const Symbol &Sym) {
+llvm::StringRef Scope = Sym.Scope;
+// Fuzzyfind might return symbols from irrelevant namespaces if query was
+// not fully-qualified, drop those.
+if (AnyScope && !approximateScopeMatch(Scope, ReqScope))
+  return;
+
 auto Loc = symbolToLocation(Sym, HintPath);
 if (!Loc) {
   log("Workspace symbols: {0}", Loc.takeError());
   return;
 }
 
-llvm::StringRef Scope = Sym.Scope;
-Scope.consume_back("::");
-SymbolInformation Info;
-Info.name = (Sym.Name + Sym.TemplateSpecializationArgs).str();
-Info.kind = indexSymbolKindToSymbolKind(Sym.SymInfo.Kind);
-Info.location = *Loc;
-Info.containerName = Scope.str();
-
 SymbolQualitySignals Quality;
 Quality.merge(Sym);
 SymbolRelevanceSignals

[PATCH] D88814: [clangd] Enable partial namespace matches for workspace symbols

2020-10-09 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6f1a56d37ac6: [clangd] Enable partial namespace matches for 
workspace symbols (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88814

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

Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -126,28 +126,43 @@
   TU.AdditionalFiles["foo.h"] = R"cpp(
   namespace ans1 {
 int ai1;
-  namespace ans2 {
-int ai2;
-  }
+namespace ans2 {
+  int ai2;
+  namespace ans3 {
+int ai3;
+  }
+}
   }
   )cpp";
   TU.Code = R"cpp(
   #include "foo.h"
   )cpp";
   EXPECT_THAT(getSymbols(TU, "a"),
-  UnorderedElementsAre(QName("ans1"), QName("ans1::ai1"),
-   QName("ans1::ans2"),
-   QName("ans1::ans2::ai2")));
+  UnorderedElementsAre(
+  QName("ans1"), QName("ans1::ai1"), QName("ans1::ans2"),
+  QName("ans1::ans2::ai2"), QName("ans1::ans2::ans3"),
+  QName("ans1::ans2::ans3::ai3")));
   EXPECT_THAT(getSymbols(TU, "::"), ElementsAre(QName("ans1")));
   EXPECT_THAT(getSymbols(TU, "::a"), ElementsAre(QName("ans1")));
   EXPECT_THAT(getSymbols(TU, "ans1::"),
-  UnorderedElementsAre(QName("ans1::ai1"), QName("ans1::ans2")));
+  UnorderedElementsAre(QName("ans1::ai1"), QName("ans1::ans2"),
+   QName("ans1::ans2::ai2"),
+   QName("ans1::ans2::ans3"),
+   QName("ans1::ans2::ans3::ai3")));
+  EXPECT_THAT(getSymbols(TU, "ans2::"),
+  UnorderedElementsAre(QName("ans1::ans2::ai2"),
+   QName("ans1::ans2::ans3"),
+   QName("ans1::ans2::ans3::ai3")));
   EXPECT_THAT(getSymbols(TU, "::ans1"), ElementsAre(QName("ans1")));
   EXPECT_THAT(getSymbols(TU, "::ans1::"),
   UnorderedElementsAre(QName("ans1::ai1"), QName("ans1::ans2")));
   EXPECT_THAT(getSymbols(TU, "::ans1::ans2"), ElementsAre(QName("ans1::ans2")));
   EXPECT_THAT(getSymbols(TU, "::ans1::ans2::"),
-  ElementsAre(QName("ans1::ans2::ai2")));
+  ElementsAre(QName("ans1::ans2::ai2"), QName("ans1::ans2::ans3")));
+
+  // Ensure sub-sequence matching works.
+  EXPECT_THAT(getSymbols(TU, "ans1::ans3::ai"),
+  UnorderedElementsAre(QName("ans1::ans2::ans3::ai3")));
 }
 
 TEST(WorkspaceSymbols, AnonymousNamespace) {
@@ -256,6 +271,17 @@
   EXPECT_THAT(getSymbols(TU, "::"), ElementsAre(QName("func"), QName("ns")));
 }
 
+TEST(WorkspaceSymbols, RankingPartialNamespace) {
+  TestTU TU;
+  TU.Code = R"cpp(
+namespace ns1 {
+  namespace ns2 { struct Foo {}; }
+}
+namespace ns2 { struct FooB {}; })cpp";
+  EXPECT_THAT(getSymbols(TU, "ns2::f"),
+  ElementsAre(QName("ns2::FooB"), QName("ns1::ns2::Foo")));
+}
+
 TEST(WorkspaceSymbols, WithLimit) {
   TestTU TU;
   TU.AdditionalFiles["foo.h"] = R"cpp(
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -18,10 +18,14 @@
 #include "clang/Index/IndexDataConsumer.h"
 #include "clang/Index/IndexSymbol.h"
 #include "clang/Index/IndexingAction.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/ScopedPrinter.h"
+#include 
 
 #define DEBUG_TYPE "FindSymbols"
 
@@ -38,6 +42,21 @@
   }
 };
 
+// Returns true if \p Query can be found as a sub-sequence inside \p Scope.
+bool approximateScopeMatch(llvm::StringRef Scope, llvm::StringRef Query) {
+  assert(Scope.empty() || Scope.endswith("::"));
+  assert(Query.empty() || Query.endswith("::"));
+  while (!Scope.empty() && !Query.empty()) {
+auto Colons = Scope.find("::");
+assert(Colons != llvm::StringRef::npos);
+
+llvm::StringRef LeadingSpecifier = Scope.slice(0, Colons + 2);
+Scope = Scope.slice(Colons + 2, llvm::StringRef::npos);
+Query.consume_front(LeadingSpecifier);
+  }
+  return Query.empty();
+}
+
 } // namespace
 
 llvm::Expected indexToLSPLocation(const SymbolLocation &Loc,
@@ -71,44 +90,54 @@
   if (Query.empty() || !Index)
 return Result;
 
+  // Lookup for qualified names are performed as:
+  // 

[clang-tools-extra] 6ee47f5 - [clangd] Fix dead variable, typo. NFC

2020-10-09 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-10-09T10:26:58+02:00
New Revision: 6ee47f552ba7654a0997c8deb71f65d0d91f4a28

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

LOG: [clangd] Fix dead variable, typo. NFC

Added: 


Modified: 
clang-tools-extra/clangd/index/SymbolCollector.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/SymbolCollector.cpp 
b/clang-tools-extra/clangd/index/SymbolCollector.cpp
index 92ebd90e950c..e7d44a79eb47 100644
--- a/clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ b/clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -552,9 +552,8 @@ void SymbolCollector::finish() {
   }
   // Fill in IncludeHeaders.
   // We delay this until end of TU so header guards are all resolved.
-  // Symbols in slabs aren' mutable, so insert() has to walk all the strings
+  // Symbols in slabs aren't mutable, so insert() has to walk all the strings
   // :-(
-  llvm::SmallString<256> QName;
   for (const auto &Entry : IncludeFiles)
 if (const Symbol *S = Symbols.find(Entry.first)) {
   if (auto Header = getIncludeHeader(*S, Entry.second)) {



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


[PATCH] D88885: [clangd] Disambiguate overloads of std::move for header insertion.

2020-10-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:557
   // :-(
   llvm::SmallString<256> QName;
   for (const auto &Entry : IncludeFiles)

kadircet wrote:
> this one is no longer needed.
whoops, fixed in 6ee47f552ba7654a0997c8deb71f65d0d91f4a28


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D5

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


[PATCH] D88648: Refactor fixed point conversion test.

2020-10-09 Thread Bevin Hansson via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9c26eb8b915e: Refactor fixed point conversion test. 
(authored by ebevhan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88648

Files:
  clang/test/Frontend/fixed_point_conversions.c
  clang/test/Frontend/fixed_point_conversions_const.c

Index: clang/test/Frontend/fixed_point_conversions_const.c
===
--- /dev/null
+++ clang/test/Frontend/fixed_point_conversions_const.c
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,SIGNED
+// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -S -emit-llvm %s -o - -fpadding-on-unsigned-fixed-point | FileCheck %s --check-prefixes=CHECK,UNSIGNED
+
+// Between different fixed point types
+short _Accum sa_const = 2.5hk;
+// CHECK-DAG: @sa_const  = {{.*}}global i16 320, align 2
+_Accum a_const = 2.5hk;
+// CHECK-DAG: @a_const   = {{.*}}global i32 81920, align 4
+short _Accum sa_const2 = 2.5k;
+// CHECK-DAG: @sa_const2 = {{.*}}global i16 320, align 2
+
+short _Accum sa_from_f_const = 0.5r;
+// CHECK-DAG: sa_from_f_const = {{.*}}global i16 64, align 2
+_Fract f_from_sa_const = 0.5hk;
+// CHECK-DAG: f_from_sa_const = {{.*}}global i16 16384, align 2
+
+unsigned short _Accum usa_const = 2.5uk;
+unsigned _Accum ua_const = 2.5uhk;
+// SIGNED-DAG: @usa_const  = {{.*}}global i16 640, align 2
+// SIGNED-DAG: @ua_const   = {{.*}}global i32 163840, align 4
+// UNSIGNED-DAG:@usa_const  = {{.*}}global i16 320, align 2
+// UNSIGNED-DAG:@ua_const   = {{.*}}global i32 81920, align 4
+
+// FixedPoint to integer
+int i_const = -128.0hk;
+// CHECK-DAG: @i_const  = {{.*}}global i32 -128, align 4
+int i_const2 = 128.0hk;
+// CHECK-DAG: @i_const2 = {{.*}}global i32 128, align 4
+int i_const3 = -128.0k;
+// CHECK-DAG: @i_const3 = {{.*}}global i32 -128, align 4
+int i_const4 = 128.0k;
+// CHECK-DAG: @i_const4 = {{.*}}global i32 128, align 4
+short s_const = -128.0k;
+// CHECK-DAG: @s_const  = {{.*}}global i16 -128, align 2
+short s_const2 = 128.0k;
+// CHECK-DAG: @s_const2 = {{.*}}global i16 128, align 2
+
+// Integer to fixed point
+short _Accum sa_const5 = 2;
+// CHECK-DAG: @sa_const5 = {{.*}}global i16 256, align 2
+short _Accum sa_const6 = -2;
+// CHECK-DAG: @sa_const6 = {{.*}}global i16 -256, align 2
+short _Accum sa_const7 = -256;
+// CHECK-DAG: @sa_const7 = {{.*}}global i16 -32768, align 2
+
+// Signedness
+unsigned short _Accum usa_const2 = 2.5hk;
+// SIGNED-DAG: @usa_const2  = {{.*}}global i16 640, align 2
+// UNSIGNED-DAG:@usa_const2  = {{.*}}global i16 320, align 2
+short _Accum sa_const3 = 2.5hk;
+// CHECK-DAG: @sa_const3 = {{.*}}global i16 320, align 2
+
+int i_const5 = 128.0uhk;
+unsigned int ui_const = 128.0hk;
+// CHECK-DAG: @i_const5  = {{.*}}global i32 128, align 4
+// CHECK-DAG: @ui_const  = {{.*}}global i32 128, align 4
+
+short _Accum sa_const9 = 2u;
+// CHECK-DAG: @sa_const9 = {{.*}}global i16 256, align 2
+unsigned short _Accum usa_const3 = 2;
+// SIGNED-DAG: @usa_const3 = {{.*}}global i16 512, align 2
+// UNSIGNED-DAG:@usa_const3 = {{.*}}global i16 256, align 2
+
+// Overflow (this is undefined but allowed)
+short _Accum sa_const4 = 256.0k;
+unsigned int ui_const2 = -2.5hk;
+short _Accum sa_const8 = 256;
+unsigned short _Accum usa_const4 = -2;
+
+// Saturation
+_Sat short _Accum sat_sa_const = 2.5hk;
+// CHECK-DAG: @sat_sa_const  = {{.*}}global i16 320, align 2
+_Sat short _Accum sat_sa_const2 = 256.0k;
+// CHECK-DAG: @sat_sa_const2 = {{.*}}global i16 32767, align 2
+_Sat unsigned short _Accum sat_usa_const = -1.0hk;
+// CHECK-DAG: @sat_usa_const = {{.*}}global i16 0, align 2
+_Sat unsigned short _Accum sat_usa_const2 = 256.0k;
+// SIGNED-DAG: @sat_usa_const2 = {{.*}}global i16 -1, align 2
+// UNSIGNED-DAG:@sat_usa_const2 = {{.*}}global i16 32767, align 2
+
+_Sat short _Accum sat_sa_const3 = 256;
+// CHECK-DAG: @sat_sa_const3 = {{.*}}global i16 32767, align 2
+_Sat short _Accum sat_sa_const4 = -257;
+// CHECK-DAG: @sat_sa_const4 = {{.*}}global i16 -32768, align 2
+_Sat unsigned short _Accum sat_usa_const3 = -1;
+// CHECK-DAG: @sat_usa_const3 = {{.*}}global i16 0, align 2
+_Sat unsigned short _Accum sat_usa_const4 = 256;
+// SIGNED-DAG: @sat_usa_const4 = {{.*}}global i16 -1, align 2
+// UNSIGNED-DAG:@sat_usa_const4 = {{.*}}global i16 32767, align 2
Index: clang/test/Frontend/fixed_point_conversions.c
===
--- clang/test/Frontend/fixed_point_conversions.c
+++ clang/test/Frontend/fixed_point_conversions.c
@@ -1,485 +1,697 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -

[clang] 9c26eb8 - Refactor fixed point conversion test.

2020-10-09 Thread Bevin Hansson via cfe-commits

Author: Bevin Hansson
Date: 2020-10-09T10:27:42+02:00
New Revision: 9c26eb8b915e5e20afa7d3e07996ea112c18ccc3

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

LOG: Refactor fixed point conversion test.

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

Added: 
clang/test/Frontend/fixed_point_conversions_const.c

Modified: 
clang/test/Frontend/fixed_point_conversions.c

Removed: 




diff  --git a/clang/test/Frontend/fixed_point_conversions.c 
b/clang/test/Frontend/fixed_point_conversions.c
index 86a687bdef93..dfe727c708f4 100644
--- a/clang/test/Frontend/fixed_point_conversions.c
+++ b/clang/test/Frontend/fixed_point_conversions.c
@@ -1,485 +1,697 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -S 
-emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,SIGNED
 // RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -S 
-emit-llvm %s -o - -fpadding-on-unsigned-fixed-point | FileCheck %s 
--check-prefixes=CHECK,UNSIGNED
 
-// Between 
diff erent fixed point types
-short _Accum sa_const = 2.5hk; // CHECK-DAG: @sa_const  = {{.*}}global i16 
320, align 2
-_Accum a_const = 2.5hk;// CHECK-DAG: @a_const   = {{.*}}global i32 
81920, align 4
-short _Accum sa_const2 = 2.5k; // CHECK-DAG: @sa_const2 = {{.*}}global i16 
320, align 2
-
-short _Accum sa_from_f_const = 0.5r; // CHECK-DAG: sa_from_f_const = 
{{.*}}global i16 64, align 2
-_Fract f_from_sa_const = 0.5hk;  // CHECK-DAG: f_from_sa_const = 
{{.*}}global i16 16384, align 2
-
-unsigned short _Accum usa_const = 2.5uk;
-unsigned _Accum ua_const = 2.5uhk;
-// SIGNED-DAG: @usa_const  = {{.*}}global i16 640, align 2
-// SIGNED-DAG: @ua_const   = {{.*}}global i32 163840, align 4
-// UNSIGNED-DAG:@usa_const  = {{.*}}global i16 320, align 2
-// UNSIGNED-DAG:@ua_const   = {{.*}}global i32 81920, align 4
-
-// FixedPoint to integer
-int i_const = -128.0hk;  // CHECK-DAG: @i_const  = {{.*}}global i32 -128, 
align 4
-int i_const2 = 128.0hk;  // CHECK-DAG: @i_const2 = {{.*}}global i32 128, align 
4
-int i_const3 = -128.0k;  // CHECK-DAG: @i_const3 = {{.*}}global i32 -128, 
align 4
-int i_const4 = 128.0k;   // CHECK-DAG: @i_const4 = {{.*}}global i32 128, align 
4
-short s_const = -128.0k; // CHECK-DAG: @s_const  = {{.*}}global i16 -128, 
align 2
-short s_const2 = 128.0k; // CHECK-DAG: @s_const2 = {{.*}}global i16 128, align 
2
-
-// Integer to fixed point
-short _Accum sa_const5 = 2;// CHECK-DAG: @sa_const5 = {{.*}}global i16 
256, align 2
-short _Accum sa_const6 = -2;   // CHECK-DAG: @sa_const6 = {{.*}}global i16 
-256, align 2
-short _Accum sa_const7 = -256; // CHECK-DAG: @sa_const7 = {{.*}}global i16 
-32768, align 2
-
-// Signedness
-unsigned short _Accum usa_const2 = 2.5hk;
-// SIGNED-DAG: @usa_const2  = {{.*}}global i16 640, align 2
-// UNSIGNED-DAG:@usa_const2  = {{.*}}global i16 320, align 2
-short _Accum sa_const3 = 2.5hk; // CHECK-DAG: @sa_const3 = {{.*}}global i16 
320, align 2
-
-int i_const5 = 128.0uhk;
-unsigned int ui_const = 128.0hk;
-// CHECK-DAG: @i_const5  = {{.*}}global i32 128, align 4
-// CHECK-DAG: @ui_const  = {{.*}}global i32 128, align 4
-
-short _Accum sa_const9 = 2u; // CHECK-DAG: @sa_const9 = {{.*}}global i16 256, 
align 2
-unsigned short _Accum usa_const3 = 2;
-// SIGNED-DAG: @usa_const3 = {{.*}}global i16 512, align 2
-// UNSIGNED-DAG:@usa_const3 = {{.*}}global i16 256, align 2
-
-// Overflow (this is undefined but allowed)
-short _Accum sa_const4 = 256.0k;
-unsigned int ui_const2 = -2.5hk;
-short _Accum sa_const8 = 256;
-unsigned short _Accum usa_const4 = -2;
-
-// Saturation
-_Sat short _Accum sat_sa_const = 2.5hk;   // CHECK-DAG: @sat_sa_const  = 
{{.*}}global i16 320, align 2
-_Sat short _Accum sat_sa_const2 = 256.0k; // CHECK-DAG: @sat_sa_const2 = 
{{.*}}global i16 32767, align 2
-_Sat unsigned short _Accum sat_usa_const = -1.0hk;
-// CHECK-DAG: @sat_usa_const = {{.*}}global i16 0, align 2
-_Sat unsigned short _Accum sat_usa_const2 = 256.0k;
-// SIGNED-DAG: @sat_usa_const2 = {{.*}}global i16 -1, align 2
-// UNSIGNED-DAG:@sat_usa_const2 = {{.*}}global i16 32767, align 2
-
-_Sat short _Accum sat_sa_const3 = 256;  // CHECK-DAG: @sat_sa_const3 = 
{{.*}}global i16 32767, align 2
-_Sat short _Accum sat_sa_const4 = -257; // CHECK-DAG: @sat_sa_const4 = 
{{.*}}global i16 -32768, align 2
-_Sat unsigned short _Accum sat_usa_const3 = -1;
-// CHECK-DAG: @sat_usa_const3 = {{.*}}global i16 0, align 2
-_Sat unsigned short _Accum sat_usa_const4 = 256;
-// SIGNED-DAG: @sat_usa_const4 = {{.*}}global i16 -1, align 2
-// UNSIGNED-DAG:@sat_usa_const4 = {{.*}}global i16 32767, align 2
-
-void TestFixedPointCastSameType() {
-  _Accum a = 2.5k;
-  _Accum a2 = a;
-  // CHECK:  [

[PATCH] D89102: [X86] Add HRESET instruction.

2020-10-09 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei created this revision.
pengfei added reviewers: craig.topper, RKSimon, LuoYuanke.
Herald added subscribers: llvm-commits, cfe-commits, dang, hiraditya, mgorny.
Herald added projects: clang, LLVM.
pengfei requested review of this revision.

For more details about these instructions, please refer to the latest ISE 
document: 
https://software.intel.com/en-us/download/intel-architecture-instruction-set-extensions-programming-reference.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89102

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/cpuid.h
  clang/lib/Headers/hresetintrin.h
  clang/lib/Headers/immintrin.h
  clang/lib/Headers/x86gprintrin.h
  clang/test/CodeGen/x86-hreset-intrin.c
  clang/test/Driver/x86-target-features.c
  clang/test/Preprocessor/x86_target_features.c
  llvm/include/llvm/Support/X86TargetParser.def
  llvm/lib/Support/Host.cpp
  llvm/lib/Support/X86TargetParser.cpp
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86InstrFormats.td
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/test/MC/Disassembler/X86/x86-32.txt
  llvm/test/MC/Disassembler/X86/x86-64.txt
  llvm/test/MC/X86/x86-32-coverage.s
  llvm/test/MC/X86/x86-64.s

Index: llvm/test/MC/X86/x86-64.s
===
--- llvm/test/MC/X86/x86-64.s
+++ llvm/test/MC/X86/x86-64.s
@@ -2014,3 +2014,7 @@
 // CHECK: tdcall
 // CHECK: encoding: [0x66,0x0f,0x01,0xcc]
 tdcall
+
+// CHECK: hreset
+// CHECK: encoding: [0xf3,0x0f,0x3a,0xf0,0xc0,0x01]
+hreset $1
Index: llvm/test/MC/X86/x86-32-coverage.s
===
--- llvm/test/MC/X86/x86-32-coverage.s
+++ llvm/test/MC/X86/x86-32-coverage.s
@@ -10891,4 +10891,8 @@
 
 // CHECK: tdcall
 // CHECK: encoding: [0x66,0x0f,0x01,0xcc]
-tdcall
\ No newline at end of file
+tdcall
+
+// CHECK: hreset
+// CHECK: encoding: [0xf3,0x0f,0x3a,0xf0,0xc0,0x01]
+hreset $1
Index: llvm/test/MC/Disassembler/X86/x86-64.txt
===
--- llvm/test/MC/Disassembler/X86/x86-64.txt
+++ llvm/test/MC/Disassembler/X86/x86-64.txt
@@ -712,3 +712,6 @@
 
 #CHECK: tdcall
 0x66 0x0f 0x01 0xcc
+
+# CHECK: hreset $1
+0xf3 0x0f 0x3a 0xf0 0xc0 0x01
Index: llvm/test/MC/Disassembler/X86/x86-32.txt
===
--- llvm/test/MC/Disassembler/X86/x86-32.txt
+++ llvm/test/MC/Disassembler/X86/x86-32.txt
@@ -1000,3 +1000,6 @@
 
 #CHECK: tdcall
 0x66 0x0f 0x01 0xcc
+
+# CHECK: hreset $1
+0xf3 0x0f 0x3a 0xf0 0xc0 0x01
Index: llvm/lib/Target/X86/X86Subtarget.h
===
--- llvm/lib/Target/X86/X86Subtarget.h
+++ llvm/lib/Target/X86/X86Subtarget.h
@@ -401,6 +401,9 @@
   /// Processor support key locker wide instructions
   bool HasWIDEKL = false;
 
+  /// Processor supports HRESET instruction
+  bool HasHRESET = false;
+
   /// Processor supports SERIALIZE instruction
   bool HasSERIALIZE = false;
 
@@ -736,6 +739,7 @@
   bool hasENQCMD() const { return HasENQCMD; }
   bool hasKL() const { return HasKL; }
   bool hasWIDEKL() const { return HasWIDEKL; }
+  bool hasHRESET() const { return HasHRESET; }
   bool hasSERIALIZE() const { return HasSERIALIZE; }
   bool hasTSXLDTRK() const { return HasTSXLDTRK; }
   bool useRetpolineIndirectCalls() const { return UseRetpolineIndirectCalls; }
Index: llvm/lib/Target/X86/X86InstrInfo.td
===
--- llvm/lib/Target/X86/X86InstrInfo.td
+++ llvm/lib/Target/X86/X86InstrInfo.td
@@ -971,6 +971,7 @@
 def HasENQCMD: Predicate<"Subtarget->hasENQCMD()">;
 def HasKL: Predicate<"Subtarget->hasKL()">;
 def HasWIDEKL: Predicate<"Subtarget->hasWIDEKL()">;
+def HasHRESET: Predicate<"Subtarget->hasHRESET()">;
 def HasSERIALIZE : Predicate<"Subtarget->hasSERIALIZE()">;
 def HasTSXLDTRK  : Predicate<"Subtarget->hasTSXLDTRK()">;
 def HasAMXTILE   : Predicate<"Subtarget->hasAMXTILE()">;
@@ -2911,6 +2912,13 @@
 def : InstAlias<"clzero\t{%eax|eax}", (CLZERO32r)>, Requires<[Not64BitMode]>;
 def : InstAlias<"clzero\t{%rax|rax}", (CLZERO64r)>, Requires<[In64BitMode]>;
 
+//===--===//
+// HRESET Instruction
+//
+let Uses = [EAX] in
+  def HRESET : Ii8<0xF0, MRM_C0, (outs), (ins i32u8imm:$imm), "hreset\t$imm", []>,
+   Requires<[HasHRESET]>, TAXS;
+
 //===--===//
 // SERIALIZE Instruction
 //
Index: llvm/lib/Target/X86/X86InstrFormats.td
===
--- llvm/lib/Target/X86/X86InstrFormats.td
+++ llvm/lib/Target/X86/X86InstrFormats.td
@@ -216,6 +216,7 @@
 class TAPS :

[PATCH] D88645: [Annotation] Allows annotation to carry some additional constant arguments.

2020-10-09 Thread Tyker via Phabricator via cfe-commits
Tyker updated this revision to Diff 297159.
Tyker marked 7 inline comments as done.
Tyker added a comment.

addressed comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88645

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/ParsedAttr.h
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/AST/ast-dump-attr.cpp
  clang/test/CodeGen/annotations-field.c
  clang/test/CodeGen/annotations-global.c
  clang/test/CodeGen/annotations-loc.c
  clang/test/CodeGen/annotations-var.c
  clang/test/CodeGenCXX/attr-annotate.cpp
  clang/test/Misc/pragma-attribute-cxx.cpp
  clang/test/Misc/pragma-attribute-objc.m
  clang/test/Parser/access-spec-attrs.cpp
  clang/test/Parser/objc-implementation-attrs.m
  clang/test/Sema/annotate.c
  clang/test/Sema/pragma-attribute.c
  clang/test/SemaCXX/attr-annotate.cpp
  llvm/include/llvm/IR/Intrinsics.td
  llvm/test/Analysis/CostModel/X86/free-intrinsics.ll
  llvm/test/Analysis/CostModel/free-intrinsics-datalayout.ll
  llvm/test/Analysis/CostModel/free-intrinsics-no_info.ll
  llvm/test/CodeGen/Generic/ptr-annotate.ll
  llvm/test/Transforms/InstCombine/assume_inevitable.ll

Index: llvm/test/Transforms/InstCombine/assume_inevitable.ll
===
--- llvm/test/Transforms/InstCombine/assume_inevitable.ll
+++ llvm/test/Transforms/InstCombine/assume_inevitable.ll
@@ -15,7 +15,7 @@
 ; CHECK-NEXT:[[DUMMY_EQ:%.*]] = icmp ugt i32 [[LOADRES]], 42
 ; CHECK-NEXT:tail call void @llvm.assume(i1 [[DUMMY_EQ]])
 ; CHECK-NEXT:[[M_I8:%.*]] = bitcast i64* [[M]] to i8*
-; CHECK-NEXT:[[M_A:%.*]] = call i8* @llvm.ptr.annotation.p0i8(i8* nonnull [[M_I8]], i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str1, i64 0, i64 0), i32 2)
+; CHECK-NEXT:[[M_A:%.*]] = call i8* @llvm.ptr.annotation.p0i8(i8* nonnull [[M_I8]], i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str1, i64 0, i64 0), i32 2, i8* null)
 ; CHECK-NEXT:[[M_X:%.*]] = bitcast i8* [[M_A]] to i64*
 ; CHECK-NEXT:[[OBJSZ:%.*]] = call i64 @llvm.objectsize.i64.p0i8(i8* [[C:%.*]], i1 false, i1 false, i1 false)
 ; CHECK-NEXT:store i64 [[OBJSZ]], i64* [[M_X]], align 4
@@ -44,7 +44,7 @@
   call void @llvm.lifetime.end.p0i8(i64 1, i8* %dummy)
 
   %m_i8 = bitcast i64* %m to i8*
-  %m_a = call i8* @llvm.ptr.annotation.p0i8(i8* %m_i8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str1, i32 0, i32 0), i32 2)
+  %m_a = call i8* @llvm.ptr.annotation.p0i8(i8* %m_i8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str1, i32 0, i32 0), i32 2, i8* null)
   %m_x = bitcast i8* %m_a to i64*
   %objsz = call i64 @llvm.objectsize.i64.p0i8(i8* %c, i1 false)
   store i64 %objsz, i64* %m_x
@@ -64,7 +64,7 @@
 
 declare i64 @llvm.objectsize.i64.p0i8(i8*, i1)
 declare i32 @llvm.annotation.i32(i32, i8*, i8*, i32)
-declare i8* @llvm.ptr.annotation.p0i8(i8*, i8*, i8*, i32)
+declare i8* @llvm.ptr.annotation.p0i8(i8*, i8*, i8*, i32, i8*)
 
 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture)
 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture)
Index: llvm/test/CodeGen/Generic/ptr-annotate.ll
===
--- llvm/test/CodeGen/Generic/ptr-annotate.ll
+++ llvm/test/CodeGen/Generic/ptr-annotate.ll
@@ -10,9 +10,9 @@
 define void @foo() {
 entry:
   %m = alloca i8, align 4
-  %0 = call i8* @llvm.ptr.annotation.p0i8(i8* %m, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str1, i32 0, i32 0), i32 2)
+  %0 = call i8* @llvm.ptr.annotation.p0i8(i8* %m, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str1, i32 0, i32 0), i32 2, i8* null)
   store i8 1, i8* %0, align 4
   ret void
 }
 
-declare i8* @llvm.ptr.annotation.p0i8(i8*, i8*, i8*, i32) #1
+declare i8* @llvm.ptr.annotation.p0i8(i8*, i8*, i8*, i32, i8*) #1
Index: llvm/test/Analysis/CostModel/free-intrinsics-no_info.ll
===
--- llvm/test/Analysis/CostModel/free-intrinsics-no_info.ll
+++ llvm/test/Analysis/CostModel/free-intrinsics-no_info.ll
@@ -15,8 +15,8 @@
 ; CHECK-SIZE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: call void @llvm.lifetime.start.p0i8(i64 1, i8* undef)

[PATCH] D87449: [clang-tidy] Add new check for SEI CERT rule SIG30-C

2020-10-09 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: clang-tools-extra/clang-tidy/cert/SignalHandlerCheck.cpp:117-118
+FunctionCallCollector Collector{[&CalledFunctions](const CallExpr *CE) {
+  if (isa(CE->getCalleeDecl()))
+CalledFunctions.push_back(CE);
+}};

aaron.ballman wrote:
> aaron.ballman wrote:
> > balazske wrote:
> > > aaron.ballman wrote:
> > > > For correctness, I think you need to handle more than just calls to 
> > > > function declarations -- for instance, this should be just as 
> > > > problematic:
> > > > ```
> > > > void some_signal_handler(int sig) {
> > > >   []{ puts("this should not be an escape hatch for the check); }();
> > > > }
> > > > ```
> > > > even though the call expression in the signal handler doesn't resolve 
> > > > back to a function declaration. (Similar for blocks instead of 
> > > > lambdas.) WDYT?
> > > I do not know how many other cases could be there. Probably this can be 
> > > left for future  improvement, the checker is mainly usable for C code 
> > > then. There is a `clang::CallGraph` functionality that could be used 
> > > instead of `FunctionCallCollector` but the `CallExpr` for the calls is 
> > > not provided by it so it does not work for this case. Maybe there is 
> > > other similar functionality that is usable?
> > Given that we want it in the CERT module, we should try to ensure it 
> > follows the rule as closely as we can. I went and checked what the C++ 
> > rules say about this and... it was interesting to notice that SIG30-C is 
> > not one of the C rules included by reference in C++ 
> > (https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=88046336).
> > 
> > It's not clear to me that this rule was accidentally tagged as 
> > `not-for-cpp` or not, so I'd say it's fine to ignore lambdas for the moment 
> > but we may have some follow-up work if CERT changes the rule to be included 
> > in C++. My recommendation is: make the check a C-only check for now, 
> > document it as such, and I'll ping the folks at CERT to see if this rule 
> > was mistagged or not. WDYT?
> Ah, this rule really is a C-only rule, because 
> https://wiki.sei.cmu.edu/confluence/display/cplusplus/MSC54-CPP.+A+signal+handler+must+be+a+plain+old+function
>  is the C++ rule. So I think the SIG30-C checker should be run in C-only mode 
> and we can ignore the C++isms in it.
> 
> FWIW, we have an ongoing discussion about MSC54-CPP in 
> https://reviews.llvm.org/D33825.
Probably this checker can be merged with the other in D33825. According to 
cppreference (https://en.cppreference.com/w/cpp/utility/program/signal) the 
check for the called functions should be present for C++ too. And the other 
checker should do a similar lookup of called functions as this checker, 
including lambdas and C++ specific things.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87449

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


[PATCH] D89102: [X86] Add HRESET instruction.

2020-10-09 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

Please can you add a mention in the 12.0 release notes?




Comment at: llvm/lib/Target/X86/X86InstrInfo.td:2920
+  def HRESET : Ii8<0xF0, MRM_C0, (outs), (ins i32u8imm:$imm), "hreset\t$imm", 
[]>,
+   Requires<[HasHRESET]>, TAXS;
+

Put this under the WriteSystem SchedRW class? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89102

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


[PATCH] D79388: [clang-format] Fix AlignConsecutive on PP blocks

2020-10-09 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Not to my knowledge, if we are not going to fix it we should probably revert it 
for now


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79388

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


[PATCH] D88300: [OpenCL] Initial patch for OpenCL C 3.0 support

2020-10-09 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

I think it should be ok to proceed with this now.


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

https://reviews.llvm.org/D88300

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


[PATCH] D88413: [clangd] Add a metric for tracking memory usage

2020-10-09 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 297172.
kadircet added a comment.

- Move MemoryTree recording from Trace into MemoryTree as suggested in D88417 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88413

Files:
  clang-tools-extra/clangd/support/MemoryTree.cpp
  clang-tools-extra/clangd/support/MemoryTree.h
  clang-tools-extra/clangd/support/Trace.cpp
  clang-tools-extra/clangd/support/Trace.h
  clang-tools-extra/clangd/unittests/support/MemoryTreeTests.cpp

Index: clang-tools-extra/clangd/unittests/support/MemoryTreeTests.cpp
===
--- clang-tools-extra/clangd/unittests/support/MemoryTreeTests.cpp
+++ clang-tools-extra/clangd/unittests/support/MemoryTreeTests.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "support/MemoryTree.h"
+#include "support/TestTracer.h"
 #include "llvm/Support/Allocator.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -16,6 +17,7 @@
 namespace clangd {
 namespace {
 using testing::Contains;
+using testing::ElementsAre;
 using testing::IsEmpty;
 using testing::UnorderedElementsAre;
 
@@ -73,6 +75,44 @@
 EXPECT_THAT(Detail.children(), Contains(WithNameAndSize("leaf", 1)));
   }
 }
+
+TEST(MemoryTree, Record) {
+  trace::TestTracer Tracer;
+  constexpr llvm::StringLiteral MetricName = "memory_usage";
+  auto AddNodes = [](MemoryTree Root) {
+Root.child("leaf").addUsage(1);
+
+{
+  auto &Detail = Root.detail("detail");
+  Detail.addUsage(1);
+  Detail.child("leaf").addUsage(1);
+  auto &Child = Detail.child("child");
+  Child.addUsage(1);
+  Child.child("leaf").addUsage(1);
+}
+
+{
+  auto &Child = Root.child("child");
+  Child.addUsage(1);
+  Child.child("leaf").addUsage(1);
+}
+return Root;
+  };
+
+  llvm::BumpPtrAllocator Alloc;
+  AddNodes(MemoryTree(&Alloc)).record("root");
+  EXPECT_THAT(Tracer.takeMetric(MetricName, "root"), ElementsAre(7));
+  EXPECT_THAT(Tracer.takeMetric(MetricName, "root.leaf"), ElementsAre(1));
+  EXPECT_THAT(Tracer.takeMetric(MetricName, "root.detail"), ElementsAre(4));
+  EXPECT_THAT(Tracer.takeMetric(MetricName, "root.detail.leaf"),
+  ElementsAre(1));
+  EXPECT_THAT(Tracer.takeMetric(MetricName, "root.detail.child"),
+  ElementsAre(2));
+  EXPECT_THAT(Tracer.takeMetric(MetricName, "root.detail.child.leaf"),
+  ElementsAre(1));
+  EXPECT_THAT(Tracer.takeMetric(MetricName, "root.child"), ElementsAre(2));
+  EXPECT_THAT(Tracer.takeMetric(MetricName, "root.child.leaf"), ElementsAre(1));
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/support/Trace.h
===
--- clang-tools-extra/clangd/support/Trace.h
+++ clang-tools-extra/clangd/support/Trace.h
@@ -68,6 +68,10 @@
   const llvm::StringLiteral LabelName;
 };
 
+/// Convenient helper for collecting memory usage metrics from across multiple
+/// components. Results are recorded under a metric named "memory_usage".
+void recordMemoryUsage(double Value, llvm::StringRef ComponentName);
+
 /// A consumer of trace events and measurements. The events are produced by
 /// Spans and trace::log, the measurements are produced by Metrics::record.
 /// Implementations of this interface must be thread-safe.
Index: clang-tools-extra/clangd/support/Trace.cpp
===
--- clang-tools-extra/clangd/support/Trace.cpp
+++ clang-tools-extra/clangd/support/Trace.cpp
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -326,6 +327,13 @@
 Context EventTracer::beginSpan(llvm::StringRef Name, llvm::json::Object *Args) {
   return Context::current().clone();
 }
+
+void recordMemoryUsage(double Value, llvm::StringRef ComponentName) {
+  static constexpr Metric MemoryUsage("memory_usage", Metric::Value,
+  "component_name");
+
+  MemoryUsage.record(Value, ComponentName);
+}
 } // namespace trace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/support/MemoryTree.h
===
--- clang-tools-extra/clangd/support/MemoryTree.h
+++ clang-tools-extra/clangd/support/MemoryTree.h
@@ -65,6 +65,10 @@
   /// Returns total number of bytes used by this node only.
   size_t self() const { return Size; }
 
+  /// Records total memory usage of each node under "memory_usage" metric.
+  /// Labels are edges on the path joined with ".", starting with \p RootName.
+  void record(std::string RootName) const;
+
 private:
   /// Adds a child with an edge labeled as \p Name. Multiple calls to this
   /// function returns the same node.
Index: clang-tools-extra/clangd/sup

[PATCH] D88417: [clangd] Record memory usages after each notification

2020-10-09 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

> What about something like a 5 minute throttle, but have ClangdLSPServer's 
> constructor set the timestamp to now+1 minute? (Without profiling)

SGTM. Note that this means we can't easily test this in LSP layer anymore. 
(We've got couple of components depending on time, maybe it is time we have a 
"mock" clock?)




Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:182
+Server.Server->profile(MT);
+trace::recordMemoryUsage(MT, "clangd_server");
 return true;

sammccall wrote:
> kadircet wrote:
> > sammccall wrote:
> > > (Sorry, I suspect we discussed this and I forgot)
> > > Is there a reason at this point to put knowledge of the core metric in 
> > > trace:: rather than define it here locally in ClangdLSPServer?
> > > (Sorry, I suspect we discussed this and I forgot)
> > 
> > Not really.
> > 
> > > Is there a reason at this point to put knowledge of the core metric in 
> > > trace:: rather than define it here locally in ClangdLSPServer?
> > 
> > `ClangdLSPServer` didnt feel like the appropriate place for that logic. 
> > Moreover other embedders of ClangdServer could benefit from traversal logic 
> > if it is defined in a lower level than ClangdLSPServer.
> (Sorry, I guess D88413 was really the place for this discussion)
> 
> > ClangdLSPServer didnt feel like the appropriate place for that logic.
> 
> To me, putting this in ClangdLSPServer feels like "this isn't part of the 
> central mission here, it could be split out for coherence/reuse".
> Whereas putting it in support/Trace feels like "this is a layering violation".
> 
> > other embedders of ClangdServer could benefit from traversal logic
> 
> If exporting memorytree->metric with the path as the label is something we 
> want to reuse, that could be a function in MemoryTree.h (taking the metric as 
> parameter) or we can include the generic traversal function you proposed 
> earlier. Even though they're both in Support, layering MemoryTree above 
> Tracer seems more appropriate than the other way around.
> My instinct is this is premature generalization and having a traversal in 
> each embedder is fine, though.
> If exporting memorytree->metric with the path as the label is something we 
> want to reuse, that could be a function in MemoryTree.h (taking the metric as 
> parameter) or we can include the generic traversal function you proposed 
> earlier. Even though they're both in Support, layering MemoryTree above 
> Tracer seems more appropriate than the other way around.

Added a `record` member to MemoryTree in D88413.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88417

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


[PATCH] D88417: [clangd] Record memory usages after each notification

2020-10-09 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 297173.
kadircet marked 2 inline comments as done.
kadircet added a comment.

- Implement periodic profiling


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88417

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/unittests/ClangdTests.cpp

Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -17,6 +17,7 @@
 #include "TestFS.h"
 #include "TestTU.h"
 #include "URI.h"
+#include "support/MemoryTree.h"
 #include "support/Path.h"
 #include "support/Threading.h"
 #include "clang/Config/config.h"
@@ -27,6 +28,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Allocator.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Regex.h"
@@ -48,6 +50,7 @@
 namespace {
 
 using ::testing::AllOf;
+using ::testing::Contains;
 using ::testing::ElementsAre;
 using ::testing::Field;
 using ::testing::Gt;
@@ -1236,6 +1239,21 @@
   EXPECT_FALSE(DiagConsumer.HadDiagsInLastCallback);
 }
 
+TEST(ClangdServer, MemoryUsageTest) {
+  MockFS FS;
+  MockCompilationDatabase CDB;
+  ClangdServer Server(CDB, FS, ClangdServer::optsForTest());
+
+  auto FooCpp = testPath("foo.cpp");
+  Server.addDocument(FooCpp, "");
+  ASSERT_TRUE(Server.blockUntilIdleForTest());
+
+  llvm::BumpPtrAllocator Alloc;
+  MemoryTree MT(&Alloc);
+  Server.profile(MT);
+  ASSERT_TRUE(MT.children().count("tuscheduler"));
+  EXPECT_TRUE(MT.child("tuscheduler").children().count(FooCpp));
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -25,6 +25,7 @@
 #include "refactor/Tweak.h"
 #include "support/Cancellation.h"
 #include "support/Function.h"
+#include "support/MemoryTree.h"
 #include "support/ThreadsafeFS.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "clang/Tooling/Core/Replacement.h"
@@ -340,6 +341,9 @@
   LLVM_NODISCARD bool
   blockUntilIdleForTest(llvm::Optional TimeoutSeconds = 10);
 
+  /// Builds a nested representation of memory used by components.
+  void profile(MemoryTree &MT) const;
+
 private:
   void formatCode(PathRef File, llvm::StringRef Code,
   ArrayRef Ranges,
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -28,6 +28,7 @@
 #include "refactor/Tweak.h"
 #include "support/Logger.h"
 #include "support/Markup.h"
+#include "support/MemoryTree.h"
 #include "support/ThreadsafeFS.h"
 #include "support/Trace.h"
 #include "clang/Format/Format.h"
@@ -824,5 +825,12 @@
   BackgroundIdx->blockUntilIdleForTest(TimeoutSeconds));
 }
 
+void ClangdServer::profile(MemoryTree &MT) const {
+  if (DynamicIdx)
+DynamicIdx->profile(MT.child("dynamic_index"));
+  if (BackgroundIdx)
+BackgroundIdx->profile(MT.child("background_index"));
+  WorkScheduler.profile(MT.child("tuscheduler"));
+}
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/ClangdLSPServer.h
===
--- clang-tools-extra/clangd/ClangdLSPServer.h
+++ clang-tools-extra/clangd/ClangdLSPServer.h
@@ -22,6 +22,7 @@
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/JSON.h"
+#include 
 #include 
 
 namespace clang {
@@ -156,6 +157,13 @@
   /// Sends a "publishDiagnostics" notification to the LSP client.
   void publishDiagnostics(const PublishDiagnosticsParams &);
 
+  /// Profiles resource-usage. No-op if there's no active tracer.
+  void profile(bool Detailed);
+
+  /// Timepoint until which profiling is off. It is used to throttle profiling
+  /// requests.
+  std::chrono::steady_clock::time_point NoProfileBefore;
+
   /// Since initialization of CDBs and ClangdServer is done lazily, the
   /// following context captures the one used while creating ClangdLSPServer and
   /// passes it to above mentioned object instances to make sure they share the
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "ClangdLSPServer.h

[PATCH] D88413: [clangd] Add a metric for tracking memory usage

2020-10-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/support/MemoryTree.h:68
 
+  /// Records total memory usage of each node under "memory_usage" metric.
+  /// Labels are edges on the path joined with ".", starting with \p RootName.

can we make this a non-member function and take the metric to write into as a 
parameter?

Putting this here for reuse seems OK to me but it's not an essential part of 
MemoryTree itself.
In particular I'd like to avoid baking magic metrics into support/.

(I know we have one already for fallback latency recording, but that seems much 
costlier to avoid as there are many callsites. Here we expect... 2?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88413

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


[clang] caf28b0 - [Diagnostics] Diagnose -Wsizeof-array-div for array of pointers

2020-10-09 Thread Dávid Bolvanský via cfe-commits

Author: Dávid Bolvanský
Date: 2020-10-09T12:56:06+02:00
New Revision: caf28b0a1288eb06720acf11d7ad09186b27b74f

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

LOG: [Diagnostics] Diagnose  -Wsizeof-array-div for array of pointers

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

Added: 


Modified: 
clang/lib/Sema/SemaExpr.cpp
clang/test/Sema/div-sizeof-array.cpp
clang/test/Sema/div-sizeof-ptr.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index dd2e8f8c0d25..26271209b78d 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -10036,7 +10036,7 @@ static void DiagnoseDivisionSizeofPointerOrArray(Sema 
&S, Expr *LHS, Expr *RHS,
   QualType RHSTy;
 
   if (RUE->isArgumentType())
-RHSTy = RUE->getArgumentType();
+RHSTy = RUE->getArgumentType().getNonReferenceType();
   else
 RHSTy = RUE->getArgumentExpr()->IgnoreParens()->getType();
 

diff  --git a/clang/test/Sema/div-sizeof-array.cpp 
b/clang/test/Sema/div-sizeof-array.cpp
index 898ff42a7bd4..f4d8c2d2a5fb 100644
--- a/clang/test/Sema/div-sizeof-array.cpp
+++ b/clang/test/Sema/div-sizeof-array.cpp
@@ -46,4 +46,8 @@ void test(void) {
   int array[10];
   int narray = sizeof(array) / sizeof(int &);
   int narray2 = sizeof(array) / sizeof(decltype(array[0]));
+
+  int *arrptrs[10];  // expected-note 
{{array 'arrptrs' declared here}}
+  int len = sizeof(arrptrs) / sizeof(decltype(*arrptrs[0])); // 
expected-warning {{expression does not compute the number of elements in this 
array; element type is 'int *', not 'int'}}
+  // expected-note@-1 {{place parentheses around the 
'sizeof(decltype(*arrptrs[0]))' expression to silence this warning}}
 }

diff  --git a/clang/test/Sema/div-sizeof-ptr.cpp 
b/clang/test/Sema/div-sizeof-ptr.cpp
index abb7bbadf0e4..dcb05ccd0162 100644
--- a/clang/test/Sema/div-sizeof-ptr.cpp
+++ b/clang/test/Sema/div-sizeof-ptr.cpp
@@ -7,7 +7,7 @@ int f(Ty (&Array)[N]) {
 
 typedef int int32;
 
-void test(int *p, int **q) {  // expected-note 5 {{pointer 'p' 
declared here}}
+void test(int *p, int **q) {  // expected-note 6 {{pointer 'p' 
declared here}}
   const int *r;   // expected-note {{pointer 'r' declared 
here}}
   int a1 = sizeof(p) / sizeof(*p);// expected-warning {{'sizeof (p)' will 
return the size of the pointer, not the array itself}}
   int a2 = sizeof p / sizeof *p;  // expected-warning {{'sizeof p' will 
return the size of the pointer, not the array itself}}
@@ -21,6 +21,7 @@ void test(int *p, int **q) {  // expected-note 5 
{{pointer 'p' declared
   int a8 = sizeof(d) / sizeof(int);  // expected-warning {{'sizeof (d)' will 
return the size of the pointer, not the array itself}}
 
   int a9 = sizeof(*q) / sizeof(**q); // expected-warning {{'sizeof (*q)' will 
return the size of the pointer, not the array itself}}
+  int a10 = sizeof(p) / sizeof(decltype(*p)); // expected-warning {{'sizeof 
(p)' will return the size of the pointer, not the array itself}}
 
   // Should not warn
   int b1 = sizeof(int *) / sizeof(int);



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


[PATCH] D87990: [Diagnostics] Diagnose -Wsizeof-array-div for array of pointers

2020-10-09 Thread Dávid Bolvanský via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcaf28b0a1288: [Diagnostics] Diagnose  -Wsizeof-array-div for 
array of pointers (authored by xbolva00).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87990

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/div-sizeof-array.cpp
  clang/test/Sema/div-sizeof-ptr.cpp


Index: clang/test/Sema/div-sizeof-ptr.cpp
===
--- clang/test/Sema/div-sizeof-ptr.cpp
+++ clang/test/Sema/div-sizeof-ptr.cpp
@@ -7,7 +7,7 @@
 
 typedef int int32;
 
-void test(int *p, int **q) {  // expected-note 5 {{pointer 'p' 
declared here}}
+void test(int *p, int **q) {  // expected-note 6 {{pointer 'p' 
declared here}}
   const int *r;   // expected-note {{pointer 'r' declared 
here}}
   int a1 = sizeof(p) / sizeof(*p);// expected-warning {{'sizeof (p)' will 
return the size of the pointer, not the array itself}}
   int a2 = sizeof p / sizeof *p;  // expected-warning {{'sizeof p' will 
return the size of the pointer, not the array itself}}
@@ -21,6 +21,7 @@
   int a8 = sizeof(d) / sizeof(int);  // expected-warning {{'sizeof (d)' will 
return the size of the pointer, not the array itself}}
 
   int a9 = sizeof(*q) / sizeof(**q); // expected-warning {{'sizeof (*q)' will 
return the size of the pointer, not the array itself}}
+  int a10 = sizeof(p) / sizeof(decltype(*p)); // expected-warning {{'sizeof 
(p)' will return the size of the pointer, not the array itself}}
 
   // Should not warn
   int b1 = sizeof(int *) / sizeof(int);
Index: clang/test/Sema/div-sizeof-array.cpp
===
--- clang/test/Sema/div-sizeof-array.cpp
+++ clang/test/Sema/div-sizeof-array.cpp
@@ -46,4 +46,8 @@
   int array[10];
   int narray = sizeof(array) / sizeof(int &);
   int narray2 = sizeof(array) / sizeof(decltype(array[0]));
+
+  int *arrptrs[10];  // expected-note 
{{array 'arrptrs' declared here}}
+  int len = sizeof(arrptrs) / sizeof(decltype(*arrptrs[0])); // 
expected-warning {{expression does not compute the number of elements in this 
array; element type is 'int *', not 'int'}}
+  // expected-note@-1 {{place parentheses around the 
'sizeof(decltype(*arrptrs[0]))' expression to silence this warning}}
 }
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -10036,7 +10036,7 @@
   QualType RHSTy;
 
   if (RUE->isArgumentType())
-RHSTy = RUE->getArgumentType();
+RHSTy = RUE->getArgumentType().getNonReferenceType();
   else
 RHSTy = RUE->getArgumentExpr()->IgnoreParens()->getType();
 


Index: clang/test/Sema/div-sizeof-ptr.cpp
===
--- clang/test/Sema/div-sizeof-ptr.cpp
+++ clang/test/Sema/div-sizeof-ptr.cpp
@@ -7,7 +7,7 @@
 
 typedef int int32;
 
-void test(int *p, int **q) {  // expected-note 5 {{pointer 'p' declared here}}
+void test(int *p, int **q) {  // expected-note 6 {{pointer 'p' declared here}}
   const int *r;   // expected-note {{pointer 'r' declared here}}
   int a1 = sizeof(p) / sizeof(*p);// expected-warning {{'sizeof (p)' will return the size of the pointer, not the array itself}}
   int a2 = sizeof p / sizeof *p;  // expected-warning {{'sizeof p' will return the size of the pointer, not the array itself}}
@@ -21,6 +21,7 @@
   int a8 = sizeof(d) / sizeof(int);  // expected-warning {{'sizeof (d)' will return the size of the pointer, not the array itself}}
 
   int a9 = sizeof(*q) / sizeof(**q); // expected-warning {{'sizeof (*q)' will return the size of the pointer, not the array itself}}
+  int a10 = sizeof(p) / sizeof(decltype(*p)); // expected-warning {{'sizeof (p)' will return the size of the pointer, not the array itself}}
 
   // Should not warn
   int b1 = sizeof(int *) / sizeof(int);
Index: clang/test/Sema/div-sizeof-array.cpp
===
--- clang/test/Sema/div-sizeof-array.cpp
+++ clang/test/Sema/div-sizeof-array.cpp
@@ -46,4 +46,8 @@
   int array[10];
   int narray = sizeof(array) / sizeof(int &);
   int narray2 = sizeof(array) / sizeof(decltype(array[0]));
+
+  int *arrptrs[10];  // expected-note {{array 'arrptrs' declared here}}
+  int len = sizeof(arrptrs) / sizeof(decltype(*arrptrs[0])); // expected-warning {{expression does not compute the number of elements in this array; element type is 'int *', not 'int'}}
+  // expected-note@-1 {{place parentheses around the 'sizeof(

[PATCH] D88417: [clangd] Record memory usages after each notification

2020-10-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:1234
 
+void ClangdLSPServer::profile(bool Detailed) {
+  if (!trace::enabled())

ClangdLSPServer does own things other than ClangdServer (e.g. the CDB), though 
we don't yet profile them.
Does it make sense to split this into ClangdLSPServer::profile (with the usual 
signature, and maybe public?) and ClangdLSPServer::maybeExportMemoryProfile()?



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:1234
 
+void ClangdLSPServer::profile(bool Detailed) {
+  if (!trace::enabled())

sammccall wrote:
> ClangdLSPServer does own things other than ClangdServer (e.g. the CDB), 
> though we don't yet profile them.
> Does it make sense to split this into ClangdLSPServer::profile (with the 
> usual signature, and maybe public?) and 
> ClangdLSPServer::maybeExportMemoryProfile()?
Detailed is always false, drop the parameter? This can't be reused by code 
wanting to e.g. service a code action anyway.



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:1424
+
+  // Delay profiling for a minute, as serious allocations don't happen at
+  // startup.

As written this isn't clearly true or false (what exactly is "startup"?)
Maybe just "Delay first profile until we've finished warming up"?



Comment at: clang-tools-extra/clangd/ClangdLSPServer.h:165
+  /// requests.
+  std::chrono::steady_clock::time_point NoProfileBefore;
+

or NextProfileTime? (to avoid the negation)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88417

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


[PATCH] D88414: [clangd] Introduce memory dumping to FileIndex, FileSymbols and BackgroundIndex

2020-10-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D88414#2320859 , @sammccall wrote:

> In D88414#2319161 , @kadircet wrote:
>
>> In D88414#2317106 , @sammccall 
>> wrote:
>>
>>> Now there's lots of usage (which looks good!) i'm finding it a bit hard to 
>>> keep track of what the tree will look like overall.
>>>
>>> At some point it'd be great to:
>>>  a) bind this to an LSP extension so we can see it in editors
>>
>> i was also thinking about it and couldn't decide between a "custom command" 
>> vs "code action".
>>
>> - the former gives a richer interaction, but requires every editor plugin to 
>> implement support.
>> - the latter is a little bit more restrictive but doesn't require a bunch of 
>> extra work.
>>
>> I am happy to go with the "code action" approach initially. WDYT? (not in 
>> the scope of this patch)
>
> I'm pretty leery about code action because it's not at all context-sensitive 
> (not even per-file).

Another slighty silly reason: because of layering, a code action is going to 
have a hard time getting at `ClangdLSPServer`'s profile (or even 
`ClangdServer`'s).
Whereas a custom method will be implemented at that layer.

(We could work around this in various ways, but I think we'll create a bit of a 
mess)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88414

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


[PATCH] D88300: [OpenCL] Initial patch for OpenCL C 3.0 support

2020-10-09 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added a comment.

Anastasia, Sven, thanks for the review! Anastasia, it seems that I don't have 
write access yet. Would you mind landing this change on behalf of me? Thanks!


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

https://reviews.llvm.org/D88300

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


[PATCH] D88088: [clang] improve accuracy of ExprMutAnalyzer

2020-10-09 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 297187.
JonasToth added a comment.

- [Feature] add elvis operator detection


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88088

Files:
  clang/lib/Analysis/ExprMutationAnalyzer.cpp
  clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp

Index: clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
+#include "clang/AST/TypeLoc.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Tooling/Tooling.h"
@@ -19,9 +20,7 @@
 
 using namespace clang::ast_matchers;
 using ::testing::ElementsAre;
-using ::testing::IsEmpty;
 using ::testing::ResultOf;
-using ::testing::StartsWith;
 using ::testing::Values;
 
 namespace {
@@ -63,12 +62,16 @@
   const auto *const S = selectFirst("stmt", Results);
   SmallVector Chain;
   ExprMutationAnalyzer Analyzer(*S, AST->getASTContext());
+
   for (const auto *E = selectFirst("expr", Results); E != nullptr;) {
 const Stmt *By = Analyzer.findMutation(E);
-std::string buffer;
-llvm::raw_string_ostream stream(buffer);
-By->printPretty(stream, nullptr, AST->getASTContext().getPrintingPolicy());
-Chain.push_back(StringRef(stream.str()).trim().str());
+if (!By)
+  break;
+
+std::string Buffer;
+llvm::raw_string_ostream Stream(Buffer);
+By->printPretty(Stream, nullptr, AST->getASTContext().getPrintingPolicy());
+Chain.emplace_back(StringRef(Stream.str()).trim().str());
 E = dyn_cast(By);
   }
   return Chain;
@@ -111,7 +114,13 @@
 
 class AssignmentTest : public ::testing::TestWithParam {};
 
+// This test is for the most basic and direct modification of a variable,
+// assignment to it (e.g. `x = 10;`).
+// It additionally tests that references to a variable are not only captured
+// directly but expressions that result in the variable are handled, too.
+// This includes the comma operator, parens and the ternary operator.
 TEST_P(AssignmentTest, AssignmentModifies) {
+  // Test the detection of the raw expression modifications.
   {
 const std::string ModExpr = "x " + GetParam() + " 10";
 const auto AST = buildASTFromCode("void f() { int x; " + ModExpr + "; }");
@@ -120,6 +129,7 @@
 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre(ModExpr));
   }
 
+  // Test the detection if the expression is surrounded by parens.
   {
 const std::string ModExpr = "(x) " + GetParam() + " 10";
 const auto AST = buildASTFromCode("void f() { int x; " + ModExpr + "; }");
@@ -127,12 +137,89 @@
 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre(ModExpr));
   }
+
+  // Test the detection if the comma operator yields the expression as result.
+  {
+const std::string ModExpr = "x " + GetParam() + " 10";
+const auto AST = buildASTFromCodeWithArgs(
+"void f() { int x, y; y, " + ModExpr + "; }", {"-Wno-unused-value"});
+const auto Results =
+match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre(ModExpr));
+  }
+
+  // Ensure no detection if the comma operator does not yield the expression as
+  // result.
+  {
+const std::string ModExpr = "y, x, y " + GetParam() + " 10";
+const auto AST = buildASTFromCodeWithArgs(
+"void f() { int x, y; " + ModExpr + "; }", {"-Wno-unused-value"});
+const auto Results =
+match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+EXPECT_FALSE(isMutated(Results, AST.get()));
+  }
+
+  // Test the detection if the a ternary operator can result in the expression.
+  {
+const std::string ModExpr = "(y != 0 ? y : x) " + GetParam() + " 10";
+const auto AST =
+buildASTFromCode("void f() { int y = 0, x; " + ModExpr + "; }");
+const auto Results =
+match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre(ModExpr));
+  }
+
+  // Test the detection if the a ternary operator can result in the expression
+  // through multiple nesting of ternary operators.
+  {
+const std::string ModExpr =
+"(y != 0 ? (y > 5 ? y : x) : (y)) " + GetParam() + " 10";
+const auto AST =
+buildASTFromCode("void f() { int y = 0, x; " + ModExpr + "; }");
+const auto Results =
+match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre(ModExpr));
+  }
+
+  // Test the detection if the a ternary operator c

[PATCH] D88088: [clang] improve accuracy of ExprMutAnalyzer

2020-10-09 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth marked an inline comment as done.
JonasToth added inline comments.



Comment at: clang/lib/Analysis/ExprMutationAnalyzer.cpp:61
+  // below.
+  auto const ConditionalOperator = conditionalOperator(anyOf(
+  hasTrueExpression(ignoringParens(canResolveToExpr(InnerMatcher))),

aaron.ballman wrote:
> Do you also want to handle the binary conditional operator (a GNU extension 
> like `a ? : b`)?
Yup, was a fast improvement. Thanks for pointing that out :+1:



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88088

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


[PATCH] D89046: [AST] Build recovery expression by default for all language.

2020-10-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang/test/CodeGen/builtins-ppc-error.c:51
 void testCTF(int index) {
-  vec_ctf(vsi, index); //expected-error {{argument to 
'__builtin_altivec_vcfsx' must be a constant integer}}
-  vec_ctf(vui, index); //expected-error {{argument to 
'__builtin_altivec_vcfsx' must be a constant integer}}
+  vec_ctf(vsi, index); //expected-error {{argument to 
'__builtin_altivec_vcfsx' must be a constant integer}} expected-error 
{{argument to '__builtin_altivec_vcfux' must be a constant integer}}
+  vec_ctf(vui, index); //expected-error {{argument to 
'__builtin_altivec_vcfsx' must be a constant integer}} expected-error 
{{argument to '__builtin_altivec_vcfux' must be a constant integer}}

hmm, this doesn't exactly look right to me - we know the type of `vsi` so we 
should only be considering the signed case I thought.

However the existing diagnostic for `vui` indicates that it's considering the 
**signed** case, so I guess this is already broken/bad.



Comment at: clang/test/CodeGen/builtins-systemz-zvector-error.c:424
+  vsc = vec_rl_mask(vsc, vuc, idx); // expected-error {{no matching function}} 
\
+// expected-error {{argument to 
'__builtin_s390_verimb' must be a constant integer}} \
+// expected-error {{argument to 
'__builtin_s390_verimh' must be a constant integer}} \

you may want to make these assertions fuzzier and possibly give a count rather 
than repeating them, but I guess the owners of these headers would be best to 
decide



Comment at: clang/test/Index/complete-switch.c:9
 
-// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:4:10 %s | 
FileCheck %s -allow-empty
+// RUN: not %clang_cc1 -fsyntax-only -Xclang -fno-recovery-ast 
-code-completion-at=%s:4:10 %s | FileCheck %s -allow-empty
 // CHECK-NOT: COMPLETION: foo

nit: no need for xclang, this is cc1 already

I guess this is a crash test (and it also doesn't crash with recovery ast)?



Comment at: clang/test/Sema/__try.c:55
+// expected-error{{too few arguments to function call, expected 1, have 
0}} \
+// expected-error{{expected ';' after expression}}
   }

this seems bad, am I missing something?



Comment at: clang/test/Sema/enum.c:104
+  switch (PR7911V); // expected-error {{statement requires expression of 
integer type}} \
+// expected-warning {{switch statement has empty body}} 
expected-note {{put the semicolon on a separate line to silence this warning}}
 }

or just move the semicolon to suppress, pretty sure that's not what's being 
tested here.



Comment at: clang/test/Sema/typo-correction.c:56
+  f(THIS_IS_AN_ERROR,   // expected-error {{use of undeclared identifier 
'THIS_IS_AN_ERROR'}}
+afunction(afunction_)); // expected-error {{use of undeclared identifier 
'afunction_'}}
 }

what's up with this change?
Do we see the LHS is dependent/contains-errors and then give up on correcting 
typos in the RHS?
Should we?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89046

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


[PATCH] D87043: [Analyzer] Fix for dereferece of smart pointer after branching on unknown inner pointer

2020-10-09 Thread Nithin VR via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
vrnithinkumar marked an inline comment as done.
Closed by commit rG0b4fe8086f03: [Analyzer] Fix for dereferece of smart pointer 
after branching on unknown inner… (authored by vrnithinkumar).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87043

Files:
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/test/Analysis/smart-ptr-text-output.cpp
  clang/test/Analysis/smart-ptr.cpp


Index: clang/test/Analysis/smart-ptr.cpp
===
--- clang/test/Analysis/smart-ptr.cpp
+++ clang/test/Analysis/smart-ptr.cpp
@@ -333,7 +333,7 @@
 void drefOnAssignedNullFromMethodPtrValidSmartPtr() {
   std::unique_ptr P(new A());
   P = returnRValRefOfUniquePtr();
-  P->foo(); // No warning. 
+  P->foo(); // No warning.
 }
 
 void derefMoveConstructedWithValidPtr() {
@@ -374,7 +374,7 @@
 
 void derefMoveConstructedWithRValueRefReturn() {
   std::unique_ptr P(functionReturnsRValueRef());
-  P->foo();  // No warning.
+  P->foo(); // No warning.
 }
 
 void derefConditionOnNullPtr() {
@@ -450,3 +450,10 @@
   else
 return *P; // expected-warning {{Dereference of null smart pointer 'P' 
[alpha.cplusplus.SmartPtr]}}
 }
+
+void derefAfterBranchingOnUnknownInnerPtr(std::unique_ptr P) {
+  A *RP = P.get();
+  if (!RP) {
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' 
[alpha.cplusplus.SmartPtr]}}
+  }
+}
Index: clang/test/Analysis/smart-ptr-text-output.cpp
===
--- clang/test/Analysis/smart-ptr-text-output.cpp
+++ clang/test/Analysis/smart-ptr-text-output.cpp
@@ -304,3 +304,12 @@
 // expected-note@-1 {{Division by zero}}
   }
 };
+
+void derefAfterBranchingOnUnknownInnerPtr(std::unique_ptr P) {
+  A *RP = P.get();
+  if (!RP) { // expected-note {{Assuming 'RP' is null}}
+// expected-note@-1 {{Taking true branch}}
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' 
[alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart pointer 'P'}}
+  }
+}
Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -103,7 +103,8 @@
 
 bool isNullSmartPtr(const ProgramStateRef State, const MemRegion *ThisRegion) {
   const auto *InnerPointVal = State->get(ThisRegion);
-  return InnerPointVal && InnerPointVal->isZeroConstant();
+  return InnerPointVal &&
+ !State->assume(InnerPointVal->castAs(), true);
 }
 } // namespace smartptr
 } // namespace ento


Index: clang/test/Analysis/smart-ptr.cpp
===
--- clang/test/Analysis/smart-ptr.cpp
+++ clang/test/Analysis/smart-ptr.cpp
@@ -333,7 +333,7 @@
 void drefOnAssignedNullFromMethodPtrValidSmartPtr() {
   std::unique_ptr P(new A());
   P = returnRValRefOfUniquePtr();
-  P->foo(); // No warning. 
+  P->foo(); // No warning.
 }
 
 void derefMoveConstructedWithValidPtr() {
@@ -374,7 +374,7 @@
 
 void derefMoveConstructedWithRValueRefReturn() {
   std::unique_ptr P(functionReturnsRValueRef());
-  P->foo();  // No warning.
+  P->foo(); // No warning.
 }
 
 void derefConditionOnNullPtr() {
@@ -450,3 +450,10 @@
   else
 return *P; // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
 }
+
+void derefAfterBranchingOnUnknownInnerPtr(std::unique_ptr P) {
+  A *RP = P.get();
+  if (!RP) {
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+  }
+}
Index: clang/test/Analysis/smart-ptr-text-output.cpp
===
--- clang/test/Analysis/smart-ptr-text-output.cpp
+++ clang/test/Analysis/smart-ptr-text-output.cpp
@@ -304,3 +304,12 @@
 // expected-note@-1 {{Division by zero}}
   }
 };
+
+void derefAfterBranchingOnUnknownInnerPtr(std::unique_ptr P) {
+  A *RP = P.get();
+  if (!RP) { // expected-note {{Assuming 'RP' is null}}
+// expected-note@-1 {{Taking true branch}}
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart pointer 'P'}}
+  }
+}
Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -103,7 +103,8 @@
 
 bool isNullSmartPtr(const ProgramStateRef State, const MemRegion *ThisRegion) {
   const auto *InnerPointVal = State->get(ThisRegion);
-  return InnerPointVal && InnerPointVal->isZeroCo

[clang] 0b4fe80 - [Analyzer] Fix for dereferece of smart pointer after branching on unknown inner pointer

2020-10-09 Thread Nithin Vadukkumchery Rajendrakumar via cfe-commits

Author: Nithin Vadukkumchery Rajendrakumar
Date: 2020-10-09T13:42:25+02:00
New Revision: 0b4fe8086f03294907180007e7de98c80a83b0d7

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

LOG: [Analyzer] Fix for dereferece of smart pointer after branching on unknown 
inner pointer

Summary: Enabling warning after dereferece of smart pointer after branching on 
unknown inner pointer.

Reviewers: NoQ, Szelethus, vsavchenko, xazax.hun
Reviewed By: NoQ
Subscribers: martong, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D87043

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
clang/test/Analysis/smart-ptr-text-output.cpp
clang/test/Analysis/smart-ptr.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp 
b/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
index 1ca53590e06c..6ee7bd9252b3 100644
--- a/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -103,7 +103,8 @@ bool isStdSmartPtrCall(const CallEvent &Call) {
 
 bool isNullSmartPtr(const ProgramStateRef State, const MemRegion *ThisRegion) {
   const auto *InnerPointVal = State->get(ThisRegion);
-  return InnerPointVal && InnerPointVal->isZeroConstant();
+  return InnerPointVal &&
+ !State->assume(InnerPointVal->castAs(), true);
 }
 } // namespace smartptr
 } // namespace ento

diff  --git a/clang/test/Analysis/smart-ptr-text-output.cpp 
b/clang/test/Analysis/smart-ptr-text-output.cpp
index 16c1bddc55e1..f8ecf9192c73 100644
--- a/clang/test/Analysis/smart-ptr-text-output.cpp
+++ b/clang/test/Analysis/smart-ptr-text-output.cpp
@@ -304,3 +304,12 @@ struct S {
 // expected-note@-1 {{Division by zero}}
   }
 };
+
+void derefAfterBranchingOnUnknownInnerPtr(std::unique_ptr P) {
+  A *RP = P.get();
+  if (!RP) { // expected-note {{Assuming 'RP' is null}}
+// expected-note@-1 {{Taking true branch}}
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' 
[alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart pointer 'P'}}
+  }
+}

diff  --git a/clang/test/Analysis/smart-ptr.cpp 
b/clang/test/Analysis/smart-ptr.cpp
index 8e8156011eb5..7761ac4cb431 100644
--- a/clang/test/Analysis/smart-ptr.cpp
+++ b/clang/test/Analysis/smart-ptr.cpp
@@ -333,7 +333,7 @@ std::unique_ptr &&returnRValRefOfUniquePtr();
 void drefOnAssignedNullFromMethodPtrValidSmartPtr() {
   std::unique_ptr P(new A());
   P = returnRValRefOfUniquePtr();
-  P->foo(); // No warning. 
+  P->foo(); // No warning.
 }
 
 void derefMoveConstructedWithValidPtr() {
@@ -374,7 +374,7 @@ std::unique_ptr &&functionReturnsRValueRef();
 
 void derefMoveConstructedWithRValueRefReturn() {
   std::unique_ptr P(functionReturnsRValueRef());
-  P->foo();  // No warning.
+  P->foo(); // No warning.
 }
 
 void derefConditionOnNullPtr() {
@@ -450,3 +450,10 @@ int derefConditionOnUnKnownPtr(int *q) {
   else
 return *P; // expected-warning {{Dereference of null smart pointer 'P' 
[alpha.cplusplus.SmartPtr]}}
 }
+
+void derefAfterBranchingOnUnknownInnerPtr(std::unique_ptr P) {
+  A *RP = P.get();
+  if (!RP) {
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' 
[alpha.cplusplus.SmartPtr]}}
+  }
+}



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


[PATCH] D88088: [clang] improve accuracy of ExprMutAnalyzer

2020-10-09 Thread Jonas Toth via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
JonasToth marked an inline comment as done.
Closed by commit rGe517e5cfec90: [clang] improve accuracy of ExprMutAnalyzer 
(authored by JonasToth).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88088

Files:
  clang/lib/Analysis/ExprMutationAnalyzer.cpp
  clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp

Index: clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
+#include "clang/AST/TypeLoc.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Tooling/Tooling.h"
@@ -19,9 +20,7 @@
 
 using namespace clang::ast_matchers;
 using ::testing::ElementsAre;
-using ::testing::IsEmpty;
 using ::testing::ResultOf;
-using ::testing::StartsWith;
 using ::testing::Values;
 
 namespace {
@@ -63,12 +62,16 @@
   const auto *const S = selectFirst("stmt", Results);
   SmallVector Chain;
   ExprMutationAnalyzer Analyzer(*S, AST->getASTContext());
+
   for (const auto *E = selectFirst("expr", Results); E != nullptr;) {
 const Stmt *By = Analyzer.findMutation(E);
-std::string buffer;
-llvm::raw_string_ostream stream(buffer);
-By->printPretty(stream, nullptr, AST->getASTContext().getPrintingPolicy());
-Chain.push_back(StringRef(stream.str()).trim().str());
+if (!By)
+  break;
+
+std::string Buffer;
+llvm::raw_string_ostream Stream(Buffer);
+By->printPretty(Stream, nullptr, AST->getASTContext().getPrintingPolicy());
+Chain.emplace_back(StringRef(Stream.str()).trim().str());
 E = dyn_cast(By);
   }
   return Chain;
@@ -111,7 +114,13 @@
 
 class AssignmentTest : public ::testing::TestWithParam {};
 
+// This test is for the most basic and direct modification of a variable,
+// assignment to it (e.g. `x = 10;`).
+// It additionally tests that references to a variable are not only captured
+// directly but expressions that result in the variable are handled, too.
+// This includes the comma operator, parens and the ternary operator.
 TEST_P(AssignmentTest, AssignmentModifies) {
+  // Test the detection of the raw expression modifications.
   {
 const std::string ModExpr = "x " + GetParam() + " 10";
 const auto AST = buildASTFromCode("void f() { int x; " + ModExpr + "; }");
@@ -120,6 +129,7 @@
 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre(ModExpr));
   }
 
+  // Test the detection if the expression is surrounded by parens.
   {
 const std::string ModExpr = "(x) " + GetParam() + " 10";
 const auto AST = buildASTFromCode("void f() { int x; " + ModExpr + "; }");
@@ -127,12 +137,89 @@
 match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
 EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre(ModExpr));
   }
+
+  // Test the detection if the comma operator yields the expression as result.
+  {
+const std::string ModExpr = "x " + GetParam() + " 10";
+const auto AST = buildASTFromCodeWithArgs(
+"void f() { int x, y; y, " + ModExpr + "; }", {"-Wno-unused-value"});
+const auto Results =
+match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre(ModExpr));
+  }
+
+  // Ensure no detection if the comma operator does not yield the expression as
+  // result.
+  {
+const std::string ModExpr = "y, x, y " + GetParam() + " 10";
+const auto AST = buildASTFromCodeWithArgs(
+"void f() { int x, y; " + ModExpr + "; }", {"-Wno-unused-value"});
+const auto Results =
+match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+EXPECT_FALSE(isMutated(Results, AST.get()));
+  }
+
+  // Test the detection if the a ternary operator can result in the expression.
+  {
+const std::string ModExpr = "(y != 0 ? y : x) " + GetParam() + " 10";
+const auto AST =
+buildASTFromCode("void f() { int y = 0, x; " + ModExpr + "; }");
+const auto Results =
+match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre(ModExpr));
+  }
+
+  // Test the detection if the a ternary operator can result in the expression
+  // through multiple nesting of ternary operators.
+  {
+const std::string ModExpr =
+"(y != 0 ? (y > 5 ? y : x) : (y)) " + GetParam() + " 10";
+const auto AST =
+buildASTFromCode("void f() { int y = 0, x; " + ModExpr + "; }");
+const auto Results =
+match(withEnclosingCompound(declRefTo("

[clang] e517e5c - [clang] improve accuracy of ExprMutAnalyzer

2020-10-09 Thread Jonas Toth via cfe-commits

Author: Jonas Toth
Date: 2020-10-09T13:45:32+02:00
New Revision: e517e5cfec90a00a488ad8df901ab9b903ebb966

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

LOG: [clang] improve accuracy of ExprMutAnalyzer

This patch extracts the ExprMutAnalyzer changes from 
https://reviews.llvm.org/D54943
into its own revision for simpler review and more atomic changes.

The analysis results are improved. Nested expressions (e.g. conditional
operators) are now detected properly. Some edge cases, especially
template induced imprecisions are improved upon.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/lib/Analysis/ExprMutationAnalyzer.cpp
clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp

Removed: 




diff  --git a/clang/lib/Analysis/ExprMutationAnalyzer.cpp 
b/clang/lib/Analysis/ExprMutationAnalyzer.cpp
index 2f80285f17b4..c3da5cc47d78 100644
--- a/clang/lib/Analysis/ExprMutationAnalyzer.cpp
+++ b/clang/lib/Analysis/ExprMutationAnalyzer.cpp
@@ -6,7 +6,10 @@
 //
 
//===--===//
 #include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/OperationKinds.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "llvm/ADT/STLExtras.h"
 
 namespace clang {
@@ -24,11 +27,11 @@ AST_MATCHER_P(CXXForRangeStmt, hasRangeStmt,
   return InnerMatcher.matches(*Range, Finder, Builder);
 }
 
-AST_MATCHER_P(Expr, maybeEvalCommaExpr,
- ast_matchers::internal::Matcher, InnerMatcher) {
-  const Expr* Result = &Node;
+AST_MATCHER_P(Expr, maybeEvalCommaExpr, ast_matchers::internal::Matcher,
+  InnerMatcher) {
+  const Expr *Result = &Node;
   while (const auto *BOComma =
-   dyn_cast_or_null(Result->IgnoreParens())) {
+ dyn_cast_or_null(Result->IgnoreParens())) {
 if (!BOComma->isCommaOp())
   break;
 Result = BOComma->getRHS();
@@ -36,6 +39,55 @@ AST_MATCHER_P(Expr, maybeEvalCommaExpr,
   return InnerMatcher.matches(*Result, Finder, Builder);
 }
 
+AST_MATCHER_P(Expr, canResolveToExpr, ast_matchers::internal::Matcher,
+  InnerMatcher) {
+  auto DerivedToBase = [](const ast_matchers::internal::Matcher &Inner) {
+return implicitCastExpr(anyOf(hasCastKind(CK_DerivedToBase),
+  hasCastKind(CK_UncheckedDerivedToBase)),
+hasSourceExpression(Inner));
+  };
+  auto IgnoreDerivedToBase =
+  [&DerivedToBase](const ast_matchers::internal::Matcher &Inner) {
+return ignoringParens(expr(anyOf(Inner, DerivedToBase(Inner;
+  };
+
+  // The 'ConditionalOperator' matches on ` ?  : `.
+  // This matching must be recursive because `` can be anything resolving
+  // to the `InnerMatcher`, for example another conditional operator.
+  // The edge-case `BaseClass &b =  ? DerivedVar1 : DerivedVar2;`
+  // is handled, too. The implicit cast happens outside of the conditional.
+  // This is matched by `IgnoreDerivedToBase(canResolveToExpr(InnerMatcher))`
+  // below.
+  auto const ConditionalOperator = conditionalOperator(anyOf(
+  hasTrueExpression(ignoringParens(canResolveToExpr(InnerMatcher))),
+  hasFalseExpression(ignoringParens(canResolveToExpr(InnerMatcher);
+  auto const ElvisOperator = binaryConditionalOperator(anyOf(
+  hasTrueExpression(ignoringParens(canResolveToExpr(InnerMatcher))),
+  hasFalseExpression(ignoringParens(canResolveToExpr(InnerMatcher);
+
+  auto const ComplexMatcher = ignoringParens(
+  expr(anyOf(IgnoreDerivedToBase(InnerMatcher),
+ maybeEvalCommaExpr(IgnoreDerivedToBase(InnerMatcher)),
+ IgnoreDerivedToBase(ConditionalOperator),
+ IgnoreDerivedToBase(ElvisOperator;
+
+  return ComplexMatcher.matches(Node, Finder, Builder);
+}
+
+// Similar to 'hasAnyArgument', but does not work because 'InitListExpr' does
+// not have the 'arguments()' method.
+AST_MATCHER_P(InitListExpr, hasAnyInit, ast_matchers::internal::Matcher,
+  InnerMatcher) {
+  for (const Expr *Arg : Node.inits()) {
+ast_matchers::internal::BoundNodesTreeBuilder Result(*Builder);
+if (InnerMatcher.matches(*Arg, Finder, &Result)) {
+  *Builder = std::move(Result);
+  return true;
+}
+  }
+  return false;
+}
+
 const ast_matchers::internal::VariadicDynCastAllOfMatcher
 cxxTypeidExpr;
 
@@ -151,7 +203,7 @@ bool ExprMutationAnalyzer::isUnevaluated(const Expr *Exp) {
  NodeID::value,
  match(
  findAll(
- expr(equalsNode(Exp),
+ expr(canResolveToExpr(equalsNode(Exp)),
   

[PATCH] D89117: Remove old create(MainFile)?IncludeInsertion overloads

2020-10-09 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh created this revision.
alexfh added a reviewer: hokein.
Herald added a project: clang.
alexfh requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89117

Files:
  clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
  clang-tools-extra/clang-tidy/utils/IncludeInserter.h
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp

Index: clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
@@ -95,15 +95,10 @@
 case transformer::EditKind::Range:
   Diag << FixItHint::CreateReplacement(T.Range, T.Replacement);
   break;
-case transformer::EditKind::AddInclude: {
-  StringRef FileName = T.Replacement;
-  bool IsAngled = FileName.startswith("<") && FileName.endswith(">");
-  Diag << Inserter.createMainFileIncludeInsertion(
-  IsAngled ? FileName.substr(1, FileName.size() - 2) : FileName,
-  IsAngled);
+case transformer::EditKind::AddInclude:
+  Diag << Inserter.createMainFileIncludeInsertion(T.Replacement);
   break;
 }
-}
 }
 
 void TransformerClangTidyCheck::storeOptions(
Index: clang-tools-extra/clang-tidy/utils/IncludeInserter.h
===
--- clang-tools-extra/clang-tidy/utils/IncludeInserter.h
+++ clang-tools-extra/clang-tidy/utils/IncludeInserter.h
@@ -66,14 +66,6 @@
   /// class is used.
   void registerPreprocessor(Preprocessor *PP);
 
-  /// Creates a \p Header inclusion directive fixit in the File \p FileID.
-  /// Returns ``llvm::None`` on error or if the inclusion directive already
-  /// exists.
-  /// FIXME: This should be removed once the clients are migrated to the
-  /// overload without the ``IsAngled`` parameter.
-  llvm::Optional
-  createIncludeInsertion(FileID FileID, llvm::StringRef Header, bool IsAngled);
-
   /// Creates a \p Header inclusion directive fixit in the File \p FileID.
   /// When \p Header is enclosed in angle brackets, uses angle brackets in the
   /// inclusion directive, otherwise uses quotes.
@@ -82,18 +74,10 @@
   llvm::Optional createIncludeInsertion(FileID FileID,
llvm::StringRef Header);
 
-  /// Creates a \p Header inclusion directive fixit in the main file.
-  /// Returns``llvm::None`` on error or if the inclusion directive already
-  /// exists.
-  /// FIXME: This should be removed once the clients are migrated to the
-  /// overload without the ``IsAngled`` parameter.
-  llvm::Optional
-  createMainFileIncludeInsertion(llvm::StringRef Header, bool IsAngled);
-
   /// Creates a \p Header inclusion directive fixit in the main file.
   /// When \p Header is enclosed in angle brackets, uses angle brackets in the
   /// inclusion directive, otherwise uses quotes.
-  /// Returns``llvm::None`` on error or if the inclusion directive already
+  /// Returns ``llvm::None`` on error or if the inclusion directive already
   /// exists.
   llvm::Optional
   createMainFileIncludeInsertion(llvm::StringRef Header);
Index: clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
===
--- clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
+++ clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
@@ -67,8 +67,10 @@
 }
 
 llvm::Optional
-IncludeInserter::createIncludeInsertion(FileID FileID, StringRef Header,
-bool IsAngled) {
+IncludeInserter::createIncludeInsertion(FileID FileID, llvm::StringRef Header) {
+  bool IsAngled = Header.consume_front("<");
+  if (IsAngled != Header.consume_back(">"))
+return llvm::None;
   // We assume the same Header will never be included both angled and not
   // angled.
   if (!InsertedHeaders[FileID].insert(Header).second)
@@ -77,22 +79,6 @@
   return getOrCreate(FileID).CreateIncludeInsertion(Header, IsAngled);
 }
 
-llvm::Optional
-IncludeInserter::createIncludeInsertion(FileID FileID, llvm::StringRef Header) {
-  bool IsAngled = Header.consume_front("<");
-  if (IsAngled != Header.consume_back(">"))
-return llvm::None;
-  return createIncludeInsertion(FileID, Header, IsAngled);
-}
-
-llvm::Optional
-IncludeInserter::createMainFileIncludeInsertion(StringRef Header,
-bool IsAngled) {
-  assert(SourceMgr && "SourceMgr shouldn't be null; did you remember to call "
-  "registerPreprocessor()?");
-  return createIncludeInsertion(SourceMgr->getMainFileID(), Header, IsAngled);
-}
-
 llvm::Optional
 IncludeInserter::createMainFileIncludeInsertion(StringRef Header) {
   assert(SourceMgr && "SourceMgr shouldn't be null; did you remember to call "
___
cfe-commits mailing list
cfe-commits@

[PATCH] D88204: [clangd] Drop path suffix mapping for std symbols

2020-10-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Taking another look at the header list, there are a couple of classes of 
symbols beyond c/c++ standard library.

We don't have an alternative database for these. Maybe we should keep the 
mechanism but stop using it for the standard library? What do you think?




Comment at: clang-tools-extra/clangd/index/CanonicalIncludes.h:49
   /// in  need to be mapped individually). Approximately, the following
   /// system headers are handled:
   ///   - C++ standard library e.g. bits/basic_string.h$ -> 

should we update these comments?



Comment at: clang-tools-extra/clangd/index/CanonicalIncludes.h:51
   ///   - C++ standard library e.g. bits/basic_string.h$ -> 
   ///   - Posix library e.g. bits/pthreadtypes.h$ -> 
   ///   - Compiler extensions, e.g. include/avx512bwintrin.h$ -> 

hmm, are we going to regress all of posix?



Comment at: clang-tools-extra/clangd/index/CanonicalIncludes.h:52
   ///   - Posix library e.g. bits/pthreadtypes.h$ -> 
   ///   - Compiler extensions, e.g. include/avx512bwintrin.h$ -> 
   /// The mapping is hardcoded and hand-maintained, so it might not cover all

and builtins, these are actually owned by us so should be portable


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88204

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


Re: [llvm-dev] [cfe-dev] Upcoming upgrade of LLVM buildbot

2020-10-09 Thread Andrzej Warzynski via cfe-commits
I switched one of our workers to the main Buildbot and everything seems 
fine #fingers-crossed. I guess that that was a temporary glitch?


We haven't updated our local Buildbot installations - still on 0.8.5. 
Should we update?


-Andrzej

On 09/10/2020 00:44, Galina Kistanova wrote:

Hi Paula,

This error is fine. The buildbot has tested the worker version. 0.8.x 
apparently does not have that method.
The error gets handled gracefully on the server side. At least it seems 
so so far.


That should not prevent your bot from connecting.

Thanks

Galina

On Thu, Oct 8, 2020 at 2:11 PM Paula Askar > wrote:


Hey Andrzej,

What are you seeing in your buildbot logs? Is it this error?
`twisted.spread.flavors.NoSuchMethod: No such method:
remote_getWorkerInfo`

If so, you might want to try updating your buildbot worker.
I updated llvmlibc's to 2.8.4 and that seemed to solve the connection
problem:

https://github.com/llvm/llvm-project/commit/f60686f35cc89504f3411f49cf16a651a74be6eb

Best,
Paula Askar


On Thu, Oct 8, 2020 at 5:43 AM Andrzej Warzynski via llvm-dev
mailto:llvm-...@lists.llvm.org>> wrote:
 >
 > Our Flang-aarch64 buildbots just won't connect to the main Buildbot
 > master anymore. I switched them to the staging buildbot master
instead
 > and it seems fine for now. Is there anything that we can/should
tweak at
 > our end?
 >
 > http://lab.llvm.org:8014/#/waterfall?tags=flang
 >
 > -Andrzej
 >
 > On 08/10/2020 00:31, Galina Kistanova via cfe-dev wrote:
 > > They are online now -
http://lab.llvm.org:8011/#/waterfall?tags=sanitizer
 > >
 > > AnnotatedCommand has severe design conflict with the new buildbot.
 > > We have changed it to be safe and still do something useful,
but it will
 > > need more love and care.
 > >
 > > Please let me know if you have some spare time to work on porting
 > > AnnotatedCommand.
 > >
 > > Thanks
 > >
 > > Galina
 > >
 > > On Wed, Oct 7, 2020 at 2:57 PM Vitaly Buka
mailto:vitalyb...@google.com>
 > > >>
wrote:
 > >
 > >     It looks like all sanitizer builder are still offline
 > > http://lab.llvm.org:8011/#/builders
 > >
 > >     On Tue, 6 Oct 2020 at 00:34, Galina Kistanova via cfe-commits
 > >     mailto:cfe-commits@lists.llvm.org>
>> wrote:
 > >
 > >         Hello everyone,
 > >
 > >         The staging buildbot was up and running for 6 days now, and
 > >         looks good.
 > >
 > >         Tomorrow at 12:00 PM PDT we will switch the production
buildbot
 > >         to the new version.
 > >
 > >         If you are a bot owner, you do not need to do anything
at this
 > >         point, unless I'll ask you to help.
 > >         The buildbot will go down for a short period of time,
and then a
 > >         new version will come up and will accept connections
from your bots.
 > >
 > >         Please note that the new version has a bit different URL
 > >         structure. You will need to update the bookmarks or
scripts if
 > >         you have stored direct URLs to inside the buldbot.
 > >
 > >         We will be watching the production and staging bots and
will be
 > >         improving zorg for the next week or so.
 > >
 > >         I will need your feedback about blame e-mails delivery, IRC
 > >         reporting issues, and anything you could spot wrong
with the new
 > >         bot. I  hope the transition will go smoothly and we
will handle
 > >         issues quickly if any would come up.
 > >
 > >         After production is good and we have about a week of
running
 > >         history, I'll ask the bot owners to upgrade buildbots
on their
 > >         side. Please do not upgrade your buildbots unless I'll
ask you
 > >         to. We are trying to limit a number of moving parts at this
 > >         stage. We will start accepting change to zorg at this
point.
 > >         Please feel free to talk to me if you will have a special
 > >         situation and if you would absolutely have to make changes.
 > >
 > >         Thanks for your support and help. And please feel free
to ask if
 > >         you have questions.
 > >
 > >         Galina
 > >
 > >
 > >         On Thu, Sep 10, 2020 at 9:35 PM Galina Kistanova
 > >         mailto:gkistan...@gmail.com>
>> wrote:
 > >
 > >             Hello everyone,
 > >
 > >             The buildbot upgrade is entering the phase when the
results
 > >             to become v

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

2020-10-09 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 297197.
JonasToth added a comment.

- update to landed ExprMutAnalyzer changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54943

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.h
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-const-correctness.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-cxx17.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-pointer-as-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-transform-pointer-as-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-transform-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-values.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-values.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-values.cpp
@@ -0,0 +1,957 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-const-correctness %t -- \
+// RUN:   -config="{CheckOptions: [\
+// RUN:   {key: 'cppcoreguidelines-const-correctness.TransformValues', value: 1}, \
+// RUN:   {key: 'cppcoreguidelines-const-correctness.WarnPointersAsValues', value: 0}, \
+// RUN:   {key: 'cppcoreguidelines-const-correctness.TransformPointersAsValues', value: 0}, \
+// RUN:   ]}" --
+
+// --- Provide test samples for primitive builtins -
+// - every 'p_*' variable is a 'potential_const_*' variable
+// - every 'np_*' variable is a 'non_potential_const_*' variable
+
+bool global;
+char np_global = 0; // globals can't be known to be const
+
+namespace foo {
+int scoped;
+float np_scoped = 1; // namespace variables are like globals
+} // namespace foo
+
+// Lambdas should be ignored, because they do not follow the normal variable
+// semantic (e.g. the type is only known to the compiler).
+void lambdas() {
+  auto Lambda = [](int i) { return i < 0; };
+}
+
+void some_function(double, wchar_t);
+
+void some_function(double np_arg0, wchar_t np_arg1) {
+  int p_local0 = 2;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+
+  int np_local0;
+  const int np_local1 = 42;
+
+  unsigned int np_local2 = 3;
+  np_local2 <<= 4;
+
+  int np_local3 = 4;
+  ++np_local3;
+  int np_local4 = 4;
+  np_local4++;
+
+  int np_local5 = 4;
+  --np_local5;
+  int np_local6 = 4;
+  np_local6--;
+}
+
+void nested_scopes() {
+  int p_local0 = 2;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+  int np_local0 = 42;
+
+  {
+int p_local1 = 42;
+// CHECK-MESSAGES: [[@LINE-1]]:5: warning: variable 'p_local1' of type 'int' can be declared 'const'
+np_local0 *= 2;
+  }
+}
+
+void ignore_reference_to_pointers() {
+  int *np_local0 = nullptr;
+  int *&np_local1 = np_local0;
+}
+
+void some_lambda_environment_capture_all_by_reference(double np_arg0) {
+  int np_local0 = 0;
+  int p_local0 = 1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+
+  int np_local2;
+  const int np_local3 = 2;
+
+  // Capturing all variables by reference prohibits making them const.
+  [&]() { ++np_local0; };
+
+  int p_local1 = 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared 'const'
+}
+
+void some_lambda_environment_capture_all_by_value(double np_arg0) {
+  int np_local0 = 0;
+  int p_local0 = 1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+
+  int np_local1;
+  const int np_local2 = 2;
+
+  // Capturing by value has no influence on them.
+  [=]() { (void)p_local0; };
+
+  np_local0 += 10;
+}
+
+void function_inout_pointer(int *inout);
+void function_in_pointer(const int *in);
+
+void some_pointer_taking(int *out) {
+  int np_local0 = 42;
+  const int *const p0_np_local0 = &np_local0;
+  int *const p1_np_local0 = &np_local0;
+
+  int np_local1 = 42;
+  const int *const p0_np_local1 = &np_local1;
+  int *const p1_np_local1 = &np_local1;
+  *p1_np_local0 = 43;
+
+  int np_local2 = 42;
+  function_inout_pointer(&np_local2);
+
+  // Prevents const.
+  int np_local3 = 42;
+  out = &np_local3; // This returns and invalid address, its just about the AST
+
+  int p_local1 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared 'const'
+  const int *const p0_p_loca

[clang-tools-extra] 7530b25 - [clangd] Make the tweak filter a parameter to enumerateTweaks. NFC

2020-10-09 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-10-09T14:11:19+02:00
New Revision: 7530b254e93a18991a86d145eff066fbe88d6164

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

LOG: [clangd] Make the tweak filter a parameter to enumerateTweaks. NFC

(Required for CodeActionContext.only)

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdLSPServer.h
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index e5ea4ccc6b8c..9ed635c88e71 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -1030,7 +1030,15 @@ void ClangdLSPServer::onCodeAction(const 
CodeActionParams &Params,
 return Reply(llvm::json::Array(Commands));
   };
 
-  Server->enumerateTweaks(File.file(), Params.range, 
std::move(ConsumeActions));
+  Server->enumerateTweaks(
+  File.file(), Params.range,
+  [&](const Tweak &T) {
+if (!Opts.TweakFilter(T))
+  return false;
+// FIXME: also consider CodeActionContext.only
+return true;
+  },
+  std::move(ConsumeActions));
 }
 
 void ClangdLSPServer::onCompletion(const CompletionParams &Params,

diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.h 
b/clang-tools-extra/clangd/ClangdLSPServer.h
index e8823d37c55d..a853a4087156 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.h
+++ b/clang-tools-extra/clangd/ClangdLSPServer.h
@@ -50,6 +50,10 @@ class ClangdLSPServer : private ClangdServer::Callbacks {
 /// per-request, but LSP allows limited/no customizations.
 clangd::CodeCompleteOptions CodeComplete;
 clangd::RenameOptions Rename;
+/// Returns true if the tweak should be enabled.
+std::function TweakFilter = [](const Tweak &T) {
+  return !T.hidden(); // only enable non-hidden tweaks.
+};
   };
 
   ClangdLSPServer(Transport &Transp, const ThreadsafeFS &TFS,

diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 68afa49514a9..93e3b10b50d5 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -180,7 +180,7 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase 
&CDB,
   SuggestMissingIncludes(Opts.SuggestMissingIncludes),
   BuildRecoveryAST(Opts.BuildRecoveryAST),
   PreserveRecoveryASTType(Opts.PreserveRecoveryASTType),
-  TweakFilter(Opts.TweakFilter), WorkspaceRoot(Opts.WorkspaceRoot),
+  WorkspaceRoot(Opts.WorkspaceRoot),
   // Pass a callback into `WorkScheduler` to extract symbols from a newly
   // parsed file and rebuild the file index synchronously each time an AST
   // is parsed.
@@ -492,13 +492,15 @@ tweakSelection(const Range &Sel, const InputsAndAST &AST) 
{
   return std::move(Result);
 }
 
-void ClangdServer::enumerateTweaks(PathRef File, Range Sel,
-   Callback> CB) {
+void ClangdServer::enumerateTweaks(
+PathRef File, Range Sel, llvm::unique_function Filter,
+Callback> CB) {
   // Tracks number of times a tweak has been offered.
   static constexpr trace::Metric TweakAvailable(
   "tweak_available", trace::Metric::Counter, "tweak_id");
   auto Action = [File = File.str(), Sel, CB = std::move(CB),
- this](Expected InpAST) mutable {
+ Filter =
+ std::move(Filter)](Expected InpAST) mutable 
{
 if (!InpAST)
   return CB(InpAST.takeError());
 auto Selections = tweakSelection(Sel, *InpAST);
@@ -507,11 +509,11 @@ void ClangdServer::enumerateTweaks(PathRef File, Range 
Sel,
 std::vector Res;
 // Don't allow a tweak to fire more than once across ambiguous selections.
 llvm::DenseSet PreparedTweaks;
-auto Filter = [&](const Tweak &T) {
-  return TweakFilter(T) && !PreparedTweaks.count(T.id());
+auto DeduplicatingFilter = [&](const Tweak &T) {
+  return Filter(T) && !PreparedTweaks.count(T.id());
 };
 for (const auto &Sel : *Selections) {
-  for (auto &T : prepareTweaks(*Sel, Filter)) {
+  for (auto &T : prepareTweaks(*Sel, DeduplicatingFilter)) {
 Res.push_back({T->id(), T->title(), T->kind()});
 PreparedTweaks.insert(T->id());
 TweakAvailable.record(1, T->id());

diff  --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index 7322b71e57ce..efba7ace6489 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -163,11 +163,6 @@ class ClangdServer {
 /// Enable preview of Foldi

[PATCH] D88724: [clangd] Make the tweak filter a parameter to enumerateTweaks. NFC

2020-10-09 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7530b254e93a: [clangd] Make the tweak filter a parameter to 
enumerateTweaks. NFC (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88724

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h

Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -163,11 +163,6 @@
 /// Enable preview of FoldingRanges feature.
 bool FoldingRanges = false;
 
-/// Returns true if the tweak should be enabled.
-std::function TweakFilter = [](const Tweak &T) {
-  return !T.hidden(); // only enable non-hidden tweaks.
-};
-
 explicit operator TUScheduler::Options() const;
   };
   // Sensible default options for use in tests.
@@ -294,7 +289,9 @@
 llvm::StringLiteral Kind;
   };
   /// Enumerate the code tweaks available to the user at a specified point.
+  /// Tweaks where Filter returns false will not be checked or included.
   void enumerateTweaks(PathRef File, Range Sel,
+   llvm::unique_function Filter,
Callback> CB);
 
   /// Apply the code tweak with a specified \p ID.
@@ -382,8 +379,6 @@
   // If true, preserve the type for recovery AST.
   bool PreserveRecoveryASTType = false;
 
-  std::function TweakFilter;
-
   // GUARDED_BY(CachedCompletionFuzzyFindRequestMutex)
   llvm::StringMap>
   CachedCompletionFuzzyFindRequestByFile;
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -180,7 +180,7 @@
   SuggestMissingIncludes(Opts.SuggestMissingIncludes),
   BuildRecoveryAST(Opts.BuildRecoveryAST),
   PreserveRecoveryASTType(Opts.PreserveRecoveryASTType),
-  TweakFilter(Opts.TweakFilter), WorkspaceRoot(Opts.WorkspaceRoot),
+  WorkspaceRoot(Opts.WorkspaceRoot),
   // Pass a callback into `WorkScheduler` to extract symbols from a newly
   // parsed file and rebuild the file index synchronously each time an AST
   // is parsed.
@@ -492,13 +492,15 @@
   return std::move(Result);
 }
 
-void ClangdServer::enumerateTweaks(PathRef File, Range Sel,
-   Callback> CB) {
+void ClangdServer::enumerateTweaks(
+PathRef File, Range Sel, llvm::unique_function Filter,
+Callback> CB) {
   // Tracks number of times a tweak has been offered.
   static constexpr trace::Metric TweakAvailable(
   "tweak_available", trace::Metric::Counter, "tweak_id");
   auto Action = [File = File.str(), Sel, CB = std::move(CB),
- this](Expected InpAST) mutable {
+ Filter =
+ std::move(Filter)](Expected InpAST) mutable {
 if (!InpAST)
   return CB(InpAST.takeError());
 auto Selections = tweakSelection(Sel, *InpAST);
@@ -507,11 +509,11 @@
 std::vector Res;
 // Don't allow a tweak to fire more than once across ambiguous selections.
 llvm::DenseSet PreparedTweaks;
-auto Filter = [&](const Tweak &T) {
-  return TweakFilter(T) && !PreparedTweaks.count(T.id());
+auto DeduplicatingFilter = [&](const Tweak &T) {
+  return Filter(T) && !PreparedTweaks.count(T.id());
 };
 for (const auto &Sel : *Selections) {
-  for (auto &T : prepareTweaks(*Sel, Filter)) {
+  for (auto &T : prepareTweaks(*Sel, DeduplicatingFilter)) {
 Res.push_back({T->id(), T->title(), T->kind()});
 PreparedTweaks.insert(T->id());
 TweakAvailable.record(1, T->id());
Index: clang-tools-extra/clangd/ClangdLSPServer.h
===
--- clang-tools-extra/clangd/ClangdLSPServer.h
+++ clang-tools-extra/clangd/ClangdLSPServer.h
@@ -50,6 +50,10 @@
 /// per-request, but LSP allows limited/no customizations.
 clangd::CodeCompleteOptions CodeComplete;
 clangd::RenameOptions Rename;
+/// Returns true if the tweak should be enabled.
+std::function TweakFilter = [](const Tweak &T) {
+  return !T.hidden(); // only enable non-hidden tweaks.
+};
   };
 
   ClangdLSPServer(Transport &Transp, const ThreadsafeFS &TFS,
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -1030,7 +1030,15 @@
 return Reply(llvm::json::Array(Commands));
   };
 
-  Server->enumerateTweaks(File.file(), Params.range, std::move(ConsumeActions));
+  Server->enumerateTweaks(
+  Fil

[PATCH] D89119: [clangd] Update CC Ranking model to use SymbolCategory::Macro

2020-10-09 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 created this revision.
Herald added subscribers: cfe-commits, kadircet, arphaman.
Herald added a project: clang.
usaxena95 requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

A bug in the dataset generation pipeline captured a
SymbolCategory::Macro as SymbolCategory::Variable.

New dataset was generated and a new model was trained addressing the
above problem.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89119

Files:
  clang-tools-extra/clangd/quality/model/forest.json




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


[clang] 4eb627e - first upstream review

2020-10-09 Thread Ben Dunbobbin via cfe-commits

Author: Ben Dunbobbin
Date: 2020-10-09T13:21:03+01:00
New Revision: 4eb627ed96e3f2f9f24aec8a0654ce5204874bb8

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

LOG: first upstream review

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/Sema/dllimport.c
clang/test/SemaCXX/dllexport.cpp
clang/test/SemaCXX/dllimport.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index c92d906580eb..9a6682e837dd 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -6497,7 +6497,9 @@ static void checkDLLAttributeRedeclaration(Sema &S, 
NamedDecl *OldDecl,
   // special MSVC extension: in the last case, the declaration is treated as if
   // it were marked dllexport.
   bool IsInline = false, IsStaticDataMember = false, IsQualifiedFriend = false;
-  bool IsMicrosoft = S.Context.getTargetInfo().getCXXABI().isMicrosoft();
+  bool IsMicrosoft =
+  S.Context.getTargetInfo().getCXXABI().isMicrosoft() ||
+  S.Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment();
   if (const auto *VD = dyn_cast(NewDecl)) {
 // Ignore static data because out-of-line definitions are diagnosed
 // separately.

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index c07e5f792d14..0ccfb1504636 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -6731,14 +6731,16 @@ DLLExportAttr *Sema::mergeDLLExportAttr(Decl *D,
 
 static void handleDLLAttr(Sema &S, Decl *D, const ParsedAttr &A) {
   if (isa(D) &&
-  S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+  (S.Context.getTargetInfo().getCXXABI().isMicrosoft() ||
+   S.Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment())) {
 S.Diag(A.getRange().getBegin(), diag::warn_attribute_ignored) << A;
 return;
   }
 
   if (const auto *FD = dyn_cast(D)) {
 if (FD->isInlined() && A.getKind() == ParsedAttr::AT_DLLImport &&
-!S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+!(S.Context.getTargetInfo().getCXXABI().isMicrosoft() ||
+  
S.Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment())) {
   // MinGW doesn't allow dllimport on inline functions.
   S.Diag(A.getRange().getBegin(), diag::warn_attribute_ignored_on_inline)
   << A;
@@ -6747,7 +6749,8 @@ static void handleDLLAttr(Sema &S, Decl *D, const 
ParsedAttr &A) {
   }
 
   if (const auto *MD = dyn_cast(D)) {
-if (S.Context.getTargetInfo().getCXXABI().isMicrosoft() &&
+if ((S.Context.getTargetInfo().getCXXABI().isMicrosoft() ||
+ S.Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment()) 
&&
 MD->getParent()->isLambda()) {
   S.Diag(A.getRange().getBegin(), diag::err_attribute_dll_lambda) << A;
   return;

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 1275fc0c95b5..138faa161c4e 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -6060,7 +6060,8 @@ void Sema::checkClassLevelDLLAttribute(CXXRecordDecl 
*Class) {
   Attr *ClassAttr = getDLLAttr(Class);
 
   // MSVC inherits DLL attributes to partial class template specializations.
-  if (Context.getTargetInfo().getCXXABI().isMicrosoft() && !ClassAttr) {
+  if ((Context.getTargetInfo().getCXXABI().isMicrosoft() || 
+   Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment()) && 
!ClassAttr) {
 if (auto *Spec = dyn_cast(Class)) {
   if (Attr *TemplateAttr =
   getDLLAttr(Spec->getSpecializedTemplate()->getTemplatedDecl())) {
@@ -6080,7 +6081,8 @@ void Sema::checkClassLevelDLLAttribute(CXXRecordDecl 
*Class) {
 return;
   }
 
-  if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
+  if ((Context.getTargetInfo().getCXXABI().isMicrosoft() || 
+   Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment()) &&
   !ClassAttr->isInherited()) {
 // Diagnose dll attributes on members of class with dll attribute.
 for (Decl *Member : Class->decls()) {

diff  --git a/clang/test/Sema/dllimport.c b/clang/test/Sema/dllimport.c
index 988a8e33a7ef..66bd2703e648 100644
--- a/clang/test/Sema/dllimport.c
+++ b/clang/test/Sema/dllimport.c
@@ -1,8 +1,10 @@
-// RUN: %clang_cc1 -triple i686-win32 -fsyntax-only -fms-extensions 
-verify -std=c99 -DMS %s
-// RUN: %clang_cc1 -triple x86_64-win32   -fsyntax-only -fms-extensions 
-verify -std=c11 -DMS %s
-// RUN: %clang_cc1 -triple i686-mingw32   -fsyntax-only -fms-extensions 
-verify -std=c11 -DGNU %s
-// RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions 
-verify -std=c99 -DGNU %s
-// RUN: %clang_cc1 -triple aarch64-win32  -

[PATCH] D87279: [clang] Fix handling of physical registers in inline assembly operands.

2020-10-09 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.

This LGTM, but I'm not super well-versed with asm statements to begin with. You 
should wait a bit for other reviewers to weigh in before landing.


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

https://reviews.llvm.org/D87279

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


[clang] a9f1bb9 - Revert "first upstream review"

2020-10-09 Thread Ben Dunbobbin via cfe-commits

Author: Ben Dunbobbin
Date: 2020-10-09T13:22:46+01:00
New Revision: a9f1bb92bfb1efc005b53bf9ea18ad5e902386fc

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

LOG: Revert "first upstream review"

Pushed by accident :(

This reverts commit 4eb627ed96e3f2f9f24aec8a0654ce5204874bb8.

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/Sema/dllimport.c
clang/test/SemaCXX/dllexport.cpp
clang/test/SemaCXX/dllimport.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 9a6682e837dd..c92d906580eb 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -6497,9 +6497,7 @@ static void checkDLLAttributeRedeclaration(Sema &S, 
NamedDecl *OldDecl,
   // special MSVC extension: in the last case, the declaration is treated as if
   // it were marked dllexport.
   bool IsInline = false, IsStaticDataMember = false, IsQualifiedFriend = false;
-  bool IsMicrosoft =
-  S.Context.getTargetInfo().getCXXABI().isMicrosoft() ||
-  S.Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment();
+  bool IsMicrosoft = S.Context.getTargetInfo().getCXXABI().isMicrosoft();
   if (const auto *VD = dyn_cast(NewDecl)) {
 // Ignore static data because out-of-line definitions are diagnosed
 // separately.

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 0ccfb1504636..c07e5f792d14 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -6731,16 +6731,14 @@ DLLExportAttr *Sema::mergeDLLExportAttr(Decl *D,
 
 static void handleDLLAttr(Sema &S, Decl *D, const ParsedAttr &A) {
   if (isa(D) &&
-  (S.Context.getTargetInfo().getCXXABI().isMicrosoft() ||
-   S.Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment())) {
+  S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
 S.Diag(A.getRange().getBegin(), diag::warn_attribute_ignored) << A;
 return;
   }
 
   if (const auto *FD = dyn_cast(D)) {
 if (FD->isInlined() && A.getKind() == ParsedAttr::AT_DLLImport &&
-!(S.Context.getTargetInfo().getCXXABI().isMicrosoft() ||
-  
S.Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment())) {
+!S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
   // MinGW doesn't allow dllimport on inline functions.
   S.Diag(A.getRange().getBegin(), diag::warn_attribute_ignored_on_inline)
   << A;
@@ -6749,8 +6747,7 @@ static void handleDLLAttr(Sema &S, Decl *D, const 
ParsedAttr &A) {
   }
 
   if (const auto *MD = dyn_cast(D)) {
-if ((S.Context.getTargetInfo().getCXXABI().isMicrosoft() ||
- S.Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment()) 
&&
+if (S.Context.getTargetInfo().getCXXABI().isMicrosoft() &&
 MD->getParent()->isLambda()) {
   S.Diag(A.getRange().getBegin(), diag::err_attribute_dll_lambda) << A;
   return;

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 138faa161c4e..1275fc0c95b5 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -6060,8 +6060,7 @@ void Sema::checkClassLevelDLLAttribute(CXXRecordDecl 
*Class) {
   Attr *ClassAttr = getDLLAttr(Class);
 
   // MSVC inherits DLL attributes to partial class template specializations.
-  if ((Context.getTargetInfo().getCXXABI().isMicrosoft() || 
-   Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment()) && 
!ClassAttr) {
+  if (Context.getTargetInfo().getCXXABI().isMicrosoft() && !ClassAttr) {
 if (auto *Spec = dyn_cast(Class)) {
   if (Attr *TemplateAttr =
   getDLLAttr(Spec->getSpecializedTemplate()->getTemplatedDecl())) {
@@ -6081,8 +6080,7 @@ void Sema::checkClassLevelDLLAttribute(CXXRecordDecl 
*Class) {
 return;
   }
 
-  if ((Context.getTargetInfo().getCXXABI().isMicrosoft() || 
-   Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment()) &&
+  if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
   !ClassAttr->isInherited()) {
 // Diagnose dll attributes on members of class with dll attribute.
 for (Decl *Member : Class->decls()) {

diff  --git a/clang/test/Sema/dllimport.c b/clang/test/Sema/dllimport.c
index 66bd2703e648..988a8e33a7ef 100644
--- a/clang/test/Sema/dllimport.c
+++ b/clang/test/Sema/dllimport.c
@@ -1,10 +1,8 @@
-// RUN: %clang_cc1 -triple i686-win32 -fsyntax-only 
-fms-extensions -verify -std=c99 -DMS %s
-// RUN: %clang_cc1 -triple x86_64-win32   -fsyntax-only 
-fms-extensions -verify -std=c11 -DMS %s
-// RUN: %clang_cc1 -triple i686-mingw32   -fsyntax-only 
-fms-extensions -verify -std=c11 -DGNU %s
-// RUN: %clang_cc1 -trip

Re: [clang] 4eb627e - first upstream review

2020-10-09 Thread Roman Lebedev via cfe-commits
On Fri, Oct 9, 2020 at 3:21 PM Ben Dunbobbin via cfe-commits
 wrote:
>
>
> Author: Ben Dunbobbin
> Date: 2020-10-09T13:21:03+01:00
> New Revision: 4eb627ed96e3f2f9f24aec8a0654ce5204874bb8
>
> URL: 
> https://github.com/llvm/llvm-project/commit/4eb627ed96e3f2f9f24aec8a0654ce5204874bb8
> DIFF: 
> https://github.com/llvm/llvm-project/commit/4eb627ed96e3f2f9f24aec8a0654ce5204874bb8.diff
>
> LOG: first upstream review
This is a very much not useful commit message.
If this is not an accidental commit, i suggest reverting and
recommitting with a proper commit.

Roman.

> Added:
>
>
> Modified:
> clang/lib/Sema/SemaDecl.cpp
> clang/lib/Sema/SemaDeclAttr.cpp
> clang/lib/Sema/SemaDeclCXX.cpp
> clang/test/Sema/dllimport.c
> clang/test/SemaCXX/dllexport.cpp
> clang/test/SemaCXX/dllimport.cpp
>
> Removed:
>
>
>
> 
> diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
> index c92d906580eb..9a6682e837dd 100644
> --- a/clang/lib/Sema/SemaDecl.cpp
> +++ b/clang/lib/Sema/SemaDecl.cpp
> @@ -6497,7 +6497,9 @@ static void checkDLLAttributeRedeclaration(Sema &S, 
> NamedDecl *OldDecl,
>// special MSVC extension: in the last case, the declaration is treated as 
> if
>// it were marked dllexport.
>bool IsInline = false, IsStaticDataMember = false, IsQualifiedFriend = 
> false;
> -  bool IsMicrosoft = S.Context.getTargetInfo().getCXXABI().isMicrosoft();
> +  bool IsMicrosoft =
> +  S.Context.getTargetInfo().getCXXABI().isMicrosoft() ||
> +  S.Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment();
>if (const auto *VD = dyn_cast(NewDecl)) {
>  // Ignore static data because out-of-line definitions are diagnosed
>  // separately.
>
> diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp 
> b/clang/lib/Sema/SemaDeclAttr.cpp
> index c07e5f792d14..0ccfb1504636 100644
> --- a/clang/lib/Sema/SemaDeclAttr.cpp
> +++ b/clang/lib/Sema/SemaDeclAttr.cpp
> @@ -6731,14 +6731,16 @@ DLLExportAttr *Sema::mergeDLLExportAttr(Decl *D,
>
>  static void handleDLLAttr(Sema &S, Decl *D, const ParsedAttr &A) {
>if (isa(D) &&
> -  S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
> +  (S.Context.getTargetInfo().getCXXABI().isMicrosoft() ||
> +   S.Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment())) 
> {
>  S.Diag(A.getRange().getBegin(), diag::warn_attribute_ignored) << A;
>  return;
>}
>
>if (const auto *FD = dyn_cast(D)) {
>  if (FD->isInlined() && A.getKind() == ParsedAttr::AT_DLLImport &&
> -!S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
> +!(S.Context.getTargetInfo().getCXXABI().isMicrosoft() ||
> +  
> S.Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment())) {
>// MinGW doesn't allow dllimport on inline functions.
>S.Diag(A.getRange().getBegin(), diag::warn_attribute_ignored_on_inline)
><< A;
> @@ -6747,7 +6749,8 @@ static void handleDLLAttr(Sema &S, Decl *D, const 
> ParsedAttr &A) {
>}
>
>if (const auto *MD = dyn_cast(D)) {
> -if (S.Context.getTargetInfo().getCXXABI().isMicrosoft() &&
> +if ((S.Context.getTargetInfo().getCXXABI().isMicrosoft() ||
> + 
> S.Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment()) &&
>  MD->getParent()->isLambda()) {
>S.Diag(A.getRange().getBegin(), diag::err_attribute_dll_lambda) << A;
>return;
>
> diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
> index 1275fc0c95b5..138faa161c4e 100644
> --- a/clang/lib/Sema/SemaDeclCXX.cpp
> +++ b/clang/lib/Sema/SemaDeclCXX.cpp
> @@ -6060,7 +6060,8 @@ void Sema::checkClassLevelDLLAttribute(CXXRecordDecl 
> *Class) {
>Attr *ClassAttr = getDLLAttr(Class);
>
>// MSVC inherits DLL attributes to partial class template specializations.
> -  if (Context.getTargetInfo().getCXXABI().isMicrosoft() && !ClassAttr) {
> +  if ((Context.getTargetInfo().getCXXABI().isMicrosoft() ||
> +   Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment()) && 
> !ClassAttr) {
>  if (auto *Spec = 
> dyn_cast(Class)) {
>if (Attr *TemplateAttr =
>
> getDLLAttr(Spec->getSpecializedTemplate()->getTemplatedDecl())) {
> @@ -6080,7 +6081,8 @@ void Sema::checkClassLevelDLLAttribute(CXXRecordDecl 
> *Class) {
>  return;
>}
>
> -  if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
> +  if ((Context.getTargetInfo().getCXXABI().isMicrosoft() ||
> +   Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment()) &&
>!ClassAttr->isInherited()) {
>  // Diagnose dll attributes on members of class with dll attribute.
>  for (Decl *Member : Class->decls()) {
>
> diff  --git a/clang/test/Sema/dllimport.c b/clang/test/Sema/dllimport.c
> index 988a8e33a7ef..66bd2703e648 100644
> --- a/clang/test/Sema/dllimport.c
> +++ b/clang/test/Sema/dllimport.c
> @@ -1,8 +1,10 @@
> -// RUN

[PATCH] D87449: [clang-tidy] Add new check for SEI CERT rule SIG30-C

2020-10-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clang-tidy/cert/SignalHandlerCheck.cpp:117-118
+FunctionCallCollector Collector{[&CalledFunctions](const CallExpr *CE) {
+  if (isa(CE->getCalleeDecl()))
+CalledFunctions.push_back(CE);
+}};

balazske wrote:
> aaron.ballman wrote:
> > aaron.ballman wrote:
> > > balazske wrote:
> > > > aaron.ballman wrote:
> > > > > For correctness, I think you need to handle more than just calls to 
> > > > > function declarations -- for instance, this should be just as 
> > > > > problematic:
> > > > > ```
> > > > > void some_signal_handler(int sig) {
> > > > >   []{ puts("this should not be an escape hatch for the check); }();
> > > > > }
> > > > > ```
> > > > > even though the call expression in the signal handler doesn't resolve 
> > > > > back to a function declaration. (Similar for blocks instead of 
> > > > > lambdas.) WDYT?
> > > > I do not know how many other cases could be there. Probably this can be 
> > > > left for future  improvement, the checker is mainly usable for C code 
> > > > then. There is a `clang::CallGraph` functionality that could be used 
> > > > instead of `FunctionCallCollector` but the `CallExpr` for the calls is 
> > > > not provided by it so it does not work for this case. Maybe there is 
> > > > other similar functionality that is usable?
> > > Given that we want it in the CERT module, we should try to ensure it 
> > > follows the rule as closely as we can. I went and checked what the C++ 
> > > rules say about this and... it was interesting to notice that SIG30-C is 
> > > not one of the C rules included by reference in C++ 
> > > (https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=88046336).
> > > 
> > > It's not clear to me that this rule was accidentally tagged as 
> > > `not-for-cpp` or not, so I'd say it's fine to ignore lambdas for the 
> > > moment but we may have some follow-up work if CERT changes the rule to be 
> > > included in C++. My recommendation is: make the check a C-only check for 
> > > now, document it as such, and I'll ping the folks at CERT to see if this 
> > > rule was mistagged or not. WDYT?
> > Ah, this rule really is a C-only rule, because 
> > https://wiki.sei.cmu.edu/confluence/display/cplusplus/MSC54-CPP.+A+signal+handler+must+be+a+plain+old+function
> >  is the C++ rule. So I think the SIG30-C checker should be run in C-only 
> > mode and we can ignore the C++isms in it.
> > 
> > FWIW, we have an ongoing discussion about MSC54-CPP in 
> > https://reviews.llvm.org/D33825.
> Probably this checker can be merged with the other in D33825. According to 
> cppreference (https://en.cppreference.com/w/cpp/utility/program/signal) the 
> check for the called functions should be present for C++ too. And the other 
> checker should do a similar lookup of called functions as this checker, 
> including lambdas and C++ specific things.
While you would think that, it's a bit more complicated unfortunately. The C++ 
committee has been moving forward with this paper http://wg21.link/p0270 so 
that C++ is no longer tied to the same constraints as C. That may suggest that 
separate checks are appropriate, or it may still mean we want to merge the 
checks into one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87449

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


[clang] bb148ad - [windows-itanium] make dllimport/export handling closer to MS behavior

2020-10-09 Thread Ben Dunbobbin via cfe-commits

Author: Ben Dunbobbin
Date: 2020-10-09T13:24:07+01:00
New Revision: bb148ad426f8c7e6a6f968d54796f872685a00b2

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

LOG: [windows-itanium] make dllimport/export handling closer to MS behavior

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

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/Sema/dllimport.c
clang/test/SemaCXX/dllexport.cpp
clang/test/SemaCXX/dllimport.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index c92d906580eb..9a6682e837dd 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -6497,7 +6497,9 @@ static void checkDLLAttributeRedeclaration(Sema &S, 
NamedDecl *OldDecl,
   // special MSVC extension: in the last case, the declaration is treated as if
   // it were marked dllexport.
   bool IsInline = false, IsStaticDataMember = false, IsQualifiedFriend = false;
-  bool IsMicrosoft = S.Context.getTargetInfo().getCXXABI().isMicrosoft();
+  bool IsMicrosoft =
+  S.Context.getTargetInfo().getCXXABI().isMicrosoft() ||
+  S.Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment();
   if (const auto *VD = dyn_cast(NewDecl)) {
 // Ignore static data because out-of-line definitions are diagnosed
 // separately.

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index c07e5f792d14..0ccfb1504636 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -6731,14 +6731,16 @@ DLLExportAttr *Sema::mergeDLLExportAttr(Decl *D,
 
 static void handleDLLAttr(Sema &S, Decl *D, const ParsedAttr &A) {
   if (isa(D) &&
-  S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+  (S.Context.getTargetInfo().getCXXABI().isMicrosoft() ||
+   S.Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment())) {
 S.Diag(A.getRange().getBegin(), diag::warn_attribute_ignored) << A;
 return;
   }
 
   if (const auto *FD = dyn_cast(D)) {
 if (FD->isInlined() && A.getKind() == ParsedAttr::AT_DLLImport &&
-!S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+!(S.Context.getTargetInfo().getCXXABI().isMicrosoft() ||
+  
S.Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment())) {
   // MinGW doesn't allow dllimport on inline functions.
   S.Diag(A.getRange().getBegin(), diag::warn_attribute_ignored_on_inline)
   << A;
@@ -6747,7 +6749,8 @@ static void handleDLLAttr(Sema &S, Decl *D, const 
ParsedAttr &A) {
   }
 
   if (const auto *MD = dyn_cast(D)) {
-if (S.Context.getTargetInfo().getCXXABI().isMicrosoft() &&
+if ((S.Context.getTargetInfo().getCXXABI().isMicrosoft() ||
+ S.Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment()) 
&&
 MD->getParent()->isLambda()) {
   S.Diag(A.getRange().getBegin(), diag::err_attribute_dll_lambda) << A;
   return;

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 1275fc0c95b5..138faa161c4e 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -6060,7 +6060,8 @@ void Sema::checkClassLevelDLLAttribute(CXXRecordDecl 
*Class) {
   Attr *ClassAttr = getDLLAttr(Class);
 
   // MSVC inherits DLL attributes to partial class template specializations.
-  if (Context.getTargetInfo().getCXXABI().isMicrosoft() && !ClassAttr) {
+  if ((Context.getTargetInfo().getCXXABI().isMicrosoft() || 
+   Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment()) && 
!ClassAttr) {
 if (auto *Spec = dyn_cast(Class)) {
   if (Attr *TemplateAttr =
   getDLLAttr(Spec->getSpecializedTemplate()->getTemplatedDecl())) {
@@ -6080,7 +6081,8 @@ void Sema::checkClassLevelDLLAttribute(CXXRecordDecl 
*Class) {
 return;
   }
 
-  if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
+  if ((Context.getTargetInfo().getCXXABI().isMicrosoft() || 
+   Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment()) &&
   !ClassAttr->isInherited()) {
 // Diagnose dll attributes on members of class with dll attribute.
 for (Decl *Member : Class->decls()) {

diff  --git a/clang/test/Sema/dllimport.c b/clang/test/Sema/dllimport.c
index 988a8e33a7ef..66bd2703e648 100644
--- a/clang/test/Sema/dllimport.c
+++ b/clang/test/Sema/dllimport.c
@@ -1,8 +1,10 @@
-// RUN: %clang_cc1 -triple i686-win32 -fsyntax-only -fms-extensions 
-verify -std=c99 -DMS %s
-// RUN: %clang_cc1 -triple x86_64-win32   -fsyntax-only -fms-extensions 
-verify -std=c11 -DMS %s
-// RUN: %clang_cc1 -triple i686-mingw32   -fsyntax-only -fms-extensions 
-verify -std=c11 -DGNU %s
-// RUN: %clang_cc1 -triple x86_64-ming

[PATCH] D86828: [windows-itanium] make dllimport/export handling closer to MS behavior

2020-10-09 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbb148ad426f8: [windows-itanium] make dllimport/export 
handling closer to MS behavior (authored by Ben Dunbobbin 
).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86828

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/Sema/dllimport.c
  clang/test/SemaCXX/dllexport.cpp
  clang/test/SemaCXX/dllimport.cpp

Index: clang/test/SemaCXX/dllimport.cpp
===
--- clang/test/SemaCXX/dllimport.cpp
+++ clang/test/SemaCXX/dllimport.cpp
@@ -1,8 +1,10 @@
-// RUN: %clang_cc1 -triple i686-win32 -fsyntax-only -fms-extensions -verify -std=c++11 -Wunsupported-dll-base-class-template -DMS %s
-// RUN: %clang_cc1 -triple x86_64-win32   -fsyntax-only -fms-extensions -verify -std=c++1y -Wunsupported-dll-base-class-template -DMS %s
-// RUN: %clang_cc1 -triple i686-mingw32   -fsyntax-only -fms-extensions -verify -std=c++1y -Wunsupported-dll-base-class-template -DGNU %s
-// RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions -verify -std=c++11 -Wunsupported-dll-base-class-template -DGNU %s
-// RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions -verify -std=c++17 -Wunsupported-dll-base-class-template -DGNU %s
+// RUN: %clang_cc1 -triple i686-win32 -fsyntax-only -fms-extensions -verify -std=c++11 -Wunsupported-dll-base-class-template -DMS %s
+// RUN: %clang_cc1 -triple x86_64-win32   -fsyntax-only -fms-extensions -verify -std=c++1y -Wunsupported-dll-base-class-template -DMS %s
+// RUN: %clang_cc1 -triple i686-mingw32   -fsyntax-only -fms-extensions -verify -std=c++1y -Wunsupported-dll-base-class-template -DGNU %s
+// RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions -verify -std=c++11 -Wunsupported-dll-base-class-template -DGNU %s
+// RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions -verify -std=c++17 -Wunsupported-dll-base-class-template -DGNU %s
+// RUN: %clang_cc1 -triple i686-windows-itanium   -fsyntax-only -fms-extensions -verify -std=c++11 -Wunsupported-dll-base-class-template -DWI %s
+// RUN: %clang_cc1 -triple x86_64-windows-itanium -fsyntax-only -fms-extensions -verify -std=c++17 -Wunsupported-dll-base-class-template -DWI %s
 
 // Helper structs to make templates more expressive.
 struct ImplicitInst_Imported {};
@@ -55,7 +57,7 @@
 // expected-note@+2{{previous attribute is here}}
 #endif
 __declspec(dllimport) extern int ExternGlobalDeclInit; // expected-note{{previous declaration is here}}
-#ifdef MS
+#if defined(MS) || defined(WI)
 // expected-warning@+4{{'ExternGlobalDeclInit' redeclared without 'dllimport' attribute: 'dllexport' attribute added}}
 #else
 // expected-warning@+2{{'ExternGlobalDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
@@ -66,7 +68,7 @@
 // expected-note@+2{{previous attribute is here}}
 #endif
 __declspec(dllimport) int GlobalDeclInit; // expected-note{{previous declaration is here}}
-#ifdef MS
+#if defined(MS) || defined(WI)
 // expected-warning@+4{{'GlobalDeclInit' redeclared without 'dllimport' attribute: 'dllexport' attribute added}}
 #else
 // expected-warning@+2{{'GlobalDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
@@ -77,7 +79,7 @@
 // expected-note@+2{{previous attribute is here}}
 #endif
 int *__attribute__((dllimport)) GlobalDeclChunkAttrInit; // expected-note{{previous declaration is here}}
-#ifdef MS
+#if defined(MS) || defined(WI)
 // expected-warning@+4{{'GlobalDeclChunkAttrInit' redeclared without 'dllimport' attribute: 'dllexport' attribute added}}
 #else
 // expected-warning@+2{{'GlobalDeclChunkAttrInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
@@ -88,7 +90,7 @@
 // expected-note@+2{{previous attribute is here}}
 #endif
 int GlobalDeclAttrInit __attribute__((dllimport)); // expected-note{{previous declaration is here}}
-#ifdef MS
+#if defined(MS) || defined(WI)
 // expected-warning@+4{{'GlobalDeclAttrInit' redeclared without 'dllimport' attribute: 'dllexport' attribute added}}
 #else
 // expected-warning@+2{{'GlobalDeclAttrInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
@@ -179,7 +181,7 @@
 #endif
 template 
 __declspec(dllimport) extern int ExternVarTmplDeclInit; // expected-note{{previous declaration is here}}
-#ifdef MS
+#if defined(MS) || defined(WI)
 // expected-warning@+5{{'ExternVarTmplDeclInit' redeclared without 'dllimport' attribute: 'dllexport' attribute added}}
 #else
 // expected-warning@+3{{'ExternVarTmplDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
@@ -192,7 +194,7 @@
 #endif
 template 

[PATCH] D89091: Regenerate ClangCommandLineReference.rst

2020-10-09 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb581c5a42f05: Regenerate ClangCommandLineReference.rst 
(authored by kzhuravl).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89091

Files:
  clang/docs/ClangCommandLineReference.rst

Index: clang/docs/ClangCommandLineReference.rst
===
--- clang/docs/ClangCommandLineReference.rst
+++ clang/docs/ClangCommandLineReference.rst
@@ -144,8 +144,6 @@
 
 .. option:: --constant-cfstrings
 
-.. option:: -coverage, --coverage
-
 .. option:: --cuda-compile-host-device
 
 Compile CUDA code for both host and device (default).  Has no effect on non-CUDA compilations.
@@ -178,6 +176,10 @@
 
 Filename (or -) to write dependency output to
 
+.. option:: -dsym-dir
+
+Directory to output dSYM's (if any) to
+
 .. option:: -dumpmachine
 
 .. option:: -dumpversion
@@ -200,6 +202,10 @@
 
 Emit Clang AST files for source inputs
 
+.. option:: --emit-static-lib
+
+Enable linker job to emit a static library.
+
 .. option:: -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
 
 Trivial automatic variable initialization to zero is only here for benchmarks, it'll eventually be removed, and I'm OK with that because I'm only using it to benchmark
@@ -262,6 +268,10 @@
 
 .. option:: -ginline-line-tables, -gno-inline-line-tables
 
+.. option:: --gpu-instrument-lib=
+
+Instrument device library for HIP, which is a LLVM bitcode containing \_\_cyg\_profile\_func\_enter and \_\_cyg\_profile\_func\_exit
+
 .. option:: --gpu-max-threads-per-block=
 
 Default max threads per block for kernel launch bounds for HIP
@@ -280,6 +290,10 @@
 
 Link clang-offload-bundler bundles for HIP
 
+.. option:: --hip-version=
+
+HIP version in the format of major.minor.patch
+
 .. option:: -ibuiltininc
 
 Enable builtin #include directories even when -nostdinc is used before or after -ibuiltininc. Using -nobuiltininc after the option disables it
@@ -310,6 +324,10 @@
 
 Enforce targets of indirect branches and function returns
 
+.. option:: -mharden-sls=
+
+Select straight-line speculation hardening scope
+
 .. option:: --migrate
 
 Run the migrator
@@ -374,8 +392,6 @@
 
 .. option:: -noseglinkedit
 
-.. option:: -nostartfiles
-
 .. option:: -nostdinc, --no-standard-includes
 
 .. program:: clang1
@@ -384,11 +400,7 @@
 
 Disable standard #include directories for the C++ standard library
 
-.. option:: -nostdlib, --no-standard-libraries
-
-.. program:: clang1
 .. option:: -nostdlib++
-.. program:: clang
 
 .. option:: -nostdlibinc
 
@@ -464,7 +476,7 @@
 
 .. option:: --offload-arch=, --cuda-gpu-arch=, --no-offload-arch=
 
-CUDA/HIP offloading device architecture (e.g. sm\_35, gfx906).  May be specified more than once.
+CUDA offloading device architecture (e.g. sm\_35), or HIP offloading target ID in the form of a device architecture followed by target ID features delimited by a colon. Each target ID feature is a pre-defined string followed by a plus or minus sign (e.g. gfx908:xnack+:sram-ecc-).  May be specified more than once.
 
 .. option:: -p, --profile
 
@@ -474,8 +486,6 @@
 
 Enable mcount instrumentation
 
-.. option:: -pie
-
 .. option:: -pipe, --pipe
 
 Use pipes between commands, when possible
@@ -538,8 +548,6 @@
 
 .. option:: -pthreads
 
-.. option:: -rdynamic
-
 .. option:: -read\_only\_relocs 
 
 .. option:: -relocatable-pch, --relocatable-pch
@@ -602,8 +610,6 @@
 
 Serialize compiler diagnostics to a file
 
-.. option:: -shared, --shared
-
 .. option:: -shared-libgcc
 
 .. option:: -shared-libsan, -shared-libasan
@@ -612,10 +618,6 @@
 
 .. option:: -single\_module
 
-.. option:: -specs=, --specs=
-
-.. option:: -static, --static
-
 .. option:: -static-libgcc
 
 .. option:: -static-libsan
@@ -628,8 +630,6 @@
 
 Use the static host OpenMP runtime while linking.
 
-.. option:: -static-pie
-
 .. option:: -std-default=
 
 .. option:: -stdlib=, --stdlib=, --stdlib 
@@ -734,7 +734,7 @@
 
 .. option:: -emit-interface-stubs
 
-Generate Inteface Stub Files.
+Generate Interface Stub Files.
 
 .. option:: -emit-llvm
 
@@ -820,7 +820,7 @@
 
 .. option:: -fexperimental-strict-floating-point
 
-Enables the use of non-default rounding modes and non-default exception handling on targets that are not currently ready.
+Enables experimental strict floating point in LLVM.
 
 .. option:: -ffine-grained-bitfield-accesses, -fno-fine-grained-bitfield-accesses
 
@@ -886,11 +886,11 @@
 
 Generalize pointers in CFI indirect call type signature checks
 
-.. option:: -fsanitize-coverage-allowlist=
+.. option:: -fsanitize-coverage-allowlist=, -fsanitize-coverage-whitelist=
 
 Restrict sanitizer coverage instrumentation exclusively to modules and functions that match the provided special case list, except the blocked ones
 
-.. option:: -fsanitize-covera

[clang] b581c5a - Regenerate ClangCommandLineReference.rst

2020-10-09 Thread Konstantin Zhuravlyov via cfe-commits

Author: Konstantin Zhuravlyov
Date: 2020-10-09T08:29:53-04:00
New Revision: b581c5a42f052d4d02f1152d0e1ff2d54668e6a0

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

LOG: Regenerate ClangCommandLineReference.rst

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

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 135495668e2d..10e0203ce241 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -144,8 +144,6 @@ Specifies configuration file
 
 .. option:: --constant-cfstrings
 
-.. option:: -coverage, --coverage
-
 .. option:: --cuda-compile-host-device
 
 Compile CUDA code for both host and device (default).  Has no effect on 
non-CUDA compilations.
@@ -178,6 +176,10 @@ Filename to write DOT-formatted header dependencies to
 
 Filename (or -) to write dependency output to
 
+.. option:: -dsym-dir
+
+Directory to output dSYM's (if any) to
+
 .. option:: -dumpmachine
 
 .. option:: -dumpversion
@@ -200,6 +202,10 @@ Filename (or -) to write dependency output to
 
 Emit Clang AST files for source inputs
 
+.. option:: --emit-static-lib
+
+Enable linker job to emit a static library.
+
 .. option:: 
-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
 
 Trivial automatic variable initialization to zero is only here for benchmarks, 
it'll eventually be removed, and I'm OK with that because I'm only using it to 
benchmark
@@ -262,6 +268,10 @@ Emit type record hashes in a .debug$H section
 
 .. option:: -ginline-line-tables, -gno-inline-line-tables
 
+.. option:: --gpu-instrument-lib=
+
+Instrument device library for HIP, which is a LLVM bitcode containing 
\_\_cyg\_profile\_func\_enter and \_\_cyg\_profile\_func\_exit
+
 .. option:: --gpu-max-threads-per-block=
 
 Default max threads per block for kernel launch bounds for HIP
@@ -280,6 +290,10 @@ Display help for hidden options
 
 Link clang-offload-bundler bundles for HIP
 
+.. option:: --hip-version=
+
+HIP version in the format of major.minor.patch
+
 .. option:: -ibuiltininc
 
 Enable builtin #include directories even when -nostdinc is used before or 
after -ibuiltininc. Using -nobuiltininc after the option disables it
@@ -310,6 +324,10 @@ Make the next included directory (-I or -F) an indexer 
header map
 
 Enforce targets of indirect branches and function returns
 
+.. option:: -mharden-sls=
+
+Select straight-line speculation hardening scope
+
 .. option:: --migrate
 
 Run the migrator
@@ -374,8 +392,6 @@ Do not link device library for CUDA/HIP device compilation
 
 .. option:: -noseglinkedit
 
-.. option:: -nostartfiles
-
 .. option:: -nostdinc, --no-standard-includes
 
 .. program:: clang1
@@ -384,11 +400,7 @@ Do not link device library for CUDA/HIP device compilation
 
 Disable standard #include directories for the C++ standard library
 
-.. option:: -nostdlib, --no-standard-libraries
-
-.. program:: clang1
 .. option:: -nostdlib++
-.. program:: clang
 
 .. option:: -nostdlibinc
 
@@ -464,7 +476,7 @@ Only modify files with a filename contained in the provided 
directory path
 
 .. option:: --offload-arch=, --cuda-gpu-arch=, 
--no-offload-arch=
 
-CUDA/HIP offloading device architecture (e.g. sm\_35, gfx906).  May be 
specified more than once.
+CUDA offloading device architecture (e.g. sm\_35), or HIP offloading target ID 
in the form of a device architecture followed by target ID features delimited 
by a colon. Each target ID feature is a pre-defined string followed by a plus 
or minus sign (e.g. gfx908:xnack+:sram-ecc-).  May be specified more than once.
 
 .. option:: -p, --profile
 
@@ -474,8 +486,6 @@ CUDA/HIP offloading device architecture (e.g. sm\_35, 
gfx906).  May be specified
 
 Enable mcount instrumentation
 
-.. option:: -pie
-
 .. option:: -pipe, --pipe
 
 Use pipes between commands, when possible
@@ -538,8 +548,6 @@ Support POSIX threads in generated code
 
 .. option:: -pthreads
 
-.. option:: -rdynamic
-
 .. option:: -read\_only\_relocs 
 
 .. option:: -relocatable-pch, --relocatable-pch
@@ -602,8 +610,6 @@ Save intermediate compilation results.
 
 Serialize compiler diagnostics to a file
 
-.. option:: -shared, --shared
-
 .. option:: -shared-libgcc
 
 .. option:: -shared-libsan, -shared-libasan
@@ -612,10 +618,6 @@ Dynamically link the sanitizer runtime
 
 .. option:: -single\_module
 
-.. option:: -specs=, --specs=
-
-.. option:: -static, --static
-
 .. option:: -static-libgcc
 
 .. option:: -static-libsan
@@ -628,8 +630,6 @@ Statically link the sanitizer runtime
 
 Use the static host OpenMP runtime while linking.
 
-.. option:: -static-pie
-
 .. option:: -std-default=
 
 .. option:: -stdlib=, --stdlib=,

[PATCH] D79388: [clang-format] Fix AlignConsecutive on PP blocks

2020-10-09 Thread Andi via Phabricator via cfe-commits
Abpostelnicu added a comment.

In D79388#2321231 , @MyDeveloperDay 
wrote:

> Not to my knowledge, if we are not going to fix it we should probably revert 
> it for now, we can bring it back later

I'm a strong supporter of reverting it for the moment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79388

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


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

2020-10-09 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth marked 2 inline comments as done.
JonasToth added inline comments.



Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt:37
+  clangLex
+  clangSerialization
   clangTidy

aaron.ballman wrote:
> Why do serialization and lex need to be pulled in?
Thats a good question 🤔 
Probably old artifact from where everything was done here.
Removed everything except analysis



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.cpp:46
+
+void ConstCorrectnessCheck::registerMatchers(MatchFinder *Finder) {
+  const auto ConstType = hasType(isConstQualified());

aaron.ballman wrote:
> Should this check only fire in C++? I'm sort of on the fence. It's a C++ core 
> guideline, so it stands to reason it should be disabled for C code. But 
> const-correctness is a thing in C too. WDYT?
I do not know all the subtle differences between C and C++ here. Judging from 
this: https://stackoverflow.com/questions/5248571/is-there-const-in-c the 
current form would not be correct for C for pointers.
The assumptions of this check and especially the transformations are done for 
C++. I dont see a reason why the value-semantic would not apply for both.

Maybe there is a way to make the code compatible for both languages. The 
easiest solution would probably to not do the 'pointer-as-value' 
transformation. This is not that relevant as a feature anyway. I expect not 
nearly as much usage of this option as for the others.

In the end of the day i would like to support both C and C++. Right now it is 
untested and especially the transformation might break the code. It should run 
on both languages though, as there is no language checking.
I will add some real world C code-bases for the transformation testing and see 
what happens :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54943

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


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

2020-10-09 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 297215.
JonasToth marked an inline comment as done.
JonasToth added a comment.

- address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54943

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.h
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-const-correctness.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-cxx17.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-pointer-as-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-transform-pointer-as-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-transform-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-values.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-values.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-values.cpp
@@ -0,0 +1,957 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-const-correctness %t -- \
+// RUN:   -config="{CheckOptions: [\
+// RUN:   {key: 'cppcoreguidelines-const-correctness.TransformValues', value: 1}, \
+// RUN:   {key: 'cppcoreguidelines-const-correctness.WarnPointersAsValues', value: 0}, \
+// RUN:   {key: 'cppcoreguidelines-const-correctness.TransformPointersAsValues', value: 0}, \
+// RUN:   ]}" --
+
+// --- Provide test samples for primitive builtins -
+// - every 'p_*' variable is a 'potential_const_*' variable
+// - every 'np_*' variable is a 'non_potential_const_*' variable
+
+bool global;
+char np_global = 0; // globals can't be known to be const
+
+namespace foo {
+int scoped;
+float np_scoped = 1; // namespace variables are like globals
+} // namespace foo
+
+// Lambdas should be ignored, because they do not follow the normal variable
+// semantic (e.g. the type is only known to the compiler).
+void lambdas() {
+  auto Lambda = [](int i) { return i < 0; };
+}
+
+void some_function(double, wchar_t);
+
+void some_function(double np_arg0, wchar_t np_arg1) {
+  int p_local0 = 2;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+
+  int np_local0;
+  const int np_local1 = 42;
+
+  unsigned int np_local2 = 3;
+  np_local2 <<= 4;
+
+  int np_local3 = 4;
+  ++np_local3;
+  int np_local4 = 4;
+  np_local4++;
+
+  int np_local5 = 4;
+  --np_local5;
+  int np_local6 = 4;
+  np_local6--;
+}
+
+void nested_scopes() {
+  int p_local0 = 2;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+  int np_local0 = 42;
+
+  {
+int p_local1 = 42;
+// CHECK-MESSAGES: [[@LINE-1]]:5: warning: variable 'p_local1' of type 'int' can be declared 'const'
+np_local0 *= 2;
+  }
+}
+
+void ignore_reference_to_pointers() {
+  int *np_local0 = nullptr;
+  int *&np_local1 = np_local0;
+}
+
+void some_lambda_environment_capture_all_by_reference(double np_arg0) {
+  int np_local0 = 0;
+  int p_local0 = 1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+
+  int np_local2;
+  const int np_local3 = 2;
+
+  // Capturing all variables by reference prohibits making them const.
+  [&]() { ++np_local0; };
+
+  int p_local1 = 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared 'const'
+}
+
+void some_lambda_environment_capture_all_by_value(double np_arg0) {
+  int np_local0 = 0;
+  int p_local0 = 1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+
+  int np_local1;
+  const int np_local2 = 2;
+
+  // Capturing by value has no influence on them.
+  [=]() { (void)p_local0; };
+
+  np_local0 += 10;
+}
+
+void function_inout_pointer(int *inout);
+void function_in_pointer(const int *in);
+
+void some_pointer_taking(int *out) {
+  int np_local0 = 42;
+  const int *const p0_np_local0 = &np_local0;
+  int *const p1_np_local0 = &np_local0;
+
+  int np_local1 = 42;
+  const int *const p0_np_local1 = &np_local1;
+  int *const p1_np_local1 = &np_local1;
+  *p1_np_local0 = 43;
+
+  int np_local2 = 42;
+  function_inout_pointer(&np_local2);
+
+  // Prevents const.
+  int np_local3 = 42;
+  out = &np_local3; // This returns and invalid address, its just about the AST
+
+  int p_local1 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared 'const'
+ 

[PATCH] D88979: [InstCombine] combineLoadToOperationType(): don't fold int<->ptr cast into load

2020-10-09 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 297217.
lebedev.ri added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Rebased, NFC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88979

Files:
  clang/test/CodeGen/arm64_32-vaarg.c
  llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
  llvm/test/Transforms/InstCombine/PR30597.ll
  llvm/test/Transforms/InstCombine/intptr1.ll
  llvm/test/Transforms/InstCombine/load-bitcast32.ll
  llvm/test/Transforms/InstCombine/load-bitcast64.ll
  llvm/test/Transforms/InstCombine/memset_chk-1.ll

Index: llvm/test/Transforms/InstCombine/memset_chk-1.ll
===
--- llvm/test/Transforms/InstCombine/memset_chk-1.ll
+++ llvm/test/Transforms/InstCombine/memset_chk-1.ll
@@ -79,10 +79,10 @@
 ; CHECK-NEXT:[[CALL50:%.*]] = call i8* @__memmove_chk(i8* [[B]], i8* [[A]], i64 [[ADD180]], i64 [[YO107]])
 ; CHECK-NEXT:[[STRLEN:%.*]] = call i64 @strlen(i8* nonnull dereferenceable(1) [[B]])
 ; CHECK-NEXT:[[STRCHR1:%.*]] = getelementptr i8, i8* [[B]], i64 [[STRLEN]]
-; CHECK-NEXT:[[TMP0:%.*]] = bitcast i8** [[C:%.*]] to i64*
-; CHECK-NEXT:[[D2:%.*]] = load i64, i64* [[TMP0]], align 8
+; CHECK-NEXT:[[D:%.*]] = load i8*, i8** [[C:%.*]], align 8
+; CHECK-NEXT:[[SUB182:%.*]] = ptrtoint i8* [[D]] to i64
 ; CHECK-NEXT:[[SUB183:%.*]] = ptrtoint i8* [[B]] to i64
-; CHECK-NEXT:[[SUB184:%.*]] = sub i64 [[D2]], [[SUB183]]
+; CHECK-NEXT:[[SUB184:%.*]] = sub i64 [[SUB182]], [[SUB183]]
 ; CHECK-NEXT:[[ADD52_I_I:%.*]] = add nsw i64 [[SUB184]], 1
 ; CHECK-NEXT:call void @llvm.memset.p0i8.i64(i8* align 1 [[STRCHR1]], i8 0, i64 [[ADD52_I_I]], i1 false)
 ; CHECK-NEXT:ret i32 4
Index: llvm/test/Transforms/InstCombine/load-bitcast64.ll
===
--- llvm/test/Transforms/InstCombine/load-bitcast64.ll
+++ llvm/test/Transforms/InstCombine/load-bitcast64.ll
@@ -7,9 +7,10 @@
 define i64* @test1(i8* %x) {
 ; CHECK-LABEL: @test1(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:[[TMP0:%.*]] = bitcast i8* [[X:%.*]] to i64**
-; CHECK-NEXT:[[B1:%.*]] = load i64*, i64** [[TMP0]], align 4
-; CHECK-NEXT:ret i64* [[B1]]
+; CHECK-NEXT:[[A:%.*]] = bitcast i8* [[X:%.*]] to i64*
+; CHECK-NEXT:[[B:%.*]] = load i64, i64* [[A]], align 4
+; CHECK-NEXT:[[C:%.*]] = inttoptr i64 [[B]] to i64*
+; CHECK-NEXT:ret i64* [[C]]
 ;
 entry:
   %a = bitcast i8* %x to i64*
@@ -56,9 +57,10 @@
 define i64 @test4(i8* %x) {
 ; CHECK-LABEL: @test4(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:[[TMP0:%.*]] = bitcast i8* [[X:%.*]] to i64*
-; CHECK-NEXT:[[B1:%.*]] = load i64, i64* [[TMP0]], align 8
-; CHECK-NEXT:ret i64 [[B1]]
+; CHECK-NEXT:[[A:%.*]] = bitcast i8* [[X:%.*]] to i64**
+; CHECK-NEXT:[[B:%.*]] = load i64*, i64** [[A]], align 8
+; CHECK-NEXT:[[C:%.*]] = ptrtoint i64* [[B]] to i64
+; CHECK-NEXT:ret i64 [[C]]
 ;
 entry:
   %a = bitcast i8* %x to i64**
@@ -71,9 +73,10 @@
 define i32 @test5(i8* %x) {
 ; CHECK-LABEL: @test5(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:[[TMP0:%.*]] = bitcast i8* [[X:%.*]] to i64*
-; CHECK-NEXT:[[B1:%.*]] = load i64, i64* [[TMP0]], align 8
-; CHECK-NEXT:[[C:%.*]] = trunc i64 [[B1]] to i32
+; CHECK-NEXT:[[A:%.*]] = bitcast i8* [[X:%.*]] to i32**
+; CHECK-NEXT:[[B:%.*]] = load i32*, i32** [[A]], align 8
+; CHECK-NEXT:[[TMP0:%.*]] = ptrtoint i32* [[B]] to i64
+; CHECK-NEXT:[[C:%.*]] = trunc i64 [[TMP0]] to i32
 ; CHECK-NEXT:ret i32 [[C]]
 ;
 entry:
@@ -87,9 +90,10 @@
 define i64 @test6(i8* %x) {
 ; CHECK-LABEL: @test6(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:[[TMP0:%.*]] = bitcast i8* [[X:%.*]] to i64*
-; CHECK-NEXT:[[B1:%.*]] = load i64, i64* [[TMP0]], align 8
-; CHECK-NEXT:ret i64 [[B1]]
+; CHECK-NEXT:[[A:%.*]] = bitcast i8* [[X:%.*]] to i32**
+; CHECK-NEXT:[[B:%.*]] = load i32*, i32** [[A]], align 8
+; CHECK-NEXT:[[C:%.*]] = ptrtoint i32* [[B]] to i64
+; CHECK-NEXT:ret i64 [[C]]
 ;
 entry:
   %a = bitcast i8* %x to i32**
Index: llvm/test/Transforms/InstCombine/load-bitcast32.ll
===
--- llvm/test/Transforms/InstCombine/load-bitcast32.ll
+++ llvm/test/Transforms/InstCombine/load-bitcast32.ll
@@ -24,9 +24,10 @@
 define i32* @test2(i8* %x) {
 ; CHECK-LABEL: @test2(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:[[TMP0:%.*]] = bitcast i8* [[X:%.*]] to i32**
-; CHECK-NEXT:[[B1:%.*]] = load i32*, i32** [[TMP0]], align 4
-; CHECK-NEXT:ret i32* [[B1]]
+; CHECK-NEXT:[[A:%.*]] = bitcast i8* [[X:%.*]] to i32*
+; CHECK-NEXT:[[B:%.*]] = load i32, i32* [[A]], align 4
+; CHECK-NEXT:[[C:%.*]] = inttoptr i32 [[B]] to i32*
+; CHECK-NEXT:ret i32* [[C]]
 ;
 entry:
   %a = bitcast i8* %x to i32*
@@ -39,9 +40,10 @@
 define i64* @test3(i8* %x) {
 ; CHECK-LABEL: @test3(
 ; CHECK-NEXT: 

[PATCH] D89126: [clangd] Support CodeActionParams.only

2020-10-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kbobyrev.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman.
Herald added a project: clang.
sammccall requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89126

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/code-action-request.test

Index: clang-tools-extra/clangd/test/code-action-request.test
===
--- clang-tools-extra/clangd/test/code-action-request.test
+++ clang-tools-extra/clangd/test/code-action-request.test
@@ -51,6 +51,47 @@
 # CHECK-NEXT:}
 # CHECK-NEXT:  ]
 ---
+{
+  "jsonrpc": "2.0",
+  "id": 2,
+  "method": "textDocument/codeAction",
+  "params": {
+"textDocument": { "uri": "test:///main.cpp" },
+"range": {
+"start": {"line": 0, "character": 0},
+"end": {"line": 0, "character": 4}
+},
+"context": {
+"diagnostics": [],
+"only": ["quickfix"]
+}
+}
+}
+#  CHECK:  "id": 2,
+# CHECK-NEXT:  "jsonrpc": "2.0",
+# CHECK-NEXT:  "result": []
+---
+{
+  "jsonrpc": "2.0",
+  "id": 3,
+  "method": "textDocument/codeAction",
+  "params": {
+"textDocument": { "uri": "test:///main.cpp" },
+"range": {
+"start": {"line": 0, "character": 0},
+"end": {"line": 0, "character": 4}
+},
+"context": {
+"diagnostics": [],
+"only": ["refactor"]
+}
+}
+}
+#  CHECK:  "id": 3,
+# CHECK-NEXT:  "jsonrpc": "2.0",
+# CHECK-NEXT:  "result": [
+# CHECK-NEXT:{
+---
 {"jsonrpc":"2.0","id":4,"method":"workspace/executeCommand","params":{"command":"clangd.applyTweak","arguments":[{"file":"test:///main.cpp","selection":{"end":{"character":4,"line":0},"start":{"character":0,"line":0}},"tweakID":"ExpandAutoType"}]}}
 #  CHECK:"newText": "int",
 # CHECK-NEXT:"range": {
@@ -64,7 +105,7 @@
 # CHECK-NEXT:  }
 # CHECK-NEXT:}
 ---
-{"jsonrpc":"2.0","id":4,"method":"shutdown"}
+{"jsonrpc":"2.0","id":5,"method":"shutdown"}
 ---
 {"jsonrpc":"2.0","method":"exit"}
 ---
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -862,8 +862,19 @@
 llvm::json::Value toJSON(const PublishDiagnosticsParams &);
 
 struct CodeActionContext {
-  /// An array of diagnostics.
+  /// An array of diagnostics known on the client side overlapping the range
+  /// provided to the `textDocument/codeAction` request. They are provided so
+  /// that the server knows which errors are currently presented to the user for
+  /// the given range. There is no guarantee that these accurately reflect the
+  /// error state of the resource. The primary parameter to compute code actions
+  /// is the provided range.
   std::vector diagnostics;
+
+  /// Requested kind of actions to return.
+  ///
+  /// Actions not of this kind are filtered out by the client before being
+  /// shown. So servers can omit computing them.
+  std::vector only;
 };
 bool fromJSON(const llvm::json::Value &, CodeActionContext &, llvm::json::Path);
 
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -600,7 +600,10 @@
 bool fromJSON(const llvm::json::Value &Params, CodeActionContext &R,
   llvm::json::Path P) {
   llvm::json::ObjectMapper O(Params, P);
-  return O && O.map("diagnostics", R.diagnostics);
+  if (!O || !O.map("diagnostics", R.diagnostics))
+return false;
+  O.map("only", R.only);
+  return true;
 }
 
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Diagnostic &D) {
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -984,12 +984,24 @@
   if (!Code)
 return Reply(llvm::make_error(
 "onCodeAction called for non-added file", ErrorCode::InvalidParams));
+
+  // Checks whether a particular CodeActionKind is included in the response.
+  auto KindAllowed = [Only(Params.context.only)](llvm::StringRef Kind) {
+if (Only.empty())
+  return true;
+return llvm::any_of(Only, [&](llvm::StringRef Base) {
+  return Kind.consume_front(Base) && (Kind.empty() || Kind.startswith("."));
+});
+  };
+
   // We provide a code action for Fixes on the specified diagnostics.
   std::vector FixIts;
-  for (const Diagnostic &D : Params.context.diagnostics) {
-for (auto &F : getFixes(File.file(), D)) {
-  FixIts.push_back(toCodeAction(F, Params.te

[PATCH] D89117: Remove old create(MainFile)?IncludeInsertion overloads

2020-10-09 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfe4715c47f9c: Remove old create(MainFile)?IncludeInsertion 
overloads (authored by alexfh).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89117

Files:
  clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
  clang-tools-extra/clang-tidy/utils/IncludeInserter.h
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp

Index: clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
@@ -95,15 +95,10 @@
 case transformer::EditKind::Range:
   Diag << FixItHint::CreateReplacement(T.Range, T.Replacement);
   break;
-case transformer::EditKind::AddInclude: {
-  StringRef FileName = T.Replacement;
-  bool IsAngled = FileName.startswith("<") && FileName.endswith(">");
-  Diag << Inserter.createMainFileIncludeInsertion(
-  IsAngled ? FileName.substr(1, FileName.size() - 2) : FileName,
-  IsAngled);
+case transformer::EditKind::AddInclude:
+  Diag << Inserter.createMainFileIncludeInsertion(T.Replacement);
   break;
 }
-}
 }
 
 void TransformerClangTidyCheck::storeOptions(
Index: clang-tools-extra/clang-tidy/utils/IncludeInserter.h
===
--- clang-tools-extra/clang-tidy/utils/IncludeInserter.h
+++ clang-tools-extra/clang-tidy/utils/IncludeInserter.h
@@ -66,14 +66,6 @@
   /// class is used.
   void registerPreprocessor(Preprocessor *PP);
 
-  /// Creates a \p Header inclusion directive fixit in the File \p FileID.
-  /// Returns ``llvm::None`` on error or if the inclusion directive already
-  /// exists.
-  /// FIXME: This should be removed once the clients are migrated to the
-  /// overload without the ``IsAngled`` parameter.
-  llvm::Optional
-  createIncludeInsertion(FileID FileID, llvm::StringRef Header, bool IsAngled);
-
   /// Creates a \p Header inclusion directive fixit in the File \p FileID.
   /// When \p Header is enclosed in angle brackets, uses angle brackets in the
   /// inclusion directive, otherwise uses quotes.
@@ -82,18 +74,10 @@
   llvm::Optional createIncludeInsertion(FileID FileID,
llvm::StringRef Header);
 
-  /// Creates a \p Header inclusion directive fixit in the main file.
-  /// Returns``llvm::None`` on error or if the inclusion directive already
-  /// exists.
-  /// FIXME: This should be removed once the clients are migrated to the
-  /// overload without the ``IsAngled`` parameter.
-  llvm::Optional
-  createMainFileIncludeInsertion(llvm::StringRef Header, bool IsAngled);
-
   /// Creates a \p Header inclusion directive fixit in the main file.
   /// When \p Header is enclosed in angle brackets, uses angle brackets in the
   /// inclusion directive, otherwise uses quotes.
-  /// Returns``llvm::None`` on error or if the inclusion directive already
+  /// Returns ``llvm::None`` on error or if the inclusion directive already
   /// exists.
   llvm::Optional
   createMainFileIncludeInsertion(llvm::StringRef Header);
Index: clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
===
--- clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
+++ clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
@@ -67,8 +67,10 @@
 }
 
 llvm::Optional
-IncludeInserter::createIncludeInsertion(FileID FileID, StringRef Header,
-bool IsAngled) {
+IncludeInserter::createIncludeInsertion(FileID FileID, llvm::StringRef Header) {
+  bool IsAngled = Header.consume_front("<");
+  if (IsAngled != Header.consume_back(">"))
+return llvm::None;
   // We assume the same Header will never be included both angled and not
   // angled.
   if (!InsertedHeaders[FileID].insert(Header).second)
@@ -77,22 +79,6 @@
   return getOrCreate(FileID).CreateIncludeInsertion(Header, IsAngled);
 }
 
-llvm::Optional
-IncludeInserter::createIncludeInsertion(FileID FileID, llvm::StringRef Header) {
-  bool IsAngled = Header.consume_front("<");
-  if (IsAngled != Header.consume_back(">"))
-return llvm::None;
-  return createIncludeInsertion(FileID, Header, IsAngled);
-}
-
-llvm::Optional
-IncludeInserter::createMainFileIncludeInsertion(StringRef Header,
-bool IsAngled) {
-  assert(SourceMgr && "SourceMgr shouldn't be null; did you remember to call "
-  "registerPreprocessor()?");
-  return createIncludeInsertion(SourceMgr->getMainFileID(), Header, IsAngled);
-}
-
 llvm::Optional
 IncludeInserter::createMainFileIncludeInsertion(StringRef Header) {
   assert(SourceMgr && "SourceMgr shouldn't be nul

[clang-tools-extra] fe4715c - Remove old create(MainFile)?IncludeInsertion overloads

2020-10-09 Thread Alexander Kornienko via cfe-commits

Author: Alexander Kornienko
Date: 2020-10-09T15:24:57+02:00
New Revision: fe4715c47f9c02a83b339c12067f1d27a3115fe4

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

LOG: Remove old create(MainFile)?IncludeInsertion overloads

Reviewed By: hokein

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
clang-tools-extra/clang-tidy/utils/IncludeInserter.h
clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp 
b/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
index fdb93a8f1a81..5fc6020d4265 100644
--- a/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
+++ b/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
@@ -67,8 +67,10 @@ IncludeSorter &IncludeInserter::getOrCreate(FileID FileID) {
 }
 
 llvm::Optional
-IncludeInserter::createIncludeInsertion(FileID FileID, StringRef Header,
-bool IsAngled) {
+IncludeInserter::createIncludeInsertion(FileID FileID, llvm::StringRef Header) 
{
+  bool IsAngled = Header.consume_front("<");
+  if (IsAngled != Header.consume_back(">"))
+return llvm::None;
   // We assume the same Header will never be included both angled and not
   // angled.
   if (!InsertedHeaders[FileID].insert(Header).second)
@@ -77,22 +79,6 @@ IncludeInserter::createIncludeInsertion(FileID FileID, 
StringRef Header,
   return getOrCreate(FileID).CreateIncludeInsertion(Header, IsAngled);
 }
 
-llvm::Optional
-IncludeInserter::createIncludeInsertion(FileID FileID, llvm::StringRef Header) 
{
-  bool IsAngled = Header.consume_front("<");
-  if (IsAngled != Header.consume_back(">"))
-return llvm::None;
-  return createIncludeInsertion(FileID, Header, IsAngled);
-}
-
-llvm::Optional
-IncludeInserter::createMainFileIncludeInsertion(StringRef Header,
-bool IsAngled) {
-  assert(SourceMgr && "SourceMgr shouldn't be null; did you remember to call "
-  "registerPreprocessor()?");
-  return createIncludeInsertion(SourceMgr->getMainFileID(), Header, IsAngled);
-}
-
 llvm::Optional
 IncludeInserter::createMainFileIncludeInsertion(StringRef Header) {
   assert(SourceMgr && "SourceMgr shouldn't be null; did you remember to call "

diff  --git a/clang-tools-extra/clang-tidy/utils/IncludeInserter.h 
b/clang-tools-extra/clang-tidy/utils/IncludeInserter.h
index ba45a1c3fa76..95236c732f13 100644
--- a/clang-tools-extra/clang-tidy/utils/IncludeInserter.h
+++ b/clang-tools-extra/clang-tidy/utils/IncludeInserter.h
@@ -66,14 +66,6 @@ class IncludeInserter {
   /// class is used.
   void registerPreprocessor(Preprocessor *PP);
 
-  /// Creates a \p Header inclusion directive fixit in the File \p FileID.
-  /// Returns ``llvm::None`` on error or if the inclusion directive already
-  /// exists.
-  /// FIXME: This should be removed once the clients are migrated to the
-  /// overload without the ``IsAngled`` parameter.
-  llvm::Optional
-  createIncludeInsertion(FileID FileID, llvm::StringRef Header, bool IsAngled);
-
   /// Creates a \p Header inclusion directive fixit in the File \p FileID.
   /// When \p Header is enclosed in angle brackets, uses angle brackets in the
   /// inclusion directive, otherwise uses quotes.
@@ -82,18 +74,10 @@ class IncludeInserter {
   llvm::Optional createIncludeInsertion(FileID FileID,
llvm::StringRef Header);
 
-  /// Creates a \p Header inclusion directive fixit in the main file.
-  /// Returns``llvm::None`` on error or if the inclusion directive already
-  /// exists.
-  /// FIXME: This should be removed once the clients are migrated to the
-  /// overload without the ``IsAngled`` parameter.
-  llvm::Optional
-  createMainFileIncludeInsertion(llvm::StringRef Header, bool IsAngled);
-
   /// Creates a \p Header inclusion directive fixit in the main file.
   /// When \p Header is enclosed in angle brackets, uses angle brackets in the
   /// inclusion directive, otherwise uses quotes.
-  /// Returns``llvm::None`` on error or if the inclusion directive already
+  /// Returns ``llvm::None`` on error or if the inclusion directive already
   /// exists.
   llvm::Optional
   createMainFileIncludeInsertion(llvm::StringRef Header);

diff  --git a/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
index 6ea757a38f05..ae2ae86f4665 100644
--- a/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
@@ -95,15 +95,10 @@ void TransformerClangTidyCheck::check(
 ca

[PATCH] D88645: [Annotation] Allows annotation to carry some additional constant arguments.

2020-10-09 Thread Tyker via Phabricator via cfe-commits
Tyker added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:3683
+  auto *Attr =
+  AnnotateAttr::Create(Context, Str, Args.empty() ? nullptr : Args.data(),
+   Args.size(), CI.getRange(), CI.getSyntax());

aaron.ballman wrote:
> Just curious, but is the `?:` actually necessary? I would have assumed that 
> an empty `ArrayRef` would return `nullptr` from `data()`.
maybe it was(in a previous version of the code) but not anymore since there is 
always at least one argument.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:3688
+Expr *&E = Attr->args_begin()[Idx];
+ConstantExpr *CE = dyn_cast(E);
+if (!E) {

aaron.ballman wrote:
> `auto *` since the type is spelled out in the initialization.
> 
> Also, I think this is unsafe -- it looks like during template instantiation, 
> any arguments that have a substitution failure will come through as 
> `nullptr`, and this will crash.
> 
> What should happen on template instantiation failure for these arguments? I 
> think the whole attribute should probably be dropped with appropriate 
> diagnostics rather than emitting a partial attribute, but perhaps you have 
> different ideas.
When template instantation fails nullptr is put in the Expr arguments and  
AddAnnotationAttr will emit a diagnostic and not associate the attribut to the 
declaration.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:3704-3705
+  Result = E->EvaluateAsRValue(Eval, Context, true);
+else
+  Result = E->EvaluateAsLValue(Eval, Context, true);
+

aaron.ballman wrote:
> Under what circumstances would we want the constant expressions to be 
> lvalues? I would have guessed you would want to call 
> `Expr::EvaluateAsConstantExpr()` instead of either of these.
Expr::EvaluateAsConstantExpr will evaluate expression in there value category.
this can be quite surprising in some situations like:
```
const int g_i = 0;
[[clang::annotate("test", g_i)]] void t() {} // annotation carries a 
pointer/reference on g_i
[[clang::annotate("test", (int)g_i)]] void t1() {} // annotation carries the 
value 0
[[clang::annotate("test", g_i + 0)]] void t1() {} // annotation carries the 
value 0

```
with EvaluateAsRValue in all of the cases above the annotation will carry the 
value 0.

optionally we could wrap expression with an LValue to RValue cast and call 
EvaluateAsConstantExpr this should also work.



Comment at: clang/test/SemaCXX/attr-annotate.cpp:1
+// RUN: %clang_cc1 -std=c++11 -emit-llvm -verify %s
+

aaron.ballman wrote:
> Do you mean to emit llvm here? I think that should probably be `-fsyntax-only`
The reason i put an -emit-llvm is to also test the asserts in IRgen on more 
complex code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88645

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


[PATCH] D89127: [SystemZ][z/OS] Update target specific __attribute__((aligned)) value for test

2020-10-09 Thread Fanbo Meng via Phabricator via cfe-commits
fanbo-meng created this revision.
fanbo-meng added reviewers: abhina.sreeskantharajan, uweigand, Kai, 
hubert.reinterpretcast.
Herald added subscribers: cfe-commits, krytarowski.
Herald added a project: clang.
fanbo-meng requested review of this revision.

z/OS defaults to 16 bytes for  __attribute__((aligned)), modify the test to 
differentiate between z/OS and Linux on s390x.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89127

Files:
  clang/test/Sema/struct-packed-align.c


Index: clang/test/Sema/struct-packed-align.c
===
--- clang/test/Sema/struct-packed-align.c
+++ clang/test/Sema/struct-packed-align.c
@@ -59,7 +59,7 @@
 struct __attribute__((aligned)) as1_2 {
 char c;
 };
-#if ( defined(__s390x__) || ( defined (__ARM_32BIT_STATE) && ! 
defined(__ANDROID__) ) )
+#if ((defined(__s390x__) && !defined(__MVS__)) || (defined(__ARM_32BIT_STATE) 
&& !defined(__ANDROID__)))
 extern int e1_2[sizeof(struct as1_2) == 8 ? 1 : -1];
 extern int e2_2[__alignof(struct as1_2) == 8 ? 1 : -1];
 #else


Index: clang/test/Sema/struct-packed-align.c
===
--- clang/test/Sema/struct-packed-align.c
+++ clang/test/Sema/struct-packed-align.c
@@ -59,7 +59,7 @@
 struct __attribute__((aligned)) as1_2 {
 char c;
 };
-#if ( defined(__s390x__) || ( defined (__ARM_32BIT_STATE) && ! defined(__ANDROID__) ) )
+#if ((defined(__s390x__) && !defined(__MVS__)) || (defined(__ARM_32BIT_STATE) && !defined(__ANDROID__)))
 extern int e1_2[sizeof(struct as1_2) == 8 ? 1 : -1];
 extern int e2_2[__alignof(struct as1_2) == 8 ? 1 : -1];
 #else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89127: [SystemZ][z/OS] Update target specific __attribute__((aligned)) value for test

2020-10-09 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan accepted this revision.
abhina.sreeskantharajan 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/D89127/new/

https://reviews.llvm.org/D89127

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


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

2020-10-09 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 297224.
JonasToth added a comment.

- fix platform dependent warning message for decltype to just match the 
beginning and not the 'a.k.a'


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54943

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.h
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-const-correctness.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-cxx17.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-pointer-as-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-transform-pointer-as-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-transform-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-values.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-values.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-values.cpp
@@ -0,0 +1,957 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-const-correctness %t -- \
+// RUN:   -config="{CheckOptions: [\
+// RUN:   {key: 'cppcoreguidelines-const-correctness.TransformValues', value: 1}, \
+// RUN:   {key: 'cppcoreguidelines-const-correctness.WarnPointersAsValues', value: 0}, \
+// RUN:   {key: 'cppcoreguidelines-const-correctness.TransformPointersAsValues', value: 0}, \
+// RUN:   ]}" --
+
+// --- Provide test samples for primitive builtins -
+// - every 'p_*' variable is a 'potential_const_*' variable
+// - every 'np_*' variable is a 'non_potential_const_*' variable
+
+bool global;
+char np_global = 0; // globals can't be known to be const
+
+namespace foo {
+int scoped;
+float np_scoped = 1; // namespace variables are like globals
+} // namespace foo
+
+// Lambdas should be ignored, because they do not follow the normal variable
+// semantic (e.g. the type is only known to the compiler).
+void lambdas() {
+  auto Lambda = [](int i) { return i < 0; };
+}
+
+void some_function(double, wchar_t);
+
+void some_function(double np_arg0, wchar_t np_arg1) {
+  int p_local0 = 2;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+
+  int np_local0;
+  const int np_local1 = 42;
+
+  unsigned int np_local2 = 3;
+  np_local2 <<= 4;
+
+  int np_local3 = 4;
+  ++np_local3;
+  int np_local4 = 4;
+  np_local4++;
+
+  int np_local5 = 4;
+  --np_local5;
+  int np_local6 = 4;
+  np_local6--;
+}
+
+void nested_scopes() {
+  int p_local0 = 2;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+  int np_local0 = 42;
+
+  {
+int p_local1 = 42;
+// CHECK-MESSAGES: [[@LINE-1]]:5: warning: variable 'p_local1' of type 'int' can be declared 'const'
+np_local0 *= 2;
+  }
+}
+
+void ignore_reference_to_pointers() {
+  int *np_local0 = nullptr;
+  int *&np_local1 = np_local0;
+}
+
+void some_lambda_environment_capture_all_by_reference(double np_arg0) {
+  int np_local0 = 0;
+  int p_local0 = 1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+
+  int np_local2;
+  const int np_local3 = 2;
+
+  // Capturing all variables by reference prohibits making them const.
+  [&]() { ++np_local0; };
+
+  int p_local1 = 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared 'const'
+}
+
+void some_lambda_environment_capture_all_by_value(double np_arg0) {
+  int np_local0 = 0;
+  int p_local0 = 1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+
+  int np_local1;
+  const int np_local2 = 2;
+
+  // Capturing by value has no influence on them.
+  [=]() { (void)p_local0; };
+
+  np_local0 += 10;
+}
+
+void function_inout_pointer(int *inout);
+void function_in_pointer(const int *in);
+
+void some_pointer_taking(int *out) {
+  int np_local0 = 42;
+  const int *const p0_np_local0 = &np_local0;
+  int *const p1_np_local0 = &np_local0;
+
+  int np_local1 = 42;
+  const int *const p0_np_local1 = &np_local1;
+  int *const p1_np_local1 = &np_local1;
+  *p1_np_local0 = 43;
+
+  int np_local2 = 42;
+  function_inout_pointer(&np_local2);
+
+  // Prevents const.
+  int np_local3 = 42;
+  out = &np_local3; // This returns and invalid address, its just about the AST
+
+  int p_local1 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type

[clang] 0741a2c - [Clang][unittests][NFC] Break up test in Callbacks.cpp

2020-10-09 Thread Stefan Pintilie via cfe-commits

Author: Stefan Pintilie
Date: 2020-10-09T08:53:50-05:00
New Revision: 0741a2c9caca864fc30af2104712d02accdc12e6

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

LOG: [Clang][unittests][NFC] Break up test in Callbacks.cpp

The Callbacks.cpp test was taking a long time to compile on some build bots
causing timeouts. This patch splits up that test into five separate cpp
files and a header file.

Reviewed By: gribozavr2

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

Added: 
clang/unittests/Tooling/RecursiveASTVisitorTests/CallbacksBinaryOperator.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/CallbacksCallExpr.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/CallbacksCommon.h

clang/unittests/Tooling/RecursiveASTVisitorTests/CallbacksCompoundAssignOperator.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/CallbacksLeaf.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/CallbacksUnaryOperator.cpp

Modified: 
clang/unittests/Tooling/CMakeLists.txt

Removed: 
clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp



diff  --git a/clang/unittests/Tooling/CMakeLists.txt 
b/clang/unittests/Tooling/CMakeLists.txt
index 9de330ab73d4..3ed6992d81f5 100644
--- a/clang/unittests/Tooling/CMakeLists.txt
+++ b/clang/unittests/Tooling/CMakeLists.txt
@@ -20,7 +20,11 @@ add_clang_unittest(ToolingTests
   QualTypeNamesTest.cpp
   RangeSelectorTest.cpp
   RecursiveASTVisitorTests/Attr.cpp
-  RecursiveASTVisitorTests/Callbacks.cpp
+  RecursiveASTVisitorTests/CallbacksLeaf.cpp
+  RecursiveASTVisitorTests/CallbacksUnaryOperator.cpp
+  RecursiveASTVisitorTests/CallbacksBinaryOperator.cpp
+  RecursiveASTVisitorTests/CallbacksCompoundAssignOperator.cpp
+  RecursiveASTVisitorTests/CallbacksCallExpr.cpp
   RecursiveASTVisitorTests/Class.cpp
   RecursiveASTVisitorTests/Concept.cpp
   RecursiveASTVisitorTests/ConstructExpr.cpp

diff  --git a/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp 
b/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
deleted file mode 100644
index 71f2bf6be599..
--- a/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
+++ /dev/null
@@ -1,1209 +0,0 @@
-//===--- clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp 
---===//
-//
-// 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 "TestVisitor.h"
-
-using namespace clang;
-
-namespace {
-
-enum class ShouldTraversePostOrder : bool {
-  No = false,
-  Yes = true,
-};
-
-/// Base class for tests for RecursiveASTVisitor tests that validate the
-/// sequence of calls to user-defined callbacks like Traverse*(), WalkUp*(),
-/// Visit*().
-template 
-class RecordingVisitorBase : public TestVisitor {
-  ShouldTraversePostOrder ShouldTraversePostOrderValue;
-
-public:
-  RecordingVisitorBase(ShouldTraversePostOrder ShouldTraversePostOrderValue)
-  : ShouldTraversePostOrderValue(ShouldTraversePostOrderValue) {}
-
-  bool shouldTraversePostOrder() const {
-return static_cast(ShouldTraversePostOrderValue);
-  }
-
-  // Callbacks received during traversal.
-  std::string CallbackLog;
-  unsigned CallbackLogIndent = 0;
-
-  std::string stmtToString(Stmt *S) {
-StringRef ClassName = S->getStmtClassName();
-if (IntegerLiteral *IL = dyn_cast(S)) {
-  return (ClassName + "(" + IL->getValue().toString(10, false) + 
")").str();
-}
-if (UnaryOperator *UO = dyn_cast(S)) {
-  return (ClassName + "(" + UnaryOperator::getOpcodeStr(UO->getOpcode()) +
-  ")")
-  .str();
-}
-if (BinaryOperator *BO = dyn_cast(S)) {
-  return (ClassName + "(" + BinaryOperator::getOpcodeStr(BO->getOpcode()) +
-  ")")
-  .str();
-}
-if (CallExpr *CE = dyn_cast(S)) {
-  if (FunctionDecl *Callee = CE->getDirectCallee()) {
-if (Callee->getIdentifier()) {
-  return (ClassName + "(" + Callee->getName() + ")").str();
-}
-  }
-}
-if (DeclRefExpr *DRE = dyn_cast(S)) {
-  if (NamedDecl *ND = DRE->getFoundDecl()) {
-if (ND->getIdentifier()) {
-  return (ClassName + "(" + ND->getName() + ")").str();
-}
-  }
-}
-return ClassName.str();
-  }
-
-  /// Record the fact that the user-defined callback member function
-  /// \p CallbackName was called with the argument \p S. Then, record the
-  /// effects of calling the default implementation \p CallDefaultFn.
-  template 
-  void recordCallback(StringRef CallbackName, Stmt *S,
-  CallDefault CallDefaultFn) {
-

[PATCH] D88886: [Clang][unittests][NFC] Break up test in Callbacks.cpp

2020-10-09 Thread Stefan Pintilie via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0741a2c9caca: [Clang][unittests][NFC] Break up test in 
Callbacks.cpp (authored by stefanp).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D6

Files:
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
  clang/unittests/Tooling/RecursiveASTVisitorTests/CallbacksBinaryOperator.cpp
  clang/unittests/Tooling/RecursiveASTVisitorTests/CallbacksCallExpr.cpp
  clang/unittests/Tooling/RecursiveASTVisitorTests/CallbacksCommon.h
  
clang/unittests/Tooling/RecursiveASTVisitorTests/CallbacksCompoundAssignOperator.cpp
  clang/unittests/Tooling/RecursiveASTVisitorTests/CallbacksLeaf.cpp
  clang/unittests/Tooling/RecursiveASTVisitorTests/CallbacksUnaryOperator.cpp

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/CallbacksUnaryOperator.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/CallbacksUnaryOperator.cpp
@@ -0,0 +1,200 @@
+//===- unittests/Tooling/RecursiveASTVisitorTests/CallbacksUnaryOperator.cpp -===//
+//
+// 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 "CallbacksCommon.h"
+
+TEST(RecursiveASTVisitor, StmtCallbacks_TraverseUnaryOperator) {
+  class RecordingVisitor : public RecordingVisitorBase {
+  public:
+RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue)
+: RecordingVisitorBase(ShouldTraversePostOrderValue) {}
+
+bool TraverseUnaryOperator(UnaryOperator *UO) {
+  recordCallback(__func__, UO, [&]() {
+RecordingVisitorBase::TraverseUnaryOperator(UO);
+  });
+  return true;
+}
+
+bool WalkUpFromStmt(Stmt *S) {
+  recordCallback(__func__, S,
+ [&]() { RecordingVisitorBase::WalkUpFromStmt(S); });
+  return true;
+}
+  };
+
+  StringRef Code = R"cpp(
+void test() {
+  1;
+  -2;
+  3;
+}
+)cpp";
+
+  EXPECT_TRUE(visitorCallbackLogEqual(
+  RecordingVisitor(ShouldTraversePostOrder::No), Code,
+  R"txt(
+WalkUpFromStmt CompoundStmt
+WalkUpFromStmt IntegerLiteral(1)
+TraverseUnaryOperator UnaryOperator(-)
+  WalkUpFromStmt UnaryOperator(-)
+  WalkUpFromStmt IntegerLiteral(2)
+WalkUpFromStmt IntegerLiteral(3)
+)txt"));
+
+  EXPECT_TRUE(visitorCallbackLogEqual(
+  RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
+  R"txt(
+WalkUpFromStmt IntegerLiteral(1)
+TraverseUnaryOperator UnaryOperator(-)
+  WalkUpFromStmt IntegerLiteral(2)
+  WalkUpFromStmt UnaryOperator(-)
+WalkUpFromStmt IntegerLiteral(3)
+WalkUpFromStmt CompoundStmt
+)txt"));
+}
+
+TEST(RecursiveASTVisitor,
+ StmtCallbacks_TraverseUnaryOperator_WalkUpFromUnaryOperator) {
+  class RecordingVisitor : public RecordingVisitorBase {
+  public:
+RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue)
+: RecordingVisitorBase(ShouldTraversePostOrderValue) {}
+
+bool TraverseUnaryOperator(UnaryOperator *UO) {
+  recordCallback(__func__, UO, [&]() {
+RecordingVisitorBase::TraverseUnaryOperator(UO);
+  });
+  return true;
+}
+
+bool WalkUpFromStmt(Stmt *S) {
+  recordCallback(__func__, S,
+ [&]() { RecordingVisitorBase::WalkUpFromStmt(S); });
+  return true;
+}
+
+bool WalkUpFromExpr(Expr *E) {
+  recordCallback(__func__, E,
+ [&]() { RecordingVisitorBase::WalkUpFromExpr(E); });
+  return true;
+}
+
+bool WalkUpFromUnaryOperator(UnaryOperator *UO) {
+  recordCallback(__func__, UO, [&]() {
+RecordingVisitorBase::WalkUpFromUnaryOperator(UO);
+  });
+  return true;
+}
+  };
+
+  StringRef Code = R"cpp(
+void test() {
+  1;
+  -2;
+  3;
+}
+)cpp";
+
+  EXPECT_TRUE(visitorCallbackLogEqual(
+  RecordingVisitor(ShouldTraversePostOrder::No), Code,
+  R"txt(
+WalkUpFromStmt CompoundStmt
+WalkUpFromExpr IntegerLiteral(1)
+  WalkUpFromStmt IntegerLiteral(1)
+TraverseUnaryOperator UnaryOperator(-)
+  WalkUpFromUnaryOperator UnaryOperator(-)
+WalkUpFromExpr UnaryOperator(-)
+  WalkUpFromStmt UnaryOperator(-)
+  WalkUpFromExpr IntegerLiteral(2)
+WalkUpFromStmt IntegerLiteral(2)
+WalkUpFromExpr IntegerLiteral(3)
+  WalkUpFromStmt IntegerLiteral(3)
+)txt"));
+
+  EXPECT_TRUE(visitorCallbackLogEqual(
+  RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
+  R"txt(
+WalkUpFromExpr IntegerLiteral(1)
+  WalkUpFromStmt IntegerLiteral(1)
+TraverseUnaryOperator UnaryOperator(-)
+  WalkUpFromExpr IntegerLiteral(2)
+WalkUpFromStmt IntegerLiteral(2)
+  WalkUpFro

[PATCH] D87547: [MinGW][clang-shlib] Build by default on MinGW

2020-10-09 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov reopened this revision.
ASDenysPetrov added a comment.
This revision is now accepted and ready to land.

Hi, @mati865
Currently I got an error while building with GCC10 on Win10.

  [2325/2656] Linking CXX shared library bin\libclang-cpp.dll
  FAILED: bin/libclang-cpp.dll lib/libclang-cpp.dll.a
  cmd.exe /C "cd . && D:\WORK\Utilities\MSYS2\mingw64\bin\c++.exe -Wa,-mbig-obj 
-Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings 
-Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long 
-Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess 
-Wno-redundant-move -Wno-noexcept-type -Wdelete-non-virtual-dtor 
-Wsuggest-override -Wno-comment -fno-common -Woverloaded-virtual 
-fno-strict-aliasing  -O2   -shared -o bin\libclang-cpp.dll 
-Wl,--out-implib,lib\libclang-cpp.dll.a 
-Wl,--major-image-version,0,--minor-image-version,0 
@tools\clang\tools\clang-shlib\CMakeFiles\clang-cpp.rsp  && cd ."
  
D:/WORK/Utilities/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
 error: export ordinal too large: 66444
  collect2.exe: error: ld returned 1 exit status
  [2328/2656] Building CXX object 
tools/clang/tools/libclang/CMakeFiles/libclang.dir/CIndex.cpp.obj
  ninja: build stopped: subcommand failed.

I've tryed this on two PCs. Could you, please, revise you solution. I'm not 
familiar with this part but this affects me (and I think other Win-people).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87547

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


[PATCH] D89130: [WIP][Sparc] Fix long double on 32-bit Solaris/SPARC

2020-10-09 Thread Rainer Orth via Phabricator via cfe-commits
ro created this revision.
ro added reviewers: efriedma, brad.
Herald added subscribers: Sanitizers, s.egerton, dexonsmith, jrtc27, simoncook, 
fedor.sergeev, hiraditya, mgorny, jyknight.
Herald added projects: clang, Sanitizers, LLVM.
ro requested review of this revision.

The SysVr4 SPARC psABI prescribes 128-bit `long double` on 32-bit Sparc, and 
Solaris follows that as do some other OSes.  However, `clang` doesn't support 
that.

**This is not yet complete, but I need guidance in some points and believe it's 
easier to do so here than in the corresponding Bug 42493**

There are several noteworthy issues:

- `long double` is 128-bit IEEEquad format, but with 64-bit alignment unlike 
SPARC V9 which uses 128-bit alignment.
- `long double` is passed and returned by reference, just like structures and 
unions.
- `long double _Complex`, a Sun extension not in the psABI, is always returned 
in registers.
- `compiler-rt` uses `__uint128_t` for `long double` support which isn't 
available for 32-bit compilations by default.  It's currently enabled with 
`-fforce-enable-int128` which `gcc` doesn't support.

Right now the basic `long double` support seems to work (need to double-check 
with GCC's `gcc.dg/compat` testsuite), but compiling 
`compiler-rt/lib/builtins/divtc3.c` fails:

  Assertion failed: isRegLoc(), file 
/vol/llvm/src/llvm-project/local/llvm/include/llvm/CodeGen/CallingConvLower.h, 
line 150
  
  11 libc.so.1 0x7edfb158 _assert + 104
  12 clang-12  0x0001038fdf90 
llvm::SparcTargetLowering::LowerCall_32(llvm::TargetLowering::CallLoweringInfo&,
 llvm::SmallVectorImpl&) const + 11888
  13 clang-12  0x0001038f9010 
llvm::SparcTargetLowering::LowerCall(llvm::TargetLowering::CallLoweringInfo&, 
llvm::SmallVectorImpl&) const + 60
  14 clang-12  0x000106062f54 
llvm::TargetLowering::LowerCallTo(llvm::TargetLowering::CallLoweringInfo&) 
const + 7724
  15 clang-12  0x000106039704 (anonymous 
namespace)::SelectionDAGLegalize::ExpandLibCall(llvm::RTLIB::Libcall, 
llvm::SDNode*, bool) + 1896

Besides, something will have to be done about the `__uint128_t` requirement on 
32-bit targets, probably using a union with `uint64_t` members.

I'm currently lost here and will need some guidance how to proceed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89130

Files:
  clang/lib/Basic/Targets/Sparc.h
  clang/lib/CodeGen/TargetInfo.cpp
  compiler-rt/lib/builtins/CMakeLists.txt
  compiler-rt/lib/builtins/int_types.h
  compiler-rt/test/builtins/CMakeLists.txt
  compiler-rt/test/builtins/Unit/divtc3_test.c
  llvm/lib/Target/Sparc/SparcCallingConv.td
  llvm/lib/Target/Sparc/SparcISelLowering.cpp

Index: llvm/lib/Target/Sparc/SparcISelLowering.cpp
===
--- llvm/lib/Target/Sparc/SparcISelLowering.cpp
+++ llvm/lib/Target/Sparc/SparcISelLowering.cpp
@@ -507,9 +507,6 @@
 SDValue Load ;
 if (VA.getValVT() == MVT::i32 || VA.getValVT() == MVT::f32) {
   Load = DAG.getLoad(VA.getValVT(), dl, Chain, FIPtr, MachinePointerInfo());
-} else if (VA.getValVT() == MVT::f128) {
-  report_fatal_error("SPARCv8 does not handle f128 in calls; "
- "pass indirectly");
 } else {
   // We shouldn't see any other value types here.
   llvm_unreachable("Unexpected ValVT encountered in frame lowering.");
Index: llvm/lib/Target/Sparc/SparcCallingConv.td
===
--- llvm/lib/Target/Sparc/SparcCallingConv.td
+++ llvm/lib/Target/Sparc/SparcCallingConv.td
@@ -34,6 +34,8 @@
   CCIfType<[i32], CCAssignToReg<[I0, I1, I2, I3, I4, I5]>>,
   CCIfType<[f32], CCAssignToReg<[F0, F1, F2, F3]>>,
   CCIfType<[f64], CCAssignToReg<[D0, D1]>>,
+  CCIfInReg>>,
+  CCIfType<[f128], CCAssignToStack<16, 8>>,
   CCIfType<[v2i32], CCCustom<"CC_Sparc_Assign_Ret_Split_64">>
 ]>;
 
Index: compiler-rt/test/builtins/Unit/divtc3_test.c
===
--- compiler-rt/test/builtins/Unit/divtc3_test.c
+++ compiler-rt/test/builtins/Unit/divtc3_test.c
@@ -2,10 +2,6 @@
 // REQUIRES: librt_has_divtc3
 // REQUIRES: c99-complex
 
-//
-// Bug 42493
-// XFAIL: sparc-target-arch
-//
 #include 
 
 #include "int_lib.h"
Index: compiler-rt/test/builtins/CMakeLists.txt
===
--- compiler-rt/test/builtins/CMakeLists.txt
+++ compiler-rt/test/builtins/CMakeLists.txt
@@ -39,7 +39,7 @@
 string(REPLACE ";" " " BUILTINS_TEST_TARGET_CFLAGS "${BUILTINS_TEST_TARGET_CFLAGS}")
   endif()
 
-  if (${arch} STREQUAL "riscv32")
+  if("${arch}" MATCHES "riscv32|sparc$" AND NOT CMAKE_COMPILER_IS_GNUCC)
 list(APPEND BUILTINS_TEST_TARGET_CFLAGS -fforce-enable-int128)
 string(REPLACE ";" " " BUILTINS_TEST_TARGET_CFLAGS "${BUILTINS_TEST_TARGET_CFLAGS}")
   endif()
Index: compiler-rt/lib/builtins/int_types.h
===
---

[PATCH] D89131: [clangd] Validate optional fields more strictly.

2020-10-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman.
Herald added a project: clang.
sammccall requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89131

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

Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -484,12 +484,10 @@
 bool fromJSON(const llvm::json::Value &Params, DidChangeTextDocumentParams &R,
   llvm::json::Path P) {
   llvm::json::ObjectMapper O(Params, P);
-  if (!O)
-return false;
-  O.map("forceRebuild", R.forceRebuild);  // Optional clangd extension.
-  return O.map("textDocument", R.textDocument) &&
+  return O && O.map("textDocument", R.textDocument) &&
  O.map("contentChanges", R.contentChanges) &&
- O.map("wantDiagnostics", R.wantDiagnostics);
+ O.map("wantDiagnostics", R.wantDiagnostics) &&
+ O.mapOptional("forceRebuild", R.forceRebuild);
 }
 
 bool fromJSON(const llvm::json::Value &E, FileChangeType &Out,
@@ -578,12 +576,10 @@
 bool fromJSON(const llvm::json::Value &Params, Diagnostic &R,
   llvm::json::Path P) {
   llvm::json::ObjectMapper O(Params, P);
-  if (!O || !O.map("range", R.range) || !O.map("message", R.message))
-return false;
-  O.map("severity", R.severity);
-  O.map("category", R.category);
-  O.map("code", R.code);
-  O.map("source", R.source);
+  return O && O.map("range", R.range) && O.map("message", R.message) &&
+ O.mapOptional("severity", R.severity) &&
+ O.mapOptional("category", R.category) &&
+ O.mapOptional("code", R.code) && O.mapOptional("source", R.source);
   return true;
 }
 
@@ -800,10 +796,8 @@
 bool fromJSON(const llvm::json::Value &Response, ApplyWorkspaceEditResponse &R,
   llvm::json::Path P) {
   llvm::json::ObjectMapper O(Response, P);
-  if (!O || !O.map("applied", R.applied))
-return false;
-  O.map("failureReason", R.failureReason);
-  return true;
+  return O && O.map("applied", R.applied) &&
+ O.mapOptional("failureReason", R.failureReason);
 }
 
 bool fromJSON(const llvm::json::Value &Params, TextDocumentPositionParams &R,
@@ -816,16 +810,11 @@
 bool fromJSON(const llvm::json::Value &Params, CompletionContext &R,
   llvm::json::Path P) {
   llvm::json::ObjectMapper O(Params, P);
-  if (!O)
-return false;
-
   int TriggerKind;
-  if (!O.map("triggerKind", TriggerKind))
+  if (!O || !O.map("triggerKind", TriggerKind) ||
+  !O.mapOptional("triggerCharacter", R.triggerCharacter))
 return false;
   R.triggerKind = static_cast(TriggerKind);
-
-  if (auto *TC = Params.getAsObject()->get("triggerCharacter"))
-return fromJSON(*TC, R.triggerCharacter, P.field("triggerCharacter"));
   return true;
 }
 
@@ -1126,8 +1115,8 @@
   llvm::json::ObjectMapper O(Params, P);
   if (!O)
 return true; // 'any' type in LSP.
-  O.map("compilationDatabaseChanges", S.compilationDatabaseChanges);
-  return true;
+  return O.mapOptional("compilationDatabaseChanges",
+   S.compilationDatabaseChanges);
 }
 
 bool fromJSON(const llvm::json::Value &Params, InitializationOptions &Opts,
@@ -1136,11 +1125,11 @@
   if (!O)
 return true; // 'any' type in LSP.
 
-  fromJSON(Params, Opts.ConfigSettings, P);
-  O.map("compilationDatabasePath", Opts.compilationDatabasePath);
-  O.map("fallbackFlags", Opts.fallbackFlags);
-  O.map("clangdFileStatus", Opts.FileStatus);
-  return true;
+  return fromJSON(Params, Opts.ConfigSettings, P) &&
+ O.mapOptional("compilationDatabasePath",
+   Opts.compilationDatabasePath) &&
+ O.mapOptional("fallbackFlags", Opts.fallbackFlags) &&
+ O.mapOptional("clangdFileStatus", Opts.FileStatus);
 }
 
 bool fromJSON(const llvm::json::Value &E, TypeHierarchyDirection &Out,
@@ -1193,20 +1182,13 @@
   llvm::json::ObjectMapper O(Params, P);
 
   // Required fields.
-  if (!(O && O.map("name", I.name) && O.map("kind", I.kind) &&
-O.map("uri", I.uri) && O.map("range", I.range) &&
-O.map("selectionRange", I.selectionRange))) {
-return false;
-  }
-
-  // Optional fields.
-  O.map("detail", I.detail);
-  O.map("deprecated", I.deprecated);
-  O.map("parents", I.parents);
-  O.map("children", I.children);
-  O.map("data", I.data);
-
-  return true;
+  return O && O.map("name", I.name) && O.map("kind", I.kind) &&
+ O.map("uri", I.uri) && O.map("range", I.range) &&
+ O.map("selectionRange", I.selectionRange) &&
+ O.mapOptional("detail", I.detail) &&
+ O.mapOptional("deprecated", I.deprecated) &&
+ O.mapOptional("parents", I.parents) &&
+ O.mapOptional("children", I.children) && O.mapOptional("data", I.data);
 }
 
 bool fr

[PATCH] D17993: [CodeGen] Apply 'nonnull' to 'this' pointer arguments.

2020-10-09 Thread CJ Johnson via Phabricator via cfe-commits
CJ-Johnson added inline comments.



Comment at: include/clang/Driver/Options.td:1157
+def fno_delete_null_pointer_checks : Flag<["-"], 
"fno-delete-null-pointer-checks">,
+  Group, Flags<[CC1Option]>;
 

rjmccall wrote:
> Please include HelpText, and it's probably worth talking about this in the 
> actual docs.
This flag has since been added via D47894 😃


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

https://reviews.llvm.org/D17993

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


[clang] d91234b - [SystemZ][z/OS] Update target specific __attribute__((aligned)) value for test

2020-10-09 Thread Fanbo Meng via cfe-commits

Author: Fanbo Meng
Date: 2020-10-09T10:14:44-04:00
New Revision: d91234b21c1a1a34d98157089a8769d8f9a32f06

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

LOG: [SystemZ][z/OS] Update target specific __attribute__((aligned)) value for 
test

z/OS defaults to 16 bytes for  __attribute__((aligned)), modify the test to 
differentiate between z/OS and Linux on s390x.

Reviewed By: abhina.sreeskantharajan

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

Added: 


Modified: 
clang/test/Sema/struct-packed-align.c

Removed: 




diff  --git a/clang/test/Sema/struct-packed-align.c 
b/clang/test/Sema/struct-packed-align.c
index 91c7ce39cc25..122b7f276461 100644
--- a/clang/test/Sema/struct-packed-align.c
+++ b/clang/test/Sema/struct-packed-align.c
@@ -59,7 +59,7 @@ extern int e2[__alignof(struct as1) == 8 ? 1 : -1];
 struct __attribute__((aligned)) as1_2 {
 char c;
 };
-#if ( defined(__s390x__) || ( defined (__ARM_32BIT_STATE) && ! 
defined(__ANDROID__) ) )
+#if ((defined(__s390x__) && !defined(__MVS__)) || (defined(__ARM_32BIT_STATE) 
&& !defined(__ANDROID__)))
 extern int e1_2[sizeof(struct as1_2) == 8 ? 1 : -1];
 extern int e2_2[__alignof(struct as1_2) == 8 ? 1 : -1];
 #else



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


[PATCH] D89127: [SystemZ][z/OS] Update target specific __attribute__((aligned)) value for test

2020-10-09 Thread Fanbo Meng via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd91234b21c1a: [SystemZ][z/OS] Update target specific 
__attribute__((aligned)) value for test (authored by fanbo-meng).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89127

Files:
  clang/test/Sema/struct-packed-align.c


Index: clang/test/Sema/struct-packed-align.c
===
--- clang/test/Sema/struct-packed-align.c
+++ clang/test/Sema/struct-packed-align.c
@@ -59,7 +59,7 @@
 struct __attribute__((aligned)) as1_2 {
 char c;
 };
-#if ( defined(__s390x__) || ( defined (__ARM_32BIT_STATE) && ! 
defined(__ANDROID__) ) )
+#if ((defined(__s390x__) && !defined(__MVS__)) || (defined(__ARM_32BIT_STATE) 
&& !defined(__ANDROID__)))
 extern int e1_2[sizeof(struct as1_2) == 8 ? 1 : -1];
 extern int e2_2[__alignof(struct as1_2) == 8 ? 1 : -1];
 #else


Index: clang/test/Sema/struct-packed-align.c
===
--- clang/test/Sema/struct-packed-align.c
+++ clang/test/Sema/struct-packed-align.c
@@ -59,7 +59,7 @@
 struct __attribute__((aligned)) as1_2 {
 char c;
 };
-#if ( defined(__s390x__) || ( defined (__ARM_32BIT_STATE) && ! defined(__ANDROID__) ) )
+#if ((defined(__s390x__) && !defined(__MVS__)) || (defined(__ARM_32BIT_STATE) && !defined(__ANDROID__)))
 extern int e1_2[sizeof(struct as1_2) == 8 ? 1 : -1];
 extern int e2_2[__alignof(struct as1_2) == 8 ? 1 : -1];
 #else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 41d2987 - [clangd] Stop logging in fromJSON, report instead.

2020-10-09 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-10-09T16:15:45+02:00
New Revision: 41d2987c7558734cef74151e743645f47d9df501

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

LOG: [clangd] Stop logging in fromJSON, report instead.

Added: 


Modified: 
clang-tools-extra/clangd/Protocol.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Protocol.cpp 
b/clang-tools-extra/clangd/Protocol.cpp
index 5d50a7bea034..f8aca226a599 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -851,7 +851,7 @@ static llvm::StringRef toTextKind(MarkupKind Kind) {
 bool fromJSON(const llvm::json::Value &V, MarkupKind &K, llvm::json::Path P) {
   auto Str = V.getAsString();
   if (!Str) {
-elog("Failed to parse markup kind: expected a string");
+P.report("expected string");
 return false;
   }
   if (*Str == "plaintext")
@@ -859,7 +859,7 @@ bool fromJSON(const llvm::json::Value &V, MarkupKind &K, 
llvm::json::Path P) {
   else if (*Str == "markdown")
 K = MarkupKind::Markdown;
   else {
-elog("Unknown markup kind: {0}", *Str);
+P.report("unknown markup kind");
 return false;
   }
   return true;



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


[PATCH] D17993: [CodeGen] Apply 'nonnull' to 'this' pointer arguments.

2020-10-09 Thread CJ Johnson via Phabricator via cfe-commits
CJ-Johnson added a comment.

After chatting with bkramer , I'm working 
on rebasing this diff so that it can be landed.


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

https://reviews.llvm.org/D17993

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


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

2020-10-09 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 297231.
JonasToth added a comment.

- missed one place of decltype


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54943

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.h
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-const-correctness.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-cxx17.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-pointer-as-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-transform-pointer-as-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-transform-values.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-values.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-values.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-values.cpp
@@ -0,0 +1,957 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-const-correctness %t -- \
+// RUN:   -config="{CheckOptions: [\
+// RUN:   {key: 'cppcoreguidelines-const-correctness.TransformValues', value: 1}, \
+// RUN:   {key: 'cppcoreguidelines-const-correctness.WarnPointersAsValues', value: 0}, \
+// RUN:   {key: 'cppcoreguidelines-const-correctness.TransformPointersAsValues', value: 0}, \
+// RUN:   ]}" --
+
+// --- Provide test samples for primitive builtins -
+// - every 'p_*' variable is a 'potential_const_*' variable
+// - every 'np_*' variable is a 'non_potential_const_*' variable
+
+bool global;
+char np_global = 0; // globals can't be known to be const
+
+namespace foo {
+int scoped;
+float np_scoped = 1; // namespace variables are like globals
+} // namespace foo
+
+// Lambdas should be ignored, because they do not follow the normal variable
+// semantic (e.g. the type is only known to the compiler).
+void lambdas() {
+  auto Lambda = [](int i) { return i < 0; };
+}
+
+void some_function(double, wchar_t);
+
+void some_function(double np_arg0, wchar_t np_arg1) {
+  int p_local0 = 2;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+
+  int np_local0;
+  const int np_local1 = 42;
+
+  unsigned int np_local2 = 3;
+  np_local2 <<= 4;
+
+  int np_local3 = 4;
+  ++np_local3;
+  int np_local4 = 4;
+  np_local4++;
+
+  int np_local5 = 4;
+  --np_local5;
+  int np_local6 = 4;
+  np_local6--;
+}
+
+void nested_scopes() {
+  int p_local0 = 2;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+  int np_local0 = 42;
+
+  {
+int p_local1 = 42;
+// CHECK-MESSAGES: [[@LINE-1]]:5: warning: variable 'p_local1' of type 'int' can be declared 'const'
+np_local0 *= 2;
+  }
+}
+
+void ignore_reference_to_pointers() {
+  int *np_local0 = nullptr;
+  int *&np_local1 = np_local0;
+}
+
+void some_lambda_environment_capture_all_by_reference(double np_arg0) {
+  int np_local0 = 0;
+  int p_local0 = 1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+
+  int np_local2;
+  const int np_local3 = 2;
+
+  // Capturing all variables by reference prohibits making them const.
+  [&]() { ++np_local0; };
+
+  int p_local1 = 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared 'const'
+}
+
+void some_lambda_environment_capture_all_by_value(double np_arg0) {
+  int np_local0 = 0;
+  int p_local0 = 1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+
+  int np_local1;
+  const int np_local2 = 2;
+
+  // Capturing by value has no influence on them.
+  [=]() { (void)p_local0; };
+
+  np_local0 += 10;
+}
+
+void function_inout_pointer(int *inout);
+void function_in_pointer(const int *in);
+
+void some_pointer_taking(int *out) {
+  int np_local0 = 42;
+  const int *const p0_np_local0 = &np_local0;
+  int *const p1_np_local0 = &np_local0;
+
+  int np_local1 = 42;
+  const int *const p0_np_local1 = &np_local1;
+  int *const p1_np_local1 = &np_local1;
+  *p1_np_local0 = 43;
+
+  int np_local2 = 42;
+  function_inout_pointer(&np_local2);
+
+  // Prevents const.
+  int np_local3 = 42;
+  out = &np_local3; // This returns and invalid address, its just about the AST
+
+  int p_local1 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared 'const'
+  const int *const p0_p_local1 = &p_loca

[clang] 71d3b7e - [OpenCL] Add new compilation mode for OpenCL 3.0.

2020-10-09 Thread Anastasia Stulova via cfe-commits

Author: Anastasia Stulova
Date: 2020-10-09T15:28:38+01:00
New Revision: 71d3b7ec7b62d37dd3c8eb1a921f0b3e1ffdaa7f

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

LOG: [OpenCL] Add new compilation mode for OpenCL 3.0.

Extended -cl-std/std flag with CL3.0 and added predefined version macros.

Patch by Anton Zabaznov (azabaznov)!

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Basic/LangStandards.def
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/InitPreprocessor.cpp
clang/test/Driver/autocomplete.c
clang/test/Driver/opencl.cl
clang/test/Driver/unknown-std.cl
clang/test/Frontend/stdlang.c
clang/test/Preprocessor/predefined-macros.c

Removed: 




diff  --git a/clang/include/clang/Basic/LangStandards.def 
b/clang/include/clang/Basic/LangStandards.def
index b09568e8b3e8..7b915c312746 100644
--- a/clang/include/clang/Basic/LangStandards.def
+++ b/clang/include/clang/Basic/LangStandards.def
@@ -167,6 +167,9 @@ LANGSTANDARD(opencl12, "cl1.2",
 LANGSTANDARD(opencl20, "cl2.0",
  OpenCL, "OpenCL 2.0",
  LineComment | C99 | Digraphs | HexFloat | OpenCL)
+LANGSTANDARD(opencl30, "cl3.0",
+ OpenCL, "OpenCL 3.0",
+ LineComment | C99 | Digraphs | HexFloat | OpenCL)
 LANGSTANDARD(openclcpp, "clc++",
  OpenCL, "C++ for OpenCL",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus17 
|
@@ -176,6 +179,7 @@ LANGSTANDARD_ALIAS_DEPR(opencl10, "CL")
 LANGSTANDARD_ALIAS_DEPR(opencl11, "CL1.1")
 LANGSTANDARD_ALIAS_DEPR(opencl12, "CL1.2")
 LANGSTANDARD_ALIAS_DEPR(opencl20, "CL2.0")
+LANGSTANDARD_ALIAS_DEPR(opencl30, "CL3.0")
 LANGSTANDARD_ALIAS_DEPR(openclcpp, "CLC++")
 
 // CUDA

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9170a33b3155..8e0343710d68 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -573,7 +573,7 @@ def cl_mad_enable : Flag<["-"], "cl-mad-enable">, 
Group, Flags<[CC
 def cl_no_signed_zeros : Flag<["-"], "cl-no-signed-zeros">, 
Group, Flags<[CC1Option]>,
   HelpText<"OpenCL only. Allow use of less precise no signed zeros 
computations in the generated binary.">;
 def cl_std_EQ : Joined<["-"], "cl-std=">, Group, 
Flags<[CC1Option]>,
-  HelpText<"OpenCL language standard to compile for.">, 
Values<"cl,CL,cl1.1,CL1.1,cl1.2,CL1.2,cl2.0,CL2.0,clc++,CLC++">;
+  HelpText<"OpenCL language standard to compile for.">, 
Values<"cl,CL,cl1.1,CL1.1,cl1.2,CL1.2,cl2.0,CL2.0,cl3.0,CL3.0,clc++,CLC++">;
 def cl_denorms_are_zero : Flag<["-"], "cl-denorms-are-zero">, 
Group,
   HelpText<"OpenCL only. Allow denormals to be flushed to zero.">;
 def cl_fp32_correctly_rounded_divide_sqrt : Flag<["-"], 
"cl-fp32-correctly-rounded-divide-sqrt">, Group, 
Flags<[CC1Option]>,

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 1df92b086986..77ecbbd093e5 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2368,6 +2368,8 @@ void CompilerInvocation::setLangDefaults(LangOptions 
&Opts, InputKind IK,
 Opts.OpenCLVersion = 120;
   else if (LangStd == LangStandard::lang_opencl20)
 Opts.OpenCLVersion = 200;
+  else if (LangStd == LangStandard::lang_opencl30)
+Opts.OpenCLVersion = 300;
   else if (LangStd == LangStandard::lang_openclcpp)
 Opts.OpenCLCPlusPlusVersion = 100;
 
@@ -2574,6 +2576,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList 
&Args, InputKind IK,
 .Cases("cl1.1", "CL1.1", LangStandard::lang_opencl11)
 .Cases("cl1.2", "CL1.2", LangStandard::lang_opencl12)
 .Cases("cl2.0", "CL2.0", LangStandard::lang_opencl20)
+.Cases("cl3.0", "CL3.0", LangStandard::lang_opencl30)
 .Cases("clc++", "CLC++", LangStandard::lang_openclcpp)
 .Default(LangStandard::lang_unspecified);
 

diff  --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index 6eef1e2376f6..08907fe2469c 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -445,6 +445,9 @@ static void InitializeStandardPredefinedMacros(const 
TargetInfo &TI,
   case 200:
 Builder.defineMacro("__OPENCL_C_VERSION__", "200");
 break;
+  case 300:
+Builder.defineMacro("__OPENCL_C_VERSION__", "300");
+break;
   default:
 llvm_unreachable("Unsupported OpenCL version");
   }
@@ -453,6 +456,7 @@ static void InitializeStandardPredefinedMacros(const 
TargetInfo &TI,
 Builder.defineMacro("CL_VERSION_1_1", "110");
 Builder.defineMacr

[PATCH] D88300: [OpenCL] Initial patch for OpenCL C 3.0 support

2020-10-09 Thread Anastasia Stulova via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG71d3b7ec7b62: [OpenCL] Add new compilation mode for OpenCL 
3.0. (authored by Anastasia).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88300

Files:
  clang/include/clang/Basic/LangStandards.def
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Driver/autocomplete.c
  clang/test/Driver/opencl.cl
  clang/test/Driver/unknown-std.cl
  clang/test/Frontend/stdlang.c
  clang/test/Preprocessor/predefined-macros.c

Index: clang/test/Preprocessor/predefined-macros.c
===
--- clang/test/Preprocessor/predefined-macros.c
+++ clang/test/Preprocessor/predefined-macros.c
@@ -129,6 +129,8 @@
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL12
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=CL2.0 \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL20
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=CL3.0 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL30
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-fast-relaxed-math \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-FRM
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++ \
@@ -137,26 +139,37 @@
 // CHECK-CL10: #define CL_VERSION_1_1 110
 // CHECK-CL10: #define CL_VERSION_1_2 120
 // CHECK-CL10: #define CL_VERSION_2_0 200
+// CHECK-CL10: #define CL_VERSION_3_0 300
 // CHECK-CL10: #define __OPENCL_C_VERSION__ 100
 // CHECK-CL10-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CL11: #define CL_VERSION_1_0 100
 // CHECK-CL11: #define CL_VERSION_1_1 110
 // CHECK-CL11: #define CL_VERSION_1_2 120
 // CHECK-CL11: #define CL_VERSION_2_0 200
+// CHECK-CL11: #define CL_VERSION_3_0 300
 // CHECK-CL11: #define __OPENCL_C_VERSION__ 110
 // CHECK-CL11-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CL12: #define CL_VERSION_1_0 100
 // CHECK-CL12: #define CL_VERSION_1_1 110
 // CHECK-CL12: #define CL_VERSION_1_2 120
 // CHECK-CL12: #define CL_VERSION_2_0 200
+// CHECK-CL12: #define CL_VERSION_3_0 300
 // CHECK-CL12: #define __OPENCL_C_VERSION__ 120
 // CHECK-CL12-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CL20: #define CL_VERSION_1_0 100
 // CHECK-CL20: #define CL_VERSION_1_1 110
 // CHECK-CL20: #define CL_VERSION_1_2 120
 // CHECK-CL20: #define CL_VERSION_2_0 200
+// CHECK-CL20: #define CL_VERSION_3_0 300
 // CHECK-CL20: #define __OPENCL_C_VERSION__ 200
 // CHECK-CL20-NOT: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CL30: #define CL_VERSION_1_0 100
+// CHECK-CL30: #define CL_VERSION_1_1 110
+// CHECK-CL30: #define CL_VERSION_1_2 120
+// CHECK-CL30: #define CL_VERSION_2_0 200
+// CHECK-CL30: #define CL_VERSION_3_0 300
+// CHECK-CL30: #define __OPENCL_C_VERSION__ 300
+// CHECK-CL30-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-FRM: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CLCPP10: #define __CL_CPP_VERSION_1_0__ 100
 // CHECK-CLCPP10: #define __OPENCL_CPP_VERSION__ 100
Index: clang/test/Frontend/stdlang.c
===
--- clang/test/Frontend/stdlang.c
+++ clang/test/Frontend/stdlang.c
@@ -4,11 +4,13 @@
 // RUN: %clang_cc1 -x cl -cl-std=cl1.1 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=cl1.2 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=cl2.0 -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=cl3.0 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=clc++ -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL1.1 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL1.2 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL2.0 -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=CL3.0 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CLC++ -DOPENCL %s
 // RUN: not %clang_cc1 -x cl -std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
 // RUN: not %clang_cc1 -x cl -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
Index: clang/test/Driver/unknown-std.cl
===
--- clang/test/Driver/unknown-std.cl
+++ clang/test/Driver/unknown-std.cl
@@ -10,6 +10,7 @@
 // CHECK-NEXT: note: use 'cl1.1' for 'OpenCL 1.1' standard
 // CHECK-NEXT: note: use 'cl1.2' for 'OpenCL 1.2' standard
 // CHECK-NEXT: note: use 'cl2.0' for 'OpenCL 2.0' standard
+// CHECK-NEXT: note: use 'cl3.0' for 'OpenCL 3.0' standard
 // CHECK-NEXT: note: use 'clc++' for 'C++ for OpenCL' standard
 
 // Make sure that no other output is present.
Index: clang/test/Driver/opencl.cl
===
--- clang/test/Driver/opencl.cl
+++ clang/test/Driver/opencl.cl
@@ -2,6 +2,7 @@
 // RUN: %clang -S -### -cl-std=CL1.1 %s 2>&1 | FileCheck --check-prefix=CHECK-CL11 %s
 // RUN: %clang -S -### -cl-std=CL1.2 

[PATCH] D89102: [X86] Add HRESET instruction.

2020-10-09 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei marked an inline comment as done.
pengfei added a comment.

Thanks for the review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89102

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


[PATCH] D89102: [X86] Add HRESET instruction.

2020-10-09 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei updated this revision to Diff 297234.
pengfei added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89102

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/cpuid.h
  clang/lib/Headers/hresetintrin.h
  clang/lib/Headers/immintrin.h
  clang/lib/Headers/x86gprintrin.h
  clang/test/CodeGen/x86-hreset-intrin.c
  clang/test/Driver/x86-target-features.c
  clang/test/Preprocessor/x86_target_features.c
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/Support/X86TargetParser.def
  llvm/lib/Support/Host.cpp
  llvm/lib/Support/X86TargetParser.cpp
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86InstrFormats.td
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/test/MC/Disassembler/X86/x86-32.txt
  llvm/test/MC/Disassembler/X86/x86-64.txt
  llvm/test/MC/X86/x86-32-coverage.s
  llvm/test/MC/X86/x86-64.s

Index: llvm/test/MC/X86/x86-64.s
===
--- llvm/test/MC/X86/x86-64.s
+++ llvm/test/MC/X86/x86-64.s
@@ -2014,3 +2014,7 @@
 // CHECK: tdcall
 // CHECK: encoding: [0x66,0x0f,0x01,0xcc]
 tdcall
+
+// CHECK: hreset
+// CHECK: encoding: [0xf3,0x0f,0x3a,0xf0,0xc0,0x01]
+hreset $1
Index: llvm/test/MC/X86/x86-32-coverage.s
===
--- llvm/test/MC/X86/x86-32-coverage.s
+++ llvm/test/MC/X86/x86-32-coverage.s
@@ -10891,4 +10891,8 @@
 
 // CHECK: tdcall
 // CHECK: encoding: [0x66,0x0f,0x01,0xcc]
-tdcall
\ No newline at end of file
+tdcall
+
+// CHECK: hreset
+// CHECK: encoding: [0xf3,0x0f,0x3a,0xf0,0xc0,0x01]
+hreset $1
Index: llvm/test/MC/Disassembler/X86/x86-64.txt
===
--- llvm/test/MC/Disassembler/X86/x86-64.txt
+++ llvm/test/MC/Disassembler/X86/x86-64.txt
@@ -712,3 +712,6 @@
 
 #CHECK: tdcall
 0x66 0x0f 0x01 0xcc
+
+# CHECK: hreset $1
+0xf3 0x0f 0x3a 0xf0 0xc0 0x01
Index: llvm/test/MC/Disassembler/X86/x86-32.txt
===
--- llvm/test/MC/Disassembler/X86/x86-32.txt
+++ llvm/test/MC/Disassembler/X86/x86-32.txt
@@ -1000,3 +1000,6 @@
 
 #CHECK: tdcall
 0x66 0x0f 0x01 0xcc
+
+# CHECK: hreset $1
+0xf3 0x0f 0x3a 0xf0 0xc0 0x01
Index: llvm/lib/Target/X86/X86Subtarget.h
===
--- llvm/lib/Target/X86/X86Subtarget.h
+++ llvm/lib/Target/X86/X86Subtarget.h
@@ -401,6 +401,9 @@
   /// Processor support key locker wide instructions
   bool HasWIDEKL = false;
 
+  /// Processor supports HRESET instruction
+  bool HasHRESET = false;
+
   /// Processor supports SERIALIZE instruction
   bool HasSERIALIZE = false;
 
@@ -736,6 +739,7 @@
   bool hasENQCMD() const { return HasENQCMD; }
   bool hasKL() const { return HasKL; }
   bool hasWIDEKL() const { return HasWIDEKL; }
+  bool hasHRESET() const { return HasHRESET; }
   bool hasSERIALIZE() const { return HasSERIALIZE; }
   bool hasTSXLDTRK() const { return HasTSXLDTRK; }
   bool useRetpolineIndirectCalls() const { return UseRetpolineIndirectCalls; }
Index: llvm/lib/Target/X86/X86InstrInfo.td
===
--- llvm/lib/Target/X86/X86InstrInfo.td
+++ llvm/lib/Target/X86/X86InstrInfo.td
@@ -971,6 +971,7 @@
 def HasENQCMD: Predicate<"Subtarget->hasENQCMD()">;
 def HasKL: Predicate<"Subtarget->hasKL()">;
 def HasWIDEKL: Predicate<"Subtarget->hasWIDEKL()">;
+def HasHRESET: Predicate<"Subtarget->hasHRESET()">;
 def HasSERIALIZE : Predicate<"Subtarget->hasSERIALIZE()">;
 def HasTSXLDTRK  : Predicate<"Subtarget->hasTSXLDTRK()">;
 def HasAMXTILE   : Predicate<"Subtarget->hasAMXTILE()">;
@@ -2911,6 +2912,13 @@
 def : InstAlias<"clzero\t{%eax|eax}", (CLZERO32r)>, Requires<[Not64BitMode]>;
 def : InstAlias<"clzero\t{%rax|rax}", (CLZERO64r)>, Requires<[In64BitMode]>;
 
+//===--===//
+// HRESET Instruction
+//
+let Uses = [EAX], SchedRW = [WriteSystem] in
+  def HRESET : Ii8<0xF0, MRM_C0, (outs), (ins i32u8imm:$imm), "hreset\t$imm", []>,
+   Requires<[HasHRESET]>, TAXS;
+
 //===--===//
 // SERIALIZE Instruction
 //
Index: llvm/lib/Target/X86/X86InstrFormats.td
===
--- llvm/lib/Target/X86/X86InstrFormats.td
+++ llvm/lib/Target/X86/X86InstrFormats.td
@@ -216,6 +216,7 @@
 class TAPS : TA { Prefix OpPrefix = PS; }
 class TAPD : TA { Prefix OpPrefix = PD; }
 class TAXD : TA { Prefix OpPrefix = XD; }
+class TAXS : TA { Prefix OpPrefix = XS; }
 class VEX{ Encoding OpEnc = EncVEX; }
 class VEX_W{ bit HasV

[PATCH] D88780: Allow interfaces to operate on in-memory buffers with no source location info.

2020-10-09 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

I think we could at least have a unittest that just calls these functions with 
an invalid SourceLocation. `unittests/Basic/SourceManagerTest.cpp` already 
takes care of creating a valid SourceManager object, so the unit test would 
just be a single call to each method. Of course it wouldn't be the exact same 
setup as whatever is Cling is doing, but it's better than nothing.

Also, I'm still trying to puzzle together what exactly the situation is that 
triggers this bug in Cling. From what I understand:

1. We call the ASTImporter::Import(Decl) with a Decl.
2. That triggers the importing of some SourceLocation. Given the ASTImporter is 
early-exiting on an invalid SourceLocation, this means you were importing a 
valid SourceLocation when hitting this crash.
3. We enter with a valid SourceLocation `isWrittenInBuiltinFile` from 
`ASTImporter::Import(SourceLocation)`. Now the function is computing the 
PresumedLoc via `getPresumedLoc` and that returns an invalid PresumedLoc.
4. We hit the assert due to the invalid PresumedLoc.

Do you know where exactly is getPresumedLoc returning the invalid error value? 
The review title just mentions a "in-memory buffer with no source location 
info", but it doesn't really explain what's going on. Are there SourceLocations 
pointing to that memory buffer but it's not registered with the SourceManager?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88780

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


[PATCH] D87029: [AIX] Implement AIX special bitfield related alignment rules

2020-10-09 Thread Sean Fertile via Phabricator via cfe-commits
sfertile added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1633
+
+if (BTy) {
+  BuiltinType::Kind BTyKind = BTy->getKind();

When can BTy be null? Should this instead be an assert?

Instead can we implement this without looking at the underlying type of the 
bitfield?
Considering StorageUnitSize:
* for types smaller then unsigned we always increase the storage size to that 
of unsigned.
* for int, and long in 32-bit the storage size is already 32 and we don't 
adjust it.
* for long long in 32-bit we decrease the size to 32.
* For long long and long in 64-bit we leave the storage size as 64.

This could be implemented as
```
if (StorageUnitSize <  Context.getTypeSize(Context.UnsignedIntTy) || 
(StorageUnitSize > Context.getTypeSize(Context.UnsignedIntTy) &&  
Context.getTargetInfo().getTriple().isArch32Bit()))
  StorageUnitSize =   Context.getTypeSize(Context.UnsignedIntTy);
```

Without relying on extracting the underlying type and having to worry about the 
case where BTy is null.
If we can also handle `FieldAlign `without knowing the underlying type then I 
think we should do so and avoid trying to extract the underlying type 
altogether.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1638
+  BTyKind != BuiltinType::LongLong) {
+// Only set bitfields alignment to unsigned when it does
+// not have attribute align specified or is less than

`to unsigned` --> `to alignof(unsigned)`



Comment at: clang/test/Layout/aix-bitfield-alignment.cpp:1
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fsyntax-only -faix-pragma-pack -x c++ %s | \

I suggest we split the test cases which are C++ only into a sperate file, and 
run the cases that are valid in both C and C++ as both to ensure there are no 
differences between C and C++ layout fir bit fields.


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

https://reviews.llvm.org/D87029

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


Re: [llvm-dev] [cfe-dev] Upcoming upgrade of LLVM buildbot

2020-10-09 Thread Galina Kistanova via cfe-commits
Hello Andrzej,

Please do not update your bots yet. I will explicitly ask later.

Feel free to move other reliably green bots of yours to the production
buildbot.

Thanks

Galina

On Fri, Oct 9, 2020 at 3:51 AM Andrzej Warzynski 
wrote:

> I switched one of our workers to the main Buildbot and everything seems
> fine #fingers-crossed. I guess that that was a temporary glitch?
>
> We haven't updated our local Buildbot installations - still on 0.8.5.
> Should we update?
>
> -Andrzej
>
> On 09/10/2020 00:44, Galina Kistanova wrote:
> > Hi Paula,
> >
> > This error is fine. The buildbot has tested the worker version. 0.8.x
> > apparently does not have that method.
> > The error gets handled gracefully on the server side. At least it seems
> > so so far.
> >
> > That should not prevent your bot from connecting.
> >
> > Thanks
> >
> > Galina
> >
> > On Thu, Oct 8, 2020 at 2:11 PM Paula Askar  > > wrote:
> >
> > Hey Andrzej,
> >
> > What are you seeing in your buildbot logs? Is it this error?
> > `twisted.spread.flavors.NoSuchMethod: No such method:
> > remote_getWorkerInfo`
> >
> > If so, you might want to try updating your buildbot worker.
> > I updated llvmlibc's to 2.8.4 and that seemed to solve the connection
> > problem:
> >
> https://github.com/llvm/llvm-project/commit/f60686f35cc89504f3411f49cf16a651a74be6eb
> >
> > Best,
> > Paula Askar
> >
> >
> > On Thu, Oct 8, 2020 at 5:43 AM Andrzej Warzynski via llvm-dev
> > mailto:llvm-...@lists.llvm.org>> wrote:
> >  >
> >  > Our Flang-aarch64 buildbots just won't connect to the main
> Buildbot
> >  > master anymore. I switched them to the staging buildbot master
> > instead
> >  > and it seems fine for now. Is there anything that we can/should
> > tweak at
> >  > our end?
> >  >
> >  > http://lab.llvm.org:8014/#/waterfall?tags=flang
> >  >
> >  > -Andrzej
> >  >
> >  > On 08/10/2020 00:31, Galina Kistanova via cfe-dev wrote:
> >  > > They are online now -
> > http://lab.llvm.org:8011/#/waterfall?tags=sanitizer
> >  > >
> >  > > AnnotatedCommand has severe design conflict with the new
> buildbot.
> >  > > We have changed it to be safe and still do something useful,
> > but it will
> >  > > need more love and care.
> >  > >
> >  > > Please let me know if you have some spare time to work on
> porting
> >  > > AnnotatedCommand.
> >  > >
> >  > > Thanks
> >  > >
> >  > > Galina
> >  > >
> >  > > On Wed, Oct 7, 2020 at 2:57 PM Vitaly Buka
> > mailto:vitalyb...@google.com>
> >  > > >>
> > wrote:
> >  > >
> >  > > It looks like all sanitizer builder are still offline
> >  > > http://lab.llvm.org:8011/#/builders
> >  > >
> >  > > On Tue, 6 Oct 2020 at 00:34, Galina Kistanova via
> cfe-commits
> >  > >  > 
> >  > >> wrote:
> >  > >
> >  > > Hello everyone,
> >  > >
> >  > > The staging buildbot was up and running for 6 days now,
> and
> >  > > looks good.
> >  > >
> >  > > Tomorrow at 12:00 PM PDT we will switch the production
> > buildbot
> >  > > to the new version.
> >  > >
> >  > > If you are a bot owner, you do not need to do anything
> > at this
> >  > > point, unless I'll ask you to help.
> >  > > The buildbot will go down for a short period of time,
> > and then a
> >  > > new version will come up and will accept connections
> > from your bots.
> >  > >
> >  > > Please note that the new version has a bit different URL
> >  > > structure. You will need to update the bookmarks or
> > scripts if
> >  > > you have stored direct URLs to inside the buldbot.
> >  > >
> >  > > We will be watching the production and staging bots and
> > will be
> >  > > improving zorg for the next week or so.
> >  > >
> >  > > I will need your feedback about blame e-mails delivery,
> IRC
> >  > > reporting issues, and anything you could spot wrong
> > with the new
> >  > > bot. I  hope the transition will go smoothly and we
> > will handle
> >  > > issues quickly if any would come up.
> >  > >
> >  > > After production is good and we have about a week of
> > running
> >  > > history, I'll ask the bot owners to upgrade buildbots
> > on their
> >  > > side. Please do not upgrade your buildbots unless I'll
> > ask you
> >  > > to. We are trying to limit a number of moving parts at
> this
> >  > > stage. We will start accepting change to zorg

[PATCH] D89055: [analyzer] Wrong type cast occures during pointer dereferencing after type punning

2020-10-09 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@NoQ

> Can we collapse this function further towards this goal? Say, why not pump 
> every region //unconditionally// through `castRegion()`? Does 
> `dispatchCast()` use `castRegion()` internally - and if it does, why are 
> there so many branches in this function?

Thank you for raising such a good questions :)
Honestly, I spent a week debugging to undersand what's going on in the Store, I 
never had a chance to dig into it before. It was tough. I'll proceed this to 
try to make what you mentioned.

The thing I'm sure that the type of retrieved value should be the same as the 
type of which this value was declared? In other words we can 
//unconditionally// cast all the values, can't we? Is there any case that 
contradicts me?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89055

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


[PATCH] D89135: [clangd] Stop capturing trace args if the tracer doesn't need them.

2020-10-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman.
Herald added a project: clang.
sammccall requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

The tracer is now expected to allocate+free the args itself.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89135

Files:
  clang-tools-extra/clangd/support/Trace.cpp
  clang-tools-extra/clangd/support/Trace.h
  clang-tools-extra/clangd/unittests/support/TraceTests.cpp

Index: clang-tools-extra/clangd/unittests/support/TraceTests.cpp
===
--- clang-tools-extra/clangd/unittests/support/TraceTests.cpp
+++ clang-tools-extra/clangd/unittests/support/TraceTests.cpp
@@ -186,6 +186,11 @@
  StartsWith("d,dist,\"a\nb\",1"), ""));
 }
 
+TEST_F(CSVMetricsTracerTest, IgnoresArgs) {
+  trace::Span Tracer("Foo");
+  EXPECT_EQ(nullptr, Tracer.Args);
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/support/Trace.h
===
--- clang-tools-extra/clangd/support/Trace.h
+++ clang-tools-extra/clangd/support/Trace.h
@@ -79,8 +79,11 @@
   /// Returns a derived context that will be destroyed when the event ends.
   /// Usually implementations will store an object in the returned context
   /// whose destructor records the end of the event.
-  /// The args are *Args, only complete when the event ends.
-  virtual Context beginSpan(llvm::StringRef Name, llvm::json::Object *Args);
+  /// If the tracer wants event details, it should call RequestArgs. The pointer
+  /// must be valid over the whole event, and will be populated before it ends.
+  virtual Context
+  beginSpan(llvm::StringRef Name,
+llvm::function_ref RequestArgs);
   // Called when a Span is destroyed (it may still be active on other threads).
   // beginSpan() and endSpan() will always form a proper stack on each thread.
   // The Context returned by beginSpan is active, but Args is not ready.
@@ -146,6 +149,8 @@
   llvm::json::Object *const Args;
 
 private:
+  // Awkward constructor works around constant initialization.
+  Span(std::pair);
   WithContext RestoreCtx;
 };
 
Index: clang-tools-extra/clangd/support/Trace.cpp
===
--- clang-tools-extra/clangd/support/Trace.cpp
+++ clang-tools-extra/clangd/support/Trace.cpp
@@ -53,9 +53,12 @@
 
   // We stash a Span object in the context. It will record the start/end,
   // and this also allows us to look up the parent Span's information.
-  Context beginSpan(llvm::StringRef Name, llvm::json::Object *Args) override {
-return Context::current().derive(
-SpanKey, std::make_unique(this, Name, Args));
+  Context beginSpan(
+  llvm::StringRef Name,
+  llvm::function_ref RequestArgs) override {
+auto JS = std::make_unique(this, Name);
+RequestArgs(&JS->Args);
+return Context::current().derive(SpanKey, std::move(JS));
   }
 
   // Trace viewer requires each thread to properly stack events.
@@ -85,9 +88,10 @@
 private:
   class JSONSpan {
   public:
-JSONSpan(JSONTracer *Tracer, llvm::StringRef Name, llvm::json::Object *Args)
+llvm::json::Object Args;
+JSONSpan(JSONTracer *Tracer, llvm::StringRef Name)
 : StartTime(Tracer->timestamp()), EndTime(0), Name(Name),
-  TID(llvm::get_threadid()), Tracer(Tracer), Args(Args) {
+  TID(llvm::get_threadid()), Tracer(Tracer) {
   // ~JSONSpan() may run in a different thread, so we need to capture now.
   Tracer->captureThreadMetadata();
 
@@ -125,7 +129,7 @@
   // Finally, record the event (ending at EndTime, not timestamp())!
   Tracer->jsonEvent("X",
 llvm::json::Object{{"name", std::move(Name)},
-   {"args", std::move(*Args)},
+   {"args", std::move(Args)},
{"dur", EndTime - StartTime}},
 TID, StartTime);
 }
@@ -144,7 +148,6 @@
 std::string Name;
 uint64_t TID;
 JSONTracer *Tracer;
-llvm::json::Object *Args;
   };
   static Key> SpanKey;
 
@@ -277,12 +280,11 @@
   T->instant("Log", llvm::json::Object{{"Message", Message.str()}});
 }
 
-// Returned context owns Args.
-static Context makeSpanContext(llvm::Twine Name, llvm::json::Object *Args,
-   const Metric &LatencyMetric) {
+// The JSON object is event args (owned by context), if the tracer wants them.
+static std::pair
+makeSpanContext(llvm::Twine Name, const Metric &LatencyMetric) {
   if (!T)
-return Context::current().clone();
-  WithContextValue WithArgs{std::unique_ptr(Args)};
+return std::make_pair(Context::current().clone(), nullptr);
   llvm::Optional WithLatency;
   usin

[PATCH] D89055: [analyzer] Wrong type cast occures during pointer dereferencing after type punning

2020-10-09 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@NoQ 
BTW, what you think we should do with D77062  
and D88477  then?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89055

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


[PATCH] D88737: [AIX] Turn -fdata-sections on by default in Clang

2020-10-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

A less intrusive approach is to not touch the existing 
InitTargetOptionsFromCodeGenFlags without parameters. You can add an 
`initTargetOptionsFromCodeGenFlags` with `const Tripe &` as its parameter.


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

https://reviews.llvm.org/D88737

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


[PATCH] D87449: [clang-tidy] Add new check for SEI CERT rule SIG30-C

2020-10-09 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: clang-tools-extra/clang-tidy/cert/SignalHandlerCheck.cpp:117-118
+FunctionCallCollector Collector{[&CalledFunctions](const CallExpr *CE) {
+  if (isa(CE->getCalleeDecl()))
+CalledFunctions.push_back(CE);
+}};

aaron.ballman wrote:
> balazske wrote:
> > aaron.ballman wrote:
> > > aaron.ballman wrote:
> > > > balazske wrote:
> > > > > aaron.ballman wrote:
> > > > > > For correctness, I think you need to handle more than just calls to 
> > > > > > function declarations -- for instance, this should be just as 
> > > > > > problematic:
> > > > > > ```
> > > > > > void some_signal_handler(int sig) {
> > > > > >   []{ puts("this should not be an escape hatch for the check); }();
> > > > > > }
> > > > > > ```
> > > > > > even though the call expression in the signal handler doesn't 
> > > > > > resolve back to a function declaration. (Similar for blocks instead 
> > > > > > of lambdas.) WDYT?
> > > > > I do not know how many other cases could be there. Probably this can 
> > > > > be left for future  improvement, the checker is mainly usable for C 
> > > > > code then. There is a `clang::CallGraph` functionality that could be 
> > > > > used instead of `FunctionCallCollector` but the `CallExpr` for the 
> > > > > calls is not provided by it so it does not work for this case. Maybe 
> > > > > there is other similar functionality that is usable?
> > > > Given that we want it in the CERT module, we should try to ensure it 
> > > > follows the rule as closely as we can. I went and checked what the C++ 
> > > > rules say about this and... it was interesting to notice that SIG30-C 
> > > > is not one of the C rules included by reference in C++ 
> > > > (https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=88046336).
> > > > 
> > > > It's not clear to me that this rule was accidentally tagged as 
> > > > `not-for-cpp` or not, so I'd say it's fine to ignore lambdas for the 
> > > > moment but we may have some follow-up work if CERT changes the rule to 
> > > > be included in C++. My recommendation is: make the check a C-only check 
> > > > for now, document it as such, and I'll ping the folks at CERT to see if 
> > > > this rule was mistagged or not. WDYT?
> > > Ah, this rule really is a C-only rule, because 
> > > https://wiki.sei.cmu.edu/confluence/display/cplusplus/MSC54-CPP.+A+signal+handler+must+be+a+plain+old+function
> > >  is the C++ rule. So I think the SIG30-C checker should be run in C-only 
> > > mode and we can ignore the C++isms in it.
> > > 
> > > FWIW, we have an ongoing discussion about MSC54-CPP in 
> > > https://reviews.llvm.org/D33825.
> > Probably this checker can be merged with the other in D33825. According to 
> > cppreference (https://en.cppreference.com/w/cpp/utility/program/signal) the 
> > check for the called functions should be present for C++ too. And the other 
> > checker should do a similar lookup of called functions as this checker, 
> > including lambdas and C++ specific things.
> While you would think that, it's a bit more complicated unfortunately. The 
> C++ committee has been moving forward with this paper http://wg21.link/p0270 
> so that C++ is no longer tied to the same constraints as C. That may suggest 
> that separate checks are appropriate, or it may still mean we want to merge 
> the checks into one.
I think it is more convenient to merge the two checkers. The visitation of 
called functions goes the same way, the support for C++ constructs should not 
cause problems if used with C code. The handling of a detected function can be 
different code for C and C++ mode but if there are similar parts code can be 
reused.
Otherwise code of this checker would be a better starting point for 
"SignalHandlerMustBePlainOldFunctionCheck" because it handles detection of the 
`signal` function already better specially for C++.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87449

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


[PATCH] D89136: Lex: Avoid MemoryBuffer* key in ExcludedPreprocessorDirectiveSkipMapping, NFC

2020-10-09 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added a reviewer: arphaman.
Herald added a subscriber: ributzka.
dexonsmith requested review of this revision.

This is a prep patch for https://reviews.llvm.org/D66782, changing 
SourceManager to return `Optional` instead of `MemoryBuffer`. 
With that change the address of the MemoryBuffer will be gone, so instead use 
the start of the buffer as the key for this map.

No functionality change intended.

Radar-Id: rdar://70139990


https://reviews.llvm.org/D89136

Files:
  clang/include/clang/Lex/PreprocessorExcludedConditionalDirectiveSkipMapping.h
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp


Index: clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -219,7 +219,9 @@
 
   llvm::ErrorOr status() override { return Stat; }
 
-  const llvm::MemoryBuffer *getBufferPtr() const { return Buffer.get(); }
+  const char *getBufferPtr() const {
+return Buffer ? nullptr : Buffer->getBufferStart();
+  }
 
   llvm::ErrorOr>
   getBuffer(const Twine &Name, int64_t FileSize, bool RequiresNullTerminator,
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -380,7 +380,10 @@
   std::pair HashFileOffset =
   SourceMgr.getDecomposedLoc(HashLoc);
   const llvm::MemoryBuffer *Buf = SourceMgr.getBuffer(HashFileOffset.first);
-  auto It = ExcludedConditionalDirectiveSkipMappings->find(Buf);
+  if (!Buf)
+return None;
+  auto It =
+  ExcludedConditionalDirectiveSkipMappings->find(Buf->getBufferStart());
   if (It == ExcludedConditionalDirectiveSkipMappings->end())
 return None;
 
Index: 
clang/include/clang/Lex/PreprocessorExcludedConditionalDirectiveSkipMapping.h
===
--- 
clang/include/clang/Lex/PreprocessorExcludedConditionalDirectiveSkipMapping.h
+++ 
clang/include/clang/Lex/PreprocessorExcludedConditionalDirectiveSkipMapping.h
@@ -23,8 +23,7 @@
 /// The datastructure that holds the mapping between the active memory buffers
 /// and the individual skip mappings.
 using ExcludedPreprocessorDirectiveSkipMapping =
-llvm::DenseMap;
+llvm::DenseMap;
 
 } // end namespace clang
 


Index: clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -219,7 +219,9 @@
 
   llvm::ErrorOr status() override { return Stat; }
 
-  const llvm::MemoryBuffer *getBufferPtr() const { return Buffer.get(); }
+  const char *getBufferPtr() const {
+return Buffer ? nullptr : Buffer->getBufferStart();
+  }
 
   llvm::ErrorOr>
   getBuffer(const Twine &Name, int64_t FileSize, bool RequiresNullTerminator,
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -380,7 +380,10 @@
   std::pair HashFileOffset =
   SourceMgr.getDecomposedLoc(HashLoc);
   const llvm::MemoryBuffer *Buf = SourceMgr.getBuffer(HashFileOffset.first);
-  auto It = ExcludedConditionalDirectiveSkipMappings->find(Buf);
+  if (!Buf)
+return None;
+  auto It =
+  ExcludedConditionalDirectiveSkipMappings->find(Buf->getBufferStart());
   if (It == ExcludedConditionalDirectiveSkipMappings->end())
 return None;
 
Index: clang/include/clang/Lex/PreprocessorExcludedConditionalDirectiveSkipMapping.h
===
--- clang/include/clang/Lex/PreprocessorExcludedConditionalDirectiveSkipMapping.h
+++ clang/include/clang/Lex/PreprocessorExcludedConditionalDirectiveSkipMapping.h
@@ -23,8 +23,7 @@
 /// The datastructure that holds the mapping between the active memory buffers
 /// and the individual skip mappings.
 using ExcludedPreprocessorDirectiveSkipMapping =
-llvm::DenseMap;
+llvm::DenseMap;
 
 } // end namespace clang
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88314: Added llvm-string-referencing check

2020-10-09 Thread Bogdan Serea via Phabricator via cfe-commits
bogser01 updated this revision to Diff 297246.
bogser01 added a comment.

Added documentation & Nit fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88314

Files:
  clang-tools-extra/clang-tidy/llvm/StringReferencingCheck.cpp
  clang-tools-extra/docs/clang-tidy/checks/llvm-string-referencing.rst
  clang-tools-extra/test/clang-tidy/checkers/llvm-string-referencing.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/llvm-string-referencing.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/llvm-string-referencing.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/llvm-string-referencing.cpp
@@ -15,41 +15,41 @@
 namespace A {
 using namespace std;
 void f(const string &P);
-// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: Use of const std::string & is discouraged in the LLVM Programmer's Manual [llvm-string-referencing]
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: parameter of type 'const std::string &' could potentially be replaced with 'llvm::StringRef' [llvm-string-referencing]
 // CHECK-FIXES: void f(llvm::StringRef P);{{$}}
 } // namespace A
 
 namespace B {
 using std::string;
 void f1(const string &P);
-// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: Use of const std::string & is discouraged in the LLVM Programmer's Manual [llvm-string-referencing]
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter of type 'const std::string &' could potentially be replaced with 'llvm::StringRef' [llvm-string-referencing]
 // CHECK-FIXES: void f1(llvm::StringRef P);{{$}}
 } // namespace B
 
 void f2(std::string, int, const std::string &);
-// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: Use of const std::string & is discouraged in the LLVM Programmer's Manual [llvm-string-referencing]
+// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: parameter of type 'const std::string &' could potentially be replaced with 'llvm::StringRef' [llvm-string-referencing]
 // CHECK-FIXES: void f2(std::string, int, llvm::StringRef );{{$}}
 void f2(std::string P, int x, const std::string &P2) {
-  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: Use of const std::string & is discouraged in the LLVM Programmer's Manual [llvm-string-referencing]
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: parameter of type 'const std::string &' could potentially be replaced with 'llvm::StringRef' [llvm-string-referencing]
   // CHECK-FIXES: void f2(std::string P, int x, llvm::StringRef P2) {{{$}}
   return;
 }
 
 void f3(const std::string &P1, const std::string &P2);
-// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: Use of const std::string & is discouraged in the LLVM Programmer's Manual [llvm-string-referencing]
-// CHECK-MESSAGES: :[[@LINE-2]]:32: warning: Use of const std::string & is discouraged in the LLVM Programmer's Manual [llvm-string-referencing]
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter of type 'const std::string &' could potentially be replaced with 'llvm::StringRef' [llvm-string-referencing]
+// CHECK-MESSAGES: :[[@LINE-2]]:32: warning: parameter of type 'const std::string &' could potentially be replaced with 'llvm::StringRef' [llvm-string-referencing]
 // CHECK-FIXES: void f3(llvm::StringRef P1, llvm::StringRef P2);{{$}}
 
 struct St {
   void operator=(const std::string &Val) const {
-// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: Use of const std::string & is discouraged in the LLVM Programmer's Manual [llvm-string-referencing]
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: parameter of type 'const std::string &' could potentially be replaced with 'llvm::StringRef' [llvm-string-referencing]
 // CHECK-FIXES: void operator=(llvm::StringRef Val) const {{{$}}
 return;
   }
 };
 
 void f7(const std::string &);
-// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: Use of const std::string & is discouraged in the LLVM Programmer's Manual [llvm-string-referencing]
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter of type 'const std::string &' could potentially be replaced with 'llvm::StringRef' [llvm-string-referencing]
 // CHECK-FIXES: void f7(llvm::StringRef );{{$}}
 
 // Functions below this line should not trigger the check
Index: clang-tools-extra/docs/clang-tidy/checks/llvm-string-referencing.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/llvm-string-referencing.rst
+++ clang-tools-extra/docs/clang-tidy/checks/llvm-string-referencing.rst
@@ -3,4 +3,15 @@
 llvm-string-referencing
 ===
 
-FIXME: Describe what patterns does the check detect and why. Give examples.
+The StringRef data type represents a reference to a constant string (a 
+character array and a length) and supports the common operations available
+on std::string. The LLVM Programmer's Manual recommends the use of StringRef
+instead 'const std::string &'
+https://llvm.org/docs/ProgrammersManual.html#id14
+
+The check warns about u

[PATCH] D66782: SourceManager: Prefer Optional over MemoryBuffer*

2020-10-09 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith updated this revision to Diff 297245.
dexonsmith added a comment.

Rebased (on top of https://reviews.llvm.org/D89136).


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

https://reviews.llvm.org/D66782

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
  clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
  clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp
  clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
  clang-tools-extra/clangd/Format.cpp
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/modularize/PreprocessorTracker.cpp
  clang/include/clang/Basic/SourceManager.h
  clang/include/clang/Frontend/FrontendAction.h
  clang/include/clang/Frontend/FrontendOptions.h
  clang/include/clang/Frontend/PrecompiledPreamble.h
  clang/include/clang/Lex/Lexer.h
  clang/include/clang/Lex/PreprocessorExcludedConditionalDirectiveSkipMapping.h
  clang/lib/ARCMigrate/Transforms.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/Basic/Diagnostic.cpp
  clang/lib/Basic/SourceLocation.cpp
  clang/lib/Basic/SourceManager.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/MacroExpander.cpp
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Frontend/PrecompiledPreamble.cpp
  clang/lib/Frontend/Rewrite/HTMLPrint.cpp
  clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
  clang/lib/Frontend/Rewrite/RewriteMacros.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Frontend/Rewrite/RewriteObjC.cpp
  clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
  clang/lib/Lex/Lexer.cpp
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Rewrite/HTMLRewrite.cpp
  clang/lib/Rewrite/TokenRewriter.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
  clang/lib/StaticAnalyzer/Core/BugReporter.cpp
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/IssueHash.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
  clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
  clang/tools/clang-diff/ClangDiff.cpp
  clang/tools/clang-import-test/clang-import-test.cpp
  clang/tools/libclang/CIndex.cpp
  clang/unittests/Format/TestLexer.h
  llvm/include/llvm/Support/LineIterator.h
  llvm/include/llvm/Support/MemoryBuffer.h
  llvm/lib/Support/LineIterator.cpp

Index: llvm/lib/Support/LineIterator.cpp
===
--- llvm/lib/Support/LineIterator.cpp
+++ llvm/lib/Support/LineIterator.cpp
@@ -31,27 +31,37 @@
   return false;
 }
 
+line_iterator::line_iterator(const MemoryBufferRef &Buffer, bool SkipBlanks,
+ char CommentMarker)
+: line_iterator(StringRef(Buffer.getBufferStart(), Buffer.getBufferSize()),
+SkipBlanks, CommentMarker) {}
+
 line_iterator::line_iterator(const MemoryBuffer &Buffer, bool SkipBlanks,
  char CommentMarker)
-: Buffer(Buffer.getBufferSize() ? &Buffer : nullptr),
+: line_iterator(StringRef(Buffer.getBufferStart(), Buffer.getBufferSize()),
+SkipBlanks, CommentMarker) {}
+
+line_iterator::line_iterator(StringRef Buffer, bool SkipBlanks,
+ char CommentMarker)
+: Buffer(Buffer.empty() ? Optional(None) : Buffer),
   CommentMarker(CommentMarker), SkipBlanks(SkipBlanks), LineNumber(1),
-  CurrentLine(Buffer.getBufferSize() ? Buffer.getBufferStart() : nullptr,
-  0) {
+  CurrentLine(Buffer.empty() ? nullptr : Buffer.begin(), 0) {
   // Ensure that if we are constructed on a non-empty memory buffer that it is
   // a null terminated buffer.
-  if (Buffer.getBufferSize()) {
-assert(Buffer.getBufferEnd()[0] == '\0');
-// Make sure we don't skip a leading newline if we're keeping blanks
-if (SkipBlanks || !isAtLineEnd(Buffer.getBufferStart()))
-  advance();
-  }
+  if (Buffer.empty())
+return;
+
+  assert(Buffer.end()[0] == '\0');
+  // Make sure we don't skip a leading newline if we're keeping blanks
+  if (SkipBlanks || !isAtLineEnd(Buffer.begin()))
+advance();
 }
 
 void line_iterator::advance() {
   assert(Buffer && "Cannot advance past the end!");
 
   const char *Pos = CurrentLine.end();
-  assert(Pos == Buffer->getBufferStart() || isAtLineEnd(Pos) || *Pos == '\0');
+  assert(Pos == Buffer->begin() || isAtLineEnd(Pos) || *Pos == '\0');
 
   if (skipIfAtLin

[PATCH] D88666: DirectoryWatcher: add an implementation for Windows

2020-10-09 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth accepted this revision.
amccarth added a comment.
This revision is now accepted and ready to land.

LGTM.  Thanks for extending this functionality to Windows!




Comment at: clang/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp:15
+#include "llvm/Support/Windows/WindowsSupport.h"
 #include 
 #include 

I don't see a reason to include `` here.



Comment at: clang/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp:77
+  void WatcherThreadProc(HANDLE DirectoryHandle);
+  void NotifierThreadProc(bool WaitForInitialSync);
 };

I like the name change from HandlerThread to NotifierThread.  Thanks!


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

https://reviews.llvm.org/D88666

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


[PATCH] D88645: [Annotation] Allows annotation to carry some additional constant arguments.

2020-10-09 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

(Drive By: This is cool)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88645

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


[PATCH] D89001: [clang] Don't look into for C++ headers if they are found alongside the toolchain

2020-10-09 Thread Louis Dionne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa3a24316087d: [clang] Don't look into  
for C++ headers if they are found alongside… (authored by ldionne).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89001

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/Inputs/basic_darwin_sdk_usr_cxx_v1/usr/include/c++/v1/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_usr_cxx_v1/usr/lib/.keep
  clang/test/Driver/darwin-header-search-libcxx.cpp

Index: clang/test/Driver/darwin-header-search-libcxx.cpp
===
--- clang/test/Driver/darwin-header-search-libcxx.cpp
+++ clang/test/Driver/darwin-header-search-libcxx.cpp
@@ -13,39 +13,57 @@
 // RUN:   | FileCheck --check-prefix=CHECK-LIBCXX-NONE %s
 // CHECK-LIBCXX-NONE: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
 
-// Check with only headers alongside the installation (those should be used,
-// but we should still add /usr/include/c++/v1 after to preserve legacy).
+// Check with only headers alongside the installation (those should be used).
 //
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
 // RUN: -target x86_64-apple-darwin \
 // RUN: -stdlib=libc++ \
 // RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \
 // RUN: --sysroot="" \
-// RUN:   | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain --check-prefix=CHECK-LIBCXX-TOOLCHAIN-1 %s
+// RUN:   | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \
+// RUN:   --check-prefix=CHECK-LIBCXX-TOOLCHAIN-1 %s
 // CHECK-LIBCXX-TOOLCHAIN-1: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
 // CHECK-LIBCXX-TOOLCHAIN-1: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1"
-// CHECK-LIBCXX-TOOLCHAIN-1: "-internal-isystem" "/usr/include/c++/v1"
+// CHECK-LIBCXX-TOOLCHAIN-1-NOT: "-internal-isystem" "/usr/include/c++/v1"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
 // RUN: -target x86_64-apple-darwin \
 // RUN: -stdlib=libc++ \
 // RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \
 // RUN: -isysroot %S/Inputs/basic_darwin_sdk_no_libcxx \
-// RUN:   | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain --check-prefix=CHECK-LIBCXX-TOOLCHAIN-2 %s
+// RUN:   | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \
+// RUN:   -DSYSROOT=%S/Inputs/basic_darwin_sdk_no_libcxx \
+// RUN:   --check-prefix=CHECK-LIBCXX-TOOLCHAIN-2 %s
 // CHECK-LIBCXX-TOOLCHAIN-2: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
 // CHECK-LIBCXX-TOOLCHAIN-2: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1"
+// CHECK-LIBCXX-TOOLCHAIN-2-NOT: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1"
+
+// Check with only headers in the sysroot (those should be used).
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-apple-darwin \
+// RUN: -stdlib=libc++ \
+// RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \
+// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr_cxx_v1 \
+// RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_cxx_v1 \
+// RUN:   -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain_no_libcxx \
+// RUN:   --check-prefix=CHECK-LIBCXX-SYSROOT-1 %s
+// CHECK-LIBCXX-SYSROOT-1: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-LIBCXX-SYSROOT-1: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1"
+// CHECK-LIBCXX-SYSROOT-1-NOT: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1"
 
 // Check with both headers in the sysroot and headers alongside the installation
-// (the headers in  should be added after the toolchain headers).
-// Ensure that both -isysroot and --sysroot work, and that isysroot has precedence.
+// (the headers in the toolchain should be preferred over the  headers).
+// Ensure that both -isysroot and --sysroot work, and that isysroot has precedence
+// over --sysroot.
 //
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
 // RUN: -target x86_64-apple-darwin \
 // RUN: -stdlib=libc++ \
 // RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
-// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr \
-// RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr \
+// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr_cxx_v1 \
+// RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_cxx_v1 \
 // RUN:   -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \
 // RUN:   --check-prefix=CHECK-LIBCXX-SYSROOT_AND_TOOLCHAIN-1 %s
 //
@@ -54,8 +72,8 @@
 // RUN: -stdlib=libc++ \
 // RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
-// RUN: --sysroot %S/Inputs/basic_darwin_sdk_usr \
-// RUN:   | FileCheck -D

[PATCH] D87528: Enable '#pragma STDC FENV_ACCESS' in frontend cf. D69272 - Work in Progress

2020-10-09 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 297260.
mibintc added a comment.

I rebased the patch
I added documentation to UserManual showing that -ffp-model=strict enables 
FENV_ACCESS
I removed ActOnAfterCompoundStatementLeadingPragmas since it was redundant with 
work being done in ActOnCompoundStmt

This patch is based on D69272 , perhaps i 
should merge both patches and upload them into this single review?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87528

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/AST/const-fpfeatures-diag.c
  clang/test/CXX/expr/expr.const/p2-0x.cpp
  clang/test/CodeGen/fp-floatcontrol-pragma.cpp
  clang/test/CodeGen/pragma-fenv_access.c
  clang/test/Parser/fp-floatcontrol-syntax.cpp
  clang/test/Parser/pragma-fenv_access.c
  clang/test/Preprocessor/pragma_unknown.c

Index: clang/test/Preprocessor/pragma_unknown.c
===
--- clang/test/Preprocessor/pragma_unknown.c
+++ clang/test/Preprocessor/pragma_unknown.c
@@ -16,15 +16,6 @@
 // CHECK: {{^}}#pragma STDC FP_CONTRACT DEFAULT{{$}}
 // CHECK: {{^}}#pragma STDC FP_CONTRACT IN_BETWEEN{{$}}
 
-#pragma STDC FENV_ACCESS ON  // expected-warning {{pragma STDC FENV_ACCESS ON is not supported, ignoring pragma}}
-#pragma STDC FENV_ACCESS OFF
-#pragma STDC FENV_ACCESS DEFAULT
-#pragma STDC FENV_ACCESS IN_BETWEEN   // expected-warning {{expected 'ON' or 'OFF' or 'DEFAULT' in pragma}}
-// CHECK: {{^}}#pragma STDC FENV_ACCESS ON{{$}}
-// CHECK: {{^}}#pragma STDC FENV_ACCESS OFF{{$}}
-// CHECK: {{^}}#pragma STDC FENV_ACCESS DEFAULT{{$}}
-// CHECK: {{^}}#pragma STDC FENV_ACCESS IN_BETWEEN{{$}}
-
 #pragma STDC CX_LIMITED_RANGE ON
 #pragma STDC CX_LIMITED_RANGE OFF
 #pragma STDC CX_LIMITED_RANGE DEFAULT 
Index: clang/test/Parser/pragma-fenv_access.c
===
--- /dev/null
+++ clang/test/Parser/pragma-fenv_access.c
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -ffp-exception-behavior=strict -DSTRICT -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x c++ -DCPP -DSTRICT -ffp-exception-behavior=strict -fsyntax-only -verify %s
+#ifdef CPP
+#define CONST constexpr
+#else
+#define CONST const
+#endif
+
+#pragma STDC FENV_ACCESS IN_BETWEEN   // expected-warning {{expected 'ON' or 'OFF' or 'DEFAULT' in pragma}}
+
+#pragma STDC FENV_ACCESS OFF
+
+float func_04(int x, float y) {
+  if (x)
+return y + 2;
+  #pragma STDC FENV_ACCESS ON // expected-error{{'#pragma STDC FENV_ACCESS' can only appear at file scope or at the start of a compound statement}}
+  return x + y;
+}
+
+#pragma STDC FENV_ACCESS ON
+int main() {
+  CONST float one = 1.0F ;
+  CONST float three = 3.0F ;
+  CONST float four = 4.0F ;
+  CONST float frac_ok = one/four;
+#if defined(CPP) & defined(STRICT)
+//expected-error@+3 {{constexpr variable 'frac' must be initialized by a constant expression}}
+//expected-note@+2 {{compile time floating point arithmetic suppressed in strict evaluation modes}}
+#endif
+  CONST float frac = one/three; // rounding
+  CONST double d = one;
+  CONST int not_too_big = 255;
+  CONST float fnot_too_big = not_too_big;
+  CONST int too_big = 0x7ff0;
+#if defined(CPP) & defined(STRICT)
+//expected-error@+6 {{constexpr variable 'fbig' must be initialized by a constant expression}}
+//expected-note@+5 {{compile time floating point arithmetic suppressed in strict evaluation modes}}
+#endif
+#if defined(CPP)
+//expected-warning@+2{{implicit conversion}}
+#endif
+  CONST float fbig = too_big; // inexact
+  if (one <= four)  return 0;
+  return -1;
+}
Index: clang/test/Parser/fp-floatcontrol-syntax.cpp
===
--- clang/test/Parser/fp-floatcontrol-syntax.cpp
+++ clang/test/Parser/fp-floatcontrol-syntax.cpp
@@ -26,19 +26,13 @@
 double a = 0.0;
 double b = 1.0;
 
-//FIXME At some point this warning will be removed, until then
-//  document the warning
-#ifdef FAST
-// expected-warning@+1{{pragma STDC FENV_ACCESS ON is not supported, ignoring pragma}}
-#pragma STDC FENV_ACCESS ON
-#else
-#pragma STDC FENV_ACCESS ON // expected-warning{{pragma STDC FENV_ACCESS ON is not supported, ignoring pragma}}
-#endif
 #ifdef STRICT
 #pragma float_control(precise, off) // expected-error {{'#pragma float_control(precise, off)' is illegal when except is enabled}}
 #else
-// Currently FENV_ACCESS cannot be enabled by pragma, skip error check
-#

[clang] a3a2431 - [clang] Don't look into for C++ headers if they are found alongside the toolchain

2020-10-09 Thread Louis Dionne via cfe-commits

Author: Louis Dionne
Date: 2020-10-09T12:41:41-04:00
New Revision: a3a24316087d0e1b4db0b8fee19cdee8b7968032

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

LOG: [clang] Don't look into  for C++ headers if they are found 
alongside the toolchain

Currently, Clang looks for libc++ headers alongside the installation
directory of Clang, and it also adds a search path for headers in the
-isysroot. This is problematic if headers are found in both the toolchain
and in the sysroot, since #include_next will end up finding the libc++
headers in the sysroot instead of the intended system headers.

This patch changes the logic such that if the toolchain contains libc++
headers, no C++ header paths are added in the sysroot. However, if the
toolchain does *not* contain libc++ headers, the sysroot is searched as
usual.

This should not be a breaking change, since any code that previously
relied on some libc++ headers being found in the sysroot suffered from
the #include_next issue described above, which renders any libc++ header
basically useless.

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

Added: 

clang/test/Driver/Inputs/basic_darwin_sdk_usr_cxx_v1/usr/include/c++/v1/.keep
clang/test/Driver/Inputs/basic_darwin_sdk_usr_cxx_v1/usr/lib/.keep

Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/darwin-header-search-libcxx.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 0d9e471ec070..c847be9ee266 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2020,21 +2020,42 @@ void DarwinClang::AddClangCXXStdlibIncludeArgs(
 
   switch (GetCXXStdlibType(DriverArgs)) {
   case ToolChain::CST_Libcxx: {
-// On Darwin, libc++ is installed alongside the compiler in
-// include/c++/v1, so get from '/bin' to 
'/include/c++/v1'.
-{
-  llvm::SmallString<128> P = 
llvm::StringRef(getDriver().getInstalledDir());
-  // Note that P can be relative, so we have to '..' and not parent_path.
-  llvm::sys::path::append(P, "..", "include", "c++", "v1");
-  addSystemInclude(DriverArgs, CC1Args, P);
+// On Darwin, libc++ can be installed in one of the following two places:
+// 1. Alongside the compiler in /include/c++/v1
+// 2. In a SDK (or a custom sysroot) in /usr/include/c++/v1
+//
+// The precendence of paths is as listed above, i.e. we take the first path
+// that exists. Also note that we never include libc++ twice -- we take the
+// first path that exists and don't send the other paths to CC1 (otherwise
+// include_next could break).
+
+// Check for (1)
+// Get from '/bin' to '/include/c++/v1'.
+// Note that InstallBin can be relative, so we use '..' instead of
+// parent_path.
+llvm::SmallString<128> InstallBin =
+llvm::StringRef(getDriver().getInstalledDir()); // /bin
+llvm::sys::path::append(InstallBin, "..", "include", "c++", "v1");
+if (getVFS().exists(InstallBin)) {
+  addSystemInclude(DriverArgs, CC1Args, InstallBin);
+  return;
+} else if (DriverArgs.hasArg(options::OPT_v)) {
+  llvm::errs() << "ignoring nonexistent directory \"" << InstallBin
+   << "\"\n";
 }
-// Also add /usr/include/c++/v1 unless -nostdinc is used,
-// to match the legacy behavior in CC1.
-if (!DriverArgs.hasArg(options::OPT_nostdinc)) {
-  llvm::SmallString<128> P = Sysroot;
-  llvm::sys::path::append(P, "usr", "include", "c++", "v1");
-  addSystemInclude(DriverArgs, CC1Args, P);
+
+// Otherwise, check for (2)
+llvm::SmallString<128> SysrootUsr = Sysroot;
+llvm::sys::path::append(SysrootUsr, "usr", "include", "c++", "v1");
+if (getVFS().exists(SysrootUsr)) {
+  addSystemInclude(DriverArgs, CC1Args, SysrootUsr);
+  return;
+} else if (DriverArgs.hasArg(options::OPT_v)) {
+  llvm::errs() << "ignoring nonexistent directory \"" << SysrootUsr
+   << "\"\n";
 }
+
+// Otherwise, don't add any path.
 break;
   }
 

diff  --git 
a/clang/test/Driver/Inputs/basic_darwin_sdk_usr_cxx_v1/usr/include/c++/v1/.keep 
b/clang/test/Driver/Inputs/basic_darwin_sdk_usr_cxx_v1/usr/include/c++/v1/.keep
new file mode 100644
index ..e69de29bb2d1

diff  --git 
a/clang/test/Driver/Inputs/basic_darwin_sdk_usr_cxx_v1/usr/lib/.keep 
b/clang/test/Driver/Inputs/basic_darwin_sdk_usr_cxx_v1/usr/lib/.keep
new file mode 100644
index ..e69de29bb2d1

diff  --git a/clang/test/Driver/darwin-header-search-libcxx.cpp 
b/clang/test/Driver/darwin-header-search-libcxx.cpp
index 6bdbbd11908a..4824525f1cf4 100644
--- a/clang/test/Driver/darwin-header-search-libcxx.cpp
+++ b/clang/test/D

[PATCH] D87528: Enable '#pragma STDC FENV_ACCESS' in frontend cf. D69272 - Work in Progress

2020-10-09 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

In D88498  @rsmith wrote,
s far from clear to me that this is correct in C++. In principle, for a dynamic 
initializer, the rounding mode could have been set by an earlier initializer.

Perhaps we can make an argument that, due to the permission to interleave 
initializers from different TUs, every dynamic initializer must leave the 
program in the default rounding mode, but I don't think even that makes this 
approach correct, because an initializer could do this:

double d;
double e = (fesetround(...), d = some calculation, fesetround(...default...), 
d);
I think we can only do this in C and will need something different for C++.

(I think this also has problems in C++ due to constexpr functions: it's not the 
case that all floating point operations that will be evaluated as part of the 
initializer lexically appear within it.)

For the initialization expression to be correct, the RoundingMode at the 
declaration of e needs to be set to Dynamic, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87528

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


[PATCH] D89143: [OpenCL][Docs] Improved description of the supported language functionality.

2020-10-09 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added reviewers: azabaznov, svenvh.
Herald added subscribers: ebevhan, yaxunl.
Anastasia requested review of this revision.

As suggested on RFC: 
http://lists.llvm.org/pipermail/cfe-dev/2020-October/066932.html


https://reviews.llvm.org/D89143

Files:
  clang/docs/UsersManual.rst


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -2714,6 +2714,9 @@
 `_) or
 into generic bitcode files loadable into other toolchains.
 
+Clang only supports the full OpenCL profile, and not `the embedded profile
+`_.
+
 Compiling to a binary using the default target from the installation can be 
done
 as follows:
 


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -2714,6 +2714,9 @@
 `_) or
 into generic bitcode files loadable into other toolchains.
 
+Clang only supports the full OpenCL profile, and not `the embedded profile
+`_.
+
 Compiling to a binary using the default target from the installation can be done
 as follows:
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89143: [OpenCL][Docs] Improved description of the supported language functionality.

2020-10-09 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/docs/UsersManual.rst:2718
+Clang only supports the full OpenCL profile, and not `the embedded profile
+`_.
+

I am surprised this doesn't appear on the registry page though. It would be 
nicer to link a pdf or an html instead of sources. 


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

https://reviews.llvm.org/D89143

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


[PATCH] D89146: [SyntaxTree] Fix rtti for `Expression`.

2020-10-09 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
eduucaldas added a reviewer: gribozavr2.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89146

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


Index: clang/include/clang/Tooling/Syntax/Nodes.h
===
--- clang/include/clang/Tooling/Syntax/Nodes.h
+++ clang/include/clang/Tooling/Syntax/Nodes.h
@@ -206,7 +206,7 @@
   Expression(NodeKind K) : Tree(K) {}
   static bool classof(const Node *N) {
 return NodeKind::UnknownExpression <= N->getKind() &&
-   N->getKind() <= NodeKind::UnknownExpression;
+   N->getKind() <= NodeKind::CallExpression;
   }
 };
 


Index: clang/include/clang/Tooling/Syntax/Nodes.h
===
--- clang/include/clang/Tooling/Syntax/Nodes.h
+++ clang/include/clang/Tooling/Syntax/Nodes.h
@@ -206,7 +206,7 @@
   Expression(NodeKind K) : Tree(K) {}
   static bool classof(const Node *N) {
 return NodeKind::UnknownExpression <= N->getKind() &&
-   N->getKind() <= NodeKind::UnknownExpression;
+   N->getKind() <= NodeKind::CallExpression;
   }
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >