[PATCH] D38171: [clang-tidy] Implement clang-tidy check aliases

2018-03-14 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

While i don't have a leg to stand on here, i'd be *much* more comfortable if 
this would be a proper RFC mail in cfe-dev,
that would explore all the possible options (this, and the one from cfe-dev 
thread clang-tidy and CppCoreGuidelines 
),
and *explain* why one is chosen, and not the other one.

I still feel like that proposal is more sound.


https://reviews.llvm.org/D38171



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


[PATCH] D44439: [Sema] Pop function scope when instantiating a func with skipped body

2018-03-14 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: lib/Sema/SemaTemplateInstantiateDecl.cpp:3942
   ActOnSkippedFunctionBody(Function);
+  // FIXME: finishing the function body while in an expression evaluation
+  // context seems wrong. Investigate more.

(hmm, not sure whether it's better to duplicate or not-duplicate this comment. 
up to you)


Repository:
  rC Clang

https://reviews.llvm.org/D44439



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


[PATCH] D44305: [clangd] Add an interface that finds symbol by SymbolID in SymbolIndex.

2018-03-14 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/index/Merge.cpp:69
+  else
+B.insert(mergeSymbol(*Sym, S, &Scratch));
+});

sammccall wrote:
> This could also just be callback(mergeSymbol(...)), if we keep track of the 
> IDs we've emitted.
> This way the slab would only have symbols from the dynamic index.
> 
> This could be just:
>  - before the static lookup, make a copy `RemainingIDs = Req.IDs`
>  - in the static callback, remove the id from RemainingIDs
>  - after the static lookup, loop through RemainingIDs, look up symbol in 
> dynamic slab, emit
> 
> This avoids:
>  - copying the static index results (which tend to be more numerous)
>  - build() on the slab builder, which isn't cheap
Good idea. Thanks!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44305



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


[PATCH] D44305: [clangd] Add an interface that finds symbol by SymbolID in SymbolIndex.

2018-03-14 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 138313.
ioeric marked 5 inline comments as done.
ioeric added a comment.

- Addressed review comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44305

Files:
  clangd/index/FileIndex.cpp
  clangd/index/FileIndex.h
  clangd/index/Index.h
  clangd/index/MemIndex.cpp
  clangd/index/MemIndex.h
  clangd/index/Merge.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/IndexTests.cpp

Index: unittests/clangd/IndexTests.cpp
===
--- unittests/clangd/IndexTests.cpp
+++ unittests/clangd/IndexTests.cpp
@@ -29,7 +29,7 @@
 Sym.Scope = "";
   } else {
 Sym.Name = QName.substr(Pos + 2);
-Sym.Scope = QName.substr(0, Pos);
+Sym.Scope = QName.substr(0, Pos + 2);
   }
   return Sym;
 }
@@ -89,13 +89,16 @@
   return generateSymbols(Names, WeakSymbols);
 }
 
+std::string getQualifiedName(const Symbol &Sym) {
+  return (Sym.Scope + Sym.Name).str();
+}
+
 std::vector match(const SymbolIndex &I,
const FuzzyFindRequest &Req,
bool *Incomplete = nullptr) {
   std::vector Matches;
   bool IsIncomplete = I.fuzzyFind(Req, [&](const Symbol &Sym) {
-Matches.push_back(
-(Sym.Scope + (Sym.Scope.empty() ? "" : "::") + Sym.Name).str());
+Matches.push_back(getQualifiedName(Sym));
   });
   if (Incomplete)
 *Incomplete = IsIncomplete;
@@ -178,43 +181,87 @@
   I.build(generateSymbols({"a::y1", "a::y2", "a::x", "b::y2", "y3"}));
   FuzzyFindRequest Req;
   Req.Query = "y";
-  Req.Scopes = {"a"};
+  Req.Scopes = {"a::"};
   EXPECT_THAT(match(I, Req), UnorderedElementsAre("a::y1", "a::y2"));
 }
 
 TEST(MemIndexTest, MatchQualifiedNamesWithMultipleScopes) {
   MemIndex I;
   I.build(generateSymbols({"a::y1", "a::y2", "a::x", "b::y3", "y3"}));
   FuzzyFindRequest Req;
   Req.Query = "y";
-  Req.Scopes = {"a", "b"};
+  Req.Scopes = {"a::", "b::"};
   EXPECT_THAT(match(I, Req), UnorderedElementsAre("a::y1", "a::y2", "b::y3"));
 }
 
 TEST(MemIndexTest, NoMatchNestedScopes) {
   MemIndex I;
   I.build(generateSymbols({"a::y1", "a::b::y2"}));
   FuzzyFindRequest Req;
   Req.Query = "y";
-  Req.Scopes = {"a"};
+  Req.Scopes = {"a::"};
   EXPECT_THAT(match(I, Req), UnorderedElementsAre("a::y1"));
 }
 
 TEST(MemIndexTest, IgnoreCases) {
   MemIndex I;
   I.build(generateSymbols({"ns::ABC", "ns::abc"}));
   FuzzyFindRequest Req;
   Req.Query = "AB";
-  Req.Scopes = {"ns"};
+  Req.Scopes = {"ns::"};
   EXPECT_THAT(match(I, Req), UnorderedElementsAre("ns::ABC", "ns::abc"));
 }
 
-TEST(MergeTest, MergeIndex) {
+// Returns qualified names of symbols with any of IDs in the index.
+std::vector lookup(const SymbolIndex &I,
+llvm::ArrayRef IDs) {
+  LookupRequest Req;
+  Req.IDs.insert(IDs.begin(), IDs.end());
+  std::vector Results;
+  I.lookup(Req, [&](const Symbol &Sym) {
+Results.push_back(getQualifiedName(Sym));
+  });
+  return Results;
+}
+
+TEST(MemIndexTest, Lookup) {
+  MemIndex I;
+  I.build(generateSymbols({"ns::abc", "ns::xyz"}));
+  EXPECT_THAT(lookup(I, SymbolID("ns::abc")), UnorderedElementsAre("ns::abc"));
+  EXPECT_THAT(lookup(I, {SymbolID("ns::abc"), SymbolID("ns::xyz")}),
+  UnorderedElementsAre("ns::abc", "ns::xyz"));
+  EXPECT_THAT(lookup(I, {SymbolID("ns::nonono"), SymbolID("ns::xyz")}),
+  UnorderedElementsAre("ns::xyz"));
+  EXPECT_THAT(lookup(I, SymbolID("ns::nonono")), UnorderedElementsAre());
+}
+
+TEST(MergeIndexTest, Lookup) {
+  MemIndex I, J;
+  I.build(generateSymbols({"ns::A", "ns::B"}));
+  J.build(generateSymbols({"ns::B", "ns::C"}));
+  EXPECT_THAT(lookup(*mergeIndex(&I, &J), SymbolID("ns::A")),
+  UnorderedElementsAre("ns::A"));
+  EXPECT_THAT(lookup(*mergeIndex(&I, &J), SymbolID("ns::B")),
+  UnorderedElementsAre("ns::B"));
+  EXPECT_THAT(lookup(*mergeIndex(&I, &J), SymbolID("ns::C")),
+  UnorderedElementsAre("ns::C"));
+  EXPECT_THAT(
+  lookup(*mergeIndex(&I, &J), {SymbolID("ns::A"), SymbolID("ns::B")}),
+  UnorderedElementsAre("ns::A", "ns::B"));
+  EXPECT_THAT(
+  lookup(*mergeIndex(&I, &J), {SymbolID("ns::A"), SymbolID("ns::C")}),
+  UnorderedElementsAre("ns::A", "ns::C"));
+  EXPECT_THAT(lookup(*mergeIndex(&I, &J), SymbolID("ns::D")),
+  UnorderedElementsAre());
+  EXPECT_THAT(lookup(*mergeIndex(&I, &J), {}), UnorderedElementsAre());
+}
+
+TEST(MergeIndexTest, FuzzyFind) {
   MemIndex I, J;
   I.build(generateSymbols({"ns::A", "ns::B"}));
   J.build(generateSymbols({"ns::B", "ns::C"}));
   FuzzyFindRequest Req;
-  Req.Scopes = {"ns"};
+  Req.Scopes = {"ns::"};
   EXPECT_THAT(match(*mergeIndex(&I, &J), Req),
   UnorderedElementsAre("ns::A", "ns::B", "ns::C"));
 }
Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cp

[PATCH] D44305: [clangd] Add an interface that finds symbol by SymbolID in SymbolIndex.

2018-03-14 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL327487: [clangd] Add an interface that finds symbol by 
SymbolID in SymbolIndex. (authored by ioeric, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D44305

Files:
  clang-tools-extra/trunk/clangd/index/FileIndex.cpp
  clang-tools-extra/trunk/clangd/index/FileIndex.h
  clang-tools-extra/trunk/clangd/index/Index.h
  clang-tools-extra/trunk/clangd/index/MemIndex.cpp
  clang-tools-extra/trunk/clangd/index/MemIndex.h
  clang-tools-extra/trunk/clangd/index/Merge.cpp
  clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
  clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp

Index: clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp
@@ -29,7 +29,7 @@
 Sym.Scope = "";
   } else {
 Sym.Name = QName.substr(Pos + 2);
-Sym.Scope = QName.substr(0, Pos);
+Sym.Scope = QName.substr(0, Pos + 2);
   }
   return Sym;
 }
@@ -89,13 +89,16 @@
   return generateSymbols(Names, WeakSymbols);
 }
 
+std::string getQualifiedName(const Symbol &Sym) {
+  return (Sym.Scope + Sym.Name).str();
+}
+
 std::vector match(const SymbolIndex &I,
const FuzzyFindRequest &Req,
bool *Incomplete = nullptr) {
   std::vector Matches;
   bool IsIncomplete = I.fuzzyFind(Req, [&](const Symbol &Sym) {
-Matches.push_back(
-(Sym.Scope + (Sym.Scope.empty() ? "" : "::") + Sym.Name).str());
+Matches.push_back(getQualifiedName(Sym));
   });
   if (Incomplete)
 *Incomplete = IsIncomplete;
@@ -178,43 +181,87 @@
   I.build(generateSymbols({"a::y1", "a::y2", "a::x", "b::y2", "y3"}));
   FuzzyFindRequest Req;
   Req.Query = "y";
-  Req.Scopes = {"a"};
+  Req.Scopes = {"a::"};
   EXPECT_THAT(match(I, Req), UnorderedElementsAre("a::y1", "a::y2"));
 }
 
 TEST(MemIndexTest, MatchQualifiedNamesWithMultipleScopes) {
   MemIndex I;
   I.build(generateSymbols({"a::y1", "a::y2", "a::x", "b::y3", "y3"}));
   FuzzyFindRequest Req;
   Req.Query = "y";
-  Req.Scopes = {"a", "b"};
+  Req.Scopes = {"a::", "b::"};
   EXPECT_THAT(match(I, Req), UnorderedElementsAre("a::y1", "a::y2", "b::y3"));
 }
 
 TEST(MemIndexTest, NoMatchNestedScopes) {
   MemIndex I;
   I.build(generateSymbols({"a::y1", "a::b::y2"}));
   FuzzyFindRequest Req;
   Req.Query = "y";
-  Req.Scopes = {"a"};
+  Req.Scopes = {"a::"};
   EXPECT_THAT(match(I, Req), UnorderedElementsAre("a::y1"));
 }
 
 TEST(MemIndexTest, IgnoreCases) {
   MemIndex I;
   I.build(generateSymbols({"ns::ABC", "ns::abc"}));
   FuzzyFindRequest Req;
   Req.Query = "AB";
-  Req.Scopes = {"ns"};
+  Req.Scopes = {"ns::"};
   EXPECT_THAT(match(I, Req), UnorderedElementsAre("ns::ABC", "ns::abc"));
 }
 
-TEST(MergeTest, MergeIndex) {
+// Returns qualified names of symbols with any of IDs in the index.
+std::vector lookup(const SymbolIndex &I,
+llvm::ArrayRef IDs) {
+  LookupRequest Req;
+  Req.IDs.insert(IDs.begin(), IDs.end());
+  std::vector Results;
+  I.lookup(Req, [&](const Symbol &Sym) {
+Results.push_back(getQualifiedName(Sym));
+  });
+  return Results;
+}
+
+TEST(MemIndexTest, Lookup) {
+  MemIndex I;
+  I.build(generateSymbols({"ns::abc", "ns::xyz"}));
+  EXPECT_THAT(lookup(I, SymbolID("ns::abc")), UnorderedElementsAre("ns::abc"));
+  EXPECT_THAT(lookup(I, {SymbolID("ns::abc"), SymbolID("ns::xyz")}),
+  UnorderedElementsAre("ns::abc", "ns::xyz"));
+  EXPECT_THAT(lookup(I, {SymbolID("ns::nonono"), SymbolID("ns::xyz")}),
+  UnorderedElementsAre("ns::xyz"));
+  EXPECT_THAT(lookup(I, SymbolID("ns::nonono")), UnorderedElementsAre());
+}
+
+TEST(MergeIndexTest, Lookup) {
+  MemIndex I, J;
+  I.build(generateSymbols({"ns::A", "ns::B"}));
+  J.build(generateSymbols({"ns::B", "ns::C"}));
+  EXPECT_THAT(lookup(*mergeIndex(&I, &J), SymbolID("ns::A")),
+  UnorderedElementsAre("ns::A"));
+  EXPECT_THAT(lookup(*mergeIndex(&I, &J), SymbolID("ns::B")),
+  UnorderedElementsAre("ns::B"));
+  EXPECT_THAT(lookup(*mergeIndex(&I, &J), SymbolID("ns::C")),
+  UnorderedElementsAre("ns::C"));
+  EXPECT_THAT(
+  lookup(*mergeIndex(&I, &J), {SymbolID("ns::A"), SymbolID("ns::B")}),
+  UnorderedElementsAre("ns::A", "ns::B"));
+  EXPECT_THAT(
+  lookup(*mergeIndex(&I, &J), {SymbolID("ns::A"), SymbolID("ns::C")}),
+  UnorderedElementsAre("ns::A", "ns::C"));
+  EXPECT_THAT(lookup(*mergeIndex(&I, &J), SymbolID("ns::D")),
+  UnorderedElementsAre());
+  EXPECT_THAT(lookup(*mergeIndex(&I, &J), {}), UnorderedElementsAre());
+}
+
+TEST(MergeIndexTest, FuzzyFind) {
   MemIndex I, J;
   I.build(generateSymbols({"ns::A", "ns::B"}));
   J.build(generateSymbols({"ns::B", "ns::C"}));
   FuzzyFindRequest Req;
-  R

[clang-tools-extra] r327487 - [clangd] Add an interface that finds symbol by SymbolID in SymbolIndex.

2018-03-14 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed Mar 14 02:48:05 2018
New Revision: 327487

URL: http://llvm.org/viewvc/llvm-project?rev=327487&view=rev
Log:
[clangd] Add an interface that finds symbol by SymbolID in SymbolIndex.

Summary:
Potential use case: argument go-to-definition result with symbol
information (e.g. function definition in cc file) that might not be in the AST.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: klimek, ilya-biryukov, jkorous-apple, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/index/FileIndex.cpp
clang-tools-extra/trunk/clangd/index/FileIndex.h
clang-tools-extra/trunk/clangd/index/Index.h
clang-tools-extra/trunk/clangd/index/MemIndex.cpp
clang-tools-extra/trunk/clangd/index/MemIndex.h
clang-tools-extra/trunk/clangd/index/Merge.cpp
clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp

Modified: clang-tools-extra/trunk/clangd/index/FileIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/FileIndex.cpp?rev=327487&r1=327486&r2=327487&view=diff
==
--- clang-tools-extra/trunk/clangd/index/FileIndex.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/FileIndex.cpp Wed Mar 14 02:48:05 2018
@@ -93,5 +93,11 @@ bool FileIndex::fuzzyFind(
   return Index.fuzzyFind(Req, Callback);
 }
 
+void FileIndex::lookup(
+const LookupRequest &Req,
+llvm::function_ref Callback) const {
+  Index.lookup(Req, Callback);
+}
+
 } // namespace clangd
 } // namespace clang

Modified: clang-tools-extra/trunk/clangd/index/FileIndex.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/FileIndex.h?rev=327487&r1=327486&r2=327487&view=diff
==
--- clang-tools-extra/trunk/clangd/index/FileIndex.h (original)
+++ clang-tools-extra/trunk/clangd/index/FileIndex.h Wed Mar 14 02:48:05 2018
@@ -63,6 +63,9 @@ public:
   fuzzyFind(const FuzzyFindRequest &Req,
 llvm::function_ref Callback) const override;
 
+  void lookup(const LookupRequest &Req,
+  llvm::function_ref Callback) const 
override;
+
 private:
   FileSymbols FSymbols;
   MemIndex Index;

Modified: clang-tools-extra/trunk/clangd/index/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=327487&r1=327486&r2=327487&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Wed Mar 14 02:48:05 2018
@@ -248,6 +248,10 @@ struct FuzzyFindRequest {
   size_t MaxCandidateCount = UINT_MAX;
 };
 
+struct LookupRequest {
+  llvm::DenseSet IDs;
+};
+
 /// \brief Interface for symbol indexes that can be used for searching or
 /// matching symbols among a set of symbols based on names or unique IDs.
 class SymbolIndex {
@@ -263,8 +267,14 @@ public:
   fuzzyFind(const FuzzyFindRequest &Req,
 llvm::function_ref Callback) const = 0;
 
+  /// Looks up symbols with any of the given symbol IDs and applies \p Callback
+  /// on each matched symbol.
+  /// The returned symbol must be deep-copied if it's used outside Callback.
+  virtual void
+  lookup(const LookupRequest &Req,
+ llvm::function_ref Callback) const = 0;
+
   // FIXME: add interfaces for more index use cases:
-  //  - Symbol getSymbolInfo(SymbolID);
   //  - getAllOccurrences(SymbolID);
 };
 

Modified: clang-tools-extra/trunk/clangd/index/MemIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/MemIndex.cpp?rev=327487&r1=327486&r2=327487&view=diff
==
--- clang-tools-extra/trunk/clangd/index/MemIndex.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/MemIndex.cpp Wed Mar 14 02:48:05 2018
@@ -60,6 +60,15 @@ bool MemIndex::fuzzyFind(
   return More;
 }
 
+void MemIndex::lookup(const LookupRequest &Req,
+  llvm::function_ref Callback) const 
{
+  for (const auto &ID : Req.IDs) {
+auto I = Index.find(ID);
+if (I != Index.end())
+  Callback(*I->second);
+  }
+}
+
 std::unique_ptr MemIndex::build(SymbolSlab Slab) {
   struct Snapshot {
 SymbolSlab Slab;

Modified: clang-tools-extra/trunk/clangd/index/MemIndex.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/MemIndex.h?rev=327487&r1=327486&r2=327487&view=diff
==
--- clang-tools-extra/trunk/clangd/index/MemIndex.h (original)
+++ clang-tools-extra/trunk/clangd/index/MemIndex.h Wed Mar 14 02:48:05 2018
@@ -31,6 +31,10 @@ public:
   fuzzyFind(const FuzzyFindRequest &Req,
 llvm::function_ref Callback) const override

r327491 - StaticAnalyzer: fix compiler warning. NFC

2018-03-14 Thread Pavel Labath via cfe-commits
Author: labath
Date: Wed Mar 14 03:16:40 2018
New Revision: 327491

URL: http://llvm.org/viewvc/llvm-project?rev=327491&view=rev
Log:
StaticAnalyzer: fix compiler warning. NFC

My compiler (clang-3.8) complains that the RCC variable is unused.
That's not really true, as it's checked by the if-declaration, but it's
also kinda true, because we don't need to declaration if we only check
it in the if statement.

In reality, all this means that the dyn_cast<> can be replaced by isa<>,
so that's what I do here.

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

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=327491&r1=327490&r2=327491&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Wed Mar 14 03:16:40 2018
@@ -464,7 +464,7 @@ ProgramStateRef ExprEngine::addAllNecess
 
 // If the temporary is being returned from the function, it will be
 // destroyed or lifetime-extended in the caller stack frame.
-if (const auto *RCC = dyn_cast(CC)) {
+if (isa(CC)) {
   const StackFrameContext *SFC = LC->getCurrentStackFrame();
   assert(SFC);
   if (SFC->getParent()) {


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


[PATCH] D44435: Add the module name to __cuda_module_ctor and __cuda_module_dtor for unique function names

2018-03-14 Thread Simeon Ehrig via Phabricator via cfe-commits
SimeonEhrig marked an inline comment as done.
SimeonEhrig added inline comments.



Comment at: lib/CodeGen/CGCUDANV.cpp:281
 
+  // get name from the module to generate unique ctor name for every module
+  SmallString<128> ModuleName

rjmccall wrote:
> Please explain in the comment *why* you're doing this.  It's just for 
> debugging, right?  So that it's known which object file the constructor 
> function comes from.
The motivation is the same at this review: https://reviews.llvm.org/D34059
We try to enable incremental compiling of cuda runtime code, so we need unique 
ctor/dtor names, to handle the cuda device code over different modules. 



Comment at: lib/CodeGen/CGCUDANV.cpp:281
 
+  // get name from the module to generate unique ctor name for every module
+  SmallString<128> ModuleName

tra wrote:
> SimeonEhrig wrote:
> > rjmccall wrote:
> > > Please explain in the comment *why* you're doing this.  It's just for 
> > > debugging, right?  So that it's known which object file the constructor 
> > > function comes from.
> > The motivation is the same at this review: https://reviews.llvm.org/D34059
> > We try to enable incremental compiling of cuda runtime code, so we need 
> > unique ctor/dtor names, to handle the cuda device code over different 
> > modules. 
> I'm also interested in in the motivation for this change.
> 
> Also, if the goal is to have an unique module identifier, would compiling two 
> different files with the same name be a problem? If the goal is to help 
> identifying a module, this may be OK, if not ideal. If you really need to 
> have unique name, then you may need to do something more elaborate. NVCC 
> appears to use some random number (or hash of something?) for that.
We need this modification for our C++-interpreter Cling, which we want to 
expand to interpret CUDA runtime code. Effective, it's a jit, which read in 
line by line the program code. Every line get his own llvm::Module. The 
Interpreter works with incremental and lazy compilation. Because the lazy 
compilation, we needs this modification. In the CUDA mode, clang generates  for 
every module an _ _cuda_module_ctor and _ _cuda_module_dtor, if the compiler 
was started with a path to a fatbinary file. But the ctor is also depend on the 
source code, which will translate to llvm IR in the module. For Example, if a _ 
_global_ _ kernel will defined, the CodeGen add the function call 
__cuda_register_globals() to the ctor. But the lazy compilations prevents, that 
we can translate a function, which is already translate. Without the 
modification, the interpreter things, that the ctor is always same and use the 
first translation of the function, which was generate. Therefore, it is 
impossible to add new kernels. 



Comment at: unittests/CodeGen/IncrementalProcessingTest.cpp:176-178
+
+// In CUDA incremental processing, a CUDA ctor or dtor will be generated for 
+// every statement if a fatbinary file exists.

tra wrote:
> I don't understand the comment. What is 'CUDA incremental processing' and 
> what exactly is meant by 'statement' here? I'd appreciate if you could give 
> me more details. My understanding is that ctor/dtor are generated once per 
> TU. I suspect "incremental processing" may change that, but I have no idea 
> what exactly does it do.
A CUDA ctor/dtor will generates for every llvm::module. The TU can also 
composed of many modules. In our interpreter, we add new code to our AST with 
new modules at runtime. 
The ctor/dtor generation is depend on the fatbinary code. The CodeGen checks, 
if a path to a fatbinary file is set. If it is, it generates an ctor with at 
least a __cudaRegisterFatBinary() function call. So, the generation is 
independent of the source code in the module and we can use every statement. A 
statement can be an expression, a declaration, a definition and so one.   


Repository:
  rC Clang

https://reviews.llvm.org/D44435



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


[PATCH] D44439: [Sema] Pop function scope when instantiating a func with skipped body

2018-03-14 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.

Test case for this change?




Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:3944
+  // context seems wrong. Investigate more.
+  ActOnFinishFunctionBody(Function, nullptr, /*IsInstantiation=*/true);
 } else {

Rather than having two paths that call the same function, why not hoist the 
call out to the common path?



Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:3967
   // context seems wrong. Investigate more.
-  ActOnFinishFunctionBody(Function, Body.get(),
-  /*IsInstantiation=*/true);
+  ActOnFinishFunctionBody(Function, Body.get(), /*IsInstantiation=*/true);
 }

This change looks unrelated to the patch.


Repository:
  rC Clang

https://reviews.llvm.org/D44439



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


[PATCH] D44462: [clangd] Don't use DraftMgr in implementation of forceReparse.

2018-03-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: sammccall.
Herald added subscribers: ioeric, jkorous-apple, klimek.

To make the removal of DraftMgr from ClangdServer easier 
(https://reviews.llvm.org/D44408).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44462

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/TUScheduler.cpp
  clangd/TUScheduler.h

Index: clangd/TUScheduler.h
===
--- clangd/TUScheduler.h
+++ clangd/TUScheduler.h
@@ -59,6 +59,18 @@
   /// The order of results is unspecified.
   std::vector> getUsedBytesPerFile() const;
 
+  /// Returns a list of currently tracked files. File starts being trakced on
+  /// first update() call to it and stops being tracked on remove() call.
+  std::vector getTrackedFiles() const;
+
+  /// Schedule a reparse for \p File with a new compile command. File must be
+  /// tracked.
+  /// FIXME: remove the callback from this function
+  void updateCompileCommand(PathRef File, tooling::CompileCommand NewCommand,
+IntrusiveRefCntPtr FS,
+WantDiagnostics WantDiags,
+UniqueFunction)> OnUpdated);
+
   /// Schedule an update for \p File. Adds \p File to a list of tracked files if
   /// \p File was not part of it before.
   /// FIXME(ibiryukov): remove the callback from this function.
Index: clangd/TUScheduler.cpp
===
--- clangd/TUScheduler.cpp
+++ clangd/TUScheduler.cpp
@@ -110,6 +110,9 @@
   Deadline scheduleLocked();
   /// Should the first task in the queue be skipped instead of run?
   bool shouldSkipHeadLocked() const;
+  /// Rebuilds AST and pushes the new diagnostics, if required.
+  void rebuildASTLocked(WantDiagnostics WantDiags,
+UniqueFunction)> OnUpdated);
 
   struct Request {
 UniqueFunction Action;
@@ -213,20 +216,8 @@
 void ASTWorker::update(ParseInputs Inputs, WantDiagnostics WantDiags,
UniqueFunction)> OnUpdated) {
   auto Task = [=](decltype(OnUpdated) OnUpdated) mutable {
-FileInputs = Inputs;
-auto Diags = AST.rebuild(std::move(Inputs));
-
-{
-  std::lock_guard Lock(Mutex);
-  if (AST.getPreamble())
-LastBuiltPreamble = AST.getPreamble();
-  LastASTSize = AST.getUsedBytes();
-}
-// We want to report the diagnostics even if this update was cancelled.
-// It seems more useful than making the clients wait indefinitely if they
-// spam us with updates.
-if (Diags && WantDiags != WantDiagnostics::No)
-  OnUpdated(std::move(*Diags));
+FileInputs = std::move(Inputs);
+rebuildASTLocked(WantDiags, std::move(OnUpdated));
   };
 
   startTask("Update", Bind(Task, std::move(OnUpdated)), WantDiags);
@@ -388,6 +379,23 @@
   llvm_unreachable("Unknown WantDiagnostics");
 }
 
+void ASTWorker::rebuildASTLocked(
+WantDiagnostics WantDiags,
+UniqueFunction)> OnUpdated) {
+  auto Diags = AST.rebuild(ParseInputs(FileInputs));
+  {
+std::lock_guard Lock(Mutex);
+if (AST.getPreamble())
+  LastBuiltPreamble = AST.getPreamble();
+LastASTSize = AST.getUsedBytes();
+  }
+  // We want to report the diagnostics even if this update was cancelled.
+  // It seems more useful than making the clients wait indefinitely if they
+  // spam us with updates.
+  if (Diags && WantDiags != WantDiagnostics::No)
+OnUpdated(std::move(*Diags));
+}
+
 bool ASTWorker::blockUntilIdle(Deadline Timeout) const {
   std::unique_lock Lock(Mutex);
   return wait(Lock, RequestsCV, Timeout, [&] { return Requests.empty(); });
@@ -446,6 +454,20 @@
   return true;
 }
 
+void TUScheduler::updateCompileCommand(
+PathRef File, tooling::CompileCommand NewCommand,
+IntrusiveRefCntPtr FS, WantDiagnostics WantDiags,
+UniqueFunction)> OnUpdated) {
+  auto FDIt = Files.find(File);
+  assert(FDIt != Files.end() &&
+ "calling updateCompileCommand on non-tracked file");
+
+  FDIt->second->Inputs.CompileCommand = std::move(NewCommand);
+  FDIt->second->Inputs.FS = std::move(FS);
+  FDIt->second->Worker->update(FDIt->second->Inputs, WantDiags,
+   std::move(OnUpdated));
+}
+
 void TUScheduler::update(PathRef File, ParseInputs Inputs,
  WantDiagnostics WantDiags,
  UniqueFunction)> OnUpdated) {
@@ -533,5 +555,9 @@
   return Result;
 }
 
