[PATCH] D41537: Optionally add code completion results for arrow instead of dot

2018-03-13 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan updated this revision to Diff 138139.
yvvan added a comment.

Return possibly required corrections in the string form


https://reviews.llvm.org/D41537

Files:
  include/clang-c/Index.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/CodeCompleteConsumer.h
  include/clang/Sema/CodeCompleteOptions.h
  include/clang/Sema/Sema.h
  lib/Frontend/ASTUnit.cpp
  lib/Parse/ParseExpr.cpp
  lib/Sema/CodeCompleteConsumer.cpp
  lib/Sema/SemaCodeComplete.cpp
  test/FixIt/fixit.cpp
  test/Index/complete-arrow-dot.cpp
  test/SemaCXX/member-expr.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/CIndexCodeCompletion.cpp
  tools/libclang/libclang.exports

Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -170,6 +170,7 @@
 clang_getCompletionChunkCompletionString
 clang_getCompletionChunkKind
 clang_getCompletionChunkText
+clang_getCompletionCorrection
 clang_getCompletionNumAnnotations
 clang_getCompletionParent
 clang_getCompletionPriority
Index: tools/libclang/CIndexCodeCompletion.cpp
===
--- tools/libclang/CIndexCodeCompletion.cpp
+++ tools/libclang/CIndexCodeCompletion.cpp
@@ -238,6 +238,20 @@
   return cxstring::createRef(CCStr->getBriefComment());
 }
 
+CXString
+clang_getCompletionCorrection(CXCompletionString completion_string) {
+  CodeCompletionString *CCStr = (CodeCompletionString *)completion_string;
+
+  if (!CCStr)
+return cxstring::createNull();
+
+  const Optional &Corr = CCStr->getCorrection();
+  if (!Corr)
+  return cxstring::createNull();
+
+  return cxstring::createRef(Corr->c_str());
+}
+
 namespace {
 
 /// \brief The CXCodeCompleteResults structure we allocate internally;
@@ -644,6 +658,7 @@
   unsigned options) {
   bool IncludeBriefComments = options & CXCodeComplete_IncludeBriefComments;
   bool SkipPreamble = options & CXCodeComplete_SkipPreamble;
+  bool IncludeCorrections = options & CXCodeComplete_IncludeCorrections;
 
 #ifdef UDP_CODE_COMPLETION_LOGGER
 #ifdef UDP_CODE_COMPLETION_LOGGER_PORT
@@ -650,7 +665,6 @@
   const llvm::TimeRecord &StartTime =  llvm::TimeRecord::getCurrentTime();
 #endif
 #endif
-
   bool EnableLogging = getenv("LIBCLANG_CODE_COMPLETION_LOGGING") != nullptr;
 
   if (cxtu::isNotUsableTU(TU)) {
@@ -691,6 +705,7 @@
   CodeCompleteOptions Opts;
   Opts.IncludeBriefComments = IncludeBriefComments;
   Opts.LoadExternal = !SkipPreamble;
+  Opts.IncludeCorrections = IncludeCorrections;
   CaptureCompletionResults Capture(Opts, *Results, &TU);
 
   // Perform completion.
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -2276,6 +2276,7 @@
   CXString ParentName;
   CXString BriefComment;
   CXString Annotation;
+  CXString Corr;
   const char *BriefCommentCString;
   
   fprintf(file, "%s:", clang_getCString(ks));
@@ -2337,7 +2338,10 @@
 fprintf(file, "(brief comment: %s)", BriefCommentCString);
   }
   clang_disposeString(BriefComment);
-  
+
+  Corr = clang_getCompletionCorrection(completion_result->CompletionString);
+  fprintf(file, " (requires correction to \"%s\")", clang_getCString(Corr));
+
   fprintf(file, "\n");
 }
 
@@ -2436,6 +2440,8 @@
 completionOptions |= CXCodeComplete_IncludeBriefComments;
   if (getenv("CINDEXTEST_COMPLETION_SKIP_PREAMBLE"))
 completionOptions |= CXCodeComplete_SkipPreamble;
+  if (getenv("CINDEXTEST_COMPLETION_INCLUDE_CORRECTIONS"))
+completionOptions |= CXCodeComplete_IncludeCorrections;
   
   if (timing_only)
 input += strlen("-code-completion-timing=");
Index: test/SemaCXX/member-expr.cpp
===
--- test/SemaCXX/member-expr.cpp
+++ test/SemaCXX/member-expr.cpp
@@ -188,6 +188,11 @@
 return c->a;  // expected-error {{member reference type 'PR15045::Cl0' is not a pointer; did you mean to use '.'?}}
   }
 
+  int g() {
+Cl0* c;
+return c.a;  // expected-error {{member reference type 'PR15045::Cl0 *' is a pointer; did you mean to use '->'?}}
+  }
+
   struct bar {
 void func();  // expected-note {{'func' declared here}}
   };
Index: test/Index/complete-arrow-dot.cpp
===
--- test/Index/complete-arrow-dot.cpp
+++ test/Index/complete-arrow-dot.cpp
@@ -0,0 +1,54 @@
+struct X {
+  void doSomething();
+
+  int field;
+};
+
+void X::doSomething() {
+  // RUN: c-index-test -code-completion-at=%s:10:8 %s | FileCheck %s
+  // RUN: env CINDEXTEST_COMPLETION_INCLUDE_CORRECTIONS=1 c-index-test -code-completion-at=%s:10:8 %s | FileCheck -check-prefix=CHECK-WITH-CORRECTION %s
+  this.;
+}
+
+void doSomething() {
+  // RUN: c-index-test -code-completion-at=%s:17:6 %s | FileCheck -check-prefix=CHECK-ARROW-TO-DOT %

[PATCH] D44293: [clangd] Fix irrelevant declaratations in goto definition (on macros).

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



Comment at: clangd/XRefs.cpp:201
   std::vector MacroInfos = DeclMacrosFinder->takeMacroInfos();
+  if (!MacroInfos.empty()) {
+for (auto Item : MacroInfos) {

hokein wrote:
> ilya-biryukov wrote:
> > I wonder whether we should fix the `DeclrationAndMacrosFinder` to not 
> > return declarations coming from macro instantiations instead.
> > There are other clients (e.g. document highlights) that will probably break 
> > in the same way.
> > 
> > Do you think it would be possible and it would make sense for 
> > `DeclrationAndMacrosFinder` to only return a macro in this case and not 
> > return Decls coming from macro expansions?
> I thought about it initially, but the information provided 
> `handleDeclOccurrence` is limited...the occurrence location (`FID` and 
> `Offset`) is expansion location (which is not always we want). That being 
> said, when GoToDefinition on a macro, all declarations inside the macro body 
> will be picked up.
> 
> In document hover implementation, we also use the same mechanism to avoid 
> this problem :(
> 
As discussed offline, we should probably move this logic to 
`DeclrationAndMacrosFinder` so that all its clients (hover, documentHighlights, 
findDefinitions) are consistent.
Having a single function in `DeclrationAndMacrosFinder` that returns results 
(currently there are two: `takeDecls()` and `takeMacros()`) would allow that 
with minimal changes.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44293



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


[PATCH] D44381: [mips] Change the way how Clang chooses relocation mode

2018-03-13 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added a comment.

This patch looks mostly ok, but I think there are some small issues with it.

Can you separate the new warnings/error relating to -fno-pic / -mabicalls into 
another patch from the change which alters the behaviour of __PIC__ / __pic__ ?

The title of the patch is misleading, as you're adding warnings related to 
-fno-pic / -mabicalls and changing how __pic__ is defined.


Repository:
  rC Clang

https://reviews.llvm.org/D44381



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


[PATCH] D44293: [clangd] Fix irrelevant declaratations in goto definition (on macros).

2018-03-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 138147.
hokein marked an inline comment as done.
hokein added a comment.

Address review comment.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44293

Files:
  clangd/XRefs.cpp
  unittests/clangd/XRefsTests.cpp


Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -213,6 +213,15 @@
 #undef macro
   )cpp",
 
+  R"cpp(// Macro
+   class TTT { public: int a; };
+   #define [[FF(S) if (int b = S.a) {}]]
+   void f() {
+ TTT t;
+ F^F(t);
+   }
+  )cpp",
+
   R"cpp(// Forward class declaration
 class Foo;
 [[class Foo {}]];
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -126,6 +126,16 @@
 MacroInfo *MacroInf = MacroDef.getMacroInfo();
 if (MacroInf) {
   MacroInfos.push_back(MacroDecl{IdentifierInfo->getName(), MacroInf});
+  // Clear all collected delcarations if this is a macro search.
+  //
+  // In theory, there should be no declarataions being collected when 
we
+  // search a source location that refers to a macro.
+  // The occurrence location returned by `handleDeclOccurence` is
+  // limited (FID, Offset are from expansion location), we will collect
+  // all declarations inside the macro.
+  //
+  // FIXME: Exclude declarations from macros.
+  Decls.clear();
 }
   }
 }


Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -213,6 +213,15 @@
 #undef macro
   )cpp",
 
+  R"cpp(// Macro
+   class TTT { public: int a; };
+   #define [[FF(S) if (int b = S.a) {}]]
+   void f() {
+ TTT t;
+ F^F(t);
+   }
+  )cpp",
+
   R"cpp(// Forward class declaration
 class Foo;
 [[class Foo {}]];
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -126,6 +126,16 @@
 MacroInfo *MacroInf = MacroDef.getMacroInfo();
 if (MacroInf) {
   MacroInfos.push_back(MacroDecl{IdentifierInfo->getName(), MacroInf});
+  // Clear all collected delcarations if this is a macro search.
+  //
+  // In theory, there should be no declarataions being collected when we
+  // search a source location that refers to a macro.
+  // The occurrence location returned by `handleDeclOccurence` is
+  // limited (FID, Offset are from expansion location), we will collect
+  // all declarations inside the macro.
+  //
+  // FIXME: Exclude declarations from macros.
+  Decls.clear();
 }
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44293: [clangd] Fix irrelevant declaratations in goto definition (on macros).

2018-03-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clangd/XRefs.cpp:201
   std::vector MacroInfos = DeclMacrosFinder->takeMacroInfos();
+  if (!MacroInfos.empty()) {
+for (auto Item : MacroInfos) {

ilya-biryukov wrote:
> hokein wrote:
> > ilya-biryukov wrote:
> > > I wonder whether we should fix the `DeclrationAndMacrosFinder` to not 
> > > return declarations coming from macro instantiations instead.
> > > There are other clients (e.g. document highlights) that will probably 
> > > break in the same way.
> > > 
> > > Do you think it would be possible and it would make sense for 
> > > `DeclrationAndMacrosFinder` to only return a macro in this case and not 
> > > return Decls coming from macro expansions?
> > I thought about it initially, but the information provided 
> > `handleDeclOccurrence` is limited...the occurrence location (`FID` and 
> > `Offset`) is expansion location (which is not always we want). That being 
> > said, when GoToDefinition on a macro, all declarations inside the macro 
> > body will be picked up.
> > 
> > In document hover implementation, we also use the same mechanism to avoid 
> > this problem :(
> > 
> As discussed offline, we should probably move this logic to 
> `DeclrationAndMacrosFinder` so that all its clients (hover, 
> documentHighlights, findDefinitions) are consistent.
> Having a single function in `DeclrationAndMacrosFinder` that returns results 
> (currently there are two: `takeDecls()` and `takeMacros()`) would allow that 
> with minimal changes.
As discussed, made the workaround in `Finder` to keep the change minimal, no 
changes are required in client side.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44293



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


[PATCH] D16008: [clang-tidy] Add calling virtual functions in constructors/destructors check.

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

If the CSA checker is still in alpha, I'd proceed with this check instead of 
investing time in polishing the CSA implementation.


Repository:
  rL LLVM

https://reviews.llvm.org/D16008



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


[PATCH] D16008: [clang-tidy] Add calling virtual functions in constructors/destructors check.

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

Aaron, WDYT?


Repository:
  rL LLVM

https://reviews.llvm.org/D16008



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


r327383 - clang-import-test: fix build with clang-3.8

2018-03-13 Thread Pavel Labath via cfe-commits
Author: labath
Date: Tue Mar 13 04:28:27 2018
New Revision: 327383

URL: http://llvm.org/viewvc/llvm-project?rev=327383&view=rev
Log:
clang-import-test: fix build with clang-3.8

clang-3.8 complains that constructor for '...' must explicitly
initialize the const object. Newer clangs and gcc seem to be fine with
this, but explicitly initializing the variable does not hurt.

Modified:
cfe/trunk/tools/clang-import-test/clang-import-test.cpp

Modified: cfe/trunk/tools/clang-import-test/clang-import-test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-import-test/clang-import-test.cpp?rev=327383&r1=327382&r2=327383&view=diff
==
--- cfe/trunk/tools/clang-import-test/clang-import-test.cpp (original)
+++ cfe/trunk/tools/clang-import-test/clang-import-test.cpp Tue Mar 13 04:28:27 
2018
@@ -245,7 +245,7 @@ struct CIAndOrigins {
   ASTContext &getASTContext() { return CI->getASTContext(); }
   FileManager &getFileManager() { return CI->getFileManager(); }
   const OriginMap &getOriginMap() {
-static const OriginMap EmptyOriginMap;
+static const OriginMap EmptyOriginMap{};
 if (ExternalASTSource *Source = CI->getASTContext().getExternalSource())
   return static_cast(Source)->GetOrigins();
 return EmptyOriginMap;


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


[PATCH] D44293: [clangd] Fix irrelevant declaratations in goto definition (on macros).

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



Comment at: clangd/XRefs.cpp:137
+  //
+  // FIXME: Exclude declarations from macros.
+  Decls.clear();

NIT: the fixme was a bit hard to follow for me. Maybe make it more clear where 
the problem should be handled, e.g. 
```FIXME: we should avoid adding decls from inside macros in handlDeclOccurence.
```


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44293



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


[PATCH] D44293: [clangd] Fix irrelevant declaratations in goto definition (on macros).

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

LGTM with a small nit about the comment.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44293



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


[clang-tools-extra] r327386 - [clangd] Remove extra ";", NFC.

2018-03-13 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Mar 13 05:26:28 2018
New Revision: 327386

URL: http://llvm.org/viewvc/llvm-project?rev=327386&view=rev
Log:
[clangd] Remove extra ";", NFC.

Modified:
clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp

Modified: clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp?rev=327386&r1=327385&r2=327386&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp Tue Mar 13 
05:26:28 2018
@@ -90,7 +90,7 @@ Position pos(int line, int character) {
   Res.line = line;
   Res.character = character;
   return Res;
-};
+}
 
 /// Matches diagnostic that has exactly one fix with the same range and message
 /// as the diagnostic itself.


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


[PATCH] D44293: [clangd] Fix irrelevant declaratations in goto definition (on macros).

2018-03-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 138160.
hokein marked an inline comment as done.
hokein added a comment.

Rephrase the fixme.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44293

Files:
  clangd/XRefs.cpp
  unittests/clangd/XRefsTests.cpp


Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -213,6 +213,15 @@
 #undef macro
   )cpp",
 
+  R"cpp(// Macro
+   class TTT { public: int a; };
+   #define [[FF(S) if (int b = S.a) {}]]
+   void f() {
+ TTT t;
+ F^F(t);
+   }
+  )cpp",
+
   R"cpp(// Forward class declaration
 class Foo;
 class [[Foo]] {};
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -127,6 +127,16 @@
 MacroInfo *MacroInf = MacroDef.getMacroInfo();
 if (MacroInf) {
   MacroInfos.push_back(MacroDecl{IdentifierInfo->getName(), MacroInf});
+  // Clear all collected delcarations if this is a macro search.
+  //
+  // In theory, there should be no declarataions being collected when 
we
+  // search a source location that refers to a macro.
+  // The occurrence location returned by `handleDeclOccurence` is
+  // limited (FID, Offset are from expansion location), we will collect
+  // all declarations inside the macro.
+  //
+  // FIXME: Avoid adding decls from inside macros in 
handlDeclOccurence.
+  Decls.clear();
 }
   }
 }


Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -213,6 +213,15 @@
 #undef macro
   )cpp",
 
+  R"cpp(// Macro
+   class TTT { public: int a; };
+   #define [[FF(S) if (int b = S.a) {}]]
+   void f() {
+ TTT t;
+ F^F(t);
+   }
+  )cpp",
+
   R"cpp(// Forward class declaration
 class Foo;
 class [[Foo]] {};
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -127,6 +127,16 @@
 MacroInfo *MacroInf = MacroDef.getMacroInfo();
 if (MacroInf) {
   MacroInfos.push_back(MacroDecl{IdentifierInfo->getName(), MacroInf});
+  // Clear all collected delcarations if this is a macro search.
+  //
+  // In theory, there should be no declarataions being collected when we
+  // search a source location that refers to a macro.
+  // The occurrence location returned by `handleDeclOccurence` is
+  // limited (FID, Offset are from expansion location), we will collect
+  // all declarations inside the macro.
+  //
+  // FIXME: Avoid adding decls from inside macros in handlDeclOccurence.
+  Decls.clear();
 }
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r327387 - [clangd] Fix irrelevant declaratations in goto definition (on macros).

2018-03-13 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Mar 13 05:30:59 2018
New Revision: 327387

URL: http://llvm.org/viewvc/llvm-project?rev=327387&view=rev
Log:
[clangd] Fix irrelevant declaratations in goto definition (on macros).

Summary:
DeclrationAndMacrosFinder will find some declarations (not macro!) that are
referened inside the macro somehow, isSearchedLocation() is not sufficient, we
don't know whether the searched source location is macro or not.

Reviewers: ilya-biryukov

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

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

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

Modified: clang-tools-extra/trunk/clangd/XRefs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/XRefs.cpp?rev=327387&r1=327386&r2=327387&view=diff
==
--- clang-tools-extra/trunk/clangd/XRefs.cpp (original)
+++ clang-tools-extra/trunk/clangd/XRefs.cpp Tue Mar 13 05:30:59 2018
@@ -127,6 +127,16 @@ private:
 MacroInfo *MacroInf = MacroDef.getMacroInfo();
 if (MacroInf) {
   MacroInfos.push_back(MacroDecl{IdentifierInfo->getName(), MacroInf});
+  // Clear all collected delcarations if this is a macro search.
+  //
+  // In theory, there should be no declarataions being collected when 
we
+  // search a source location that refers to a macro.
+  // The occurrence location returned by `handleDeclOccurence` is
+  // limited (FID, Offset are from expansion location), we will collect
+  // all declarations inside the macro.
+  //
+  // FIXME: Avoid adding decls from inside macros in 
handlDeclOccurence.
+  Decls.clear();
 }
   }
 }

Modified: clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp?rev=327387&r1=327386&r2=327387&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp Tue Mar 13 05:30:59 
2018
@@ -213,6 +213,15 @@ TEST(GoToDefinition, All) {
 #undef macro
   )cpp",
 
+  R"cpp(// Macro
+   class TTT { public: int a; };
+   #define [[FF(S) if (int b = S.a) {}]]
+   void f() {
+ TTT t;
+ F^F(t);
+   }
+  )cpp",
+
   R"cpp(// Forward class declaration
 class Foo;
 class [[Foo]] {};


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


[PATCH] D44293: [clangd] Fix irrelevant declaratations in goto definition (on macros).

2018-03-13 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE327387: [clangd] Fix irrelevant declaratations in goto 
definition (on macros). (authored by hokein, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44293?vs=138160&id=138162#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44293

Files:
  clangd/XRefs.cpp
  unittests/clangd/XRefsTests.cpp


Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -213,6 +213,15 @@
 #undef macro
   )cpp",
 
+  R"cpp(// Macro
+   class TTT { public: int a; };
+   #define [[FF(S) if (int b = S.a) {}]]
+   void f() {
+ TTT t;
+ F^F(t);
+   }
+  )cpp",
+
   R"cpp(// Forward class declaration
 class Foo;
 class [[Foo]] {};
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -127,6 +127,16 @@
 MacroInfo *MacroInf = MacroDef.getMacroInfo();
 if (MacroInf) {
   MacroInfos.push_back(MacroDecl{IdentifierInfo->getName(), MacroInf});
+  // Clear all collected delcarations if this is a macro search.
+  //
+  // In theory, there should be no declarataions being collected when 
we
+  // search a source location that refers to a macro.
+  // The occurrence location returned by `handleDeclOccurence` is
+  // limited (FID, Offset are from expansion location), we will collect
+  // all declarations inside the macro.
+  //
+  // FIXME: Avoid adding decls from inside macros in 
handlDeclOccurence.
+  Decls.clear();
 }
   }
 }


Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -213,6 +213,15 @@
 #undef macro
   )cpp",
 
+  R"cpp(// Macro
+   class TTT { public: int a; };
+   #define [[FF(S) if (int b = S.a) {}]]
+   void f() {
+ TTT t;
+ F^F(t);
+   }
+  )cpp",
+
   R"cpp(// Forward class declaration
 class Foo;
 class [[Foo]] {};
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -127,6 +127,16 @@
 MacroInfo *MacroInf = MacroDef.getMacroInfo();
 if (MacroInf) {
   MacroInfos.push_back(MacroDecl{IdentifierInfo->getName(), MacroInf});
+  // Clear all collected delcarations if this is a macro search.
+  //
+  // In theory, there should be no declarataions being collected when we
+  // search a source location that refers to a macro.
+  // The occurrence location returned by `handleDeclOccurence` is
+  // limited (FID, Offset are from expansion location), we will collect
+  // all declarations inside the macro.
+  //
+  // FIXME: Avoid adding decls from inside macros in handlDeclOccurence.
+  Decls.clear();
 }
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D16008: [clang-tidy] Add calling virtual functions in constructors/destructors check.

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

In https://reviews.llvm.org/D16008#1035683, @alexfh wrote:

> If the CSA checker is still in alpha, I'd proceed with this check instead of 
> investing time in polishing the CSA implementation.


Do you know why the CSA checker is still in alpha? As best I can tell, that 
check and this one are attempting to do the same work. I'm kind of worried 
about having competing functionalities because users have to guess as to which 
one is the "correct" one to use.


Repository:
  rL LLVM

https://reviews.llvm.org/D16008



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


[PATCH] D44423: [clangd] Use the macro name range as the definition range.

2018-03-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: ioeric, jkorous-apple, ilya-biryukov, klimek.

This also aligns with the behavior of declarations.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44423

Files:
  clangd/XRefs.cpp
  unittests/clangd/XRefsTests.cpp


Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -207,15 +207,15 @@
 
   R"cpp(// Macro
 #define MACRO 0
-#define [[MACRO 1]]
+#define [[MACRO]] 1
 int main() { return ^MACRO; }
 #define MACRO 2
 #undef macro
   )cpp",
 
   R"cpp(// Macro
class TTT { public: int a; };
-   #define [[FF(S) if (int b = S.a) {}]]
+   #define [[FF]](S) if (int b = S.a) {}
void f() {
  TTT t;
  F^F(t);
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -219,9 +219,8 @@
   }
 
   for (auto Item : MacroInfos) {
-SourceRange SR(Item.Info->getDefinitionLoc(),
-   Item.Info->getDefinitionEndLoc());
-auto L = makeLocation(AST, SR);
+auto Loc = Item.Info->getDefinitionLoc();
+auto L = makeLocation(AST, SourceRange(Loc, Loc));
 if (L)
   Result.push_back(*L);
   }


Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -207,15 +207,15 @@
 
   R"cpp(// Macro
 #define MACRO 0
-#define [[MACRO 1]]
+#define [[MACRO]] 1
 int main() { return ^MACRO; }
 #define MACRO 2
 #undef macro
   )cpp",
 
   R"cpp(// Macro
