r366782 - [CrossTU] Added CTU argument to diagnostic consumer create fn.

2019-07-23 Thread Balazs Keri via cfe-commits
Author: balazske
Date: Tue Jul 23 00:04:20 2019
New Revision: 366782

URL: http://llvm.org/viewvc/llvm-project?rev=366782&view=rev
Log:
[CrossTU] Added CTU argument to diagnostic consumer create fn.

Summary:
The PListDiagnosticConsumer needs a new CTU parameter that is passed
through the create functions.

Reviewers: NoQ, Szelethus, xazax.hun, martong

Reviewed By: Szelethus

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h
cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h?rev=366782&r1=366781&r2=366782&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h Tue 
Jul 23 00:04:20 2019
@@ -20,17 +20,19 @@ namespace clang {
 
 class AnalyzerOptions;
 class Preprocessor;
+namespace cross_tu {
+class CrossTranslationUnitContext;
+}
 
 namespace ento {
 
 class PathDiagnosticConsumer;
 typedef std::vector PathDiagnosticConsumers;
 
-#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN)\
-void CREATEFN(AnalyzerOptions &AnalyzerOpts,\
-  PathDiagnosticConsumers &C,\
-  const std::string &Prefix,\
-  const Preprocessor &PP);
+#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN)
\
+  void CREATEFN(AnalyzerOptions &AnalyzerOpts, PathDiagnosticConsumers &C, 
\
+const std::string &Prefix, const Preprocessor &PP, 
\
+const cross_tu::CrossTranslationUnitContext &CTU);
 #include "clang/StaticAnalyzer/Core/Analyses.def"
 
 } // end 'ento' namespace

Modified: cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp?rev=366782&r1=366781&r2=366782&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp Tue Jul 23 00:04:20 
2019
@@ -134,17 +134,17 @@ private:
 
 } // namespace
 
-void ento::createHTMLDiagnosticConsumer(AnalyzerOptions &AnalyzerOpts,
-PathDiagnosticConsumers &C,
-const std::string& prefix,
-const Preprocessor &PP) {
+void ento::createHTMLDiagnosticConsumer(
+AnalyzerOptions &AnalyzerOpts, PathDiagnosticConsumers &C,
+const std::string &prefix, const Preprocessor &PP,
+const cross_tu::CrossTranslationUnitContext &) {
   C.push_back(new HTMLDiagnostics(AnalyzerOpts, prefix, PP, true));
 }
 
-void ento::createHTMLSingleFileDiagnosticConsumer(AnalyzerOptions 
&AnalyzerOpts,
-  PathDiagnosticConsumers &C,
-  const std::string& prefix,
-  const Preprocessor &PP) {
+void ento::createHTMLSingleFileDiagnosticConsumer(
+AnalyzerOptions &AnalyzerOpts, PathDiagnosticConsumers &C,
+const std::string &prefix, const Preprocessor &PP,
+const cross_tu::CrossTranslationUnitContext &) {
   C.push_back(new HTMLDiagnostics(AnalyzerOpts, prefix, PP, false));
 }
 

Modified: cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp?rev=366782&r1=366781&r2=366782&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp Tue Jul 23 00:04:20 
2019
@@ -14,6 +14,7 @@
 #include "clang/Basic/PlistSupport.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Version.h"
+#include "clang/CrossTU/CrossTranslationUnit.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/TokenConcatenation.h"
 #include "clang/Rewrite/Core/HTMLRewrite.h"
@@ -21,9 +22,9 @@
 #include "clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h"
 #include "clang/StaticAnalyzer/Core/IssueHash.h"
 #include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h"
-#include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/Statistic.h"
 #include "llvm/Support/Casting.h"

[PATCH] D64635: [CrossTU] Added CTU argument to diagnostic consumer create fn.

2019-07-23 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366782: [CrossTU] Added CTU argument to diagnostic consumer 
create fn. (authored by balazske, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64635?vs=209480&id=211253#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64635

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h
  cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Index: cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
@@ -43,10 +43,10 @@
 };
 } // end anonymous namespace
 
-void ento::createSarifDiagnosticConsumer(AnalyzerOptions &AnalyzerOpts,
- PathDiagnosticConsumers &C,
- const std::string &Output,
- const Preprocessor &) {
+void ento::createSarifDiagnosticConsumer(
+AnalyzerOptions &AnalyzerOpts, PathDiagnosticConsumers &C,
+const std::string &Output, const Preprocessor &,
+const cross_tu::CrossTranslationUnitContext &) {
   C.push_back(new SarifDiagnostics(AnalyzerOpts, Output));
 }
 
Index: cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -134,17 +134,17 @@
 
 } // namespace
 
-void ento::createHTMLDiagnosticConsumer(AnalyzerOptions &AnalyzerOpts,
-PathDiagnosticConsumers &C,
-const std::string& prefix,
-const Preprocessor &PP) {
+void ento::createHTMLDiagnosticConsumer(
+AnalyzerOptions &AnalyzerOpts, PathDiagnosticConsumers &C,
+const std::string &prefix, const Preprocessor &PP,
+const cross_tu::CrossTranslationUnitContext &) {
   C.push_back(new HTMLDiagnostics(AnalyzerOpts, prefix, PP, true));
 }
 
-void ento::createHTMLSingleFileDiagnosticConsumer(AnalyzerOptions &AnalyzerOpts,
-  PathDiagnosticConsumers &C,
-  const std::string& prefix,
-  const Preprocessor &PP) {
+void ento::createHTMLSingleFileDiagnosticConsumer(
+AnalyzerOptions &AnalyzerOpts, PathDiagnosticConsumers &C,
+const std::string &prefix, const Preprocessor &PP,
+const cross_tu::CrossTranslationUnitContext &) {
   C.push_back(new HTMLDiagnostics(AnalyzerOpts, prefix, PP, false));
 }
 
Index: cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -14,6 +14,7 @@
 #include "clang/Basic/PlistSupport.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Version.h"
+#include "clang/CrossTU/CrossTranslationUnit.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/TokenConcatenation.h"
 #include "clang/Rewrite/Core/HTMLRewrite.h"
@@ -21,9 +22,9 @@
 #include "clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h"
 #include "clang/StaticAnalyzer/Core/IssueHash.h"
 #include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h"
-#include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/Statistic.h"
 #include "llvm/Support/Casting.h"
 
 using namespace clang;
@@ -39,12 +40,13 @@
   class PlistDiagnostics : public PathDiagnosticConsumer {
 const std::string OutputFile;
 const Preprocessor &PP;
+const cross_tu::CrossTranslationUnitContext &CTU;
 AnalyzerOptions &AnOpts;
 const bool SupportsCrossFileDiagnostics;
   public:
-PlistDiagnostics(AnalyzerOptions &AnalyzerOpts,
- const std::string& prefix,
+PlistDiagnostics(AnalyzerOptions &AnalyzerOpts, const std::string &prefix,
  const Preprocessor &PP,
+ const cross_tu::CrossTranslationUnitContext &CTU,
  bool supportsMultipleFiles);
 
 ~PlistDiagnostics() override {}
@@ -518,26 +520,29 @@
 // Methods of PlistDiagnostics.
 //===--===//
 
-PlistDiagnostics::PlistDiagnostics(AnalyzerOptions &AnalyzerOpts,
-   const s

[PATCH] D65101: [clangd] SelectionTree treats TranslationUnitDecl consistently with other containers.

2019-07-23 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/Selection.h:100
   };
   // The most specific common ancestor of all the selected nodes.
+  const Node &commonAncestor() const;

I think it would be nice to mention "what means no selection" (TUDecl with 
partial)?

And it seems that we are missing some documentation describing the selection 
tree behavior on the preprocessor elements e.g. `#incl^ude`, header guard. 



Comment at: 
clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp:47
   // Narrow the traversal scope to the selected node.
   Inputs.AST.getASTContext().setTraversalScope(
   {const_cast(InterestedDecl)});

we'll get a TUDecl if the whole file is selected, however this tweak doesn't 
want to traversal the whole TU (otherwise we will generate highlighting tokens 
for #included files), we only interested in the top level decls of the main 
file. 



Comment at: clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp:38
  N = N->Parent)
-  if (dumpable(N->ASTNode))
+  if (N->Parent && dumpable(N->ASTNode))
 Node = N->ASTNode;

Is the `N->Parent` intended?  this seems like we'd exclude the TUDecl?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65101



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


[PATCH] D64991: [analyzer][WIP] Implement a primitive reaching definitions analysis

2019-07-23 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a reviewer: steakhal.
Szelethus added a subscriber: steakhal.
Szelethus added a comment.

@steakhal you some great experience with (strict) aliasing, could you chip in 
on this maybe? :)


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

https://reviews.llvm.org/D64991



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


[PATCH] D65092: [clang] Add isDirectlyDerivedFrom AST Matcher.

2019-07-23 Thread Anton Bikineev via Phabricator via cfe-commits
AntonBikineev updated this revision to Diff 211261.
AntonBikineev added a comment.

Thanks for the note, updated the diff with autogenerated 
LibASTMatcherReference.html.


Repository:
  rC Clang

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

https://reviews.llvm.org/D65092

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/lib/ASTMatchers/ASTMatchFinder.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -331,6 +331,16 @@
   EXPECT_TRUE(notMatches("class Y;", IsDerivedFromX));
   EXPECT_TRUE(notMatches("", IsDerivedFromX));
 
+  DeclarationMatcher IsDirectlyDerivedFromX =
+  cxxRecordDecl(isDirectlyDerivedFrom("X"));
+
+  EXPECT_TRUE(
+  matches("class X {}; class Y : public X {};", IsDirectlyDerivedFromX));
+  EXPECT_TRUE(notMatches("class X {};", IsDirectlyDerivedFromX));
+  EXPECT_TRUE(notMatches("class X;", IsDirectlyDerivedFromX));
+  EXPECT_TRUE(notMatches("class Y;", IsDirectlyDerivedFromX));
+  EXPECT_TRUE(notMatches("", IsDirectlyDerivedFromX));
+
   DeclarationMatcher IsAX = cxxRecordDecl(isSameOrDerivedFrom("X"));
 
   EXPECT_TRUE(matches("class X {}; class Y : public X {};", IsAX));
@@ -341,13 +351,22 @@
 
   DeclarationMatcher ZIsDerivedFromX =
 cxxRecordDecl(hasName("Z"), isDerivedFrom("X"));
+  DeclarationMatcher ZIsDirectlyDerivedFromX =
+  cxxRecordDecl(hasName("Z"), isDirectlyDerivedFrom("X"));
   EXPECT_TRUE(
 matches("class X {}; class Y : public X {}; class Z : public Y {};",
 ZIsDerivedFromX));
+  EXPECT_TRUE(
+  notMatches("class X {}; class Y : public X {}; class Z : public Y {};",
+ ZIsDirectlyDerivedFromX));
   EXPECT_TRUE(
 matches("class X {};"
   "template class Y : public X {};"
   "class Z : public Y {};", ZIsDerivedFromX));
+  EXPECT_TRUE(notMatches("class X {};"
+ "template class Y : public X {};"
+ "class Z : public Y {};",
+ ZIsDirectlyDerivedFromX));
   EXPECT_TRUE(matches("class X {}; template class Z : public X {};",
   ZIsDerivedFromX));
   EXPECT_TRUE(
@@ -411,6 +430,9 @@
 matches("class X {}; class Y : public X {}; "
   "typedef Y V; typedef V W; class Z : public W {};",
 ZIsDerivedFromX));
+  EXPECT_TRUE(notMatches("class X {}; class Y : public X {}; "
+ "typedef Y V; typedef V W; class Z : public W {};",
+ ZIsDirectlyDerivedFromX));
   EXPECT_TRUE(
 matches("template class X {}; "
   "template class A { class Z : public X {}; };",
@@ -467,6 +489,14 @@
   "template<> struct X<0> : public A {};"
   "struct B : public X<42> {};",
 cxxRecordDecl(hasName("B"), isDerivedFrom(recordDecl(hasName("A"));
+  EXPECT_TRUE(notMatches(
+  "struct A {};"
+  "template struct X;"
+  "template struct X : public X {};"
+  "template<> struct X<0> : public A {};"
+  "struct B : public X<42> {};",
+  cxxRecordDecl(hasName("B"),
+isDirectlyDerivedFrom(recordDecl(hasName("A"));
 
   // FIXME: Once we have better matchers for template type matching,
   // get rid of the Variable(...) matching and match the right template
Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp
===
--- clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -430,7 +430,8 @@
 
   bool classIsDerivedFrom(const CXXRecordDecl *Declaration,
   const Matcher &Base,
-  BoundNodesTreeBuilder *Builder) override;
+  BoundNodesTreeBuilder *Builder,
+  bool Directly) override;
 
   // Implements ASTMatchFinder::matchesChildOf.
   bool matchesChildOf(const ast_type_traits::DynTypedNode &Node,
@@ -817,7 +818,8 @@
 // derived from itself.
 bool MatchASTVisitor::classIsDerivedFrom(const CXXRecordDecl *Declaration,
  const Matcher &Base,
- BoundNodesTreeBuilder *Builder) {
+ BoundNodesTreeBuilder *Builder,
+ bool Directly) {
   if (!Declaration->hasDefinition())
 return false;
   for (const auto &It : Declaration->bases()) {
@@ -842,7 +844,7 @@
   *Builder = std::move(Result);
   return true;
 }
-if (classIsDerivedFrom(ClassDecl, Base, Builder))
+if (!Directly && classIsDerivedFrom(ClassDecl, Base, Builder, Directly))
   return true;
   }
   re

[PATCH] D64739: [SVE][Inline-Asm] Add support to specify SVE registers in the clobber list

2019-07-23 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 211264.
kmclaughlin added a comment.

- Removed second test in aarch64-sve-inline-asm.c which didn't use 
//-emit-llvm//


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

https://reviews.llvm.org/D64739

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/test/CodeGen/aarch64-sve-inline-asm.c


Index: clang/test/CodeGen/aarch64-sve-inline-asm.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-inline-asm.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK
+
+void test_sve_asm() {
+  asm volatile(
+  "ptrue p0.d\n"
+  "ptrue p15.d\n"
+  "add z0.d, p0/m, z0.d, z0.d\n"
+  "add z31.d, p0/m, z31.d, z31.d\n"
+  :
+  :
+  : "z0", "z31", "p0", "p15");
+  // CHECK: "~{z0},~{z31},~{p0},~{p15}"
+}
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -351,10 +351,19 @@
 "d12", "d13", "d14", "d15", "d16", "d17", "d18", "d19", "d20", "d21", 
"d22",
 "d23", "d24", "d25", "d26", "d27", "d28", "d29", "d30", "d31",
 
-// Vector registers
+// Neon vector registers
 "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "v11",
 "v12", "v13", "v14", "v15", "v16", "v17", "v18", "v19", "v20", "v21", 
"v22",
-"v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31"
+"v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31",
+
+// SVE vector registers
+"z0",  "z1",  "z2",  "z3",  "z4",  "z5",  "z6",  "z7",  "z8",  "z9",  
"z10",
+"z11", "z12", "z13", "z14", "z15", "z16", "z17", "z18", "z19", "z20", 
"z21",
+"z22", "z23", "z24", "z25", "z26", "z27", "z28", "z29", "z30", "z31",
+
+// SVE predicate registers
+"p0",  "p1",  "p2",  "p3",  "p4",  "p5",  "p6",  "p7",  "p8",  "p9",  
"p10",
+"p11", "p12", "p13", "p14", "p15"
 };
 
 ArrayRef AArch64TargetInfo::getGCCRegNames() const {


Index: clang/test/CodeGen/aarch64-sve-inline-asm.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-inline-asm.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK
+
+void test_sve_asm() {
+  asm volatile(
+  "ptrue p0.d\n"
+  "ptrue p15.d\n"
+  "add z0.d, p0/m, z0.d, z0.d\n"
+  "add z31.d, p0/m, z31.d, z31.d\n"
+  :
+  :
+  : "z0", "z31", "p0", "p15");
+  // CHECK: "~{z0},~{z31},~{p0},~{p15}"
+}
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -351,10 +351,19 @@
 "d12", "d13", "d14", "d15", "d16", "d17", "d18", "d19", "d20", "d21", "d22",
 "d23", "d24", "d25", "d26", "d27", "d28", "d29", "d30", "d31",
 
-// Vector registers
+// Neon vector registers
 "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "v11",
 "v12", "v13", "v14", "v15", "v16", "v17", "v18", "v19", "v20", "v21", "v22",
-"v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31"
+"v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31",
+
+// SVE vector registers
+"z0",  "z1",  "z2",  "z3",  "z4",  "z5",  "z6",  "z7",  "z8",  "z9",  "z10",
+"z11", "z12", "z13", "z14", "z15", "z16", "z17", "z18", "z19", "z20", "z21",
+"z22", "z23", "z24", "z25", "z26", "z27", "z28", "z29", "z30", "z31",
+
+// SVE predicate registers
+"p0",  "p1",  "p2",  "p3",  "p4",  "p5",  "p6",  "p7",  "p8",  "p9",  "p10",
+"p11", "p12", "p13", "p14", "p15"
 };
 
 ArrayRef AArch64TargetInfo::getGCCRegNames() const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64739: [SVE][Inline-Asm] Add support to specify SVE registers in the clobber list

2019-07-23 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen accepted this revision.
sdesmalen added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D64739



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


[PATCH] D27918: [analyzer] OStreamChecker

2019-07-23 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 abandoned this revision.
gamesh411 added a comment.
Herald added subscribers: Charusso, donat.nagy, Szelethus, mikhail.ramalho, 
a.sidorin, szepet, baloghadamsoftware.

There are multiple new additions to stream formatters, and this patch is way 
too old. I may consider creating a new checker like this with an extended 
feature set later.


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

https://reviews.llvm.org/D27918



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


[PATCH] D59934: Compare SourceLocations from different TUs by FileID

2019-07-23 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 abandoned this revision.
gamesh411 added a comment.

32f220c5fbe5 
 is the 
more sophisticated solution to the problem.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59934



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


[PATCH] D65102: [OpenCL] Rename lang mode flag for C++ mode

2019-07-23 Thread Kévin Petit via Phabricator via cfe-commits
kpet added a comment.

Thanks for doing this!




Comment at: include/clang/Frontend/LangStandards.def:177
 LANGSTANDARD_ALIAS_DEPR(opencl20, "CL2.0")
+LANGSTANDARD_ALIAS_DEPR(opencl20, "CLC++")
 

Shouldn't this be `openclcpp`?


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

https://reviews.llvm.org/D65102



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


r366792 - PlistDiagnostics Fix for compile warning (NFC).

2019-07-23 Thread Balazs Keri via cfe-commits
Author: balazske
Date: Tue Jul 23 03:21:42 2019
New Revision: 366792

URL: http://llvm.org/viewvc/llvm-project?rev=366792&view=rev
Log:
PlistDiagnostics Fix for compile warning (NFC).

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp?rev=366792&r1=366791&r2=366792&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp Tue Jul 23 03:21:42 
2019
@@ -527,7 +527,7 @@ PlistDiagnostics::PlistDiagnostics(
 : OutputFile(output), PP(PP), CTU(CTU), AnOpts(AnalyzerOpts),
   SupportsCrossFileDiagnostics(supportsMultipleFiles) {
   // FIXME: Will be used by a later planned change.
-  (void)CTU;
+  (void)this->CTU;
 }
 
 void ento::createPlistDiagnosticConsumer(


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


[PATCH] D64488: [Driver] Support -fsanitize=function on Solaris/x86

2019-07-23 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

Ping^2?  Two weeks now.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64488



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


[PATCH] D64487: [clang, test] Fix Clang :: Headers/max_align.c on 64-bit SPARC

2019-07-23 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

Ping^2?  It's been two weeks now.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64487



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


[PATCH] D64793: [Driver] Properly use values-X[ca].o, values-xpg[46].o on Solaris

2019-07-23 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

Ping?  It's been a week now and this is a correctness issue on Solaris, not 
just a single failing test.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64793



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


[PATCH] D65139: [clangd] Support extraction of binary "subexpressions" like a + [[b + c]].

2019-07-23 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: SureYeaah.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

These aren't formally subexpressions in C++, in this case + is left-associative.
However informally +, *, etc are usually (mathematically) associative and users
consider these subexpressions.

We detect these and in simple cases support extracting the partial expression.
As well as builtin associative operators, we assume that overloads of them
are associative and support those too.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65139

Files:
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/Selection.h
  clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
  clang-tools-extra/clangd/unittests/SelectionTests.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
@@ -444,6 +444,47 @@
   // FIXME: Doesn't work correctly for \[\[clang::uninitialized\]\] int
   // b = [[1]]; since the attr is inside the DeclStmt and the bounds of
   // DeclStmt don't cover the attribute
+
+  // Binary subexpressions
+  {R"cpp(void f() {
+   int x = 1 + [[2 + 3 + 4]] + 5;
+ })cpp",
+   R"cpp(void f() {
+   auto dummy = 2 + 3 + 4; int x = 1 + dummy + 5;
+ })cpp"},
+  // Non-associative operations have no special support
+  {R"cpp(void f() {
+   int x = 1 - [[2 - 3 - 4]] - 5;
+ })cpp",
+   R"cpp(void f() {
+   auto dummy = 1 - 2 - 3 - 4; int x = dummy - 5;
+ })cpp"},
+  // A mix of associative operators isn't associative.
+  {R"cpp(void f() {
+   int x = 1 * [[2 + 3 * 4]] + 5;
+ })cpp",
+   R"cpp(void f() {
+   auto dummy = 1 * 2 + 3 * 4; int x = dummy + 5;
+ })cpp"},
+  // Overloaded operators are supported, we assume associativity
+  // as if they were built-in.
+  {R"cpp(struct S {
+   S(int);
+ };
+ S operator+(S, S);
+
+ void f() {
+   S x = S(1) + [[S(2) + S(3) + S(4)]] + S(5);
+ })cpp",
+   R"cpp(struct S {
+   S(int);
+ };
+ S operator+(S, S);
+
+ void f() {
+   auto dummy = S(2) + S(3) + S(4); S x = S(1) + dummy + S(5);
+ })cpp"},
+
   };
   for (const auto &IO : InputOutputs) {
 checkTransform(ID, IO.first, IO.second);
Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -335,6 +335,23 @@
   }
 }
 
+TEST(SelectionTest, Implicit) {
+  const char* Test = R"cpp(
+struct S { S(const char*); };
+int f(S);
+int x = f("^");
+  )cpp";
+  auto AST = TestTU::withCode(Annotations(Test).code()).build();
+  auto T = makeSelectionTree(Test, AST);
+
+  const SelectionTree::Node *Str = T.commonAncestor();
+  EXPECT_EQ("StringLiteral", nodeKind(Str)) << "Implicit selected?";
+  EXPECT_EQ("ImplicitCastExpr", nodeKind(Str->Parent));
+  EXPECT_EQ("CXXConstructExpr", nodeKind(Str->Parent->Parent));
+  EXPECT_EQ(Str, &Str->Parent->Parent->ignoreImplicit())
+  << "Didn't unwrap " << nodeKind(&Str->Parent->Parent->ignoreImplicit());
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
@@ -13,7 +13,9 @@
 #include "refactor/Tweak.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/OperationKinds.h"
