[PATCH] D71090: [clangd] Navigation from definition of template specialization to primary template

2019-12-07 Thread Nathan Ridge via Phabricator via cfe-commits
nridge marked an inline comment as done.
nridge added inline comments.



Comment at: clang-tools-extra/clangd/XRefs.cpp:240
+// it's more useful to navigate to the template declaration.
+if (Preferred->getLocation() == IdentStartLoc) {
+  if (auto *CTSD = dyn_cast(Preferred)) {

nridge wrote:
> sammccall wrote:
> > sammccall wrote:
> > > Be aware that this is going to break "go to definition" toggling between 
> > > def and decl. I think that's fine.
> > (I think you probably want the macro-arg-expanded location here)
> For what will this break toggling? Aas far as I'm aware, partial and explicit 
> specializations of templates do not have separate declarations.
I stand corrected: I checked, and it seems like specializations can indeed have 
forward declarations.

I expect they are relatively rare, though, and it's probably fine to break 
toggling for them, like you said.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71090



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


[PATCH] D71090: [clangd] Navigation from definition of template specialization to primary template

2019-12-07 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 232725.
nridge marked 2 inline comments as done.
nridge retitled this revision from "[clangd] Navigation from definition of 
template specialization to primary template

Fixes https://github.com/clangd/clangd/issues/212."; to "[clangd] Navigation 
from definition of template specialization to primary template".
nridge edited the summary of this revision.
nridge added a comment.

Address comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71090

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


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -450,7 +450,22 @@
   +^+x;
 }
   )cpp",