class TTT { public: int a; };
-   #define [[FF(S) if (int b = S.a) {}]]
+   #define [[FF]](S) if (int b = S.a) {}
void f() {
  TTT t;
  F^F(t);
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -219,9 +219,8 @@
   }
 
   for (auto Item : MacroInfos) {
-SourceRange SR(Item.Info->getDefinitionLoc(),
-   Item.Info->getDefinitionEndLoc());
-auto L = makeLocation(AST, SR);
+auto Loc = Item.Info->getDefinitionLoc();
+auto L = makeLocation(AST, SourceRange(Loc, Loc));
 if (L)
   Result.push_back(*L);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43290: clang-format: tweak formatting of variable initialization blocks

2018-03-13 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

ping?


Repository:
  rC Clang

https://reviews.llvm.org/D43290



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


[PATCH] D43015: clang-format: Introduce BreakInheritanceList option

2018-03-13 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

ping?


Repository:
  rC Clang

https://reviews.llvm.org/D43015



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


[PATCH] D42684: clang-format: Allow optimizer to break template declaration.

2018-03-13 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

ping?


Repository:
  rC Clang

https://reviews.llvm.org/D42684



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


r327393 - [Hexagon] Clang side of r327302 in LLVM

2018-03-13 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Tue Mar 13 06:30:43 2018
New Revision: 327393

URL: http://llvm.org/viewvc/llvm-project?rev=327393&view=rev
Log:
[Hexagon] Clang side of r327302 in LLVM

Add option -m[no-]packets to control generation of instruction packets
(enabled by default).

Added:
cfe/trunk/test/Driver/hexagon-packets.c
Modified:
cfe/trunk/include/clang/Driver/Options.td

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=327393&r1=327392&r2=327393&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Mar 13 06:30:43 2018
@@ -2472,41 +2472,45 @@ def _write_dependencies : Flag<["--"], "
 def _write_user_dependencies : Flag<["--"], "write-user-dependencies">, 
Alias;
 def _ : Joined<["--"], "">, Flags<[Unsupported]>;
 
-def mieee_rnd_near : Flag<["-"], "mieee-rnd-near">, 
Group;
+// Hexagon feature flags.
+def mieee_rnd_near : Flag<["-"], "mieee-rnd-near">,
+  Group;
 def mv4 : Flag<["-"], "mv4">, Group,
-  Alias, AliasArgs<["hexagonv4"]>;
+  Alias, AliasArgs<["hexagonv4"]>;
 def mv5 : Flag<["-"], "mv5">, Group, Alias,
-  AliasArgs<["hexagonv5"]>;
+  AliasArgs<["hexagonv5"]>;
 def mv55 : Flag<["-"], "mv55">, Group,
-   Alias, AliasArgs<["hexagonv55"]>;
+  Alias, AliasArgs<["hexagonv55"]>;
 def mv60 : Flag<["-"], "mv60">, Group,
-   Alias, AliasArgs<["hexagonv60"]>;
+  Alias, AliasArgs<["hexagonv60"]>;
 def mv62 : Flag<["-"], "mv62">, Group,
-   Alias, AliasArgs<["hexagonv62"]>;
+  Alias, AliasArgs<["hexagonv62"]>;
 def mv65 : Flag<["-"], "mv65">, Group,
-   Alias, AliasArgs<["hexagonv65"]>;
-def mhexagon_hvx : Flag<[ "-" ], "mhvx">,
-   Group,
-   HelpText<"Enable Hexagon Vector eXtensions">;
+  Alias, AliasArgs<["hexagonv65"]>;
+def mhexagon_hvx : Flag<[ "-" ], "mhvx">, Group,
+  HelpText<"Enable Hexagon Vector eXtensions">;
 def mhexagon_hvx_EQ : Joined<[ "-" ], "mhvx=">,
- Group,
- HelpText<"Enable Hexagon Vector eXtensions">;
+  Group,
+  HelpText<"Enable Hexagon Vector eXtensions">;
 def mno_hexagon_hvx : Flag<[ "-" ], "mno-hvx">,
-  Group,
-  HelpText<"Disable Hexagon Vector eXtensions">;
+  Group,
+  HelpText<"Disable Hexagon Vector eXtensions">;
 def mhexagon_hvx_length_EQ : Joined<[ "-" ], "mhvx-length=">,
-Group,
-HelpText<"Set Hexagon Vector Length">, 
Values<"64B,128B">;
-// hvx-double deprecrated flag.
-def mhexagon_hvx_double : Flag<[ "-" ], "mhvx-double">,
-  Group,
-  HelpText<"Enable Hexagon Double Vector eXtensions">;
-def mno_hexagon_hvx_double
-: Flag<[ "-" ], "mno-hvx-double">,
-  Group,
-  HelpText<"Disable Hexagon Double Vector eXtensions">;
+  Group, HelpText<"Set Hexagon Vector Length">,
+  Values<"64B,128B">;
 def ffixed_r19: Flag<["-"], "ffixed-r19">,
   HelpText<"Reserve the r19 register (Hexagon only)">;
+def mpackets : Flag<["-"], "mpackets">, Group,
+  Flags<[CC1Option]>, HelpText<"Enable generation of instruction packets">;
+def mno_packets : Flag<["-"], "mno-packets">, Group,
+  Flags<[CC1Option]>, HelpText<"Disable generation of instruction packets">;
+// hvx-double deprecrated flag.
+def mhexagon_hvx_double : Flag<[ "-" ], "mhvx-double">,
+  Group,
+  HelpText<"Enable Hexagon Double Vector eXtensions">;
+def mno_hexagon_hvx_double : Flag<[ "-" ], "mno-hvx-double">,
+  Group,
+  HelpText<"Disable Hexagon Double Vector eXtensions">;
 
 
 // X86 feature flags

Added: cfe/trunk/test/Driver/hexagon-packets.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hexagon-packets.c?rev=327393&view=auto
==
--- cfe/trunk/test/Driver/hexagon-packets.c (added)
+++ cfe/trunk/test/Driver/hexagon-packets.c Tue Mar 13 06:30:43 2018
@@ -0,0 +1,10 @@
+// RUN: %clang -target hexagon -### -mpackets %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-PACKETS
+
+// RUN: %clang -target hexagon -### -mno-packets %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-NO-PACKETS
+
+// CHECK-PACKETS: "-target-feature" "+packets"
+
+// CHECK-NO-PACKETS: "-target-feature" "-packets"
+


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


[PATCH] D43650: [ARM] Add ARMv8.2-A FP16 vector intrinsics

2018-03-13 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D43650#1034009, @mstorsjo wrote:

> This change broke building Qt for armv7, see PR36683 for details.


Ping - any update on looking into this? Should we revert this change for now, 
until the breakage is handled?


https://reviews.llvm.org/D43650



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


[PATCH] D43650: [ARM] Add ARMv8.2-A FP16 vector intrinsics

2018-03-13 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

Hi @mstorsjo, thanks for reporting this!
I was waiting for @az, and only had a quick look myself, but I don't think it's 
going to be
a quick fix. So that would suggest indeed that a revert is a best. Perhaps we 
can wait a few
more hours to give the guys in the US time zone the opportunity to reply in 
case I've
missed something, but yes, let's revert "end of today" otherwise.


https://reviews.llvm.org/D43650



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


[PATCH] D44426: Fix llvm + clang build with Intel compiler

2018-03-13 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan created this revision.
yvvan added reviewers: bkramer, klimek.
Herald added subscribers: JDevlieghere, nhaehnle, arsenm.
Herald added a reviewer: deadalnix.

I've tested it on Windows with 64-bit icl

These are mostly workarounds for 
https://software.intel.com/en-us/comment/1919743 , 
https://software.intel.com/en-us/forums/intel-c-compiler/topic/749369 and few 
more enum-related issues


https://reviews.llvm.org/D44426

Files:
  include/llvm-c/Target.h
  include/llvm/ADT/BitmaskEnum.h
  include/llvm/Analysis/AliasAnalysis.h
  lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
  lib/Target/AMDGPU/SIISelLowering.cpp
  tools/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
  tools/llvm-nm/llvm-nm.cpp

Index: tools/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
===
--- tools/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
+++ tools/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
@@ -282,8 +282,12 @@
 
   /// SExpr objects cannot be deleted.
   // This declaration is public to workaround a gcc bug that breaks building
-  // with REQUIRES_EH=1.
+  // with REQUIRES_EH=1. Do not mark it 'delete' to avoid error with intel compiler.
+#ifdef __INTEL_COMPILER
+  void operator delete(void *);
+#else
   void operator delete(void *) = delete;
+#endif
 
   /// Returns the instruction ID for this expression.
   /// All basic block instructions have a unique ID (i.e. virtual register).
Index: tools/llvm-nm/llvm-nm.cpp
===
--- tools/llvm-nm/llvm-nm.cpp
+++ tools/llvm-nm/llvm-nm.cpp
@@ -876,14 +876,14 @@
 case ELF::SHT_PROGBITS:
 case ELF::SHT_DYNAMIC:
   switch (SecI->getFlags()) {
-  case (ELF::SHF_ALLOC | ELF::SHF_EXECINSTR):
+  case (ELF::SHF_ALLOC | static_cast(ELF::SHF_EXECINSTR)):
 return 't';
-  case (ELF::SHF_TLS | ELF::SHF_ALLOC | ELF::SHF_WRITE):
-  case (ELF::SHF_ALLOC | ELF::SHF_WRITE):
+  case (ELF::SHF_TLS | static_cast(ELF::SHF_ALLOC) | static_cast(ELF::SHF_WRITE)):
+  case (ELF::SHF_ALLOC | static_cast(ELF::SHF_WRITE)):
 return 'd';
   case ELF::SHF_ALLOC:
-  case (ELF::SHF_ALLOC | ELF::SHF_MERGE):
-  case (ELF::SHF_ALLOC | ELF::SHF_MERGE | ELF::SHF_STRINGS):
+  case (ELF::SHF_ALLOC | static_cast(ELF::SHF_MERGE)):
+  case (ELF::SHF_ALLOC | static_cast(ELF::SHF_MERGE) | static_cast(ELF::SHF_STRINGS)):
 return 'r';
   }
   break;
Index: lib/Target/AMDGPU/SIISelLowering.cpp
===
--- lib/Target/AMDGPU/SIISelLowering.cpp
+++ lib/Target/AMDGPU/SIISelLowering.cpp
@@ -6128,11 +6128,13 @@
   SIInstrFlags::P_SUBNORMAL |
   SIInstrFlags::P_NORMAL;
 
+#ifndef __INTEL_COMPILER
 static_assert(((~(SIInstrFlags::S_NAN |
   SIInstrFlags::Q_NAN |
   SIInstrFlags::N_INFINITY |
   SIInstrFlags::P_INFINITY)) & 0x3ff) == Mask,
   "mask not equal");
+#endif
 
 SDLoc DL(N);
 return DAG.getNode(AMDGPUISD::FP_CLASS, DL, MVT::i1,
Index: lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
===
--- lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
+++ lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
@@ -76,24 +76,24 @@
 return "sdata4";
   case dwarf::DW_EH_PE_sdata8:
 return "sdata8";
-  case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata4:
+  case dwarf::DW_EH_PE_pcrel | static_cast(dwarf::DW_EH_PE_udata4):
 return "pcrel udata4";
-  case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4:
+  case dwarf::DW_EH_PE_pcrel | static_cast(dwarf::DW_EH_PE_sdata4):
 return "pcrel sdata4";
-  case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8:
+  case dwarf::DW_EH_PE_pcrel | static_cast(dwarf::DW_EH_PE_udata8):
 return "pcrel udata8";
-  case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata8:
+  case dwarf::DW_EH_PE_pcrel | static_cast(dwarf::DW_EH_PE_sdata8):
 return "pcrel sdata8";
-  case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata4
+  case dwarf::DW_EH_PE_indirect | static_cast(dwarf::DW_EH_PE_pcrel) | static_cast(dwarf::DW_EH_PE_udata4)
   :
 return "indirect pcrel udata4";
-  case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
+  case dwarf::DW_EH_PE_indirect | static_cast(dwarf::DW_EH_PE_pcrel) | static_cast(dwarf::DW_EH_PE_sdata4)
   :
 return "indirect pcrel sdata4";
-  case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8
+  case dwarf::DW_EH_PE_indirect | static_cast(dwarf::DW_EH_PE_pcrel) | static_cast(dwarf::DW_EH_PE_udata8)
   :
 return "indirect pcrel udata8";
-  case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata8
+  case dwarf::DW_EH_PE_indirect | static_cast(dwarf::DW

[clang-tools-extra] r327401 - [clangd] Use the macro name range as the definition range.

2018-03-13 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Mar 13 07:31:31 2018
New Revision: 327401

URL: http://llvm.org/viewvc/llvm-project?rev=327401&view=rev
Log:
[clangd] Use the macro name range as the definition range.

Summary: This also aligns with the behavior of declarations.

Reviewers: sammccall

Reviewed By: sammccall

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

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

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

Modified: clang-tools-extra/trunk/clangd/XRefs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/XRefs.cpp?rev=327401&r1=327400&r2=327401&view=diff
==
--- clang-tools-extra/trunk/clangd/XRefs.cpp (original)
+++ clang-tools-extra/trunk/clangd/XRefs.cpp Tue Mar 13 07:31:31 2018
@@ -219,9 +219,8 @@ std::vector findDefinitions(Pa
   }
 
   for (auto Item : MacroInfos) {
-SourceRange SR(Item.Info->getDefinitionLoc(),
-   Item.Info->getDefinitionEndLoc());
-auto L = makeLocation(AST, SR);
+auto Loc = Item.Info->getDefinitionLoc();
+auto L = makeLocation(AST, SourceRange(Loc, Loc));
 if (L)
   Result.push_back(*L);
   }

Modified: clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp?rev=327401&r1=327400&r2=327401&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp Tue Mar 13 07:31:31 
2018
@@ -207,7 +207,7 @@ TEST(GoToDefinition, All) {
 
   R"cpp(// Macro
 #define MACRO 0
-#define [[MACRO 1]]
+#define [[MACRO]] 1
 int main() { return ^MACRO; }
 #define MACRO 2
 #undef macro
@@ -215,7 +215,7 @@ TEST(GoToDefinition, All) {
 
   R"cpp(// Macro
class TTT { public: int a; };
-   #define [[FF(S) if (int b = S.a) {}]]
+   #define [[FF]](S) if (int b = S.a) {}
void f() {
  TTT t;
  F^F(t);


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


[PATCH] D44423: [clangd] Use the macro name range as the definition range.

2018-03-13 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE327401: [clangd] Use the macro name range as the 
definition range. (authored by hokein, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44423?vs=138163&id=138189#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44423

Files:
  clangd/XRefs.cpp
  unittests/clangd/XRefsTests.cpp


Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -207,15 +207,15 @@
 
   R"cpp(// Macro
 #define MACRO 0
-#define [[MACRO 1]]
+#define [[MACRO]] 1
 int main() { return ^MACRO; }
 #define MACRO 2
 #undef macro
   )cpp",
 
   R"cpp(// Macro
class TTT { public: int a; };
-   #define [[FF(S) if (int b = S.a) {}]]
+   #define [[FF]](S) if (int b = S.a) {}
void f() {
  TTT t;
  F^F(t);
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -219,9 +219,8 @@
   }
 
   for (auto Item : MacroInfos) {
-SourceRange SR(Item.Info->getDefinitionLoc(),
-   Item.Info->getDefinitionEndLoc());
-auto L = makeLocation(AST, SR);
+auto Loc = Item.Info->getDefinitionLoc();
+auto L = makeLocation(AST, SourceRange(Loc, Loc));
 if (L)
   Result.push_back(*L);
   }


Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -207,15 +207,15 @@
 
   R"cpp(// Macro
 #define MACRO 0
-#define [[MACRO 1]]
+#define [[MACRO]] 1
 int main() { return ^MACRO; }
 #define MACRO 2
 #undef macro
   )cpp",
 
   R"cpp(// Macro
class TTT { public: int a; };
-   #define [[FF(S) if (int b = S.a) {}]]
+   #define [[FF]](S) if (int b = S.a) {}
void f() {
  TTT t;
  F^F(t);
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -219,9 +219,8 @@
   }
 
   for (auto Item : MacroInfos) {
-SourceRange SR(Item.Info->getDefinitionLoc(),
-   Item.Info->getDefinitionEndLoc());
-auto L = makeLocation(AST, SR);
+auto Loc = Item.Info->getDefinitionLoc();
+auto L = makeLocation(AST, SourceRange(Loc, Loc));
 if (L)
   Result.push_back(*L);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38216: [C++17] Fix class template argument deduction for default constructors without an initializer

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

Addressed review comments :)

Thanks!


https://reviews.llvm.org/D38216

Files:
  lib/Sema/SemaDecl.cpp
  test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp
  test/Parser/cxx1z-class-template-argument-deduction.cpp


Index: test/Parser/cxx1z-class-template-argument-deduction.cpp
===
--- test/Parser/cxx1z-class-template-argument-deduction.cpp
+++ test/Parser/cxx1z-class-template-argument-deduction.cpp
@@ -137,7 +137,6 @@
 (void)A{n};
 (void)new A(n);
 (void)new A{n};
-// FIXME: We should diagnose the lack of an initializer here.
 (void)new A;
   }
 }
@@ -150,7 +149,7 @@
 
   auto k() -> A; // expected-error{{requires template arguments}}
 
-  A a; // expected-error {{declaration of variable 'a' with deduced type 'A' 
requires an initializer}}
+  A a;
   A b = 0;
   const A c = 0;
   A (parens) = 0; // expected-error {{cannot use parentheses when declaring 
variable with deduced class template specialization type}}
Index: test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp
===
--- test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp
+++ test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp
@@ -5,8 +5,7 @@
 A(int) -> A;
 
 static constexpr inline const volatile A a = {}; // ok, specifiers are 
permitted
-// FIXME: There isn't really a good reason to reject this.
-A b; // expected-error {{requires an initializer}}
+A b;
 A c [[]] {};
 
 A d = {}, e = {};
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -10395,12 +10395,22 @@
   // C++11 [dcl.spec.auto]p3
   if (!Init) {
 assert(VDecl && "no init for init capture deduction?");
-Diag(VDecl->getLocation(), diag::err_auto_var_requires_init)
-  << VDecl->getDeclName() << Type;
-return QualType();
+
+// Except for class argument deduction, and then for an initializing
+// declaration only, i.e. no static at class scope or extern.
+if (!isa(Deduced) ||
+VDecl->hasExternalStorage() ||
+VDecl->isStaticDataMember()) {
+  Diag(VDecl->getLocation(), diag::err_auto_var_requires_init)
+<< VDecl->getDeclName() << Type;
+  return QualType();
+}
   }
 
-  ArrayRef DeduceInits = Init;
+  ArrayRef DeduceInits;
+  if (Init)
+DeduceInits = Init;
+
   if (DirectInit) {
 if (auto *PL = dyn_cast_or_null(Init))
   DeduceInits = PL->exprs();


Index: test/Parser/cxx1z-class-template-argument-deduction.cpp
===
--- test/Parser/cxx1z-class-template-argument-deduction.cpp
+++ test/Parser/cxx1z-class-template-argument-deduction.cpp
@@ -137,7 +137,6 @@
 (void)A{n};
 (void)new A(n);
 (void)new A{n};
-// FIXME: We should diagnose the lack of an initializer here.
 (void)new A;
   }
 }
@@ -150,7 +149,7 @@
 
   auto k() -> A; // expected-error{{requires template arguments}}
 
-  A a; // expected-error {{declaration of variable 'a' with deduced type 'A' requires an initializer}}
+  A a;
   A b = 0;
   const A c = 0;
   A (parens) = 0; // expected-error {{cannot use parentheses when declaring variable with deduced class template specialization type}}
Index: test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp
===
--- test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp
+++ test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp
@@ -5,8 +5,7 @@
 A(int) -> A;
 
 static constexpr inline const volatile A a = {}; // ok, specifiers are permitted
-// FIXME: There isn't really a good reason to reject this.
-A b; // expected-error {{requires an initializer}}
+A b;
 A c [[]] {};
 
 A d = {}, e = {};
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -10395,12 +10395,22 @@
   // C++11 [dcl.spec.auto]p3
   if (!Init) {
 assert(VDecl && "no init for init capture deduction?");
-Diag(VDecl->getLocation(), diag::err_auto_var_requires_init)
-  << VDecl->getDeclName() << Type;
-return QualType();
+
+// Except for class argument deduction, and then for an initializing
+// declaration only, i.e. no static at class scope or extern.
+if (!isa(Deduced) ||
+VDecl->hasExternalStorage() ||
+VDecl->isStaticDataMember()) {
+  Diag(VDecl->getLocation(), diag::err_auto_var_requires_init)
+<< VDecl->getDeclName() << Type;
+  return QualType();
+}
   }
 
-  ArrayRef DeduceInits = Init;
+  ArrayRef DeduceInits;
+  if (Init)
+DeduceInits = Init;
+
   if (DirectInit) {
 if (auto *PL = dyn_cast_or_null(Init))
   DeduceInits = PL->exprs();

r327405 - Reland "[Attr] Fix parameter indexing for several attributes"

2018-03-13 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Tue Mar 13 07:51:22 2018
New Revision: 327405

URL: http://llvm.org/viewvc/llvm-project?rev=327405&view=rev
Log:
Reland "[Attr] Fix parameter indexing for several attributes"

Relands r326602 (reverted in r326862) with new test and fix for
PR36620.

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

Added:
cfe/trunk/test/Frontend/ast-attr.cpp
cfe/trunk/test/Sema/attr-ownership.cpp
Modified:
cfe/trunk/include/clang/AST/Attr.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
cfe/trunk/test/CodeGenCXX/alloc-size.cpp
cfe/trunk/test/Misc/ast-dump-attr.cpp
cfe/trunk/test/Sema/attr-print.cpp
cfe/trunk/test/Sema/error-type-safety.cpp
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/include/clang/AST/Attr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=327405&r1=327404&r2=327405&view=diff
==
--- cfe/trunk/include/clang/AST/Attr.h (original)
+++ cfe/trunk/include/clang/AST/Attr.h Tue Mar 13 07:51:22 2018
@@ -195,6 +195,128 @@ public:
}
 };
 
+/// A single parameter index whose accessors require each use to make explicit
+/// the parameter index encoding needed.
+class ParamIdx {
+  // Idx is exposed only via accessors that specify specific encodings.
+  unsigned Idx : 30;
+  unsigned HasThis : 1;
+  unsigned IsValid : 1;
+
+  void assertComparable(const ParamIdx &I) const {
+assert(isValid() && I.isValid() &&
+   "ParamIdx must be valid to be compared");
+// It's possible to compare indices from separate functions, but so far
+// it's not proven useful.  Moreover, it might be confusing because a
+// comparison on the results of getASTIndex might be inconsistent with a
+// comparison on the ParamIdx objects themselves.
+assert(HasThis == I.HasThis &&
+   "ParamIdx must be for the same function to be compared");
+  }
+
+public:
+  /// Construct an invalid parameter index (\c isValid returns false and
+  /// accessors fail an assert).
+  ParamIdx() : Idx(0), HasThis(false), IsValid(false) {}
+
+  /// \param Idx is the parameter index as it is normally specified in
+  /// attributes in the source: one-origin including any C++ implicit this
+  /// parameter.
+  ///
+  /// \param D is the declaration containing the parameters.  It is used to
+  /// determine if there is a C++ implicit this parameter.
+  ParamIdx(unsigned Idx, const Decl *D)
+  : Idx(Idx), HasThis(false), IsValid(true) {
+assert(Idx >= 1 && "Idx must be one-origin");
+if (const auto *FD = dyn_cast(D))
+  HasThis = FD->isCXXInstanceMember();
+  }
+
+  /// A type into which \c ParamIdx can be serialized.
+  ///
+  /// A static assertion that it's of the correct size follows the \c ParamIdx
+  /// class definition.
+  typedef uint32_t SerialType;
+
+  /// Produce a representation that can later be passed to \c deserialize to
+  /// construct an equivalent \c ParamIdx.
+  SerialType serialize() const {
+return *reinterpret_cast(this);
+  }
+
+  /// Construct from a result from \c serialize.
+  static ParamIdx deserialize(SerialType S) {
+ParamIdx P(*reinterpret_cast(&S));
+assert((!P.IsValid || P.Idx >= 1) && "valid Idx must be one-origin");
+return P;
+  }
+
+  /// Is this parameter index valid?
+  bool isValid() const { return IsValid; }
+
+  /// Get the parameter index as it would normally be encoded for attributes at
+  /// the source level of representation: one-origin including any C++ implicit
+  /// this parameter.
+  ///
+  /// This encoding thus makes sense for diagnostics, pretty printing, and
+  /// constructing new attributes from a source-like specification.
+  unsigned getSourceIndex() const {
+assert(isValid() && "ParamIdx must be valid");
+return Idx;
+  }
+
+  /// Get the parameter index as it would normally be encoded at the AST level
+  /// of representation: zero-origin not including any C++ implicit this
+  /// parameter.
+  ///
+  /// This is the encoding primarily used in Sema.  However, in diagnostics,
+  /// Sema uses \c getSourceIndex instead.
+  unsigned getASTIndex() const {
+assert(isValid() && "ParamIdx must be valid");
+assert(Idx >= 1 + HasThis &&
+   "stored index must be base-1 and not specify C++ implicit this");
+return Idx - 1 - HasThis;
+  }
+
+  /// Get the parameter index as it would normally be encoded at the LLVM level
+  /// of representation: zero-origin including any C++ implicit this parameter.
+  ///
+  /// This is the encoding primarily used in CodeGen.
+  unsigned ge

[PATCH] D16008: [clang-tidy] Add calling virtual functions in constructors/destructors check.

2018-03-13 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D16008#1035789, @aaron.ballman wrote:

> Do you know why the CSA checker is still in alpha?


It isn't - https://reviews.llvm.org/D26768 moved it to optin.

I don't know why https://reviews.llvm.org/D34275 didn't turn it on by default.


Repository:
  rL LLVM

https://reviews.llvm.org/D16008



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


[PATCH] D43248: [Attr] Fix parameter indexing for attributes

2018-03-13 Thread Joel E. Denny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
jdenny marked 8 inline comments as done.
Closed by commit rC327405: Reland "[Attr] Fix parameter indexing for 
several attributes" (authored by jdenny, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D43248?vs=138113&id=138193#toc

Repository:
  rC Clang

https://reviews.llvm.org/D43248

Files:
  include/clang/AST/Attr.h
  include/clang/Basic/Attr.td
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGCall.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
  test/CodeGenCXX/alloc-size.cpp
  test/Frontend/ast-attr.cpp
  test/Misc/ast-dump-attr.cpp
  test/Sema/attr-ownership.cpp
  test/Sema/attr-print.cpp
  test/Sema/error-type-safety.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -1231,9 +1231,10 @@
   if (Att->getModule() != II_malloc)
 return nullptr;
 
-  OwnershipAttr::args_iterator I = Att->args_begin(), E = Att->args_end();
+  ParamIdx *I = Att->args_begin(), *E = Att->args_end();
   if (I != E) {
-return MallocMemAux(C, CE, CE->getArg(*I), UndefinedVal(), State);
+return MallocMemAux(C, CE, CE->getArg(I->getASTIndex()), UndefinedVal(),
+State);
   }
   return MallocMemAux(C, CE, UnknownVal(), UndefinedVal(), State);
 }
@@ -1331,9 +1332,9 @@
   bool ReleasedAllocated = false;
 
   for (const auto &Arg : Att->args()) {
-ProgramStateRef StateI = FreeMemAux(C, CE, State, Arg,
-   Att->getOwnKind() == OwnershipAttr::Holds,
-   ReleasedAllocated);
+ProgramStateRef StateI = FreeMemAux(
+C, CE, State, Arg.getASTIndex(),
+Att->getOwnKind() == OwnershipAttr::Holds, ReleasedAllocated);
 if (StateI)
   State = StateI;
   }
Index: lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
+++ lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
@@ -54,10 +54,11 @@
   AttrNonNull.set(0, NumArgs);
   break;
 }
