[PATCH] D60455: [SYCL] Add sycl_kernel attribute for accelerated code outlining

2019-12-02 Thread Alexey Bader via Phabricator via cfe-commits
bader marked 5 inline comments as done.
bader added inline comments.



Comment at: clang/test/SemaSYCL/kernel-attribute.cpp:4-5
+
+__attribute((sycl_kernel)) void foo() {
+}

aaron.ballman wrote:
> aaron.ballman wrote:
> > Missing some tests:
> > * test that both attributes can be applied to whatever subjects they 
> > appertain to
> > * test that neither attribute can be applied to an incorrect subject
> > * test that the attributes do not accept arguments
> > * test that the attribute is ignored when SYCL is not enabled
> > 
> > Are there situations where the attribute does not make sense, such as 
> > member functions, virtual functions, etc? If so, those are good test cases 
> > (and diagnostics) to add as well.
> Still missing a test that the attribute is ignored when SYCL is not enabled.
> Still missing a test that the attribute is ignored when SYCL is not enabled.

I think clang/test/SemaSYCL/kernel-attribute-on-non-sycl.cpp should check that. 
Please, let me know if you mean something else.

> This test should be on a templated function (we already demonstrated it only 
> applies to templated functions, so the check for the argument is not what is 
> failing).

Nice catch. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



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


[PATCH] D60455: [SYCL] Add sycl_kernel attribute for accelerated code outlining

2019-12-02 Thread Alexey Bader via Phabricator via cfe-commits
bader updated this revision to Diff 231644.
bader marked an inline comment as done.
bader added a comment.

Applied @aaron.ballman suggestions to kernel-attribute.cpp test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/SemaSYCL/kernel-attribute-on-non-sycl.cpp
  clang/test/SemaSYCL/kernel-attribute.cpp

Index: clang/test/SemaSYCL/kernel-attribute.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/kernel-attribute.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl-is-device -verify %s
+
+// Only function templates
+[[clang::sycl_kernel]] int gv2 = 0; // expected-warning {{'sycl_kernel' attribute only applies to function templates}}
+__attribute__((sycl_kernel)) int gv3 = 0; // expected-warning {{'sycl_kernel' attribute only applies to function templates}}
+
+__attribute__((sycl_kernel)) void foo(); // expected-warning {{'sycl_kernel' attribute only applies to function templates}}
+[[clang::sycl_kernel]] void foo1(); // expected-warning {{'sycl_kernel' attribute only applies to function templates}}
+
+// Attribute takes no arguments
+template 
+__attribute__((sycl_kernel(1))) void foo(T P); // expected-error {{'sycl_kernel' attribute takes no arguments}}
+template 
+[[clang::sycl_kernel(1)]] void foo1(T P);// expected-error {{'sycl_kernel' attribute takes no arguments}}
+
+// At least two template parameters
+template 
+__attribute__((sycl_kernel)) void foo(T P); // expected-warning {{'sycl_kernel' attribute only applies to a function template with at least two template parameters}}
+template 
+[[clang::sycl_kernel]] void foo1(T P); // expected-warning {{'sycl_kernel' attribute only applies to a function template with at least two template parameters}}
+
+// First two template parameters cannot be non-type template parameters
+template 
+__attribute__((sycl_kernel)) void foo(T P); // expected-warning {{template parameter of a function template with the 'sycl_kernel' attribute cannot be a non-type template parameter}}
+template 
+[[clang::sycl_kernel]] void foo1(T P); // expected-warning {{template parameter of a function template with the 'sycl_kernel' attribute cannot be a non-type template parameter}}
+
+// Must return void
+template 
+__attribute__((sycl_kernel)) int foo(T P); // expected-warning {{function template with 'sycl_kernel' attribute must have a 'void' return type}}
+template 
+[[clang::sycl_kernel]] int foo1(T P); // expected-warning {{function template with 'sycl_kernel' attribute must have a 'void' return type}}
+
+// Must take at least one argument
+template 
+__attribute__((sycl_kernel)) void foo(); // expected-warning {{function template with 'sycl_kernel' attribute must have a single parameter}}
+template 
+[[clang::sycl_kernel]] void foo1(T t, A a); // expected-warning {{function template with 'sycl_kernel' attribute must have a single parameter}}
+
+// No diagnostics
+template 
+__attribute__((sycl_kernel)) void foo(T P);
+template 
+[[clang::sycl_kernel]] void foo1(T P);
Index: clang/test/SemaSYCL/kernel-attribute-on-non-sycl.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/kernel-attribute-on-non-sycl.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl-is-device -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -x c++ %s
+
+#ifndef __SYCL_DEVICE_ONLY__
+// expected-warning@+7 {{'sycl_kernel' attribute ignored}}
+// expected-warning@+8 {{'sycl_kernel' attribute ignored}}
+#else
+// expected-no-diagnostics
+#endif
+
+template 
+__attribute__((sycl_kernel)) void foo(T P);
+template 
+[[clang::sycl_kernel]] void foo1(T P);
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -6412,6 +6412,45 @@
   D->addAttr(::new (S.Context) OpenCLAccessAttr(S.Context, AL));
 }
 