-  };
+
+  R"cpp(// Declaration of explicit template specialization
+template 
+struct $decl[[Foo]] {};
+
+template <>
+struct Fo^o {};
+  )cpp",
+
+  R"cpp(// Declaration of partial template specialization
+template 
+struct $decl[[Foo]] {};
+
+template 
+struct Fo^o {};
+  )cpp"};
   for (const char *Test : Tests) {
 Annotations T(Test);
 llvm::Optional WantDecl;
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -191,10 +191,10 @@
 
   // Macros are simple: there's no declaration/definition distinction.
   // As a consequence, there's no need to look them up in the index either.
-  SourceLocation MaybeMacroLocation = SM.getMacroArgExpandedLocation(
+  SourceLocation IdentStartLoc = SM.getMacroArgExpandedLocation(
   getBeginningOfIdentifier(Pos, AST.getSourceManager(), 
AST.getLangOpts()));
   std::vector Result;
-  if (auto M = locateMacroAt(MaybeMacroLocation, AST.getPreprocessor())) {
+  if (auto M = locateMacroAt(IdentStartLoc, AST.getPreprocessor())) {
 if (auto Loc = makeLocation(AST.getASTContext(),
 M->Info->getDefinitionLoc(), *MainFilePath)) {
   LocatedSymbol Macro;
@@ -234,6 +234,18 @@
   for (const Decl *D : getDeclAtPosition(AST, SourceLoc, Relations)) {
 const Decl *Def = getDefinition(D);
 const Decl *Preferred = Def ? Def : D;
+
+// If we're at the point of declaration of a template specialization,
+// it's more useful to navigate to the template declaration.
+if (SM.getMacroArgExpandedLocation(Preferred->getLocation()) ==
+IdentStartLoc) {
+  if (auto *CTSD = dyn_cast(Preferred)) {
+D = CTSD->getSpecializedTemplate();
+Def = getDefinition(D);
+Preferred = Def ? Def : D;
+  }
+}
+
 auto Loc = makeLocation(AST.getASTContext(),
 spellingLocIfSpelled(findName(Preferred), SM),
 *MainFilePath);
@@ -373,8 +385,8 @@
   // different kinds, deduplicate them.
   std::vector Result;
   for (const auto &Ref : References) {
-if (auto Range = getTokenRange(AST.getSourceManager(),
-   AST.getLangOpts(), Ref.Loc)) {
+if (auto Range =
+getTokenRange(AST.getSourceManager(), AST.getLangOpts(), Ref.Loc)) 
{
   DocumentHighlight DH;
   DH.range = *Range;
   if (Ref.Role & index::SymbolRoleSet(index::SymbolRole::Write))


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -450,7 +450,22 @@
   +^+x;
 }
   )cpp",
-  };
+
+  R"cpp(// Declaration of explicit template specialization
+template 
+struct $decl[[Foo]] {};
+
+template <>
+struct Fo^o {};
+  )cpp",
+
+  R"cpp(// Declaration of partial template specialization
+template 
+struct $decl[[Foo]] {};
+
+template 
+struct Fo^o {};
+  )cpp"};
   for (const char *Test : Tests) {
 Annotations T(Test);
 llvm::Optional WantDecl;
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -191,10 +191,10 @@
 
   // Macros are simple: there's no declaration/definition distinction.
   // As a consequence, there's no need to look them up in the index either.
-  SourceLocation MaybeMacroLocation = SM.getMacroArgExpandedLocation(
+  SourceLocation IdentStartLoc = SM.getMacroArgExpandedLocation(
   getBeginningOfIdentifier(Pos, AST.getSourceManager(), AST.getLangOpts()));
   std::vector Result;
-  if (auto M = locateMacroAt(MaybeMacroLocation, AST.get

[PATCH] D71090: [clangd] Navigation from definition of template specialization to primary template

2019-12-07 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe8716a6df7ab: [clangd] Navigation from definition of 
template specialization to primary… (authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71090

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


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -450,7 +450,22 @@
   +^+x;
 }
   )cpp",
-  };
+
+  R"cpp(// Declaration of explicit template specialization
+template 
+struct $decl[[Foo]] {};
+
+template <>
+struct Fo^o {};
+  )cpp",
+
+  R"cpp(// Declaration of partial template specialization
+template 
+struct $decl[[Foo]] {};
+
+template 
+struct Fo^o {};
+  )cpp"};
   for (const char *Test : Tests) {
 Annotations T(Test);
 llvm::Optional WantDecl;
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -191,10 +191,10 @@
 
   // Macros are simple: there's no declaration/definition distinction.
   // As a consequence, there's no need to look them up in the index either.
-  SourceLocation MaybeMacroLocation = SM.getMacroArgExpandedLocation(
+  SourceLocation IdentStartLoc = SM.getMacroArgExpandedLocation(
   getBeginningOfIdentifier(Pos, AST.getSourceManager(), 
AST.getLangOpts()));
   std::vector Result;
-  if (auto M = locateMacroAt(MaybeMacroLocation, AST.getPreprocessor())) {
+  if (auto M = locateMacroAt(IdentStartLoc, AST.getPreprocessor())) {
 if (auto Loc = makeLocation(AST.getASTContext(),
 M->Info->getDefinitionLoc(), *MainFilePath)) {
   LocatedSymbol Macro;
@@ -234,6 +234,18 @@
   for (const Decl *D : getDeclAtPosition(AST, SourceLoc, Relations)) {
 const Decl *Def = getDefinition(D);
 const Decl *Preferred = Def ? Def : D;
+
+// If we're at the point of declaration of a template specialization,
+// it's more useful to navigate to the template declaration.
+if (SM.getMacroArgExpandedLocation(Preferred->getLocation()) ==
+IdentStartLoc) {
+  if (auto *CTSD = dyn_cast(Preferred)) {
+D = CTSD->getSpecializedTemplate();
+Def = getDefinition(D);
+Preferred = Def ? Def : D;
+  }
+}
+
 auto Loc = makeLocation(AST.getASTContext(),
 spellingLocIfSpelled(findName(Preferred), SM),
 *MainFilePath);
@@ -373,8 +385,8 @@
   // different kinds, deduplicate them.
   std::vector Result;
   for (const auto &Ref : References) {
-if (auto Range = getTokenRange(AST.getSourceManager(),
-   AST.getLangOpts(), Ref.Loc)) {
+if (auto Range =
+getTokenRange(AST.getSourceManager(), AST.getLangOpts(), Ref.Loc)) 
{
   DocumentHighlight DH;
   DH.range = *Range;
   if (Ref.Role & index::SymbolRoleSet(index::SymbolRole::Write))


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -450,7 +450,22 @@
   +^+x;
 }
   )cpp",
-  };
+
+  R"cpp(// Declaration of explicit template specialization
+template 
+struct $decl[[Foo]] {};
+
+template <>
+struct Fo^o {};
+  )cpp",
+
+  R"cpp(// Declaration of partial template specialization
+template 
+struct $decl[[Foo]] {};
+
+template 
+struct Fo^o {};
+  )cpp"};
   for (const char *Test : Tests) {
 Annotations T(Test);
 llvm::Optional WantDecl;
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -191,10 +191,10 @@
 
   // Macros are simple: there's no declaration/definition distinction.
   // As a consequence, there's no need to look them up in the index either.
-  SourceLocation MaybeMacroLocation = SM.getMacroArgExpandedLocation(
+  SourceLocation IdentStartLoc = SM.getMacroArgExpandedLocation(
   getBeginningOfIdentifier(Pos, AST.getSourceManager(), AST.getLangOpts()));
   std::vector Result;
-  if (auto M = locateMacroAt(MaybeMacroLocation, AST.getPreprocessor())) {
+  if (auto M = locateMacroAt(IdentStartLoc, AST.getPreprocessor())) {
 if (auto Loc = makeLocation(AST.getASTContext(),
 M->Info->getDefinitionLoc(), *MainFilePath)) {
   

[PATCH] D71090: [clangd] Navigation from definition of template specialization to primary template

2019-12-07 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang-tools-extra/clangd/XRefs.cpp:240
+// it's more useful to navigate to the template declaration.
+if (Preferred->getLocation() == IdentStartLoc) {
+  if (auto *CTSD = dyn_cast(Preferred)) {

sammccall wrote:
> sammccall wrote:
> > Be aware that this is going to break "go to definition" toggling between 
> > def and decl. I think that's fine.
> (I think you probably want the macro-arg-expanded location here)
For what will this break toggling? Aas far as I'm aware, partial and explicit 
specializations of templates do not have separate declarations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71090



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


[clang-tools-extra] e8716a6 - [clangd] Navigation from definition of template specialization to primary template

2019-12-07 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2019-12-08T00:40:45-05:00
New Revision: e8716a6df7abad68b6cf81c437a2e0524e88f3ad

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

LOG: [clangd] Navigation from definition of template specialization to primary 
template

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

Reviewers: sammccall

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

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index 157faf37ea1e..cf5cc4eb273e 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -191,10 +191,10 @@ std::vector locateSymbolAt(ParsedAST &AST, 
Position Pos,
 
   // Macros are simple: there's no declaration/definition distinction.
   // As a consequence, there's no need to look them up in the index either.
-  SourceLocation MaybeMacroLocation = SM.getMacroArgExpandedLocation(
+  SourceLocation IdentStartLoc = SM.getMacroArgExpandedLocation(
   getBeginningOfIdentifier(Pos, AST.getSourceManager(), 
AST.getLangOpts()));
   std::vector Result;
-  if (auto M = locateMacroAt(MaybeMacroLocation, AST.getPreprocessor())) {
+  if (auto M = locateMacroAt(IdentStartLoc, AST.getPreprocessor())) {
 if (auto Loc = makeLocation(AST.getASTContext(),
 M->Info->getDefinitionLoc(), *MainFilePath)) {
   LocatedSymbol Macro;
@@ -234,6 +234,18 @@ std::vector locateSymbolAt(ParsedAST &AST, 
Position Pos,
   for (const Decl *D : getDeclAtPosition(AST, SourceLoc, Relations)) {
 const Decl *Def = getDefinition(D);
 const Decl *Preferred = Def ? Def : D;
+
+// If we're at the point of declaration of a template specialization,
+// it's more useful to navigate to the template declaration.
+if (SM.getMacroArgExpandedLocation(Preferred->getLocation()) ==
+IdentStartLoc) {
+  if (auto *CTSD = dyn_cast(Preferred)) {
+D = CTSD->getSpecializedTemplate();
+Def = getDefinition(D);
+Preferred = Def ? Def : D;
+  }
+}
+
 auto Loc = makeLocation(AST.getASTContext(),
 spellingLocIfSpelled(findName(Preferred), SM),
 *MainFilePath);
@@ -373,8 +385,8 @@ std::vector 
findDocumentHighlights(ParsedAST &AST,
   // 
diff erent kinds, deduplicate them.
   std::vector Result;
   for (const auto &Ref : References) {
-if (auto Range = getTokenRange(AST.getSourceManager(),
-   AST.getLangOpts(), Ref.Loc)) {
+if (auto Range =
+getTokenRange(AST.getSourceManager(), AST.getLangOpts(), Ref.Loc)) 
{
   DocumentHighlight DH;
   DH.range = *Range;
   if (Ref.Role & index::SymbolRoleSet(index::SymbolRole::Write))

diff  --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp 
b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
index b6115065d1b7..ee23522d109a 100644
--- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -450,7 +450,22 @@ TEST(LocateSymbol, All) {
   +^+x;
 }
   )cpp",
-  };
+
+  R"cpp(// Declaration of explicit template specialization
+template 
+struct $decl[[Foo]] {};
+
+template <>
+struct Fo^o {};
+  )cpp",
+
+  R"cpp(// Declaration of partial template specialization
+template 
+struct $decl[[Foo]] {};
+
+template 
+struct Fo^o {};
+  )cpp"};
   for (const char *Test : Tests) {
 Annotations T(Test);
 llvm::Optional WantDecl;



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


[PATCH] D70094: [clang-tidy] new altera ID dependent backward branch check

2019-12-07 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies updated this revision to Diff 232724.
ffrankies marked 2 inline comments as done.
ffrankies added a comment.

Addressed @Eugene.Zelenko's comments on use of `auto`


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

https://reviews.llvm.org/D70094

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/ClangTidyForceLinker.h
  clang-tidy/altera/AlteraTidyModule.cpp
  clang-tidy/altera/CMakeLists.txt
  clang-tidy/altera/IdDependentBackwardBranchCheck.cpp
  clang-tidy/altera/IdDependentBackwardBranchCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/altera-id-dependent-backward-branch.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/checkers/altera-id-dependent-backward-branch.cpp

Index: test/clang-tidy/checkers/altera-id-dependent-backward-branch.cpp
===
--- /dev/null
+++ test/clang-tidy/checkers/altera-id-dependent-backward-branch.cpp
@@ -0,0 +1,83 @@
+// RUN: %check_clang_tidy %s altera-id-dependent-backward-branch %t -- -header-filter=.* "--" -cl-std=CL1.2 -c --include opencl-c.h
+
+typedef struct ExampleStruct {
+  int IDDepField;
+} ExampleStruct;
+
+void error() {
+  //  Assignments 
+  int ThreadID = get_local_id(0); 
+// CHECK-NOTES: :[[@LINE-1]]:3: warning: assignment of ID-dependent variable ThreadID [altera-id-dependent-backward-branch]
+
+  ExampleStruct Example;
+  Example.IDDepField = get_local_id(0);
+// CHECK-NOTES: :[[@LINE-1]]:3: warning: assignment of ID-dependent field IDDepField [altera-id-dependent-backward-branch]
+
+  //  Inferred Assignments 
+  int ThreadID2 = ThreadID * get_local_size(0);
+// CHECK-NOTES: :[[@LINE-1]]:3: warning: inferred assignment of ID-dependent value from ID-dependent variable ThreadID [altera-id-dependent-backward-branch]
+  
+  int ThreadID3 = Example.IDDepField;  // OK: not used in any loops
+
+  ExampleStruct UnusedStruct = {
+ThreadID * 2  // OK: not used in any loops
+  };
+
+  //  Conditional Expressions 
+  int accumulator = 0;
+  for (int i = 0; i < get_local_id(0); i++) {
+// CHECK-NOTES: :[[@LINE-1]]:19: warning: backward branch (for loop) is ID-dependent due to ID function call and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  int j = 0;
+  while (j < get_local_id(0)) {
+// CHECK-NOTES: :[[@LINE-1]]:10: warning: backward branch (while loop) is ID-dependent due to ID function call and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  do {
+accumulator++;
+  } while (j < get_local_id(0));
+  // CHECK-NOTES: :[[@LINE-1]]:12: warning: backward branch (do loop) is ID-dependent due to ID function call and may cause performance degradation [altera-id-dependent-backward-branch]
+  
+  for (int i = 0; i < ThreadID2; i++) {
+// CHECK-NOTES: :[[@LINE-1]]:19: warning: backward branch (for loop) is ID-dependent due to variable reference to 'ThreadID2' and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  while (j < ThreadID) {
+// CHECK-NOTES: :[[@LINE-1]]:10: warning: backward branch (while loop) is ID-dependent due to variable reference to 'ThreadID' and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  do {
+accumulator++;
+  } while (j < ThreadID);
+  // CHECK-NOTES: :[[@LINE-1]]:12: warning: backward branch (do loop) is ID-dependent due to variable reference to 'ThreadID' and may cause performance degradation [altera-id-dependent-backward-branch]
+  
+  for (int i = 0; i < Example.IDDepField; i++) {
+// CHECK-NOTES: :[[@LINE-1]]:19: warning: backward branch (for loop) is ID-dependent due to member reference to 'IDDepField' and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  while (j < Example.IDDepField) {
+// CHECK-NOTES: :[[@LINE-1]]:10: warning: backward branch (while loop) is ID-dependent due to member reference to 'IDDepField' and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  do {
+accumulator++;
+  } while (j < Example.IDDepField);
+  // CHECK-NOTES: :[[@LINE-1]]:12: warning: backward branch (do loop) is ID-dependent due to member reference to 'IDDepField' and may cause performance degradation [altera-id-dependent-backward-branch]
+}
+
+void success() {
+  int accumulator = 0;
+
+  for (int i = 0; i < 1000; i++) {
+if (i < get_local_id(0)) {
+  accumulator++;
+}
+  }
+}
Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -59,6 +59,7 @@
 == =
 ``abseil-``Checks related to Abseil library.
 ``android-``   Checks related to Android.
+``a

[PATCH] D70469: [attributes] [analyzer] Add handle related attributes

2019-12-07 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 232723.

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

https://reviews.llvm.org/D70469

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-handles.cpp

Index: clang/test/Sema/attr-handles.cpp
===
--- /dev/null
+++ clang/test/Sema/attr-handles.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1  -fsyntax-only -verify %s
+
+// Decl annotations.
+void f(int *a __attribute__((acquire_handle)));
+void (*fp)(int handle [[clang::use_handle]]);
+auto lambda = [](int handle [[clang::use_handle]]){};
+void g(int a __attribute__((acquire_handle))); // expected-error {{attribute only applies to output parameters}}
+void h(int *a __attribute__((acquire_handle(1; // expected-error {{'acquire_handle' attribute takes no arguments}}
+__attribute__((release_handle)) int i(); // expected-warning {{'release_handle' attribute only applies to parameters}}
+__attribute__((use_handle)) int j(); // expected-warning {{'use_handle' attribute only applies to parameters}}
+int a __attribute__((acquire_handle)); // expected-warning {{'acquire_handle' attribute only applies to functions, function pointers, and parameters}}
+
+// Type annotations.
+void ft(int __attribute__((acquire_handle)) * a);
+void (*fpt)(int __attribute__((use_handle)) handle);
+auto lambdat = [](int __attribute__((use_handle)) handle) ->
+int __attribute__((acquire_handle)) { return 0; };
+void gt(int __attribute__((acquire_handle)) a); // expected-error {{attribute only applies to output parameters}}
+void ht(int __attribute__((acquire_handle(1))) *a); // expected-error {{'acquire_handle' attribute takes no arguments}}
+int it() __attribute__((release_handle)); // expected-warning {{'release_handle' only applies to non-function types; type here is 'int ()'}}
+int jt() __attribute__((use_handle)); // expected-warning {{'use_handle' only applies to non-function types; type here is 'int ()'}}
+int __attribute__((acquire_handle)) at; // expected-warning {{'acquire_handle' attribute only applies to functions, function pointers, and parameters}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -9,6 +9,7 @@
 // CHECK-NEXT: AMDGPUWavesPerEU (SubjectMatchRule_function)
 // CHECK-NEXT: AVRSignal (SubjectMatchRule_function)
 // CHECK-NEXT: AbiTag (SubjectMatchRule_record_not_is_union, SubjectMatchRule_variable, SubjectMatchRule_function, SubjectMatchRule_namespace)
+// CHECK-NEXT: AcquireHandle (SubjectMatchRule_hasType_functionType, SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: Alias (SubjectMatchRule_function, SubjectMatchRule_variable_is_global)
 // CHECK-NEXT: AlignValue (SubjectMatchRule_variable, SubjectMatchRule_type_alias)
 // CHECK-NEXT: AllocSize (SubjectMatchRule_function)
@@ -128,6 +129,7 @@
 // CHECK-NEXT: ParamTypestate (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: PassObjectSize (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: Pointer (SubjectMatchRule_record_not_is_union)
+// CHECK-NEXT: ReleaseHandle (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: RenderScriptKernel (SubjectMatchRule_function)
 // CHECK-NEXT: ReqdWorkGroupSize (SubjectMatchRule_function)
 // CHECK-NEXT: Restrict (SubjectMatchRule_function)
@@ -145,6 +147,7 @@
 // CHECK-NEXT: Target (SubjectMatchRule_function)
 // CHECK-NEXT: TestTypestate (SubjectMatchRule_function_is_member)
 // CHECK-NEXT: TrivialABI (SubjectMatchRule_record)
+// CHECK-NEXT: UseHandle (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: VecReturn (SubjectMatchRule_record)
 // CHECK-NEXT: VecTypeHint (SubjectMatchRule_function)
 // CHECK-NEXT: WarnUnused (SubjectMatchRule_record)
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -7418,6 +7418,21 @@
  attrKind == ParsedAttr::AT_OpenCLGenericAddressSpace;
 }
 
+template 
+static void handleHandleAttr(TypeProcessingState &State, QualType &CurType,
+ ParsedAttr &Attr) {
+  if (CurType->isFunctionType()) {
+State.getSema().Diag(Attr.getLoc(), diag::warn_type_attribute_wrong_type)
+<< Attr.getAttrName()->getName() << 3 << CurType;
+Attr.setInvalid();
+return;
+  }
+  ASTContext &Ctx = State.getSema().Context;
+  CurType = State.getAttributedType(createSimpleAttr(Ctx, Attr),
+CurType, CurType);
+  Attr.setUsedAsTypeAttr();
+

[PATCH] D70469: [attributes] [analyzer] Add handle related attributes

2019-12-07 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun marked 2 inline comments as done.
xazax.hun added inline comments.



Comment at: clang/test/Sema/attr-handles.cpp:20-21
+void ht(int __attribute__((acquire_handle(1))) *a); // expected-error 
{{'acquire_handle' attribute takes no arguments}}
+int it() __attribute__((release_handle)); // expected-warning 
{{'release_handle' only applies to non-function types; type here is 'int ()'}}
+int jt() __attribute__((use_handle)); // expected-warning {{'use_handle' only 
applies to non-function types; type here is 'int ()'}}
+int __attribute__((acquire_handle)) at; // expected-warning {{'acquire_handle' 
attribute only applies to functions, function pointers, and parameters}}

aaron.ballman wrote:
> These diagnostics look incorrect to me -- I thought we wanted the attribute 
> to apply to function types?
> 
> You should also add some test cases where the attribute is applied to a 
> function pointer type.
I think this one can be a bit confusing. We can apply this to the types of the 
parameter or the return type. I thought restricting to users to put it either 
on the parameter or the return type would make it more obvious what is the 
target of this attribute.  In case this is not idiomatic, I can let the user to 
attach it to the function type. 


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

https://reviews.llvm.org/D70469



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


[PATCH] D68362: [libunwind][RISCV] Add 64-bit RISC-V support

2019-12-07 Thread Mitchell Horne via Phabricator via cfe-commits
mhorne updated this revision to Diff 232721.

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

https://reviews.llvm.org/D68362

Files:
  libunwind/include/__libunwind_config.h
  libunwind/include/libunwind.h
  libunwind/src/Registers.hpp
  libunwind/src/UnwindCursor.hpp
  libunwind/src/UnwindRegistersRestore.S
  libunwind/src/UnwindRegistersSave.S
  libunwind/src/config.h
  libunwind/src/libunwind.cpp

Index: libunwind/src/libunwind.cpp
===
--- libunwind/src/libunwind.cpp
+++ libunwind/src/libunwind.cpp
@@ -58,6 +58,8 @@
 # warning The MIPS architecture is not supported with this ABI and environment!
 #elif defined(__sparc__)
 # define REGISTER_KIND Registers_sparc
+#elif defined(__riscv) && __riscv_xlen == 64
+# define REGISTER_KIND Registers_riscv
 #else
 # error Architecture not supported
 #endif
Index: libunwind/src/config.h
===
--- libunwind/src/config.h
+++ libunwind/src/config.h
@@ -103,7 +103,8 @@
 defined(__ppc__) || defined(__ppc64__) || defined(__powerpc64__) ||\
 (!defined(__APPLE__) && defined(__arm__)) ||   \
 (defined(__arm64__) || defined(__aarch64__)) ||\
-defined(__mips__)
+defined(__mips__) ||   \
+defined(__riscv)
 #if !defined(_LIBUNWIND_BUILD_SJLJ_APIS)
 #define _LIBUNWIND_BUILD_ZERO_COST_APIS
 #endif
Index: libunwind/src/UnwindRegistersSave.S
===
--- libunwind/src/UnwindRegistersSave.S
+++ libunwind/src/UnwindRegistersSave.S
@@ -974,6 +974,86 @@
   std %i6, [%o0 + 120]
   jmp %o7
clr %o0   // return UNW_ESUCCESS
+
+#elif defined(__riscv) && __riscv_xlen == 64
+
+#
+# extern int __unw_getcontext(unw_context_t* thread_state)
+#
+# On entry:
+#  thread_state pointer is in a0
+#
+DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
+  // x0 is zero
+  sdx1, (8 * 1)(a0)
+  sdx2, (8 * 2)(a0)
+  sdx3, (8 * 3)(a0)
+  sdx4, (8 * 4)(a0)
+  sdx5, (8 * 5)(a0)
+  sdx6, (8 * 6)(a0)
+  sdx7, (8 * 7)(a0)
+  sdx8, (8 * 8)(a0)
+  sdx9, (8 * 9)(a0)
+  sdx10, (8 * 10)(a0)
+  sdx11, (8 * 11)(a0)
+  sdx12, (8 * 12)(a0)
+  sdx13, (8 * 13)(a0)
+  sdx14, (8 * 14)(a0)
+  sdx15, (8 * 15)(a0)
+  sdx16, (8 * 16)(a0)
+  sdx17, (8 * 17)(a0)
+  sdx18, (8 * 18)(a0)
+  sdx19, (8 * 19)(a0)
+  sdx20, (8 * 20)(a0)
+  sdx21, (8 * 21)(a0)
+  sdx22, (8 * 22)(a0)
+  sdx23, (8 * 23)(a0)
+  sdx24, (8 * 24)(a0)
+  sdx25, (8 * 25)(a0)
+  sdx26, (8 * 26)(a0)
+  sdx27, (8 * 27)(a0)
+  sdx28, (8 * 28)(a0)
+  sdx29, (8 * 29)(a0)
+  sdx30, (8 * 30)(a0)
+  sdx31, (8 * 31)(a0)
+
+#if defined(__riscv_flen) && __riscv_flen == 64
+  fsdf0, (8 * 32 + 8 * 0)(a0)
+  fsdf1, (8 * 32 + 8 * 1)(a0)
+  fsdf2, (8 * 32 + 8 * 2)(a0)
+  fsdf3, (8 * 32 + 8 * 3)(a0)
+  fsdf4, (8 * 32 + 8 * 4)(a0)
+  fsdf5, (8 * 32 + 8 * 5)(a0)
+  fsdf6, (8 * 32 + 8 * 6)(a0)
+  fsdf7, (8 * 32 + 8 * 7)(a0)
+  fsdf8, (8 * 32 + 8 * 8)(a0)
+  fsdf9, (8 * 32 + 8 * 9)(a0)
+  fsdf10, (8 * 32 + 8 * 10)(a0)
+  fsdf11, (8 * 32 + 8 * 11)(a0)
+  fsdf12, (8 * 32 + 8 * 12)(a0)
+  fsdf13, (8 * 32 + 8 * 13)(a0)
+  fsdf14, (8 * 32 + 8 * 14)(a0)
+  fsdf15, (8 * 32 + 8 * 15)(a0)
+  fsdf16, (8 * 32 + 8 * 16)(a0)
+  fsdf17, (8 * 32 + 8 * 17)(a0)
+  fsdf18, (8 * 32 + 8 * 18)(a0)
+  fsdf19, (8 * 32 + 8 * 19)(a0)
+  fsdf20, (8 * 32 + 8 * 20)(a0)
+  fsdf21, (8 * 32 + 8 * 21)(a0)
+  fsdf22, (8 * 32 + 8 * 22)(a0)
+  fsdf23, (8 * 32 + 8 * 23)(a0)
+  fsdf24, (8 * 32 + 8 * 24)(a0)
+  fsdf25, (8 * 32 + 8 * 25)(a0)
+  fsdf26, (8 * 32 + 8 * 26)(a0)
+  fsdf27, (8 * 32 + 8 * 27)(a0)
+  fsdf28, (8 * 32 + 8 * 28)(a0)
+  fsdf29, (8 * 32 + 8 * 29)(a0)
+  fsdf30, (8 * 32 + 8 * 30)(a0)
+  fsdf31, (8 * 32 + 8 * 31)(a0)
+#endif
+
+  li a0, 0  // return UNW_ESUCCESS
+  ret   // jump to ra
 #endif
 
   WEAK_ALIAS(__unw_getcontext, unw_getcontext)
Index: libunwind/src/UnwindRegistersRestore.S
===
--- libunwind/src/UnwindRegistersRestore.S
+++ libunwind/src/UnwindRegistersRestore.S
@@ -1029,6 +1029,87 @@
   jmp %o7
nop
 
+#elif defined(__riscv) && __riscv_xlen == 64
+
+//
+// void libunwind::Registers_riscv::jumpto()
+//
+// On entry:
+//  thread_state pointer is in a0
+//
+  .p2align 2
+DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind15Registers_riscv6jumptoEv)
+#if defined(__riscv_flen) && __riscv_flen == 64
+  fldf0, (8 * 32 + 8 * 0)(a0)
+  fldf1, (8 * 32 + 8 * 1)(a0)
+  fldf2, (8 * 32 + 8 * 2)(a0)
+  fldf3, (8 * 32 + 8 * 3)(a0)
+  fldf4, (8 * 32 + 8 * 4)(a0)
+  fldf5, (8 * 32 + 8 * 5)(a0)
+  fldf6, (8 * 32 + 8 * 6)

[PATCH] D71166: Deprecate the hasDefaultArgument matcher

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

LGTM with a small doc request.




Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:6555
+/// \endcode
+/// parmVarDecl(hasInitializer(integerLiteral(equals(42
+///   matches the parameter of y

It would probably be useful to show an equivalent expression to 
`hasDefaultArgument()` as well, e.g., `parmVarDecl(hasInitializer(anything()))`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71166



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


[PATCH] D71167: [Driver] Default to -momit-leaf-frame-pointer for AArch64

2019-12-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: c-rhodes, efriedma, rengolin, sdesmalen.
Herald added subscribers: cfe-commits, kristof.beyls.
Herald added a project: clang.

This matches https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html

> -momit-leaf-frame-pointer
> -mno-omit-leaf-frame-pointer
> 
>   Omit or keep the frame pointer in leaf functions. The former behavior is 
> the default.

-mno-omit-leaf-frame-pointer is currently a no-op because
TargetOptions::DisableFramePointerElim is only considered for non-leaf
functions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71167

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/frame-pointer-elim.c


Index: clang/test/Driver/frame-pointer-elim.c
===
--- clang/test/Driver/frame-pointer-elim.c
+++ clang/test/Driver/frame-pointer-elim.c
@@ -90,7 +90,9 @@
 // WARN-OMIT-LEAF-7S-NOT: warning: optimization flag 
'-momit-leaf-frame-pointer' is not supported for target 'armv7s'
 // WARN-OMIT-LEAF-7S: "-mframe-pointer=non-leaf"
 
-// On the PS4, we default to omitting the frame pointer on leaf functions
+// On AArch64 and PS4, default to omitting the frame pointer on leaf functions
+// RUN: %clang -### -target aarch64 -S %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
 // RUN: %clang -### -target x86_64-scei-ps4 -S %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
 // RUN: %clang -### -target x86_64-scei-ps4 -S -O2 %s 2>&1 | \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -603,9 +603,9 @@
   bool OmitFP = A && A->getOption().matches(options::OPT_fomit_frame_pointer);
   bool NoOmitFP =
   A && A->getOption().matches(options::OPT_fno_omit_frame_pointer);
-  bool KeepLeaf =
-  Args.hasFlag(options::OPT_momit_leaf_frame_pointer,
-   options::OPT_mno_omit_leaf_frame_pointer, 
Triple.isPS4CPU());
+  bool KeepLeaf = Args.hasFlag(options::OPT_momit_leaf_frame_pointer,
+   options::OPT_mno_omit_leaf_frame_pointer,
+   Triple.isAArch64() || Triple.isPS4CPU());
   if (NoOmitFP || mustUseNonLeafFramePointerForTarget(Triple) ||
   (!OmitFP && useFramePointerForTargetByDefault(Args, Triple))) {
 if (KeepLeaf)


Index: clang/test/Driver/frame-pointer-elim.c
===
--- clang/test/Driver/frame-pointer-elim.c
+++ clang/test/Driver/frame-pointer-elim.c
@@ -90,7 +90,9 @@
 // WARN-OMIT-LEAF-7S-NOT: warning: optimization flag '-momit-leaf-frame-pointer' is not supported for target 'armv7s'
 // WARN-OMIT-LEAF-7S: "-mframe-pointer=non-leaf"
 
-// On the PS4, we default to omitting the frame pointer on leaf functions
+// On AArch64 and PS4, default to omitting the frame pointer on leaf functions
+// RUN: %clang -### -target aarch64 -S %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
 // RUN: %clang -### -target x86_64-scei-ps4 -S %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
 // RUN: %clang -### -target x86_64-scei-ps4 -S -O2 %s 2>&1 | \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -603,9 +603,9 @@
   bool OmitFP = A && A->getOption().matches(options::OPT_fomit_frame_pointer);
   bool NoOmitFP =
   A && A->getOption().matches(options::OPT_fno_omit_frame_pointer);
-  bool KeepLeaf =
-  Args.hasFlag(options::OPT_momit_leaf_frame_pointer,
-   options::OPT_mno_omit_leaf_frame_pointer, Triple.isPS4CPU());
+  bool KeepLeaf = Args.hasFlag(options::OPT_momit_leaf_frame_pointer,
+   options::OPT_mno_omit_leaf_frame_pointer,
+   Triple.isAArch64() || Triple.isPS4CPU());
   if (NoOmitFP || mustUseNonLeafFramePointerForTarget(Triple) ||
   (!OmitFP && useFramePointerForTargetByDefault(Args, Triple))) {
 if (KeepLeaf)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71166: Deprecate the hasDefaultArgument matcher

2019-12-07 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

It doesn't provide a way to match on the contents of the default
argumment.  Rather than give it that capability, make it deprecated and
recomment the use of hasInitializer instead.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71166

Files:
  clang/include/clang/ASTMatchers/ASTMatchers.h


Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -6544,6 +6544,16 @@
 /// void x(int val) {}
 /// void y(int val = 0) {}
 /// \endcode
+///
+/// Deprecated. Use hasInitializer() instead to be able to
+/// match on the contents of the default argument.  For example:
+///
+/// \code
+/// void x(int val = 7) {}
+/// void y(int val = 42) {}
+/// \endcode
+/// parmVarDecl(hasInitializer(integerLiteral(equals(42
+///   matches the parameter of y
 AST_MATCHER(ParmVarDecl, hasDefaultArgument) {
   return Node.hasDefaultArg();
 }


Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -6544,6 +6544,16 @@
 /// void x(int val) {}
 /// void y(int val = 0) {}
 /// \endcode
+///
+/// Deprecated. Use hasInitializer() instead to be able to
+/// match on the contents of the default argument.  For example:
+///
+/// \code
+/// void x(int val = 7) {}
+/// void y(int val = 42) {}
+/// \endcode
+/// parmVarDecl(hasInitializer(integerLiteral(equals(42
+///   matches the parameter of y
 AST_MATCHER(ParmVarDecl, hasDefaultArgument) {
   return Node.hasDefaultArg();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71018: [ASTImporter] Improved import of TypeSourceInfo (TypeLoc)

2019-12-07 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin added a comment.

Finally, this FIXME is addressed. Thanks! Are you going to add any tests in the 
following patches?
It looks almost good to me, but I have a question inline.




Comment at: clang/lib/AST/ASTImporter.cpp:7914
+
+#define IMPORT_TYPE_LOC(NAME)  
\
+  if (auto ImpOrErr = Importer.Import(From.get##NAME()))   
\

IMPORT_TYPE_LOC_ELEMENT_OR_RETURN_ERROR.



Comment at: clang/lib/AST/ASTImporter.cpp:8043
+
+  Error VisitFunctionTypeLoc(FunctionTypeLoc From) {
+auto To = ToL.castAs();

Does this import interacts well with type loc import partially done at L3258 
(VisitFunctionDecl)? Should we merge them?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71018



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


[PATCH] D71159: [Attr] Move ParsedTargetAttr out of the TargetAttr class

2019-12-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM


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

https://reviews.llvm.org/D71159



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


[clang-tools-extra] 6dcb100 - Optionally exclude bitfield definitions from magic numbers check

2019-12-07 Thread Aaron Ballman via cfe-commits

Author: Florin Iucha
Date: 2019-12-07T12:33:10-05:00
New Revision: 6dcb1003f2022cba36e9f5a6d39648c3a3a213a0

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

LOG: Optionally exclude bitfield definitions from magic numbers check

Adds the IgnoreBitFieldsWidths option to readability-magic-numbers.

Added: 

clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers-bitfields.cpp

Modified: 
clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.h
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/readability-magic-numbers.rst
clang-tools-extra/test/clang-tidy/checkers/readability-magic-numbers.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
index 39aaf89901f2..6f6366cab6f6 100644
--- a/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
@@ -21,12 +21,12 @@
 using namespace clang::ast_matchers;
 using namespace clang::ast_type_traits;
 
-namespace {
+namespace clang {
 
-bool isUsedToInitializeAConstant(const MatchFinder::MatchResult &Result,
- const DynTypedNode &Node) {
+static bool isUsedToInitializeAConstant(const MatchFinder::MatchResult &Result,
+const DynTypedNode &Node) {
 
-  const auto *AsDecl = Node.get();
+  const auto *AsDecl = Node.get();
   if (AsDecl) {
 if (AsDecl->getType().isConstQualified())
   return true;
@@ -34,7 +34,7 @@ bool isUsedToInitializeAConstant(const 
MatchFinder::MatchResult &Result,
 return AsDecl->isImplicit();
   }
 
-  if (Node.get() != nullptr)
+  if (Node.get() != nullptr)
 return true;
 
   return llvm::any_of(Result.Context->getParents(Node),
@@ -43,9 +43,18 @@ bool isUsedToInitializeAConstant(const 
MatchFinder::MatchResult &Result,
   });
 }
 
-} // namespace
+static bool isUsedToDefineABitField(const MatchFinder::MatchResult &Result,
+const DynTypedNode &Node) {
+  const auto *AsFieldDecl = Node.get();
+  if (AsFieldDecl && AsFieldDecl->isBitField())
+return true;
+
+  return llvm::any_of(Result.Context->getParents(Node),
+  [&Result](const DynTypedNode &Parent) {
+return isUsedToDefineABitField(Result, Parent);
+  });
+}
 
-namespace clang {
 namespace tidy {
 namespace readability {
 
@@ -56,6 +65,7 @@ MagicNumbersCheck::MagicNumbersCheck(StringRef Name, 
ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
   IgnoreAllFloatingPointValues(
   Options.get("IgnoreAllFloatingPointValues", false)),
+  IgnoreBitFieldsWidths(Options.get("IgnoreBitFieldsWidths", true)),
   IgnorePowersOf2IntegerValues(
   Options.get("IgnorePowersOf2IntegerValues", false)) {
   // Process the set of ignored integer values.
@@ -165,6 +175,16 @@ bool MagicNumbersCheck::isSyntheticValue(const 
SourceManager *SourceManager,
   return BufferIdentifier.empty();
 }
 
+bool MagicNumbersCheck::isBitFieldWidth(
+const clang::ast_matchers::MatchFinder::MatchResult &Result,
+const IntegerLiteral &Literal) const {
+  return IgnoreBitFieldsWidths &&
+ llvm::any_of(Result.Context->getParents(Literal),
+  [&Result](const DynTypedNode &Parent) {
+return isUsedToDefineABitField(Result, Parent);
+  });
+}
+
 } // namespace readability
 } // namespace tidy
 } // namespace clang

diff  --git a/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.h 
b/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.h
index e59ca1759670..0cf7419d703c 100644
--- a/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.h
+++ b/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.h
@@ -40,10 +40,17 @@ class MagicNumbersCheck : public ClangTidyCheck {
 const FloatingLiteral *) const {
 return false;
   }
-
   bool isSyntheticValue(const clang::SourceManager *SourceManager,
 const IntegerLiteral *Literal) const;
 
+  bool isBitFieldWidth(const clang::ast_matchers::MatchFinder::MatchResult &,
+   const FloatingLiteral &) const {
+ return false;
+  }
+
+  bool isBitFieldWidth(const clang::ast_matchers::MatchFinder::MatchResult 
&Result,
+   const IntegerLiteral &Literal) const;
+
   template 
   void checkBoundMatch(const ast_matchers::MatchFinder::MatchResult &Result,
const char *BoundName) {
@@ -64,6 +71,9 @@ class MagicN

[PATCH] D71020: [ASTImporter] Friend class decl should not be visible in its context

2019-12-07 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin added a comment.

Hi Gabor,
This patch looks mostly good to me. Thanks!




Comment at: clang/lib/AST/ASTImporter.cpp:334
+  FromDC->lookup(FromNamed->getDeclName());
+  if (std::find(FromLookup.begin(), FromLookup.end(), FromNamed) !=
+  FromLookup.end())

llvm::is_contained?



Comment at: clang/unittests/AST/ASTImporterTest.cpp:258
+static const RecordDecl *getRecordDeclOfFriend(FriendDecl *FD) {
+  QualType Ty = FD->getFriendType()->getType();
+  if (auto *Inner = dyn_cast(Ty.getTypePtr())) {

Why don't we use getCanonicalType() anymore?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71020



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


[PATCH] D62686: [RISCV] Add support for save/restore of callee-saved registers via libcalls

2019-12-07 Thread Lewis Revill via Phabricator via cfe-commits
lewis-revill updated this revision to Diff 232702.
lewis-revill added a comment.

Rebased.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62686

Files:
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-features.c
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
  llvm/lib/Target/RISCV/RISCVFrameLowering.h
  llvm/lib/Target/RISCV/RISCVMachineFunctionInfo.h
  llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
  llvm/lib/Target/RISCV/RISCVRegisterInfo.h
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/CodeGen/RISCV/saverestore.ll
  llvm/test/CodeGen/RISCV/shrinkwrap.ll

Index: llvm/test/CodeGen/RISCV/shrinkwrap.ll
===
--- llvm/test/CodeGen/RISCV/shrinkwrap.ll
+++ llvm/test/CodeGen/RISCV/shrinkwrap.ll
@@ -1,6 +1,8 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -mtriple riscv32 < %s | FileCheck %s -check-prefix=RV32I-NOSW
 ; RUN: llc -mtriple riscv32 -enable-shrink-wrap < %s | FileCheck %s -check-prefix=RV32I-SW
+; RUN: llc -mtriple riscv32 -enable-shrink-wrap -mattr=+save-restore < %s \
+; RUN: | FileCheck %s -check-prefix=RV32I-SW-SR
 
 
 declare void @abort()
@@ -29,6 +31,16 @@
 ; RV32I-SW-NEXT:addi sp, sp, -16
 ; RV32I-SW-NEXT:sw ra, 12(sp)
 ; RV32I-SW-NEXT:call abort
+;
+; RV32I-SW-SR-LABEL: eliminate_restore:
+; RV32I-SW-SR:   # %bb.0:
+; RV32I-SW-SR-NEXT:addi a1, zero, 32
+; RV32I-SW-SR-NEXT:bgeu a1, a0, .LBB0_2
+; RV32I-SW-SR-NEXT:  # %bb.1: # %if.end
+; RV32I-SW-SR-NEXT:ret
+; RV32I-SW-SR-NEXT:  .LBB0_2: # %if.then
+; RV32I-SW-SR-NEXT:call t0, __riscv_save_0
+; RV32I-SW-SR-NEXT:call abort
   %cmp = icmp ule i32 %n, 32
   br i1 %cmp, label %if.then, label %if.end
 
@@ -84,6 +96,23 @@
 ; RV32I-SW-NEXT:addi sp, sp, 16
 ; RV32I-SW-NEXT:  .LBB1_2: # %if.end
 ; RV32I-SW-NEXT:ret
+;
+; RV32I-SW-SR-LABEL: conditional_alloca:
+; RV32I-SW-SR:   # %bb.0:
+; RV32I-SW-SR-NEXT:addi a1, zero, 32
+; RV32I-SW-SR-NEXT:bltu a1, a0, .LBB1_2
+; RV32I-SW-SR-NEXT:  # %bb.1: # %if.then
+; RV32I-SW-SR-NEXT:call t0, __riscv_save_1
+; RV32I-SW-SR-NEXT:addi s0, sp, 16
+; RV32I-SW-SR-NEXT:addi a0, a0, 15
+; RV32I-SW-SR-NEXT:andi a0, a0, -16
+; RV32I-SW-SR-NEXT:sub a0, sp, a0
+; RV32I-SW-SR-NEXT:mv sp, a0
+; RV32I-SW-SR-NEXT:call notdead
+; RV32I-SW-SR-NEXT:addi sp, s0, -16
+; RV32I-SW-SR-NEXT:tail __riscv_restore_1
+; RV32I-SW-SR-NEXT:  .LBB1_2: # %if.end
+; RV32I-SW-SR-NEXT:ret
   %cmp = icmp ule i32 %n, 32
   br i1 %cmp, label %if.then, label %if.end
 
Index: llvm/test/CodeGen/RISCV/saverestore.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/saverestore.ll
@@ -0,0 +1,299 @@
+; RUN: llc -mtriple=riscv32 < %s | FileCheck %s -check-prefix=RV32I
+; RUN: llc -mtriple=riscv64 < %s | FileCheck %s -check-prefix=RV64I
+; RUN: llc -mtriple=riscv32 -mattr=+save-restore < %s | FileCheck %s -check-prefix=RV32I-SR
+; RUN: llc -mtriple=riscv64 -mattr=+save-restore < %s | FileCheck %s -check-prefix=RV64I-SR
+; RUN: llc -mtriple=riscv32 -mattr=+f,+save-restore -target-abi=ilp32f < %s | FileCheck %s -check-prefix=RV32I-FP-SR
+; RUN: llc -mtriple=riscv64 -mattr=+f,+d,+save-restore -target-abi=lp64d < %s | FileCheck %s -check-prefix=RV64I-FP-SR
+
+; Check that the correct save/restore libcalls are generated.
+
+@var0 = global [18 x i32] zeroinitializer
+@var1 = global [24 x i32] zeroinitializer
+@var2 = global [30 x i32] zeroinitializer
+
+define void @callee_saved0() nounwind {
+; RV32I-LABEL: callee_saved0:
+; RV32I-NOT: call t0, __riscv_save
+; RV32I-NOT: tail __riscv_restore
+;
+; RV64I-LABEL: callee_saved0:
+; RV64I-NOT: call t0, __riscv_save
+; RV64I-NOT: tail __riscv_restore
+;
+; RV32I-SR-LABEL: callee_saved0:
+; RV32I-SR: call t0, __riscv_save_5
+; RV32I-SR: tail __riscv_restore_5
+;
+; RV64I-SR-LABEL: callee_saved0:
+; RV64I-SR: call t0, __riscv_save_5
+; RV64I-SR: tail __riscv_restore_5
+;
+; RV32I-FP-SR-LABEL: callee_saved0:
+; RV32I-FP-SR: call t0, __riscv_save_5
+; RV32I-FP-SR: tail __riscv_restore_5
+;
+; RV64I-FP-SR-LABEL: callee_saved0:
+; RV64I-FP-SR: call t0, __riscv_save_5
+; RV64I-FP-SR: tail __riscv_restore_5
+  %val = load [18 x i32], [18 x i32]* @var0
+  store volatile [18 x i32] %val, [18 x i32]* @var0
+  ret void
+}
+
+define void @callee_saved1() nounwind {
+; RV32I-LABEL: callee_saved1:
+; RV32I-NOT: call t0, __riscv_save
+; RV32I-NOT: tail __riscv_restore
+;
+; RV64I-LABEL: callee_saved1:
+; RV64I-NOT: call t0, __riscv_save
+; RV64I-NOT: tail __riscv_restore
+;
+; RV32I-SR-LABEL: callee_saved1:
+; RV32I-SR: call t0, __riscv_save_11
+; RV32I-SR: tail __riscv_restore_11
+;
+; RV64I-SR-LABEL: callee_saved1:
+;

[PATCH] D71159: [Attr] Move ParsedTargetAttr out of the TargetAttr class

2019-12-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.

Lg


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

https://reviews.llvm.org/D71159



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


[PATCH] D70469: [attributes] [analyzer] Add handle related attributes

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



Comment at: clang/lib/Sema/SemaType.cpp:7424
+ ParsedAttr &Attr) {
+  if (CurType->isFunctionType()) {
+State.getSema().Diag(Attr.getLoc(), diag::warn_type_attribute_wrong_type)

Is this correct, or should it be `if (!CurType->isFunctionType())`?



Comment at: clang/test/Sema/attr-handles.cpp:20-21
+void ht(int __attribute__((acquire_handle(1))) *a); // expected-error 
{{'acquire_handle' attribute takes no arguments}}
+int it() __attribute__((release_handle)); // expected-warning 
{{'release_handle' only applies to non-function types; type here is 'int ()'}}
+int jt() __attribute__((use_handle)); // expected-warning {{'use_handle' only 
applies to non-function types; type here is 'int ()'}}
+int __attribute__((acquire_handle)) at; // expected-warning {{'acquire_handle' 
attribute only applies to functions, function pointers, and parameters}}

These diagnostics look incorrect to me -- I thought we wanted the attribute to 
apply to function types?

You should also add some test cases where the attribute is applied to a 
function pointer type.



Comment at: clang/test/Sema/attr-handles.cpp:23
+int __attribute__((acquire_handle)) at; // expected-warning {{'acquire_handle' 
attribute only applies to functions, function pointers, and parameters}}
\ No newline at end of file


Please add the newline to the end of the file.


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

https://reviews.llvm.org/D70469



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


[PATCH] D71142: [Sema] Validate large bitfields

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

In D71142#1773933 , @Mordante wrote:

> I'll have a look whether I can find a sane maximum width for a bit-field.


The limits according to C are the size of the field's declared type (C17 
6.7.2.1p4), but it seems that C++ decided it would make sense to turn the bits 
into padding bits (http://eel.is/c++draft/class.bit#1.sentence-6), so I guess a 
reasonable implementation limit would be `SIZE_MAX` for the target architecture 
(aka, `sizeof(size_t) * CHAR_BIT` bits).




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:5186-5189
+def warn_bitfield_width_exceeds_maximum_width: Error<
+  "width of bit-field %0 doesn't fit in a 64 bit unsigned integer">;
+def warn_anon_bitfield_width_exceeds_maximum_width : Error<
+  "width of anonymous bit-field doesn't fit in a 64 bit unsigned integer">;

rsmith wrote:
> aaron.ballman wrote:
> > I feel like this situation should be an error rather than a warning -- what 
> > could the code possibly have meant?
> The name of the diagnostic and the kind of diagnostic should agree. Currently 
> we have `warn_` vs `Error<`.
Ooof, good catch! These diagnostics should be renamed to start with `err_` 
instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71142



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


[PATCH] D71141: [Wdocumentation] Use C2x/C++14 deprecated attribute

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

LGTM!




Comment at: clang/lib/AST/CommentSema.cpp:693
+StringRef AttributeSpelling =
+CPlusPlus14 ? "[[deprecated]]" : "__attribute__((deprecated))";
 if (PP) {

Mordante wrote:
> Mordante wrote:
> > aaron.ballman wrote:
> > > Mordante wrote:
> > > > aaron.ballman wrote:
> > > > > This attribute also exists with this spelling in C2x, FWIW.
> > > > True, but unless I'm mistaken `CPlusPlus17` and `CPlusPlus2a` also 
> > > > include `CPlusPlus14`. Do you prefer a different name for the Boolean?
> > > I'm talking about C2x, not C++2a. The name for the variable is fine, but 
> > > we should prefer `[[deprecated]]` in C2x mode to 
> > > `__attribute__((deprecated))`.
> > > 
> > > I think the correct predicate is: 
> > > `getLangOpts().DoubleSquareBracketAttributes` -- if the user says they 
> > > want to use double-square bracket attributes, we should probably prefer 
> > > them to GNU-style attributes.
> > Ah sorry I misread. I'll have a look at C2x. Thanks for the information.
> `getLangOpts().DoubleSquareBracketAttributes` will not work since it includes 
> C++11, which doesn't support `[[deprecated]]`, so I will just test for C++14 
> and C2x.
> (I had a look at the proper syntax in C2x and found N2334 ;-))
> getLangOpts().DoubleSquareBracketAttributes will not work since it includes 
> C++11, which doesn't support [[deprecated]], so I will just test for C++14 
> and C2x.

We support `[[deprecated]]` in C++11 mode as an extension, but I suppose the 
concern there is pedantic warnings?

I think what you're doing now is fine, but it suggests that we need a better 
interface to `clang::hasAttribute()` so that you can test for support through 
the same machinery as `__has_cpp_attribute`/`__has_c_attribute`. It wouldn't be 
suitable to use here because you want to know something more specific than it 
can tell you (whether the attribute can be used without triggering an extension 
diagnostic), but this seems like a reasonable utility for us to have someday.


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

https://reviews.llvm.org/D71141



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


[PATCH] D71154: Driver: Don't look for libc++ headers in the install directory on Android.

2019-12-07 Thread David Zarzycki via Phabricator via cfe-commits
davezarzycki added a comment.

Can we revert this? It doesn't seem to work on my Fedora 31 box:

  FAIL: Clang :: Driver/android-no-installed-libcxx.cpp (9249 of 59761)
   TEST 'Clang :: Driver/android-no-installed-libcxx.cpp' 
FAILED 
  Script:
  --
  : 'RUN: at line 4';   mkdir -p 
/tmp/_update_lc/r/tools/clang/test/Driver/Output/android-no-installed-libcxx.cpp.tmp/bin
  : 'RUN: at line 5';   mkdir -p 
/tmp/_update_lc/r/tools/clang/test/Driver/Output/android-no-installed-libcxx.cpp.tmp/include/c++/v1
  : 'RUN: at line 6';   /tmp/_update_lc/r/bin/clang -target 
aarch64-linux-android -ccc-install-dir 
/tmp/_update_lc/r/tools/clang/test/Driver/Output/android-no-installed-libcxx.cpp.tmp/bin
-stdlib=libc++ -fsyntax-only 
/home/dave/s/lp/clang/test/Driver/android-no-installed-libcxx.cpp -### 2>&1 | 
/tmp/_update_lc/r/bin/FileCheck 
/home/dave/s/lp/clang/test/Driver/android-no-installed-libcxx.cpp
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  /home/dave/s/lp/clang/test/Driver/android-no-installed-libcxx.cpp:8:15: 
error: CHECK-NOT: excluded string found in input
  // CHECK-NOT: "-internal-isystem" "{{.*}}v1"
^
  :5:653: note: found here
   "/tmp/_update_lc/r/bin/clang-10" "-cc1" "-triple" 
"aarch64-unknown-linux-android" "-fsyntax-only" "-disable-free" 
"-disable-llvm-verifier" "-discard-value-names" "-main-file-name" 
"android-no-installed-libcxx.cpp" "-mrelocation-model" "pic" "-pic-level" "2" 
"-pic-is-pie" "-mthread-model" "posix" "-mframe-pointer=all" 
"-fno-rounding-math" "-masm-verbose" "-mconstructor-aliases" "-fuse-init-array" 
"-target-cpu" "generic" "-target-feature" "+neon" "-target-abi" "aapcs" 
"-mllvm" "-aarch64-fix-cortex-a53-835769=1" 
"-fallow-half-arguments-and-returns" "-dwarf-column-info" 
"-debugger-tuning=gdb" "-resource-dir" "/tmp/_update_lc/r/lib64/clang/10.0.0" 
"-internal-isystem" "/usr/include/c++/v1" "-internal-isystem" 
"/usr/local/include" "-internal-isystem" 
"/tmp/_update_lc/r/lib64/clang/10.0.0/include" "-internal-externc-isystem" 
"/include" "-internal-externc-isystem" "/usr/include" "-fdeprecated-macro" 
"-fdebug-compilation-dir" "/tmp/_update_lc/r/tools/clang/test/Driver" 
"-ferror-limit" "19" "-fmessage-length" "0" "-fno-signed-char" 
"-fgnuc-version=4.2.1" "-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions" 
"-fdiagnostics-show-option" "-x" "c++" 
"/home/dave/s/lp/clang/test/Driver/android-no-installed-libcxx.cpp"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71154



___
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-07 Thread Gabor Marton via Phabricator via cfe-commits
martong added a reviewer: teemperor.
martong marked an inline comment as done.
martong added inline comments.



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.

martong wrote:
> 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
> ```
So, this means that the type information is transformed during the include 
expansion. That is very strange.
I think, I'll have an email to cfe-dev, maybe others have some insights on this.


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-07 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin accepted this revision.
a_sidorin added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!
Let's wait for Shafik's comments before committing this.




Comment at: clang/lib/AST/ASTImporter.cpp:48
 #include "clang/Basic/Builtins.h"
+#include "clang/Basic/DiagnosticSema.h"
 #include "clang/Basic/ExceptionSpecificationType.h"

Do we use this new include?


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] D71134: [OpenMP] Require trivially copyable type for mapping

2019-12-07 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Hahnfeld marked an inline comment as done.
Closed by commit rG071dca24cea9: [OpenMP] Require trivially copyable type for 
mapping (authored by Hahnfeld).

Changed prior to commit:
  https://reviews.llvm.org/D71134?vs=232610&id=232696#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71134

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/distribute_firstprivate_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_private_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_aligned_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_shared_messages.cpp
  clang/test/OpenMP/distribute_simd_aligned_messages.cpp
  clang/test/OpenMP/distribute_simd_firstprivate_messages.cpp
  clang/test/OpenMP/distribute_simd_lastprivate_messages.cpp
  clang/test/OpenMP/distribute_simd_linear_messages.cpp
  clang/test/OpenMP/distribute_simd_loop_messages.cpp
  clang/test/OpenMP/distribute_simd_private_messages.cpp
  clang/test/OpenMP/distribute_simd_reduction_messages.cpp
  clang/test/OpenMP/target_firstprivate_messages.cpp
  clang/test/OpenMP/target_parallel_for_private_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_private_messages.cpp
  clang/test/OpenMP/target_private_messages.cpp
  clang/test/OpenMP/target_simd_private_messages.cpp
  clang/test/OpenMP/target_teams_distribute_firstprivate_messages.cpp
  clang/test/OpenMP/teams_distribute_loop_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_loop_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_aligned_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_loop_messages.cpp
  clang/test/OpenMP/teams_distribute_simd_aligned_messages.cpp
  clang/test/OpenMP/teams_distribute_simd_linear_messages.cpp
  clang/test/OpenMP/teams_distribute_simd_loop_messages.cpp

Index: clang/test/OpenMP/teams_distribute_simd_loop_messages.cpp
===
--- clang/test/OpenMP/teams_distribute_simd_loop_messages.cpp
+++ clang/test/OpenMP/teams_distribute_simd_loop_messages.cpp
@@ -416,7 +416,7 @@
   Iter0 begin0, end0;
 #pragma omp target
 #pragma omp teams distribute simd
-  for (GoodIter I = begin; I < end; ++I) // expected-warning 2 {{Non-trivial type 'GoodIter' is mapped, only trivial types are guaranteed to be mapped correctly}}
+  for (GoodIter I = begin; I < end; ++I) // expected-warning 2 {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
 ++I;
 #pragma omp target
 #pragma omp teams distribute simd
@@ -425,31 +425,31 @@
 ++I;
 #pragma omp target
 #pragma omp teams distribute simd
-  for (GoodIter I = begin; I >= end; --I) // expected-warning 2 {{Non-trivial type 'GoodIter' is mapped, only trivial types are guaranteed to be mapped correctly}}
+  for (GoodIter I = begin; I >= end; --I) // expected-warning 2 {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
 ++I;
 #pragma omp target
 #pragma omp teams distribute simd
 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
-  for (GoodIter I(begin); I < end; ++I) // expected-warning 2 {{Non-trivial type 'GoodIter' is mapped, only trivial types are guaranteed to be mapped correctly}}
+  for (GoodIter I(begin); I < end; ++I) // expected-warning 2 {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
 ++I;
 #pragma omp target
 #pragma omp teams distribute simd
 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
-  for (GoodIter I(nullptr); I < end; ++I) // expected-warning {{Non-trivial type 'GoodIter' is mapped, only trivial types are guaranteed to be mapped correctly}}
+  for (GoodIter I(nullptr); I < end; ++I) // expected-warning {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
 ++I;
 #pragma omp target
 #pragma omp teams distribute simd
 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
-  for (GoodIter I(0); I < end; ++I) // expected-warning {{Non-trivial type 'GoodIter' is mapped, only trivial types are guaranteed to be mapped correctly}}
+  for (GoodIter I(0); I < end; ++I) // expected-warning {{Type 'GoodIter' is not trivially copyable and not guaranteed to be map

[PATCH] D71141: [Wdocumentation] Use C2x/C++14 deprecated attribute

2019-12-07 Thread Mark de Wever via Phabricator via cfe-commits
Mordante updated this revision to Diff 232695.
Mordante retitled this revision from "[Wdocumentation] Use C++14 deprecated 
attribute" to "[Wdocumentation] Use C2x/C++14 deprecated attribute".
Mordante edited the summary of this revision.
Mordante added a comment.

Added C2x support as requested.


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

https://reviews.llvm.org/D71141

Files:
  clang/lib/AST/CommentSema.cpp
  clang/test/Sema/warn-documentation-fixits.c
  clang/test/Sema/warn-documentation-fixits.cpp
  clang/test/Sema/warn-documentation.cpp

Index: clang/test/Sema/warn-documentation.cpp
===
--- clang/test/Sema/warn-documentation.cpp
+++ clang/test/Sema/warn-documentation.cpp
@@ -612,6 +612,12 @@
 /// \deprecated Bbb
 void test_deprecated_1(int a) __attribute__((deprecated));
 
+#if __cplusplus >= 201402L
+/// Aaa
+/// \deprecated Bbb
+[[deprecated]] void test_deprecated_no_warning_std14(int a);
+#endif
+
 // We don't want \deprecated to warn about empty paragraph.  It is fine to use
 // \deprecated by itself without explanations.
 
Index: clang/test/Sema/warn-documentation-fixits.cpp
===
--- clang/test/Sema/warn-documentation-fixits.cpp
+++ clang/test/Sema/warn-documentation-fixits.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -verify %s
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
-// RUN: %clang_cc1 -std=c++14 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck --check-prefixes=CHECK,CHECK14 %s
+// RUN  %clang_cc1 -std=c++11 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck -DATTRIBUTE="__attribute__((deprecated))" %s
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck --check-prefixes=CHECK,CHECK14 -DATTRIBUTE="[[deprecated]]" %s
 
 // expected-warning@+1 {{parameter 'ZZ' not found in the function declaration}} expected-note@+1 {{did you mean 'a'?}}
 /// \param ZZ Blah blah.
@@ -96,6 +96,14 @@
 /// \deprecated
 void test_deprecated_9(int a);
 
+#if __cplusplus >= 201402L
+#define ATTRIBUTE_DEPRECATED [[deprecated]]
+
+// expected-warning@+1 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
+/// \deprecated
+void test_deprecated_10(int a);
+#endif
+
 // rdar://12381408
 // expected-warning@+2  {{unknown command tag name 'retur'; did you mean 'return'?}}
 /// \brief testing fixit
@@ -119,16 +127,17 @@
 // CHECK: fix-it:"{{.*}}":{10:12-10:15}:"aaa"
 // CHECK: fix-it:"{{.*}}":{14:13-14:23}:"T"
 // CHECK: fix-it:"{{.*}}":{19:13-19:18}:"SomeTy"
-// CHECK: fix-it:"{{.*}}":{26:1-26:1}:"__attribute__((deprecated)) "
-// CHECK: fix-it:"{{.*}}":{30:1-30:1}:"__attribute__((deprecated)) "
-// CHECK: fix-it:"{{.*}}":{35:3-35:3}:"__attribute__((deprecated)) "
-// CHECK: fix-it:"{{.*}}":{39:3-39:3}:"__attribute__((deprecated)) "
-// CHECK: fix-it:"{{.*}}":{47:3-47:3}:"__attribute__((deprecated)) "
-// CHECK: fix-it:"{{.*}}":{51:3-51:3}:"__attribute__((deprecated)) "
-// CHECK: fix-it:"{{.*}}":{76:3-76:3}:"__attribute__((deprecated)) "
-// CHECK: fix-it:"{{.*}}":{81:3-81:3}:"__attribute__((deprecated)) "
-// CHECK14: fix-it:"{{.*}}":{87:3-87:3}:"__attribute__((deprecated)) "
+// CHECK: fix-it:"{{.*}}":{26:1-26:1}:"[[ATTRIBUTE]] "
+// CHECK: fix-it:"{{.*}}":{30:1-30:1}:"[[ATTRIBUTE]] "
+// CHECK: fix-it:"{{.*}}":{35:3-35:3}:"[[ATTRIBUTE]] "
+// CHECK: fix-it:"{{.*}}":{39:3-39:3}:"[[ATTRIBUTE]] "
+// CHECK: fix-it:"{{.*}}":{47:3-47:3}:"[[ATTRIBUTE]] "
+// CHECK: fix-it:"{{.*}}":{51:3-51:3}:"[[ATTRIBUTE]] "
+// CHECK: fix-it:"{{.*}}":{76:3-76:3}:"[[ATTRIBUTE]] "
+// CHECK: fix-it:"{{.*}}":{81:3-81:3}:"[[ATTRIBUTE]] "
+// CHECK14: fix-it:"{{.*}}":{87:3-87:3}:"[[ATTRIBUTE]] "
 // CHECK: fix-it:"{{.*}}":{97:1-97:1}:"MY_ATTR_DEPRECATED "
-// CHECK: fix-it:"{{.*}}":{102:6-102:11}:"return"
-// CHECK: fix-it:"{{.*}}":{106:6-106:11}:"foobar"
-// CHECK: fix-it:"{{.*}}":{115:6-115:12}:"endcode"
+// CHECK14: fix-it:"{{.*}}":{104:1-104:1}:"ATTRIBUTE_DEPRECATED "
+// CHECK: fix-it:"{{.*}}":{110:6-110:11}:"return"
+// CHECK: fix-it:"{{.*}}":{114:6-114:11}:"foobar"
+// CHECK: fix-it:"{{.*}}":{123:6-123:12}:"endcode"
Index: clang/test/Sema/warn-documentation-fixits.c
===
--- /dev/null
+++ clang/test/Sema/warn-documentation-fixits.c
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -Wd

[PATCH] D71141: [Wdocumentation] Use C++14 deprecated attribute

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



Comment at: clang/lib/AST/CommentSema.cpp:693
+StringRef AttributeSpelling =
+CPlusPlus14 ? "[[deprecated]]" : "__attribute__((deprecated))";
 if (PP) {

Mordante wrote:
> aaron.ballman wrote:
> > Mordante wrote:
> > > aaron.ballman wrote:
> > > > This attribute also exists with this spelling in C2x, FWIW.
> > > True, but unless I'm mistaken `CPlusPlus17` and `CPlusPlus2a` also 
> > > include `CPlusPlus14`. Do you prefer a different name for the Boolean?
> > I'm talking about C2x, not C++2a. The name for the variable is fine, but we 
> > should prefer `[[deprecated]]` in C2x mode to `__attribute__((deprecated))`.
> > 
> > I think the correct predicate is: 
> > `getLangOpts().DoubleSquareBracketAttributes` -- if the user says they want 
> > to use double-square bracket attributes, we should probably prefer them to 
> > GNU-style attributes.
> Ah sorry I misread. I'll have a look at C2x. Thanks for the information.
`getLangOpts().DoubleSquareBracketAttributes` will not work since it includes 
C++11, which doesn't support `[[deprecated]]`, so I will just test for C++14 
and C2x.
(I had a look at the proper syntax in C2x and found N2334 ;-))


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71141



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


[PATCH] D71142: [Sema] Validate large bitfields

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

I'll have a look whether I can find a sane maximum width for a bit-field.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71142



___
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-07 Thread annita.zhang via Phabricator via cfe-commits
annita.zhang added a comment.



In D70157#1760278 , @jyknight wrote:

>




> Branch alignment
> 
>  ---
> 
> The primary goal of this patch, restricting the placement of branch 
> instructions, is a performance optimization. Similar to loop alignment, the 
> desire is to increase speed, at the cost of code-size. However, the way this 
> feature has been designed is a global assembler flag. I find that not ideal, 
> because it cannot take into account hotness of a block/function, as for 
> example loop alignment code does. Basic-block alignment of loops is 
> explicitly opt-in on an block-by-block basis -- the compiler simply emits a 
> p2align directive where it needs, and the assembler honors that. And so, 
> MachineBlockPlacement::alignBlocks has a bunch of conditions under which it 
> will avoid emitting a p2align. This seems like a good model -- the assembler 
> does what it's told by the compiler (or assembly-writer). Making the 
> branch-instruction-alignment work similarly seems like it would be good.
> 
> IMO it would be nicest if there could be a directive that requests to 
> specially-align the next instruction. However, the fused-jcc case makes that 
> quite tricky, so perhaps this ought to also be a mode which can be 
> enabled/disabled on a region as well.

Yes, the primary goal of this patch is a performance optimization or 
mitigation. The intention is to provide a simple method for users to mitigate 
the performance impact of JCC MCU with less effort. We also provide users 
several options to tune the performance. But the basic idea is to make it easy 
for users to mitigate it and improve the performance.

Your proposal is a good idea. But I'm afraid it may not cover all the 
scenarios. Firstly, the proposal replies on compiler to detect the hotspots. 
But the compiler needs LTO and/or PGO to get the precise hot spots. Otherwise, 
if the compiler misses the hot spots which impact the application performance, 
the users have no way but have to insert the directives manually. Secondly, for 
the existing codes written in assembly, the compiler can't handle it. The users 
have to insert the directives by hand, which are pretty much work.

I think the current patch wants to give a simple and general solution to 
mitigate JCC MCU performance impact to both C/C++ and Assembly. And it doesn't 
need any source code change. I think your proposal will be a good enhancement 
on top of it.


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] D61446: Generalize the pass registration mechanism used by Polly to any third-party tool

2019-12-07 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 232690.
serge-sans-paille added a comment.

@Meinersbur : with this version, validation passes using static build on three 
platforms, with the following config:

  -DLLVM_ENABLE_PROJECTS='polly;clang' -DPOLLY_ENABLE_GPGPU_CODEGEN=ON  
-DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_POLLY_LINK_INTO_TOOLS=ON

and also on dynamic builds, with the following config, except on windows:

  -DLLVM_ENABLE_PROJECTS='polly;clang' -DPOLLY_ENABLE_GPGPU_CODEGEN=OFF 
-DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_POLLY_LINK_INTO_TOOLS=OFF

Is there any other setup you'd like to be added to the github action validation?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61446

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CMakeLists.txt
  clang/tools/driver/CMakeLists.txt
  clang/tools/driver/cc1_main.cpp
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/docs/WritingAnLLVMPass.rst
  llvm/examples/Bye/Bye.cpp
  llvm/examples/Bye/CMakeLists.txt
  llvm/examples/CMakeLists.txt
  llvm/include/llvm/Config/llvm-config.h.cmake
  llvm/test/Feature/load_extension.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/opt-O0-pipeline.ll
  llvm/test/Other/opt-O2-pipeline.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/opt-Os-pipeline.ll
  llvm/test/lit.cfg.py
  llvm/test/lit.site.cfg.py.in
  llvm/tools/CMakeLists.txt
  llvm/tools/bugpoint/CMakeLists.txt
  llvm/tools/bugpoint/bugpoint.cpp
  llvm/tools/opt/CMakeLists.txt
  llvm/tools/opt/NewPMDriver.cpp
  llvm/tools/opt/opt.cpp
  llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
  polly/include/polly/RegisterPasses.h
  polly/lib/CMakeLists.txt
  polly/lib/Plugin/Polly.cpp
  polly/lib/Polly.cpp
  polly/lib/Support/RegisterPasses.cpp
  polly/test/Unit/lit.site.cfg.in
  polly/test/lit.site.cfg.in
  polly/test/update_check.py

Index: polly/test/update_check.py
===
--- polly/test/update_check.py
+++ polly/test/update_check.py
@@ -15,7 +15,7 @@
 polly_lib_dir = '''@POLLY_LIB_DIR@'''
 shlibext = '''@LLVM_SHLIBEXT@'''
 llvm_tools_dir = '''@LLVM_TOOLS_DIR@'''
-link_polly_into_tools = not '''@LINK_POLLY_INTO_TOOLS@'''.lower() in {'','0','n','no','off','false','notfound','link_polly_into_tools-notfound'}
+llvm_polly_link_into_tools = not '''@LLVM_POLLY_LINK_INTO_TOOLS@'''.lower() in {'','0','n','no','off','false','notfound','llvm_polly_link_into_tools-notfound'}
 
 runre = re.compile(r'\s*\;\s*RUN\s*\:(?P.*)')
 filecheckre = re.compile(r'\s*(?P.*)\|\s*(?PFileCheck\s[^|]*)')
@@ -298,7 +298,7 @@
 toolarg = toolarg.replace('%s', filename)
 toolarg = toolarg.replace('%S', os.path.dirname(filename))
 if toolarg == '%loadPolly':
-if not link_polly_into_tools:
+if not llvm_polly_link_into_tools:
 newtool += ['-load',os.path.join(polly_lib_dir,'LLVMPolly' + shlibext)]
 newtool.append('-polly-process-unprofitable')
 newtool.append('-polly-remarks-minimal')
Index: polly/test/lit.site.cfg.in
===
--- polly/test/lit.site.cfg.in
+++ polly/test/lit.site.cfg.in
@@ -8,7 +8,7 @@
 config.polly_lib_dir = "@POLLY_LIB_DIR@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.enable_gpgpu_codegen = "@GPU_CODEGEN@"
-config.link_polly_into_tools = "@LINK_POLLY_INTO_TOOLS@"
+config.llvm_polly_link_into_tools = "@LLVM_POLLY_LINK_INTO_TOOLS@"
 config.targets_to_build = "@TARGETS_TO_BUILD@"
 config.extra_paths = "@POLLY_TEST_EXTRA_PATHS@".split(";")
 
@@ -36,14 +36,14 @@
 # directories.
 config.excludes = ['Inputs']
 
-if config.link_polly_into_tools == '' or \
-   config.link_polly_into_tools.lower() == '0' or \
-   config.link_polly_into_tools.lower() == 'n' or \
-   config.link_polly_into_tools.lower() == 'no' or \
-   config.link_polly_into_tools.lower() == 'off' or \
-   config.link_polly_into_tools.lower() == 'false' or \
-   config.link_polly_into_tools.lower() == 'notfound' or \
-   config.link_polly_into_tools.lower() == 'link_polly_into_tools-notfound':
+if config.llvm_polly_link_into_tools == '' or \
+   config.llvm_polly_link_into_tools.lower() == '0' or \
+   config.llvm_polly_link_into_tools.lower() == 'n' or \
+   config.llvm_polly_link_into_tools.lower() == 'no' or \
+   config.llvm_polly_link_into_tools.lower() == 'off' or \
+   config.llvm_polly_link_into_tools.lower() == 'false' or \
+   config.llvm_polly_link_into_tools.lower() == 'notfound' or \
+   config.llvm_polly_link_into_tools.lower() == 'llvm_polly_link_into_tools-notfound':
 config.substitutions.append(('%loadPolly', '-load '
  + config.polly_lib_dir + '/LLVMPolly@LLVM_SHLIBEXT@'
  + ' -load-pass-plugin '
Index: polly/test/Unit/lit.site.cf