-for (unsigned Val : NonNull->args()) {
-  if (Val >= NumArgs)
+for (const ParamIdx &Idx : NonNull->args()) {
+  unsigned IdxAST = Idx.getASTIndex();
+  if (IdxAST >= NumArgs)
 continue;
-  AttrNonNull.set(Val);
+  AttrNonNull.set(IdxAST);
 }
   }
   return AttrNonNull;
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -5475,9 +5475,8 @@
 llvm::APInt &Result) {
   const AllocSizeAttr *AllocSize = getAllocSizeAttr(Call);
 
-  // alloc_size args are 1-indexed, 0 means not present.
-  assert(AllocSize && AllocSize->getElemSizeParam() != 0);
-  unsigned SizeArgNo = AllocSize->getElemSizeParam() - 1;
+  assert(AllocSize && AllocSize->getElemSizeParam().isValid());
+  unsigned SizeArgNo = AllocSize->getElemSizeParam().getASTIndex();
   unsigned BitsInSizeT = Ctx.getTypeSize(Ctx.getSizeType());
   if (Call->getNumArgs() <= SizeArgNo)
 return false;
@@ -5495,14 +5494,13 @@
   if (!EvaluateAsSizeT(Call->getArg(SizeArgNo), SizeOfElem))
 return false;
 
-  if (!AllocSize->getNumElemsParam()) {
+  if (!AllocSize->getNumElemsParam().isValid()) {
 Result = std::move(SizeOfElem);
 return true;
   }
 
   APSInt NumberOfElems;
-  // Argument numbers start at 1
-  unsigned NumArgNo = AllocSize->getNumElemsParam() - 1;
+  unsigned NumArgNo = AllocSize->getNumElemsParam().getASTIndex();
   if (!EvaluateAsSizeT(Call->getArg(NumArgNo), NumberOfElems))
 return false;
 
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -176,7 +176,8 @@
 Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs,
 const AllocAlignAttr *Align, Decl *New) {
   Expr *Param = IntegerLiteral::Create(
-  S.getASTContext(), llvm::APInt(64, Align->getParamIndex()),
+  S.getASTContext(),
+  llvm::APInt(64, Align->getParamIndex().getSourceIndex()),
   S.getASTContext().UnsignedLongLongTy, Align->getLocation());
   S.AddAllocAlignAttr(Align->getLocation(), New, Param,
   Align->getSpellingListIndex());
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -13185,7 +13185,7 @@
 // We already have a __builtin___CFStringMakeConstan

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

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

- - Addressed review comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44305

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

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

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

2018-03-13 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

Thanks for the review!




Comment at: clangd/index/Index.h:268
+  virtual bool
+  getSymbol(const SymbolID &ID,
+llvm::function_ref Callback) const = 0;

sammccall wrote:
> sammccall wrote:
> > sammccall wrote:
> > > Can we make this a bulk operation (take an arrayref or similar?)
> > > 
> > > There are use cases like augmenting sema-returned results with info from 
> > > the index where we want a bunch at once. In practice a single bulk 
> > > operation will be much nicer for an rpc-based index to implement than a 
> > > single lookup issued many times in parallel.
> > > 
> > > (The callback interface is really nice here, because the underlying RPC 
> > > can be streaming!)
> > For extensibility and uniformity with FuzzyFind, we should consider adding 
> > a struct around the parameters.
> > 
> > At least one option seems likely to be added here: retrieving the full 
> > ("detail") symbol vs the basic symbol (particularly for bulk actions).
> > Others are less obvious, but could include something like "chase pointers" 
> > so that if returning a typedef, the target of the typedef would also be 
> > looked up and returned.
> > 
> `getSymbol` isn't a bad name, but it's a bit hard to talk about without 
> ambiguity because "get" is so overloaded and everything deals with 
> "symbols".. (e.g. "this method gets a symbol as a parameter..."). It's also 
> awkward to use as a noun, which is common with RPCs.
> 
> `lookup` or `fetch` would be specific enough to avoid this. (Dropping 
> "symbol" from the method name because it's present in the interface name). 
> WDYT?
Makes sense. I wasn't really sure about `getSymbol` and wanted your thought. 
Going with `lookup`.



Comment at: unittests/clangd/IndexTests.cpp:93
+std::string getQualifiedName(const Symbol &Sym) {
+  return (Sym.Scope + (Sym.Scope.empty() ? "" : "::") + Sym.Name).str();
+}

sammccall wrote:
> Symbol;Scope is already e.g. "ns::", this shouldn't be needed.
This wasn't true in the tests. Fixed.



Comment at: unittests/clangd/IndexTests.cpp:112
+  std::string Res = "";
+  I.getSymbol(ID, [&](const Symbol &Sym) { Res = getQualifiedName(Sym); });
+  return Res;

sammccall wrote:
> check the return value
This was intended. If no symbol was found, `Res` would be empty by default. No 
longer relevant in the new revision.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44305



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


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

2018-03-13 Thread Simeon Ehrig via Phabricator via cfe-commits
SimeonEhrig created this revision.
SimeonEhrig added reviewers: karies, v.g.vassilev, rsmith, rjmccall.

This allows multi-module / incremental compilation environments to have unique 
global CUDA constructor and destructor function names.


Repository:
  rC Clang

https://reviews.llvm.org/D44435

Files:
  lib/CodeGen/CGCUDANV.cpp
  unittests/CodeGen/IncrementalProcessingTest.cpp

Index: unittests/CodeGen/IncrementalProcessingTest.cpp
===
--- unittests/CodeGen/IncrementalProcessingTest.cpp
+++ unittests/CodeGen/IncrementalProcessingTest.cpp
@@ -21,9 +21,11 @@
 #include "llvm/IR/Module.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Target/TargetOptions.h"
 #include "gtest/gtest.h"
 
 #include 
+#include 
 
 using namespace llvm;
 using namespace clang;
@@ -171,4 +173,122 @@
 
 }
 
+
+// If the cuda mode in the compiler instance is enable, a cuda ctor or dtor will
+// be generated for every statement, if a fatbinary file is exists.
+const char CUDATestProgram1[] =
+"void cudaFunc1(){}\n";
+
+const char CUDATestProgram2[] =
+"void cudaFunc2(){}\n";
+
+const Function* getCUDActor(llvm::Module& M) {
+  for (const auto& Func: M)
+if (Func.hasName() && Func.getName().startswith("__cuda_module_ctor-"))
+  return &Func;
+
+  return nullptr;
+}
+
+const Function* getCUDAdtor(llvm::Module& M) {
+  for (const auto& Func: M)
+if (Func.hasName() && Func.getName().startswith("__cuda_module_dtor-"))
+  return &Func;
+
+  return nullptr;
+}
+
+TEST(IncrementalProcessing, EmitCUDAGlobalInitFunc) {
+LLVMContext Context;
+CompilerInstance compiler;
+
+compiler.createDiagnostics();
+compiler.getLangOpts().CPlusPlus = 1;
+compiler.getLangOpts().CPlusPlus11 = 1;
+compiler.getLangOpts().CUDA = 1;
+
+compiler.getTargetOpts().Triple = llvm::Triple::normalize(
+llvm::sys::getProcessTriple());
+compiler.setTarget(clang::TargetInfo::CreateTargetInfo(
+  compiler.getDiagnostics(),
+  std::make_shared(
+compiler.getTargetOpts(;
+
+// To enable the generating of cuda host code, it's needs to set up the
+// auxTriple.
+llvm::Triple hostTriple(llvm::sys::getProcessTriple());
+compiler.getFrontendOpts().AuxTriple =
+hostTriple.isArch64Bit() ? "nvptx64-nvidia-cuda" : "nvptx-nvidia-cuda";
+auto targetOptions = std::make_shared();
+targetOptions->Triple = compiler.getFrontendOpts().AuxTriple;
+targetOptions->HostTriple = compiler.getTarget().getTriple().str();
+compiler.setAuxTarget(clang::TargetInfo::CreateTargetInfo(
+compiler.getDiagnostics(), targetOptions));
+
+// A fatbinary file is necessary, that the code generator generates the ctor
+// and dtor.
+auto tmpFatbinFileOrError = llvm::sys::fs::TempFile::create("dummy.fatbin");
+ASSERT_TRUE((bool)tmpFatbinFileOrError);
+auto tmpFatbinFile = std::move(*tmpFatbinFileOrError);
+compiler.getCodeGenOpts().CudaGpuBinaryFileName = tmpFatbinFile.TmpName;
+
+compiler.createFileManager();
+compiler.createSourceManager(compiler.getFileManager());
+compiler.createPreprocessor(clang::TU_Prefix);
+compiler.getPreprocessor().enableIncrementalProcessing();
+
+compiler.createASTContext();
+
+CodeGenerator* CG =
+CreateLLVMCodeGen(
+compiler.getDiagnostics(),
+"main-module",
+compiler.getHeaderSearchOpts(),
+compiler.getPreprocessorOpts(),
+compiler.getCodeGenOpts(),
+Context);
+
+compiler.setASTConsumer(std::unique_ptr(CG));
+compiler.createSema(clang::TU_Prefix, nullptr);
+Sema& S = compiler.getSema();
+
+std::unique_ptr ParseOP(new Parser(S.getPreprocessor(), S,
+   /*SkipFunctionBodies*/ false));
+Parser &P = *ParseOP.get();
+
+std::array, 3> M;
+M[0] = IncrementalParseAST(compiler, P, *CG, nullptr);
+ASSERT_TRUE(M[0]);
+
+M[1] = IncrementalParseAST(compiler, P, *CG, CUDATestProgram1);
+ASSERT_TRUE(M[1]);
+ASSERT_TRUE(M[1]->getFunction("_Z9cudaFunc1v"));
+
+M[2] = IncrementalParseAST(compiler, P, *CG, CUDATestProgram2);
+ASSERT_TRUE(M[2]);
+ASSERT_TRUE(M[2]->getFunction("_Z9cudaFunc2v"));
+// First code should not end up in second module:
+ASSERT_FALSE(M[2]->getFunction("_Z9cudaFunc1v"));
+
+// Make sure, that cuda ctor's and dtor's exist:
+const Function* CUDActor1 = getCUDActor(*M[1]);
+ASSERT_TRUE(CUDActor1);
+
+const Function* CUDActor2 = getCUDActor(*M[2]);
+ASSERT_TRUE(CUDActor2);
+
+const Function* CUDAdtor1 = getCUDAdtor(*M[1]);
+ASSERT_TRUE(CUDAdtor1);
+
+const Function* CUDAdtor2 = getCUDAdtor(*M[2]);
+ASSERT_TRUE(CUDAdtor2);
+
+// Compare the names of both ctor's and dtor's to check, that they are
+// unique.
+ASSERT_FALSE(CUDActor1->getName() == CUDActor2->getName());
+ASSE

[PATCH] D43197: [OpenMP] Add flag for linking runtime bitcode library

2018-03-13 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Driver/ToolChains/Cuda.cpp:595-596
+// Add user defined library paths from LIBRARY_PATH.
+if (llvm::Optional LibPath =
+  llvm::sys::Process::GetEnv("LIBRARY_PATH")) {
+  SmallVector Frags;

Move the definition of `LibPath` out of `if` statement scope.



Comment at: lib/Driver/ToolChains/Cuda.cpp:600
+  llvm::SplitString(*LibPath, Frags, EnvPathSeparatorStr);
+  for (auto Path : Frags)
+LibraryPaths.emplace_back(Path.trim());

`auto`->`StringRef`



Comment at: lib/Driver/ToolChains/Cuda.cpp:607
+bool FoundBCLibrary = false;
+for (const std::string &LibraryPath : LibraryPaths) {
+  SmallString<128> LibOmpTargetFile(LibraryPath);

`const std::string &`->`StringRef`


Repository:
  rC Clang

https://reviews.llvm.org/D43197



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


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

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



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

Please explain in the comment *why* you're doing this.  It's just for 
debugging, right?  So that it's known which object file the constructor 
function comes from.



Comment at: lib/CodeGen/CGCUDANV.cpp:358
+  if (ModuleName.empty())
+ModuleName = "";
+

This doesn't actually seem more useful than the empty string.



Comment at: unittests/CodeGen/IncrementalProcessingTest.cpp:178
+// If the cuda mode in the compiler instance is enable, a cuda ctor or dtor 
will
+// be generated for every statement, if a fatbinary file is exists.
+const char CUDATestProgram1[] =

"In CUDA incremental processing, a CUDA ctor or dtor will be generated for 
every statement if a fatbinary file exists."


Repository:
  rC Clang

https://reviews.llvm.org/D44435



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


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

2018-03-13 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: bkramer, sammccall, sepavloff.

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

The bug was introduced in r321174.


Repository:
  rC Clang

https://reviews.llvm.org/D44439

Files:
  lib/Sema/SemaTemplateInstantiateDecl.cpp


Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3939,6 +3939,9 @@
 
 if (PatternDecl->hasSkippedBody()) {
   ActOnSkippedFunctionBody(Function);
+  // FIXME: finishing the function body while in an expression evaluation
+  // context seems wrong. Investigate more.
+  ActOnFinishFunctionBody(Function, nullptr, /*IsInstantiation=*/true);
 } else {
   if (CXXConstructorDecl *Ctor = dyn_cast(Function)) {
 // If this is a constructor, instantiate the member initializers.
@@ -3961,8 +3964,7 @@
 
   // FIXME: finishing the function body while in an expression evaluation
   // context seems wrong. Investigate more.
-  ActOnFinishFunctionBody(Function, Body.get(),
-  /*IsInstantiation=*/true);
+  ActOnFinishFunctionBody(Function, Body.get(), /*IsInstantiation=*/true);
 }
 
 PerformDependentDiagnostics(PatternDecl, TemplateArgs);


Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3939,6 +3939,9 @@
 
 if (PatternDecl->hasSkippedBody()) {
   ActOnSkippedFunctionBody(Function);
+  // FIXME: finishing the function body while in an expression evaluation
+  // context seems wrong. Investigate more.
+  ActOnFinishFunctionBody(Function, nullptr, /*IsInstantiation=*/true);
 } else {
   if (CXXConstructorDecl *Ctor = dyn_cast(Function)) {
 // If this is a constructor, instantiate the member initializers.
@@ -3961,8 +3964,7 @@
 
   // FIXME: finishing the function body while in an expression evaluation
   // context seems wrong. Investigate more.
-  ActOnFinishFunctionBody(Function, Body.get(),
-  /*IsInstantiation=*/true);
+  ActOnFinishFunctionBody(Function, Body.get(), /*IsInstantiation=*/true);
 }
 
 PerformDependentDiagnostics(PatternDecl, TemplateArgs);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2018-03-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clangd/index/Index.h:253
+struct LookupRequest {
+  std::set IDs;
+};

nit: DenseSet? we already have the traits



Comment at: clangd/index/Index.h:274
+  /// The returned symbol must be deep-copied if it's used outside Callback.
+  /// Returns true if at least one matched symbol was found.
+  virtual bool

is "at least one matched symbol was found" so useful that we need to provide it 
in a second way (rather than just invoking the callback at least once)?

Having both fuzzyFind and lookup return bool (but with very different 
semantics) seems confusing, and I suspect void would be fine here.



Comment at: clangd/index/Merge.cpp:67
+  if (!Sym)
+B.insert(S);
+  else

this could just be callback(S)



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

This could also just be callback(mergeSymbol(...)), if we keep track of the IDs 
we've emitted.
This way the slab would only have symbols from the dynamic index.

This could be just:
 - before the static lookup, make a copy `RemainingIDs = Req.IDs`
 - in the static callback, remove the id from RemainingIDs
 - after the static lookup, loop through RemainingIDs, look up symbol in 
dynamic slab, emit

This avoids:
 - copying the static index results (which tend to be more numerous)
 - build() on the slab builder, which isn't cheap



Comment at: unittests/clangd/CodeCompleteTests.cpp:693
+  bool
+  lookup(const LookupRequest & /*Req*/,
+ llvm::function_ref /*Callback*/) const override 
{

why comment out the param names here? can't we just either include or omit them?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44305



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


r327426 - [analyzer] Fix the matcher for GCDAntipattern to look for "signal" call in all parameters

2018-03-13 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Tue Mar 13 10:27:01 2018
New Revision: 327426

URL: http://llvm.org/viewvc/llvm-project?rev=327426&view=rev
Log:
[analyzer] Fix the matcher for GCDAntipattern to look for "signal" call in all 
parameters

rdar://38405904

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp
cfe/trunk/test/Analysis/gcdantipatternchecker_test.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp?rev=327426&r1=327425&r2=327426&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp Tue Mar 13 
10:27:01 2018
@@ -121,11 +121,11 @@ void GCDAntipatternChecker::checkASTCode
 hasCanonicalType(blockPointerType())
 ));
 
-  auto ArgCallsSignalM = hasArgument(0, hasDescendant(callExpr(
+  auto ArgCallsSignalM = hasAnyArgument(stmt(hasDescendant(callExpr(
   allOf(
   callsName("dispatch_semaphore_signal"),
   equalsBoundArgDecl(0, SemaphoreBinding)
-  ;
+  );
 
   auto HasBlockAndCallsSignalM = allOf(HasBlockArgumentM, ArgCallsSignalM);
 

Modified: cfe/trunk/test/Analysis/gcdantipatternchecker_test.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/gcdantipatternchecker_test.m?rev=327426&r1=327425&r2=327426&view=diff
==
--- cfe/trunk/test/Analysis/gcdantipatternchecker_test.m (original)
+++ cfe/trunk/test/Analysis/gcdantipatternchecker_test.m Tue Mar 13 10:27:01 
2018
@@ -177,9 +177,11 @@ void warn_with_cast() {
 
 @interface MyInterface1 : NSObject
 -(void)use_method_warn;
+-(void) pass_block_as_second_param_warn;
 -(void)use_objc_callback_warn;
 -(void)testNoWarn;
 -(void)acceptBlock:(block_t)callback;
+-(void)flag:(int)flag acceptBlock:(block_t)callback;
 @end
 
 @implementation MyInterface1
@@ -193,6 +195,15 @@ void warn_with_cast() {
   dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a 
semaphore with Grand Central Dispatch creates useless threads and is subject to 
priority inversion}}
 }
 
+-(void) pass_block_as_second_param_warn {
+  dispatch_semaphore_t sema = dispatch_semaphore_create(0);
+
+  [self flag:1 acceptBlock:^{
+  dispatch_semaphore_signal(sema);
+  }];
+  dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a 
semaphore with Grand Central Dispatch creates useless threads and is subject to 
priority inversion}}
+}
+
 -(void)testNoWarn {
   dispatch_semaphore_t sema = dispatch_semaphore_create(0);
 
@@ -206,6 +217,10 @@ void warn_with_cast() {
   callback();
 }
 
+-(void)flag:(int)flag acceptBlock:(block_t)callback {
+  callback();
+}
+
 -(void)use_objc_callback_warn {
   dispatch_semaphore_t sema = dispatch_semaphore_create(0);
 


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


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

2018-03-13 Thread Simeon Ehrig via Phabricator via cfe-commits
SimeonEhrig updated this revision to Diff 138224.
SimeonEhrig added a comment.

change comment of the example function for TEST(IncrementalProcessing, 
EmitCUDAGlobalInitFunc)


Repository:
  rC Clang

https://reviews.llvm.org/D44435

Files:
  lib/CodeGen/CGCUDANV.cpp
  unittests/CodeGen/IncrementalProcessingTest.cpp

Index: unittests/CodeGen/IncrementalProcessingTest.cpp
===
--- unittests/CodeGen/IncrementalProcessingTest.cpp
+++ unittests/CodeGen/IncrementalProcessingTest.cpp
@@ -21,9 +21,11 @@
 #include "llvm/IR/Module.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Target/TargetOptions.h"
 #include "gtest/gtest.h"
 
 #include 
+#include 
 
 using namespace llvm;
 using namespace clang;
@@ -171,4 +173,122 @@
 
 }
 
+
+// In CUDA incremental processing, a CUDA ctor or dtor will be generated for 
+// every statement if a fatbinary file exists.
+const char CUDATestProgram1[] =
+"void cudaFunc1(){}\n";
+
+const char CUDATestProgram2[] =
+"void cudaFunc2(){}\n";
+
+const Function* getCUDActor(llvm::Module& M) {
+  for (const auto& Func: M)
+if (Func.hasName() && Func.getName().startswith("__cuda_module_ctor-"))
+  return &Func;
+
+  return nullptr;
+}
+
+const Function* getCUDAdtor(llvm::Module& M) {
+  for (const auto& Func: M)
+if (Func.hasName() && Func.getName().startswith("__cuda_module_dtor-"))
+  return &Func;
+
+  return nullptr;
+}
+
+TEST(IncrementalProcessing, EmitCUDAGlobalInitFunc) {
+LLVMContext Context;
+CompilerInstance compiler;
+
+compiler.createDiagnostics();
+compiler.getLangOpts().CPlusPlus = 1;
+compiler.getLangOpts().CPlusPlus11 = 1;
+compiler.getLangOpts().CUDA = 1;
+
+compiler.getTargetOpts().Triple = llvm::Triple::normalize(
+llvm::sys::getProcessTriple());
+compiler.setTarget(clang::TargetInfo::CreateTargetInfo(
+  compiler.getDiagnostics(),
+  std::make_shared(
+compiler.getTargetOpts(;
+
+// To enable the generating of cuda host code, it's needs to set up the
+// auxTriple.
+llvm::Triple hostTriple(llvm::sys::getProcessTriple());
+compiler.getFrontendOpts().AuxTriple =
+hostTriple.isArch64Bit() ? "nvptx64-nvidia-cuda" : "nvptx-nvidia-cuda";
+auto targetOptions = std::make_shared();
+targetOptions->Triple = compiler.getFrontendOpts().AuxTriple;
+targetOptions->HostTriple = compiler.getTarget().getTriple().str();
+compiler.setAuxTarget(clang::TargetInfo::CreateTargetInfo(
+compiler.getDiagnostics(), targetOptions));
+
+// A fatbinary file is necessary, that the code generator generates the ctor
+// and dtor.
+auto tmpFatbinFileOrError = llvm::sys::fs::TempFile::create("dummy.fatbin");
+ASSERT_TRUE((bool)tmpFatbinFileOrError);
+auto tmpFatbinFile = std::move(*tmpFatbinFileOrError);
+compiler.getCodeGenOpts().CudaGpuBinaryFileName = tmpFatbinFile.TmpName;
+
+compiler.createFileManager();
+compiler.createSourceManager(compiler.getFileManager());
+compiler.createPreprocessor(clang::TU_Prefix);
+compiler.getPreprocessor().enableIncrementalProcessing();
+
+compiler.createASTContext();
+
+CodeGenerator* CG =
+CreateLLVMCodeGen(
+compiler.getDiagnostics(),
+"main-module",
+compiler.getHeaderSearchOpts(),
+compiler.getPreprocessorOpts(),
+compiler.getCodeGenOpts(),
+Context);
+
+compiler.setASTConsumer(std::unique_ptr(CG));
+compiler.createSema(clang::TU_Prefix, nullptr);
+Sema& S = compiler.getSema();
+
+std::unique_ptr ParseOP(new Parser(S.getPreprocessor(), S,
+   /*SkipFunctionBodies*/ false));
+Parser &P = *ParseOP.get();
+
+std::array, 3> M;
+M[0] = IncrementalParseAST(compiler, P, *CG, nullptr);
+ASSERT_TRUE(M[0]);
+
+M[1] = IncrementalParseAST(compiler, P, *CG, CUDATestProgram1);
+ASSERT_TRUE(M[1]);
+ASSERT_TRUE(M[1]->getFunction("_Z9cudaFunc1v"));
+
+M[2] = IncrementalParseAST(compiler, P, *CG, CUDATestProgram2);
+ASSERT_TRUE(M[2]);
+ASSERT_TRUE(M[2]->getFunction("_Z9cudaFunc2v"));
+// First code should not end up in second module:
+ASSERT_FALSE(M[2]->getFunction("_Z9cudaFunc1v"));
+
+// Make sure, that cuda ctor's and dtor's exist:
+const Function* CUDActor1 = getCUDActor(*M[1]);
+ASSERT_TRUE(CUDActor1);
+
+const Function* CUDActor2 = getCUDActor(*M[2]);
+ASSERT_TRUE(CUDActor2);
+
+const Function* CUDAdtor1 = getCUDAdtor(*M[1]);
+ASSERT_TRUE(CUDAdtor1);
+
+const Function* CUDAdtor2 = getCUDAdtor(*M[2]);
+ASSERT_TRUE(CUDAdtor2);
+
+// Compare the names of both ctor's and dtor's to check, that they are
+// unique.
+ASSERT_FALSE(CUDActor1->getName() == CUDActor2->getName());
+ASSERT_FALSE(CUDAdtor1->getName() == CUDAdtor2->getName());
+
+ASSERT_FALSE((bool)tmpFat

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

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

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

> For computing the start/end-loc of function bodies, I tried the 
> SingleFileParseMode and SkipFunctionBodies separately ( as a start). The 
> source I use this on looks like this:
>
>  


Given the discussion in https://reviews.llvm.org/D44247, I think we can do 
without the start/end-loc of function bodies and try some heuristics 
client-side. We can always revisit this later if necessary.

However, for the end-loc of occurrences, would you be OK with this being added? 
I think it would be a good compromise in terms of performance, simplicity and 
index size.


https://reviews.llvm.org/D39050



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


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

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



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

rjmccall wrote:
> Please explain in the comment *why* you're doing this.  It's just for 
> debugging, right?  So that it's known which object file the constructor 
> function comes from.
I'm also interested in in the motivation for this change.

Also, if the goal is to have an unique module identifier, would compiling two 
different files with the same name be a problem? If the goal is to help 
identifying a module, this may be OK, if not ideal. If you really need to have 
unique name, then you may need to do something more elaborate. NVCC appears to 
use some random number (or hash of something?) for that.



Comment at: lib/CodeGen/CGCUDANV.cpp:289
   llvm::FunctionType::get(VoidTy, VoidPtrTy, false),
-  llvm::GlobalValue::InternalLinkage, "__cuda_module_ctor", &TheModule);
+  llvm::GlobalValue::InternalLinkage, "__cuda_module_ctor-" + ModuleName,
+  &TheModule);

I'd rather not use '-' in a symbol. It's likely to end up being escaped in some 
way. '_' is a safer bet.



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

I don't understand the comment. What is 'CUDA incremental processing' and what 
exactly is meant by 'statement' here? I'd appreciate if you could give me more 
details. My understanding is that ctor/dtor are generated once per TU. I 
suspect "incremental processing" may change that, but I have no idea what 
exactly does it do.


Repository:
  rC Clang

https://reviews.llvm.org/D44435



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


[PATCH] D44143: [clang-tidy] Create properly seeded random generator check

2018-03-13 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/ReleaseNotes.rst:63
+
+  Detects inappropriate seeding of C++ random generators and C srand function.
+

Please replace srand  with ``srand ()``.



Comment at: docs/clang-tidy/checks/cert-msc51-cpp.rst:7
+This check flags all pseudo-random number engines, engine adaptor
+instantiations and srand when initialized or seeded with default argument,
+constant expression or any user-configurable type. Pseudo-random number

aaron.ballman wrote:
> Backticks around `srand`
Two of them and please add (). Will be good idea to make first statement same 
as in Release Notes.



Comment at: docs/clang-tidy/checks/cert-msc51-cpp.rst:29
+  }
+
+Options

Is there guideline documentation available online? If so, please add link. See 
other checks documentation as example.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44143



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


[PATCH] D44233: Set dso_local on external rtti GVs

2018-03-13 Thread Rafael Avila de Espindola via Phabricator via cfe-commits
espindola added a comment.

ping


https://reviews.llvm.org/D44233



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


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

2018-03-13 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 138241.
juliehockett marked 8 inline comments as done.
juliehockett retitled this revision from "[clang-tidy] Add Fuchsia checker for 
temporary objects" to "[clang-tidy] Add Zircon module to clang-tidy".
juliehockett edited the summary of this revision.
juliehockett added a comment.

Moved check to new Zircon module, fixed comments


https://reviews.llvm.org/D44346

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

Index: test/clang-tidy/zircon-temporary-objects.cpp
===
--- /dev/null
+++ test/clang-tidy/zircon-temporary-objects.cpp
@@ -0,0 +1,82 @@
+// RUN: %check_clang_tidy %s zircon-temporary-objects %t -- \
+// RUN:   -config="{CheckOptions: [{key: zircon-temporary-objects.Names, value: 'Foo;NS::Bar'}]}" \
+// RUN:   -header-filter=.* \
+// RUN: -- -std=c++11
+
+// Should flag instances of Foo, NS::Bar
+
+class Foo {
+public:
+  Foo() = default;
+  Foo(int Val) : Val(Val){};
+
+private:
+  int Val;
+};
+
+namespace NS {
+
+class Bar {
+public:
+  Bar() = default;
+  Bar(int Val) : Val(Val){};
+
+private:
+  int Val;
+};
+
+} // namespace NS
+
+class Bar {
+public:
+  Bar() = default;
+  Bar(int Val) : Val(Val){};
+
+private:
+  int Val;
+};
+
+int func(Foo F) { return 1; };
+
+int main() {
+  Foo F;
+  Foo *F2 = new Foo();
+  new Foo();
+  Foo();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: creating a temporary object of type Foo is prohibited
+  Foo F3 = Foo();
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: creating a temporary object of type Foo is prohibited
+
+  Bar();
+  NS::Bar();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: creating a temporary object of type NS::Bar is prohibited
+
+  int A = func(Foo());
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: creating a temporary object of type Foo is prohibited
+
+  Foo F4(0);
+  Foo *F5 = new Foo(0);
+  new Foo(0);
+  Foo(0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: creating a temporary object of type Foo is prohibited
+  Foo F6 = Foo(0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: creating a temporary object of type Foo is prohibited
+
+  Bar(0);
+  NS::Bar(0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: creating a temporary object of type NS::Bar is prohibited
+
+  int B = func(Foo(0));
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: creating a temporary object of type Foo is prohibited
+}
+
+namespace NS {
+
+void f() {
+  Bar();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: creating a temporary object of type NS::Bar is prohibited
+  Bar(0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: creating a temporary object of type NS::Bar is prohibited
+}
+
+} // namespace NS
Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -75,6 +75,7 @@
relate to any particular coding style.
 ``readability-``   Checks that target readability-related issues that don't
relate to any particular coding style.
+``zircon-``Checks related to Zercon kernel coding conventions.
 == =
 
 Clang diagnostics are treated in a similar way as check diagnostics. Clang
Index: docs/clang-tidy/checks/zircon-temporary-objects.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/zircon-temporary-objects.rst
@@ -0,0 +1,40 @@
+.. title:: clang-tidy - zircon-temporary-objects
+
+zircon-temporary-objects
+
+
+Warns on construction of specific temporary objects in the Zircon kernel.
+
+For example, given the list of classes "Foo" and "NS::Bar", all of the 
+following will trigger the warning: 
+
+.. code-block:: c++
+
+  Foo();
+  Foo F = Foo();
+  func(Foo());
+
+  namespace NS {
+
+  Bar();
+
+  }
+
+With the same list, the following will not trigger the warning:
+
+.. code-block:: c++
+
+  Foo F;// Non-temporary construction okay
+  Foo F(param);			// Non-temporary construction okay
+  Foo *F = new Foo();	// New construction okay
+
+  Bar(); // Not NS::Bar, so okay
+  NS::Bar B;			// Non-temporary construction okay
+
+Options
+---
+
+.. option:: Names
+
+   A semi-colon-separated list of fully-qualified names of C++ classes that 
+   should not be constructed as temporaries. Default is empty.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/

[PATCH] D43197: [OpenMP] Add flag for linking runtime bitcode library

2018-03-13 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 138242.
gtbercea added a comment.

Address comments.


Repository:
  rC Clang

https://reviews.llvm.org/D43197

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_20.bc
  test/Driver/openmp-offload-gpu.c


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -142,3 +142,23 @@
 // RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
 
 // CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_60
+
+/// ###
+
+/// Check that the runtime bitcode library is part of the compile line. Create 
a bogus
+/// bitcode library and add it to the LIBRARY_PATH.
+// RUN:   env LIBRARY_PATH=%S/Inputs/libomptarget %clang -### -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda \
+// RUN:   -Xopenmp-target -march=sm_20 -fopenmp-relocatable-target -save-temps 
\
+// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck -check-prefix=CHK-BCLIB %s
+
+// CHK-BCLIB: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-cuda-bitcode{{.*}}libomptarget-nvptx-sm_20.bc
+
+/// ###
+
+/// Check that the warning is thrown when the libomptarget bitcode library is 
not found.
+/// Libomptarget requires sm_35 or newer so an sm_20 bitcode library should 
never exist.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
+// RUN:   -Xopenmp-target -march=sm_20 -fopenmp-relocatable-target -save-temps 
\
+// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck 
-check-prefix=CHK-BCLIB-WARN %s
+
+// CHK-BCLIB-WARN: No library 'libomptarget-nvptx-sm_20.bc' found in the 
default clang lib directory or in LIBRARY_PATH. Expect degraded performance due 
to no inlining of runtime functions on target devices.
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -21,6 +21,7 @@
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/Program.h"
 #include 
 
@@ -580,6 +581,44 @@
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+ptx42");
   }
+
+  if (DeviceOffloadingKind == Action::OFK_OpenMP) {
+SmallVector LibraryPaths;
+// Add path to lib and/or lib64 folders.
+SmallString<256> DefaultLibPath =
+  llvm::sys::path::parent_path(getDriver().Dir);
+llvm::sys::path::append(DefaultLibPath,
+Twine("lib") + CLANG_LIBDIR_SUFFIX);
+LibraryPaths.emplace_back(DefaultLibPath.c_str());
+
+// Add user defined library paths from LIBRARY_PATH.
+llvm::Optional LibPath =
+llvm::sys::Process::GetEnv("LIBRARY_PATH");
+if (LibPath) {
+  SmallVector Frags;
+  const char EnvPathSeparatorStr[] = {llvm::sys::EnvPathSeparator, '\0'};
+  llvm::SplitString(*LibPath, Frags, EnvPathSeparatorStr);
+  for (StringRef Path : Frags)
+LibraryPaths.emplace_back(Path.trim());
+}
+
+std::string LibOmpTargetName =
+  "libomptarget-nvptx-" + GpuArch.str() + ".bc";
+bool FoundBCLibrary = false;
+for (StringRef LibraryPath : LibraryPaths) {
+  SmallString<128> LibOmpTargetFile(LibraryPath);
+  llvm::sys::path::append(LibOmpTargetFile, LibOmpTargetName);
+  if (llvm::sys::fs::exists(LibOmpTargetFile)) {
+CC1Args.push_back("-mlink-cuda-bitcode");
+CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetFile));
+FoundBCLibrary = true;
+break;
+  }
+}
+if (!FoundBCLibrary)
+  getDriver().Diag(diag::warn_drv_omp_offload_target_missingbcruntime)
+  << LibOmpTargetName;
+  }
 }
 
 void CudaToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,
Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -203,6 +203,9 @@
 def warn_drv_omp_offload_target_duplicate : Warning<
   "The OpenMP offloading target '%0' is similar to target '%1' already 
specified - will be ignored.">, 
   InGroup;
+def warn_drv_omp_offload_target_missingbcruntime : Warning<
+  "No library '%0' found in the default clang lib directory or in 
LIBRARY_PATH. Expect degraded performance due to no inlining of runtime 
functions on target devices.">,
+  InGroup;
 def err_drv_bitcode_unsupported_on_toolchain : Error<
   "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
 


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c

r327434 - Serialize the NonTrivialToPrimitive* flags I added in r326307.

2018-03-13 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Tue Mar 13 11:58:25 2018
New Revision: 327434

URL: http://llvm.org/viewvc/llvm-project?rev=327434&view=rev
Log:
Serialize the NonTrivialToPrimitive* flags I added in r326307.

rdar://problem/38421774

Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/CodeGenObjC/strong-in-c-struct.m

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=327434&r1=327433&r2=327434&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Mar 13 11:58:25 2018
@@ -3616,24 +3616,24 @@ public:
 return NonTrivialToPrimitiveDefaultInitialize;
   }
 
-  void setNonTrivialToPrimitiveDefaultInitialize() {
-NonTrivialToPrimitiveDefaultInitialize = true;
+  void setNonTrivialToPrimitiveDefaultInitialize(bool V) {
+NonTrivialToPrimitiveDefaultInitialize = V;
   }
 
   bool isNonTrivialToPrimitiveCopy() const {
 return NonTrivialToPrimitiveCopy;
   }
 
-  void setNonTrivialToPrimitiveCopy() {
-NonTrivialToPrimitiveCopy = true;
+  void setNonTrivialToPrimitiveCopy(bool V) {
+NonTrivialToPrimitiveCopy = V;
   }
 
   bool isNonTrivialToPrimitiveDestroy() const {
 return NonTrivialToPrimitiveDestroy;
   }
 
-  void setNonTrivialToPrimitiveDestroy() {
-NonTrivialToPrimitiveDestroy = true;
+  void setNonTrivialToPrimitiveDestroy(bool V) {
+NonTrivialToPrimitiveDestroy = V;
   }
 
   /// \brief Determines whether this declaration represents the

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=327434&r1=327433&r2=327434&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Mar 13 11:58:25 2018
@@ -15445,12 +15445,12 @@ void Sema::ActOnFields(Scope *S, SourceL
 if (Record && !getLangOpts().CPlusPlus) {
   QualType FT = FD->getType();
   if (FT.isNonTrivialToPrimitiveDefaultInitialize())
-Record->setNonTrivialToPrimitiveDefaultInitialize();
+Record->setNonTrivialToPrimitiveDefaultInitialize(true);
   QualType::PrimitiveCopyKind PCK = FT.isNonTrivialToPrimitiveCopy();
   if (PCK != QualType::PCK_Trivial && PCK != QualType::PCK_VolatileTrivial)
-Record->setNonTrivialToPrimitiveCopy();
+Record->setNonTrivialToPrimitiveCopy(true);
   if (FT.isDestructedType())
-Record->setNonTrivialToPrimitiveDestroy();
+Record->setNonTrivialToPrimitiveDestroy(true);
 }
 
 if (Record && FD->getType().isVolatileQualified())

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=327434&r1=327433&r2=327434&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Tue Mar 13 11:58:25 2018
@@ -739,6 +739,9 @@ ASTDeclReader::VisitRecordDeclImpl(Recor
   RD->setAnonymousStructOrUnion(Record.readInt());
   RD->setHasObjectMember(Record.readInt());
   RD->setHasVolatileMember(Record.readInt());
+  RD->setNonTrivialToPrimitiveDefaultInitialize(Record.readInt());
+  RD->setNonTrivialToPrimitiveCopy(Record.readInt());
+  RD->setNonTrivialToPrimitiveDestroy(Record.readInt());
   return Redecl;
 }
 

Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=327434&r1=327433&r2=327434&view=diff
==
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Tue Mar 13 11:58:25 2018
@@ -465,6 +465,9 @@ void ASTDeclWriter::VisitRecordDecl(Reco
   Record.push_back(D->isAnonymousStructOrUnion());
   Record.push_back(D->hasObjectMember());
   Record.push_back(D->hasVolatileMember());
+  Record.push_back(D->isNonTrivialToPrimitiveDefaultInitialize());
+  Record.push_back(D->isNonTrivialToPrimitiveCopy());
+  Record.push_back(D->isNonTrivialToPrimitiveDestroy());
 
   if (D->getDeclContext() == D->getLexicalDeclContext() &&
   !D->hasAttrs() &&
@@ -1899,6 +1902,14 @@ void ASTWriter::WriteDeclAbbrevs() {
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // AnonymousStructUnion
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // hasObjectMember
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // hasVolatileMember
+
+  // isNonTrivialToPrimitiveDefaultInitialize
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
+  // isNonTrivialToPrimitiveCopy

[PATCH] D43197: [OpenMP] Add flag for linking runtime bitcode library

2018-03-13 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.

LG


Repository:
  rC Clang

https://reviews.llvm.org/D43197



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


r327438 - [OpenMP] Add flag for linking runtime bitcode library

2018-03-13 Thread Gheorghe-Teodor Bercea via cfe-commits
Author: gbercea
Date: Tue Mar 13 12:39:19 2018
New Revision: 327438

URL: http://llvm.org/viewvc/llvm-project?rev=327438&view=rev
Log:
[OpenMP] Add flag for linking runtime bitcode library

Summary: This patch adds an additional flag to the OpenMP device offloading 
toolchain to link in the runtime library bitcode.

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

Reviewed By: ABataev, grokos

Subscribers: jholewinski, guansong, cfe-commits

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

Added:
cfe/trunk/test/Driver/Inputs/libomptarget/
cfe/trunk/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_20.bc
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
cfe/trunk/test/Driver/openmp-offload-gpu.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=327438&r1=327437&r2=327438&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Mar 13 12:39:19 
2018
@@ -203,6 +203,9 @@ def err_drv_expecting_fopenmp_with_fopen
 def warn_drv_omp_offload_target_duplicate : Warning<
   "The OpenMP offloading target '%0' is similar to target '%1' already 
specified - will be ignored.">, 
   InGroup;
+def warn_drv_omp_offload_target_missingbcruntime : Warning<
+  "No library '%0' found in the default clang lib directory or in 
LIBRARY_PATH. Expect degraded performance due to no inlining of runtime 
functions on target devices.">,
+  InGroup;
 def err_drv_bitcode_unsupported_on_toolchain : Error<
   "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
 

Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.cpp?rev=327438&r1=327437&r2=327438&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp Tue Mar 13 12:39:19 2018
@@ -21,6 +21,7 @@
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/Program.h"
 #include 
 
@@ -580,6 +581,44 @@ void CudaToolChain::addClangTargetOption
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+ptx42");
   }
+
+  if (DeviceOffloadingKind == Action::OFK_OpenMP) {
+SmallVector LibraryPaths;
+// Add path to lib and/or lib64 folders.
+SmallString<256> DefaultLibPath =
+  llvm::sys::path::parent_path(getDriver().Dir);
+llvm::sys::path::append(DefaultLibPath,
+Twine("lib") + CLANG_LIBDIR_SUFFIX);
+LibraryPaths.emplace_back(DefaultLibPath.c_str());
+
+// Add user defined library paths from LIBRARY_PATH.
+llvm::Optional LibPath =
+llvm::sys::Process::GetEnv("LIBRARY_PATH");
+if (LibPath) {
+  SmallVector Frags;
+  const char EnvPathSeparatorStr[] = {llvm::sys::EnvPathSeparator, '\0'};
+  llvm::SplitString(*LibPath, Frags, EnvPathSeparatorStr);
+  for (StringRef Path : Frags)
+LibraryPaths.emplace_back(Path.trim());
+}
+
+std::string LibOmpTargetName =
+  "libomptarget-nvptx-" + GpuArch.str() + ".bc";
+bool FoundBCLibrary = false;
+for (StringRef LibraryPath : LibraryPaths) {
+  SmallString<128> LibOmpTargetFile(LibraryPath);
+  llvm::sys::path::append(LibOmpTargetFile, LibOmpTargetName);
+  if (llvm::sys::fs::exists(LibOmpTargetFile)) {
+CC1Args.push_back("-mlink-cuda-bitcode");
+CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetFile));
+FoundBCLibrary = true;
+break;
+  }
+}
+if (!FoundBCLibrary)
+  getDriver().Diag(diag::warn_drv_omp_offload_target_missingbcruntime)
+  << LibOmpTargetName;
+  }
 }
 
 void CudaToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,

Added: cfe/trunk/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_20.bc
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_20.bc?rev=327438&view=auto
==
(empty)

Modified: cfe/trunk/test/Driver/openmp-offload-gpu.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openmp-offload-gpu.c?rev=327438&r1=327437&r2=327438&view=diff
==
--- cfe/trunk/test/Driver/openmp-offload-gpu.c (original)
+++ cfe/trunk/test/Driver/openmp-offload-gpu.c Tue Mar 13 12:39:19 2018
@@ -142,3 +142,23 @@
 // RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
 
 // CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_60
+
+/// ##

r327437 - This reverts "r327189 - [ARM] Add ARMv8.2-A FP16 vector intrinsic"

2018-03-13 Thread Sjoerd Meijer via cfe-commits
Author: sjoerdmeijer
Date: Tue Mar 13 12:38:56 2018
New Revision: 327437

URL: http://llvm.org/viewvc/llvm-project?rev=327437&view=rev
Log:
This reverts "r327189 - [ARM] Add ARMv8.2-A FP16 vector intrinsic"

This is causing problems in testing, and PR36683 was raised.
Reverting it until we have sorted out how to pass f16 vectors.


Removed:
cfe/trunk/test/CodeGen/arm-v8.2a-neon-intrinsics.c
Modified:
cfe/trunk/include/clang/Basic/arm_neon.td
cfe/trunk/lib/Basic/Targets/ARM.cpp
cfe/trunk/lib/Basic/Targets/ARM.h
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGen/arm_neon_intrinsics.c

Modified: cfe/trunk/include/clang/Basic/arm_neon.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=327437&r1=327436&r2=327437&view=diff
==
--- cfe/trunk/include/clang/Basic/arm_neon.td (original)
+++ cfe/trunk/include/clang/Basic/arm_neon.td Tue Mar 13 12:38:56 2018
@@ -1363,8 +1363,8 @@ def SCALAR_VDUP_LANE : IInst<"vdup_lane"
 def SCALAR_VDUP_LANEQ : IInst<"vdup_laneq", "sji", 
"ScSsSiSlSfSdSUcSUsSUiSUlSPcSPs">;
 }
 
-// ARMv8.2-A FP16 vector intrinsics for A32/A64.
-let ArchGuard = "defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)" in {
+// ARMv8.2-A FP16 intrinsics.
+let ArchGuard = "defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) && 
defined(__aarch64__)" in {
 
   // ARMv8.2-A FP16 one-operand vector intrinsics.
 
@@ -1395,12 +1395,14 @@ let ArchGuard = "defined(__ARM_FEATURE_F
   def FRINTPH  : SInst<"vrndp", "dd", "hQh">;
   def FRINTMH  : SInst<"vrndm", "dd", "hQh">;
   def FRINTXH  : SInst<"vrndx", "dd", "hQh">;
+  def FRINTIH  : SInst<"vrndi", "dd", "hQh">;
 
   // Misc.
   def VABSH: SInst<"vabs", "dd", "hQh">;
   def VNEGH: SOpInst<"vneg", "dd", "hQh", OP_NEG>;
   def VRECPEH  : SInst<"vrecpe", "dd", "hQh">;
   def FRSQRTEH : SInst<"vrsqrte", "dd", "hQh">;
+  def FSQRTH   : SInst<"vsqrt", "dd", "hQh">;
 
   // ARMv8.2-A FP16 two-operands vector intrinsics.
 
@@ -1441,13 +1443,18 @@ let ArchGuard = "defined(__ARM_FEATURE_F
 
   // Multiplication/Division
   def VMULH : SOpInst<"vmul", "ddd", "hQh", OP_MUL>;
+  def MULXH : SInst<"vmulx", "ddd", "hQh">;
+  def FDIVH : IOpInst<"vdiv", "ddd",  "hQh", OP_DIV>;
 
   // Pairwise addition
-  def VPADDH: SInst<"vpadd", "ddd", "h">;
+  def VPADDH: SInst<"vpadd", "ddd", "hQh">;
 
   // Pairwise Max/Min
-  def VPMAXH: SInst<"vpmax", "ddd", "h">;
-  def VPMINH: SInst<"vpmin", "ddd", "h">;
+  def VPMAXH: SInst<"vpmax", "ddd", "hQh">;
+  def VPMINH: SInst<"vpmin", "ddd", "hQh">;
+  // Pairwise MaxNum/MinNum
+  def FMAXNMPH  : SInst<"vpmaxnm", "ddd", "hQh">;
+  def FMINNMPH  : SInst<"vpminnm", "ddd", "hQh">;
 
   // Reciprocal/Sqrt
   def VRECPSH   : SInst<"vrecps", "ddd", "hQh">;
@@ -1461,63 +1468,6 @@ let ArchGuard = "defined(__ARM_FEATURE_F
 
   // ARMv8.2-A FP16 lane vector intrinsics.
 
-  // Mul lane
-  def VMUL_LANEH: IOpInst<"vmul_lane", "ddgi", "hQh", OP_MUL_LN>;
-  def VMUL_NH   : IOpInst<"vmul_n", "dds", "hQh", OP_MUL_N>;
-
-  // Data processing intrinsics - section 5
-
-  // Logical operations
-  let isHiddenLInst = 1 in
-  def VBSLH: SInst<"vbsl", "dudd", "hQh">;
-
-  // Transposition operations
-  def VZIPH: WInst<"vzip", "2dd", "hQh">;
-  def VUZPH: WInst<"vuzp", "2dd", "hQh">;
-  def VTRNH: WInst<"vtrn", "2dd", "hQh">;
-
-
-  let ArchGuard = "!defined(__aarch64__)" in {
-// Set all lanes to same value.
-// Already implemented prior to ARMv8.2-A.
-def VMOV_NH  : WOpInst<"vmov_n", "ds", "hQh", OP_DUP>;
-def VDUP_NH  : WOpInst<"vdup_n", "ds", "hQh", OP_DUP>;
-def VDUP_LANE1H : WOpInst<"vdup_lane", "dgi", "hQh", OP_DUP_LN>;
-  }
-
-  // Vector Extract
-  def VEXTH  : WInst<"vext", "dddi", "hQh">;
-
-  // Reverse vector elements
-  def VREV64H: WOpInst<"vrev64", "dd", "hQh", OP_REV64>;
-}
-
-// ARMv8.2-A FP16 vector intrinsics for A64 only.
-let ArchGuard = "defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) && 
defined(__aarch64__)" in {
-
-  // Vector rounding
-  def FRINTIH  : SInst<"vrndi", "dd", "hQh">;
-
-  // Misc.
-  def FSQRTH   : SInst<"vsqrt", "dd", "hQh">;
-
-  // Multiplication/Division
-  def MULXH : SInst<"vmulx", "ddd", "hQh">;
-  def FDIVH : IOpInst<"vdiv", "ddd",  "hQh", OP_DIV>;
-
-  // Pairwise addition
-  def VPADDH1   : SInst<"vpadd", "ddd", "Qh">;
-
-  // Pairwise Max/Min
-  def VPMAXH1   : SInst<"vpmax", "ddd", "Qh">;
-  def VPMINH1   : SInst<"vpmin", "ddd", "Qh">;
-
-  // Pairwise MaxNum/MinNum
-  def FMAXNMPH  : SInst<"vpmaxnm", "ddd", "hQh">;
-  def FMINNMPH  : SInst<"vpminnm", "ddd", "hQh">;
-
-  // ARMv8.2-A FP16 lane vector intrinsics.
-
   // FMA lane
   def VFMA_LANEH   : IInst<"vfma_lane", "dddgi", "hQh">;
   def VFMA_LANEQH  : IInst<"vfma

[PATCH] D43197: [OpenMP] Add flag for linking runtime bitcode library

2018-03-13 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC327438: [OpenMP] Add flag for linking runtime bitcode 
library (authored by gbercea, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D43197?vs=138242&id=138245#toc

Repository:
  rC Clang

https://reviews.llvm.org/D43197

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_20.bc
  test/Driver/openmp-offload-gpu.c


Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -21,6 +21,7 @@
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/Program.h"
 #include 
 
@@ -580,6 +581,44 @@
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+ptx42");
   }
+
+  if (DeviceOffloadingKind == Action::OFK_OpenMP) {
+SmallVector LibraryPaths;
+// Add path to lib and/or lib64 folders.
+SmallString<256> DefaultLibPath =
+  llvm::sys::path::parent_path(getDriver().Dir);
+llvm::sys::path::append(DefaultLibPath,
+Twine("lib") + CLANG_LIBDIR_SUFFIX);
+LibraryPaths.emplace_back(DefaultLibPath.c_str());
+
+// Add user defined library paths from LIBRARY_PATH.
+llvm::Optional LibPath =
+llvm::sys::Process::GetEnv("LIBRARY_PATH");
+if (LibPath) {
+  SmallVector Frags;
+  const char EnvPathSeparatorStr[] = {llvm::sys::EnvPathSeparator, '\0'};
+  llvm::SplitString(*LibPath, Frags, EnvPathSeparatorStr);
+  for (StringRef Path : Frags)
+LibraryPaths.emplace_back(Path.trim());
+}
+
+std::string LibOmpTargetName =
+  "libomptarget-nvptx-" + GpuArch.str() + ".bc";
+bool FoundBCLibrary = false;
+for (StringRef LibraryPath : LibraryPaths) {
+  SmallString<128> LibOmpTargetFile(LibraryPath);
+  llvm::sys::path::append(LibOmpTargetFile, LibOmpTargetName);
+  if (llvm::sys::fs::exists(LibOmpTargetFile)) {
+CC1Args.push_back("-mlink-cuda-bitcode");
+CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetFile));
+FoundBCLibrary = true;
+break;
+  }
+}
+if (!FoundBCLibrary)
+  getDriver().Diag(diag::warn_drv_omp_offload_target_missingbcruntime)
+  << LibOmpTargetName;
+  }
 }
 
 void CudaToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,
Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -203,6 +203,9 @@
 def warn_drv_omp_offload_target_duplicate : Warning<
   "The OpenMP offloading target '%0' is similar to target '%1' already 
specified - will be ignored.">, 
   InGroup;
+def warn_drv_omp_offload_target_missingbcruntime : Warning<
+  "No library '%0' found in the default clang lib directory or in 
LIBRARY_PATH. Expect degraded performance due to no inlining of runtime 
functions on target devices.">,
+  InGroup;
 def err_drv_bitcode_unsupported_on_toolchain : Error<
   "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
 
Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -142,3 +142,23 @@
 // RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
 
 // CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_60
+
+/// ###
+
+/// Check that the runtime bitcode library is part of the compile line. Create 
a bogus
+/// bitcode library and add it to the LIBRARY_PATH.
+// RUN:   env LIBRARY_PATH=%S/Inputs/libomptarget %clang -### -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda \
+// RUN:   -Xopenmp-target -march=sm_20 -fopenmp-relocatable-target -save-temps 
\
+// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck -check-prefix=CHK-BCLIB %s
+
+// CHK-BCLIB: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-cuda-bitcode{{.*}}libomptarget-nvptx-sm_20.bc
+
+/// ###
+
+/// Check that the warning is thrown when the libomptarget bitcode library is 
not found.
+/// Libomptarget requires sm_35 or newer so an sm_20 bitcode library should 
never exist.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
+// RUN:   -Xopenmp-target -march=sm_20 -fopenmp-relocatable-target -save-temps 
\
+// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck 
-check-prefix=CHK-BCLIB-WARN %s
+
+// CHK-BCLIB-WARN: No library 'libomptarget-nvptx-sm_20.bc' found in the 
default clang lib directory or in LIBRARY_PATH. Expect degraded performance due 
to no inlining of runtime functions on target devices.

[PATCH] D43650: [ARM] Add ARMv8.2-A FP16 vector intrinsics

2018-03-13 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

Reverted in r327437.


https://reviews.llvm.org/D43650



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


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

2018-03-13 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: rsmith, rjmccall.

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

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

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

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


https://reviews.llvm.org/D5

Files:
  lib/CodeGen/CGCall.h
  lib/CodeGen/CGValue.h
  test/CodeGenCXX/deep-ast-tree.cpp

Index: test/CodeGenCXX/deep-ast-tree.cpp
===
--- /dev/null
+++ test/CodeGenCXX/deep-ast-tree.cpp
@@ -0,0 +1,262 @@
+// RUN: %clang_cc1 %s
+// This test will cause clang to generate a deep AST tree with many CallArgs.
+// This is to make sure there is no stack overflow for such situations.
+// It is based on a use case in Eigen: 
+// https://eigen.tuxfamily.org/dox/group__TutorialAdvancedInitialization.html
+//
+struct VectorBuilder {
+  VectorBuilder &operator,(int);
+};
+void f() {
+  VectorBuilder(),
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,

[PATCH] D43248: [Attr] Fix parameter indexing for attributes

2018-03-13 Thread Eric Christopher via Phabricator via cfe-commits
echristo added inline comments.



Comment at: test/Sema/attr-print.cpp:3
 
+// This file is also used as input for %S/../Frontend/ast-attr.cpp.
+

Relatedly I don't think we use files as input files to other directories and I 
don't think we should really. What are you trying to test here? This breaks the 
hermeticness of each particular test directory.


Repository:
  rC Clang

https://reviews.llvm.org/D43248



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


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

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



Comment at: lib/CodeGen/CGValue.h:234
 this->Quals = Quals;
 this->Alignment = Alignment.getQuantity();
 assert(this->Alignment == Alignment.getQuantity() &&

Please saturate Alignment here instead of allowing it to be truncated: that is, 
if the passed-in alignment is greater than (1U << 31), please store (1U << 31).


https://reviews.llvm.org/D5



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


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

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



Comment at: clang-tidy/tool/ClangTidyMain.cpp:527
 
-// This anchor is used to force the linker to link the GoogleModule.
+// This anchor is used to force the linker to link the FuchsiaModule.
 extern volatile int FuchsiaModuleAnchorSource;

You can go ahead and commit this change directly to trunk, no need to roll it 
in to this patch (since it's an unrelated drive-by). No review necessary.



Comment at: clang-tidy/zircon/TemporaryObjectsCheck.cpp:31
+void TemporaryObjectsCheck::registerMatchers(MatchFinder *Finder) {
+  // Matcher for default constructors
+  Finder->addMatcher(

Full stop at the end of comments (here and elsewhere).



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

You can skip the call to `getQualifiedNameAsString()`; the diagnostics engine 
will handle it properly.



Comment at: clang-tidy/zircon/TemporaryObjectsCheck.h:21-22
+/// Construction of specific temporary objects in the Zircon kernel is
+/// discouraged. Takes the list of such discouraged temporary objects as a
+/// parameter.
+///

I think the "Takes the list" sentence could be made more clear as "The list of 
disallowed temporary object types is configurable.", but you could probably 
just drop the sentence entirely as well.



Comment at: docs/clang-tidy/checks/list.rst:93
fuchsia-virtual-inheritance
+   zircon-temporary-objects
google-build-explicit-make-pair

Can you keep this list alphabetical?



Comment at: docs/clang-tidy/index.rst:78
relate to any particular coding style.
+``zircon-``Checks related to Zercon kernel coding conventions.
 == 
=

s/Zercon/Zircon


https://reviews.llvm.org/D44346



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


[PATCH] D44408: Move DraftMgr from ClangdServer to ClangdLSPServer

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

Rebase

Non-trivial rebase on today's master.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44408

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

Index: unittests/clangd/SyncAPI.h
===
--- unittests/clangd/SyncAPI.h
+++ unittests/clangd/SyncAPI.h
@@ -22,11 +22,13 @@
 void runAddDocument(ClangdServer &Server, PathRef File, StringRef Contents);
 
 llvm::Expected
-runCodeComplete(ClangdServer &Server, PathRef File, Position Pos,
-clangd::CodeCompleteOptions Opts);
+runCodeComplete(ClangdServer &Server, PathRef File, std::string Contents,
+Position Pos, clangd::CodeCompleteOptions Opts);
 
 llvm::Expected runSignatureHelp(ClangdServer &Server,
-   PathRef File, Position Pos);
+   PathRef File,
+   std::string Contents,
+   Position Pos);
 
 llvm::Expected>
 runFindDefinitions(ClangdServer &Server, PathRef File, Position Pos);
Index: unittests/clangd/SyncAPI.cpp
===
--- unittests/clangd/SyncAPI.cpp
+++ unittests/clangd/SyncAPI.cpp
@@ -68,17 +68,19 @@
 } // namespace
 
 llvm::Expected
-runCodeComplete(ClangdServer &Server, PathRef File, Position Pos,
-clangd::CodeCompleteOptions Opts) {
+runCodeComplete(ClangdServer &Server, PathRef File, std::string Contents,
+Position Pos, clangd::CodeCompleteOptions Opts) {
   llvm::Optional> Result;
-  Server.codeComplete(File, Pos, Opts, capture(Result));
+  Server.codeComplete(File, std::move(Contents), Pos, Opts, capture(Result));
   return std::move(*Result);
 }
 
 llvm::Expected runSignatureHelp(ClangdServer &Server,
-   PathRef File, Position Pos) {
+   PathRef File,
+   std::string Contents,
+   Position Pos) {
   llvm::Optional> Result;
-  Server.signatureHelp(File, Pos, capture(Result));
+  Server.signatureHelp(File, std::move(Contents), Pos, capture(Result));
   return std::move(*Result);
 }
 
Index: unittests/clangd/DraftStoreTests.cpp
===
--- /dev/null
+++ unittests/clangd/DraftStoreTests.cpp
@@ -0,0 +1,56 @@
+//===-- DraftStoreTests.cpp - Clangd unit tests -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "DraftStore.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+using namespace llvm;
+
+using ::testing::UnorderedElementsAre;
+
+/// Get the active drafts from \p DS as a vector.
+static std::vector getActiveDrafts(const DraftStore &DS) {
+  std::vector ActiveDrafts;
+
+  DS.forEachActiveDraft([&ActiveDrafts](PathRef File, StringRef Contents) {
+ActiveDrafts.push_back(File);
+  });
+
+  return ActiveDrafts;
+}
+
+TEST(DraftStoreTest, forEachActiveDraft) {
+  DraftStore DS;
+
+  DS.updateDraft("/foo.cpp", "Foo");
+  DS.updateDraft("/bar.cpp", "Bar");
+  DS.updateDraft("/baz.cpp", "Baz");
+
+  std::vector Drafts = getActiveDrafts(DS);
+  EXPECT_THAT(Drafts, UnorderedElementsAre("/foo.cpp", "/bar.cpp", "/baz.cpp"));
+
+  DS.removeDraft("/bar.cpp");
+
+  Drafts = getActiveDrafts(DS);
+  EXPECT_THAT(Drafts, UnorderedElementsAre("/foo.cpp", "/baz.cpp"));
+
+  DS.removeDraft("/another.cpp");
+
+  Drafts = getActiveDrafts(DS);
+  EXPECT_THAT(Drafts, UnorderedElementsAre("/foo.cpp", "/baz.cpp"));
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -122,7 +122,7 @@
   Annotations Test(Text);
   runAddDocument(Server, File, Test.code());
   auto CompletionList =
-  cantFail(runCodeComplete(Server, File, Test.point(), Opts));
+  cantFail(runCodeComplete(Server, File, Test.code(), Test.point(), Opts));
   // Sanity-check that filterText is valid.
   EXPECT_THAT(CompletionList.items, Each(NameContainsFilter()));
   return CompletionL

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

2018-03-13 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 138252.
yaxunl marked an inline comment as done.
yaxunl added a comment.

Saturate alignment when it is too large.


https://reviews.llvm.org/D5

Files:
  lib/CodeGen/CGCall.h
  lib/CodeGen/CGValue.h
  test/CodeGenCXX/deep-ast-tree.cpp

Index: test/CodeGenCXX/deep-ast-tree.cpp
===
--- /dev/null
+++ test/CodeGenCXX/deep-ast-tree.cpp
@@ -0,0 +1,262 @@
+// RUN: %clang_cc1 %s
+// This test will cause clang to generate a deep AST tree with many CallArgs.
+// This is to make sure there is no stack overflow for such situations.
+// It is based on a use case in Eigen: 
+// https://eigen.tuxfamily.org/dox/group__TutorialAdvancedInitialization.html
+//
+struct VectorBuilder {
+  VectorBuilder &operator,(int);
+};
+void f() {
+  VectorBuilder(),
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,
+  1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,

[PATCH] D43248: [Attr] Fix parameter indexing for attributes

2018-03-13 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added inline comments.



Comment at: test/Sema/attr-print.cpp:3
 
+// This file is also used as input for %S/../Frontend/ast-attr.cpp.
+

echristo wrote:
> Relatedly I don't think we use files as input files to other directories and 
> I don't think we should really. What are you trying to test here? This breaks 
> the hermeticness of each particular test directory.
Grep for "%S/.." and you'll see that a few other tests do something like this 
as well.

In test/Sema/attr-print.cpp, I am testing printing of attributes.  I chose to 
put that there because of the existing attr-print.c there.

In test/Frontend/ast-attr.cpp, I am testing serialization of attributes.  I 
chose to put that there because I see other -emit-ast tests there and because, 
if I put it in test/Sema instead, I get the complaint "Do not use the driver in 
Sema tests".

The same C++ code makes sense in both of these, but replicating it in two files 
would worsen maintainability.

I could try to  combine into one file in, say, tests/Misc if that works.

I have no strong opinions on where these live.  Just for my own education, is 
something real breaking right now because of their current locations?

Thanks.


Repository:
  rC Clang

https://reviews.llvm.org/D43248



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


Re: [PATCH] D30170: Function definition may have uninstantiated body

2018-03-13 Thread Kim Gräsman via cfe-commits
On Wed, Feb 28, 2018 at 8:21 PM, Richard Smith - zygoloid via
Phabricator via cfe-commits  wrote:
> 
> Comment at: lib/Sema/SemaDecl.cpp:11986
> +  !FD->isDefined(Definition)
> +  && FD->getDeclContext()->isFileContext()) {
> +// If this is a friend function defined in a class template, it does not
> 
> `&&` on the end of the previous line, please.
>
> If the intent here is to detect non-member functions, using 
> `!FD->isCXXClassMember()` or `!isa(FD)` would be clearer.

I just recently did something like this and finally settled on
`FD->getKind() == Decl::Function`. `FunctionDecl` now has two derived
types, `CXXMethodDecl` and `CXXDeductionGuideDecl`, so the negation on
`CXXMethodDecl` is no longer strictly enough.

I think it would be nice if `FunctionDecl` had an
`isNonMemberFunction()` (or whatever the formal term is) that did the
above-mentioned check for kind equality.

For what it's worth,
- Kim
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2018-03-13 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Thank you.  LGTM.


https://reviews.llvm.org/D5



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


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

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

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

> In https://reviews.llvm.org/D39050#1021204, @malaperle wrote:
>
> > For computing the start/end-loc of function bodies, I tried the 
> > SingleFileParseMode and SkipFunctionBodies separately ( as a start). The 
> > source I use this on looks like this:
> >
> >  
>
>
> Given the discussion in https://reviews.llvm.org/D44247, I think we can do 
> without the start/end-loc of function bodies and try some heuristics 
> client-side. We can always revisit this later if necessary.
>
> However, for the end-loc of occurrences, would you be OK with this being 
> added? I think it would be a good compromise in terms of performance, 
> simplicity and index size.


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

@akyrtzi Are the numbers from Marc-Andre's experiment what you'd expect to see 
and is there anything else to try? I'm not familiar with those modes at all to 
comment, sorry. I assume any API to gather syntactic structure info would be 
based on those modes, right?


https://reviews.llvm.org/D39050



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


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

2018-03-13 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis updated this revision to Diff 138254.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44295

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/ParentVirtualCallCheck.cpp
  clang-tidy/bugprone/ParentVirtualCallCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-parent-virtual-call.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-parent-virtual-call.cpp

Index: test/clang-tidy/bugprone-parent-virtual-call.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-parent-virtual-call.cpp
@@ -0,0 +1,127 @@
+// RUN: %check_clang_tidy %s bugprone-parent-virtual-call %t
+
+extern int foo();
+
+class A {
+public:
+  A() = default;
+  virtual ~A() = default;
+
+  virtual int virt_1() { return foo() + 1; }
+  virtual int virt_2() { return foo() + 2; }
+
+  int non_virt() { return foo() + 3; }
+  static int stat() { return foo() + 4; }
+};
+
+class B : public A {
+public:
+  B() = default;
+
+  // Nothing to fix: calls to parent.
+  int virt_1() override { return A::virt_1() + 3; }
+  int virt_2() override { return A::virt_2() + 4; }
+};
+
+class C : public B {
+public:
+  int virt_1() override { return A::virt_1() + B::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: 'A::virt_1' is a grand-parent's method, not parent's. Did you mean 'B'?
+  // CHECK-FIXES:  int virt_1() override { return B::virt_1() + B::virt_1(); }
+  int virt_2() override { return A::virt_1() + B::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: 'A::virt_1' is a grand-parent's method, not parent's. Did you mean 'B'?
+  // CHECK-FIXES:  int virt_2() override { return B::virt_1() + B::virt_1(); }
+
+  // Test that non-virtual and static methods are not affected by this cherker.
+  int method_c() { return A::stat() + A::non_virt(); }
+};
+
+// Test that the check affects grand-grand..-parent calls too.
+class D : public C {
+public:
+  int virt_1() override { return A::virt_1() + B::virt_1() + D::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: 'A::virt_1' is a grand-parent's method, not parent's. Did you mean 'C'?
+  // CHECK-MESSAGES: :[[@LINE-2]]:48: warning: 'B::virt_1' is a grand-parent's method, not parent's. Did you mean 'C'?
+  // CHECK-FIXES:  int virt_1() override { return C::virt_1() + C::virt_1() + D::virt_1(); }
+  int virt_2() override { return A::virt_1() + B::virt_1() + D::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: 'A::virt_1' is a grand-parent's method, not parent's. Did you mean 'C'?
+  // CHECK-MESSAGES: :[[@LINE-2]]:48: warning: 'B::virt_1' is a grand-parent's method, not parent's. Did you mean 'C'?
+  // CHECK-FIXES:  int virt_2() override { return C::virt_1() + C::virt_1() + D::virt_1(); }
+};
+
+// Test classes in anonymous namespaces.
+namespace {
+class BN : public A {
+public:
+  int virt_1() override { return A::virt_1() + 3; }
+  int virt_2() override { return A::virt_2() + 4; }
+};
+} // namespace N
+
+class CN : public BN {
+public:
+  int virt_1() override { return A::virt_1() + BN::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: 'A::virt_1' is a grand-parent's method, not parent's. Did you mean 'BN'?
+  // CHECK-FIXES:  int virt_1() override { return BN::virt_1() + BN::virt_1(); }
+  int virt_2() override { return A::virt_1() + BN::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: 'A::virt_1' is a grand-parent's method, not parent's. Did you mean 'BN'?
+  // CHECK-FIXES:  int virt_2() override { return BN::virt_1() + BN::virt_1(); }
+};
+
+// Test multiple inheritance fixes
+class AA {
+public:
+  AA() = default;
+  virtual ~AA() = default;
+
+  virtual int virt_1() { return foo() + 1; }
+  virtual int virt_2() { return foo() + 2; }
+
+  int non_virt() { return foo() + 3; }
+  static int stat() { return foo() + 4; }
+};
+
+class BB_1 : virtual public AA {
+public:
+  BB_1() = default;
+
+  // Nothing to fix: calls to parent.
+  int virt_1() override { return AA::virt_1() + 3; }
+  int virt_2() override { return AA::virt_2() + 4; }
+};
+
+class BB_2 : virtual public AA {
+public:
+BB_2() = default;
+};
+
+class CC : public BB_1, public BB_2 {
+public:
+  int virt_1() override { return AA::virt_1() + 3; }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: 'AA::virt_1' is a grand-parent's method, not parent's. Did you mean 'BB_1' or 'BB_2'? [bugprone-parent-virtual-call]
+  // No fix available due to multiple choice of parent class.
+};
+
+// Test templated classes.
+template  class BF : public A {
+public:
+  int virt_1() override { return A::virt_1() + 3; }
+};
+
+// Test templated parent class.
+class CF : public BF {
+public:
+  int virt_1() override { return A::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: 'A::virt_1' is a grand-parent's method, not parent's. Did you mean 'BF'?
+};
+
+// Test both templated class and its parent class.
+template  class DF : pub

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

2018-03-13 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis marked an inline comment as done and an inline comment as not done.
zinovy.nis added inline comments.



Comment at: test/clang-tidy/bugprone-parent-virtual-call.cpp:115
+  int virt_1() override { return A::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: 'A::virt_1' is a grand-parent's 
method, not parent's. Did you mean 'BF'?
+  // CHECK-FIXES:  int virt_1() override { return BF::virt_1(); }

malcolm.parsons wrote:
> There isn't an F in scope.
> The base class isn't a dependent type here, so no template params are needed.
Finally I decided not to propose a fix for templated parent.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44295



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


r327447 - Revert revision 327438.

2018-03-13 Thread Gheorghe-Teodor Bercea via cfe-commits
Author: gbercea
Date: Tue Mar 13 13:50:12 2018
New Revision: 327447

URL: http://llvm.org/viewvc/llvm-project?rev=327447&view=rev
Log:
Revert revision 327438.

Removed:
cfe/trunk/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_20.bc
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
cfe/trunk/test/Driver/openmp-offload-gpu.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=327447&r1=327446&r2=327447&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Mar 13 13:50:12 
2018
@@ -203,9 +203,6 @@ def err_drv_expecting_fopenmp_with_fopen
 def warn_drv_omp_offload_target_duplicate : Warning<
   "The OpenMP offloading target '%0' is similar to target '%1' already 
specified - will be ignored.">, 
   InGroup;
-def warn_drv_omp_offload_target_missingbcruntime : Warning<
-  "No library '%0' found in the default clang lib directory or in 
LIBRARY_PATH. Expect degraded performance due to no inlining of runtime 
functions on target devices.">,
-  InGroup;
 def err_drv_bitcode_unsupported_on_toolchain : Error<
   "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
 

Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.cpp?rev=327447&r1=327446&r2=327447&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp Tue Mar 13 13:50:12 2018
@@ -581,44 +581,6 @@ void CudaToolChain::addClangTargetOption
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+ptx42");
   }
-
-  if (DeviceOffloadingKind == Action::OFK_OpenMP) {
-SmallVector LibraryPaths;
-// Add path to lib and/or lib64 folders.
-SmallString<256> DefaultLibPath =
-  llvm::sys::path::parent_path(getDriver().Dir);
-llvm::sys::path::append(DefaultLibPath,
-Twine("lib") + CLANG_LIBDIR_SUFFIX);
-LibraryPaths.emplace_back(DefaultLibPath.c_str());
-
-// Add user defined library paths from LIBRARY_PATH.
-llvm::Optional LibPath =
-llvm::sys::Process::GetEnv("LIBRARY_PATH");
-if (LibPath) {
-  SmallVector Frags;
-  const char EnvPathSeparatorStr[] = {llvm::sys::EnvPathSeparator, '\0'};
-  llvm::SplitString(*LibPath, Frags, EnvPathSeparatorStr);
-  for (StringRef Path : Frags)
-LibraryPaths.emplace_back(Path.trim());
-}
-
-std::string LibOmpTargetName =
-  "libomptarget-nvptx-" + GpuArch.str() + ".bc";
-bool FoundBCLibrary = false;
-for (StringRef LibraryPath : LibraryPaths) {
-  SmallString<128> LibOmpTargetFile(LibraryPath);
-  llvm::sys::path::append(LibOmpTargetFile, LibOmpTargetName);
-  if (llvm::sys::fs::exists(LibOmpTargetFile)) {
-CC1Args.push_back("-mlink-cuda-bitcode");
-CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetFile));
-FoundBCLibrary = true;
-break;
-  }
-}
-if (!FoundBCLibrary)
-  getDriver().Diag(diag::warn_drv_omp_offload_target_missingbcruntime)
-  << LibOmpTargetName;
-  }
 }
 
 void CudaToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,

Removed: cfe/trunk/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_20.bc
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_20.bc?rev=327446&view=auto
==
(empty)

Modified: cfe/trunk/test/Driver/openmp-offload-gpu.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openmp-offload-gpu.c?rev=327447&r1=327446&r2=327447&view=diff
==
--- cfe/trunk/test/Driver/openmp-offload-gpu.c (original)
+++ cfe/trunk/test/Driver/openmp-offload-gpu.c Tue Mar 13 13:50:12 2018
@@ -142,23 +142,3 @@
 // RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
 
 // CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_60
-
-/// ###
-
-/// Check that the runtime bitcode library is part of the compile line. Create 
a bogus
-/// bitcode library and add it to the LIBRARY_PATH.
-// RUN:   env LIBRARY_PATH=%S/Inputs/libomptarget %clang -### -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda \
-// RUN:   -Xopenmp-target -march=sm_20 -fopenmp-relocatable-target -save-temps 
\
-// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck -check-prefix=CHK-BCLIB %s
-
-// CHK-BCLIB: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-cuda-bitcode{{.*}}libomptarget-nvptx-sm_20.bc
-
-/// #

Re: r327447 - Revert revision 327438.

2018-03-13 Thread Aaron Ballman via cfe-commits
On Tue, Mar 13, 2018 at 4:50 PM, Gheorghe-Teodor Bercea via
cfe-commits  wrote:
> Author: gbercea
> Date: Tue Mar 13 13:50:12 2018
> New Revision: 327447
>
> URL: http://llvm.org/viewvc/llvm-project?rev=327447&view=rev
> Log:
> Revert revision 327438.

Can you give some extra context as to why this was reverted?

~Aaron

>
> Removed:
> cfe/trunk/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_20.bc
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
> cfe/trunk/test/Driver/openmp-offload-gpu.c
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=327447&r1=327446&r2=327447&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Mar 13 
> 13:50:12 2018
> @@ -203,9 +203,6 @@ def err_drv_expecting_fopenmp_with_fopen
>  def warn_drv_omp_offload_target_duplicate : Warning<
>"The OpenMP offloading target '%0' is similar to target '%1' already 
> specified - will be ignored.">,
>InGroup;
> -def warn_drv_omp_offload_target_missingbcruntime : Warning<
> -  "No library '%0' found in the default clang lib directory or in 
> LIBRARY_PATH. Expect degraded performance due to no inlining of runtime 
> functions on target devices.">,
> -  InGroup;
>  def err_drv_bitcode_unsupported_on_toolchain : Error<
>"-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
>
>
> Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.cpp?rev=327447&r1=327446&r2=327447&view=diff
> ==
> --- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp Tue Mar 13 13:50:12 2018
> @@ -581,44 +581,6 @@ void CudaToolChain::addClangTargetOption
>  CC1Args.push_back("-target-feature");
>  CC1Args.push_back("+ptx42");
>}
> -
> -  if (DeviceOffloadingKind == Action::OFK_OpenMP) {
> -SmallVector LibraryPaths;
> -// Add path to lib and/or lib64 folders.
> -SmallString<256> DefaultLibPath =
> -  llvm::sys::path::parent_path(getDriver().Dir);
> -llvm::sys::path::append(DefaultLibPath,
> -Twine("lib") + CLANG_LIBDIR_SUFFIX);
> -LibraryPaths.emplace_back(DefaultLibPath.c_str());
> -
> -// Add user defined library paths from LIBRARY_PATH.
> -llvm::Optional LibPath =
> -llvm::sys::Process::GetEnv("LIBRARY_PATH");
> -if (LibPath) {
> -  SmallVector Frags;
> -  const char EnvPathSeparatorStr[] = {llvm::sys::EnvPathSeparator, '\0'};
> -  llvm::SplitString(*LibPath, Frags, EnvPathSeparatorStr);
> -  for (StringRef Path : Frags)
> -LibraryPaths.emplace_back(Path.trim());
> -}
> -
> -std::string LibOmpTargetName =
> -  "libomptarget-nvptx-" + GpuArch.str() + ".bc";
> -bool FoundBCLibrary = false;
> -for (StringRef LibraryPath : LibraryPaths) {
> -  SmallString<128> LibOmpTargetFile(LibraryPath);
> -  llvm::sys::path::append(LibOmpTargetFile, LibOmpTargetName);
> -  if (llvm::sys::fs::exists(LibOmpTargetFile)) {
> -CC1Args.push_back("-mlink-cuda-bitcode");
> -CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetFile));
> -FoundBCLibrary = true;
> -break;
> -  }
> -}
> -if (!FoundBCLibrary)
> -  getDriver().Diag(diag::warn_drv_omp_offload_target_missingbcruntime)
> -  << LibOmpTargetName;
> -  }
>  }
>
>  void CudaToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,
>
> Removed: cfe/trunk/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_20.bc
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_20.bc?rev=327446&view=auto
> ==
> (empty)
>
> Modified: cfe/trunk/test/Driver/openmp-offload-gpu.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openmp-offload-gpu.c?rev=327447&r1=327446&r2=327447&view=diff
> ==
> --- cfe/trunk/test/Driver/openmp-offload-gpu.c (original)
> +++ cfe/trunk/test/Driver/openmp-offload-gpu.c Tue Mar 13 13:50:12 2018
> @@ -142,23 +142,3 @@
>  // RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
>
>  // CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_60
> -
> -/// 
> ###
> -
> -/// Check that the runtime bitcode library is part of the compile line. 
> Create a bogus
> -/// bitcode library and add it to the LIBRARY_PATH.
> -// RUN:   env LIBRARY_PATH=%S/Inputs/libomptarget %clang -### 
> -fopen

[PATCH] D43248: [Attr] Fix parameter indexing for attributes

2018-03-13 Thread Eric Christopher via Phabricator via cfe-commits
echristo added inline comments.



Comment at: test/Sema/attr-print.cpp:3
 
+// This file is also used as input for %S/../Frontend/ast-attr.cpp.
+

jdenny wrote:
> echristo wrote:
> > Relatedly I don't think we use files as input files to other directories 
> > and I don't think we should really. What are you trying to test here? This 
> > breaks the hermeticness of each particular test directory.
> Grep for "%S/.." and you'll see that a few other tests do something like this 
> as well.
> 
> In test/Sema/attr-print.cpp, I am testing printing of attributes.  I chose to 
> put that there because of the existing attr-print.c there.
> 
> In test/Frontend/ast-attr.cpp, I am testing serialization of attributes.  I 
> chose to put that there because I see other -emit-ast tests there and 
> because, if I put it in test/Sema instead, I get the complaint "Do not use 
> the driver in Sema tests".
> 
> The same C++ code makes sense in both of these, but replicating it in two 
> files would worsen maintainability.
> 
> I could try to  combine into one file in, say, tests/Misc if that works.
> 
> I have no strong opinions on where these live.  Just for my own education, is 
> something real breaking right now because of their current locations?
> 
> Thanks.
Basically it's breaking an external build system (bazel) that has fairly 
distinct and specific dependency requirements and so layering and other 
dependencies are pretty entertaining.

Right now we avoid testing those particular tests and have TODOs of fixing them 
and the requirements to use a single directory and I was trying to avoid one 
more here.

All of that said I totally understand the desire to keep the maintenance burden 
minimized and an external build system shouldn't affect whether or not we do 
one particular thing or another - I was trying to get it written so that we 
could enable it without much undue burden. I'm uncertain if a comment of:

// If you change this file you should also change blah file.

or moving it to another directory where you can do both tests at the same time.


Repository:
  rC Clang

https://reviews.llvm.org/D43248



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


[PATCH] D43248: [Attr] Fix parameter indexing for attributes

2018-03-13 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

I'd prefer to move it than to expect people to obey such a comment.  Let's see 
what Aaron says.


Repository:
  rC Clang

https://reviews.llvm.org/D43248



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


[PATCH] D43248: [Attr] Fix parameter indexing for attributes

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

In https://reviews.llvm.org/D43248#1036409, @jdenny wrote:

> I'd prefer to move it than to expect people to obey such a comment.  Let's 
> see what Aaron says.


I have a slight preference for moving the tests now that I know they're causing 
problems, unless that turns out to be overly onerous for some reason.

Thank you, @echristo for pointing out the issues with the tests, I hadn't 
considered that.


Repository:
  rC Clang

https://reviews.llvm.org/D43248



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


[PATCH] D44447: Treat libclang_rt.* as normal library if the user uses --sysroot=

2018-03-13 Thread Tom Rix via Phabricator via cfe-commits
trixirt created this revision.
trixirt added reviewers: rsmith, atanasyan, vkalintiris.
trixirt added a project: clang.
Herald added a subscriber: cfe-commits.

In cross compiling, one normally assumes that the user supplied sysroot 
contains all of the libraries needed in the link.  And so the linker adjusts 
the -L paths to look in the sysroot.
However because libclang_rt.* is supplied at link time as a full path, the link 
can not find it in the sysroot.

This change will churn the user's current experience and the unit tests.
I will take take of the tests, if folks are ok with the change.


Repository:
  rC Clang

https://reviews.llvm.org/D7

Files:
  lib/Driver/ToolChain.cpp


Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -356,11 +356,17 @@
   TT.isWindowsMSVCEnvironment() || TT.isWindowsItaniumEnvironment();
 
   StringRef Arch = getArchNameForCompilerRTLib(*this, Args);
-  const char *Prefix = IsITANMSVCWindows ? "" : "lib";
-  const char *Suffix = Shared ? (Triple.isOSWindows() ? ".dll" : ".so")
+  const char *Prefix = "-l";
+  const char *Suffix = "";
+  SmallString<128> Path;
+
+  if (getDriver().SysRoot.empty()) {
+Prefix = IsITANMSVCWindows ? "" : "lib";
+Suffix = Shared ? (Triple.isOSWindows() ? ".dll" : ".so")
   : (IsITANMSVCWindows ? ".lib" : ".a");
+Path = getCompilerRTPath();
+  }
 
-  SmallString<128> Path(getCompilerRTPath());
   llvm::sys::path::append(Path, Prefix + Twine("clang_rt.") + Component + "-" +
 Arch + Env + Suffix);
   return Path.str();


Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -356,11 +356,17 @@
   TT.isWindowsMSVCEnvironment() || TT.isWindowsItaniumEnvironment();
 
   StringRef Arch = getArchNameForCompilerRTLib(*this, Args);
-  const char *Prefix = IsITANMSVCWindows ? "" : "lib";
-  const char *Suffix = Shared ? (Triple.isOSWindows() ? ".dll" : ".so")
+  const char *Prefix = "-l";
+  const char *Suffix = "";
+  SmallString<128> Path;
+
+  if (getDriver().SysRoot.empty()) {
+Prefix = IsITANMSVCWindows ? "" : "lib";
+Suffix = Shared ? (Triple.isOSWindows() ? ".dll" : ".so")
   : (IsITANMSVCWindows ? ".lib" : ".a");
+Path = getCompilerRTPath();
+  }
 
-  SmallString<128> Path(getCompilerRTPath());
   llvm::sys::path::append(Path, Prefix + Twine("clang_rt.") + Component + "-" +
 Arch + Env + Suffix);
   return Path.str();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43248: [Attr] Fix parameter indexing for attributes

2018-03-13 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

In https://reviews.llvm.org/D43248#1036426, @aaron.ballman wrote:

> In https://reviews.llvm.org/D43248#1036409, @jdenny wrote:
>
> > I'd prefer to move it than to expect people to obey such a comment.  Let's 
> > see what Aaron says.
>
>
> I have a slight preference for moving the tests now that I know they're 
> causing problems, unless that turns out to be overly onerous for some reason.
>
> Thank you, @echristo for pointing out the issues with the tests, I hadn't 
> considered that.


No worries :)

That said, please don't revert and reapply to move. Just a followup commit is 
just fine - and whenever you get a chance. (Though if you let me know when you 
do I'd appreciate it :)


Repository:
  rC Clang

https://reviews.llvm.org/D43248



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


[clang-tools-extra] r327452 - [clang-tidy] Fixing incorrect comment

2018-03-13 Thread Julie Hockett via cfe-commits
Author: juliehockett
Date: Tue Mar 13 14:24:08 2018
New Revision: 327452

URL: http://llvm.org/viewvc/llvm-project?rev=327452&view=rev
Log:
[clang-tidy] Fixing incorrect comment

Modified:
clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp

Modified: clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp?rev=327452&r1=327451&r2=327452&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp Tue Mar 13 
14:24:08 2018
@@ -524,7 +524,7 @@ extern volatile int CppCoreGuidelinesMod
 static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination =
 CppCoreGuidelinesModuleAnchorSource;
 
-// This anchor is used to force the linker to link the GoogleModule.
+// This anchor is used to force the linker to link the FuchsiaModule.
 extern volatile int FuchsiaModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED FuchsiaModuleAnchorDestination =
 FuchsiaModuleAnchorSource;


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


[PATCH] D43197: [OpenMP] Add flag for linking runtime bitcode library

2018-03-13 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 138260.
gtbercea added a comment.

Improve test robustness for the case when CUDA libdevice cannot be found.
Check that the warning is not emitted when the bc lib is found.


Repository:
  rC Clang

https://reviews.llvm.org/D43197

Files:
  test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_20.bc
  test/Driver/openmp-offload-gpu.c


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -148,17 +148,20 @@
 /// Check that the runtime bitcode library is part of the compile line. Create 
a bogus
 /// bitcode library and add it to the LIBRARY_PATH.
 // RUN:   env LIBRARY_PATH=%S/Inputs/libomptarget %clang -### -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda \
-// RUN:   -Xopenmp-target -march=sm_20 -fopenmp-relocatable-target -save-temps 
\
-// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck -check-prefix=CHK-BCLIB %s
+// RUN:   -Xopenmp-target -march=sm_20 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB %s
 
 // CHK-BCLIB: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-cuda-bitcode{{.*}}libomptarget-nvptx-sm_20.bc
+// CHK-BCLIB-NOT: No library 'libomptarget-nvptx-sm_20.bc' found in the 
default clang lib directory or in LIBRARY_PATH. Expect degraded performance due 
to no inlining of runtime functions on target devices.
 
 /// ###
 
 /// Check that the warning is thrown when the libomptarget bitcode library is 
not found.
 /// Libomptarget requires sm_35 or newer so an sm_20 bitcode library should 
never exist.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
-// RUN:   -Xopenmp-target -march=sm_20 -fopenmp-relocatable-target -save-temps 
\
-// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck 
-check-prefix=CHK-BCLIB-WARN %s
+// RUN:   -Xopenmp-target -march=sm_20 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB-WARN %s
 
 // CHK-BCLIB-WARN: No library 'libomptarget-nvptx-sm_20.bc' found in the 
default clang lib directory or in LIBRARY_PATH. Expect degraded performance due 
to no inlining of runtime functions on target devices.


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -148,17 +148,20 @@
 /// Check that the runtime bitcode library is part of the compile line. Create a bogus
 /// bitcode library and add it to the LIBRARY_PATH.
 // RUN:   env LIBRARY_PATH=%S/Inputs/libomptarget %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
-// RUN:   -Xopenmp-target -march=sm_20 -fopenmp-relocatable-target -save-temps \
-// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck -check-prefix=CHK-BCLIB %s
+// RUN:   -Xopenmp-target -march=sm_20 --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB %s
 
 // CHK-BCLIB: clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-cuda-bitcode{{.*}}libomptarget-nvptx-sm_20.bc
+// CHK-BCLIB-NOT: No library 'libomptarget-nvptx-sm_20.bc' found in the default clang lib directory or in LIBRARY_PATH. Expect degraded performance due to no inlining of runtime functions on target devices.
 
 /// ###
 
 /// Check that the warning is thrown when the libomptarget bitcode library is not found.
 /// Libomptarget requires sm_35 or newer so an sm_20 bitcode library should never exist.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
-// RUN:   -Xopenmp-target -march=sm_20 -fopenmp-relocatable-target -save-temps \
-// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck -check-prefix=CHK-BCLIB-WARN %s
+// RUN:   -Xopenmp-target -march=sm_20 --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB-WARN %s
 
 // CHK-BCLIB-WARN: No library 'libomptarget-nvptx-sm_20.bc' found in the default clang lib directory or in LIBRARY_PATH. Expect degraded performance due to no inlining of runtime functions on target devices.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43197: [OpenMP] Add flag for linking runtime bitcode library

2018-03-13 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 138261.
gtbercea added a comment.

Add bclib.


Repository:
  rC Clang

https://reviews.llvm.org/D43197

Files:
  test/Driver/openmp-offload-gpu.c


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -148,17 +148,20 @@
 /// Check that the runtime bitcode library is part of the compile line. Create 
a bogus
 /// bitcode library and add it to the LIBRARY_PATH.
 // RUN:   env LIBRARY_PATH=%S/Inputs/libomptarget %clang -### -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda \
-// RUN:   -Xopenmp-target -march=sm_20 -fopenmp-relocatable-target -save-temps 
\
-// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck -check-prefix=CHK-BCLIB %s
+// RUN:   -Xopenmp-target -march=sm_20 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB %s
 
 // CHK-BCLIB: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-cuda-bitcode{{.*}}libomptarget-nvptx-sm_20.bc
+// CHK-BCLIB-NOT: No library 'libomptarget-nvptx-sm_20.bc' found in the 
default clang lib directory or in LIBRARY_PATH. Expect degraded performance due 
to no inlining of runtime functions on target devices.
 
 /// ###
 
 /// Check that the warning is thrown when the libomptarget bitcode library is 
not found.
 /// Libomptarget requires sm_35 or newer so an sm_20 bitcode library should 
never exist.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
-// RUN:   -Xopenmp-target -march=sm_20 -fopenmp-relocatable-target -save-temps 
\
-// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck 
-check-prefix=CHK-BCLIB-WARN %s
+// RUN:   -Xopenmp-target -march=sm_20 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB-WARN %s
 
 // CHK-BCLIB-WARN: No library 'libomptarget-nvptx-sm_20.bc' found in the 
default clang lib directory or in LIBRARY_PATH. Expect degraded performance due 
to no inlining of runtime functions on target devices.


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -148,17 +148,20 @@
 /// Check that the runtime bitcode library is part of the compile line. Create a bogus
 /// bitcode library and add it to the LIBRARY_PATH.
 // RUN:   env LIBRARY_PATH=%S/Inputs/libomptarget %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
-// RUN:   -Xopenmp-target -march=sm_20 -fopenmp-relocatable-target -save-temps \
-// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck -check-prefix=CHK-BCLIB %s
+// RUN:   -Xopenmp-target -march=sm_20 --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB %s
 
 // CHK-BCLIB: clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-cuda-bitcode{{.*}}libomptarget-nvptx-sm_20.bc
+// CHK-BCLIB-NOT: No library 'libomptarget-nvptx-sm_20.bc' found in the default clang lib directory or in LIBRARY_PATH. Expect degraded performance due to no inlining of runtime functions on target devices.
 
 /// ###
 
 /// Check that the warning is thrown when the libomptarget bitcode library is not found.
 /// Libomptarget requires sm_35 or newer so an sm_20 bitcode library should never exist.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
-// RUN:   -Xopenmp-target -march=sm_20 -fopenmp-relocatable-target -save-temps \
-// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck -check-prefix=CHK-BCLIB-WARN %s
+// RUN:   -Xopenmp-target -march=sm_20 --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB-WARN %s
 
 // CHK-BCLIB-WARN: No library 'libomptarget-nvptx-sm_20.bc' found in the default clang lib directory or in LIBRARY_PATH. Expect degraded performance due to no inlining of runtime functions on target devices.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43248: [Attr] Fix parameter indexing for attributes

2018-03-13 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

In https://reviews.llvm.org/D43248#1036427, @echristo wrote:

> In https://reviews.llvm.org/D43248#1036426, @aaron.ballman wrote:
>
> > In https://reviews.llvm.org/D43248#1036409, @jdenny wrote:
> >
> > > I'd prefer to move it than to expect people to obey such a comment.  
> > > Let's see what Aaron says.
> >
> >
> > I have a slight preference for moving the tests now that I know they're 
> > causing problems, unless that turns out to be overly onerous for some 
> > reason.
> >
> > Thank you, @echristo for pointing out the issues with the tests, I hadn't 
> > considered that.
>
>
> No worries :)
>
> That said, please don't revert and reapply to move. Just a followup commit is 
> just fine - and whenever you get a chance. (Though if you let me know when 
> you do I'd appreciate it :)


Sure.

So, I'm planning to remove test/Frontend/ast-attr.cpp, rename 
test/Sema/attr-print.cpp to test/Misc/attr-print-emit.cpp, and change its run 
lines to:

  // RUN: %clang_cc1 %s -ast-print | FileCheck %s
  // RUN: %clang -emit-ast -o %t.ast %s
  // RUN: %clang_cc1 %t.ast -ast-print | FileCheck %s

That seems to work fine locally.  I'll just leave the old 
test/Sema/attr-print.c alone as it's not part of this problem.  Any objections?


Repository:
  rC Clang

https://reviews.llvm.org/D43248



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


[PATCH] D43197: [OpenMP] Add flag for linking runtime bitcode library

2018-03-13 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 138262.
gtbercea added a comment.

Test.


Repository:
  rC Clang

https://reviews.llvm.org/D43197

Files:
  test/Driver/openmp-offload-gpu.c


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -148,17 +148,20 @@
 /// Check that the runtime bitcode library is part of the compile line. Create 
a bogus
 /// bitcode library and add it to the LIBRARY_PATH.
 // RUN:   env LIBRARY_PATH=%S/Inputs/libomptarget %clang -### -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda \
-// RUN:   -Xopenmp-target -march=sm_20 -fopenmp-relocatable-target -save-temps 
\
-// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck -check-prefix=CHK-BCLIB %s
+// RUN:   -Xopenmp-target -march=sm_20 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB %s
 
 // CHK-BCLIB: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-cuda-bitcode{{.*}}libomptarget-nvptx-sm_20.bc
+// CHK-BCLIB-NOT: No library 'libomptarget-nvptx-sm_20.bc' found in the 
default clang lib directory or in LIBRARY_PATH. Expect degraded performance due 
to no inlining of runtime functions on target devices.
 
 /// ###
 
 /// Check that the warning is thrown when the libomptarget bitcode library is 
not found.
 /// Libomptarget requires sm_35 or newer so an sm_20 bitcode library should 
never exist.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
-// RUN:   -Xopenmp-target -march=sm_20 -fopenmp-relocatable-target -save-temps 
\
-// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck 
-check-prefix=CHK-BCLIB-WARN %s
+// RUN:   -Xopenmp-target -march=sm_20 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB-WARN %s
 
 // CHK-BCLIB-WARN: No library 'libomptarget-nvptx-sm_20.bc' found in the 
default clang lib directory or in LIBRARY_PATH. Expect degraded performance due 
to no inlining of runtime functions on target devices.


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -148,17 +148,20 @@
 /// Check that the runtime bitcode library is part of the compile line. Create a bogus
 /// bitcode library and add it to the LIBRARY_PATH.
 // RUN:   env LIBRARY_PATH=%S/Inputs/libomptarget %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
-// RUN:   -Xopenmp-target -march=sm_20 -fopenmp-relocatable-target -save-temps \
-// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck -check-prefix=CHK-BCLIB %s
+// RUN:   -Xopenmp-target -march=sm_20 --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB %s
 
 // CHK-BCLIB: clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-cuda-bitcode{{.*}}libomptarget-nvptx-sm_20.bc
+// CHK-BCLIB-NOT: No library 'libomptarget-nvptx-sm_20.bc' found in the default clang lib directory or in LIBRARY_PATH. Expect degraded performance due to no inlining of runtime functions on target devices.
 
 /// ###
 
 /// Check that the warning is thrown when the libomptarget bitcode library is not found.
 /// Libomptarget requires sm_35 or newer so an sm_20 bitcode library should never exist.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
-// RUN:   -Xopenmp-target -march=sm_20 -fopenmp-relocatable-target -save-temps \
-// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck -check-prefix=CHK-BCLIB-WARN %s
+// RUN:   -Xopenmp-target -march=sm_20 --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB-WARN %s
 
 // CHK-BCLIB-WARN: No library 'libomptarget-nvptx-sm_20.bc' found in the default clang lib directory or in LIBRARY_PATH. Expect degraded performance due to no inlining of runtime functions on target devices.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

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

Addressing comments


https://reviews.llvm.org/D44346

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

Index: test/clang-tidy/zircon-temporary-objects.cpp
===
--- /dev/null
+++ test/clang-tidy/zircon-temporary-objects.cpp
@@ -0,0 +1,82 @@
+// RUN: %check_clang_tidy %s zircon-temporary-objects %t -- \
+// RUN:   -config="{CheckOptions: [{key: zircon-temporary-objects.Names, value: 'Foo;NS::Bar'}]}" \
+// RUN:   -header-filter=.* \
+// RUN: -- -std=c++11
+
+// Should flag instances of Foo, NS::Bar.
+
+class Foo {
+public:
+  Foo() = default;
+  Foo(int Val) : Val(Val){};
+
+private:
+  int Val;
+};
+
+namespace NS {
+
+class Bar {
+public:
+  Bar() = default;
+  Bar(int Val) : Val(Val){};
+
+private:
+  int Val;
+};
+
+} // namespace NS
+
+class Bar {
+public:
+  Bar() = default;
+  Bar(int Val) : Val(Val){};
+
+private:
+  int Val;
+};
+
+int func(Foo F) { return 1; };
+
+int main() {
+  Foo F;
+  Foo *F2 = new Foo();
+  new Foo();
+  Foo();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: creating a temporary object of type 'Foo' is prohibited
+  Foo F3 = Foo();
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: creating a temporary object of type 'Foo' is prohibited
+
+  Bar();
+  NS::Bar();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: creating a temporary object of type 'Bar' is prohibited
+
+  int A = func(Foo());
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: creating a temporary object of type 'Foo' is prohibited
+
+  Foo F4(0);
+  Foo *F5 = new Foo(0);
+  new Foo(0);
+  Foo(0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: creating a temporary object of type 'Foo' is prohibited
+  Foo F6 = Foo(0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: creating a temporary object of type 'Foo' is prohibited
+
+  Bar(0);
+  NS::Bar(0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: creating a temporary object of type 'Bar' is prohibited
+
+  int B = func(Foo(0));
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: creating a temporary object of type 'Foo' is prohibited
+}
+
+namespace NS {
+
+void f() {
+  Bar();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: creating a temporary object of type 'Bar' is prohibited
+  Bar(0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: creating a temporary object of type 'Bar' is prohibited
+}
+
+} // namespace NS
Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -75,6 +75,7 @@
relate to any particular coding style.
 ``readability-``   Checks that target readability-related issues that don't
relate to any particular coding style.
+``zircon-``Checks related to Zircon kernel coding conventions.
 == =
 
 Clang diagnostics are treated in a similar way as check diagnostics. Clang
Index: docs/clang-tidy/checks/zircon-temporary-objects.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/zircon-temporary-objects.rst
@@ -0,0 +1,40 @@
+.. title:: clang-tidy - zircon-temporary-objects
+
+zircon-temporary-objects
+
+
+Warns on construction of specific temporary objects in the Zircon kernel.
+
+For example, given the list of classes "Foo" and "NS::Bar", all of the 
+following will trigger the warning: 
+
+.. code-block:: c++
+
+  Foo();
+  Foo F = Foo();
+  func(Foo());
+
+  namespace NS {
+
+  Bar();
+
+  }
+
+With the same list, the following will not trigger the warning:
+
+.. code-block:: c++
+
+  Foo F;// Non-temporary construction okay
+  Foo F(param);			// Non-temporary construction okay
+  Foo *F = new Foo();	// New construction okay
+
+  Bar(); // Not NS::Bar, so okay
+  NS::Bar B;			// Non-temporary construction okay
+
+Options
+---
+
+.. option:: Names
+
+   A semi-colon-separated list of fully-qualified names of C++ classes that 
+   should not be constructed as temporaries. Default is empty.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -225,3 +225,4 @@
readability-static-definition-in-anonymous-namespace
readability-string-compare
readability-uniqueptr-delete-release
+   zircon-temporary-objects
I

[PATCH] D43197: [OpenMP] Add flag for linking runtime bitcode library

2018-03-13 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 138265.
gtbercea added a comment.

Update patch manually.


Repository:
  rC Clang

https://reviews.llvm.org/D43197

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_20.bc
  test/Driver/openmp-offload-gpu.c


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -142,3 +142,26 @@
 // RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
 
 // CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_60
+
+/// ###
+
+/// Check that the runtime bitcode library is part of the compile line. Create 
a bogus
+/// bitcode library and add it to the LIBRARY_PATH.
+// RUN:   env LIBRARY_PATH=%S/Inputs/libomptarget %clang -### -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda \
+// RUN:   -Xopenmp-target -march=sm_20 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB %s
+
+// CHK-BCLIB: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-cuda-bitcode{{.*}}libomptarget-nvptx-sm_20.bc
+// CHK-BCLIB-NOT: No library 'libomptarget-nvptx-sm_20.bc' found in the 
default clang lib directory or in LIBRARY_PATH. Expect degraded performance due 
to no inlining of runtime functions on target devices.
+
+/// ###
+
+/// Check that the warning is thrown when the libomptarget bitcode library is 
not found.
+/// Libomptarget requires sm_35 or newer so an sm_20 bitcode library should 
never exist.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
+// RUN:   -Xopenmp-target -march=sm_20 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB-WARN %s
+
+// CHK-BCLIB-WARN: No library 'libomptarget-nvptx-sm_20.bc' found in the 
default clang lib directory or in LIBRARY_PATH. Expect degraded performance due 
to no inlining of runtime functions on target devices.
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -581,6 +581,44 @@
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+ptx42");
   }
+
+  if (DeviceOffloadingKind == Action::OFK_OpenMP) {
+SmallVector LibraryPaths;
+// Add path to lib and/or lib64 folders.
+SmallString<256> DefaultLibPath =
+  llvm::sys::path::parent_path(getDriver().Dir);
+llvm::sys::path::append(DefaultLibPath,
+Twine("lib") + CLANG_LIBDIR_SUFFIX);
+LibraryPaths.emplace_back(DefaultLibPath.c_str());
+
+// Add user defined library paths from LIBRARY_PATH.
+llvm::Optional LibPath =
+llvm::sys::Process::GetEnv("LIBRARY_PATH");
+if (LibPath) {
+  SmallVector Frags;
+  const char EnvPathSeparatorStr[] = {llvm::sys::EnvPathSeparator, '\0'};
+  llvm::SplitString(*LibPath, Frags, EnvPathSeparatorStr);
+  for (StringRef Path : Frags)
+LibraryPaths.emplace_back(Path.trim());
+}
+
+std::string LibOmpTargetName =
+  "libomptarget-nvptx-" + GpuArch.str() + ".bc";
+bool FoundBCLibrary = false;
+for (StringRef LibraryPath : LibraryPaths) {
+  SmallString<128> LibOmpTargetFile(LibraryPath);
+  llvm::sys::path::append(LibOmpTargetFile, LibOmpTargetName);
+  if (llvm::sys::fs::exists(LibOmpTargetFile)) {
+CC1Args.push_back("-mlink-cuda-bitcode");
+CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetFile));
+FoundBCLibrary = true;
+break;
+  }
+}
+if (!FoundBCLibrary)
+  getDriver().Diag(diag::warn_drv_omp_offload_target_missingbcruntime)
+  << LibOmpTargetName;
+  }
 }
 
 void CudaToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,
Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -203,6 +203,9 @@
 def warn_drv_omp_offload_target_duplicate : Warning<
   "The OpenMP offloading target '%0' is similar to target '%1' already 
specified - will be ignored.">, 
   InGroup;
+def warn_drv_omp_offload_target_missingbcruntime : Warning<
+  "No library '%0' found in the default clang lib directory or in 
LIBRARY_PATH. Expect degraded performance due to no inlining of runtime 
functions on target devices.">,
+  InGroup;
 def err_drv_bitcode_unsupported_on_toolchain : Error<
   "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
 


Index: test/Driver/openmp-offload-gpu.c
=

r327453 - [Analysis] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

2018-03-13 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Tue Mar 13 14:32:01 2018
New Revision: 327453

URL: http://llvm.org/viewvc/llvm-project?rev=327453&view=rev
Log:
[Analysis] Fix some Clang-tidy modernize and Include What You Use warnings; 
other minor fixes (NFC).

Modified:
cfe/trunk/include/clang/Analysis/Analyses/Consumed.h
cfe/trunk/include/clang/Analysis/Analyses/Dominators.h
cfe/trunk/include/clang/Analysis/Analyses/PostOrderCFGView.h
cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
cfe/trunk/lib/Analysis/Consumed.cpp
cfe/trunk/lib/Analysis/Dominators.cpp
cfe/trunk/lib/Analysis/PostOrderCFGView.cpp
cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp

Modified: cfe/trunk/include/clang/Analysis/Analyses/Consumed.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/Consumed.h?rev=327453&r1=327452&r2=327453&view=diff
==
--- cfe/trunk/include/clang/Analysis/Analyses/Consumed.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/Consumed.h Tue Mar 13 14:32:01 
2018
@@ -1,4 +1,4 @@
-//===- Consumed.h --*- C++ 
--*-===//
+//===- Consumed.h ---*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -15,16 +15,32 @@
 #ifndef LLVM_CLANG_ANALYSIS_ANALYSES_CONSUMED_H
 #define LLVM_CLANG_ANALYSIS_ANALYSES_CONSUMED_H
 
-#include "clang/AST/DeclCXX.h"
-#include "clang/AST/ExprCXX.h"
-#include "clang/AST/StmtCXX.h"
 #include "clang/Analysis/Analyses/PostOrderCFGView.h"
-#include "clang/Analysis/AnalysisDeclContext.h"
+#include "clang/Analysis/CFG.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/PartialDiagnostic.h"
 #include "clang/Basic/SourceLocation.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+#include 
+#include 
+#include 
 
 namespace clang {
+
+class AnalysisDeclContext;
+class CXXBindTemporaryExpr;
+class FunctionDecl;
+class PostOrderCFGView;
+class Stmt;
+class VarDecl;
+
 namespace consumed {
   
+  class ConsumedStmtVisitor;
+
   enum ConsumedState {
 // No state information for the given variable.
 CS_None,
@@ -34,16 +50,12 @@ namespace consumed {
 CS_Consumed
   };
   
-  class ConsumedStmtVisitor;
-  
-  typedef SmallVector OptionalNotes;
-  typedef std::pair DelayedDiag;
-  typedef std::list DiagList;
+  using OptionalNotes = SmallVector;
+  using DelayedDiag = std::pair;
+  using DiagList = std::list;
 
   class ConsumedWarningsHandlerBase {
-
   public:
-
 virtual ~ConsumedWarningsHandlerBase();
 
 /// \brief Emit the warnings and notes left by the analysis.
@@ -129,23 +141,21 @@ namespace consumed {
   };
 
   class ConsumedStateMap {
-
-typedef llvm::DenseMap VarMapType;
-typedef llvm::DenseMap
-TmpMapType;
+using VarMapType = llvm::DenseMap;
+using TmpMapType =
+llvm::DenseMap;
 
   protected:
-
-bool Reachable;
-const Stmt *From;
+bool Reachable = true;
+const Stmt *From = nullptr;
 VarMapType VarMap;
 TmpMapType TmpMap;
 
   public:
-ConsumedStateMap() : Reachable(true), From(nullptr) {}
+ConsumedStateMap() = default;
 ConsumedStateMap(const ConsumedStateMap &Other)
-  : Reachable(Other.Reachable), From(Other.From), VarMap(Other.VarMap),
-TmpMap() {}
+: Reachable(Other.Reachable), From(Other.From), VarMap(Other.VarMap),
+  TmpMap() {}
 
 /// \brief Warn if any of the parameters being tracked are not in the state
 /// they were declared to be in upon return from a function.
@@ -205,10 +215,8 @@ namespace consumed {
 ConsumedBlockInfo(unsigned int NumBlocks, PostOrderCFGView *SortedGraph)
 : StateMapsArray(NumBlocks), VisitOrder(NumBlocks, 0) {
   unsigned int VisitOrderCounter = 0;
-  for (PostOrderCFGView::iterator BI = SortedGraph->begin(),
-   BE = SortedGraph->end(); BI != BE; ++BI) {
-VisitOrder[(*BI)->getBlockID()] = VisitOrderCounter++;
-  }
+  for (const auto BI : *SortedGraph)
+VisitOrder[BI->getBlockID()] = VisitOrderCounter++;
 }
 
 bool allBackEdgesVisited(const CFGBlock *CurrBlock,
@@ -231,7 +239,6 @@ namespace consumed {
 
   /// A class that handles the analysis of uniqueness violations.
   class ConsumedAnalyzer {
-
 ConsumedBlockInfo BlockInfo;
 std::unique_ptr CurrStates;
 
@@ -243,7 +250,6 @@ namespace consumed {
 const ConsumedStmtVisitor &Visitor);
 
   public:
-
 ConsumedWarningsHandlerBase &WarningsHandler;
 
 ConsumedAnalyzer(ConsumedWarningsHandlerBase &WarningsHandler)
@@ -259,6 +265,9 @@ namespace consumed {
 /// exactly once.
 void run(AnalysisDeclContext &AC);
   };
-}} // end namespace clang::consumed
 
-#endif
+} // namespace consumed
+
+} // namespace clang
+
+#endif // LLVM_CLANG

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

2018-03-13 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/ReleaseNotes.rst:77
 
+- New `zircon-temporary-objects
+  
`_ 
check

Please sort new checks in alphabetical order.


https://reviews.llvm.org/D44346



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


[PATCH] D43197: [OpenMP] Add flag for linking runtime bitcode library

2018-03-13 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 138266.

Repository:
  rC Clang

https://reviews.llvm.org/D43197

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_20.bc
  test/Driver/openmp-offload-gpu.c


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -142,3 +142,26 @@
 // RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
 
 // CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_60
+
+/// ###
+
+/// Check that the runtime bitcode library is part of the compile line. Create 
a bogus
+/// bitcode library and add it to the LIBRARY_PATH.
+// RUN:   env LIBRARY_PATH=%S/Inputs/libomptarget %clang -### -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda \
+// RUN:   -Xopenmp-target -march=sm_20 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB %s
+
+// CHK-BCLIB: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-cuda-bitcode{{.*}}libomptarget-nvptx-sm_20.bc
+// CHK-BCLIB-NOT: No library 'libomptarget-nvptx-sm_20.bc' found in the 
default clang lib directory or in LIBRARY_PATH. Expect degraded performance due 
to no inlining of runtime functions on target devices.
+
+/// ###
+
+/// Check that the warning is thrown when the libomptarget bitcode library is 
not found.
+/// Libomptarget requires sm_35 or newer so an sm_20 bitcode library should 
never exist.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
+// RUN:   -Xopenmp-target -march=sm_20 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB-WARN %s
+
+// CHK-BCLIB-WARN: No library 'libomptarget-nvptx-sm_20.bc' found in the 
default clang lib directory or in LIBRARY_PATH. Expect degraded performance due 
to no inlining of runtime functions on target devices.
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -581,6 +581,44 @@
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+ptx42");
   }
+
+  if (DeviceOffloadingKind == Action::OFK_OpenMP) {
+SmallVector LibraryPaths;
+// Add path to lib and/or lib64 folders.
+SmallString<256> DefaultLibPath =
+  llvm::sys::path::parent_path(getDriver().Dir);
+llvm::sys::path::append(DefaultLibPath,
+Twine("lib") + CLANG_LIBDIR_SUFFIX);
+LibraryPaths.emplace_back(DefaultLibPath.c_str());
+
+// Add user defined library paths from LIBRARY_PATH.
+llvm::Optional LibPath =
+llvm::sys::Process::GetEnv("LIBRARY_PATH");
+if (LibPath) {
+  SmallVector Frags;
+  const char EnvPathSeparatorStr[] = {llvm::sys::EnvPathSeparator, '\0'};
+  llvm::SplitString(*LibPath, Frags, EnvPathSeparatorStr);
+  for (StringRef Path : Frags)
+LibraryPaths.emplace_back(Path.trim());
+}
+
+std::string LibOmpTargetName =
+  "libomptarget-nvptx-" + GpuArch.str() + ".bc";
+bool FoundBCLibrary = false;
+for (StringRef LibraryPath : LibraryPaths) {
+  SmallString<128> LibOmpTargetFile(LibraryPath);
+  llvm::sys::path::append(LibOmpTargetFile, LibOmpTargetName);
+  if (llvm::sys::fs::exists(LibOmpTargetFile)) {
+CC1Args.push_back("-mlink-cuda-bitcode");
+CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetFile));
+FoundBCLibrary = true;
+break;
+  }
+}
+if (!FoundBCLibrary)
+  getDriver().Diag(diag::warn_drv_omp_offload_target_missingbcruntime)
+  << LibOmpTargetName;
+  }
 }
 
 void CudaToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,
Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -203,6 +203,9 @@
 def warn_drv_omp_offload_target_duplicate : Warning<
   "The OpenMP offloading target '%0' is similar to target '%1' already 
specified - will be ignored.">, 
   InGroup;
+def warn_drv_omp_offload_target_missingbcruntime : Warning<
+  "No library '%0' found in the default clang lib directory or in 
LIBRARY_PATH. Expect degraded performance due to no inlining of runtime 
functions on target devices.">,
+  InGroup;
 def err_drv_bitcode_unsupported_on_toolchain : Error<
   "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
 


Index: test/Driver/openmp-offload-gpu.c
==

r327455 - [ARM] ACLE FP16 feature test macros

2018-03-13 Thread Sjoerd Meijer via cfe-commits
Author: sjoerdmeijer
Date: Tue Mar 13 15:11:06 2018
New Revision: 327455

URL: http://llvm.org/viewvc/llvm-project?rev=327455&view=rev
Log:
[ARM] ACLE FP16 feature test macros

This is a partial recommit of r327189 that was reverted
due to test issues. I.e., this recommits minimal functional
change, the FP16 feature test macros, and adds tests that 
were missing in the original commit.


Modified:
cfe/trunk/lib/Basic/Targets/ARM.cpp
cfe/trunk/lib/Basic/Targets/ARM.h
cfe/trunk/test/Preprocessor/arm-target-features.c

Modified: cfe/trunk/lib/Basic/Targets/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/ARM.cpp?rev=327455&r1=327454&r2=327455&view=diff
==
--- cfe/trunk/lib/Basic/Targets/ARM.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/ARM.cpp Tue Mar 13 15:11:06 2018
@@ -379,6 +379,7 @@ bool ARMTargetInfo::handleTargetFeatures
   Unaligned = 1;
   SoftFloat = SoftFloatABI = false;
   HWDiv = 0;
+  HasFullFP16 = 0;
 
   // This does not diagnose illegal cases like having both
   // "+vfpv2" and "+vfpv3" or having "+neon" and "+fp-only-sp".
@@ -419,6 +420,8 @@ bool ARMTargetInfo::handleTargetFeatures
   Unaligned = 0;
 } else if (Feature == "+fp16") {
   HW_FP |= HW_FP_HP;
+} else if (Feature == "+fullfp16") {
+  HasFullFP16 = 1;
 }
   }
   HW_FP &= ~HW_FP_remove;
@@ -710,6 +713,15 @@ void ARMTargetInfo::getTargetDefines(con
   if (Opts.UnsafeFPMath)
 Builder.defineMacro("__ARM_FP_FAST", "1");
 
+  // Armv8.2-A FP16 vector intrinsic
+  if ((FPU & NeonFPU) && HasFullFP16)
+Builder.defineMacro("__ARM_FEATURE_FP16_VECTOR_ARITHMETIC", "1");
+
+  // Armv8.2-A FP16 scalar intrinsics
+  if (HasFullFP16)
+Builder.defineMacro("__ARM_FEATURE_FP16_SCALAR_ARITHMETIC", "1");
+
+
   switch (ArchKind) {
   default:
 break;

Modified: cfe/trunk/lib/Basic/Targets/ARM.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/ARM.h?rev=327455&r1=327454&r2=327455&view=diff
==
--- cfe/trunk/lib/Basic/Targets/ARM.h (original)
+++ cfe/trunk/lib/Basic/Targets/ARM.h Tue Mar 13 15:11:06 2018
@@ -69,6 +69,7 @@ class LLVM_LIBRARY_VISIBILITY ARMTargetI
   unsigned Crypto : 1;
   unsigned DSP : 1;
   unsigned Unaligned : 1;
+  unsigned HasFullFP16 : 1;
 
   enum {
 LDREX_B = (1 << 0), /// byte (8-bit)

Modified: cfe/trunk/test/Preprocessor/arm-target-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/arm-target-features.c?rev=327455&r1=327454&r2=327455&view=diff
==
--- cfe/trunk/test/Preprocessor/arm-target-features.c (original)
+++ cfe/trunk/test/Preprocessor/arm-target-features.c Tue Mar 13 15:11:06 2018
@@ -19,6 +19,18 @@
 // CHECK-V8A-ALLOW-FP-INSTR: #define __ARM_FP16_ARGS 1
 // CHECK-V8A-ALLOW-FP-INSTR: #define __ARM_FP16_FORMAT_IEEE 1
 
+// RUN: %clang -target arm-none-linux-gnueabi -march=armv8.2a+fp16 -x c -E -dM 
%s -o - | FileCheck -match-full-lines 
--check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s
+// CHECK-FULLFP16-VECTOR-SCALAR: #define __ARM_FEATURE_FP16_SCALAR_ARITHMETIC 1
+// CHECK-FULLFP16-VECTOR-SCALAR: #define __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 1
+// CHECK-FULLFP16-VECTOR-SCALAR: #define __ARM_FP 0xe
+// CHECK-FULLFP16-VECTOR-SCALAR: #define __ARM_FP16_FORMAT_IEEE 1
+
+// RUN: %clang -target arm-none-linux-gnueabi -march=armv8.2a+fp16 -mfpu=vfp4 
-x c -E -dM %s -o - | FileCheck -match-full-lines 
--check-prefix=CHECK-FULLFP16-SCALAR %s
+// CHECK-FULLFP16-SCALAR:   #define __ARM_FEATURE_FP16_SCALAR_ARITHMETIC 1
+// CHECK-FULLFP16-SCALAR-NOT:   #define __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 1
+// CHECK-FULLFP16-SCALAR:   #define __ARM_FP 0xe
+// CHECK-FULLFP16-SCALAR:   #define __ARM_FP16_FORMAT_IEEE 1
+
 // RUN: %clang -target armv8r-none-linux-gnu -x c -E -dM %s -o - | FileCheck 
-match-full-lines --check-prefix=CHECK-V8R %s
 // CHECK-V8R: #define __ARMEL__ 1
 // CHECK-V8R: #define __ARM_ARCH 8


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


r327456 - [Attr] Merge two dependent tests from different directories

2018-03-13 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Tue Mar 13 15:18:29 2018
New Revision: 327456

URL: http://llvm.org/viewvc/llvm-project?rev=327456&view=rev
Log:
[Attr] Merge two dependent tests from different directories

Suggested at: https://reviews.llvm.org/D43248

Added:
cfe/trunk/test/Misc/attr-print-emit.cpp
  - copied, changed from r327455, cfe/trunk/test/Sema/attr-print.cpp
Removed:
cfe/trunk/test/Frontend/ast-attr.cpp
cfe/trunk/test/Sema/attr-print.cpp

Removed: cfe/trunk/test/Frontend/ast-attr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/ast-attr.cpp?rev=327455&view=auto
==
--- cfe/trunk/test/Frontend/ast-attr.cpp (original)
+++ cfe/trunk/test/Frontend/ast-attr.cpp (removed)
@@ -1,5 +0,0 @@
-// RUN: %clang -emit-ast -o %t.ast %S/../Sema/attr-print.cpp
-// RUN: %clang_cc1 %t.ast -ast-print | FileCheck %S/../Sema/attr-print.cpp
-
-// %S/../Sema/attr-print.cpp exercises many different attributes, so we reuse
-// it here to check -emit-ast for attributes.

Copied: cfe/trunk/test/Misc/attr-print-emit.cpp (from r327455, 
cfe/trunk/test/Sema/attr-print.cpp)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/attr-print-emit.cpp?p2=cfe/trunk/test/Misc/attr-print-emit.cpp&p1=cfe/trunk/test/Sema/attr-print.cpp&r1=327455&r2=327456&rev=327456&view=diff
==
--- cfe/trunk/test/Sema/attr-print.cpp (original)
+++ cfe/trunk/test/Misc/attr-print-emit.cpp Tue Mar 13 15:18:29 2018
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 %s -ast-print | FileCheck %s
-
-// This file is also used as input for %S/../Frontend/ast-attr.cpp.
+// RUN: %clang -emit-ast -o %t.ast %s
+// RUN: %clang_cc1 %t.ast -ast-print | FileCheck %s
 
 // CHECK: void xla(int a) __attribute__((xray_log_args(1)));
 void xla(int a) __attribute__((xray_log_args(1)));

Removed: cfe/trunk/test/Sema/attr-print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-print.cpp?rev=327455&view=auto
==
--- cfe/trunk/test/Sema/attr-print.cpp (original)
+++ cfe/trunk/test/Sema/attr-print.cpp (removed)
@@ -1,69 +0,0 @@
-// RUN: %clang_cc1 %s -ast-print | FileCheck %s
-
-// This file is also used as input for %S/../Frontend/ast-attr.cpp.
-
-// CHECK: void xla(int a) __attribute__((xray_log_args(1)));
-void xla(int a) __attribute__((xray_log_args(1)));
-
-// CHECK: void *as2(int, int) __attribute__((alloc_size(1, 2)));
-void *as2(int, int) __attribute__((alloc_size(1, 2)));
-// CHECK: void *as1(void *, int) __attribute__((alloc_size(2)));
-void *as1(void *, int) __attribute__((alloc_size(2)));
-
-// CHECK: void fmt(int, const char *, ...) __attribute__((format(printf, 2, 
3)));
-void fmt(int, const char *, ...) __attribute__((format(printf, 2, 3)));
-
-// CHECK: char *fmta(int, const char *) __attribute__((format_arg(2)));
-char *fmta(int, const char *) __attribute__((format_arg(2)));
-
-// CHECK: void nn(int *, int *) __attribute__((nonnull(1, 2)));
-void nn(int *, int *) __attribute__((nonnull(1, 2)));
-
-// CHECK: int *aa(int i) __attribute__((alloc_align(1)));
-int *aa(int i) __attribute__((alloc_align(1)));
-
-// CHECK: void ownt(int *, int *) __attribute__((ownership_takes(foo, 1, 2)));
-void ownt(int *, int *) __attribute__((ownership_takes(foo, 1, 2)));
-// CHECK: void ownh(int *, int *) __attribute__((ownership_holds(foo, 1, 2)));
-void ownh(int *, int *) __attribute__((ownership_holds(foo, 1, 2)));
-// CHECK: void ownr(int) __attribute__((ownership_returns(foo, 1)));
-void ownr(int) __attribute__((ownership_returns(foo, 1)));
-
-// CHECK: void awtt(int, int, ...) __attribute__((argument_with_type_tag(foo, 
3, 2)));
-void awtt(int, int, ...) __attribute__((argument_with_type_tag(foo, 3, 2)));
-// CHECK: void pwtt(void *, int) __attribute__((pointer_with_type_tag(foo, 1, 
2)));
-void pwtt(void *, int) __attribute__((pointer_with_type_tag(foo, 1, 2)));
-
-class C {
-  // CHECK: void xla(int a) __attribute__((xray_log_args(2)));
-  void xla(int a) __attribute__((xray_log_args(2)));
-
-  // CHECK: void *as2(int, int) __attribute__((alloc_size(2, 3)));
-  void *as2(int, int) __attribute__((alloc_size(2, 3)));
-  // CHECK: void *as1(void *, int) __attribute__((alloc_size(3)));
-  void *as1(void *, int) __attribute__((alloc_size(3)));
-
-  // CHECK: void fmt(int, const char *, ...) __attribute__((format(printf, 3, 
4)));
-  void fmt(int, const char *, ...) __attribute__((format(printf, 3, 4)));
-
-  // CHECK: char *fmta(int, const char *) __attribute__((format_arg(3)));
-  char *fmta(int, const char *) __attribute__((format_arg(3)));
-
-  // CHECK: void nn(int *, int *) __attribute__((nonnull(2, 3)));
-  void nn(int *, int *) __attribute__((nonnull(2, 3)));
-
-  // CHECK: int *aa(int i) __attribute__((alloc_align(2)));
-  int *aa(int i) __attribute__((alloc_align(2)));
-
-  // CHECK: void ownt(int *, int *) __attr

[PATCH] D43650: [ARM] Add ARMv8.2-A FP16 vector intrinsics

2018-03-13 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

FYI: I have partially recommitted this in r327455; I have separated out the 
minimal functional change related to the FP16 macros.


https://reviews.llvm.org/D43650



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


[PATCH] D43248: [Attr] Fix parameter indexing for attributes

2018-03-13 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

In https://reviews.llvm.org/D43248#1036439, @jdenny wrote:

> So, I'm planning to remove test/Frontend/ast-attr.cpp, rename 
> test/Sema/attr-print.cpp to test/Misc/attr-print-emit.cpp, and change its run 
> lines to:
>
>   // RUN: %clang_cc1 %s -ast-print | FileCheck %s
>   // RUN: %clang -emit-ast -o %t.ast %s
>   // RUN: %clang_cc1 %t.ast -ast-print | FileCheck %s
>
>
> That seems to work fine locally.  I'll just leave the old 
> test/Sema/attr-print.c alone as it's not part of this problem.  Any 
> objections?


I went ahead and committed.  It's in r327456.


Repository:
  rC Clang

https://reviews.llvm.org/D43248



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


[PATCH] D44449: [Parser] Fix assertion-on-invalid for unexpected typename.

2018-03-13 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.
vsapsai added reviewers: rsmith, arphaman.
Herald added a subscriber: jkorous-apple.

In `ParseDeclarationSpecifiers` for the code

  class A typename A;

we were able to annotate token `kw_typename` because it refers to
existing type. But later during processing token `annot_typename` we
failed to `SetTypeSpecType` and exited switch statement leaving
annotation token unconsumed. The code after the switch statement failed
because it didn't expect a special token.

The fix is not to assume that switch statement consumes all special
tokens and consume any token, not just non-special.

rdar://problem/37099386


https://reviews.llvm.org/D9

Files:
  clang/lib/Parse/ParseDecl.cpp
  clang/test/Parser/cxx-decl.cpp


Index: clang/test/Parser/cxx-decl.cpp
===
--- clang/test/Parser/cxx-decl.cpp
+++ clang/test/Parser/cxx-decl.cpp
@@ -298,6 +298,11 @@
   }
 }
 
+namespace rdar37099386 {
+  class A typename A; // expected-error {{expected a qualified name after 
'typename'}}
+  // expected-error@-1 {{cannot combine with previous 'class' declaration 
specifier}}
+}
+
 // PR8380
 extern ""  // expected-error {{unknown linkage language}}
 test6a { ;// expected-error {{C++ requires a type specifier for all 
declarations}}
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -3799,7 +3799,7 @@
 
 DS.SetRangeEnd(Tok.getLocation());
 if (DiagID != diag::err_bool_redeclaration)
-  ConsumeToken();
+  ConsumeAnyToken();
 
 AttrsLastTime = false;
   }


Index: clang/test/Parser/cxx-decl.cpp
===
--- clang/test/Parser/cxx-decl.cpp
+++ clang/test/Parser/cxx-decl.cpp
@@ -298,6 +298,11 @@
   }
 }
 
+namespace rdar37099386 {
+  class A typename A; // expected-error {{expected a qualified name after 'typename'}}
+  // expected-error@-1 {{cannot combine with previous 'class' declaration specifier}}
+}
+
 // PR8380
 extern ""  // expected-error {{unknown linkage language}}
 test6a { ;// expected-error {{C++ requires a type specifier for all declarations}}
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -3799,7 +3799,7 @@
 
 DS.SetRangeEnd(Tok.getLocation());
 if (DiagID != diag::err_bool_redeclaration)
-  ConsumeToken();
+  ConsumeAnyToken();
 
 AttrsLastTime = false;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44449: [Parser] Fix assertion-on-invalid for unexpected typename.

2018-03-13 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

I had performance considerations regarding this change because 
`ConsumeAnyToken` is heavier than `ConsumeToken`. But I didn't notice any 
problems. If you know this is a hot path that deserves more attention, please 
let me know.




Comment at: clang/lib/Parse/ParseDecl.cpp:3076
 DS.SetRangeEnd(Tok.getAnnotationEndLoc());
 ConsumeAnnotationToken(); // The typename
   }

Here we potentially can leave annotation token unconsumed. But I wasn't able to 
create a test case that would trigger a problem at this point.



Comment at: clang/lib/Parse/ParseDecl.cpp:3148
   DS.SetRangeEnd(Tok.getAnnotationEndLoc());
   ConsumeAnnotationToken(); // The typename
 

We didn't consume the annotation token because of `break` on `isInvalid` a few 
lines above.


https://reviews.llvm.org/D9



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


[PATCH] D43898: Preliminary refactoring in service of -Wreturn-std-move. NFC.

2018-03-13 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu added a comment.

Everything looks good and ready for commit.


Repository:
  rC Clang

https://reviews.llvm.org/D43898



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


[PATCH] D43197: [OpenMP] Add flag for linking runtime bitcode library

2018-03-13 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 138274.
gtbercea added a comment.

- Revert
- Add back.
- Improve tests.
- Add bclib.
- Fix.
- Fix.


Repository:
  rC Clang

https://reviews.llvm.org/D43197

Files:
  test/Driver/openmp-offload-gpu.c


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -148,17 +148,20 @@
 /// Check that the runtime bitcode library is part of the compile line. Create 
a bogus
 /// bitcode library and add it to the LIBRARY_PATH.
 // RUN:   env LIBRARY_PATH=%S/Inputs/libomptarget %clang -### -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda \
-// RUN:   -Xopenmp-target -march=sm_20 -fopenmp-relocatable-target -save-temps 
\
-// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck -check-prefix=CHK-BCLIB %s
+// RUN:   -Xopenmp-target -march=sm_20 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB %s
 
 // CHK-BCLIB: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-cuda-bitcode{{.*}}libomptarget-nvptx-sm_20.bc
+// CHK-BCLIB-NOT: {{error:|warning:}}
 
 /// ###
 
 /// Check that the warning is thrown when the libomptarget bitcode library is 
not found.
 /// Libomptarget requires sm_35 or newer so an sm_20 bitcode library should 
never exist.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
-// RUN:   -Xopenmp-target -march=sm_20 -fopenmp-relocatable-target -save-temps 
\
-// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck 
-check-prefix=CHK-BCLIB-WARN %s
+// RUN:   -Xopenmp-target -march=sm_20 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB-WARN %s
 
 // CHK-BCLIB-WARN: No library 'libomptarget-nvptx-sm_20.bc' found in the 
default clang lib directory or in LIBRARY_PATH. Expect degraded performance due 
to no inlining of runtime functions on target devices.


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -148,17 +148,20 @@
 /// Check that the runtime bitcode library is part of the compile line. Create a bogus
 /// bitcode library and add it to the LIBRARY_PATH.
 // RUN:   env LIBRARY_PATH=%S/Inputs/libomptarget %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
-// RUN:   -Xopenmp-target -march=sm_20 -fopenmp-relocatable-target -save-temps \
-// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck -check-prefix=CHK-BCLIB %s
+// RUN:   -Xopenmp-target -march=sm_20 --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB %s
 
 // CHK-BCLIB: clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-cuda-bitcode{{.*}}libomptarget-nvptx-sm_20.bc
+// CHK-BCLIB-NOT: {{error:|warning:}}
 
 /// ###
 
 /// Check that the warning is thrown when the libomptarget bitcode library is not found.
 /// Libomptarget requires sm_35 or newer so an sm_20 bitcode library should never exist.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
-// RUN:   -Xopenmp-target -march=sm_20 -fopenmp-relocatable-target -save-temps \
-// RUN:   -no-canonical-prefixes %s 2>&1 | FileCheck -check-prefix=CHK-BCLIB-WARN %s
+// RUN:   -Xopenmp-target -march=sm_20 --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB-WARN %s
 
 // CHK-BCLIB-WARN: No library 'libomptarget-nvptx-sm_20.bc' found in the default clang lib directory or in LIBRARY_PATH. Expect degraded performance due to no inlining of runtime functions on target devices.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43197: [OpenMP] Add flag for linking runtime bitcode library

2018-03-13 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 138275.

Repository:
  rC Clang

https://reviews.llvm.org/D43197

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_20.bc
  test/Driver/openmp-offload-gpu.c


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -142,3 +142,26 @@
 // RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
 
 // CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_60
+
+/// ###
+
+/// Check that the runtime bitcode library is part of the compile line. Create 
a bogus
+/// bitcode library and add it to the LIBRARY_PATH.
+// RUN:   env LIBRARY_PATH=%S/Inputs/libomptarget %clang -### -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda \
+// RUN:   -Xopenmp-target -march=sm_20 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB %s
+
+// CHK-BCLIB: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-cuda-bitcode{{.*}}libomptarget-nvptx-sm_20.bc
+// CHK-BCLIB-NOT: {{error:|warning:}}
+
+/// ###
+
+/// Check that the warning is thrown when the libomptarget bitcode library is 
not found.
+/// Libomptarget requires sm_35 or newer so an sm_20 bitcode library should 
never exist.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
+// RUN:   -Xopenmp-target -march=sm_20 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB-WARN %s
+
+// CHK-BCLIB-WARN: No library 'libomptarget-nvptx-sm_20.bc' found in the 
default clang lib directory or in LIBRARY_PATH. Expect degraded performance due 
to no inlining of runtime functions on target devices.
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -581,6 +581,44 @@
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+ptx42");
   }
+
+  if (DeviceOffloadingKind == Action::OFK_OpenMP) {
+SmallVector LibraryPaths;
+// Add path to lib and/or lib64 folders.
+SmallString<256> DefaultLibPath =
+  llvm::sys::path::parent_path(getDriver().Dir);
+llvm::sys::path::append(DefaultLibPath,
+Twine("lib") + CLANG_LIBDIR_SUFFIX);
+LibraryPaths.emplace_back(DefaultLibPath.c_str());
+
+// Add user defined library paths from LIBRARY_PATH.
+llvm::Optional LibPath =
+llvm::sys::Process::GetEnv("LIBRARY_PATH");
+if (LibPath) {
+  SmallVector Frags;
+  const char EnvPathSeparatorStr[] = {llvm::sys::EnvPathSeparator, '\0'};
+  llvm::SplitString(*LibPath, Frags, EnvPathSeparatorStr);
+  for (StringRef Path : Frags)
+LibraryPaths.emplace_back(Path.trim());
+}
+
+std::string LibOmpTargetName =
+  "libomptarget-nvptx-" + GpuArch.str() + ".bc";
+bool FoundBCLibrary = false;
+for (StringRef LibraryPath : LibraryPaths) {
+  SmallString<128> LibOmpTargetFile(LibraryPath);
+  llvm::sys::path::append(LibOmpTargetFile, LibOmpTargetName);
+  if (llvm::sys::fs::exists(LibOmpTargetFile)) {
+CC1Args.push_back("-mlink-cuda-bitcode");
+CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetFile));
+FoundBCLibrary = true;
+break;
+  }
+}
+if (!FoundBCLibrary)
+  getDriver().Diag(diag::warn_drv_omp_offload_target_missingbcruntime)
+  << LibOmpTargetName;
+  }
 }
 
 void CudaToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,
Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -203,6 +203,9 @@
 def warn_drv_omp_offload_target_duplicate : Warning<
   "The OpenMP offloading target '%0' is similar to target '%1' already 