+std::vector TUScheduler::getTrackedFiles() const {
+  return std::vector(Files.keys().begin(), Files.keys().end());
+}
+
 } // namespace clangd
 } // namespace clang
Index: clangd/ClangdServer.h
===
--- clangd/ClangdServer.h
+++ clangd/ClangdServer.h
@@ -240,9 +240,8 @@
   formatCode(llvm::StringRef Code, PathRef File,
  ArrayRef Ranges);
 
-  void scheduleReparseAndDiags(PathRef File, VersionedDraft Contents,
-

[PATCH] D44463: [clangd] Don't expose vfs in TUScheduler::runWithPreamble.

2018-03-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: sammccall.
Herald added subscribers: ioeric, jkorous-apple, klimek.

It previously an easy way to concurrently access a mutable vfs, which
is a recipe for disaster.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44463

Files:
  clangd/ClangdServer.cpp
  clangd/TUScheduler.cpp
  clangd/TUScheduler.h
  unittests/clangd/TUSchedulerTests.cpp

Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -226,8 +226,7 @@
 EXPECT_THAT(Context::current().get(NonceKey), Pointee(Nonce));
 
 ASSERT_TRUE((bool)Preamble);
-EXPECT_EQ(Preamble->Inputs.FS, Inputs.FS);
-EXPECT_EQ(Preamble->Inputs.Contents, Inputs.Contents);
+EXPECT_EQ(Preamble->Contents, Inputs.Contents);
 
 std::lock_guard Lock(Mut);
 ++TotalPreambleReads;
Index: clangd/TUScheduler.h
===
--- clangd/TUScheduler.h
+++ clangd/TUScheduler.h
@@ -29,7 +29,8 @@
 };
 
 struct InputsAndPreamble {
-  const ParseInputs &Inputs;
+  llvm::StringRef Contents;
+  const tooling::CompileCommand &Command;
   const PreambleData *Preamble;
 };
 
Index: clangd/TUScheduler.cpp
===
--- clangd/TUScheduler.cpp
+++ clangd/TUScheduler.cpp
@@ -415,7 +415,8 @@
 
 struct TUScheduler::FileData {
   /// Latest inputs, passed to TUScheduler::update().
-  ParseInputs Inputs;
+  std::string Contents;
+  tooling::CompileCommand Command;
   ASTWorkerHandle Worker;
 };
 
@@ -462,10 +463,14 @@
   assert(FDIt != Files.end() &&
  "calling updateCompileCommand on non-tracked file");
 
-  FDIt->second->Inputs.CompileCommand = std::move(NewCommand);
-  FDIt->second->Inputs.FS = std::move(FS);
-  FDIt->second->Worker->update(FDIt->second->Inputs, WantDiags,
-   std::move(OnUpdated));
+  FDIt->second->Command = NewCommand;
+  FDIt->second->Worker->update(
+  ParseInputs{
+  std::move(NewCommand),
+  std::move(FS),
+  FDIt->second->Contents,
+  },
+  WantDiags, std::move(OnUpdated));
 }
 
 void TUScheduler::update(PathRef File, ParseInputs Inputs,
@@ -478,9 +483,11 @@
 File, WorkerThreads ? WorkerThreads.getPointer() : nullptr, Barrier,
 CppFile(File, StorePreamblesInMemory, PCHOps, ASTCallback),
 UpdateDebounce);
-FD = std::unique_ptr(new FileData{Inputs, std::move(Worker)});
+FD = std::unique_ptr(new FileData{
+Inputs.Contents, Inputs.CompileCommand, std::move(Worker)});
   } else {
-FD->Inputs = Inputs;
+FD->Contents = Inputs.Contents;
+FD->Command = Inputs.CompileCommand;
   }
   FD->Worker->update(std::move(Inputs), WantDiags, std::move(OnUpdated));
 }
@@ -522,26 +529,28 @@
 SPAN_ATTACH(Tracer, "file", File);
 std::shared_ptr Preamble =
 It->second->Worker->getPossiblyStalePreamble();
-Action(InputsAndPreamble{It->second->Inputs, Preamble.get()});
+Action(InputsAndPreamble{It->second->Contents, It->second->Command,
+ Preamble.get()});
 return;
   }
 
-  ParseInputs InputsCopy = It->second->Inputs;
   std::shared_ptr Worker = It->second->Worker.lock();
-  auto Task = [InputsCopy, Worker, this](std::string Name, std::string File,
- Context Ctx,
- decltype(Action) Action) mutable {
+  auto Task = [Worker, this](std::string Name, std::string File,
+ std::string Contents,
+ tooling::CompileCommand Command, Context Ctx,
+ decltype(Action) Action) mutable {
 std::lock_guard BarrierLock(Barrier);
 WithContext Guard(std::move(Ctx));
 trace::Span Tracer(Name);
 SPAN_ATTACH(Tracer, "file", File);
 std::shared_ptr Preamble =
 Worker->getPossiblyStalePreamble();
-Action(InputsAndPreamble{InputsCopy, Preamble.get()});
+Action(InputsAndPreamble{Contents, Command, Preamble.get()});
   };
 
   PreambleTasks->runAsync("task:" + llvm::sys::path::filename(File),
   Bind(Task, std::string(Name), std::string(File),
+   It->second->Contents, It->second->Command,
Context::current().clone(), std::move(Action)));
 }
 
Index: clangd/ClangdServer.cpp
===
--- clangd/ClangdServer.cpp
+++ clangd/ClangdServer.cpp
@@ -171,12 +171,11 @@
   llvm::Expected IP) {
 assert(IP && "error when trying to read preamble for codeComplete");
 auto PreambleData = IP->Preamble;
-auto &Command = IP->Inputs.CompileCommand;
 
 // FIXME(ibir

[PATCH] D44408: Move DraftMgr from ClangdServer to ClangdLSPServer

2018-03-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a reviewer: ilya-biryukov.
ilya-biryukov requested changes to this revision.
ilya-biryukov added a comment.
This revision now requires changes to proceed.

We shouldn't add `Contents` parameter to every method, it would defeat the 
purpose of caching ASTs and won't allow to properly manage lifetimes of the 
indexes.

The most tricky part is getting rid of `DraftMgr` in `forceReparse`. Here's a 
change that removes usages of it there: https://reviews.llvm.org/D44462`, it 
should be much easier to make it work when it lands.
Any other reason why we need to add them?




Comment at: clangd/ClangdLSPServer.h:87
+  /// conversions in outside code, maybe there's a way to get rid of it.
+  llvm::Optional getDocument(PathRef File);
+

We can remove this function now, it is equivalent to a one-liner 
`DraftMgr.getDraft(File).Draft`


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44408



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


[PATCH] D44439: [Sema] Pop function scope when instantiating a func with skipped body

2018-03-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

I also came up with a test case, but it breaks because of invalid errors when 
function bodies are skipped. I'll make sure to include it along with a fix for 
the errors in a follow-up patch.




Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:3942
   ActOnSkippedFunctionBody(Function);
+  // FIXME: finishing the function body while in an expression evaluation
+  // context seems wrong. Investigate more.

sammccall wrote:
> (hmm, not sure whether it's better to duplicate or not-duplicate this 
> comment. up to you)
It looks relevant to both sites, so I'd probably keep it. It adds some noise, 
but it's better than having a chance of confusing someone by not including it.


Repository:
  rC Clang

https://reviews.llvm.org/D44439



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


[PATCH] D44439: [Sema] Pop function scope when instantiating a func with skipped body

2018-03-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 138333.
ilya-biryukov marked 4 inline comments as done.
ilya-biryukov added a comment.

- Addressed review comments


Repository:
  rC Clang

https://reviews.llvm.org/D44439

Files:
  lib/Sema/SemaTemplateInstantiateDecl.cpp


Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3937,8 +3937,10 @@
  TemplateArgs))
   return;
 
+StmtResult Body;
 if (PatternDecl->hasSkippedBody()) {
   ActOnSkippedFunctionBody(Function);
+  Body = nullptr;
 } else {
   if (CXXConstructorDecl *Ctor = dyn_cast(Function)) {
 // If this is a constructor, instantiate the member initializers.
@@ -3954,16 +3956,14 @@
   }
 
   // Instantiate the function body.
-  StmtResult Body = SubstStmt(Pattern, TemplateArgs);
+  Body = SubstStmt(Pattern, TemplateArgs);
 
   if (Body.isInvalid())
 Function->setInvalidDecl();
-
-  // FIXME: finishing the function body while in an expression evaluation
-  // context seems wrong. Investigate more.
-  ActOnFinishFunctionBody(Function, Body.get(),
-  /*IsInstantiation=*/true);
 }
+// FIXME: finishing the function body while in an expression evaluation
+// context seems wrong. Investigate more.
+ActOnFinishFunctionBody(Function, Body.get(), /*IsInstantiation=*/true);
 
 PerformDependentDiagnostics(PatternDecl, TemplateArgs);
 


Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3937,8 +3937,10 @@
  TemplateArgs))
   return;
 
+StmtResult Body;
 if (PatternDecl->hasSkippedBody()) {
   ActOnSkippedFunctionBody(Function);
+  Body = nullptr;
 } else {
   if (CXXConstructorDecl *Ctor = dyn_cast(Function)) {
 // If this is a constructor, instantiate the member initializers.
@@ -3954,16 +3956,14 @@
   }
 
   // Instantiate the function body.
-  StmtResult Body = SubstStmt(Pattern, TemplateArgs);
+  Body = SubstStmt(Pattern, TemplateArgs);
 
   if (Body.isInvalid())
 Function->setInvalidDecl();
-
-  // FIXME: finishing the function body while in an expression evaluation
-  // context seems wrong. Investigate more.
-  ActOnFinishFunctionBody(Function, Body.get(),
-  /*IsInstantiation=*/true);
 }
+// FIXME: finishing the function body while in an expression evaluation
+// context seems wrong. Investigate more.
+ActOnFinishFunctionBody(Function, Body.get(), /*IsInstantiation=*/true);
 
 PerformDependentDiagnostics(PatternDecl, TemplateArgs);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44439: [Sema] Pop function scope when instantiating a func with skipped body

2018-03-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you for the explanation about the tests.


Repository:
  rC Clang

https://reviews.llvm.org/D44439



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


[PATCH] D44439: [Sema] Pop function scope when instantiating a func with skipped body

2018-03-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

@aaron.ballman , here's a test-case I came up with. I'll fix the other issue 
(invalid error, that forces the test to fail) and submit it for review along 
with the fix for the error. Does that SG?

  template 
  auto make_func() {
struct impl {
  impl* func() {
// body of this function is skipped during completion.
// but will be instantiated anyway.
return this;
  }
};
  
return impl();
  }
  
  void foo() {
[]() {
  make_func();// currently also produces invalid error `function 
with auto-deduced type 'make_func' is used before defined
  m
  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:17:6 %s -o - | 
FileCheck %s
  // CHECK: make_func : [#auto#]make_func<<#class T#>>()
  
};
  }




Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:3967
   // context seems wrong. Investigate more.
-  ActOnFinishFunctionBody(Function, Body.get(),
-  /*IsInstantiation=*/true);
+  ActOnFinishFunctionBody(Function, Body.get(), /*IsInstantiation=*/true);
 }

aaron.ballman wrote:
> This change looks unrelated to the patch.
It was a formatting change.


Repository:
  rC Clang

https://reviews.llvm.org/D44439



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


[PATCH] D44439: [Sema] Pop function scope when instantiating a func with skipped body

2018-03-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D44439#1036868, @ilya-biryukov wrote:

> @aaron.ballman , here's a test-case I came up with. I'll fix the other issue 
> (invalid error, that forces the test to fail) and submit it for review along 
> with the fix for the error. Does that SG?


Yes, that sounds good to me. Thank you!


Repository:
  rC Clang

https://reviews.llvm.org/D44439



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


[PATCH] D36357: Added a better diagnostic when using the delete operator with lambdas

2018-03-14 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete updated this revision to Diff 138335.
Rakete added a comment.

> Did you forget to upload the updated patch? This looks unchanged compared to 
> the prior version.

Whoops, that's true. Sorry...


https://reviews.llvm.org/D36357

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  lib/Parse/ParseExprCXX.cpp
  test/Parser/cxx0x-lambda-expressions.cpp
  test/SemaCXX/new-delete-0x.cpp

Index: test/SemaCXX/new-delete-0x.cpp
===
--- test/SemaCXX/new-delete-0x.cpp
+++ test/SemaCXX/new-delete-0x.cpp
@@ -34,6 +34,7 @@
 void bad_deletes()
 {
   // 'delete []' is always array delete, per [expr.delete]p1.
-  // FIXME: Give a better diagnostic.
-  delete []{ return (int*)0; }(); // expected-error {{expected expression}}
+  delete []{ return (int*)0; }(); // expected-error {{'[]' after delete interpreted as 'delete[]'}}
+  // expected-note@-1 {{add parentheses around the lambda}}
 }
+
Index: test/Parser/cxx0x-lambda-expressions.cpp
===
--- test/Parser/cxx0x-lambda-expressions.cpp
+++ test/Parser/cxx0x-lambda-expressions.cpp
@@ -53,7 +53,8 @@
   void delete_lambda(int *p) {
 delete [] p;
 delete [] (int*) { new int }; // ok, compound-literal, not lambda
-delete [] { return new int; } (); // expected-error{{expected expression}}
+delete [] { return new int; } (); // expected-error {{'[]' after delete interpreted as 'delete[]'}}
+// expected-note@-1 {{add parentheses around the lambda}}
 delete [&] { return new int; } (); // ok, lambda
   }
 
Index: lib/Parse/ParseExprCXX.cpp
===
--- lib/Parse/ParseExprCXX.cpp
+++ lib/Parse/ParseExprCXX.cpp
@@ -2903,15 +2903,47 @@
 //   [Footnote: A lambda expression with a lambda-introducer that consists
 //  of empty square brackets can follow the delete keyword if
 //  the lambda expression is enclosed in parentheses.]
-// FIXME: Produce a better diagnostic if the '[]' is unambiguously a
-//lambda-introducer.
-ArrayDelete = true;
-BalancedDelimiterTracker T(*this, tok::l_square);
 
-T.consumeOpen();
-T.consumeClose();
-if (T.getCloseLocation().isInvalid())
-  return ExprError();
+const Token Next = GetLookAheadToken(2);
+const Token After = GetLookAheadToken(3);
+const Token Last = GetLookAheadToken(4);
+
+// Basic lookahead to check if we have a lambda expression.
+if (Next.isOneOf(tok::l_brace, tok::less) ||
+(Next.is(tok::l_paren) && (
+  After.is(tok::r_paren) || (After.is(tok::identifier) &&
+Last.is(tok::identifier))
+))) {
+  // Warn if the non-capturing lambda isn't surrounded by parenthesis
+  // to disambiguate it from 'delete[]'.
+  ExprResult Lambda = TryParseLambdaExpression();
+  if (!Lambda.isInvalid()) {
+SourceLocation StartLoc = Lambda.get()->getLocStart();
+Diag(Start, diag::err_lambda_after_delete)
+<< SourceRange(Start, StartLoc.getLocWithOffset(1));
+
+SourceLocation BeforeBracket = StartLoc.getLocWithOffset(-1);
+Diag(BeforeBracket, diag::note_lambda_after_delete)
+<< FixItHint::CreateInsertion(BeforeBracket, "(")
+<< FixItHint::CreateInsertion(
+   Lambda.get()->getLocEnd().getLocWithOffset(1), ")");
+
+// Evaluate any postfix expressions used on the lambda.
+Lambda = ParsePostfixExpressionSuffix(Lambda);
+return Actions.ActOnCXXDelete(Start, UseGlobal, /*ArrayForm=*/false,
+  Lambda.get());
+  }
+  else
+return ExprError();
+} else {
+  ArrayDelete = true;
+  BalancedDelimiterTracker T(*this, tok::l_square);
+
+  T.consumeOpen();
+  T.consumeClose();
+  if (T.getCloseLocation().isInvalid())
+return ExprError();
+}
   }
 
   ExprResult Operand(ParseCastExpression(false));
Index: include/clang/Basic/DiagnosticParseKinds.td
===
--- include/clang/Basic/DiagnosticParseKinds.td
+++ include/clang/Basic/DiagnosticParseKinds.td
@@ -99,6 +99,10 @@
   InGroup, DefaultIgnore;
 def ext_alignof_expr : ExtWarn<
   "%0 applied to an expression is a GNU extension">, InGroup;
+def err_lambda_after_delete : Error<
+  "'[]' after delete interpreted as 'delete[]'">;
+def note_lambda_after_delete : Note<
+  "add parentheses around the lambda">;
 
 def warn_microsoft_dependent_exists : Warning<
   "dependent %select{__if_not_exists|__if_exists}0 declarations are ignored">, 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36357: Added a better diagnostic when using the delete operator with lambdas

2018-03-14 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete added a comment.

@rsmith Which type specifiers should I test for? just `T`? Or also `T*`, `T&`, 
...? Now I'm just checking for an identifier, but anything else would make the 
lookahead more complicated I think. Any ideas?


https://reviews.llvm.org/D36357



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


[PATCH] D44408: Move DraftMgr from ClangdServer to ClangdLSPServer

2018-03-14 Thread Simon Marchi via Phabricator via cfe-commits
simark added a comment.

In https://reviews.llvm.org/D44408#1036846, @ilya-biryukov wrote:

> We shouldn't add `Contents` parameter to every method, it would defeat the 
> purpose of caching ASTs and won't allow to properly manage lifetimes of the 
> indexes.


Makes sense.

> The most tricky part is getting rid of `DraftMgr` in `forceReparse`. Here's a 
> change that removes usages of it there: https://reviews.llvm.org/D44462`, it 
> should be much easier to make it work when it lands.

I'll take a look, thanks!

> Any other reason why we need to add them?

No, just ignorance on my part.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44408



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


[PATCH] D37442: [C++17] Disallow lambdas in template parameters (PR33696).

2018-03-14 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete updated this revision to Diff 138337.
Rakete added a comment.

Rebase and ping :)


https://reviews.llvm.org/D37442

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseStmt.cpp
  lib/Parse/ParseTemplate.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/TreeTransform.h
  test/CXX/expr/expr.prim/expr.prim.lambda/p2-template-parameter.cpp

Index: test/CXX/expr/expr.prim/expr.prim.lambda/p2-template-parameter.cpp
===
--- test/CXX/expr/expr.prim/expr.prim.lambda/p2-template-parameter.cpp
+++ test/CXX/expr/expr.prim/expr.prim.lambda/p2-template-parameter.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -std=c++17 %s -verify
+
+template struct Nothing {};
+
+void pr33696() {
+Nothing<[]() { return 0; }()> nothing; // expected-error{{a lambda expression cannot appear in this context}}
+}
+
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -5495,7 +5495,7 @@
   // decltype expressions are not potentially evaluated contexts
   EnterExpressionEvaluationContext Unevaluated(
   SemaRef, Sema::ExpressionEvaluationContext::Unevaluated, nullptr,
-  /*IsDecltype=*/true);
+  Sema::ExpressionEvaluationContextRecord::EK_Decltype);
 
   ExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr());
   if (E.isInvalid())
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -6226,7 +6226,8 @@
   if (RD->isInvalidDecl() || RD->isDependentContext())
 return E;
 
-  bool IsDecltype = ExprEvalContexts.back().IsDecltype;
+  bool IsDecltype = ExprEvalContexts.back().ExprContext ==
+ExpressionEvaluationContextRecord::EK_Decltype;
   CXXDestructorDecl *Destructor = IsDecltype ? nullptr : LookupDestructor(RD);
 
   if (Destructor) {
@@ -6308,7 +6309,9 @@
 /// are omitted for the 'topmost' call in the decltype expression. If the
 /// topmost call bound a temporary, strip that temporary off the expression.
 ExprResult Sema::ActOnDecltypeExpression(Expr *E) {
-  assert(ExprEvalContexts.back().IsDecltype && "not in a decltype expression");
+  assert(ExprEvalContexts.back().ExprContext ==
+ ExpressionEvaluationContextRecord::EK_Decltype &&
+ "not in a decltype expression");
 
   // C++11 [expr.call]p11:
   //   If a function call is a prvalue of object type,
@@ -6350,7 +6353,8 @@
 TopBind = nullptr;
 
   // Disable the special decltype handling now.
-  ExprEvalContexts.back().IsDecltype = false;
+  ExprEvalContexts.back().ExprContext =
+  ExpressionEvaluationContextRecord::EK_Other;
 
   // In MS mode, don't perform any extra checking of call return types within a
   // decltype expression.
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -13757,53 +13757,53 @@
 }
 
 void
-Sema::PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext,
-  Decl *LambdaContextDecl,
-  bool IsDecltype) {
+Sema::PushExpressionEvaluationContext(
+ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl,
+ExpressionEvaluationContextRecord::ExpressionKind ExprContext) {
   ExprEvalContexts.emplace_back(NewContext, ExprCleanupObjects.size(), Cleanup,
-LambdaContextDecl, IsDecltype);
+LambdaContextDecl, ExprContext);
   Cleanup.reset();
   if (!MaybeODRUseExprs.empty())
 std::swap(MaybeODRUseExprs, ExprEvalContexts.back().SavedMaybeODRUseExprs);
 }
 
 void