+static void handleSYCLKernelAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  // The 'sycl_kernel' attribute applies only to function templates.
+  const auto *FD = cast(D);
+  const FunctionTemplateDecl *FT = FD->getDescribedFunctionTemplate();
+  assert(FT && "Function template is expected");
+
+  // Function template must have at least two template parameters.
+  const TemplateParameterList *TL = FT->getTemplateParameters();
+  if (TL->size() < 2) {
+S.Diag(FT->getLocation(), diag::warn_sycl_kernel_num_of_template_params);
+return;
+  }
+
+  // Template parameters must be typenames.
+  for (unsigned I = 0; I < 2; ++I) {
+const NamedDecl *TParam = TL->getParam(I);
+if (isa(TParam)) {
+  S.Diag(FT->getLocation(),
+ diag::warn

[PATCH] D70746: [clangd] Highlighting dependent types in more contexts

2019-12-02 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

Thanks! LGTM




Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:275
+  if (NNS->getKind() == NestedNameSpecifier::Identifier) {
+H.addToken(Q.getLocalBeginLoc(), HighlightingKind::DependentType);
+  }

NIT: remove braces from the inner `if`. They look totally ok in the outer if, 
though


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70746



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


[PATCH] D70863: [clangd] Try harder to find a plausible `clang` as argv0, particularly on Mac.

2019-12-02 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

The code LG, but my mac is at home, so I could not verify it.
@kbobyrev, would you mind running this on your machine?




Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:135
+// On other platforms, just look for compilers on the PATH.
+for (const char* Name : {"clang", "gcc", "ccc"})
+  if (auto PathCC = llvm::sys::findProgramByName(Name))

NIT: maybe add braces to the for statement?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70863



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


[PATCH] D70863: [clangd] Try harder to find a plausible `clang` as argv0, particularly on Mac.

2019-12-02 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:135
+// On other platforms, just look for compilers on the PATH.
+for (const char* Name : {"clang", "gcc", "ccc"})
+  if (auto PathCC = llvm::sys::findProgramByName(Name))

ilya-biryukov wrote:
> NIT: maybe add braces to the for statement?
did you mean "cc" instead of "ccc"? or is that really a think ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70863



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


[PATCH] D69223: WDocumentation: Implement the \anchor.

2019-12-02 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

A few more comments, but generally looks good!




Comment at: clang/include/clang-c/Documentation.h:188
+  /**
+   * Command argument should not be rendered (since it is a only defines
+   * an anchor).

"since it is a only" => "since it only"



Comment at: clang/lib/Index/CommentToXML.cpp:650
+assert(C->getNumArgs() == 1);
+Result << "";
+appendToResultWithXMLEscaping(Arg0);

Sholudn't this code be producing ""?



Comment at: clang/test/Index/Inputs/CommentXML/valid-inline-command-01.xml:1
+
+

Please add a line to `clang/test/Index/comment-xml-schema.c` that executes this 
test.


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

https://reviews.llvm.org/D69223



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


[PATCH] D70862: [ARM][AArch64] Complex addition Neon intrinsics for Armv8.3-A

2019-12-02 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover added a comment.

Why are you only implementing rot90 and rot270 intrinsics? My quick 
calculations made rot0 and rot90 the natural ones to implement a bog-standard 
complex multiplication, but even if I slipped up there I'd expect the others to 
be useful in some situations.




Comment at: clang/include/clang/Basic/arm_neon.td:1687
+  def VCADD_ROT270  : SInst<"vcadd_rot270", "...", "f">;
+  def VCADDQ_ROT90  : SInst<"vcaddq_rot90", "QQQ", "f">;
+  def VCADDQ_ROT270 : SInst<"vcaddq_rot270", "QQQ", "f">;

I take it you can't fuse this with vcadd_rot90 because NeonEmitter tries to 
call it vcadd_rot90q? If so, I think your solution is reasonable, the rotations 
are a tiny edge-case in the ISA.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70862



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


[clang-tools-extra] 902dc6c - [clangd] Fix a regression issue in local rename.

2019-12-02 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2019-12-02T10:32:55+01:00
New Revision: 902dc6c69ce7985427efa103a7c4099c372da6fa

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

LOG: [clangd] Fix a regression issue in local rename.

Summary:
The regression is that we can't rename symbols in annonymous
namespaces.

Reviewers: ilya-biryukov

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/Rename.cpp
clang-tools-extra/clangd/unittests/RenameTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index 6a3439cc0612..7d74641be719 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -123,20 +123,26 @@ llvm::Optional renameable(const Decl 
&RenameDecl,
   if (RenameDecl.getParentFunctionOrMethod())
 return None;
 
+  // Check whether the symbol being rename is indexable.
+  auto &ASTCtx = RenameDecl.getASTContext();
+  bool MainFileIsHeader = isHeaderFile(MainFilePath, ASTCtx.getLangOpts());
+  bool DeclaredInMainFile =
+  isInsideMainFile(RenameDecl.getBeginLoc(), ASTCtx.getSourceManager());
+  bool IsMainFileOnly = true;
+  if (MainFileIsHeader)
+// main file is a header, the symbol can't be main file only.
+IsMainFileOnly = false;
+  else if (!DeclaredInMainFile)
+IsMainFileOnly = false;
   bool IsIndexable =
   isa(RenameDecl) &&
   SymbolCollector::shouldCollectSymbol(
   cast(RenameDecl), RenameDecl.getASTContext(),
-  SymbolCollector::Options(), CrossFile);
+  SymbolCollector::Options(), IsMainFileOnly);
   if (!IsIndexable) // If the symbol is not indexable, we disallow rename.
 return ReasonToReject::NonIndexable;
 
   if (!CrossFile) {
-auto &ASTCtx = RenameDecl.getASTContext();
-const auto &SM = ASTCtx.getSourceManager();
-bool MainFileIsHeader = isHeaderFile(MainFilePath, ASTCtx.getLangOpts());
-bool DeclaredInMainFile = isInsideMainFile(RenameDecl.getBeginLoc(), SM);
-
 if (!DeclaredInMainFile)
   // We are sure the symbol is used externally, bail out early.
   return ReasonToReject::UsedOutsideFile;

diff  --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp 
b/clang-tools-extra/clangd/unittests/RenameTests.cpp
index 0615272de372..1ade0c0443bc 100644
--- a/clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ b/clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -450,13 +450,20 @@ TEST(RenameTest, Renameable) {
   )cpp",
"used outside main file", HeaderFile, Index},
 
-  {R"cpp(// disallow -- symbol is not indexable.
+  {R"cpp(// disallow -- symbol in annonymous namespace in header is not 
indexable.
 namespace {
 class Unin^dexable {};
 }
   )cpp",
"not eligible for indexing", HeaderFile, Index},
 
+  {R"cpp(// allow -- symbol in annonymous namespace in non-header file is 
indexable.
+namespace {
+class [[F^oo]] {};
+}
+  )cpp",
+   nullptr, !HeaderFile, Index},
+
   {R"cpp(// disallow -- namespace symbol isn't supported
 namespace n^s {}
   )cpp",



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


[PATCH] D70853: [clangd] Fix a regression issue in local rename.

2019-12-02 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.
Closed by commit rG902dc6c69ce7: [clangd] Fix a regression issue in local 
rename. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D70853?vs=231525&id=231647#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70853

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -450,13 +450,20 @@
   )cpp",
"used outside main file", HeaderFile, Index},
 
-  {R"cpp(// disallow -- symbol is not indexable.
+  {R"cpp(// disallow -- symbol in annonymous namespace in header is not 
indexable.
 namespace {
 class Unin^dexable {};
 }
   )cpp",
"not eligible for indexing", HeaderFile, Index},
 
+  {R"cpp(// allow -- symbol in annonymous namespace in non-header file is 
indexable.
+namespace {
+class [[F^oo]] {};
+}
+  )cpp",
+   nullptr, !HeaderFile, Index},
+
   {R"cpp(// disallow -- namespace symbol isn't supported
 namespace n^s {}
   )cpp",
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -123,20 +123,26 @@
   if (RenameDecl.getParentFunctionOrMethod())
 return None;
 
+  // Check whether the symbol being rename is indexable.
+  auto &ASTCtx = RenameDecl.getASTContext();
+  bool MainFileIsHeader = isHeaderFile(MainFilePath, ASTCtx.getLangOpts());
+  bool DeclaredInMainFile =
+  isInsideMainFile(RenameDecl.getBeginLoc(), ASTCtx.getSourceManager());
+  bool IsMainFileOnly = true;
+  if (MainFileIsHeader)
+// main file is a header, the symbol can't be main file only.
+IsMainFileOnly = false;
+  else if (!DeclaredInMainFile)
+IsMainFileOnly = false;
   bool IsIndexable =
   isa(RenameDecl) &&
   SymbolCollector::shouldCollectSymbol(
   cast(RenameDecl), RenameDecl.getASTContext(),
-  SymbolCollector::Options(), CrossFile);
+  SymbolCollector::Options(), IsMainFileOnly);
   if (!IsIndexable) // If the symbol is not indexable, we disallow rename.
 return ReasonToReject::NonIndexable;
 
   if (!CrossFile) {
-auto &ASTCtx = RenameDecl.getASTContext();
-const auto &SM = ASTCtx.getSourceManager();
-bool MainFileIsHeader = isHeaderFile(MainFilePath, ASTCtx.getLangOpts());
-bool DeclaredInMainFile = isInsideMainFile(RenameDecl.getBeginLoc(), SM);
-
 if (!DeclaredInMainFile)
   // We are sure the symbol is used externally, bail out early.
   return ReasonToReject::UsedOutsideFile;


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -450,13 +450,20 @@
   )cpp",
"used outside main file", HeaderFile, Index},
 
-  {R"cpp(// disallow -- symbol is not indexable.
+  {R"cpp(// disallow -- symbol in annonymous namespace in header is not indexable.
 namespace {
 class Unin^dexable {};
 }
   )cpp",
"not eligible for indexing", HeaderFile, Index},
 
+  {R"cpp(// allow -- symbol in annonymous namespace in non-header file is indexable.
+namespace {
+class [[F^oo]] {};
+}
+  )cpp",
+   nullptr, !HeaderFile, Index},
+
   {R"cpp(// disallow -- namespace symbol isn't supported
 namespace n^s {}
   )cpp",
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -123,20 +123,26 @@
   if (RenameDecl.getParentFunctionOrMethod())
 return None;
 
+  // Check whether the symbol being rename is indexable.
+  auto &ASTCtx = RenameDecl.getASTContext();
+  bool MainFileIsHeader = isHeaderFile(MainFilePath, ASTCtx.getLangOpts());
+  bool DeclaredInMainFile =
+  isInsideMainFile(RenameDecl.getBeginLoc(), ASTCtx.getSourceManager());
+  bool IsMainFileOnly = true;
+  if (MainFileIsHeader)
+// main file is a header, the symbol can't be main file only.
+IsMainFileOnly = false;
+  else if (!DeclaredInMainFile)
+IsMainFileOnly = false;
   bool IsIndexable =
   isa(RenameDecl) &&
   SymbolCollector::shouldCollectSymbol(
   cast(RenameDecl), RenameDecl.getASTContext(),
-  SymbolCollector::Options(), CrossFile

[PATCH] D70862: [ARM][AArch64] Complex addition Neon intrinsics for Armv8.3-A

2019-12-02 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover accepted this revision.
t.p.northover added a comment.
This revision is now accepted and ready to land.

> Why are you only implementing rot90 and rot270 intrinsics? My quick 
> calculations made rot0 and rot90 the natural ones to implement a bog-standard 
> complex multiplication, but even if I slipped up there I'd expect the others 
> to be useful in some situations.

Sorry, ignore that. I didn't notice you were doing the addition instructions 
rather than multiplication. LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70862



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


[PATCH] D70489: [clangd] Add xref for macro to static index.

2019-12-02 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 marked an inline comment as done.
usaxena95 added inline comments.



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:374
+Roles & static_cast(index::SymbolRole::Definition) ||
+Roles & static_cast(index::SymbolRole::Reference)))
 return true;

hokein wrote:
> I think we should avoid running the code below if this is a mere reference.
Interesting. Just to understand it better can you give an example where the 
Role is just a reference ?



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:532
+  const IdentifierInfo *II = MacroRef.first;
+  if (const auto *MI = PP->getMacroDefinition(II).getMacroInfo())
+if (auto ID = getSymbolID(II->getName(), MI, PP->getSourceManager())) {

hokein wrote:
> I'm curious of the behavior `getMacroDefinition` -- from its implementation, 
> if `II` doesn't have macro definition, it just returns empty.
> 
> could you check whether it works at the below case (or even with a same macro 
> name defined/undef multiple times)?
> 
> ```
> #define abc 1
> #undef abc
> 
> // not at the EOF, I guess, II for `abc` doesn't have macro definition at 
> this point because it has been undef?
> ```
I had a FIXME in the tests for this case. I see why there was no macro 
definition at that point. I guess it would be better to keep the symbol id  
instead of the II.



Comment at: clang-tools-extra/clangd/index/SymbolCollector.h:76
 /// macro even if this is true.
 bool CollectMacro = false;
 /// Collect symbols local to main-files, such as static functions

hokein wrote:
> This option is for macro symbols, I'd not use it for collecting macro 
> references. I think the whether to collect macro references is judged by 
> `RefFilter` and `RefsInHeaders`. 
I see. `RefFilter` sounds right but I am don't think `RefsInHeaders` is the 
correct one. It just tells whether to collect references from the included 
header (i.e. outside mainfile) or not.
I think it would be better to have a separate flag for macro references in such 
case.
WDYT ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70489



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


[PATCH] D70489: [clangd] Add xref for macro to static index.

2019-12-02 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 231648.
usaxena95 marked 5 inline comments as done.
usaxena95 added a comment.

Addressed comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70489

Files:
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -39,6 +39,7 @@
 using ::testing::Each;
 using ::testing::ElementsAre;
 using ::testing::Field;
+using ::testing::IsEmpty;
 using ::testing::Not;
 using ::testing::Pair;
 using ::testing::UnorderedElementsAre;
@@ -577,15 +578,16 @@
 
 TEST_F(SymbolCollectorTest, Refs) {
   Annotations Header(R"(
-  class $foo[[Foo]] {
+  #define $macro[[MACRO]](X) (X + 1)
+  class Foo {
   public:
-$foo[[Foo]]() {}
-$foo[[Foo]](int);
+Foo() {}
+Foo(int);
   };
-  class $bar[[Bar]];
-  void $func[[func]]();
+  class Bar;
+  void func();
 
-  namespace $ns[[NS]] {} // namespace ref is ignored
+  namespace NS {} // namespace ref is ignored
   )");
   Annotations Main(R"(
   class $bar[[Bar]] {};
@@ -598,19 +600,20 @@
 $func[[func]]();
 int abc = 0;
 $foo[[Foo]] foo2 = abc;
+abc = $macro[[MACRO]](1);
   }
   )");
   Annotations SymbolsOnlyInMainCode(R"(
+  #define FUNC(X) (X+1)
   int a;
   void b() {}
-  static const int c = 0;
+  static const int c = FUNC(1);
   class d {};
   )");
   CollectorOpts.RefFilter = RefKind::All;
+  CollectorOpts.CollectMacro = true;
   runSymbolCollector(Header.code(),
  (Main.code() + SymbolsOnlyInMainCode.code()).str());
-  auto HeaderSymbols = TestTU::withHeaderCode(Header.code()).headerSymbols();
-
   EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "Foo").ID,
   HaveRanges(Main.ranges("foo");
   EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "Bar").ID,
@@ -618,12 +621,72 @@
   EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "func").ID,
   HaveRanges(Main.ranges("func");
   EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(Symbols, "NS").ID, _;
+  EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "MACRO").ID,
+  HaveRanges(Main.ranges("macro");
   // Symbols *only* in the main file (a, b, c) had no refs collected.
   auto MainSymbols =
   TestTU::withHeaderCode(SymbolsOnlyInMainCode.code()).headerSymbols();
   EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(MainSymbols, "a").ID, _;
   EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(MainSymbols, "b").ID, _;
   EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(MainSymbols, "c").ID, _;
+  EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(MainSymbols, "FUNC").ID, _;
+}
+
+TEST_F(SymbolCollectorTest, MacroRef) {
+  Annotations Main(R"(
+  #define $foo[[FOO]](X) (X + 1)
+  #define $bar[[BAR]](X) (X + 2)
+
+  // FIXME: No references for undef'ed macros.
+  #define $ud1[[UD]] 1
+  int ud_1 = $ud1[[UD]];
+  #undef UD
+
+  #define $ud2[[UD]] 2
+  int ud_2 = $ud2[[UD]];
+  #undef UD
+
+  // Macros from token concatenations not included.
+  #define $concat[[CONCAT]](X) X##A()
+  #define $prepend[[PREPEND]](X) MACRO##X()
+  #define $macroa[[MACROA]]() 123
+  int B = $concat[[CONCAT]](MACRO);
+  int D = $prepend[[PREPEND]](A);
+
+  void fff() {
+int abc = $foo[[FOO]](1) + $bar[[BAR]]($foo[[FOO]](1));
+  }
+  )");
+  CollectorOpts.RefFilter = RefKind::All;
+  CollectorOpts.CollectMacro = true;
+  CollectorOpts.CollectMainFileSymbols = true;
+  
+  runSymbolCollector("", Main.code());
+
+  EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "FOO").ID,
+  HaveRanges(Main.ranges("foo");
+  EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "BAR").ID,
+  HaveRanges(Main.ranges("bar");
+  EXPECT_THAT(Refs, Contains(Pair(_,
+  HaveRanges(Main.ranges("ud1");
+  EXPECT_THAT(Refs, Contains(Pair(_,
+  HaveRanges(Main.ranges("ud2");
+  EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "CONCAT").ID,
+  HaveRanges(Main.ranges("concat");
+  EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "PREPEND").ID,
+  HaveRanges(Main.ranges("prepend");
+  EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "MACROA").ID,
+  HaveRanges(Main.ranges("macroa");
+}
+
+TEST_F(SymbolCollectorTest, RefsWithoutMacros) {
+  Annotations Header("#define $macro[[MACRO]](X) (X + 1)");
+  Annotations Main("void foo() { int x = $macro[[MACRO]](1); }");
+

[PATCH] D70849: [AST] Traverse the class type loc inside the member pointer type loc.

2019-12-02 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 231649.
hokein marked 3 inline comments as done.
hokein added a comment.
Herald added subscribers: arphaman, jkorous.

address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70849

Files:
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/RecursiveASTVisitorTests/MemberPointerTypeLoc.cpp


Index: clang/unittests/Tooling/RecursiveASTVisitorTests/MemberPointerTypeLoc.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/MemberPointerTypeLoc.cpp
@@ -0,0 +1,37 @@
+//===- unittest/Tooling/RecursiveASTVisitorTests/MemberPointerTypeLoc.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TestVisitor.h"
+
+using namespace clang;
+
+namespace {
+
+class MemberPointerTypeLocVisitor
+: public ExpectedLocationVisitor {
+public:
+  bool VisitRecordTypeLoc(RecordTypeLoc RTL) {
+if (!RTL)
+  return true;
+Match(RTL.getDecl()->getName(), RTL.getNameLoc());
+return true;
+  }
+};
+
+TEST(RecursiveASTVisitor, VisitTypeLocInMemberPointerTypeLoc) {
+  MemberPointerTypeLocVisitor Visitor;
+  Visitor.ExpectMatch("Bar", 4, 36);
+  EXPECT_TRUE(Visitor.runOver(R"cpp(
+ class Bar { void func(int); };
+ class Foo {
+   void bind(const char*, void(Bar::*Foo)(int)) {}
+ };
+  )cpp"));
+}
+
+} // end anonymous namespace
Index: clang/unittests/Tooling/CMakeLists.txt
===
--- clang/unittests/Tooling/CMakeLists.txt
+++ clang/unittests/Tooling/CMakeLists.txt
@@ -42,6 +42,7 @@
   RecursiveASTVisitorTests/LambdaDefaultCapture.cpp
   RecursiveASTVisitorTests/LambdaExpr.cpp
   RecursiveASTVisitorTests/LambdaTemplateParams.cpp
+  RecursiveASTVisitorTests/MemberPointerTypeLoc.cpp
   RecursiveASTVisitorTests/NestedNameSpecifiers.cpp
   RecursiveASTVisitorTests/ParenExpr.cpp
   RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp
Index: clang/include/clang/AST/RecursiveASTVisitor.h
===
--- clang/include/clang/AST/RecursiveASTVisitor.h
+++ clang/include/clang/AST/RecursiveASTVisitor.h
@@ -1162,11 +1162,11 @@
 DEF_TRAVERSE_TYPELOC(RValueReferenceType,
  { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
 
-// FIXME: location of base class?
 // We traverse this in the type case as well, but how is it not reached through
 // the pointee type?
 DEF_TRAVERSE_TYPELOC(MemberPointerType, {
-  TRY_TO(TraverseType(QualType(TL.getTypePtr()->getClass(), 0)));
+  if (auto *TSI = TL.getClassTInfo())
+TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));
   TRY_TO(TraverseTypeLoc(TL.getPointeeLoc()));
 })
 
Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -407,8 +407,8 @@
   }
 )cpp",
   R"cpp(
-  template
+  template
   struct $Class[[G]] {
 void $Method[[foo]](
 $TemplateParameter[[T]] *$Parameter[[O]]) {


Index: clang/unittests/Tooling/RecursiveASTVisitorTests/MemberPointerTypeLoc.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/MemberPointerTypeLoc.cpp
@@ -0,0 +1,37 @@
+//===- unittest/Tooling/RecursiveASTVisitorTests/MemberPointerTypeLoc.cpp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TestVisitor.h"
+
+using namespace clang;
+
+namespace {
+
+class MemberPointerTypeLocVisitor
+: public ExpectedLocationVisitor {
+public:
+  bool VisitRecordTypeLoc(RecordTypeLoc RTL) {
+if (!RTL)
+  return true;
+Match(RTL.getDecl()->getName(), RTL.getNameLoc());
+return true;
+  }
+};
+
+TEST(RecursiveASTVisitor, VisitTypeLocInMemberPointerTypeLoc) {
+  MemberPointerTypeLocVisitor Visitor;
+  Visitor.ExpectMatch("Bar", 4, 36);
+  EXPECT_TRUE(Visitor.runOver(R"cpp(
+ class Bar { void func(int); };
+ class Foo {
+   void bind(const char*, void(Bar::*Foo)(int)) {}
+ };
+  )cpp"));
+}
+
+} // end anonymous namespace
Index: clang/un

[PATCH] D70856: [Syntax] Build nodes for simple cases of top level declarations

2019-12-02 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:346
+/// static_assert(, )
+/// static_assert()
+class StaticAssertDeclaration final : public Declaration {

Why no semicolon, here and in other newly-added comments below? Seems like 
these syntax nodes cover the semicolon as implemented.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:378
+
+/// namespace  {  }
+class NamespaceDefinition final : public Declaration {

Isn't it a "nested name specifier" since C++17?



Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:515
+Builder.markExprChild(S->getAssertExpr(),
+  syntax::NodeRole::StaticAssertDeclaration_condition);
+Builder.foldNode(Builder.getRange(S),

Why not also mark the message?



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:517
+  {R"cpp(
+namespace a { namespace b {} }
+namespace {}

Also add `namespace a::b {}` ?



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:692
+static_assert(true, "message");
+static_assert(true);
+)cpp",

Duplicate test? (There's one above that's exactly like this.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70856



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


[PATCH] D70863: [clangd] Try harder to find a plausible `clang` as argv0, particularly on Mac.

2019-12-02 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Another interesting consideration: we choose to ask users to whitelists 
compilers we might run from `compile_commands.json` that we can.
We are in a better position here, since we're not running the binaries based on 
user input.

Technically, we could consider using the same mechanism for running `xcrun`. It 
will probably never be used in practice, though (and we'll have to whitelist 
some common `xcrun` binaries anyway).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70863



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


[PATCH] D70863: [clangd] Try harder to find a plausible `clang` as argv0, particularly on Mac.

2019-12-02 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added a comment.

The current version of the patch fixes one of the related issues. When running 
on a simple file like this

  #include 
  
  int main() {
  std::cout << "Hello, world" << std::endl;
  return 0;
  }

Clangd would fail to find `iostream` header and produce errors for `std::cout` 
and `std::endl` which are also not found before the patch. After the patch, 
this is no longer an issue. Hence, I believe that standard library headers can 
be identified correctly now.

However, after the patch `wchar.h` from `#include_next` is not found and this 
produces another error. `wchar.h` there is AFAIK not a part of the standard 
library and should be found in the SDKROOT.

The following is a log of Clangd failing to find `wchar.h`:

  kbobyrev$ ./bin/clangd -sync < /tmp/mirror


  clangd is a language server that provides IDE-like features to editors.
  
  It should be used via an editor plugin rather than invoked directly. For more 
information, see:
  https://clang.llvm.org/extra/clangd/
  https://microsoft.github.io/language-server-protocol/
  
  clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment 
variable.
  
  I[11:18:01.774] clangd version 10.0.0 (https://github.com/llvm/llvm-project 
bd23859f390aa81ddb1bf0b16684cce50ad9d66d)   
   
  I[11:18:01.775] PID: 92552
  I[11:18:01.775] Working directory: /Users/kbobyrev/dev/build/llvm-release
  I[11:18:01.775] argv[0]: ./bin/clangd
  I[11:18:01.775] argv[1]: -sync
  I[11:18:01.775] Starting LSP over stdin/stdout
  I[11:18:01.776] <-- initialize(0)
  I[11:18:01.776] --> reply:initialize(0) 0 ms
  Content-Length: 800
  
  
{"id":0,"jsonrpc":"2.0","result":{"capabilities":{"codeActionProvider":{"codeActionKinds":["quickfix","refactor","info"]},"completionProvider":{"resolveProvider":false,"triggerCharacters":[".",">",":"]},"declarationProvider":true,"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"\n","moreTriggerCharacter":[]},"documentRangeFormattingProvider":true,"documentSymbolProvider":true,"executeCommandProvider":{"commands":["clangd.applyFix","clangd.applyTweak"]},"hoverProvider":true,"referencesProvider":true,"renameProvider":true,"selectionRangeProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"textDocumentSync":2,"typeHierarchyProvider":true,"workspaceSymbolProvider":true}}}I[11:18:01.776]
 <-- textDocument/didOpen
  I[11:18:01.789] Failed to find compilation database for /private/tmp/test.cpp
  I[11:18:01.789] Updating file /private/tmp/test.cpp with command clangd 
fallback
  [/private/tmp]
  /Library/Developer/CommandLineTools/usr/bin/clang /private/tmp/test.cpp 
-fsyntax-only 
-resource-dir=/Users/kbobyrev/dev/build/llvm-release/lib/clang/10.0.0   
 
  I[11:18:02.155] --> textDocument/publishDiagnostics
  Content-Length: 819
  
  
{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":"pp_file_not_found","message":"In
 included file: 'wchar.h' file not 
found","range":{"end":{"character":10,"line":0},"start":{"character":9,"line":0}},"relatedInformation":[{"location":{"range":{"end":{"character":23,"line":118},"start":{"character":14,"line":118}},"uri":"file:///Library/Developer/CommandLineTools/usr/include/c%2B%2B/v1/wchar.h"},"message":"Error
 occurred 
here"}],"severity":1,"source":"clang"},{"code":"typecheck_invalid_operands","message":"Invalid
 operands to binary expression ('std::__1::ostream' (aka 'int') and 'const char 
[13]')","range":{"end":{"character":13,"line":3},"start":{"character":11,"line":3}},"relatedInformation":[],"severity":1,"source":"clang"}],"uri":"file:///private/tmp/test.cpp"}}I[11:18:02.155]
 Warning: Missing Content-Length header, or zero-length message.
  E[11:18:02.155] Transport error: Input/output error
  I[11:18:02.155] LSP finished, exiting with status 1

This can be fixed manually by appending `env SDKROOT=$(xcrun --show-sdk-path)` 
to the clangd invocation (or simply defining the environment variable for all 
invocations), but I believe we might want to deal with it on the Clangd side, 
too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70863



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


[PATCH] D70863: [clangd] Try harder to find a plausible `clang` as argv0, particularly on Mac.

2019-12-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall planned changes to this revision.
sammccall added a comment.

@kbobyrev tested this and it turns out we also have to set `$SDKROOT`. And we 
probably want to fix `clang` in compile_commands.json too.

In D70863#1764785 , @ilya-biryukov 
wrote:

> Another interesting consideration: we choose to ask users to whitelists 
> compilers we might run from `compile_commands.json` that we can.
>  We are in a better position here, since we're not running the binaries based 
> on user input.


Interesting idea. Wouldn't mix it with this patch as the purposes don't overlap 
much...

- apple clang in practice won't report the required info to the driver query 
until the next major xcode release I think (with your driver patch)
- the motivating case for this patch is the fallback compile command

> Technically, we could consider using the same mechanism for running `xcrun`. 
> It will probably never be used in practice, though (and we'll have to 
> whitelist some common `xcrun` binaries anyway).

You mean the whitelist? The security risk we were worried about with 
--query_driver is that compile_commands.json is easily attacker-controlled. The 
string `xcrun` is fixed, and the attack "put a different xcrun on the user's 
PATH" requires way more privileges - generally you're owned at that point 
anyway. I don't think it's worth guarding.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70863



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


[PATCH] D69764: [clang-format] Add Left/Right Const (East/West , Before/After) fixer capability

2019-12-02 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

I'm not generally opposed to this, given that
a) clang-format already changes code; I think by now we're not fixing double 
semicolon mainly for workflow reasons, would be fine to add
b) the implementation is very self contained




Comment at: clang/docs/ClangFormatStyleOptions.rst:1378
 
+**ConstStyle** (``ConstAlignmentStyle``)
+  Different ways to arrange const.

Personally, I'm somewhat against having 3 different aliases for the options. 
I'd chose one, even though it doesn't make everybody happy, and move on. I'm 
fine with East/West as long as the documentation makes it clear what it is.



Comment at: clang/lib/Format/EastWestConstFixer.cpp:143
+SmallVectorImpl &AnnotatedLines,
+FormatTokenLexer &Tokens) {
+  const AdditionalKeywords &Keywords = Tokens.getKeywords();

This function is super large - can we split it up?



Comment at: clang/unittests/Format/FormatTest.cpp:30-32
+#define VERIFYFORMAT(expect, style) verifyFormat(expect, style, __LINE__)
+#define VERIFYFORMAT2(expect, actual, style)   
\
+  verifyFormat(expect, actual, style, __LINE__)

I'm somewhat opposed to introducing these macros in this patch. If we want 
them, we should create an extra patch, and figure out ho to use them in all 
format tests.


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

https://reviews.llvm.org/D69764



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


[PATCH] D70489: [clangd] Add xref for macro to static index.

2019-12-02 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 60166 tests passed, 0 failed and 730 were skipped.

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70489



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


[PATCH] D70489: [clangd] Add xref for macro to static index.

2019-12-02 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 marked 2 inline comments as done.
usaxena95 added inline comments.



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:374
+Roles & static_cast(index::SymbolRole::Definition) ||
+Roles & static_cast(index::SymbolRole::Reference)))
 return true;

usaxena95 wrote:
> hokein wrote:
> > I think we should avoid running the code below if this is a mere reference.
> Interesting. Just to understand it better can you give an example where the 
> Role is just a reference ?
My bad. Got this one. The part below it is just for the symbol slab so it's 
fine to omit a reference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70489



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


[PATCH] D69840: [Basic] Make SourceLocation usable as key in hash maps, NFCI

2019-12-02 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

ping^3


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

https://reviews.llvm.org/D69840



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


[PATCH] D70489: [clangd] Add xref for macro to static index.

2019-12-02 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 231660.
usaxena95 added a comment.

Added correct documentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70489

Files:
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -39,6 +39,7 @@
 using ::testing::Each;
 using ::testing::ElementsAre;
 using ::testing::Field;
+using ::testing::IsEmpty;
 using ::testing::Not;
 using ::testing::Pair;
 using ::testing::UnorderedElementsAre;
@@ -577,15 +578,16 @@
 
 TEST_F(SymbolCollectorTest, Refs) {
   Annotations Header(R"(
-  class $foo[[Foo]] {
+  #define $macro[[MACRO]](X) (X + 1)
+  class Foo {
   public:
-$foo[[Foo]]() {}
-$foo[[Foo]](int);
+Foo() {}
+Foo(int);
   };
-  class $bar[[Bar]];
-  void $func[[func]]();
+  class Bar;
+  void func();
 
-  namespace $ns[[NS]] {} // namespace ref is ignored
+  namespace NS {} // namespace ref is ignored
   )");
   Annotations Main(R"(
   class $bar[[Bar]] {};
@@ -598,19 +600,20 @@
 $func[[func]]();
 int abc = 0;
 $foo[[Foo]] foo2 = abc;
+abc = $macro[[MACRO]](1);
   }
   )");
   Annotations SymbolsOnlyInMainCode(R"(
+  #define FUNC(X) (X+1)
   int a;
   void b() {}
-  static const int c = 0;
+  static const int c = FUNC(1);
   class d {};
   )");
   CollectorOpts.RefFilter = RefKind::All;
+  CollectorOpts.CollectMacro = true;
   runSymbolCollector(Header.code(),
  (Main.code() + SymbolsOnlyInMainCode.code()).str());
-  auto HeaderSymbols = TestTU::withHeaderCode(Header.code()).headerSymbols();
-
   EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "Foo").ID,
   HaveRanges(Main.ranges("foo");
   EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "Bar").ID,
@@ -618,12 +621,72 @@
   EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "func").ID,
   HaveRanges(Main.ranges("func");
   EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(Symbols, "NS").ID, _;
+  EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "MACRO").ID,
+  HaveRanges(Main.ranges("macro");
   // Symbols *only* in the main file (a, b, c) had no refs collected.
   auto MainSymbols =
   TestTU::withHeaderCode(SymbolsOnlyInMainCode.code()).headerSymbols();
   EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(MainSymbols, "a").ID, _;
   EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(MainSymbols, "b").ID, _;
   EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(MainSymbols, "c").ID, _;
+  EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(MainSymbols, "FUNC").ID, _;
+}
+
+TEST_F(SymbolCollectorTest, MacroRef) {
+  Annotations Main(R"(
+  #define $foo[[FOO]](X) (X + 1)
+  #define $bar[[BAR]](X) (X + 2)
+
+  // Macro defined multiple times.
+  #define $ud1[[UD]] 1
+  int ud_1 = $ud1[[UD]];
+  #undef UD
+
+  #define $ud2[[UD]] 2
+  int ud_2 = $ud2[[UD]];
+  #undef UD
+
+  // Macros from token concatenations not included.
+  #define $concat[[CONCAT]](X) X##A()
+  #define $prepend[[PREPEND]](X) MACRO##X()
+  #define $macroa[[MACROA]]() 123
+  int B = $concat[[CONCAT]](MACRO);
+  int D = $prepend[[PREPEND]](A);
+
+  void fff() {
+int abc = $foo[[FOO]](1) + $bar[[BAR]]($foo[[FOO]](1));
+  }
+  )");
+  CollectorOpts.RefFilter = RefKind::All;
+  CollectorOpts.CollectMacro = true;
+  CollectorOpts.CollectMainFileSymbols = true;
+  
+  runSymbolCollector("", Main.code());
+
+  EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "FOO").ID,
+  HaveRanges(Main.ranges("foo");
+  EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "BAR").ID,
+  HaveRanges(Main.ranges("bar");
+  EXPECT_THAT(Refs, Contains(Pair(_,
+  HaveRanges(Main.ranges("ud1");
+  EXPECT_THAT(Refs, Contains(Pair(_,
+  HaveRanges(Main.ranges("ud2");
+  EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "CONCAT").ID,
+  HaveRanges(Main.ranges("concat");
+  EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "PREPEND").ID,
+  HaveRanges(Main.ranges("prepend");
+  EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "MACROA").ID,
+  HaveRanges(Main.ranges("macroa");
+}
+
+TEST_F(SymbolCollectorTest, RefsWithoutMacros) {
+  Annotations Header("#define $macro[[MACRO]](X) (X + 1)");
+  Annotations Main("void foo() { int x = $macro[[MACRO]](1); }");
+  CollectorOpts.RefFilter = RefKind::All;
+  Co

[PATCH] D70829: [ARM][MVE][Intrinsics] Add VMINQ/VMAXQ/VMINNMQ/VMAXNMQ intrinsics.

2019-12-02 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham accepted this revision.
simon_tatham added a comment.

I do, but only an indentation quibble.




Comment at: clang/include/clang/Basic/arm_mve.td:205
+(select (icmp_ule $a, $b), $a, $b)>,
+NameOverride<"vminq">;
+  def vmaxqu: Intrinsichttps://reviews.llvm.org/D70829/new/

https://reviews.llvm.org/D70829



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


[PATCH] D70253: [AArch64][SVE2] Implement remaining SVE2 floating-point intrinsics

2019-12-02 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin added inline comments.



Comment at: llvm/include/llvm/IR/IntrinsicsAArch64.td:898
+ llvm_i32_ty],
+[IntrNoMem]>;
+

sdesmalen wrote:
> efriedma wrote:
> > kmclaughlin wrote:
> > > sdesmalen wrote:
> > > > I'd expect the `llvm_i32_ty` to be an immediate for these instructions, 
> > > > right? If so you'll need to add `ImmArg`  to the list of 
> > > > properties.
> > > > 
> > > Thanks for taking a look at this :) I tried your suggestion of adding 
> > > ImmAr to the list of properties here but had some problems with it 
> > > (i.e. Cannot select: intrinsic %llvm.aarch64.sve.fmlalb.lane). I don't 
> > > think this is too much of an issue here as we have additional checks on 
> > > the immediate with VectorIndexH32b, which ensures the immediate is in the 
> > > correct range.
> > The point of immarg markings isn't to assist the backend; it's to ensure IR 
> > optimizations don't break your intrinsic calls.
> The pattern is probably not matching because the immediate operand is a 
> `TargetConstant` where the `AsmVectorIndexOpnd` derives from `ImmLeaf`, 
> rather than `TImmLeaf` as introduced by D58232.
Thanks for the suggestion, this was the reason why the patterns were not 
matching! As this also affects many of the existing intrinsics not added here 
or in D70437, I would prefer to address this fully in a separate patch - do you 
have objections to this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70253



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


[clang] 510792a - [ARM][MVE][Intrinsics] Add VMINQ/VMAXQ/VMINNMQ/VMAXNMQ intrinsics.

2019-12-02 Thread Mark Murray via cfe-commits

Author: Mark Murray
Date: 2019-12-02T11:18:53Z
New Revision: 510792a2e0e3792871baa00ed34e162bba7cd9a2

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

LOG: [ARM][MVE][Intrinsics] Add VMINQ/VMAXQ/VMINNMQ/VMAXNMQ intrinsics.

Summary: Add VMINQ/VMAXQ/VMINNMQ/VMAXNMQ intrinsics and their predicated 
versions. Add unit tests.

Subscribers: kristof.beyls, hiraditya, dmgreen, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 
clang/test/CodeGen/arm-mve-intrinsics/vmaxnmq.c
clang/test/CodeGen/arm-mve-intrinsics/vmaxq.c
clang/test/CodeGen/arm-mve-intrinsics/vminnmq.c
clang/test/CodeGen/arm-mve-intrinsics/vminq.c
llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmq.ll
llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxq.ll
llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmq.ll
llvm/test/CodeGen/Thumb2/mve-intrinsics/vminq.ll

Modified: 
clang/include/clang/Basic/arm_mve.td
clang/include/clang/Basic/arm_mve_defs.td
llvm/include/llvm/IR/IntrinsicsARM.td
llvm/lib/Target/ARM/ARMInstrMVE.td

Removed: 




diff  --git a/clang/include/clang/Basic/arm_mve.td 
b/clang/include/clang/Basic/arm_mve.td
index dfd8097f0644..90cccb12472c 100644
--- a/clang/include/clang/Basic/arm_mve.td
+++ b/clang/include/clang/Basic/arm_mve.td
@@ -105,6 +105,26 @@ defm vornq_m: predicated_bit_op_fp<"orn_predicated">;
 defm vorrq_m: predicated_bit_op_fp<"orr_predicated">;
 }
 
+// Predicated intrinsics - Int types only
+let params = T.Int in {
+def vminq_m: Intrinsic<
+Vector, (args Vector:$inactive, Vector:$a, Vector:$b, Predicate:$pred),
+(IRInt<"min_predicated", [Vector, Predicate]> $a, $b, $pred, $inactive)>;
+def vmaxq_m: Intrinsic<
+Vector, (args Vector:$inactive, Vector:$a, Vector:$b, Predicate:$pred),
+(IRInt<"max_predicated", [Vector, Predicate]> $a, $b, $pred, $inactive)>;
+}
+
+// Predicated intrinsics - Float types only
+let params = T.Float in {
+def vminnmq_m: Intrinsic<
+Vector, (args Vector:$inactive, Vector:$a, Vector:$b, Predicate:$pred),
+(IRInt<"min_predicated", [Vector, Predicate]> $a, $b, $pred, $inactive)>;
+def vmaxnmq_m: Intrinsic<
+Vector, (args Vector:$inactive, Vector:$a, Vector:$b, Predicate:$pred),
+(IRInt<"max_predicated", [Vector, Predicate]> $a, $b, $pred, $inactive)>;
+}
+
 let params = T.Int in {
 def vminvq: Intrinsic $prev, $vec))>;
@@ -173,6 +193,28 @@ let params = T.Float in {
   defm: compare<"le", fcmp_le>;
 }
 
+let params = T.Signed in {
+  def vminq: Intrinsic;
+  def vmaxq: Intrinsic;
+}
+let params = T.Unsigned in {
+  def vminqu: Intrinsic,
+  NameOverride<"vminq">;
+  def vmaxqu: Intrinsic,
+  NameOverride<"vmaxq">;
+}
+let params = T.Float in {
+  def vminnmq: Intrinsic $a, $b)>;
+  def vmaxnmq: Intrinsic $a, $b)>;
+}
+
+
 multiclass contiguous_load same_size, list wider> {
   // Intrinsics named with explicit memory and element sizes that match:

diff  --git a/clang/include/clang/Basic/arm_mve_defs.td 
b/clang/include/clang/Basic/arm_mve_defs.td
index c0ed80d456a5..d837a1d33d00 100644
--- a/clang/include/clang/Basic/arm_mve_defs.td
+++ b/clang/include/clang/Basic/arm_mve_defs.td
@@ -107,6 +107,7 @@ def fcmp_ge: IRBuilder<"CreateFCmpOGE">;
 def fcmp_lt: IRBuilder<"CreateFCmpOLT">;
 def fcmp_le: IRBuilder<"CreateFCmpOLE">;
 def splat: CGHelperFn<"ARMMVEVectorSplat">;
+def select: IRBuilder<"CreateSelect">;
 
 // A node that makes an Address out of a pointer-typed Value, by
 // providing an alignment as the second argument.

diff  --git a/clang/test/CodeGen/arm-mve-intrinsics/vmaxnmq.c 
b/clang/test/CodeGen/arm-mve-intrinsics/vmaxnmq.c
new file mode 100644
index ..63300466c819
--- /dev/null
+++ b/clang/test/CodeGen/arm-mve-intrinsics/vmaxnmq.c
@@ -0,0 +1,65 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature 
+mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O3 
-disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature 
+mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O3 
-disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg | 
FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vmaxnmq_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call <8 x half> @llvm.maxnum.v8f16(<8 x 
half> [[A:%.*]], <8 x half> [[B:%.*]])
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vmaxnmq_f16(float16x8_t a, float16x8_t b)
+{
+#ifdef POLYMORPHIC
+return vmaxnmq(a, b);
+#else /* POLYMORPHIC */
+return vmaxnmq_f16(a, b);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: 

[PATCH] D70489: [clangd] Add xref for macro to static index.

2019-12-02 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 60166 tests passed, 0 failed and 730 were skipped.

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70489



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


[PATCH] D70829: [ARM][MVE][Intrinsics] Add VMINQ/VMAXQ/VMINNMQ/VMAXNMQ intrinsics.

2019-12-02 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM updated this revision to Diff 231664.
MarkMurrayARM added a comment.

Address whitespace nit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70829

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/test/CodeGen/arm-mve-intrinsics/vmaxnmq.c
  clang/test/CodeGen/arm-mve-intrinsics/vmaxq.c
  clang/test/CodeGen/arm-mve-intrinsics/vminnmq.c
  clang/test/CodeGen/arm-mve-intrinsics/vminq.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vminq.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vminq.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vminq.ll
@@ -0,0 +1,89 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define dso_local arm_aapcs_vfpcc <16 x i8> @test_vminq_u8(<16 x i8> %a, <16 x i8> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vminq_u8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmin.u8 q0, q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = icmp ugt <16 x i8> %a, %b
+  %1 = select <16 x i1> %0, <16 x i8> %b, <16 x i8> %a
+  ret <16 x i8> %1
+}
+
+define dso_local arm_aapcs_vfpcc <8 x i16> @test_vminq_s16(<8 x i16> %a, <8 x i16> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vminq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmin.s16 q0, q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = icmp sgt <8 x i16> %a, %b
+  %1 = select <8 x i1> %0, <8 x i16> %b, <8 x i16> %a
+  ret <8 x i16> %1
+}
+
+define dso_local arm_aapcs_vfpcc <4 x i32> @test_vminq_u32(<4 x i32> %a, <4 x i32> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vminq_u32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmin.u32 q0, q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = icmp ugt <4 x i32> %a, %b
+  %1 = select <4 x i1> %0, <4 x i32> %b, <4 x i32> %a
+  ret <4 x i32> %1
+}
+
+define dso_local arm_aapcs_vfpcc <16 x i8> @test_vminq_m_s8(<16 x i8> %inactive, <16 x i8> %a, <16 x i8> %b, i16 zeroext %p) local_unnamed_addr #1 {
+; CHECK-LABEL: test_vminq_m_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vmint.s8 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %0)
+  %2 = tail call <16 x i8> @llvm.arm.mve.min.predicated.v16i8.v16i1(<16 x i8> %a, <16 x i8> %b, <16 x i1> %1, <16 x i8> %inactive)
+  ret <16 x i8> %2
+}
+
+declare <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32) #2
+
+declare <16 x i8> @llvm.arm.mve.min.predicated.v16i8.v16i1(<16 x i8>, <16 x i8>, <16 x i1>, <16 x i8>) #2
+
+define dso_local arm_aapcs_vfpcc <8 x i16> @test_vminq_m_u16(<8 x i16> %inactive, <8 x i16> %a, <8 x i16> %b, i16 zeroext %p) local_unnamed_addr #1 {
+; CHECK-LABEL: test_vminq_m_u16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vmint.s16 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = tail call <8 x i16> @llvm.arm.mve.min.predicated.v8i16.v8i1(<8 x i16> %a, <8 x i16> %b, <8 x i1> %1, <8 x i16> %inactive)
+  ret <8 x i16> %2
+}
+
+declare <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32) #2
+
+declare <8 x i16> @llvm.arm.mve.min.predicated.v8i16.v8i1(<8 x i16>, <8 x i16>, <8 x i1>, <8 x i16>) #2
+
+define dso_local arm_aapcs_vfpcc <4 x i32> @test_vminq_m_s32(<4 x i32> %inactive, <4 x i32> %a, <4 x i32> %b, i16 zeroext %p) local_unnamed_addr #1 {
+; CHECK-LABEL: test_vminq_m_s32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vmint.s32 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %0)
+  %2 = tail call <4 x i32> @llvm.arm.mve.min.predicated.v4i32.v4i1(<4 x i32> %a, <4 x i32> %b, <4 x i1> %1, <4 x i32> %inactive)
+  ret <4 x i32> %2
+}
+
+declare <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32) #2
+
+declare <4 x i32> @llvm.arm.mve.min.predicated.v4i32.v4i1(<4 x i32>, <4 x i32>, <4 x i1>, <4 x i32>) #2
Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmq.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmq.ll
@@ -0,0 +1,62 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define dso_local arm_aapcs_vfpcc <8 x half> @test_vminnmq_f16(

[PATCH] D70437: [AArch64][SVE] Implement shift intrinsics

2019-12-02 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 231663.
kmclaughlin added a comment.

- Rebased & enclosed additional //setOperationAction// calls within check for 
//Subtarget->isSVE()//


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

https://reviews.llvm.org/D70437

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-shifts.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-shifts.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-shifts.ll
@@ -0,0 +1,367 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
+
+;
+; ASR
+;
+
+define  @asr_i8( %pg,  %a,  %b) {
+; CHECK-LABEL: asr_i8:
+; CHECK: asr z0.b, p0/m, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asr.nxv16i8( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+define  @asr_i16( %pg,  %a,  %b) {
+; CHECK-LABEL: asr_i16:
+; CHECK: asr z0.h, p0/m, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asr.nxv8i16( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+define  @asr_i32( %pg,  %a,  %b) {
+; CHECK-LABEL: asr_i32:
+; CHECK: asr z0.s, p0/m, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asr.nxv4i32( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+define  @asr_i64( %pg,  %a,  %b) {
+; CHECK-LABEL: asr_i64:
+; CHECK: asr z0.d, p0/m, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asr.nxv2i64( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+define  @asr_wide_i8( %pg,  %a,  %b) {
+; CHECK-LABEL: asr_wide_i8:
+; CHECK: asr z0.b, p0/m, z0.b, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asr.wide.nxv16i8( %pg,
+ %a,
+ %b)
+  ret  %out
+}
+
+define  @asr_wide_i16( %pg,  %a,  %b) {
+; CHECK-LABEL: asr_wide_i16:
+; CHECK: asr z0.h, p0/m, z0.h, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asr.wide.nxv8i16( %pg,
+ %a,
+ %b)
+  ret  %out
+}
+
+define  @asr_wide_i32( %pg,  %a,  %b) {
+; CHECK-LABEL: asr_wide_i32:
+; CHECK: asr z0.s, p0/m, z0.s, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asr.wide.nxv4i32( %pg,
+ %a,
+ %b)
+  ret  %out
+}
+
+;
+; ASRD
+;
+
+define  @asrd_i8( %pg,  %a) {
+; CHECK-LABEL: asrd_i8:
+; CHECK: asrd z0.b, p0/m, z0.b, #1
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asrd.nxv16i8( %pg,
+ %a,
+i32 1)
+  ret  %out
+}
+
+define  @asrd_i16( %pg,  %a) {
+; CHECK-LABEL: asrd_i16:
+; CHECK: asrd z0.h, p0/m, z0.h, #2
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asrd.nxv8i16( %pg,
+ %a,
+i32 2)
+  ret  %out
+}
+
+define  @asrd_i32( %pg,  %a) {
+; CHECK-LABEL: asrd_i32:
+; CHECK: asrd z0.s, p0/m, z0.s, #31
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asrd.nxv4i32( %pg,
+ %a,
+i32 31)
+  ret  %out
+}
+
+define  @asrd_i64( %pg,  %a) {
+; CHECK-LABEL: asrd_i64:
+; CHECK: asrd z0.d, p0/m, z0.d, #64
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asrd.nxv2i64( %pg,
+ %a,
+i32 64)
+  ret  %out
+}
+
+;
+; INSR
+;
+
+define  @insr_i8( %a, i8 %b) {
+; CHECK-LABEL: insr_i8:
+; CHECK: insr z0.b, w0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.insr.nxv16i8( %a, i8 %b)
+  ret  %out
+}
+
+define  @insr_i16( %a, i16 %b) {
+; CHECK-LABEL: insr_i16:
+; CHECK: insr z0.h, w0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.insr.nxv8i16( %a, i16 %b)
+  ret  %out
+}
+
+define  @insr_i32( %a, i32 %b

[PATCH] D70829: [ARM][MVE][Intrinsics] Add VMINQ/VMAXQ/VMINNMQ/VMAXNMQ intrinsics.

2019-12-02 Thread Mark Murray via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG510792a2e0e3: [ARM][MVE][Intrinsics] Add 
VMINQ/VMAXQ/VMINNMQ/VMAXNMQ intrinsics. (authored by MarkMurrayARM).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70829

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/test/CodeGen/arm-mve-intrinsics/vmaxnmq.c
  clang/test/CodeGen/arm-mve-intrinsics/vmaxq.c
  clang/test/CodeGen/arm-mve-intrinsics/vminnmq.c
  clang/test/CodeGen/arm-mve-intrinsics/vminq.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vminq.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vminq.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vminq.ll
@@ -0,0 +1,89 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define dso_local arm_aapcs_vfpcc <16 x i8> @test_vminq_u8(<16 x i8> %a, <16 x i8> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vminq_u8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmin.u8 q0, q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = icmp ugt <16 x i8> %a, %b
+  %1 = select <16 x i1> %0, <16 x i8> %b, <16 x i8> %a
+  ret <16 x i8> %1
+}
+
+define dso_local arm_aapcs_vfpcc <8 x i16> @test_vminq_s16(<8 x i16> %a, <8 x i16> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vminq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmin.s16 q0, q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = icmp sgt <8 x i16> %a, %b
+  %1 = select <8 x i1> %0, <8 x i16> %b, <8 x i16> %a
+  ret <8 x i16> %1
+}
+
+define dso_local arm_aapcs_vfpcc <4 x i32> @test_vminq_u32(<4 x i32> %a, <4 x i32> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vminq_u32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmin.u32 q0, q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = icmp ugt <4 x i32> %a, %b
+  %1 = select <4 x i1> %0, <4 x i32> %b, <4 x i32> %a
+  ret <4 x i32> %1
+}
+
+define dso_local arm_aapcs_vfpcc <16 x i8> @test_vminq_m_s8(<16 x i8> %inactive, <16 x i8> %a, <16 x i8> %b, i16 zeroext %p) local_unnamed_addr #1 {
+; CHECK-LABEL: test_vminq_m_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vmint.s8 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %0)
+  %2 = tail call <16 x i8> @llvm.arm.mve.min.predicated.v16i8.v16i1(<16 x i8> %a, <16 x i8> %b, <16 x i1> %1, <16 x i8> %inactive)
+  ret <16 x i8> %2
+}
+
+declare <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32) #2
+
+declare <16 x i8> @llvm.arm.mve.min.predicated.v16i8.v16i1(<16 x i8>, <16 x i8>, <16 x i1>, <16 x i8>) #2
+
+define dso_local arm_aapcs_vfpcc <8 x i16> @test_vminq_m_u16(<8 x i16> %inactive, <8 x i16> %a, <8 x i16> %b, i16 zeroext %p) local_unnamed_addr #1 {
+; CHECK-LABEL: test_vminq_m_u16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vmint.s16 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = tail call <8 x i16> @llvm.arm.mve.min.predicated.v8i16.v8i1(<8 x i16> %a, <8 x i16> %b, <8 x i1> %1, <8 x i16> %inactive)
+  ret <8 x i16> %2
+}
+
+declare <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32) #2
+
+declare <8 x i16> @llvm.arm.mve.min.predicated.v8i16.v8i1(<8 x i16>, <8 x i16>, <8 x i1>, <8 x i16>) #2
+
+define dso_local arm_aapcs_vfpcc <4 x i32> @test_vminq_m_s32(<4 x i32> %inactive, <4 x i32> %a, <4 x i32> %b, i16 zeroext %p) local_unnamed_addr #1 {
+; CHECK-LABEL: test_vminq_m_s32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vmint.s32 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %0)
+  %2 = tail call <4 x i32> @llvm.arm.mve.min.predicated.v4i32.v4i1(<4 x i32> %a, <4 x i32> %b, <4 x i1> %1, <4 x i32> %inactive)
+  ret <4 x i32> %2
+}
+
+declare <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32) #2
+
+declare <4 x i32> @llvm.arm.mve.min.predicated.v4i32.v4i1(<4 x i32>, <4 x i32>, <4 x i1>, <4 x i32>) #2
Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmq.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmq.ll
@@ -0,0 +1,62 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machine

[PATCH] D70829: [ARM][MVE][Intrinsics] Add VMINQ/VMAXQ/VMINNMQ/VMAXNMQ intrinsics.

2019-12-02 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM marked an inline comment as done.
MarkMurrayARM added a comment.

Nit terminated with extreme prejudice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70829



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


[PATCH] D60455: [SYCL] Add sycl_kernel attribute for accelerated code outlining

2019-12-02 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon accepted this revision.
Fznamznon added a comment.

LGTM with a couple of minor comments.




Comment at: clang/include/clang/Basic/AttrDocs.td:273
+cgh.parallel_for(range<1>{1024}, [=](id<1> index) {
+  A[index] = index[0] * 2 + index[1] + foo(42);
+});

Sorry for late catch, but there is a little bug in this SYCL code: `index` is 
one-dimensional `id`, so calling subscript operator with any value other than 
`0` is a bug.



Comment at: clang/include/clang/Basic/AttrDocs.td:319
+- The function must have at least one parameter. The first parameter is
+  required to be a function object type (named or unnamed i.e. lambda).  The
+  compiler uses function object type fields to generate OpenCL kernel

There are two spaces between "." and "The" at the end of line 319.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



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


[PATCH] D70863: [clangd] Try harder to find a plausible `clang` as argv0, particularly on Mac.

2019-12-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

@kbobyrev would you mind testing this again?

Dropping an empty compile_flags.txt should also work (and test the other 
codepath)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70863



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


[PATCH] D70863: [clangd] Try harder to find a plausible `clang` as argv0, particularly on Mac.

2019-12-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 231674.
sammccall added a comment.
This revision is now accepted and ready to land.

Also add detected -isysroot on mac unless $SDKROOT is set.
Also add path to driver when bare driver name comes from CDB.
While here, address -resource-dir fixme.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70863

Files:
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
  clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp

Index: clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
===
--- clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
+++ clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
@@ -105,8 +105,9 @@
 TEST_F(OverlayCDBTest, GetFallbackCommand) {
   OverlayCDB CDB(Base.get(), {"-DA=4"});
   EXPECT_THAT(CDB.getFallbackCommand(testPath("bar.cc")).CommandLine,
-  ElementsAre("clang", "-DA=2", testPath("bar.cc"), "-DA=4",
-  "-fsyntax-only", StartsWith("-resource-dir")));
+  ElementsAre(EndsWith("clang"), "-DA=2", testPath("bar.cc"),
+  "-DA=4", "-fsyntax-only",
+  StartsWith("-resource-dir")));
 }
 
 TEST_F(OverlayCDBTest, NoBase) {
Index: clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
@@ -542,7 +542,7 @@
   FS.Files[testPath("A.h")] = "";
   Cmd.Filename = "../A.cc";
   Cmd.Directory = testPath("build");
-  Cmd.CommandLine = {"clang++", "../A.cc", "-fsyntax-only"};
+  Cmd.CommandLine = {"/bin/clang++", "../A.cc", "-fsyntax-only"};
   CDB.setCompileCommand(testPath("build/../A.cc"), Cmd);
   ASSERT_TRUE(Idx.blockUntilIdleForTest());
 
@@ -558,7 +558,7 @@
 
   // FIXME: Changing compile commands should be enough to invalidate the cache.
   FS.Files[testPath("A.cc")] = " ";
-  Cmd.CommandLine = {"clang++", "../A.cc", "-Dfoo", "-fsyntax-only"};
+  Cmd.CommandLine = {"/bin/clang++", "../A.cc", "-Dfoo", "-fsyntax-only"};
   CDB.setCompileCommand(testPath("build/../A.cc"), Cmd);
   ASSERT_TRUE(Idx.blockUntilIdleForTest());
 
Index: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
===
--- clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -18,7 +18,9 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
 #include 
 #include 
 #include 
@@ -27,6 +29,113 @@
 namespace clangd {
 namespace {
 
+// Query apple's `xcrun` launcher, which is the source of truth for "how should"
+// clang be invoked on this system.
+llvm::Optional queryXcrun(llvm::ArrayRef Argv) {
+  auto Xcrun = llvm::sys::findProgramByName("xcrun");
+  if (!Xcrun) {
+log("Couldn't find xcrun. Hopefully you have a non-apple toolchain...");
+return llvm::None;
+  }
+  llvm::SmallString<64> OutFile;
+  llvm::sys::fs::createTemporaryFile("clangd-xcrun", "", OutFile);
+  llvm::FileRemover OutRemover(OutFile);
+  llvm::Optional Redirects[3] = {
+  /*stdin=*/{""}, /*stdout=*/{OutFile}, /*stderr=*/{""}};
+  vlog("Invoking {0} to find clang installation", *Xcrun);
+  int Ret = llvm::sys::ExecuteAndWait(*Xcrun, Argv,
+  /*Env=*/llvm::None, Redirects,
+  /*SecondsToWait=*/10);
+  if (Ret != 0) {
+log("xcrun exists but failed with code {0}. "
+"If you have a non-apple toolchain, this is OK. "
+"Otherwise, try xcode-select --install.",
+Ret);
+return llvm::None;
+  }
+
+  auto Buf = llvm::MemoryBuffer::getFile(OutFile);
+  if (!Buf) {
+log("Can't read xcrun output: {0}", Buf.getError().message());
+return llvm::None;
+  }
+  StringRef Path = Buf->get()->getBuffer().trim();
+  if (Path.empty()) {
+log("xcrun produced no output");
+return llvm::None;
+  }
+  return Path.str();
+}
+
+// On Mac, `which clang` is /usr/bin/clang. It runs `xcrun clang`, which knows
+// where the real clang is kept. We need to do the same thing,
+// because cc1 (not the driver!) will find libc++ relative to argv[0].
+llvm::Optional queryMacClangPath() {
+#ifndef __APPLE__
+  return llvm::None;
+#endif
+
+  return queryXcrun({"xcrun", "--find", "clang"});
+}
+
+// Resolve symlinks if possible.
+std::string resolve(std::string Path) {
+  llvm::SmallString<128> Resolved;
+  if (llvm::sys::fs::real_path(Path, Resolved))
+return Path; // On error;
+

[PATCH] D60455: [SYCL] Add sycl_kernel attribute for accelerated code outlining

2019-12-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/SemaSYCL/kernel-attribute.cpp:4-5
+
+__attribute((sycl_kernel)) void foo() {
+}

bader wrote:
> aaron.ballman wrote:
> > aaron.ballman wrote:
> > > Missing some tests:
> > > * test that both attributes can be applied to whatever subjects they 
> > > appertain to
> > > * test that neither attribute can be applied to an incorrect subject
> > > * test that the attributes do not accept arguments
> > > * test that the attribute is ignored when SYCL is not enabled
> > > 
> > > Are there situations where the attribute does not make sense, such as 
> > > member functions, virtual functions, etc? If so, those are good test 
> > > cases (and diagnostics) to add as well.
> > Still missing a test that the attribute is ignored when SYCL is not enabled.
> > Still missing a test that the attribute is ignored when SYCL is not enabled.
> 
> I think clang/test/SemaSYCL/kernel-attribute-on-non-sycl.cpp should check 
> that. Please, let me know if you mean something else.
> 
> > This test should be on a templated function (we already demonstrated it 
> > only applies to templated functions, so the check for the argument is not 
> > what is failing).
> 
> Nice catch. Thanks!
> I think clang/test/SemaSYCL/kernel-attribute-on-non-sycl.cpp should check 
> that. Please, let me know if you mean something else.

Oh, you're correct, that was the test I was hoping for!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



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


[PATCH] D70073: [ConstExprPreter] Implemented function calls and if statements

2019-12-02 Thread Nandor Licker via Phabricator via cfe-commits
nand added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70073



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


[PATCH] D60455: [SYCL] Add sycl_kernel attribute for accelerated code outlining

2019-12-02 Thread Alexey Bader via Phabricator via cfe-commits
bader added a comment.

I hope all comments from are @Fznamznon and @aaron.ballman are applied.
@ABataev, do you have any other comments?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



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


[PATCH] D60455: [SYCL] Add sycl_kernel attribute for accelerated code outlining

2019-12-02 Thread Alexey Bader via Phabricator via cfe-commits
bader updated this revision to Diff 231679.
bader marked 2 inline comments as done.
bader added a comment.

Fixed SYCL code example for sycl_kernel attribute documentation and commit 
message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/SemaSYCL/kernel-attribute-on-non-sycl.cpp
  clang/test/SemaSYCL/kernel-attribute.cpp

Index: clang/test/SemaSYCL/kernel-attribute.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/kernel-attribute.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl-is-device -verify %s
+
+// Only function templates
+[[clang::sycl_kernel]] int gv2 = 0; // expected-warning {{'sycl_kernel' attribute only applies to function templates}}
+__attribute__((sycl_kernel)) int gv3 = 0; // expected-warning {{'sycl_kernel' attribute only applies to function templates}}
+
+__attribute__((sycl_kernel)) void foo(); // expected-warning {{'sycl_kernel' attribute only applies to function templates}}
+[[clang::sycl_kernel]] void foo1(); // expected-warning {{'sycl_kernel' attribute only applies to function templates}}
+
+// Attribute takes no arguments
+template 
+__attribute__((sycl_kernel(1))) void foo(T P); // expected-error {{'sycl_kernel' attribute takes no arguments}}
+template 
+[[clang::sycl_kernel(1)]] void foo1(T P);// expected-error {{'sycl_kernel' attribute takes no arguments}}
+
+// At least two template parameters
+template 
+__attribute__((sycl_kernel)) void foo(T P); // expected-warning {{'sycl_kernel' attribute only applies to a function template with at least two template parameters}}
+template 
+[[clang::sycl_kernel]] void foo1(T P); // expected-warning {{'sycl_kernel' attribute only applies to a function template with at least two template parameters}}
+
+// First two template parameters cannot be non-type template parameters
+template 
+__attribute__((sycl_kernel)) void foo(T P); // expected-warning {{template parameter of a function template with the 'sycl_kernel' attribute cannot be a non-type template parameter}}
+template 
+[[clang::sycl_kernel]] void foo1(T P); // expected-warning {{template parameter of a function template with the 'sycl_kernel' attribute cannot be a non-type template parameter}}
+
+// Must return void
+template 
+__attribute__((sycl_kernel)) int foo(T P); // expected-warning {{function template with 'sycl_kernel' attribute must have a 'void' return type}}
+template 
+[[clang::sycl_kernel]] int foo1(T P); // expected-warning {{function template with 'sycl_kernel' attribute must have a 'void' return type}}
+
+// Must take at least one argument
+template 
+__attribute__((sycl_kernel)) void foo(); // expected-warning {{function template with 'sycl_kernel' attribute must have a single parameter}}
+template 
+[[clang::sycl_kernel]] void foo1(T t, A a); // expected-warning {{function template with 'sycl_kernel' attribute must have a single parameter}}
+
+// No diagnostics
+template 
+__attribute__((sycl_kernel)) void foo(T P);
+template 
+[[clang::sycl_kernel]] void foo1(T P);
Index: clang/test/SemaSYCL/kernel-attribute-on-non-sycl.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/kernel-attribute-on-non-sycl.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl-is-device -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -x c++ %s
+
+#ifndef __SYCL_DEVICE_ONLY__
+// expected-warning@+7 {{'sycl_kernel' attribute ignored}}
+// expected-warning@+8 {{'sycl_kernel' attribute ignored}}
+#else
+// expected-no-diagnostics
+#endif
+
+template 
+__attribute__((sycl_kernel)) void foo(T P);
+template 
+[[clang::sycl_kernel]] void foo1(T P);
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -6412,6 +6412,45 @@
   D->addAttr(::new (S.Context) OpenCLAccessAttr(S.Context, AL));
 }
 
+static void handleSYCLKernelAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  // The 'sycl_kernel' attribute applies only to function templates.
+  const auto *FD = cast(D);
+  const FunctionTemplateDecl *FT = FD->getDescribedFunctionTemplate();
+  assert(FT && "Function template is expected");
+
+  // Function template must have at least two template parameters.
+  const TemplateParameterList *TL = FT->getTemplateParameters();
+  if (TL->size() < 2) {
+S.Diag(FT->getLocation(), diag::warn_sycl_kernel_num_of_template_params);
+return;
+  }
+
+  // Template parameters must be typenames.
+  for (unsigned I = 0; I < 2; ++I) {
+const NamedDecl *TParam = TL->getParam(I);
+if (isa(TParam)) {
+  S.Diag(FT->getLocation(),
+  

[PATCH] D70849: [AST] Traverse the class type loc inside the member pointer type loc.

2019-12-02 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang/include/clang/AST/RecursiveASTVisitor.h:1168
 DEF_TRAVERSE_TYPELOC(MemberPointerType, {
-  TRY_TO(TraverseType(QualType(TL.getTypePtr()->getClass(), 0)));
+  if (auto *TSI = TL.getClassTInfo())
+TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));

Our tests probably don't catch the case where it's null, right?
Could we add one? (Temporarily removing the check for null should be enough to 
trigger a crash here)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70849



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


[PATCH] D70740: [clangd] Find reference to template parameter in 'sizeof...' expression

2019-12-02 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Could you add another test for `findExplicitReferences` too? Those tests are 
right after `targetDecl`.
These two functions kinda duplicate each other a lot, but that's intentional - 
those two functions do a somewhat similar thing and we want to keep them in 
sync (put another way, we want to fix bugs in both simultaneously)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70740



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


[PATCH] D70863: [clangd] Try harder to find a plausible `clang` as argv0, particularly on Mac.

2019-12-02 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev accepted this revision.
kbobyrev added a comment.

In D70863#1764977 , @sammccall wrote:

> @kbobyrev would you mind testing this again?
>
> Dropping an empty compile_flags.txt should also work (and test the other 
> codepath)


I've tested again (and also with empty compile_flags.txt) and this works now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70863



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


[PATCH] D70437: [AArch64][SVE] Implement shift intrinsics

2019-12-02 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 231693.
kmclaughlin added a comment.

- Removed re-ordering of integer arithmetic & logical op intrinsic definitions 
in IntrinsicsAArch64.td


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

https://reviews.llvm.org/D70437

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-shifts.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-shifts.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-shifts.ll
@@ -0,0 +1,367 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
+
+;
+; ASR
+;
+
+define  @asr_i8( %pg,  %a,  %b) {
+; CHECK-LABEL: asr_i8:
+; CHECK: asr z0.b, p0/m, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asr.nxv16i8( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+define  @asr_i16( %pg,  %a,  %b) {
+; CHECK-LABEL: asr_i16:
+; CHECK: asr z0.h, p0/m, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asr.nxv8i16( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+define  @asr_i32( %pg,  %a,  %b) {
+; CHECK-LABEL: asr_i32:
+; CHECK: asr z0.s, p0/m, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asr.nxv4i32( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+define  @asr_i64( %pg,  %a,  %b) {
+; CHECK-LABEL: asr_i64:
+; CHECK: asr z0.d, p0/m, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asr.nxv2i64( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+define  @asr_wide_i8( %pg,  %a,  %b) {
+; CHECK-LABEL: asr_wide_i8:
+; CHECK: asr z0.b, p0/m, z0.b, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asr.wide.nxv16i8( %pg,
+ %a,
+ %b)
+  ret  %out
+}
+
+define  @asr_wide_i16( %pg,  %a,  %b) {
+; CHECK-LABEL: asr_wide_i16:
+; CHECK: asr z0.h, p0/m, z0.h, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asr.wide.nxv8i16( %pg,
+ %a,
+ %b)
+  ret  %out
+}
+
+define  @asr_wide_i32( %pg,  %a,  %b) {
+; CHECK-LABEL: asr_wide_i32:
+; CHECK: asr z0.s, p0/m, z0.s, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asr.wide.nxv4i32( %pg,
+ %a,
+ %b)
+  ret  %out
+}
+
+;
+; ASRD
+;
+
+define  @asrd_i8( %pg,  %a) {
+; CHECK-LABEL: asrd_i8:
+; CHECK: asrd z0.b, p0/m, z0.b, #1
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asrd.nxv16i8( %pg,
+ %a,
+i32 1)
+  ret  %out
+}
+
+define  @asrd_i16( %pg,  %a) {
+; CHECK-LABEL: asrd_i16:
+; CHECK: asrd z0.h, p0/m, z0.h, #2
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asrd.nxv8i16( %pg,
+ %a,
+i32 2)
+  ret  %out
+}
+
+define  @asrd_i32( %pg,  %a) {
+; CHECK-LABEL: asrd_i32:
+; CHECK: asrd z0.s, p0/m, z0.s, #31
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asrd.nxv4i32( %pg,
+ %a,
+i32 31)
+  ret  %out
+}
+
+define  @asrd_i64( %pg,  %a) {
+; CHECK-LABEL: asrd_i64:
+; CHECK: asrd z0.d, p0/m, z0.d, #64
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.asrd.nxv2i64( %pg,
+ %a,
+i32 64)
+  ret  %out
+}
+
+;
+; INSR
+;
+
+define  @insr_i8( %a, i8 %b) {
+; CHECK-LABEL: insr_i8:
+; CHECK: insr z0.b, w0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.insr.nxv16i8( %a, i8 %b)
+  ret  %out
+}
+
+define  @insr_i16( %a, i16 %b) {
+; CHECK-LABEL: insr_i16:
+; CHECK: insr z0.h, w0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.insr.nxv8i16( %a, i16 %b)
+  ret  %out
+}
+
+define  @insr_i32( %a, i32 

[clang] 6236496 - [OpenCL] Fix address space for implicit conversion (PR43145)

2019-12-02 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2019-12-02T14:20:15Z
New Revision: 62364965619bd7e8847418b21ec327a78bd1624c

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

LOG: [OpenCL] Fix address space for implicit conversion (PR43145)

Clang was creating a DerivedToBase ImplicitCastExpr that was also
casting between address spaces as part of the second step in the
standard conversion sequence.  Defer the address space conversion to
the third step in the sequence instead, such that we get a separate
ImplicitCastExpr for the address space conversion.

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

Added: 


Modified: 
clang/lib/Sema/SemaExprCXX.cpp
clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl

Removed: 




diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 67492a2cd463..9e5e49fa0f93 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -4095,9 +4095,26 @@ Sema::PerformImplicitConversion(Expr *From, QualType 
ToType,
 << From->getSourceRange();
 }
 
+// Defer address space conversion to the third conversion.
+QualType FromPteeType = From->getType()->getPointeeType();
+QualType ToPteeType = ToType->getPointeeType();
+QualType NewToType = ToType;
+if (!FromPteeType.isNull() && !ToPteeType.isNull() &&
+FromPteeType.getAddressSpace() != ToPteeType.getAddressSpace()) {
+  NewToType = Context.removeAddrSpaceQualType(ToPteeType);
+  NewToType = Context.getAddrSpaceQualType(NewToType,
+   FromPteeType.getAddressSpace());
+  if (ToType->isObjCObjectPointerType())
+NewToType = Context.getObjCObjectPointerType(NewToType);
+  else if (ToType->isBlockPointerType())
+NewToType = Context.getBlockPointerType(NewToType);
+  else
+NewToType = Context.getPointerType(NewToType);
+}
+
 CastKind Kind;
 CXXCastPath BasePath;
-if (CheckPointerConversion(From, ToType, Kind, BasePath, CStyle))
+if (CheckPointerConversion(From, NewToType, Kind, BasePath, CStyle))
   return ExprError();
 
 // Make sure we extend blocks if necessary.
@@ -4108,8 +4125,8 @@ Sema::PerformImplicitConversion(Expr *From, QualType 
ToType,
   From = E.get();
 }
 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers())
-  CheckObjCConversion(SourceRange(), ToType, From, CCK);
-From = ImpCastExprToType(From, ToType, Kind, VK_RValue, &BasePath, CCK)
+  CheckObjCConversion(SourceRange(), NewToType, From, CCK);
+From = ImpCastExprToType(From, NewToType, Kind, VK_RValue, &BasePath, CCK)
  .get();
 break;
   }

diff  --git a/clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl 
b/clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
index d5d369fa80bb..623d201c2180 100644
--- a/clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
+++ b/clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
@@ -69,3 +69,14 @@ void pr43145_3(int n) {
   // CHECK: bitcast i8 addrspace(4)* %add.ptr1 to %class.B2 addrspace(4)*
   // CHECK: call {{.*}} @_ZNU3AS42B26getRefEv
 }
+
+// Implicit conversion of derived to base.
+
+void functionWithBaseArgPtr(class B2 *b) {}
+void functionWithBaseArgRef(class B2 &b) {}
+
+void pr43145_4() {
+  Derived d;
+  functionWithBaseArgPtr(&d);
+  functionWithBaseArgRef(d);
+}



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


[PATCH] D70605: [OpenCL] Fix address space for implicit conversion (PR43145)

2019-12-02 Thread Sven van Haastregt via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG62364965619b: [OpenCL] Fix address space for implicit 
conversion (PR43145) (authored by svenvh).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70605

Files:
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl


Index: clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
===
--- clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
+++ clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
@@ -69,3 +69,14 @@
   // CHECK: bitcast i8 addrspace(4)* %add.ptr1 to %class.B2 addrspace(4)*
   // CHECK: call {{.*}} @_ZNU3AS42B26getRefEv
 }
+
+// Implicit conversion of derived to base.
+
+void functionWithBaseArgPtr(class B2 *b) {}
+void functionWithBaseArgRef(class B2 &b) {}
+
+void pr43145_4() {
+  Derived d;
+  functionWithBaseArgPtr(&d);
+  functionWithBaseArgRef(d);
+}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -4095,9 +4095,26 @@
 << From->getSourceRange();
 }
 
+// Defer address space conversion to the third conversion.
+QualType FromPteeType = From->getType()->getPointeeType();
+QualType ToPteeType = ToType->getPointeeType();
+QualType NewToType = ToType;
+if (!FromPteeType.isNull() && !ToPteeType.isNull() &&
+FromPteeType.getAddressSpace() != ToPteeType.getAddressSpace()) {
+  NewToType = Context.removeAddrSpaceQualType(ToPteeType);
+  NewToType = Context.getAddrSpaceQualType(NewToType,
+   FromPteeType.getAddressSpace());
+  if (ToType->isObjCObjectPointerType())
+NewToType = Context.getObjCObjectPointerType(NewToType);
+  else if (ToType->isBlockPointerType())
+NewToType = Context.getBlockPointerType(NewToType);
+  else
+NewToType = Context.getPointerType(NewToType);
+}
+
 CastKind Kind;
 CXXCastPath BasePath;
-if (CheckPointerConversion(From, ToType, Kind, BasePath, CStyle))
+if (CheckPointerConversion(From, NewToType, Kind, BasePath, CStyle))
   return ExprError();
 
 // Make sure we extend blocks if necessary.
@@ -4108,8 +4125,8 @@
   From = E.get();
 }
 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers())
-  CheckObjCConversion(SourceRange(), ToType, From, CCK);
-From = ImpCastExprToType(From, ToType, Kind, VK_RValue, &BasePath, CCK)
+  CheckObjCConversion(SourceRange(), NewToType, From, CCK);
+From = ImpCastExprToType(From, NewToType, Kind, VK_RValue, &BasePath, CCK)
  .get();
 break;
   }


Index: clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
===
--- clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
+++ clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
@@ -69,3 +69,14 @@
   // CHECK: bitcast i8 addrspace(4)* %add.ptr1 to %class.B2 addrspace(4)*
   // CHECK: call {{.*}} @_ZNU3AS42B26getRefEv
 }
+
+// Implicit conversion of derived to base.
+
+void functionWithBaseArgPtr(class B2 *b) {}
+void functionWithBaseArgRef(class B2 &b) {}
+
+void pr43145_4() {
+  Derived d;
+  functionWithBaseArgPtr(&d);
+  functionWithBaseArgRef(d);
+}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -4095,9 +4095,26 @@
 << From->getSourceRange();
 }
 
+// Defer address space conversion to the third conversion.
+QualType FromPteeType = From->getType()->getPointeeType();
+QualType ToPteeType = ToType->getPointeeType();
+QualType NewToType = ToType;
+if (!FromPteeType.isNull() && !ToPteeType.isNull() &&
+FromPteeType.getAddressSpace() != ToPteeType.getAddressSpace()) {
+  NewToType = Context.removeAddrSpaceQualType(ToPteeType);
+  NewToType = Context.getAddrSpaceQualType(NewToType,
+   FromPteeType.getAddressSpace());
+  if (ToType->isObjCObjectPointerType())
+NewToType = Context.getObjCObjectPointerType(NewToType);
+  else if (ToType->isBlockPointerType())
+NewToType = Context.getBlockPointerType(NewToType);
+  else
+NewToType = Context.getPointerType(NewToType);
+}
+
 CastKind Kind;
 CXXCastPath BasePath;
-if (CheckPointerConversion(From, ToType, Kind, BasePath, CStyle))
+if (CheckPointerConversion(From, NewToType, Kind, BasePath, CStyle))
   return ExprError();
 
 // Make sure we extend blocks if necessary.
@@ -4108,8 +4125,8 @@
   From = E.get();
 }
 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifi

[PATCH] D70902: Fix compatibility with python3 of clang-include-fixer.py

2019-12-02 Thread Yannack via Phabricator via cfe-commits
yannack created this revision.
yannack added a reviewer: bkramer.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

clang-include-fixer was recently updated to be python3-compatible.
However, an exception handling clause was improperly using the deprecated 
`message` property of Exception classes, so the code was not yet entirely 
python3-compatible.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70902

Files:
  clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py


Index: clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
===
--- clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
+++ clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
@@ -211,7 +211,7 @@
 InsertHeaderToVimBuffer(include_fixer_context, text)
 print("Added #include {0} for {1}.".format(selected, symbol))
   except Exception as error:
-print(error.message, file=sys.stderr)
+print(error, file=sys.stderr)
   return
 
 


Index: clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
===
--- clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
+++ clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
@@ -211,7 +211,7 @@
 InsertHeaderToVimBuffer(include_fixer_context, text)
 print("Added #include {0} for {1}.".format(selected, symbol))
   except Exception as error:
-print(error.message, file=sys.stderr)
+print(error, file=sys.stderr)
   return
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] dcf11c5 - [ARM][AArch64] Complex addition Neon intrinsics for Armv8.3-A

2019-12-02 Thread Victor Campos via cfe-commits

Author: Victor Campos
Date: 2019-12-02T14:38:39Z
New Revision: dcf11c5e86cee94ec649a7a31c5dd259f60579d6

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

LOG: [ARM][AArch64] Complex addition Neon intrinsics for Armv8.3-A

Summary:
Add support for vcadd_* family of intrinsics. This set of intrinsics is
available in Armv8.3-A.

The fp16 versions require the FP16 extension, which has been available
(opt-in) since Armv8.2-A.

Reviewers: t.p.northover

Reviewed By: t.p.northover

Subscribers: t.p.northover, kristof.beyls, hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 
clang/test/CodeGen/aarch64-neon-vcadd.c
clang/test/CodeGen/arm-neon-vcadd.c
llvm/test/CodeGen/AArch64/neon-vcadd.ll
llvm/test/CodeGen/ARM/neon-vcadd.ll

Modified: 
clang/include/clang/Basic/arm_neon.td
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/Basic/Targets/ARM.cpp
clang/lib/Basic/Targets/ARM.h
clang/lib/CodeGen/CGBuiltin.cpp
llvm/include/llvm/IR/IntrinsicsAArch64.td
llvm/include/llvm/IR/IntrinsicsARM.td
llvm/lib/Target/AArch64/AArch64InstrInfo.td
llvm/lib/Target/ARM/ARMInstrNEON.td

Removed: 




diff  --git a/clang/include/clang/Basic/arm_neon.td 
b/clang/include/clang/Basic/arm_neon.td
index b5e395c8103f..a4dc21b64311 100644
--- a/clang/include/clang/Basic/arm_neon.td
+++ b/clang/include/clang/Basic/arm_neon.td
@@ -1673,3 +1673,21 @@ let ArchGuard = "defined(__ARM_FEATURE_FP16FML) && 
defined(__aarch64__)" in {
   def VFMLAL_LANEQ_HIGH : SOpInst<"vfmlal_laneq_high", "(F>)(F>)F(FQ)I", 
"hQh", OP_FMLAL_LN_Hi>;
   def VFMLSL_LANEQ_HIGH : SOpInst<"vfmlsl_laneq_high", "(F>)(F>)F(FQ)I", 
"hQh", OP_FMLSL_LN_Hi>;
 }
+
+// v8.3-A Vector complex addition intrinsics
+let ArchGuard = "defined(__ARM_FEATURE_COMPLEX) && 
defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)" in {
+  def VCADD_ROT90_FP16   : SInst<"vcadd_rot90", "...", "h">;
+  def VCADD_ROT270_FP16  : SInst<"vcadd_rot270", "...", "h">;
+  def VCADDQ_ROT90_FP16  : SInst<"vcaddq_rot90", "QQQ", "h">;
+  def VCADDQ_ROT270_FP16 : SInst<"vcaddq_rot270", "QQQ", "h">;
+}
+let ArchGuard = "defined(__ARM_FEATURE_COMPLEX)" in {
+  def VCADD_ROT90   : SInst<"vcadd_rot90", "...", "f">;
+  def VCADD_ROT270  : SInst<"vcadd_rot270", "...", "f">;
+  def VCADDQ_ROT90  : SInst<"vcaddq_rot90", "QQQ", "f">;
+  def VCADDQ_ROT270 : SInst<"vcaddq_rot270", "QQQ", "f">;
+}
+let ArchGuard = "defined(__ARM_FEATURE_COMPLEX) && defined(__aarch64__)" in {
+  def VCADDQ_ROT90_FP64  : SInst<"vcaddq_rot90", "QQQ", "d">;
+  def VCADDQ_ROT270_FP64 : SInst<"vcaddq_rot270", "QQQ", "d">;
+}
\ No newline at end of file

diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index 5214f7c30ee0..cba3e3ada7ea 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -158,6 +158,7 @@ void AArch64TargetInfo::getTargetDefinesARMV82A(const 
LangOptions &Opts,
 
 void AArch64TargetInfo::getTargetDefinesARMV83A(const LangOptions &Opts,
 MacroBuilder &Builder) const {
+  Builder.defineMacro("__ARM_FEATURE_COMPLEX", "1");
   Builder.defineMacro("__ARM_FEATURE_JCVT", "1");
   // Also include the Armv8.2 defines
   getTargetDefinesARMV82A(Opts, Builder);

diff  --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index 437a77afdc99..be088e81cffe 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -580,6 +580,13 @@ void ARMTargetInfo::getTargetDefinesARMV82A(const 
LangOptions &Opts,
   getTargetDefinesARMV81A(Opts, Builder);
 }
 
+void ARMTargetInfo::getTargetDefinesARMV83A(const LangOptions &Opts,
+MacroBuilder &Builder) const {
+  // Also include the ARMv8.2-A defines
+  Builder.defineMacro("__ARM_FEATURE_COMPLEX", "1");
+  getTargetDefinesARMV82A(Opts, Builder);
+}
+
 void ARMTargetInfo::getTargetDefines(const LangOptions &Opts,
  MacroBuilder &Builder) const {
   // Target identification.
@@ -809,6 +816,11 @@ void ARMTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case llvm::ARM::ArchKind::ARMV8_2A:
 getTargetDefinesARMV82A(Opts, Builder);
 break;
+  case llvm::ARM::ArchKind::ARMV8_3A:
+  case llvm::ARM::ArchKind::ARMV8_4A:
+  case llvm::ARM::ArchKind::ARMV8_5A:
+getTargetDefinesARMV83A(Opts, Builder);
+break;
   }
 }
 

diff  --git a/clang/lib/Basic/Targets/ARM.h b/clang/lib/Basic/Targets/ARM.h
index ce87a6265934..9696a4404589 100644
--- a/clang/lib/Basic/Targets/ARM.h
+++ b/clang/lib/Basic/Targets/ARM.h
@@ -148,9 +148,10 @@ class LLVM_LIBRARY_VISIBILITY ARMTargetInfo : public 
TargetInfo {
 
   void getTargetDefinesARMV81

[PATCH] D70862: [ARM][AArch64] Complex addition Neon intrinsics for Armv8.3-A

2019-12-02 Thread Victor Campos via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdcf11c5e86ce: [ARM][AArch64] Complex addition Neon 
intrinsics for Armv8.3-A (authored by vhscampos).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70862

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/ARM.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-neon-vcadd.c
  clang/test/CodeGen/arm-neon-vcadd.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/ARM/ARMInstrNEON.td
  llvm/test/CodeGen/AArch64/neon-vcadd.ll
  llvm/test/CodeGen/ARM/neon-vcadd.ll

Index: llvm/test/CodeGen/ARM/neon-vcadd.ll
===
--- /dev/null
+++ llvm/test/CodeGen/ARM/neon-vcadd.ll
@@ -0,0 +1,54 @@
+; RUN: llc %s -mtriple=arm -mattr=+armv8.3-a,+fullfp16 -o - | FileCheck %s
+
+define <4 x half> @foo16x4_rot(<4 x half> %a, <4 x half> %b) {
+entry:
+; CHECK-LABEL: foo16x4_rot
+; CHECK-DAG: vcadd.f16 d{{[0-9]+}}, d{{[0-9]+}}, d{{[0-9]+}}, #90
+; CHECK-DAG: vcadd.f16 d{{[0-9]+}}, d{{[0-9]+}}, d{{[0-9]+}}, #270
+  %vcadd_rot90_v2.i = tail call <4 x half> @llvm.arm.neon.vcadd.rot90.v4f16(<4 x half> %a, <4 x half> %b)
+  %vcadd_rot270_v2.i = tail call <4 x half> @llvm.arm.neon.vcadd.rot270.v4f16(<4 x half> %a, <4 x half> %b)
+  %add = fadd <4 x half> %vcadd_rot90_v2.i, %vcadd_rot270_v2.i
+  ret <4 x half> %add
+}
+
+define <2 x float> @foo32x2_rot(<2 x float> %a, <2 x float> %b) {
+entry:
+; CHECK-LABEL: foo32x2_rot
+; CHECK-DAG: vcadd.f32 d{{[0-9]+}}, d{{[0-9]+}}, d{{[0-9]+}}, #90
+; CHECK-DAG: vcadd.f32 d{{[0-9]+}}, d{{[0-9]+}}, d{{[0-9]+}}, #270
+  %vcadd_rot90_v2.i = tail call <2 x float> @llvm.arm.neon.vcadd.rot90.v2f32(<2 x float> %a, <2 x float> %b)
+  %vcadd_rot270_v2.i = tail call <2 x float> @llvm.arm.neon.vcadd.rot270.v2f32(<2 x float> %a, <2 x float> %b)
+  %add = fadd <2 x float> %vcadd_rot90_v2.i, %vcadd_rot270_v2.i
+  ret <2 x float> %add
+}
+
+define <8 x half> @foo16x8_rot(<8 x half> %a, <8 x half> %b) {
+entry:
+; CHECK-LABEL: foo16x8_rot
+; CHECK-DAG: vcadd.f16 q{{[0-9]+}}, q{{[0-9]+}}, q{{[0-9]+}}, #90
+; CHECK-DAG: vcadd.f16 q{{[0-9]+}}, q{{[0-9]+}}, q{{[0-9]+}}, #270
+  %vcaddq_rot90_v2.i = tail call <8 x half> @llvm.arm.neon.vcadd.rot90.v8f16(<8 x half> %a, <8 x half> %b)
+  %vcaddq_rot270_v2.i = tail call <8 x half> @llvm.arm.neon.vcadd.rot270.v8f16(<8 x half> %a, <8 x half> %b)
+  %add = fadd <8 x half> %vcaddq_rot90_v2.i, %vcaddq_rot270_v2.i
+  ret <8 x half> %add
+}
+
+define <4 x float> @foo32x4_rot(<4 x float> %a, <4 x float> %b) {
+entry:
+; CHECK-LABEL: foo32x4_rot
+; CHECK-DAG: vcadd.f32 q{{[0-9]+}}, q{{[0-9]+}}, q{{[0-9]+}}, #90
+; CHECK-DAG: vcadd.f32 q{{[0-9]+}}, q{{[0-9]+}}, q{{[0-9]+}}, #270
+  %vcaddq_rot90_v2.i = tail call <4 x float> @llvm.arm.neon.vcadd.rot90.v4f32(<4 x float> %a, <4 x float> %b)
+  %vcaddq_rot270_v2.i = tail call <4 x float> @llvm.arm.neon.vcadd.rot270.v4f32(<4 x float> %a, <4 x float> %b)
+  %add = fadd <4 x float> %vcaddq_rot90_v2.i, %vcaddq_rot270_v2.i
+  ret <4 x float> %add
+}
+
+declare <4 x half> @llvm.arm.neon.vcadd.rot90.v4f16(<4 x half>, <4 x half>)
+declare <4 x half> @llvm.arm.neon.vcadd.rot270.v4f16(<4 x half>, <4 x half>)
+declare <2 x float> @llvm.arm.neon.vcadd.rot90.v2f32(<2 x float>, <2 x float>)
+declare <2 x float> @llvm.arm.neon.vcadd.rot270.v2f32(<2 x float>, <2 x float>)
+declare <8 x half> @llvm.arm.neon.vcadd.rot90.v8f16(<8 x half>, <8 x half>)
+declare <8 x half> @llvm.arm.neon.vcadd.rot270.v8f16(<8 x half>, <8 x half>)
+declare <4 x float> @llvm.arm.neon.vcadd.rot90.v4f32(<4 x float>, <4 x float>)
+declare <4 x float> @llvm.arm.neon.vcadd.rot270.v4f32(<4 x float>, <4 x float>)
Index: llvm/test/CodeGen/AArch64/neon-vcadd.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/neon-vcadd.ll
@@ -0,0 +1,67 @@
+; RUN: llc %s -mtriple=aarch64 -mattr=+v8.3a,+fullfp16 -o - | FileCheck %s
+
+define <4 x half> @foo16x4_rot(<4 x half> %a, <4 x half> %b) {
+entry:
+; CHECK-LABEL: foo16x4_rot
+; CHECK-DAG: fcadd v{{[0-9]+}}.4h, v{{[0-9]+}}.4h, v{{[0-9]+}}.4h, #90
+; CHECK-DAG: fcadd v{{[0-9]+}}.4h, v{{[0-9]+}}.4h, v{{[0-9]+}}.4h, #270
+  %vcadd_rot90_v2.i = tail call <4 x half> @llvm.aarch64.neon.vcadd.rot90.v4f16(<4 x half> %a, <4 x half> %b)
+  %vcadd_rot270_v2.i = tail call <4 x half> @llvm.aarch64.neon.vcadd.rot270.v4f16(<4 x half> %a, <4 x half> %b)
+  %add = fadd <4 x half> %vcadd_rot90_v2.i, %vcadd_rot270_v2.i
+  ret <4 x half> %add
+}
+
+define <2 x float> @foo32x2_rot(<2 x float> %a, <2 x float> %b) {
+entry:
+; CHECK-LABEL: foo32x2_rot
+; CHECK-DAG: fcadd v{{[0-9]+}}.2s, v{{[0-9]+}}.2s, v{{[0-9]+}}.2s, #90
+; CHECK-DAG: fcadd v{{[0-9]+}}.2s, v{{[0-9]+}}.2s, v

[PATCH] D70594: [clangd] Implement range patching heuristics for cross-file rename.

2019-12-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

High level comments based on offline discussion:

I think we want to define/formalize the concept of a near miss, to make precise 
the tradeoffs between false positives, false negatives, and implementability.
Not just at the individual level (an index occurrence vs a lexed occurrence) 
but at a whole-document level.
A possible definition, intuitively finding the locations where the indexed 
occurrences are now spelled:

- a near miss maps all of the **name** occurrences in the index onto a 
**subset** of the lexed occurrences. (names may refer to more than one thing)
- indexed occurrences must all be mapped. Result must be distinct, and preserve 
order. (Support only simple edits to ensure our mapping is robust)
- each indexed->lexed correspondence may change row or column but not both 
(increases chance our mapping is robust)

Then we can use a greedy algorithm to find a match (or memoized DFS to 
enumerate/compare all matches)

A good metric for comparing competing mappings might be the sum of the implied 
edit sizes between successive entries.
i.e. if the first three mappings are offset by 1 column down, and the last is 
offset by 2 columns down, then this implies an insertion of 1 line at the top 
of the file and 1 line between edits 3 and 4, for a total of 2.

subset is fine/good to handle as a special case - if the subset is small we 
don't want to find it by search.




Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:385
+  assert(std::is_sorted(Superset.begin(), Superset.end()));
+  auto ItSubset = Subset.begin();
+  auto ItSuperset = Superset.begin();

I think this is just 
return std::includes(Superset.begin, Superset.end(), Subset.begin(), 
Subset.end());
(probably clear enough to just inline to the callsite)



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:623
+  if (M == MatchType::Subset)
+return std::move(IndexOccurrences); // RVO is disallowed for parameters.
+  if (M == MatchType::NearMiss)

That doesn't mean you need std::move to get a move, it just means you can't 
avoid calling the move constructor.
https://godbolt.org/z/Rh-CvT


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70594



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


[PATCH] D70863: [clangd] Try harder to find a plausible `clang` as argv0, particularly on Mac.

2019-12-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D70863#1765042 , @kbobyrev wrote:

> In D70863#1764977 , @sammccall wrote:
>
> > @kbobyrev would you mind testing this again?
> >
> > Dropping an empty compile_flags.txt should also work (and test the other 
> > codepath)
>
>
> I've tested again (and also with empty compile_flags.txt) and this works now.


Woohoo, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70863



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


[PATCH] D70863: [clangd] Try harder to find a plausible `clang` as argv0, particularly on Mac.

2019-12-02 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG88bccded8fa1: [clangd] Try harder to find a plausible 
`clang` as argv0, particularly on Mac. (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70863

Files:
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
  clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp

Index: clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
===
--- clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
+++ clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
@@ -105,8 +105,9 @@
 TEST_F(OverlayCDBTest, GetFallbackCommand) {
   OverlayCDB CDB(Base.get(), {"-DA=4"});
   EXPECT_THAT(CDB.getFallbackCommand(testPath("bar.cc")).CommandLine,
-  ElementsAre("clang", "-DA=2", testPath("bar.cc"), "-DA=4",
-  "-fsyntax-only", StartsWith("-resource-dir")));
+  ElementsAre(EndsWith("clang"), "-DA=2", testPath("bar.cc"),
+  "-DA=4", "-fsyntax-only",
+  StartsWith("-resource-dir")));
 }
 
 TEST_F(OverlayCDBTest, NoBase) {
Index: clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
@@ -542,7 +542,7 @@
   FS.Files[testPath("A.h")] = "";
   Cmd.Filename = "../A.cc";
   Cmd.Directory = testPath("build");
-  Cmd.CommandLine = {"clang++", "../A.cc", "-fsyntax-only"};
+  Cmd.CommandLine = {"/bin/clang++", "../A.cc", "-fsyntax-only"};
   CDB.setCompileCommand(testPath("build/../A.cc"), Cmd);
   ASSERT_TRUE(Idx.blockUntilIdleForTest());
 
@@ -558,7 +558,7 @@
 
   // FIXME: Changing compile commands should be enough to invalidate the cache.
   FS.Files[testPath("A.cc")] = " ";
-  Cmd.CommandLine = {"clang++", "../A.cc", "-Dfoo", "-fsyntax-only"};
+  Cmd.CommandLine = {"/bin/clang++", "../A.cc", "-Dfoo", "-fsyntax-only"};
   CDB.setCompileCommand(testPath("build/../A.cc"), Cmd);
   ASSERT_TRUE(Idx.blockUntilIdleForTest());
 
Index: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
===
--- clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -18,7 +18,9 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
 #include 
 #include 
 #include 
@@ -27,6 +29,113 @@
 namespace clangd {
 namespace {
 
+// Query apple's `xcrun` launcher, which is the source of truth for "how should"
+// clang be invoked on this system.
+llvm::Optional queryXcrun(llvm::ArrayRef Argv) {
+  auto Xcrun = llvm::sys::findProgramByName("xcrun");
+  if (!Xcrun) {
+log("Couldn't find xcrun. Hopefully you have a non-apple toolchain...");
+return llvm::None;
+  }
+  llvm::SmallString<64> OutFile;
+  llvm::sys::fs::createTemporaryFile("clangd-xcrun", "", OutFile);
+  llvm::FileRemover OutRemover(OutFile);
+  llvm::Optional Redirects[3] = {
+  /*stdin=*/{""}, /*stdout=*/{OutFile}, /*stderr=*/{""}};
+  vlog("Invoking {0} to find clang installation", *Xcrun);
+  int Ret = llvm::sys::ExecuteAndWait(*Xcrun, Argv,
+  /*Env=*/llvm::None, Redirects,
+  /*SecondsToWait=*/10);
+  if (Ret != 0) {
+log("xcrun exists but failed with code {0}. "
+"If you have a non-apple toolchain, this is OK. "
+"Otherwise, try xcode-select --install.",
+Ret);
+return llvm::None;
+  }
+
+  auto Buf = llvm::MemoryBuffer::getFile(OutFile);
+  if (!Buf) {
+log("Can't read xcrun output: {0}", Buf.getError().message());
+return llvm::None;
+  }
+  StringRef Path = Buf->get()->getBuffer().trim();
+  if (Path.empty()) {
+log("xcrun produced no output");
+return llvm::None;
+  }
+  return Path.str();
+}
+
+// On Mac, `which clang` is /usr/bin/clang. It runs `xcrun clang`, which knows
+// where the real clang is kept. We need to do the same thing,
+// because cc1 (not the driver!) will find libc++ relative to argv[0].
+llvm::Optional queryMacClangPath() {
+#ifndef __APPLE__
+  return llvm::None;
+#endif
+
+  return queryXcrun({"xcrun", "--find", "clang"});
+}
+
+// Resolve symlinks if possible.
+std::string resolve(std::string Path) {
+  llvm::SmallString<128> Resolved;
+  if (llvm::sys::fs::real_path(Path, Resolved))
+return Path; // On error;
+  return Resolved.str();
+}
+
+// Get a plausible full `clang` path.
+// Thi

[clang-tools-extra] 88bccde - [clangd] Try harder to find a plausible `clang` as argv0, particularly on Mac.

2019-12-02 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2019-12-02T16:17:40+01:00
New Revision: 88bccded8fa169481fa367debf5ec615640635a1

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

LOG: [clangd] Try harder to find a plausible `clang` as argv0, particularly on 
Mac.

Summary:
Fixes https://github.com/clangd/clangd/issues/211
Fixes https://github.com/clangd/clangd/issues/178

No tests - this is hard to test, and basically impossible to verify what we want
(this produces compile commands that work on a real mac with recent toolchain)

(Need someone on mac to verify it actually fixes these!)

Reviewers: kbobyrev, ilya-biryukov

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp 
b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index ed3b86f0f55b..8e78fedf44bb 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -18,7 +18,9 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
 #include 
 #include 
 #include 
@@ -27,6 +29,113 @@ namespace clang {
 namespace clangd {
 namespace {
 
+// Query apple's `xcrun` launcher, which is the source of truth for "how 
should"
+// clang be invoked on this system.
+llvm::Optional queryXcrun(llvm::ArrayRef Argv) {
+  auto Xcrun = llvm::sys::findProgramByName("xcrun");
+  if (!Xcrun) {
+log("Couldn't find xcrun. Hopefully you have a non-apple toolchain...");
+return llvm::None;
+  }
+  llvm::SmallString<64> OutFile;
+  llvm::sys::fs::createTemporaryFile("clangd-xcrun", "", OutFile);
+  llvm::FileRemover OutRemover(OutFile);
+  llvm::Optional Redirects[3] = {
+  /*stdin=*/{""}, /*stdout=*/{OutFile}, /*stderr=*/{""}};
+  vlog("Invoking {0} to find clang installation", *Xcrun);
+  int Ret = llvm::sys::ExecuteAndWait(*Xcrun, Argv,
+  /*Env=*/llvm::None, Redirects,
+  /*SecondsToWait=*/10);
+  if (Ret != 0) {
+log("xcrun exists but failed with code {0}. "
+"If you have a non-apple toolchain, this is OK. "
+"Otherwise, try xcode-select --install.",
+Ret);
+return llvm::None;
+  }
+
+  auto Buf = llvm::MemoryBuffer::getFile(OutFile);
+  if (!Buf) {
+log("Can't read xcrun output: {0}", Buf.getError().message());
+return llvm::None;
+  }
+  StringRef Path = Buf->get()->getBuffer().trim();
+  if (Path.empty()) {
+log("xcrun produced no output");
+return llvm::None;
+  }
+  return Path.str();
+}
+
+// On Mac, `which clang` is /usr/bin/clang. It runs `xcrun clang`, which knows
+// where the real clang is kept. We need to do the same thing,
+// because cc1 (not the driver!) will find libc++ relative to argv[0].
+llvm::Optional queryMacClangPath() {
+#ifndef __APPLE__
+  return llvm::None;
+#endif
+
+  return queryXcrun({"xcrun", "--find", "clang"});
+}
+
+// Resolve symlinks if possible.
+std::string resolve(std::string Path) {
+  llvm::SmallString<128> Resolved;
+  if (llvm::sys::fs::real_path(Path, Resolved))
+return Path; // On error;
+  return Resolved.str();
+}
+
+// Get a plausible full `clang` path.
+// This is used in the fallback compile command, or when the CDB returns a
+// generic driver with no path.
+llvm::StringRef getFallbackClangPath() {
+  static const std::string &MemoizedFallbackPath = [&]() -> std::string {
+// The driver and/or cc1 sometimes depend on the binary name to compute
+// useful things like the standard library location.
+// We need to emulate what clang on this system is likely to see.
+// cc1 in particular looks at the "real path" of the running process, and
+// so if /usr/bin/clang is a symlink, it sees the resolved path.
+// clangd doesn't have that luxury, so we resolve symlinks ourselves.
+
+// /usr/bin/clang on a mac is a program that redirects to the right clang.
+// We resolve it as if it were a symlink.
+if (auto MacClang = queryMacClangPath())
+  return resolve(std::move(*MacClang));
+// On other platforms, just look for compilers on the PATH.
+for (const char* Name : {"clang", "gcc", "cc"})
+  if (auto PathCC = llvm::sys::findProgramByName(Name))
+return resolve(std::move(*PathCC));
+// Fallback: a nonexistent 'clang' 

[PATCH] D70594: [clangd] Implement range patching heuristics for cross-file rename.

2019-12-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/refactor/Rename.h:95
+  /// \p getBest, exposing for testing only.
+  static MatchType match(llvm::ArrayRef LHS, llvm::ArrayRef RHS);
+

Oops, forgot this...
I think the public API isn't quite right here - exposing parts for testing is 
fine, but the classification itself isn't fine grained enough I think. (Too 
easy to write a test that "passes" but the actual mapping found isn't the right 
one).

And the class structure wrapping a LangOpts ref seems like a detail that can be 
hidden.

I'd like to see:
 - a function that returns the lexed ranges from a StringRef/LangOpts
 - a function that constructs the mapping given two sequences of ranges (like 
`getMappedRanges(ArrayRef, ArrayRef) -> vector`
 - a function that ties these together to the data structures we care about 
(i.e. taking Code + identifier + LangOpts + ArrayRef or so)

then you can unit test the first and second and smoke test the third.

Tests like

```
Indexed = "int [[x]] = 0; void foo(int x);";
Draft = "double [[x]] = 0; void foo(double x);";
verifyRenameMatches(Indexed, Draft);
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70594



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


[PATCH] D69043: [RFC] Adding time-trace to LLD?

2019-12-02 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop added a comment.

I've re-implemented this using thread local time tracing.

Have broken the changes down into a couple of patches. First one doing some 
minor tidying up here (https://reviews.llvm.org/D70904).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69043



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


[PATCH] D70111: [DWARF5]Addition of alignment field in the typedef for dwarf5

2019-12-02 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Looks OK to me - please recommit when you're ready.


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

https://reviews.llvm.org/D70111



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


[PATCH] D70849: [AST] Traverse the class type loc inside the member pointer type loc.

2019-12-02 Thread Haojian Wu via Phabricator via cfe-commits
hokein marked an inline comment as done.
hokein added inline comments.



Comment at: clang/include/clang/AST/RecursiveASTVisitor.h:1168
 DEF_TRAVERSE_TYPELOC(MemberPointerType, {
-  TRY_TO(TraverseType(QualType(TL.getTypePtr()->getClass(), 0)));
+  if (auto *TSI = TL.getClassTInfo())
+TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));

ilya-biryukov wrote:
> Our tests probably don't catch the case where it's null, right?
> Could we add one? (Temporarily removing the check for null should be enough 
> to trigger a crash here)
I tried to add one for this, but failed to figure out a case that would trigger 
this code path (the existing tests are all passed if we remove this if guard 
check.)

any thoughts?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70849



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


[PATCH] D69620: Add AIX assembler support

2019-12-02 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 231712.
stevewan added a comment.

State in the comment the expectation to driver in handling assembler source 
input when invoking as(1).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69620

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/AIX.h
  clang/test/Driver/Inputs/aix_ppc_tree/dummy0.s
  clang/test/Driver/Inputs/aix_ppc_tree/dummy1.s
  clang/test/Driver/Inputs/aix_ppc_tree/dummy2.s
  clang/test/Driver/aix-as.c

Index: clang/test/Driver/aix-as.c
===
--- /dev/null
+++ clang/test/Driver/aix-as.c
@@ -0,0 +1,73 @@
+// General tests that as(1) invocations on AIX targets are sane. Note that we
+// only test assembler functionalities in this suite.
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit.
+// RUN: %clang -no-canonical-prefixes %s -### -c -o %t.o 2>&1 \
+// RUN: -target powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-AS32 %s
+// CHECK-AS32-NOT: warning:
+// CHECK-AS32: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-AS32: "{{.*}}as{{(.exe)?}}" 
+// CHECK-AS32: "-a32" 
+// CHECK-AS32: "-u" 
+// CHECK-AS32: "-many" 
+
+// Check powerpc64-ibm-aix7.1.0.0, 64-bit.
+// RUN: %clang -no-canonical-prefixes %s -### -c -o %t.o 2>&1 \
+// RUN: -target powerpc64-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-AS64 %s
+// CHECK-AS64-NOT: warning:
+// CHECK-AS64: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0"
+// CHECK-AS64: "{{.*}}as{{(.exe)?}}" 
+// CHECK-AS64: "-a64" 
+// CHECK-AS64: "-u" 
+// CHECK-AS64: "-many"
+
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit. -Xassembler  option. 
+// RUN: %clang -no-canonical-prefixes %s -### -c -o %t.o 2>&1 \
+// RUN: -Xassembler -w \
+// RUN: -target powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-AS32-Xassembler %s
+// CHECK-AS32-Xassembler-NOT: warning:
+// CHECK-AS32-Xassembler: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-AS32-Xassembler: "{{.*}}as{{(.exe)?}}" 
+// CHECK-AS32-Xassembler: "-a32" 
+// CHECK-AS32-Xassembler: "-u" 
+// CHECK-AS32-Xassembler: "-many"
+// CHECK-AS32-Xassembler: "-w"
+
+// Check powerpc64-ibm-aix7.1.0.0, 64-bit. -Wa,, option.
+// RUN: %clang -no-canonical-prefixes %s -### -c -o %t.o 2>&1 \
+// RUN: -Wa,-v,-w \
+// RUN: -target powerpc64-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-AS64-Wa %s
+// CHECK-AS64-Wa-NOT: warning:
+// CHECK-AS64-Wa: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0"
+// CHECK-AS64-Wa: "{{.*}}as{{(.exe)?}}" 
+// CHECK-AS64-Wa: "-a64" 
+// CHECK-AS64-Wa: "-u" 
+// CHECK-AS64-Wa: "-many"
+// CHECK-AS64-Wa: "-v"
+// CHECK-AS64-Wa: "-w"
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit. Multiple input files.
+// RUN: %clang -no-canonical-prefixes -### -c \
+// RUN: %S/Inputs/aix_ppc_tree/dummy0.s \
+// RUN: %S/Inputs/aix_ppc_tree/dummy1.s \
+// RUN: %S/Inputs/aix_ppc_tree/dummy2.s 2>&1 \
+// RUN: -target powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-AS32-MultiInput %s
+// CHECK-AS32-MultiInput-NOT: warning:
+// CHECK-AS32-MultiInput: "{{.*}}as{{(.exe)?}}"
+// CHECK-AS32-MultiInput: "-a32"
+// CHECK-AS32-MultiInput: "-u"
+// CHECK-AS32-MultiInput: "-many"
+// CHECK-AS32-MultiInput: "{{.*}}as{{(.exe)?}}"
+// CHECK-AS32-MultiInput: "-a32"
+// CHECK-AS32-MultiInput: "-u"
+// CHECK-AS32-MultiInput: "-many"
+// CHECK-AS32-MultiInput: "{{.*}}as{{(.exe)?}}"
+// CHECK-AS32-MultiInput: "-a32"
+// CHECK-AS32-MultiInput: "-u"
+// CHECK-AS32-MultiInput: "-many"
Index: clang/lib/Driver/ToolChains/AIX.h
===
--- clang/lib/Driver/ToolChains/AIX.h
+++ clang/lib/Driver/ToolChains/AIX.h
@@ -16,10 +16,21 @@
 namespace driver {
 namespace tools {
 
-/// aix -- Directly call system default linker.
-// TODO: Enable direct call to system default assembler.
+/// aix -- Directly call system default assembler and linker.
 namespace aix {
 
+class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
+public:
+  Assembler(const ToolChain &TC) : Tool("aix::Assembler", "assembler", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+
+  void ConstructJob(Compilation &C, const JobAction &JA,
+const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::opt::ArgList &TCArgs,
+const char *LinkingOutput) const override;
+};
+
 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
 public:
   Linker(const ToolChain &TC) : Tool("aix::Linker", "linker", TC) {}
@@ -53,6 +64,7 @@
   bool isPICDefaultForced() const override { return true; }
 
 protected:
+  Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
 };
 
Index: clang/lib/D

[PATCH] D70857: [llvm][Support] Take in CurrentDirectory as a parameter in ExpandResponseFiles

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



Comment at: llvm/include/llvm/Support/CommandLine.h:1972
+/// \param [in] CurrentDir Path used to resolve relative rsp files when \p
+/// RelativeNames is set to true, when set to None, process' cwd is used
+/// instead.

This seems confusing.
Suppose we have `@x/a`, which includes `@y/b`

Relative=true, CurrentDir=none: we read ./x/y/b
Relative=true, CurrentDir=foo: we read foo/x/y/b
Relative=false, CurrentDir=none: we read ./y/b
Relative=false, CurrentDir=foo: we read... ./y/b?

Seems like it would be clearer to just say relative paths are relative to this 
directory, so the last one would be foo/y/b.

Actually looking at the code, I think that's what you implemented?



Comment at: llvm/lib/Support/CommandLine.cpp:1105
+SmallString<128> ResponseFile;
+llvm::sys::path::append(ResponseFile, "@", BasePath, FileName);
+Arg = Saver.save(ResponseFile.c_str()).data();

This is @/BasePath I think (args are segments).

(I think this means you were running the wrong tests)



Comment at: llvm/lib/Support/CommandLine.cpp:1183
 ExpandResponseFile(FName, Saver, Tokenizer, ExpandedArgv, MarkEOLs,
-   RelativeNames, FS)) {
+   RelativeNames, FS, CurrentDir)) {
   // We couldn't read this file, so we leave it in the argument stream and

this is subtle, consider a comment: CurrentDir is only relevant for "top-level" 
expansions || !RelativeNames, but nested ones always have absolute paths if 
RelativeNames so CurrentDir is ignored.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70857



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


[PATCH] D70905: Actually delay processing DelayedDllExportClasses until the outermost class is finished (PR40006)

2019-12-02 Thread Hans Wennborg via Phabricator via cfe-commits
hans created this revision.
hans added reviewers: rnk, rsmith.

This was already the intention of DelayedDllExportClasses, but this test case 
would break it:

  template struct Tmpl {};
  struct Outer {
  struct Inner {
  __declspec(dllexport) Inner() = default;
  unsigned int x = 0;
  };
  Tmpl y;
  };

ActOnFinishCXXNonNestedClass() would get called when the instantiation of 
Templ is finished, even though the compiler is still not finished with 
Outer, causing the compile fail.

This hooks into Sema::{Push,Pop}ParsingClass() to avoid calling 
ActOnFinishCXXNonNestedClass() for template instantiations while a class is 
being parsed.

This was the cleanest solution I could come up with :-)


https://reviews.llvm.org/D70905

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/CodeGenCXX/dllexport.cpp


Index: clang/test/CodeGenCXX/dllexport.cpp
===
--- clang/test/CodeGenCXX/dllexport.cpp
+++ clang/test/CodeGenCXX/dllexport.cpp
@@ -860,6 +860,20 @@
 };
 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc 
%"struct.InClassInits::PR40006"* @"??0PR40006@InClassInits@@QAE@XZ"
 
+namespace pr40006 {
+// Delay emitting the method also past the instantiation of Tmpl, i.e.
+// until the top-level class Outer is completely finished.
+template struct Tmpl {};
+struct Outer {
+struct Inner {
+__declspec(dllexport) Inner() = default;
+unsigned int x = 0;
+};
+Tmpl y;
+};
+// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc 
%"struct.InClassInits::pr40006::Outer::Inner"* 
@"??0Inner@Outer@pr40006@InClassInits@@QAE@XZ"
+}
+
 // PR42857: Clang would try to emit the non-trivial explicitly defaulted
 // dllexport ctor twice when doing an explicit instantiation definition.
 struct Qux { Qux(); };
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2226,8 +2226,10 @@
   CheckCompletedCXXClass(Instantiation);
 
   // Default arguments are parsed, if not instantiated. We can go instantiate
-  // default arg exprs for default constructors if necessary now.
-  ActOnFinishCXXNonNestedClass(Instantiation);
+  // default arg exprs for default constructors if necessary now. Unless we're
+  // parsing a class, in which case wait until that's finished.
+  if (ParsingClassDepth == 0)
+ActOnFinishCXXNonNestedClass(Instantiation);
 
   // Instantiate late parsed attributes, and attach them to their decls.
   // See Sema::InstantiateAttrs
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -4335,9 +4335,11 @@
 
   typedef ProcessingContextState ParsingClassState;
   ParsingClassState PushParsingClass() {
+ParsingClassDepth++;
 return DelayedDiagnostics.pushUndelayed();
   }
   void PopParsingClass(ParsingClassState state) {
+ParsingClassDepth--;
 DelayedDiagnostics.popUndelayed(state);
   }
 
@@ -11544,6 +11546,8 @@
   SmallVector DelayedDllExportMemberFunctions;
 
 private:
+  int ParsingClassDepth = 0;
+
   class SavePendingParsedClassStateRAII {
   public:
 SavePendingParsedClassStateRAII(Sema &S) : S(S) { swapSavedState(); }
@@ -11553,8 +11557,6 @@
  "there shouldn't be any pending delayed exception spec checks");
   assert(S.DelayedEquivalentExceptionSpecChecks.empty() &&
  "there shouldn't be any pending delayed exception spec checks");
-  assert(S.DelayedDllExportClasses.empty() &&
- "there shouldn't be any pending delayed DLL export classes");
   swapSavedState();
 }
 
@@ -11564,14 +11566,12 @@
 SavedOverridingExceptionSpecChecks;
 decltype(DelayedEquivalentExceptionSpecChecks)
 SavedEquivalentExceptionSpecChecks;
-decltype(DelayedDllExportClasses) SavedDllExportClasses;
 
 void swapSavedState() {
   SavedOverridingExceptionSpecChecks.swap(
   S.DelayedOverridingExceptionSpecChecks);
   SavedEquivalentExceptionSpecChecks.swap(
   S.DelayedEquivalentExceptionSpecChecks);
-  SavedDllExportClasses.swap(S.DelayedDllExportClasses);
 }
   };
 


Index: clang/test/CodeGenCXX/dllexport.cpp
===
--- clang/test/CodeGenCXX/dllexport.cpp
+++ clang/test/CodeGenCXX/dllexport.cpp
@@ -860,6 +860,20 @@
 };
 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc %"struct.InClassInits::PR40006"* @"??0PR40006@InClassInits@@QAE@XZ"
 
+namespace pr40006 {
+// Delay emitting the method also past the instantiation of Tmpl, i.e.
+// until the top-level class Outer is completely finished.
+template struct Tmpl {};
+struct Outer {
+struct Inner {
+__declspec(dllexport)

[PATCH] D70183: Detect source location overflow due includes

2019-12-02 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

> clang shall either die due an assert in debug [...]

I think I have already mentioned the reasons why I don't think this is 
acceptable:

- it would break tests, as they are usually run with enabled assertions (and 
since this diagnostic is quite easy to test, it should be tested)
- it would make the code harder to debug (i.e. if someone finds another problem 
related to large includes, they would first need to fix the failing assertions 
before they could start debugging their problem)

IMHO we should discuss this in person, that would be quicker.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70183



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


[PATCH] D70489: [clangd] Add xref for macro to static index.

2019-12-02 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

btw, could you measure the increasing size of the index with this patch?

You could run

  ./bin/clangd-indexer -format=binary -executor=all-TUs . > static-index.idx
  ./bin/dexp static-index.idx
  # you will see the memory usage.




Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:532
+  const IdentifierInfo *II = MacroRef.first;
+  if (const auto *MI = PP->getMacroDefinition(II).getMacroInfo())
+if (auto ID = getSymbolID(II->getName(), MI, PP->getSourceManager())) {

usaxena95 wrote:
> hokein wrote:
> > I'm curious of the behavior `getMacroDefinition` -- from its 
> > implementation, if `II` doesn't have macro definition, it just returns 
> > empty.
> > 
> > could you check whether it works at the below case (or even with a same 
> > macro name defined/undef multiple times)?
> > 
> > ```
> > #define abc 1
> > #undef abc
> > 
> > // not at the EOF, I guess, II for `abc` doesn't have macro definition at 
> > this point because it has been undef?
> > ```
> I had a FIXME in the tests for this case. I see why there was no macro 
> definition at that point. I guess it would be better to keep the symbol id  
> instead of the II.
sorry, I didn't see a FIXME in the test, am I missing anything? Maybe move the 
FIXME to here?



Comment at: clang-tools-extra/clangd/index/SymbolCollector.h:76
 /// macro even if this is true.
 bool CollectMacro = false;
 /// Collect symbols local to main-files, such as static functions

usaxena95 wrote:
> hokein wrote:
> > This option is for macro symbols, I'd not use it for collecting macro 
> > references. I think the whether to collect macro references is judged by 
> > `RefFilter` and `RefsInHeaders`. 
> I see. `RefFilter` sounds right but I am don't think `RefsInHeaders` is the 
> correct one. It just tells whether to collect references from the included 
> header (i.e. outside mainfile) or not.
> I think it would be better to have a separate flag for macro references in 
> such case.
> WDYT ?
I don't think we need an extra flag merely for macro references. macro 
references should be treated in the same way of decl references.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70489



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


[PATCH] D70876: [clang-tidy] Add spuriously-wake-up-functions check

2019-12-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp:45-46
 "misc-redundant-expression");
+CheckFactories.registerCheck(
+"misc-spuriously-wake-up-functions");
 CheckFactories.registerCheck("misc-static-assert");

If we want to expose this check outside of the CERT module, I think it should 
go into `bugprone` rather than `misc`.



Comment at: 
clang-tools-extra/clang-tidy/misc/SpuriouslyWakeUpFunctionsCheck.cpp:62
+auto hasWaitDescendantC =
+hasDescendant(callExpr(callee(functionDecl(allOf(hasName("cnd_wait"),
+ 
parameterCountIs(2)

What about `cnd_timedwait`?



Comment at: 
clang-tools-extra/clang-tidy/misc/SpuriouslyWakeUpFunctionsCheck.h:19
+/// Finds ``cnd_wait`` or `wait` function calls in an ``IfStmt`` and tries to
+/// replace it with ``WhileStm``.
+///

WhileStm -> WhileStmt



Comment at: 
clang-tools-extra/test/clang-tidy/misc-spuriously-wake-up-functions.cpp:1
+// RUN: %check_clang_tidy %s misc-spuriously-wake-up-functions %t -- -- -I 
%S/../../../libcxx/include/
+

Eugene.Zelenko wrote:
> What will happen if libcxx is not part build/source tree?
Also, there are no tests for the C functionality yet.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D70876



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


[PATCH] D70485: [ARM,MVE] Add intrinsics to deal with predicates.

2019-12-02 Thread Simon Tatham via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd173fb5d2854: [ARM,MVE] Add intrinsics to deal with 
predicates. (authored by simon_tatham).

Changed prior to commit:
  https://reviews.llvm.org/D70485?vs=230627&id=231718#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70485

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/test/CodeGen/arm-mve-intrinsics/predicates.c
  clang/utils/TableGen/MveEmitter.cpp
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/predicates.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/predicates.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/predicates.ll
@@ -0,0 +1,219 @@
+; RUN: opt -instcombine %s | llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - | FileCheck %s
+
+declare <16 x i1> @llvm.arm.mve.vctp8(i32)
+declare <8 x i1> @llvm.arm.mve.vctp16(i32)
+declare <4 x i1> @llvm.arm.mve.vctp32(i32)
+declare <4 x i1> @llvm.arm.mve.vctp64(i32)
+
+declare i32 @llvm.arm.mve.pred.v2i.v4i1(<4 x i1>)
+declare i32 @llvm.arm.mve.pred.v2i.v8i1(<8 x i1>)
+declare i32 @llvm.arm.mve.pred.v2i.v16i1(<16 x i1>)
+
+declare <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32)
+declare <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32)
+declare <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32)
+
+define arm_aapcs_vfpcc zeroext i16 @test_vctp8q(i32 %a) {
+; CHECK-LABEL: test_vctp8q:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vctp.8 r0
+; CHECK-NEXT:vmrs r0, p0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = call <16 x i1> @llvm.arm.mve.vctp8(i32 %a)
+  %1 = call i32 @llvm.arm.mve.pred.v2i.v16i1(<16 x i1> %0)
+  %2 = trunc i32 %1 to i16
+  ret i16 %2
+}
+
+define arm_aapcs_vfpcc zeroext i16 @test_vctp8q_m(i32 %a, i16 zeroext %p) {
+; CHECK-LABEL: test_vctp8q_m:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r1
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vctpt.8 r0
+; CHECK-NEXT:vmrs r0, p0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %0)
+  %2 = call <16 x i1> @llvm.arm.mve.vctp8(i32 %a)
+  %3 = and <16 x i1> %1, %2
+  %4 = call i32 @llvm.arm.mve.pred.v2i.v16i1(<16 x i1> %3)
+  %5 = trunc i32 %4 to i16
+  ret i16 %5
+}
+
+define arm_aapcs_vfpcc zeroext i16 @test_vctp16q(i32 %a) {
+; CHECK-LABEL: test_vctp16q:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vctp.16 r0
+; CHECK-NEXT:vmrs r0, p0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = call <8 x i1> @llvm.arm.mve.vctp16(i32 %a)
+  %1 = call i32 @llvm.arm.mve.pred.v2i.v8i1(<8 x i1> %0)
+  %2 = trunc i32 %1 to i16
+  ret i16 %2
+}
+
+define arm_aapcs_vfpcc zeroext i16 @test_vctp16q_m(i32 %a, i16 zeroext %p) {
+; CHECK-LABEL: test_vctp16q_m:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r1
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vctpt.16 r0
+; CHECK-NEXT:vmrs r0, p0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = call <8 x i1> @llvm.arm.mve.vctp16(i32 %a)
+  %3 = and <8 x i1> %1, %2
+  %4 = call i32 @llvm.arm.mve.pred.v2i.v8i1(<8 x i1> %3)
+  %5 = trunc i32 %4 to i16
+  ret i16 %5
+}
+
+define arm_aapcs_vfpcc zeroext i16 @test_vctp32q(i32 %a) {
+; CHECK-LABEL: test_vctp32q:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vctp.32 r0
+; CHECK-NEXT:vmrs r0, p0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = call <4 x i1> @llvm.arm.mve.vctp32(i32 %a)
+  %1 = call i32 @llvm.arm.mve.pred.v2i.v4i1(<4 x i1> %0)
+  %2 = trunc i32 %1 to i16
+  ret i16 %2
+}
+
+define arm_aapcs_vfpcc zeroext i16 @test_vctp32q_m(i32 %a, i16 zeroext %p) {
+; CHECK-LABEL: test_vctp32q_m:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r1
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vctpt.32 r0
+; CHECK-NEXT:vmrs r0, p0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %0)
+  %2 = call <4 x i1> @llvm.arm.mve.vctp32(i32 %a)
+  %3 = and <4 x i1> %1, %2
+  %4 = call i32 @llvm.arm.mve.pred.v2i.v4i1(<4 x i1> %3)
+  %5 = trunc i32 %4 to i16
+  ret i16 %5
+}
+
+define arm_aapcs_vfpcc zeroext i16 @test_vctp64q(i32 %a) {
+; CHECK-LABEL: test_vctp64q:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vctp.64 r0
+; CHECK-NEXT:vmrs r0, p0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = call <4 x i1> @llvm.arm.mve.vctp64(i32 %a)
+  %1 = call i32 @llvm.arm.mve.pred.v2i.v4i1(<4 x i1> %0)
+  %2 = trunc i32 %1 to i16
+  ret i16 %2
+}
+
+define arm_aapcs_vfpcc zeroext i16 @test_vctp64q_m(i32 %a, i16 zeroext %p) {
+; CHECK-LABEL: test_vctp64q_m:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r1
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vctpt.64 r0
+; CHECK-NEXT:vmrs r0, p0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %

[clang] 3ebfab7 - Add AIX assembler support

2019-12-02 Thread David Tenty via cfe-commits

Author: stevewan
Date: 2019-12-02T11:29:36-05:00
New Revision: 3ebfab709583cfa7635693b123e56f76a1de765b

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

LOG: Add AIX assembler support

Summary:
A skeleton of AIX toolchain and system linker support has been introduced in 
D68340, and this is a follow on patch to it.
This patch adds support to system assembler invocation to the AIX toolchain.

Reviewers: daltenty, hubert.reinterpretcast, jasonliu, Xiangling_L, dlj

Reviewed By: daltenty, hubert.reinterpretcast

Subscribers: wuzish, nemanjai, kbarton, jfb, cfe-commits

Tags: #clang

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

Added: 
clang/test/Driver/Inputs/aix_ppc_tree/dummy0.s
clang/test/Driver/Inputs/aix_ppc_tree/dummy1.s
clang/test/Driver/Inputs/aix_ppc_tree/dummy2.s
clang/test/Driver/aix-as.c

Modified: 
clang/lib/Driver/ToolChains/AIX.cpp
clang/lib/Driver/ToolChains/AIX.h

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index 50450b7deb56..6fbff61f7656 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -20,6 +20,62 @@ using namespace clang::driver::tools;
 
 using namespace llvm::opt;
 
+void aix::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
+  const InputInfo &Output,
+  const InputInfoList &Inputs,
+  const ArgList &Args,
+  const char *LinkingOutput) const {
+  ArgStringList CmdArgs;
+
+  const bool IsArch32Bit = getToolChain().getTriple().isArch32Bit();
+  const bool IsArch64Bit = getToolChain().getTriple().isArch64Bit();
+  // Only support 32 and 64 bit.
+  if (!IsArch32Bit && !IsArch64Bit)
+llvm_unreachable("Unsupported bit width value.");
+
+  // Specify the mode in which the as(1) command operates.
+  if (IsArch32Bit) {
+CmdArgs.push_back("-a32");
+  } else {
+// Must be 64-bit, otherwise asserted already.
+CmdArgs.push_back("-a64");
+  }
+
+  // Accept an undefined symbol as an extern so that an error message is not
+  // displayed. Otherwise, undefined symbols are flagged with error messages.
+  // FIXME: This should be removed when the assembly generation from the
+  // compiler is able to write externs properly.
+  CmdArgs.push_back("-u");
+
+  // Accept any mixture of instructions.
+  // On Power for AIX and Linux, this behaviour matches that of GCC for both 
the
+  // user-provided assembler source case and the compiler-produced assembler
+  // source case. Yet XL with user-provided assembler source would not add 
this.
+  CmdArgs.push_back("-many");
+
+  Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, 
options::OPT_Xassembler);
+
+  // Specify assembler output file.
+  assert((Output.isFilename() || Output.isNothing()) && "Invalid output.");
+  if (Output.isFilename()) {
+CmdArgs.push_back("-o");
+CmdArgs.push_back(Output.getFilename());
+  }
+
+  // Specify assembler input file.
+  // The system assembler on AIX takes exactly one input file. The driver is
+  // expected to invoke as(1) separately for each assembler source input file.
+  if (Inputs.size() != 1)
+llvm_unreachable("Invalid number of input files.");
+  const InputInfo &II = Inputs[0];
+  assert((II.isFilename() || II.isNothing()) && "Invalid input.");
+  if (II.isFilename())
+CmdArgs.push_back(II.getFilename());
+
+  const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as"));
+  C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs));
+}
+
 void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output,
const InputInfoList &Inputs, const ArgList 
&Args,
@@ -42,7 +98,7 @@ void aix::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   if (Output.isFilename()) {
 CmdArgs.push_back("-o");
 CmdArgs.push_back(Output.getFilename());
-  } 
+  }
 
   // Set linking mode (i.e., 32/64-bit) and the address of
   // text and data sections based on arch bit width.
@@ -92,11 +148,12 @@ void aix::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
 
-/// AIX - AIX tool chain which can call ld(1) directly.
-// TODO: Enable direct call to as(1).
+/// AIX - AIX tool chain which can call as(1) and ld(1) directly.
 AIX::AIX(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
 : ToolChain(D, Triple, Args) {
   getFilePaths().push_back(getDriver().SysRoot + "/usr/lib");
 }
 
+auto AIX::buildAssembler() const -> Tool * { return new aix::Assembler(*this); 
}
+
 auto AIX::buildLinker() const

[PATCH] D61446: Generalize the pass registration mechanism used by Polly to any third-party tool

2019-12-02 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

In D61446#1763278 , @serge-sans-paille 
wrote:

> @Meinersbur I have a strange symbol issue when activating the GPu part: 
> https://github.com/serge-sans-paille/llvm-project/pull/2/checks?check_run_id=324901896#step:5:4888
>  Any hint?


I mentioned this already here: 
https://groups.google.com/d/msg/polly-dev/vxumPMhrSEs/uE7OfPojCwAJ

Polly uses `llvm::Linker`, which is not used in `opt` and hence thrown out when 
statically linking the `opt` executable. Try 
`-DLLVM_EXPORT_SYMBOLS_FOR_PLUGINS=ON`.

Note this never worked before, so you don't need to bother for this patch. It's 
what I think is a flaw in the plugin system with statically linked executables.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61446



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


[PATCH] D65591: [AST] Add a flag indicating if any subexpression had errors

2019-12-02 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

I would actually try to counter the type proposal and defend the 
`containsErrors` bit. Here's my thinking.

Not knowing that `int()` had errors inside can 
lead to situations with bad diagnostics.
We won't be able to suppress any non-type-related error, e.g. `int *a = 
int()` will probably complain that you can't 
assign an `int` to a pointer. This diagnostics is spurious, because 
`` might have actually evaluated to `0` and the 
users are better-off fixing the original error first and showing the other 
diagnostic is just noise.
The example might look a little contrived, but having an easy-to-use mechanism 
to suppress those errors is useful.

Expressions are not the only construct where we loose information. Something 
like `containsErrors` could generalize to types, template arguments, name 
qualifiers and other constructs that can potentially have valid sub-components, 
even if the compiler chooses to not produce them now due to semantic errors. 
This is forward-looking and I don't think we have concrete plans to make this 
happen, but it would be sad to go with a design that can't be extended to 
anything beyond expressions even theoretically.

Adding a new type, properly propagating it and checking for it in all places 
where we suppress diagnostics is a lot of work. `containsErrors` is a good way 
to incrementally find places that need to be tweaked and fix them to avoid 
producing extra diagnostics and running function that require well-formed ASTs. 
Having a new type seems like an all-or-nothing effort, i.e. one would have to 
spend considerable time building it and fixing everything that used to produce 
invalid expressions.
As for the lamda case: can we actually propagate `containsErrors` through 
lambdas? That probably means lifting this bit to the statement level, but that 
could definitely work. Knowing that lambda (or any other function, for that 
matter) produced an error somewhere inside its body actually looks like useful 
information and propagating it is not a lot of effort (in fact, I did try this 
and, while being more complicated than expressions, propagating this flag for 
statements seems doable).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65591



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


[PATCH] D69620: Add AIX assembler support

2019-12-02 Thread David Tenty via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3ebfab709583: Add AIX assembler support (authored by 
stevewan, committed by daltenty).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69620

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/AIX.h
  clang/test/Driver/Inputs/aix_ppc_tree/dummy0.s
  clang/test/Driver/Inputs/aix_ppc_tree/dummy1.s
  clang/test/Driver/Inputs/aix_ppc_tree/dummy2.s
  clang/test/Driver/aix-as.c

Index: clang/test/Driver/aix-as.c
===
--- /dev/null
+++ clang/test/Driver/aix-as.c
@@ -0,0 +1,73 @@
+// General tests that as(1) invocations on AIX targets are sane. Note that we
+// only test assembler functionalities in this suite.
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit.
+// RUN: %clang -no-canonical-prefixes %s -### -c -o %t.o 2>&1 \
+// RUN: -target powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-AS32 %s
+// CHECK-AS32-NOT: warning:
+// CHECK-AS32: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-AS32: "{{.*}}as{{(.exe)?}}" 
+// CHECK-AS32: "-a32" 
+// CHECK-AS32: "-u" 
+// CHECK-AS32: "-many" 
+
+// Check powerpc64-ibm-aix7.1.0.0, 64-bit.
+// RUN: %clang -no-canonical-prefixes %s -### -c -o %t.o 2>&1 \
+// RUN: -target powerpc64-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-AS64 %s
+// CHECK-AS64-NOT: warning:
+// CHECK-AS64: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0"
+// CHECK-AS64: "{{.*}}as{{(.exe)?}}" 
+// CHECK-AS64: "-a64" 
+// CHECK-AS64: "-u" 
+// CHECK-AS64: "-many"
+
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit. -Xassembler  option. 
+// RUN: %clang -no-canonical-prefixes %s -### -c -o %t.o 2>&1 \
+// RUN: -Xassembler -w \
+// RUN: -target powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-AS32-Xassembler %s
+// CHECK-AS32-Xassembler-NOT: warning:
+// CHECK-AS32-Xassembler: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-AS32-Xassembler: "{{.*}}as{{(.exe)?}}" 
+// CHECK-AS32-Xassembler: "-a32" 
+// CHECK-AS32-Xassembler: "-u" 
+// CHECK-AS32-Xassembler: "-many"
+// CHECK-AS32-Xassembler: "-w"
+
+// Check powerpc64-ibm-aix7.1.0.0, 64-bit. -Wa,, option.
+// RUN: %clang -no-canonical-prefixes %s -### -c -o %t.o 2>&1 \
+// RUN: -Wa,-v,-w \
+// RUN: -target powerpc64-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-AS64-Wa %s
+// CHECK-AS64-Wa-NOT: warning:
+// CHECK-AS64-Wa: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0"
+// CHECK-AS64-Wa: "{{.*}}as{{(.exe)?}}" 
+// CHECK-AS64-Wa: "-a64" 
+// CHECK-AS64-Wa: "-u" 
+// CHECK-AS64-Wa: "-many"
+// CHECK-AS64-Wa: "-v"
+// CHECK-AS64-Wa: "-w"
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit. Multiple input files.
+// RUN: %clang -no-canonical-prefixes -### -c \
+// RUN: %S/Inputs/aix_ppc_tree/dummy0.s \
+// RUN: %S/Inputs/aix_ppc_tree/dummy1.s \
+// RUN: %S/Inputs/aix_ppc_tree/dummy2.s 2>&1 \
+// RUN: -target powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=CHECK-AS32-MultiInput %s
+// CHECK-AS32-MultiInput-NOT: warning:
+// CHECK-AS32-MultiInput: "{{.*}}as{{(.exe)?}}"
+// CHECK-AS32-MultiInput: "-a32"
+// CHECK-AS32-MultiInput: "-u"
+// CHECK-AS32-MultiInput: "-many"
+// CHECK-AS32-MultiInput: "{{.*}}as{{(.exe)?}}"
+// CHECK-AS32-MultiInput: "-a32"
+// CHECK-AS32-MultiInput: "-u"
+// CHECK-AS32-MultiInput: "-many"
+// CHECK-AS32-MultiInput: "{{.*}}as{{(.exe)?}}"
+// CHECK-AS32-MultiInput: "-a32"
+// CHECK-AS32-MultiInput: "-u"
+// CHECK-AS32-MultiInput: "-many"
Index: clang/lib/Driver/ToolChains/AIX.h
===
--- clang/lib/Driver/ToolChains/AIX.h
+++ clang/lib/Driver/ToolChains/AIX.h
@@ -16,10 +16,21 @@
 namespace driver {
 namespace tools {
 
-/// aix -- Directly call system default linker.
-// TODO: Enable direct call to system default assembler.
+/// aix -- Directly call system default assembler and linker.
 namespace aix {
 
+class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
+public:
+  Assembler(const ToolChain &TC) : Tool("aix::Assembler", "assembler", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+
+  void ConstructJob(Compilation &C, const JobAction &JA,
+const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::opt::ArgList &TCArgs,
+const char *LinkingOutput) const override;
+};
+
 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
 public:
   Linker(const ToolChain &TC) : Tool("aix::Linker", "linker", TC) {}
@@ -53,6 +64,7 @@
   bool isPICDefaultForced() const override { return true; }
 
 protected:
+  Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
 };
 
Index: clang/lib

[PATCH] D70748: [clang test] Do not assume default target

2019-12-02 Thread Francis Visoiu Mistrih via Phabricator via cfe-commits
thegameg accepted this revision.
thegameg added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for fixing this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70748



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


[PATCH] D69740: [profile] Support counter relocation at runtime

2019-12-02 Thread Vedant Kumar via Phabricator via cfe-commits
vsk accepted this revision.
vsk added a comment.
This revision is now accepted and ready to land.

Lgtm with a small cleanup.




Comment at: llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp:674
+  if (isRuntimeCounterRelocationEnabled()) {
+Type *Int64Ty = Type::getInt64Ty(M->getContext());
+Type *Int64PtrTy = Type::getInt64PtrTy(M->getContext());

Could you lazily insert the bias load inside of `lowerIncrement`? That removes 
the need to delete the load when no increment is found.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69740



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


[PATCH] D70571: [Coverage] Emit a gap region to cover switch bodies

2019-12-02 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 231724.
vsk added a comment.

Add test case from PR44011.


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

https://reviews.llvm.org/D70571

Files:
  clang/docs/SourceBasedCodeCoverage.rst
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CoverageMapping/switch.cpp
  clang/test/CoverageMapping/switchmacro.c

Index: clang/test/CoverageMapping/switchmacro.c
===
--- clang/test/CoverageMapping/switchmacro.c
+++ clang/test/CoverageMapping/switchmacro.c
@@ -4,7 +4,7 @@
 
 // CHECK: foo
 int foo(int i) { // CHECK-NEXT: File 0, [[@LINE]]:16 -> {{[0-9]+}}:2 = #0
-  switch (i) {
+  switch (i) {   // CHECK-NEXT: Gap,File 0, [[@LINE]]:14 -> {{[0-9]+}}:11 = 0
   default:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> {{[0-9]+}}:11 = #2
 if (i == 1)  // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE]]:15 = #2
   return 0;  // CHECK: File 0, [[@LINE]]:7 -> [[@LINE]]:15 = #3
Index: clang/test/CoverageMapping/switch.cpp
===
--- clang/test/CoverageMapping/switch.cpp
+++ clang/test/CoverageMapping/switch.cpp
@@ -2,11 +2,11 @@
 
 // CHECK: foo
 void foo(int i) {   // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+8]]:2 = #0
-  switch(i) {
+  switch(i) {   // CHECK-NEXT: Gap,File 0, [[@LINE]]:13 -> [[@LINE+4]]:10 = 0
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:11 = #2
 return;
   case 2:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #3
-break;  // CHECK-NEXT: File 0, [[@LINE]]:10 -> [[@LINE+2]]:3 = #1
+break;  // CHECK-NEXT: Gap,File 0, [[@LINE]]:10 -> [[@LINE+2]]:3 = #1
   }
   int x = 0;// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:2 = #1
 }
@@ -29,7 +29,7 @@
 nop();
 
   switch (i) {  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+6]]:2 = #4
-nop();  // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE+2]]:10 = 0
+nop();  // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:14 -> [[@LINE+2]]:10 = 0
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #7
 nop();
   }
@@ -47,7 +47,7 @@
 // CHECK-NEXT: main
 int main() {// CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+35]]:2 = #0
   int i = 0;
-  switch(i) {
+  switch(i) {   // CHECK-NEXT: Gap,File 0, [[@LINE]]:13 -> [[@LINE+8]]:10 = 0
   case 0:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = #2
 i = 1;
 break;
@@ -58,16 +58,16 @@
 break;  // CHECK-NEXT: File 0, [[@LINE]]:10 -> [[@LINE+2]]:3 = #1
   }
   switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+23]]:2 = #1
-  case 0:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = #6
-i = 1;
+  case 0:   // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:13 -> [[@LINE+6]]:10 = 0
+i = 1;  // CHECK-NEXT: File 0, [[@LINE-1]]:3 -> [[@LINE+1]]:10 = #6
 break;
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:10 = #7
 i = 2;
   default:  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = (#7 + #8)
 break;  // CHECK-NEXT: File 0, [[@LINE]]:10 -> [[@LINE+3]]:3 = #5
   }
-
-  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+13]]:2 = #5
+// CHECK-NEXT: File 0, [[@LINE+1]]:3 -> [[@LINE+14]]:2 = #5
+  switch(i) {   // CHECK-NEXT: Gap,File 0, [[@LINE]]:13 -> [[@LINE+6]]:11 = 0
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+5]]:11 = #10
   case 2:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+4]]:11 = (#10 + #11)
 i = 11;
@@ -82,10 +82,23 @@
   return 0;
 }
 
+ // CHECK: pr44011
+int pr44011(int i) { // CHECK-NEXT: File 0, [[@LINE]]:20 -> {{.*}}:2 = #0
+  switch (i) {   // CHECK-NEXT: Gap,File 0, [[@LINE]]:14 -> [[@LINE+6]]:13 = 0
+
+  case 1:// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:13 = #2
+return 0;
+
+  default:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:13 = #3
+return 1;
+  }
+} // A region for counter #1 is missing due to the missing return.
+
+
 // FIXME: End location for "case 1" shouldn't point at the end of the switch.
  // CHECK: fallthrough
 int fallthrough(int i) { // CHECK-NEXT: File 0, [[@LINE]]:24 -> [[@LINE+12]]:2 = #0
-  switch(i) {
+  switch(i) {   // CHECK-NEXT: Gap,File 0, [[@LINE]]:13 -> [[@LINE+9]]:10 = 0
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+8]]:10 = #2
 i = 23;
   case 2:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = (#2 + #3)
@@ -101,7 +114,7 @@
 void abort(void) __attribute((noreturn));
// CHECK: noret
 int noret(int x) { // CHECK-NEXT: File 0, [[@LINE]]:18 -> [[@LINE+9]]:2
-  switch (x) {
+  switch (x) { // CHECK-NEXT: Gap,File 0, [[@LINE]]:14 -> [[@LINE+6]]:14 = 0
   default: // CHECK

[PATCH] D70819: [ASTImporter] Support functions with placeholder return types ...

2019-12-02 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 9 inline comments as done.
martong added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:3008
+// which is equal to the given DC.
+bool isAncestorDeclContextOf(DeclContext *DC, Decl *D) {
+  DeclContext *DCi = D->getDeclContext();

a_sidorin wrote:
>  ASTImporter is not very const-friendly, but this function is pure, so I 
> think it's better to const-qualify the parameters.
Ok, added the const qualifiers.



Comment at: clang/lib/AST/ASTImporter.cpp:3020
+  QualType FromTy = D->getType();
+  const FunctionProtoType *FromFPT = FromTy->getAs();
+  if (AutoType *AutoT = FromFPT->getReturnType()->getContainedAutoType()) {

a_sidorin wrote:
> Is it possible for getAs() to return nullptr at this point?
No. So, I added an assertion to reflect this.



Comment at: clang/lib/AST/ASTImporter.cpp:3174
+  bool UsedDifferentProtoType = false;
+  const auto *FromFPT = FromTy->getAs();
+  if (FromFPT) {

a_sidorin wrote:
> If FromFPT is not used outside of the condition, we can move the 
> initialization inside if().
Ok, I moved it inside the `if`.



Comment at: clang/unittests/AST/ASTImporterTest.cpp:5625
+  // parsed libcxx/src/filesystem/directory_iterator.cpp, but could not reduce
+  // that with creduce, because after preprocessing, the AST no longer
+  // contained the TypeAlias as a return type of the lambda.

a_sidorin wrote:
> That's interesting. Have you tried '-frewrite-includes' for expanding 
> inclusions only without macro expansion?
I hadn't tried it before, but I've just done that now. Unfortunately, the AST 
produced with `-E -frewrite-includes` produces a type for the operator() that 
already has a canonical type: `long (long) const`

```
) ./bin/clang-check -p cxx_cmd_json 
~w/llvm3/git/llvm-project/libcxx/src/filesystem/directory_iterator.cpp 
-ast-dump -ast-dump-filter "posix_utimes" | ag "CXXMethodDecl.*int_type"
   --- COMMAND ---
  |   | |-CXXMethodDecl 0x3007ec0  line:396:18 used 
operator() 'int_type (long) const' inline
  |   | |-CXXMethodDecl 0x30131f0  line:396:18 
implicit __invoke 'int_type (long)' static inline
  |   | |-CXXMethodDecl 0x2ddfaf0  line:396:18 used 
operator() 'int_type (long) const' inline
  |   | |-CXXMethodDecl 0x2deae20  line:396:18 
implicit __invoke 'int_type (long)' static inline
(venv) egbomrt@elx78373d5s|~/WORK/llvm3/build/release_assert
) ./bin/clang-check -p cxx_cmd_json 
~w/llvm3/git/llvm-project/libcxx/src/filesystem/directory_iterator.cpp 
-ast-dump -ast-dump-filter "posix_utimes" | ag "CXXMethodDecl.*operator"
  |   | |-CXXMethodDecl 0x2833020  line:396:18 used 
operator() 'int_type (long) const' inline
  |   | |-CXXMethodDecl 0x287fa20  line:396:18 used 
operator() 'int_type (long) const' inline
(venv) egbomrt@elx78373d5s|~/WORK/llvm3/build/release_assert
) ./bin/clang -x c++ directory_iterator.cpp.E.orig -fsyntax-only -Xclang 
-ast-dump -Xclang -ast-dump-filter -Xclang posix_utimes | ag 
"CXXMethodDecl.*operator"
  |   | |-CXXMethodDecl 0x31c6ad0  line:396:18 used 
operator() 'long (long) const' inline
(venv) egbomrt@elx78373d5s|~/WORK/llvm3/build/release_assert
) ./bin/clang -x c++ directory_iterator.cpp.E.ri -fsyntax-only -Xclang 
-ast-dump -Xclang -ast-dump-filter -Xclang posix_utimes | ag 
"CXXMethodDecl.*operator"
  |   | |-CXXMethodDecl 0x25ad7f0  line:396:18 used 
operator() 'long (long) const' inline
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70819



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


[PATCH] D70819: [ASTImporter] Support functions with placeholder return types ...

2019-12-02 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 231725.
martong marked 4 inline comments as done.
martong added a comment.

- Address Alexei's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70819

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

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -10,9 +10,11 @@
 //
 //===--===//
 
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "llvm/ADT/StringMap.h"
 
 #include "clang/AST/DeclContextInternals.h"
+#include "gtest/gtest.h"
 
 #include "ASTImporterFixtures.h"
 #include "MatchVerifier.h"
@@ -5599,6 +5601,113 @@
 2u);
 }
 
+struct ImportAutoFunctions : ASTImporterOptionSpecificTestBase {};
+
+TEST_P(ImportAutoFunctions, ReturnWithTypedefDeclaredInside) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  auto X = [](long l) {
+using int_type = long;
+auto dur = 13;
+return static_cast(dur);
+  };
+  )",
+  Lang_CXX14, "input0.cc");
+  CXXMethodDecl *From =
+  FirstDeclMatcher().match(FromTU, cxxMethodDecl());
+
+  // Explicitly set the return type of the lambda's operator() to the TypeAlias.
+  // Normally the return type would be the built-in 'long' type. However, there
+  // are cases when Clang does not use the canonical type and the TypeAlias is
+  // used. I could not create such an AST from regular source code, it requires
+  // some special state in the preprocessor. I've found such an AST when Clang
+  // parsed libcxx/src/filesystem/directory_iterator.cpp, but could not reduce
+  // that with creduce, because after preprocessing, the AST no longer
+  // contained the TypeAlias as a return type of the lambda.
+  ASTContext &Ctx = From->getASTContext();
+  TypeAliasDecl *FromTA =
+  FirstDeclMatcher().match(FromTU, typeAliasDecl());
+  QualType TT = Ctx.getTypedefType(FromTA);
+  const FunctionProtoType *FPT = cast(From->getType());
+  QualType NewFunType =
+  Ctx.getFunctionType(TT, FPT->getParamTypes(), FPT->getExtProtoInfo());
+  From->setType(NewFunType);
+
+  CXXMethodDecl *To = Import(From, Lang_CXX14);
+  EXPECT_TRUE(To);
+  EXPECT_TRUE(isa(To->getReturnType()));
+}
+
+TEST_P(ImportAutoFunctions, ReturnWithStructDeclaredInside) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  auto foo() {
+struct X {};
+return X();
+  }
+  )",
+  Lang_CXX14, "input0.cc");
+  FunctionDecl *From =
+  FirstDeclMatcher().match(FromTU, functionDecl());
+
+  FunctionDecl *To = Import(From, Lang_CXX14);
+  EXPECT_TRUE(To);
+  EXPECT_TRUE(isa(To->getReturnType()));
+}
+
+TEST_P(ImportAutoFunctions, ReturnWithStructDeclaredInside2) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  auto foo() {
+struct X {};
+return X();
+  }
+  )",
+  Lang_CXX14, "input0.cc");
+  FunctionDecl *From =
+  FirstDeclMatcher().match(FromTU, functionDecl());
+
+  // This time import the type directly.
+  QualType ToT = ImportType(From->getType(), From, Lang_CXX14);
+  const FunctionProtoType *FPT = cast(ToT);
+  EXPECT_TRUE(isa(FPT->getReturnType()));
+}
+
+TEST_P(ImportAutoFunctions, ReturnWithTypedefToStructDeclaredInside) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  auto foo() {
+struct X {};
+using Y = X;
+return Y();
+  }
+  )",
+  Lang_CXX14, "input0.cc");
+  FunctionDecl *From =
+  FirstDeclMatcher().match(FromTU, functionDecl());
+
+  FunctionDecl *To = Import(From, Lang_CXX14);
+  EXPECT_TRUE(To);
+  EXPECT_TRUE(isa(To->getReturnType()));
+}
+
+TEST_P(ImportAutoFunctions, ReturnWithStructDeclaredNestedInside) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  auto foo() {
+struct X { struct Y{}; };
+return X::Y();
+  }
+  )",
+  Lang_CXX14, "input0.cc");
+  FunctionDecl *From =
+  FirstDeclMatcher().match(FromTU, functionDecl());
+
+  FunctionDecl *To = Import(From, Lang_CXX14);
+  EXPECT_TRUE(To);
+  EXPECT_TRUE(isa(To->getReturnType()));
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
@@ -5626,6 +5735,9 @@
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFunctions,
 DefaultTestValuesForRunOptions, );
 
+INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportAutoFunctions,
+DefaultTestValuesForRunOptions, );
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFunctionTemplates,
 DefaultTestValuesForRunOptions, );
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -45,6 +4

[PATCH] D70819: [ASTImporter] Support functions with placeholder return types ...

2019-12-02 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Alexei, thanks for the assiduous review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70819



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


[PATCH] D69979: clang: Guess at some platform FTZ/DAZ default settings

2019-12-02 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 231726.
arsenm added a comment.

DAZ/FTZ seem to be set in crtfastmath.o, so try to reproduce the logic for 
linking that


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

https://reviews.llvm.org/D69979

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/Linux.h
  clang/lib/Driver/ToolChains/PS4CPU.h
  clang/test/Driver/default-denormal-fp-math.c

Index: clang/test/Driver/default-denormal-fp-math.c
===
--- /dev/null
+++ clang/test/Driver/default-denormal-fp-math.c
@@ -0,0 +1,19 @@
+// RUN: %clang -### -target arm-unknown-linux-gnu -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s
+// RUN: %clang -### -target i386-unknown-linux-gnu -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu --sysroot=%S/Inputs/basic_linux_tree -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s
+
+// crtfastmath enables ftz and daz
+// RUN: %clang -### -target x86_64-unknown-linux-gnu -ffast-math --sysroot=%S/Inputs/basic_linux_tree -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-ZEROSIGN %s
+
+// crt not linked in with nostartfiles
+// RUN: %clang -### -target x86_64-unknown-linux-gnu -ffast-math -nostartfiles --sysroot=%S/Inputs/basic_linux_tree -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s
+
+// If there's no crtfastmath, don't assume ftz/daz
+// RUN: %clang -### -target x86_64-unknown-linux-gnu -ffast-math --sysroot=/dev/null -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s
+
+// RUN: %clang -### -target x86_64-scei-ps4 -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-ZEROSIGN %s
+
+
+// CHECK-IEEE: -fdenormal-fp-math=ieee,ieee
+// CHECK-ZEROSIGN: -fdenormal-fp-math=preserve-sign,preserve-sign
Index: clang/lib/Driver/ToolChains/PS4CPU.h
===
--- clang/lib/Driver/ToolChains/PS4CPU.h
+++ clang/lib/Driver/ToolChains/PS4CPU.h
@@ -88,6 +88,14 @@
   // capable of unit splitting.
   bool canSplitThinLTOUnit() const override { return false; }
 