specified - will be ignored.">, 
   InGroup;
+def warn_drv_omp_offload_target_missingbcruntime : Warning<
+  "No library '%0' found in the default clang lib directory or in 
LIBRARY_PATH. Expect degraded performance due to no inlining of runtime 
functions on target devices.">,
+  InGroup;
 def err_drv_bitcode_unsupported_on_toolchain : Error<
   "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
 


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -142,3 +142,26 @@
 // RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
 
 // CHK-NOLIBDEV

r327460 - [OpenMP] Add flag for linking runtime bitcode library

2018-03-13 Thread Gheorghe-Teodor Bercea via cfe-commits
Author: gbercea
Date: Tue Mar 13 16:19:52 2018
New Revision: 327460

URL: http://llvm.org/viewvc/llvm-project?rev=327460&view=rev
Log:
[OpenMP] Add flag for linking runtime bitcode library

Summary: This patch adds an additional flag to the OpenMP device offloading 
toolchain to link in the runtime library bitcode.

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

Reviewed By: ABataev, grokos

Subscribers: jholewinski, guansong, cfe-commits

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

Added:
cfe/trunk/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_20.bc
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
cfe/trunk/test/Driver/openmp-offload-gpu.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=327460&r1=327459&r2=327460&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Mar 13 16:19:52 
2018
@@ -203,6 +203,9 @@ def err_drv_expecting_fopenmp_with_fopen
 def warn_drv_omp_offload_target_duplicate : Warning<
   "The OpenMP offloading target '%0' is similar to target '%1' already 