-Sema::PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext,
-  ReuseLambdaContextDecl_t,
-  bool IsDecltype) {
+Sema::PushExpressionEvaluationContext(
+ExpressionEvaluationContext NewContext, ReuseLambdaContextDecl_t,
+ExpressionEvaluationContextRecord::ExpressionKind ExprContext) {
   Decl *ClosureContextDecl = ExprEvalContexts.back().ManglingContextDecl;
-  PushExpressionEvaluationContext(NewContext, ClosureContextDecl, IsDecltype);
+  PushExpressionEvaluationContext(NewContext, ClosureContextDecl, ExprContext);
 }
 
 void Sema::PopExpressionEvaluationContext() {
   ExpressionEvaluationContextRecord& Rec = ExprEvalContexts.back();
   unsigned NumTypos = Rec.NumTypos;
 
   if (!Rec.Lambdas.empty()) {
-if (Rec.isUnevaluated() || Rec.isConstantEvaluated()) {
+using ExpressionKind = ExpressionEvaluationContextRecord::ExpressionKind;
+if (Rec.ExprContext == ExpressionKind::EK_TemplateParameter || Rec.isUnevaluated() ||
+(Rec.isConstantEvaluated() 

[PATCH] D43341: [clang-doc] Implement reducer portion of the frontend framework

2018-03-14 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Once the base differential firmly lands, could you please rebase this so the 
review could continue?


https://reviews.llvm.org/D43341



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


r327504 - [Sema] Pop function scope when instantiating a func with skipped body

2018-03-14 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Mar 14 06:18:30 2018
New Revision: 327504

URL: http://llvm.org/viewvc/llvm-project?rev=327504&view=rev
Log:
[Sema] Pop function scope when instantiating a func with skipped body

Summary:
By calling ActOnFinishFunctionBody(). Previously we were only calling
ActOnSkippedFunctionBody, which didn't pop the function scope.
This causes a crash when running on our internal code. No test-case,
though, since I couldn't come up with a small example in reasonable
time.

The bug was introduced in r321174.

Reviewers: bkramer, sammccall, sepavloff, aaron.ballman

Reviewed By: sammccall, aaron.ballman

Subscribers: aaron.ballman, cfe-commits

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

Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=327504&r1=327503&r2=327504&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Wed Mar 14 06:18:30 2018
@@ -3937,8 +3937,10 @@ void Sema::InstantiateFunctionDefinition
  TemplateArgs))
   return;
 
+StmtResult Body;
 if (PatternDecl->hasSkippedBody()) {
   ActOnSkippedFunctionBody(Function);
+  Body = nullptr;
 } else {
   if (CXXConstructorDecl *Ctor = dyn_cast(Function)) {
 // If this is a constructor, instantiate the member initializers.
@@ -3954,16 +3956,14 @@ void Sema::InstantiateFunctionDefinition
   }
 
   // Instantiate the function body.
-  StmtResult Body = SubstStmt(Pattern, TemplateArgs);
+  Body = SubstStmt(Pattern, TemplateArgs);
 
   if (Body.isInvalid())
 Function->setInvalidDecl();
-
-  // FIXME: finishing the function body while in an expression evaluation
-  // context seems wrong. Investigate more.
-  ActOnFinishFunctionBody(Function, Body.get(),
-  /*IsInstantiation=*/true);
 }
+// FIXME: finishing the function body while in an expression evaluation
+// context seems wrong. Investigate more.
+ActOnFinishFunctionBody(Function, Body.get(), /*IsInstantiation=*/true);
 
 PerformDependentDiagnostics(PatternDecl, TemplateArgs);
 


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


[PATCH] D44439: [Sema] Pop function scope when instantiating a func with skipped body

2018-03-14 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC327504: [Sema] Pop function scope when instantiating a func 
with skipped body (authored by ibiryukov, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44439?vs=138333&id=138338#toc

Repository:
  rC Clang

https://reviews.llvm.org/D44439

Files:
  lib/Sema/SemaTemplateInstantiateDecl.cpp


Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3937,8 +3937,10 @@
  TemplateArgs))
   return;
 
+StmtResult Body;
 if (PatternDecl->hasSkippedBody()) {
   ActOnSkippedFunctionBody(Function);
+  Body = nullptr;
 } else {
   if (CXXConstructorDecl *Ctor = dyn_cast(Function)) {
 // If this is a constructor, instantiate the member initializers.
@@ -3954,16 +3956,14 @@
   }
 
   // Instantiate the function body.
-  StmtResult Body = SubstStmt(Pattern, TemplateArgs);
+  Body = SubstStmt(Pattern, TemplateArgs);
 
   if (Body.isInvalid())
 Function->setInvalidDecl();
-
-  // FIXME: finishing the function body while in an expression evaluation
-  // context seems wrong. Investigate more.
-  ActOnFinishFunctionBody(Function, Body.get(),
-  /*IsInstantiation=*/true);
 }
+// FIXME: finishing the function body while in an expression evaluation
+// context seems wrong. Investigate more.
+ActOnFinishFunctionBody(Function, Body.get(), /*IsInstantiation=*/true);
 
 PerformDependentDiagnostics(PatternDecl, TemplateArgs);
 


Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3937,8 +3937,10 @@
  TemplateArgs))
   return;
 
+StmtResult Body;
 if (PatternDecl->hasSkippedBody()) {
   ActOnSkippedFunctionBody(Function);
+  Body = nullptr;
 } else {
   if (CXXConstructorDecl *Ctor = dyn_cast(Function)) {
 // If this is a constructor, instantiate the member initializers.
@@ -3954,16 +3956,14 @@
   }
 
   // Instantiate the function body.
-  StmtResult Body = SubstStmt(Pattern, TemplateArgs);
+  Body = SubstStmt(Pattern, TemplateArgs);
 
   if (Body.isInvalid())
 Function->setInvalidDecl();
-
-  // FIXME: finishing the function body while in an expression evaluation
-  // context seems wrong. Investigate more.
-  ActOnFinishFunctionBody(Function, Body.get(),
-  /*IsInstantiation=*/true);
 }
+// FIXME: finishing the function body while in an expression evaluation
+// context seems wrong. Investigate more.
+ActOnFinishFunctionBody(Function, Body.get(), /*IsInstantiation=*/true);
 
 PerformDependentDiagnostics(PatternDecl, TemplateArgs);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44188: Misc typos

2018-03-14 Thread luzpaz via Phabricator via cfe-commits
luzpaz added a comment.

Please advise how to proceed


Repository:
  rC Clang

https://reviews.llvm.org/D44188



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


[PATCH] D40445: [C++17] Allow an empty expression in an if init statement

2018-03-14 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete updated this revision to Diff 138339.
Rakete added a comment.

Rebase and ping :)


https://reviews.llvm.org/D40445

Files:
  lib/Parse/ParseExprCXX.cpp
  test/CXX/stmt.stmt/stmt.select/p3.cpp

Index: test/CXX/stmt.stmt/stmt.select/p3.cpp
===
--- test/CXX/stmt.stmt/stmt.select/p3.cpp
+++ test/CXX/stmt.stmt/stmt.select/p3.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++1z -Wc++14-compat -verify %s -DCPP17
 
 int f();
 
@@ -10,10 +11,67 @@
   }
 }
 
-
 void h() {
   if (int x = f()) // expected-note 2{{previous definition}}
 int x; // expected-error{{redefinition of 'x'}}
   else
 int x; // expected-error{{redefinition of 'x'}}
 }
+
+void ifInitStatement() {
+  int Var = 0;
+
+  if (int I = 0; true) {}
+  if (Var + Var; true) {}
+  if (; true) {}
+#ifdef CPP17
+  // expected-warning@-4 {{if initialization statements are incompatible with C++ standards before C++17}}
+  // expected-warning@-4 {{if initialization statements are incompatible with C++ standards before C++17}}
+  // expected-warning@-4 {{if initialization statements are incompatible with C++ standards before C++17}}
+#else
+  // expected-warning@-8 {{'if' initialization statements are a C++17 extension}}
+  // expected-warning@-8 {{'if' initialization statements are a C++17 extension}}
+  // expected-warning@-8 {{'if' initialization statements are a C++17 extension}}
+#endif
+}
+
+void switchInitStatement() {
+  int Var = 0;
+
+  switch (int I = 0; Var) {}
+  switch (Var + Var; Var) {}
+  switch (; Var) {}
+#ifdef CPP17
+  // expected-warning@-4 {{switch initialization statements are incompatible with C++ standards before C++17}}
+  // expected-warning@-4 {{switch initialization statements are incompatible with C++ standards before C++17}}
+  // expected-warning@-4 {{switch initialization statements are incompatible with C++ standards before C++17}}
+#else
+  // expected-warning@-8 {{'switch' initialization statements are a C++17 extension}}
+  // expected-warning@-8 {{'switch' initialization statements are a C++17 extension}}
+  // expected-warning@-8 {{'switch' initialization statements are a C++17 extension}}
+#endif
+}
+
+// TODO: Better diagnostics for while init statements.
+void whileInitStatement() {
+  while (int I = 10; I--); // expected-error {{expected ')'}}
+  // expected-note@-1 {{to match this '('}}
+  // expected-error@-2 {{use of undeclared identifier 'I'}}
+
+  int Var = 10;
+  while (Var + Var; Var--) {} // expected-error {{expected ')'}}
+  // expected-note@-1 {{to match this '('}}
+  // expected-error@-2 {{expected ';' after expression}}
+  // expected-error@-3 {{expected expression}}
+  // expected-warning@-4 {{while loop has empty body}}
+  // expected-note@-5 {{put the semicolon on a separate line to silence this warning}}
+}
+
+// TODO: This is needed because clang can't seem to diagnose invalid syntax after the
+// last loop above. It would be nice to remove this.
+void whileInitStatement2() {
+  while (; false) {} // expected-error {{expected expression}}
+  // expected-warning@-1 {{expression result unused}}
+  // expected-error@-2 {{expected ';' after expression}}
+  // expected-error@-3 {{expected expression}}
+}
Index: lib/Parse/ParseExprCXX.cpp
===
--- lib/Parse/ParseExprCXX.cpp
+++ lib/Parse/ParseExprCXX.cpp
@@ -1744,17 +1744,34 @@
   ParsedAttributesWithRange attrs(AttrFactory);
   MaybeParseCXX11Attributes(attrs);
 
+  const auto WarnOnInit = [this, &CK] {
+Diag(Tok.getLocation(), getLangOpts().CPlusPlus17
+? diag::warn_cxx14_compat_init_statement
+: diag::ext_init_statement)
+<< (CK == Sema::ConditionKind::Switch);
+  };
+
   // Determine what kind of thing we have.
   switch (isCXXConditionDeclarationOrInitStatement(InitStmt)) {
   case ConditionOrInitStatement::Expression: {
 ProhibitAttributes(attrs);
 
+// We can have an empty expression here.
+//   if (; true);
+if (InitStmt && Tok.is(tok::semi)) {
+  WarnOnInit();
+  SourceLocation SemiLoc = ConsumeToken();
+  *InitStmt = Actions.ActOnNullStmt(SemiLoc);
+  return ParseCXXCondition(nullptr, Loc, CK);
+}
+
 // Parse the expression.
 ExprResult Expr = ParseExpression(); // expression
 if (Expr.isInvalid())
   return Sema::ConditionError();
 
 if (InitStmt && Tok.is(tok::semi)) {
+  WarnOnInit();
   *InitStmt = Actions.ActOnExprStmt(Expr.get());
   ConsumeToken();
   return ParseCXXCondition(nullptr, Loc, CK);
@@ -1764,10 +1781,7 @@
   }
 
   case ConditionOrInitStatement::InitStmtDecl: {
-Diag(Tok.getLocation(), getLangOpts().CPlusPlus17
-? diag::warn_cxx14_compat_init_statement
-: diag::ext_init_statement)
-<< (CK == Sema::Conditio

[PATCH] D38171: [clang-tidy] Implement clang-tidy check aliases

2018-03-14 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

I apologize for completely ignoring this for a long time.

I'm totally fine taking full control of clang-diagnostic- "checks", i.e. 
automatically adding corresponding -W flags and removing all other -W flags (or 
prepending -Wno-everything).

However, could we split the aliases stuff to a separate patch? My concerns 
w.r.t. the current implementation:

1. it doesn't allow more than one alias to each diagnostic
2. it's not clear that clang diagnostic aliases need to be separate from 
aliases for native clang-tidy checks. It might be better to add a more 
high-level API to register aliases (e.g. `registerCheckAlias(, 
, )`).




Comment at: clang-tidy/ClangTidy.cpp:406
+  for (const auto &Diag : Context.getEnabledClangDiagnostics())
+CheckNames.push_back("clang-diagnostic-" + Diag);
+

The "clang-diagnostic-" string is now repeated multiple times. Could you pull 
it out to a constant (or maybe `llvm::StringRef getClangDiagnosticPrefix()`)?



Comment at: clang-tidy/ClangTidyModule.h:96
+  virtual void addWarningCheckAliases(
+  llvm::DenseMap &WarningCheckAliases) {}
+

Consider using `llvm::StringMap`.


https://reviews.llvm.org/D38171



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


[PATCH] D38171: [clang-tidy] Implement clang-tidy check aliases

2018-03-14 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D38171#1036893, @alexfh wrote:

> I'm totally fine taking full control of clang-diagnostic- "checks", i.e. 
> automatically adding corresponding -W flags and removing all other -W flags 
> (or prepending -Wno-everything).
>
> However, could we split the aliases stuff to a separate patch?


The other way round. It will be better to split the clang-diagnostic part to a 
separate patch, since this patch focuses on the aliases.


https://reviews.llvm.org/D38171



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


[PATCH] D38171: [clang-tidy] Implement clang-tidy check aliases

2018-03-14 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: test/clang-tidy/misc-suspicious-semicolon-fail.cpp:5
-// RUN: clang-tidy %s -checks="-*,misc-suspicious-semicolon,clang-diagnostic*" 
\
-// RUN:-- -DWERROR -Wno-everything -Werror=unused-variable 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=CHECK-WERROR \

This reminds me that we should also filter out all -W(no-)error.* compiler 
arguments, if we're to take full control of clang diagnostics and make them 
behave closer to native checks.



Comment at: test/clang-tidy/validate-check-names.cpp:2
 // Check names may only contain alphanumeric characters, '-', '_', and '.'.
-// RUN: clang-tidy -checks=* -list-checks | grep '^' | cut -b5- | not grep 
-v '^[a-zA-Z0-9_.\-]\+$'
+// RUN: clang-tidy -checks=*,-clang-diagnostic* -list-checks | grep '^' | 
cut -b5- | not grep -v '^[a-zA-Z0-9_.\-]\+$'

Which clang diagnostic names fail this test?


https://reviews.llvm.org/D38171



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


[PATCH] D40445: [C++17] Allow an empty expression in an if init statement

2018-03-14 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM


https://reviews.llvm.org/D40445



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


[PATCH] D44463: [clangd] Don't expose vfs in TUScheduler::runWithPreamble.

2018-03-14 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: clangd/TUScheduler.h:94
 
   /// Schedule an async read of the Preamble. Preamble passed to \p Action may
   /// be built for any version of the file, callers must not rely on it being

I think this is the right place to describe the way FS interaction works (which 
implies why we don't propagate vfs):

```
/// The preamble may be stale, generated from an older version of the file.
/// Reading from locations in the preamble may cause the files to be re-read.
/// This gives callers two options:
/// - validate that the preamble is still valid, and only use it in this case
/// - accept that preamble contents may be outdated, and try to avoid reading 
source code from headers.
```


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44463



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


[PATCH] D43162: [Parser] (C++) Make -Wextra-semi slightly more useful

2018-03-14 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Let's move weekly ping away from friday :)
Ping.


Repository:
  rC Clang

https://reviews.llvm.org/D43162



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


[PATCH] D44462: [clangd] Don't use DraftMgr in implementation of forceReparse.

2018-03-14 Thread Simon Marchi via Phabricator via cfe-commits
simark accepted this revision.
simark added a comment.
This revision is now accepted and ready to land.

I rebased my patch (https://reviews.llvm.org/D44408) on top of this one, it 
looks good.




Comment at: clangd/ClangdServer.cpp:143
+  tooling::CompileCommand NewCommand = CompileArgs.getCompileCommand(File);
+  DocVersion Version = DraftMgr.getVersion(File);
+  Path FileStr = File.str();

I was wondering if we should increment the version here.  From what I 
understand, it is used to identify each version of the parse, so that when 
diagnostics are ready, we know if they are for the latest version (and should 
be sent to the user) or if they are stale and should be ignored.  If we don't 
change the document content but change the compile commands, I would consider 
it as a new version, since the diagnostics coming from the same document but 
old compile commands should be considered stale.



Comment at: clangd/TUScheduler.h:62
 
+  /// Returns a list of currently tracked files. File starts being trakced on
+  /// first update() call to it and stops being tracked on remove() call.

"trakced"


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44462



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


[PATCH] D44408: Move DraftMgr from ClangdServer to ClangdLSPServer

2018-03-14 Thread Simon Marchi via Phabricator via cfe-commits
simark updated this revision to Diff 138344.
simark added a comment.

Rebase on https://reviews.llvm.org/D44462


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44408

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/DraftStore.cpp
  clangd/DraftStore.h
  unittests/clangd/ClangdTests.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/SyncAPI.cpp
  unittests/clangd/SyncAPI.h

Index: unittests/clangd/SyncAPI.h
===
--- unittests/clangd/SyncAPI.h
+++ unittests/clangd/SyncAPI.h
@@ -22,11 +22,13 @@
 void runAddDocument(ClangdServer &Server, PathRef File, StringRef Contents);
 
 llvm::Expected
-runCodeComplete(ClangdServer &Server, PathRef File, Position Pos,
-clangd::CodeCompleteOptions Opts);
+runCodeComplete(ClangdServer &Server, PathRef File, std::string Contents,
+Position Pos, clangd::CodeCompleteOptions Opts);
 
 llvm::Expected runSignatureHelp(ClangdServer &Server,
-   PathRef File, Position Pos);
+   PathRef File,
+   std::string Contents,
+   Position Pos);
 
 llvm::Expected>
 runFindDefinitions(ClangdServer &Server, PathRef File, Position Pos);
Index: unittests/clangd/SyncAPI.cpp
===
--- unittests/clangd/SyncAPI.cpp
+++ unittests/clangd/SyncAPI.cpp
@@ -68,17 +68,19 @@
 } // namespace
 
 llvm::Expected
-runCodeComplete(ClangdServer &Server, PathRef File, Position Pos,
-clangd::CodeCompleteOptions Opts) {
+runCodeComplete(ClangdServer &Server, PathRef File, std::string Contents,
+Position Pos, clangd::CodeCompleteOptions Opts) {
   llvm::Optional> Result;
-  Server.codeComplete(File, Pos, Opts, capture(Result));
+  Server.codeComplete(File, std::move(Contents), Pos, Opts, capture(Result));
   return std::move(*Result);
 }
 
 llvm::Expected runSignatureHelp(ClangdServer &Server,
-   PathRef File, Position Pos) {
+   PathRef File,
+   std::string Contents,
+   Position Pos) {
   llvm::Optional> Result;
-  Server.signatureHelp(File, Pos, capture(Result));
+  Server.signatureHelp(File, std::move(Contents), Pos, capture(Result));
   return std::move(*Result);
 }
 
Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -122,7 +122,7 @@
   Annotations Test(Text);
   runAddDocument(Server, File, Test.code());
   auto CompletionList =
-  cantFail(runCodeComplete(Server, File, Test.point(), Opts));
+  cantFail(runCodeComplete(Server, File, Test.code(), Test.point(), Opts));
   // Sanity-check that filterText is valid.
   EXPECT_THAT(CompletionList.items, Each(NameContainsFilter()));
   return CompletionList;
@@ -537,16 +537,17 @@
 
   auto I = memIndex({var("ns::index")});
   Opts.Index = I.get();
-  auto WithIndex = cantFail(runCodeComplete(Server, File, Test.point(), Opts));
+  auto WithIndex =
+  cantFail(runCodeComplete(Server, File, Test.code(), Test.point(), Opts));
   EXPECT_THAT(WithIndex.items,
   UnorderedElementsAre(Named("local"), Named("index")));
-  auto ClassFromPreamble =
-  cantFail(runCodeComplete(Server, File, Test.point("2"), Opts));
+  auto ClassFromPreamble = cantFail(
+  runCodeComplete(Server, File, Test.code(), Test.point("2"), Opts));
   EXPECT_THAT(ClassFromPreamble.items, Contains(Named("member")));
 
   Opts.Index = nullptr;
   auto WithoutIndex =
-  cantFail(runCodeComplete(Server, File, Test.point(), Opts));
+  cantFail(runCodeComplete(Server, File, Test.code(), Test.point(), Opts));
   EXPECT_THAT(WithoutIndex.items,
   UnorderedElementsAre(Named("local"), Named("preamble")));
 }
@@ -577,7 +578,8 @@
   )cpp");
   runAddDocument(Server, File, Test.code());
 
-  auto Results = cantFail(runCodeComplete(Server, File, Test.point(), {}));
+  auto Results =
+  cantFail(runCodeComplete(Server, File, Test.code(), Test.point(), {}));
   // "XYZ" and "foo" are not included in the file being completed but are still
   // visible through the index.
   EXPECT_THAT(Results.items, Has("XYZ", CompletionItemKind::Class));
@@ -616,7 +618,7 @@
   auto File = testPath("foo.cpp");
   Annotations Test(Text);
   runAddDocument(Server, File, Test.code());
-  return cantFail(runSignatureHelp(Server, File, Test.point()));
+  return cantFail(runSignatureHelp(Server, File, Test.code(), Test.point()));
 }
 
 MATCHER_P(ParamsAre, P, "") {
Index: unittests/clangd/ClangdTests.cpp

[PATCH] D44408: Move DraftMgr from ClangdServer to ClangdLSPServer

2018-03-14 Thread Simon Marchi via Phabricator via cfe-commits
simark added a comment.

I don't see how to avoid adding the Contents parameter to the codeComplete and 
signatureHelp methods, since they needed to fetch the document from the draft 
manager and pass it to the backend.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44408



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


r327513 - [OpenMP] Add OpenMP data sharing infrastructure using global memory

2018-03-14 Thread Gheorghe-Teodor Bercea via cfe-commits
Author: gbercea
Date: Wed Mar 14 07:17:45 2018
New Revision: 327513

URL: http://llvm.org/viewvc/llvm-project?rev=327513&view=rev
Log:
[OpenMP] Add OpenMP data sharing infrastructure using global memory

Summary:
This patch handles the Clang code generation phase for the OpenMP data sharing 
infrastructure.

TODO: add a more detailed description.

Reviewers: ABataev, carlo.bertolli, caomhin, hfinkel, Hahnfeld

Reviewed By: ABataev

Subscribers: jholewinski, guansong, cfe-commits

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

Added:
cfe/trunk/test/OpenMP/nvptx_data_sharing.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=327513&r1=327512&r2=327513&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Mar 14 07:17:45 2018
@@ -1068,9 +1068,17 @@ CodeGenFunction::EmitAutoVarAlloca(const
 }
 
 // A normal fixed sized variable becomes an alloca in the entry block,
-// unless it's an NRVO variable.
-
-if (NRVO) {
+// unless:
+// - it's an NRVO variable.
+// - we are compiling OpenMP and it's an OpenMP local variable.
+
+Address OpenMPLocalAddr =
+getLangOpts().OpenMP
+? CGM.getOpenMPRuntime().getAddressOfLocalVariable(*this, &D)
+: Address::invalid();
+if (getLangOpts().OpenMP && OpenMPLocalAddr.isValid()) {
+  address = OpenMPLocalAddr;
+} else if (NRVO) {
   // The named return value optimization: allocate this variable in the
   // return slot, so that we can elide the copy when returning this
   // variable (C++0x [class.copy]p34).
@@ -1896,9 +1904,18 @@ void CodeGenFunction::EmitParmDecl(const
   }
 }
   } else {
-// Otherwise, create a temporary to hold the value.
-DeclPtr = CreateMemTemp(Ty, getContext().getDeclAlign(&D),
-D.getName() + ".addr");
+// Check if the parameter address is controlled by OpenMP runtime.
+Address OpenMPLocalAddr =
+getLangOpts().OpenMP
+? CGM.getOpenMPRuntime().getAddressOfLocalVariable(*this, &D)
+: Address::invalid();
+if (getLangOpts().OpenMP && OpenMPLocalAddr.isValid()) {
+  DeclPtr = OpenMPLocalAddr;
+} else {
+  // Otherwise, create a temporary to hold the value.
+  DeclPtr = CreateMemTemp(Ty, getContext().getDeclAlign(&D),
+  D.getName() + ".addr");
+}
 DoStore = true;
   }
 

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=327513&r1=327512&r2=327513&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed Mar 14 07:17:45 2018
@@ -8100,6 +8100,11 @@ Address CGOpenMPRuntime::getParameterAdd
   return CGF.GetAddrOfLocalVar(NativeParam);
 }
 
+Address CGOpenMPRuntime::getAddressOfLocalVariable(CodeGenFunction &CGF,
+   const VarDecl *VD) {
+  return Address::invalid();
+}
+
 llvm::Value *CGOpenMPSIMDRuntime::emitParallelOutlinedFunction(
 const OMPExecutableDirective &D, const VarDecl *ThreadIDVar,
 OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen) {

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=327513&r1=327512&r2=327513&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Wed Mar 14 07:17:45 2018
@@ -676,7 +676,7 @@ public:
 
   /// \brief Cleans up references to the objects in finished function.
   ///
-  void functionFinished(CodeGenFunction &CGF);
+  virtual void functionFinished(CodeGenFunction &CGF);
 
   /// \brief Emits code for parallel or serial call of the \a OutlinedFn with
   /// variables captured in a record which address is stored in \a
@@ -1362,6 +1362,14 @@ public:
   emitOutlinedFunctionCall(CodeGenFunction &CGF, SourceLocation Loc,
llvm::Value *OutlinedFn,
ArrayRef Args = llvm::None) const;
+
+  /// Emits OpenMP-specific function prolog.
+  /// Required for device constructs.
+  virtual void emitFunctionProlog(CodeGenFunction &CGF, const Decl *D) {}
+
+  /// Gets the OpenMP

[PATCH] D43660: [OpenMP] Add OpenMP data sharing infrastructure using global memory

2018-03-14 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL327513: [OpenMP] Add OpenMP data sharing infrastructure 
using global memory (authored by gbercea, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43660?vs=137600&id=138351#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43660

Files:
  cfe/trunk/lib/CodeGen/CGDecl.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
  cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/test/OpenMP/nvptx_data_sharing.cpp
  cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp

Index: cfe/trunk/test/OpenMP/nvptx_data_sharing.cpp
===
--- cfe/trunk/test/OpenMP/nvptx_data_sharing.cpp
+++ cfe/trunk/test/OpenMP/nvptx_data_sharing.cpp
@@ -0,0 +1,91 @@
+// Test device global memory data sharing codegen.
+///==///
+
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CK1
+
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+void test_ds(){
+  #pragma omp target
+  {
+int a = 10;
+#pragma omp parallel
+{
+  a = 1000;
+}
+int b = 100;
+#pragma omp parallel
+{
+  b = a + 1;
+}
+  }
+}
+
+/// = In the kernel function = ///
+
+// CK1: {{.*}}define void @__omp_offloading{{.*}}test_ds{{.*}}()
+// CK1: [[SHAREDARGS1:%.+]] = alloca i8**
+// CK1: [[SHAREDARGS2:%.+]] = alloca i8**
+// CK1: call void @__kmpc_kernel_init
+// CK1: call void @__kmpc_data_sharing_init_stack
+// CK1: [[GLOBALSTACK:%.+]] = call i8* @__kmpc_data_sharing_push_stack(i64 8, i16 0)
+// CK1: [[GLOBALSTACK2:%.+]] = bitcast i8* [[GLOBALSTACK]] to %struct._globalized_locals_ty*
+// CK1: [[A:%.+]] = getelementptr inbounds %struct._globalized_locals_ty, %struct._globalized_locals_ty* [[GLOBALSTACK2]], i32 0, i32 0
+// CK1: [[B:%.+]] = getelementptr inbounds %struct._globalized_locals_ty, %struct._globalized_locals_ty* [[GLOBALSTACK2]], i32 0, i32 1
+// CK1: store i32 10, i32* [[A]]
+// CK1: call void @__kmpc_kernel_prepare_parallel({{.*}}, i16 1)
+// CK1: call void @__kmpc_begin_sharing_variables(i8*** [[SHAREDARGS1]], i64 1)
+// CK1: [[SHARGSTMP1:%.+]] = load i8**, i8*** [[SHAREDARGS1]]
+// CK1: [[SHARGSTMP2:%.+]] = getelementptr inbounds i8*, i8** [[SHARGSTMP1]], i64 0
+// CK1: [[SHAREDVAR:%.+]] = bitcast i32* [[A]] to i8*
+// CK1: store i8* [[SHAREDVAR]], i8** [[SHARGSTMP2]]
+// CK1: call void @llvm.nvvm.barrier0()
+// CK1: call void @llvm.nvvm.barrier0()
+// CK1: call void @__kmpc_end_sharing_variables()
+// CK1: store i32 100, i32* [[B]]
+// CK1: call void @__kmpc_kernel_prepare_parallel({{.*}}, i16 1)
+// CK1: call void @__kmpc_begin_sharing_variables(i8*** [[SHAREDARGS2]], i64 2)
+// CK1: [[SHARGSTMP3:%.+]] = load i8**, i8*** [[SHAREDARGS2]]
+// CK1: [[SHARGSTMP4:%.+]] = getelementptr inbounds i8*, i8** [[SHARGSTMP3]], i64 0
+// CK1: [[SHAREDVAR1:%.+]] = bitcast i32* [[B]] to i8*
+// CK1: store i8* [[SHAREDVAR1]], i8** [[SHARGSTMP4]]
+// CK1: [[SHARGSTMP12:%.+]] = getelementptr inbounds i8*, i8** [[SHARGSTMP3]], i64 1
+// CK1: [[SHAREDVAR2:%.+]] = bitcast i32* [[A]] to i8*
+// CK1: store i8* [[SHAREDVAR2]], i8** [[SHARGSTMP12]]
+// CK1: call void @llvm.nvvm.barrier0()
+// CK1: call void @llvm.nvvm.barrier0()
+// CK1: call void @__kmpc_end_sharing_variables()
+// CK1: call void @__kmpc_data_sharing_pop_stack(i8* [[GLOBALSTACK]])
+// CK1: call void @__kmpc_kernel_deinit(i16 1)
+
+/// = In the data sharing wrapper function = ///
+
+// CK1: {{.*}}define internal void @__omp_outlined{{.*}}wrapper({{.*}})
+// CK1: [[SHAREDARGS4:%.+]] = alloca i8**
+// CK1: call void @__kmpc_get_shared_variables(i8*** [[SHAREDARGS4]])
+// CK1: [[SHARGSTMP13:%.+]] = load i8**, i8*** [[SHAREDARGS4]]
+// CK1: [[SHARGSTMP14:%.+]] = getelementptr inbounds i8*, i8** [[SHARGSTMP13]], i64 0
+// CK1: [[SHARGSTMP15:%.+]] = bitcast i8** [[SHARGSTMP14]] to i32**
+// CK1: [[SHARGSTMP16:%.+]] = load i32*, i32** [[SHARGSTMP15]]
+// CK1: call void @__omp_outlined__{{.*}}({{.*}}, i32* [[SHARGSTMP16]])
+
+/// = In the data sharing wrapper function = ///
+
+// CK1: {{.*}}define internal void @__omp_outlined{{.*}}wrapper({{.*}})
+// CK1: [[SHAREDARGS3:%.+]] = alloca i8**
+// CK1: call void @__kmpc_get_shared_variables(i8*** [[SHAREDARGS3]])
+// CK1: [[SHARGSTMP5:%.+]] = load i8**, i8*** [[SHAREDARGS3]]
+// CK1: [[SHARGSTMP6:%.+]] = g

[PATCH] D43660: [OpenMP] Add OpenMP data sharing infrastructure using global memory

2018-03-14 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC327513: [OpenMP] Add OpenMP data sharing infrastructure 
using global memory (authored by gbercea, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D43660

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.cpp
  test/OpenMP/nvptx_data_sharing.cpp
  test/OpenMP/nvptx_parallel_codegen.cpp

Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -1068,9 +1068,17 @@
 }
 
 // A normal fixed sized variable becomes an alloca in the entry block,
-// unless it's an NRVO variable.
-
-if (NRVO) {
+// unless:
+// - it's an NRVO variable.
+// - we are compiling OpenMP and it's an OpenMP local variable.
+
+Address OpenMPLocalAddr =
+getLangOpts().OpenMP
+? CGM.getOpenMPRuntime().getAddressOfLocalVariable(*this, &D)
+: Address::invalid();
+if (getLangOpts().OpenMP && OpenMPLocalAddr.isValid()) {
+  address = OpenMPLocalAddr;
+} else if (NRVO) {
   // The named return value optimization: allocate this variable in the
   // return slot, so that we can elide the copy when returning this
   // variable (C++0x [class.copy]p34).
@@ -1896,9 +1904,18 @@
   }
 }
   } else {
-// Otherwise, create a temporary to hold the value.
-DeclPtr = CreateMemTemp(Ty, getContext().getDeclAlign(&D),
-D.getName() + ".addr");
+// Check if the parameter address is controlled by OpenMP runtime.
+Address OpenMPLocalAddr =
+getLangOpts().OpenMP
+? CGM.getOpenMPRuntime().getAddressOfLocalVariable(*this, &D)
+: Address::invalid();
+if (getLangOpts().OpenMP && OpenMPLocalAddr.isValid()) {
+  DeclPtr = OpenMPLocalAddr;
+} else {
+  // Otherwise, create a temporary to hold the value.
+  DeclPtr = CreateMemTemp(Ty, getContext().getDeclAlign(&D),
+  D.getName() + ".addr");
+}
 DoStore = true;
   }
 
Index: lib/CodeGen/CGOpenMPRuntime.h
===
--- lib/CodeGen/CGOpenMPRuntime.h
+++ lib/CodeGen/CGOpenMPRuntime.h
@@ -676,7 +676,7 @@
 
   /// \brief Cleans up references to the objects in finished function.
   ///
-  void functionFinished(CodeGenFunction &CGF);
+  virtual void functionFinished(CodeGenFunction &CGF);
 
   /// \brief Emits code for parallel or serial call of the \a OutlinedFn with
   /// variables captured in a record which address is stored in \a
@@ -1362,6 +1362,14 @@
   emitOutlinedFunctionCall(CodeGenFunction &CGF, SourceLocation Loc,
llvm::Value *OutlinedFn,
ArrayRef Args = llvm::None) const;
+
+  /// Emits OpenMP-specific function prolog.
+  /// Required for device constructs.
+  virtual void emitFunctionProlog(CodeGenFunction &CGF, const Decl *D) {}
+
+  /// Gets the OpenMP-specific address of the local variable.
+  virtual Address getAddressOfLocalVariable(CodeGenFunction &CGF,
+const VarDecl *VD);
 };
 
 /// Class supports emissionof SIMD-only code.
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.h
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.h
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.h
@@ -289,6 +289,14 @@
   CodeGenFunction &CGF, SourceLocation Loc, llvm::Value *OutlinedFn,
   ArrayRef Args = llvm::None) const override;
 
+  /// Emits OpenMP-specific function prolog.
+  /// Required for device constructs.
+  void emitFunctionProlog(CodeGenFunction &CGF, const Decl *D) override;
+
+  /// Gets the OpenMP-specific address of the local variable.
+  Address getAddressOfLocalVariable(CodeGenFunction &CGF,
+const VarDecl *VD) override;
+
   /// Target codegen is specialized based on two programming models: the
   /// 'generic' fork-join model of OpenMP, and a more GPU efficient 'spmd'
   /// model for constructs like 'target parallel' that support it.
@@ -300,12 +308,37 @@
 Unknown,
   };
 