+  llvm::DenormalMode getDefaultDenormalModeForType(
+const llvm::opt::ArgList &DriverArgs,
+Action::OffloadKind DeviceOffloadKind,
+const llvm::fltSemantics *FPType) const override {
+// DAZ and FTZ are on by default.
+return llvm::DenormalMode::getPreserveSign();
+  }
+
 protected:
   Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
Index: clang/lib/Driver/ToolChains/Linux.h
===
--- clang/lib/Driver/ToolChains/Linux.h
+++ clang/lib/Driver/ToolChains/Linux.h
@@ -49,6 +49,11 @@
 
   std::vector ExtraOpts;
 
+  llvm::DenormalMode getDefaultDenormalModeForType(
+const llvm::opt::ArgList &DriverArgs,
+Action::OffloadKind DeviceOffloadKind,
+const llvm::fltSemantics *FPType = nullptr) const override;
+
 protected:
   Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -1044,3 +1044,22 @@
 Twine("-u", llvm::getInstrProfRuntimeHookVarName(;
   ToolChain::addProfileRTLibs(Args, CmdArgs);
 }
+
+llvm::DenormalMode Linux::getDefaultDenormalModeForType(
+  const llvm::opt::ArgList &DriverArgs,
+  Action::OffloadKind DeviceOffloadKind,
+  const llvm::fltSemantics *FPType) const {
+  switch (getTriple().getArch()) {
+  case llvm::Triple::x86:
+  case llvm::Triple::x86_64: {
+std::string Unused;
+// DAZ and FTZ are turned on in crtfastmath.o
+if (!DriverArgs.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles) &&
+FastMathRuntimeIsAvailable(DriverArgs, Unused))
+  return llvm::DenormalMode::getPreserveSign();
+return llvm::DenormalMode::getIEEE();
+  }
+  default:
+return llvm::DenormalMode::getIEEE();
+  }
+}
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -915,28 +915,35 @@
   CmdArgs.push_back("-lcc_kext");
 }
 