specified - will be ignored.">, 
   InGroup;
+def warn_drv_omp_offload_target_missingbcruntime : Warning<
+  "No library '%0' found in the default clang lib directory or in 
LIBRARY_PATH. Expect degraded performance due to no inlining of runtime 
functions on target devices.">,
+  InGroup;
 def err_drv_bitcode_unsupported_on_toolchain : Error<
   "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
 

Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.cpp?rev=327460&r1=327459&r2=327460&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp Tue Mar 13 16:19:52 2018
@@ -581,6 +581,44 @@ void CudaToolChain::addClangTargetOption
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+ptx42");
   }
+
+  if (DeviceOffloadingKind == Action::OFK_OpenMP) {
+SmallVector LibraryPaths;
+// Add path to lib and/or lib64 folders.
+SmallString<256> DefaultLibPath =
+  llvm::sys::path::parent_path(getDriver().Dir);
+llvm::sys::path::append(DefaultLibPath,
+Twine("lib") + CLANG_LIBDIR_SUFFIX);
+LibraryPaths.emplace_back(DefaultLibPath.c_str());
+
+// Add user defined library paths from LIBRARY_PATH.
+llvm::Optional LibPath =
+llvm::sys::Process::GetEnv("LIBRARY_PATH");
+if (LibPath) {
+  SmallVector Frags;
+  const char EnvPathSeparatorStr[] = {llvm::sys::EnvPathSeparator, '\0'};
+  llvm::SplitString(*LibPath, Frags, EnvPathSeparatorStr);
+  for (StringRef Path : Frags)
+LibraryPaths.emplace_back(Path.trim());
+}
+
+std::string LibOmpTargetName =
+  "libomptarget-nvptx-" + GpuArch.str() + ".bc";
+bool FoundBCLibrary = false;
+for (StringRef LibraryPath : LibraryPaths) {
+  SmallString<128> LibOmpTargetFile(LibraryPath);
+  llvm::sys::path::append(LibOmpTargetFile, LibOmpTargetName);
+  if (llvm::sys::fs::exists(LibOmpTargetFile)) {
+CC1Args.push_back("-mlink-cuda-bitcode");
+CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetFile));
+FoundBCLibrary = true;
+break;
+  }
+}
+if (!FoundBCLibrary)
+  getDriver().Diag(diag::warn_drv_omp_offload_target_missingbcruntime)
+  << LibOmpTargetName;
+  }
 }
 
 void CudaToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,