+#include "clang/AST/PrettyPrinter.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/StmtCXX.h"
@@ -26,6 +28,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
 
 namespace clang {
 namespace clangd {
@@ -38,10 +41,14 @@
   const clang::Expr *getExpr() const { return Expr; }
   const SelectionTree::Node *getExprNode() const { return ExprNode; }
   bool isExtractable() const { return Extractable; }
+  // The half-open range for the expression to be extracted.
+  SourceRange getExtractionC

[PATCH] D63126: [clangd] Implement "prepareRename"

2019-07-23 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:393
 ;
+  if (Params.capabilities.RenamePrepareSupport)
+Result["renameProvider"] = llvm::json::Object{{"prepareProvider", true}};

why set this only if the client advertised support?



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:295
+auto &AST = InpAST->AST;
+// Return null if the "rename" is not valid at the position.
+auto Changes = renameWithinFile(AST, File, Pos, "dummy", Index);

move this comment to at/in the !Changes block?



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:296
+// Return null if the "rename" is not valid at the position.
+auto Changes = renameWithinFile(AST, File, Pos, "dummy", Index);
+if (!Changes) {

High level comment indicating why we use rename to implement preparerename?
(i.e. why isn't it too expensive)



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:298
+if (!Changes) {
+  llvm::consumeError(Changes.takeError());
+  return CB(llvm::None);

I thought the point of supporting this was to get errors to the user sooner. 
That can't happen if we throw away the error message...



Comment at: clang-tools-extra/clangd/Protocol.h:412
+  /// before execution.
+  bool RenamePrepareSupport = false;
 };

(i think we shouldn't need to parse this at all)



Comment at: clang-tools-extra/clangd/test/prepare-rename.test:2
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{"textDocument":
 {"rename": {"dynamicRegistration": true, "prepareSupport": 
true}}},"trace":"off"}}
+# CHECK:  "renameProvider": {

inline this test into rename.test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63126



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


[PATCH] D65065: [clang-tidy] Possibility of displaying duplicate warnings

2019-07-23 Thread Tibor Brunner via Phabricator via cfe-commits
bruntib added a comment.

Yes, LessClangTidyError would really be the best place for this. The reason of 
my implementation was that I wanted to bind this feature to a command line 
option. I don't know if there was any design decision behind the current 
uniquing logic and I didn't want to break it if there was any. So would you be 
agree with having duplicate reports by default without any command line flag in 
case of alias checkers? I believe this would be the most painless solution, 
since in case of further improvements about including notes, fixes, etc. in the 
functor, the potential command line option controlling this would be 
unnecessarily complex. I don't know if there could be any use-case on those.
Thanks for the review!


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D65065



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


[PATCH] D64666: [Sema] Enable -Wimplicit-float-conversion for integral to floating point precision loss

2019-07-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman requested changes to this revision.
aaron.ballman added a comment.
This revision now requires changes to proceed.

In D64666#1596660 , @xbolva00 wrote:

> I think we should warn in that case even if GCC does not warn.


Strong +1.

In D64666#1596853 , @ziangwan wrote:

> Final review ping.


Please be sure to give reviewers enough time to respond to comments before 
pinging a review.


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

https://reviews.llvm.org/D64666



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


[PATCH] D64737: RISCV: Add support for floating point registers in inlineasm

2019-07-23 Thread Sam Elliott via Phabricator via cfe-commits
lenary accepted this revision.
lenary added a comment.
This revision is now accepted and ready to land.

Looks good to me! Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64737



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


[PATCH] D59474: [OpenMP 5.0] Codegen support for user-defined mappers

2019-07-23 Thread Lingda Li via Phabricator via cfe-commits
lildmh updated this revision to Diff 211278.
lildmh added a comment.
Herald added a reviewer: jdoerfert.

Rebase


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

https://reviews.llvm.org/D59474

Files:
  include/clang/AST/GlobalDecl.h
  lib/AST/ASTContext.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/ModuleBuilder.cpp
  test/OpenMP/declare_mapper_codegen.cpp

Index: test/OpenMP/declare_mapper_codegen.cpp
===
--- test/OpenMP/declare_mapper_codegen.cpp
+++ test/OpenMP/declare_mapper_codegen.cpp
@@ -1,92 +1,414 @@
-///==///
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap %s
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap %s
-
-// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY0 %s
-
 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
 
 // expected-no-diagnostics
 #ifndef HEADER
 #define HEADER
 
+///==///
+// RUN: %clang_cc1 -DCK0 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix CK0 --check-prefix CK0-64 %s
+// RUN: %clang_cc1 -DCK0 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
+// RUN: %clang_cc1 -DCK0 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -femit-all-decls -disable-llvm-passes -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix CK0 --check-prefix CK0-64 %s
+// RUN: %clang_cc1 -DCK0 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix CK0 --check-prefix CK0-32 %s
+// RUN: %clang_cc1 -DCK0 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
+// RUN: %clang_cc1 -DCK0 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -femit-all-decls -disable-llvm-passes -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix CK0 --check-prefix CK0-32 %s
+
+// RUN: %clang_cc1 -DCK0 -verify -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -DCK0 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
+// RUN: %clang_cc1 -DCK0 -fopenmp-simd -fopenmp-ta

[PATCH] D64487: [clang, test] Fix Clang :: Headers/max_align.c on 64-bit SPARC

2019-07-23 Thread James Y Knight via Phabricator via cfe-commits
jyknight accepted this revision.
jyknight added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64487



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


[PATCH] D64998: Improve clang-format-diff help output

2019-07-23 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/tools/clang-format/clang-format-diff.py:11
 
-r"""
-ClangFormat Diff Reformatter
-
-
+"""
 This script reads input from a unified diff and reformats all the changed

Please add a comment that this section serves a dual purpose now.


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

https://reviews.llvm.org/D64998



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


[PATCH] D65125: clang-format: Fix namespace end comments for namespaces with attributes and macros

2019-07-23 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

LG, thx!


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

https://reviews.llvm.org/D65125



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


[PATCH] D63126: [clangd] Implement "prepareRename"

2019-07-23 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 211288.
hokein marked 6 inline comments as done.
hokein added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63126

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/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/clients/clangd-vscode/package.json
  clang-tools-extra/clangd/test/rename.test

Index: clang-tools-extra/clangd/test/rename.test
===
--- clang-tools-extra/clangd/test/rename.test
+++ clang-tools-extra/clangd/test/rename.test
@@ -1,12 +1,45 @@
 # RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
-{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{"textDocument": {"rename": {"dynamicRegistration": true, "prepareSupport": true}}},"trace":"off"}}
+# CHECK:  "renameProvider": {
+# CHECK-NEXT:"prepareProvider": true
+# CHECK-NEXT: },
 ---
 {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.cpp","languageId":"cpp","version":1,"text":"int foo;"}}}
 ---
-{"jsonrpc":"2.0","id":1,"method":"textDocument/rename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":5},"newName":"bar"}}
+{"jsonrpc":"2.0","id":1,"method":"textDocument/prepareRename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":5}}}
 #  CHECK:  "id": 1,
 # CHECK-NEXT:  "jsonrpc": "2.0",
 # CHECK-NEXT:  "result": {
+# CHECK-NEXT:  "end": {
+# CHECK-NEXT:"character": 7,
+# CHECK-NEXT:"line": 0
+# CHECK-NEXT:  },
+# CHECK-NEXT:  "start": {
+# CHECK-NEXT:"character": 4,
+# CHECK-NEXT:"line": 0
+# CHECK-NEXT:  }
+# CHECK-NEXT:  }
+---
+{"jsonrpc":"2.0","id":2,"method":"textDocument/prepareRename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":2}}}
+#  CHECK:  "error": {
+# CHECK-NEXT:"code": -32001,
+# CHECK-NEXT:"message": "there is no symbol at the given location"
+# CHECK-NEXT:  },
+# CHECK-NEXT:  "id": 2,
+# CHECK-NEXT:  "jsonrpc": "2.0"
+---
+{"jsonrpc":"2.0","id":4,"method":"textDocument/rename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":2},"newName":"bar"}}
+#  CHECK:  "error": {
+# CHECK-NEXT:"code": -32001,
+# CHECK-NEXT:"message": "there is no symbol at the given location"
+# CHECK-NEXT:  },
+# CHECK-NEXT:  "id": 4,
+# CHECK-NEXT:  "jsonrpc": "2.0"
+---
+{"jsonrpc":"2.0","id":3,"method":"textDocument/rename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":5},"newName":"bar"}}
+#  CHECK:  "id": 3,
+# CHECK-NEXT:  "jsonrpc": "2.0",
+# CHECK-NEXT:  "result": {
 # CHECK-NEXT:"changes": {
 # CHECK-NEXT:  "file://{{.*}}/foo.cpp": [
 # CHECK-NEXT:{
@@ -26,14 +59,6 @@
 # CHECK-NEXT:}
 # CHECK-NEXT:  }
 ---
-{"jsonrpc":"2.0","id":2,"method":"textDocument/rename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":2},"newName":"bar"}}
-#  CHECK:  "error": {
-# CHECK-NEXT:"code": -32001,
-# CHECK-NEXT:"message": "there is no symbol at the given location"
-# CHECK-NEXT:  },
-# CHECK-NEXT:  "id": 2,
-# CHECK-NEXT:  "jsonrpc": "2.0"