-bool ToolChain::AddFastMathRuntimeIfAvailable(const ArgList &Args,
-  ArgStringList &CmdArgs) const {
+bool ToolChain::FastMathRuntimeIsAvailable(const ArgList &Args,
+   std::string &Path) const {
   // Do not check for -fno-fast-math or -fno-unsafe-math when -Ofast passed
   // (to keep the linker options consistent with gcc and clang itself).
   if (!isOptimizationLevelFast(Args)) {
 // Check if -ffast-math or -funsafe-math.
 Arg *A =
-Args.getLastArg(options::OPT_ffast_math, options::OPT_fno_fast_math,
-

[PATCH] D70537: [clang] CGDebugInfo asserts `!DT.isNull()` when compiling with debug symbols

2019-12-02 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added inline comments.



Comment at: clang/test/CodeGenCXX/pr42710.cpp:4
+// RUN: %clang %s -DTYPE=int -emit-llvm -S -g -o - -std=c++17
+// expected-no-diagnostics
+

Could you validate the debug info for the struct members in the `int` case? (It 
may be simpler to structure the test using separate namespaces for the 
deduced/undeduced VarTemplateSpecializationDecl cases)


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

https://reviews.llvm.org/D70537



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


[PATCH] D69770: [APFloat] Add recoverable string parsing errors to APFloat

2019-12-02 Thread Ehud Katz via Phabricator via cfe-commits
ekatz added a comment.

Ping


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

https://reviews.llvm.org/D69770



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


[PATCH] D70157: Align branches within 32-Byte boundary

2019-12-02 Thread Philip Reames via Phabricator via cfe-commits
reames added a comment.

I want to chime in support of jyknight's meta comments - particularly the one 
about the need to balance execution speed vs code size differently in hot vs 
cold code.  For our use case, we have a very large amount of branch dense known 
cold paths, and being able to only align fast path branches would be a 
substantial space savings.

I also see value in having the prefix padding feature factored out generically. 
 If that mechanism is truly measurably faster than multi-byte nops - which if I 
reading comments correctly, has been claimed but not documented or measured? - 
using it generically for other alignment purposes would likely be worthwhile.

I'd also like to see - probably in a separate patch - support for 
auto-detecting whether the host CPU needs this mitigation.  Both -mcpu=native 
and various JITs will end up needing this, having the code centralized in one 
place would be good.


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

https://reviews.llvm.org/D70157



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


[PATCH] D70253: [AArch64][SVE2] Implement remaining SVE2 floating-point intrinsics

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

Thanks @kmclaughlin , LGTM.




Comment at: llvm/include/llvm/IR/IntrinsicsAArch64.td:898
+ llvm_i32_ty],
+[IntrNoMem]>;
+

kmclaughlin wrote:
> sdesmalen wrote:
> > efriedma wrote:
> > > kmclaughlin wrote:
> > > > sdesmalen wrote:
> > > > > I'd expect the `llvm_i32_ty` to be an immediate for these 
> > > > > instructions, right? If so you'll need to add `ImmArg`  to the 
> > > > > list of properties.
> > > > > 
> > > > Thanks for taking a look at this :) I tried your suggestion of adding 
> > > > ImmAr to the list of properties here but had some problems with it 
> > > > (i.e. Cannot select: intrinsic %llvm.aarch64.sve.fmlalb.lane). I don't 
> > > > think this is too much of an issue here as we have additional checks on 
> > > > the immediate with VectorIndexH32b, which ensures the immediate is in 
> > > > the correct range.
> > > The point of immarg markings isn't to assist the backend; it's to ensure 
> > > IR optimizations don't break your intrinsic calls.
> > The pattern is probably not matching because the immediate operand is a 
> > `TargetConstant` where the `AsmVectorIndexOpnd` derives from `ImmLeaf`, 
> > rather than `TImmLeaf` as introduced by D58232.
> Thanks for the suggestion, this was the reason why the patterns were not 
> matching! As this also affects many of the existing intrinsics not added here 
> or in D70437, I would prefer to address this fully in a separate patch - do 
> you have objections to this?
Okay, I'm happy with you want to make that change in a separate patch. It will 
also be needed for several of the other SVE intrinsics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70253



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


[PATCH] D70437: [AArch64][SVE] Implement shift intrinsics

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

LGTM!


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

https://reviews.llvm.org/D70437



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


[PATCH] D70872: [clangd] Implement "textDocument/documentLink" protocol support

2019-12-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks, looks nice!
It occurred to me we could compute (but not resolve) the ranges cheaply to 
speed up the UI. We don't need to do this now.
Only real thing to do is add a gunit test.




Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:1204
 
+void ClangdLSPServer::onDocumentLink(
+const DocumentLinkParams &Params,

Eagerly resolving everything means that this request is going to block on the 
preamble/AST being built. This isn't terrible (clients should be sending their 
initial requests in parallel) but does mean a delay before the links show up. 
(And in updating if we insert an include and want to ctrl-click it, because we 
just invalidated the preamble).

There are a few ways we could improve this:
a) find the links using a quick pass (simple string matching or raw-lexer 
based), then resolve results from the MainFileIncludes structure (blocking on 
the AST at that point)
b) use a quick pass to serve results in the first place, e.g. a 
PreprocessorOnlyAction with SingleFileParseMode (doesn't descend into headers).
c) a combination of these.