Added: cfe/trunk/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_20.bc
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_20.bc?rev=327460&view=auto
==
(empty)

Modified: cfe/trunk/test/Driver/openmp-offload-gpu.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openmp-offload-gpu.c?rev=327460&r1=327459&r2=327460&view=diff
==
--- cfe/trunk/test/Driver/openmp-offload-gpu.c (original)
+++ cfe/trunk/test/Driver/openmp-offload-gpu.c Tue Mar 13 16:19:52 2018
@@ -142,3 +142,26 @@
 // RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
 
 // CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_60
+
+/// ###
+
+/// Check that the runtime bitcode library is part of the compile line. Create 
a bogus
+/// bitcode library and add it to the LIBRARY_PATH.
+// RUN:   env LIBRARY_PATH=%S/Inputs/libomptarget %clang -### -fopenmp=li

[PATCH] D43197: [OpenMP] Add flag for linking runtime bitcode library

2018-03-13 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL327460: [OpenMP] Add flag for linking runtime bitcode 
library (authored by gbercea, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43197?vs=138275&id=138276#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43197

Files:
  cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
  cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
  cfe/trunk/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_20.bc
  cfe/trunk/test/Driver/openmp-offload-gpu.c


Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
@@ -203,6 +203,9 @@
 def warn_drv_omp_offload_target_duplicate : Warning<
   "The OpenMP offloading target '%0' is similar to target '%1' already 
specified - will be ignored.">, 
   InGroup;
+def warn_drv_omp_offload_target_missingbcruntime : Warning<
+  "No library '%0' found in the default clang lib directory or in 
LIBRARY_PATH. Expect degraded performance due to no inlining of runtime 
functions on target devices.">,
+  InGroup;
 def err_drv_bitcode_unsupported_on_toolchain : Error<
   "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
 
Index: cfe/trunk/test/Driver/openmp-offload-gpu.c
===
--- cfe/trunk/test/Driver/openmp-offload-gpu.c
+++ cfe/trunk/test/Driver/openmp-offload-gpu.c
@@ -142,3 +142,26 @@
 // RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
 
 // CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_60
+
+/// ###
+
+/// Check that the runtime bitcode library is part of the compile line. Create 
a bogus
+/// bitcode library and add it to the LIBRARY_PATH.
+// RUN:   env LIBRARY_PATH=%S/Inputs/libomptarget %clang -### -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda \
+// RUN:   -Xopenmp-target -march=sm_20 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB %s
+
+// CHK-BCLIB: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-cuda-bitcode{{.*}}libomptarget-nvptx-sm_20.bc
+// CHK-BCLIB-NOT: {{error:|warning:}}
+
+/// ###
+
+/// Check that the warning is thrown when the libomptarget bitcode library is 
not found.
+/// Libomptarget requires sm_35 or newer so an sm_20 bitcode library should 
never exist.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
+// RUN:   -Xopenmp-target -march=sm_20 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB-WARN %s
+
+// CHK-BCLIB-WARN: No library 'libomptarget-nvptx-sm_20.bc' found in the 
default clang lib directory or in LIBRARY_PATH. Expect degraded performance due 
to no inlining of runtime functions on target devices.
Index: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
@@ -581,6 +581,44 @@
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+ptx42");
   }
