[clang-tools-extra] r363765 - [clangd] Add ClangdServer accessor for buffer contents

2019-06-19 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Wed Jun 19 00:29:05 2019
New Revision: 363765

URL: http://llvm.org/viewvc/llvm-project?rev=363765&view=rev
Log:
[clangd] Add ClangdServer accessor for buffer contents

Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/clangd/TUScheduler.cpp
clang-tools-extra/trunk/clangd/TUScheduler.h
clang-tools-extra/trunk/clangd/unittests/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=363765&r1=363764&r2=363765&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Jun 19 00:29:05 2019
@@ -150,6 +150,10 @@ void ClangdServer::addDocument(PathRef F
 
 void ClangdServer::removeDocument(PathRef File) { WorkScheduler.remove(File); }
 
+llvm::StringRef ClangdServer::getDocument(PathRef File) const {
+  return WorkScheduler.getContents(File);
+}
+
 void ClangdServer::codeComplete(PathRef File, Position Pos,
 const clangd::CodeCompleteOptions &Opts,
 Callback CB) {

Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=363765&r1=363764&r2=363765&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Wed Jun 19 00:29:05 2019
@@ -163,6 +163,9 @@ public:
   void addDocument(PathRef File, StringRef Contents,
WantDiagnostics WD = WantDiagnostics::Auto);
 
+  /// Get the contents of \p File, which should have been added.
+  llvm::StringRef getDocument(PathRef File) const;
+
   /// Remove \p File from list of tracked files, schedule a request to free
   /// resources associated with it. Pending diagnostics for closed files may 
not
   /// be delivered, even if requested with WantDiags::Auto or WantDiags::Yes.

Modified: clang-tools-extra/trunk/clangd/TUScheduler.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/TUScheduler.cpp?rev=363765&r1=363764&r2=363765&view=diff
==
--- clang-tools-extra/trunk/clangd/TUScheduler.cpp (original)
+++ clang-tools-extra/trunk/clangd/TUScheduler.cpp Wed Jun 19 00:29:05 2019
@@ -884,6 +884,15 @@ void TUScheduler::remove(PathRef File) {
  File);
 }
 
+llvm::StringRef TUScheduler::getContents(PathRef File) const {
+  auto It = Files.find(File);
+  if (It == Files.end()) {
+elog("getContents() for untracked file: {0}", File);
+return "";
+  }
+  return It->second->Contents;
+}
+
 void TUScheduler::run(llvm::StringRef Name,
   llvm::unique_function Action) {
   if (!PreambleTasks)

Modified: clang-tools-extra/trunk/clangd/TUScheduler.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/TUScheduler.h?rev=363765&r1=363764&r2=363765&view=diff
==
--- clang-tools-extra/trunk/clangd/TUScheduler.h (original)
+++ clang-tools-extra/trunk/clangd/TUScheduler.h Wed Jun 19 00:29:05 2019
@@ -155,6 +155,10 @@ public:
   /// if requested with WantDiags::Auto or WantDiags::Yes.
   void remove(PathRef File);
 
+  /// Returns the current contents of the buffer for File, per last update().
+  /// The returned StringRef may be invalidated by any write to TUScheduler.
+  llvm::StringRef getContents(PathRef File) const;
+
   /// Schedule an async task with no dependencies.
   void run(llvm::StringRef Name, llvm::unique_function Action);
 

Modified: clang-tools-extra/trunk/clangd/unittests/TUSchedulerTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/TUSchedulerTests.cpp?rev=363765&r1=363764&r2=363765&view=diff
==
--- clang-tools-extra/trunk/clangd/unittests/TUSchedulerTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/TUSchedulerTests.cpp Wed Jun 19 
00:29:05 2019
@@ -107,12 +107,14 @@ TEST_F(TUSchedulerTests, MissingFiles) {
 ASTRetentionPolicy());
 
   auto Added = testPath("added.cpp");
-  Files[Added] = "";
+  Files[Added] = "x";
 
   auto Missing = testPath("missing.cpp");
   Files[Missing] = "";
 
-  S.update(Added, getInputs(Added, ""), WantDiagnostics::No);
+  EXPECT_EQ(S.getContents(Added), "");
+  S.update(Added, getInputs(Added, "x"), WantDiagnostics::No);
+  EXPECT_EQ(S.getContents(Added), "x");
 
   // Assert each operation for missing file is an error (even if it's available
   // in VFS).
@@ -131,7 +133,9 @@ TEST_F(TUSchedul

[clang-tools-extra] r363766 - Revert "[clangd] Return vector from applyTweak. NFC"

2019-06-19 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Wed Jun 19 00:29:10 2019
New Revision: 363766

URL: http://llvm.org/viewvc/llvm-project?rev=363766&view=rev
Log:
Revert "[clangd] Return vector from applyTweak. NFC"

This reverts commit r363691.

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

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=363766&r1=363765&r2=363766&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Wed Jun 19 00:29:10 2019
@@ -491,14 +491,14 @@ void ClangdLSPServer::onCommand(const Ex
 
 auto Action = [this, ApplyEdit](decltype(Reply) Reply, URIForFile File,
 std::string Code,
-llvm::Expected R) {
+llvm::Expected R) {
   if (!R)
 return Reply(R.takeError());
 
   if (R->ApplyEdit) {
 WorkspaceEdit WE;
 WE.changes.emplace();
-(*WE.changes)[File.uri()] = *R->ApplyEdit;
+(*WE.changes)[File.uri()] = replacementsToEdits(Code, *R->ApplyEdit);
 ApplyEdit(std::move(WE));
   }
   if (R->ShowMessage) {

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=363766&r1=363765&r2=363766&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Jun 19 00:29:10 2019
@@ -329,7 +329,7 @@ void ClangdServer::enumerateTweaks(PathR
 }
 
 void ClangdServer::applyTweak(PathRef File, Range Sel, StringRef TweakID,
-  Callback CB) {
+  Callback CB) {
   auto Action = [Sel](decltype(CB) CB, std::string File, std::string TweakID,
   Expected InpAST) {
 if (!InpAST)
@@ -352,13 +352,7 @@ void ClangdServer::applyTweak(PathRef Fi
 *Effect->ApplyEdit, Style))
 Effect->ApplyEdit = std::move(*Formatted);
 }
-
-ResolvedEffect R;
-R.ShowMessage = std::move(Effect->ShowMessage);
-if (Effect->ApplyEdit)
-  R.ApplyEdit =
-  replacementsToEdits(InpAST->Inputs.Contents, *Effect->ApplyEdit);
-return CB(std::move(R));
+return CB(std::move(*Effect));
   };
   WorkScheduler.runWithAST(
   "ApplyTweak", File,

Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=363766&r1=363765&r2=363766&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Wed Jun 19 00:29:10 2019
@@ -57,14 +57,6 @@ public:
 using ClangTidyOptionsBuilder = std::function;
 
-/// Like Tweak::Effect, but stores TextEdits instead of tooling::Replacements.
-/// Slightly nicer to embedders of ClangdServer.
-/// FIXME: figure out how to remove this duplication.
-struct ResolvedEffect {
-  llvm::Optional ShowMessage;
-  llvm::Optional> ApplyEdit;
-};
-
 /// Manages a collection of source files and derived data (ASTs, indexes),
 /// and provides language-aware features such as code completion.
 ///
@@ -250,7 +242,7 @@ public:
 
   /// Apply the code tweak with a specified \p ID.
   void applyTweak(PathRef File, Range Sel, StringRef ID,
-  Callback CB);
+  Callback CB);
 
   /// Only for testing purposes.
   /// Waits until all requests to worker thread are finished and dumps AST for


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


[PATCH] D62953: [Syntax] Do not glue multiple empty PP expansions to a single mapping

2019-06-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Sorry, I'm having trouble understanding this patch. Can you try to find some 
clearer names for the new concepts, or describe how they differ?




Comment at: clang/include/clang/Tooling/Syntax/Tokens.h:318
+  ///   2. macro name and arguments for macro expansions.
+  using SpelledMappings =
+  llvm::DenseMap;

There are now 4 things called mappings, and I can't understand how they relate 
to each other. I think this needs new names and/or concepts.



Comment at: clang/include/clang/Tooling/Syntax/Tokens.h:326
   Preprocessor &PP;
+  Callbacks *CB;
 };

Give the class and member more descriptive names?



Comment at: clang/lib/Tooling/Syntax/Tokens.cpp:256
 
+class TokenCollector::Callbacks : public PPCallbacks {
+public:

what is this class for, what does it do?



Comment at: clang/lib/Tooling/Syntax/Tokens.cpp:278
+private:
+  TokenCollector *C;
+  /// Used to detect recursive macro expansions.

members should have real names


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62953



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


[PATCH] D59744: Fix i386 ABI "__m64" type bug

2019-06-19 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D59744#1549675 , @wxiao3 wrote:

> Can anyone provide me some small reproducers code for the issue tripped over 
> by Chromium / Skia?


Sorry, I don't have a small repro yet. I'm still working on finding out exactly 
what's happening in Chromium, but it's a large test. It's easy to find where 
the x87 state gets clobbered after your change, but I haven't found what code 
was depending on that state yet.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59744



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


[PATCH] D57055: [RISCV] Mark TLS as supported

2019-06-19 Thread Lewis Revill via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL363776: [RISCV] Mark TLS as supported (authored by 
lewis-revill, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57055?vs=185283&id=205523#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D57055

Files:
  cfe/trunk/lib/Basic/Targets/RISCV.h
  cfe/trunk/test/CodeGen/thread-specifier.c


Index: cfe/trunk/test/CodeGen/thread-specifier.c
===
--- cfe/trunk/test/CodeGen/thread-specifier.c
+++ cfe/trunk/test/CodeGen/thread-specifier.c
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple i686-pc-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple riscv32 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm -o - %s | FileCheck %s
 
 // CHECK: @b = external thread_local global
 // CHECK: @d.e = internal thread_local global
Index: cfe/trunk/lib/Basic/Targets/RISCV.h
===
--- cfe/trunk/lib/Basic/Targets/RISCV.h
+++ cfe/trunk/lib/Basic/Targets/RISCV.h
@@ -35,7 +35,6 @@
   RISCVTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
   : TargetInfo(Triple), HasM(false), HasA(false), HasF(false),
 HasD(false), HasC(false) {
-TLSSupported = false;
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::IEEEquad();


Index: cfe/trunk/test/CodeGen/thread-specifier.c
===
--- cfe/trunk/test/CodeGen/thread-specifier.c
+++ cfe/trunk/test/CodeGen/thread-specifier.c
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple i686-pc-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple riscv32 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm -o - %s | FileCheck %s
 
 // CHECK: @b = external thread_local global
 // CHECK: @d.e = internal thread_local global
Index: cfe/trunk/lib/Basic/Targets/RISCV.h
===
--- cfe/trunk/lib/Basic/Targets/RISCV.h
+++ cfe/trunk/lib/Basic/Targets/RISCV.h
@@ -35,7 +35,6 @@
   RISCVTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
   : TargetInfo(Triple), HasM(false), HasA(false), HasF(false),
 HasD(false), HasC(false) {
-TLSSupported = false;
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::IEEEquad();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63508: make -frewrite-includes handle __has_include wrapped in a macro

2019-06-19 Thread Luboš Luňák via Phabricator via cfe-commits
llunak added a comment.

The code uses a raw lexer, so it doesn't expand macros. Thus the piece of code 
quoted will not get the "#if QT_HAS_INCLUDE()" part rewritten. My 
specific use case is the Icecream distributed build tool which does remote 
builds in a chroot and so this #if will be false and the expanded contents of 
 will be ignored, leading to build errors 
(https://github.com/icecc/icecream/issues/471).

I can change the code to use 'while' instead of 'if' to handle nested macros, 
but I think such an approach should go only so far. My patch is simple and 
handles a realistic scenario, but if more complex macro handling is needed 
(which is a question), then IMO the code should be changed to do macro 
expansion properly. It was a long time ago when I wrote the code, but seeing 
that usage of Preprocessor::SetMacroExpansionOnlyInDirectives() I think such an 
expansion could be done similarly how handling macro expansion is handled in 
other directives - which IIRC is getting that information from PPCallbacks.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63508



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


[PATCH] D63508: make -frewrite-includes handle __has_include wrapped in a macro

2019-06-19 Thread Tor Arne Vestbø via Phabricator via cfe-commits
torarnv added a comment.

Just a thought: From the point of view of `-frewrite-includes`, it should 
technically do full/nested macro expansion right? But from the point of view of 
Icecream, that would defeat the purpose of using `-frewrite-includes`, since 
the goal is to embed all includes into a single source file, ship it to a 
remote node, and do the rest of the preprocessing there. Or is there a way to 
expand all the parts that may resolve to a `__has_include` but leave others as 
is (for later processing)? How does the code deal with `#if FOO(123) && 
MACRO_HAS_INCLUDE()` eg?

From the Qt side, this patch is good enough, since we only use one level of 
indirection (to handle compilers without this feature), so I'm just thinking 
out loud to understand the problem better 😃


Repository:
  rC Clang

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

https://reviews.llvm.org/D63508



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


[PATCH] D63330: [clangd] Add Value field to HoverInfo

2019-06-19 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/XRefs.cpp:733
+else
+  Init->printPretty(ValueOS, nullptr, Policy);
+  }

sammccall wrote:
> why not print the non-evaluated init if it's dependent?
not-necessary anymore, since we only generate value if it can be evaluated.



Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:956
+   }},
+  // FIXME: We should use TypeLoc instead of Decl to extract the concrete
+  // value.

sammccall wrote:
> Hmm, actually I'm not sure whether this is TypeLoc vs Decl here. Rather this 
> should be a DeclRefExpr to the VarDecl (result) in the *expanded* 
> CXXRecordDecl.
> 
> This suggests that maybe the isValueDependent check isn't quite right - the 
> initializer expression is value dependent as spelled, but in the 
> instantiation it's resolved. Not sure if this is fixable. What happens if you 
> comment out the check?
yes, and the problem lies in the IndexingAPI, inside `handleDeclOccurence` 
implicit instantiations are resolved into templated decls. therefore we lose 
the template params :/

we can't call expression evaluator on value dependent expressions, there is an 
assertion in the beginning of EvaluateAsRvalue.



Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:981
+ HI.NamespaceScope = "";
+ HI.Value = "&\"1234\"[0]";
+   }},

sammccall wrote:
> whoa, that's... weird. But fine, I think.
> 
> (It would be nice to elide the `&[]` if the index is zero, or maybe print as 
> `"1234" + 2` etc)
do you think it is worth changing that in printpretty (either the defaults or 
via some `PrintingPolicy` option)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63330



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


[PATCH] D63330: [clangd] Add Value field to HoverInfo

2019-06-19 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 205530.
kadircet marked 6 inline comments as done.
kadircet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63330

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -661,15 +661,16 @@
}},
   // Variable with template type
   {R"cpp(
-  template  class Foo {};
-  Foo [[fo^o]];
+  template  class Foo { public: Foo(int); };
+  Foo [[fo^o]] = Foo(5);
   )cpp",
[](HoverInfo &HI) {
  HI.NamespaceScope = "";
  HI.Name = "foo";
  HI.Kind = SymbolKind::Variable;
- HI.Definition = "Foo foo";
+ HI.Definition = "Foo foo = Foo(5)";
  HI.Type = "Foo";
+ HI.Value = "Foo(5)";
}},
   // Implicit template instantiation
   {R"cpp(
@@ -786,6 +787,7 @@
  {std::string("int"), std::string("T"), llvm::None},
  {std::string("bool"), std::string("B"), llvm::None},
  };
+ HI.Value = "&b";
  return HI;
}},
   // Lambda parameter with decltype reference
@@ -850,6 +852,7 @@
  {std::string("int"), std::string("T"), llvm::None},
  {std::string("bool"), std::string("B"), llvm::None},
  };
+ HI.Value = "[&bar](int T, bool B) -> bool {}";
  return HI;
}},
   // Local variable in lambda
@@ -911,6 +914,72 @@
  HI.Name = "MACRO", HI.Kind = SymbolKind::String,
  HI.Definition = "#define MACRO(x, y, z) void foo(x, y, z);";
}},
+
+  // constexprs
+  {R"cpp(
+int add(int a, int b) { return a + b; }
+int [[b^ar]] = add(1, 2);
+)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "bar";
+ HI.Definition = "int bar = add(1, 2)";
+ HI.Kind = SymbolKind::Variable;
+ HI.Type = "int";
+ HI.NamespaceScope = "";
+ HI.Value = "3";
+   }},
+  {R"cpp(
+int [[b^ar]] = sizeof(char);
+)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "bar";
+ HI.Definition = "int bar = sizeof(char)";
+ HI.Kind = SymbolKind::Variable;
+ HI.Type = "int";
+ HI.NamespaceScope = "";
+ HI.Value = "1";
+   }},
+  {R"cpp(
+template struct Add {
+  static constexpr int result = a + b;
+};
+int [[ba^r]] = Add<1, 2>::result;
+)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "bar";
+ HI.Definition = "int bar = Add<1, 2>::result";
+ HI.Kind = SymbolKind::Variable;
+ HI.Type = "int";
+ HI.NamespaceScope = "";
+ HI.Value = "3";
+   }},
+  // FIXME: We should use TypeLoc instead of Decl to extract the concrete
+  // value.
+  {R"cpp(
+template struct Add {
+  static constexpr int result = a + b;
+};
+int bar = Add<1, 2>::[[resu^lt]];
+)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "result";
+ HI.Definition = "static constexpr int result = a + b";
+ HI.Kind = SymbolKind::Property;
+ HI.Type = "const int";
+ HI.NamespaceScope = "";
+ HI.LocalScope = "Add::";
+   }},
+  {R"cpp(
+const char *[[ba^r]] = "1234";
+)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "bar";
+ HI.Definition = "const char *bar = \"1234\"";
+ HI.Kind = SymbolKind::Variable;
+ HI.Type = "const char *";
+ HI.NamespaceScope = "";
+ HI.Value = "&\"1234\"[0]";
+   }},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
Index: clang-tools-extra/clangd/XRefs.h
===
--- clang-tools-extra/clangd/XRefs.h
+++ clang-tools-extra/clangd/XRefs.h
@@ -103,6 +103,8 @@
   llvm::Optional> Parameters;
   /// Set for all templates(function, class, variable).
   llvm::Optional> TemplateParameters;
+  /// Contains the evaluated value of the symbol if exists.
+  llvm::Optional Value;
 
   /// Produce a user-readable information.
   FormattedString present() const;
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -719,6 +719,19 @@
 VD->getType().print(OS, Policy);
   }
 
+  // Fill in value with evaluated initializer if possible.
+  if (const auto *Var = dyn_cast(D)) {
+if (const Expr *Init = Var->getInit()) {
+  Expr::EvalResult Result;
+  if (!Init->isValueDepend

[PATCH] D63538: [analyzer][CFG] Return the correct terminator condition

2019-06-19 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, xazax.hun, a_sidorin, baloghadamsoftware, 
rnkovacs, dcoughlin.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, Charusso, gamesh411, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, szepet, whisperity.

For the following terminator statement:

  if (A && B && C && D)

The built CFG is the following:

  [B5 (ENTRY)]
Succs (1): B4
  
  [B1]
1: 10
2: j
3: [B1.2] (ImplicitCastExpr, LValueToRValue, int)
4: [B1.1] / [B1.3]
5: int x = 10 / j;
Preds (1): B2
Succs (1): B0
  
  [B2]
1: C
2: [B2.1] (ImplicitCastExpr, LValueToRValue, _Bool)
T: if [B4.4] && [B3.2] && [B2.2]
Preds (1): B3
Succs (2): B1 B0
  
  [B3]
1: B
2: [B3.1] (ImplicitCastExpr, LValueToRValue, _Bool)
T: [B4.4] && [B3.2] && ...
Preds (1): B4
Succs (2): B2 B0
  
  [B4]
1: 0
2: int j = 0;
3: A
4: [B4.3] (ImplicitCastExpr, LValueToRValue, _Bool)
T: [B4.4] && ...
Preds (1): B5
Succs (2): B3 B0
  
  [B0 (EXIT)]
Preds (4): B1 B2 B3 B4

However, even though the path of execution in B2  
only depends on C's value, `CFGBlock::getCondition()` would return the entire 
condition (`A && B && C`). For B3 , it would 
return `A && B`. I changed this the actual condition.

The tests show an addition of an extra arrow for `ObjCForCollectionStmt`, all 
of them similar to this:
F9306419: image.png 
(the first arrow the addition)


Repository:
  rC Clang

https://reviews.llvm.org/D63538

Files:
  clang/include/clang/Analysis/CFG.h
  clang/lib/Analysis/CFG.cpp
  clang/test/Analysis/Inputs/expected-plists/edges-new.mm.plist
  clang/test/Analysis/Inputs/expected-plists/plist-output.m.plist

Index: clang/test/Analysis/Inputs/expected-plists/plist-output.m.plist
===
--- clang/test/Analysis/Inputs/expected-plists/plist-output.m.plist
+++ clang/test/Analysis/Inputs/expected-plists/plist-output.m.plist
@@ -5743,11 +5743,45 @@
   
 
 
+ kindcontrol
+ edges
+  
+   
+start
+ 
+  
+   line160
+   col3
+   file0
+  
+  
+   line160
+   col5
+   file0
+  
+ 
+end
+ 
+  
+   line160
+   col18
+   file0
+  
+  
+   line160
+   col20
+   file0
+  
+ 
+   
+  
+
+
  kindevent
  location
  
   line160
-  col8
+  col18
   file0
  
  ranges
@@ -5755,12 +5789,12 @@

 
  line160
- col8
+ col18
  file0
 
 
  line160
- col13
+ col20
  file0
 

@@ -5780,12 +5814,12 @@
  
   
line160
-   col3
+   col18
file0
   
   
line160
-   col5
+   col20
file0
   
  
Index: clang/test/Analysis/Inputs/expected-plists/edges-new.mm.plist
===
--- clang/test/Analysis/Inputs/expected-plists/edges-new.mm.plist
+++ clang/test/Analysis/Inputs/expected-plists/edges-new.mm.plist
@@ -2182,11 +2182,45 @@
   
 
 
+ kindcontrol
+ edges
+  
+   
+start
+ 
+  
+   line131
+   col3
+   file0
+  
+  
+   line131
+   col5
+   file0
+  
+ 
+end
+ 
+  
+   line131
+   col15
+   file0
+  
+  
+   line131
+   col15
+   file0
+  
+ 
+   
+  
+
+
  kindevent
  location
  
   line131
-  col8
+  col15
   file0
  
  ranges
@@ -2194,12 +2228,12 @@

 
  line131
- col8
+ col15
  file0
 
 
  line131
- col10
+ col15
  file0
 

@@ -2219,12 +2253,12 @@
  
   
line131
-   col3
+   col15
file0
   
   
line131
-   col5
+   col15
file0
   
  
@@ -2457,11 +2491,45 @@
   
 
 
+ kindcontrol
+ edges
+  
+   
+start
+ 
+  
+   line137
+   col3
+   file0
+  
+  
+   line137
+   col5
+   file0
+  
+ 
+end
+ 
+  
+   line137
+   col18
+   file0
+  
+  
+   line137
+   col20
+   file0
+  
+

[PATCH] D63482: [clang-tidy] Fix the YAML created for checks like modernize-pass-by-value

2019-06-19 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added a comment.

Thanks! Please add tests in `./unittests/Tooling/ReplacementsYamlTest.cpp`.




Comment at: clang/include/clang/Tooling/ReplacementsYaml.h:43
+ReplacementText.replace(lineBreakPos, 1, "\n\n");
+// Get the next occurrence from the current position
+lineBreakPos = ReplacementText.find('\n', lineBreakPos + 2);

Please add comments that explain why this is the correct serialization. Please 
don't add comments that repeat the code.


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

https://reviews.llvm.org/D63482



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


[PATCH] D59744: Fix i386 ABI "__m64" type bug

2019-06-19 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

I've raised https://bugs.llvm.org/show_bug.cgi?id=42319 which suggests the 
creation of a EMMS insertion pass.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59744



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


[PATCH] D62953: [Syntax] Do not glue multiple empty PP expansions to a single mapping

2019-06-19 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov marked 7 inline comments as done.
ilya-biryukov added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/Tokens.h:318
+  ///   2. macro name and arguments for macro expansions.
+  using SpelledMappings =
+  llvm::DenseMap;

sammccall wrote:
> There are now 4 things called mappings, and I can't understand how they 
> relate to each other. I think this needs new names and/or concepts.
Renamed to `PPExpansions`.



Comment at: clang/include/clang/Tooling/Syntax/Tokens.h:326
   Preprocessor &PP;
+  Callbacks *CB;
 };

sammccall wrote:
> Give the class and member more descriptive names?
Renamed to `Expansions`



Comment at: clang/lib/Tooling/Syntax/Tokens.cpp:256
 
+class TokenCollector::Callbacks : public PPCallbacks {
+public:

sammccall wrote:
> what is this class for, what does it do?
Added a comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62953



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


[PATCH] D62953: [Syntax] Do not glue multiple empty PP expansions to a single mapping

2019-06-19 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 205537.
ilya-biryukov marked 3 inline comments as done.
ilya-biryukov added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62953

Files:
  clang/include/clang/Tooling/Syntax/Tokens.h
  clang/lib/Tooling/Syntax/Tokens.cpp
  clang/unittests/Tooling/Syntax/TokensTest.cpp

Index: clang/unittests/Tooling/Syntax/TokensTest.cpp
===
--- clang/unittests/Tooling/Syntax/TokensTest.cpp
+++ clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -428,7 +428,9 @@
   spelled tokens:
 # define EMPTY # define EMPTY_FUNC ( X ) EMPTY EMPTY_FUNC ( 1 + 2 + 3 )
   mappings:
-['#'_0, ''_18) => [''_0, ''_0)
+['#'_0, 'EMPTY'_9) => [''_0, ''_0)
+['EMPTY'_9, 'EMPTY_FUNC'_10) => [''_0, ''_0)
+['EMPTY_FUNC'_10, ''_18) => [''_0, ''_0)
 )"},
   // File ends with a macro replacement.
   {R"cpp(
Index: clang/lib/Tooling/Syntax/Tokens.cpp
===
--- clang/lib/Tooling/Syntax/Tokens.cpp
+++ clang/lib/Tooling/Syntax/Tokens.cpp
@@ -14,6 +14,7 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TokenKinds.h"
+#include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/Token.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -252,6 +253,35 @@
   return Tokens;
 }
 
+/// Records information reqired to construct mappings for the token buffer that
+/// we are collecting.
+class TokenCollector::CollectPPExpansions : public PPCallbacks {
+public:
+  CollectPPExpansions(TokenCollector &C) : Collector(&C) {}
+
+  /// Disabled instance will stop reporting anything to TokenCollector.
+  void disable() { Collector = nullptr; }
+
+  void MacroExpands(const clang::Token &MacroNameTok, const MacroDefinition &MD,
+SourceRange Range, const MacroArgs *Args) override {
+if (!Collector)
+  return;
+// Do not record recursive expansions.
+if (!MacroNameTok.getLocation().isFileID() ||
+(LastExpansionEnd.isValid() &&
+ Collector->PP.getSourceManager().isBeforeInTranslationUnit(
+ Range.getBegin(), LastExpansionEnd)))
+  return;
+Collector->Expansions[Range.getBegin().getRawEncoding()] = Range.getEnd();
+LastExpansionEnd = Range.getEnd();
+  }
+  // FIXME: handle #pragma, #include, etc.
+private:
+  TokenCollector *Collector;
+  /// Used to detect recursive macro expansions.
+  SourceLocation LastExpansionEnd;
+};
+
 /// Fills in the TokenBuffer by tracing the run of a preprocessor. The
 /// implementation tracks the tokens, macro expansions and directives coming
 /// from the preprocessor and:
@@ -279,15 +309,21 @@
 );
 Expanded.push_back(syntax::Token(T));
   });