I don't particularly think we need to do these at this point, but may be worth 
a comment.



Comment at: clang-tools-extra/clangd/Protocol.h:1263
+///
+/// TODO(forster): For now only file URIs are supported.
+struct DocumentLink {

I don't think this TODO is needed - there's nothing to do unless we decide we 
want to emit other types of links.
(Which seems fairly unlikely: my understanding is that e.g. hyperlinks in 
comments should be resolved by editors generically rather than by language 
servers)



Comment at: clang-tools-extra/clangd/XRefs.cpp:181
+if (!Inc.Resolved.empty()) {
+  Result.emplace_back(DocumentLink(
+  {Inc.R, URIForFile::canonicalize(Inc.Resolved, *MainFilePath)}));

nit `push_back(DocumentLink{...})`



Comment at: clang-tools-extra/clangd/test/document-link.test:1
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}

Generally we smoke-test features in a lit test such as this one, and then do 
fine-grained testing as gunit tests (e.g. unittests/XRefTests.cpp). It's good 
to test end-to-end, but it's too hard to maintain lit tests for all cases as 
features get extended.

For this feature there's not much difference between the two, but you could 
drop one of the includes here and cover one more case in the unit tests:

```
#include "foo.h"
int end_of_preamble = 0;
#include "not_part_of_preamble.h"
```
(The non-preamble includes get into the data structures you're querying via a 
different path).

The unit tests are generally easier to set up:
 - you can use Annotations to write code with marked regions, and get the 
coordinates + unmarked code
 - you can use TestTU to add extra files "foo.h" to the VFS, and produce a 
ParsedAST
 - then just assert that the results match testPath("foo.h") + 
annotations.points()[0] etc.

`TEST(LocateSymbol, WithIndex)` in `XRefsTests.cpp` is a reasonable example.



Comment at: clang-tools-extra/clangd/test/document-link.test:21
+# CHECK-NEXT:  },
+# CHECK-NEXT:  "target": "file://{{.*}}/iostream"
+# CHECK-NEXT:},

MForster wrote:
> Originally I tried to add a header file to the setup with a second didOpen 
> request, but I didn't get this to work. Would I need to set this up like 
> `background-index.test`, or is there a simpler way?
> 
> Anyway, I think the regular expression is probably good enough for the 
> purpose of this test.
> Originally I tried to add a header file to the setup with a second didOpen 
> request, but I didn't get this to work
Clangd's model is that the *current* file is always via LSP (didOpen), and all 
other files are read from disk. The setup would be slightly simpler than 
background-index.test because you don't need a compile command for the other 
file, but still a bit awkward.

I think the regex is OK, but would prefer to change to `stdint.h`/`stddef.h` 
(not the C++ versions). This is because they're builtin headers in clang, so 
even if we don't find a standard library they'll still exist. (clangd tests do 
formally depend on the builtins but not a stdlib, I believe).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70872



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


[PATCH] D70696: [DebugInfo] Support to emit debugInfo for extern variables

2019-12-02 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:1140
 
+  for (auto D: ExternalDeclarations) {
+if (!D || D->isInvalidDecl() || D->getPreviousDecl() || !D->isUsed())

clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70696



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


[PATCH] D70911: [clangd] Switch Hover.All to structured tests

2019-12-02 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70911

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

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -11,9 +11,14 @@
 #include "TestIndex.h"
 #include "TestTU.h"
 #include "index/MemIndex.h"
+#include "clang/Index/IndexSymbol.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/StringRef.h"
 
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -532,252 +537,333 @@
   }
 }
 