-{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+{"jsonrpc":"2.0","id":5,"method":"shutdown"}
 ---
 {"jsonrpc":"2.0","method":"exit"}
Index: clang-tools-extra/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/clangd/clients/clangd-vscode/package.json
@@ -6,7 +6,7 @@
 "publisher": "llvm-vs-code-extensions",
 "homepage": "https://clang.llvm.org/extra/clangd.html";,
 "engines": {
-"vscode": "^1.30.0"
+"vscode": "^1.36.0"
 },
 "categories": [
 "Programming Languages",
@@ -35,8 +35,8 @@
 "test": "node ./node_modules/vscode/bin/test"
 },
 "dependencies": {
-"vscode-languageclient": "^5.2.0",
-"vscode-languageserver": "^5.2.0"
+"vscode-languageclient": "^5.3.0-next.6",
+"vscode-languageserver": "^5.3.0-next.6"
 },
 "devDependencies": {
 "@types/mocha": "^2.2.32",
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -422,6 +422,10 @@
   /// The content format that should be

[PATCH] D64638: [CrossTU] Fix plist macro expansion if macro in other file.

2019-07-23 Thread Gabor Marton via Phabricator via cfe-commits
martong added a subscriber: NoQ.
martong added a comment.

In D64638#1593382 , @ilya-biryukov 
wrote:

> `StaticAnalyzer/Core` does not depend on `clangFrontend` now, you can see 
> this by looking at `lib/StaticAnalyzer/Core/CMakeLists.txt`:
>
>   add_clang_library(clangStaticAnalyzerCore
>   ...
> LINK_LIBS
> clangAST
> clangASTMatchers
> clangAnalysis
> clangBasic
> clangCrossTU
> clangLex
> clangRewrite
> )
>
>
> Not a `StaticAnalyzer` expert, so I don't know whether it's acceptable to add 
> this dependency to `clangStaticAnalyzerCore`, you'll have to find someone who 
> owns the code to know whether this dependency is justified.
>  (My wild guess from looking at the names of the libraries would be that this 
> dependency is not ok and the code should go into 
> `clangStaticAnalyzerFrontend` instead. But again, not an expert here, just a 
> guess).
>
> But please add a dependency into `LINK_LIBS` inside `CMakeLists.txt` if you 
> start depending on `clangFrontend`.
>  Most of these violations are found if you build in a `cmake 
> -DBUILD_SHARED_LIBS=On` configuration.


@Szelethus @Noq Could StaticAnalyzer/Core depend on clangFrontend? I am not 
sure if we can get the Preprocessor somewhere else ...


Repository:
  rC Clang

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

https://reviews.llvm.org/D64638



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


[PATCH] D63126: [clangd] Implement "prepareRename"

2019-07-23 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:393
 ;
+  if (Params.capabilities.RenamePrepareSupport)
+Result["renameProvider"] = llvm::json::Object{{"prepareProvider", true}};

sammccall wrote:
> why set this only if the client advertised support?
The LSP says
``` 
 /**
 * The server provides rename support. RenameOptions may only be
 * specified if the client states that it supports
 * `prepareSupport` in its initial `initialize` request.
 */
renameProvider?: boolean | RenameOptions;
```

so we only send `RenameOptions` when the client declares it supports 
prepareRename.



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:298
+if (!Changes) {
+  llvm::consumeError(Changes.takeError());
+  return CB(llvm::None);

sammccall wrote:
> I thought the point of supporting this was to get errors to the user sooner. 
> That can't happen if we throw away the error message...
use our own error message instead, luckily, VSCode prompt this error message to 
users.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63126



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


[PATCH] D61466: [Rewrite][NFC] Add FIXMEs and tests for RemoveLineIfEmpty bug

2019-07-23 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

Ping.


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

https://reviews.llvm.org/D61466



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


[PATCH] D65146: [clangd] Log version, cwd, args, and transport on startup. NFC

2019-07-23 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65146

Files:
  clang-tools-extra/clangd/tool/ClangdMain.cpp


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -423,6 +423,20 @@
   llvm::errs().SetBuffered();
   StreamLogger Logger(llvm::errs(), LogLevel);
   LoggingSession LoggingSession(Logger);
+  // Write some initial logs before we start doing any real work.
+  log("{0}", clang::getClangToolFullVersion("clangd"));
+  {
+SmallString<128> CWD;
+if (auto Err = llvm::sys::fs::current_path(CWD))
+  log("Working directory unknown: {0}", Err.message());
+else
+  log("Working directory: {0}", CWD);
+  }
+  {
+std::string LoggableArgs;
+for (int I = 0; I < argc; ++I)
+  log("argv[{0}]: {1}", I, argv[I]);
+  }
 
   // If --compile-commands-dir arg was invoked, check value and override 
default
   // path.
@@ -501,12 +515,14 @@
   std::unique_ptr TransportLayer;
   if (getenv("CLANGD_AS_XPC_SERVICE")) {
 #if CLANGD_BUILD_XPC
+log("Starting LSP over XPC service");
 TransportLayer = newXPCTransport();
 #else
 llvm::errs() << "This clangd binary wasn't built with XPC support.\n";
 return (int)ErrorResultCode::CantRunAsXPCService;
 #endif
   } else {
+log("Starting LSP over stdin/stdout");
 TransportLayer = newJSONTransport(
 stdin, llvm::outs(),
 InputMirrorStream ? InputMirrorStream.getPointer() : nullptr,


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -423,6 +423,20 @@
   llvm::errs().SetBuffered();
   StreamLogger Logger(llvm::errs(), LogLevel);
   LoggingSession LoggingSession(Logger);
+  // Write some initial logs before we start doing any real work.
+  log("{0}", clang::getClangToolFullVersion("clangd"));
+  {
+SmallString<128> CWD;
+if (auto Err = llvm::sys::fs::current_path(CWD))
+  log("Working directory unknown: {0}", Err.message());
+else
+  log("Working directory: {0}", CWD);
+  }
+  {
+std::string LoggableArgs;
+for (int I = 0; I < argc; ++I)
+  log("argv[{0}]: {1}", I, argv[I]);
+  }
 
   // If --compile-commands-dir arg was invoked, check value and override default
   // path.
@@ -501,12 +515,14 @@
   std::unique_ptr TransportLayer;
   if (getenv("CLANGD_AS_XPC_SERVICE")) {
 #if CLANGD_BUILD_XPC
+log("Starting LSP over XPC service");
 TransportLayer = newXPCTransport();
 #else
 llvm::errs() << "This clangd binary wasn't built with XPC support.\n";
 return (int)ErrorResultCode::CantRunAsXPCService;
 #endif
   } else {
+log("Starting LSP over stdin/stdout");
 TransportLayer = newJSONTransport(
 stdin, llvm::outs(),
 InputMirrorStream ? InputMirrorStream.getPointer() : nullptr,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64638: [CrossTU] Fix plist macro expansion if macro in other file.

2019-07-23 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

It is possible to use the `Preprocessor` instead of `ASTUnit` in 
`getImportedFromSourceLocation`. But this will contain less useful (even if 
currently not used) information. The test extension in D65064 
 is not possible to do if not `ASTUnit` is 
used. (Or a tuple must be used that contains `Preprocessor` and 
`TranslationUnitDecl` and maybe other objects that are stored in the `ASTUnit`.)


Repository:
  rC Clang

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

https://reviews.llvm.org/D64638



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


Re: r366694 - [NFC] Relaxed regression tests for PR42665

2019-07-23 Thread Anastasia Stulova via cfe-commits
+ cfe-commits


From: Anastasia Stulova
Sent: 23 July 2019 15:16
To: Hans Wennborg 
Cc: Marco Antognini 
Subject: Re: r366694 - [NFC] Relaxed regression tests for PR42665


@Hans, would it be possible to merge this commit along with r366670 to the 
release 9.0?


FY, I have also added this to the blocker bug: 
https://bugs.llvm.org/show_bug.cgi?id=41727

Thanks!
Anastasia

From: cfe-commits  on behalf of Marco 
Antognini via cfe-commits 
Sent: 22 July 2019 15:47
To: cfe-commits@lists.llvm.org 
Subject: r366694 - [NFC] Relaxed regression tests for PR42665

Author: mantognini
Date: Mon Jul 22 07:47:36 2019
New Revision: 366694

URL: http://llvm.org/viewvc/llvm-project?rev=366694&view=rev
Log:
[NFC] Relaxed regression tests for PR42665

Following up on the buildbot failures, this commits relaxes some tests:
instead of checking for specific IR output, it now ensures that the
underlying issue (the crash), and only that, doesn't happen.

Modified:
cfe/trunk/test/CodeGenCXX/PR42665.cpp

Modified: cfe/trunk/test/CodeGenCXX/PR42665.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/PR42665.cpp?rev=366694&r1=366693&r2=366694&view=diff
==
--- cfe/trunk/test/CodeGenCXX/PR42665.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/PR42665.cpp Mon Jul 22 07:47:36 2019
@@ -1,7 +1,8 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -std=c++17 -O0 %s -o 
- | FileCheck %s
-// RUN: %clang_cc1 -triple %ms_abi_triple -emit-llvm -std=c++17 -O0 %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -std=c++17 -O0 %s -emit-llvm -o /dev/null -verify -triple 
%itanium_abi_triple
+// RUN: %clang_cc1 -std=c++17 -O0 %s -emit-llvm -o /dev/null -verify -triple 
%ms_abi_triple

 // Minimal reproducer for PR42665.
+// expected-no-diagnostics

 struct Foo {
   Foo() = default;
@@ -31,31 +32,3 @@ void foobar() {
   d(f); // Invoke virtual destructor of Foo through d.
 } // p's destructor is invoked.

-// Regexes are used to handle both kind of mangling.
-//
-// CHECK-LABEL: define linkonce_odr{{( dso_local)?}} void 
@{{.*deleter.*Foo.*}}(%struct.Foo* dereferenceable({{[0-9]+}})
-// CHECK-SAME: [[T:%.*]])
-// CHECK: [[T_ADDR:%.*]] = alloca %struct.Foo*
-// CHECK: store %struct.Foo* [[T]], %struct.Foo** [[T_ADDR]]
-// CHECK: [[R0:%.*]] = load %struct.Foo*, %struct.Foo** [[T_ADDR]]
-// CHECK: [[R1:%.*]] = bitcast %struct.Foo* [[R0]] to 
[[TYPE:.*struct\.Foo.*]]***
-// CHECK: [[VTABLE:%.*]] = load [[TYPE]]**, [[TYPE]]*** [[R1]]
-// CHECK: [[VFUN:%.*]] = getelementptr inbounds [[TYPE]]*, [[TYPE]]** 
[[VTABLE]], i64 0
-// CHECK: [[DTOR:%.*]] = load [[TYPE]]*, [[TYPE]]** [[VFUN]]
-// CHECK: call {{(void|i8\*)}} [[DTOR]](%struct.Foo* [[R0]]
-//
-// CHECK-LABEL: define{{( dso_local)?}} void @{{.*foobar.*}}()
-// CHECK: [[P:%.*]] = alloca %struct.Pair
-// CHECK: [[F:%.*]] = alloca %struct.Foo*
-// CHECK: [[D:%.*]] = alloca [[TYPE:void \(%struct.Foo\*\)]]**
-// CHECK: call void @{{.*make_pair.*}}(%struct.Pair* sret [[P]])
-// CHECK: [[FIRST:%.*]] = getelementptr inbounds %struct.Pair, %struct.Pair* 
[[P]], i32 0, i32 0
-// CHECK: store %struct.Foo* [[FIRST]], %struct.Foo** [[F]]
-// CHECK: [[SECOND:%.*]] = getelementptr inbounds %struct.Pair, %struct.Pair* 
[[P]], i32 0, i32 1
-// CHECK: store void (%struct.Foo*)** [[SECOND]], [[TYPE]]*** [[D]]
-// CHECK: [[R0:%.*]] = load [[TYPE]]**, [[TYPE]]*** [[D]]
-// CHECK: [[R1:%.*]] = load [[TYPE]]*, [[TYPE]]** [[R0]]
-// CHECK: [[R2:%.*]] = load %struct.Foo*, %struct.Foo** [[F]]
-// CHECK: call void [[R1]](%struct.Foo* dereferenceable({{[0-9]+}}) [[R2]])
-// CHECK: call void @{{.*Pair.*Foo.*}}(%struct.Pair* [[P]])
-


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


[PATCH] D65146: [clangd] Log version, cwd, args, and transport on startup. NFC

2019-07-23 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:436
+  {
+std::string LoggableArgs;
+for (int I = 0; I < argc; ++I)

this variable is not used.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65146



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


[PATCH] D63126: [clangd] Implement "prepareRename"

2019-07-23 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:393
 ;
+  if (Params.capabilities.RenamePrepareSupport)
+Result["renameProvider"] = llvm::json::Object{{"prepareProvider", true}};

hokein wrote:
> sammccall wrote:
> > why set this only if the client advertised support?
> The LSP says
> ``` 
>  /**
>* The server provides rename support. RenameOptions may only be
>* specified if the client states that it supports
>* `prepareSupport` in its initial `initialize` request.
>*/
>   renameProvider?: boolean | RenameOptions;
> ```
> 
> so we only send `RenameOptions` when the client declares it supports 
> prepareRename.
Ah, OK. this should be documented.

Could we put this logic above instead, for less data structure wrangling?
```
llvm::json::Value RenameProvider = llvm::json::Object{{"prepareProvider", 
true}};
if (!Params.capabilities.RenamePrepareSupport) // Only boolean allowed per LSP
  RenameProvider = true;
...
{"renameProvider", std::move(RenameProvider)}
```




Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:581
+  Params.textDocument.uri.file(), Params.position,
+  Bind(
+  [](decltype(Reply) Reply, llvm::Expected> R) {

this appears to be the same as just passing std::move(Reply) to preparerename



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:298
+if (!Changes) {
+  // LSP clients may emit a hard-coded error message (e.g. "can't be
+  // renamed" in VSCode) if we returns null, we use the interl error 
message

There's some context missing here - you're explaining *why* we're going against 
LSP, but you haven't explained that we're doing so!

"LSP says to return null on failure, but that will result in a generic failure 
message. If we send an LSP error response, clients can surface the message to 
users (VSCode does)"

("will" not "may", because there's no way it can result in a detailed message)



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:296
+// Return null if the "rename" is not valid at the position.
+auto Changes = renameWithinFile(AST, File, Pos, "dummy", Index);
+if (!Changes) {

sammccall wrote:
> High level comment indicating why we use rename to implement preparerename?
> (i.e. why isn't it too expensive)
can you say something like "Performing the rename isn't substantially more 
expensive than an AST-based check, so we just rename and throw away the 
results. We may have to revisit this when we support cross-file rename"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63126



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


[PATCH] D65149: [Format] Add test demonstrating PR42722

2019-07-23 Thread Brian Gesiak via Phabricator via cfe-commits
modocache created this revision.
modocache added reviewers: ank, klimek, acoomans.
Herald added a project: clang.

https://bugs.llvm.org/show_bug.cgi?id=42722 describes what I believe to
be a bug in lambda formatting. If it is indeed a bug, I'd like to commit
this test that reliably reproduces it. I'll try in the coming days to
then fix the behavior and update this test to demonstrate the correct
behavior (but if anyone fixes it before I do, this test will help them
too, I think).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65149

Files:
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -5173,6 +5173,17 @@
"   \"\");\n"
"}",
getLLVMStyleWithColumns(30));
+  verifyFormat("testPR42722() {\n"
+   "  int c = 19;\n"
+   "  int d = 32;\n"
+   "  Executor ex;\n"
+   "  ex.addFuture([]() {\n"
+   "  throw std::runtime_error(\"oops\");\n"
+   "}).then([](Result &&result) {\n"
+   "c++;\n"
+   "d++\n"
+   "  });\n"
+   "}");
 }
 
 TEST_F(FormatTest, BreaksAccordingToOperatorPrecedence) {


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -5173,6 +5173,17 @@
"   \"\");\n"
"}",
getLLVMStyleWithColumns(30));
+  verifyFormat("testPR42722() {\n"
+   "  int c = 19;\n"
+   "  int d = 32;\n"
+   "  Executor ex;\n"
+   "  ex.addFuture([]() {\n"
+   "  throw std::runtime_error(\"oops\");\n"
+   "}).then([](Result &&result) {\n"
+   "c++;\n"
+   "d++\n"
+   "  });\n"
+   "}");
 }
 
 TEST_F(FormatTest, BreaksAccordingToOperatorPrecedence) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D65064: [CrossTU] Add a function to retrieve original source location.

2019-07-23 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked an inline comment as done.
balazske added inline comments.



Comment at: clang/include/clang/CrossTU/CrossTranslationUnit.h:175
+  /// returned.
+  llvm::Optional>
+  getImportedFromSourceLocation(const clang::SourceLocation &ToLoc) const;

It would be better to use `std::tuple` here. (Or * if & does not work.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65064



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


[clang-tools-extra] r366811 - [clangd] Log version, cwd, args, and transport on startup. NFC

2019-07-23 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Tue Jul 23 07:30:28 2019
New Revision: 366811

URL: http://llvm.org/viewvc/llvm-project?rev=366811&view=rev
Log:
[clangd] Log version, cwd, args, and transport on startup. NFC

Reviewers: hokein

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

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp

Modified: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp?rev=366811&r1=366810&r2=366811&view=diff
==
--- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp Tue Jul 23 07:30:28 2019
@@ -423,6 +423,17 @@ int main(int argc, char *argv[]) {
   llvm::errs().SetBuffered();
   StreamLogger Logger(llvm::errs(), LogLevel);
   LoggingSession LoggingSession(Logger);
+  // Write some initial logs before we start doing any real work.
+  log("{0}", clang::getClangToolFullVersion("clangd"));
+  {
+SmallString<128> CWD;
+if (auto Err = llvm::sys::fs::current_path(CWD))
+  log("Working directory unknown: {0}", Err.message());
+else
+  log("Working directory: {0}", CWD);
+  }
+  for (int I = 0; I < argc; ++I)
+log("argv[{0}]: {1}", I, argv[I]);
 
   // If --compile-commands-dir arg was invoked, check value and override 
default
   // path.
@@ -501,12 +512,14 @@ int main(int argc, char *argv[]) {
   std::unique_ptr TransportLayer;
   if (getenv("CLANGD_AS_XPC_SERVICE")) {
 #if CLANGD_BUILD_XPC
+log("Starting LSP over XPC service");
 TransportLayer = newXPCTransport();
 #else
 llvm::errs() << "This clangd binary wasn't built with XPC support.\n";
 return (int)ErrorResultCode::CantRunAsXPCService;
 #endif
   } else {
+log("Starting LSP over stdin/stdout");
 TransportLayer = newJSONTransport(
 stdin, llvm::outs(),
 InputMirrorStream ? InputMirrorStream.getPointer() : nullptr,


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


[PATCH] D65146: [clangd] Log version, cwd, args, and transport on startup. NFC

2019-07-23 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366811: [clangd] Log version, cwd, args, and transport on 
startup. NFC (authored by sammccall, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D65146?vs=211295&id=211301#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D65146

Files:
  clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp


Index: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
@@ -423,6 +423,17 @@
   llvm::errs().SetBuffered();
   StreamLogger Logger(llvm::errs(), LogLevel);
   LoggingSession LoggingSession(Logger);
+  // Write some initial logs before we start doing any real work.
+  log("{0}", clang::getClangToolFullVersion("clangd"));
+  {
+SmallString<128> CWD;
+if (auto Err = llvm::sys::fs::current_path(CWD))
+  log("Working directory unknown: {0}", Err.message());
+else
+  log("Working directory: {0}", CWD);
+  }
+  for (int I = 0; I < argc; ++I)
+log("argv[{0}]: {1}", I, argv[I]);
 
   // If --compile-commands-dir arg was invoked, check value and override 
default
   // path.
@@ -501,12 +512,14 @@
   std::unique_ptr TransportLayer;
   if (getenv("CLANGD_AS_XPC_SERVICE")) {
 #if CLANGD_BUILD_XPC
+log("Starting LSP over XPC service");
 TransportLayer = newXPCTransport();
 #else
 llvm::errs() << "This clangd binary wasn't built with XPC support.\n";
 return (int)ErrorResultCode::CantRunAsXPCService;
 #endif
   } else {
+log("Starting LSP over stdin/stdout");
 TransportLayer = newJSONTransport(
 stdin, llvm::outs(),
 InputMirrorStream ? InputMirrorStream.getPointer() : nullptr,


Index: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
@@ -423,6 +423,17 @@
   llvm::errs().SetBuffered();
   StreamLogger Logger(llvm::errs(), LogLevel);
   LoggingSession LoggingSession(Logger);
+  // Write some initial logs before we start doing any real work.
+  log("{0}", clang::getClangToolFullVersion("clangd"));
+  {
+SmallString<128> CWD;
+if (auto Err = llvm::sys::fs::current_path(CWD))
+  log("Working directory unknown: {0}", Err.message());
+else
+  log("Working directory: {0}", CWD);
+  }
+  for (int I = 0; I < argc; ++I)
+log("argv[{0}]: {1}", I, argv[I]);
 
   // If --compile-commands-dir arg was invoked, check value and override default
   // path.
@@ -501,12 +512,14 @@
   std::unique_ptr TransportLayer;
   if (getenv("CLANGD_AS_XPC_SERVICE")) {
 #if CLANGD_BUILD_XPC
+log("Starting LSP over XPC service");
 TransportLayer = newXPCTransport();
 #else
 llvm::errs() << "This clangd binary wasn't built with XPC support.\n";
 return (int)ErrorResultCode::CantRunAsXPCService;
 #endif
   } else {
+log("Starting LSP over stdin/stdout");
 TransportLayer = newJSONTransport(
 stdin, llvm::outs(),
 InputMirrorStream ? InputMirrorStream.getPointer() : nullptr,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60663: Time profiler: small fixes and optimizations

2019-07-23 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: llvm/trunk/lib/Support/TimeProfiler.cpp:27
 
+static cl::opt TimeTraceGranularity(
+"time-trace-granularity",

I know this is late, but... this shows up in the help for any tool that links 
in libSupport, many of which don't support the time profiler. Can you mark this 
as hidden or (preferably) move this to cc1_main?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D60663



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


[PATCH] D63126: [clangd] Implement "prepareRename"

2019-07-23 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 211302.
hokein marked 4 inline comments as done.
hokein added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63126

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/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/clients/clangd-vscode/package.json
  clang-tools-extra/clangd/test/rename.test

Index: clang-tools-extra/clangd/test/rename.test
===
--- clang-tools-extra/clangd/test/rename.test
+++ clang-tools-extra/clangd/test/rename.test
@@ -1,12 +1,45 @@
 # RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
-{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{"textDocument": {"rename": {"dynamicRegistration": true, "prepareSupport": true}}},"trace":"off"}}
+# CHECK:  "renameProvider": {
+# CHECK-NEXT:"prepareProvider": true
+# CHECK-NEXT: },
 ---
 {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.cpp","languageId":"cpp","version":1,"text":"int foo;"}}}
 ---
-{"jsonrpc":"2.0","id":1,"method":"textDocument/rename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":5},"newName":"bar"}}
+{"jsonrpc":"2.0","id":1,"method":"textDocument/prepareRename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":5}}}
 #  CHECK:  "id": 1,
 # CHECK-NEXT:  "jsonrpc": "2.0",
 # CHECK-NEXT:  "result": {
+# CHECK-NEXT:  "end": {
+# CHECK-NEXT:"character": 7,
+# CHECK-NEXT:"line": 0
+# CHECK-NEXT:  },
+# CHECK-NEXT:  "start": {
+# CHECK-NEXT:"character": 4,
+# CHECK-NEXT:"line": 0
+# CHECK-NEXT:  }
+# CHECK-NEXT:  }
+---
+{"jsonrpc":"2.0","id":2,"method":"textDocument/prepareRename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":2}}}
+#  CHECK:  "error": {
+# CHECK-NEXT:"code": -32001,
+# CHECK-NEXT:"message": "there is no symbol at the given location"
+# CHECK-NEXT:  },
+# CHECK-NEXT:  "id": 2,
+# CHECK-NEXT:  "jsonrpc": "2.0"
+---
+{"jsonrpc":"2.0","id":4,"method":"textDocument/rename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":2},"newName":"bar"}}
+#  CHECK:  "error": {
+# CHECK-NEXT:"code": -32001,
+# CHECK-NEXT:"message": "there is no symbol at the given location"
+# CHECK-NEXT:  },
+# CHECK-NEXT:  "id": 4,
+# CHECK-NEXT:  "jsonrpc": "2.0"
+---
+{"jsonrpc":"2.0","id":3,"method":"textDocument/rename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":5},"newName":"bar"}}
+#  CHECK:  "id": 3,
+# CHECK-NEXT:  "jsonrpc": "2.0",
+# CHECK-NEXT:  "result": {
 # CHECK-NEXT:"changes": {
 # CHECK-NEXT:  "file://{{.*}}/foo.cpp": [
 # CHECK-NEXT:{
@@ -26,14 +59,6 @@
 # CHECK-NEXT:}
 # CHECK-NEXT:  }
 ---
-{"jsonrpc":"2.0","id":2,"method":"textDocument/rename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":2},"newName":"bar"}}
-#  CHECK:  "error": {
-# CHECK-NEXT:"code": -32001,
-# CHECK-NEXT:"message": "there is no symbol at the given location"
-# CHECK-NEXT:  },
-# CHECK-NEXT:  "id": 2,
-# CHECK-NEXT:  "jsonrpc": "2.0"

-{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+{"jsonrpc":"2.0","id":5,"method":"shutdown"}
 ---
 {"jsonrpc":"2.0","method":"exit"}
Index: clang-tools-extra/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/clangd/clients/clangd-vscode/package.json
@@ -6,7 +6,7 @@
 "publisher": "llvm-vs-code-extensions",
 "homepage": "https://clang.llvm.org/extra/clangd.html";,
 "engines": {
-"vscode": "^1.30.0"
+"vscode": "^1.36.0"
 },
 "categories": [
 "Programming Languages",
@@ -35,8 +35,8 @@
 "test": "node ./node_modules/vscode/bin/test"
 },
 "dependencies": {
-"vscode-languageclient": "^5.2.0",
-"vscode-languageserver": "^5.2.0"
+"vscode-languageclient": "^5.3.0-next.6",
+"vscode-languageserver": "^5.3.0-next.6"
 },
 "devDependencies": {
 "@types/mocha": "^2.2.32",
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -422,6 +422,10 @@
   /// The content format that should be used fo

Re: r366694 - [NFC] Relaxed regression tests for PR42665

2019-07-23 Thread Hans Wennborg via cfe-commits
Merged them both in r366814.

Thanks,
Hans

On Tue, Jul 23, 2019 at 7:20 AM Anastasia Stulova
 wrote:
>
>
> + cfe-commits
>
> 
> From: Anastasia Stulova
> Sent: 23 July 2019 15:16
> To: Hans Wennborg 
> Cc: Marco Antognini 
> Subject: Re: r366694 - [NFC] Relaxed regression tests for PR42665
>
>
> @Hans, would it be possible to merge this commit along with r366670 to the 
> release 9.0?
>
>
> FY, I have also added this to the blocker bug: 
> https://bugs.llvm.org/show_bug.cgi?id=41727
>
> Thanks!
> Anastasia
> 
> From: cfe-commits  on behalf of Marco 
> Antognini via cfe-commits 
> Sent: 22 July 2019 15:47
> To: cfe-commits@lists.llvm.org 
> Subject: r366694 - [NFC] Relaxed regression tests for PR42665
>
> Author: mantognini
> Date: Mon Jul 22 07:47:36 2019
> New Revision: 366694
>
> URL: http://llvm.org/viewvc/llvm-project?rev=366694&view=rev
> Log:
> [NFC] Relaxed regression tests for PR42665
>
> Following up on the buildbot failures, this commits relaxes some tests:
> instead of checking for specific IR output, it now ensures that the
> underlying issue (the crash), and only that, doesn't happen.
>
> Modified:
> cfe/trunk/test/CodeGenCXX/PR42665.cpp
>
> Modified: cfe/trunk/test/CodeGenCXX/PR42665.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/PR42665.cpp?rev=366694&r1=366693&r2=366694&view=diff
> ==
> --- cfe/trunk/test/CodeGenCXX/PR42665.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/PR42665.cpp Mon Jul 22 07:47:36 2019
> @@ -1,7 +1,8 @@
> -// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -std=c++17 -O0 %s 
> -o - | FileCheck %s
> -// RUN: %clang_cc1 -triple %ms_abi_triple -emit-llvm -std=c++17 -O0 %s -o - 
> | FileCheck %s
> +// RUN: %clang_cc1 -std=c++17 -O0 %s -emit-llvm -o /dev/null -verify -triple 
> %itanium_abi_triple
> +// RUN: %clang_cc1 -std=c++17 -O0 %s -emit-llvm -o /dev/null -verify -triple 
> %ms_abi_triple
>
>  // Minimal reproducer for PR42665.
> +// expected-no-diagnostics
>
>  struct Foo {
>Foo() = default;
> @@ -31,31 +32,3 @@ void foobar() {
>d(f); // Invoke virtual destructor of Foo through d.
>  } // p's destructor is invoked.
>
> -// Regexes are used to handle both kind of mangling.
> -//
> -// CHECK-LABEL: define linkonce_odr{{( dso_local)?}} void 
> @{{.*deleter.*Foo.*}}(%struct.Foo* dereferenceable({{[0-9]+}})
> -// CHECK-SAME: [[T:%.*]])
> -// CHECK: [[T_ADDR:%.*]] = alloca %struct.Foo*
> -// CHECK: store %struct.Foo* [[T]], %struct.Foo** [[T_ADDR]]
> -// CHECK: [[R0:%.*]] = load %struct.Foo*, %struct.Foo** [[T_ADDR]]
> -// CHECK: [[R1:%.*]] = bitcast %struct.Foo* [[R0]] to 
> [[TYPE:.*struct\.Foo.*]]***
> -// CHECK: [[VTABLE:%.*]] = load [[TYPE]]**, [[TYPE]]*** [[R1]]
> -// CHECK: [[VFUN:%.*]] = getelementptr inbounds [[TYPE]]*, [[TYPE]]** 
> [[VTABLE]], i64 0
> -// CHECK: [[DTOR:%.*]] = load [[TYPE]]*, [[TYPE]]** [[VFUN]]
> -// CHECK: call {{(void|i8\*)}} [[DTOR]](%struct.Foo* [[R0]]
> -//
> -// CHECK-LABEL: define{{( dso_local)?}} void @{{.*foobar.*}}()
> -// CHECK: [[P:%.*]] = alloca %struct.Pair
> -// CHECK: [[F:%.*]] = alloca %struct.Foo*
> -// CHECK: [[D:%.*]] = alloca [[TYPE:void \(%struct.Foo\*\)]]**
> -// CHECK: call void @{{.*make_pair.*}}(%struct.Pair* sret [[P]])
> -// CHECK: [[FIRST:%.*]] = getelementptr inbounds %struct.Pair, %struct.Pair* 
> [[P]], i32 0, i32 0
> -// CHECK: store %struct.Foo* [[FIRST]], %struct.Foo** [[F]]
> -// CHECK: [[SECOND:%.*]] = getelementptr inbounds %struct.Pair, 
> %struct.Pair* [[P]], i32 0, i32 1
> -// CHECK: store void (%struct.Foo*)** [[SECOND]], [[TYPE]]*** [[D]]
> -// CHECK: [[R0:%.*]] = load [[TYPE]]**, [[TYPE]]*** [[D]]
> -// CHECK: [[R1:%.*]] = load [[TYPE]]*, [[TYPE]]** [[R0]]
> -// CHECK: [[R2:%.*]] = load %struct.Foo*, %struct.Foo** [[F]]
> -// CHECK: call void [[R1]](%struct.Foo* dereferenceable({{[0-9]+}}) [[R2]])
> -// CHECK: call void @{{.*Pair.*Foo.*}}(%struct.Pair* [[P]])
> -
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64638: [CrossTU] Fix plist macro expansion if macro in other file.

2019-07-23 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

Maybe CrossTU should not use the Frontend library? (Now the StaticAnalyzerCore 
is using CrossTU and CrossTU is using Frontend, in this way StaticAnalyzerCore 
could use Frontend too.)


Repository:
  rC Clang

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

https://reviews.llvm.org/D64638



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


[PATCH] D65153: [clangd] Also accept flags from CLANGD_FLAGS variable.

2019-07-23 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

This simplifies various workflows, particularly in debugging/development.
e.g. editors will tend to propagate flags, so you can run
`env CLANGD_FLAGS=-input-mirror-file=/tmp/mirror vim foo.cc` rather than change
the configuration in a persistent way.
(This also gives us a generic lever when we don't know how to customize the
flags in some particular LSP client).

While here, add a test for this and other startup logging, and fix a couple
of direct writes to errs() that should have been logs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65153

Files:
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/test/log.test
  clang-tools-extra/clangd/tool/ClangdMain.cpp


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -22,6 +22,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
@@ -342,14 +343,18 @@
   llvm::cl::SetVersionPrinter([](llvm::raw_ostream &OS) {
 OS << clang::getClangToolFullVersion("clangd") << "\n";
   });
-  llvm::cl::ParseCommandLineOptions(
-  argc, argv,
-  "clangd is a language server that provides IDE-like features to editors. 
"
-  "\n\nIt should be used via an editor plugin rather than invoked "
-  "directly. "
-  "For more information, see:"
-  "\n\thttps://clang.llvm.org/extra/clangd.html";
-  "\n\thttps://microsoft.github.io/language-server-protocol/";);
+  const char *FlagsEnvVar = "CLANGD_FLAGS";
+  const char *Overview =
+  R"(clangd is a language server that provides IDE-like features to 
editors.
+
+It should be used via an editor plugin rather than invoked directly. For more 
information, see:
+   https://clang.llvm.org/extra/clangd.html
+   https://microsoft.github.io/language-server-protocol/
+
+clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment 
variable.
+)";
+  llvm::cl::ParseCommandLineOptions(argc, argv, Overview,
+/*Errs=*/nullptr, FlagsEnvVar);
   if (Test) {
 Sync = true;
 InputStyle = JSONStreamStyle::Delimited;
@@ -434,6 +439,8 @@
   }
   for (int I = 0; I < argc; ++I)
 log("argv[{0}]: {1}", I, argv[I]);
+  if (auto EnvFlags = llvm::sys::Process::GetEnv(FlagsEnvVar))
+log("{0}: {1}", FlagsEnvVar, *EnvFlags);
 
   // If --compile-commands-dir arg was invoked, check value and override 
default
   // path.
Index: clang-tools-extra/clangd/test/log.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/log.test
@@ -0,0 +1,9 @@
+# RUN: not env CLANGD_FLAGS=-index-file=no-such-index clangd -lit-test 
&1 >/dev/null | FileCheck %s
+CHECK: I[{{.*}}] clangd version {{.*}}
+CHECK: Working directory: {{.*}}
+CHECK: argv[0]: clangd
+CHECK: argv[1]: -lit-test
+CHECK: CLANGD_FLAGS: -index-file=no-such-index
+CHECK: E[{{.*}}] Can't open no-such-index
+CHECK: Starting LSP over stdin/stdout
+
Index: clang-tools-extra/clangd/index/Serialization.cpp
===
--- clang-tools-extra/clangd/index/Serialization.cpp
+++ clang-tools-extra/clangd/index/Serialization.cpp
@@ -690,7 +690,7 @@
   trace::Span OverallTracer("LoadIndex");
   auto Buffer = llvm::MemoryBuffer::getFile(SymbolFilename);
   if (!Buffer) {
-llvm::errs() << "Can't open " << SymbolFilename << "\n";
+elog("Can't open {0}", SymbolFilename);
 return nullptr;
   }
 
@@ -707,7 +707,7 @@
   if (I->Relations)
 Relations = std::move(*I->Relations);
 } else {
-  llvm::errs() << "Bad Index: " << llvm::toString(I.takeError()) << "\n";
+  elog("Bad Index: {0}", I.takeError());
   return nullptr;
 }
   }


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -22,6 +22,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
@@ -342,14 +343,18 @@
   llvm::cl::SetVersionPrinter([](llvm::raw_ostream &OS) {
 OS << clang::getClangToolFullVersion("clangd") << "\n";
   });
-  llvm::cl::ParseCommandLineOptions(
-  argc, argv,
-  "clangd is a language server that provides IDE-like features t

[PATCH] D64883: Add new warning -Walloca for use of builtin alloca function

2019-07-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:2776
+def warn_alloca : Warning<
+  "use of builtin function %0">,
+  InGroup>, DefaultIgnore;

george.burgess.iv wrote:
> aaron.ballman wrote:
> > george.burgess.iv wrote:
> > > aaron.ballman wrote:
> > > > george.burgess.iv wrote:
> > > > > nit: I'd just say "use of function '%0'" here; "builtin" doesn't 
> > > > > really add much.
> > > > > 
> > > > > I also wonder if we should be saying anything more than "we found a 
> > > > > use of this function." Looks like GCC doesn't 
> > > > > (https://godbolt.org/z/sYs_8G), but since this warning is sort of 
> > > > > opinionated in itself, might it be better to expand this to "use of 
> > > > > '%0' is discouraged"?
> > > > > 
> > > > > WDYT, Aaron?
> > > > What is the purpose to this diagnostic, aside from GCC compatibility? 
> > > > What does it protect against?
> > > > 
> > > > If there's a reason users should not use alloc(), it would be better 
> > > > for the diagnostic to spell it out.
> > > > 
> > > > Btw, I'm okay with this being default-off because the GCC warning is as 
> > > > well. I'm mostly hoping we can do better with our diagnostic wording.
> > > > I'm mostly hoping we can do better with our diagnostic wording
> > > 
> > > +1
> > > 
> > > > What is the purpose to this diagnostic?
> > > 
> > > I think the intent boils down to that `alloca` is easily misused, and 
> > > leads to e.g., 
> > > https://www.qualys.com/2017/06/19/stack-clash/stack-clash.txt . Since its 
> > > use often boils down to nothing but a tiny micro-optimization, some 
> > > parties would like to discourage its use.
> > > 
> > > Both glibc and bionic recommend against the use of `alloca` in their 
> > > documentation, though glibc's docs are less assertive than bionic's, and 
> > > explicitly call out "[alloca's] use can improve efficiency compared to 
> > > the use of malloc plus free."
> > > 
> > > Greping a codebase and investigating the first 15 results:
> > > - all of them look like microoptimizations; many of them also sit close 
> > > to other `malloc`/`new` ops, so allocating on these paths presumably 
> > > isn't prohibitively expensive
> > > - all but two of the uses of `alloca` have no logic to fall back to the 
> > > heap `malloc` if the array they want to allocate passes a certain 
> > > threshold. Some of the uses make it look *really* easy for the array to 
> > > grow very large.
> > > - one of the uses compares the result of `alloca` to `NULL`. Since 
> > > `alloca`'s behavior is undefined if it fails, ...
> > > 
> > > I'm having trouble putting this into a concise and actionable diagnostic 
> > > message, though. The best I can come up with at the moment is something 
> > > along the lines of "use of function %0 is subtle; consider using heap 
> > > allocation instead."
> > Okay, that's along the lines of what I was thinking.
> > 
> > Part of me thinks that this should not diagnose calls to `alloca()` that 
> > are given a constant value that we can test for sanity at compile time. 
> > e.g., calling `alloca(10)` is highly unlikely to be a problem, but calling 
> > `alloca(100)` certainly could be, while `alloca(x)` is a different 
> > class of problem without good static analysis.
> > 
> > That said, perhaps we could get away with `use of function %0 is 
> > discouraged; there is no way to check for failure but failure may still 
> > occur, resulting in a possibly exploitable security vulnerability` or 
> > something along those lines?
> Yeah, GCC has a similar `-Walloca-larger-than=N` that does roughly what you 
> described. The icky part is exactly what you said. GCC will warn about 
> unknown values, but considers control flow when doing so: 
> https://godbolt.org/z/J3pGiT
> 
> It looks like it's the same "we apply optimizations and then see what 
> happens" behavior as similar diagnostics: https://godbolt.org/z/lLyteP
> 
> WRT the diag we emit here, maybe we could use notes to break it up and imply 
> things? e.g.
> 
> warning: use of function %0 is discouraged, due to its security implications
> note: 'malloc' or 'new' are suggested alternatives, since they have 
> well-defined behavior on failure
> 
> ...not sold on the idea, but it's a thought.
> 
> If we don't want to break it to pieces, I'm fine with your suggestion
I'm not certain the note adds value because it will always be printed on the 
same line as the warning. A note would make sense if we had a secondary 
location to annotate though.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64883



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


[PATCH] D63954: Add lifetime categories attributes

2019-07-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:4167
+
+The attribute ``[[gsl::Owner(T)]]`` applies to structs and classes that own an
+object of type ``T``:

Do either of these attributes make sense on a union type? If so, might be worth 
mentioning unions here and below. If not, would it be worth diagnosing on a 
union?



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:2516
   "%0 and %1 attributes are not compatible">;
+def err_attribute_invalid_argument : Error<
+  "%0 is an invalid argument to attribute %1">;

Can you combine this one with `err_attribute_argument_vec_type_hint`?



Comment at: clang/lib/Parse/ParseDecl.cpp:385
+  TheParsedType = T.get();
+break; // Multiple type arguments are not implemented.
+  } else if (Tok.is(tok::identifier) &&

Can you add a FIXME prefix to the comment?



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:4550
+  S.Diag(AL.getLoc(), diag::err_attribute_invalid_argument)
+  << "A reference type" << AL;
+  return;

This should say `a reference type`, but I prefer seeing this done in a 
`%select{}` within the diagnostic rather than manually adding string literals. 
This will also simplify the logic down to:
```
unsigned SelectIdx = ~0U;
if (ParamType->isVoidType())
  SelectIdx = 0;
else if (ParamType->isReferenceType())
  SelectIdx = 1;
else if (ParamType->isArrayType())
  SelectIdx = 2;

if (SelectIdx != ~0U) {
  S.Diag(...) << SelectIdx << AL;
  return;
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63954



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


[PATCH] D62829: [clang-tidy] Check for dynamically initialized statics in headers.

2019-07-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-dynamic-static-initializers.rst:9
+
+This can pose problems in certain multithreaded contexts.

Eugene.Zelenko wrote:
> Will be good idea to provide example.
Agreed, I'd like to see an example in the docs.



Comment at: 
clang-tools-extra/test/clang-tidy/bugprone-dynamic-static-initializers.hpp:33-35
+  // This may work fine when optimization is enabled because bar() can
+  // be turned into a constant 7.  But without optimization, it can
+  // cause problems. Therefore, we must err on the side of conservatism.

What problems can be caused here? Typically, dynamic init is only problematic 
when it happens before main() is executed (because of initialization order 
dependencies), but that doesn't apply to local statics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62829



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


[PATCH] D64793: [Driver] Properly use values-X[ca].o, values-xpg[46].o on Solaris

2019-07-23 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

Is this really necessary? Users don't typically pass -std= to the driver for 
linking anyways (what do you even pass if you've compiled both C and C++ code?) 
so this seems a rather odd way to control behavior.

How about instead just adding "values-xpg6.o" unconditionally, alongside the 
current unconditional "values-Xa.o", and just forget about the xpg4 and Xc 
modes?




Comment at: lib/Driver/ToolChains/Solaris.cpp:16
 #include "clang/Driver/Options.h"
+#include "clang/Frontend/LangStandard.h"
 #include "llvm/Option/ArgList.h"

I'm not sure that's an acceptable dependency -- I think Driver probably is not 
supposed to depend on Frontend. If so, I guess LangStandard should move to 
clang/Basic/. Which also means moving InputKind from 
clang/include/clang/Frontend/FrontendOptions.h.

(Maybe someone else can weigh in on this question?)


Repository:
  rC Clang

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

https://reviews.llvm.org/D64793



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


[PATCH] D65154: [clangd] Reformat use of cl::opt: use unqualified name and don't bin-pack attributes. NFC

2019-07-23 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65154

Files:
  clang-tools-extra/clangd/tool/ClangdMain.cpp

Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -36,128 +36,161 @@
 namespace clang {
 namespace clangd {
 
-static llvm::cl::opt CompileCommandsDir(
+using llvm::cl::cat;
+using llvm::cl::CommaSeparated;
+using llvm::cl::desc;
+using llvm::cl::Hidden;
+using llvm::cl::init;
+using llvm::cl::list;
+using llvm::cl::opt;
+using llvm::cl::values;
+
+static opt CompileCommandsDir{
 "compile-commands-dir",
-llvm::cl::desc("Specify a path to look for compile_commands.json. If path "
-   "is invalid, clangd will look in the current directory and "
-   "parent paths of each source file"));
+desc("Specify a path to look for compile_commands.json. If path "
+ "is invalid, clangd will look in the current directory and "
+ "parent paths of each source file"),
+};
 
-static llvm::cl::opt
-WorkerThreadsCount("j",
-   llvm::cl::desc("Number of async workers used by clangd"),
-   llvm::cl::init(getDefaultAsyncThreadsCount()));
+static opt WorkerThreadsCount{
+"j",
+desc("Number of async workers used by clangd"),
+init(getDefaultAsyncThreadsCount()),
+};
 
 // FIXME: also support "plain" style where signatures are always omitted.
 enum CompletionStyleFlag { Detailed, Bundled };
-static llvm::cl::opt CompletionStyle(
+static opt CompletionStyle{
 "completion-style",
-llvm::cl::desc("Granularity of code completion suggestions"),
-llvm::cl::values(
-clEnumValN(Detailed, "detailed",
-   "One completion item for each semantically distinct "
-   "completion, with full type information"),
-clEnumValN(Bundled, "bundled",
-   "Similar completion items (e.g. function overloads) are "
-   "combined. Type information shown where possible")));
+desc("Granularity of code completion suggestions"),
+values(clEnumValN(Detailed, "detailed",
+  "One completion item for each semantically distinct "
+  "completion, with full type information"),
+   clEnumValN(Bundled, "bundled",
+  "Similar completion items (e.g. function overloads) are "
+  "combined. Type information shown where possible")),
+};
 
 // FIXME: Flags are the wrong mechanism for user preferences.
 // We should probably read a dotfile or similar.
-static llvm::cl::opt IncludeIneligibleResults(
+static opt IncludeIneligibleResults{
 "include-ineligible-results",
-llvm::cl::desc(
-"Include ineligible completion results (e.g. private members)"),
-llvm::cl::init(CodeCompleteOptions().IncludeIneligibleResults),
-llvm::cl::Hidden);
-
-static llvm::cl::opt InputStyle(
-"input-style", llvm::cl::desc("Input JSON stream encoding"),
-llvm::cl::values(
+desc("Include ineligible completion results (e.g. private members)"),
+init(CodeCompleteOptions().IncludeIneligibleResults),
+Hidden,
+};
+
+static opt InputStyle{
+"input-style",
+desc("Input JSON stream encoding"),
+values(
 clEnumValN(JSONStreamStyle::Standard, "standard", "usual LSP protocol"),
 clEnumValN(JSONStreamStyle::Delimited, "delimited",
"messages delimited by --- lines, with # comment support")),
-llvm::cl::init(JSONStreamStyle::Standard), llvm::cl::Hidden);
-
-static llvm::cl::opt
-PrettyPrint("pretty", llvm::cl::desc("Pretty-print JSON output"),
-llvm::cl::init(false));
-
-static llvm::cl::opt LogLevel(
-"log", llvm::cl::desc("Verbosity of log messages written to stderr"),
-llvm::cl::values(clEnumValN(Logger::Error, "error", "Error messages only"),
- clEnumValN(Logger::Info, "info",
-"High level execution tracing"),
- clEnumValN(Logger::Debug, "verbose", "Low level details")),
-llvm::cl::init(Logger::Info));
-
-static llvm::cl::opt
-Test("lit-test",
- llvm::cl::desc("Abbreviation for -input-style=delimited -pretty -sync "
-"-enable-test-scheme -log=verbose."
-"Intended to simplify lit tests"),
- llvm::cl::init(false), llvm::cl::Hidden);
-
-static llvm::cl::opt EnableTestScheme(
+init(JSONStreamStyle::Standard),
+Hidden,
+};
+
+static opt PrettyPrint{
+"pretty",
+desc("Pretty-print JSON output"),
+init(false),
+};
+
+static opt LogLevel{
+"log",
+desc("Verbosity 

r366818 - [ASTImporter] Fix inequivalence of ClassTemplateInstantiations

2019-07-23 Thread Gabor Marton via cfe-commits
Author: martong
Date: Tue Jul 23 08:46:38 2019
New Revision: 366818

URL: http://llvm.org/viewvc/llvm-project?rev=366818&view=rev
Log:
[ASTImporter] Fix inequivalence of ClassTemplateInstantiations

Summary:
We falsely state inequivalence if the template parameter is a
qualified/nonquialified template in the first/second instantiation.
Also, different kinds of TemplateName should be equal if the template
decl (if available) is equal (even if the name kind is different).

Reviewers: a_sidorin, a.sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp

Modified: cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp?rev=366818&r1=366817&r2=366818&view=diff
==
--- cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp (original)
+++ cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp Tue Jul 23 08:46:38 2019
@@ -235,12 +235,21 @@ static bool IsStructurallyEquivalent(Str
 static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
  const TemplateName &N1,
  const TemplateName &N2) {
-  if (N1.getKind() != N2.getKind())
+  TemplateDecl *TemplateDeclN1 = N1.getAsTemplateDecl();
+  TemplateDecl *TemplateDeclN2 = N2.getAsTemplateDecl();
+  if (TemplateDeclN1 && TemplateDeclN2) {
+if (!IsStructurallyEquivalent(Context, TemplateDeclN1, TemplateDeclN2))
+  return false;
+// If the kind is different we compare only the template decl.
+if (N1.getKind() != N2.getKind())
+  return true;
+  } else if (TemplateDeclN1 || TemplateDeclN2)
+return false;
+  else if (N1.getKind() != N2.getKind())
 return false;
+
+  // Check for special case incompatibilities.
   switch (N1.getKind()) {
-  case TemplateName::Template:
-return IsStructurallyEquivalent(Context, N1.getAsTemplateDecl(),
-N2.getAsTemplateDecl());
 
   case TemplateName::OverloadedTemplate: {
 OverloadedTemplateStorage *OS1 = N1.getAsOverloadedTemplate(),
@@ -259,14 +268,6 @@ static bool IsStructurallyEquivalent(Str
 return TN1->getDeclName() == TN2->getDeclName();
   }
 
-  case TemplateName::QualifiedTemplate: {
-QualifiedTemplateName *QN1 = N1.getAsQualifiedTemplateName(),
-  *QN2 = N2.getAsQualifiedTemplateName();
-return IsStructurallyEquivalent(Context, QN1->getDecl(), QN2->getDecl()) &&
-   IsStructurallyEquivalent(Context, QN1->getQualifier(),
-QN2->getQualifier());
-  }
-
   case TemplateName::DependentTemplate: {
 DependentTemplateName *DN1 = N1.getAsDependentTemplateName(),
   *DN2 = N2.getAsDependentTemplateName();
@@ -281,15 +282,6 @@ static bool IsStructurallyEquivalent(Str
 return false;
   }
 
-  case TemplateName::SubstTemplateTemplateParm: {
-SubstTemplateTemplateParmStorage *TS1 = 
N1.getAsSubstTemplateTemplateParm(),
- *TS2 = 
N2.getAsSubstTemplateTemplateParm();
-return IsStructurallyEquivalent(Context, TS1->getParameter(),
-TS2->getParameter()) &&
-   IsStructurallyEquivalent(Context, TS1->getReplacement(),
-TS2->getReplacement());
-  }
-
   case TemplateName::SubstTemplateTemplateParmPack: {
 SubstTemplateTemplateParmPackStorage
 *P1 = N1.getAsSubstTemplateTemplateParmPack(),
@@ -299,8 +291,16 @@ static bool IsStructurallyEquivalent(Str
IsStructurallyEquivalent(Context, P1->getParameterPack(),
 P2->getParameterPack());
   }
+
+   case TemplateName::Template:
+   case TemplateName::QualifiedTemplate:
+   case TemplateName::SubstTemplateTemplateParm:
+ // It is sufficient to check value of getAsTemplateDecl.
+ break;
+
   }
-  return false;
+
+  return true;
 }
 
 /// Determine whether two template arguments are equivalent.

Modified: cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp?rev=366818&r1=366817&r2=366818&view=diff
==
--- cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp (original)
+++ cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp Tue Jul 23 08:46:38 
2019
@@ -944,6 +944,67 @@ TEST_F(StructuralEquivalenceTemplateTest
   EXPECT_FALSE(testStructuralMatch(First, Second));
 }
 
+TEST_F(StructuralEquivalenceTemplateTest,
+   TemplateVsSubstTemplateTemplateParmInArgEq) {
+  auto t = makeDecls(
+  R"(
+template  class Arg { };
+template  class P1> cla

[PATCH] D64241: [ASTImporter] Fix inequivalence of ClassTemplateInstantiations

2019-07-23 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366818: [ASTImporter] Fix inequivalence of 
ClassTemplateInstantiations (authored by martong, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64241?vs=210581&id=211311#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64241

Files:
  cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
  cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp

Index: cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
===
--- cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
+++ cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
@@ -235,12 +235,21 @@
 static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
  const TemplateName &N1,
  const TemplateName &N2) {
-  if (N1.getKind() != N2.getKind())
+  TemplateDecl *TemplateDeclN1 = N1.getAsTemplateDecl();
+  TemplateDecl *TemplateDeclN2 = N2.getAsTemplateDecl();
+  if (TemplateDeclN1 && TemplateDeclN2) {
+if (!IsStructurallyEquivalent(Context, TemplateDeclN1, TemplateDeclN2))
+  return false;
+// If the kind is different we compare only the template decl.
+if (N1.getKind() != N2.getKind())
+  return true;
+  } else if (TemplateDeclN1 || TemplateDeclN2)
 return false;
+  else if (N1.getKind() != N2.getKind())
+return false;
+
+  // Check for special case incompatibilities.
   switch (N1.getKind()) {
-  case TemplateName::Template:
-return IsStructurallyEquivalent(Context, N1.getAsTemplateDecl(),
-N2.getAsTemplateDecl());
 
   case TemplateName::OverloadedTemplate: {
 OverloadedTemplateStorage *OS1 = N1.getAsOverloadedTemplate(),
@@ -259,14 +268,6 @@
 return TN1->getDeclName() == TN2->getDeclName();
   }
 
-  case TemplateName::QualifiedTemplate: {
-QualifiedTemplateName *QN1 = N1.getAsQualifiedTemplateName(),
-  *QN2 = N2.getAsQualifiedTemplateName();
-return IsStructurallyEquivalent(Context, QN1->getDecl(), QN2->getDecl()) &&
-   IsStructurallyEquivalent(Context, QN1->getQualifier(),
-QN2->getQualifier());
-  }
-
   case TemplateName::DependentTemplate: {
 DependentTemplateName *DN1 = N1.getAsDependentTemplateName(),
   *DN2 = N2.getAsDependentTemplateName();
@@ -281,15 +282,6 @@
 return false;
   }
 
-  case TemplateName::SubstTemplateTemplateParm: {
-SubstTemplateTemplateParmStorage *TS1 = N1.getAsSubstTemplateTemplateParm(),
- *TS2 = N2.getAsSubstTemplateTemplateParm();
-return IsStructurallyEquivalent(Context, TS1->getParameter(),
-TS2->getParameter()) &&
-   IsStructurallyEquivalent(Context, TS1->getReplacement(),
-TS2->getReplacement());
-  }
-
   case TemplateName::SubstTemplateTemplateParmPack: {
 SubstTemplateTemplateParmPackStorage
 *P1 = N1.getAsSubstTemplateTemplateParmPack(),
@@ -299,8 +291,16 @@
IsStructurallyEquivalent(Context, P1->getParameterPack(),
 P2->getParameterPack());
   }
+
+   case TemplateName::Template:
+   case TemplateName::QualifiedTemplate:
+   case TemplateName::SubstTemplateTemplateParm:
+ // It is sufficient to check value of getAsTemplateDecl.
+ break;
+
   }
-  return false;
+
+  return true;
 }
 
 /// Determine whether two template arguments are equivalent.
Index: cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp
===
--- cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp
+++ cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp
@@ -944,6 +944,67 @@
   EXPECT_FALSE(testStructuralMatch(First, Second));
 }
 
+TEST_F(StructuralEquivalenceTemplateTest,
+   TemplateVsSubstTemplateTemplateParmInArgEq) {
+  auto t = makeDecls(
+  R"(
+template  class Arg { };
+template  class P1> class Primary { };
+
+void f() {
+  // Make specialization with simple template.
+  Primary  A;
+}
+  )",
+  R"(
+template  class Arg { };
+template  class P1> class Primary { };
+
+template  class P1> class Templ {
+  void f() {
+// Make specialization with substituted template template param.
+Primary  A;
+  };
+};
+
+// Instantiate with substitution Arg into P1.
+template class Templ ;
+  )",
+  Lang_CXX, classTemplateSpecializationDecl(hasName("Primary")));
+  EXPECT_TRUE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceTemplateTest,
+   TemplateVsSubstTemplateTemplateParmInArgNotEq) {
+  auto t = makeDecls(
+  R"(
+template  class Arg { };
+template  class P1> class Primary { };
+
+void f() {
+

[PATCH] D59692: [ASTImporter] Fix name conflict handling

2019-07-23 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 211312.
martong added a comment.

- Rebase to master


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59692

Files:
  clang/include/clang/AST/ASTImporter.h
  clang/lib/AST/ASTImporter.cpp
  clang/test/Analysis/Inputs/ctu-other.c
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -1879,7 +1879,7 @@
   auto *ToTU = ToAST->getASTContext().getTranslationUnitDecl();
   // We expect one (ODR) warning during the import.
   EXPECT_EQ(1u, ToTU->getASTContext().getDiagnostics().getNumWarnings());
-  EXPECT_EQ(2u,
+  EXPECT_EQ(1u,
 DeclCounter().match(ToTU, recordDecl(hasName("X";
 }
 
@@ -2389,6 +2389,64 @@
 functionDecl(hasName("f"), hasDescendant(declRefExpr()));
 }
 
+struct ImportFunctionTemplates : ASTImporterOptionSpecificTestBase {};
+
+TEST_P(ImportFunctionTemplates,
+   ImportFunctionWhenThereIsAFunTemplateWithSameName) {
+  getToTuDecl(
+  R"(
+  template 
+  void foo(T) {}
+  void foo();
+  )",
+  Lang_CXX);
+  Decl *FromTU = getTuDecl("void foo();", Lang_CXX);
+  auto *FromD = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("foo")));
+  auto *ImportedD = Import(FromD, Lang_CXX);
+  EXPECT_TRUE(ImportedD);
+}
+
+TEST_P(ImportFunctionTemplates,
+   ImportConstructorWhenThereIsAFunTemplateWithSameName) {
+  auto Code =
+  R"(
+  struct Foo {
+template 
+Foo(T) {}
+Foo();
+  };
+  )";
+  getToTuDecl(Code, Lang_CXX);
+  Decl *FromTU = getTuDecl(Code, Lang_CXX);
+  auto *FromD =
+  LastDeclMatcher().match(FromTU, cxxConstructorDecl());
+  auto *ImportedD = Import(FromD, Lang_CXX);
+  EXPECT_TRUE(ImportedD);
+}
+
+TEST_P(ImportFunctionTemplates,
+   ImportOperatorWhenThereIsAFunTemplateWithSameName) {
+  getToTuDecl(
+  R"(
+  template 
+  void operator<(T,T) {}
+  struct X{};
+  void operator<(X, X);
+  )",
+  Lang_CXX);
+  Decl *FromTU = getTuDecl(
+  R"(
+  struct X{};
+  void operator<(X, X);
+  )",
+  Lang_CXX);
+  auto *FromD = LastDeclMatcher().match(
+  FromTU, functionDecl(hasOverloadedOperatorName("<")));
+  auto *ImportedD = Import(FromD, Lang_CXX);
+  EXPECT_TRUE(ImportedD);
+}
+
 struct ImportFriendFunctions : ImportFunctions {};
 
 TEST_P(ImportFriendFunctions, ImportFriendFunctionRedeclChainProto) {
@@ -5207,6 +5265,9 @@
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFunctions,
 DefaultTestValuesForRunOptions, );
 
+INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFunctionTemplates,
+DefaultTestValuesForRunOptions, );
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFriendFunctionTemplates,
 DefaultTestValuesForRunOptions, );
 
Index: clang/test/Analysis/Inputs/ctu-other.c
===
--- clang/test/Analysis/Inputs/ctu-other.c
+++ clang/test/Analysis/Inputs/ctu-other.c
@@ -12,11 +12,11 @@
 }
 
 // Test enums.
-enum B { x = 42,
- l,
- s };
+enum B { x2 = 42,
+ y2,
+ z2 };
 int enumCheck(void) {
-  return x;
+  return x2;
 }
 
 // Test reporting an error in macro definition
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -80,6 +80,7 @@
   using ExpectedExpr = llvm::Expected;
   using ExpectedDecl = llvm::Expected;
   using ExpectedSLoc = llvm::Expected;
+  using ExpectedName = llvm::Expected;
 
   std::string ImportError::toString() const {
 // FIXME: Improve error texts.
@@ -2188,11 +2189,11 @@
 }
 
 if (!ConflictingDecls.empty()) {
-  Name = Importer.HandleNameConflict(Name, DC, Decl::IDNS_Namespace,
- ConflictingDecls.data(),
- ConflictingDecls.size());
-  if (!Name)
-return make_error(ImportError::NameConflict);
+  ExpectedName NameOrErr = Importer.HandleNameConflict(
+  Name, DC, Decl::IDNS_Namespace, ConflictingDecls.data(),
+  ConflictingDecls.size());
+  if (!NameOrErr)
+return NameOrErr.takeError();
 }
   }
 
@@ -2296,21 +2297,19 @@
   // already have a complete underlying type then return with that.
   if (!FromUT->isIncompleteType() && !FoundUT->isIncompleteType())
 return Importer.MapImported(D, FoundTypedef);
+  // FIXME Handle redecl chain. When you do that make consistent changes
+  // in ASTImporterLookupTable too.
+} else {
+  ConflictingDecls.push_back(FoundDecl);
 }
-// FIXME Hand

[PATCH] D64914: Implement P1771

2019-07-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D64914#1595660 , @erichkeane wrote:

> Rebased and did all the comments (including the www_status).  @aaron.ballman 
> : Wasn't positive what you meant about the conversion functions, but I think 
> I got one?


I was talking about [dcl.attr.nodiscard]p2.2: "an explicit type conversion 
(7.6.1.8 [expr.static.cast], 7.6.3 [expr.cast], 7.6.1.3 [expr.type.conv]) that 
constructs an object through a constructor declared nodiscard, or that 
initializes an object of a nodiscard type." and specifically the part about 
type conversion operators that are marked `nodiscard` directly.




Comment at: clang/include/clang/Basic/AttrDocs.td:1518
+marked_ctor(); // diagnoses.
+marked_ctor(3); // Does not diagnose, int constructor isn't marked 
nodiscard.
+  }

I think we may want to add a case like:
```
struct S {
  operator marked_type() const;
  [[nodiscard]] operator int() const;
};

void func() {
  S s;
  static_cast(s); // diagnoses
  (int)s; // diagnoses
}
```



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:2835
+  D->getFunctionType()->getReturnType()->isVoidType() &&
+  !isa(D)) {
 S.Diag(AL.getLoc(), diag::warn_attribute_void_function_method) << AL << 0;

Conversion functions?



Comment at: clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp:100
+S s;
+(ConvertTo)s; // expected-warning {{expression result unused}}
+  }

If you specify a message on the `nodiscard` attribute used here, does the 
message get printed?


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

https://reviews.llvm.org/D64914



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


[PATCH] D44100: [ASTImporter] Reorder fields after structure import is finished

2019-07-23 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 211314.
martong marked 5 inline comments as done.
martong added a comment.

- Address Alexei's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D44100

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -1472,7 +1472,7 @@
 }
 
 TEST_P(ASTImporterOptionSpecificTestBase,
-   DISABLED_CXXRecordDeclFieldOrderShouldNotDependOnImportOrder) {
+   CXXRecordDeclFieldOrderShouldNotDependOnImportOrder) {
   Decl *From, *To;
   std::tie(From, To) = getImportedDecl(
   // The original recursive algorithm of ASTImporter first imports 'c' then
@@ -2795,6 +2795,16 @@
   "main.c", enumDecl(), VerificationMatcher);
 }
 
+TEST_P(ImportDecl, ImportFieldOrder) {
+  MatchVerifier Verifier;
+  testImport("struct declToImport {"
+ "  int b = a + 2;"
+ "  int a = 5;"
+ "};",
+ Lang_CXX11, "", Lang_CXX11, Verifier,
+ recordDecl(hasFieldOrder({"b", "a"})));
+}
+
 const internal::VariadicDynCastAllOfMatcher
 dependentScopeDeclRefExpr;
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -1645,7 +1645,6 @@
   bool AccumulateChildErrors = isa(FromDC);
 
   Error ChildErrors = Error::success();
-  llvm::SmallVector ImportedDecls;
   for (auto *From : FromDC->decls()) {
 ExpectedDecl ImportedOrErr = import(From);
 if (!ImportedOrErr) {
@@ -1657,6 +1656,59 @@
 }
   }
 
+  // We reorder declarations in RecordDecls because they may have another order
+  // in the "to" context than they have in the "from" context. This may happen
+  // e.g when we import a class like this:
+  //struct declToImport {
+  //int a = c + b;
+  //int b = 1;
+  //int c = 2;
+  //};
+  // During the import of `a` we import first the dependencies in sequence,
+  // thus the order would be `c`, `b`, `a`. We will get the normal order by
+  // first removing the already imported members and then adding them in the
+  // order as they apper in the "from" context.
+  //
+  // Keeping field order is vital because it determines structure layout.
+  //
+  // Here and below, we cannot call field_begin() method and its callers on
+  // ToDC if it has an external storage. Calling field_begin() will
+  // automatically load all the fields by calling
+  // LoadFieldsFromExternalStorage(). LoadFieldsFromExternalStorage() would
+  // call ASTImporter::Import(). This is because the ExternalASTSource
+  // interface in LLDB is implemented by the means of the ASTImporter. However,
+  // calling an import at this point would result in an uncontrolled import, we
+  // must avoid that.
+  const auto *FromRD = dyn_cast(FromDC);
+  if (!FromRD)
+return ChildErrors;
+
+  auto ToDCOrErr = Importer.ImportContext(FromDC);
+  if (!ToDCOrErr) {
+consumeError(std::move(ChildErrors));
+return ToDCOrErr.takeError();
+  }
+
+  DeclContext *ToDC = *ToDCOrErr;
+  // Remove all declarations, which may be in wrong order in the
+  // lexical DeclContext and then add them in the proper order.
+  for (auto *D : FromRD->decls()) {
+if (isa(D) || isa(D)) {
+  assert(D && "DC contains a null decl");
+  Decl *ToD = Importer.GetAlreadyImportedOrNull(D);
+  // Remove only the decls which we successfully imported.
+  if (ToD) {
+assert(ToDC == ToD->getLexicalDeclContext() && ToDC->containsDecl(ToD));
+// Remove the decl from its wrong place in the linked list.
+ToDC->removeDecl(ToD);
+// Add the decl to the end of the linked list.
+// This time it will be at the proper place because the enclosing for
+// loop iterates in the original (good) order of the decls.
+ToDC->addDeclInternal(ToD);
+  }
+}
+  }
+
   return ChildErrors;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64666: [Sema] Enable -Wimplicit-float-conversion for integral to floating point precision loss

2019-07-23 Thread JF Bastien via Phabricator via cfe-commits
jfb requested changes to this revision.
jfb added a comment.
Herald added a subscriber: dexonsmith.

In D64666#1597193 , @aaron.ballman 
wrote:

> In D64666#1596660 , @xbolva00 wrote:
>
> > I think we should warn in that case even if GCC does not warn.
>
>
> Strong +1.


Sorry if the phrasing was misleading: if we know for a fact that there's a 
problem, we should warn unconditionally. If we don't know for a fact then the 
warning should *not* be enabled by `-Wall` nor `-Wextra`. I don't really care 
what GCC does by default, LLVM doesn't have to match every single thing. That 
being said, if LLVM behaves differently then maybe the flag name should be 
different.

> In D64666#1596853 , @ziangwan wrote:
> 
>> Final review ping.
> 
> 
> Please be sure to give reviewers enough time to respond to comments before 
> pinging a review.

Indeed. You haven't answered my first comment, I'd expect you to do so and not 
"final ping" anything. I'm not saying you must do what I say, just that you 
must answer comments, not ignore them.


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

https://reviews.llvm.org/D64666



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


[PATCH] D44100: [ASTImporter] Reorder fields after structure import is finished

2019-07-23 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/unittests/AST/ASTImporterTest.cpp:5244
+}
+
+

a_sidorin wrote:
> A redundant newline?
Yes, I deleted that. And moved the test case closer the the last `ImportDecl` 
test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D44100



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


r366820 - [clang, test] Fix Clang :: Headers/max_align.c on 64-bit SPARC

2019-07-23 Thread Rainer Orth via cfe-commits
Author: ro
Date: Tue Jul 23 09:24:00 2019
New Revision: 366820

URL: http://llvm.org/viewvc/llvm-project?rev=366820&view=rev
Log:
[clang, test] Fix Clang :: Headers/max_align.c on 64-bit SPARC

Clang :: Headers/max_align.c currently FAILs on 64-bit SPARC:

  error: 'error' diagnostics seen but not expected: 
File /vol/llvm/src/clang/dist/test/Headers/max_align.c Line 12: 
static_assert failed due to requirement '8 == _Alignof(max_align_t)' ""
  1 error generated.

This happens because SuitableAlign isn't defined for SPARCv9 unlike SPARCv8
(which uses the default of 64 bits).  gcc's sparc/sparc.h has

  #define BIGGEST_ALIGNMENT (TARGET_ARCH64 ? 128 : 64)

This patch sets SuitableAlign to match and updates the corresponding testcase.

Tested on sparcv9-sun-solaris2.11.

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

Modified:
cfe/trunk/lib/Basic/Targets/Sparc.h
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/Targets/Sparc.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/Sparc.h?rev=366820&r1=366819&r2=366820&view=diff
==
--- cfe/trunk/lib/Basic/Targets/Sparc.h (original)
+++ cfe/trunk/lib/Basic/Targets/Sparc.h Tue Jul 23 09:24:00 2019
@@ -208,6 +208,7 @@ public:
 // aligned. The SPARCv9 SCD 2.4.1 says 16-byte aligned.
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
+SuitableAlign = 128;
 LongDoubleFormat = &llvm::APFloat::IEEEquad();
 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
   }

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=366820&r1=366819&r2=366820&view=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Tue Jul 23 09:24:00 2019
@@ -9599,6 +9599,7 @@
 // X86-64-DECLSPEC: #define __declspec{{.*}}
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc64-none-none < /dev/null 
| FileCheck -match-full-lines -check-prefix SPARCV9 %s
+// SPARCV9:#define __BIGGEST_ALIGNMENT__ 16
 // SPARCV9:#define __INT64_TYPE__ long int
 // SPARCV9:#define __INTMAX_C_SUFFIX__ L
 // SPARCV9:#define __INTMAX_TYPE__ long int


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


[PATCH] D65102: [OpenCL] Rename lang mode flag for C++ mode

2019-07-23 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 211315.
Anastasia added a comment.

- Fixed `LANGSTANDARD_ALIAS_DEPR`


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

https://reviews.llvm.org/D65102

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/LangStandards.def
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCXX/mangle-address-space.cpp
  test/CodeGenOpenCL/builtins.cl
  test/CodeGenOpenCL/images.cl
  test/CodeGenOpenCL/logical-ops.cl
  test/CodeGenOpenCL/pipe_builtin.cl
  test/CodeGenOpenCL/sampler.cl
  test/CodeGenOpenCL/spir_version.cl
  test/CodeGenOpenCL/to_addr_builtin.cl
  test/CodeGenOpenCLCXX/address-space-castoperators.cpp
  test/CodeGenOpenCLCXX/address-space-deduction.cl
  test/CodeGenOpenCLCXX/address-space-deduction2.cl
  test/CodeGenOpenCLCXX/addrspace-conversion.cl
  test/CodeGenOpenCLCXX/addrspace-derived-base.cl
  test/CodeGenOpenCLCXX/addrspace-of-this.cl
  test/CodeGenOpenCLCXX/addrspace-operators.cl
  test/CodeGenOpenCLCXX/addrspace-references.cl
  test/CodeGenOpenCLCXX/addrspace-with-class.cl
  test/CodeGenOpenCLCXX/atexit.cl
  test/CodeGenOpenCLCXX/global_init.cl
  test/CodeGenOpenCLCXX/local_addrspace_init.cl
  test/CodeGenOpenCLCXX/method-overload-address-space.cl
  test/CodeGenOpenCLCXX/template-address-spaces.cl
  test/Driver/autocomplete.c
  test/Driver/opencl.cl
  test/Frontend/opencl.cl
  test/Frontend/stdlang.c
  test/Headers/opencl-c-header.cl
  test/Parser/opencl-cxx-keywords.cl
  test/Parser/opencl-cxx-virtual.cl
  test/Preprocessor/predefined-macros.c
  test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  test/SemaOpenCL/address-spaces.cl
  test/SemaOpenCL/builtin.cl
  test/SemaOpenCL/clk_event_t.cl
  test/SemaOpenCL/extension-version.cl
  test/SemaOpenCL/extensions.cl
  test/SemaOpenCL/invalid-image.cl
  test/SemaOpenCL/invalid-pipes-cl2.0.cl
  test/SemaOpenCLCXX/address-space-deduction.cl
  test/SemaOpenCLCXX/address-space-of-this-class-scope.cl
  test/SemaOpenCLCXX/address-space-of-this.cl
  test/SemaOpenCLCXX/address-space-references.cl
  test/SemaOpenCLCXX/address-space-templates.cl
  test/SemaOpenCLCXX/address_space_overloading.cl
  test/SemaOpenCLCXX/kernel_invalid.cl
  test/SemaOpenCLCXX/method-overload-address-space.cl
  test/SemaOpenCLCXX/newdelete.cl
  test/SemaOpenCLCXX/restricted.cl

Index: test/SemaOpenCLCXX/restricted.cl
===
--- test/SemaOpenCLCXX/restricted.cl
+++ test/SemaOpenCLCXX/restricted.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -pedantic -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=clc++ -pedantic -verify -fsyntax-only
 
 // This test checks that various C/C++/OpenCL C constructs are not available in
 // C++ for OpenCL.
Index: test/SemaOpenCLCXX/newdelete.cl
===
--- test/SemaOpenCLCXX/newdelete.cl
+++ test/SemaOpenCLCXX/newdelete.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -pedantic -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=clc++ -pedantic -verify -fsyntax-only
 
 class A {
   public:
Index: test/SemaOpenCLCXX/method-overload-address-space.cl
===
--- test/SemaOpenCLCXX/method-overload-address-space.cl
+++ test/SemaOpenCLCXX/method-overload-address-space.cl
@@ -1,4 +1,4 @@
-//RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -pedantic -verify
+//RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=clc++ -pedantic -verify
 
 struct C {
   void m1() __local __local; //expected-warning{{multiple identical address spaces specified for type}}
Index: test/SemaOpenCLCXX/kernel_invalid.cl
===
--- test/SemaOpenCLCXX/kernel_invalid.cl
+++ test/SemaOpenCLCXX/kernel_invalid.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -cl-std=c++ -pedantic -verify -fsyntax-only
+// RUN: %clang_cc1 %s -cl-std=clc++ -pedantic -verify -fsyntax-only
 
 struct C {
   kernel void m(); //expected-error{{kernel functions cannot be class members}}
Index: test/SemaOpenCLCXX/address_space_overloading.cl
===
--- test/SemaOpenCLCXX/address_space_overloading.cl
+++ test/SemaOpenCLCXX/address_space_overloading.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=c++
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++
 // expected-no-diagnostics
 
 struct RetGlob {
Index: test/SemaOpenCLCXX/address-space-templates.cl
===
--- test/SemaOpenCLCXX/address-space-templates.cl
+++ test/SemaOpenCLCXX/address-space-templates.cl
@@ -1,4 +1,4 @@
-//RUN: %clang_cc1 %s -cl-std=c++ -pedantic -verify -fsyntax-only
+//RUN: %clang_cc1 %s -cl-std=clc++ -pedantic -verify -fsyntax-only
 
 te

[PATCH] D65102: [OpenCL] Rename lang mode flag for C++ mode

2019-07-23 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia marked an inline comment as done.
Anastasia added inline comments.



Comment at: include/clang/Frontend/LangStandards.def:177
 LANGSTANDARD_ALIAS_DEPR(opencl20, "CL2.0")
+LANGSTANDARD_ALIAS_DEPR(opencl20, "CLC++")
 

kpet wrote:
> Shouldn't this be `openclcpp`?
Definitely! Good spot! Thanks!


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

https://reviews.llvm.org/D65102



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


[PATCH] D64487: [clang, test] Fix Clang :: Headers/max_align.c on 64-bit SPARC

2019-07-23 Thread Rainer Orth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2da6eea07cde: [clang, test] Fix Clang :: Headers/max_align.c 
on 64-bit SPARC (authored by ro).

Changed prior to commit:
  https://reviews.llvm.org/D64487?vs=208946&id=211316#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64487

Files:
  clang/lib/Basic/Targets/Sparc.h
  clang/test/Preprocessor/init.c


Index: clang/test/Preprocessor/init.c
===
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -9599,6 +9599,7 @@
 // X86-64-DECLSPEC: #define __declspec{{.*}}
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc64-none-none < /dev/null 
| FileCheck -match-full-lines -check-prefix SPARCV9 %s
+// SPARCV9:#define __BIGGEST_ALIGNMENT__ 16
 // SPARCV9:#define __INT64_TYPE__ long int
 // SPARCV9:#define __INTMAX_C_SUFFIX__ L
 // SPARCV9:#define __INTMAX_TYPE__ long int
Index: clang/lib/Basic/Targets/Sparc.h
===
--- clang/lib/Basic/Targets/Sparc.h
+++ clang/lib/Basic/Targets/Sparc.h
@@ -208,6 +208,7 @@
 // aligned. The SPARCv9 SCD 2.4.1 says 16-byte aligned.
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
+SuitableAlign = 128;
 LongDoubleFormat = &llvm::APFloat::IEEEquad();
 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
   }


Index: clang/test/Preprocessor/init.c
===
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -9599,6 +9599,7 @@
 // X86-64-DECLSPEC: #define __declspec{{.*}}
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc64-none-none < /dev/null | FileCheck -match-full-lines -check-prefix SPARCV9 %s
+// SPARCV9:#define __BIGGEST_ALIGNMENT__ 16
 // SPARCV9:#define __INT64_TYPE__ long int
 // SPARCV9:#define __INTMAX_C_SUFFIX__ L
 // SPARCV9:#define __INTMAX_TYPE__ long int
Index: clang/lib/Basic/Targets/Sparc.h
===
--- clang/lib/Basic/Targets/Sparc.h
+++ clang/lib/Basic/Targets/Sparc.h
@@ -208,6 +208,7 @@
 // aligned. The SPARCv9 SCD 2.4.1 says 16-byte aligned.
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
+SuitableAlign = 128;
 LongDoubleFormat = &llvm::APFloat::IEEEquad();
 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D65102: [OpenCL] Rename lang mode flag for C++ mode

2019-07-23 Thread Kévin Petit via Phabricator via cfe-commits
kpet added a comment.

Hmm, maybe we need to make sure that one of the tests is using a C++ feature 
and building with `CLC++`. This would have caught the mistake.


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

https://reviews.llvm.org/D65102



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


[PATCH] D59474: [OpenMP 5.0] Codegen support for user-defined mappers

2019-07-23 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGDecl.cpp:2533
+ CodeGenFunction *CGF) {
+  if (!LangOpts.OpenMP || LangOpts.OpenMPSimd ||
+  (!LangOpts.EmitAllDecls && !D->isUsed()))

Why do we need to emit it for simd only mode?



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:1695
+  if (FunctionUDMMap.count(CGF.CurFn) > 0) {
+for(auto *D : FunctionUDMMap[CGF.CurFn])
+  UDMMap.erase(D);

You're looking for `CGF.CurFn` twice here, used `find` member function instead 
and work with iterator.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:7116-7124
+  /// Get the offset of the OMP_MAP_MEMBER_OF field.
+  static unsigned getFlagMemberOffset() {
+unsigned Offset = 0;
+for (uint64_t Remain = OMP_MAP_MEMBER_OF; !(Remain & 1);
+ Remain = Remain >> 1)
+  Offset++;
+return Offset;

Maybe it is better to define a constant `constexpr uint64_t OMP_MEMBER_OF_RANK 
= 48` and then deduce `OMP_MAP_MEMBER_OF` as `~((1< to find member CurDir.
+assert(this->CurDir.is() &&

AFAIK, LLVM has dropped support for msvc 2013, do we still need this?



Comment at: lib/CodeGen/CGOpenMPRuntime.h:352
+  /// Map of functions and their local user-defined mappers.
+  typedef llvm::DenseMap>

Use `using` instead of `typedef`.


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

https://reviews.llvm.org/D59474



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


Re: r366694 - [NFC] Relaxed regression tests for PR42665

2019-07-23 Thread Anastasia Stulova via cfe-commits
Great! Thanks!


From: Hans Wennborg 
Sent: 23 July 2019 15:58
To: Anastasia Stulova 
Cc: Marco Antognini ; Clang Commits 
; nd 
Subject: Re: r366694 - [NFC] Relaxed regression tests for PR42665

Merged them both in r366814.

Thanks,
Hans

On Tue, Jul 23, 2019 at 7:20 AM Anastasia Stulova
 wrote:
>
>
> + cfe-commits
>
> 
> From: Anastasia Stulova
> Sent: 23 July 2019 15:16
> To: Hans Wennborg 
> Cc: Marco Antognini 
> Subject: Re: r366694 - [NFC] Relaxed regression tests for PR42665
>
>
> @Hans, would it be possible to merge this commit along with r366670 to the 
> release 9.0?
>
>
> FY, I have also added this to the blocker bug: 
> https://bugs.llvm.org/show_bug.cgi?id=41727
>
> Thanks!
> Anastasia
> 
> From: cfe-commits  on behalf of Marco 
> Antognini via cfe-commits 
> Sent: 22 July 2019 15:47
> To: cfe-commits@lists.llvm.org 
> Subject: r366694 - [NFC] Relaxed regression tests for PR42665
>
> Author: mantognini
> Date: Mon Jul 22 07:47:36 2019
> New Revision: 366694
>
> URL: http://llvm.org/viewvc/llvm-project?rev=366694&view=rev
> Log:
> [NFC] Relaxed regression tests for PR42665
>
> Following up on the buildbot failures, this commits relaxes some tests:
> instead of checking for specific IR output, it now ensures that the
> underlying issue (the crash), and only that, doesn't happen.
>
> Modified:
> cfe/trunk/test/CodeGenCXX/PR42665.cpp
>
> Modified: cfe/trunk/test/CodeGenCXX/PR42665.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/PR42665.cpp?rev=366694&r1=366693&r2=366694&view=diff
> ==
> --- cfe/trunk/test/CodeGenCXX/PR42665.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/PR42665.cpp Mon Jul 22 07:47:36 2019
> @@ -1,7 +1,8 @@
> -// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -std=c++17 -O0 %s 
> -o - | FileCheck %s
> -// RUN: %clang_cc1 -triple %ms_abi_triple -emit-llvm -std=c++17 -O0 %s -o - 
> | FileCheck %s
> +// RUN: %clang_cc1 -std=c++17 -O0 %s -emit-llvm -o /dev/null -verify -triple 
> %itanium_abi_triple
> +// RUN: %clang_cc1 -std=c++17 -O0 %s -emit-llvm -o /dev/null -verify -triple 
> %ms_abi_triple
>
>  // Minimal reproducer for PR42665.
> +// expected-no-diagnostics
>
>  struct Foo {
>Foo() = default;
> @@ -31,31 +32,3 @@ void foobar() {
>d(f); // Invoke virtual destructor of Foo through d.
>  } // p's destructor is invoked.
>
> -// Regexes are used to handle both kind of mangling.
> -//
> -// CHECK-LABEL: define linkonce_odr{{( dso_local)?}} void 
> @{{.*deleter.*Foo.*}}(%struct.Foo* dereferenceable({{[0-9]+}})
> -// CHECK-SAME: [[T:%.*]])
> -// CHECK: [[T_ADDR:%.*]] = alloca %struct.Foo*
> -// CHECK: store %struct.Foo* [[T]], %struct.Foo** [[T_ADDR]]
> -// CHECK: [[R0:%.*]] = load %struct.Foo*, %struct.Foo** [[T_ADDR]]
> -// CHECK: [[R1:%.*]] = bitcast %struct.Foo* [[R0]] to 
> [[TYPE:.*struct\.Foo.*]]***
> -// CHECK: [[VTABLE:%.*]] = load [[TYPE]]**, [[TYPE]]*** [[R1]]
> -// CHECK: [[VFUN:%.*]] = getelementptr inbounds [[TYPE]]*, [[TYPE]]** 
> [[VTABLE]], i64 0
> -// CHECK: [[DTOR:%.*]] = load [[TYPE]]*, [[TYPE]]** [[VFUN]]
> -// CHECK: call {{(void|i8\*)}} [[DTOR]](%struct.Foo* [[R0]]
> -//
> -// CHECK-LABEL: define{{( dso_local)?}} void @{{.*foobar.*}}()
> -// CHECK: [[P:%.*]] = alloca %struct.Pair
> -// CHECK: [[F:%.*]] = alloca %struct.Foo*
> -// CHECK: [[D:%.*]] = alloca [[TYPE:void \(%struct.Foo\*\)]]**
> -// CHECK: call void @{{.*make_pair.*}}(%struct.Pair* sret [[P]])
> -// CHECK: [[FIRST:%.*]] = getelementptr inbounds %struct.Pair, %struct.Pair* 
> [[P]], i32 0, i32 0
> -// CHECK: store %struct.Foo* [[FIRST]], %struct.Foo** [[F]]
> -// CHECK: [[SECOND:%.*]] = getelementptr inbounds %struct.Pair, 
> %struct.Pair* [[P]], i32 0, i32 1
> -// CHECK: store void (%struct.Foo*)** [[SECOND]], [[TYPE]]*** [[D]]
> -// CHECK: [[R0:%.*]] = load [[TYPE]]**, [[TYPE]]*** [[D]]
> -// CHECK: [[R1:%.*]] = load [[TYPE]]*, [[TYPE]]** [[R0]]
> -// CHECK: [[R2:%.*]] = load %struct.Foo*, %struct.Foo** [[F]]
> -// CHECK: call void [[R1]](%struct.Foo* dereferenceable({{[0-9]+}}) [[R2]])
> -// CHECK: call void @{{.*Pair.*Foo.*}}(%struct.Pair* [[P]])
> -
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D65102: [OpenCL] Rename lang mode flag for C++ mode

2019-07-23 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 211320.
Anastasia added a comment.

Use -cl-std=CLC++ spelling for test/CodeGenOpenCLCXX/addrspace-with-class.cl


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

https://reviews.llvm.org/D65102

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/LangStandards.def
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCXX/mangle-address-space.cpp
  test/CodeGenOpenCL/builtins.cl
  test/CodeGenOpenCL/images.cl
  test/CodeGenOpenCL/logical-ops.cl
  test/CodeGenOpenCL/pipe_builtin.cl
  test/CodeGenOpenCL/sampler.cl
  test/CodeGenOpenCL/spir_version.cl
  test/CodeGenOpenCL/to_addr_builtin.cl
  test/CodeGenOpenCLCXX/address-space-castoperators.cpp
  test/CodeGenOpenCLCXX/address-space-deduction.cl
  test/CodeGenOpenCLCXX/address-space-deduction2.cl
  test/CodeGenOpenCLCXX/addrspace-conversion.cl
  test/CodeGenOpenCLCXX/addrspace-derived-base.cl
  test/CodeGenOpenCLCXX/addrspace-of-this.cl
  test/CodeGenOpenCLCXX/addrspace-operators.cl
  test/CodeGenOpenCLCXX/addrspace-references.cl
  test/CodeGenOpenCLCXX/addrspace-with-class.cl
  test/CodeGenOpenCLCXX/atexit.cl
  test/CodeGenOpenCLCXX/global_init.cl
  test/CodeGenOpenCLCXX/local_addrspace_init.cl
  test/CodeGenOpenCLCXX/method-overload-address-space.cl
  test/CodeGenOpenCLCXX/template-address-spaces.cl
  test/Driver/autocomplete.c
  test/Driver/opencl.cl
  test/Frontend/opencl.cl
  test/Frontend/stdlang.c
  test/Headers/opencl-c-header.cl
  test/Parser/opencl-cxx-keywords.cl
  test/Parser/opencl-cxx-virtual.cl
  test/Preprocessor/predefined-macros.c
  test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  test/SemaOpenCL/address-spaces.cl
  test/SemaOpenCL/builtin.cl
  test/SemaOpenCL/clk_event_t.cl
  test/SemaOpenCL/extension-version.cl
  test/SemaOpenCL/extensions.cl
  test/SemaOpenCL/invalid-image.cl
  test/SemaOpenCL/invalid-pipes-cl2.0.cl
  test/SemaOpenCLCXX/address-space-deduction.cl
  test/SemaOpenCLCXX/address-space-of-this-class-scope.cl
  test/SemaOpenCLCXX/address-space-of-this.cl
  test/SemaOpenCLCXX/address-space-references.cl
  test/SemaOpenCLCXX/address-space-templates.cl
  test/SemaOpenCLCXX/address_space_overloading.cl
  test/SemaOpenCLCXX/kernel_invalid.cl
  test/SemaOpenCLCXX/method-overload-address-space.cl
  test/SemaOpenCLCXX/newdelete.cl
  test/SemaOpenCLCXX/restricted.cl

Index: test/SemaOpenCLCXX/restricted.cl
===
--- test/SemaOpenCLCXX/restricted.cl
+++ test/SemaOpenCLCXX/restricted.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -pedantic -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=clc++ -pedantic -verify -fsyntax-only
 
 // This test checks that various C/C++/OpenCL C constructs are not available in
 // C++ for OpenCL.
Index: test/SemaOpenCLCXX/newdelete.cl
===
--- test/SemaOpenCLCXX/newdelete.cl
+++ test/SemaOpenCLCXX/newdelete.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -pedantic -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=clc++ -pedantic -verify -fsyntax-only
 
 class A {
   public:
Index: test/SemaOpenCLCXX/method-overload-address-space.cl
===
--- test/SemaOpenCLCXX/method-overload-address-space.cl
+++ test/SemaOpenCLCXX/method-overload-address-space.cl
@@ -1,4 +1,4 @@
-//RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -pedantic -verify
+//RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=clc++ -pedantic -verify
 
 struct C {
   void m1() __local __local; //expected-warning{{multiple identical address spaces specified for type}}
Index: test/SemaOpenCLCXX/kernel_invalid.cl
===
--- test/SemaOpenCLCXX/kernel_invalid.cl
+++ test/SemaOpenCLCXX/kernel_invalid.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -cl-std=c++ -pedantic -verify -fsyntax-only
+// RUN: %clang_cc1 %s -cl-std=clc++ -pedantic -verify -fsyntax-only
 
 struct C {
   kernel void m(); //expected-error{{kernel functions cannot be class members}}
Index: test/SemaOpenCLCXX/address_space_overloading.cl
===
--- test/SemaOpenCLCXX/address_space_overloading.cl
+++ test/SemaOpenCLCXX/address_space_overloading.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=c++
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++
 // expected-no-diagnostics
 
 struct RetGlob {
Index: test/SemaOpenCLCXX/address-space-templates.cl
===
--- test/SemaOpenCLCXX/address-space-templates.cl
+++ test/SemaOpenCLCXX/address-space-templates.cl
@@ -1,4 +1,4 @@
-//RUN: %clang_cc1 %s -cl-std=c++ -pedantic -verify -fsyntax-only
+//RUN: %clang_cc1 %s -cl-std=

[PATCH] D65102: [OpenCL] Rename lang mode flag for C++ mode

2019-07-23 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D65102#1597651 , @kpet wrote:

> Hmm, maybe we need to make sure that one of the tests is using a C++ feature 
> and building with `CLC++`. This would have caught the mistake.


That's right! The only test we had wasn't using any C++ features in it. :)


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

https://reviews.llvm.org/D65102



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


r366823 - [clang][NFCI] Fix random typos

2019-07-23 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Tue Jul 23 09:54:11 2019
New Revision: 366823

URL: http://llvm.org/viewvc/llvm-project?rev=366823&view=rev
Log:
[clang][NFCI] Fix random typos

Modified:
cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
cfe/trunk/lib/Index/IndexSymbol.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h?rev=366823&r1=366822&r2=366823&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h Tue Jul 23 
09:54:11 2019
@@ -1315,7 +1315,7 @@ class ForEachMatcher : public WrapperMat
 ///
 /// Input matchers can have any type (including other polymorphic matcher
 /// types), and the actual Matcher is generated on demand with an implicit
-/// coversion operator.
+/// conversion operator.
 template  class VariadicOperatorMatcher {
 public:
   VariadicOperatorMatcher(DynTypedMatcher::VariadicOperator Op, Ps &&... 
Params)

Modified: cfe/trunk/lib/Index/IndexSymbol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=366823&r1=366822&r2=366823&view=diff
==
--- cfe/trunk/lib/Index/IndexSymbol.cpp (original)
+++ cfe/trunk/lib/Index/IndexSymbol.cpp Tue Jul 23 09:54:11 2019
@@ -513,7 +513,7 @@ StringRef index::getSymbolKindString(Sym
   case SymbolKind::StaticProperty: return "static-property";
   case SymbolKind::Constructor: return "constructor";
   case SymbolKind::Destructor: return "destructor";
-  case SymbolKind::ConversionFunction: return "coversion-func";
+  case SymbolKind::ConversionFunction: return "conversion-func";
   case SymbolKind::Parameter: return "param";
   case SymbolKind::Using: return "using";
   }

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=366823&r1=366822&r2=366823&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Jul 23 09:54:11 2019
@@ -7173,7 +7173,7 @@ ExprResult Sema::BuildCXXMemberCallExpr(
 
   if (Method->getParent()->isLambda() &&
   Method->getConversionType()->isBlockPointerType()) {
-// This is a lambda coversion to block pointer; check if the argument
+// This is a lambda conversion to block pointer; check if the argument
 // was a LambdaExpr.
 Expr *SubE = E;
 CastExpr *CE = dyn_cast(SubE);


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


[PATCH] D64644: Fixes an assertion failure while instantiation a template with an incomplete typo corrected type

2019-07-23 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added reviewers: aaron.ballman, erichkeane.
lebedev.ri added a comment.

Test looks good, adding a few more potential reviewers..


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

https://reviews.llvm.org/D64644



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


[PATCH] D64838: [Attr] Support _attribute__ ((fallthrough))

2019-07-23 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry added a comment.

In D64838#1593516 , @aaron.ballman 
wrote:

> In D64838#1592520 , 
> @Nathan-Huckleberry wrote:
>
> >   void foo() {
> > __attribute__((address_space(0))) *x;
> > *y;
> >   }
> >
> >
> > If the attributes are parsed then function body looks like this to the 
> > parser:
> >
> >   {
> > *x; //this one has attributes now
> > *y;
> >   {
> >
> >
> > The first line should be a valid declaration and the second like should be 
> > a dereference of an uninitialized variable. If the attributes token is 
> > discarded before parsing the rest of the line the only way to differentiate 
> > these is by looking at the attributes added to them.
> >
> > An alternative may be parse the attributes list and immediately try to 
> > parse as a declaration then if that parsing fails attempt to parse as 
> > something else. Although this approach also has the scary implication of 
> > things that are supposed to be declarations getting reparsed as something 
> > entirely different.
>
>
> The issue is that a leading GNU-style attribute is not sufficient information 
> to determine whether we're parsing a declaration or a statement; it shouldn't 
> always be treated as a decl-specifier. I spoke with a GCC dev about how they 
> handle this, and effectively, they parse the attributes first then attempt to 
> parse a declaration; if that fails, they fall back to parsing a statement. I 
> think the way forward for us that should be similar is to parse the 
> attributes first and then wait until we see a decl-specifier before 
> determining whether we want to parse a declaration or a statement, and attach 
> the attributes after we've figured out which production we have. @rsmith may 
> have even better approaches in mind, but we're definitely agreed that we 
> should not parse statement/decl based on attribute identity. I would hope we 
> could find a way to avoid lots of re-parsing work if we can (even to the 
> point of perhaps breaking the `address_space` case because implicit int is 
> pretty horrible to rely on in the first place; it depends on whether breaking 
> that will break a lot of code or not).


@xbolva00's patch https://reviews.llvm.org/D63260?id=204583 essentially does 
that already. I'm not sure how to continue on this patch, several solutions 
have been suggested, but I'm not sure which to implement.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64838



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


[PATCH] D64666: [Sema] Enable -Wimplicit-float-conversion for integral to floating point precision loss

2019-07-23 Thread Ziang Wan via Phabricator via cfe-commits
ziangwan added a comment.

In D64666#1597627 , @jfb wrote:

> In D64666#1597193 , @aaron.ballman 
> wrote:
>
> > In D64666#1596660 , @xbolva00 
> > wrote:
> >
> > > I think we should warn in that case even if GCC does not warn.
> >
> >
> > Strong +1.
>
>
> Sorry if the phrasing was misleading: if we know for a fact that there's a 
> problem, we should warn unconditionally. If we don't know for a fact then the 
> warning should *not* be enabled by `-Wall` nor `-Wextra`. I don't really care 
> what GCC does by default, LLVM doesn't have to match every single thing. That 
> being said, if LLVM behaves differently then maybe the flag name should be 
> different.
>
> > In D64666#1596853 , @ziangwan 
> > wrote:
> > 
> >> Final review ping.
> > 
> > 
> > Please be sure to give reviewers enough time to respond to comments before 
> > pinging a review.
>
> Indeed. You haven't answered my first comment, I'd expect you to do so and 
> not "final ping" anything. I'm not saying you must do what I say, just that 
> you must answer comments, not ignore them.


Sorry to miss out your first comment, but I did answer it under @xbolva00's 
comment. I will make sure I put my response under the original one next time.

In D64666#1596655 , @ziangwan wrote:

> In D64666#1596512 , @xbolva00 wrote:
>
> > @jfb’s comment is not addressed yet.
> >
> > In D64666#1583629 , @jfb wrote:
> >
> > > I think you want to default-ignore the "may lose precision" warnings, but 
> > > not the ones that you know always lose precision.
> >
>
>
> In GCC, the int type -> float type conversion warning is disabled by default. 
> When the user uses `-Wconversion` or `-Wimplicit-float-conversion`, both 
> "definitely lose" warning and "may lose" warning are issued. The current 
> patch works the same way as GCC.


I think we definitely should issue the warning that says "may lose" precision. 
The reason is that a "may lose" warning encourages developers to examine their 
code and definitely helps them capture potential precision loss bugs. Also, in 
most case, we won't be able to know the exact value of the integer type, e.g. 
variables. If the developers are certain they are going to do an int->float 
conversion, they can always write explicit conversion, and the "may lose" 
warnings will go away.


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

https://reviews.llvm.org/D64666



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


[PATCH] D64883: Add new warning -Walloca for use of builtin alloca function

2019-07-23 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:2776
+def warn_alloca : Warning<
+  "use of builtin function %0">,
+  InGroup>, DefaultIgnore;

aaron.ballman wrote:
> george.burgess.iv wrote:
> > aaron.ballman wrote:
> > > george.burgess.iv wrote:
> > > > aaron.ballman wrote:
> > > > > george.burgess.iv wrote:
> > > > > > nit: I'd just say "use of function '%0'" here; "builtin" doesn't 
> > > > > > really add much.
> > > > > > 
> > > > > > I also wonder if we should be saying anything more than "we found a 
> > > > > > use of this function." Looks like GCC doesn't 
> > > > > > (https://godbolt.org/z/sYs_8G), but since this warning is sort of 
> > > > > > opinionated in itself, might it be better to expand this to "use of 
> > > > > > '%0' is discouraged"?
> > > > > > 
> > > > > > WDYT, Aaron?
> > > > > What is the purpose to this diagnostic, aside from GCC compatibility? 
> > > > > What does it protect against?
> > > > > 
> > > > > If there's a reason users should not use alloc(), it would be better 
> > > > > for the diagnostic to spell it out.
> > > > > 
> > > > > Btw, I'm okay with this being default-off because the GCC warning is 
> > > > > as well. I'm mostly hoping we can do better with our diagnostic 
> > > > > wording.
> > > > > I'm mostly hoping we can do better with our diagnostic wording
> > > > 
> > > > +1
> > > > 
> > > > > What is the purpose to this diagnostic?
> > > > 
> > > > I think the intent boils down to that `alloca` is easily misused, and 
> > > > leads to e.g., 
> > > > https://www.qualys.com/2017/06/19/stack-clash/stack-clash.txt . Since 
> > > > its use often boils down to nothing but a tiny micro-optimization, some 
> > > > parties would like to discourage its use.
> > > > 
> > > > Both glibc and bionic recommend against the use of `alloca` in their 
> > > > documentation, though glibc's docs are less assertive than bionic's, 
> > > > and explicitly call out "[alloca's] use can improve efficiency compared 
> > > > to the use of malloc plus free."
> > > > 
> > > > Greping a codebase and investigating the first 15 results:
> > > > - all of them look like microoptimizations; many of them also sit close 
> > > > to other `malloc`/`new` ops, so allocating on these paths presumably 
> > > > isn't prohibitively expensive
> > > > - all but two of the uses of `alloca` have no logic to fall back to the 
> > > > heap `malloc` if the array they want to allocate passes a certain 
> > > > threshold. Some of the uses make it look *really* easy for the array to 
> > > > grow very large.
> > > > - one of the uses compares the result of `alloca` to `NULL`. Since 
> > > > `alloca`'s behavior is undefined if it fails, ...
> > > > 
> > > > I'm having trouble putting this into a concise and actionable 
> > > > diagnostic message, though. The best I can come up with at the moment 
> > > > is something along the lines of "use of function %0 is subtle; consider 
> > > > using heap allocation instead."
> > > Okay, that's along the lines of what I was thinking.
> > > 
> > > Part of me thinks that this should not diagnose calls to `alloca()` that 
> > > are given a constant value that we can test for sanity at compile time. 
> > > e.g., calling `alloca(10)` is highly unlikely to be a problem, but 
> > > calling `alloca(100)` certainly could be, while `alloca(x)` is a 
> > > different class of problem without good static analysis.
> > > 
> > > That said, perhaps we could get away with `use of function %0 is 
> > > discouraged; there is no way to check for failure but failure may still 
> > > occur, resulting in a possibly exploitable security vulnerability` or 
> > > something along those lines?
> > Yeah, GCC has a similar `-Walloca-larger-than=N` that does roughly what you 
> > described. The icky part is exactly what you said. GCC will warn about 
> > unknown values, but considers control flow when doing so: 
> > https://godbolt.org/z/J3pGiT
> > 
> > It looks like it's the same "we apply optimizations and then see what 
> > happens" behavior as similar diagnostics: https://godbolt.org/z/lLyteP
> > 
> > WRT the diag we emit here, maybe we could use notes to break it up and 
> > imply things? e.g.
> > 
> > warning: use of function %0 is discouraged, due to its security implications
> > note: 'malloc' or 'new' are suggested alternatives, since they have 
> > well-defined behavior on failure
> > 
> > ...not sold on the idea, but it's a thought.
> > 
> > If we don't want to break it to pieces, I'm fine with your suggestion
> I'm not certain the note adds value because it will always be printed on the 
> same line as the warning. A note would make sense if we had a secondary 
> location to annotate though.
SGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D64883



___
cfe-commits mailing list
cfe-commits@l

r366828 - Improve clang-format-diff help output

2019-07-23 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Jul 23 10:34:18 2019
New Revision: 366828

URL: http://llvm.org/viewvc/llvm-project?rev=366828&view=rev
Log:
Improve clang-format-diff help output

The description in clang-format-diff.py is more useful than the one
in `clang-format-diff -h`, so use the same description in both places.

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

Modified:
cfe/trunk/tools/clang-format/clang-format-diff.py

Modified: cfe/trunk/tools/clang-format/clang-format-diff.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format-diff.py?rev=366828&r1=366827&r2=366828&view=diff
==
--- cfe/trunk/tools/clang-format/clang-format-diff.py (original)
+++ cfe/trunk/tools/clang-format/clang-format-diff.py Tue Jul 23 10:34:18 2019
@@ -8,10 +8,7 @@
 #
 
#======#
 
-r"""
-ClangFormat Diff Reformatter
-
-
+"""
 This script reads input from a unified diff and reformats all the changed
 lines. This is useful to reformat all the lines touched by a specific patch.
 Example usage for git/svn users:
@@ -35,10 +32,9 @@ else:
 
 
 def main():
-  parser = argparse.ArgumentParser(description=
-   'Reformat changed lines in diff. Without -i 
'
-   'option just output the diff that would be '
-   'introduced.')
+  parser = argparse.ArgumentParser(description=__doc__,
+   formatter_class=
+   
argparse.RawDescriptionHelpFormatter)
   parser.add_argument('-i', action='store_true', default=False,
   help='apply edits to files instead of displaying a diff')
   parser.add_argument('-p', metavar='NUM', default=0,


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


[PATCH] D64998: Improve clang-format-diff help output

2019-07-23 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366828: Improve clang-format-diff help output (authored by 
nico, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64998?vs=210837&id=211331#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64998

Files:
  cfe/trunk/tools/clang-format/clang-format-diff.py


Index: cfe/trunk/tools/clang-format/clang-format-diff.py
===
--- cfe/trunk/tools/clang-format/clang-format-diff.py
+++ cfe/trunk/tools/clang-format/clang-format-diff.py
@@ -8,10 +8,7 @@
 #
 
#======#
 
-r"""
-ClangFormat Diff Reformatter
-
-
+"""
 This script reads input from a unified diff and reformats all the changed
 lines. This is useful to reformat all the lines touched by a specific patch.
 Example usage for git/svn users:
@@ -35,10 +32,9 @@
 
 
 def main():
-  parser = argparse.ArgumentParser(description=
-   'Reformat changed lines in diff. Without -i 
'
-   'option just output the diff that would be '
-   'introduced.')
+  parser = argparse.ArgumentParser(description=__doc__,
+   formatter_class=
+   
argparse.RawDescriptionHelpFormatter)
   parser.add_argument('-i', action='store_true', default=False,
   help='apply edits to files instead of displaying a diff')
   parser.add_argument('-p', metavar='NUM', default=0,


Index: cfe/trunk/tools/clang-format/clang-format-diff.py
===
--- cfe/trunk/tools/clang-format/clang-format-diff.py
+++ cfe/trunk/tools/clang-format/clang-format-diff.py
@@ -8,10 +8,7 @@
 #
 #======#
 
-r"""
-ClangFormat Diff Reformatter
-
-
+"""
 This script reads input from a unified diff and reformats all the changed
 lines. This is useful to reformat all the lines touched by a specific patch.
 Example usage for git/svn users:
@@ -35,10 +32,9 @@
 
 
 def main():
-  parser = argparse.ArgumentParser(description=
-   'Reformat changed lines in diff. Without -i '
-   'option just output the diff that would be '
-   'introduced.')
+  parser = argparse.ArgumentParser(description=__doc__,
+   formatter_class=
+   argparse.RawDescriptionHelpFormatter)
   parser.add_argument('-i', action='store_true', default=False,
   help='apply edits to files instead of displaying a diff')
   parser.add_argument('-p', metavar='NUM', default=0,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D65043: [Format] Add C++20 standard to style options

2019-07-23 Thread Brian Gesiak via Phabricator via cfe-commits
modocache added a comment.

Friendly ping! I'm wondering, from the clang-format maintainers' point of view, 
whether a diff like this and https://reviews.llvm.org/D65044 make sense to add? 
I do think that it is useful for users to specify whether they wish to use 
C++11 or C++20 constructs, but I'm not an expert.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65043



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


[PATCH] D64666: [Sema] Enable -Wimplicit-float-conversion for integral to floating point precision loss

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



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3279
+  "implicit conversion from %2 to %3 changes value from %0 to %1">,
+  InGroup, DefaultIgnore;
+

Drop ‘DefaultIgnore‘ here


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

https://reviews.llvm.org/D64666



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


[PATCH] D59474: [OpenMP 5.0] Codegen support for user-defined mappers

2019-07-23 Thread Lingda Li via Phabricator via cfe-commits
lildmh added inline comments.



Comment at: lib/CodeGen/CGDecl.cpp:2533
+ CodeGenFunction *CGF) {
+  if (!LangOpts.OpenMP || LangOpts.OpenMPSimd ||
+  (!LangOpts.EmitAllDecls && !D->isUsed()))

ABataev wrote:
> Why do we need to emit it for simd only mode?
This code is not emitting mapper for simd only mode.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:7116-7124
+  /// Get the offset of the OMP_MAP_MEMBER_OF field.
+  static unsigned getFlagMemberOffset() {
+unsigned Offset = 0;
+for (uint64_t Remain = OMP_MAP_MEMBER_OF; !(Remain & 1);
+ Remain = Remain >> 1)
+  Offset++;
+return Offset;

ABataev wrote:
> Maybe it is better to define a constant `constexpr uint64_t 
> OMP_MEMBER_OF_RANK = 48` and then deduce `OMP_MAP_MEMBER_OF` as 
> `~((1

[PATCH] D59474: [OpenMP 5.0] Codegen support for user-defined mappers

2019-07-23 Thread Lingda Li via Phabricator via cfe-commits
lildmh updated this revision to Diff 211333.
lildmh marked 4 inline comments as done.

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

https://reviews.llvm.org/D59474

Files:
  include/clang/AST/GlobalDecl.h
  lib/AST/ASTContext.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/ModuleBuilder.cpp
  test/OpenMP/declare_mapper_codegen.cpp

Index: test/OpenMP/declare_mapper_codegen.cpp
===
--- test/OpenMP/declare_mapper_codegen.cpp
+++ test/OpenMP/declare_mapper_codegen.cpp
@@ -1,92 +1,414 @@
-///==///
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap %s
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap %s
-
-// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY0 %s
-
 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
 
 // expected-no-diagnostics
 #ifndef HEADER
 #define HEADER
 
+///==///
+// RUN: %clang_cc1 -DCK0 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix CK0 --check-prefix CK0-64 %s
+// RUN: %clang_cc1 -DCK0 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
+// RUN: %clang_cc1 -DCK0 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -femit-all-decls -disable-llvm-passes -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix CK0 --check-prefix CK0-64 %s
+// RUN: %clang_cc1 -DCK0 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix CK0 --check-prefix CK0-32 %s
+// RUN: %clang_cc1 -DCK0 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
+// RUN: %clang_cc1 -DCK0 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -femit-all-decls -disable-llvm-passes -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix CK0 --check-prefix CK0-32 %s
+
+// RUN: %clang_cc1 -DCK0 -verify -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -DCK0 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
+// RUN: %clang_cc1 -DCK0 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-

r366831 - clang-format: Fix namespace end comments for namespaces with attributes and macros.

2019-07-23 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Jul 23 10:49:45 2019
New Revision: 366831

URL: http://llvm.org/viewvc/llvm-project?rev=366831&view=rev
Log:
clang-format: Fix namespace end comments for namespaces with attributes and 
macros.

Fixes PR39247.

While here, also make C++20 `namespace A::inline B::inline C` nested
inline namespaced definitions work.

Before:
#define DEPRECATE_WOOF [[deprecated("meow")]]

namespace DEPRECATE_WOOF woof {
void f() {}
} // namespace DEPRECATE_WOOFwoof

namespace [[deprecated("meow")]] woof {
  void f() {}
} // namespace [[deprecated("meow")]]woof

namespace woof::inline bark {
  void f() {}
} // namespace woof::inlinebark

Now:
#define DEPRECATE_WOOF [[deprecated("meow")]]

namespace DEPRECATE_WOOF woof {
void f() {}
} // namespace woof

namespace [[deprecated("meow")]] woof {
void f() {}
} // namespace woof

namespace woof::inline bark {
void f() {}
} // namespace woof::inline bark

(In addition to the fixed namespace end comments, also note the correct
indent of the namespace contents.)

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

Modified:
cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp

Modified: cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp?rev=366831&r1=366830&r2=366831&view=diff
==
--- cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp (original)
+++ cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp Tue Jul 23 10:49:45 2019
@@ -36,7 +36,7 @@ std::string computeName(const FormatToke
   const FormatToken *Tok = NamespaceTok->getNextNonComment();
   if (NamespaceTok->is(TT_NamespaceMacro)) {
 // Collects all the non-comment tokens between opening parenthesis
-// and closing parenthesis or comma
+// and closing parenthesis or comma.
 assert(Tok && Tok->is(tok::l_paren) && "expected an opening parenthesis");
 Tok = Tok->getNextNonComment();
 while (Tok && !Tok->isOneOf(tok::r_paren, tok::comma)) {
@@ -44,9 +44,21 @@ std::string computeName(const FormatToke
   Tok = Tok->getNextNonComment();
 }
   } else {
-// Collects all the non-comment tokens between 'namespace' and '{'.
+// For `namespace [[foo]] A::B::inline C {` or
+// `namespace MACRO1 MACRO2 A::B::inline C {`, returns "A::B::inline C".
+// Peek for the first '::' (or '{') and then return all tokens from one
+// token before that up until the '{'.
+const FormatToken *FirstNSTok = Tok;
+while (Tok && !Tok->is(tok::l_brace) && !Tok->is(tok::coloncolon)) {
+  FirstNSTok = Tok;
+  Tok = Tok->getNextNonComment();
+}
+
+Tok = FirstNSTok;
 while (Tok && !Tok->is(tok::l_brace)) {
   name += Tok->TokenText;
+  if (Tok->is(tok::kw_inline))
+name += " ";
   Tok = Tok->getNextNonComment();
 }
   }

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=366831&r1=366830&r2=366831&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Tue Jul 23 10:49:45 2019
@@ -1873,8 +1873,13 @@ void UnwrappedLineParser::parseNamespace
   if (InitialToken.is(TT_NamespaceMacro)) {
 parseParens();
   } else {
-while (FormatTok->isOneOf(tok::identifier, tok::coloncolon))
-  nextToken();
+while (FormatTok->isOneOf(tok::identifier, tok::coloncolon, tok::kw_inline,
+  tok::l_square)) {
+  if (FormatTok->is(tok::l_square))
+parseSquare();
+  else
+nextToken();
+}
   }
   if (FormatTok->Tok.is(tok::l_brace)) {
 if (ShouldBreakBeforeBrace(Style, InitialToken))

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=366831&r1=366830&r2=366831&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Jul 23 10:49:45 2019
@@ -1782,6 +1782,21 @@ TEST_F(FormatTest, FormatsNamespaces) {
"void f() { f(); }\n"
"}",
LLVMWithNoNamespaceFix);
+  verifyFormat("namespace N::inline D {\n"
+   "class A {};\n"
+   "void f() { f(); }\n"
+   "}",
+   LLVMWithNoNamespaceFix);
+  verifyFormat("namespace N::inline D::E {\n"
+   "class A {};\n"
+   "void f() { f(); }\n"
+   "}",
+   LLVMWithNoNames

[PATCH] D65125: clang-format: Fix namespace end comments for namespaces with attributes and macros

2019-07-23 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366831: clang-format: Fix namespace end comments for 
namespaces with attributes and… (authored by nico, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D65125?vs=211228&id=211334#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D65125

Files:
  cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp
  cfe/trunk/unittests/Format/FormatTest.cpp
  cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp

Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -1873,8 +1873,13 @@
   if (InitialToken.is(TT_NamespaceMacro)) {
 parseParens();
   } else {
-while (FormatTok->isOneOf(tok::identifier, tok::coloncolon))
-  nextToken();
+while (FormatTok->isOneOf(tok::identifier, tok::coloncolon, tok::kw_inline,
+  tok::l_square)) {
+  if (FormatTok->is(tok::l_square))
+parseSquare();
+  else
+nextToken();
+}
   }
   if (FormatTok->Tok.is(tok::l_brace)) {
 if (ShouldBreakBeforeBrace(Style, InitialToken))
Index: cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
===
--- cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
+++ cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
@@ -36,7 +36,7 @@
   const FormatToken *Tok = NamespaceTok->getNextNonComment();
   if (NamespaceTok->is(TT_NamespaceMacro)) {
 // Collects all the non-comment tokens between opening parenthesis
-// and closing parenthesis or comma
+// and closing parenthesis or comma.
 assert(Tok && Tok->is(tok::l_paren) && "expected an opening parenthesis");
 Tok = Tok->getNextNonComment();
 while (Tok && !Tok->isOneOf(tok::r_paren, tok::comma)) {
@@ -44,9 +44,21 @@
   Tok = Tok->getNextNonComment();
 }
   } else {
-// Collects all the non-comment tokens between 'namespace' and '{'.
+// For `namespace [[foo]] A::B::inline C {` or
+// `namespace MACRO1 MACRO2 A::B::inline C {`, returns "A::B::inline C".
+// Peek for the first '::' (or '{') and then return all tokens from one
+// token before that up until the '{'.
+const FormatToken *FirstNSTok = Tok;
+while (Tok && !Tok->is(tok::l_brace) && !Tok->is(tok::coloncolon)) {
+  FirstNSTok = Tok;
+  Tok = Tok->getNextNonComment();
+}
+
+Tok = FirstNSTok;
 while (Tok && !Tok->is(tok::l_brace)) {
   name += Tok->TokenText;
+  if (Tok->is(tok::kw_inline))
+name += " ";
   Tok = Tok->getNextNonComment();
 }
   }
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -1782,6 +1782,21 @@
"void f() { f(); }\n"
"}",
LLVMWithNoNamespaceFix);
+  verifyFormat("namespace N::inline D {\n"
+   "class A {};\n"
+   "void f() { f(); }\n"
+   "}",
+   LLVMWithNoNamespaceFix);
+  verifyFormat("namespace N::inline D::E {\n"
+   "class A {};\n"
+   "void f() { f(); }\n"
+   "}",
+   LLVMWithNoNamespaceFix);
+  verifyFormat("namespace [[deprecated(\"foo[bar\")]] some_namespace {\n"
+   "class A {};\n"
+   "void f() { f(); }\n"
+   "}",
+   LLVMWithNoNamespaceFix);
   verifyFormat("/* something */ namespace some_namespace {\n"
"class A {};\n"
"void f() { f(); }\n"
Index: cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp
===
--- cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -77,6 +77,44 @@
 "int i;\n"
 "int j;\n"
 "}"));
+
+  EXPECT_EQ("namespace [[deprecated(\"foo\")]] A::B {\n"
+"int i;\n"
+"int j;\n"
+"}// namespace A::B",
+fixNamespaceEndComments("namespace [[deprecated(\"foo\")]] A::B {\n"
+"int i;\n"
+"int j;\n"
+"}"));
+
+  EXPECT_EQ("namespace [[deprecated(\"foo\")]] A::inline B::inline C {\n"
+"int i;\n"
+"int j;\n"
+"}// namespace A::inline B::inline C",
+fixNamespaceEndComments(
+"namesp

[PATCH] D64793: [Driver] Properly use values-X[ca].o, values-xpg[46].o on Solaris

2019-07-23 Thread Rainer Orth via Phabricator via cfe-commits
ro marked an inline comment as done.
ro added a comment.

In D64793#1597550 , @jyknight wrote:

> Is this really necessary? Users don't typically pass -std= to the driver for 
> linking anyways (what do you even pass if you've compiled both C and C++ 
> code?) so this seems a rather odd way to control behavior.


I fear it is necessary: at least it matches documented behaviour of both the 
Sun/Oracle Studio compilers and gcc.

The -std= options usually get passed to the linking step because CFLAGS is 
added to the options as well.  In the mixed-language case, you have to link
with the C++ compiler, and the !isGNUMode test deals with both languages alike.

> How about instead just adding "values-xpg6.o" unconditionally, alongside the 
> current unconditional "values-Xa.o", and just forget about the xpg4 and Xc 
> modes?

If all else fails, that would have to be the last fallback.  I'd rather do 
things correctly, though.




Comment at: lib/Driver/ToolChains/Solaris.cpp:16
 #include "clang/Driver/Options.h"
+#include "clang/Frontend/LangStandard.h"
 #include "llvm/Option/ArgList.h"

jyknight wrote:
> I'm not sure that's an acceptable dependency -- I think Driver probably is 
> not supposed to depend on Frontend. If so, I guess LangStandard should move 
> to clang/Basic/. Which also means moving InputKind from 
> clang/include/clang/Frontend/FrontendOptions.h.
> 
> (Maybe someone else can weigh in on this question?)
I wondered about this myself, including frontend code in the
driver might be considered a layering violation.  I certainly need
guidance here what is and isn't acceptable here.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64793



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


[PATCH] D64838: [Attr] Support _attribute__ ((fallthrough))

2019-07-23 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

>>   they parse the attributes first then attempt to parse a declaration; if 
>> that fails, they fall back to parsing a statement

Well, I don’t think this reparsing is ideal in terms of compile time either.

If we really care about attributes on implicit ints: I don’t think that parsing 
according to attribute name is so bad solution - if only “possible” issue is 
same attr. name for stmt and decl for some future attribute - let’s talk with 
GCC devs and make a deal about it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64838



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


[PATCH] D59474: [OpenMP 5.0] Codegen support for user-defined mappers

2019-07-23 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGDecl.cpp:2533
+ CodeGenFunction *CGF) {
+  if (!LangOpts.OpenMP || LangOpts.OpenMPSimd ||
+  (!LangOpts.EmitAllDecls && !D->isUsed()))

lildmh wrote:
> ABataev wrote:
> > Why do we need to emit it for simd only mode?
> This code is not emitting mapper for simd only mode.
Ah, yes, it is the condition for the early exit.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:7116-7124
+  /// Get the offset of the OMP_MAP_MEMBER_OF field.
+  static unsigned getFlagMemberOffset() {
+unsigned Offset = 0;
+for (uint64_t Remain = OMP_MAP_MEMBER_OF; !(Remain & 1);
+ Remain = Remain >> 1)
+  Offset++;
+return Offset;

lildmh wrote:
> ABataev wrote:
> > Maybe it is better to define a constant `constexpr uint64_t 
> > OMP_MEMBER_OF_RANK = 48` and then deduce `OMP_MAP_MEMBER_OF` as 
> > `~((1< In libomptarget, the same way is used to define `OMP_TGT_MAPTYPE_MEMBER_OF`: 
> `OMP_TGT_MAPTYPE_MEMBER_OF   = 0x`. So I think they 
> should stay the same. Btw, the number 48 is directly used in libomptarget 
> now, which may need to change in the future.
> 
> In your code, it assumes bits higher than 48 are all `OMP_MAP_MEMBER_OF`, 
> which may not be true in the future. My code here is more universal, although 
> it does not look great. What do you think?
You can apply a mask to drop some of the most significant bits if required. My 
code looks much cleaner it would be good to have the same code in libomptarget 
too.
But it is up to you what to do here.




Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:8116
+MapFlagsArrayTy &Types) const {
+// FIXME: MSVC 2013 seems to require this-> to find member CurDir.
+assert(this->CurDir.is() &&

ABataev wrote:
> AFAIK, LLVM has dropped support for msvc 2013, do we still need this?
Ping.



Comment at: lib/CodeGen/CGOpenMPRuntime.h:810-815
+  virtual void emitUserDefinedMapper(const OMPDeclareMapperDecl *D,
+ CodeGenFunction *CGF = nullptr);
+
+  /// Emit the array initialization or deletion portion for user-defined mapper
+  /// code generation.
+  virtual void emitUDMapperArrayInitOrDel(

I don't think we need virtual functions here, non-virtual are good enough.



Comment at: lib/CodeGen/CGOpenMPRuntime.h:2110
+  /// Emit code for the user defined mapper construct.
+  void emitUserDefinedMapper(const OMPDeclareMapperDecl *D,
+ CodeGenFunction *CGF = nullptr) override;

I think you can drop this function here if the original function is not virtual


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

https://reviews.llvm.org/D59474



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


[PATCH] D64696: Adds a warning when an inline Doxygen comment has no argument

2019-07-23 Thread Mark de Wever via Phabricator via cfe-commits
Mordante marked 2 inline comments as done.
Mordante added a comment.

All inline commands defined in include/clang/AST/CommentCommands.td require an 
argument. The escape commands, like \&, are handled in the switch starting at 
lib/AST/CommentLexer.cpp:366. They are stored as Text and not as an 
InlineCommand.

If you want I can add an extra field in the Command class in 
include/clang/AST/CommentCommands.td. Something like `bit 
IsEmptyInlineCommandAllowed = 0;`.


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

https://reviews.llvm.org/D64696



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


[PATCH] D64696: Adds a warning when an inline Doxygen comment has no argument

2019-07-23 Thread Mark de Wever via Phabricator via cfe-commits
Mordante updated this revision to Diff 211340.
Mordante added a comment.

Addresses @gribozavr comments.


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

https://reviews.llvm.org/D64696

Files:
  clang/include/clang/Basic/DiagnosticCommentKinds.td
  clang/lib/AST/CommentParser.cpp
  clang/test/Sema/warn-documentation.cpp


Index: clang/test/Sema/warn-documentation.cpp
===
--- clang/test/Sema/warn-documentation.cpp
+++ clang/test/Sema/warn-documentation.cpp
@@ -1044,6 +1044,48 @@
 template 
 void test_attach38::test_attach39(int, B);
 
+// The inline comments expect a string after the command.
+// expected-warning@+1 {{'\a' command does not have an argument}}
+/// \a
+int test_inline_no_argument_a_bad(int);
+
+/// \a A
+int test_inline_no_argument_a_good(int);
+
+// expected-warning@+1 {{'@b' command does not have an argument}}
+/// @b
+int test_inline_no_argument_b_bad(int);
+
+/// @b A
+int test_inline_no_argument_b_good(int);
+
+// expected-warning@+1 {{'\c' command does not have an argument}}
+/// \c
+int test_inline_no_argument_c_bad(int);
+
+/// \c A
+int test_inline_no_argument_c_good(int);
+
+// expected-warning@+1 {{'\e' command does not have an argument}}
+/// \e
+int test_inline_no_argument_e_bad(int);
+
+/// \e A
+int test_inline_no_argument_e_good(int);
+
+// expected-warning@+1 {{'\em' command does not have an argument}}
+/// \em
+int test_inline_no_argument_em_bad(int);
+
+/// \em A
+int test_inline_no_argument_em_good(int);
+
+// expected-warning@+1 {{'\p' command does not have an argument}}
+/// \p
+int test_inline_no_argument_p_bad(int);
+
+/// \p A
+int test_inline_no_argument_p_good(int);
 
 // PR13411, reduced.  We used to crash on this.
 /**
Index: clang/lib/AST/CommentParser.cpp
===
--- clang/lib/AST/CommentParser.cpp
+++ clang/lib/AST/CommentParser.cpp
@@ -422,6 +422,12 @@
 IC = S.actOnInlineCommand(CommandTok.getLocation(),
   CommandTok.getEndLocation(),
   CommandTok.getCommandID());
+
+Diag(CommandTok.getEndLocation().getLocWithOffset(1),
+ diag::warn_doc_inline_contents_no_argument)
+<< CommandTok.is(tok::at_command)
+<< Traits.getCommandInfo(CommandTok.getCommandID())->Name
+<< SourceRange(CommandTok.getLocation(), CommandTok.getEndLocation());
   }
 
   Retokenizer.putBackLeftoverTokens();
Index: clang/include/clang/Basic/DiagnosticCommentKinds.td
===
--- clang/include/clang/Basic/DiagnosticCommentKinds.td
+++ clang/include/clang/Basic/DiagnosticCommentKinds.td
@@ -153,6 +153,12 @@
 def note_add_deprecation_attr : Note<
   "add a deprecation attribute to the declaration to silence this warning">;
 
+// inline contents commands
+
+def warn_doc_inline_contents_no_argument : Warning<
+  "'%select{\\|@}0%1' command does not have an argument">,
+  InGroup, DefaultIgnore;
+
 // verbatim block commands
 
 def warn_verbatim_block_end_without_start : Warning<


Index: clang/test/Sema/warn-documentation.cpp
===
--- clang/test/Sema/warn-documentation.cpp
+++ clang/test/Sema/warn-documentation.cpp
@@ -1044,6 +1044,48 @@
 template 
 void test_attach38::test_attach39(int, B);
 
+// The inline comments expect a string after the command.
+// expected-warning@+1 {{'\a' command does not have an argument}}
+/// \a
+int test_inline_no_argument_a_bad(int);
+
+/// \a A
+int test_inline_no_argument_a_good(int);
+
+// expected-warning@+1 {{'@b' command does not have an argument}}
+/// @b
+int test_inline_no_argument_b_bad(int);
+
+/// @b A
+int test_inline_no_argument_b_good(int);
+
+// expected-warning@+1 {{'\c' command does not have an argument}}
+/// \c
+int test_inline_no_argument_c_bad(int);
+
+/// \c A
+int test_inline_no_argument_c_good(int);
+
+// expected-warning@+1 {{'\e' command does not have an argument}}
+/// \e
+int test_inline_no_argument_e_bad(int);
+
+/// \e A
+int test_inline_no_argument_e_good(int);
+
+// expected-warning@+1 {{'\em' command does not have an argument}}
+/// \em
+int test_inline_no_argument_em_bad(int);
+
+/// \em A
+int test_inline_no_argument_em_good(int);
+
+// expected-warning@+1 {{'\p' command does not have an argument}}
+/// \p
+int test_inline_no_argument_p_bad(int);
+
+/// \p A
+int test_inline_no_argument_p_good(int);
 
 // PR13411, reduced.  We used to crash on this.
 /**
Index: clang/lib/AST/CommentParser.cpp
===
--- clang/lib/AST/CommentParser.cpp
+++ clang/lib/AST/CommentParser.cpp
@@ -422,6 +422,12 @@
 IC = S.actOnInlineCommand(CommandTok.getLocation(),
   CommandTok.getEndLocation(),
   CommandTok.getCommandID());
+
+Diag(CommandTok.getEndLocation().getLocWithOff

[PATCH] D59474: [OpenMP 5.0] Codegen support for user-defined mappers

2019-07-23 Thread Lingda Li via Phabricator via cfe-commits
lildmh marked 3 inline comments as done.
lildmh added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:7116-7124
+  /// Get the offset of the OMP_MAP_MEMBER_OF field.
+  static unsigned getFlagMemberOffset() {
+unsigned Offset = 0;
+for (uint64_t Remain = OMP_MAP_MEMBER_OF; !(Remain & 1);
+ Remain = Remain >> 1)
+  Offset++;
+return Offset;

ABataev wrote:
> lildmh wrote:
> > ABataev wrote:
> > > Maybe it is better to define a constant `constexpr uint64_t 
> > > OMP_MEMBER_OF_RANK = 48` and then deduce `OMP_MAP_MEMBER_OF` as 
> > > `~((1< > In libomptarget, the same way is used to define 
> > `OMP_TGT_MAPTYPE_MEMBER_OF`: `OMP_TGT_MAPTYPE_MEMBER_OF   = 
> > 0x`. So I think they should stay the same. Btw, the number 
> > 48 is directly used in libomptarget now, which may need to change in the 
> > future.
> > 
> > In your code, it assumes bits higher than 48 are all `OMP_MAP_MEMBER_OF`, 
> > which may not be true in the future. My code here is more universal, 
> > although it does not look great. What do you think?
> You can apply a mask to drop some of the most significant bits if required. 
> My code looks much cleaner it would be good to have the same code in 
> libomptarget too.
> But it is up to you what to do here.
> 
Maybe let's keep it this way in this patch, then we modify both places in a 
further patch?



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:8116
+MapFlagsArrayTy &Types) const {
+// FIXME: MSVC 2013 seems to require this-> to find member CurDir.
+assert(this->CurDir.is() &&

ABataev wrote:
> ABataev wrote:
> > AFAIK, LLVM has dropped support for msvc 2013, do we still need this?
> Ping.
I'm okay either way. I guess it doesn't hurt to keep it?



Comment at: lib/CodeGen/CGOpenMPRuntime.h:2110
+  /// Emit code for the user defined mapper construct.
+  void emitUserDefinedMapper(const OMPDeclareMapperDecl *D,
+ CodeGenFunction *CGF = nullptr) override;

ABataev wrote:
> I think you can drop this function here if the original function is not 
> virtual
The function for simd only mode includes a `llvm_unreachable`, so I think it's 
still needed as a virtual function above


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

https://reviews.llvm.org/D59474



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


[PATCH] D59474: [OpenMP 5.0] Codegen support for user-defined mappers

2019-07-23 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.h:2110
+  /// Emit code for the user defined mapper construct.
+  void emitUserDefinedMapper(const OMPDeclareMapperDecl *D,
+ CodeGenFunction *CGF = nullptr) override;

lildmh wrote:
> ABataev wrote:
> > I think you can drop this function here if the original function is not 
> > virtual
> The function for simd only mode includes a `llvm_unreachable`, so I think 
> it's still needed as a virtual function above
It is better to reduce number of virtual functions, if possible.


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

https://reviews.llvm.org/D59474



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


[PATCH] D65154: [clangd] Reformat use of cl::opt: use unqualified name and don't bin-pack attributes. NFC

2019-07-23 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

That LGTM, but i didn't have any bad feelings regarding the previous state. 
Since we tend to read those options in isolation and don't care about how they 
look like in general, but that might be just me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65154



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


[PATCH] D64638: [CrossTU] Fix plist macro expansion if macro in other file.

2019-07-23 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

The preprocessor is defined in `Lex`, so i guess i'm curious about a more 
precise description of what's impossible to do without `Frontend`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64638



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


[PATCH] D64914: Implement P1771

2019-07-23 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked 2 inline comments as done.
erichkeane added a comment.

Ugg... well conversion functions are an interesting bit, as well as Type{}; 
with no constructors.  It ends up being a function style cast to an 
init-list-expr, so its going to require a bit more work.  Stay tuned :)




Comment at: clang/lib/Sema/SemaDeclAttr.cpp:2835
+  D->getFunctionType()->getReturnType()->isVoidType() &&
+  !isa(D)) {
 S.Diag(AL.getLoc(), diag::warn_attribute_void_function_method) << AL << 0;

aaron.ballman wrote:
> Conversion functions?
Conversion functions don't return 'void', so the 2nd condition should do it, 
right?


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

https://reviews.llvm.org/D64914



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


[PATCH] D64914: Implement P1771

2019-07-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman marked an inline comment as done.
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:2835
+  D->getFunctionType()->getReturnType()->isVoidType() &&
+  !isa(D)) {
 S.Diag(AL.getLoc(), diag::warn_attribute_void_function_method) << AL << 0;

erichkeane wrote:
> aaron.ballman wrote:
> > Conversion functions?
> Conversion functions don't return 'void', so the 2nd condition should do it, 
> right?
true -- we already seem to diagnose a conversion function that returns void 
anyway. Sorry for the noise!


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

https://reviews.llvm.org/D64914



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


[PATCH] D64744: #pragma clang loop vectorize_predicate(enable|disable)

2019-07-23 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

Apologies for the early ping! Bu I'm off next weeks, so it would be nice to get 
this in before that if there are no further comments.
Tomorrow, I will upload another diff that builds on top D64916 
, which enables code-generation with tail 
loops folded, thus also demonstrating an end to end test.


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

https://reviews.llvm.org/D64744



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


[PATCH] D64539: [clang-doc] Add stylesheet to generated html docs

2019-07-23 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett accepted this revision.
juliehockett added a comment.

LGTM


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

https://reviews.llvm.org/D64539



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


[PATCH] D64938: [clang-doc] Add option for user provided stylesheets

2019-07-23 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added inline comments.



Comment at: clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp:26
+  ClangDocContext CDCtx;
+  CDCtx.UserStylesheets = {"../share/clang/clang-doc-default-stylesheet.css"};
+  return CDCtx;

Can you write a test for the output of more than one stylesheet?


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

https://reviews.llvm.org/D64938



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


[PATCH] D65107: [clang-doc] Fix html entities in rendered text

2019-07-23 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett accepted this revision.
juliehockett added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D65107



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


[PATCH] D64454: [clang-tidy] Adding static analyzer check to list of clang-tidy checks

2019-07-23 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry added a comment.

In D64454#1587102 , @aaron.ballman 
wrote:

> I think this looks reasonable to me, though I am still not certain if the 
> relative path in the python script will work with both the svn in-tree 
> directory layout as well as the git monorepo layout (which I'm far less 
> familiar with).


This works in the git monorepo layout as that's what I'm using. Not sure if it 
works with the svn in-tree directory layout.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64454



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


[PATCH] D65110: [NewPM] Run avx*-builtins.c tests under the new pass manager only

2019-07-23 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: clang/test/CodeGen/avx512vlbw-builtins.c:904
+  // CHECK: [[TMP:%.*]] = bitcast [[SRCTY:<.*>]] [[SEL]] to [[DSTTY:<.*>]]
+  // CHECK: [[SEL:%.*]] = bitcast [[DSTTY]] [[TMP]] to [[SRCTY]]
   // CHECK: select <16 x i1> %{{.*}}, <16 x i8> [[SEL]], <16 x i8> %{{.*}}

Can you release the DSTTY/SRCTY patterns with the actual types to improve 
readability?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65110



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


[PATCH] D65050: [SemaTemplate] Mark a function type as dependent when its parameter list contains pack expansion

2019-07-23 Thread S. B. Tam via Phabricator via cfe-commits
cpplearner updated this revision to Diff 211358.

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

https://reviews.llvm.org/D65050

Files:
  clang/lib/AST/Type.cpp
  clang/test/SemaTemplate/alias-templates.cpp


Index: clang/test/SemaTemplate/alias-templates.cpp
===
--- clang/test/SemaTemplate/alias-templates.cpp
+++ clang/test/SemaTemplate/alias-templates.cpp
@@ -267,3 +267,34 @@
 int z = Bar(); // expected-error {{use of template template parameter 
'Bar' requires template arguments}}
   }
 }
+
+namespace PR42654 {
+  template struct function { };
+
+  template
+  struct thing {
+void f(function) { }
+  };
+
+  template
+  struct Environment
+  {
+template
+using Integer = int;
+
+using Function = function...)>;
+using MyTuple = thing...>;
+
+void run(Function func)
+{
+  MyTuple t;
+  t.f(func);
+}
+  };
+
+  void f()
+  {
+Environment env;
+env.run({});
+  }
+}
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2912,7 +2912,10 @@
   // Fill in the trailing argument array.
   auto *argSlot = getTrailingObjects();
   for (unsigned i = 0; i != getNumParams(); ++i) {
-if (params[i]->isDependentType())
+// A pack expansion with a non-dependent pattern still affects the number 
of
+// parameters, thus we mark such function type as dependent, even though
+// this isn't listed in N4820 [temp.dep.type].
+if (params[i]->isDependentType() || params[i]->getAs())
   setDependent();
 else if (params[i]->isInstantiationDependentType())
   setInstantiationDependent();


Index: clang/test/SemaTemplate/alias-templates.cpp
===
--- clang/test/SemaTemplate/alias-templates.cpp
+++ clang/test/SemaTemplate/alias-templates.cpp
@@ -267,3 +267,34 @@
 int z = Bar(); // expected-error {{use of template template parameter 'Bar' requires template arguments}}
   }
 }
+
+namespace PR42654 {
+  template struct function { };
+
+  template
+  struct thing {
+void f(function) { }
+  };
+
+  template
+  struct Environment
+  {
+template
+using Integer = int;
+
+using Function = function...)>;
+using MyTuple = thing...>;
+
+void run(Function func)
+{
+  MyTuple t;
+  t.f(func);
+}
+  };
+
+  void f()
+  {
+Environment env;
+env.run({});
+  }
+}
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2912,7 +2912,10 @@
   // Fill in the trailing argument array.
   auto *argSlot = getTrailingObjects();
   for (unsigned i = 0; i != getNumParams(); ++i) {
-if (params[i]->isDependentType())
+// A pack expansion with a non-dependent pattern still affects the number of
+// parameters, thus we mark such function type as dependent, even though
+// this isn't listed in N4820 [temp.dep.type].
+if (params[i]->isDependentType() || params[i]->getAs())
   setDependent();
 else if (params[i]->isInstantiationDependentType())
   setInstantiationDependent();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D65050: [SemaTemplate] Mark a function type as dependent when its parameter list contains pack expansion

2019-07-23 Thread S. B. Tam via Phabricator via cfe-commits
cpplearner added a comment.

In D65050#1596514 , @efriedma wrote:

> Is this the only place where a compound type can contain a PackExpansionType?


Yes AFAIK. No other place can contain a list or a pack expansion. The closest 
thing is dynamic exception specification (which isn't part of the type), and it 
seems to be handled properly.

> The code could probably use a brief comment explaining why we need to check 
> this explicitly, even though it isn't listed in [temp.dep.type].

Done.


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

https://reviews.llvm.org/D65050



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


[PATCH] D64753: [CrossTU][NFCI] Refactor loadExternalAST function

2019-07-23 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 updated this revision to Diff 211361.
gamesh411 added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Refactor functionality into local classes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64753

Files:
  clang/include/clang/CrossTU/CrossTranslationUnit.h
  clang/lib/CrossTU/CrossTranslationUnit.cpp
  llvm/test/CodeGen/X86/packss.ll

Index: llvm/test/CodeGen/X86/packss.ll
===
--- llvm/test/CodeGen/X86/packss.ll
+++ llvm/test/CodeGen/X86/packss.ll
@@ -266,7 +266,7 @@
 }
 
 define <16 x i8> @packsswb_icmp_128_zero(<8 x i16> %a0) {
-; SSE-LABEL: packsswb_128_zero:
+; SSE-LABEL: packsswb_icmp_128_zero:
 ; SSE:   # %bb.0:
 ; SSE-NEXT:pxor %xmm1, %xmm1
 ; SSE-NEXT:pcmpeqw %xmm0, %xmm1
@@ -274,7 +274,7 @@
 ; SSE-NEXT:movq {{.*#+}} xmm0 = xmm1[0],zero
 ; SSE-NEXT:ret{{[l|q]}}
 ;
-; AVX-LABEL: packsswb_128_zero:
+; AVX-LABEL: packsswb_icmp_128_zero:
 ; AVX:   # %bb.0:
 ; AVX-NEXT:vpxor %xmm1, %xmm1, %xmm1
 ; AVX-NEXT:vpcmpeqw %xmm1, %xmm0, %xmm0
@@ -287,7 +287,7 @@
 }
 
 define <32 x i8> @packsswb_icmp_zero_256(<16 x i16> %a0) {
-; SSE-LABEL: packsswb_zero_256:
+; SSE-LABEL: packsswb_icmp_zero_256:
 ; SSE:   # %bb.0:
 ; SSE-NEXT:pxor %xmm2, %xmm2
 ; SSE-NEXT:pcmpeqw %xmm2, %xmm1
@@ -298,7 +298,7 @@
 ; SSE-NEXT:movaps %xmm2, %xmm1
 ; SSE-NEXT:ret{{[l|q]}}
 ;
-; AVX1-LABEL: packsswb_zero_256:
+; AVX1-LABEL: packsswb_icmp_zero_256:
 ; AVX1:   # %bb.0:
 ; AVX1-NEXT:vextractf128 $1, %ymm0, %xmm1
 ; AVX1-NEXT:vpxor %xmm2, %xmm2, %xmm2
@@ -311,7 +311,7 @@
 ; AVX1-NEXT:vblendps {{.*#+}} ymm0 = ymm1[0,1],ymm0[2,3],ymm1[4,5],ymm0[6,7]
 ; AVX1-NEXT:ret{{[l|q]}}
 ;
-; AVX2-LABEL: packsswb_zero_256:
+; AVX2-LABEL: packsswb_icmp_zero_256:
 ; AVX2:   # %bb.0:
 ; AVX2-NEXT:vpxor %xmm1, %xmm1, %xmm1
 ; AVX2-NEXT:vpcmpeqw %ymm1, %ymm0, %ymm0
Index: clang/lib/CrossTU/CrossTranslationUnit.cpp
===
--- clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -18,8 +18,8 @@
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Index/USRGeneration.h"
-#include "llvm/ADT/Triple.h"
 #include "llvm/ADT/Statistic.h"
+#include "llvm/ADT/Triple.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Path.h"
@@ -65,8 +65,7 @@
   Rhs.getVendor() != Triple::UnknownVendor &&
   Lhs.getVendor() != Rhs.getVendor())
 return false;
-  if (!Lhs.isOSUnknown() && !Rhs.isOSUnknown() &&
-  Lhs.getOS() != Rhs.getOS())
+  if (!Lhs.isOSUnknown() && !Rhs.isOSUnknown() && Lhs.getOS() != Rhs.getOS())
 return false;
   if (Lhs.getEnvironment() != Triple::UnknownEnvironment &&
   Rhs.getEnvironment() != Triple::UnknownEnvironment &&
@@ -188,8 +187,8 @@
 }
 
 CrossTranslationUnitContext::CrossTranslationUnitContext(CompilerInstance &CI)
-: CI(CI), Context(CI.getASTContext()),
-  CTULoadThreshold(CI.getAnalyzerOpts()->CTUImportThreshold) {}
+: CI(CI), Context(CI.getASTContext()), ASTStorage(CI),
+  CTULoadGuard(CI.getAnalyzerOpts()->CTUImportThreshold) {}
 
 CrossTranslationUnitContext::~CrossTranslationUnitContext() {}
 
@@ -237,8 +236,8 @@
   if (LookupName.empty())
 return llvm::make_error(
 index_error_code::failed_to_generate_usr);
-  llvm::Expected ASTUnitOrError = loadExternalAST(
-  LookupName, CrossTUDir, IndexName, DisplayCTUProgress);
+  llvm::Expected ASTUnitOrError =
+  loadExternalAST(LookupName, CrossTUDir, IndexName, DisplayCTUProgress);
   if (!ASTUnitOrError)
 return ASTUnitOrError.takeError();
   ASTUnit *Unit = *ASTUnitOrError;
@@ -340,6 +339,144 @@
   }
 }
 
+CrossTranslationUnitContext::LoadGuard::LoadGuard(unsigned CTULoadThreshold)
+: CTULoadThreshold(CTULoadThreshold), NumASTLoaded(0u) {}
+
+CrossTranslationUnitContext::LoadPass
+CrossTranslationUnitContext::LoadGuard::beginLoad() {
+  bool CanBegin = NumASTLoaded < CTULoadThreshold;
+  return {NumASTLoaded, CanBegin};
+}
+
+CrossTranslationUnitContext::LoadPass::LoadPass(unsigned &NumASTLoaded,
+bool CanBegin)
+: NumASTLoaded(NumASTLoaded), CanBegin(CanBegin), WasSuccessful(false) {}
+
+CrossTranslationUnitContext::LoadPass::~LoadPass() {
+  if (WasSuccessful)
+++NumASTLoaded;
+}
+
+void CrossTranslationUnitContext::LoadPass::wasSuccessful() {
+  WasSuccessful = true;
+}
+
+CrossTranslationUnitContext::LoadPass::operator bool() const {
+  return CanBegin;
+}
+
+CrossTranslationUnitContext::ASTDumpLoader::ASTDumpLoader(
+const CompilerInstance &CI)
+: CI(CI) {}
+
+std::unique_ptr
+CrossTranslationUnitContext::ASTDumpLoader::operator()(StringRef ASTFileName) {
+  // Load AST from

[PATCH] D64938: [clang-doc] Add option for user provided stylesheets

2019-07-23 Thread Diego Astiazarán via Phabricator via cfe-commits
DiegoAstiazaran updated this revision to Diff 211362.
DiegoAstiazaran marked an inline comment as done.
DiegoAstiazaran added a comment.

Add a second CSS file to one of the tests in HTMLGeneratorTest.cpp


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

https://reviews.llvm.org/D64938

Files:
  clang-tools-extra/clang-doc/Generators.h
  clang-tools-extra/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/clang-doc/MDGenerator.cpp
  clang-tools-extra/clang-doc/Representation.h
  clang-tools-extra/clang-doc/YAMLGenerator.cpp
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
  clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
  clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp

Index: clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp
@@ -40,7 +40,7 @@
   assert(G);
   std::string Buffer;
   llvm::raw_string_ostream Actual(Buffer);
-  auto Err = G->generateDocForInfo(&I, Actual);
+  auto Err = G->generateDocForInfo(&I, Actual, ClangDocContext());
   assert(!Err);
   std::string Expected =
   R"raw(---
@@ -94,7 +94,7 @@
   assert(G);
   std::string Buffer;
   llvm::raw_string_ostream Actual(Buffer);
-  auto Err = G->generateDocForInfo(&I, Actual);
+  auto Err = G->generateDocForInfo(&I, Actual, ClangDocContext());
   assert(!Err);
   std::string Expected =
   R"raw(---
@@ -158,7 +158,7 @@
   assert(G);
   std::string Buffer;
   llvm::raw_string_ostream Actual(Buffer);
-  auto Err = G->generateDocForInfo(&I, Actual);
+  auto Err = G->generateDocForInfo(&I, Actual, ClangDocContext());
   assert(!Err);
   std::string Expected =
   R"raw(---
@@ -206,7 +206,7 @@
   assert(G);
   std::string Buffer;
   llvm::raw_string_ostream Actual(Buffer);
-  auto Err = G->generateDocForInfo(&I, Actual);
+  auto Err = G->generateDocForInfo(&I, Actual, ClangDocContext());
   assert(!Err);
   std::string Expected =
   R"raw(---
@@ -343,7 +343,7 @@
   assert(G);
   std::string Buffer;
   llvm::raw_string_ostream Actual(Buffer);
-  auto Err = G->generateDocForInfo(&I, Actual);
+  auto Err = G->generateDocForInfo(&I, Actual, ClangDocContext());
   assert(!Err);
   std::string Expected =
   R"raw(---
Index: clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
@@ -38,7 +38,7 @@
   assert(G);
   std::string Buffer;
   llvm::raw_string_ostream Actual(Buffer);
-  auto Err = G->generateDocForInfo(&I, Actual);
+  auto Err = G->generateDocForInfo(&I, Actual, ClangDocContext());
   assert(!Err);
   std::string Expected = R"raw(# namespace Namespace
 
@@ -101,7 +101,7 @@
   assert(G);
   std::string Buffer;
   llvm::raw_string_ostream Actual(Buffer);
-  auto Err = G->generateDocForInfo(&I, Actual);
+  auto Err = G->generateDocForInfo(&I, Actual, ClangDocContext());
   assert(!Err);
   std::string Expected = R"raw(# class r
 
@@ -162,7 +162,7 @@
   assert(G);
   std::string Buffer;
   llvm::raw_string_ostream Actual(Buffer);
-  auto Err = G->generateDocForInfo(&I, Actual);
+  auto Err = G->generateDocForInfo(&I, Actual, ClangDocContext());
   assert(!Err);
   std::string Expected = R"raw(### f
 
@@ -190,7 +190,7 @@
   assert(G);
   std::string Buffer;
   llvm::raw_string_ostream Actual(Buffer);
-  auto Err = G->generateDocForInfo(&I, Actual);
+  auto Err = G->generateDocForInfo(&I, Actual, ClangDocContext());
   assert(!Err);
   std::string Expected = R"raw(| enum class e |
 
@@ -320,7 +320,7 @@
   assert(G);
   std::string Buffer;
   llvm::raw_string_ostream Actual(Buffer);
-  auto Err = G->generateDocForInfo(&I, Actual);
+  auto Err = G->generateDocForInfo(&I, Actual, ClangDocContext());
   assert(!Err);
   std::string Expected =
   R"raw(### f
Index: clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
@@ -21,6 +21,16 @@
   return std::move(G.get());
 }
 
+ClangDocContext
+getClangDocContext(std::vector UserStylesheets = {}) {
+  ClangDocContext CDCtx;
+  CDCtx.UserStylesheets = {UserStylesheets.begin(), UserStylesheets.end()};
+  CDCtx.UserStylesheets.insert(
+  CDCtx.UserStylesheets.begin(),
+  "../share/clang/clang-doc-default-stylesheet.css");
+  return CDCtx;
+}
+
 TEST(HTMLGeneratorTest, emitNamespaceHTML) {
   NamespaceInfo I;
   I.Name = "Namespace";
@@ -38,12 +48,14 @@
   assert(G);
   std::string Buffer;
   llvm::raw_string_ostream Actual(Buffer);
-  auto Err = G->generateDocForInfo(&I, Actual);
+  ClangDocConte

[PATCH] D64678: [Sema] Fix -Wuninitialized for struct assignment from GNU C statement expression

2019-07-23 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers accepted this revision.
nickdesaulniers added a comment.
This revision is now accepted and ready to land.

Thanks for the patch and following up on the review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64678



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


[PATCH] D64753: [CrossTU][NFCI] Refactor loadExternalAST function

2019-07-23 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 updated this revision to Diff 211363.
gamesh411 added a comment.

Too much autoformat fixed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64753

Files:
  clang/include/clang/CrossTU/CrossTranslationUnit.h
  clang/lib/CrossTU/CrossTranslationUnit.cpp

Index: clang/lib/CrossTU/CrossTranslationUnit.cpp
===
--- clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -188,8 +188,8 @@
 }
 
 CrossTranslationUnitContext::CrossTranslationUnitContext(CompilerInstance &CI)
-: CI(CI), Context(CI.getASTContext()),
-  CTULoadThreshold(CI.getAnalyzerOpts()->CTUImportThreshold) {}
+: CI(CI), Context(CI.getASTContext()), ASTStorage(CI),
+  CTULoadGuard(CI.getAnalyzerOpts()->CTUImportThreshold) {}
 
 CrossTranslationUnitContext::~CrossTranslationUnitContext() {}
 
@@ -237,8 +237,8 @@
   if (LookupName.empty())
 return llvm::make_error(
 index_error_code::failed_to_generate_usr);
-  llvm::Expected ASTUnitOrError = loadExternalAST(
-  LookupName, CrossTUDir, IndexName, DisplayCTUProgress);
+  llvm::Expected ASTUnitOrError =
+  loadExternalAST(LookupName, CrossTUDir, IndexName, DisplayCTUProgress);
   if (!ASTUnitOrError)
 return ASTUnitOrError.takeError();
   ASTUnit *Unit = *ASTUnitOrError;
@@ -340,6 +340,144 @@
   }
 }
 
+CrossTranslationUnitContext::LoadGuard::LoadGuard(unsigned CTULoadThreshold)
+: CTULoadThreshold(CTULoadThreshold), NumASTLoaded(0u) {}
+
+CrossTranslationUnitContext::LoadPass
+CrossTranslationUnitContext::LoadGuard::beginLoad() {
+  bool CanBegin = NumASTLoaded < CTULoadThreshold;
+  return {NumASTLoaded, CanBegin};
+}
+
+CrossTranslationUnitContext::LoadPass::LoadPass(unsigned &NumASTLoaded,
+bool CanBegin)
+: NumASTLoaded(NumASTLoaded), CanBegin(CanBegin), WasSuccessful(false) {}
+
+CrossTranslationUnitContext::LoadPass::~LoadPass() {
+  if (WasSuccessful)
+++NumASTLoaded;
+}
+
+void CrossTranslationUnitContext::LoadPass::wasSuccessful() {
+  WasSuccessful = true;
+}
+
+CrossTranslationUnitContext::LoadPass::operator bool() const {
+  return CanBegin;
+}
+
+CrossTranslationUnitContext::ASTDumpLoader::ASTDumpLoader(
+const CompilerInstance &CI)
+: CI(CI) {}
+
+std::unique_ptr
+CrossTranslationUnitContext::ASTDumpLoader::operator()(StringRef ASTFileName) {
+  // Load AST from ast-dump.
+  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+  TextDiagnosticPrinter *DiagClient =
+  new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts);
+  IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
+  IntrusiveRefCntPtr Diags(
+  new DiagnosticsEngine(DiagID, &*DiagOpts, DiagClient));
+
+  return ASTUnit::LoadFromASTFile(
+  ASTFileName, CI.getPCHContainerOperations()->getRawReader(),
+  ASTUnit::LoadEverything, Diags, CI.getFileSystemOpts());
+}
+
+CrossTranslationUnitContext::ASTUnitStorage::ASTUnitStorage(
+const CompilerInstance &CI)
+: FileAccessor(CI) {}
+
+llvm::Expected
+CrossTranslationUnitContext::ASTUnitStorage::getASTUnitForFile(StringRef FileName) {
+  // Try the cache first.
+  auto ASTCacheEntry = FileASTUnitMap.find(FileName);
+  if (ASTCacheEntry == FileASTUnitMap.end()) {
+// Load the ASTUnit from the pre-dumped AST file specified by ASTFileName.
+std::unique_ptr LoadedUnit = FileAccessor(FileName);
+
+// Need the raw pointer and the unique_ptr as well.
+ASTUnit* Unit = LoadedUnit.get();
+
+// Update the cache.
+FileASTUnitMap[FileName] = std::move(LoadedUnit);
+return Unit;
+
+  } else {
+// Found in the cache.
+return ASTCacheEntry->second.get();
+  }
+}
+
+llvm::Expected
+CrossTranslationUnitContext::ASTUnitStorage::getASTUnitForFunction(
+StringRef FunctionName, StringRef CrossTUDir, StringRef IndexName) {
+  // Try the cache first.
+  auto ASTCacheEntry = NameASTUnitMap.find(FunctionName);
+  if (ASTCacheEntry == NameASTUnitMap.end()) {
+// Load the ASTUnit from the pre-dumped AST file specified by ASTFileName.
+
+// Ensure that the Index is loaded, as we need to search in it.
+if (llvm::Error IndexLoadError =
+ensureCTUIndexLoaded(CrossTUDir, IndexName))
+  return std::move(IndexLoadError);
+
+// Check if there is and entry in the index for the function.
+if (!NameFileMap.count(FunctionName)) {
+  ++NumNotInOtherTU;
+  return llvm::make_error(index_error_code::missing_definition);
+}
+
+// Search in the index for the filename where the definition of FuncitonName
+// resides.
+if (llvm::Expected FoundForFile =
+getASTUnitForFile(NameFileMap[FunctionName])) {
+
+  // Update the cache.
+  NameASTUnitMap[FunctionName] = *FoundForFile;
+  return *FoundForFile;
+
+} else {
+  return FoundForFile.takeError();
+}
+  } else {
+// Found in th

[PATCH] D64666: [Sema] Enable -Wimplicit-float-conversion for integral to floating point precision loss

2019-07-23 Thread Ziang Wan via Phabricator via cfe-commits
ziangwan marked an inline comment as done.
ziangwan added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3279
+  "implicit conversion from %2 to %3 changes value from %0 to %1">,
+  InGroup, DefaultIgnore;
+

xbolva00 wrote:
> Drop ‘DefaultIgnore‘ here
I wish both warnings to be off by default and can be turned on by 
`-Wconversion` (`-Wimplicit-float-conversion`).


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

https://reviews.llvm.org/D64666



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


[PATCH] D65169: [WIP] LLVM Optimization Remark for Attributes

2019-07-23 Thread William Moses via Phabricator via cfe-commits
wsmoses created this revision.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, mgorny, 
mehdi_amini.
Herald added projects: clang, LLVM.

This is a *work in progress* patch illustrating how an optimization remark that 
prints out derived function/argument attributes could be implemented.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65169

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp
  llvm/include/llvm/IR/Attributes.h
  llvm/include/llvm/IR/DiagnosticInfo.h
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/LinkAllPasses.h
  llvm/include/llvm/Transforms/Utils.h
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/lib/Transforms/Utils/CMakeLists.txt
  llvm/lib/Transforms/Utils/Utils.cpp

Index: llvm/lib/Transforms/Utils/Utils.cpp
===
--- llvm/lib/Transforms/Utils/Utils.cpp
+++ llvm/lib/Transforms/Utils/Utils.cpp
@@ -26,6 +26,7 @@
   initializeAddDiscriminatorsLegacyPassPass(Registry);
   initializeBreakCriticalEdgesPass(Registry);
   initializeCanonicalizeAliasesLegacyPassPass(Registry);
+  initializeEmitAnnotationsLegacyPassPass(Registry);
   initializeInstNamerPass(Registry);
   initializeLCSSAWrapperPassPass(Registry);
   initializeLibCallsShrinkWrapLegacyPassPass(Registry);
Index: llvm/lib/Transforms/Utils/CMakeLists.txt
===
--- llvm/lib/Transforms/Utils/CMakeLists.txt
+++ llvm/lib/Transforms/Utils/CMakeLists.txt
@@ -12,6 +12,7 @@
   CodeExtractor.cpp
   CtorUtils.cpp
   DemoteRegToStack.cpp
+  EmitAnnotations.cpp
   EntryExitInstrumenter.cpp
   EscapeEnumerator.cpp
   Evaluator.cpp
Index: llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
===
--- llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
+++ llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -777,7 +777,7 @@
   MPM.add(createCFGSimplificationPass());
 
   addExtensionsToPM(EP_OptimizerLast, MPM);
-
+  MPM.add(createEmitAnnotationsPass());
   if (PrepareForLTO) {
 MPM.add(createCanonicalizeAliasesPass());
 // Rename anon globals to be able to handle them in the summary
Index: llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp
===
--- llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp
+++ llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp
@@ -24,48 +24,6 @@
  "example -force-attribute=foo:noinline. This "
  "option can be specified multiple times."));
 
-static Attribute::AttrKind parseAttrKind(StringRef Kind) {
-  return StringSwitch(Kind)
-  .Case("alwaysinline", Attribute::AlwaysInline)
-  .Case("builtin", Attribute::Builtin)
-  .Case("cold", Attribute::Cold)
-  .Case("convergent", Attribute::Convergent)
-  .Case("inlinehint", Attribute::InlineHint)
-  .Case("jumptable", Attribute::JumpTable)
-  .Case("minsize", Attribute::MinSize)
-  .Case("naked", Attribute::Naked)
-  .Case("nobuiltin", Attribute::NoBuiltin)
-  .Case("noduplicate", Attribute::NoDuplicate)
-  .Case("noimplicitfloat", Attribute::NoImplicitFloat)
-  .Case("noinline", Attribute::NoInline)
-  .Case("nonlazybind", Attribute::NonLazyBind)
-  .Case("noredzone", Attribute::NoRedZone)
-  .Case("noreturn", Attribute::NoReturn)
-  .Case("nocf_check", Attribute::NoCfCheck)
-  .Case("norecurse", Attribute::NoRecurse)
-  .Case("nounwind", Attribute::NoUnwind)
-  .Case("optforfuzzing", Attribute::OptForFuzzing)
-  .Case("optnone", Attribute::OptimizeNone)
-  .Case("optsize", Attribute::OptimizeForSize)
-  .Case("readnone", Attribute::ReadNone)
-  .Case("readonly", Attribute::ReadOnly)
-  .Case("argmemonly", Attribute::ArgMemOnly)
-  .Case("returns_twice", Attribute::ReturnsTwice)
-  .Case("safestack", Attribute::SafeStack)
-  .Case("shadowcallstack", Attribute::ShadowCallStack)
-  .Case("sanitize_address", Attribute::SanitizeAddress)
-  .Case("sanitize_hwaddress", Attribute::SanitizeHWAddress)
-  .Case("sanitize_memory", Attribute::SanitizeMemory)
-  .Case("sanitize_thread", Attribute::SanitizeThread)
-  .Case("speculative_load_hardening", Attribute::SpeculativeLoadHardening)
-  .Case("ssp", Attribute::StackProtect)
-  .Case("sspreq", Attribute::StackProtectReq)
-  .Case("sspstrong", Attribute::StackProtectStrong)
-  .Case("strictfp", Attribute::StrictFP)
-  .Case("uwtable", Attribute::UWTable)
-  .Defaul

  1   2   >