+  // And locations of macro calls, to properly recover boundaries of those in
+  // case of empty expansions.
+  auto CB = llvm::make_unique(*this);
+  this->Collector = CB.get();
+  PP.addPPCallbacks(std::move(CB));
 }
 
 /// Builds mappings and spelled tokens in the TokenBuffer based on the expanded
 /// token stream.
 class TokenCollector::Builder {
 public:
-  Builder(std::vector Expanded, const SourceManager &SM,
-  const LangOptions &LangOpts)
-  : Result(SM), SM(SM), LangOpts(LangOpts) {
+  Builder(std::vector Expanded, PPExpansions Expansions,
+  const SourceManager &SM, const LangOptions &LangOpts)
+  : Result(SM), Expansions(std::move(Expansions)), SM(SM),
+LangOpts(LangOpts) {
 Result.ExpandedTokens = std::move(Expanded);
   }
 
@@ -296,6 +332,9 @@
 
 // Walk over expanded tokens and spelled tokens in parallel, building the
 // mappings between those using source locations.
+// To correctly recover empty macro expansions, we also take locations
+// reported to PPCallbacks::MacroExpands into account as we do not have any
+// expanded tokens with source locations to guide us.
 
 // The 'eof' token is special, it is not part of spelled token stream. We
 // handle it separately at the end.
@@ -356,22 +395,17 @@
 
 fillGapUntil(File, SpelledRange.getBegin(), I);
 
-TokenBuffer::Mapping M;
-// Skip the spelled macro tokens.
-std::tie(M.BeginSpelled, M.EndSpelled) =
-consumeSpelledUntil(File, SpelledRange.getEnd().getLocWithOffset(1));
 // Skip all expanded tokens from the same macro expansion.
-M.BeginExpanded = I;
+unsigned BeginExpanded = I;
 for (; I + 1 < Result.ExpandedTokens.size(); ++I) {
   auto NextL = Result.ExpandedTokens[I + 1].location();
   if (!NextL.isMacroID() ||
   SM.getExpansionLoc(NextL) != SpelledRange.getBegin())
 break;
 }
-M.EndExpanded = I + 1;
-
-// Add a resulting mapping.
-File.Mappings.push_back(M);
+unsigned EndExpanded = I + 1;
+consumeMapping(File, SM.getFileOff

[PATCH] D63376: [clang] Small improvments after Adding APValue to ConstantExpr

2019-06-19 Thread Tyker via Phabricator via cfe-commits
Tyker marked an inline comment as done.
Tyker added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:10298
+ bool AllowFold = true,
+ bool StoreResult = true);
   ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,

rsmith wrote:
> Do you need this new flag? No callers are passing it.
the idea behind it is that not all integral constant expression benefit from 
storing the result. i have not analyzed which benefit from it and which don't. 
adding a FIXME would have probably be more appropriate.


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

https://reviews.llvm.org/D63376



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


[PATCH] D63426: [clangd] Narrow rename to local symbols.

2019-06-19 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 205540.
hokein marked an inline comment as done.
hokein added a comment.

Switch to a hybrid solution (language semantic + index) to detect "symbol 
local".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63426

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/refactor/Rename.h
  clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang/include/clang/Tooling/Refactoring/Rename/RenamingAction.h
  clang/lib/Tooling/Refactoring/Rename/RenamingAction.cpp

Index: clang/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
+++ clang/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
@@ -74,6 +74,8 @@
std::move(NewName));
 }
 
+const NamedDecl *RenameOccurrences::getRenameDecl() const { return ND; }
+
 Expected
 RenameOccurrences::createSourceReplacements(RefactoringRuleContext &Context) {
   Expected Occurrences = findSymbolOccurrences(ND, Context);
Index: clang/include/clang/Tooling/Refactoring/Rename/RenamingAction.h
===
--- clang/include/clang/Tooling/Refactoring/Rename/RenamingAction.h
+++ clang/include/clang/Tooling/Refactoring/Rename/RenamingAction.h
@@ -54,6 +54,8 @@
 
   static const RefactoringDescriptor &describe();
 
+  const NamedDecl *getRenameDecl() const;
+
 private:
   RenameOccurrences(const NamedDecl *ND, std::string NewName)
   : ND(ND), NewName(std::move(NewName)) {}
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -18,6 +18,10 @@
 namespace clangd {
 namespace {
 
+MATCHER_P2(RenameRange, Code, Range, "") {
+  return replacementToEdit(Code, arg).range == Range;
+}
+
 TEST(RenameTest, SingleFile) {
   struct Test {
 const char* Before;
@@ -87,6 +91,69 @@
   }
 }
 
+TEST(RenameTest, WithIndex) {
+  const char *Tests[] = {
+  R"cpp(
+class [[Foo]] {};
+void f() {
+  [[Fo^o]] b;
+}
+ )cpp",
+
+  R"cpp(
+void f(int [[Lo^cal]]) {
+  [[Local]] = 2;
+}
+  )cpp",
+
+  // Cases where we reject to do the rename.
+  R"cpp( // no symbol at the cursor
+// This is in comme^nt.
+   )cpp",
+
+  R"cpp(
+void f() { // Outside main file.
+  Out^side s;
+}
+  )cpp",
+  };
+  const char *Header = "class Outside {};";
+
+  TestTU OtherFile = TestTU::withCode("Outside s;");
+  OtherFile.HeaderCode = Header;
+  OtherFile.Filename = "other.cc";
+
+  for (const char *Test : Tests) {
+Annotations T(Test);
+TestTU MainFile;
+MainFile.Code = T.code();
+MainFile.HeaderCode = Header;
+auto AST = MainFile.build();
+// Build a fake index containing refs of MainFile and OtherFile
+auto OtherFileIndex = OtherFile.index();
+auto MainFileIndex = MainFile.index();
+auto Index = MergedIndex(MainFileIndex.get(), OtherFileIndex.get());
+
+auto Results = renameWithinFile(AST, testPath(MainFile.Filename), T.point(),
+"dummyNewName", &Index);
+bool WantRename = true;
+if (T.ranges().empty())
+  WantRename = false;
+if (!WantRename) {
+  EXPECT_FALSE(Results) << "expected renameWithinFile returned an error: "
+<< T.code();
+  llvm::consumeError(Results.takeError());
+} else {
+  EXPECT_TRUE(bool(Results)) << "renameWithinFile returned an error: "
+ << llvm::toString(Results.takeError());
+  std::vector> Expected;
+  for (const auto &R : T.ranges())
+Expected.push_back(RenameRange(MainFile.Code, R));
+  EXPECT_THAT(*Results, UnorderedElementsAreArray(Expected));
+}
+  }
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
@@ -94,7 +94,7 @@
   Intent intent() const override { return Info; }
   bool hidden() const override { return true; }
 };
-REGISTER_TWEAK(ShowSelectionTree);
+REGISTER_TWEAK(ShowSelectionTree)
 
 /// Shows the layout of the RecordDecl under the cursor.
 /// Input:
@@ -132,7 +132,7 @@
 private:
   const RecordDecl *Record = nullptr;
 };
-REGISTER_TWEAK(DumpRecordLayout);
+REGISTER_TWEAK(DumpRecordLayout)
 
 } // namespace
 } // namespace clangd
Index: clang-tools-extra/clangd/refactor/Rename.h
=

[PATCH] D63426: [clangd] Narrow rename to local symbols.

2019-06-19 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Use the hybrid approach based on our discussion, the implementation should be 
fine to review, I'm still working on adding more tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63426



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


[PATCH] D63426: [clangd] Narrow rename to local symbols.

2019-06-19 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 205541.
hokein added a comment.

Remove the unrelated changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63426

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/refactor/Rename.h
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang/include/clang/Tooling/Refactoring/Rename/RenamingAction.h
  clang/lib/Tooling/Refactoring/Rename/RenamingAction.cpp

Index: clang/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
+++ clang/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
@@ -74,6 +74,8 @@
std::move(NewName));
 }
 
+const NamedDecl *RenameOccurrences::getRenameDecl() const { return ND; }
+
 Expected
 RenameOccurrences::createSourceReplacements(RefactoringRuleContext &Context) {
   Expected Occurrences = findSymbolOccurrences(ND, Context);
Index: clang/include/clang/Tooling/Refactoring/Rename/RenamingAction.h
===
--- clang/include/clang/Tooling/Refactoring/Rename/RenamingAction.h
+++ clang/include/clang/Tooling/Refactoring/Rename/RenamingAction.h
@@ -54,6 +54,8 @@
 
   static const RefactoringDescriptor &describe();
 
+  const NamedDecl *getRenameDecl() const;
+
 private:
   RenameOccurrences(const NamedDecl *ND, std::string NewName)
   : ND(ND), NewName(std::move(NewName)) {}
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -18,6 +18,10 @@
 namespace clangd {
 namespace {
 
+MATCHER_P2(RenameRange, Code, Range, "") {
+  return replacementToEdit(Code, arg).range == Range;
+}
+
 TEST(RenameTest, SingleFile) {
   struct Test {
 const char* Before;
@@ -87,6 +91,69 @@
   }
 }
 
+TEST(RenameTest, WithIndex) {
+  const char *Tests[] = {
+  R"cpp(
+class [[Foo]] {};
+void f() {
+  [[Fo^o]] b;
+}
+ )cpp",
+
+  R"cpp(
+void f(int [[Lo^cal]]) {
+  [[Local]] = 2;
+}
+  )cpp",
+
+  // Cases where we reject to do the rename.
+  R"cpp( // no symbol at the cursor
+// This is in comme^nt.
+   )cpp",
+
+  R"cpp(
+void f() { // Outside main file.
+  Out^side s;
+}
+  )cpp",
+  };
+  const char *Header = "class Outside {};";
+
+  TestTU OtherFile = TestTU::withCode("Outside s;");
+  OtherFile.HeaderCode = Header;
+  OtherFile.Filename = "other.cc";
+
+  for (const char *Test : Tests) {
+Annotations T(Test);
+TestTU MainFile;
+MainFile.Code = T.code();
+MainFile.HeaderCode = Header;
+auto AST = MainFile.build();
+// Build a fake index containing refs of MainFile and OtherFile
+auto OtherFileIndex = OtherFile.index();
+auto MainFileIndex = MainFile.index();
+auto Index = MergedIndex(MainFileIndex.get(), OtherFileIndex.get());
+
+auto Results = renameWithinFile(AST, testPath(MainFile.Filename), T.point(),
+"dummyNewName", &Index);
+bool WantRename = true;
+if (T.ranges().empty())
+  WantRename = false;
+if (!WantRename) {
+  EXPECT_FALSE(Results) << "expected renameWithinFile returned an error: "
+<< T.code();
+  llvm::consumeError(Results.takeError());
+} else {
+  EXPECT_TRUE(bool(Results)) << "renameWithinFile returned an error: "
+ << llvm::toString(Results.takeError());
+  std::vector> Expected;
+  for (const auto &R : T.ranges())
+Expected.push_back(RenameRange(MainFile.Code, R));
+  EXPECT_THAT(*Results, UnorderedElementsAreArray(Expected));
+}
+  }
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/refactor/Rename.h
===
--- clang-tools-extra/clangd/refactor/Rename.h
+++ clang-tools-extra/clangd/refactor/Rename.h
@@ -18,10 +18,10 @@
 
 /// Renames all occurrences of the symbol at \p Pos to \p NewName.
 /// Occurrences outside the current file are not modified.
-llvm::Expected renameWithinFile(ParsedAST &AST,
-   llvm::StringRef File,
-   Position Pos,
-   llvm::StringRef NewName);
+/// Only support renaming symbols not being used outside the file.
+llvm::Expected
+renameWithinFile(ParsedAST &AST, llvm::StringRef File, Position Pos,
+ llvm::StringRef NewName, const SymbolIndex *Index = nullptr);
 
 } // namespace clangd
 }

r363788 - [analyzer][NFC][tests] Pre-normalize expected-sarif files

2019-06-19 Thread Hubert Tong via cfe-commits
Author: hubert.reinterpretcast
Date: Wed Jun 19 04:19:51 2019
New Revision: 363788

URL: http://llvm.org/viewvc/llvm-project?rev=363788&view=rev
Log:
[analyzer][NFC][tests] Pre-normalize expected-sarif files

As discussed in the review for D62952, this patch pre-normalizes the
reference expected output sarif files by removing lines containing
fields for which we expect differences that should be ignored.

Modified:

cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif

cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif

Modified: 
cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif?rev=363788&r1=363787&r2=363788&view=diff
==
--- 
cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif
 (original)
+++ 
cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif
 Wed Jun 19 04:19:51 2019