-TEST(Hover, All) {
-  struct OneTest {
-StringRef Input;
-StringRef ExpectedHover;
-  };
-
-  OneTest Tests[] = {
-  {
-  R"cpp(// No hover
-^int main() {
+TEST(Hover, NoHover) {
+  llvm::StringRef Tests[] = {
+  "^int main() {}",
+  "void foo() {^}",
+  R"cpp(// structured binding. Not supported yet
+struct Bar {};
+void foo() {
+  Bar a[2];
+  ^auto [x,y] = a;
+}
+  )cpp",
+  R"cpp(// Template auto parameter. Nothing (Not useful).
+template<^auto T>
+void func() {
+}
+void foo() {
+   func<1>();
 }
   )cpp",
-  "",
-  },
+  };
+
+  for (const auto &Test : Tests) {
+SCOPED_TRACE(Test);
+
+Annotations T(Test);
+TestTU TU = TestTU::withCode(T.code());
+TU.ExtraArgs.push_back("-std=c++17");
+auto AST = TU.build();
+ASSERT_TRUE(AST.getDiagnostics().empty());
+
+auto H = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+ASSERT_FALSE(H);
+  }
+}
+
+TEST(Hover, All) {
+  struct {
+const char *const Code;
+const std::function ExpectedBuilder;
+  } Cases[] = {
   {
   R"cpp(// Local variable
 int main() {
   int bonjour;
-  ^bonjour = 2;
+  ^[[bonjour]] = 2;
   int test1 = bonjour;
 }
   )cpp",
-  "text[Declared in]code[main]\n"
-  "codeblock(cpp) [\n"
-  "int bonjour\n"
-  "]",
-  },
+  [](HoverInfo &HI) {
+HI.Name = "bonjour";
+HI.Kind = index::SymbolKind::Variable;
+HI.NamespaceScope = "";
+HI.LocalScope = "main::";
+HI.Type = "int";
+HI.Definition = "int bonjour";
+  }},
   {
   R"cpp(// Local variable in method
 struct s {
   void method() {
 int bonjour;
-^bonjour = 2;
+^[[bonjour]] = 2;
   }
 };
   )cpp",
-  "text[Declared in]code[s::method]\n"
-  "codeblock(cpp) [\n"
-  "int bonjour\n"
-  "]",
-  },
+  [](HoverInfo &HI) {
+HI.Name = "bonjour";
+HI.Kind = index::SymbolKind::Variable;
+HI.NamespaceScope = "";
+HI.LocalScope = "s::method::";
+HI.Type = "int";
+HI.Definition = "int bonjour";
+  }},
   {
   R"cpp(// Struct
 namespace ns1 {
   struct MyClass {};
 } // namespace ns1
 int main() {
-  ns1::My^Class* Params;
+  ns1::[[My^Class]]* Params;
 }
   )cpp",
-  "text[Declared in]code[ns1]\n"
-  "codeblock(cpp) [\n"
-  "struct MyClass {}\n"
-  "]",
-  },
+  [](HoverInfo &HI) {
+HI.Name = "MyClass";
+HI.Kind = index::SymbolKind::Struct;
+HI.NamespaceScope = "ns1::";
+HI.Definition = "struct MyClass {}";
+  }},
   {
   R"cpp(// Class
 namespace ns1 {
   class MyClass {};
 } // namespace ns1
 int main() {
-  ns1::My^Class* Params;
+  ns1::[[My^Class]]* Params;
 }
   )cpp",
-  "text[Declared in]code[ns1]\n"
-  "codeblock(cpp) [\n"
-  "class MyClass {}\n"
-  "]",
-  },
+  [](HoverInfo &HI) {
+HI.Name = "MyClass";
+HI.Kind = index::SymbolKind::Class;
+HI.NamespaceScope = "ns1::";
+HI.Definition = "class MyClass {}";
+  }},
   {
   R"cpp(// Union
 namespace ns1 {
   union MyUnion { int x; int y; };
 } // namespace ns1
 int main() {
-  ns1::My^Union Params;
+  ns1::[[My^Union]] Params;
 }
   )cpp",
-  "text[Declared in

[PATCH] D70911: [clangd] Switch Hover.All to structured tests

2019-12-02 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: FAILURE - 
Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70911



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


[PATCH] D70912: [Analyzer] Iterator Modeling: Print Container Data and Iterator Positions when printing the Program State

2019-12-02 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 231738.
baloghadamsoftware added a comment.

Wrong diff uploaded.


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

https://reviews.llvm.org/D70912

Files:
  clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
  clang/test/Analysis/iterator-modelling.cpp

Index: clang/test/Analysis/iterator-modelling.cpp
===
--- clang/test/Analysis/iterator-modelling.cpp
+++ clang/test/Analysis/iterator-modelling.cpp
@@ -1,6 +1,9 @@
 // RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false %s -verify
+
 // RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify
 
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true %s 2>&1 | FileCheck %s
+
 #include "Inputs/system-header-simulator-cxx.h"
 
 template 
@@ -1970,3 +1973,29 @@
 clang_analyzer_iterator_position(first)); // expected-warning@-1{{FALSE}} expected-warning@-1 0-1{{TRUE}} FIXME: should only expect FALSE in every case
   }
 }
+
+void clang_analyzer_printState();
+
+void print_state(std::vector &V) {
+  const auto i0 = V.cbegin();
+  clang_analyzer_printState();
+
+// CHECK:  "checker_messages": [
+// CHECK-NEXT:   { "checker": "alpha.cplusplus.IteratorModeling", "messages": [
+// CHECK-NEXT: "Container Data :",
+// CHECK-NEXT: "SymRegion{reg_$[[#]] & V>} : [ conj_$[[#]]{long, LC[[#]], S[[#]], #[[#]]} ..  ]",
+// CHECK-NEXT: "Iterator Positions :",
+// CHECK-NEXT: "i0 : Valid ; Container == SymRegion{reg_$[[#]] & V>} ; Offset == conj_$[[#]]{long, LC[[#]], S[[#]], #[[#]]}"
+// CHECK-NEXT:   ]}
+
+  const auto i1 = V.cend();
+  clang_analyzer_printState();
+  
+// CHECK:  "checker_messages": [
+// CHECK-NEXT:   { "checker": "alpha.cplusplus.IteratorModeling", "messages": [
+// CHECK-NEXT: "Container Data :",
+// CHECK-NEXT: "SymRegion{reg_$[[#]] & V>} : [ conj_$[[#]]{long, LC[[#]], S[[#]], #[[#]]} .. conj_$[[#]]{long, LC[[#]], S[[#]], #[[#]]} ]",
+// CHECK-NEXT: "Iterator Positions :",
+// CHECK-NEXT: "i1 : Valid ; Container == SymRegion{reg_$[[#]] & V>} ; Offset == conj_$[[#]]{long, LC[[#]], S[[#]], #[[#]]}"
+// CHECK-NEXT:   ]}
+}
Index: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
@@ -121,6 +121,9 @@
   void handleEraseAfter(CheckerContext &C, const SVal &Iter) const;
   void handleEraseAfter(CheckerContext &C, const SVal &Iter1,
 const SVal &Iter2) const;
+  void printState(raw_ostream &Out, ProgramStateRef State, const char *NL,
+  const char *Sep) const override;
+
 public:
   IteratorModeling() {}
 
@@ -1080,6 +1083,58 @@
   C.addTransition(State);
 }
 