+  /// Cleans up references to the objects in finished function.
+  ///
+  void functionFinished(CodeGenFunction &CGF) override;
+
 private:
   // Track the execution mode when codegening directives within a target
   // region. The appropriate mode (generic/spmd) is set on entry to the
   // target region and used by containing directives such as 'parallel'
   // to emit optimized code.
   ExecutionMode CurrentExecutionMode;
+
+  /// Map between an outlined function and its wrapper.
+  llvm::DenseMap WrapperFunctionsMap;
+
+  /// Emit function which wraps the outline parallel region
+  /// and c

[PATCH] D44462: [clangd] Don't use DraftMgr in implementation of forceReparse.

2018-03-14 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

This patch is the right direction, but if you're up for it we can simplify 
interfaces further I think.




Comment at: clangd/TUScheduler.h:62
 
+  /// Returns a list of currently tracked files. File starts being trakced on
+  /// first update() call to it and stops being tracked on remove() call.

simark wrote:
> "trakced"
tracked



Comment at: clangd/TUScheduler.h:69
+  /// FIXME: remove the callback from this function
+  void updateCompileCommand(PathRef File, tooling::CompileCommand NewCommand,
+IntrusiveRefCntPtr FS,

(summarizing offline discussion)

this is so close to `update`, it'd be nice if we could just call `update` 
instead.

For that we need the contents, so forceReparse needs contents, so... can 
forceReparse just be addDocument(skipCache=true) or something?

Requiring content to be passed doesn't seem like a big burden in practice, and 
makes it clear that clangdserver is never responsible for maintaining copies of 
the content on the callers behalf (and clangdlspserver is).

reparseOpenFiles needs to move to clangdlspserver, but this seems consistent 
with the design. (so I think we can drop getTrackedFiles?)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44462



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


[PATCH] D43162: [Parser] (C++) Make -Wextra-semi slightly more useful

2018-03-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM aside from a testing nit.




Comment at: test/SemaCXX/extra-semi.cpp:14
+void F(){}
+; // expected-warning {{extra ';' outside of a function is}}
+

Can you use the full diagnostic text for this first appearance in the test?


Repository:
  rC Clang

https://reviews.llvm.org/D43162



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


[PATCH] D31308: [clang-tidy] new check readability-no-alternative-tokens

2018-03-14 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.
Herald added a subscriber: xazax.hun.

As noted above, my concern with the current implementation is that the use of 
AST in this check seems to be superfluous. It should be enough to handle 
PPCallbacks and re-lex each file opened during compilation to find all 
alternative tokens.


https://reviews.llvm.org/D31308



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


[PATCH] D44462: [clangd] Don't use DraftMgr in implementation of forceReparse.

2018-03-14 Thread Simon Marchi via Phabricator via cfe-commits
simark added inline comments.



Comment at: clangd/TUScheduler.h:69
+  /// FIXME: remove the callback from this function
+  void updateCompileCommand(PathRef File, tooling::CompileCommand NewCommand,
+IntrusiveRefCntPtr FS,

sammccall wrote:
> (summarizing offline discussion)
> 
> this is so close to `update`, it'd be nice if we could just call `update` 
> instead.
> 
> For that we need the contents, so forceReparse needs contents, so... can 
> forceReparse just be addDocument(skipCache=true) or something?
> 
> Requiring content to be passed doesn't seem like a big burden in practice, 
> and makes it clear that clangdserver is never responsible for maintaining 
> copies of the content on the callers behalf (and clangdlspserver is).
> 
> reparseOpenFiles needs to move to clangdlspserver, but this seems consistent 
> with the design. (so I think we can drop getTrackedFiles?)
I also thought it would be nice to have only one method `update`.  What about 
if the `Contents` member of `ParseInputs` is optional?  When it is not 
instantiated (such as when calling `forceReparse`), it would mean to re-use the 
previously sent source.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44462



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


[PATCH] D43162: [Parser] (C++) Make -Wextra-semi slightly more useful

2018-03-14 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: test/SemaCXX/extra-semi.cpp:14
+void F(){}
+; // expected-warning {{extra ';' outside of a function is}}
+

aaron.ballman wrote:
> Can you use the full diagnostic text for this first appearance in the test?
Will require preprocessor, because these are two different messages depending 
of `-std=`
Will do.


Repository:
  rC Clang

https://reviews.llvm.org/D43162



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


[PATCH] D40445: [C++17] Allow an empty expression in an if init statement

2018-03-14 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete added a comment.

@rsmith Can you commit please?


https://reviews.llvm.org/D40445



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


[PATCH] D39050: Add index-while-building support to Clang

2018-03-14 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

In https://reviews.llvm.org/D39050#1036394, @nathawes wrote:

> @malaperle Just to clarify, what's the particular end-loc we're talking about 
> here? e.g. for a function call, would this be the end of the function's name, 
> or the closing paren? 
>  For the end of the name, couldn't this be derived from the start loc + 
> symbol name length (barring token pastes and escaped new lines in the middle 
> of identifiers, which hopefully aren't too common)?
>  I can see the value for the closing paren though.


I mean the end of the name referencing the symbol, so that it can be 
highlighted properly when using the "find references in workspace" feature. 
There are cases where the name of the symbol itself is not present, for example 
"MyClass o1, o2;" (o1 and o2 reference the constructor), references to 
overloaded operators, etc.


https://reviews.llvm.org/D39050



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


[PATCH] D44462: [clangd] Don't use DraftMgr in implementation of forceReparse.

2018-03-14 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clangd/ClangdServer.cpp:143
+  tooling::CompileCommand NewCommand = CompileArgs.getCompileCommand(File);
+  DocVersion Version = DraftMgr.getVersion(File);
+  Path FileStr = File.str();

simark wrote:
> I was wondering if we should increment the version here.  From what I 
> understand, it is used to identify each version of the parse, so that when 
> diagnostics are ready, we know if they are for the latest version (and should 
> be sent to the user) or if they are stale and should be ignored.  If we don't 
> change the document content but change the compile commands, I would consider 
> it as a new version, since the diagnostics coming from the same document but 
> old compile commands should be considered stale.
Diagnostics happen on the ASTWorker thread, of which there's only one per TU, 
so they're actually already serialized along with the decision of whether to 
publish.

The only "gap" is that if we add/remove/add the same document, we can get two 
concurrent astworkers that might deliver diagnostics out-of-order. That's on me 
to fix, at which point we can remove version comparisons from clangdserver 
entirely.

(We may still want a version concept - LSP has them, and it's a useful building 
block. One option is to use them only in ClangdLSPServer and propagate using 
context. This fails if ClangdServer starts watching disk for file changes, so 
maybe we'll want to explicitly pass opaque version tokens around at some point. 
But it's unrelated to the way versions are currently used)



Comment at: clangd/TUScheduler.h:69
+  /// FIXME: remove the callback from this function
+  void updateCompileCommand(PathRef File, tooling::CompileCommand NewCommand,
+IntrusiveRefCntPtr FS,

simark wrote:
> sammccall wrote:
> > (summarizing offline discussion)
> > 
> > this is so close to `update`, it'd be nice if we could just call `update` 
> > instead.
> > 
> > For that we need the contents, so forceReparse needs contents, so... can 
> > forceReparse just be addDocument(skipCache=true) or something?
> > 
> > Requiring content to be passed doesn't seem like a big burden in practice, 
> > and makes it clear that clangdserver is never responsible for maintaining 
> > copies of the content on the callers behalf (and clangdlspserver is).
> > 
> > reparseOpenFiles needs to move to clangdlspserver, but this seems 
> > consistent with the design. (so I think we can drop getTrackedFiles?)
> I also thought it would be nice to have only one method `update`.  What about 
> if the `Contents` member of `ParseInputs` is optional?  When it is not 
> instantiated (such as when calling `forceReparse`), it would mean to re-use 
> the previously sent source.
That would also work. If we can get away with just requiring the contents to 
always be passed in, I think it's simpler to understand.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44462



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


r327515 - CodeGen: Reduce LValue and CallArgList memory footprint before recommitting r326946

2018-03-14 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Wed Mar 14 08:02:28 2018
New Revision: 327515

URL: http://llvm.org/viewvc/llvm-project?rev=327515&view=rev
Log:
CodeGen: Reduce LValue and CallArgList memory footprint before recommitting 
r326946

Recent change r326946 (https://reviews.llvm.org/D34367) causes regression in 
Eigen due to increased
memory footprint of CallArg.

This patch reduces LValue size from 112 to 96 bytes and reduces inline argument 
count of CallArgList
from 16 to 8.

It has been verified that this will let the added deep AST tree test pass with 
r326946.

In the long run, CallArg or LValue memory footprint should be further optimized.

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

Modified:
cfe/trunk/lib/CodeGen/CGCall.h
cfe/trunk/lib/CodeGen/CGValue.h

Modified: cfe/trunk/lib/CodeGen/CGCall.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.h?rev=327515&r1=327514&r2=327515&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.h (original)
+++ cfe/trunk/lib/CodeGen/CGCall.h Wed Mar 14 08:02:28 2018
@@ -224,7 +224,7 @@ public:
   /// CallArgList - Type for representing both the value and type of
   /// arguments in a call.
   class CallArgList :
-public SmallVector {
+public SmallVector {
   public:
 CallArgList() : StackBase(nullptr) {}
 

Modified: cfe/trunk/lib/CodeGen/CGValue.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGValue.h?rev=327515&r1=327514&r2=327515&view=diff
==
--- cfe/trunk/lib/CodeGen/CGValue.h (original)
+++ cfe/trunk/lib/CodeGen/CGValue.h Wed Mar 14 08:02:28 2018
@@ -193,7 +193,7 @@ class LValue {
 
   // The alignment to use when accessing this lvalue.  (For vector elements,
   // this is the alignment of the whole vector.)
-  int64_t Alignment;
+  unsigned Alignment;
 
   // objective-c's ivar
   bool Ivar:1;
@@ -215,13 +215,13 @@ class LValue {
   // to make the default bitfield pattern all-zeroes.
   bool ImpreciseLifetime : 1;
 
-  LValueBaseInfo BaseInfo;
-  TBAAAccessInfo TBAAInfo;
-
   // This flag shows if a nontemporal load/stores should be used when accessing
   // this lvalue.
   bool Nontemporal : 1;
 
+  LValueBaseInfo BaseInfo;
+  TBAAAccessInfo TBAAInfo;
+
   Expr *BaseIvarExp;
 
 private:
@@ -231,7 +231,10 @@ private:
"initializing l-value with zero alignment!");
 this->Type = Type;
 this->Quals = Quals;
-this->Alignment = Alignment.getQuantity();
+const unsigned MaxAlign = 1U << 31;
+this->Alignment = Alignment.getQuantity() <= MaxAlign
+  ? Alignment.getQuantity()
+  : MaxAlign;
 assert(this->Alignment == Alignment.getQuantity() &&
"Alignment exceeds allowed max!");
 this->BaseInfo = BaseInfo;


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


[PATCH] D44445: CodeGen: Reduce LValue and CallArgList memory footprint before recommitting r326946

2018-03-14 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC327515: CodeGen: Reduce LValue and CallArgList memory 
footprint before recommitting… (authored by yaxunl, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D5?vs=138252&id=138358#toc

Repository:
  rC Clang

https://reviews.llvm.org/D5

Files:
  lib/CodeGen/CGCall.h
  lib/CodeGen/CGValue.h


Index: lib/CodeGen/CGValue.h
===
--- lib/CodeGen/CGValue.h
+++ lib/CodeGen/CGValue.h
@@ -193,7 +193,7 @@
 
   // The alignment to use when accessing this lvalue.  (For vector elements,
   // this is the alignment of the whole vector.)
-  int64_t Alignment;
+  unsigned Alignment;
 
   // objective-c's ivar
   bool Ivar:1;
@@ -215,13 +215,13 @@
   // to make the default bitfield pattern all-zeroes.
   bool ImpreciseLifetime : 1;
 
-  LValueBaseInfo BaseInfo;
-  TBAAAccessInfo TBAAInfo;
-
   // This flag shows if a nontemporal load/stores should be used when accessing
   // this lvalue.
   bool Nontemporal : 1;
 
+  LValueBaseInfo BaseInfo;
+  TBAAAccessInfo TBAAInfo;
+
   Expr *BaseIvarExp;
 
 private:
@@ -231,7 +231,10 @@
"initializing l-value with zero alignment!");
 this->Type = Type;
 this->Quals = Quals;
-this->Alignment = Alignment.getQuantity();
+const unsigned MaxAlign = 1U << 31;
+this->Alignment = Alignment.getQuantity() <= MaxAlign
+  ? Alignment.getQuantity()
+  : MaxAlign;
 assert(this->Alignment == Alignment.getQuantity() &&
"Alignment exceeds allowed max!");
 this->BaseInfo = BaseInfo;
Index: lib/CodeGen/CGCall.h
===
--- lib/CodeGen/CGCall.h
+++ lib/CodeGen/CGCall.h
@@ -224,7 +224,7 @@
   /// CallArgList - Type for representing both the value and type of
   /// arguments in a call.
   class CallArgList :
-public SmallVector {
+public SmallVector {
   public:
 CallArgList() : StackBase(nullptr) {}
 


Index: lib/CodeGen/CGValue.h
===
--- lib/CodeGen/CGValue.h
+++ lib/CodeGen/CGValue.h
@@ -193,7 +193,7 @@
 
   // The alignment to use when accessing this lvalue.  (For vector elements,
   // this is the alignment of the whole vector.)
-  int64_t Alignment;
+  unsigned Alignment;
 
   // objective-c's ivar
   bool Ivar:1;
@@ -215,13 +215,13 @@
   // to make the default bitfield pattern all-zeroes.
   bool ImpreciseLifetime : 1;
 
-  LValueBaseInfo BaseInfo;
-  TBAAAccessInfo TBAAInfo;
-
   // This flag shows if a nontemporal load/stores should be used when accessing
   // this lvalue.
   bool Nontemporal : 1;
 
+  LValueBaseInfo BaseInfo;
+  TBAAAccessInfo TBAAInfo;
+
   Expr *BaseIvarExp;
 
 private:
@@ -231,7 +231,10 @@
"initializing l-value with zero alignment!");
 this->Type = Type;
 this->Quals = Quals;
-this->Alignment = Alignment.getQuantity();
+const unsigned MaxAlign = 1U << 31;
+this->Alignment = Alignment.getQuantity() <= MaxAlign
+  ? Alignment.getQuantity()
+  : MaxAlign;
 assert(this->Alignment == Alignment.getQuantity() &&
"Alignment exceeds allowed max!");
 this->BaseInfo = BaseInfo;
Index: lib/CodeGen/CGCall.h
===
--- lib/CodeGen/CGCall.h
+++ lib/CodeGen/CGCall.h
@@ -224,7 +224,7 @@
   /// CallArgList - Type for representing both the value and type of
   /// arguments in a call.
   class CallArgList :
-public SmallVector {
+public SmallVector {
   public:
 CallArgList() : StackBase(nullptr) {}
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43766: [clang-tidy][modernize-make-unique] Checks c++14 flag before using std::make_unique

2018-03-14 Thread Frederic Tingaud via Phabricator via cfe-commits
ftingaud added a comment.

Hi,

I think all requested modifications were done.

Regards,

Fred


https://reviews.llvm.org/D43766



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


r327516 - Add deep AST tree test for r327515

2018-03-14 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Wed Mar 14 08:03:31 2018
New Revision: 327516

URL: http://llvm.org/viewvc/llvm-project?rev=327516&view=rev
Log:
Add deep AST tree test for r327515

Added:
cfe/trunk/test/CodeGenCXX/deep-ast-tree.cpp

Added: cfe/trunk/test/CodeGenCXX/deep-ast-tree.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/deep-ast-tree.cpp?rev=327516&view=auto
==
--- cfe/trunk/test/CodeGenCXX/deep-ast-tree.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/deep-ast-tree.cpp Wed Mar 14 08:03:31 2018
@@ -0,0 +1,262 @@
+// RUN: %clang_cc1 %s
+// This test will cause clang to generate a deep AST tree with many CallArgs.
+// This is to make sure there is no stack overflow for such situations.
+// It is based on a use case in Eigen: 
+// https://eigen.tuxfamily.org/dox/group__TutorialAdvancedInitialization.html
+//
+struct VectorBuilder {
+  VectorBuilder &operator,(int);
+};
+void f() {
+  VectorBuilder(),
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+

[PATCH] D33537: [clang-tidy] Exception Escape Checker

2018-03-14 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.
Herald added a subscriber: rnkovacs.

Is there a more specific module for this check than misc? For example, does it 
check a rule that happens to appear in a certain coding standard? Otherwise, 
maybe "bugprone-"? I've moved a number of checks out of misc- and it would be 
nice to avoid putting more stuff there.


https://reviews.llvm.org/D33537



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


[PATCH] D33470: [clang-tidy] Add misc-default-numerics

2018-03-14 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

Should the check be in "bugprone-" instead?


https://reviews.llvm.org/D33470



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


[PATCH] D43766: [clang-tidy][modernize-make-unique] Checks c++14 flag before using std::make_unique

2018-03-14 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh removed a reviewer: Prazek. alexfh added 1 blocking reviewer(s): hokein.
alexfh added a comment.

A couple of nits.




Comment at: clang-tidy/modernize/MakeUniqueCheck.cpp:42-44
+  if (RequireCPlusPlus14)
+return LangOpts.CPlusPlus14;
+  return LangOpts.CPlusPlus11;

nit: Use ternary operator?



Comment at: test/clang-tidy/modernize-make-unique-cxx11.cpp:7
+
+int main() {
+  auto my_ptr = std::unique_ptr(new int(1));

No need to define `int main()` in the test. It can also become confusing for 
the readers of the code. Please change this to `void f()` or something like 
that and remove the return statement.

Same below.


https://reviews.llvm.org/D43766



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


[PATCH] D36836: [clang-tidy] Implement sonarsource-function-cognitive-complexity check

2018-03-14 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

Removing from my dashboard until the licensing stuff gets sorted out.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D36836



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


[PATCH] D38921: [analyzer] LoopUnrolling: update the matched assignment operators

2018-03-14 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Do you want to submit the matcher part separately?


https://reviews.llvm.org/D38921



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


[PATCH] D40937: [clang-tidy] Infinite loop checker

2018-03-14 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

Please move this check to "bugprone-", since it seems to be an appropriate 
category for this check.


https://reviews.llvm.org/D40937



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


[PATCH] D41655: [clang-tidy] New check bugprone-unused-return-value

2018-03-14 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.

LG. Thank you!

BTW, there's an old related patch https://reviews.llvm.org/D17043, which mostly 
focuses on member functions of STL containers. It might be useful as a 
reference (there's a pretty extensive list of member functions and containers).


https://reviews.llvm.org/D41655



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


[PATCH] D41655: [clang-tidy] New check bugprone-unused-return-value

2018-03-14 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Do you need help committing the patch?


https://reviews.llvm.org/D41655



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


r327528 - Expand clang-interpreter with example of throwing in and from the JIT for Windows64.

2018-03-14 Thread Frederich Munch via cfe-commits
Author: marsupial
Date: Wed Mar 14 09:04:45 2018
New Revision: 327528

URL: http://llvm.org/viewvc/llvm-project?rev=327528&view=rev
Log:
Expand clang-interpreter with example of throwing in and from the JIT for 
Windows64.

Summary:
Getting this to work is not particularly obvious, and having it as an example 
should be helpful.
Portions of this could be placed into LLVM, but as a whole it seems necessary 
to do this a higher level.

Reviewers: lhames, mehdi_amini

Reviewed By: lhames

Subscribers: mgrang, martell, cfe-commits, mgorny

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

Added:
cfe/trunk/examples/clang-interpreter/Invoke.cpp
cfe/trunk/examples/clang-interpreter/Invoke.h
cfe/trunk/examples/clang-interpreter/Manager.cpp
cfe/trunk/examples/clang-interpreter/Manager.h
cfe/trunk/examples/clang-interpreter/Test.cxx
Modified:
cfe/trunk/examples/clang-interpreter/CMakeLists.txt
cfe/trunk/examples/clang-interpreter/README.txt
cfe/trunk/examples/clang-interpreter/main.cpp

Modified: cfe/trunk/examples/clang-interpreter/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/clang-interpreter/CMakeLists.txt?rev=327528&r1=327527&r2=327528&view=diff
==
--- cfe/trunk/examples/clang-interpreter/CMakeLists.txt (original)
+++ cfe/trunk/examples/clang-interpreter/CMakeLists.txt Wed Mar 14 09:04:45 2018
@@ -3,13 +3,17 @@ set(LLVM_LINK_COMPONENTS
   ExecutionEngine
   MC
   MCJIT
+  OrcJit
   Option
+  RuntimeDyld
   Support
   native
   )
 
 add_clang_executable(clang-interpreter
   main.cpp
+  Invoke.cpp
+  Manager.cpp
   )
 
 add_dependencies(clang-interpreter
@@ -23,3 +27,67 @@ target_link_libraries(clang-interpreter
   clangDriver
   clangFrontend
   )
+
+export_executable_symbols(clang-interpreter)
+
+if (MSVC)
+  # Is this a CMake bug that even with export_executable_symbols, Windows
+  # needs to explictly export the type_info vtable
+  set_property(TARGET clang-interpreter
+   APPEND_STRING PROPERTY LINK_FLAGS /EXPORT:??_7type_info@@6B@)
+endif()
+
+function(clang_enable_exceptions TARGET)
+  # Really have to jump through hoops to enable exception handling independent
+  # of how LLVM is being built.
+  if (NOT LLVM_REQUIRES_EH AND NOT LLVM_REQUIRES_RTTI)
+if (MSVC)
+  # /EHs to allow throwing rom extern "C"
+  set(excptnExceptions_ON "/D _HAS_EXCEPTIONS=1 /EHs /wd4714")
+  set(excptnExceptions_OFF "/D _HAS_EXCEPTIONS=0 /EHs-c-")
+  set(excptnRTTI_ON "/GR")
+  set(excptnRTTI_OFF "/GR-")
+  set(excptnEHRTTIRegEx "(/EHs(-c-?)|_HAS_EXCEPTIONS=(0|1))")
+else()
+  set(excptnExceptions_ON "-fexceptions")
+  set(excptnExceptions_OFF "-fno-exceptions")
+  set(excptnRTTI_ON "-frtti")
+  set(excptnRTTI_OFF "-fno-rtti")
+  set(excptnEHRTTIRegEx "-f(exceptions|no-exceptions)")
+endif()
+if (LLVM_REQUIRES_EH)
+  set(excptnExceptions_DFLT ${excptnExceptions_ON})
+else()
+  set(excptnExceptions_DFLT ${excptnExceptions_OFF})
+endif()
+if (LLVM_REQUIRES_RTTI)
+  set(excptnRTTI_DFLT ${excptnRTTI_ON})
+else()
+  set(excptnRTTI_DFLT ${excptnRTTI_OFF})
+endif()
+
+# Strip the exception & rtti flags from the target
+get_property(addedFlags TARGET ${TARGET} PROPERTY COMPILE_FLAGS)
+string(REGEX REPLACE ${excptnEHRTTIRegEx} "" editedFlags ${addedFlags})
+string(REPLACE ${excptnRTTI_OFF} "" editedFlags ${editedFlags})
+set_property(TARGET ${TARGET} PROPERTY COMPILE_FLAGS ${editedFlags})
+
+get_property(addedFlags TARGET ${TARGET} PROPERTY COMPILE_DEFINITIONS)
+string(REGEX REPLACE ${excptnEHRTTIRegEx} "" editedFlags ${addedFlags})
+string(REPLACE ${excptnRTTI_OFF} "" editedFlags ${editedFlags})
+set_property(TARGET ${TARGET} PROPERTY COMPILE_DEFINITIONS ${editedFlags})
+
+# Re-add the exception & rtti flags from LLVM
+set_property(SOURCE main.cpp APPEND_STRING PROPERTY COMPILE_FLAGS
+   " ${excptnExceptions_DFLT} ${excptnRTTI_DFLT} ")
+set_property(SOURCE Manager.cpp APPEND_STRING PROPERTY COMPILE_FLAGS
+   " ${excptnExceptions_DFLT} ${excptnRTTI_DFLT} ")
+
+# Invoke with exceptions & rtti
+set_property(SOURCE Invoke.cpp APPEND_STRING PROPERTY COMPILE_FLAGS
+   " ${excptnExceptions_ON} ${excptnRTTI_ON} ")
+
+  endif()
+endfunction(clang_enable_exceptions)
+
+clang_enable_exceptions(clang-interpreter)

Added: cfe/trunk/examples/clang-interpreter/Invoke.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/clang-interpreter/Invoke.cpp?rev=327528&view=auto
==
--- cfe/trunk/examples/clang-interpreter/Invoke.cpp (added)
+++ cfe/trunk/examples/clang-interpreter/Invoke.cpp Wed Mar 14 09:04:45 2018
@@ -0,0 +1,31 @@
+//==-- examples/clang-interpreter/Invoke.cpp - Clang C Interpreter Example 
-==//
+//
+//   

[PATCH] D35103: Expand clang-interpreter with example of throwing in and from the JIT for Windows64.

2018-03-14 Thread Frederich Munch via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC327528: Expand clang-interpreter with example of throwing in 
and from the JIT for… (authored by marsupial, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D35103

Files:
  examples/clang-interpreter/CMakeLists.txt
  examples/clang-interpreter/Invoke.cpp
  examples/clang-interpreter/Invoke.h
  examples/clang-interpreter/Manager.cpp
  examples/clang-interpreter/Manager.h
  examples/clang-interpreter/README.txt
  examples/clang-interpreter/Test.cxx
  examples/clang-interpreter/main.cpp

Index: examples/clang-interpreter/Invoke.cpp
===
--- examples/clang-interpreter/Invoke.cpp
+++ examples/clang-interpreter/Invoke.cpp
@@ -0,0 +1,31 @@
+//==-- examples/clang-interpreter/Invoke.cpp - Clang C Interpreter Example -==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "Invoke.h"
+
+#include 
+#include 
+
+namespace interpreter {
+
+int TryIt(llvm::ExecutionEngine *EE, llvm::Function *EntryFn,
+  const std::vector &Args, char *const *EnvP,
+  Invoker Invoke) {
+  int Res = -1;
+  try {
+Res = Invoke(EE, EntryFn, Args, EnvP);
+  } catch (const std::exception &E) {
+std::cout << "Caught '" << E.what() << "'\n";
+  } catch (...) {
+std::cout << "Unknown exception\n";
+  }
+  return Res;
+}
+
+}
Index: examples/clang-interpreter/README.txt
===
--- examples/clang-interpreter/README.txt
+++ examples/clang-interpreter/README.txt
@@ -1,4 +1,4 @@
-This is an example of Clang based interpreter, for executing standalone C
+This is an example of Clang based interpreter, for executing standalone C/C++
 programs.
 
 It demonstrates the following features:
@@ -12,6 +12,9 @@
 
  4. Use the LLVM JIT functionality to execute the final module.
 
+ 5. Intercepting a Win64 library call to allow throwing and catching exceptions
+in and from the JIT.
+
 The implementation has many limitations and is not designed to be a full fledged
-C interpreter. It is designed to demonstrate a simple but functional use of the
+interpreter. It is designed to demonstrate a simple but functional use of the
 Clang compiler libraries.
Index: examples/clang-interpreter/Manager.cpp
===
--- examples/clang-interpreter/Manager.cpp
+++ examples/clang-interpreter/Manager.cpp
@@ -0,0 +1,328 @@
+//==-- examples/clang-interpreter/Manager.cpp - Clang C Interpreter Example -=//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "Manager.h"
+
+#ifdef CLANG_INTERPRETER_WIN_EXCEPTIONS
+#include "llvm/Support/DynamicLibrary.h"
+
+#define WIN32_LEAN_AND_MEAN
+#define NOGDI
+#define NOMINMAX
+#include 
+#endif
+
+namespace interpreter {
+
+using namespace llvm;
+
+void SingleSectionMemoryManager::Block::Reset(uint8_t *Ptr, uintptr_t Size) {
+  assert(Ptr != nullptr && "Bad allocation");
+  Addr = Ptr;
+  End = Ptr ? Ptr + Size : nullptr;
+}
+
+uint8_t *SingleSectionMemoryManager::Block::Next(uintptr_t Size,
+ unsigned Alignment) {
+  uintptr_t Out = (uintptr_t)Addr;
+
+  // Align the out pointer properly
+  if (!Alignment)
+Alignment = 16;
+  Out = (Out + Alignment - 1) & ~(uintptr_t)(Alignment - 1);
+
+  // RuntimeDyld should have called reserveAllocationSpace with an amount that
+  // will fit all required alignemnts...but assert on this to make sure.
+  assert((Out + Size) <= (uintptr_t)End && "Out of bounds");
+
+  // Set the next Addr to deliver at the end of this one.
+  Addr = (uint8_t *)(Out + Size);
+  return (uint8_t *)Out;
+}
+
+uint8_t *SingleSectionMemoryManager::allocateCodeSection(uintptr_t Size,
+ unsigned Align,
+ unsigned ID,
+ StringRef Name) {
+  return Code.Next(Size, Align);
+}
+
+uint8_t *SingleSectionMemoryManager::allocateDataSection(
+uintptr_t Size, unsigned Align, unsigned ID, StringRef Name, bool RO) {
+  return RO ? ROData.Next(Size, Align) : RWData.Next(Size, Align);
+}
+
+void SingleSectionMemoryManager::reserveAllocationSpace(
+uintptr_t CodeSize, uint32_t CodeAlign, uintptr_t ROSize, uint32_t ROAlign,
+uintptr_t RWSize, uint32_t RWAlign) {
+  // FIXME: Ideally this should be one contiguous block, with Code, ROData,
+  // and RWData poi

[PATCH] D23130: [Clang-tidy] Add a check for definitions in the global namespace.

2018-03-14 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: xazax.hun.

It looks like all concerns were resolved.

LG, if you still want to proceed with this patch.


https://reviews.llvm.org/D23130



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


[PATCH] D44480: [Sema] Don't skip function bodies with 'auto' without trailing return type

2018-03-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: aaron.ballman, sammccall.

Skipping them was clearly not intentional. It's impossible to
guarantee correctness if the bodies are skipped.
Also adds a test case for r327504, now that it does not produce
invalid errors that made the test fail.


Repository:
  rC Clang

https://reviews.llvm.org/D44480

Files:
  lib/Sema/SemaDecl.cpp
  test/CodeCompletion/crash-skipped-bodies-template-inst.cpp


Index: test/CodeCompletion/crash-skipped-bodies-template-inst.cpp
===
--- /dev/null
+++ test/CodeCompletion/crash-skipped-bodies-template-inst.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:24:5 %s -o - 2>&1 | 
FileCheck %s
+template 
+auto make_func() {
+  struct impl {
+impl* func() {
+  int x;
+  if (x = 10) {}
+  // Check that body of this function is actually skipped.
+  // CHECK-NOT: crash-skipped-bodies-template-inst.cpp:7:{{[0-9]+}}: 
warning: using the result of an assignment as a condition without parentheses
+  return this;
+}
+  };
+
+  int x;
+  if (x = 10) {}
+  // Check that this function is not skipped.
+  // CHECK: crash-skipped-bodies-template-inst.cpp:15:9: warning: using the 
result of an assignment as a condition without parentheses
+  return impl();
+}
+
+void foo() {
+  []() {
+make_func();
+m
+// CHECK: COMPLETION: make_func : [#auto#]make_func<<#class T#>>()
+  };
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -12603,9 +12603,15 @@
   // rest of the file.
   // We cannot skip the body of a function with an undeduced return type,
   // because any callers of that function need to know the type.
-  if (const FunctionDecl *FD = D->getAsFunction())
-if (FD->isConstexpr() || FD->getReturnType()->isUndeducedType())
+  if (const FunctionDecl *FD = D->getAsFunction()) {
+if (FD->isConstexpr())
   return false;
+// We can't simply call Type::isUndeducedType here, because it returns
+// false on C++14's auto return type without trailing return type.
+auto *DT = FD->getReturnType()->getContainedDeducedType();
+if (DT && DT->getDeducedType().isNull())
+  return false;
+  }
   return Consumer.shouldSkipFunctionBody(D);
 }
 


Index: test/CodeCompletion/crash-skipped-bodies-template-inst.cpp
===
--- /dev/null
+++ test/CodeCompletion/crash-skipped-bodies-template-inst.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:24:5 %s -o - 2>&1 | FileCheck %s
+template 
+auto make_func() {
+  struct impl {
+impl* func() {
+  int x;
+  if (x = 10) {}
+  // Check that body of this function is actually skipped.
+  // CHECK-NOT: crash-skipped-bodies-template-inst.cpp:7:{{[0-9]+}}: warning: using the result of an assignment as a condition without parentheses
+  return this;
+}
+  };
+
+  int x;
+  if (x = 10) {}
+  // Check that this function is not skipped.
+  // CHECK: crash-skipped-bodies-template-inst.cpp:15:9: warning: using the result of an assignment as a condition without parentheses
+  return impl();
+}
+
+void foo() {
+  []() {
+make_func();
+m
+// CHECK: COMPLETION: make_func : [#auto#]make_func<<#class T#>>()
+  };
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -12603,9 +12603,15 @@
   // rest of the file.
   // We cannot skip the body of a function with an undeduced return type,
   // because any callers of that function need to know the type.
-  if (const FunctionDecl *FD = D->getAsFunction())
-if (FD->isConstexpr() || FD->getReturnType()->isUndeducedType())
+  if (const FunctionDecl *FD = D->getAsFunction()) {
+if (FD->isConstexpr())
   return false;
+// We can't simply call Type::isUndeducedType here, because it returns
+// false on C++14's auto return type without trailing return type.
+auto *DT = FD->getReturnType()->getContainedDeducedType();
+if (DT && DT->getDeducedType().isNull())
+  return false;
+  }
   return Consumer.shouldSkipFunctionBody(D);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D23130: [Clang-tidy] Add a check for definitions in the global namespace.

2018-03-14 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer added a comment.

I'd like to, but I don't know when I find time to rebase this thing after more 
than a year of waiting for review.


https://reviews.llvm.org/D23130



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


[PATCH] D44295: [clang-tidy] Detects and fixes calls to grand-...parent virtual methods instead of calls to parent's virtual methods

2018-03-14 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added inline comments.
This revision now requires changes to proceed.



Comment at: clang-tidy/bugprone/ParentVirtualCallCheck.cpp:24-25
+   const CXXRecordDecl *ThisClass) {
+  assert(Parent);
+  assert(ThisClass);
+  if (Parent->getCanonicalDecl() == ThisClass->getCanonicalDecl())

aaron.ballman wrote:
> You can drop these asserts.
... and make arguments const references ;)



Comment at: clang-tidy/bugprone/ParentVirtualCallCheck.cpp:44
+
+static std::list
+GetParentsByGrandParent(const CXXRecordDecl *GrandParent,

std::list is almost never a good choice due to large overhead, poor locality of 
the data, etc. Use std::vector instead.



Comment at: clang-tidy/bugprone/ParentVirtualCallCheck.cpp:53
+GrandParent,
+Base.getType()->getAsCXXRecordDecl()->getCanonicalDecl()))
+  result.push_back(

Pull this to a variable to avoid repetition.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44295



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


[PATCH] D44346: [clang-tidy] Add Zircon module to clang-tidy

2018-03-14 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 138392.
juliehockett marked 3 inline comments as done.
juliehockett added a comment.

Fixing tests and updating docs


https://reviews.llvm.org/D44346

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  clang-tidy/zircon/CMakeLists.txt
  clang-tidy/zircon/TemporaryObjectsCheck.cpp
  clang-tidy/zircon/TemporaryObjectsCheck.h
  clang-tidy/zircon/ZirconTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/zircon-temporary-objects.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/zircon-temporary-objects.cpp

Index: test/clang-tidy/zircon-temporary-objects.cpp
===
--- /dev/null
+++ test/clang-tidy/zircon-temporary-objects.cpp
@@ -0,0 +1,109 @@
+// RUN: %check_clang_tidy %s zircon-temporary-objects %t -- \
+// RUN:   -config="{CheckOptions: [{key: zircon-temporary-objects.Names, value: 'Foo;NS::Bar'}]}" \
+// RUN:   -header-filter=.* \
+// RUN: -- -std=c++11
+
+// Should flag instances of Foo, NS::Bar.
+
+class Foo {
+public:
+  Foo() = default;
+  Foo(int Val) : Val(Val){};
+
+private:
+  int Val;
+};
+
+namespace NS {
+
+class Bar {
+public:
+  Bar() = default;
+  Bar(int Val) : Val(Val){};
+
+private:
+  int Val;
+};
+
+} // namespace NS
+
+class Bar {
+public:
+  Bar() = default;
+  Bar(int Val) : Val(Val){};
+
+private:
+  int Val;
+};
+
+int func(Foo F) { return 1; };
+
+int main() {
+  Foo F;
+  Foo *F2 = new Foo();
+  new Foo();
+  Foo();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: creating a temporary object of type 'Foo' is prohibited
+  Foo F3 = Foo();
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: creating a temporary object of type 'Foo' is prohibited
+
+  Bar();
+  NS::Bar();
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: creating a temporary object of type 'NS::Bar' is prohibited
+
+  int A = func(Foo());
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: creating a temporary object of type 'Foo' is prohibited
+
+  Foo F4(0);
+  Foo *F5 = new Foo(0);
+  new Foo(0);
+  Foo(0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: creating a temporary object of type 'Foo' is prohibited
+  Foo F6 = Foo(0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: creating a temporary object of type 'Foo' is prohibited
+
+  Bar(0);
+  NS::Bar(0);
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: creating a temporary object of type 'NS::Bar' is prohibited
+
+  int B = func(Foo(0));
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: creating a temporary object of type 'Foo' is prohibited
+}
+
+namespace NS {
+
+void f() {
+  Bar();
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: creating a temporary object of type 'NS::Bar' is prohibited
+  Bar(0);
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: creating a temporary object of type 'NS::Bar' is prohibited
+}
+
+} // namespace NS
+
+template 
+Ty make_ty() { return Ty(); }
+// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: creating a temporary object of type 'Foo' is prohibited
+// CHECK-MESSAGES: :[[@LINE-2]]:23: warning: creating a temporary object of type 'NS::Bar' is prohibited
+
+void ty_func() {
+  make_ty();
+  make_ty();
+  make_ty();
+}
+
+// Inheriting the disallowed class does not trigger the check.
+
+class Bingo : NS::Bar {}; // Not explicitly disallowed
+
+void f2() {
+  Bingo();
+}
+
+template 
+class Quux : Ty {};
+
+void f3() {
+  Quux();
+  Quux();
+}
Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -75,6 +75,7 @@
relate to any particular coding style.
 ``readability-``   Checks that target readability-related issues that don't
relate to any particular coding style.
+``zircon-``Checks related to Zircon kernel coding conventions.
 == =
 
 Clang diagnostics are treated in a similar way as check diagnostics. Clang
Index: docs/clang-tidy/checks/zircon-temporary-objects.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/zircon-temporary-objects.rst
@@ -0,0 +1,45 @@
+.. title:: clang-tidy - zircon-temporary-objects
+
+zircon-temporary-objects
+
+
+Warns on construction of specific temporary objects in the Zircon kernel. 
+If the object should be flagged, the fully qualified name of the object 
+must be explicitly passed as a parameter to the check.
+
+For example, given the list of classes "Foo" and "NS::Bar", all of the 
+following will trigger the warning: 
+
+.. code-block:: c++
+
+  Foo();
+  Foo F = Foo();
+  func(Foo());
+
+  namespace NS {
+
+  Bar();
+
+  }
+
+With the same list, the following will not trigger the warning:
+
+.. code-block:: c++
+
+  Foo F; // Non-temporary construction okay
+  Foo F(param);			 // Non-

[PATCH] D44462: [clangd] Don't use DraftMgr in implementation of forceReparse.

2018-03-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 138394.
ilya-biryukov marked 2 inline comments as done.
ilya-biryukov added a comment.

- Remove TUScheduler::updateCompileCommands, add a new optional parameter to 
clear the cache of compile commands instead
- Address review comments


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44462

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/TUScheduler.cpp
  unittests/clangd/ClangdTests.cpp
  unittests/clangd/SyncAPI.cpp
  unittests/clangd/SyncAPI.h

Index: unittests/clangd/SyncAPI.h
===
--- unittests/clangd/SyncAPI.h
+++ unittests/clangd/SyncAPI.h
@@ -19,7 +19,8 @@
 namespace clangd {
 
 // Calls addDocument and then blockUntilIdleForTest.
-void runAddDocument(ClangdServer &Server, PathRef File, StringRef Contents);
+void runAddDocument(ClangdServer &Server, PathRef File, StringRef Contents,
+bool SkipCache = false);
 
 llvm::Expected
 runCodeComplete(ClangdServer &Server, PathRef File, Position Pos,
Index: unittests/clangd/SyncAPI.cpp
===
--- unittests/clangd/SyncAPI.cpp
+++ unittests/clangd/SyncAPI.cpp
@@ -11,8 +11,9 @@
 namespace clang {
 namespace clangd {
 
-void runAddDocument(ClangdServer &Server, PathRef File, StringRef Contents) {
-  Server.addDocument(File, Contents);
+void runAddDocument(ClangdServer &Server, PathRef File, StringRef Contents,
+bool SkipCache) {
+  Server.addDocument(File, Contents, WantDiagnostics::Auto, SkipCache);
   if (!Server.blockUntilIdleForTest())
 llvm_unreachable("not idle after addDocument");
 }
Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -245,13 +245,13 @@
   EXPECT_FALSE(DiagConsumer.hadErrorInLastDiags());
 
   FS.Files[FooH] = "";
-  Server.forceReparse(FooCpp);
+  Server.addDocument(FooCpp, SourceContents);
   auto DumpParseDifferent = dumpASTWithoutMemoryLocs(Server, FooCpp);
   ASSERT_TRUE(Server.blockUntilIdleForTest()) << "Waiting for diagnostics";
   EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
 
   FS.Files[FooH] = "int a;";
-  Server.forceReparse(FooCpp);
+  Server.addDocument(FooCpp, SourceContents);
   auto DumpParse2 = dumpASTWithoutMemoryLocs(Server, FooCpp);
   ASSERT_TRUE(Server.blockUntilIdleForTest()) << "Waiting for diagnostics";
   EXPECT_FALSE(DiagConsumer.hadErrorInLastDiags());
@@ -368,15 +368,15 @@
 
   // Now switch to C++ mode.
   CDB.ExtraClangFlags = {"-xc++"};
-  // Currently, addDocument never checks if CompileCommand has changed, so we
+  // By default addDocument does not check if CompileCommand has changed, so we
   // expect to see the errors.
   runAddDocument(Server, FooCpp, SourceContents1);
   EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
   runAddDocument(Server, FooCpp, SourceContents2);
   EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
-  // But forceReparse should reparse the file with proper flags.
-  Server.forceReparse(FooCpp);
-  ASSERT_TRUE(Server.blockUntilIdleForTest());
+  // Passing SkipCache=true will force addDocument to reparse the file with
+  // proper flags.
+  runAddDocument(Server, FooCpp, SourceContents2, /*SkipCache=*/true);
   EXPECT_FALSE(DiagConsumer.hadErrorInLastDiags());
   // Subsequent addDocument calls should finish without errors too.
   runAddDocument(Server, FooCpp, SourceContents1);
@@ -408,12 +408,13 @@
 
   // Parse without the define, no errors should be produced.
   CDB.ExtraClangFlags = {};
-  // Currently, addDocument never checks if CompileCommand has changed, so we
+  // By default addDocument does not check if CompileCommand has changed, so we
   // expect to see the errors.
   runAddDocument(Server, FooCpp, SourceContents);
   EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
-  // But forceReparse should reparse the file with proper flags.
-  Server.forceReparse(FooCpp);
+  // Passing SkipCache=true will force addDocument to reparse the file with
+  // proper flags.
+  runAddDocument(Server, FooCpp, SourceContents, /*SkipCache=*/true);
   ASSERT_TRUE(Server.blockUntilIdleForTest());
   EXPECT_FALSE(DiagConsumer.hadErrorInLastDiags());
   // Subsequent addDocument call should finish without errors too.
@@ -675,44 +676,31 @@
   Stats.FileIsRemoved = true;
 };
 
-auto UpdateStatsOnForceReparse = [&](unsigned FileIndex) {
-  auto &Stats = ReqStats[FileIndex];
-
-  if (Stats.LastContentsHadErrors)
-++Stats.RequestsWithErrors;
-  else
-++Stats.RequestsWithoutErrors;
-};
-
-auto AddDocument = [&](unsigned FileIndex) {
+auto AddDocument = [&](unsigned FileIndex, bool SkipCache) {
   bool ShouldHaveErrors = ShouldHaveErrorsDist(RandGen);
   Server.addDocument(FilePaths[FileIndex],
  ShouldHaveErrors ? SourceContentsWit

[PATCH] D44462: [clangd] Don't use DraftMgr in implementation of forceReparse.

2018-03-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/TUScheduler.h:69
+  /// FIXME: remove the callback from this function
+  void updateCompileCommand(PathRef File, tooling::CompileCommand NewCommand,
+IntrusiveRefCntPtr FS,

sammccall wrote:
> simark wrote:
> > sammccall wrote:
> > > (summarizing offline discussion)
> > > 
> > > this is so close to `update`, it'd be nice if we could just call `update` 
> > > instead.
> > > 
> > > For that we need the contents, so forceReparse needs contents, so... can 
> > > forceReparse just be addDocument(skipCache=true) or something?
> > > 
> > > Requiring content to be passed doesn't seem like a big burden in 
> > > practice, and makes it clear that clangdserver is never responsible for 
> > > maintaining copies of the content on the callers behalf (and 
> > > clangdlspserver is).
> > > 
> > > reparseOpenFiles needs to move to clangdlspserver, but this seems 
> > > consistent with the design. (so I think we can drop getTrackedFiles?)
> > I also thought it would be nice to have only one method `update`.  What 
> > about if the `Contents` member of `ParseInputs` is optional?  When it is 
> > not instantiated (such as when calling `forceReparse`), it would mean to 
> > re-use the previously sent source.
> That would also work. If we can get away with just requiring the contents to 
> always be passed in, I think it's simpler to understand.
> That would also work. If we can get away with just requiring the contents to 
> always be passed in, I think it's simpler to understand.
Also makes the implementation of `update` a bit simpler, because it doesn't 
have to care about missing files.
And `ParseInputs` is used in other places too, all of them need to be updated 
or we need two versions of `ParseInputs`: with optional and required contents.
Requiring contents for `forceReparse` seems easier. And when we got automated 
tracking of changes to compilation database, this will go away


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44462



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


r327529 - Attempt to fix failure of deep-ast-tree.cpp on ppc64 and atom

2018-03-14 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Wed Mar 14 09:47:49 2018
New Revision: 327529

URL: http://llvm.org/viewvc/llvm-project?rev=327529&view=rev
Log:
Attempt to fix failure of deep-ast-tree.cpp on ppc64 and atom

Modified:
cfe/trunk/test/CodeGenCXX/deep-ast-tree.cpp

Modified: cfe/trunk/test/CodeGenCXX/deep-ast-tree.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/deep-ast-tree.cpp?rev=327529&r1=327528&r2=327529&view=diff
==
--- cfe/trunk/test/CodeGenCXX/deep-ast-tree.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/deep-ast-tree.cpp Wed Mar 14 09:47:49 2018
@@ -130,6 +130,8 @@ void f() {
   
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
   
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
   
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  /* some archs have smaller stack size */
+#if !defined(__ppc__) && !defined(__arm__) 
   
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
   
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
   
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
@@ -257,6 +259,7 @@ void f() {
   
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
   
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
   
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+#endif
   
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0;
 }
 


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


r327531 - [CMake] Properly quote string arguments to quiet errors from r327528 when built

2018-03-14 Thread Frederich Munch via cfe-commits
Author: marsupial
Date: Wed Mar 14 09:56:02 2018
New Revision: 327531

URL: http://llvm.org/viewvc/llvm-project?rev=327531&view=rev
Log:
[CMake] Properly quote string arguments to quiet errors from r327528 when built
with LLVM_ENABLE_EH and LLVM_ENABLE_RTTI.

Modified:
cfe/trunk/examples/clang-interpreter/CMakeLists.txt

Modified: cfe/trunk/examples/clang-interpreter/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/clang-interpreter/CMakeLists.txt?rev=327531&r1=327530&r2=327531&view=diff
==
--- cfe/trunk/examples/clang-interpreter/CMakeLists.txt (original)
+++ cfe/trunk/examples/clang-interpreter/CMakeLists.txt Wed Mar 14 09:56:02 2018
@@ -42,7 +42,7 @@ function(clang_enable_exceptions TARGET)
   # of how LLVM is being built.
   if (NOT LLVM_REQUIRES_EH AND NOT LLVM_REQUIRES_RTTI)
 if (MSVC)
-  # /EHs to allow throwing rom extern "C"
+  # /EHs to allow throwing from extern "C"
   set(excptnExceptions_ON "/D _HAS_EXCEPTIONS=1 /EHs /wd4714")
   set(excptnExceptions_OFF "/D _HAS_EXCEPTIONS=0 /EHs-c-")
   set(excptnRTTI_ON "/GR")
@@ -68,14 +68,14 @@ function(clang_enable_exceptions TARGET)
 
 # Strip the exception & rtti flags from the target
 get_property(addedFlags TARGET ${TARGET} PROPERTY COMPILE_FLAGS)
-string(REGEX REPLACE ${excptnEHRTTIRegEx} "" editedFlags ${addedFlags})
-string(REPLACE ${excptnRTTI_OFF} "" editedFlags ${editedFlags})
-set_property(TARGET ${TARGET} PROPERTY COMPILE_FLAGS ${editedFlags})
+string(REGEX REPLACE ${excptnEHRTTIRegEx} "" editedFlags "${addedFlags}")
+string(REPLACE ${excptnRTTI_OFF} "" editedFlags "${editedFlags}")
+set_property(TARGET ${TARGET} PROPERTY COMPILE_FLAGS "${editedFlags}")
 
 get_property(addedFlags TARGET ${TARGET} PROPERTY COMPILE_DEFINITIONS)
-string(REGEX REPLACE ${excptnEHRTTIRegEx} "" editedFlags ${addedFlags})
-string(REPLACE ${excptnRTTI_OFF} "" editedFlags ${editedFlags})
-set_property(TARGET ${TARGET} PROPERTY COMPILE_DEFINITIONS ${editedFlags})
+string(REGEX REPLACE ${excptnEHRTTIRegEx} "" editedFlags "${addedFlags}")
+string(REPLACE ${excptnRTTI_OFF} "" editedFlags "${editedFlags}")
+set_property(TARGET ${TARGET} PROPERTY COMPILE_DEFINITIONS 
"${editedFlags}")
 
 # Re-add the exception & rtti flags from LLVM
 set_property(SOURCE main.cpp APPEND_STRING PROPERTY COMPILE_FLAGS


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


[PATCH] D44462: [clangd] Don't use DraftMgr in implementation of forceReparse.

2018-03-14 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.



Comment at: clangd/TUScheduler.cpp:220
+FileInputs = std::move(Inputs);
+rebuildASTLocked(WantDiags, std::move(OnUpdated));
   };

you might want to inline this function here again - it's not overly long, and 
we're now back to one callsite



Comment at: unittests/clangd/SyncAPI.h:23
+void runAddDocument(ClangdServer &Server, PathRef File, StringRef Contents,
+bool SkipCache = false);
 

it's slightly odd that wantdiagnostics is missing here. Previously this was 
"forwards compatible" and could easily be added later. But now we'll have 
callsites that pass different arguments than addDocument takes.

Maybe just add the defaulted param to the signature?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44462



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


[PATCH] D44408: Move DraftMgr from ClangdServer to ClangdLSPServer

2018-03-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D44408#1036941, @simark wrote:

> I don't see how to avoid adding the Contents parameter to the codeComplete 
> and signatureHelp methods, since they needed to fetch the document from the 
> draft manager and pass it to the backend.


You can get the contents inside the `runWithPreamble` callback:

  llvm::Expected IP;
  auto &Contents = IP->Inputs.Contents;


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44408



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


[PATCH] D39050: Add index-while-building support to Clang

2018-03-14 Thread Nathan Hawes via Phabricator via cfe-commits
nathawes added a comment.

In https://reviews.llvm.org/D39050#1037008, @malaperle wrote:

> In https://reviews.llvm.org/D39050#1036394, @nathawes wrote:
>
> > @malaperle Just to clarify, what's the particular end-loc we're talking 
> > about here? e.g. for a function call, would this be the end of the 
> > function's name, or the closing paren? 
> >  For the end of the name, couldn't this be derived from the start loc + 
> > symbol name length (barring token pastes and escaped new lines in the 
> > middle of identifiers, which hopefully aren't too common)?
> >  I can see the value for the closing paren though.
>
>
> I mean the end of the name referencing the symbol, so that it can be 
> highlighted properly when using the "find references in workspace" feature. 
> There are cases where the name of the symbol itself is not present, for 
> example "MyClass o1, o2;" (o1 and o2 reference the constructor), references 
> to overloaded operators, etc.


Ah, I see – thanks! I was thinking all occurrences whose symbol name didn't 
actually appear at their location were marked with `SymbolRole::Implicit`, but 
that only seems to be true for the ObjC index data.


https://reviews.llvm.org/D39050



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


[PATCH] D44462: [clangd] Don't use DraftMgr in implementation of forceReparse.

2018-03-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 138397.
ilya-biryukov marked 2 inline comments as done.
ilya-biryukov added a comment.

- Add WantDiagnostics param to runAddDocument
- Revert changes in TUScheduler


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44462

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  unittests/clangd/ClangdTests.cpp
  unittests/clangd/SyncAPI.cpp
  unittests/clangd/SyncAPI.h

Index: unittests/clangd/SyncAPI.h
===
--- unittests/clangd/SyncAPI.h
+++ unittests/clangd/SyncAPI.h
@@ -19,7 +19,9 @@
 namespace clangd {
 
 // Calls addDocument and then blockUntilIdleForTest.
-void runAddDocument(ClangdServer &Server, PathRef File, StringRef Contents);
+void runAddDocument(ClangdServer &Server, PathRef File, StringRef Contents,
+WantDiagnostics WantDiags = WantDiagnostics::Auto,
+bool SkipCache = false);
 
 llvm::Expected
 runCodeComplete(ClangdServer &Server, PathRef File, Position Pos,
Index: unittests/clangd/SyncAPI.cpp
===
--- unittests/clangd/SyncAPI.cpp
+++ unittests/clangd/SyncAPI.cpp
@@ -11,8 +11,9 @@
 namespace clang {
 namespace clangd {
 
-void runAddDocument(ClangdServer &Server, PathRef File, StringRef Contents) {
-  Server.addDocument(File, Contents);
+void runAddDocument(ClangdServer &Server, PathRef File, StringRef Contents,
+WantDiagnostics WantDiags, bool SkipCache) {
+  Server.addDocument(File, Contents, WantDiags, SkipCache);
   if (!Server.blockUntilIdleForTest())
 llvm_unreachable("not idle after addDocument");
 }
Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -245,13 +245,13 @@
   EXPECT_FALSE(DiagConsumer.hadErrorInLastDiags());
 
   FS.Files[FooH] = "";
-  Server.forceReparse(FooCpp);
+  Server.addDocument(FooCpp, SourceContents);
   auto DumpParseDifferent = dumpASTWithoutMemoryLocs(Server, FooCpp);
   ASSERT_TRUE(Server.blockUntilIdleForTest()) << "Waiting for diagnostics";
   EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
 
   FS.Files[FooH] = "int a;";
-  Server.forceReparse(FooCpp);
+  Server.addDocument(FooCpp, SourceContents);
   auto DumpParse2 = dumpASTWithoutMemoryLocs(Server, FooCpp);
   ASSERT_TRUE(Server.blockUntilIdleForTest()) << "Waiting for diagnostics";
   EXPECT_FALSE(DiagConsumer.hadErrorInLastDiags());
@@ -368,15 +368,16 @@
 
   // Now switch to C++ mode.
   CDB.ExtraClangFlags = {"-xc++"};
-  // Currently, addDocument never checks if CompileCommand has changed, so we
+  // By default addDocument does not check if CompileCommand has changed, so we
   // expect to see the errors.
   runAddDocument(Server, FooCpp, SourceContents1);
   EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
   runAddDocument(Server, FooCpp, SourceContents2);
   EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
-  // But forceReparse should reparse the file with proper flags.
-  Server.forceReparse(FooCpp);
-  ASSERT_TRUE(Server.blockUntilIdleForTest());
+  // Passing SkipCache=true will force addDocument to reparse the file with
+  // proper flags.
+  runAddDocument(Server, FooCpp, SourceContents2, WantDiagnostics::Auto,
+ /*SkipCache=*/true);
   EXPECT_FALSE(DiagConsumer.hadErrorInLastDiags());
   // Subsequent addDocument calls should finish without errors too.
   runAddDocument(Server, FooCpp, SourceContents1);
@@ -408,12 +409,14 @@
 
   // Parse without the define, no errors should be produced.
   CDB.ExtraClangFlags = {};
-  // Currently, addDocument never checks if CompileCommand has changed, so we
+  // By default addDocument does not check if CompileCommand has changed, so we
   // expect to see the errors.
   runAddDocument(Server, FooCpp, SourceContents);
   EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
-  // But forceReparse should reparse the file with proper flags.
-  Server.forceReparse(FooCpp);
+  // Passing SkipCache=true will force addDocument to reparse the file with
+  // proper flags.
+  runAddDocument(Server, FooCpp, SourceContents, WantDiagnostics::Auto,
+ /*SkipCache=*/true);
   ASSERT_TRUE(Server.blockUntilIdleForTest());
   EXPECT_FALSE(DiagConsumer.hadErrorInLastDiags());
   // Subsequent addDocument call should finish without errors too.
@@ -675,44 +678,31 @@
   Stats.FileIsRemoved = true;
 };
 
-auto UpdateStatsOnForceReparse = [&](unsigned FileIndex) {
-  auto &Stats = ReqStats[FileIndex];
-
-  if (Stats.LastContentsHadErrors)
-++Stats.RequestsWithErrors;
-  else
-++Stats.RequestsWithoutErrors;
-};
-
-auto AddDocument = [&](unsigned FileIndex) {
+auto AddDocument = [&](unsigned FileIndex, bool SkipCache) {
   bool ShouldHaveErrors = ShouldHaveErrorsDist(RandGen);
   Server.addDocument(FilePaths[

[PATCH] D44462: [clangd] Don't use DraftMgr in implementation of forceReparse.

2018-03-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: unittests/clangd/SyncAPI.h:23
+void runAddDocument(ClangdServer &Server, PathRef File, StringRef Contents,
+bool SkipCache = false);
 

sammccall wrote:
> it's slightly odd that wantdiagnostics is missing here. Previously this was 
> "forwards compatible" and could easily be added later. But now we'll have 
> callsites that pass different arguments than addDocument takes.
> 
> Maybe just add the defaulted param to the signature?
Done. I thought it's slightly confusing to have both `Auto` and `Yes` for 
synchronous case, but being consistent with `addDocument` is a good cause to do 
this.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44462



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


[clang-tools-extra] r327532 - [clangd] Remove forceReparse, add a flag to addDocument instead

2018-03-14 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Mar 14 10:08:41 2018
New Revision: 327532

URL: http://llvm.org/viewvc/llvm-project?rev=327532&view=rev
Log:
[clangd] Remove forceReparse, add a flag to addDocument instead

Summary: To make the removal of DraftMgr from ClangdServer easier (D44408).

Reviewers: sammccall, simark

Reviewed By: sammccall, simark

Subscribers: simark, klimek, jkorous-apple, ioeric, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
clang-tools-extra/trunk/unittests/clangd/SyncAPI.cpp
clang-tools-extra/trunk/unittests/clangd/SyncAPI.h

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=327532&r1=327531&r2=327532&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Mar 14 10:08:41 2018
@@ -116,10 +116,19 @@ void ClangdServer::setRootPath(PathRef R
 }
 
 void ClangdServer::addDocument(PathRef File, StringRef Contents,
-   WantDiagnostics WantDiags) {
+   WantDiagnostics WantDiags, bool SkipCache) {
+  if (SkipCache)
+CompileArgs.invalidate(File);
+
   DocVersion Version = DraftMgr.updateDraft(File, Contents);
-  scheduleReparseAndDiags(File, VersionedDraft{Version, Contents.str()},
-  WantDiags, FSProvider.getFileSystem());
+  ParseInputs Inputs = {CompileArgs.getCompileCommand(File),
+FSProvider.getFileSystem(), Contents.str()};
+
+  Path FileStr = File.str();
+  WorkScheduler.update(File, std::move(Inputs), WantDiags,
+   [this, FileStr, Version](std::vector Diags) {
+ consumeDiagnostics(FileStr, Version, 
std::move(Diags));
+   });
 }
 
 void ClangdServer::removeDocument(PathRef File) {
@@ -128,19 +137,6 @@ void ClangdServer::removeDocument(PathRe
   WorkScheduler.remove(File);
 }
 
-void ClangdServer::forceReparse(PathRef File) {
-  auto FileContents = DraftMgr.getDraft(File);
-  assert(FileContents.Draft &&
- "forceReparse() was called for non-added document");
-
-  // forceReparse promises to request new compilation flags from CDB, so we
-  // remove any cahced flags.
-  CompileArgs.invalidate(File);
-
-  scheduleReparseAndDiags(File, std::move(FileContents), WantDiagnostics::Yes,
-  FSProvider.getFileSystem());
-}
-
 void ClangdServer::codeComplete(PathRef File, Position Pos,
 const clangd::CodeCompleteOptions &Opts,
 Callback CB) {
@@ -335,8 +331,8 @@ ClangdServer::insertInclude(PathRef File
   // Replacement with offset UINT_MAX and length 0 will be treated as include
   // insertion.
   tooling::Replacement R(File, /*Offset=*/UINT_MAX, 0, "#include " + 
ToInclude);
-  auto Replaces = format::cleanupAroundReplacements(
-  Code, tooling::Replacements(R), *Style);
+  auto Replaces =
+  format::cleanupAroundReplacements(Code, tooling::Replacements(R), 
*Style);
   if (!Replaces)
 return Replaces;
   return formatReplacements(Code, *Replaces, *Style);
@@ -499,39 +495,28 @@ void ClangdServer::findHover(PathRef Fil
   WorkScheduler.runWithAST("Hover", File, Bind(Action, std::move(CB)));
 }
 
-void ClangdServer::scheduleReparseAndDiags(
-PathRef File, VersionedDraft Contents, WantDiagnostics WantDiags,
-IntrusiveRefCntPtr FS) {
-  tooling::CompileCommand Command = CompileArgs.getCompileCommand(File);
-
-  DocVersion Version = Contents.Version;
-  Path FileStr = File.str();
-
-  auto Callback = [this, Version, FileStr](std::vector Diags) {
-// We need to serialize access to resulting diagnostics to avoid calling
-// `onDiagnosticsReady` in the wrong order.
-std::lock_guard DiagsLock(DiagnosticsMutex);
-DocVersion &LastReportedDiagsVersion = ReportedDiagnosticVersions[FileStr];
-// FIXME(ibiryukov): get rid of '<' comparison here. In the current
-// implementation diagnostics will not be reported after version counters'
-// overflow. This should not happen in practice, since DocVersion is a
-// 64-bit unsigned integer.
-if (Version < LastReportedDiagsVersion)
-  return;
-LastReportedDiagsVersion = Version;
-
-DiagConsumer.onDiagnosticsReady(FileStr, std::move(Diags));
-  };
+void ClangdServer::consumeDiagnostics(PathRef File, DocVersion Version,
+  std::vector Diags) {
+  // We need to serialize access to resulting diagnostics to avoid calling
+  // `onDiagnosticsReady` in the wrong order.
+  std::lock_guard DiagsLock(DiagnosticsMutex);
+  DocVersion &LastReportedDiagsVersion = ReportedDiag

[PATCH] D44462: [clangd] Don't use DraftMgr in implementation of forceReparse.

2018-03-14 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL327532: [clangd] Remove forceReparse, add a flag to 
addDocument instead (authored by ibiryukov, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D44462

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

Index: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
@@ -245,13 +245,13 @@
   EXPECT_FALSE(DiagConsumer.hadErrorInLastDiags());
 
   FS.Files[FooH] = "";
-  Server.forceReparse(FooCpp);
+  Server.addDocument(FooCpp, SourceContents);
   auto DumpParseDifferent = dumpASTWithoutMemoryLocs(Server, FooCpp);
   ASSERT_TRUE(Server.blockUntilIdleForTest()) << "Waiting for diagnostics";
   EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
 
   FS.Files[FooH] = "int a;";
-  Server.forceReparse(FooCpp);
+  Server.addDocument(FooCpp, SourceContents);
   auto DumpParse2 = dumpASTWithoutMemoryLocs(Server, FooCpp);
   ASSERT_TRUE(Server.blockUntilIdleForTest()) << "Waiting for diagnostics";
   EXPECT_FALSE(DiagConsumer.hadErrorInLastDiags());
@@ -368,15 +368,16 @@
 
   // Now switch to C++ mode.
   CDB.ExtraClangFlags = {"-xc++"};
-  // Currently, addDocument never checks if CompileCommand has changed, so we
+  // By default addDocument does not check if CompileCommand has changed, so we
   // expect to see the errors.
   runAddDocument(Server, FooCpp, SourceContents1);
   EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
   runAddDocument(Server, FooCpp, SourceContents2);
   EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
-  // But forceReparse should reparse the file with proper flags.
-  Server.forceReparse(FooCpp);
-  ASSERT_TRUE(Server.blockUntilIdleForTest());
+  // Passing SkipCache=true will force addDocument to reparse the file with
+  // proper flags.
+  runAddDocument(Server, FooCpp, SourceContents2, WantDiagnostics::Auto,
+ /*SkipCache=*/true);
   EXPECT_FALSE(DiagConsumer.hadErrorInLastDiags());
   // Subsequent addDocument calls should finish without errors too.
   runAddDocument(Server, FooCpp, SourceContents1);
@@ -408,12 +409,14 @@
 
   // Parse without the define, no errors should be produced.
   CDB.ExtraClangFlags = {};
-  // Currently, addDocument never checks if CompileCommand has changed, so we
+  // By default addDocument does not check if CompileCommand has changed, so we
   // expect to see the errors.
   runAddDocument(Server, FooCpp, SourceContents);
   EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
-  // But forceReparse should reparse the file with proper flags.
-  Server.forceReparse(FooCpp);
+  // Passing SkipCache=true will force addDocument to reparse the file with
+  // proper flags.
+  runAddDocument(Server, FooCpp, SourceContents, WantDiagnostics::Auto,
+ /*SkipCache=*/true);
   ASSERT_TRUE(Server.blockUntilIdleForTest());
   EXPECT_FALSE(DiagConsumer.hadErrorInLastDiags());
   // Subsequent addDocument call should finish without errors too.
@@ -675,44 +678,31 @@
   Stats.FileIsRemoved = true;
 };
 
-auto UpdateStatsOnForceReparse = [&](unsigned FileIndex) {
-  auto &Stats = ReqStats[FileIndex];
-
-  if (Stats.LastContentsHadErrors)
-++Stats.RequestsWithErrors;
-  else
-++Stats.RequestsWithoutErrors;
-};
-
-auto AddDocument = [&](unsigned FileIndex) {
+auto AddDocument = [&](unsigned FileIndex, bool SkipCache) {
   bool ShouldHaveErrors = ShouldHaveErrorsDist(RandGen);
   Server.addDocument(FilePaths[FileIndex],
  ShouldHaveErrors ? SourceContentsWithErrors
-  : SourceContentsWithoutErrors);
+  : SourceContentsWithoutErrors,
+ WantDiagnostics::Auto, SkipCache);
   UpdateStatsOnAddDocument(FileIndex, ShouldHaveErrors);
 };
 
 // Various requests that we would randomly run.
 auto AddDocumentRequest = [&]() {
   unsigned FileIndex = FileIndexDist(RandGen);
-  AddDocument(FileIndex);
+  AddDocument(FileIndex, /*SkipCache=*/false);
 };
 
 auto ForceReparseRequest = [&]() {
   unsigned FileIndex = FileIndexDist(RandGen);
-  // Make sure we don't violate the ClangdServer's contract.
-  if (ReqStats[FileIndex].FileIsRemoved)
-AddDocument(FileIndex);
-
-  Server.forceReparse(FilePaths[FileIndex]);
-  UpdateStatsOnForceReparse(FileIndex);
+  AddDocument(FileIndex, /*SkipCache=*/true);
 };
 
 auto RemoveDocumentRequest = [&]() {
   unsig

[PATCH] D43766: [clang-tidy][modernize-make-unique] Checks c++14 flag before using std::make_unique

2018-03-14 Thread Frederic Tingaud via Phabricator via cfe-commits
ftingaud updated this revision to Diff 138398.
ftingaud added a comment.

Clean code along code review recommendations.


https://reviews.llvm.org/D43766

Files:
  clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tidy/modernize/MakeSmartPtrCheck.h
  clang-tidy/modernize/MakeUniqueCheck.cpp
  clang-tidy/modernize/MakeUniqueCheck.h
  test/clang-tidy/modernize-make-unique-cxx11.cpp
  test/clang-tidy/modernize-make-unique-cxx14.cpp
  test/clang-tidy/modernize-make-unique-macros.cpp
  test/clang-tidy/modernize-make-unique.cpp

Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s modernize-make-unique %t -- -- -std=c++11 \
+// RUN: %check_clang_tidy %s modernize-make-unique %t -- -- -std=c++14 \
 // RUN:   -I%S/Inputs/modernize-smart-ptr
 
 #include "unique_ptr.h"
Index: test/clang-tidy/modernize-make-unique-macros.cpp
===
--- test/clang-tidy/modernize-make-unique-macros.cpp
+++ test/clang-tidy/modernize-make-unique-macros.cpp
@@ -1,6 +1,6 @@
 // RUN: %check_clang_tidy %s modernize-make-unique %t -- \
 // RUN:   -config="{CheckOptions: [{key: modernize-make-unique.IgnoreMacros, value: 0}]}" \
-// RUN:   -- -std=c++11  -I%S/Inputs/modernize-smart-ptr
+// RUN:   -- -std=c++14  -I%S/Inputs/modernize-smart-ptr
 
 #include "unique_ptr.h"
 
Index: test/clang-tidy/modernize-make-unique-cxx14.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-make-unique-cxx14.cpp
@@ -0,0 +1,11 @@
+// RUN: %check_clang_tidy %s modernize-make-unique %t -- -- -std=c++14 \
+// RUN:   -I%S/Inputs/modernize-smart-ptr
+
+#include "unique_ptr.h"
+// CHECK-FIXES: #include 
+
+void f() {
+  auto my_ptr = std::unique_ptr(new int(1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use std::make_unique instead
+  // CHECK-FIXES: auto my_ptr = std::make_unique(1);
+}
Index: test/clang-tidy/modernize-make-unique-cxx11.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-make-unique-cxx11.cpp
@@ -0,0 +1,10 @@
+// RUN: %check_clang_tidy %s modernize-make-unique %t -- -- -std=c++11 \
+// RUN:   -I%S/Inputs/modernize-smart-ptr
+
+#include "unique_ptr.h"
+// CHECK-FIXES: #include "unique_ptr.h"
+
+void f() {
+  auto my_ptr = std::unique_ptr(new int(1));
+  // CHECK-FIXES: auto my_ptr = std::unique_ptr(new int(1));
+}
Index: clang-tidy/modernize/MakeUniqueCheck.h
===
--- clang-tidy/modernize/MakeUniqueCheck.h
+++ clang-tidy/modernize/MakeUniqueCheck.h
@@ -31,6 +31,11 @@
 
 protected:
   SmartPtrTypeMatcher getSmartPointerTypeMatcher() const override;
+
+  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override;
+
+private:
+  const bool RequireCPlusPlus14;
 };
 
 } // namespace modernize
Index: clang-tidy/modernize/MakeUniqueCheck.cpp
===
--- clang-tidy/modernize/MakeUniqueCheck.cpp
+++ clang-tidy/modernize/MakeUniqueCheck.cpp
@@ -17,7 +17,8 @@
 
 MakeUniqueCheck::MakeUniqueCheck(StringRef Name,
  clang::tidy::ClangTidyContext *Context)
-: MakeSmartPtrCheck(Name, Context, "std::make_unique") {}
+: MakeSmartPtrCheck(Name, Context, "std::make_unique"),
+  RequireCPlusPlus14(Options.get("MakeSmartPtrFunction", "").empty()) {}
 
 MakeUniqueCheck::SmartPtrTypeMatcher
 MakeUniqueCheck::getSmartPointerTypeMatcher() const {
@@ -36,6 +37,11 @@
 equalsBoundNode(PointerType;
 }
 
+bool MakeUniqueCheck::isLanguageVersionSupported(
+const LangOptions &LangOpts) const {
+  return RequireCPlusPlus14 ? LangOpts.CPlusPlus14 : LangOpts.CPlusPlus11;
+}
+
 } // namespace modernize
 } // namespace tidy
 } // namespace clang
Index: clang-tidy/modernize/MakeSmartPtrCheck.h
===
--- clang-tidy/modernize/MakeSmartPtrCheck.h
+++ clang-tidy/modernize/MakeSmartPtrCheck.h
@@ -40,6 +40,9 @@
   /// in this class.
   virtual SmartPtrTypeMatcher getSmartPointerTypeMatcher() const = 0;
 
+  /// Returns whether the C++ version is compatible with current check.
+  virtual bool isLanguageVersionSupported(const LangOptions &LangOpts) const;
+
   static const char PointerType[];
   static const char ConstructorCall[];
   static const char ResetCall[];
Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -61,16 +61,21 @@
   Options.store(Opts, "IgnoreMacros", IgnoreMacros);
 }
 
+bool MakeSmartPtrCheck::isLanguageVersionSupported(
+const 

[PATCH] D41968: [libunwind][MIPS] Support MIPS floating-point registers for hard-float ABIs.

2018-03-14 Thread John Baldwin via Phabricator via cfe-commits
bsdjhb added a comment.

@sdardis ping.  I think the approach I've used for O32 is probably the right 
one in that it matches what DWARF expects (DWARF doesn't treat the 32-bit 
floating point registers as pairs but as individual registers).  I think the 
question is if I O32 with 32-bit FP registers should use an array of float[]s 
instead of an array of double[]s though (which adds an extra #ifdef for context 
size) vs keeping the current layout.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D41968



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


[PATCH] D43967: [ASTImporter] Add test helper Fixture

2018-03-14 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Hello Gabor,

Sorry for the delay with review: the patch is pretty big and it was hard to 
find time for reviewing it.
I like the patch but it requires some cleanup like formatting changes. Could 
you please clang-format new code?
Also, I'd like to avoid code duplication. I pointed some places where it 
happens.




Comment at: unittests/AST/ASTImporterTest.cpp:167
+
+  // We may have several From context and related translation units.  In each
+  // AST, the buffers for the source are handled via references and are set

context_s_; two spaces before 'In'.



Comment at: unittests/AST/ASTImporterTest.cpp:178
+  // already exists then the file will not be created again as a duplicate.
+  void createVirtualFile(StringRef FileName, const std::string &Code) {
+assert(ToAST);

Could you refactor `testImport()` to use `createVirtualFile()` to avoid code 
duplication?



Comment at: unittests/AST/ASTImporterTest.cpp:194
+  // of the identifier into the To context.
+  // Must not call more than once within the same test.
+  std::tuple

Must not be called?



Comment at: unittests/AST/ASTImporterTest.cpp:197
+  getImportedDecl(StringRef FromSrcCode, Language FromLang, StringRef 
ToSrcCode,
+  Language ToLang, StringRef Identifier = "declToImport") {
+ArgVector FromArgs = getBasicRunOptionsForLanguage(FromLang),

This magic constant was factored out in my review.



Comment at: unittests/AST/ASTImporterTest.cpp:198
+  Language ToLang, StringRef Identifier = "declToImport") {
+ArgVector FromArgs = getBasicRunOptionsForLanguage(FromLang),
+  ToArgs = getBasicRunOptionsForLanguage(ToLang);

This means that testing under MSVC is omitted. It caused a lot of buildbot 
headache before, so I strongly recommend to add it.



Comment at: unittests/AST/ASTImporterTest.cpp:202
+FromTUs.emplace_back(FromSrcCode, InputFileName, FromArgs);
+TU &FromTu = FromTUs.back();
+

FromTU?



Comment at: unittests/AST/ASTImporterTest.cpp:226
+
+Decl *Imported = Importer.Import(*FoundDecls.begin());
+assert(Imported);

`FoundDecls.front()`



Comment at: unittests/AST/ASTImporterTest.cpp:978
+R"(
+template
+struct X {};

Could you please format inline code?



Comment at: unittests/AST/ASTImporterTest.cpp:1090
+  R"(
+template
+class Base {};

Sometimes we start raw literal from the beginning of the line, sometimes - with 
indent. Is there any common style?



Comment at: unittests/AST/ASTImporterTest.cpp:1193
+
+  auto Check = [](Decl *D) -> bool {
+std::array FieldNamesInOrder{{"a", "b", "c"}};

Code duplication with upper example. In my patch, I introduced a matcher for 
this; I think it can be reused here.



Comment at: unittests/AST/ASTImporterTest.cpp:1254
+  std::tie(From, To) = getImportedDecl(
+R"(
+void declToImport() {}

This can be written on single line.



Comment at: unittests/AST/ASTImporterTest.cpp:1365
+
+  // There must be only one imported FunctionDecl ...
+  EXPECT_TRUE(FirstDeclMatcher().match(ToTU, Pattern) ==

It looks like this piece of code duplicates below several times. If so, I think 
it should be factored into a separate function.



Comment at: unittests/AST/ASTImporterTest.cpp:1443
+   ImportDefinitionThenPrototype) {
+  auto Pattern = functionDecl(hasName("f"));
+

This `Pattern` is repeated often.



Comment at: unittests/AST/ASTImporterTest.cpp:1494
+  EXPECT_TRUE(!ProtoD->doesThisDeclarationHaveABody());
+  FunctionDecl* DefinitionD = LastDeclMatcher().match(ToTU, 
Pattern);
+  EXPECT_TRUE(DefinitionD->doesThisDeclarationHaveABody());

FunctionDecl *DefinitionD (same upper).



Comment at: unittests/AST/ASTImporterTest.cpp:1526
+
+TEST_F(ImportFunctions,
+   OverriddenMethodsShouldBeImported) {

This fits 80-char limit, no need to split.



Comment at: unittests/AST/DeclMatcher.h:33
+  template 
+  NodeType *match(const Decl *D, const MatcherType &AMatcher) {
+MatchFinder Finder;

We can use `ASTContext &` directly instead of `const Decl *`.



Comment at: unittests/AST/DeclMatcher.h:48
+class DeclCounter : public MatchFinder::MatchCallback {
+  unsigned count = 0;
+  void run(const MatchFinder::MatchResult &Result) override {

Member names should start with capital: `Count`.



Comment at: unittests/AST/DeclMatcher.h:59
+MatchFinder Finder;
+Finder.addMatcher(AMatcher.bind(""), this);
+Finder.match

[PATCH] D44188: Misc typos

2018-03-14 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

You may want to split the patch into smaller pieces -- per leaf directory, for 
example. 
That way potential reviewers would at least be able to see the changes 
(hundreds of files in one patch is a bit too much), and the subset of changes 
would be small enough for someone to own it (or at least familiar enough with 
it to give approval).


Repository:
  rC Clang

https://reviews.llvm.org/D44188



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


[PATCH] D41217: [Concepts] Concept Specialization Expressions

2018-03-14 Thread Faisal Vali via Phabricator via cfe-commits
faisalv added inline comments.



Comment at: include/clang/AST/ExprCXX.h:4416
+/// According to C++2a [expr.prim.id]p3 an id-expression that denotes the
+/// specialization of a concepts results in a prvalue of type bool.
+class ConceptSpecializationExpr final : public Expr {

Typo (Hubert): concepts -> concept



Comment at: include/clang/AST/ExprCXX.h:4419
+protected:
+  /// \brief The concept specialization this represents.
+  ConceptDecl *SpecializedConcept;

Hubert: The concept named.



Comment at: include/clang/AST/ExprCXX.h:4420
+  /// \brief The concept specialization this represents.
+  ConceptDecl *SpecializedConcept;
+

NamedConcept



Comment at: include/clang/Sema/Sema.h:5577
+ ConceptDecl *CTD,
+   const TemplateArgumentListInfo *TALI);
+

Hubert: clang-format this



Comment at: include/clang/Sema/Sema.h:5580
+  /// Check whether the given expression is a valid constraint expression.
+  /// A diagnostic is emmited if it is not, and false is returned.
+  bool CheckConstraintExpression(Expr *CE);

Hubert: Typo: emitted



Comment at: lib/AST/ExprCXX.cpp:1441
+ConceptSpecializationExpr::ConceptSpecializationExpr(ASTContext &C, Sema &S,
+  SourceLocation 
ConceptNameLoc,
+ ConceptDecl *CD,

Hubert: clang-format



Comment at: lib/AST/ExprCXX.cpp:1478
+  {
+// We do not want error diagnostics escaping here.
+Sema::SFINAETrap Trap(S);

Hubert: This needs a TODO: the idea is not to drop SFINAE errors, but to avoid 
instantiation that may trigger errors not in the immediate context of 
instantiation. The substitution needs to happen piecewise.



Comment at: lib/AST/ExprCXX.cpp:1485
+  //   constraint is not satisfied.
+  IsSatisfied = false;
+  return true;

Hubert: The name of the function gives no indication that it modifies the 
expression node. The interface of the function extends past what is expected.


Repository:
  rC Clang

https://reviews.llvm.org/D41217



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


[PATCH] D44435: Add the module name to __cuda_module_ctor and __cuda_module_dtor for unique function names

2018-03-14 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGCUDANV.cpp:281
 
+  // get name from the module to generate unique ctor name for every module
+  SmallString<128> ModuleName

SimeonEhrig wrote:
> tra wrote:
> > SimeonEhrig wrote:
> > > rjmccall wrote:
> > > > Please explain in the comment *why* you're doing this.  It's just for 
> > > > debugging, right?  So that it's known which object file the constructor 
> > > > function comes from.
> > > The motivation is the same at this review: https://reviews.llvm.org/D34059
> > > We try to enable incremental compiling of cuda runtime code, so we need 
> > > unique ctor/dtor names, to handle the cuda device code over different 
> > > modules. 
> > I'm also interested in in the motivation for this change.
> > 
> > Also, if the goal is to have an unique module identifier, would compiling 
> > two different files with the same name be a problem? If the goal is to help 
> > identifying a module, this may be OK, if not ideal. If you really need to 
> > have unique name, then you may need to do something more elaborate. NVCC 
> > appears to use some random number (or hash of something?) for that.
> We need this modification for our C++-interpreter Cling, which we want to 
> expand to interpret CUDA runtime code. Effective, it's a jit, which read in 
> line by line the program code. Every line get his own llvm::Module. The 
> Interpreter works with incremental and lazy compilation. Because the lazy 
> compilation, we needs this modification. In the CUDA mode, clang generates  
> for every module an _ _cuda_module_ctor and _ _cuda_module_dtor, if the 
> compiler was started with a path to a fatbinary file. But the ctor is also 
> depend on the source code, which will translate to llvm IR in the module. For 
> Example, if a _ _global_ _ kernel will defined, the CodeGen add the function 
> call __cuda_register_globals() to the ctor. But the lazy compilations 
> prevents, that we can translate a function, which is already translate. 
> Without the modification, the interpreter things, that the ctor is always 
> same and use the first translation of the function, which was generate. 
> Therefore, it is impossible to add new kernels. 
I'm not asking you to explain to *me* why you're doing this, I'm asking you to 
explain *in the comment* why you're doing this.

That said, we should discuss this.  It sounds like you need the function to 
have a unique name because otherwise you're seeing inter-module conflicts 
between incremental slices.  Since the function is emitted with internal 
linkage, I assume that those conflicts must be because you're promoting 
internal linkage to external in order to make incremental processing able to 
link to declarations from an earlier slice of the translation unit.  I really 
think that a better solution would be to change how we assign LLVM linkage to 
static global declarations in IRGen — basically, recognizing the difference 
between internal linkage (where different parts of the translation unit can 
still refer to the same entity) and no linkage at all (where they cannot).  We 
could then continue to emit truly private entities, like global ctors/dtors, 
lambda bodies, block functions, and so on, with internal/private linkage 
without worrying about how your pass will mess up the linkage later.


Repository:
  rC Clang

https://reviews.llvm.org/D44435



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


[PATCH] D44463: [clangd] Don't expose vfs in TUScheduler::runWithPreamble.

2018-03-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 138409.
ilya-biryukov added a comment.

- Rebase on top of master
- Add the suggested comment


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44463

Files:
  clangd/ClangdServer.cpp
  clangd/TUScheduler.cpp
  clangd/TUScheduler.h
  unittests/clangd/TUSchedulerTests.cpp

Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -226,8 +226,7 @@
 EXPECT_THAT(Context::current().get(NonceKey), Pointee(Nonce));
 
 ASSERT_TRUE((bool)Preamble);
-EXPECT_EQ(Preamble->Inputs.FS, Inputs.FS);
-EXPECT_EQ(Preamble->Inputs.Contents, Inputs.Contents);
+EXPECT_EQ(Preamble->Contents, Inputs.Contents);
 
 std::lock_guard Lock(Mut);
 ++TotalPreambleReads;
Index: clangd/TUScheduler.h
===
--- clangd/TUScheduler.h
+++ clangd/TUScheduler.h
@@ -29,7 +29,8 @@
 };
 
 struct InputsAndPreamble {
-  const ParseInputs &Inputs;
+  llvm::StringRef Contents;
+  const tooling::CompileCommand &Command;
   const PreambleData *Preamble;
 };
 
@@ -78,11 +79,14 @@
   void runWithAST(llvm::StringRef Name, PathRef File,
   Callback Action);
 
-  /// Schedule an async read of the Preamble. Preamble passed to \p Action may
-  /// be built for any version of the file, callers must not rely on it being
-  /// consistent with the current version of the file.
-  /// If an error occurs during processing, it is forwarded to the \p Action
-  /// callback.
+  /// Schedule an async read of the Preamble.
+  /// The preamble may be stale, generated from an older version of the file.
+  /// Reading from locations in the preamble may cause the files to be re-read.
+  /// This gives callers two options:
+  /// - validate that the preamble is still valid, and only use it in this case
+  /// - accept that preamble contents may be outdated, and try to avoid reading
+  /// source code from headers. If an error occurs during processing, it is
+  /// forwarded to the \p Action callback.
   void runWithPreamble(llvm::StringRef Name, PathRef File,
Callback Action);
 
Index: clangd/TUScheduler.cpp
===
--- clangd/TUScheduler.cpp
+++ clangd/TUScheduler.cpp
@@ -407,7 +407,8 @@
 
 struct TUScheduler::FileData {
   /// Latest inputs, passed to TUScheduler::update().
-  ParseInputs Inputs;
+  std::string Contents;
+  tooling::CompileCommand Command;
   ASTWorkerHandle Worker;
 };
 
@@ -456,9 +457,11 @@
 File, WorkerThreads ? WorkerThreads.getPointer() : nullptr, Barrier,
 CppFile(File, StorePreamblesInMemory, PCHOps, ASTCallback),
 UpdateDebounce);
-FD = std::unique_ptr(new FileData{Inputs, std::move(Worker)});
+FD = std::unique_ptr(new FileData{
+Inputs.Contents, Inputs.CompileCommand, std::move(Worker)});
   } else {
-FD->Inputs = Inputs;
+FD->Contents = Inputs.Contents;
+FD->Command = Inputs.CompileCommand;
   }
   FD->Worker->update(std::move(Inputs), WantDiags, std::move(OnUpdated));
 }
@@ -500,26 +503,28 @@
 SPAN_ATTACH(Tracer, "file", File);
 std::shared_ptr Preamble =
 It->second->Worker->getPossiblyStalePreamble();
-Action(InputsAndPreamble{It->second->Inputs, Preamble.get()});
+Action(InputsAndPreamble{It->second->Contents, It->second->Command,
+ Preamble.get()});
 return;
   }
 
-  ParseInputs InputsCopy = It->second->Inputs;
   std::shared_ptr Worker = It->second->Worker.lock();
-  auto Task = [InputsCopy, Worker, this](std::string Name, std::string File,
- Context Ctx,
- decltype(Action) Action) mutable {
+  auto Task = [Worker, this](std::string Name, std::string File,
+ std::string Contents,
+ tooling::CompileCommand Command, Context Ctx,
+ decltype(Action) Action) mutable {
 std::lock_guard BarrierLock(Barrier);
 WithContext Guard(std::move(Ctx));
 trace::Span Tracer(Name);
 SPAN_ATTACH(Tracer, "file", File);
 std::shared_ptr Preamble =
 Worker->getPossiblyStalePreamble();
-Action(InputsAndPreamble{InputsCopy, Preamble.get()});
+Action(InputsAndPreamble{Contents, Command, Preamble.get()});
   };
 
   PreambleTasks->runAsync("task:" + llvm::sys::path::filename(File),
   Bind(Task, std::string(Name), std::string(File),
+   It->second->Contents, It->second->Command,
Context::current().clone(), std::move(Action)));
 }
 
Index: clangd/ClangdServer.cpp
=

[PATCH] D44482: Set dso_local for NSConcreteStackBlock

2018-03-14 Thread Rafael Avila de Espindola via Phabricator via cfe-commits
espindola created this revision.
espindola added reviewers: rnk, echristo.

https://reviews.llvm.org/D44482

Files:
  lib/CodeGen/CGBlocks.cpp
  test/CodeGen/blocks-windows.c


Index: test/CodeGen/blocks-windows.c
===
--- test/CodeGen/blocks-windows.c
+++ test/CodeGen/blocks-windows.c
@@ -67,7 +67,7 @@
   return _Block_copy(^{ ++i; return i; });
 }
 
-// CHECK-BLOCKS-IN-BLOCKS-DECL: @_NSConcreteStackBlock = external dllexport 
global i8*
+// CHECK-BLOCKS-IN-BLOCKS-DECL: @_NSConcreteStackBlock = external dso_local 
dllexport global i8*
 // CHECK-BLOCKS-IN-BLOCKS-DEFN: @_NSConcreteStackBlock = common dso_local 
dllexport global [5 x i32]
 // CHECK-BLOCKS-NOT-IN-BLOCKS: @_NSConcreteStackBlock = external dllimport 
global i8*
 // CHECK-BLOCKS-NOT-IN-BLOCKS-EXTERN: @_NSConcreteStackBlock = external 
dllimport global i8*
Index: lib/CodeGen/CGBlocks.cpp
===
--- lib/CodeGen/CGBlocks.cpp
+++ lib/CodeGen/CGBlocks.cpp
@@ -2586,11 +2586,11 @@
 }
   }
 
-  if (!CGM.getLangOpts().BlocksRuntimeOptional)
-return;
-
-  if (GV->isDeclaration() && GV->hasExternalLinkage())
+  if (CGM.getLangOpts().BlocksRuntimeOptional && GV->isDeclaration() &&
+  GV->hasExternalLinkage())
 GV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage);
+
+  CGM.setDSOLocal(GV);
 }
 
 llvm::Constant *CodeGenModule::getBlockObjectDispose() {


Index: test/CodeGen/blocks-windows.c
===
--- test/CodeGen/blocks-windows.c
+++ test/CodeGen/blocks-windows.c
@@ -67,7 +67,7 @@
   return _Block_copy(^{ ++i; return i; });
 }
 
-// CHECK-BLOCKS-IN-BLOCKS-DECL: @_NSConcreteStackBlock = external dllexport global i8*
+// CHECK-BLOCKS-IN-BLOCKS-DECL: @_NSConcreteStackBlock = external dso_local dllexport global i8*
 // CHECK-BLOCKS-IN-BLOCKS-DEFN: @_NSConcreteStackBlock = common dso_local dllexport global [5 x i32]
 // CHECK-BLOCKS-NOT-IN-BLOCKS: @_NSConcreteStackBlock = external dllimport global i8*
 // CHECK-BLOCKS-NOT-IN-BLOCKS-EXTERN: @_NSConcreteStackBlock = external dllimport global i8*
Index: lib/CodeGen/CGBlocks.cpp
===
--- lib/CodeGen/CGBlocks.cpp
+++ lib/CodeGen/CGBlocks.cpp
@@ -2586,11 +2586,11 @@
 }
   }
 
-  if (!CGM.getLangOpts().BlocksRuntimeOptional)
-return;
-
-  if (GV->isDeclaration() && GV->hasExternalLinkage())
+  if (CGM.getLangOpts().BlocksRuntimeOptional && GV->isDeclaration() &&
+  GV->hasExternalLinkage())
 GV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage);
+
+  CGM.setDSOLocal(GV);
 }
 
 llvm::Constant *CodeGenModule::getBlockObjectDispose() {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r327537 - [clangd] Don't expose vfs in TUScheduler::runWithPreamble.

2018-03-14 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Mar 14 10:46:52 2018
New Revision: 327537

URL: http://llvm.org/viewvc/llvm-project?rev=327537&view=rev
Log:
[clangd] Don't expose vfs in TUScheduler::runWithPreamble.

Summary:
It was previously an easy way to concurrently access a mutable vfs,
which is a recipe for disaster.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: klimek, jkorous-apple, cfe-commits, ioeric

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

Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/TUScheduler.cpp
clang-tools-extra/trunk/clangd/TUScheduler.h
clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=327537&r1=327536&r2=327537&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Mar 14 10:46:52 2018
@@ -159,12 +159,11 @@ void ClangdServer::codeComplete(PathRef
   llvm::Expected IP) {
 assert(IP && "error when trying to read preamble for codeComplete");
 auto PreambleData = IP->Preamble;
-auto &Command = IP->Inputs.CompileCommand;
 
 // FIXME(ibiryukov): even if Preamble is non-null, we may want to check
 // both the old and the new version in case only one of them matches.
 CompletionList Result = clangd::codeComplete(
-File, Command, PreambleData ? &PreambleData->Preamble : nullptr,
+File, IP->Command, PreambleData ? &PreambleData->Preamble : nullptr,
 Contents, Pos, FS, PCHs, CodeCompleteOpts);
 CB(std::move(Result));
   };
@@ -191,8 +190,7 @@ void ClangdServer::signatureHelp(PathRef
   return CB(IP.takeError());
 
 auto PreambleData = IP->Preamble;
-auto &Command = IP->Inputs.CompileCommand;
-CB(clangd::signatureHelp(File, Command,
+CB(clangd::signatureHelp(File, IP->Command,
  PreambleData ? &PreambleData->Preamble : nullptr,
  Contents, Pos, FS, PCHs));
   };

Modified: clang-tools-extra/trunk/clangd/TUScheduler.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/TUScheduler.cpp?rev=327537&r1=327536&r2=327537&view=diff
==
--- clang-tools-extra/trunk/clangd/TUScheduler.cpp (original)
+++ clang-tools-extra/trunk/clangd/TUScheduler.cpp Wed Mar 14 10:46:52 2018
@@ -407,7 +407,8 @@ unsigned getDefaultAsyncThreadsCount() {
 
 struct TUScheduler::FileData {
   /// Latest inputs, passed to TUScheduler::update().
-  ParseInputs Inputs;
+  std::string Contents;
+  tooling::CompileCommand Command;
   ASTWorkerHandle Worker;
 };
 
@@ -456,9 +457,11 @@ void TUScheduler::update(PathRef File, P
 File, WorkerThreads ? WorkerThreads.getPointer() : nullptr, Barrier,
 CppFile(File, StorePreamblesInMemory, PCHOps, ASTCallback),
 UpdateDebounce);
-FD = std::unique_ptr(new FileData{Inputs, std::move(Worker)});
+FD = std::unique_ptr(new FileData{
+Inputs.Contents, Inputs.CompileCommand, std::move(Worker)});
   } else {
-FD->Inputs = Inputs;
+FD->Contents = Inputs.Contents;
+FD->Command = Inputs.CompileCommand;
   }
   FD->Worker->update(std::move(Inputs), WantDiags, std::move(OnUpdated));
 }
@@ -500,26 +503,28 @@ void TUScheduler::runWithPreamble(
 SPAN_ATTACH(Tracer, "file", File);
 std::shared_ptr Preamble =
 It->second->Worker->getPossiblyStalePreamble();
-Action(InputsAndPreamble{It->second->Inputs, Preamble.get()});
+Action(InputsAndPreamble{It->second->Contents, It->second->Command,
+ Preamble.get()});
 return;
   }
 
-  ParseInputs InputsCopy = It->second->Inputs;
   std::shared_ptr Worker = It->second->Worker.lock();
-  auto Task = [InputsCopy, Worker, this](std::string Name, std::string File,
- Context Ctx,
- decltype(Action) Action) mutable {
+  auto Task = [Worker, this](std::string Name, std::string File,
+ std::string Contents,
+ tooling::CompileCommand Command, Context Ctx,
+ decltype(Action) Action) mutable {
 std::lock_guard BarrierLock(Barrier);
 WithContext Guard(std::move(Ctx));
 trace::Span Tracer(Name);
 SPAN_ATTACH(Tracer, "file", File);
 std::shared_ptr Preamble =
 Worker->getPossiblyStalePreamble();
-Action(InputsAndPreamble{InputsCopy, Preamble.get()});
+Action(InputsAndPreamble{Contents, Command, Preamble.get()});
   };
 
   PreambleTasks->runAsync("task:" + llvm::sys::path::filename(File),
   Bind(Task, std::string(Name), std::string(File),
+   

[PATCH] D44463: [clangd] Don't expose vfs in TUScheduler::runWithPreamble.

2018-03-14 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE327537: [clangd] Don't expose vfs in 
TUScheduler::runWithPreamble. (authored by ibiryukov, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44463?vs=138409&id=138411#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44463

Files:
  clangd/ClangdServer.cpp
  clangd/TUScheduler.cpp
  clangd/TUScheduler.h
  unittests/clangd/TUSchedulerTests.cpp

Index: clangd/TUScheduler.cpp
===
--- clangd/TUScheduler.cpp
+++ clangd/TUScheduler.cpp
@@ -407,7 +407,8 @@
 
 struct TUScheduler::FileData {
   /// Latest inputs, passed to TUScheduler::update().
-  ParseInputs Inputs;
+  std::string Contents;
+  tooling::CompileCommand Command;
   ASTWorkerHandle Worker;
 };
 
@@ -456,9 +457,11 @@
 File, WorkerThreads ? WorkerThreads.getPointer() : nullptr, Barrier,
 CppFile(File, StorePreamblesInMemory, PCHOps, ASTCallback),
 UpdateDebounce);
-FD = std::unique_ptr(new FileData{Inputs, std::move(Worker)});
+FD = std::unique_ptr(new FileData{
+Inputs.Contents, Inputs.CompileCommand, std::move(Worker)});
   } else {
-FD->Inputs = Inputs;
+FD->Contents = Inputs.Contents;
+FD->Command = Inputs.CompileCommand;
   }
   FD->Worker->update(std::move(Inputs), WantDiags, std::move(OnUpdated));
 }
@@ -500,26 +503,28 @@
 SPAN_ATTACH(Tracer, "file", File);
 std::shared_ptr Preamble =
 It->second->Worker->getPossiblyStalePreamble();
-Action(InputsAndPreamble{It->second->Inputs, Preamble.get()});
+Action(InputsAndPreamble{It->second->Contents, It->second->Command,
+ Preamble.get()});
 return;
   }
 
-  ParseInputs InputsCopy = It->second->Inputs;
   std::shared_ptr Worker = It->second->Worker.lock();
-  auto Task = [InputsCopy, Worker, this](std::string Name, std::string File,
- Context Ctx,
- decltype(Action) Action) mutable {
+  auto Task = [Worker, this](std::string Name, std::string File,
+ std::string Contents,
+ tooling::CompileCommand Command, Context Ctx,
+ decltype(Action) Action) mutable {
 std::lock_guard BarrierLock(Barrier);
 WithContext Guard(std::move(Ctx));
 trace::Span Tracer(Name);
 SPAN_ATTACH(Tracer, "file", File);
 std::shared_ptr Preamble =
 Worker->getPossiblyStalePreamble();
-Action(InputsAndPreamble{InputsCopy, Preamble.get()});
+Action(InputsAndPreamble{Contents, Command, Preamble.get()});
   };
 
   PreambleTasks->runAsync("task:" + llvm::sys::path::filename(File),
   Bind(Task, std::string(Name), std::string(File),
+   It->second->Contents, It->second->Command,
Context::current().clone(), std::move(Action)));
 }
 
Index: clangd/ClangdServer.cpp
===
--- clangd/ClangdServer.cpp
+++ clangd/ClangdServer.cpp
@@ -159,12 +159,11 @@
   llvm::Expected IP) {
 assert(IP && "error when trying to read preamble for codeComplete");
 auto PreambleData = IP->Preamble;
-auto &Command = IP->Inputs.CompileCommand;
 
 // FIXME(ibiryukov): even if Preamble is non-null, we may want to check
 // both the old and the new version in case only one of them matches.
 CompletionList Result = clangd::codeComplete(
-File, Command, PreambleData ? &PreambleData->Preamble : nullptr,
+File, IP->Command, PreambleData ? &PreambleData->Preamble : nullptr,
 Contents, Pos, FS, PCHs, CodeCompleteOpts);
 CB(std::move(Result));
   };
@@ -191,8 +190,7 @@
   return CB(IP.takeError());
 
 auto PreambleData = IP->Preamble;
-auto &Command = IP->Inputs.CompileCommand;
-CB(clangd::signatureHelp(File, Command,
+CB(clangd::signatureHelp(File, IP->Command,
  PreambleData ? &PreambleData->Preamble : nullptr,
  Contents, Pos, FS, PCHs));
   };
Index: clangd/TUScheduler.h
===
--- clangd/TUScheduler.h
+++ clangd/TUScheduler.h
@@ -29,7 +29,8 @@
 };
 
 struct InputsAndPreamble {
-  const ParseInputs &Inputs;
+  llvm::StringRef Contents;
+  const tooling::CompileCommand &Command;
   const PreambleData *Preamble;
 };
 
@@ -78,11 +79,14 @@
   void runWithAST(llvm::StringRef Name, PathRef File,
   Callback Action);
 
-  /// Schedule an async read of the Preamble. Preamble passed to \p Action may
-  /// be built for any version of the file, callers must not rely on it being
-  /// consistent with the current version of the file.
-  /// If an error occurs during processing, it is forwarded to the \p Action
-  /// callback

[clang-tools-extra] r327539 - [clangd] Fix indentation in the comment. NFC

2018-03-14 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Mar 14 10:49:19 2018
New Revision: 327539

URL: http://llvm.org/viewvc/llvm-project?rev=327539&view=rev
Log:
[clangd] Fix indentation in the comment. NFC

Modified:
clang-tools-extra/trunk/clangd/TUScheduler.h

Modified: clang-tools-extra/trunk/clangd/TUScheduler.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/TUScheduler.h?rev=327539&r1=327538&r2=327539&view=diff
==
--- clang-tools-extra/trunk/clangd/TUScheduler.h (original)
+++ clang-tools-extra/trunk/clangd/TUScheduler.h Wed Mar 14 10:49:19 2018
@@ -85,8 +85,9 @@ public:
   /// This gives callers two options:
   /// - validate that the preamble is still valid, and only use it in this case
   /// - accept that preamble contents may be outdated, and try to avoid reading
-  /// source code from headers. If an error occurs during processing, it is
-  /// forwarded to the \p Action callback.
+  ///   source code from headers.
+  /// If an error occurs during processing, it is forwarded to the \p Action
+  /// callback.
   void runWithPreamble(llvm::StringRef Name, PathRef File,
Callback Action);
 


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


[PATCH] D44482: Set dso_local for NSConcreteStackBlock

2018-03-14 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D44482



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


[PATCH] D44480: [Sema] Don't skip function bodies with 'auto' without trailing return type

2018-03-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: rsmith.
aaron.ballman added a comment.

Adding Richard as a reviewer, because this seems somewhat clever to me (so 
there may be a better change to make).




Comment at: lib/Sema/SemaDecl.cpp:12611
+// false on C++14's auto return type without trailing return type.
+auto *DT = FD->getReturnType()->getContainedDeducedType();
+if (DT && DT->getDeducedType().isNull())

Please don't use `auto` here as the type is not spelled out explicitly. Also, 
the type can be const-qualified.


Repository:
  rC Clang

https://reviews.llvm.org/D44480



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


[PATCH] D44233: Set dso_local on external rtti GVs

2018-03-14 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added inline comments.
This revision is now accepted and ready to land.



Comment at: lib/CodeGen/ItaniumCXXABI.cpp:2618-2620
+const CXXRecordDecl *RD = nullptr;
+if (const auto *RecordTy = dyn_cast(Ty))
+  RD = cast(RecordTy->getDecl());

This looks like `Ty->getAsCXXRecordDecl()`.


https://reviews.llvm.org/D44233



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


[PATCH] D44346: [clang-tidy] Add Zircon module to clang-tidy

2018-03-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/zircon/TemporaryObjectsCheck.cpp:51
+ "creating a temporary object of type %0 is prohibited")
+<< D->getConstructor()->getParent()->getQualifiedNameAsString();
+}

aaron.ballman wrote:
> You can skip the call to `getQualifiedNameAsString()`; the diagnostics engine 
> will handle it properly.
This doesn't seem to be done?



Comment at: docs/clang-tidy/checks/zircon-temporary-objects.rst:36-37
+
+  class Derived : Foo {} // Derived is not explicitly disallowed
+  Derived(); // and so temporary construction is okay
+

Can you hoist this into the exposition as well? It seems sufficiently important 
to warrant calling out in something other than an example.


https://reviews.llvm.org/D44346



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


[PATCH] D44346: [clang-tidy] Add Zircon module to clang-tidy

2018-03-14 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added inline comments.



Comment at: clang-tidy/fuchsia/FuchsiaTidyModule.cpp:44
+CheckFactories.registerCheck(
+"fuchsia-zx-temporary-objects");
   }

aaron.ballman wrote:
> Do we want a zircon module instead? I'm wondering about people who enable 
> modules by doing `fuchsia-*` and whether or not they would expect this check 
> (and others for zircon) to be enabled.
We definitely can -- it would be nice to have the additional separation (so 
that non-zircon parts of fuchsia don't need to explicitly disable checks.



Comment at: test/clang-tidy/zircon-temporary-objects.cpp:82
+
+} // namespace NS

aaron.ballman wrote:
> Some additional test cases:
> ```
> template 
> Ty make_ty() { return Ty{}; }
> 
> // Call make_ty<> with two types: one allowed and one disallowed; I assume 
> only the disallowed triggers the diagnostic.
> 
> struct Bingo : NS::Bar {}; // Not explicitly disallowed
> 
> void f() {
>   Bingo{}; // Should this diagnose because it inherits from Bar?
> }
> 
> // Assuming derived classes diagnose if the base is prohibited:
> template 
> struct Quux : Ty {};
> 
> void f() {
>   Quux{}; // Diagnose
>   Quux{}; // Fine?
> }
> ```
For the inheritance ones, `Quux` would have to be explicitly included in the 
list in order to be triggered by the checker (to avoid over-diagnosing), so in 
this case no warnings should be generated.



Comment at: test/clang-tidy/zircon-temporary-objects.cpp:86
+Ty make_ty() { return Ty(); }
+// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: creating a temporary object of 
type 'Bar' is prohibited
+// CHECK-MESSAGES: :[[@LINE-2]]:23: warning: creating a temporary object of 
type 'Foo' is prohibited

aaron.ballman wrote:
> Why? I thought `Bar` was allowed, but `NS::Bar` was prohibited?
Artifact of passing in the decl instead of the fully-qualified name string -- 
the automatic to-string method generates just the unqualified name. 


https://reviews.llvm.org/D44346



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


[PATCH] D44484: [clangd] Use Contents from inputs in codeComplete and signatureHelp

2018-03-14 Thread Simon Marchi via Phabricator via cfe-commits
simark created this revision.
Herald added subscribers: cfe-commits, ioeric, jkorous-apple, ilya-biryukov, 
klimek.

ClangdServer::{codeComplete,signatureHelp} both use the Contents from
the draft manager.  Since we want to move the draft manager from
ClangdServer to ClangdLSPServer, this patch changes those methods to
find the file contents from InputsAndPreamble, which contains the source
passed in previously.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44484

Files:
  clangd/ClangdServer.cpp


Index: clangd/ClangdServer.cpp
===
--- clangd/ClangdServer.cpp
+++ clangd/ClangdServer.cpp
@@ -154,23 +154,22 @@
   // Copy PCHs to avoid accessing this->PCHs concurrently
   std::shared_ptr PCHs = this->PCHs;
   auto FS = FSProvider.getFileSystem();
-  auto Task = [PCHs, Pos, FS, CodeCompleteOpts](
-  std::string Contents, Path File, Callback CB,
-  llvm::Expected IP) {
+  auto Task = [PCHs, Pos, FS,
+   CodeCompleteOpts](Path File, Callback CB,
+ llvm::Expected IP) {
 assert(IP && "error when trying to read preamble for codeComplete");
 auto PreambleData = IP->Preamble;
 
 // FIXME(ibiryukov): even if Preamble is non-null, we may want to check
 // both the old and the new version in case only one of them matches.
 CompletionList Result = clangd::codeComplete(
 File, IP->Command, PreambleData ? &PreambleData->Preamble : nullptr,
-Contents, Pos, FS, PCHs, CodeCompleteOpts);
+IP->Contents, Pos, FS, PCHs, CodeCompleteOpts);
 CB(std::move(Result));
   };
 
-  WorkScheduler.runWithPreamble(
-  "CodeComplete", File,
-  Bind(Task, std::move(*Latest.Draft), File.str(), std::move(CB)));
+  WorkScheduler.runWithPreamble("CodeComplete", File,
+Bind(Task, File.str(), std::move(CB)));
 }
 
 void ClangdServer::signatureHelp(PathRef File, Position Pos,
@@ -183,21 +182,19 @@
 
   auto PCHs = this->PCHs;
   auto FS = FSProvider.getFileSystem();
-  auto Action = [Pos, FS, PCHs](std::string Contents, Path File,
-Callback CB,
+  auto Action = [Pos, FS, PCHs](Path File, Callback CB,
 llvm::Expected IP) {
 if (!IP)
   return CB(IP.takeError());
 
 auto PreambleData = IP->Preamble;
 CB(clangd::signatureHelp(File, IP->Command,
  PreambleData ? &PreambleData->Preamble : nullptr,
- Contents, Pos, FS, PCHs));
+ IP->Contents, Pos, FS, PCHs));
   };
 
-  WorkScheduler.runWithPreamble(
-  "SignatureHelp", File,
-  Bind(Action, std::move(*Latest.Draft), File.str(), std::move(CB)));
+  WorkScheduler.runWithPreamble("SignatureHelp", File,
+Bind(Action, File.str(), std::move(CB)));
 }
 
 llvm::Expected


Index: clangd/ClangdServer.cpp
===
--- clangd/ClangdServer.cpp
+++ clangd/ClangdServer.cpp
@@ -154,23 +154,22 @@
   // Copy PCHs to avoid accessing this->PCHs concurrently
   std::shared_ptr PCHs = this->PCHs;
   auto FS = FSProvider.getFileSystem();
-  auto Task = [PCHs, Pos, FS, CodeCompleteOpts](
-  std::string Contents, Path File, Callback CB,
-  llvm::Expected IP) {
+  auto Task = [PCHs, Pos, FS,
+   CodeCompleteOpts](Path File, Callback CB,
+ llvm::Expected IP) {
 assert(IP && "error when trying to read preamble for codeComplete");
 auto PreambleData = IP->Preamble;
 
 // FIXME(ibiryukov): even if Preamble is non-null, we may want to check
 // both the old and the new version in case only one of them matches.
 CompletionList Result = clangd::codeComplete(
 File, IP->Command, PreambleData ? &PreambleData->Preamble : nullptr,
-Contents, Pos, FS, PCHs, CodeCompleteOpts);
+IP->Contents, Pos, FS, PCHs, CodeCompleteOpts);
 CB(std::move(Result));
   };
 
-  WorkScheduler.runWithPreamble(
-  "CodeComplete", File,
-  Bind(Task, std::move(*Latest.Draft), File.str(), std::move(CB)));
+  WorkScheduler.runWithPreamble("CodeComplete", File,
+Bind(Task, File.str(), std::move(CB)));
 }
 
 void ClangdServer::signatureHelp(PathRef File, Position Pos,
@@ -183,21 +182,19 @@
 
   auto PCHs = this->PCHs;
   auto FS = FSProvider.getFileSystem();
-  auto Action = [Pos, FS, PCHs](std::string Contents, Path File,
-Callback CB,
+  auto Action = [Pos, FS, PCHs](Path File, Callback CB,
 llvm::Expected IP) {
 if (!IP)
   return CB(IP.takeError());
 
 auto PreambleData = IP->Preamble;
 CB(clangd::signatureHelp(File, IP->Command,
  PreambleData ? &PreambleData->Preamble : nullptr,
-   

[PATCH] D44408: Move DraftMgr from ClangdServer to ClangdLSPServer

2018-03-14 Thread Simon Marchi via Phabricator via cfe-commits
simark added a comment.

In https://reviews.llvm.org/D44408#1037327, @ilya-biryukov wrote:

> In https://reviews.llvm.org/D44408#1036941, @simark wrote:
>
> > I don't see how to avoid adding the Contents parameter to the codeComplete 
> > and signatureHelp methods, since they needed to fetch the document from the 
> > draft manager and pass it to the backend.
>
>
> You can get the contents inside the `runWithPreamble` callback:
>
>   llvm::Expected IP;
>   auto &Contents = IP->Inputs.Contents;
>


I see, I made this as a separate patch:

https://reviews.llvm.org/D44484


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44408



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


[PATCH] D44346: [clang-tidy] Add Zircon module to clang-tidy

2018-03-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/zircon/TemporaryObjectsCheck.cpp:51
+ "creating a temporary object of type %0 is prohibited")
+<< D->getConstructor()->getParent()->getQualifiedNameAsString();
+}

aaron.ballman wrote:
> aaron.ballman wrote:
> > You can skip the call to `getQualifiedNameAsString()`; the diagnostics 
> > engine will handle it properly.
> This doesn't seem to be done?
Ah, I see why now. You should change to `%q0` (and drop the existing single 
quotes) and then get rid of `getQualifiedNameAsString()`.


https://reviews.llvm.org/D44346



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


r327543 - Set dso_local on external rtti GVs.

2018-03-14 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Wed Mar 14 11:14:46 2018
New Revision: 327543

URL: http://llvm.org/viewvc/llvm-project?rev=327543&view=rev
Log:
Set dso_local on external rtti GVs.

In this particular case it would be possible to just add an else with
CGM.setDSOLocal(GV), but it seems better to have as many callers as
possible just call setGVProperties so that we can centralize the logic
there.

This patch then makes setGVProperties able to handle null Decls.

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGenCXX/windows-itanium-exceptions.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=327543&r1=327542&r2=327543&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Mar 14 11:14:46 2018
@@ -707,7 +707,8 @@ void CodeGenModule::setGlobalVisibility(
 GV->setVisibility(llvm::GlobalValue::DefaultVisibility);
 return;
   }
-
+  if (!D)
+return;
   // Set visibility for definitions.
   LinkageInfo LV = D->getLinkageAndVisibility();
   if (LV.isVisibilityExplicit() || !GV->isDeclarationForLinker())
@@ -797,7 +798,7 @@ void CodeGenModule::setDLLImportDLLExpor
 
 void CodeGenModule::setDLLImportDLLExport(llvm::GlobalValue *GV,
   const NamedDecl *D) const {
-  if (D->isExternallyVisible()) {
+  if (D && D->isExternallyVisible()) {
 if (D->hasAttr())
   GV->setDLLStorageClass(llvm::GlobalVariable::DLLImportStorageClass);
 else if (D->hasAttr() && !GV->isDeclarationForLinker())

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=327543&r1=327542&r2=327543&view=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Wed Mar 14 11:14:46 2018
@@ -2616,10 +2616,8 @@ ItaniumRTTIBuilder::GetAddrOfExternalRTT
   /*Constant=*/true,
   llvm::GlobalValue::ExternalLinkage, nullptr,
   Name);
-if (const RecordType *RecordTy = dyn_cast(Ty)) {
-  const CXXRecordDecl *RD = cast(RecordTy->getDecl());
-  CGM.setGVProperties(GV, RD);
-}
+const CXXRecordDecl *RD = Ty->getAsCXXRecordDecl();
+CGM.setGVProperties(GV, RD);
   }
 
   return llvm::ConstantExpr::getBitCast(GV, CGM.Int8PtrTy);

Modified: cfe/trunk/test/CodeGenCXX/windows-itanium-exceptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/windows-itanium-exceptions.cpp?rev=327543&r1=327542&r2=327543&view=diff
==
--- cfe/trunk/test/CodeGenCXX/windows-itanium-exceptions.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/windows-itanium-exceptions.cpp Wed Mar 14 
11:14:46 2018
@@ -10,7 +10,7 @@ void attempt() {
   try { except(); } catch (...) { }
 }
 
-// CHECK: @_ZTIi = external constant i8*
+// CHECK: @_ZTIi = external dso_local constant i8*
 
 // CHECK: define {{.*}}void @_Z6exceptv() {{.*}} {
 // CHECK:   %exception = call {{.*}}i8* @__cxa_allocate_exception(i32 4)


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


[PATCH] D44233: Set dso_local on external rtti GVs

2018-03-14 Thread Rafael Avila de Espindola via Phabricator via cfe-commits
espindola closed this revision.
espindola added a comment.

r327543


https://reviews.llvm.org/D44233



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


[PATCH] D44435: Add the module name to __cuda_module_ctor and __cuda_module_dtor for unique function names

2018-03-14 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: unittests/CodeGen/IncrementalProcessingTest.cpp:176-178
+
+// In CUDA incremental processing, a CUDA ctor or dtor will be generated for 
+// every statement if a fatbinary file exists.

SimeonEhrig wrote:
> tra wrote:
> > I don't understand the comment. What is 'CUDA incremental processing' and 
> > what exactly is meant by 'statement' here? I'd appreciate if you could give 
> > me more details. My understanding is that ctor/dtor are generated once per 
> > TU. I suspect "incremental processing" may change that, but I have no idea 
> > what exactly does it do.
> A CUDA ctor/dtor will generates for every llvm::module. The TU can also 
> composed of many modules. In our interpreter, we add new code to our AST with 
> new modules at runtime. 
> The ctor/dtor generation is depend on the fatbinary code. The CodeGen checks, 
> if a path to a fatbinary file is set. If it is, it generates an ctor with at 
> least a __cudaRegisterFatBinary() function call. So, the generation is 
> independent of the source code in the module and we can use every statement. 
> A statement can be an expression, a declaration, a definition and so one.   
I still don't understand how it's going to work. Do you have some sort of 
design document outlining how the interpreter is going to work with CUDA?

The purpose of the ctor/dtor is to stitch together host-side kernel launch with 
the GPU-side kernel binary which resides in the GPU binary created by 
device-side compilation. 

So, the question #1 -- if you pass GPU-side binary to the compiler, where did 
you get it? Normally it's the result of device-side compilation of the same TU. 
In your case it's not quite clear what exactly would that be, if you feed the 
source to the compiler incrementally. I.e. do you somehow recompile everything 
we've seen on device side so far for each new chunk of host-side source you 
feed to the compiler? 

Next question is -- assuming that device side does have correct GPU-side 
binary, when do you call those ctors/dtors? JIT model does not quite fit the 
assumptions that drive regular CUDA compilation.

Let's consider this:
```
__global__ void foo();
__global__ void bar();

// If that's all we've  fed to compiler so far, we have no GPU code yet, so 
there 
// should be no fatbin file. If we do have it, what's in it?

void launch() {
  foo<<<1,1>>>();
  bar<<<1,1>>>();
}
// If you've generated ctors/dtors at this point they would be 
// useless as no GPU code exists in the preceding code.

__global__ void foo() {}
// Now we'd have some GPU code, but how can we need to retrofit it into 
// all the ctors/dtors we've generated before. 
__global__ void bar() {}
// Does bar end up in its own fatbinary? Or is it combined into a new 
// fatbin which contains both boo and bar?
// If it's a new fatbin, you somehow need to update existing ctors/dtors, 
// unless you want to leak CUDA resources fast.
// If it's a separate fatbin, then you will need to at the very least change 
the way 
// ctors/dtors are generated by the 'launch' function, because now they need to 
// tie each kernel launch to a different fatbin.

```

It looks to me that if you want to JIT CUDA code you will need to take over 
GPU-side kernel management.
ctors/dtors do that for full-TU compilation, but they rely on device-side code 
being compiled and available during host-side compilation. For JIT, the 
interpreter should be in charge of registering new kernels with the CUDA 
runtime and unregistering/unloading them when a kernel goes away. This makes 
ctors/dtors completely irrelevant.


Repository:
  rC Clang

https://reviews.llvm.org/D44435



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


r327544 - Set dso_local for NSConcreteStackBlock.

2018-03-14 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Wed Mar 14 11:19:26 2018
New Revision: 327544

URL: http://llvm.org/viewvc/llvm-project?rev=327544&view=rev
Log:
Set dso_local for NSConcreteStackBlock.

Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/test/CodeGen/blocks-windows.c

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=327544&r1=327543&r2=327544&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Wed Mar 14 11:19:26 2018
@@ -2586,11 +2586,11 @@ static void configureBlocksRuntimeObject
 }
   }
 
-  if (!CGM.getLangOpts().BlocksRuntimeOptional)
-return;
-
-  if (GV->isDeclaration() && GV->hasExternalLinkage())
+  if (CGM.getLangOpts().BlocksRuntimeOptional && GV->isDeclaration() &&
+  GV->hasExternalLinkage())
 GV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage);
+
+  CGM.setDSOLocal(GV);
 }
 
 llvm::Constant *CodeGenModule::getBlockObjectDispose() {

Modified: cfe/trunk/test/CodeGen/blocks-windows.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/blocks-windows.c?rev=327544&r1=327543&r2=327544&view=diff
==
--- cfe/trunk/test/CodeGen/blocks-windows.c (original)
+++ cfe/trunk/test/CodeGen/blocks-windows.c Wed Mar 14 11:19:26 2018
@@ -67,7 +67,7 @@ int (*g(void))(void) {
   return _Block_copy(^{ ++i; return i; });
 }
 
-// CHECK-BLOCKS-IN-BLOCKS-DECL: @_NSConcreteStackBlock = external dllexport 
global i8*
+// CHECK-BLOCKS-IN-BLOCKS-DECL: @_NSConcreteStackBlock = external dso_local 
dllexport global i8*
 // CHECK-BLOCKS-IN-BLOCKS-DEFN: @_NSConcreteStackBlock = common dso_local 
dllexport global [5 x i32]
 // CHECK-BLOCKS-NOT-IN-BLOCKS: @_NSConcreteStackBlock = external dllimport 
global i8*
 // CHECK-BLOCKS-NOT-IN-BLOCKS-EXTERN: @_NSConcreteStackBlock = external 
dllimport global i8*


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


r327545 - [www] Update C++ DR status to match latest issues list.

2018-03-14 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Mar 14 11:19:41 2018
New Revision: 327545

URL: http://llvm.org/viewvc/llvm-project?rev=327545&view=rev
Log:
[www] Update C++ DR status to match latest issues list.

Modified:
cfe/trunk/www/cxx_dr_status.html

Modified: cfe/trunk/www/cxx_dr_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_dr_status.html?rev=327545&r1=327544&r2=327545&view=diff
==
--- cfe/trunk/www/cxx_dr_status.html (original)
+++ cfe/trunk/www/cxx_dr_status.html Wed Mar 14 11:19:41 2018
@@ -937,7 +937,7 @@
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#150";>150
-DR
+C++17
 Template template parameters and default arguments
 Unknown
   
@@ -1554,11 +1554,11 @@ accessible?
 Looking up deallocation functions in virtual destructors
 Yes
   
-  
-http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#253";>253
-drafting
+  
+http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#253";>253
+C++17
 Why must empty or fully-initialized const objects be initialized?
-Not resolved
+Unknown
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#254";>254
@@ -1921,11 +1921,11 @@ of class templates
 Class with single conversion function to integral as array size in 
new
 Duplicate of 299 (C++11 
onwards)
   
-  
-http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#314";>314
-drafting
+  
+http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#314";>314
+C++17
 template in base class specifier
-Not resolved
+Unknown
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#315";>315
@@ -2095,11 +2095,11 @@ of class templates
 Terminology: "indirection" versus "dereference"
 N/A
   
-  
-http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#343";>343
-drafting
+  
+http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#343";>343
+C++17
 Make template optional in contexts that require a type
-Not resolved
+Unknown
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#344";>344
@@ -2593,11 +2593,11 @@ of class templates
 Set of candidates for overloaded built-in operator with float 
operand
 Yes
   
-  
-http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#426";>426
-review
+  
+http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#426";>426
+C++17
 Identically-named variables, one internally and one externally linked, 
allowed?
-Not resolved
+Unknown
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#427";>427
@@ -3615,11 +3615,11 @@ and POD class
 Exception specifications in templates instantiated from class 
bodies
 Duplicate of 1330
   
-  
-http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#596";>596
-open
+  
+http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#596";>596
+NAD
 Replacing an exception object
-Not resolved
+Unknown
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#597";>597
@@ -3855,11 +3855,11 @@ and POD class
 Names of constructors and destructors of templates
 Yes
   
-  
-http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#636";>636
-drafting
+  
+http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#636";>636
+CD4
 Dynamic type of objects and aliasing
-Not resolved
+Unknown
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#637";>637
@@ -4383,11 +4383,11 @@ and POD class
 Atomic and non-atomic objects in the memory model
 Unknown
   
-  
-http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#727";>727
-drafting
+  
+http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#727";>727
+C++17
 In-class explicit specializations
-Not resolved
+Unknown
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#728";>728
@@ -5235,11 +5235,11 @@ and POD class
 Explicit conversion functions in direct class initialization
 Unknown
   
-  
+  
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#900";>900
-NAD
+extension
 Lifetime of temporaries in range-based for
-Unknown
+Not resolved
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#901";>901
@@ -5469,11 +5469,11 @@ and POD class
 Is this an entity?
 Unknown
   
-  
-http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#943";>943
-open
+  
+http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#943";>943
+DRWP
 Is T() a temporary?
-Not resolved
+Unknown
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#944";>944
@@ -6267,11 +6267,11 @@ and POD class
 Grammar does not allow template alias in type-name
 Unknown

  1   2   >