@@ -5,7 +5,6 @@
   "files": [
 {
   "fileLocation": {
-"uri": "file:sarif-diagnostics-taint-test.c"
   },
   "length": 415,
   "mimeType": "text/plain",
@@ -43,7 +42,6 @@
 "physicalLocation": {
   "fileLocation": {
 "fileIndex": 0,
-"uri": "file:sarif-diagnostics-taint-test.c"
   },
   "region": {
 "endColumn": 5,
@@ -63,7 +61,6 @@
 "physicalLocation": {
   "fileLocation": {
 "fileIndex": 0,
-"uri": "file:sarif-diagnostics-taint-test.c"
   },
   "region": {
 "endColumn": 17,
@@ -84,7 +81,6 @@
   "physicalLocation": {
 "fileLocation": {
   "fileIndex": 0,
-  "uri": "file:sarif-diagnostics-taint-test.c"
 },
 "region": {
   "endColumn": 17,
@@ -106,9 +102,7 @@
 "fullName": "clang static analyzer",
 "language": "en-US",
 "name": "clang",
-"version": "clang version 8.0.0"
   }
 }
   ],
-  "version": "2.0.0-csd.2.beta.2018-11-28"
 }

Modified: 
cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif?rev=363788&r1=363787&r2=363788&view=diff
==
--- 
cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
 (original)
+++ 
cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
 Wed Jun 19 04:19:51 2019
@@ -5,7 +5,6 @@
   "files": [  
 {
   "fileLocation": {
-"uri": "file:sarif-multi-diagnostic-test.c"
   },
   "length": 667,
   "mimeType": "text/plain",
@@ -63,7 +62,6 @@
 "physicalLocation": {
   "fileLocation": {
 "fileIndex": 0,
-"uri": "file:sarif-multi-diagnostic-test.c"
   },
   "region": {
 "endColumn": 5,
@@ -83,7 +81,6 @@
 "physicalLocation": {
   "fileLocation": {
 "fileIndex": 0,
-"uri": "file:sarif-multi-diagnostic-test.c"
   },
   "region": {
 "endColumn": 17,
@@ -104,7 +101,6 @@
   "physicalLocation": {
 "fileLocation": {
   "fileIndex": 0,
-  "uri": "file:sarif-multi-diagnostic-test.c"
 },
 "region": {
   "endColumn": 17,
@@ -136,7 +132,6 @@
 "physicalLocation": {
   "fileLocation": {
 "fileIndex": 0,
-"uri": "file:sarif-multi-diagnostic-test.c"
   },
   "region": {
 "endColumn": 5,
@@ -156,7 +151,6 @@
 "physicalLocation": {
   "fileLocation": {
 "fileIndex": 0,
-"uri": "file:sarif-multi-diagnostic-test.c"
   },

[PATCH] D59744: Fix i386 ABI "__m64" type bug

2019-06-19 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D59744#1549746 , @hans wrote:

> In D59744#1549675 , @wxiao3 wrote:
>
> > Can anyone provide me some small reproducers code for the issue tripped 
> > over by Chromium / Skia?
>
>
> Sorry, I don't have a small repro yet. I'm still working on finding out 
> exactly what's happening in Chromium, but it's a large test. It's easy to 
> find where the x87 state gets clobbered after your change, but I haven't 
> found what code was depending on that state yet.


Oh, I thought the problem was just that the registers alias, not that the whole 
x87 state gets messed up by mmx instructions. Here's a simple repro:

  $ cat /tmp/a.c
  #include 
  #include 
  
  #ifdef __clang__
  typedef uint16_t __attribute__((ext_vector_type(4))) V;
  #else
  typedef uint16_t V __attribute__ ((vector_size (4*sizeof(uint16_t;
  #endif
  
  V f() {
V v = { 1,2,3,4 };
return v;
  }
  
  double d() { return 3.14; }
  
  int main() {
f();
printf("%lf\n", d());
return 0;
  }
  
  $ bin/clang -m32 -O0 /tmp/a.c && ./a.out
  -nan

Before your change, it prints 3.14.

Chromium was previously working around this problem in gcc by force-inlining 
f() into main(). That doesn't work with Clang because it touches %mm0 even 
after inlining.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59744



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


[PATCH] D63417: [RISCV] Specify registers used for exception handling

2019-06-19 Thread Edward Jones via Phabricator via cfe-commits
edward-jones updated this revision to Diff 205542.
edward-jones retitled this revision from "[WIP][RISCV] Specify registers used 
for exception handling" to "[RISCV] Specify registers used for exception 
handling".
edward-jones edited the summary of this revision.
edward-jones added a comment.

Added tests


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

https://reviews.llvm.org/D63417

Files:
  lib/Basic/Targets/RISCV.h
  test/CodeGen/builtin-riscv.c


Index: test/CodeGen/builtin-riscv.c
===
--- /dev/null
+++ test/CodeGen/builtin-riscv.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -Wall -Werror -triple riscv32 -disable-O0-optnone 
-emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+
+void test_eh_return_data_regno()
+{
+  // CHECK: store volatile i32 10
+  // CHECK: store volatile i32 11
+  volatile int res;
+  res = __builtin_eh_return_data_regno(0);
+  res = __builtin_eh_return_data_regno(1);
+}
Index: lib/Basic/Targets/RISCV.h
===
--- lib/Basic/Targets/RISCV.h
+++ lib/Basic/Targets/RISCV.h
@@ -57,6 +57,15 @@
 
   ArrayRef getGCCRegNames() const override;
 
+  int getEHDataRegisterNumber(unsigned RegNo) const override {
+if (RegNo == 0)
+  return 10;
+else if (RegNo == 1)
+  return 11;
+else
+  return -1;
+  }
+
   ArrayRef getGCCRegAliases() const override;
 
   bool validateAsmConstraint(const char *&Name,


Index: test/CodeGen/builtin-riscv.c
===
--- /dev/null
+++ test/CodeGen/builtin-riscv.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -Wall -Werror -triple riscv32 -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+
+void test_eh_return_data_regno()
+{
+  // CHECK: store volatile i32 10
+  // CHECK: store volatile i32 11
+  volatile int res;
+  res = __builtin_eh_return_data_regno(0);
+  res = __builtin_eh_return_data_regno(1);
+}
Index: lib/Basic/Targets/RISCV.h
===
--- lib/Basic/Targets/RISCV.h
+++ lib/Basic/Targets/RISCV.h
@@ -57,6 +57,15 @@
 
   ArrayRef getGCCRegNames() const override;
 
+  int getEHDataRegisterNumber(unsigned RegNo) const override {
+if (RegNo == 0)
+  return 10;
+else if (RegNo == 1)
+  return 11;
+else
+  return -1;
+  }
+
   ArrayRef getGCCRegAliases() const override;
 
   bool validateAsmConstraint(const char *&Name,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r363790 - Revert r363116 "[X86] [ABI] Fix i386 ABI "__m64" type bug"

2019-06-19 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jun 19 04:34:08 2019
New Revision: 363790

URL: http://llvm.org/viewvc/llvm-project?rev=363790&view=rev
Log:
Revert r363116 "[X86] [ABI] Fix i386 ABI "__m64" type bug"

This introduced MMX instructions in code that wasn't previously using
them, breaking programs using 64-bit vectors and x87 floating-point in
the same application. See discussion on the code review for more
details.

> According to System V i386 ABI: the  __m64 type paramater and return
> value are passed by MMX registers. But current implementation treats
> __m64 as i64 which results in parameter passing by stack and returning
> by EDX and EAX.
>
> This patch fixes the bug (https://bugs.llvm.org/show_bug.cgi?id=41029)
> for Linux and NetBSD.
>
> Patch by Wei Xiao (wxiao3)
>
> Differential Revision: https://reviews.llvm.org/D59744

Removed:
cfe/trunk/test/CodeGen/x86_32-m64.c
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGen/x86_32-arguments-linux.c

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=363790&r1=363789&r2=363790&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Jun 19 04:34:08 2019
@@ -915,6 +915,14 @@ ABIArgInfo PNaClABIInfo::classifyReturnT
: ABIArgInfo::getDirect());
 }
 
+/// IsX86_MMXType - Return true if this is an MMX type.
+bool IsX86_MMXType(llvm::Type *IRType) {
+  // Return true if the type is an MMX type <2 x i32>, <4 x i16>, or <8 x i8>.
+  return IRType->isVectorTy() && IRType->getPrimitiveSizeInBits() == 64 &&
+cast(IRType)->getElementType()->isIntegerTy() &&
+IRType->getScalarSizeInBits() != 64;
+}
+
 static llvm::Type* X86AdjustInlineAsmType(CodeGen::CodeGenFunction &CGF,
   StringRef Constraint,
   llvm::Type* Ty) {
@@ -1003,7 +1011,6 @@ class X86_32ABIInfo : public SwiftABIInf
   bool IsSoftFloatABI;
   bool IsMCUABI;
   unsigned DefaultNumRegisterParameters;
-  bool IsMMXEnabled;
 
   static bool isRegisterSize(unsigned Size) {
 return (Size == 8 || Size == 16 || Size == 32 || Size == 64);
@@ -1063,15 +1070,13 @@ public:
 
   X86_32ABIInfo(CodeGen::CodeGenTypes &CGT, bool DarwinVectorABI,
 bool RetSmallStructInRegABI, bool Win32StructABI,
-unsigned NumRegisterParameters, bool SoftFloatABI,
-bool MMXEnabled)
+unsigned NumRegisterParameters, bool SoftFloatABI)
 : SwiftABIInfo(CGT), IsDarwinVectorABI(DarwinVectorABI),
   IsRetSmallStructInRegABI(RetSmallStructInRegABI),
   IsWin32StructABI(Win32StructABI),
   IsSoftFloatABI(SoftFloatABI),
   IsMCUABI(CGT.getTarget().getTriple().isOSIAMCU()),
-  DefaultNumRegisterParameters(NumRegisterParameters),
-  IsMMXEnabled(MMXEnabled) {}
+  DefaultNumRegisterParameters(NumRegisterParameters) {}
 
   bool shouldPassIndirectlyForSwift(ArrayRef scalars,
 bool asReturnValue) const override {
@@ -1086,30 +1091,16 @@ public:
 // x86-32 lowering does not support passing swifterror in a register.
 return false;
   }
-
-  bool isPassInMMXRegABI() const {
-// The System V i386 psABI requires __m64 to be passed in MMX registers.
-// Clang historically had a bug where it failed to apply this rule, and
-// some platforms (e.g. Darwin, PS4, and FreeBSD) have opted to maintain
-// compatibility with the old Clang behavior, so we only apply it on
-// platforms that have specifically requested it (currently just Linux and
-// NetBSD).
-const llvm::Triple &T = getTarget().getTriple();
-if (IsMMXEnabled && (T.isOSLinux() || T.isOSNetBSD()))
-  return true;
-return false;
-  }
 };
 
 class X86_32TargetCodeGenInfo : public TargetCodeGenInfo {
 public:
   X86_32TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, bool DarwinVectorABI,
   bool RetSmallStructInRegABI, bool Win32StructABI,
-  unsigned NumRegisterParameters, bool SoftFloatABI,
-  bool MMXEnabled = false)
+  unsigned NumRegisterParameters, bool SoftFloatABI)
   : TargetCodeGenInfo(new X86_32ABIInfo(
 CGT, DarwinVectorABI, RetSmallStructInRegABI, Win32StructABI,
-NumRegisterParameters, SoftFloatABI, MMXEnabled)) {}
+NumRegisterParameters, SoftFloatABI)) {}
 
   static bool isStructReturnInRegABI(
   const llvm::Triple &Triple, const CodeGenOptions &Opts);
@@ -1395,9 +1386,10 @@ ABIArgInfo X86_32ABIInfo::classifyReturn
   }
 
   if (const VectorType *VT = RetTy->getAs()) {
-uint64_t Size = getContext().getTypeSize(RetTy);
 // On Darwin, some vectors are returned in registers.
 if (IsDarwinVectorABI) {
+  uint64_

[PATCH] D59744: Fix i386 ABI "__m64" type bug

2019-06-19 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

I've reverted in r363790 until a solution can be found.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59744



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


r363776 - [RISCV] Mark TLS as supported

2019-06-19 Thread Lewis Revill via cfe-commits
Author: lewis-revill
Date: Wed Jun 19 01:53:46 2019
New Revision: 363776

URL: http://llvm.org/viewvc/llvm-project?rev=363776&view=rev
Log:
[RISCV] Mark TLS as supported

Inform Clang that TLS is implemented by LLVM for RISC-V

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


Modified:
cfe/trunk/lib/Basic/Targets/RISCV.h
cfe/trunk/test/CodeGen/thread-specifier.c

Modified: cfe/trunk/lib/Basic/Targets/RISCV.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/RISCV.h?rev=363776&r1=363775&r2=363776&view=diff
==
--- cfe/trunk/lib/Basic/Targets/RISCV.h (original)
+++ cfe/trunk/lib/Basic/Targets/RISCV.h Wed Jun 19 01:53:46 2019
@@ -35,7 +35,6 @@ public:
   RISCVTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
   : TargetInfo(Triple), HasM(false), HasA(false), HasF(false),
 HasD(false), HasC(false) {
-TLSSupported = false;
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::IEEEquad();

Modified: cfe/trunk/test/CodeGen/thread-specifier.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thread-specifier.c?rev=363776&r1=363775&r2=363776&view=diff
==
--- cfe/trunk/test/CodeGen/thread-specifier.c (original)
+++ cfe/trunk/test/CodeGen/thread-specifier.c Wed Jun 19 01:53:46 2019
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple i686-pc-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple riscv32 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm -o - %s | FileCheck %s
 
 // CHECK: @b = external thread_local global
 // CHECK: @d.e = internal thread_local global


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


r363794 - [OpenCL] Split type and macro definitions into opencl-c-base.h

2019-06-19 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Wed Jun 19 05:48:22 2019
New Revision: 363794

URL: http://llvm.org/viewvc/llvm-project?rev=363794&view=rev
Log:
[OpenCL] Split type and macro definitions into opencl-c-base.h

Using the -fdeclare-opencl-builtins option will require a way to
predefine types and macros such as `int4`, `CLK_GLOBAL_MEM_FENCE`,
etc.  Move these out of opencl-c.h into opencl-c-base.h such that the
latter can be shared by -fdeclare-opencl-builtins and
-finclude-default-header.

This changes the behaviour of -finclude-default-header when
-fdeclare-opencl-builtins is specified: instead of including the full
header, it will include the header with only the base definitions.

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

Added:
cfe/trunk/lib/Headers/opencl-c-base.h
Modified:
cfe/trunk/include/clang/Basic/SyncScope.h
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Headers/CMakeLists.txt
cfe/trunk/lib/Headers/module.modulemap
cfe/trunk/lib/Headers/opencl-c.h
cfe/trunk/test/SemaOpenCL/fdeclare-opencl-builtins.cl

Modified: cfe/trunk/include/clang/Basic/SyncScope.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SyncScope.h?rev=363794&r1=363793&r2=363794&view=diff
==
--- cfe/trunk/include/clang/Basic/SyncScope.h (original)
+++ cfe/trunk/include/clang/Basic/SyncScope.h Wed Jun 19 05:48:22 2019
@@ -95,7 +95,7 @@ class AtomicScopeOpenCLModel : public At
 public:
   /// The enum values match the pre-defined macros
   /// __OPENCL_MEMORY_SCOPE_*, which are used to define memory_scope_*
-  /// enums in opencl-c.h.
+  /// enums in opencl-c-base.h.
   enum ID {
 WorkGroup = 1,
 Device = 2,

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=363794&r1=363793&r2=363794&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Jun 19 05:48:22 2019
@@ -2194,9 +2194,15 @@ void CompilerInvocation::setLangDefaults
 Opts.NativeHalfType = 1;
 Opts.NativeHalfArgsAndReturns = 1;
 Opts.OpenCLCPlusPlus = Opts.CPlusPlus;
+
 // Include default header file for OpenCL.
-if (Opts.IncludeDefaultHeader && !Opts.DeclareOpenCLBuiltins) {
-  PPOpts.Includes.push_back("opencl-c.h");
+if (Opts.IncludeDefaultHeader) {
+  if (Opts.DeclareOpenCLBuiltins) {
+// Only include base header file for builtin types and constants.
+PPOpts.Includes.push_back("opencl-c-base.h");
+  } else {
+PPOpts.Includes.push_back("opencl-c.h");
+  }
 }
   }
 

Modified: cfe/trunk/lib/Headers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=363794&r1=363793&r2=363794&view=diff
==
--- cfe/trunk/lib/Headers/CMakeLists.txt (original)
+++ cfe/trunk/lib/Headers/CMakeLists.txt Wed Jun 19 05:48:22 2019
@@ -77,6 +77,7 @@ set(files
   mwaitxintrin.h
   nmmintrin.h
   opencl-c.h
+  opencl-c-base.h
   pkuintrin.h
   pmmintrin.h
   pconfigintrin.h

Modified: cfe/trunk/lib/Headers/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/module.modulemap?rev=363794&r1=363793&r2=363794&view=diff
==
--- cfe/trunk/lib/Headers/module.modulemap (original)
+++ cfe/trunk/lib/Headers/module.modulemap Wed Jun 19 05:48:22 2019
@@ -154,4 +154,5 @@ module _Builtin_stddef_max_align_t [syst
 module opencl_c {
   requires opencl
   header "opencl-c.h"
+  header "opencl-c-base.h"
 }

Added: cfe/trunk/lib/Headers/opencl-c-base.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/opencl-c-base.h?rev=363794&view=auto
==
--- cfe/trunk/lib/Headers/opencl-c-base.h (added)
+++ cfe/trunk/lib/Headers/opencl-c-base.h Wed Jun 19 05:48:22 2019
@@ -0,0 +1,573 @@
+//===- opencl-c-base.h - OpenCL C language base definitions 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _OPENCL_BASE_H_
+#define _OPENCL_BASE_H_
+
+// built-in scalar data types:
+
+/**
+ * An unsigned 8-bit integer.
+ */
+typedef unsigned char uchar;
+
+/**
+ * An unsigned 16-bit integer.
+ */
+typedef unsigned short ushort;
+
+/**
+ * An unsigned 32-bit integer.
+ */
+typedef unsigned int uint;
+
+/**
+ * An unsigned 64-bit integer.
+ */
+typedef unsigned long ulong;
+
+/**
+ * The unsigned integer type of the 

[PATCH] D63256: [OpenCL] Split type and macro definitions into opencl-c-base.h

2019-06-19 Thread Sven van Haastregt via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL363794: [OpenCL] Split type and macro definitions into 
opencl-c-base.h (authored by svenvh, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D63256?vs=204796&id=205558#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63256

Files:
  cfe/trunk/include/clang/Basic/SyncScope.h
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/lib/Headers/CMakeLists.txt
  cfe/trunk/lib/Headers/module.modulemap
  cfe/trunk/lib/Headers/opencl-c-base.h
  cfe/trunk/lib/Headers/opencl-c.h
  cfe/trunk/test/SemaOpenCL/fdeclare-opencl-builtins.cl

Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -2194,9 +2194,15 @@
 Opts.NativeHalfType = 1;
 Opts.NativeHalfArgsAndReturns = 1;
 Opts.OpenCLCPlusPlus = Opts.CPlusPlus;
+
 // Include default header file for OpenCL.
-if (Opts.IncludeDefaultHeader && !Opts.DeclareOpenCLBuiltins) {
-  PPOpts.Includes.push_back("opencl-c.h");
+if (Opts.IncludeDefaultHeader) {
+  if (Opts.DeclareOpenCLBuiltins) {
+// Only include base header file for builtin types and constants.
+PPOpts.Includes.push_back("opencl-c-base.h");
+  } else {
+PPOpts.Includes.push_back("opencl-c.h");
+  }
 }
   }
 
Index: cfe/trunk/lib/Headers/opencl-c.h
===
--- cfe/trunk/lib/Headers/opencl-c.h
+++ cfe/trunk/lib/Headers/opencl-c.h
@@ -9,6 +9,8 @@
 #ifndef _OPENCL_H_
 #define _OPENCL_H_
 
+#include "opencl-c-base.h"
+
 #if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 #ifndef cl_khr_depth_images
 #define cl_khr_depth_images
@@ -33,255 +35,6 @@
 #define __purefn __attribute__((pure))
 #define __cnfn __attribute__((const))
 
-// built-in scalar data types:
-
-/**
- * An unsigned 8-bit integer.
- */
-typedef unsigned char uchar;
-
-/**
- * An unsigned 16-bit integer.
- */
-typedef unsigned short ushort;
-
-/**
- * An unsigned 32-bit integer.
- */
-typedef unsigned int uint;
-
-/**
- * An unsigned 64-bit integer.
- */
-typedef unsigned long ulong;
-
-/**
- * The unsigned integer type of the result of the sizeof operator. This
- * is a 32-bit unsigned integer if CL_DEVICE_ADDRESS_BITS
- * defined in table 4.3 is 32-bits and is a 64-bit unsigned integer if
- * CL_DEVICE_ADDRESS_BITS is 64-bits.
- */
-typedef __SIZE_TYPE__ size_t;
-
-/**
- * A signed integer type that is the result of subtracting two pointers.
- * This is a 32-bit signed integer if CL_DEVICE_ADDRESS_BITS
- * defined in table 4.3 is 32-bits and is a 64-bit signed integer if
- * CL_DEVICE_ADDRESS_BITS is 64-bits.
- */
-typedef __PTRDIFF_TYPE__ ptrdiff_t;
-
-/**
-* A signed integer type with the property that any valid pointer to
-* void can be converted to this type, then converted back to pointer
-* to void, and the result will compare equal to the original pointer.
-*/
-typedef __INTPTR_TYPE__ intptr_t;
-
-/**
-* An unsigned integer type with the property that any valid pointer to
-* void can be converted to this type, then converted back to pointer
-* to void, and the result will compare equal to the original pointer.
-*/
-typedef __UINTPTR_TYPE__ uintptr_t;
-
-// built-in vector data types:
-typedef char char2 __attribute__((ext_vector_type(2)));
-typedef char char3 __attribute__((ext_vector_type(3)));
-typedef char char4 __attribute__((ext_vector_type(4)));
-typedef char char8 __attribute__((ext_vector_type(8)));
-typedef char char16 __attribute__((ext_vector_type(16)));
-typedef uchar uchar2 __attribute__((ext_vector_type(2)));
-typedef uchar uchar3 __attribute__((ext_vector_type(3)));
-typedef uchar uchar4 __attribute__((ext_vector_type(4)));
-typedef uchar uchar8 __attribute__((ext_vector_type(8)));
-typedef uchar uchar16 __attribute__((ext_vector_type(16)));
-typedef short short2 __attribute__((ext_vector_type(2)));
-typedef short short3 __attribute__((ext_vector_type(3)));
-typedef short short4 __attribute__((ext_vector_type(4)));
-typedef short short8 __attribute__((ext_vector_type(8)));
-typedef short short16 __attribute__((ext_vector_type(16)));
-typedef ushort ushort2 __attribute__((ext_vector_type(2)));
-typedef ushort ushort3 __attribute__((ext_vector_type(3)));
-typedef ushort ushort4 __attribute__((ext_vector_type(4)));
-typedef ushort ushort8 __attribute__((ext_vector_type(8)));
-typedef ushort ushort16 __attribute__((ext_vector_type(16)));
-typedef int int2 __attribute__((ext_vector_type(2)));
-typedef int int3 __attribute__((ext_vector_type(3)));
-typedef int int4 __attribute__((ext_vector_type(4)));
-typedef int int8 __attribute__((ext_vector_type(8)));
-typedef int int16 __attribute__((ext_vector_t

[PATCH] D61552: [clang] Adapt ASTMatcher to explicit(bool) specifier

2019-06-19 Thread Tyker via Phabricator via cfe-commits
Tyker updated this revision to Diff 205559.
Tyker marked 3 inline comments as done.
Tyker added a comment.

fixed requested changes.

> Are you getting errors from running it, or just incorrect output?

the issue happens to me even on master so i suppose the input is correct.
here is the error report:

  [tyker@tyker tools]$ ./dump_ast_matchers.py 
  *** Unparsable: " #ifndef LLVM_CLANG_ASTMATCHERS_ASTMATCHERS_H #define 
LLVM_CLANG_ASTMATCHERS_ASTMATCHERS_H " ***
  *** Unparsable: " #include "clang/AST/ASTContext.h" #include 
"clang/AST/ASTTypeTraits.h" #include "clang/AST/Attr.h" #include 
"clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" #include 
"clang/AST/DeclFriend.h" #include "clang/AST/DeclObjC.h" #include 
"clang/AST/DeclTemplate.h" #include "clang/AST/Expr.h" #include 
"clang/AST/ExprCXX.h" #include "clang/AST/ExprObjC.h" #include 
"clang/AST/NestedNameSpecifier.h" #include "clang/AST/OpenMPClause.h" #include 
"clang/AST/OperationKinds.h" #include "clang/AST/Stmt.h" #include 
"clang/AST/StmtCXX.h" #include "clang/AST/StmtObjC.h" #include 
"clang/AST/StmtOpenMP.h" #include "clang/AST/TemplateBase.h" #include 
"clang/AST/TemplateName.h" #include "clang/AST/Type.h" #include 
"clang/AST/TypeLoc.h" #include "clang/ASTMatchers/ASTMatchersInternal.h" 
#include "clang/ASTMatchers/ASTMatchersMacros.h" #include 
"clang/Basic/AttrKinds.h" #include "clang/Basic/ExceptionSpecificationType.h" 
#include "clang/Basic/IdentifierTable.h" #include "clang/Basic/LLVM.h" #include 
"clang/Basic/SourceManager.h" #include "clang/Basic/Specifiers.h" #include 
"clang/Basic/TypeTraits.h" #include "llvm/ADT/ArrayRef.h" #include 
"llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include 
"llvm/Support/Casting.h" #include "llvm/Support/Compiler.h" #include 
"llvm/Support/ErrorHandling.h" #include "llvm/Support/Regex.h" #include 
 #include  #include  #include  #include 
 #include  #include  " ***
  *** Unparsable: " namespace clang {" ***
  *** Unparsable: " using DeclarationMatcher = internal::Matcher;" ***
  *** Unparsable: " using StatementMatcher = internal::Matcher;" ***
  *** Unparsable: " using TypeMatcher = internal::Matcher;" ***
  *** Unparsable: " using TypeLocMatcher = internal::Matcher;" ***
  *** Unparsable: " using NestedNameSpecifierMatcher = 
internal::Matcher;" ***
  *** Unparsable: " using NestedNameSpecifierLocMatcher = 
internal::Matcher;" ***
  *** Unparsable: " using CXXCtorInitializerMatcher = 
internal::Matcher;" ***
  Probing https://clang.llvm.org/doxygen/classclang_1_1Decl.html...

after this the script keep probing with no issues.
i tested using python 2.7 and python 3.7 the same error occurs


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

https://reviews.llvm.org/D61552

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1735,6 +1735,56 @@
 llvm::make_unique>("x", 3)));
 }
 
+TEST(Declaration, HasExplicitSpecifier) {
+  EXPECT_TRUE(matchesConditionally(
+  "void f();", functionDecl(hasExplicitSpecifier(constantExpr())), false,
+  "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "template struct S { explicit operator int(); };",
+  cxxConversionDecl(hasExplicitSpecifier(constantExpr(has(cxxBoolLiteral(),
+  false, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "template struct S { explicit(b) operator int(); };",
+  cxxConversionDecl(hasExplicitSpecifier(constantExpr(has(cxxBoolLiteral(),
+  false, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "struct S { explicit(true) operator int(); };",
+  cxxConversionDecl(hasExplicitSpecifier(constantExpr(has(cxxBoolLiteral(),
+  true, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "struct S { explicit(false) operator int(); };",
+  cxxConversionDecl(hasExplicitSpecifier(constantExpr(has(cxxBoolLiteral(),
+  true, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "template struct S { explicit(b) S(int); };",
+  cxxConstructorDecl(hasExplicitSpecifier(constantExpr(has(cxxBoolLiteral(),
+  false, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "struct S { explicit(true) S(int); };",
+  cxxConstructorDecl(hasExplicitSpecifier(constantExpr(has(cxxBoolLiteral(),
+  true, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "struct S { explicit(false) S(int); };",
+  cxxConstructorDecl(hasExplicitSpecifier(constantExpr(has(cxxBoolLiteral(),
+  true, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "tem

[clang-tools-extra] r363798 - [clangd] Correct the MessageType enum values.

2019-06-19 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed Jun 19 06:14:59 2019
New Revision: 363798

URL: http://llvm.org/viewvc/llvm-project?rev=363798&view=rev
Log:
[clangd] Correct the MessageType enum values.

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

Modified: clang-tools-extra/trunk/clangd/Protocol.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.h?rev=363798&r1=363797&r2=363798&view=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.h (original)
+++ clang-tools-extra/trunk/clangd/Protocol.h Wed Jun 19 06:14:59 2019
@@ -487,11 +487,11 @@ enum class MessageType {
   /// An error message.
   Error = 1,
   /// A warning message.
-  Warning = 1,
+  Warning = 2,
   /// An information message.
-  Info = 1,
+  Info = 3,
   /// A log message.
-  Log = 1,
+  Log = 4,
 };
 llvm::json::Value toJSON(const MessageType &);
 


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


[PATCH] D61552: [clang] Adapt ASTMatcher to explicit(bool) specifier

2019-06-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D61552#1550080 , @Tyker wrote:

> fixed requested changes.
>
> > Are you getting errors from running it, or just incorrect output?
>
> the issue happens to me even on master so i suppose the input is correct.
>  here is the error report:
>
>   [tyker@tyker tools]$ ./dump_ast_matchers.py 
>   *** Unparsable: " #ifndef LLVM_CLANG_ASTMATCHERS_ASTMATCHERS_H #define 
> LLVM_CLANG_ASTMATCHERS_ASTMATCHERS_H " ***
>   *** Unparsable: " #include "clang/AST/ASTContext.h" #include 
> "clang/AST/ASTTypeTraits.h" #include "clang/AST/Attr.h" #include 
> "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" #include 
> "clang/AST/DeclFriend.h" #include "clang/AST/DeclObjC.h" #include 
> "clang/AST/DeclTemplate.h" #include "clang/AST/Expr.h" #include 
> "clang/AST/ExprCXX.h" #include "clang/AST/ExprObjC.h" #include 
> "clang/AST/NestedNameSpecifier.h" #include "clang/AST/OpenMPClause.h" 
> #include "clang/AST/OperationKinds.h" #include "clang/AST/Stmt.h" #include 
> "clang/AST/StmtCXX.h" #include "clang/AST/StmtObjC.h" #include 
> "clang/AST/StmtOpenMP.h" #include "clang/AST/TemplateBase.h" #include 
> "clang/AST/TemplateName.h" #include "clang/AST/Type.h" #include 
> "clang/AST/TypeLoc.h" #include "clang/ASTMatchers/ASTMatchersInternal.h" 
> #include "clang/ASTMatchers/ASTMatchersMacros.h" #include 
> "clang/Basic/AttrKinds.h" #include "clang/Basic/ExceptionSpecificationType.h" 
> #include "clang/Basic/IdentifierTable.h" #include "clang/Basic/LLVM.h" 
> #include "clang/Basic/SourceManager.h" #include "clang/Basic/Specifiers.h" 
> #include "clang/Basic/TypeTraits.h" #include "llvm/ADT/ArrayRef.h" #include 
> "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include 
> "llvm/Support/Casting.h" #include "llvm/Support/Compiler.h" #include 
> "llvm/Support/ErrorHandling.h" #include "llvm/Support/Regex.h" #include 
>  #include  #include  #include  #include 
>  #include  #include  " ***
>   *** Unparsable: " namespace clang {" ***
>   *** Unparsable: " using DeclarationMatcher = internal::Matcher;" ***
>   *** Unparsable: " using StatementMatcher = internal::Matcher;" ***
>   *** Unparsable: " using TypeMatcher = internal::Matcher;" ***
>   *** Unparsable: " using TypeLocMatcher = internal::Matcher;" ***
>   *** Unparsable: " using NestedNameSpecifierMatcher = 
> internal::Matcher;" ***
>   *** Unparsable: " using NestedNameSpecifierLocMatcher = 
> internal::Matcher;" ***
>   *** Unparsable: " using CXXCtorInitializerMatcher = 
> internal::Matcher;" ***
>   Probing https://clang.llvm.org/doxygen/classclang_1_1Decl.html...
>
>
> after this the script keep probing with no issues.
>  i tested using python 2.7 and python 3.7 the same error occurs


That output matches what I get, and my docs generate for me. Are you sure the 
.html file is not being generated properly for you?


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

https://reviews.llvm.org/D61552



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


[PATCH] D62953: [Syntax] Do not glue multiple empty PP expansions to a single mapping

2019-06-19 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

To clarify, I don't think there are new concepts in this patch.
Previously, we only took information from source locations into account when 
building token buffers. That works fine in most cases, but not enough to find 
the boundaries of empty macro expansions.
In order to find those, we now also watch the callbacks from the preprocessor 
to get all macro expansions (incuding the empty ones) and reconstruct the 
mappings of token buffers from there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62953



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


[PATCH] D33841: [clang-tidy] redundant 'extern' keyword check

2019-06-19 Thread Daniel Kolozsvari via Phabricator via cfe-commits
koldaniel marked an inline comment as done.
koldaniel added inline comments.



Comment at: clang-tidy/readability/RedundantExternCheck.cpp:43-44
+
+  if (FD->getBeginLoc().isMacroID())
+return;
+

lebedev.ri wrote:
> koldaniel wrote:
> > lebedev.ri wrote:
> > > Similarly, do this in `registerMatchers()`
> > Could you please help me how could I achieve that? I did not find any 
> > matchers which match for macros.
> You can simply add your own matchers, see e.g. `AST_MATCHER()`'s in  
> `AvoidCArraysCheck.cpp`.
I see, I can update the checker based on your previous comment (move  `if 
(FD->getStorageClass() != SC_Extern)` to `registerMatchers()`), but moving the 
macro check would disable the warning. We do not want to ignore the macro 
findings, we just don't want to apply fix-its.


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

https://reviews.llvm.org/D33841



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


[PATCH] D63454: [OpenMP] Strengthen regression tests for task allocation under nowait depend clauses NFC

2019-06-19 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

ping


Repository:
  rC Clang

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

https://reviews.llvm.org/D63454



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


[PATCH] D63454: [OpenMP] Strengthen regression tests for task allocation under nowait depend clauses NFC

2019-06-19 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rC Clang

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

https://reviews.llvm.org/D63454



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


r363801 - [Syntax] Fix a crash when dumping empty token buffer

2019-06-19 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Jun 19 06:56:36 2019
New Revision: 363801

URL: http://llvm.org/viewvc/llvm-project?rev=363801&view=rev
Log:
[Syntax] Fix a crash when dumping empty token buffer

Modified:
cfe/trunk/lib/Tooling/Syntax/Tokens.cpp
cfe/trunk/unittests/Tooling/Syntax/TokensTest.cpp

Modified: cfe/trunk/lib/Tooling/Syntax/Tokens.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Syntax/Tokens.cpp?rev=363801&r1=363800&r2=363801&view=diff
==
--- cfe/trunk/lib/Tooling/Syntax/Tokens.cpp (original)
+++ cfe/trunk/lib/Tooling/Syntax/Tokens.cpp Wed Jun 19 06:56:36 2019
@@ -477,8 +477,7 @@ std::string TokenBuffer::dumpForTests()
 
   auto DumpTokens = [this, &PrintToken](llvm::raw_ostream &OS,
 llvm::ArrayRef Tokens) {
-if (Tokens.size() == 1) {
-  assert(Tokens[0].kind() == tok::eof);
+if (Tokens.empty()) {
   OS << "";
   return;
 }
@@ -495,7 +494,8 @@ std::string TokenBuffer::dumpForTests()
 
   OS << "expanded tokens:\n"
  << "  ";
-  DumpTokens(OS, ExpandedTokens);
+  // (!) we do not show ''.
+  DumpTokens(OS, llvm::makeArrayRef(ExpandedTokens).drop_back());
   OS << "\n";
 
   std::vector Keys;

Modified: cfe/trunk/unittests/Tooling/Syntax/TokensTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/Syntax/TokensTest.cpp?rev=363801&r1=363800&r2=363801&view=diff
==
--- cfe/trunk/unittests/Tooling/Syntax/TokensTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/Syntax/TokensTest.cpp Wed Jun 19 06:56:36 2019
@@ -290,6 +290,14 @@ file './input.cpp'
 # pragma GCC visibility push ( public ) # pragma GCC visibility pop
   mappings:
 ['#'_0, ''_13) => [''_0, ''_0)
+)"},
+  // Empty files should not crash.
+  {R"cpp()cpp", R"(expanded tokens:
+  
+file './input.cpp'
+  spelled tokens:
+
+  no mappings.
 )"}};
   for (auto &Test : TestCases)
 EXPECT_EQ(collectAndDump(Test.first), Test.second)


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


[clang-tools-extra] r363803 - [clangd] Collect tokens of main files when building the AST

2019-06-19 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Jun 19 07:03:19 2019
New Revision: 363803

URL: http://llvm.org/viewvc/llvm-project?rev=363803&view=rev
Log:
[clangd] Collect tokens of main files when building the AST

Summary:
The first use of this is a code tweak to expand macro calls.
Will later be used to build syntax trees.

The memory overhead is small as we only store tokens of the main file.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/CMakeLists.txt
clang-tools-extra/trunk/clangd/ClangdUnit.cpp
clang-tools-extra/trunk/clangd/ClangdUnit.h
clang-tools-extra/trunk/clangd/tool/CMakeLists.txt
clang-tools-extra/trunk/clangd/unittests/CMakeLists.txt
clang-tools-extra/trunk/clangd/unittests/ClangdUnitTests.cpp

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=363803&r1=363802&r2=363803&view=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Wed Jun 19 07:03:19 2019
@@ -128,6 +128,7 @@ add_clang_library(clangDaemon
   clangToolingCore
   clangToolingInclusions
   clangToolingRefactoring
+  clangToolingSyntax
   ${LLVM_PTHREAD_LIB}
   ${CLANGD_ATOMIC_LIB}
   )

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=363803&r1=363802&r2=363803&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Wed Jun 19 07:03:19 2019
@@ -36,6 +36,7 @@
 #include "clang/Serialization/ASTWriter.h"
 #include "clang/Serialization/PCHContainerOperations.h"
 #include "clang/Tooling/CompilationDatabase.h"
+#include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
@@ -418,6 +419,9 @@ ParsedAST::build(std::unique_ptrgetPreprocessor().addCommentHandler(IWYUHandler.get());
 
+  // Collect tokens of the main file.
+  syntax::TokenCollector Tokens(Clang->getPreprocessor());
+
   if (!Action->Execute())
 log("Execute() failed when building AST for {0}", MainInput.getFile());
 
@@ -446,8 +450,9 @@ ParsedAST::build(std::unique_ptrDiags.begin(), 
Preamble->Diags.end());
   return ParsedAST(std::move(Preamble), std::move(Clang), std::move(Action),
-   std::move(ParsedDecls), std::move(Diags),
-   std::move(Includes), std::move(CanonIncludes));
+   std::move(Tokens).consume(), std::move(ParsedDecls),
+   std::move(Diags), std::move(Includes),
+   std::move(CanonIncludes));
 }
 
 ParsedAST::ParsedAST(ParsedAST &&Other) = default;
@@ -540,11 +545,13 @@ PreambleData::PreambleData(PrecompiledPr
 ParsedAST::ParsedAST(std::shared_ptr Preamble,
  std::unique_ptr Clang,
  std::unique_ptr Action,
+ syntax::TokenBuffer Tokens,
  std::vector LocalTopLevelDecls,
  std::vector Diags, IncludeStructure Includes,
  CanonicalIncludes CanonIncludes)
 : Preamble(std::move(Preamble)), Clang(std::move(Clang)),
-  Action(std::move(Action)), Diags(std::move(Diags)),
+  Action(std::move(Action)), Tokens(std::move(Tokens)),
+  Diags(std::move(Diags)),
   LocalTopLevelDecls(std::move(LocalTopLevelDecls)),
   Includes(std::move(Includes)), CanonIncludes(std::move(CanonIncludes)) {
   assert(this->Clang);

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.h?rev=363803&r1=363802&r2=363803&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.h Wed Jun 19 07:03:19 2019
@@ -24,6 +24,7 @@
 #include "clang/Serialization/ASTBitCodes.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "clang/Tooling/Syntax/Tokens.h"
 #include 
 #include 
 #include 
@@ -115,10 +116,14 @@ public:
   const IncludeStructure &getIncludeStructure() const;
   const CanonicalIncludes &getCanonicalIncludes() const;
 
+  /// Tokens recorded while parsing the main file.
+  /// (!) does not have tokens from the preamble.
+  const syntax::TokenBuffer &getTokens() const { return Tokens; }
+
 private:
   ParsedAST(std::shared_ptr Preamble,
 std::unique_ptr Clang,
-std::unique_ptr Action,
+std::unique_ptr Action, syntax::TokenBuffer T

[PATCH] D62956: [clangd] Collect tokens of main files when building the AST

2019-06-19 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL363803: [clangd] Collect tokens of main files when building 
the AST (authored by ibiryukov, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62956?vs=205387&id=205579#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62956

Files:
  clang-tools-extra/trunk/clangd/CMakeLists.txt
  clang-tools-extra/trunk/clangd/ClangdUnit.cpp
  clang-tools-extra/trunk/clangd/ClangdUnit.h
  clang-tools-extra/trunk/clangd/tool/CMakeLists.txt
  clang-tools-extra/trunk/clangd/unittests/CMakeLists.txt
  clang-tools-extra/trunk/clangd/unittests/ClangdUnitTests.cpp

Index: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp
@@ -36,6 +36,7 @@
 #include "clang/Serialization/ASTWriter.h"
 #include "clang/Serialization/PCHContainerOperations.h"
 #include "clang/Tooling/CompilationDatabase.h"
+#include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
@@ -418,6 +419,9 @@
   collectIWYUHeaderMaps(&CanonIncludes);
   Clang->getPreprocessor().addCommentHandler(IWYUHandler.get());
 
+  // Collect tokens of the main file.
+  syntax::TokenCollector Tokens(Clang->getPreprocessor());
+
   if (!Action->Execute())
 log("Execute() failed when building AST for {0}", MainInput.getFile());
 
@@ -446,8 +450,9 @@
   if (Preamble)
 Diags.insert(Diags.begin(), Preamble->Diags.begin(), Preamble->Diags.end());
   return ParsedAST(std::move(Preamble), std::move(Clang), std::move(Action),
-   std::move(ParsedDecls), std::move(Diags),
-   std::move(Includes), std::move(CanonIncludes));
+   std::move(Tokens).consume(), std::move(ParsedDecls),
+   std::move(Diags), std::move(Includes),
+   std::move(CanonIncludes));
 }
 
 ParsedAST::ParsedAST(ParsedAST &&Other) = default;
@@ -540,11 +545,13 @@
 ParsedAST::ParsedAST(std::shared_ptr Preamble,
  std::unique_ptr Clang,
  std::unique_ptr Action,
+ syntax::TokenBuffer Tokens,
  std::vector LocalTopLevelDecls,
  std::vector Diags, IncludeStructure Includes,
  CanonicalIncludes CanonIncludes)
 : Preamble(std::move(Preamble)), Clang(std::move(Clang)),
-  Action(std::move(Action)), Diags(std::move(Diags)),
+  Action(std::move(Action)), Tokens(std::move(Tokens)),
+  Diags(std::move(Diags)),
   LocalTopLevelDecls(std::move(LocalTopLevelDecls)),
   Includes(std::move(Includes)), CanonIncludes(std::move(CanonIncludes)) {
   assert(this->Clang);
Index: clang-tools-extra/trunk/clangd/tool/CMakeLists.txt
===
--- clang-tools-extra/trunk/clangd/tool/CMakeLists.txt
+++ clang-tools-extra/trunk/clangd/tool/CMakeLists.txt
@@ -26,5 +26,6 @@
   clangSema
   clangTooling
   clangToolingCore
+  clangToolingSyntax
   ${CLANGD_XPC_LIBS}
   )
Index: clang-tools-extra/trunk/clangd/CMakeLists.txt
===
--- clang-tools-extra/trunk/clangd/CMakeLists.txt
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt
@@ -128,6 +128,7 @@
   clangToolingCore
   clangToolingInclusions
   clangToolingRefactoring
+  clangToolingSyntax
   ${LLVM_PTHREAD_LIB}
   ${CLANGD_ATOMIC_LIB}
   )
Index: clang-tools-extra/trunk/clangd/ClangdUnit.h
===
--- clang-tools-extra/trunk/clangd/ClangdUnit.h
+++ clang-tools-extra/trunk/clangd/ClangdUnit.h
@@ -24,6 +24,7 @@
 #include "clang/Serialization/ASTBitCodes.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "clang/Tooling/Syntax/Tokens.h"
 #include 
 #include 
 #include 
@@ -115,10 +116,14 @@
   const IncludeStructure &getIncludeStructure() const;
   const CanonicalIncludes &getCanonicalIncludes() const;
 
+  /// Tokens recorded while parsing the main file.
+  /// (!) does not have tokens from the preamble.
+  const syntax::TokenBuffer &getTokens() const { return Tokens; }
+
 private:
   ParsedAST(std::shared_ptr Preamble,
 std::unique_ptr Clang,
-std::unique_ptr Action,
+std::unique_ptr Action, syntax::TokenBuffer Tokens,
 std::vector LocalTopLevelDecls, std::vector Diags,
 IncludeStructure Includes, CanonicalIncludes CanonIncludes);
 
@@ -132,6 +137,11 @@
   // FrontendAction.EndSourceFile).
   std::unique_ptr Clang;
   std::unique_ptr Action;
+  /// Tokens recorded after the preamble finished.
+  ///   

r363804 - Allow copy/move assignment operator to be coroutine as per N4775

2019-06-19 Thread Vivek Pandya via cfe-commits
Author: vivekvpandya
Date: Wed Jun 19 07:12:19 2019
New Revision: 363804

URL: http://llvm.org/viewvc/llvm-project?rev=363804&view=rev
Log:
Allow copy/move assignment operator to be coroutine as per N4775

This change fixes https://bugs.llvm.org/show_bug.cgi?id=40997.

Reviewers: GorNishanov, rsmith
Reviewed by: GorNishanov
Subscribers: cfe-commits, lewissbaker, modocache, llvm-commits

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaCoroutine.cpp
cfe/trunk/test/SemaCXX/coroutines.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=363804&r1=363803&r2=363804&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jun 19 07:12:19 
2019
@@ -9432,9 +9432,9 @@ def err_coroutine_outside_function : Err
   "'%0' cannot be used outside a function">;
 def err_coroutine_invalid_func_context : Error<
   "'%1' cannot be used in %select{a constructor|a destructor"
-  "|a copy assignment operator|a move assignment operator|the 'main' function"
-  "|a constexpr function|a function with a deduced return type"
-  "|a varargs function|a consteval function}0">;
+  "|the 'main' function|a constexpr function"
+  "|a function with a deduced return type|a varargs function"
+  "|a consteval function}0">;
 def err_implied_coroutine_type_not_found : Error<
   "%0 type was not found; include  before defining "
   "a coroutine">;

Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCoroutine.cpp?rev=363804&r1=363803&r2=363804&view=diff
==
--- cfe/trunk/lib/Sema/SemaCoroutine.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCoroutine.cpp Wed Jun 19 07:12:19 2019
@@ -204,8 +204,6 @@ static bool isValidCoroutineContext(Sema
   enum InvalidFuncDiag {
 DiagCtor = 0,
 DiagDtor,
-DiagCopyAssign,
-DiagMoveAssign,
 DiagMain,
 DiagConstexpr,
 DiagAutoRet,
@@ -219,23 +217,15 @@ static bool isValidCoroutineContext(Sema
 return false;
   };
 
-  // Diagnose when a constructor, destructor, copy/move assignment operator,
+  // Diagnose when a constructor, destructor
   // or the function 'main' are declared as a coroutine.
   auto *MD = dyn_cast(FD);
-  // [class.ctor]p6: "A constructor shall not be a coroutine."
+  // [class.ctor]p11: "A constructor shall not be a coroutine."
   if (MD && isa(MD))
 return DiagInvalid(DiagCtor);
   // [class.dtor]p17: "A destructor shall not be a coroutine."
   else if (MD && isa(MD))
 return DiagInvalid(DiagDtor);
-  // N4499 [special]p6: "A special member function shall not be a coroutine."
-  // Per C++ [special]p1, special member functions are the "default 
constructor,
-  // copy constructor and copy assignment operator, move constructor and move
-  // assignment operator, and destructor."
-  else if (MD && MD->isCopyAssignmentOperator())
-return DiagInvalid(DiagCopyAssign);
-  else if (MD && MD->isMoveAssignmentOperator())
-return DiagInvalid(DiagMoveAssign);
   // [basic.start.main]p3: "The function main shall not be a coroutine."
   else if (FD->isMain())
 return DiagInvalid(DiagMain);

Modified: cfe/trunk/test/SemaCXX/coroutines.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/coroutines.cpp?rev=363804&r1=363803&r2=363804&view=diff
==
--- cfe/trunk/test/SemaCXX/coroutines.cpp (original)
+++ cfe/trunk/test/SemaCXX/coroutines.cpp Wed Jun 19 07:12:19 2019
@@ -296,18 +296,17 @@ struct CtorDtor {
   ~CtorDtor() {
 co_return 0; // expected-error {{'co_return' cannot be used in a 
destructor}}
   }
-  // FIXME: The spec says this is ill-formed.
   void operator=(CtorDtor&) {
-co_yield 0; // expected-error {{'co_yield' cannot be used in a copy 
assignment operator}}
+co_yield 0; // OK.
   }
   void operator=(CtorDtor const &) {
-co_yield 0; // expected-error {{'co_yield' cannot be used in a copy 
assignment operator}}
+co_yield 0; // OK.
   }
   void operator=(CtorDtor &&) {
-co_await a; // expected-error {{'co_await' cannot be used in a move 
assignment operator}}
+co_await a; // OK.
   }
   void operator=(CtorDtor const &&) {
-co_await a; // expected-error {{'co_await' cannot be used in a move 
assignment operator}}
+co_await a; // OK.
   }
   void operator=(int) {
 co_await a; // OK. Not a special member


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


[PATCH] D63381: Allow copy/move assignment operator to be coroutine as per N4775

2019-06-19 Thread Vivek Pandya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL363804: Allow copy/move assignment operator to be coroutine 
as per N4775 (authored by vivekvpandya, committed by ).
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D63381?vs=204934&id=205581#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63381

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaCoroutine.cpp
  cfe/trunk/test/SemaCXX/coroutines.cpp


Index: cfe/trunk/test/SemaCXX/coroutines.cpp
===
--- cfe/trunk/test/SemaCXX/coroutines.cpp
+++ cfe/trunk/test/SemaCXX/coroutines.cpp
@@ -296,18 +296,17 @@
   ~CtorDtor() {
 co_return 0; // expected-error {{'co_return' cannot be used in a 
destructor}}
   }
-  // FIXME: The spec says this is ill-formed.
   void operator=(CtorDtor&) {
-co_yield 0; // expected-error {{'co_yield' cannot be used in a copy 
assignment operator}}
+co_yield 0; // OK.
   }
   void operator=(CtorDtor const &) {
-co_yield 0; // expected-error {{'co_yield' cannot be used in a copy 
assignment operator}}
+co_yield 0; // OK.
   }
   void operator=(CtorDtor &&) {
-co_await a; // expected-error {{'co_await' cannot be used in a move 
assignment operator}}
+co_await a; // OK.
   }
   void operator=(CtorDtor const &&) {
-co_await a; // expected-error {{'co_await' cannot be used in a move 
assignment operator}}
+co_await a; // OK.
   }
   void operator=(int) {
 co_await a; // OK. Not a special member
Index: cfe/trunk/lib/Sema/SemaCoroutine.cpp
===
--- cfe/trunk/lib/Sema/SemaCoroutine.cpp
+++ cfe/trunk/lib/Sema/SemaCoroutine.cpp
@@ -204,8 +204,6 @@
   enum InvalidFuncDiag {
 DiagCtor = 0,
 DiagDtor,
-DiagCopyAssign,
-DiagMoveAssign,
 DiagMain,
 DiagConstexpr,
 DiagAutoRet,
@@ -219,23 +217,15 @@
 return false;
   };
 
-  // Diagnose when a constructor, destructor, copy/move assignment operator,
+  // Diagnose when a constructor, destructor
   // or the function 'main' are declared as a coroutine.
   auto *MD = dyn_cast(FD);
-  // [class.ctor]p6: "A constructor shall not be a coroutine."
+  // [class.ctor]p11: "A constructor shall not be a coroutine."
   if (MD && isa(MD))
 return DiagInvalid(DiagCtor);
   // [class.dtor]p17: "A destructor shall not be a coroutine."
   else if (MD && isa(MD))
 return DiagInvalid(DiagDtor);
-  // N4499 [special]p6: "A special member function shall not be a coroutine."
-  // Per C++ [special]p1, special member functions are the "default 
constructor,
-  // copy constructor and copy assignment operator, move constructor and move
-  // assignment operator, and destructor."
-  else if (MD && MD->isCopyAssignmentOperator())
-return DiagInvalid(DiagCopyAssign);
-  else if (MD && MD->isMoveAssignmentOperator())
-return DiagInvalid(DiagMoveAssign);
   // [basic.start.main]p3: "The function main shall not be a coroutine."
   else if (FD->isMain())
 return DiagInvalid(DiagMain);
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9432,9 +9432,9 @@
   "'%0' cannot be used outside a function">;
 def err_coroutine_invalid_func_context : Error<
   "'%1' cannot be used in %select{a constructor|a destructor"
-  "|a copy assignment operator|a move assignment operator|the 'main' function"
-  "|a constexpr function|a function with a deduced return type"
-  "|a varargs function|a consteval function}0">;
+  "|the 'main' function|a constexpr function"
+  "|a function with a deduced return type|a varargs function"
+  "|a consteval function}0">;
 def err_implied_coroutine_type_not_found : Error<
   "%0 type was not found; include  before defining "
   "a coroutine">;


Index: cfe/trunk/test/SemaCXX/coroutines.cpp
===
--- cfe/trunk/test/SemaCXX/coroutines.cpp
+++ cfe/trunk/test/SemaCXX/coroutines.cpp
@@ -296,18 +296,17 @@
   ~CtorDtor() {
 co_return 0; // expected-error {{'co_return' cannot be used in a destructor}}
   }
-  // FIXME: The spec says this is ill-formed.
   void operator=(CtorDtor&) {
-co_yield 0; // expected-error {{'co_yield' cannot be used in a copy assignment operator}}
+co_yield 0; // OK.
   }
   void operator=(CtorDtor const &) {
-co_yield 0; // expected-error {{'co_yield' cannot be used in a copy assignment operator}}
+co_yield 0; // OK.
   }
   void operator=(CtorDtor &&) {
-co_await a; // expected-error {{'co_await' cannot be used in a move assignment operator}}
+co_await a; // OK.
   }
   void operator=(CtorDtor const &&) {
-co_await a;

[PATCH] D62960: SVE opaque type for C intrinsics demo

2019-06-19 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm marked an inline comment as done.
rsandifo-arm added inline comments.



Comment at: lib/AST/ItaniumMangle.cpp:2680
+break;
+#include "clang/Basic/AArch64SVEACLETypes.def"
   }

erik.pilkington wrote:
> jfb wrote:
> > @rjmccall you probably should review this part.
> Sorry for the drive by comment, but: All of these mangling should really be 
> using the "vendor extension" production IMO:
> 
> ` ::= u `
> 
> As is, these manglings intrude on the users's namespace, (i.e. if they had a 
> type named `objc_selector` or something), and confuse demanglers which 
> incorrectly assume these are substitutable (vendor extension builtin types 
> are substitutable too though, but that should be handled here).
It isn't obvious from the patch, but the SVE names that we're mangling are 
predefined names like __SVInt8_t. rather than user-facing names like svint8_t  
The predefined names and their mangling are defined by the platform ABI 
(https://developer.arm.com/docs/100986/), so it wouldn't be valid for 
another part of the implementation to use those names for something else.

I realise you were making a general point here though, sorry.



Repository:
  rC Clang

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

https://reviews.llvm.org/D62960



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


r363809 - [OpenMP] Strengthen regression tests for task allocation under nowait depend clauses NFC

2019-06-19 Thread Gheorghe-Teodor Bercea via cfe-commits
Author: gbercea
Date: Wed Jun 19 07:26:43 2019
New Revision: 363809

URL: http://llvm.org/viewvc/llvm-project?rev=363809&view=rev
Log:
[OpenMP] Strengthen regression tests for task allocation under nowait depend 
clauses NFC

Summary:
This patch strengthens the tests introduced in D63009 by:
- adding new test for default device ID.
- modifying existing tests to pass device ID local variable to the task 
allocation function.

Reviewers: ABataev, Hahnfeld, caomhin, jdoerfert

Reviewed By: ABataev

Subscribers: guansong, jdoerfert, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/OpenMP/target_constant_device_codegen.cpp
Modified:
cfe/trunk/test/OpenMP/target_depend_codegen.cpp
cfe/trunk/test/OpenMP/target_enter_data_depend_codegen.cpp
cfe/trunk/test/OpenMP/target_exit_data_depend_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_depend_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_for_depend_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
cfe/trunk/test/OpenMP/target_simd_depend_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_depend_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_depend_codegen.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
cfe/trunk/test/OpenMP/target_update_depend_codegen.cpp

Added: cfe/trunk/test/OpenMP/target_constant_device_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_constant_device_codegen.cpp?rev=363809&view=auto
==
--- cfe/trunk/test/OpenMP/target_constant_device_codegen.cpp (added)
+++ cfe/trunk/test/OpenMP/target_constant_device_codegen.cpp Wed Jun 19 
07:26:43 2019
@@ -0,0 +1,34 @@
+// Test host codegen.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s 
--check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify 
%s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+int global;
+extern int global;
+
+// CHECK: define {{.*}}[[FOO:@.+]](
+int foo(int n) {
+  int a = 0;
+  float b[10];
+  double cn[5][n];
+
+  #pragma omp target nowait depend(in: global) depend(out: a, b, cn[4])
+  {
+  }
+
+  // CHECK: call i8* @__kmpc_omp_target_task_alloc({{.*}}, i64 -1)
+
+  #pragma omp target device(1) nowait depend(in: global) depend(out: a, b, 
cn[4])
+  {
+  }
+
+  // CHECK: call i8* @__kmpc_omp_target_task_alloc({{.*}}, i64 1)
+
+  return a;
+}
+
+#endif

Modified: cfe/trunk/test/OpenMP/target_depend_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_depend_codegen.cpp?rev=363809&r1=363808&r2=363809&view=diff
==
--- cfe/trunk/test/OpenMP/target_depend_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/target_depend_codegen.cpp Wed Jun 19 07:26:43 2019
@@ -132,8 +132,10 @@ int foo(int n) {
   // CHECK:   [[GEP:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* 
%{{.+}}, i32 0, i32 2
   // CHECK:   [[DEV:%.+]] = load i32, i32* [[DEVICE_CAP]],
   // CHECK:   store i32 [[DEV]], i32* [[GEP]],
+  // CHECK:   [[DEV1:%.+]] = load i32, i32* [[DEVICE_CAP]],
+  // CHECK:   [[DEV2:%.+]] = sext i32 [[DEV1]] to i64
 
-  // CHECK:   [[TASK:%.+]] = call i8* 
@__kmpc_omp_target_task_alloc(%struct.ident_t* @0, i32 [[GTID]], i32 1, i[[SZ]] 
{{104|52}}, i[[SZ]] {{16|12}}, i32 (i32, i8*)* bitcast (i32 (i32, %{{.+}}*)* 
[[TASK_ENTRY1_:@.+]] to i32 (i32, i8*)*), i64
+  // CHECK:   [[TASK:%.+]] = call i8* 
@__kmpc_omp_target_task_alloc(%struct.ident_t* @0, i32 [[GTID]], i32 1, i[[SZ]] 
{{104|52}}, i[[SZ]] {{16|12}}, i32 (i32, i8*)* bitcast (i32 (i32, %{{.+}}*)* 
[[TASK_ENTRY1_:@.+]] to i32 (i32, i8*)*), i64 [[DEV2]])
   // CHECK:   [[BC_TASK:%.+]] = bitcast i8* [[TASK]] to [[TASK_TY1_:%.+]]*
   // CHECK:   getelementptr inbounds [3 x %struct.kmp_depend_info], [3 x 
%struct.kmp_depend_info]* %{{.+}}, i[[SZ]] 0, i[[SZ]] 0
   // CHECK:   getelementptr inbounds [3 x %struct.kmp_depend_info], [3 x 
%struct.kmp_depend_info]* %{{.+}}, i[[SZ]] 0, i[[SZ]] 1
@@ -148,8 +150,10 @@ int foo(int n) {
   // CHECK:   [[GEP:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* 
%{{.+}}, i32 0, i32 2
   // CHECK:   [[DEV:%.+]] = load i32, i32* [[DEVICE_CAP]],
   //

[PATCH] D63009: [OpenMP] Add target task alloc function with device ID

2019-06-19 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

Fixed in D63454 


Repository:
  rL LLVM

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

https://reviews.llvm.org/D63009



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


[PATCH] D63454: [OpenMP] Strengthen regression tests for task allocation under nowait depend clauses NFC

2019-06-19 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL363809: [OpenMP] Strengthen regression tests for task 
allocation under nowait depend… (authored by gbercea, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63454

Files:
  cfe/trunk/test/OpenMP/target_constant_device_codegen.cpp
  cfe/trunk/test/OpenMP/target_depend_codegen.cpp
  cfe/trunk/test/OpenMP/target_enter_data_depend_codegen.cpp
  cfe/trunk/test/OpenMP/target_exit_data_depend_codegen.cpp
  cfe/trunk/test/OpenMP/target_parallel_depend_codegen.cpp
  cfe/trunk/test/OpenMP/target_parallel_for_depend_codegen.cpp
  cfe/trunk/test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
  cfe/trunk/test/OpenMP/target_simd_depend_codegen.cpp
  cfe/trunk/test/OpenMP/target_teams_depend_codegen.cpp
  cfe/trunk/test/OpenMP/target_teams_distribute_depend_codegen.cpp
  cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp
  
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
  cfe/trunk/test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
  cfe/trunk/test/OpenMP/target_update_depend_codegen.cpp

Index: cfe/trunk/test/OpenMP/target_update_depend_codegen.cpp
===
--- cfe/trunk/test/OpenMP/target_update_depend_codegen.cpp
+++ cfe/trunk/test/OpenMP/target_update_depend_codegen.cpp
@@ -63,7 +63,9 @@
   // CK1: [[CAP_DEVICE:%.+]] = getelementptr inbounds %struct.anon, %struct.anon* [[CAPTURES:%.+]], i32 0, i32 0
   // CK1: [[DEVICE:%.+]] = load i32, i32* %{{.+}}
   // CK1: store i32 [[DEVICE]], i32* [[CAP_DEVICE]],
-  // CK1: [[RES:%.+]] = call i8* @__kmpc_omp_target_task_alloc(%struct.ident_t* {{.+}}, i32 {{.+}}, i32 1, i[[sz]] [[sz]], i[[sz]] 4, i32 (i32, i8*)* bitcast (i32 (i32, %struct.kmp_task_t_with_privates*)* [[TASK_ENTRY0:@.+]] to i32 (i32, i8*)*), i64
+  // CK1: [[DEV1:%.+]] = load i32, i32* %{{.+}}
+  // CK1: [[DEV2:%.+]] = sext i32 [[DEV1]] to i64
+  // CK1: [[RES:%.+]] = call i8* @__kmpc_omp_target_task_alloc(%struct.ident_t* {{.+}}, i32 {{.+}}, i32 1, i[[sz]] [[sz]], i[[sz]] 4, i32 (i32, i8*)* bitcast (i32 (i32, %struct.kmp_task_t_with_privates*)* [[TASK_ENTRY0:@.+]] to i32 (i32, i8*)*), i64 [[DEV2]])
   // CK1: [[BC:%.+]] = bitcast i8* [[RES]] to %struct.kmp_task_t_with_privates*
   // CK1: [[TASK_T:%.+]] = getelementptr inbounds %struct.kmp_task_t_with_privates, %struct.kmp_task_t_with_privates* [[BC]], i32 0, i32 0
   // CK1: [[SHAREDS:%.+]] = getelementptr inbounds %struct.kmp_task_t, %struct.kmp_task_t* [[TASK_T]], i32 0, i32 0
Index: cfe/trunk/test/OpenMP/target_exit_data_depend_codegen.cpp
===
--- cfe/trunk/test/OpenMP/target_exit_data_depend_codegen.cpp
+++ cfe/trunk/test/OpenMP/target_exit_data_depend_codegen.cpp
@@ -63,7 +63,9 @@
   // CK1: [[CAP_DEVICE:%.+]] = getelementptr inbounds %struct.anon, %struct.anon* [[CAPTURES:%.+]], i32 0, i32 0
   // CK1: [[DEVICE:%.+]] = load i32, i32* %{{.+}}
   // CK1: store i32 [[DEVICE]], i32* [[CAP_DEVICE]],
-  // CK1: [[RES:%.+]] = call i8* @__kmpc_omp_target_task_alloc(%struct.ident_t* {{.+}}, i32 {{.+}}, i32 1, i[[sz]] [[sz]], i[[sz]] 4, i32 (i32, i8*)* bitcast (i32 (i32, %struct.kmp_task_t_with_privates*)* [[TASK_ENTRY0:@.+]] to i32 (i32, i8*)*), i64
+  // CK1: [[DEV1:%.+]] = load i32, i32* %{{.+}}
+  // CK1: [[DEV2:%.+]] = sext i32 [[DEV1]] to i64
+  // CK1: [[RES:%.+]] = call i8* @__kmpc_omp_target_task_alloc(%struct.ident_t* {{.+}}, i32 {{.+}}, i32 1, i[[sz]] [[sz]], i[[sz]] 4, i32 (i32, i8*)* bitcast (i32 (i32, %struct.kmp_task_t_with_privates*)* [[TASK_ENTRY0:@.+]] to i32 (i32, i8*)*), i64 [[DEV2]])
   // CK1: [[BC:%.+]] = bitcast i8* [[RES]] to %struct.kmp_task_t_with_privates*
   // CK1: [[TASK_T:%.+]] = getelementptr inbounds %struct.kmp_task_t_with_privates, %struct.kmp_task_t_with_privates* [[BC]], i32 0, i32 0
   // CK1: [[SHAREDS:%.+]] = getelementptr inbounds %struct.kmp_task_t, %struct.kmp_task_t* [[TASK_T]], i32 0, i32 0
Index: cfe/trunk/test/OpenMP/target_parallel_depend_codegen.cpp
===
--- cfe/trunk/test/OpenMP/target_parallel_depend_codegen.cpp
+++ cfe/trunk/test/OpenMP/target_parallel_depend_codegen.cpp
@@ -132,8 +132,10 @@
   // CHECK:   [[GEP:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* %{{.+}}, i32 0, i32 2
   // CHECK:   [[DEV:%.+]] = load i32, i32* [[DEVICE_CAP]],
   // CHECK:   store i32 [[DEV]], i32* [[GEP]],
+  // CHECK:   [[DEV1:%.+]] = load i32, i32* [[DEVICE_CAP]],
+  // CHECK:   [[DEV2:%.+]] = sext i32 [[DEV1]] to i64
 
-  // CHECK:   [[TASK:%.+]] = call i8* @__kmpc_omp_target_task_alloc(%struct.ident_t* @0, i32 [[GTID]], i32 1, i[[SZ]] {{104|52}}, i[[SZ]] {{16|12}}, i32 (i32, i8*)* bitcast (i32 (i32, %{{.+

[PATCH] D61637: [Syntax] Introduce syntax trees

2019-06-19 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 205589.
ilya-biryukov added a comment.

- Do the renames


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61637

Files:
  clang/include/clang/Tooling/Syntax/BuildTree.h
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/CMakeLists.txt
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/lib/Tooling/Syntax/Tree.cpp
  clang/unittests/Tooling/Syntax/CMakeLists.txt
  clang/unittests/Tooling/Syntax/TreeTest.cpp
  llvm/utils/gn/secondary/clang/lib/Tooling/Syntax/BUILD.gn

Index: llvm/utils/gn/secondary/clang/lib/Tooling/Syntax/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/Tooling/Syntax/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/Tooling/Syntax/BUILD.gn
@@ -8,6 +8,10 @@
 "//llvm/lib/Support",
   ]
   sources = [
+"Arena.cpp",
+"BuildFromAST.cpp",
+"Cascade.cpp",
+"Nodes.cpp",
 "Tokens.cpp",
   ]
 }
Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -0,0 +1,160 @@
+//===- TreeTest.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/Syntax/Tree.h"
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/Decl.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendAction.h"
+#include "clang/Lex/PreprocessorOptions.h"
+#include "clang/Tooling/Syntax/BuildTree.h"
+#include "clang/Tooling/Syntax/Nodes.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace clang;
+
+namespace {
+class SyntaxTreeTest : public ::testing::Test {
+protected:
+  // Build a syntax tree for the code.
+  syntax::TranslationUnitDeclaration *buildTree(llvm::StringRef Code) {
+// FIXME: this code is almost the identical to the one in TokensTest. Share
+//it.
+class BuildSyntaxTree : public ASTConsumer {
+public:
+  BuildSyntaxTree(syntax::TranslationUnitDeclaration *&Root,
+  std::unique_ptr &Arena,
+  std::unique_ptr Tokens)
+  : Root(Root), Arena(Arena), Tokens(std::move(Tokens)) {
+assert(this->Tokens);
+  }
+
+  void HandleTranslationUnit(ASTContext &Ctx) override {
+Arena = llvm::make_unique(Ctx.getSourceManager(),
+ Ctx.getLangOpts(),
+ std::move(*Tokens).consume());
+Tokens = nullptr; // make sure we fail if this gets called twice.
+Root = syntax::buildSyntaxTree(*Arena, *Ctx.getTranslationUnitDecl());
+  }
+
+private:
+  syntax::TranslationUnitDeclaration *&Root;
+  std::unique_ptr &Arena;
+  std::unique_ptr Tokens;
+};
+
+class BuildSyntaxTreeAction : public ASTFrontendAction {
+public:
+  BuildSyntaxTreeAction(syntax::TranslationUnitDeclaration *&Root,
+std::unique_ptr &Arena)
+  : Root(Root), Arena(Arena) {}
+
+  std::unique_ptr
+  CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override {
+// We start recording the tokens, ast consumer will take on the result.
+auto Tokens =
+llvm::make_unique(CI.getPreprocessor());
+return llvm::make_unique(Root, Arena,
+  std::move(Tokens));
+  }
+
+private:
+  syntax::TranslationUnitDeclaration *&Root;
+  std::unique_ptr &Arena;
+};
+
+constexpr const char *FileName = "./input.cpp";
+FS->addFile(FileName, time_t(), llvm::MemoryBuffer::getMemBufferCopy(""));
+// Prepare to run a compiler.
+std::vector Args = {"tok-test", "-std=c++03", "-fsyntax-only",
+  FileName};
+auto CI = createInvocationFromCommandLine(Args, Diags, FS);
+assert(CI);
+CI->getFrontendOpts().DisableFree = false;
+CI->getPreprocessorOpts().addRemappedFile(
+FileName, llvm::MemoryBuffer::getMemBufferCopy(Code).release());
+CompilerInstance Compiler;
+Compiler.setInvocation(std::move(CI));
+if (!Diags->getClient())
+  Diags->setClient(new IgnoringDiagConsumer);
+Compiler.setDiagnostics(Diags.get());
+Compiler.setFileManager(FileMgr.get());
+Compiler.setSourceManager(SourceMgr.get());
+
+syntax::Trans

[PATCH] D62952: [analyzer][tests] Use normalize_sarif in place of diff_sarif

2019-06-19 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast updated this revision to Diff 205590.
hubert.reinterpretcast added a comment.

Update based on review comments from D62949  
as confirmed in D62952 

Normalized versions of the reference expected SARIF output files were
checked in under r363788. The patch has been updated with that revision
as the base. Made the SARIF output generation produce a newline at the
end of the file, and modified the RUN lines in the manner discussed.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62952

Files:
  lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  
test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif
  
test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
  test/Analysis/diagnostics/sarif-diagnostics-taint-test.c
  test/Analysis/diagnostics/sarif-multi-diagnostic-test.c
  test/Analysis/lit.local.cfg


Index: test/Analysis/lit.local.cfg
===
--- test/Analysis/lit.local.cfg
+++ test/Analysis/lit.local.cfg
@@ -17,9 +17,12 @@
  '^[[:space:]]*/.*[[:space:]]*$',
  '^[[:space:]]*.:.*[[:space:]]*$')))
 
-# Diff command for testing SARIF output to reference output.
-config.substitutions.append(('%diff_sarif',
-'''diff -U1 -w -I ".*file:.*%basename_t" -I '"version":' -I 
"2\.0\.0\-csd\.[0-9]*\.beta\."'''))
+# Filtering command for testing SARIF output against reference output.
+config.substitutions.append(('%normalize_sarif',
+"grep -Ev '^[[:space:]]*(%s|%s|%s)[[:space:]]*$'" %
+('"uri": "file:.*%basename_t"',
+ '"version": ".* version .*"',
+ '"version": "2\.0\.0-csd\.[0-9]*\.beta\.[0-9-]{10}"')))
 
 if not config.root.clang_staticanalyzer:
 config.unsupported = True
Index: test/Analysis/diagnostics/sarif-multi-diagnostic-test.c
===
--- test/Analysis/diagnostics/sarif-multi-diagnostic-test.c
+++ test/Analysis/diagnostics/sarif-multi-diagnostic-test.c
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 
-analyzer-checker=core,alpha.security.taint,debug.TaintTest %s -verify 
-analyzer-output=sarif -o - | %diff_sarif 
%S/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif -
+// RUN: %clang_analyze_cc1 
-analyzer-checker=core,alpha.security.taint,debug.TaintTest %s -verify 
-analyzer-output=sarif -o - | %normalize_sarif | diff -U1 -b 
%S/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif -
 #include "../Inputs/system-header-simulator.h"
 
 int atoi(const char *nptr);
Index: test/Analysis/diagnostics/sarif-diagnostics-taint-test.c
===
--- test/Analysis/diagnostics/sarif-diagnostics-taint-test.c
+++ test/Analysis/diagnostics/sarif-diagnostics-taint-test.c
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 
-analyzer-checker=alpha.security.taint,debug.TaintTest %s -verify 
-analyzer-output=sarif -o - | %diff_sarif 
%S/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif -
+// RUN: %clang_analyze_cc1 
-analyzer-checker=alpha.security.taint,debug.TaintTest %s -verify 
-analyzer-output=sarif -o - | %normalize_sarif | diff -U1 -b 
%S/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif -
 #include "../Inputs/system-header-simulator.h"
 
 int atoi(const char *nptr);
Index: 
test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
===
--- 
test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
+++ 
test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
@@ -6,7 +6,7 @@
 {
   "fileLocation": {
   },
-  "length": 667,
+  "length": 686,
   "mimeType": "text/plain",
   "roles": [
 "resultFile"
Index: 
test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif
===
--- 
test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif
+++ 
test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif
@@ -6,7 +6,7 @@
 {
   "fileLocation": {
   },
-  "length": 415,
+  "length": 434,
   "mimeType": "text/plain",
   "roles": [
 "resultFile"
Index: lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
===
--- lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
+++ lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
@@ -345,5 +345,5 @@
"http://json.schemastore.org/sarif-2.0.0-csd.2.beta.2018-11-28"},
   {"version", "2.0.0-csd.2.beta.2018-11-28"},
   {"runs", json::Array{createRun(Diags)}}};
-  OS << llvm::formatv("{0:2}"

[PATCH] D63290: Unify DependencyFileGenerator class and DependencyCollector interface

2019-06-19 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea accepted this revision.
aganea added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D63290



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


[PATCH] D59744: Fix i386 ABI "__m64" type bug

2019-06-19 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

> $ bin/clang -m32 -O0 /tmp/a.c && ./a.out
> -nan
> 
>   Before your change, it prints 3.14.

I looked through the Intel manual to understand what's happening in detail:

When we return from f() with the new ABI, we write to the %mm0 register, and as 
a side effect:

(9.5.1) After each MMX instruction, the entire x87 FPU tag word is set to valid 
(00B).

What does that mean?

(8.1.7) "The x87 FPU uses the tag values to detect stack overflow and underflow 
conditions (see Section 8.5.1.1)"

(8.5.1.1) "Stack overflow — An instruction attempts to load a non-empty x87 FPU 
register from memory. A non-empty
register is defined as a register containing a zero (tag value of 01), a valid 
value (tag value of 00), or a special
value (tag value of 10).

When the x87 FPU detects stack overflow or underflow, it sets the IE flag (bit 
0) and the SF flag (bit 6) in the x87
FPU status word to 1. It then sets condition-code flag C1 (bit 9) in the x87 
FPU status word to 1 if stack overflow
occurred or to 0 if stack underflow occurred.
If the invalid-operation exception is masked, the x87 FPU returns the floating 
point, integer, or packed decimal
integer indefinite value to the destination operand, depending on the 
instruction being executed. This value over-
writes the destination register or memory location specified by the 
instruction."

Okay, so essentially any MMX instruction marks the x87 register stack as full, 
and when we try to store into it in d() with "fldl" we get a stack overflow, 
and because the exception is masked, it stores "the floating point indefinite 
value" into the register, which is what we end up printing.

At least I finally think I understand what's going on :-)


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59744



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


[PATCH] D62952: [analyzer] SARIF: Add EOF newline; replace diff_sarif

2019-06-19 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!


Repository:
  rC Clang

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

https://reviews.llvm.org/D62952



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


[PATCH] D63366: AMDGPU: Add GWS instruction builtins

2019-06-19 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

I'm now getting test suite failures like this:

  
/home/uweigand/llvm/llvm-head/tools/clang/test/CodeGenOpenCL/builtins-amdgcn.cl:554:3:
 error: cannot compile this builtin function yet
__builtin_amdgcn_ds_gws_init(value, id);

Is this supposed to work?  I'm not seeing any LLVM support for this builtin 
anywhere ...


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

https://reviews.llvm.org/D63366



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


r363819 - Change the way we output templates for JSON AST dumping and dump information about template arguments.

2019-06-19 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed Jun 19 08:24:06 2019
New Revision: 363819

URL: http://llvm.org/viewvc/llvm-project?rev=363819&view=rev
Log:
Change the way we output templates for JSON AST dumping and dump information 
about template arguments.

Previously, we attempted to write out template parameters and specializations 
to their own array, but due to the architecture of the ASTNodeTraverser, this 
meant that other nodes were not being written out. This now follows the same 
behavior as the regular AST dumper and puts all the (correct) information into 
the "inner" array. When we correct the AST node traverser itself, we can 
revisit splitting this information into separate arrays again.

Added:
cfe/trunk/test/AST/ast-dump-template-decls-json.cpp
Modified:
cfe/trunk/include/clang/AST/JSONNodeDumper.h
cfe/trunk/lib/AST/JSONNodeDumper.cpp
cfe/trunk/test/AST/ast-dump-expr-json.cpp
cfe/trunk/test/AST/ast-dump-funcs-json.cpp
cfe/trunk/test/AST/ast-dump-stmt-json.cpp

Modified: cfe/trunk/include/clang/AST/JSONNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/JSONNodeDumper.h?rev=363819&r1=363818&r2=363819&view=diff
==
--- cfe/trunk/include/clang/AST/JSONNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/JSONNodeDumper.h Wed Jun 19 08:24:06 2019
@@ -150,6 +150,7 @@ class JSONNodeDumper
   std::string createPointerRepresentation(const void *Ptr);
   llvm::json::Object createQualType(QualType QT, bool Desugar = true);
   llvm::json::Object createBareDeclRef(const Decl *D);
+  void writeBareDeclRef(const Decl *D);
   llvm::json::Object createCXXRecordDefinitionData(const CXXRecordDecl *RD);
   llvm::json::Object createCXXBaseSpecifier(const CXXBaseSpecifier &BS);
   std::string createAccessSpecifier(AccessSpecifier AS);
@@ -265,6 +266,16 @@ public:
   void VisitWhileStmt(const WhileStmt *WS);
   void VisitObjCAtCatchStmt(const ObjCAtCatchStmt *OACS);
 
+  void VisitNullTemplateArgument(const TemplateArgument &TA);
+  void VisitTypeTemplateArgument(const TemplateArgument &TA);
+  void VisitDeclarationTemplateArgument(const TemplateArgument &TA);
+  void VisitNullPtrTemplateArgument(const TemplateArgument &TA);
+  void VisitIntegralTemplateArgument(const TemplateArgument &TA);
+  void VisitTemplateTemplateArgument(const TemplateArgument &TA);
+  void VisitTemplateExpansionTemplateArgument(const TemplateArgument &TA);
+  void VisitExpressionTemplateArgument(const TemplateArgument &TA);
+  void VisitPackTemplateArgument(const TemplateArgument &TA);
+
   void visitTextComment(const comments::TextComment *C,
 const comments::FullComment *);
   void visitInlineCommandComment(const comments::InlineCommandComment *C,
@@ -319,13 +330,9 @@ class JSONDumper : public ASTNodeTravers
   case TSK_Undeclared:
   case TSK_ImplicitInstantiation:
 if (DumpRefOnly)
-  NodeDumper.JOS.value(NodeDumper.createBareDeclRef(Redecl));
+  NodeDumper.AddChild([=] { NodeDumper.writeBareDeclRef(Redecl); });
 else
-  // FIXME: this isn't quite right -- we want to call Visit() rather
-  // than NodeDumper.Visit() but that causes issues because it attempts
-  // to create a new array of child objects due to calling AddChild(),
-  // which messes up the JSON creation.
-  NodeDumper.JOS.object([this, Redecl] { NodeDumper.Visit(Redecl); });
+  Visit(Redecl);
 DumpedAny = true;
 break;
   case TSK_ExplicitSpecialization:
@@ -335,30 +342,24 @@ class JSONDumper : public ASTNodeTravers
 
 // Ensure we dump at least one decl for each specialization.
 if (!DumpedAny)
-  NodeDumper.JOS.value(NodeDumper.createBareDeclRef(SD));
+  NodeDumper.AddChild([=] { NodeDumper.writeBareDeclRef(SD); });
   }
 
   template 
   void writeTemplateDecl(const TemplateDecl *TD, bool DumpExplicitInst) {
-if (const TemplateParameterList *TPL = TD->getTemplateParameters()) {
-  NodeDumper.JOS.attributeArray("templateParams", [this, TPL] {
-for (const auto &TP : *TPL) {
-  NodeDumper.JOS.object([this, TP] { NodeDumper.Visit(TP); });
-}
-  });
-}
+// FIXME: it would be nice to dump template parameters and specializations
+// to their own named arrays rather than shoving them into the "inner"
+// array. However, template declarations are currently being handled at the
+// wrong "level" of the traversal hierarchy and so it is difficult to
+// achieve without losing information elsewhere.
+
+dumpTemplateParameters(TD->getTemplateParameters());
 
 Visit(TD->getTemplatedDecl());
 
-auto spec_range = TD->specializations();
-if (!llvm::empty(spec_range)) {
-  NodeDumper.JOS.attributeArray(
-  "specializations", [this, spec_range, TD, DumpExplicitInst] {
-for (const auto *Child : spec_range)
-  writeT

r363820 - Add a script to help generate expected test output for dumping the AST to JSON.

2019-06-19 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed Jun 19 08:25:24 2019
New Revision: 363820

URL: http://llvm.org/viewvc/llvm-project?rev=363820&view=rev
Log:
Add a script to help generate expected test output for dumping the AST to JSON.

Patch by Abhishek Bhaskar.

Added:
cfe/trunk/test/AST/gen_ast_dump_json_test.py

Added: cfe/trunk/test/AST/gen_ast_dump_json_test.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/gen_ast_dump_json_test.py?rev=363820&view=auto
==
--- cfe/trunk/test/AST/gen_ast_dump_json_test.py (added)
+++ cfe/trunk/test/AST/gen_ast_dump_json_test.py Wed Jun 19 08:25:24 2019
@@ -0,0 +1,137 @@
+#!/usr/bin/env python
+
+from collections import OrderedDict
+from sets import Set
+from shutil import copyfile
+import argparse
+import json
+import os
+import pprint
+import re
+import subprocess
+
+def normalize(dict_var):
+for k, v in dict_var.items():
+if isinstance(v, OrderedDict):
+normalize(v)
+elif isinstance(v, list):
+for e in v:
+if isinstance(e, OrderedDict):
+normalize(e)
+elif type(v) is unicode:
+st = v.encode('utf-8')
+if re.match(r"0x[0-9A-Fa-f]+", v):
+dict_var[k] = u'0x{{.*}}'
+elif os.path.isfile(v):
+dict_var[k] = u'{{.*}}'
+else:
+splits = (v.split(u' '))
+out_splits = []
+for split in splits:
+inner_splits = split.rsplit(u':',2)
+if os.path.isfile(inner_splits[0]):
+out_splits.append(
+u'{{.*}}:%s:%s'
+%(inner_splits[1],
+  inner_splits[2]))
+continue
+out_splits.append(split)
+
+dict_var[k] = ' '.join(out_splits)
+
+def filter_json(dict_var, filters, out):
+for k, v in dict_var.items():
+if type(v) is unicode:
+st = v.encode('utf-8')
+if st in filters:
+out.append(dict_var)
+break
+elif isinstance(v, OrderedDict):
+filter_json(v, filters, out)
+elif isinstance(v, list):
+for e in v:
+if isinstance(e, OrderedDict):
+filter_json(e, filters, out)
+
+def main():
+parser = argparse.ArgumentParser()
+parser.add_argument("--clang", help="The clang binary (could be a relative 
or absolute path)",
+action="store", required=True)
+parser.add_argument("--opts", help="other options",
+action="store", default='', type=str)
+parser.add_argument("--source", help="the source file. Command used to 
generate the json will be of the format  -cc1 -ast-dump=json  
",
+action="store", required=True)
+parser.add_argument("--filters", help="comma separated list of AST 
filters. Ex: --filters=TypedefDecl,BuiltinType",
+action="store", default='')
+
+args = parser.parse_args()
+
+if not args.source:
+print("Specify the source file to give to clang.")
+return -1
+
+clang_binary = os.path.abspath(args.clang)
+if not os.path.isfile(clang_binary):
+print("clang binary specified not present.")
+return -1
+
+options = args.opts.split(' ')
+filters = Set(args.filters.split(',')) if args.filters else Set([])
+
+cmd = [clang_binary, "-cc1"]
+cmd.extend(options)
+
+using_ast_dump_filter = 'ast-dump-filter' in args.opts
+
+cmd.extend(["-ast-dump=json", args.source])
+
+try:
+json_str = subprocess.check_output(cmd)
+except Exception as ex:
+print("The clang command failed with %s" % ex)
+return -1
+
+out_asts = []
+if using_ast_dump_filter:
+splits = re.split('Dumping .*:\n', json_str)
+if len(splits) > 1:
+for split in splits[1:]:
+j = json.loads(split.decode('utf-8'), 
object_pairs_hook=OrderedDict)
+normalize(j)
+out_asts.append(j)
+else:
+j = json.loads(json_str.decode('utf-8'), object_pairs_hook=OrderedDict)
+normalize(j)
+
+if len(filters) == 0:
+out_asts.append(j)
+else:
+#assert using_ast_dump_filter is False,\
+#"Does not support using compiler's ast-dump-filter "\
+#"and the tool's filter option at the same time yet."
+
+filter_json(j, filters, out_asts)
+
+partition = args.source.rpartition('.')
+dest_path = '%s-json%s%s' % (partition[0], partition[1], partition[2])
+
+print("Writing json appended source file to %s." %(dest_path))
+copyfile(args.source, dest_path)
+with open(dest_path, "a") as f

[PATCH] D61552: [clang] Adapt ASTMatcher to explicit(bool) specifier

2019-06-19 Thread Tyker via Phabricator via cfe-commits
Tyker updated this revision to Diff 205602.
Tyker added a comment.

i was confuse because the log seemed like an error and it was happening in 
python2.7 and python3.7
but the actual error that was preventing generating the documentation only 
occurs in 3.7.

it works in python2.7.


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

https://reviews.llvm.org/D61552

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1735,6 +1735,56 @@
 llvm::make_unique>("x", 3)));
 }
 
+TEST(Declaration, HasExplicitSpecifier) {
+  EXPECT_TRUE(matchesConditionally(
+  "void f();", functionDecl(hasExplicitSpecifier(constantExpr())), false,
+  "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "template struct S { explicit operator int(); };",
+  cxxConversionDecl(hasExplicitSpecifier(constantExpr(has(cxxBoolLiteral(),
+  false, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "template struct S { explicit(b) operator int(); };",
+  cxxConversionDecl(hasExplicitSpecifier(constantExpr(has(cxxBoolLiteral(),
+  false, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "struct S { explicit(true) operator int(); };",
+  cxxConversionDecl(hasExplicitSpecifier(constantExpr(has(cxxBoolLiteral(),
+  true, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "struct S { explicit(false) operator int(); };",
+  cxxConversionDecl(hasExplicitSpecifier(constantExpr(has(cxxBoolLiteral(),
+  true, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "template struct S { explicit(b) S(int); };",
+  cxxConstructorDecl(hasExplicitSpecifier(constantExpr(has(cxxBoolLiteral(),
+  false, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "struct S { explicit(true) S(int); };",
+  cxxConstructorDecl(hasExplicitSpecifier(constantExpr(has(cxxBoolLiteral(),
+  true, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "struct S { explicit(false) S(int); };",
+  cxxConstructorDecl(hasExplicitSpecifier(constantExpr(has(cxxBoolLiteral(),
+  true, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "template struct S { S(int); };"
+  "template explicit(b) S(int) -> S;",
+  cxxDeductionGuideDecl(
+  hasExplicitSpecifier(constantExpr(has(cxxBoolLiteral(),
+  false, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally("template struct S { S(int); };"
+   "explicit(true) S(int) -> S;",
+   cxxDeductionGuideDecl(hasExplicitSpecifier(
+   constantExpr(has(cxxBoolLiteral(),
+   true, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally("template struct S { S(int); };"
+   "explicit(false) S(int) -> S;",
+   cxxDeductionGuideDecl(hasExplicitSpecifier(
+   constantExpr(has(cxxBoolLiteral(),
+   true, "-std=c++2a"));
+}
+
 TEST(ForEachConstructorInitializer, MatchesInitializers) {
   EXPECT_TRUE(matches(
 "struct X { X() : i(42), j(42) {} int i, j; };",
Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -878,6 +878,15 @@
   cxxConversionDecl(isExplicit(;
   EXPECT_TRUE(notMatches("struct S { operator int(); };",
  cxxConversionDecl(isExplicit(;
+  EXPECT_TRUE(matchesConditionally(
+  "template struct S { explicit(b) operator int(); };",
+  cxxConversionDecl(isExplicit()), false, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "struct S { explicit(true) operator int(); };",
+  cxxConversionDecl(isExplicit()), true, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "struct S { explicit(false) operator int(); };",
+  cxxConversionDecl(isExplicit()), false, "-std=c++2a"));
 }
 
 TEST(Matcher, ArgumentCount) {
@@ -1197,6 +1206,38 @@
   cxxConstructorDecl(isExplicit(;
   EXPECT_TRUE(notMatches("struct S { S(int); };",
  cxxConstructorDecl(isExplicit(;
+  EXPECT_TRUE(matchesConditionally(
+  "template struct S { explicit(b) S(int);};",
+  cxxConstructorDecl(isExp

[PATCH] D63490: Script for generating AST JSON dump test cases

2019-06-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Committed in r363820; we'll look into integrating the script into lit as you 
suggested for a possible follow-up.


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

https://reviews.llvm.org/D63490



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


r363822 - [analyzer] SARIF: Add EOF newline; replace diff_sarif

2019-06-19 Thread Hubert Tong via cfe-commits
Author: hubert.reinterpretcast
Date: Wed Jun 19 08:27:35 2019
New Revision: 363822

URL: http://llvm.org/viewvc/llvm-project?rev=363822&view=rev
Log:
[analyzer] SARIF: Add EOF newline; replace diff_sarif

Summary:
This patch applies a change similar to rC363069, but for SARIF files.

The `%diff_sarif` lit substitution invokes `diff` with a non-portable
`-I` option. The intended effect can be achieved by normalizing the
inputs to `diff` beforehand. Such normalization can be done with
`grep -Ev`, which is also used by other tests.

Additionally, this patch updates the SARIF output to have a newline at
the end of the file. This makes it so that the SARIF file qualifies as a
POSIX text file, which increases the consumability of the generated file
in relation to various tools.

Reviewers: NoQ, sfertile, xingxue, jasonliu, daltenty, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, 
Szelethus, donat.nagy, dkrupp, Charusso, jsji, cfe-commits

Tags: #clang

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

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

cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif

cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
cfe/trunk/test/Analysis/diagnostics/sarif-diagnostics-taint-test.c
cfe/trunk/test/Analysis/diagnostics/sarif-multi-diagnostic-test.c
cfe/trunk/test/Analysis/lit.local.cfg

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp?rev=363822&r1=363821&r2=363822&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp Wed Jun 19 08:27:35 
2019
@@ -345,5 +345,5 @@ void SarifDiagnostics::FlushDiagnosticsI
"http://json.schemastore.org/sarif-2.0.0-csd.2.beta.2018-11-28"},
   {"version", "2.0.0-csd.2.beta.2018-11-28"},
   {"runs", json::Array{createRun(Diags)}}};
-  OS << llvm::formatv("{0:2}", json::Value(std::move(Sarif)));
+  OS << llvm::formatv("{0:2}\n", json::Value(std::move(Sarif)));
 }

Modified: 
cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif?rev=363822&r1=363821&r2=363822&view=diff
==
--- 
cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif
 (original)
+++ 
cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif
 Wed Jun 19 08:27:35 2019
@@ -6,7 +6,7 @@
 {
   "fileLocation": {
   },
-  "length": 415,
+  "length": 434,
   "mimeType": "text/plain",
   "roles": [
 "resultFile"

Modified: 
cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif?rev=363822&r1=363821&r2=363822&view=diff
==
--- 
cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
 (original)
+++ 
cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
 Wed Jun 19 08:27:35 2019
@@ -6,7 +6,7 @@
 {
   "fileLocation": {
   },
-  "length": 667,
+  "length": 686,
   "mimeType": "text/plain",
   "roles": [
 "resultFile"

Modified: cfe/trunk/test/Analysis/diagnostics/sarif-diagnostics-taint-test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/diagnostics/sarif-diagnostics-taint-test.c?rev=363822&r1=363821&r2=363822&view=diff
==
--- cfe/trunk/test/Analysis/diagnostics/sarif-diagnostics-taint-test.c 
(original)
+++ cfe/trunk/test/Analysis/diagnostics/sarif-diagnostics-taint-test.c Wed Jun 
19 08:27:35 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 
-analyzer-checker=alpha.security.taint,debug.TaintTest %s -verify 
-analyzer-output=sarif -o - | %diff_sarif 
%S/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif -
+// RUN: %clang_analyze_cc1 
-analyzer-checker=alpha.security.taint,debug.TaintTest %s -verify 
-analyzer-output=sarif -o - | %normalize_sarif | diff -U1 -b 
%S/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif -
 #include "../Inputs/system-header-simulator.h"
 
 int atoi(const char *nptr);

Modified: cfe/trunk/test/An

[PATCH] D62952: [analyzer] SARIF: Add EOF newline; replace diff_sarif

2019-06-19 Thread Hubert Tong via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL363822: [analyzer] SARIF: Add EOF newline; replace 
diff_sarif (authored by hubert.reinterpretcast, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62952

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  
cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif
  
cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
  cfe/trunk/test/Analysis/diagnostics/sarif-diagnostics-taint-test.c
  cfe/trunk/test/Analysis/diagnostics/sarif-multi-diagnostic-test.c
  cfe/trunk/test/Analysis/lit.local.cfg


Index: cfe/trunk/test/Analysis/diagnostics/sarif-diagnostics-taint-test.c
===
--- cfe/trunk/test/Analysis/diagnostics/sarif-diagnostics-taint-test.c
+++ cfe/trunk/test/Analysis/diagnostics/sarif-diagnostics-taint-test.c
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 
-analyzer-checker=alpha.security.taint,debug.TaintTest %s -verify 
-analyzer-output=sarif -o - | %diff_sarif 
%S/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif -
+// RUN: %clang_analyze_cc1 
-analyzer-checker=alpha.security.taint,debug.TaintTest %s -verify 
-analyzer-output=sarif -o - | %normalize_sarif | diff -U1 -b 
%S/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif -
 #include "../Inputs/system-header-simulator.h"
 
 int atoi(const char *nptr);
Index: 
cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
===
--- 
cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
+++ 
cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
@@ -6,7 +6,7 @@
 {
   "fileLocation": {
   },
-  "length": 667,
+  "length": 686,
   "mimeType": "text/plain",
   "roles": [
 "resultFile"
Index: 
cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif
===
--- 
cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif
+++ 
cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif
@@ -6,7 +6,7 @@
 {
   "fileLocation": {
   },
-  "length": 415,
+  "length": 434,
   "mimeType": "text/plain",
   "roles": [
 "resultFile"
Index: cfe/trunk/test/Analysis/diagnostics/sarif-multi-diagnostic-test.c
===
--- cfe/trunk/test/Analysis/diagnostics/sarif-multi-diagnostic-test.c
+++ cfe/trunk/test/Analysis/diagnostics/sarif-multi-diagnostic-test.c
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 
-analyzer-checker=core,alpha.security.taint,debug.TaintTest %s -verify 
-analyzer-output=sarif -o - | %diff_sarif 
%S/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif -
+// RUN: %clang_analyze_cc1 
-analyzer-checker=core,alpha.security.taint,debug.TaintTest %s -verify 
-analyzer-output=sarif -o - | %normalize_sarif | diff -U1 -b 
%S/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif -
 #include "../Inputs/system-header-simulator.h"
 
 int atoi(const char *nptr);
Index: cfe/trunk/test/Analysis/lit.local.cfg
===
--- cfe/trunk/test/Analysis/lit.local.cfg
+++ cfe/trunk/test/Analysis/lit.local.cfg
@@ -17,9 +17,12 @@
  '^[[:space:]]*/.*[[:space:]]*$',
  '^[[:space:]]*.:.*[[:space:]]*$')))
 
-# Diff command for testing SARIF output to reference output.
-config.substitutions.append(('%diff_sarif',
-'''diff -U1 -w -I ".*file:.*%basename_t" -I '"version":' -I 
"2\.0\.0\-csd\.[0-9]*\.beta\."'''))
+# Filtering command for testing SARIF output against reference output.
+config.substitutions.append(('%normalize_sarif',
+"grep -Ev '^[[:space:]]*(%s|%s|%s)[[:space:]]*$'" %
+('"uri": "file:.*%basename_t"',
+ '"version": ".* version .*"',
+ '"version": "2\.0\.0-csd\.[0-9]*\.beta\.[0-9-]{10}"')))
 
 if not config.root.clang_staticanalyzer:
 config.unsupported = True
Index: cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
@@ -345,5 +345,5 @@
"http://json.schemastore.org/sarif-2.0.0-csd.2.beta.2018-11-28"},
   {"version", "2.0.0-csd.2.beta.2018-11-28"},
   {"runs", json::Array{createRun(Diags)}}};
-  OS << llvm::formatv("{0:2}", j

[PATCH] D61552: [clang] Adapt ASTMatcher to explicit(bool) specifier

2019-06-19 Thread Tyker via Phabricator via cfe-commits
Tyker added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:6190
+/// cxxDeductionGuideDecl(isExplicit()) will match #6, but not #5.
+/// cxxConstructorDecl(isExplicit()) will match #8, but not #7 or #9.
+AST_POLYMORPHIC_MATCHER(isExplicit, AST_POLYMORPHIC_SUPPORTED_TYPES(

aaron.ballman wrote:
> Why won't it match #2?
#2 matches.


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

https://reviews.llvm.org/D61552



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


[PATCH] D63559: [clang-tidy] Added functionality for getting semantic highlights for variable and function declarations

2019-06-19 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom created this revision.
jvikstrom added reviewers: hokein, ilya-biryukov.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, xazax.hun.
Herald added a project: clang.

Adds functionality for getting semantic highlights


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63559

Files:
  clang-tools-extra/clangd/SemanticHighlight.cpp
  clang-tools-extra/clangd/SemanticHighlight.h
  clang-tools-extra/clangd/unittests/SemanticHighlightTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/SemanticHighlightTests.cpp
@@ -0,0 +1,76 @@
+//===-- SemanticSymbolASTCollectorTests.cpp - SemanticSymbolASTCollector tests
+//--*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Annotations.h"
+#include "ClangdUnit.h"
+#include "Protocol.h"
+#include "SemanticHighlight.h"
+#include "SourceCode.h"
+#include "TestTU.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+using ::testing::ElementsAreArray;
+
+Position createPosition(int Line, int Character) {
+  Position Pos;
+  Pos.character = Character;
+  Pos.line = Line;
+  return Pos;
+}
+
+TEST(SemanticSymbolASTCollector, GetBeginningOfIdentifier) {
+  std::string Preamble = R"cpp(
+struct A {
+  double SomeMember;
+};
+void $foo[[foo]](int $a[[a]]) {
+  auto $vlvn[[VeryLongVariableName]] = 12312;
+  A $aa[[aa]];
+}
+  )cpp";
+
+  Annotations Test(Preamble);
+  auto Foo = Test.range("foo");
+  auto A = Test.range("a");
+  auto VeryLong = Test.range("vlvn");
+  auto AA = Test.range("aa");
+  std::vector CorrectLines = std::vector{
+  LineHighlight(
+  Foo.start.line,
+  {SemanticSymbol(SemanticScope::FunctionDeclaration,
+  createPosition(Foo.start.line, Foo.start.character),
+  3),
+   SemanticSymbol(SemanticScope::VariableDeclaration,
+  createPosition(A.start.line, A.start.character), 1)}),
+  LineHighlight(
+  VeryLong.start.line,
+  {SemanticSymbol(
+  SemanticScope::VariableDeclaration,
+  createPosition(VeryLong.start.line, VeryLong.start.character),
+  VeryLong.end.character - VeryLong.start.character)}),
+  LineHighlight(
+  AA.start.line,
+  {SemanticSymbol(SemanticScope::VariableDeclaration,
+  createPosition(AA.start.line, AA.start.character),
+  2)})};
+
+  auto AST = TestTU::withCode(Test.code()).build();
+  auto Lines = getASTHighlights(AST.getASTContext());
+  EXPECT_THAT(Lines, ElementsAreArray(CorrectLines));
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/SemanticHighlight.h
===
--- /dev/null
+++ clang-tools-extra/clangd/SemanticHighlight.h
@@ -0,0 +1,67 @@
+//===--- SemanticHighlight.h - Generating highlights from the AST
+//-*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Code for collecting semantic symbols from the C++ AST using the
+// RecursiveASTVisitor
+//
+//===--===//
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_SEMANTICSYMBOLASTCOLLECTOR_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SEMANTICSYMBOLASTCOLLECTOR_H
+
+#include "AST.h"
+#include "Headers.h"
+#include "Protocol.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Lex/Lexer.h"
+
+namespace clang {
+namespace clangd {
+
+// ScopeIndex represents the mapping from the scopes list to a type of
+// expression.
+enum class SemanticScope : int {
+  VariableDeclaration = 0,
+  FunctionDeclaration = 1,
+};
+
+// Contains all information needed for the highlighting a symbol.
+struct SemanticSymbol {
+  SemanticSymbol() {}
+  SemanticSymbol(SemanticScope Scope, Position StartPosition, unsigned int Len)
+  : Scope(Scope), StartPosition(StartPosition), Len(Len) {}
+  SemanticScope Scope;
+  Position StartPosition;
+  unsigned int Len;
+};
+
+bool operator==(const SemanticSymbol &Lhs, const SemanticSymbol &Rhs);
+bool operator!=(const SemanticSymbol &Lhs, const SemanticSymbol &Rhs);
+
+// Contains all highlights in a single line.
+st

[PATCH] D63559: [clang-tidy] Added functionality for getting semantic highlights for variable and function declarations

2019-06-19 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom updated this revision to Diff 205608.
jvikstrom added a comment.
Herald added a subscriber: mgorny.

Adds CMakeLists changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63559

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/SemanticHighlight.cpp
  clang-tools-extra/clangd/SemanticHighlight.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/SemanticHighlightTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/SemanticHighlightTests.cpp
@@ -0,0 +1,76 @@
+//===-- SemanticSymbolASTCollectorTests.cpp - SemanticSymbolASTCollector tests
+//--*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Annotations.h"
+#include "ClangdUnit.h"
+#include "Protocol.h"
+#include "SemanticHighlight.h"
+#include "SourceCode.h"
+#include "TestTU.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+using ::testing::ElementsAreArray;
+
+Position createPosition(int Line, int Character) {
+  Position Pos;
+  Pos.character = Character;
+  Pos.line = Line;
+  return Pos;
+}
+
+TEST(SemanticSymbolASTCollector, GetBeginningOfIdentifier) {
+  std::string Preamble = R"cpp(
+struct A {
+  double SomeMember;
+};
+void $foo[[foo]](int $a[[a]]) {
+  auto $vlvn[[VeryLongVariableName]] = 12312;
+  A $aa[[aa]];
+}
+  )cpp";
+
+  Annotations Test(Preamble);
+  auto Foo = Test.range("foo");
+  auto A = Test.range("a");
+  auto VeryLong = Test.range("vlvn");
+  auto AA = Test.range("aa");
+  std::vector CorrectLines = std::vector{
+  LineHighlight(
+  Foo.start.line,
+  {SemanticSymbol(SemanticScope::FunctionDeclaration,
+  createPosition(Foo.start.line, Foo.start.character),
+  3),
+   SemanticSymbol(SemanticScope::VariableDeclaration,
+  createPosition(A.start.line, A.start.character), 1)}),
+  LineHighlight(
+  VeryLong.start.line,
+  {SemanticSymbol(
+  SemanticScope::VariableDeclaration,
+  createPosition(VeryLong.start.line, VeryLong.start.character),
+  VeryLong.end.character - VeryLong.start.character)}),
+  LineHighlight(
+  AA.start.line,
+  {SemanticSymbol(SemanticScope::VariableDeclaration,
+  createPosition(AA.start.line, AA.start.character),
+  2)})};
+
+  auto AST = TestTU::withCode(Test.code()).build();
+  auto Lines = getASTHighlights(AST.getASTContext());
+  EXPECT_THAT(Lines, ElementsAreArray(CorrectLines));
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -53,6 +53,7 @@
   RenameTests.cpp
   RIFFTests.cpp
   SelectionTests.cpp
+  SemanticHighlightTests.cpp
   SerializationTests.cpp
   SourceCodeTests.cpp
   SymbolCollectorTests.cpp
Index: clang-tools-extra/clangd/SemanticHighlight.h
===
--- /dev/null
+++ clang-tools-extra/clangd/SemanticHighlight.h
@@ -0,0 +1,67 @@
+//===--- SemanticHighlight.h - Generating highlights from the AST
+//-*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Code for collecting semantic symbols from the C++ AST using the
+// RecursiveASTVisitor
+//
+//===--===//
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_SEMANTICSYMBOLASTCOLLECTOR_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SEMANTICSYMBOLASTCOLLECTOR_H
+
+#include "AST.h"
+#include "Headers.h"
+#include "Protocol.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Lex/Lexer.h"
+
+namespace clang {
+namespace clangd {
+
+// ScopeIndex represents the mapping from the scopes list to a type of
+// expression.
+enum class SemanticScope : int {
+  VariableDeclaration = 0,
+  FunctionDeclaration = 1,
+};
+
+// Contains all information needed for the highlighting a symbol.
+

r363824 - Revert rL363684 : AMDGPU: Add GWS instruction builtins

2019-06-19 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Wed Jun 19 08:35:45 2019
New Revision: 363824

URL: http://llvm.org/viewvc/llvm-project?rev=363824&view=rev
Log:
Revert rL363684 : AMDGPU: Add GWS instruction builtins

Depends on rL363678 which was reverted at rL363797

Modified:
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=363824&r1=363823&r2=363824&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Wed Jun 19 08:35:45 2019
@@ -45,8 +45,6 @@ BUILTIN(__builtin_amdgcn_s_barrier, "v",
 BUILTIN(__builtin_amdgcn_wave_barrier, "v", "n")
 BUILTIN(__builtin_amdgcn_s_dcache_inv, "v", "n")
 BUILTIN(__builtin_amdgcn_buffer_wbinvl1, "v", "n")
-BUILTIN(__builtin_amdgcn_ds_gws_init, "vUiUi", "n")
-BUILTIN(__builtin_amdgcn_ds_gws_barrier, "vUiUi", "n")
 
 // FIXME: Need to disallow constant address space.
 BUILTIN(__builtin_amdgcn_div_scale, "dddbb*", "n")

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl?rev=363824&r1=363823&r2=363824&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl Wed Jun 19 08:35:45 2019
@@ -548,18 +548,6 @@ kernel void test_ds_consume_lds(global i
   *out = __builtin_amdgcn_ds_consume(ptr);
 }
 
-// CHECK-LABEL: @test_gws_init(
-// CHECK: call void @llvm.amdgcn.ds.gws.init(i32 %value, i32 %id)
-kernel void test_gws_init(uint value, uint id) {
-  __builtin_amdgcn_ds_gws_init(value, id);
-}
-
-// CHECK-LABEL: @test_gws_barrier(
-// CHECK: call void @llvm.amdgcn.ds.gws.barrier(i32 %value, i32 %id)
-kernel void test_gws_barrier(uint value, uint id) {
-  __builtin_amdgcn_ds_gws_barrier(value, id);
-}
-
 // CHECK-DAG: [[$WI_RANGE]] = !{i32 0, i32 1024}
 // CHECK-DAG: attributes #[[$NOUNWIND_READONLY:[0-9]+]] = { nounwind readonly }
 // CHECK-DAG: attributes #[[$READ_EXEC_ATTRS]] = { convergent }


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


[PATCH] D63451: P0840R2: support for [[no_unique_address]] attribute

2019-06-19 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.

The attribute parts LGTM! You can change the `TargetItaniumCXXABI` part in a 
follow-up commit if you'd prefer.




Comment at: lib/AST/Decl.cpp:3945
+return false;
+  }
+

rjmccall wrote:
> rsmith wrote:
> > rjmccall wrote:
> > > Is this a C/C++ modules interaction?
> > We don't allow C modules to be imported into C++ compilations or vice 
> > versa, so this should be unreachable unless we start allowing the attribute 
> > in C. Nice catch.
> > 
> > I guess the question is, then: should we allow this attribute in C (either 
> > with a GNU `__attribute__` spelling or as a C20 `[[clang::attribute]]`)? I 
> > don't think it's really useful in C (empty structs are ill-formed, and you 
> > can't reuse tail padding because structs are always trivial, at least in 
> > standard C), so I'm inclined to say no.
> I agree that it seems relatively useless in C, and there's no reason to think 
> they'd use this language design if they decided they did want it.
Agreed that this makes no sense in C. I was not planning on proposing this to 
WG14 because I couldn't think of a use case for it.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63451



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


r363826 - [NFC][codeview] Avoid undefined grep in debug-info-codeview-display-name.cpp

2019-06-19 Thread Hubert Tong via cfe-commits
Author: hubert.reinterpretcast
Date: Wed Jun 19 08:48:12 2019
New Revision: 363826

URL: http://llvm.org/viewvc/llvm-project?rev=363826&view=rev
Log:
[NFC][codeview] Avoid undefined grep in debug-info-codeview-display-name.cpp

vertical-line is not a BRE special character.

POSIX.1-2017 XBD Section 9.3.2 indicates that the interpretation of `\|`
is undefined. This patch uses an ERE instead.

Modified:
cfe/trunk/test/CodeGenCXX/debug-info-codeview-display-name.cpp

Modified: cfe/trunk/test/CodeGenCXX/debug-info-codeview-display-name.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-codeview-display-name.cpp?rev=363826&r1=363825&r2=363826&view=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-codeview-display-name.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-codeview-display-name.cpp Wed Jun 19 
08:48:12 2019
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
 // RUN:   -o - -triple=x86_64-pc-win32 -std=c++98 | \
-// RUN:grep 'DISubprogram\|DICompositeType' | sed -e 's/.*name: 
"\([^"]*\)".*/"\1"/' | \
+// RUN:grep -E 'DISubprogram|DICompositeType' | sed -e 's/.*name: 
"\([^"]*\)".*/"\1"/' | \
 // RUN:FileCheck %s --check-prefix=CHECK --check-prefix=UNQUAL
 // RUN: %clang_cc1 -fblocks -debug-info-kind=line-tables-only -gcodeview 
-emit-llvm %s \
 // RUN:   -o - -triple=x86_64-pc-win32 -std=c++98 | \


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


[PATCH] D63561: [OpenCL] Improve diagnostic for placement new

2019-06-19 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added a reviewer: Anastasia.
Herald added subscribers: cfe-commits, yaxunl.
Herald added a project: clang.

Without an explicit declaration for placement new, clang would reject
uses of placement new with "default new' is not supported in OpenCL
C++", suggesting that placement new is not supported, see e.g.
PR42060.


Repository:
  rC Clang

https://reviews.llvm.org/D63561

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExprCXX.cpp
  test/SemaOpenCLCXX/newdelete.cl


Index: test/SemaOpenCLCXX/newdelete.cl
===
--- test/SemaOpenCLCXX/newdelete.cl
+++ test/SemaOpenCLCXX/newdelete.cl
@@ -21,7 +21,7 @@
 void test_default_new_delete(void *buffer, A **pa) {
   A *a = new A; // expected-error {{'default new' is not supported in 
OpenCL C++}}
   delete a; // expected-error {{'default delete' is not supported 
in OpenCL C++}}
-  *pa = new (buffer) A; // expected-error {{'default new' is not supported in 
OpenCL C++}}
+  *pa = new (buffer) A; // expected-error {{use of placement new requires 
explicit declaration}}
 }
 
 // expected-note@+1 {{candidate function not viable: requires 2 arguments, but 
1 was provided}}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -2413,7 +2413,11 @@
 }
 
 if (getLangOpts().OpenCLCPlusPlus && R.empty()) {
-  Diag(StartLoc, diag::err_openclcxx_not_supported) << "default new";
+  if (PlaceArgs.empty()) {
+Diag(StartLoc, diag::err_openclcxx_not_supported) << "default new";
+  } else {
+Diag(StartLoc, diag::err_openclcxx_placement_new);
+  }
   return true;
 }
 
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -8808,6 +8808,9 @@
   "vector component name '%0' is an OpenCL version 2.2 feature">,
   InGroup;
 
+def err_openclcxx_placement_new : Error<
+  "use of placement new requires explicit declaration">;
+
 // MIG routine annotations.
 def warn_mig_server_routine_does_not_return_kern_return_t : Warning<
   "'mig_server_routine' attribute only applies to routines that return a 
kern_return_t">,


Index: test/SemaOpenCLCXX/newdelete.cl
===
--- test/SemaOpenCLCXX/newdelete.cl
+++ test/SemaOpenCLCXX/newdelete.cl
@@ -21,7 +21,7 @@
 void test_default_new_delete(void *buffer, A **pa) {
   A *a = new A; // expected-error {{'default new' is not supported in OpenCL C++}}
   delete a; // expected-error {{'default delete' is not supported in OpenCL C++}}
-  *pa = new (buffer) A; // expected-error {{'default new' is not supported in OpenCL C++}}
+  *pa = new (buffer) A; // expected-error {{use of placement new requires explicit declaration}}
 }
 
 // expected-note@+1 {{candidate function not viable: requires 2 arguments, but 1 was provided}}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -2413,7 +2413,11 @@
 }
 
 if (getLangOpts().OpenCLCPlusPlus && R.empty()) {
-  Diag(StartLoc, diag::err_openclcxx_not_supported) << "default new";
+  if (PlaceArgs.empty()) {
+Diag(StartLoc, diag::err_openclcxx_not_supported) << "default new";
+  } else {
+Diag(StartLoc, diag::err_openclcxx_placement_new);
+  }
   return true;
 }
 
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -8808,6 +8808,9 @@
   "vector component name '%0' is an OpenCL version 2.2 feature">,
   InGroup;
 
+def err_openclcxx_placement_new : Error<
+  "use of placement new requires explicit declaration">;
+
 // MIG routine annotations.
 def warn_mig_server_routine_does_not_return_kern_return_t : Warning<
   "'mig_server_routine' attribute only applies to routines that return a kern_return_t">,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61552: [clang] Adapt ASTMatcher to explicit(bool) specifier

2019-06-19 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 documentation nit.




Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:6190
+/// cxxDeductionGuideDecl(isExplicit()) will match #6, but not #5.
+/// cxxConstructorDecl(isExplicit()) will match #8, but not #7 or #9.
+AST_POLYMORPHIC_MATCHER(isExplicit, AST_POLYMORPHIC_SUPPORTED_TYPES(

Tyker wrote:
> aaron.ballman wrote:
> > Why won't it match #2?
> #2 matches.
I figured it would -- the comment should be updated to correct that (and then 
generate the docs again).


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

https://reviews.llvm.org/D61552



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


[PATCH] D63535: [clang][AST] MangleUtil: A refactoring of CodegenNameGeneratorImpl (NFC).

2019-06-19 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: clang/include/clang/AST/Mangle.h:19
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclObjC.h"
 #include "clang/AST/Type.h"

Move these into the implementation, forward declarations should be sufficient.



Comment at: clang/include/clang/AST/Mangle.h:21
 #include "clang/AST/Type.h"
+#include "clang/AST/VTableBuilder.h"
 #include "clang/Basic/ABI.h"

This isn't used, it belongs in the implementation.



Comment at: clang/include/clang/AST/Mangle.h:25
+#include "llvm/IR/DataLayout.h"
+#include "llvm/IR/Mangler.h"
 #include "llvm/Support/Casting.h"

Is `Mangler` used in the header?  I think this can be in the implementation.



Comment at: clang/include/clang/AST/Mangle.h:253
+
+struct MangleUtil {
+  std::unique_ptr MC;

I think I prefer `ASTNameGenerator` or even `ASTNameMangler` (though I am 
partial to Microsoft's term: "decoration").


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63535



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


[PATCH] D57086: Ignore trailing NullStmts in StmtExprs for GCC compatibility

2019-06-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D57086#1549632 , @domdom wrote:

> clang-format the patch


Thanks! Do you need someone to commit on your behalf?


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

https://reviews.llvm.org/D57086



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


[PATCH] D61552: [clang] Adapt ASTMatcher to explicit(bool) specifier

2019-06-19 Thread Tyker via Phabricator via cfe-commits
Tyker marked an inline comment as done.
Tyker added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:6190
+/// cxxDeductionGuideDecl(isExplicit()) will match #6, but not #5.
+/// cxxConstructorDecl(isExplicit()) will match #8, but not #7 or #9.
+AST_POLYMORPHIC_MATCHER(isExplicit, AST_POLYMORPHIC_SUPPORTED_TYPES(

aaron.ballman wrote:
> Tyker wrote:
> > aaron.ballman wrote:
> > > Why won't it match #2?
> > #2 matches.
> I figured it would -- the comment should be updated to correct that (and then 
> generate the docs again).
but the comment says it matches

> cxxConstructorDecl(isExplicit()) will match #2, but not #1.




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

https://reviews.llvm.org/D61552



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


[PATCH] D63082: [Diagnostics] Added support for -Wint-in-bool-context

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

Is it ok now?


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

https://reviews.llvm.org/D63082



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


[PATCH] D63423: [Diagnostics] Diagnose misused xor as pow

2019-06-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:3306
+def warn_xor_used_as_pow_base_two : Warning<
+  "result of '%0' is %1, maybe you mean '%2' (%3)?">,
+  InGroup;

We usually use "did you mean" in these kinds of diagnostics. Replace the comma 
with a semicolon.

Same comments below.



Comment at: lib/Sema/SemaExpr.cpp:10895
+SourceLocation Loc) {
+  // Do not diagnose macros
+  if (Loc.isMacroID())

Missing a full stop at the end of the comment. Same comment applies elsewhere.


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

https://reviews.llvm.org/D63423



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


[PATCH] D63423: [Diagnostics] Diagnose misused xor as pow

2019-06-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D63423#1547244 , @regehr wrote:

> In D63423#1547216 , @xbolva00 wrote:
>
> > The only remaining question is, as your said, whether or not to diagnose 
> > xors in macros. @regerh @jfb ?
>
>
> IMO it's better to not warn about xors in macros-- I like the current 
> tradeoffs.


Do you mind explaining why? I would have expected to diagnose an xor within a 
macro because the code is just as wrong there, but maybe I'm missing something.


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

https://reviews.llvm.org/D63423



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


[PATCH] D61552: [clang] Adapt ASTMatcher to explicit(bool) specifier

2019-06-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:6190
+/// cxxDeductionGuideDecl(isExplicit()) will match #6, but not #5.
+/// cxxConstructorDecl(isExplicit()) will match #8, but not #7 or #9.
+AST_POLYMORPHIC_MATCHER(isExplicit, AST_POLYMORPHIC_SUPPORTED_TYPES(

Tyker wrote:
> aaron.ballman wrote:
> > Tyker wrote:
> > > aaron.ballman wrote:
> > > > Why won't it match #2?
> > > #2 matches.
> > I figured it would -- the comment should be updated to correct that (and 
> > then generate the docs again).
> but the comment says it matches
> 
> > cxxConstructorDecl(isExplicit()) will match #2, but not #1.
> 
> 
Because this comment says it doesn't:
```
/// cxxConstructorDecl(isExplicit()) will match #8, but not #7 or #9.
```
I see now that there are two different comments that say different and 
incorrect things. I'd say they should be combined into one correct comment.


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

https://reviews.llvm.org/D61552



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


[PATCH] D63562: [clangd] Format changes produced by rename

2019-06-19 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: hokein, kadircet, sammccall.
Herald added subscribers: arphaman, jkorous, MaskRay.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63562

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


Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -285,6 +285,15 @@
 auto Changes = renameWithinFile(InpAST->AST, File, Pos, NewName);
 if (!Changes)
   return CB(Changes.takeError());
+
+auto Style = getFormatStyleForFile(File, InpAST->Inputs.Contents,
+   InpAST->Inputs.FS.get());
+if (auto Formatted =
+cleanupAndFormat(InpAST->Inputs.Contents, *Changes, Style))
+  *Changes = std::move(*Formatted);
+else
+  elog("Failed to format replacements: {0}", Formatted.takeError());
+
 std::vector Edits;
 for (const auto &Rep : *Changes)
   Edits.push_back(replacementToEdit(InpAST->Inputs.Contents, Rep));


Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -285,6 +285,15 @@
 auto Changes = renameWithinFile(InpAST->AST, File, Pos, NewName);
 if (!Changes)
   return CB(Changes.takeError());
+
+auto Style = getFormatStyleForFile(File, InpAST->Inputs.Contents,
+   InpAST->Inputs.FS.get());
+if (auto Formatted =
+cleanupAndFormat(InpAST->Inputs.Contents, *Changes, Style))
+  *Changes = std::move(*Formatted);
+else
+  elog("Failed to format replacements: {0}", Formatted.takeError());
+
 std::vector Edits;
 for (const auto &Rep : *Changes)
   Edits.push_back(replacementToEdit(InpAST->Inputs.Contents, Rep));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63082: [Diagnostics] Added support for -Wint-in-bool-context

2019-06-19 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 marked an inline comment as done.
xbolva00 added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:5612
+def warn_left_shift_in_bool_context : Warning<
+  "'<<' in boolean context, maybe you mean '<'?">,
+  InGroup;

I will this line.


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

https://reviews.llvm.org/D63082



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


[PATCH] D63082: [Diagnostics] Added support for -Wint-in-bool-context

2019-06-19 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 marked an inline comment as done.
xbolva00 added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:5612
+def warn_left_shift_in_bool_context : Warning<
+  "'<<' in boolean context, maybe you mean '<'?">,
+  InGroup;

xbolva00 wrote:
> I will this line.
* Ehh.. I will fix this line to use "did you mean". 


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

https://reviews.llvm.org/D63082



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


[PATCH] D63423: [Diagnostics] Diagnose misused xor as pow

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

We will be noisy in this case

  #define IRQ_CHINT4_LEVEL(11 ^ 7)
  #define IRQ_CHINT3_LEVEL(10 ^ 7)
  #define IRQ_CHINT2_LEVEL(9 ^ 7)
  #define IRQ_CHINT1_LEVEL(8 ^ 7)


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

https://reviews.llvm.org/D63423



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


[PATCH] D63423: [Diagnostics] Diagnose misused xor as pow

2019-06-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D63423#1550563 , @xbolva00 wrote:

> We will be noisy in this case
>
>   #define IRQ_CHINT4_LEVEL(11 ^ 7)
>   #define IRQ_CHINT3_LEVEL(10 ^ 7)
>   #define IRQ_CHINT2_LEVEL(9 ^ 7)
>   #define IRQ_CHINT1_LEVEL(8 ^ 7)
>   


Sure, but do we not want to be noisy in a case like: `#define BAD_IDEA (2 ^ 
16)`?


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

https://reviews.llvm.org/D63423



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


[PATCH] D63423: [Diagnostics] Diagnose misused xor as pow

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

... But I go thru codesearch and this is just one case I think.

I think we should warn in macros... In codesearch case ,they are many more true 
positives, then false negatives.

  #define MAX_T_U32 ((2^32)-1)

Ouch.


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

https://reviews.llvm.org/D63423



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


[PATCH] D63361: Pretend NRVO variables are references so they can be found by debug info

2019-06-19 Thread Amy Huang via Phabricator via cfe-commits
akhuang marked an inline comment as done.
akhuang added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:3946
+  // the address of the variable.
+  if (VD->isNRVOVariable())
+Expr.push_back(llvm::dwarf::DW_OP_deref);

rnk wrote:
> I think we should check for `getLangOpts().ElideConstructors` here, and check 
> that the debug info is correct (no deref) in that mode.
Makes sense, though now I realized there is also an issue because CGDecl checks 
whether `ReturnValuePointer` is valid before changing the debug value, but 
CGDebugInfo doesn't check this when adding DW_OP_deref.. so maybe it makes 
sense to pass something through to `EmitDeclare`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63361



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


[PATCH] D63423: [Diagnostics] Diagnose misused xor as pow

2019-06-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D63423#1550586 , @xbolva00 wrote:

> ... But I go thru codesearch and this is just one case I think.
>
> I think we should warn in macros... In codesearch case ,they are many more 
> true positives, then false negatives.
>
>   #define MAX_T_U32 ((2^32)-1)
>
>
> Ouch.


That's my rationale as well. If it happens outside of macros and is bad, it's 
probably just as likely to happen within a macro and be equally as bad. I think 
we probably should warn within macros.


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

https://reviews.llvm.org/D63423



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


[PATCH] D63361: Pretend NRVO variables are references so they can be found by debug info

2019-06-19 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:3946
+  // the address of the variable.
+  if (VD->isNRVOVariable())
+Expr.push_back(llvm::dwarf::DW_OP_deref);

akhuang wrote:
> rnk wrote:
> > I think we should check for `getLangOpts().ElideConstructors` here, and 
> > check that the debug info is correct (no deref) in that mode.
> Makes sense, though now I realized there is also an issue because CGDecl 
> checks whether `ReturnValuePointer` is valid before changing the debug value, 
> but CGDebugInfo doesn't check this when adding DW_OP_deref.. so maybe it 
> makes sense to pass something through to `EmitDeclare`?
I guess adding a boolean to EmitDeclareOfAutoVariable would be the way to go, 
and then to thread that through here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63361



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


[PATCH] D63535: [clang][AST] ASTNameGenerator: A refactoring of CodegenNameGeneratorImpl (NFC).

2019-06-19 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi updated this revision to Diff 205625.
plotfi added a comment.

Addressing @compnerd's feedback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63535

Files:
  clang/include/clang/AST/Mangle.h
  clang/include/clang/Index/CodegenNameGenerator.h
  clang/lib/AST/Mangle.cpp
  clang/lib/Index/CodegenNameGenerator.cpp

Index: clang/lib/Index/CodegenNameGenerator.cpp
===
--- clang/lib/Index/CodegenNameGenerator.cpp
+++ clang/lib/Index/CodegenNameGenerator.cpp
@@ -12,203 +12,12 @@
 
 #include "clang/Index/CodegenNameGenerator.h"
 #include "clang/AST/ASTContext.h"
-#include "clang/AST/DeclCXX.h"
-#include "clang/AST/DeclObjC.h"
-#include "clang/AST/Mangle.h"
-#include "clang/AST/VTableBuilder.h"
-#include "clang/Basic/TargetInfo.h"
-#include "llvm/IR/DataLayout.h"
-#include "llvm/IR/Mangler.h"
-#include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
 using namespace clang::index;
 
-struct CodegenNameGenerator::Implementation {
-  std::unique_ptr MC;
-  llvm::DataLayout DL;
-
-  Implementation(ASTContext &Ctx)
-: MC(Ctx.createMangleContext()),
-  DL(Ctx.getTargetInfo().getDataLayout()) {}
-
-  bool writeName(const Decl *D, raw_ostream &OS) {
-// First apply frontend mangling.
-SmallString<128> FrontendBuf;
-llvm::raw_svector_ostream FrontendBufOS(FrontendBuf);
-if (auto *FD = dyn_cast(D)) {
-  if (FD->isDependentContext())
-return true;
-  if (writeFuncOrVarName(FD, FrontendBufOS))
-return true;
-} else if (auto *VD = dyn_cast(D)) {
-  if (writeFuncOrVarName(VD, FrontendBufOS))
-return true;
-} else if (auto *MD = dyn_cast(D)) {
-  MC->mangleObjCMethodNameWithoutSize(MD, OS);
-  return false;
-} else if (auto *ID = dyn_cast(D)) {
-  writeObjCClassName(ID, FrontendBufOS);
-} else {
-  return true;
-}
-
-// Now apply backend mangling.
-llvm::Mangler::getNameWithPrefix(OS, FrontendBufOS.str(), DL);
-return false;
-  }
-
-  std::string getName(const Decl *D) {
-std::string Name;
-{
-  llvm::raw_string_ostream OS(Name);
-  writeName(D, OS);
-}
-return Name;
-  }
-
-  enum ObjCKind {
-ObjCClass,
-ObjCMetaclass,
-  };
-
-  std::vector getAllManglings(const ObjCContainerDecl *OCD) {
-StringRef ClassName;
-if (const auto *OID = dyn_cast(OCD))
-  ClassName = OID->getObjCRuntimeNameAsString();
-else if (const auto *OID = dyn_cast(OCD))
-  ClassName = OID->getObjCRuntimeNameAsString();
-
-if (ClassName.empty())
-  return {};
-
-auto Mangle = [&](ObjCKind Kind, StringRef ClassName) -> std::string {
-  SmallString<40> Mangled;
-  auto Prefix = getClassSymbolPrefix(Kind, OCD->getASTContext());
-  llvm::Mangler::getNameWithPrefix(Mangled, Prefix + ClassName, DL);
-  return Mangled.str();
-};
-
-return {
-  Mangle(ObjCClass, ClassName),
-  Mangle(ObjCMetaclass, ClassName),
-};
-  }
-
-  std::vector getAllManglings(const Decl *D) {
-if (const auto *OCD = dyn_cast(D))
-  return getAllManglings(OCD);
-
-if (!(isa(D) || isa(D)))
-  return {};
-
-const NamedDecl *ND = cast(D);
-
-ASTContext &Ctx = ND->getASTContext();
-std::unique_ptr M(Ctx.createMangleContext());
-
-std::vector Manglings;
-
-auto hasDefaultCXXMethodCC = [](ASTContext &C, const CXXMethodDecl *MD) {
-  auto DefaultCC = C.getDefaultCallingConvention(/*IsVariadic=*/false,
- /*IsCSSMethod=*/true);
-  auto CC = MD->getType()->getAs()->getCallConv();
-  return CC == DefaultCC;
-};
-
-if (const auto *CD = dyn_cast_or_null(ND)) {
-  Manglings.emplace_back(getMangledStructor(CD, Ctor_Base));
-
-  if (Ctx.getTargetInfo().getCXXABI().isItaniumFamily())
-if (!CD->getParent()->isAbstract())
-  Manglings.emplace_back(getMangledStructor(CD, Ctor_Complete));
-
-  if (Ctx.getTargetInfo().getCXXABI().isMicrosoft())
-if (CD->hasAttr() && CD->isDefaultConstructor())
-  if (!(hasDefaultCXXMethodCC(Ctx, CD) && CD->getNumParams() == 0))
-Manglings.emplace_back(getMangledStructor(CD, Ctor_DefaultClosure));
-} else if (const auto *DD = dyn_cast_or_null(ND)) {
-  Manglings.emplace_back(getMangledStructor(DD, Dtor_Base));
-  if (Ctx.getTargetInfo().getCXXABI().isItaniumFamily()) {
-Manglings.emplace_back(getMangledStructor(DD, Dtor_Complete));
-if (DD->isVirtual())
-  Manglings.emplace_back(getMangledStructor(DD, Dtor_Deleting));
-  }
-} else if (const auto *MD = dyn_cast_or_null(ND)) {
-  Manglings.emplace_back(getName(ND));
-  if (MD->isVirtual())
-if (const auto *TIV = Ctx.getVTableContext()->getThunkInfo(MD))
-  for (const auto &T : *TIV)
-Manglings.emplace_back(getMangledThunk(MD, T));
-

r363840 - Unify DependencyFileGenerator class and DependencyCollector interface (NFCI)

2019-06-19 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Jun 19 10:07:36 2019
New Revision: 363840

URL: http://llvm.org/viewvc/llvm-project?rev=363840&view=rev
Log:
Unify DependencyFileGenerator class and DependencyCollector interface (NFCI)

Make DependencyFileGenerator a DependencyCollector as it was intended when
DependencyCollector was introduced. The missing PPCallbacks overrides are added 
to
the DependencyCollector as well.

This change will allow clang-scan-deps to access the produced dependencies 
without
writing them out to .d files to disk, so that it will be able collate them and
report them to the user.

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

Modified:
cfe/trunk/include/clang/Frontend/CompilerInstance.h
cfe/trunk/include/clang/Frontend/Utils.h
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/DependencyFile.cpp

Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=363840&r1=363839&r2=363840&view=diff
==
--- cfe/trunk/include/clang/Frontend/CompilerInstance.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInstance.h Wed Jun 19 10:07:36 2019
@@ -124,9 +124,6 @@ class CompilerInstance : public ModuleLo
   /// The module provider.
   std::shared_ptr ThePCHContainerOperations;
 
-  /// The dependency file generator.
-  std::unique_ptr TheDependencyFileGenerator;
-
   std::vector> DependencyCollectors;
 
   /// The set of top-level modules that has already been loaded,
@@ -661,7 +658,6 @@ public:
   InMemoryModuleCache &ModuleCache, ASTContext &Context,
   const PCHContainerReader &PCHContainerRdr,
   ArrayRef> Extensions,
-  DependencyFileGenerator *DependencyFile,
   ArrayRef> DependencyCollectors,
   void *DeserializationListener, bool OwnDeserializationListener,
   bool Preamble, bool UseGlobalModuleIndex);

Modified: cfe/trunk/include/clang/Frontend/Utils.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/Utils.h?rev=363840&r1=363839&r2=363840&view=diff
==
--- cfe/trunk/include/clang/Frontend/Utils.h (original)
+++ cfe/trunk/include/clang/Frontend/Utils.h Wed Jun 19 10:07:36 2019
@@ -15,6 +15,7 @@
 
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/LLVM.h"
+#include "clang/Frontend/DependencyOutputOptions.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/StringMap.h"
@@ -46,7 +47,6 @@ namespace clang {
 class ASTReader;
 class CompilerInstance;
 class CompilerInvocation;
-class DependencyOutputOptions;
 class DiagnosticsEngine;
 class ExternalSemaSource;
 class FrontendOptions;
@@ -77,8 +77,7 @@ void DoPrintPreprocessedInput(Preprocess
 /// An interface for collecting the dependencies of a compilation. Users should
 /// use \c attachToPreprocessor and \c attachToASTReader to get all of the
 /// dependencies.
-/// FIXME: Migrate DependencyFileGen and DependencyGraphGen to use this
-/// interface.
+/// FIXME: Migrate DependencyGraphGen to use this interface.
 class DependencyCollector {
 public:
   virtual ~DependencyCollector();
@@ -95,7 +94,7 @@ public:
  bool IsSystem, bool IsModuleFile, bool IsMissing);
 
   /// Called when the end of the main file is reached.
-  virtual void finishedMainFile() {}
+  virtual void finishedMainFile(DiagnosticsEngine &Diags) {}
 
   /// Return true if system files should be passed to sawDependency().
   virtual bool needSystemDependencies() { return false; }
@@ -106,25 +105,45 @@ public:
   void maybeAddDependency(StringRef Filename, bool FromModule, bool IsSystem,
   bool IsModuleFile, bool IsMissing);
 
+protected:
+  /// Return true if the filename was added to the list of dependencies, false
+  /// otherwise.
+  bool addDependency(StringRef Filename);
+
 private:
   llvm::StringSet<> Seen;
   std::vector Dependencies;
 };
 
-/// Builds a depdenency file when attached to a Preprocessor (for includes) and
+/// Builds a dependency file when attached to a Preprocessor (for includes) and
 /// ASTReader (for module imports), and writes it out at the end of processing
 /// a source file.  Users should attach to the ast reader whenever a module is
 /// loaded.
-class DependencyFileGenerator {
-  void *Impl; // Opaque implementation
+class DependencyFileGenerator : public DependencyCollector {
+public:
+  DependencyFileGenerator(const DependencyOutputOptions &Opts);
 
-  DependencyFileGenerator(void *Impl);
+  void attachToPreprocessor(Preprocessor &PP) override;
 
-public:
-  static DependencyFileGenerator *CreateAndAttachToPreprocessor(
-Preprocessor &PP, const DependencyOutputOptions &Opts);
+  void finishedMainFile(DiagnosticsEngine &Diags) override;
+
+  bool needSystemDependencies() final override { return Include

[PATCH] D63559: [clang-tidy] Added functionality for getting semantic highlights for variable and function declarations

2019-06-19 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom updated this revision to Diff 205626.
jvikstrom added a comment.

Renamed SemanticSymbol to SemanticToken


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63559

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/SemanticHighlight.cpp
  clang-tools-extra/clangd/SemanticHighlight.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/SemanticHighlightTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/SemanticHighlightTests.cpp
@@ -0,0 +1,76 @@
+//===-- SemanticSymbolASTCollectorTests.cpp - SemanticSymbolASTCollector tests
+//--*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Annotations.h"
+#include "ClangdUnit.h"
+#include "Protocol.h"
+#include "SemanticHighlight.h"
+#include "SourceCode.h"
+#include "TestTU.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+using ::testing::ElementsAreArray;
+
+Position createPosition(int Line, int Character) {
+  Position Pos;
+  Pos.character = Character;
+  Pos.line = Line;
+  return Pos;
+}
+
+TEST(SemanticSymbolASTCollector, GetBeginningOfIdentifier) {
+  std::string Preamble = R"cpp(
+struct A {
+  double SomeMember;
+};
+void $foo[[foo]](int $a[[a]]) {
+  auto $vlvn[[VeryLongVariableName]] = 12312;
+  A $aa[[aa]];
+}
+  )cpp";
+
+  Annotations Test(Preamble);
+  auto Foo = Test.range("foo");
+  auto A = Test.range("a");
+  auto VeryLong = Test.range("vlvn");
+  auto AA = Test.range("aa");
+  std::vector CorrectLines = std::vector{
+  LineHighlight(
+  Foo.start.line,
+  {SemanticToken(SemanticScope::FunctionDeclaration,
+  createPosition(Foo.start.line, Foo.start.character),
+  3),
+   SemanticToken(SemanticScope::VariableDeclaration,
+  createPosition(A.start.line, A.start.character), 1)}),
+  LineHighlight(
+  VeryLong.start.line,
+  {SemanticToken(
+  SemanticScope::VariableDeclaration,
+  createPosition(VeryLong.start.line, VeryLong.start.character),
+  VeryLong.end.character - VeryLong.start.character)}),
+  LineHighlight(
+  AA.start.line,
+  {SemanticToken(SemanticScope::VariableDeclaration,
+  createPosition(AA.start.line, AA.start.character),
+  2)})};
+
+  auto AST = TestTU::withCode(Test.code()).build();
+  auto Lines = getASTHighlights(AST.getASTContext());
+  EXPECT_THAT(Lines, ElementsAreArray(CorrectLines));
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -53,6 +53,7 @@
   RenameTests.cpp
   RIFFTests.cpp
   SelectionTests.cpp
+  SemanticHighlightTests.cpp
   SerializationTests.cpp
   SourceCodeTests.cpp
   SymbolCollectorTests.cpp
Index: clang-tools-extra/clangd/SemanticHighlight.h
===
--- /dev/null
+++ clang-tools-extra/clangd/SemanticHighlight.h
@@ -0,0 +1,67 @@
+//===--- SemanticHighlight.h - Generating highlights from the AST
+//-*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Code for collecting semantic symbols from the C++ AST using the
+// RecursiveASTVisitor
+//
+//===--===//
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_SEMANTICSYMBOLASTCOLLECTOR_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SEMANTICSYMBOLASTCOLLECTOR_H
+
+#include "AST.h"
+#include "Headers.h"
+#include "Protocol.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Lex/Lexer.h"
+
+namespace clang {
+namespace clangd {
+
+// ScopeIndex represents the mapping from the scopes list to a type of
+// expression.
+enum class SemanticScope : int {
+  VariableDeclaration = 0,
+  FunctionDeclaration = 1,
+};
+
+// Contains all information needed for the highlighting a symbol.
+struct SemanticToken {

[PATCH] D63559: [clang-tidy] Added functionality for getting semantic highlights for variable and function declarations

2019-06-19 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlight.cpp:1
+#include "SemanticHighlight.h"
+

Header is missing.



Comment at: clang-tools-extra/clangd/SemanticHighlight.cpp:32
+  void addSymbol(Decl *D, SemanticScope Scope) {
+auto Loc = D->getLocation();
+SemanticSymbol S;

Please don't use auto if type is not spelled explicitly.



Comment at: clang-tools-extra/clangd/SemanticHighlight.cpp:34
+SemanticSymbol S;
+auto LSPLoc = sourceLocToPosition(SM, Loc);
+

Please don't use auto if type is not spelled explicitly.



Comment at: clang-tools-extra/clangd/SemanticHighlight.cpp:99
+void write32be(uint32_t I, llvm::raw_ostream &OS) {
+  char Buf[4];
+  llvm::support::endian::write32be(Buf, I);

May be std::array is better way to do this? Same below.



Comment at: clang-tools-extra/clangd/SemanticHighlight.cpp:135
+  Collector.TraverseAST(AST);
+  auto Symbols = Collector.getSymbols();
+  std::vector Lines;

Please don't use auto if type is not spelled explicitly.



Comment at: clang-tools-extra/clangd/SemanticHighlight.h:2
+//===--- SemanticHighlight.h - Generating highlights from the AST
+//-*- C++ -*-===//
+//

Please merge with previous line. If it doesn't fit, remove some - and =.



Comment at: clang-tools-extra/clangd/SemanticHighlight.h:14
+//===--===//
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_SEMANTICSYMBOLASTCOLLECTOR_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SEMANTICSYMBOLASTCOLLECTOR_H

Please separate with empty line.



Comment at: clang-tools-extra/clangd/SemanticHighlight.h:35
+struct SemanticSymbol {
+  SemanticSymbol() {}
+  SemanticSymbol(SemanticScope Scope, Position StartPosition, unsigned int Len)

Please use = default;



Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightTests.cpp:2
+//===-- SemanticSymbolASTCollectorTests.cpp - SemanticSymbolASTCollector tests
+//--*- C++ -*-===//
+//

Please merge with previous line. If it doesn't fit, remove some - and =.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63559



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


[PATCH] D63290: Unify DependencyFileGenerator class and DependencyCollector interface

2019-06-19 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL363840: Unify DependencyFileGenerator class and 
DependencyCollector interface (NFCI) (authored by arphaman, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D63290?vs=205438&id=205628#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63290

Files:
  cfe/trunk/include/clang/Frontend/CompilerInstance.h
  cfe/trunk/include/clang/Frontend/Utils.h
  cfe/trunk/lib/Frontend/CompilerInstance.cpp
  cfe/trunk/lib/Frontend/DependencyFile.cpp

Index: cfe/trunk/include/clang/Frontend/Utils.h
===
--- cfe/trunk/include/clang/Frontend/Utils.h
+++ cfe/trunk/include/clang/Frontend/Utils.h
@@ -15,6 +15,7 @@
 
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/LLVM.h"
+#include "clang/Frontend/DependencyOutputOptions.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/StringMap.h"
@@ -46,7 +47,6 @@
 class ASTReader;
 class CompilerInstance;
 class CompilerInvocation;
-class DependencyOutputOptions;
 class DiagnosticsEngine;
 class ExternalSemaSource;
 class FrontendOptions;
@@ -77,8 +77,7 @@
 /// An interface for collecting the dependencies of a compilation. Users should
 /// use \c attachToPreprocessor and \c attachToASTReader to get all of the
 /// dependencies.
-/// FIXME: Migrate DependencyFileGen and DependencyGraphGen to use this
-/// interface.
+/// FIXME: Migrate DependencyGraphGen to use this interface.
 class DependencyCollector {
 public:
   virtual ~DependencyCollector();
@@ -95,7 +94,7 @@
  bool IsSystem, bool IsModuleFile, bool IsMissing);
 
   /// Called when the end of the main file is reached.
-  virtual void finishedMainFile() {}
+  virtual void finishedMainFile(DiagnosticsEngine &Diags) {}
 
   /// Return true if system files should be passed to sawDependency().
   virtual bool needSystemDependencies() { return false; }
@@ -106,25 +105,45 @@
   void maybeAddDependency(StringRef Filename, bool FromModule, bool IsSystem,
   bool IsModuleFile, bool IsMissing);
 
+protected:
+  /// Return true if the filename was added to the list of dependencies, false
+  /// otherwise.
+  bool addDependency(StringRef Filename);
+
 private:
   llvm::StringSet<> Seen;
   std::vector Dependencies;
 };
 
-/// Builds a depdenency file when attached to a Preprocessor (for includes) and
+/// Builds a dependency file when attached to a Preprocessor (for includes) and
 /// ASTReader (for module imports), and writes it out at the end of processing
 /// a source file.  Users should attach to the ast reader whenever a module is
 /// loaded.
-class DependencyFileGenerator {
-  void *Impl; // Opaque implementation
+class DependencyFileGenerator : public DependencyCollector {
+public:
+  DependencyFileGenerator(const DependencyOutputOptions &Opts);
 
-  DependencyFileGenerator(void *Impl);
+  void attachToPreprocessor(Preprocessor &PP) override;
 
-public:
-  static DependencyFileGenerator *CreateAndAttachToPreprocessor(
-Preprocessor &PP, const DependencyOutputOptions &Opts);
+  void finishedMainFile(DiagnosticsEngine &Diags) override;
+
+  bool needSystemDependencies() final override { return IncludeSystemHeaders; }
+
+  bool sawDependency(StringRef Filename, bool FromModule, bool IsSystem,
+ bool IsModuleFile, bool IsMissing) final override;
+
+private:
+  void outputDependencyFile(DiagnosticsEngine &Diags);
 
-  void AttachToASTReader(ASTReader &R);
+  std::string OutputFile;
+  std::vector Targets;
+  bool IncludeSystemHeaders;
+  bool PhonyTarget;
+  bool AddMissingHeaderDeps;
+  bool SeenMissingHeader;
+  bool IncludeModuleFiles;
+  DependencyOutputFormat OutputFormat;
+  unsigned InputFileIndex;
 };
 
 /// Collects the dependencies for imported modules into a directory.  Users
Index: cfe/trunk/include/clang/Frontend/CompilerInstance.h
===
--- cfe/trunk/include/clang/Frontend/CompilerInstance.h
+++ cfe/trunk/include/clang/Frontend/CompilerInstance.h
@@ -124,9 +124,6 @@
   /// The module provider.
   std::shared_ptr ThePCHContainerOperations;
 
-  /// The dependency file generator.
-  std::unique_ptr TheDependencyFileGenerator;
-
   std::vector> DependencyCollectors;
 
   /// The set of top-level modules that has already been loaded,
@@ -661,7 +658,6 @@
   InMemoryModuleCache &ModuleCache, ASTContext &Context,
   const PCHContainerReader &PCHContainerRdr,
   ArrayRef> Extensions,
-  DependencyFileGenerator *DependencyFile,
   ArrayRef> DependencyCollectors,
   void *DeserializationListener, bool OwnDeserializationListener,
   bool Preamble, bool UseGlobalModuleIndex);
Index: cfe/trunk/lib/Frontend/Depend

[PATCH] D63535: [clang][AST] ASTNameGenerator: A refactoring of CodegenNameGeneratorImpl (NFC).

2019-06-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/AST/Mangle.h:249-250
+struct ASTNameGenerator {
+  std::unique_ptr MC;
+  llvm::DataLayout DL;
+

Do these still need to be public members? Back when this class was an 
implementation detail, that didn't matter as much, but I'd prefer a cleaner 
public interface before we expose this to other consumers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63535



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


[PATCH] D63508: make -frewrite-includes handle __has_include wrapped in a macro

2019-06-19 Thread Luboš Luňák via Phabricator via cfe-commits
llunak added a comment.

Icecream's usage of -frewrite-includes is not special, the purpose is always to 
merge everything necessary for the compilation into one source file that can be 
later compiled on its own as if the original file was compiled. The #include 
expansion done during -frewrite-includes will evaluate all the #if conditions 
etc. the same way they will be evaluated again during the actual compilation.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63508



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


[PATCH] D63535: [clang][AST] ASTNameGenerator: A refactoring of CodegenNameGeneratorImpl (NFC).

2019-06-19 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: clang/include/clang/AST/Mangle.h:248
+
+struct ASTNameGenerator {
+  std::unique_ptr MC;

Please make this a `class` and hide the members, exposing just the constructor 
and the 3 methods as @aaron.ballman pointed out that this is a `struct` not a 
`class`!  I missed that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63535



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


[PATCH] D63508: make -frewrite-includes handle __has_include wrapped in a macro

2019-06-19 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Perhaps we should rewrite all `#if`-like directives to `#if 0` or `#if 1`? 
Either that or we could emit pragmas indicating the values of later 
`__has_include`s. Special-casing macros of this specific form is at best a 
partial solution.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63508



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


[PATCH] D63535: [clang][AST] ASTNameGenerator: A refactoring of CodegenNameGeneratorImpl (NFC).

2019-06-19 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi marked an inline comment as done.
plotfi added inline comments.



Comment at: clang/include/clang/AST/Mangle.h:249-250
+struct ASTNameGenerator {
+  std::unique_ptr MC;
+  llvm::DataLayout DL;
+

aaron.ballman wrote:
> Do these still need to be public members? Back when this class was an 
> implementation detail, that didn't matter as much, but I'd prefer a cleaner 
> public interface before we expose this to other consumers.
Good catch! This was a struct when it was CodegenNameGeneratorImpl but these 
were hidden by the mere fact that they were inside the .cpp file and not in a 
header. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63535



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


[clang-tools-extra] r363843 - [clangd] Format changes produced by rename

2019-06-19 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Jun 19 10:25:24 2019
New Revision: 363843

URL: http://llvm.org/viewvc/llvm-project?rev=363843&view=rev
Log:
[clangd] Format changes produced by rename

Reviewers: hokein, kadircet, sammccall

Reviewed By: kadircet

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=363843&r1=363842&r2=363843&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Jun 19 10:25:24 2019
@@ -285,6 +285,15 @@ void ClangdServer::rename(PathRef File,
 auto Changes = renameWithinFile(InpAST->AST, File, Pos, NewName);
 if (!Changes)
   return CB(Changes.takeError());
+
+auto Style = getFormatStyleForFile(File, InpAST->Inputs.Contents,
+   InpAST->Inputs.FS.get());
+if (auto Formatted =
+cleanupAndFormat(InpAST->Inputs.Contents, *Changes, Style))
+  *Changes = std::move(*Formatted);
+else
+  elog("Failed to format replacements: {0}", Formatted.takeError());
+
 std::vector Edits;
 for (const auto &Rep : *Changes)
   Edits.push_back(replacementToEdit(InpAST->Inputs.Contents, Rep));


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


[PATCH] D63508: make -frewrite-includes handle __has_include wrapped in a macro

2019-06-19 Thread Tor Arne Vestbø via Phabricator via cfe-commits
torarnv added a comment.

In D63508#1550668 , @rsmith wrote:

> Perhaps we should rewrite all `#if`-like directives to `#if 0` or `#if 1`?


If I understand your suggestion correctly, wouldn't the latter break this case?

  #if QT_HAS_INCLUDE()
  #  include 
  #  define HAS_NOPE
  #endif
  
  #ifdef HAS_NOPE
  void bar() { nope(); }
  #endif




Repository:
  rC Clang

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

https://reviews.llvm.org/D63508



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


[PATCH] D63562: [clangd] Format changes produced by rename

2019-06-19 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL363843: [clangd] Format changes produced by rename (authored 
by ibiryukov, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D63562?vs=205618&id=205635#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63562

Files:
  clang-tools-extra/trunk/clangd/ClangdServer.cpp


Index: clang-tools-extra/trunk/clangd/ClangdServer.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp
@@ -285,6 +285,15 @@
 auto Changes = renameWithinFile(InpAST->AST, File, Pos, NewName);
 if (!Changes)
   return CB(Changes.takeError());
+
+auto Style = getFormatStyleForFile(File, InpAST->Inputs.Contents,
+   InpAST->Inputs.FS.get());
+if (auto Formatted =
+cleanupAndFormat(InpAST->Inputs.Contents, *Changes, Style))
+  *Changes = std::move(*Formatted);
+else
+  elog("Failed to format replacements: {0}", Formatted.takeError());
+
 std::vector Edits;
 for (const auto &Rep : *Changes)
   Edits.push_back(replacementToEdit(InpAST->Inputs.Contents, Rep));


Index: clang-tools-extra/trunk/clangd/ClangdServer.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp
@@ -285,6 +285,15 @@
 auto Changes = renameWithinFile(InpAST->AST, File, Pos, NewName);
 if (!Changes)
   return CB(Changes.takeError());
+
+auto Style = getFormatStyleForFile(File, InpAST->Inputs.Contents,
+   InpAST->Inputs.FS.get());
+if (auto Formatted =
+cleanupAndFormat(InpAST->Inputs.Contents, *Changes, Style))
+  *Changes = std::move(*Formatted);
+else
+  elog("Failed to format replacements: {0}", Formatted.takeError());
+
 std::vector Edits;
 for (const auto &Rep : *Changes)
   Edits.push_back(replacementToEdit(InpAST->Inputs.Contents, Rep));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r363844 - [clangd] Consume error returned by cleanupAndFormat

2019-06-19 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Jun 19 10:30:02 2019
New Revision: 363844

URL: http://llvm.org/viewvc/llvm-project?rev=363844&view=rev
Log:
[clangd] Consume error returned by cleanupAndFormat

When called by ClangdServer::applyTweak.
No idea how to actually trigger this in practice, so no tests.

Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=363844&r1=363843&r2=363844&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Jun 19 10:30:02 2019
@@ -360,6 +360,8 @@ void ClangdServer::applyTweak(PathRef Fi
   if (auto Formatted = cleanupAndFormat(InpAST->Inputs.Contents,
 *Effect->ApplyEdit, Style))
 Effect->ApplyEdit = std::move(*Formatted);
+  else
+elog("Failed to format replacements: {0}", Formatted.takeError());
 }
 return CB(std::move(*Effect));
   };


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


[PATCH] D63423: [Diagnostics] Diagnose misused xor as pow

2019-06-19 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 205636.
xbolva00 added a comment.

Added support to warn in macros.
Renamed to -Wxor-used-as-pow.


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

https://reviews.llvm.org/D63423

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExpr.cpp
  test/SemaCXX/warn-xor-as-pow.cpp

Index: test/SemaCXX/warn-xor-as-pow.cpp
===
--- test/SemaCXX/warn-xor-as-pow.cpp
+++ test/SemaCXX/warn-xor-as-pow.cpp
@@ -0,0 +1,102 @@
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -Wxor-used-as-pow %s
+// RUN: %clang_cc1 -x c -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x c -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+
+// RUN: %clang_cc1 -x c++ -DKW_XOR -fsyntax-only -verify -Wxor-used-as-pow %s
+// RUN: %clang_cc1 -x c++ -DKW_XOR -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x c++ -DKW_XOR -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+
+#define FOOBAR(x, y) (x * y)
+#define XOR(x, y) (x ^ y)
+#define TWO 2
+#define TEN 10
+#define TWO_ULL 2ULL
+#define EPSILON 10 ^ -300
+
+void test(unsigned a, unsigned b) {
+  unsigned res;
+  res = a ^ 5;
+  res = 2 ^ b;
+  res = a ^ b;
+  res = 2 ^ -1;
+  res = 2 ^ 0; // expected-warning {{result of '2 ^ 0' is 2; did you mean '1<<0' (1)?}}
+   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1"
+   // expected-note@-2 {{replace expression with '0x2 ^ 0' to silence this warning}}
+  res = 2 ^ 1; // expected-warning {{result of '2 ^ 1' is 3; did you mean '1<<1' (2)?}}
+   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1<<1"
+   // expected-note@-2 {{replace expression with '0x2 ^ 1' to silence this warning}}
+  res = 2 ^ 2; // expected-warning {{result of '2 ^ 2' is 0; did you mean '1<<2' (4)?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1<<2"
+  // expected-note@-2 {{replace expression with '0x2 ^ 2' to silence this warning}}
+  res = 2 ^ 8; // expected-warning {{result of '2 ^ 8' is 10; did you mean '1<<8' (256)?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1<<8"
+  // expected-note@-2 {{replace expression with '0x2 ^ 8' to silence this warning}}
+  res = TWO ^ 8; // expected-warning {{result of 'TWO ^ 8' is 10; did you mean '1<<8' (256)?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:16}:"1<<8"
+  // expected-note@-2 {{replace expression with '0x2 ^ 8' to silence this warning}}
+  res = 2 ^ 16; // expected-warning {{result of '2 ^ 16' is 18; did you mean '1<<16' (65536)?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1<<16"
+  // expected-note@-2 {{replace expression with '0x2 ^ 16' to silence this warning}}
+  res = 2 ^ TEN; // expected-warning {{result of '2 ^ TEN' is 8; did you mean '1<= width of type}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1LL<<32"
+  // expected-note@-2 {{replace expression with '0x2 ^ 32' to silence this warning}}
+  res = 2 ^ 64; // expected-warning {{result of '2 ^ 64' is 66; did you mean '1<<64', but shift count >= width of type}}
+// expected-note@-1 {{replace expression with '0x2 ^ 64' to silence this warning}}
+
+  res = EPSILON; // expected-warning {{result of 'EPSILON' is 294; did you mean '1e-300'?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:16}:"1e-300"
+  // expected-note@-2 {{replace expression with '0xA ^ -300' to silence this warning}}
+  res = 10 ^ 0; // expected-warning {{result of '10 ^ 0' is 10; did you mean '1e0'?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1e0"
+  // expected-note@-2 {{replace expression with '0xA ^ 0' to silence this warning}}
+  res = 10 ^ 1; // expected-warning {{result of '10 ^ 1' is 11; did you mean '1e1'?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1e1"
+  // expected-note@-2 {{replace expression with '0xA ^ 1' to silence this warning}}
+  res = 10 ^ 2; // expected-warning {{result of '10 ^ 2' is 8; did you mean '1e2'?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1e2"
+  // expected-note@-2 {{replace expression with '0xA ^ 2' to silence this warning}}
+  res = 10 ^ 4; // expected-warning {{result of '10 ^ 4' is 14; did you mean '1e4'?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1e4"
+  // expected-note@-2 {{replace expression with '0xA ^ 4' to silence this warning}}
+  res = 10 ^ 10; // expected-warning {{result of '10 ^ 10' is 0; did you mean '1e10'?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:16}:"1e10"
+  // expected-note@-2 {{replace expression with '0xA ^ 10' to silence this warning}}
+  res = TEN ^ 10; // expected-warning {{result of 'TEN ^ 10' is 0; did you mean '1e10'?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:17}:"1e10"
+  // expected-note@-2 {{replace expression with '0xA ^ 10' to silence this warning}}
+  res =

[PATCH] D63423: [Diagnostics] Diagnose misused xor as pow

2019-06-19 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

What I meant with macros was that I don't think we should warn on:

  #define LEGIT(a, b) ({ work work work; a ^ b; work work work; })
  
  LEGIT(10, 5);

If the constants are inline in the macros then sure, warn there. Basically: if 
you literally wrote `CONSTANT ^ CONSTANT` and it looks fishy, let's warn. If 
token-pasting wrote it for you and it looks fishy, let's not warn.


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

https://reviews.llvm.org/D63423



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


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

2019-06-19 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:8739
+/// // For each component specified by this mapper:
+/// if (currentComponent.hasMapper())
+///   (*currentComponent.Mapper())(rt_mapper_handle, arg_base, arg_begin,

Currently `currentComponent` is generated by the compiler. But can we instead 
pass this data as an extra parameter to this `omp_mapper` function.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:8740
+/// if (currentComponent.hasMapper())
+///   (*currentComponent.Mapper())(rt_mapper_handle, arg_base, arg_begin,
+///arg_size, arg_type);

I don't see this part of logic in the code. Could you show me where is it 
exactly?



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:8785
+  std::string Name = getName({"omp_mapper", Ty.getAsString(), D->getName()});
+  std::replace(Name.begin(), Name.end(), ' ', '_');
+  auto *Fn = llvm::Function::Create(FnTy, llvm::GlobalValue::InternalLinkage,

Bad idea to do this. Better to use something like this:
```
SmallString<256> TyStr;
llvm::raw_svector_ostream Out(TyStr);
CGM.getCXXABI().getMangleContext().mangleTypeName(Ty, Out);

```



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

https://reviews.llvm.org/D59474



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


r363846 - [clang][NewPM] Fixing remaining -O0 tests that are broken under new PM

2019-06-19 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Wed Jun 19 10:41:30 2019
New Revision: 363846

URL: http://llvm.org/viewvc/llvm-project?rev=363846&view=rev
Log:
[clang][NewPM] Fixing remaining -O0 tests that are broken under new PM

- CodeGen/flatten.c will fail under new PM becausec the new PM AlwaysInliner
  seems to intentionally inline functions but not call sites marked with
  alwaysinline (D23299)
- Tests that check remarks happen to check them for the inliner which is not
  turned on at O0. These tests just check that remarks work, but we can make
  separate tests for the new PM with -O1 so we can turn on the inliner and
  check the remarks with minimal changes.

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

Added:
cfe/trunk/test/Frontend/optimization-remark-new-pm.c
cfe/trunk/test/Frontend/optimization-remark-with-hotness-new-pm.c
Modified:
cfe/trunk/test/CMakeLists.txt
cfe/trunk/test/CodeGen/flatten.c
cfe/trunk/test/CodeGenCXX/flatten.cpp
cfe/trunk/test/Frontend/optimization-remark-line-directive.c
cfe/trunk/test/Frontend/optimization-remark-with-hotness.c
cfe/trunk/test/Frontend/optimization-remark.c
cfe/trunk/test/lit.cfg.py
cfe/trunk/test/lit.site.cfg.py.in

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=363846&r1=363845&r2=363846&view=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Wed Jun 19 10:41:30 2019
@@ -23,6 +23,7 @@ llvm_canonicalize_cmake_booleans(
   CLANG_ENABLE_ARCMT
   CLANG_ENABLE_STATIC_ANALYZER
   ENABLE_BACKTRACES
+  ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER
   HAVE_LIBZ
   LLVM_ENABLE_PER_TARGET_RUNTIME_DIR
   LLVM_ENABLE_PLUGINS)

Modified: cfe/trunk/test/CodeGen/flatten.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/flatten.c?rev=363846&r1=363845&r2=363846&view=diff
==
--- cfe/trunk/test/CodeGen/flatten.c (original)
+++ cfe/trunk/test/CodeGen/flatten.c Wed Jun 19 10:41:30 2019
@@ -1,3 +1,9 @@
+// UNSUPPORTED: experimental-new-pass-manager
+// Currently, different code seems to be intentionally generated under the new
+// PM since we alwaysinline functions and not callsites under new PM.
+// Under new PM, f() will not be inlined from g() since f is not marked as
+// alwaysinline.
+
 // RUN: %clang_cc1 -triple=x86_64-linux-gnu %s -emit-llvm -o - | FileCheck %s
 
 void f(void) {}

Modified: cfe/trunk/test/CodeGenCXX/flatten.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/flatten.cpp?rev=363846&r1=363845&r2=363846&view=diff
==
--- cfe/trunk/test/CodeGenCXX/flatten.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/flatten.cpp Wed Jun 19 10:41:30 2019
@@ -1,3 +1,7 @@
+// UNSUPPORTED: experimental-new-pass-manager
+// See the comment for CodeGen/flatten.c on why this is unsupported with the 
new
+// PM.
+
 // RUN: %clang_cc1 -triple=x86_64-linux-gnu -std=c++11 %s -emit-llvm -o - | 
FileCheck %s
 
 void f(void) {}

Modified: cfe/trunk/test/Frontend/optimization-remark-line-directive.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/optimization-remark-line-directive.c?rev=363846&r1=363845&r2=363846&view=diff
==
--- cfe/trunk/test/Frontend/optimization-remark-line-directive.c (original)
+++ cfe/trunk/test/Frontend/optimization-remark-line-directive.c Wed Jun 19 
10:41:30 2019
@@ -2,7 +2,11 @@
 // directives. We cannot map #line directives back to
 // a SourceLocation.
 
-// RUN: %clang_cc1 %s -Rpass=inline -debug-info-kind=line-tables-only 
-dwarf-column-info -emit-llvm-only -verify
+// RUN: %clang_cc1 %s -Rpass=inline -debug-info-kind=line-tables-only 
-dwarf-column-info -emit-llvm-only -verify -fno-experimental-new-pass-manager
+
+// The new PM inliner is not added to the default pipeline at O0, so we add
+// some optimizations to trigger it.
+// RUN: %clang_cc1 %s -Rpass=inline -fexperimental-new-pass-manager -O1 
-debug-info-kind=line-tables-only -dwarf-column-info -emit-llvm-only -verify
 
 int foo(int x, int y) __attribute__((always_inline));
 int foo(int x, int y) { return x + y; }

Added: cfe/trunk/test/Frontend/optimization-remark-new-pm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/optimization-remark-new-pm.c?rev=363846&view=auto
==
--- cfe/trunk/test/Frontend/optimization-remark-new-pm.c (added)
+++ cfe/trunk/test/Frontend/optimization-remark-new-pm.c Wed Jun 19 10:41:30 
2019
@@ -0,0 +1,20 @@
+// Verify that remarks for the inliner appear. The remarks under the new PM 
will
+// be slightly different than those emitted by the legacy PM. The new PM 
inliner
+// also doesnot appear to be added 

[PATCH] D63277: [CUDA][HIP] Don't set "comdat" attribute for CUDA device stub functions.

2019-06-19 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

SGTM in principle. Folding the stubs would be bad as their addresses are 
implicitly used to identify the kernels to launch.




Comment at: clang/lib/CodeGen/CodeGenModule.cpp:4294
   setNonAliasAttributes(GD, Fn);
   SetLLVMFunctionAttributesForDefinition(D, Fn);
   if (const ConstructorAttr *CA = D->getAttr())

Perhaps this should be pushed further down into `shouldBeInCOMDAT()` which 
seems to be the right place to decide whether something is not suitable for 
comdat.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63277



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


[PATCH] D62225: [clang][NewPM] Fixing remaining -O0 tests that are broken under new PM

2019-06-19 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL363846: [clang][NewPM] Fixing remaining -O0 tests that are 
broken under new PM (authored by leonardchan, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62225?vs=204198&id=205639#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62225

Files:
  cfe/trunk/test/CMakeLists.txt
  cfe/trunk/test/CodeGen/flatten.c
  cfe/trunk/test/CodeGenCXX/flatten.cpp
  cfe/trunk/test/Frontend/optimization-remark-line-directive.c
  cfe/trunk/test/Frontend/optimization-remark-new-pm.c
  cfe/trunk/test/Frontend/optimization-remark-with-hotness-new-pm.c
  cfe/trunk/test/Frontend/optimization-remark-with-hotness.c
  cfe/trunk/test/Frontend/optimization-remark.c
  cfe/trunk/test/lit.cfg.py
  cfe/trunk/test/lit.site.cfg.py.in

Index: cfe/trunk/test/CodeGenCXX/flatten.cpp
===
--- cfe/trunk/test/CodeGenCXX/flatten.cpp
+++ cfe/trunk/test/CodeGenCXX/flatten.cpp
@@ -1,3 +1,7 @@
+// UNSUPPORTED: experimental-new-pass-manager
+// See the comment for CodeGen/flatten.c on why this is unsupported with the new
+// PM.
+
 // RUN: %clang_cc1 -triple=x86_64-linux-gnu -std=c++11 %s -emit-llvm -o - | FileCheck %s
 
 void f(void) {}
Index: cfe/trunk/test/lit.site.cfg.py.in
===
--- cfe/trunk/test/lit.site.cfg.py.in
+++ cfe/trunk/test/lit.site.cfg.py.in
@@ -24,6 +24,7 @@
 config.clang_examples = @CLANG_BUILD_EXAMPLES@
 config.enable_shared = @ENABLE_SHARED@
 config.enable_backtrace = @ENABLE_BACKTRACES@
+config.enable_experimental_new_pass_manager = @ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER@
 config.host_arch = "@HOST_ARCH@"
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.use_z3_solver = lit_config.params.get('USE_Z3_SOLVER', "@USE_Z3_SOLVER@")
Index: cfe/trunk/test/lit.cfg.py
===
--- cfe/trunk/test/lit.cfg.py
+++ cfe/trunk/test/lit.cfg.py
@@ -97,6 +97,10 @@
 if platform.system() not in ['FreeBSD']:
 config.available_features.add('crash-recovery')
 
+# Support for new pass manager.
+if config.enable_experimental_new_pass_manager:
+config.available_features.add('experimental-new-pass-manager')
+
 # ANSI escape sequences in non-dumb terminal
 if platform.system() not in ['Windows']:
 config.available_features.add('ansi-escape-sequences')
Index: cfe/trunk/test/Frontend/optimization-remark-new-pm.c
===
--- cfe/trunk/test/Frontend/optimization-remark-new-pm.c
+++ cfe/trunk/test/Frontend/optimization-remark-new-pm.c
@@ -0,0 +1,20 @@
+// Verify that remarks for the inliner appear. The remarks under the new PM will
+// be slightly different than those emitted by the legacy PM. The new PM inliner
+// also doesnot appear to be added at O0, so we test at O1.
+// RUN: %clang_cc1 %s -Rpass=inline -Rpass-analysis=inline -Rpass-missed=inline -O1 -fexperimental-new-pass-manager -emit-llvm-only -verify
+// RUN: %clang_cc1 %s -Rpass=inline -Rpass-analysis=inline -Rpass-missed=inline -O1 -fexperimental-new-pass-manager -emit-llvm-only -debug-info-kind=line-tables-only -verify
+
+int foo(int x, int y) __attribute__((always_inline));
+int foo(int x, int y) { return x + y; }
+
+float foz(int x, int y) __attribute__((noinline));
+float foz(int x, int y) { return x * y; }
+
+// The negative diagnostics are emitted twice because the inliner runs
+// twice.
+//
+int bar(int j) {
+  // expected-remark@+2 {{foz not inlined into bar because it should never be inlined (cost=never)}}
+  // expected-remark@+1 {{foo inlined into bar}}
+  return foo(j, j - 2) * foz(j - 2, j);
+}
Index: cfe/trunk/test/Frontend/optimization-remark-line-directive.c
===
--- cfe/trunk/test/Frontend/optimization-remark-line-directive.c
+++ cfe/trunk/test/Frontend/optimization-remark-line-directive.c
@@ -2,7 +2,11 @@
 // directives. We cannot map #line directives back to
 // a SourceLocation.
 
-// RUN: %clang_cc1 %s -Rpass=inline -debug-info-kind=line-tables-only -dwarf-column-info -emit-llvm-only -verify
+// RUN: %clang_cc1 %s -Rpass=inline -debug-info-kind=line-tables-only -dwarf-column-info -emit-llvm-only -verify -fno-experimental-new-pass-manager
+
+// The new PM inliner is not added to the default pipeline at O0, so we add
+// some optimizations to trigger it.
+// RUN: %clang_cc1 %s -Rpass=inline -fexperimental-new-pass-manager -O1 -debug-info-kind=line-tables-only -dwarf-column-info -emit-llvm-only -verify
 
 int foo(int x, int y) __attribute__((always_inline));
 int foo(int x, int y) { return x + y; }
Index: cfe/trunk/test/Frontend/optimization-remark.c
===
--- cfe/trunk/test/Frontend/optimization-remark.c
+++ cfe/trunk/te

[PATCH] D63423: [Diagnostics] Diagnose misused xor as pow

2019-06-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D63423#1550697 , @jfb wrote:

> What I meant with macros was that I don't think we should warn on:
>
>   #define LEGIT(a, b) ({ work work work; a ^ b; work work work; })
>  
>   LEGIT(10, 5);
>
>
> If the constants are inline in the macros then sure, warn there. Basically: 
> if you literally wrote `CONSTANT ^ CONSTANT` and it looks fishy, let's warn. 
> If token-pasting wrote it for you and it looks fishy, let's not warn.


So you would not want to see this code diagnosed?

  #define POW(x, y) (x ^ y)
  
  void f() {
int two_to_the_derp = POW(2, 16);
  }

I'm not certain I understand the rationale for why we would not want to 
diagnose such a construct. Do we have reason to expect a lot of false positives?


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

https://reviews.llvm.org/D63423



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


r363848 - [clang][test] Add missing LambdaTemplateParams test and migrate from getLocStart

2019-06-19 Thread Jordan Rupprecht via cfe-commits
Author: rupprecht
Date: Wed Jun 19 10:43:58 2019
New Revision: 363848

URL: http://llvm.org/viewvc/llvm-project?rev=363848&view=rev
Log:
[clang][test] Add missing LambdaTemplateParams test and migrate from getLocStart

These were removed a long time ago in r341573, but this test was missed because 
it was not in cmake

Modified:
cfe/trunk/unittests/Tooling/CMakeLists.txt

cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/LambdaTemplateParams.cpp

Modified: cfe/trunk/unittests/Tooling/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/CMakeLists.txt?rev=363848&r1=363847&r2=363848&view=diff
==
--- cfe/trunk/unittests/Tooling/CMakeLists.txt (original)
+++ cfe/trunk/unittests/Tooling/CMakeLists.txt Wed Jun 19 10:43:58 2019
@@ -38,6 +38,7 @@ add_clang_unittest(ToolingTests
   RecursiveASTVisitorTests/IntegerLiteral.cpp
   RecursiveASTVisitorTests/LambdaDefaultCapture.cpp
   RecursiveASTVisitorTests/LambdaExpr.cpp
+  RecursiveASTVisitorTests/LambdaTemplateParams.cpp
   RecursiveASTVisitorTests/NestedNameSpecifiers.cpp
   RecursiveASTVisitorTests/ParenExpr.cpp
   RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp

Modified: 
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/LambdaTemplateParams.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/LambdaTemplateParams.cpp?rev=363848&r1=363847&r2=363848&view=diff
==
--- 
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/LambdaTemplateParams.cpp 
(original)
+++ 
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/LambdaTemplateParams.cpp 
Wed Jun 19 10:43:58 2019
@@ -21,19 +21,19 @@ public:
 
   bool VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
 EXPECT_FALSE(D->isImplicit());
-Match(D->getName(), D->getLocStart());
+Match(D->getName(), D->getBeginLoc());
 return true;
   }
 
   bool VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) {
 EXPECT_FALSE(D->isImplicit());
-Match(D->getName(), D->getLocStart());
+Match(D->getName(), D->getBeginLoc());
 return true;
   }
 
   bool VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) {
 EXPECT_FALSE(D->isImplicit());
-Match(D->getName(), D->getLocStart());
+Match(D->getName(), D->getBeginLoc());
 return true;
   }
 };


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


  1   2   3   >