+
+  if (DeviceOffloadingKind == Action::OFK_OpenMP) {
+SmallVector LibraryPaths;
+// Add path to lib and/or lib64 folders.
+SmallString<256> DefaultLibPath =
+  llvm::sys::path::parent_path(getDriver().Dir);
+llvm::sys::path::append(DefaultLibPath,
+Twine("lib") + CLANG_LIBDIR_SUFFIX);
+LibraryPaths.emplace_back(DefaultLibPath.c_str());
+
+// Add user defined library paths from LIBRARY_PATH.
+llvm::Optional LibPath =
+llvm::sys::Process::GetEnv("LIBRARY_PATH");
+if (LibPath) {
+  SmallVector Frags;
+  const char EnvPathSeparatorStr[] = {llvm::sys::EnvPathSeparator, '\0'};
+  llvm::SplitString(*LibPath, Frags, EnvPathSeparatorStr);
+  for (StringRef Path : Frags)
+LibraryPaths.emplace_back(Path.trim());
+}
+
+std::string LibOmpTargetName =
+  "libomptarget-nvptx-" + GpuArch.str() + ".bc";
+bool FoundBCLibrary = false;
+for (StringRef LibraryPath : LibraryPaths) {
+  SmallString<128> LibOmpTargetFile(LibraryPath);
+  llvm::sys::path::append(LibOmpTargetFile, LibOmpTargetName);
+  if (llvm::sys::fs::exists(LibOmpTargetFile)) {
+CC1Args.push_back("-mlink-cuda-bitcode");
+CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetFile));
+FoundBCLibrary = true;
+break;
+  }
+}
+if (!FoundBCLibrary)
+  getDriver().Diag(diag::warn_drv_omp_offload_target_missi

r327464 - Check that a field is not annotated with attribute "unavailable" before

2018-03-13 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Tue Mar 13 16:37:51 2018
New Revision: 327464

URL: http://llvm.org/viewvc/llvm-project?rev=327464&view=rev
Log:
Check that a field is not annotated with attribute "unavailable" before
setting the NonTrivialToPrimitive* flags of a record.

Union fields that have non-trivial Objective-C ownership qualifications
are normally not legal, but if the union is declared in a system header,
the fields are annotated with attribute "unavailable".

rdar://problem/38431072

Added:
cfe/trunk/test/CodeGenObjC/Inputs/strong_in_union.h
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CodeGenObjC/strong-in-c-struct.m

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=327464&r1=327463&r2=327464&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Mar 13 16:37:51 2018
@@ -15442,7 +15442,7 @@ void Sema::ActOnFields(Scope *S, SourceL
   }
 }
 