+void IteratorModeling::printState(raw_ostream &Out, ProgramStateRef State,
+  const char *NL, const char *Sep) const {
+
+  auto ContMap = State->get();
+
+  if (!ContMap.isEmpty()) {
+Out << Sep << "Container Data :" << NL;
+for (const auto Cont : ContMap) {
+  Cont.first->dumpToStream(Out);
+  Out << " : [ ";
+  const auto CData = Cont.second;
+  if (CData.getBegin())
+CData.getBegin()->dumpToStream(Out);
+  else
+Out << "";
+  Out << " .. ";
+  if (CData.getEnd())
+CData.getEnd()->dumpToStream(Out);
+  else
+Out << "";
+  Out << " ]" << NL;
+}
+  }
+
+  auto SymbolMap = State->get();
+  auto RegionMap = State->get();
+
+  if (!SymbolMap.isEmpty() || !RegionMap.isEmpty()) {
+Out << Sep << "Iterator Positions :" << NL;
+for (const auto Sym : SymbolMap) {
+  Sym.first->dumpToStream(Out);
+  Out << " : ";
+  const auto Pos = Sym.second;
+  Out << (Pos.isValid() ? "Valid" : "Invalid") << " ; Container == ";
+  Pos.getContainer()->dumpToStream(Out);
+  Out<<" ; Offset == ";
+  Pos.getOffset()->dumpToStream(Out);
+}
+
+for (const auto Reg : RegionMap) {
+  Reg.first->dumpToStream(Out);
+  Out << " : ";
+  const auto Pos = Reg.second;
+  Out << (Pos.isValid() ? "Valid" : "Invalid") << " ; Container == ";
+  Pos.getContainer()->dumpToStream(Out);
+  Out<<" ; Offset == ";
+  Pos.getOffset()->dumpToStream(Out);
+}
+  }
+}
+
+
 namespace {
 
 const CXXRecordDecl *getCXXRecordDecl(ProgramStateRef State,
___

[PATCH] D70537: [clang] CGDebugInfo asserts `!DT.isNull()` when compiling with debug symbols

2019-12-02 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

I guess first I'm confused about why the type would be undeduced in the first 
place, given that it is actually instantiated.
And if undeduced is correct, wouldn't we rather emit these with 
DW_TAG_unspecified_type?




Comment at: clang/test/CodeGenCXX/pr42710.cpp:2
+// RUN: %clang %s -DTYPE=auto -emit-llvm -S -g -o - -std=c++17
+// expected-no-diagnostics
+// RUN: %clang %s -DTYPE=int -emit-llvm -S -g -o - -std=c++17

I believe you would use `expected-no-diagnostics` only if you run clang with 
`-verify`.  So, please remove those two directives.


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

https://reviews.llvm.org/D70537



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


[clang] 9ec6d71 - [clang][modules] Add support for merging lifetime-extended temporaries

2019-12-02 Thread via cfe-commits

Author: Tyker
Date: 2019-12-02T19:55:13+01:00
New Revision: 9ec6d7121132d30db68818e4f684910f76307fdf

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

LOG: [clang][modules] Add support for merging lifetime-extended temporaries

Summary: Add support for merging lifetime-extended temporaries

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: xbolva00, cfe-commits

Tags: #clang

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

Added: 
clang/test/Modules/Inputs/merge-lifetime-extended-temporary/a.h
clang/test/Modules/Inputs/merge-lifetime-extended-temporary/b.h
clang/test/Modules/Inputs/merge-lifetime-extended-temporary/c.h
clang/test/Modules/Inputs/merge-lifetime-extended-temporary/module.modulemap
clang/test/Modules/merge-lifetime-extended-temporary.cpp

Modified: 
clang/include/clang/AST/DeclCXX.h
clang/include/clang/AST/TextNodeDumper.h
clang/include/clang/Serialization/ASTReader.h
clang/lib/AST/TextNodeDumper.cpp
clang/lib/Serialization/ASTReaderDecl.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 63d67bd3f55b..0f2018fb9e8c 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -3041,7 +3041,9 @@ class NamespaceAliasDecl : public NamedDecl,
 
 /// Implicit declaration of a temporary that was materialized by
 /// a MaterializeTemporaryExpr and lifetime-extended by a declaration
-class LifetimeExtendedTemporaryDecl final : public Decl {
+class LifetimeExtendedTemporaryDecl final
+: public Decl,
+  public Mergeable {
   friend class MaterializeTemporaryExpr;
   friend class ASTDeclReader;
 

diff  --git a/clang/include/clang/AST/TextNodeDumper.h 
b/clang/include/clang/AST/TextNodeDumper.h
index 0ff5a614a864..d293ea190aa4 100644
--- a/clang/include/clang/AST/TextNodeDumper.h
+++ b/clang/include/clang/AST/TextNodeDumper.h
@@ -346,6 +346,8 @@ class TextNodeDumper
   void VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D);
   void VisitBlockDecl(const BlockDecl *D);
   void VisitConceptDecl(const ConceptDecl *D);
+  void
+  VisitLifetimeExtendedTemporaryDecl(const LifetimeExtendedTemporaryDecl *D);
 };
 
 } // namespace clang

diff  --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index f0b5e9933823..b6dae68b3413 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -551,6 +551,14 @@ class ASTReader
   llvm::DenseMap>
 AnonymousDeclarationsForMerging;
 
+  /// Key used to identify LifetimeExtendedTemporaryDecl for merging,
+  /// containing the lifetime-extending declaration and the mangling number.
+  using LETemporaryKey = std::pair;
+
+  /// Map of already deserialiazed temporaries.
+  llvm::DenseMap
+  LETemporaryForMerging;
+
   struct FileDeclsInfo {
 ModuleFile *Mod = nullptr;
 ArrayRef Decls;

diff  --git a/clang/lib/AST/TextNodeDumper.cpp 
b/clang/lib/AST/TextNodeDumper.cpp
index 0ff95213118f..561c76a45cbc 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -1338,6 +1338,17 @@ void TextNodeDumper::VisitFunctionDecl(const 
FunctionDecl *D) {
 OS << " <>>";
 }
 
+void TextNodeDumper::VisitLifetimeExtendedTemporaryDecl(
+const LifetimeExtendedTemporaryDecl *D) {
+  OS << " extended by ";
+  dumpBareDeclRef(D->getExtendingDecl());
+  OS << " mangling ";
+  {
+ColorScope Color(OS, ShowColors, ValueColor);
+OS << D->getManglingNumber();
+  }
+}
+
 void TextNodeDumper::VisitFieldDecl(const FieldDecl *D) {
   dumpName(D);
   dumpType(D->getType());

diff  --git a/clang/lib/Serialization/ASTReaderDecl.cpp 
b/clang/lib/Serialization/ASTReaderDecl.cpp
index 8991a39a7067..3f7a1ed7fd5c 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -424,6 +424,8 @@ namespace clang {
 template
 void mergeMergeable(Mergeable *D);
 
+void mergeMergeable(LifetimeExtendedTemporaryDecl *D);
+
 void mergeTemplatePattern(RedeclarableTemplateDecl *D,
   RedeclarableTemplateDecl *Existing,
   DeclID DsID, bool IsKeyDecl);
@@ -2358,6 +2360,7 @@ void ASTDeclReader::VisitLifetimeExtendedTemporaryDecl(
   if (Record.readInt())
 D->Value = new (D->getASTContext()) APValue(Record.readAPValue());
   D->ManglingNumber = Record.readInt();
+  mergeMergeable(D);
 }
 
 std::pair
@@ -2555,6 +2558,25 @@ static bool allowODRLikeMergeInC(NamedDecl *ND) {
   return false;
 }
 
+/// Attempts to merge LifetimeExtendedTemporaryDecl with
+/// identical class definitions from two 
diff erent modules.
+void ASTDeclReader::mergeMergeable(LifetimeExtendedTe

[PATCH] D70696: [DebugInfo] Support to emit debugInfo for extern variables

2019-12-02 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

For the case:

  cat def.c
  int global_var = 2;

def.o should have debug info for the definition of global_var.
For the case:

  cat noref.c
  extern int global_var;
  int main() {}

I would not expect to see debug info for the declaration of global_var.
For the case:

  cat ref.c
  extern int global_var;
  int main() { return global_var; }

I *do* expect to see debug info for the declaration of global_var.

Does bpf require debug info for the declaration of global_var in `noref.c` ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70696



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


[clang] 478541a - [OPENMP]Fix PR44133: Emit definitions of used constructors/functions.

2019-12-02 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2019-12-02T14:07:29-05:00
New Revision: 478541a6da59fa3eadab98cabdcb0126fad3fdb5

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

LOG: [OPENMP]Fix PR44133: Emit definitions of used constructors/functions.

Need to fully rebuild the initializer/combiner when instatiating the
declare reduction constrcut to properly emit used functions.

Added: 


Modified: 
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/OpenMP/declare_reduction_codegen.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 9a6c7b5277b5..e9cb9f89e0a2 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3070,20 +3070,11 @@ Decl 
*TemplateDeclInstantiator::VisitOMPDeclareReductionDecl(
   } else {
 SubstReductionType = D->getType();
   }
-  Expr *Combiner = D->getCombiner();
-  Expr *Init = D->getInitializer();
-  const bool CombinerRequiresInstantiation =
-  Combiner &&
-  (Combiner->isValueDependent() || Combiner->isInstantiationDependent() ||
-   Combiner->isTypeDependent() ||
-   Combiner->containsUnexpandedParameterPack());
-  const bool InitRequiresInstantiation =
-  Init &&
-  (Init->isValueDependent() || Init->isInstantiationDependent() ||
-   Init->isTypeDependent() || Init->containsUnexpandedParameterPack());
   if (SubstReductionType.isNull())
 return nullptr;
-  bool IsCorrect = !SubstReductionType.isNull();
+  Expr *Combiner = D->getCombiner();
+  Expr *Init = D->getInitializer();
+  bool IsCorrect = true;
   // Create instantiated copy.
   std::pair ReductionTypes[] = {
   std::make_pair(SubstReductionType, D->getLocation())};
@@ -3098,79 +3089,53 @@ Decl 
*TemplateDeclInstantiator::VisitOMPDeclareReductionDecl(
   PrevDeclInScope);
   auto *NewDRD = cast(DRD.get().getSingleDecl());
   SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, NewDRD);
-  if (!RequiresInstantiation && !CombinerRequiresInstantiation &&
-  !InitRequiresInstantiation) {
-if (Combiner) {
-  NewDRD->setCombinerData(D->getCombinerIn(), D->getCombinerOut());
-  NewDRD->setCombiner(Combiner);
-  if (Init) {
-NewDRD->setInitializerData(D->getInitOrig(), D->getInitPriv());
-NewDRD->setInitializer(Init, D->getInitializerKind());
-  }
-}
-(void)SemaRef.ActOnOpenMPDeclareReductionDirectiveEnd(
-/*S=*/nullptr, DRD, IsCorrect && !D->isInvalidDecl());
-return NewDRD;
-  }
   Expr *SubstCombiner = nullptr;
   Expr *SubstInitializer = nullptr;
   // Combiners instantiation sequence.
   if (Combiner) {
-if (!CombinerRequiresInstantiation) {
-  NewDRD->setCombinerData(D->getCombinerIn(), D->getCombinerOut());
-  NewDRD->setCombiner(Combiner);
-} else {
-  SemaRef.ActOnOpenMPDeclareReductionCombinerStart(
-  /*S=*/nullptr, NewDRD);
-  SemaRef.CurrentInstantiationScope->InstantiatedLocal(
-  cast(D->getCombinerIn())->getDecl(),
-  cast(NewDRD->getCombinerIn())->getDecl());
-  SemaRef.CurrentInstantiationScope->InstantiatedLocal(
-  cast(D->getCombinerOut())->getDecl(),
-  cast(NewDRD->getCombinerOut())->getDecl());
-  auto *ThisContext = dyn_cast_or_null(Owner);
-  Sema::CXXThisScopeRAII ThisScope(SemaRef, ThisContext, Qualifiers(),
-   ThisContext);
-  SubstCombiner = SemaRef.SubstExpr(Combiner, TemplateArgs).get();
-  SemaRef.ActOnOpenMPDeclareReductionCombinerEnd(NewDRD, SubstCombiner);
-}
+SemaRef.ActOnOpenMPDeclareReductionCombinerStart(
+/*S=*/nullptr, NewDRD);
+SemaRef.CurrentInstantiationScope->InstantiatedLocal(
+cast(D->getCombinerIn())->getDecl(),
+cast(NewDRD->getCombinerIn())->getDecl());
+SemaRef.CurrentInstantiationScope->InstantiatedLocal(
+cast(D->getCombinerOut())->getDecl(),
+cast(NewDRD->getCombinerOut())->getDecl());
+auto *ThisContext = dyn_cast_or_null(Owner);
+Sema::CXXThisScopeRAII ThisScope(SemaRef, ThisContext, Qualifiers(),
+ ThisContext);
+SubstCombiner = SemaRef.SubstExpr(Combiner, TemplateArgs).get();
+SemaRef.ActOnOpenMPDeclareReductionCombinerEnd(NewDRD, SubstCombiner);
   }
   // Initializers instantiation sequence.
   if (Init) {
-if (!InitRequiresInstantiation) {
-  NewDRD->setInitializerData(D->getInitOrig(), D->getInitPriv());
-  NewDRD->setInitializer(Init, D->getInitializerKind());
+VarDecl *OmpPrivParm = SemaRef.ActOnOpenMPDeclareReductionInitializerStart(
+/*S=*/nullptr, NewDRD);
+SemaRef.CurrentInstantiationScope->InstantiatedLocal(
+cast(D->getInitOrig()

[clang] f17a1d8 - [OPENMP]Use cast instead dyn_cast, NFC.

2019-12-02 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2019-12-02T14:16:52-05:00
New Revision: f17a1d8b283d227dcbc88caf94acf55abc91c1f9

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

LOG: [OPENMP]Use cast instead dyn_cast, NFC.

Here the expression is always a DeclRefExpr, no need to use dyn_cast.

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 2773efcf3dae..50d9ab974dd4 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -5445,7 +5445,7 @@ void 
Sema::markOpenMPDeclareVariantFuncsReferenced(SourceLocation Loc,
  Func->specific_attrs()) {
   // TODO: add checks for active OpenMP context where possible.
   Expr *VariantRef = A->getVariantFuncRef();
-  auto *DRE = dyn_cast(VariantRef->IgnoreParenImpCasts());
+  auto *DRE = cast(VariantRef->IgnoreParenImpCasts());
   auto *F = cast(DRE->getDecl());
   if (!F->isDefined() && F->isTemplateInstantiation())
 InstantiateFunctionDefinition(Loc, F->getFirstDecl());



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


[PATCH] D70524: Support DebugInfo generation for auto return type for C++ functions.

2019-12-02 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:2925
+return C.getQualifiedType(T.getTypePtr(), Quals);
+  }
 case Type::DeducedTemplateSpecialization: {

aprantl wrote:
> You need to mark this `LLVM_FALLTHROUGH` now or you'll get a warning.
The FALLTHROUGH must come right before the next `case`



Comment at: clang/test/CodeGenCXX/debug-info-auto-return.cpp:7
+
+// CHECK: !DISubprogram(name: "findMax",{{.*}}, type: !18
+// CHECK: !18 =  !DISubroutineType(types: !19)

aprantl wrote:
> Please don't hardcode the MDNode numbers, they will inevitably change over 
> time. Instead use variables:
> ```
> type: ![[SUBROUTINE_TYPE:[0-9]+]]`
> // CHECK: ![[SUBROUTINE_TYPE]] =  !DISubroutineType(types: ![[ARGS:[0-9]+)
> ```
> etc
you still need to make sure that the two nodes CHECKed are being connected. 
Please use variables like in the example I posted.


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

https://reviews.llvm.org/D70524



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


[PATCH] D68101: [MC][ELF] Prevent globals with an explicit section from being mergeable

2019-12-02 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Let me try to restate what's happening here so that I can see if I understand 
it.

There are two concepts of "section" in play here:

- a unit in an object file with a particular section name, which need not be 
unique within the object file, and which can have interesting per-unit 
attributes like mergeability; and
- the high-level layout of the final linked image, where all of the units with 
the same section name (within a single image) are supposed to be contiguous, 
and where the image will contain metadata describing the location and size of 
the section.

I'll call the first a "section unit" and the second an "image section" just for 
clarity; my apologies if there's more standard jargon.

Marking a section unit as mergeable in ELF opts in to a link-time optimization 
where the linker can avoid unnecessary duplication in the image section by 
combining identical data that would have ended up in it.  Essentially, the 
section unit is broken up into entries according to an entry size that's part 
of the mergeable attribute, and if the linker sees that two entries will be 
identical (whether they come from different section units or not), it can 
simply remove the redundant entry from the final image section.  (Presumably 
there's some rule about the order of entries, but it doesn't really matter for 
this analysis.)  This is done as a relatively late pass; any sort of mandatory 
"merging" from e.g. COMDAT, weak, and common symbols will already have been 
applied, so we don't need to worry about this interfering with 
language-mandated symbol coalescing.

When LLVM is emitting ELF, it will try to place an object in a mergeable 
section unit if the object is `unnamed_addr`.  It will also generally emit 
objects into the same section unit if they share the same section name.  I 
assume this takes attributes into account to at least some degree, or else we 
might be lumping non-`unnamed_addr` into a mergeable section just because the 
first object we processed with that section name was `unnamed_addr`.  But it 
must not take entry size into account, because PR 43457 shows us clearly 
emitting a single section unit for objects of different sizes.

Given all that, this patch seems far too aggressive.  While mergeable sections 
can be useful for optimizing arbitrary code that might not use a section, they 
are also extremely useful for optimizing the sorts of global tables that 
programmers frequently use explicit sections for.  It seems to me that the 
right fix is to find the place that ensures that we don't put mergeable and 
non-mergeable objects in the same section unit (or at least conservatively 
makes the section unit non-mergeable) and fix it to consider entry size as 
well.  That should be straightforward unless that place doesn't exist, in which 
case we have very serious problems.


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

https://reviews.llvm.org/D68101



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


[PATCH] D70696: [DebugInfo] Support to emit debugInfo for extern variables

2019-12-02 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song marked an inline comment as done.
yonghong-song added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:1140
 
+  for (auto D: ExternalDeclarations) {
+if (!D || D->isInvalidDecl() || D->getPreviousDecl() || !D->isUsed())

aprantl wrote:
> clang-format
Thanks for the review! Will update the patch today after running clang-format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70696



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


[PATCH] D70863: [clangd] Try harder to find a plausible `clang` as argv0, particularly on Mac.

2019-12-02 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

@sammccall Sam, it looks like the tests are failing on the darwin bots:

http://lab.llvm.org:8080/green/job/clang-stage1-RA/4243/consoleFull

  Value of: CDB.getFallbackCommand(testPath("bar.cc")).CommandLine
  Expected: has 6 elements where
  element #0 ends with "clang",
  element #1 is equal to "-DA=2",
  element #2 is equal to "/clangd-test/bar.cc",
  element #3 is equal to "-DA=4",
  element #4 is equal to "-fsyntax-only",
  element #5 starts with "-resource-dir"
Actual: { 
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang",
 "-DA=2", "/clangd-test/bar.cc", "-DA=4", "-fsyntax-only", 
"-resource-dir=/Users/buildslave/jenkins/workspace/clang-stage1-RA/clang-build/tools/clang/tools/extra/clangd/lib/clang/10.0.0",
 "-isysroot", 
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
 }, which has 8 elements

Can you please take a look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70863



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


[PATCH] D70696: [DebugInfo] Support to emit debugInfo for extern variables

2019-12-02 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D70696#1765637 , @probinson wrote:

> For the case:
>
>   cat def.c
>   int global_var = 2;
>
>
> def.o should have debug info for the definition of global_var.
>  For the case:
>
>   cat noref.c
>   extern int global_var;
>   int main() {}
>
>
> I would not expect to see debug info for the declaration of global_var.
>  For the case:
>
>   cat ref.c
>   extern int global_var;
>   int main() { return global_var; }
>
>
> I *do* expect to see debug info for the declaration of global_var.


FWIW I'd only expect it there with -fstandalone-debug - with 
-fno-standalone-debug I'd expect this code to rely on the assumption that def.c 
is also compiled with debug info.

(as it stands today, Clang/LLVM never produces debug info for global_var in 
ref.c, even with -fstandalone-debug & I'm not too fussed about that, but would 
be OK if someone wanted to fix/improve that)

> Does bpf require debug info for the declaration of global_var in `noref.c` ?

Yeah, +1, I'm still curious to know more/trying to understand this ^ 
requirement.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70696



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


[PATCH] D70696: [DebugInfo] Support to emit debugInfo for extern variables

2019-12-02 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

@probinson for the question,

> Does bpf require debug info for the declaration of global_var in noref.c ?

No, bpf only cares the referenced external global variables. So my current 
implementation does not emit debug info
for external global_var in noref.c.

It is just strange that gcc 7.3.1 (did not test, but maybe later gcc versions 
as well) emits the debuginfo (encoded in dwarf)
even if the external variable is not used in the current compilation unit. Not 
sure what is the rationale behind it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70696



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


[PATCH] D69979: clang: Guess at some platform FTZ/DAZ default settings

2019-12-02 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a subscriber: andreadb.
spatel added inline comments.



Comment at: clang/include/clang/Driver/ToolChain.h:580
+  /// This checks for presence of the -Ofast, -ffast-math or -funsafe-math 
flags.
+  virtual bool FastMathRuntimeIsAvailable(
+const llvm::opt::ArgList &Args, std::string &Path) const;

Formatting nit - prefer to start with verb and lower-case: 
isFastMathRuntimeAvailable() or hasFastMathRuntime().



Comment at: clang/include/clang/Driver/ToolChain.h:587
   /// This checks for presence of the -Ofast, -ffast-math or -funsafe-math 
flags.
-  virtual bool AddFastMathRuntimeIfAvailable(
-  const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const;
+  bool AddFastMathRuntimeIfAvailable(
+const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const;

Add -> add



Comment at: clang/lib/Driver/ToolChains/PS4CPU.h:95-96
+const llvm::fltSemantics *FPType) const override {
+// DAZ and FTZ are on by default.
+return llvm::DenormalMode::getPreserveSign();
+  }

@probinson / @andreadb - is this correct for PS4? or is there some equivalent 
to the Linux startup file?


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

https://reviews.llvm.org/D69979



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


[PATCH] D70041: register cuda language activation event and activate for .cuh files

2019-12-02 Thread Paul Taylor via Phabricator via cfe-commits
ptaylor updated this revision to Diff 231742.
ptaylor added a comment.

drop comment about vscode cuda syntax highlighting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70041

Files:
  clang-tools-extra/clangd/clients/clangd-vscode/package.json
  clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -83,21 +83,14 @@
   }
   const serverOptions: vscodelc.ServerOptions = clangd;
 
-  // Note that CUDA ('.cu') files are special. When opening files of all other
-  // extensions, VSCode would load clangd automatically. This is achieved by
-  // having a corresponding 'onLanguage:...' activation event in package.json.
-  // However, VSCode does not have CUDA as a supported language yet, so we
-  // cannot add a corresponding activationEvent for CUDA files and clangd will
-  // *not* load itself automatically on '.cu' files.
-  const cudaFilePattern: string = '**/*.{' + [ 'cu' ].join() + '}';
   const clientOptions: vscodelc.LanguageClientOptions = {
 // Register the server for c-family and cuda files.
 documentSelector: [
 { scheme: 'file', language: 'c' },
 { scheme: 'file', language: 'cpp' },
+{ scheme: 'file', language: 'cuda' },
 { scheme: 'file', language: 'objective-c'},
-{ scheme: 'file', language: 'objective-cpp'},
-{ scheme: 'file', pattern: cudaFilePattern },
+{ scheme: 'file', language: 'objective-cpp'}
 ],
 synchronize: !syncFileEvents ? undefined : {
 // FIXME: send sync file events when clangd provides implemenatations.
@@ -111,10 +104,10 @@
 serverOptions, clientOptions);
   if (getConfig('semanticHighlighting')) {
 const semanticHighlightingFeature =
-  new semanticHighlighting.SemanticHighlightingFeature(clangdClient,
-context);
+new semanticHighlighting.SemanticHighlightingFeature(clangdClient,
+ context);
 context.subscriptions.push(
-  vscode.Disposable.from(semanticHighlightingFeature));
+vscode.Disposable.from(semanticHighlightingFeature));
 clangdClient.registerFeature(semanticHighlightingFeature);
   }
   console.log('Clang Language Server is now active!');
Index: clang-tools-extra/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/clangd/clients/clangd-vscode/package.json
@@ -23,6 +23,7 @@
 "activationEvents": [
 "onLanguage:c",
 "onLanguage:cpp",
+"onLanguage:cuda",
 "onLanguage:objective-c",
 "onLanguage:objective-cpp",
 "onCommand:clangd-vscode.activate"
@@ -64,6 +65,13 @@
 "**/MSVC/*/include/**"
 ],
 "firstLine": "^/[/*].*-\\*-\\s*C\\+\\+\\s*-\\*-.*"
+},
+{
+"id": "cuda",
+"extensions": [
+".cu",
+".cuh"
+]
 }
 ],
 "configuration": {


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -83,21 +83,14 @@
   }
   const serverOptions: vscodelc.ServerOptions = clangd;
 
-  // Note that CUDA ('.cu') files are special. When opening files of all other
-  // extensions, VSCode would load clangd automatically. This is achieved by
-  // having a corresponding 'onLanguage:...' activation event in package.json.
-  // However, VSCode does not have CUDA as a supported language yet, so we
-  // cannot add a corresponding activationEvent for CUDA files and clangd will
-  // *not* load itself automatically on '.cu' files.
-  const cudaFilePattern: string = '**/*.{' + [ 'cu' ].join() + '}';
   const clientOptions: vscodelc.LanguageClientOptions = {
 // Register the server for c-family and cuda files.
 documentSelector: [
 { scheme: 'file', language: 'c' },
 { scheme: 'file', language: 'cpp' },
+{ scheme: 'file', language: 'cuda' },
 { scheme: 'file', language: 'objective-c'},
-{ scheme: 'file', language: 'objective-cpp'},
-{ scheme: 'file', pattern: cudaFilePattern },
+{ scheme: 'file', language: 'objective-cpp'}
 ],
 synchronize: !syncFileEven

[PATCH] D10833: Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface

2019-12-02 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a comment.

Hi @arthurp, I can review the libclang part of the patch.

Could you please remove the changes that are just code formatting? You can land 
those as a separate NFC commit.




Comment at: clang/tools/libclang/CIndex.cpp:259
+
+  std::pair Begin = SM.getDecomposedLoc(
+  SM.getFileLoc(RegionOfInterest.getBegin())),

This seems like just a clang-format change. Maybe we could separate these as a 
NFC commit?



Comment at: clang/tools/libclang/CIndex.cpp:436
 
-  bool OnlyLocalDecls
-= !AU->isMainFileAST() && AU->getOnlyLocalDecls(); 
-  
+  bool OnlyLocalDecls = !AU->isMainFileAST() && AU->getOnlyLocalDecls();
+

This seems like just a clang-format change. Maybe we could separate these as a 
NFC commit?



Comment at: clang/tools/libclang/CIndex.cpp:1369
 
-bool 
-CursorVisitor::VisitNestedNameSpecifierLoc(NestedNameSpecifierLoc Qualifier) {
+bool CursorVisitor::VisitNestedNameSpecifierLoc(
+NestedNameSpecifierLoc Qualifier) {

This seems like just a clang-format change. Maybe we could separate these as a 
NFC commit?

Could you please leave out all such changes from this patch? It would be easier 
to review. (It seems to me a bunch of changes below are of this nature.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D10833



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


[clang] 1d45873 - [AArch64] Attempt to fixup test line. NFC

2019-12-02 Thread David Green via cfe-commits

Author: David Green
Date: 2019-12-02T19:30:54Z
New Revision: 1d4587346f51ca5cc5741337cadfaeb208ca59ad

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

LOG: [AArch64] Attempt to fixup test line. NFC

The test is complaining on some of the builders. This attempts to
adjust the run line to be more line the others in the same folder, using
clang_cc1 as opposed to the driver.

Added: 


Modified: 
clang/test/CodeGen/aarch64-neon-vcadd.c

Removed: 




diff  --git a/clang/test/CodeGen/aarch64-neon-vcadd.c 
b/clang/test/CodeGen/aarch64-neon-vcadd.c
index 6f1b3dcd4015..2d721f187fe6 100644
--- a/clang/test/CodeGen/aarch64-neon-vcadd.c
+++ b/clang/test/CodeGen/aarch64-neon-vcadd.c
@@ -1,4 +1,6 @@
-// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.3-a+fp16 %s -S 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +neon \
+// RUN:  -target-feature +v8.3a -target-feature +fullfp16 -S -emit-llvm -o - 
%s \
+// RUN:  | FileCheck %s
 
 #include 
 



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


[PATCH] D69223: WDocumentation: Implement the \anchor.

2019-12-02 Thread Mark de Wever via Phabricator via cfe-commits
Mordante marked 6 inline comments as done.
Mordante added inline comments.



Comment at: clang/lib/Index/CommentToXML.cpp:650
+assert(C->getNumArgs() == 1);
+Result << "";
+appendToResultWithXMLEscaping(Arg0);

gribozavr2 wrote:
> Sholudn't this code be producing ""?
Good catch, will update it in the next patch.



Comment at: clang/test/Index/Inputs/CommentXML/valid-inline-command-01.xml:1
+
+

gribozavr2 wrote:
> Please add a line to `clang/test/Index/comment-xml-schema.c` that executes 
> this test.
I already added a line.



Comment at: clang/test/Index/comment-xml-schema.c:38
+// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng 
%S/Inputs/CommentXML/valid-inline-command-01.xml
 
 // RUN: not xmllint --noout --relaxng 
%S/../../bindings/xml/comment-xml-schema.rng 
%S/Inputs/CommentXML/invalid-function-01.xml 2>&1 | FileCheck %s 
-check-prefix=CHECK-INVALID

Is this what you meant? Or did you mean something different?


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

https://reviews.llvm.org/D69223



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


[PATCH] D70696: [DebugInfo] Support to emit debugInfo for extern variables

2019-12-02 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

@dblaikie Good points. I will guard external variable debug info generation 
under `-fstandalone-debug` flag.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70696



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


[clang] 8f1e215 - [WebAssembly] Find wasm-opt with GetProgramPath

2019-12-02 Thread Dan Gohman via cfe-commits

Author: Dan Gohman
Date: 2019-12-02T11:48:36-08:00
New Revision: 8f1e2151b8e923345a18aa3025a7d074e134768b

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

LOG: [WebAssembly] Find wasm-opt with GetProgramPath

Instead of just searching for wasm-opt in PATH, use GetProgramPath, which
checks the `COMPILER_PATH` environment variable, -B paths, and `PATH`.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/WebAssembly.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 55b82592c09f..1bb7c35d0c52 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -92,10 +92,10 @@ void wasm::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 
   C.addCommand(std::make_unique(JA, *this, Linker, CmdArgs, Inputs));
 
-  // When optimizing, if wasm-opt is in the PATH, run wasm-opt.
+  // When optimizing, if wasm-opt is available, run it.
   if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
-if (llvm::ErrorOr WasmOptPath =
-   llvm::sys::findProgramByName("wasm-opt")) {
+auto WasmOptPath = getToolChain().GetProgramPath("wasm-opt");
+if (WasmOptPath != "wasm-opt") {
   StringRef OOpt = "s";
   if (A->getOption().matches(options::OPT_O4) ||
   A->getOption().matches(options::OPT_Ofast))
@@ -106,7 +106,7 @@ void wasm::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 OOpt = A->getValue();
 
   if (OOpt != "0") {
-const char *WasmOpt = Args.MakeArgString(*WasmOptPath);
+const char *WasmOpt = Args.MakeArgString(WasmOptPath);
 ArgStringList CmdArgs;
 CmdArgs.push_back(Output.getFilename());
 CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-O") + OOpt));



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


  1   2   >