-if (Record && !getLangOpts().CPlusPlus) {
+if (Record && !getLangOpts().CPlusPlus && !FD->hasAttr()) 
{
   QualType FT = FD->getType();
   if (FT.isNonTrivialToPrimitiveDefaultInitialize())
 Record->setNonTrivialToPrimitiveDefaultInitialize(true);

Added: cfe/trunk/test/CodeGenObjC/Inputs/strong_in_union.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/Inputs/strong_in_union.h?rev=327464&view=auto
==
--- cfe/trunk/test/CodeGenObjC/Inputs/strong_in_union.h (added)
+++ cfe/trunk/test/CodeGenObjC/Inputs/strong_in_union.h Tue Mar 13 16:37:51 2018
@@ -0,0 +1,10 @@
+#ifndef STRONG_IN_UNION_H
+#define STRONG_IN_UNION_H
+#pragma clang system_header
+
+typedef union {
+  id f0;
+  int *f1;
+} U;
+
+#endif // STRONG_IN_UNION_H

Modified: cfe/trunk/test/CodeGenObjC/strong-in-c-struct.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/strong-in-c-struct.m?rev=327464&r1=327463&r2=327464&view=diff
==
--- cfe/trunk/test/CodeGenObjC/strong-in-c-struct.m (original)
+++ cfe/trunk/test/CodeGenObjC/strong-in-c-struct.m Tue Mar 13 16:37:51 2018
@@ -1,10 +1,11 @@
-// RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -fblocks  
-fobjc-runtime=ios-11.0 -emit-llvm -o - -DUSESTRUCT %s | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -fblocks  
-fobjc-runtime=ios-11.0 -emit-llvm -o - -DUSESTRUCT -I %S/Inputs %s | FileCheck 
%s
 
-// RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -fblocks  
-fobjc-runtime=ios-11.0 -emit-pch -o %t %s
-// RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -fblocks  
-fobjc-runtime=ios-11.0 -include-pch %t -emit-llvm -o - -DUSESTRUCT %s | 
FileCheck %s
+// RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -fblocks  
-fobjc-runtime=ios-11.0 -emit-pch -I %S/Inputs -o %t %s
+// RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -fblocks  
-fobjc-runtime=ios-11.0 -include-pch %t -emit-llvm -o - -DUSESTRUCT -I 
%S/Inputs %s | FileCheck %s
 
 #ifndef HEADER
 #define HEADER
+#include "strong_in_union.h"
 
 typedef void (^BlockTy)(void);
 
@@ -531,4 +532,12 @@ void test_copy_constructor_Bitfield1(Bit
   Bitfield1 t = *a;
 }
 
+// CHECK: define void @test_strong_in_union()
+// CHECK: alloca %{{.*}}
+// CHECK-NEXT: ret void
+
+void test_strong_in_union() {
+  U t;
+}
+
 #endif /* USESTRUCT */


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


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

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

I dreamed up some test cases that may or may not make sense. I think they boil 
down to a few things:

- Does inheriting from a prohibited type still diagnose when the derived type 
is used to construct a temporary?
- Should it still be prohibited if the temporary type is being returned?




Comment at: clang-tidy/zircon/ZirconTidyModule.cpp:29
+};
+// Register the ZirconTidyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add

Can you add a bit of vertical whitespace before this comment?



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

Some additional test cases:
```
template 
Ty make_ty() { return Ty{}; }

// Call make_ty<> with two types: one allowed and one disallowed; I assume only 
the disallowed triggers the diagnostic.

struct Bingo : NS::Bar {}; // Not explicitly disallowed

void f() {
  Bingo{}; // Should this diagnose because it inherits from Bar?
}

// Assuming derived classes diagnose if the base is prohibited:
template 
struct Quux : Ty {};

void f() {
  Quux{}; // Diagnose
  Quux{}; // Fine?
}
```


https://reviews.llvm.org/D44346



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


[PATCH] D43898: Preliminary refactoring in service of -Wreturn-std-move. NFC.

2018-03-13 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

@rtrieu thanks!  I don't have commit privileges; could I ask you to commit this 
on my behalf?  (Or if not, please say no, and I'll know to go looking for 
someone else to ask.)

Once/if https://reviews.llvm.org/D43898 hits master, I'll rebase 
https://reviews.llvm.org/D43322 and await a LGTM there, at which point I'll 
again ask for help committing it. :)


Repository:
  rC Clang

https://reviews.llvm.org/D43898



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


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

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



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

You can drop these asserts.



Comment at: clang-tidy/bugprone/ParentVirtualCallCheck.cpp:28-29
+return true;
+  const auto ClassIter = std::find_if(
+  ThisClass->bases_begin(), ThisClass->bases_end(), [=](auto &Base) {
+assert(Base.getType()->getAsCXXRecordDecl());

You can use `llvm::find_if()` for the range-based API instead.



Comment at: clang-tidy/bugprone/ParentVirtualCallCheck.cpp:30-32
+assert(Base.getType()->getAsCXXRecordDecl());
+return Parent->getCanonicalDecl() ==
+   Base.getType()->getAsCXXRecordDecl()->getCanonicalDecl();

Factor out `Base.getType()->getAs()` and use the pointer in both the assert and 
the comparison.



Comment at: clang-tidy/bugprone/ParentVirtualCallCheck.cpp:39-40
+const CXXRecordDecl *ThisClass) {
+  assert(Parent);
+  assert(ThisClass);
+  return ThisClass->isDerivedFrom(Parent);

And these asserts as well.

I don't think this function adds much value given that it's a one-liner; I'd 
hoist its functionality out to the caller.



Comment at: clang-tidy/bugprone/ParentVirtualCallCheck.cpp:56-60
+  }
+  return result;
+}
+
+static std::string GetNameAsString(const NamedDecl *Decl) {

This should be `getNameAsString()`



Comment at: clang-tidy/bugprone/ParentVirtualCallCheck.cpp:101-103
+  else {
+if (auto *TemplateSpecializationTypePtr =
+Result.Nodes.getNodeAs("castToType")) {

Convert this to an `else if` and elide the braces.



Comment at: clang-tidy/bugprone/ParentVirtualCallCheck.cpp:112
+
+  const auto Parents = GetParentsByGrandParent(CastToType, ThisType);
+  assert(!Parents.empty());

Do not use `auto` here as the type is not spelled out in the intialization.



Comment at: clang-tidy/bugprone/ParentVirtualCallCheck.cpp:128
+  diag(Member->getQualifierLoc().getSourceRange().getBegin(),
+   "'%0' is a grand-parent's method, not parent's. Did you mean %1?")
+  << CalleeName << ParentsStr;

The diagnostic should not contain punctuation aside from the question mark.

Also, the diagnostic uses some novel terminology in "grandparent's method". How 
about: "qualified function name %0 refers to a function that is not defined by 
a direct base class; did you mean %1?"



Comment at: test/clang-tidy/bugprone-parent-virtual-call.cpp:127
+// Just to instantiate DF.
+int bar() { return (new DF())->virt_1(); }

What should happen in this case?
```
struct Base {
  virtual void f() {}
};

struct Intermediary : Base {
};

struct Derived : Intermediary {
  void f() override {
Base::f(); // I would expect this not to diagnose
  }
};
```
This would be a reasonable test case to add.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44295



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


[PATCH] D16008: [clang-tidy] Add calling virtual functions in constructors/destructors check.

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

In https://reviews.llvm.org/D16008#1035948, @malcolm.parsons wrote:

> In https://reviews.llvm.org/D16008#1035789, @aaron.ballman wrote:
>
> > Do you know why the CSA checker is still in alpha?
>
>
> It isn't - https://reviews.llvm.org/D26768 moved it to optin.
>
> I don't know why https://reviews.llvm.org/D34275 didn't turn it on by default.


Then I'm not certain the utility of this check given that you can call the CSA 
check from clang-tidy directly; however, I do like the idea of exposing the CSA 
check under the name cert-oop50-cpp.


Repository:
  rL LLVM

https://reviews.llvm.org/D16008



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


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

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

Addomg tests amd fixing documentation


https://reviews.llvm.org/D44346

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

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

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

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



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

Why? I thought `Bar` was allowed, but `NS::Bar` was prohibited?



Comment at: test/clang-tidy/zircon-temporary-objects.cpp:95
+
+// Inheriting the disallowed class does not trigger the check.
+

The documentation should explicitly call this out, as it's different than I 
would have expected (I was assuming the derived classes would inherit the 
prohibition).



Comment at: test/clang-tidy/zircon-temporary-objects.cpp:107-108
+void f3() {
+  Quux(); // Diagnose
+  Quux(); // Fine?
+}

The comments here seem amiss.


https://reviews.llvm.org/D44346



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


r327471 - [hwasan] update docs

2018-03-13 Thread Kostya Serebryany via cfe-commits
Author: kcc
Date: Tue Mar 13 18:55:49 2018
New Revision: 327471

URL: http://llvm.org/viewvc/llvm-project?rev=327471&view=rev
Log:
[hwasan] update docs

Modified:
cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst

Modified: cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst?rev=327471&r1=327470&r2=327471&view=diff
==
--- cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst (original)
+++ cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst Tue Mar 13 
18:55:49 2018
@@ -7,8 +7,6 @@ This page is a design document for
 a tool similar to :doc:`AddressSanitizer`,
 but based on partial hardware assistance.
 
-The document is a draft, suggestions are welcome.
-
 
 Introduction
 
@@ -30,15 +28,16 @@ accuracy guarantees.
 
 Algorithm
 =
-* Every heap/stack/global memory object is forcibly aligned by `N` bytes
-  (`N` is e.g. 16 or 64). We call `N` the **granularity** of tagging.
-* For every such object a random `K`-bit tag `T` is chosen (`K` is e.g. 4 or 8)
+* Every heap/stack/global memory object is forcibly aligned by `TG` bytes
+  (`TG` is e.g. 16 or 64). We call `TG` the **tagging granularity**.
+* For every such object a random `TS`-bit tag `T` is chosen (`TS`, or tag 
size, is e.g. 4 or 8)
 * The pointer to the object is tagged with `T`.
-* The memory for the object is also tagged with `T`
-  (using a `N=>1` shadow memory)
+* The memory for the object is also tagged with `T` (using a `TG=>1` shadow 
memory)
 * Every load and store is instrumented to read the memory tag and compare it
   with the pointer tag, exception is raised on tag mismatch.
 
+For a more detailed discussion of this approach see 
https://arxiv.org/pdf/1802.09517.pdf
+
 Instrumentation
 ===
 
@@ -59,8 +58,8 @@ verifies the tags. Currently, the follow
c:  3f 01 08 6b cmp w9, w8   // compare tags
   10:  61 00 00 54 b.ne#12  // jump on mismatch
   14:  00 00 40 b9 ldr w0, [x0] // original load
-  18:  c0 03 5f d6 ret 
-  1c:  40 20 40 d4 hlt #0x102   // halt
+  18:  c0 03 5f d6 ret
+  1c:  40 20 21 d4 brk #0x902   // trap
 
 
 Alternatively, memory accesses are prefixed with a function call.
@@ -69,14 +68,14 @@ Heap
 
 
 Tagging the heap memory/pointers is done by `malloc`.
-This can be based on any malloc that forces all objects to be N-aligned.
+This can be based on any malloc that forces all objects to be TG-aligned.
 `free` tags the memory with a different tag.
 
 Stack
 -
 
 Stack frames are instrumented by aligning all non-promotable allocas
-by `N` and tagging stack memory in function prologue and epilogue.
+by `TG` and tagging stack memory in function prologue and epilogue.
 
 Tags for different allocas in one function are **not** generated
 independently; doing that in a function with `M` allocas would require
@@ -131,15 +130,25 @@ HWASAN:
 https://www.kernel.org/doc/Documentation/arm64/tagged-pointers.txt).
   * **Does not require redzones to detect buffer overflows**,
 but the buffer overflow detection is probabilistic, with roughly
-`(2**K-1)/(2**K)` probability of catching a bug.
+`(2**TS-1)/(2**TS)` probability of catching a bug.
   * **Does not require quarantine to detect heap-use-after-free,
 or stack-use-after-return**.
 The detection is similarly probabilistic.
 
 The memory overhead of HWASAN is expected to be much smaller
 than that of AddressSanitizer:
-`1/N` extra memory for the shadow
-and some overhead due to `N`-aligning all objects.
+`1/TG` extra memory for the shadow
+and some overhead due to `TG`-aligning all objects.
+
+Supported architectures
+===
+HWASAN relies on `Address Tagging`_ which is only available on AArch64.
+For other 64-bit architectures it is possible to remove the address tags
+before every load and store by compiler instrumentation, but this variant
+will have limited deployability since not all of the code is
+typically instrumented.
+
+The HWASAN's approach is not applicable to 32-bit architectures.
 
 
 Related Work


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


Re: r327345 - [analyzer] Destroy and lifetime-extend inlined function return values properly.

2018-03-13 Thread Mikael Holmén via cfe-commits

Hi Artem,

This commit gives the following warning:

../tools/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp:283:23: error: 
unused variable 'RCC' [-Werror,-Wunused-variable]
  if (const auto *RCC = 
dyn_cast(CC)) {

  ^
1 error generated.

Regards,
Mikael

On 03/13/2018 12:22 AM, Artem Dergachev via cfe-commits wrote:

Author: dergachev
Date: Mon Mar 12 16:22:35 2018
New Revision: 327345

URL: http://llvm.org/viewvc/llvm-project?rev=327345&view=rev
Log:
[analyzer] Destroy and lifetime-extend inlined function return values properly.

This patch uses the newly added CFGCXXRecordTypedCall element at the call site
of the caller to construct the return value within the callee directly into the
caller's stack frame. This way it is also capable of populating the temporary
destructor and lifetime extension maps for the temporary, which allows
temporary destructors and lifetime extension to work correctly.

This patch does not affect temporaries that were returned from conservatively
evaluated functions.

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

Modified:
 cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
 cfe/trunk/test/Analysis/lifetime-extension.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp?rev=327345&r1=327344&r2=327345&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp Mon Mar 12 16:22:35 2018
@@ -197,16 +197,19 @@ ExprEngine::getRegionForConstructedObjec
return MRMgr.getCXXTempObjectRegion(CE, LCtx);
  }
  case ConstructionContext::ReturnedValueKind: {
-  // TODO: We should construct into a CXXBindTemporaryExpr or a
-  // MaterializeTemporaryExpr around the call-expression on the previous
-  // stack frame. Currently we re-bind the temporary to the correct region
-  // later, but that's not semantically correct. This of course does not
-  // apply when we're in the top frame. But if we are in an inlined
-  // function, we should be able to take the call-site CFG element,
-  // and it should contain (but right now it wouldn't) some sort of
-  // construction context that'd give us the right temporary expression.
+  // The temporary is to be managed by the parent stack frame.
+  // So build it in the parent stack frame if we're not in the
+  // top frame of the analysis.
+  // TODO: What exactly happens when we are? Does the temporary object live
+  // long enough in the region store in this case? Would checkers think
+  // that this object immediately goes out of scope?
+  const LocationContext *TempLCtx = LCtx;
+  if (const LocationContext *CallerLCtx =
+  LCtx->getCurrentStackFrame()->getParent()) {
+TempLCtx = CallerLCtx;
+  }
CallOpts.IsTemporaryCtorOrDtor = true;
-  return MRMgr.getCXXTempObjectRegion(CE, LCtx);
+  return MRMgr.getCXXTempObjectRegion(CE, TempLCtx);
  }
  }
}
@@ -262,6 +265,7 @@ void ExprEngine::VisitCXXConstructExpr(c
assert(C || getCurrentCFGElement().getAs());
const ConstructionContext *CC = C ? C->getConstructionContext() : nullptr;
  
+  bool IsReturnedIntoParentStackFrame = false;

const CXXBindTemporaryExpr *BTE = nullptr;
const MaterializeTemporaryExpr *MTE = nullptr;
  
@@ -269,25 +273,44 @@ void ExprEngine::VisitCXXConstructExpr(c

case CXXConstructExpr::CK_Complete: {
  Target = getRegionForConstructedObject(CE, Pred, CC, CallOpts);
  
-// In case of temporary object construction, extract data necessary for

-// destruction and lifetime extension.
-if (const auto *TCC =
-dyn_cast_or_null(CC)) {
-  assert(CallOpts.IsTemporaryCtorOrDtor);
-  assert(!CallOpts.IsCtorOrDtorWithImproperlyModeledTargetRegion);
-  if (AMgr.getAnalyzerOptions().includeTemporaryDtorsInCFG()) {
-BTE = TCC->getCXXBindTemporaryExpr();
-MTE = TCC->getMaterializedTemporaryExpr();
-if (!BTE) {
-  // FIXME: lifetime extension for temporaries without destructors
-  // is not implemented yet.
-  MTE = nullptr;
+if (CC) {
+  // In case of temporary object construction, extract data necessary for
+  // destruction and lifetime extension.
+  const auto *TCC = dyn_cast(CC);
+
+  // If the temporary is being returned from the function, it will be
+  // destroyed or lifetime-extended in the caller stack frame.
+  if (const auto *RCC = dyn_cast(CC)) {
+const StackFrameContext *SFC = LCtx->getCurrentStackFrame();
+assert(SFC);
+if (SFC->getParent()) {
+  IsReturnedIntoParentStackFrame = true;
+  const CFGElement &CallElem =
+  (*SFC->getCallSiteBlock())[SFC->getIndex()];
+  if (

[PATCH] D21508: Diagnose friend function template redefinitions

2018-03-13 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 138303.
sepavloff added a comment.

Updated patch

- Rebased relative to recent ToT
- Removed the change in `FunctionDecl::getTemplateInstantiationPattern()`, as 
it is not necessary for error detection,
- Added test for use in module.


Repository:
  rC Clang

https://reviews.llvm.org/D21508

Files:
  include/clang/AST/DeclBase.h
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/Modules/friend-definition.cpp
  test/SemaCXX/friend2.cpp

Index: test/SemaCXX/friend2.cpp
===
--- test/SemaCXX/friend2.cpp
+++ test/SemaCXX/friend2.cpp
@@ -129,6 +129,83 @@
 void func_22() {} // expected-error{{redefinition of 'func_22'}}
 
 
+// Case of template friend functions.
+
+template void func_31(T *x);
+template
+struct C31a {
+  template friend void func_31(T *x) {}
+};
+template
+struct C31b {
+  template friend void func_31(T *x) {}
+};
+
+
+template inline void func_32(T *x) {}
+template
+struct C32a {
+  template friend void func_32(T *x) {}
+};
+template
+struct C32b {
+  template friend void func_32(T *x) {}
+};
+
+
+template
+struct C33a {
+  template friend void func_33(T *x) {}
+};
+template
+struct C33b {
+  template friend void func_33(T *x) {}
+};
+
+
+template inline void func_34(T *x) {}  // expected-note{{previous definition is here}}
+template
+struct C34 {
+  template friend void func_34(T *x) {} // expected-error{{redefinition of 'func_34'}}
+};
+
+C34 v34;  // expected-note{{in instantiation of template class 'C34' requested here}}
+
+
+template inline void func_35(T *x);
+template
+struct C35a {
+  template friend void func_35(T *x) {} // expected-note{{previous definition is here}}
+};
+template
+struct C35b {
+  template friend void func_35(T *x) {} // expected-error{{redefinition of 'func_35'}}
+};
+
+C35a v35a;
+C35b v35b;  // expected-note{{in instantiation of template class 'C35b' requested here}}
+
+
+template void func_36(T *x);
+template
+struct C36 {
+  template friend void func_36(T *x) {}  // expected-error{{redefinition of 'func_36'}}
+ // expected-note@-1{{previous definition is here}}
+};
+
+C36 v36a;
+C36 v36b;  //expected-note{{in instantiation of template class 'C36' requested here}}
+
+
+template void func_37(T *x);
+template
+struct C37 {
+  template friend void func_37(T *x) {} // expected-note{{previous definition is here}}
+};
+
+C37 v37;
+template void func_37(T *x) {} // expected-error{{redefinition of 'func_37'}}
+
 
 namespace pr22307 {
 
Index: test/Modules/friend-definition.cpp
===
--- test/Modules/friend-definition.cpp
+++ test/Modules/friend-definition.cpp
@@ -7,6 +7,7 @@
 #pragma clang module begin A
 template struct A {
   friend A operator+(const A&, const A&) { return {}; }
+  template friend void func_1(const A&, const T2 &) {}
 };
 #pragma clang module end
 #pragma clang module endbuild
@@ -36,4 +37,5 @@
 void h() {
   A a;
   a + a;
+  func_1(a, 0);
 }
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1795,7 +1795,9 @@
   // If the original function was part of a friend declaration,
   // inherit its namespace state and add it to the owner.
   if (isFriend) {
-PrincipalDecl->setObjectOfFriendDecl();
+Function->setObjectOfFriendDecl();
+if (FunctionTemplateDecl *FT = Function->getDescribedFunctionTemplate())
+  FT->setObjectOfFriendDecl();
 DC->makeDeclVisibleInContext(PrincipalDecl);
 
 bool QueuedInstantiation = false;
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -12321,6 +12321,29 @@
   }
 }
   }
+
+  if (!Definition)
+// Similar to friend functions a friend function template may be a
+// definition and do not have a body if it is instantiated in a class
+// template.
+if (FunctionTemplateDecl *FTD = FD->getDescribedFunctionTemplate()) {
+  for (auto I : FTD->redecls()) {
+auto D = cast(I);
+if (D != FTD) {
+  assert(!D->isThisDeclarationADefinition() &&
+ "More than one definition in redeclaration chain");
+  if (D->getFriendObjectKind() != Decl::FOK_None)
+if (FunctionTemplateDecl *FT =
+   D->getInstantiatedFromMemberTemplate()) {
+  if (FT->isThisDeclarationADefinition()) {
+Definition = D->getTemplatedDecl();
+break;
+  }
+}
+}
+  }
+}
+
   if (!Definition)
 return;
 
Index: include/clang/AST/DeclBase.h
===
--- include/clang/AST/DeclBase.h
+++ include/clang/AST

  1   2   >