[PATCH] D33820: [PowerPC] Pass CPU to assembler with -no-integrated-as

2017-06-29 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.

Ping.


Repository:
  rL LLVM

https://reviews.llvm.org/D33820



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


[PATCH] D33820: [PowerPC] Pass CPU to assembler with -no-integrated-as

2017-06-29 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

Sorry, when I say "One inline comment otherwise LGTM" feel free to commit after 
fixing :)

Since you have, then LGTM.

-eric


Repository:
  rL LLVM

https://reviews.llvm.org/D33820



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


[PATCH] D34275: [analyzer] Re-implemente current virtual calls checker in a path-sensitive way

2017-06-29 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp:31
+class VirtualCallChecker: public Checker {
+  mutable std::unique_ptr BT_CT;
+  mutable std::unique_ptr BT_DT;

Could you find more descriptive names for these BugTypes?



Comment at: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp:32
+  mutable std::unique_ptr BT_CT;
+  mutable std::unique_ptr BT_DT;
 

I'd rather have one bug type, describing a call to a virtual function from 
ctor/dtor. The actual error message can clarify whether this is a call from 
ctor or from dtor and whether it is pure virtual. You do not need to reflect 
every detail in the bug type. 



Comment at: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp:35
 public:
-  WalkAST(const CheckerBase *checker, BugReporter &br, AnalysisDeclContext *ac,
-  const CXXMethodDecl *rootMethod, bool isInterprocedural,
-  bool reportPureOnly)
-  : Checker(checker), BR(br), AC(ac), RootMethod(rootMethod),
-IsInterprocedural(isInterprocedural), ReportPureOnly(reportPureOnly),
-visitingCallExpr(nullptr) {
-// Walking should always start from either a constructor or a destructor.
-assert(isa(rootMethod) ||
-   isa(rootMethod));
-  }
-
-  bool hasWork() const { return !WList.empty(); }
-
-  /// This method adds a CallExpr to the worklist and marks the callee as
-  /// being PreVisited.
-  void Enqueue(WorkListUnit WLUnit) {
-const FunctionDecl *FD = WLUnit->getDirectCallee();
-if (!FD || !FD->getBody())
-  return;
-Kind &K = VisitedFunctions[FD];
-if (K != NotVisited)
-  return;
-K = PreVisited;
-WList.push_back(WLUnit);
-  }
-
-  /// This method returns an item from the worklist without removing it.
-  WorkListUnit Dequeue() {
-assert(!WList.empty());
-return WList.back();
-  }
-
-  void Execute() {
-while (hasWork()) {
-  WorkListUnit WLUnit = Dequeue();
-  const FunctionDecl *FD = WLUnit->getDirectCallee();
-  assert(FD && FD->getBody());
-
-  if (VisitedFunctions[FD] == PreVisited) {
-// If the callee is PreVisited, walk its body.
-// Visit the body.
-SaveAndRestore SaveCall(visitingCallExpr, WLUnit);
-Visit(FD->getBody());
-
-// Mark the function as being PostVisited to indicate we have
-// scanned the body.
-VisitedFunctions[FD] = PostVisited;
-continue;
-  }
+  // The flag to determine if pure virtual functions should be issued only
+  DefaultBool isPureOnly;

Comments should be full sentences, this means they should be terminated with a 
period. 



Comment at: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp:36
+  // The flag to determine if pure virtual functions should be issued only
+  DefaultBool isPureOnly;
 

Variables should start with capital letters. 



Comment at: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp:40
+  void checkPostCall(const CallEvent &Call, CheckerContext &C) const;
+  bool isCalledbyCtor(const CallExpr *CE,ProgramStateRef state,const 
LocationContext *LCtx) const;
+  bool isCalledbyDtor(const CallExpr *CE,ProgramStateRef state,const 
LocationContext *LCtx) const;

The names of the arguments should start with an uppercase letter. 



Comment at: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp:72
+//GDM (generic data map) to determine if a function is called by an object
+REGISTER_TRAIT_WITH_PROGRAMSTATE(ObjectFlag, unsigned)
+//GDM (generic data map) to the memregion of this for the ctor and dtor

Do you need these traits above after having the maps bellow? 



Comment at: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp:96
+ 
+  if((!CD && !DD) || (Ctorflag!=TrackedCtorDtorFlag && 
+  Dtorflag!=TrackedCtorDtorFlag)) 

The formatting here seems to be off, could you run clang-format on the code? 
This is a tool that can format the code to comply with the LLVM formatting 
style guide. 



Comment at: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp:129
 
-void WalkAST::VisitChildren(Stmt *S) {
-  for (Stmt *Child : S->children())
-if (Child)
-  Visit(Child);
-}
+  const auto *CC = dyn_cast_or_null(&Call);
+  const auto *CD = dyn_cast_or_null(&Call);

I think you do not need the or_null suffix here since the argument of this cast 
will never be null. 



Comment at: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp:141
+  // Enter a constructor, increase the corresponding integer
+  if (dyn_cast(D)) {
+unsigned Constructorflag = State->get();

If you do not use the result of `dyn_cast`, you could use `isa` instead. Even 
better, you could reuse `CC` or `DC` in this check. 



Comment at: lib/StaticAnalyzer/Check

[PATCH] D34469: Use vfs::FileSystem in ASTUnit when creating CompilerInvocation.

2017-06-29 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

@bruno, I've added a test to clangd, see D34755 
.


Repository:
  rL LLVM

https://reviews.llvm.org/D34469



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


[clang-tools-extra] r306650 - [clang-tidy] follow-up on misc-definitions-in-header check.

2017-06-29 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Jun 29 01:28:45 2017
New Revision: 306650

URL: http://llvm.org/viewvc/llvm-project?rev=306650&view=rev
Log:
[clang-tidy] follow-up on misc-definitions-in-header check.

Summary:
A follow-up on D34449:
* add `-std=c++11` to `.hpp` file by default.
* add constexpr function to test and doc.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere, xazax.hun, cfe-commits

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

Modified:

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst
clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst?rev=306650&r1=306649&r2=306650&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst 
(original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst 
Thu Jun 29 01:28:45 2017
@@ -82,6 +82,8 @@ from multiple translation units.
 
constexpr int k = 1; // OK: constexpr variable has internal linkage.
 
+   constexpr int f10() { return 0; } // OK: constexpr function definition.
+
 Options
 ---
 

Modified: clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py?rev=306650&r1=306649&r2=306650&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py (original)
+++ clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py Thu Jun 29 
01:28:45 2017
@@ -58,8 +58,8 @@ def main():
 
   clang_tidy_extra_args = extra_args
   if len(clang_tidy_extra_args) == 0:
-clang_tidy_extra_args = ['--', '--std=c++11'] if extension == '.cpp' \
-   else ['--']
+clang_tidy_extra_args = ['--', '--std=c++11'] \
+if extension == '.cpp' or extension == '.hpp' else ['--']
 
   # Tests should not rely on STL being available, and instead provide mock
   # implementations of relevant APIs.

Modified: 
clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp?rev=306650&r1=306649&r2=306650&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp Thu 
Jun 29 01:28:45 2017
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-definitions-in-headers %t -- -- -std=c++11
+// RUN: %check_clang_tidy %s misc-definitions-in-headers %t
 
 int f() {
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f' defined in a header 
file; function definitions in header files can lead to ODR violations 
[misc-definitions-in-headers]
@@ -177,3 +177,5 @@ int CD::f() { // OK: partial tem
 }
 
 constexpr int k = 1; // OK: constexpr variable has internal linkage.
+
+constexpr int f10() { return 0; } // OK: constexpr function definition.


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


[PATCH] D34771: [clang-tidy] follow-up on misc-definitions-in-header check.

2017-06-29 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL306650: [clang-tidy] follow-up on misc-definitions-in-header 
check. (authored by hokein).

Repository:
  rL LLVM

https://reviews.llvm.org/D34771

Files:
  clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst
  clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
  clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp


Index: 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst
===
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst
@@ -82,6 +82,8 @@
 
constexpr int k = 1; // OK: constexpr variable has internal linkage.
 
+   constexpr int f10() { return 0; } // OK: constexpr function definition.
+
 Options
 ---
 
Index: clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-definitions-in-headers %t -- -- -std=c++11
+// RUN: %check_clang_tidy %s misc-definitions-in-headers %t
 
 int f() {
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f' defined in a header 
file; function definitions in header files can lead to ODR violations 
[misc-definitions-in-headers]
@@ -177,3 +177,5 @@
 }
 
 constexpr int k = 1; // OK: constexpr variable has internal linkage.
+
+constexpr int f10() { return 0; } // OK: constexpr function definition.
Index: clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
===
--- clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
+++ clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
@@ -58,8 +58,8 @@
 
   clang_tidy_extra_args = extra_args
   if len(clang_tidy_extra_args) == 0:
-clang_tidy_extra_args = ['--', '--std=c++11'] if extension == '.cpp' \
-   else ['--']
+clang_tidy_extra_args = ['--', '--std=c++11'] \
+if extension == '.cpp' or extension == '.hpp' else ['--']
 
   # Tests should not rely on STL being available, and instead provide mock
   # implementations of relevant APIs.


Index: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst
@@ -82,6 +82,8 @@
 
constexpr int k = 1; // OK: constexpr variable has internal linkage.
 
+   constexpr int f10() { return 0; } // OK: constexpr function definition.
+
 Options
 ---
 
Index: clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-definitions-in-headers %t -- -- -std=c++11
+// RUN: %check_clang_tidy %s misc-definitions-in-headers %t
 
 int f() {
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f' defined in a header file; function definitions in header files can lead to ODR violations [misc-definitions-in-headers]
@@ -177,3 +177,5 @@
 }
 
 constexpr int k = 1; // OK: constexpr variable has internal linkage.
+
+constexpr int f10() { return 0; } // OK: constexpr function definition.
Index: clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
===
--- clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
+++ clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
@@ -58,8 +58,8 @@
 
   clang_tidy_extra_args = extra_args
   if len(clang_tidy_extra_args) == 0:
-clang_tidy_extra_args = ['--', '--std=c++11'] if extension == '.cpp' \
-   else ['--']
+clang_tidy_extra_args = ['--', '--std=c++11'] \
+if extension == '.cpp' or extension == '.hpp' else ['--']
 
   # Tests should not rely on STL being available, and instead provide mock
   # implementations of relevant APIs.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r306651 - [clang-tidy] Fix modernize-use-nullptr only warns the first NULL argument.

2017-06-29 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Jun 29 01:43:36 2017
New Revision: 306651

URL: http://llvm.org/viewvc/llvm-project?rev=306651&view=rev
Log:
[clang-tidy] Fix modernize-use-nullptr only warns the first NULL argument.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: xazax.hun, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp?rev=306651&r1=306650&r2=306651&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp Thu Jun 29 
01:43:36 2017
@@ -235,7 +235,7 @@ public:
   allArgUsesValid(C)) {
 replaceWithNullptr(Check, SM, FileLocStart, FileLocEnd);
   }
-  return skipSubTree();
+  return true;
 }
 
 if (SM.isMacroBodyExpansion(StartLoc) && SM.isMacroBodyExpansion(EndLoc)) {

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp?rev=306651&r1=306650&r2=306651&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp Thu Jun 
29 01:43:36 2017
@@ -275,3 +275,31 @@ void test_cast_nullptr() {
   G(g(static_cast(nullptr)));
   G(g(static_cast(nullptr)));
 }
+
+// Test on recognizing multiple NULLs.
+class H {
+public:
+  H(bool);
+};
+
+#define T(expression) H(expression);
+bool h(int *, int *, int * = nullptr);
+void test_multiple_nulls() {
+  T(h(NULL, NULL));
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use nullptr
+// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: use nullptr
+// CHECK-FIXES: T(h(nullptr, nullptr));
+  T(h(NULL, nullptr));
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use nullptr
+// CHECK-FIXES: T(h(nullptr, nullptr));
+  T(h(nullptr, NULL));
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use nullptr
+// CHECK-FIXES: T(h(nullptr, nullptr));
+  T(h(nullptr, nullptr));
+  T(h(NULL, NULL, NULL));
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use nullptr
+// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: use nullptr
+// CHECK-MESSAGES: :[[@LINE-3]]:19: warning: use nullptr
+// CHECK-FIXES: T(h(nullptr, nullptr, nullptr));
+}
+#undef T


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


[clang-tools-extra] r306652 - [clangd] Added a test, checking that gcc install is searched via VFS.

2017-06-29 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Thu Jun 29 01:43:51 2017
New Revision: 306652

URL: http://llvm.org/viewvc/llvm-project?rev=306652&view=rev
Log:
[clangd] Added a test, checking that gcc install is searched via VFS.

Reviewers: bkramer, krasimir, klimek

Reviewed By: klimek

Subscribers: klimek, cfe-commits

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

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

Modified: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp?rev=306652&r1=306651&r2=306652&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp Thu Jun 29 
01:43:51 2017
@@ -166,8 +166,22 @@ class MockCompilationDatabase : public G
 public:
   std::vector
   getCompileCommands(PathRef File) override {
-return {};
+if (ExtraClangFlags.empty())
+  return {};
+
+std::vector CommandLine;
+CommandLine.reserve(3 + ExtraClangFlags.size());
+CommandLine.insert(CommandLine.end(), {"clang", "-fsyntax-only"});
+CommandLine.insert(CommandLine.end(), ExtraClangFlags.begin(),
+   ExtraClangFlags.end());
+CommandLine.push_back(File.str());
+
+return {tooling::CompileCommand(llvm::sys::path::parent_path(File),
+llvm::sys::path::filename(File),
+CommandLine, "")};
   }
+
+  std::vector ExtraClangFlags;
 };
 
 class MockFSProvider : public FileSystemProvider {
@@ -394,6 +408,53 @@ TEST_F(ClangdVFSTest, CheckVersions) {
   EXPECT_EQ(Server.codeComplete(FooCpp, Position{0, 0}).Tag, FS.Tag);
 }
 
+TEST_F(ClangdVFSTest, SearchLibDir) {
+  // Checks that searches for GCC installation is done through vfs.
+  MockFSProvider FS;
+  ErrorCheckingDiagConsumer DiagConsumer;
+  MockCompilationDatabase CDB;
+  CDB.ExtraClangFlags = {"-xc++", "-target", "x86_64-linux-unknown", "-m64"};
+  ClangdServer Server(CDB, DiagConsumer, FS,
+  /*RunSynchronously=*/true);
+
+  // Just a random gcc version string
+  SmallString<8> Version("4.9.3");
+
+  // A lib dir for gcc installation
+  SmallString<64> LibDir("/usr/lib/gcc/x86_64-linux-gnu");
+  llvm::sys::path::append(LibDir, Version);
+
+  // Put crtbegin.o into LibDir/64 to trick clang into thinking there's a gcc
+  // installation there.
+  SmallString<64> DummyLibFile;
+  llvm::sys::path::append(DummyLibFile, LibDir, "64", "crtbegin.o");
+  FS.Files[DummyLibFile] = "";
+
+  SmallString<64> IncludeDir("/usr/include/c++");
+  llvm::sys::path::append(IncludeDir, Version);
+
+  SmallString<64> StringPath;
+  llvm::sys::path::append(StringPath, IncludeDir, "string");
+  FS.Files[StringPath] = "class mock_string {};";
+
+  auto FooCpp = getVirtualTestFilePath("foo.cpp");
+  const auto SourceContents = R"cpp(
+#include 
+mock_string x;
+)cpp";
+  FS.Files[FooCpp] = SourceContents;
+
+  Server.addDocument(FooCpp, SourceContents);
+  EXPECT_FALSE(DiagConsumer.hadErrorInLastDiags());
+
+  const auto SourceContentsWithError = R"cpp(
+#include 
+std::string x;
+)cpp";
+  Server.addDocument(FooCpp, SourceContentsWithError);
+  EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
+}
+
 class ClangdCompletionTest : public ClangdVFSTest {
 protected:
   bool ContainsItem(std::vector const &Items, StringRef Name) {


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


[PATCH] D34755: [clangd] Added a test, checking that gcc install is searched via VFS.

2017-06-29 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL306652: [clangd] Added a test, checking that gcc install is 
searched via VFS. (authored by ibiryukov).

Repository:
  rL LLVM

https://reviews.llvm.org/D34755

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


Index: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
@@ -166,8 +166,22 @@
 public:
   std::vector
   getCompileCommands(PathRef File) override {
-return {};
+if (ExtraClangFlags.empty())
+  return {};
+
+std::vector CommandLine;
+CommandLine.reserve(3 + ExtraClangFlags.size());
+CommandLine.insert(CommandLine.end(), {"clang", "-fsyntax-only"});
+CommandLine.insert(CommandLine.end(), ExtraClangFlags.begin(),
+   ExtraClangFlags.end());
+CommandLine.push_back(File.str());
+
+return {tooling::CompileCommand(llvm::sys::path::parent_path(File),
+llvm::sys::path::filename(File),
+CommandLine, "")};
   }
+
+  std::vector ExtraClangFlags;
 };
 
 class MockFSProvider : public FileSystemProvider {
@@ -394,6 +408,53 @@
   EXPECT_EQ(Server.codeComplete(FooCpp, Position{0, 0}).Tag, FS.Tag);
 }
 
+TEST_F(ClangdVFSTest, SearchLibDir) {
+  // Checks that searches for GCC installation is done through vfs.
+  MockFSProvider FS;
+  ErrorCheckingDiagConsumer DiagConsumer;
+  MockCompilationDatabase CDB;
+  CDB.ExtraClangFlags = {"-xc++", "-target", "x86_64-linux-unknown", "-m64"};
+  ClangdServer Server(CDB, DiagConsumer, FS,
+  /*RunSynchronously=*/true);
+
+  // Just a random gcc version string
+  SmallString<8> Version("4.9.3");
+
+  // A lib dir for gcc installation
+  SmallString<64> LibDir("/usr/lib/gcc/x86_64-linux-gnu");
+  llvm::sys::path::append(LibDir, Version);
+
+  // Put crtbegin.o into LibDir/64 to trick clang into thinking there's a gcc
+  // installation there.
+  SmallString<64> DummyLibFile;
+  llvm::sys::path::append(DummyLibFile, LibDir, "64", "crtbegin.o");
+  FS.Files[DummyLibFile] = "";
+
+  SmallString<64> IncludeDir("/usr/include/c++");
+  llvm::sys::path::append(IncludeDir, Version);
+
+  SmallString<64> StringPath;
+  llvm::sys::path::append(StringPath, IncludeDir, "string");
+  FS.Files[StringPath] = "class mock_string {};";
+
+  auto FooCpp = getVirtualTestFilePath("foo.cpp");
+  const auto SourceContents = R"cpp(
+#include 
+mock_string x;
+)cpp";
+  FS.Files[FooCpp] = SourceContents;
+
+  Server.addDocument(FooCpp, SourceContents);
+  EXPECT_FALSE(DiagConsumer.hadErrorInLastDiags());
+
+  const auto SourceContentsWithError = R"cpp(
+#include 
+std::string x;
+)cpp";
+  Server.addDocument(FooCpp, SourceContentsWithError);
+  EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
+}
+
 class ClangdCompletionTest : public ClangdVFSTest {
 protected:
   bool ContainsItem(std::vector const &Items, StringRef Name) {


Index: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
@@ -166,8 +166,22 @@
 public:
   std::vector
   getCompileCommands(PathRef File) override {
-return {};
+if (ExtraClangFlags.empty())
+  return {};
+
+std::vector CommandLine;
+CommandLine.reserve(3 + ExtraClangFlags.size());
+CommandLine.insert(CommandLine.end(), {"clang", "-fsyntax-only"});
+CommandLine.insert(CommandLine.end(), ExtraClangFlags.begin(),
+   ExtraClangFlags.end());
+CommandLine.push_back(File.str());
+
+return {tooling::CompileCommand(llvm::sys::path::parent_path(File),
+llvm::sys::path::filename(File),
+CommandLine, "")};
   }
+
+  std::vector ExtraClangFlags;
 };
 
 class MockFSProvider : public FileSystemProvider {
@@ -394,6 +408,53 @@
   EXPECT_EQ(Server.codeComplete(FooCpp, Position{0, 0}).Tag, FS.Tag);
 }
 
+TEST_F(ClangdVFSTest, SearchLibDir) {
+  // Checks that searches for GCC installation is done through vfs.
+  MockFSProvider FS;
+  ErrorCheckingDiagConsumer DiagConsumer;
+  MockCompilationDatabase CDB;
+  CDB.ExtraClangFlags = {"-xc++", "-target", "x86_64-linux-unknown", "-m64"};
+  ClangdServer Server(CDB, DiagConsumer, FS,
+  /*RunSynchronously=*/true);
+
+  // Just a random gcc version string
+  SmallString<8> Version("4.9.3");
+
+  // A lib dir for gcc installation
+  SmallString<64> LibDir("/usr/lib/gcc/x86_64-linux-gnu");
+  llvm::sys::path::append(LibDir, Version);
+
+  // Put crtbegin.o into LibDir/64 to trick clang into thinking there's a gcc
+  // installation there.
+  SmallString<64> DummyLibFile;
+

r306653 - [OpenCL] Allow function declaration with empty argument list.

2017-06-29 Thread Alexey Bader via cfe-commits
Author: bader
Date: Thu Jun 29 01:44:10 2017
New Revision: 306653

URL: http://llvm.org/viewvc/llvm-project?rev=306653&view=rev
Log:
[OpenCL] Allow function declaration with empty argument list.

Summary:
does it make sense to enable K&R function declaration style for OpenCL?
clang throws following error message for the declaration w/o arguments:

```
int my_func();
error: function with no prototype cannot use the spir_function calling 
convention
```

Current way to fix this issue is to specify that parameter list is empty by 
using 'void':

```
int my_func(void);
```

Let me know what do you think about this patch.

Reviewers: Anastasia, yaxunl

Reviewed By: Anastasia

Subscribers: cfe-commits, echuraev

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

Added:
cfe/trunk/test/SemaOpenCL/function-no-args.cl
Modified:
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=306653&r1=306652&r2=306653&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Thu Jun 29 01:44:10 2017
@@ -4355,7 +4355,7 @@ static TypeSourceInfo *GetFullTypeForDec
 
   FunctionType::ExtInfo EI(getCCForDeclaratorChunk(S, D, FTI, chunkIndex));
 
-  if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus) {
+  if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus  && 
!LangOpts.OpenCL) {
 // Simple void foo(), where the incoming T is the result type.
 T = Context.getFunctionNoProtoType(T, EI);
   } else {

Added: cfe/trunk/test/SemaOpenCL/function-no-args.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/function-no-args.cl?rev=306653&view=auto
==
--- cfe/trunk/test/SemaOpenCL/function-no-args.cl (added)
+++ cfe/trunk/test/SemaOpenCL/function-no-args.cl Thu Jun 29 01:44:10 2017
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -verify -pedantic -fsyntax-only -cl-std=CL2.0 %s
+// expected-no-diagnostics
+
+global int gi;
+int my_func();
+int my_func() {
+  gi = 2;
+  return gi;
+}

Modified: cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl?rev=306653&r1=306652&r2=306653&view=diff
==
--- cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl (original)
+++ cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl Thu Jun 29 01:44:10 2017
@@ -3,7 +3,7 @@
 global pipe int gp;// expected-error {{type '__global read_only 
pipe int' can only be used as a function parameter in OpenCL}}
 global reserve_id_t rid;  // expected-error {{the '__global 
reserve_id_t' type cannot be used to declare a program scope variable}}
 
-extern pipe write_only int get_pipe(); // expected-error {{type '__global 
write_only pipe int ()' can only be used as a function parameter in OpenCL}}
+extern pipe write_only int get_pipe(); // expected-error {{type '__global 
write_only pipe int (void)' can only be used as a function parameter in OpenCL}}
 
 kernel void test_invalid_reserved_id(reserve_id_t ID) { // expected-error 
{{'reserve_id_t' cannot be used as the type of a kernel parameter}}
 }


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


[PATCH] D34526: [clang-tidy] Fix modernize-use-nullptr only warns the first NULL argument.

2017-06-29 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL306651: [clang-tidy] Fix modernize-use-nullptr only warns 
the first NULL argument. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D34526?vs=103618&id=104607#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34526

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp


Index: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -235,7 +235,7 @@
   allArgUsesValid(C)) {
 replaceWithNullptr(Check, SM, FileLocStart, FileLocEnd);
   }
-  return skipSubTree();
+  return true;
 }
 
 if (SM.isMacroBodyExpansion(StartLoc) && SM.isMacroBodyExpansion(EndLoc)) {
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
@@ -275,3 +275,31 @@
   G(g(static_cast(nullptr)));
   G(g(static_cast(nullptr)));
 }
+
+// Test on recognizing multiple NULLs.
+class H {
+public:
+  H(bool);
+};
+
+#define T(expression) H(expression);
+bool h(int *, int *, int * = nullptr);
+void test_multiple_nulls() {
+  T(h(NULL, NULL));
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use nullptr
+// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: use nullptr
+// CHECK-FIXES: T(h(nullptr, nullptr));
+  T(h(NULL, nullptr));
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use nullptr
+// CHECK-FIXES: T(h(nullptr, nullptr));
+  T(h(nullptr, NULL));
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use nullptr
+// CHECK-FIXES: T(h(nullptr, nullptr));
+  T(h(nullptr, nullptr));
+  T(h(NULL, NULL, NULL));
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use nullptr
+// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: use nullptr
+// CHECK-MESSAGES: :[[@LINE-3]]:19: warning: use nullptr
+// CHECK-FIXES: T(h(nullptr, nullptr, nullptr));
+}
+#undef T


Index: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -235,7 +235,7 @@
   allArgUsesValid(C)) {
 replaceWithNullptr(Check, SM, FileLocStart, FileLocEnd);
   }
-  return skipSubTree();
+  return true;
 }
 
 if (SM.isMacroBodyExpansion(StartLoc) && SM.isMacroBodyExpansion(EndLoc)) {
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
@@ -275,3 +275,31 @@
   G(g(static_cast(nullptr)));
   G(g(static_cast(nullptr)));
 }
+
+// Test on recognizing multiple NULLs.
+class H {
+public:
+  H(bool);
+};
+
+#define T(expression) H(expression);
+bool h(int *, int *, int * = nullptr);
+void test_multiple_nulls() {
+  T(h(NULL, NULL));
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use nullptr
+// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: use nullptr
+// CHECK-FIXES: T(h(nullptr, nullptr));
+  T(h(NULL, nullptr));
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use nullptr
+// CHECK-FIXES: T(h(nullptr, nullptr));
+  T(h(nullptr, NULL));
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use nullptr
+// CHECK-FIXES: T(h(nullptr, nullptr));
+  T(h(nullptr, nullptr));
+  T(h(NULL, NULL, NULL));
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use nullptr
+// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: use nullptr
+// CHECK-MESSAGES: :[[@LINE-3]]:19: warning: use nullptr
+// CHECK-FIXES: T(h(nullptr, nullptr, nullptr));
+}
+#undef T
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33816: [Sema][ObjC] Don't allow -Wunguarded-availability to be silenced with redeclarations

2017-06-29 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM. One last comment below:




Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2880
   InGroup;
 def note_partial_availability_silence : Note<
+  "annotate %0 with an availability attribute to silence">;

I think that you can just use one note and select the text, e.g.

```
def note_partial_availability_silence : Note<
  "annotate %select{%1|anonymous %0}0 with an availability attribute to 
silence">;
```

And use it like:

```
enum class PartialAvailabilityNoteKind {
  Named,
  Anonymous
};

...

S.Diag(Enclosing->getLocation(), diag::note_partial_availability_silence)
  <<  PartialAvailabilityNoteKind::Named << Enclosing;

```




https://reviews.llvm.org/D33816



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


[clang-tools-extra] r306656 - [clangd] Run a test, searching for gcc install, only on Unix.

2017-06-29 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Thu Jun 29 02:22:32 2017
New Revision: 306656

URL: http://llvm.org/viewvc/llvm-project?rev=306656&view=rev
Log:
[clangd] Run a test, searching for gcc install, only on Unix.

This should fix windows buildbots.

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

Modified: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp?rev=306656&r1=306655&r2=306656&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp Thu Jun 29 
02:22:32 2017
@@ -408,6 +408,8 @@ TEST_F(ClangdVFSTest, CheckVersions) {
   EXPECT_EQ(Server.codeComplete(FooCpp, Position{0, 0}).Tag, FS.Tag);
 }
 
+// Only enable this test on Unix
+#ifdef LLVM_ON_UNIX
 TEST_F(ClangdVFSTest, SearchLibDir) {
   // Checks that searches for GCC installation is done through vfs.
   MockFSProvider FS;
@@ -454,6 +456,7 @@ std::string x;
   Server.addDocument(FooCpp, SourceContentsWithError);
   EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
 }
+#endif // LLVM_ON_UNIX
 
 class ClangdCompletionTest : public ClangdVFSTest {
 protected:


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


[PATCH] D34696: [refactor] Move the core of clang-rename to lib/Tooling/Refactoring

2017-06-29 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In https://reviews.llvm.org/D34696#793613, @klimek wrote:

> The main thing I'm concerned about is having the main code in core, but 
> having all tests in tools-extra. I think if we go that route we should also 
> move clang-rename and its tests to core. Thoughts?


Would it be better if I make a patch for the `clang-refactor` tool first and 
then update this patch to support some of clang-rename's functionality in 
clang-refactor and move the tests over? Or should I just move all of 
clang-rename and its tests to clang's repository first and then focus on 
clang-refactor?


Repository:
  rL LLVM

https://reviews.llvm.org/D34696



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


[PATCH] D34696: [refactor] Move the core of clang-rename to lib/Tooling/Refactoring

2017-06-29 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

In https://reviews.llvm.org/D34696#795020, @arphaman wrote:

> In https://reviews.llvm.org/D34696#793613, @klimek wrote:
>
> > The main thing I'm concerned about is having the main code in core, but 
> > having all tests in tools-extra. I think if we go that route we should also 
> > move clang-rename and its tests to core. Thoughts?
>
>
> Would it be better if I make a patch for the `clang-refactor` tool first and 
> then update this patch to support some of clang-rename's functionality in 
> clang-refactor and move the tests over? Or should I just move all of 
> clang-rename and its tests to clang's repository first and then focus on 
> clang-refactor?


Given the end goal is clear, I'm fine with either :)


Repository:
  rL LLVM

https://reviews.llvm.org/D34696



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


[PATCH] D34687: [Tooling] CompilationDatabase should be able to strip position arguments when `-fsyntax-only` is used

2017-06-29 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL306659: [Tooling] FixedCompilationDatabase should be able to 
strip positional (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D34687?vs=104161&id=104618#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34687

Files:
  cfe/trunk/lib/Tooling/CompilationDatabase.cpp
  cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp


Index: cfe/trunk/lib/Tooling/CompilationDatabase.cpp
===
--- cfe/trunk/lib/Tooling/CompilationDatabase.cpp
+++ cfe/trunk/lib/Tooling/CompilationDatabase.cpp
@@ -255,10 +255,12 @@
   CompileJobAnalyzer CompileAnalyzer;
 
   for (const auto &Cmd : Jobs) {
-// Collect only for Assemble jobs. If we do all jobs we get duplicates
-// since Link jobs point to Assemble jobs as inputs.
-if (Cmd.getSource().getKind() == driver::Action::AssembleJobClass)
+// Collect only for Assemble and Compile jobs. If we do all jobs we get
+// duplicates since Link jobs point to Assemble jobs as inputs.
+if (Cmd.getSource().getKind() == driver::Action::AssembleJobClass ||
+Cmd.getSource().getKind() == driver::Action::CompileJobClass) {
   CompileAnalyzer.run(&Cmd.getSource());
+}
   }
 
   if (CompileAnalyzer.Inputs.empty()) {
Index: cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp
+++ cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -586,6 +586,27 @@
   EXPECT_EQ(2, Argc);
 }
 
+TEST(ParseFixedCompilationDatabase, HandlesPositionalArgsSyntaxOnly) {
+  // Adjust the given command line arguments to ensure that any positional
+  // arguments in them are stripped.
+  const char *Argv[] = {"--", "somefile.cpp", "-fsyntax-only", "-DDEF3"};
+  int Argc = llvm::array_lengthof(Argv);
+  std::string ErrorMessage;
+  std::unique_ptr Database =
+  FixedCompilationDatabase::loadFromCommandLine(Argc, Argv, ErrorMessage);
+  ASSERT_TRUE((bool)Database);
+  ASSERT_TRUE(ErrorMessage.empty());
+  std::vector Result = Database->getCompileCommands("source");
+  ASSERT_EQ(1ul, Result.size());
+  ASSERT_EQ(".", Result[0].Directory);
+  std::vector Expected;
+  Expected.push_back("clang-tool");
+  Expected.push_back("-fsyntax-only");
+  Expected.push_back("-DDEF3");
+  Expected.push_back("source");
+  ASSERT_EQ(Expected, Result[0].CommandLine);
+}
+
 TEST(ParseFixedCompilationDatabase, HandlesArgv0) {
   const char *Argv[] = {"1", "2", "--", "mytool", "somefile.cpp"};
   int Argc = sizeof(Argv) / sizeof(char*);


Index: cfe/trunk/lib/Tooling/CompilationDatabase.cpp
===
--- cfe/trunk/lib/Tooling/CompilationDatabase.cpp
+++ cfe/trunk/lib/Tooling/CompilationDatabase.cpp
@@ -255,10 +255,12 @@
   CompileJobAnalyzer CompileAnalyzer;
 
   for (const auto &Cmd : Jobs) {
-// Collect only for Assemble jobs. If we do all jobs we get duplicates
-// since Link jobs point to Assemble jobs as inputs.
-if (Cmd.getSource().getKind() == driver::Action::AssembleJobClass)
+// Collect only for Assemble and Compile jobs. If we do all jobs we get
+// duplicates since Link jobs point to Assemble jobs as inputs.
+if (Cmd.getSource().getKind() == driver::Action::AssembleJobClass ||
+Cmd.getSource().getKind() == driver::Action::CompileJobClass) {
   CompileAnalyzer.run(&Cmd.getSource());
+}
   }
 
   if (CompileAnalyzer.Inputs.empty()) {
Index: cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp
+++ cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -586,6 +586,27 @@
   EXPECT_EQ(2, Argc);
 }
 
+TEST(ParseFixedCompilationDatabase, HandlesPositionalArgsSyntaxOnly) {
+  // Adjust the given command line arguments to ensure that any positional
+  // arguments in them are stripped.
+  const char *Argv[] = {"--", "somefile.cpp", "-fsyntax-only", "-DDEF3"};
+  int Argc = llvm::array_lengthof(Argv);
+  std::string ErrorMessage;
+  std::unique_ptr Database =
+  FixedCompilationDatabase::loadFromCommandLine(Argc, Argv, ErrorMessage);
+  ASSERT_TRUE((bool)Database);
+  ASSERT_TRUE(ErrorMessage.empty());
+  std::vector Result = Database->getCompileCommands("source");
+  ASSERT_EQ(1ul, Result.size());
+  ASSERT_EQ(".", Result[0].Directory);
+  std::vector Expected;
+  Expected.push_back("clang-tool");
+  Expected.push_back("-fsyntax-only");
+  Expected.push_back("-DDEF3");
+  Expected.push_back("source");
+  ASSERT_EQ(Expected, Result[0].CommandLine);
+}
+
 TEST(ParseFixedCompilationDatabase, HandlesArgv0) {
   const char *Argv[] = {"1", "2", "--", "mytool", "somefile.cpp"};
   int Argc = sizeof(Argv) / sizeof(char*);
___

r306659 - [Tooling] FixedCompilationDatabase should be able to strip positional

2017-06-29 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Jun 29 03:43:44 2017
New Revision: 306659

URL: http://llvm.org/viewvc/llvm-project?rev=306659&view=rev
Log:
[Tooling] FixedCompilationDatabase should be able to strip positional
arguments when `-fsyntax-only` is used

Previously, Clang failed to create a fixed compilation database when the
compilation arguments use -fsyntax-only instead of -c. This commit fixes the
issue by forcing Clang to look at the compilation job when stripping the
positional arguments.

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

Modified:
cfe/trunk/lib/Tooling/CompilationDatabase.cpp
cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp

Modified: cfe/trunk/lib/Tooling/CompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CompilationDatabase.cpp?rev=306659&r1=306658&r2=306659&view=diff
==
--- cfe/trunk/lib/Tooling/CompilationDatabase.cpp (original)
+++ cfe/trunk/lib/Tooling/CompilationDatabase.cpp Thu Jun 29 03:43:44 2017
@@ -255,10 +255,12 @@ static bool stripPositionalArgs(std::vec
   CompileJobAnalyzer CompileAnalyzer;
 
   for (const auto &Cmd : Jobs) {
-// Collect only for Assemble jobs. If we do all jobs we get duplicates
-// since Link jobs point to Assemble jobs as inputs.
-if (Cmd.getSource().getKind() == driver::Action::AssembleJobClass)
+// Collect only for Assemble and Compile jobs. If we do all jobs we get
+// duplicates since Link jobs point to Assemble jobs as inputs.
+if (Cmd.getSource().getKind() == driver::Action::AssembleJobClass ||
+Cmd.getSource().getKind() == driver::Action::CompileJobClass) {
   CompileAnalyzer.run(&Cmd.getSource());
+}
   }
 
   if (CompileAnalyzer.Inputs.empty()) {

Modified: cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp?rev=306659&r1=306658&r2=306659&view=diff
==
--- cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp Thu Jun 29 03:43:44 
2017
@@ -586,6 +586,27 @@ TEST(ParseFixedCompilationDatabase, Hand
   EXPECT_EQ(2, Argc);
 }
 
+TEST(ParseFixedCompilationDatabase, HandlesPositionalArgsSyntaxOnly) {
+  // Adjust the given command line arguments to ensure that any positional
+  // arguments in them are stripped.
+  const char *Argv[] = {"--", "somefile.cpp", "-fsyntax-only", "-DDEF3"};
+  int Argc = llvm::array_lengthof(Argv);
+  std::string ErrorMessage;
+  std::unique_ptr Database =
+  FixedCompilationDatabase::loadFromCommandLine(Argc, Argv, ErrorMessage);
+  ASSERT_TRUE((bool)Database);
+  ASSERT_TRUE(ErrorMessage.empty());
+  std::vector Result = Database->getCompileCommands("source");
+  ASSERT_EQ(1ul, Result.size());
+  ASSERT_EQ(".", Result[0].Directory);
+  std::vector Expected;
+  Expected.push_back("clang-tool");
+  Expected.push_back("-fsyntax-only");
+  Expected.push_back("-DDEF3");
+  Expected.push_back("source");
+  ASSERT_EQ(Expected, Result[0].CommandLine);
+}
+
 TEST(ParseFixedCompilationDatabase, HandlesArgv0) {
   const char *Argv[] = {"1", "2", "--", "mytool", "somefile.cpp"};
   int Argc = sizeof(Argv) / sizeof(char*);


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


r306660 - Revert r306653, "[OpenCL] Allow function declaration with empty argument list."

2017-06-29 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Thu Jun 29 03:47:23 2017
New Revision: 306660

URL: http://llvm.org/viewvc/llvm-project?rev=306660&view=rev
Log:
Revert r306653, "[OpenCL] Allow function declaration with empty argument list."

It broke bots.

Removed:
cfe/trunk/test/SemaOpenCL/function-no-args.cl
Modified:
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=306660&r1=306659&r2=306660&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Thu Jun 29 03:47:23 2017
@@ -4355,7 +4355,7 @@ static TypeSourceInfo *GetFullTypeForDec
 
   FunctionType::ExtInfo EI(getCCForDeclaratorChunk(S, D, FTI, chunkIndex));
 
-  if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus  && 
!LangOpts.OpenCL) {
+  if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus) {
 // Simple void foo(), where the incoming T is the result type.
 T = Context.getFunctionNoProtoType(T, EI);
   } else {

Removed: cfe/trunk/test/SemaOpenCL/function-no-args.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/function-no-args.cl?rev=306659&view=auto
==
--- cfe/trunk/test/SemaOpenCL/function-no-args.cl (original)
+++ cfe/trunk/test/SemaOpenCL/function-no-args.cl (removed)
@@ -1,9 +0,0 @@
-// RUN: %clang_cc1 -verify -pedantic -fsyntax-only -cl-std=CL2.0 %s
-// expected-no-diagnostics
-
-global int gi;
-int my_func();
-int my_func() {
-  gi = 2;
-  return gi;
-}

Modified: cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl?rev=306660&r1=306659&r2=306660&view=diff
==
--- cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl (original)
+++ cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl Thu Jun 29 03:47:23 2017
@@ -3,7 +3,7 @@
 global pipe int gp;// expected-error {{type '__global read_only 
pipe int' can only be used as a function parameter in OpenCL}}
 global reserve_id_t rid;  // expected-error {{the '__global 
reserve_id_t' type cannot be used to declare a program scope variable}}
 
-extern pipe write_only int get_pipe(); // expected-error {{type '__global 
write_only pipe int (void)' can only be used as a function parameter in OpenCL}}
+extern pipe write_only int get_pipe(); // expected-error {{type '__global 
write_only pipe int ()' can only be used as a function parameter in OpenCL}}
 
 kernel void test_invalid_reserved_id(reserve_id_t ID) { // expected-error 
{{'reserve_id_t' cannot be used as the type of a kernel parameter}}
 }


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


[PATCH] D33681: [OpenCL] Allow function declaration with empty argument list.

2017-06-29 Thread NAKAMURA Takumi via Phabricator via cfe-commits
chapuni reopened this revision.
chapuni added a comment.
This revision is now accepted and ready to land.

Reverted in https://reviews.llvm.org/rL306660.
See also; http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/4926


https://reviews.llvm.org/D33681



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


RE: D34158: to support gcc 4.8 (and newer) compatibility on Linux, preinclude

2017-06-29 Thread Hahnfeld, Jonas via cfe-commits
Hi,

-Original Message-
From: Blower, Melanie [mailto:melanie.blo...@intel.com]
Sent: Thursday, June 29, 2017 5:35 AM
To: reviews+d34158+public+125da21f27579...@reviews.llvm.org; 
zhangsheng...@huawei.com; olivier...@gmail.com; kalinichev.s...@gmail.com; 
kf...@kde.org; m...@milianw.de; Keane, Erich ; 
Hahnfeld, Jonas ; mgo...@gentoo.org; 
fedor.serg...@oracle.com; rich...@metafoo.co.uk; renato.go...@linaro.org
Cc: cfe-commits@lists.llvm.org; kli...@google.com; simon.dar...@imgtec.com; 
anastasia.stul...@arm.com; arichardson@gmail.com
Subject: RE: D34158: to support gcc 4.8 (and newer) compatibility on Linux, 
preinclude 

[...]


Comment at: test/Driver/gcc-predef.c:9
+  #else
+#if !defined(  _STDC_PREDEF_H )
+  #error "stdc-predef.h should be preincluded for GNU/Linux 4.8 and 
higher"

The driver will only include `stdc-predef.h` if it can be found in the system. 
With that, the current version of this test will only run on such Linux 
system. Maybe add a basic tree in `test/Driver/Inputs` and test that the 
corresponding header is included?
>>>OK I understand what you mean now.

To be clear here: I was thinking about running this test case on let's say 
Darwin/Mac OS X != GNU/Linux. But you probably figured that out of my 
imprecise comment already. Sorry about that.

Regards,
Jonas


smime.p7s
Description: S/MIME cryptographic signature
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34810: [Sema] -Wcomma should not warn for expression that return void

2017-06-29 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

Right now -Wcomma is too strict IMO, we shouldn't warn about expressions that 
return void.


Repository:
  rL LLVM

https://reviews.llvm.org/D34810

Files:
  lib/Sema/SemaExpr.cpp
  test/SemaCXX/warn-comma-operator.cpp


Index: test/SemaCXX/warn-comma-operator.cpp
===
--- test/SemaCXX/warn-comma-operator.cpp
+++ test/SemaCXX/warn-comma-operator.cpp
@@ -276,3 +276,13 @@
   // CHECK: fix-it:{{.*}}:{[[@LINE-7]]:33-[[@LINE-7]]:33}:"static_cast("
   // CHECK: fix-it:{{.*}}:{[[@LINE-8]]:46-[[@LINE-8]]:46}:")"
 }
+
+void returnsVoid();
+
+void noWarningForVoidReturns(int x) {
+  returnsVoid(), x = 0;
+  returnsVoid(),
+  return_four(), // expected-warning {{possible misuse of comma operator 
here}} \
+expected-note{{cast expression to void}}
+  returnsVoid();
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -10648,6 +10648,8 @@
   return true;
 }
   }
+  if (E->getType()->isVoidType())
+return true;
 
   return false;
 }


Index: test/SemaCXX/warn-comma-operator.cpp
===
--- test/SemaCXX/warn-comma-operator.cpp
+++ test/SemaCXX/warn-comma-operator.cpp
@@ -276,3 +276,13 @@
   // CHECK: fix-it:{{.*}}:{[[@LINE-7]]:33-[[@LINE-7]]:33}:"static_cast("
   // CHECK: fix-it:{{.*}}:{[[@LINE-8]]:46-[[@LINE-8]]:46}:")"
 }
+
+void returnsVoid();
+
+void noWarningForVoidReturns(int x) {
+  returnsVoid(), x = 0;
+  returnsVoid(),
+  return_four(), // expected-warning {{possible misuse of comma operator here}} \
+expected-note{{cast expression to void}}
+  returnsVoid();
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -10648,6 +10648,8 @@
   return true;
 }
   }
+  if (E->getType()->isVoidType())
+return true;
 
   return false;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34766: fix NSAPI constants to reflect the current state of NSStringMethodKind/NSDictionaryMethodKind enums

2017-06-29 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

LGTM, Thanks! Do you have commit access?


https://reviews.llvm.org/D34766



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


[PATCH] D33932: [clang-format] Add support for case-insensitive header matching and use it to improve support for LLVM-style include sorting.

2017-06-29 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good. Thank you.


https://reviews.llvm.org/D33932



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


[PATCH] D34749: [clang-format] Fix parsing of msg{field}-style proto options

2017-06-29 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good.


https://reviews.llvm.org/D34749



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


[PATCH] D33681: [OpenCL] Allow function declaration with empty argument list.

2017-06-29 Thread Alexey Bader via Phabricator via cfe-commits
bader added a comment.

@chapuni, thanks for taking care of this. I'll take a look.


https://reviews.llvm.org/D33681



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


[PATCH] D31697: Check for null before using TUScope

2017-06-29 Thread Kim Gräsman via Phabricator via cfe-commits
kimgr added a comment.

I did some more debugging today. This happens when we attempt to analyze 
llvm/Support/MathExtras.h, and only for the function templates that use 
Microsoft intrinsics (e.g. `_BitScanForward` in `TrailingZerosCounter`.) So 
there's something in the parsing of builtins/intrinsics that requires `TUScope` 
to be non-null.

Can we seed Sema with a valid `TUScope` before invoking `LateTemplateParser`, 
and if so, how? Or is this because we invoke the parser multiple times? I'm 
guessing Clang is already done parsing when we invoke the late template parsing.

Grateful for any ideas here.


https://reviews.llvm.org/D31697



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


[PATCH] D34510: Teach clang how to merge typedef over anonymous structs in C mode.

2017-06-29 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

@bruno ping...


Repository:
  rL LLVM

https://reviews.llvm.org/D34510



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


[PATCH] D34766: fix NSAPI constants to reflect the current state of NSStringMethodKind/NSDictionaryMethodKind enums

2017-06-29 Thread Vladimir Voskresensky via Phabricator via cfe-commits
voskresensky.vladimir added a comment.

In https://reviews.llvm.org/D34766#795087, @arphaman wrote:

> LGTM, Thanks! Do you have commit access?


No. Could you commit, please. Thanks!


https://reviews.llvm.org/D34766



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


[PATCH] D32478: [clang-format] Fix AlignOperands when BreakBeforeBinaryOperators is set

2017-06-29 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added inline comments.



Comment at: include/clang/Format/Format.h:167
+/// \endcode
+OAS_StrictAlign,
+  };

djasper wrote:
> The name is not intuitive. I don't think this is any more or less strict than 
> the other version.
It is a bit stricter in the sense that it really aligns operands, not operator 
with first operand... But this is indeed not very intuitive.

Any suggestion?


https://reviews.llvm.org/D32478



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


r306672 - [clang-format] Fix parsing of msg{field}-style proto options

2017-06-29 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Thu Jun 29 06:30:41 2017
New Revision: 306672

URL: http://llvm.org/viewvc/llvm-project?rev=306672&view=rev
Log:
[clang-format] Fix parsing of msg{field}-style proto options

Summary:
This patch makes the `{` in `msg_field{field: OK}` in a proto option scope be
treated as an assignment operator. Previosly the added test case was formatted
as:
```
option (MyProto.options) = {
  field_a: OK
  field_b{field_c: OK} field_d: OKOKOK field_e: OK
}
```

Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestProto.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=306672&r1=306671&r2=306672&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Jun 29 06:30:41 2017
@@ -1570,8 +1570,10 @@ private:
   const FormatToken *NextNonComment = Current->getNextNonComment();
   if (Current->is(TT_ConditionalExpr))
 return prec::Conditional;
-  if (NextNonComment && NextNonComment->is(tok::colon) &&
-  NextNonComment->is(TT_DictLiteral))
+  if (NextNonComment && Current->is(TT_SelectorName) &&
+  (NextNonComment->is(TT_DictLiteral) ||
+   (Style.Language == FormatStyle::LK_Proto &&
+NextNonComment->is(tok::less
 return prec::Assignment;
   if (Current->is(TT_JsComputedPropertyName))
 return prec::Assignment;

Modified: cfe/trunk/unittests/Format/FormatTestProto.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestProto.cpp?rev=306672&r1=306671&r2=306672&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestProto.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestProto.cpp Thu Jun 29 06:30:41 2017
@@ -201,6 +201,12 @@ TEST_F(FormatTestProto, FormatsOptions)
"  field_c: \"OK\"\n"
"  msg_field{field_d: 123}\n"
"};");
+  verifyFormat("option (MyProto.options) = {\n"
+   "  field_a: OK\n"
+   "  field_b{field_c: OK}\n"
+   "  field_d: OKOKOK\n"
+   "  field_e: OK\n"
+   "}");
 
   // Support syntax with <> instead of {}.
   verifyFormat("option (MyProto.options) = {\n"
@@ -209,6 +215,13 @@ TEST_F(FormatTestProto, FormatsOptions)
"};");
 
   verifyFormat("option (MyProto.options) = {\n"
+   "  field_a: OK\n"
+   "  field_b\n"
+   "  field_d: OKOKOK\n"
+   "  field_e: OK\n"
+   "}");
+
+  verifyFormat("option (MyProto.options) = {\n"
"  msg_field: <>\n"
"  field_c: \"OK\",\n"
"  msg_field: \n"


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


[PATCH] D34749: [clang-format] Fix parsing of msg{field}-style proto options

2017-06-29 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL306672: [clang-format] Fix parsing of msg{field}-style proto 
options (authored by krasimir).

Changed prior to commit:
  https://reviews.llvm.org/D34749?vs=104410&id=104632#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34749

Files:
  cfe/trunk/lib/Format/TokenAnnotator.cpp
  cfe/trunk/unittests/Format/FormatTestProto.cpp


Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -1570,8 +1570,10 @@
   const FormatToken *NextNonComment = Current->getNextNonComment();
   if (Current->is(TT_ConditionalExpr))
 return prec::Conditional;
-  if (NextNonComment && NextNonComment->is(tok::colon) &&
-  NextNonComment->is(TT_DictLiteral))
+  if (NextNonComment && Current->is(TT_SelectorName) &&
+  (NextNonComment->is(TT_DictLiteral) ||
+   (Style.Language == FormatStyle::LK_Proto &&
+NextNonComment->is(tok::less
 return prec::Assignment;
   if (Current->is(TT_JsComputedPropertyName))
 return prec::Assignment;
Index: cfe/trunk/unittests/Format/FormatTestProto.cpp
===
--- cfe/trunk/unittests/Format/FormatTestProto.cpp
+++ cfe/trunk/unittests/Format/FormatTestProto.cpp
@@ -201,14 +201,27 @@
"  field_c: \"OK\"\n"
"  msg_field{field_d: 123}\n"
"};");
+  verifyFormat("option (MyProto.options) = {\n"
+   "  field_a: OK\n"
+   "  field_b{field_c: OK}\n"
+   "  field_d: OKOKOK\n"
+   "  field_e: OK\n"
+   "}");
 
   // Support syntax with <> instead of {}.
   verifyFormat("option (MyProto.options) = {\n"
"  field_c: \"OK\",\n"
"  msg_field: \n"
"};");
 
   verifyFormat("option (MyProto.options) = {\n"
+   "  field_a: OK\n"
+   "  field_b\n"
+   "  field_d: OKOKOK\n"
+   "  field_e: OK\n"
+   "}");
+
+  verifyFormat("option (MyProto.options) = {\n"
"  msg_field: <>\n"
"  field_c: \"OK\",\n"
"  msg_field: \n"


Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -1570,8 +1570,10 @@
   const FormatToken *NextNonComment = Current->getNextNonComment();
   if (Current->is(TT_ConditionalExpr))
 return prec::Conditional;
-  if (NextNonComment && NextNonComment->is(tok::colon) &&
-  NextNonComment->is(TT_DictLiteral))
+  if (NextNonComment && Current->is(TT_SelectorName) &&
+  (NextNonComment->is(TT_DictLiteral) ||
+   (Style.Language == FormatStyle::LK_Proto &&
+NextNonComment->is(tok::less
 return prec::Assignment;
   if (Current->is(TT_JsComputedPropertyName))
 return prec::Assignment;
Index: cfe/trunk/unittests/Format/FormatTestProto.cpp
===
--- cfe/trunk/unittests/Format/FormatTestProto.cpp
+++ cfe/trunk/unittests/Format/FormatTestProto.cpp
@@ -201,14 +201,27 @@
"  field_c: \"OK\"\n"
"  msg_field{field_d: 123}\n"
"};");
+  verifyFormat("option (MyProto.options) = {\n"
+   "  field_a: OK\n"
+   "  field_b{field_c: OK}\n"
+   "  field_d: OKOKOK\n"
+   "  field_e: OK\n"
+   "}");
 
   // Support syntax with <> instead of {}.
   verifyFormat("option (MyProto.options) = {\n"
"  field_c: \"OK\",\n"
"  msg_field: \n"
"};");
 
   verifyFormat("option (MyProto.options) = {\n"
+   "  field_a: OK\n"
+   "  field_b\n"
+   "  field_d: OKOKOK\n"
+   "  field_e: OK\n"
+   "}");
+
+  verifyFormat("option (MyProto.options) = {\n"
"  msg_field: <>\n"
"  field_c: \"OK\",\n"
"  msg_field: \n"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r306673 - [Clang][X86][Goldmont]Adding new target-cpu: Goldmont

2017-06-29 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Thu Jun 29 06:41:04 2017
New Revision: 306673

URL: http://llvm.org/viewvc/llvm-project?rev=306673&view=rev
Log:
[Clang][X86][Goldmont]Adding new target-cpu: Goldmont 

[Clang-side] Connecting the GoldMont processor to his feature.


Reviewers:
1. igorb
2. delena
3. zvi


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

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=306673&r1=306672&r2=306673&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Jun 29 06:41:04 2017
@@ -2737,6 +2737,7 @@ class X86TargetInfo : public TargetInfo
 //@{
 CK_Bonnell,
 CK_Silvermont,
+CK_Goldmont,
 //@}
 
 /// \name Nehalem
@@ -2878,6 +2879,7 @@ class X86TargetInfo : public TargetInfo
 .Case("atom", CK_Bonnell) // Legacy name.
 .Case("silvermont", CK_Silvermont)
 .Case("slm", CK_Silvermont) // Legacy name.
+.Case("goldmont", CK_Goldmont)
 .Case("nehalem", CK_Nehalem)
 .Case("corei7", CK_Nehalem) // Legacy name.
 .Case("westmere", CK_Westmere)
@@ -3093,6 +3095,7 @@ public:
 case CK_Penryn:
 case CK_Bonnell:
 case CK_Silvermont:
+case CK_Goldmont:
 case CK_Nehalem:
 case CK_Westmere:
 case CK_SandyBridge:
@@ -3285,6 +3288,21 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "fxsr", true);
 setFeatureEnabledImpl(Features, "cx16", true);
 break;
+  case CK_Goldmont:
+setFeatureEnabledImpl(Features, "sha", true);
+setFeatureEnabledImpl(Features, "rdseed", true);
+setFeatureEnabledImpl(Features, "xsave", true);
+setFeatureEnabledImpl(Features, "xsaveopt", true);
+setFeatureEnabledImpl(Features, "xsavec", true);
+setFeatureEnabledImpl(Features, "xsaves", true);
+setFeatureEnabledImpl(Features, "clflushopt", true);
+setFeatureEnabledImpl(Features, "mpx", true);
+setFeatureEnabledImpl(Features, "aes", true);
+setFeatureEnabledImpl(Features, "pclmul", true);
+setFeatureEnabledImpl(Features, "sse4.2", true);
+setFeatureEnabledImpl(Features, "fxsr", true);
+setFeatureEnabledImpl(Features, "cx16", true);
+  break;
   case CK_KNL:
 setFeatureEnabledImpl(Features, "avx512f", true);
 setFeatureEnabledImpl(Features, "avx512cd", true);
@@ -3893,6 +3911,9 @@ void X86TargetInfo::getTargetDefines(con
   case CK_Silvermont:
 defineCPUMacros(Builder, "slm");
 break;
+  case CK_Goldmont:
+defineCPUMacros(Builder, "goldmont");
+break;
   case CK_Nehalem:
   case CK_Westmere:
   case CK_SandyBridge:

Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-arch-macros.c?rev=306673&r1=306672&r2=306673&view=diff
==
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Thu Jun 29 06:41:04 
2017
@@ -986,6 +986,79 @@
 // CHECK_ATOM_M64: #define __x86_64 1
 // CHECK_ATOM_M64: #define __x86_64__ 1
 //
+// RUN: %clang -march=goldmont -m32 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck %s -check-prefix=CHECK_GLM_M32
+// CHECK_GLM_M32: #define __AES__ 1
+// CHECK_GLM_M32: #define __CLFLUSHOPT__ 1
+// CHECK_GLM_M32: #define __FXSR__ 1
+// CHECK_GLM_M32: #define __MMX__ 1
+// CHECK_GLM_M32: #define __MPX__ 1
+// CHECK_GLM_M32: #define __PCLMUL__ 1
+// CHECK_GLM_M32: #define __POPCNT__ 1
+// CHECK_GLM_M32: #define __RDSEED__ 1
+// CHECK_GLM_M32: #define __SHA__ 1
+// CHECK_GLM_M32: #define __SSE2__ 1
+// CHECK_GLM_M32: #define __SSE3__ 1
+// CHECK_GLM_M32: #define __SSE4_1__ 1
+// CHECK_GLM_M32: #define __SSE4_2__ 1
+// CHECK_GLM_M32: #define __SSE_MATH__ 1
+// CHECK_GLM_M32: #define __SSE__ 1
+// CHECK_GLM_M32: #define __SSSE3__ 1
+// CHECK_GLM_M32: #define __XSAVEC__ 1
+// CHECK_GLM_M32: #define __XSAVEOPT__ 1
+// CHECK_GLM_M32: #define __XSAVES__ 1
+// CHECK_GLM_M32: #define __XSAVE__ 1
+// CHECK_GLM_M32: #define __clang__ 1
+// CHECK_GLM_M32: #define __goldmont 1
+// CHECK_GLM_M32: #define __goldmont__ 1
+// CHECK_GLM_M32: #define __i386 1
+// CHECK_GLM_M32: #define __i386__ 1
+// CHECK_GLM_M32: #define __linux 1
+// CHECK_GLM_M32: #define __linux__ 1
+// CHECK_GLM_M32: #define __llvm__ 1
+// CHECK_GLM_M32: #define __tune_goldmont__ 1
+// CHECK_GLM_M32: #define __unix 1
+// CHECK_GLM_M32: #define __unix__ 1
+// CHECK_GLM_M32: #define i386 1
+// CHECK_GLM_M32: #define linux 1
+// CHECK_GLM_M32: #define unix 1
+//
+// RUN: %clang -march=goldmont -m64 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck %s -check-prefix=CHECK_G

[PATCH] D34770: [Bash-autocompletion] Auto complete cc1 options if -cc1 is specified

2017-06-29 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

Two thought from me on this:

1. I think we want to support completing both -cc1 and normal driver 
invocation. Most people use the driver, but for example during debugging people 
use the cc1 version, so both are valid use cases. I just saw we actually have 
the completion code in the Driver, so what do you think about moving the code 
to the Frontend part and call it from the Driver/Frontend part?

2. I think it makes the most sense if we complete cc1 options but return 
"-Xclang OPTION" when we encounter a cc1 option from the Driver (because it's 
the least intrusive thing to do and the cc1 options are the ones everyone 
forgets about :) ).


https://reviews.llvm.org/D34770



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


[PATCH] D34790: [NewPM] Add a flag -fexperimental-new-pass-manager=on/off/debug for printing debug output.

2017-06-29 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

As I said in the discussion about similar flags for GVN, I'm generally fine 
with. We should have a big fat warning in the Release Notes that all 
-fexperimental-* flags are exactly that -- temporary and not intended for long 
term consumption. I.e. "we can and will remove them whenever it creates the 
most havoc".


https://reviews.llvm.org/D34790



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


Re: [PATCH] D31697: Check for null before using TUScope

2017-06-29 Thread Zachary Turner via cfe-commits
Might want to ask on cfe-dev or irc for more visibility since this review
thread isn't getting much action
On Thu, Jun 29, 2017 at 5:12 AM Kim Gräsman via Phabricator <
revi...@reviews.llvm.org> wrote:

> kimgr added a comment.
>
> I did some more debugging today. This happens when we attempt to analyze
> llvm/Support/MathExtras.h, and only for the function templates that use
> Microsoft intrinsics (e.g. `_BitScanForward` in `TrailingZerosCounter`.)
> So there's something in the parsing of builtins/intrinsics that requires
> `TUScope` to be non-null.
>
> Can we seed Sema with a valid `TUScope` before invoking
> `LateTemplateParser`, and if so, how? Or is this because we invoke the
> parser multiple times? I'm guessing Clang is already done parsing when we
> invoke the late template parsing.
>
> Grateful for any ideas here.
>
>
> https://reviews.llvm.org/D31697
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34444: Teach codegen to work in incremental processing mode.

2017-06-29 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a subscriber: karies.
v.g.vassilev added a comment.

@rjmccall, thanks for the prompt and thorough reply.

In https://reviews.llvm.org/D3#793311, @rjmccall wrote:

> Okay.  In that case, I see two problems, one major and one potentially major.




  This is a very accurate diagnosis which took us 5 years to discover on an 
empirical basis ;)

> The major problem is that, as Richard alludes to, you need to make sure you 
> emit any on-demand definitions that Sema registered with CodeGen during the 
> initial CGM's lifetime but used in later CGMs.



  We bring the CGM state to the subsequent CGMs. See 
https://github.com/vgvassilev/clang/blob/cling-patches/lib/CodeGen/ModuleBuilder.cpp#L138-L160

> The potentially major problem is that it is not possible in general to 
> automatically break up a single translation unit into multiple translation 
> units, for two reasons.  The big reason is that there is no way to correctly 
> handle entities with non-external linkage that are referenced from two parts 
> of the translation unit without implicitly finding some way to promote them 
> to external linkage, which might open a huge can of worms if you have 
> multiple "outer" translation units.



  We do not have an multiple 'outer' translation units. We have just one ever 
growing TU (which probably invalidates my previous statement that we have a 
distinct TUs) which we send to the RuntimeDyLD allowing only JIT to resolve 
symbols from it.  We aid the JIT when resolving symbols with internal linkage 
by changing all internal linkage to external (We haven't seen issues with that 
approach).

>   The lesser reason is that the prefix of a valid translation unit is not 
> necessarily a valid translation unit: for example, a static or inline 
> function can be defined at an arbitrary within the translation unit, i.e. not 
> necessarily before its first use.  But if your use case somehow defines away 
> these problems, this might be fine.



  If we end up with a module containing no definition of a symbol and such is 
required, then we complain. So indeed we are defining away this issue.
   

> As a minor request, if you are going to make HandleTranslationUnit no longer 
> the final call on CodeGenerator, please either add a new method that *is* a 
> guaranteed final call or add a new method that does the whole "end a previous 
> part of the translation unit and start a new one" step.



  We can have this but it would be a copy of `HandleTranslationUnit`.  The 
`StartModule` interface is the antagonist routine to `ReleaseModule`. If you 
prefer we could merge `StartModule` into `ReleaseModule` adding a flag (or 
reading the value of `isIncrementalProcessingEnabled`).

(Thanks @karies for helping!)


Repository:
  rL LLVM

https://reviews.llvm.org/D3



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


r306680 - Fix NSAPI constants to reflect the current state of

2017-06-29 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Jun 29 07:18:26 2017
New Revision: 306680

URL: http://llvm.org/viewvc/llvm-project?rev=306680&view=rev
Log:
Fix NSAPI constants to reflect the current state of
NSStringMethodKind/NSDictionaryMethodKind enums

Patch by Vladimir Voskresensky!

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

Modified:
cfe/trunk/include/clang/AST/NSAPI.h

Modified: cfe/trunk/include/clang/AST/NSAPI.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/NSAPI.h?rev=306680&r1=306679&r2=306680&view=diff
==
--- cfe/trunk/include/clang/AST/NSAPI.h (original)
+++ cfe/trunk/include/clang/AST/NSAPI.h Thu Jun 29 07:18:26 2017
@@ -49,7 +49,7 @@ public:
 NSStr_initWithString,
 NSStr_initWithUTF8String
   };
-  static const unsigned NumNSStringMethods = 5;
+  static const unsigned NumNSStringMethods = 6;
 
   IdentifierInfo *getNSClassId(NSClassIdKindKind K) const;
 
@@ -112,7 +112,7 @@ public:
 NSMutableDict_setObjectForKeyedSubscript,
 NSMutableDict_setValueForKey
   };
-  static const unsigned NumNSDictionaryMethods = 14;
+  static const unsigned NumNSDictionaryMethods = 13;
   
   /// \brief The Objective-C NSDictionary selectors.
   Selector getNSDictionarySelector(NSDictionaryMethodKind MK) const;


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


[PATCH] D34766: fix NSAPI constants to reflect the current state of NSStringMethodKind/NSDictionaryMethodKind enums

2017-06-29 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL306680: Fix NSAPI constants to reflect the current state of 
(authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D34766?vs=104455&id=104643#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34766

Files:
  cfe/trunk/include/clang/AST/NSAPI.h


Index: cfe/trunk/include/clang/AST/NSAPI.h
===
--- cfe/trunk/include/clang/AST/NSAPI.h
+++ cfe/trunk/include/clang/AST/NSAPI.h
@@ -49,7 +49,7 @@
 NSStr_initWithString,
 NSStr_initWithUTF8String
   };
-  static const unsigned NumNSStringMethods = 5;
+  static const unsigned NumNSStringMethods = 6;
 
   IdentifierInfo *getNSClassId(NSClassIdKindKind K) const;
 
@@ -112,7 +112,7 @@
 NSMutableDict_setObjectForKeyedSubscript,
 NSMutableDict_setValueForKey
   };
-  static const unsigned NumNSDictionaryMethods = 14;
+  static const unsigned NumNSDictionaryMethods = 13;
   
   /// \brief The Objective-C NSDictionary selectors.
   Selector getNSDictionarySelector(NSDictionaryMethodKind MK) const;


Index: cfe/trunk/include/clang/AST/NSAPI.h
===
--- cfe/trunk/include/clang/AST/NSAPI.h
+++ cfe/trunk/include/clang/AST/NSAPI.h
@@ -49,7 +49,7 @@
 NSStr_initWithString,
 NSStr_initWithUTF8String
   };
-  static const unsigned NumNSStringMethods = 5;
+  static const unsigned NumNSStringMethods = 6;
 
   IdentifierInfo *getNSClassId(NSClassIdKindKind K) const;
 
@@ -112,7 +112,7 @@
 NSMutableDict_setObjectForKeyedSubscript,
 NSMutableDict_setValueForKey
   };
-  static const unsigned NumNSDictionaryMethods = 14;
+  static const unsigned NumNSDictionaryMethods = 13;
   
   /// \brief The Objective-C NSDictionary selectors.
   Selector getNSDictionarySelector(NSDictionaryMethodKind MK) const;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34441: [clang-format] Support text proto messages

2017-06-29 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 104645.
krasimir added a comment.

- Add initial support for <>-style message fields
- Added single-line tests
- Added multiline message proto tests


https://reviews.llvm.org/D34441

Files:
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/TokenAnnotator.cpp
  lib/Format/UnwrappedLineParser.cpp
  lib/Format/UnwrappedLineParser.h
  unittests/Format/CMakeLists.txt
  unittests/Format/FormatTestTextProto.cpp

Index: unittests/Format/FormatTestTextProto.cpp
===
--- /dev/null
+++ unittests/Format/FormatTestTextProto.cpp
@@ -0,0 +1,251 @@
+//===- unittest/Format/FormatTestProto.cpp ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "FormatTestUtils.h"
+#include "clang/Format/Format.h"
+#include "llvm/Support/Debug.h"
+#include "gtest/gtest.h"
+
+#define DEBUG_TYPE "format-test"
+
+namespace clang {
+namespace format {
+
+class FormatTestTextProto : public ::testing::Test {
+protected:
+  static std::string format(llvm::StringRef Code, unsigned Offset,
+unsigned Length, const FormatStyle &Style) {
+DEBUG(llvm::errs() << "---\n");
+DEBUG(llvm::errs() << Code << "\n\n");
+std::vector Ranges(1, tooling::Range(Offset, Length));
+tooling::Replacements Replaces = reformat(Style, Code, Ranges);
+auto Result = applyAllReplacements(Code, Replaces);
+EXPECT_TRUE(static_cast(Result));
+DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
+return *Result;
+  }
+
+  static std::string format(llvm::StringRef Code) {
+FormatStyle Style = getGoogleStyle(FormatStyle::LK_TextProto);
+Style.ColumnLimit = 60; // To make writing tests easier.
+return format(Code, 0, Code.size(), Style);
+  }
+
+  static void verifyFormat(llvm::StringRef Code) {
+EXPECT_EQ(Code.str(), format(test::messUp(Code)));
+  }
+};
+
+TEST_F(FormatTestTextProto, KeepsTopLevelEntriesFittingALine) {
+  verifyFormat("field_a: OK field_b: OK field_c: OK field_d: OK field_e: OK");
+}
+
+TEST_F(FormatTestTextProto, SupportsMessageFields) {
+  verifyFormat("msg_field: {}");
+
+  verifyFormat("msg_field: {field_a: A}");
+
+  verifyFormat("msg_field: {field_a: \"OK\" field_b: 123}");
+
+  verifyFormat("msg_field: {\n"
+   "  field_a: 1\n"
+   "  field_b: OK\n"
+   "  field_c: \"OK\"\n"
+   "  field_d: 123\n"
+   "  field_e: 23\n"
+   "}");
+
+  verifyFormat("msg_field{}");
+
+  verifyFormat("msg_field{field_a: A}");
+
+  verifyFormat("msg_field{field_a: \"OK\" field_b: 123}");
+
+  verifyFormat("msg_field{\n"
+   "  field_a: 1\n"
+   "  field_b: OK\n"
+   "  field_c: \"OK\"\n"
+   "  field_d: 123\n"
+   "  field_e: 23.0\n"
+   "  field_f: false\n"
+   "  field_g: 'lala'\n"
+   "  field_h: 1234.567e-89\n"
+   "}");
+
+  verifyFormat("msg_field: {msg_field{field_a: 1}}");
+
+  verifyFormat("id: \"ala.bala\"\n"
+   "item{type: ITEM_A rank: 1 score: 90.0}\n"
+   "item{type: ITEM_B rank: 2 score: 70.5}\n"
+   "item{\n"
+   "  type: ITEM_A\n"
+   "  rank: 3\n"
+   "  score: 20.0\n"
+   "  description: \"the third item has a description\"\n"
+   "}");
+}
+
+TEST_F(FormatTestTextProto, AvoidsTopLevelBinPacking) {
+  verifyFormat("field_a: OK\n"
+   "field_b: OK\n"
+   "field_c: OK\n"
+   "field_d: OK\n"
+   "field_e: OK\n"
+   "field_f: OK");
+
+  verifyFormat("field_a: OK\n"
+   "field_b: \"OK\"\n"
+   "field_c: \"OK\"\n"
+   "msg_field: {field_d: 123}\n"
+   "field_e: OK\n"
+   "field_f: OK");
+
+  verifyFormat("field_a: OK\n"
+   "field_b: \"OK\"\n"
+   "field_c: \"OK\"\n"
+   "msg_field: {field_d: 123 field_e: OK}");
+
+  verifyFormat("a: {\n"
+   "  field_a: OK\n"
+   "  field_b{field_c: OK}\n"
+   "  field_d: OKOKOK\n"
+   "  field_e: OK\n"
+   "}");
+
+  verifyFormat("field_a: OK,\n"
+   "field_b{field_c: OK},\n"
+   "field_d: OKOKOK,\n"
+   "field_e: OK");
+}
+
+TEST_F(FormatTestTextProto, AddsNewlinesAfterTrailingComments) {
+  verifyFormat("field_a: OK  // Comment\n"
+   "field_b: 1");
+
+  verifyFormat("field_a: OK\n"
+   "msg_field: {\n"
+   "  field_b: OK  // Comment\n"
+   "}");
+
+ 

[PATCH] D34441: [clang-format] Support text proto messages

2017-06-29 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 104646.
krasimir added a comment.

- Wrap-up this patch


https://reviews.llvm.org/D34441

Files:
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/TokenAnnotator.cpp
  lib/Format/UnwrappedLineParser.cpp
  lib/Format/UnwrappedLineParser.h
  unittests/Format/CMakeLists.txt
  unittests/Format/FormatTestTextProto.cpp

Index: unittests/Format/FormatTestTextProto.cpp
===
--- /dev/null
+++ unittests/Format/FormatTestTextProto.cpp
@@ -0,0 +1,251 @@
+//===- unittest/Format/FormatTestProto.cpp ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "FormatTestUtils.h"
+#include "clang/Format/Format.h"
+#include "llvm/Support/Debug.h"
+#include "gtest/gtest.h"
+
+#define DEBUG_TYPE "format-test"
+
+namespace clang {
+namespace format {
+
+class FormatTestTextProto : public ::testing::Test {
+protected:
+  static std::string format(llvm::StringRef Code, unsigned Offset,
+unsigned Length, const FormatStyle &Style) {
+DEBUG(llvm::errs() << "---\n");
+DEBUG(llvm::errs() << Code << "\n\n");
+std::vector Ranges(1, tooling::Range(Offset, Length));
+tooling::Replacements Replaces = reformat(Style, Code, Ranges);
+auto Result = applyAllReplacements(Code, Replaces);
+EXPECT_TRUE(static_cast(Result));
+DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
+return *Result;
+  }
+
+  static std::string format(llvm::StringRef Code) {
+FormatStyle Style = getGoogleStyle(FormatStyle::LK_TextProto);
+Style.ColumnLimit = 60; // To make writing tests easier.
+return format(Code, 0, Code.size(), Style);
+  }
+
+  static void verifyFormat(llvm::StringRef Code) {
+EXPECT_EQ(Code.str(), format(test::messUp(Code)));
+  }
+};
+
+TEST_F(FormatTestTextProto, KeepsTopLevelEntriesFittingALine) {
+  verifyFormat("field_a: OK field_b: OK field_c: OK field_d: OK field_e: OK");
+}
+
+TEST_F(FormatTestTextProto, SupportsMessageFields) {
+  verifyFormat("msg_field: {}");
+
+  verifyFormat("msg_field: {field_a: A}");
+
+  verifyFormat("msg_field: {field_a: \"OK\" field_b: 123}");
+
+  verifyFormat("msg_field: {\n"
+   "  field_a: 1\n"
+   "  field_b: OK\n"
+   "  field_c: \"OK\"\n"
+   "  field_d: 123\n"
+   "  field_e: 23\n"
+   "}");
+
+  verifyFormat("msg_field{}");
+
+  verifyFormat("msg_field{field_a: A}");
+
+  verifyFormat("msg_field{field_a: \"OK\" field_b: 123}");
+
+  verifyFormat("msg_field{\n"
+   "  field_a: 1\n"
+   "  field_b: OK\n"
+   "  field_c: \"OK\"\n"
+   "  field_d: 123\n"
+   "  field_e: 23.0\n"
+   "  field_f: false\n"
+   "  field_g: 'lala'\n"
+   "  field_h: 1234.567e-89\n"
+   "}");
+
+  verifyFormat("msg_field: {msg_field{field_a: 1}}");
+
+  verifyFormat("id: \"ala.bala\"\n"
+   "item{type: ITEM_A rank: 1 score: 90.0}\n"
+   "item{type: ITEM_B rank: 2 score: 70.5}\n"
+   "item{\n"
+   "  type: ITEM_A\n"
+   "  rank: 3\n"
+   "  score: 20.0\n"
+   "  description: \"the third item has a description\"\n"
+   "}");
+}
+
+TEST_F(FormatTestTextProto, AvoidsTopLevelBinPacking) {
+  verifyFormat("field_a: OK\n"
+   "field_b: OK\n"
+   "field_c: OK\n"
+   "field_d: OK\n"
+   "field_e: OK\n"
+   "field_f: OK");
+
+  verifyFormat("field_a: OK\n"
+   "field_b: \"OK\"\n"
+   "field_c: \"OK\"\n"
+   "msg_field: {field_d: 123}\n"
+   "field_e: OK\n"
+   "field_f: OK");
+
+  verifyFormat("field_a: OK\n"
+   "field_b: \"OK\"\n"
+   "field_c: \"OK\"\n"
+   "msg_field: {field_d: 123 field_e: OK}");
+
+  verifyFormat("a: {\n"
+   "  field_a: OK\n"
+   "  field_b{field_c: OK}\n"
+   "  field_d: OKOKOK\n"
+   "  field_e: OK\n"
+   "}");
+
+  verifyFormat("field_a: OK,\n"
+   "field_b{field_c: OK},\n"
+   "field_d: OKOKOK,\n"
+   "field_e: OK");
+}
+
+TEST_F(FormatTestTextProto, AddsNewlinesAfterTrailingComments) {
+  verifyFormat("field_a: OK  // Comment\n"
+   "field_b: 1");
+
+  verifyFormat("field_a: OK\n"
+   "msg_field: {\n"
+   "  field_b: OK  // Comment\n"
+   "}");
+
+  verifyFormat("field_a: OK\n"
+   "msg_field{\n"
+   "  field_b: OK  

[PATCH] D34441: [clang-format] Support text proto messages

2017-06-29 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

@djasper: I think this is ready for review.


https://reviews.llvm.org/D34441



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


[PATCH] D30946: [ScopePrinting] Added support to print full scopes of types and declarations.

2017-06-29 Thread Simon Schroeder via Phabricator via cfe-commits
schroedersi updated this revision to Diff 104649.
schroedersi added a comment.

In https://reviews.llvm.org/D30946#792798, @rsmith wrote:

> I'd be interested to see how much complexity that adds, if you're prepared to 
> give it a try.


Thanks for your feedback :). I added a printing context and moved 
`TemporarySuppressScope` from `PrintingPolicy` to the printing context. The 
printing context is currently passed around by value. This is not ideal because 
changes to the context made inside a function are not available in the caller 
but it is sufficient for the temporary suppress scope functionality. And it 
gives an overview of the amount of code changes.

Passing the context around by reference would be better but it would also 
necessitate the creation of a overloaded version of almost each affected 
function. (Something like this:

  void print(const PrintingPolicy& Policy, PrintingContext& Context) { /*...*/ }
  
  void print(const PrintingPolicy& Policy) {
PrintingContext Context;
print(Policy, Context);
  }

).

> Yes, I think that's right -- `SuppressScope` isn't really an externally 
> useful "print without scopes" mechanism, it's an internal mechanism / 
> implementation detail used for printing an "inner" AST node when we've 
> already printed a scope for it based on outer sugar (eg, the entity is a type 
> component of a nested name specifier, or the type inside an elaborated type 
> specifier, or the class name in a destructor name). It's not really 
> `SuppressScope`, it's 
> `ScopeWasAlreadyPrintedForWhateverTopLevelThingIAskedYouToPrint` =)

Thanks for clarification :)


https://reviews.llvm.org/D30946

Files:
  include/clang/AST/Decl.h
  include/clang/AST/DeclBase.h
  include/clang/AST/NestedNameSpecifier.h
  include/clang/AST/PrettyPrinter.h
  include/clang/AST/TemplateBase.h
  include/clang/AST/TemplateName.h
  include/clang/AST/Type.h
  lib/AST/Decl.cpp
  lib/AST/DeclPrinter.cpp
  lib/AST/NestedNameSpecifier.cpp
  lib/AST/TemplateBase.cpp
  lib/AST/TemplateName.cpp
  lib/AST/TypePrinter.cpp

Index: lib/AST/TypePrinter.cpp
===
--- lib/AST/TypePrinter.cpp
+++ lib/AST/TypePrinter.cpp
@@ -63,30 +63,28 @@
 bool SuppressTagKeyword;
 
   public:
-explicit ElaboratedTypePolicyRAII(PrintingPolicy &Policy,
-  bool TemporarySuppressScope = true)
-: Policy(Policy) {
+explicit ElaboratedTypePolicyRAII(PrintingPolicy &Policy) : Policy(Policy) {
   SuppressTagKeyword = Policy.SuppressTagKeyword;
   Policy.SuppressTagKeyword = true;
-  Policy.TemporarySuppressScope = TemporarySuppressScope;
 }
 
 ~ElaboratedTypePolicyRAII() {
   Policy.SuppressTagKeyword = SuppressTagKeyword;
-  Policy.TemporarySuppressScope = false;
 }
   };
   
   class TypePrinter {
 PrintingPolicy Policy;
+PrintingContext Context;
 unsigned Indentation;
 bool HasEmptyPlaceHolder;
 bool InsideCCAttribute;
 
   public:
-explicit TypePrinter(const PrintingPolicy &Policy, unsigned Indentation = 0)
-  : Policy(Policy), Indentation(Indentation),
-HasEmptyPlaceHolder(false), InsideCCAttribute(false) { }
+explicit TypePrinter(const PrintingPolicy &Policy, unsigned Indentation = 0,
+ PrintingContext Context = PrintingContext())
+: Policy(Policy), Context(Context), Indentation(Indentation),
+  HasEmptyPlaceHolder(false), InsideCCAttribute(false) {}
 
 void print(const Type *ty, Qualifiers qs, raw_ostream &OS,
StringRef PlaceHolder);
@@ -415,7 +413,8 @@
 
   PrintingPolicy InnerPolicy(Policy);
   InnerPolicy.IncludeTagDefinition = false;
-  TypePrinter(InnerPolicy).print(QualType(T->getClass(), 0), OS, StringRef());
+  TypePrinter(InnerPolicy, 0, Context)
+  .print(QualType(T->getClass(), 0), OS, StringRef());
 
   OS << "::*";
 }
@@ -590,21 +589,20 @@
   OS << ")))";
 }
 
-void 
-FunctionProtoType::printExceptionSpecification(raw_ostream &OS, 
-   const PrintingPolicy &Policy)
- const {
-  
+void FunctionProtoType::printExceptionSpecification(
+raw_ostream &OS, const PrintingPolicy &Policy,
+PrintingContext Context) const {
+
   if (hasDynamicExceptionSpec()) {
 OS << " throw(";
 if (getExceptionSpecType() == EST_MSAny)
   OS << "...";
 else
   for (unsigned I = 0, N = getNumExceptions(); I != N; ++I) {
 if (I)
   OS << ", ";
-
-OS << getExceptionType(I).stream(Policy);
+
+OS << getExceptionType(I).stream(Policy, Twine(), 0, Context);
   }
 OS << ')';
   } else if (isNoexceptExceptionSpec(getExceptionSpecType())) {
@@ -768,7 +766,7 @@
 OS << " &&";
 break;
   }
-  T->printExceptionSpecification(OS, Policy);
+  T->printExceptionSpecification(OS, Policy, Context);
 
   if (T->

[PATCH] D29647: [OpenMP] Extend CLANG target options with device offloading kind.

2017-06-29 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel accepted this revision.
hfinkel added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

https://reviews.llvm.org/D29647



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


[PATCH] D29647: [OpenMP] Extend CLANG target options with device offloading kind.

2017-06-29 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D29647#795271, @hfinkel wrote:

> LGTM


When you commit this, please make sure to mention in the commit message that 
the test cases will be associated with follow-up commits.


Repository:
  rL LLVM

https://reviews.llvm.org/D29647



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


[PATCH] D29339: [OpenMP] Add support for auxiliary triple specification

2017-06-29 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 104656.
gtbercea added a comment.

Rebase


https://reviews.llvm.org/D29339

Files:
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/InitPreprocessor.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -250,32 +250,32 @@
 //
 // Compile for the powerpc device.
 //
-// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-obj" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" "
+// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-aux-triple" "powerpc64le--linux" "-emit-obj" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-COMMANDS-SAME: [[T1OBJ:[^\\/]+\.o]]" "-x" "c" "{{.*}}[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "{{.*}}[[HOSTBC]]"
 // CHK-COMMANDS: ld{{(\.exe)?}}" {{.*}}"-o" "
 // CHK-COMMANDS-SAME: [[T1BIN:[^\\/]+\.out]]" {{.*}}"{{.*}}[[T1OBJ]]"
-// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-aux-triple" "powerpc64le--linux" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-COMMANDS-ST-SAME: [[T1PP:[^\\/]+\.i]]" "-x" "c" "{{.*}}[[INPUT]]"
-// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-llvm-bc" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" "
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-aux-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-COMMANDS-ST-SAME: [[T1BC:[^\\/]+\.bc]]" "-x" "cpp-output" "{{.*}}[[T1PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "{{.*}}[[HOSTBC]]"
-// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-aux-triple" "powerpc64le--linux" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-COMMANDS-ST-SAME: [[T1ASM:[^\\/]+\.s]]" "-x" "ir" "{{.*}}[[T1BC]]"
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le-ibm-linux-gnu" "-filetype" "obj" {{.*}}"-o" "
 // CHK-COMMANDS-ST-SAME: [[T1OBJ:[^\\/]+\.o]]" "{{.*}}[[T1ASM]]"
 // CHK-COMMANDS-ST: ld{{(\.exe)?}}" {{.*}}"-shared" {{.*}}"-o" "
 // CHK-COMMANDS-ST-SAME: [[T1BIN:[^\\/]+\.out-openmp-powerpc64le-ibm-linux-gnu]]" {{.*}}"{{.*}}[[T1OBJ]]"
 //
 // Compile for the x86 device.
 //
-// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp"  {{.*}}"-o" "
+// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-aux-triple" "powerpc64le--linux" "-emit-obj" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp"  {{.*}}"-o" "
 // CHK-COMMANDS-SAME: [[T2OBJ:[^\\/]+\.o]]" "-x" "c" "{{.*}}[[INPUT]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "{{.*}}[[HOSTBC]]"
 // CHK-COMMANDS: ld{{(\.exe)?}}" {{.*}}"-o" "
 // CHK-COMMANDS-SAME: [[T2BIN:[^\\/]+\.out]]" {{.*}}"{{.*}}[[T2OBJ]]"
-// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-aux-triple" "powerpc64le--linux" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-COMMANDS-ST-SAME: [[T2PP:[^\\/]+\.i]]" "-x" "c" "{{.*}}[[INPUT]]"
-// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-llvm-bc" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" "
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-aux-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-COMMANDS-ST-SAME: [[T2BC:[^\\/]+\.bc]]" "-x" "cpp-output" "{{.*}}[[T2PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" "{{.*}}[[HOSTBC]]"
-// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-aux-triple" "powerpc64le--linux" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-COMMANDS-ST-SAME: [[T2ASM:[^\\/]+\.s]]" "-x" "ir" "{{.*}}[[T2BC]]"
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "x86_64-pc-linux-gnu" "-filetype" "obj" {{.*}}"-o" "
 // CHK-COMMANDS-ST-SAME: [[T2OBJ:[^\\/]+\.o]]" "{{.*}}[[T2ASM]]"
@@ -398,25 +398,25 @@
 // CHK-BUJOBS-ST-SAME: [[HOSTBC:[^\\/]+\.bc]]" "-x" "cpp-output" "{{.*}}[[HOSTPP]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu"
 
 // Create target 1 object.
-// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "
+// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-aux-triple" "powerpc64le--linux" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-BU

[PATCH] D34784: [OpenMP] Add flag for specifying the target device architecture for OpenMP device offloading

2017-06-29 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

What happens if you have multiple targets? Maybe this should be 
-fopenmp-targets-arch=foo,bar,whatever?

Once this all lands, please make sure that you add additional test cases here. 
Make sure that the arch is passed through to the ptx and cuda tools as it 
should be. Make sure that the defaults work. Make sure that something 
reasonable happens if the user specifies the option more than once (if they're 
all the same).


Repository:
  rL LLVM

https://reviews.llvm.org/D34784



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


[PATCH] D30946: [ScopePrinting] Added support to print full scopes of types and declarations.

2017-06-29 Thread Simon Schroeder via Phabricator via cfe-commits
schroedersi updated this revision to Diff 104655.
schroedersi added a comment.

I forgot to add the previous changes in Diff 104649 
 (it only contains the 
incremental diff of the printing context changes). This diff contains all 
changes between trunk and the current patch state. I apologize!


https://reviews.llvm.org/D30946

Files:
  include/clang/AST/Decl.h
  include/clang/AST/DeclBase.h
  include/clang/AST/NestedNameSpecifier.h
  include/clang/AST/PrettyPrinter.h
  include/clang/AST/TemplateBase.h
  include/clang/AST/TemplateName.h
  include/clang/AST/Type.h
  lib/AST/Decl.cpp
  lib/AST/DeclPrinter.cpp
  lib/AST/DeclarationName.cpp
  lib/AST/NestedNameSpecifier.cpp
  lib/AST/TemplateBase.cpp
  lib/AST/TemplateName.cpp
  lib/AST/TypePrinter.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/Tooling/Core/QualTypeNames.cpp
  test/CXX/class.access/p6.cpp
  test/Index/comment-cplus-decls.cpp
  unittests/AST/AbsoluteScopeTest.cpp
  unittests/AST/CMakeLists.txt
  unittests/AST/NamedDeclPrinterTest.cpp
  unittests/AST/TypePrinterTest.cpp

Index: unittests/AST/TypePrinterTest.cpp
===
--- /dev/null
+++ unittests/AST/TypePrinterTest.cpp
@@ -0,0 +1,464 @@
+//===- unittests/AST/TypePrinterTest.cpp -- TypePrinter printer tests -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file contains tests for TypePrinter::print(...).
+//
+// These tests have a coding convention:
+// * variable whose type to be printed is named 'A' unless it should have some
+// special name
+// * additional helper classes/namespaces/... are 'Z', 'Y', 'X' and so on.
+//
+//===--===//
+
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/SmallString.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace ast_matchers;
+using namespace tooling;
+namespace {
+
+class PrintMatch : public MatchFinder::MatchCallback {
+  SmallString<1024> Printed;
+  unsigned NumFoundDecls;
+  bool SuppressUnwrittenScope;
+  ScopePrintingKind::ScopePrintingKind Scope;
+
+public:
+  explicit PrintMatch(bool suppressUnwrittenScope,
+  ScopePrintingKind::ScopePrintingKind scope)
+  : NumFoundDecls(0), SuppressUnwrittenScope(suppressUnwrittenScope),
+Scope(scope) {}
+
+  void run(const MatchFinder::MatchResult &Result) override {
+const ValueDecl *VD = Result.Nodes.getNodeAs("id");
+if (!VD)
+  return;
+NumFoundDecls++;
+if (NumFoundDecls > 1)
+  return;
+
+llvm::raw_svector_ostream Out(Printed);
+PrintingPolicy Policy = Result.Context->getPrintingPolicy();
+Policy.SuppressUnwrittenScope = SuppressUnwrittenScope;
+Policy.Scope = Scope;
+QualType Type = VD->getType();
+Type.print(Out, Policy);
+  }
+
+  StringRef getPrinted() const { return Printed; }
+
+  unsigned getNumFoundDecls() const { return NumFoundDecls; }
+};
+
+::testing::AssertionResult
+PrintedTypeMatches(StringRef Code, const std::vector &Args,
+   bool SuppressUnwrittenScope,
+   const DeclarationMatcher &NodeMatch,
+   StringRef ExpectedPrinted, StringRef FileName,
+   ScopePrintingKind::ScopePrintingKind Scope) {
+  PrintMatch Printer(SuppressUnwrittenScope, Scope);
+  MatchFinder Finder;
+  Finder.addMatcher(NodeMatch, &Printer);
+  std::unique_ptr Factory =
+  newFrontendActionFactory(&Finder);
+
+  if (!runToolOnCodeWithArgs(Factory->create(), Code, Args, FileName))
+return testing::AssertionFailure()
+   << "Parsing error in \"" << Code.str() << "\"";
+
+  if (Printer.getNumFoundDecls() == 0)
+return testing::AssertionFailure()
+   << "Matcher didn't find any value declarations";
+
+  if (Printer.getNumFoundDecls() > 1)
+return testing::AssertionFailure()
+   << "Matcher should match only one value declaration "
+  "(found "
+   << Printer.getNumFoundDecls() << ")";
+
+  if (Printer.getPrinted() != ExpectedPrinted)
+return ::testing::AssertionFailure()
+   << "Expected \"" << ExpectedPrinted.str()
+   << "\", "
+  "got \""
+   << Printer.getPrinted().str() << "\"";
+
+  return ::testing::AssertionSuccess();
+}
+
+::testing::AssertionResult
+PrintedTypeCXX11MatchesWrapper(StringRef Code, StringRef DeclName,
+   StringRef ExpectedPrinted,
+   ScopePrintingKind::ScopePrintingKind Scope) {
+  std::vector Args(1, "-std=c++11");
+  return PrintedTypeMatches(Code, Args,
+/*Supp

[PATCH] D34329: [clang-diff] Initial implementation.

2017-06-29 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: include/clang/Tooling/ASTDiff/ASTDiffInternal.h:184
+
+  std::string getNodeValueI(NodeId Id) const;
+  std::string getNodeValueI(const DynTypedNode &DTN) const;

`getNodeValueImpl`?



Comment at: lib/Tooling/ASTDiff/ASTDiff.cpp:439
+// Computes an optimal mapping between two trees.
+class ZsMatcher {
+  const ASTDiff::Impl &DiffImpl;

Do you know the reason for the `ZsMatcher` name? I noticed that they used it in 
the GumTree java implementation as well. If it's based on some paper you should 
add a comment that mentions it.


https://reviews.llvm.org/D34329



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


r306689 - [OpenMP] Add support for auxiliary triple specification

2017-06-29 Thread Gheorghe-Teodor Bercea via cfe-commits
Author: gbercea
Date: Thu Jun 29 08:49:03 2017
New Revision: 306689

URL: http://llvm.org/viewvc/llvm-project?rev=306689&view=rev
Log:
[OpenMP] Add support for auxiliary triple specification

Summary: Device offloading requires the specification of an additional flag 
containing the triple of the //other// architecture the code is being compiled 
on if such an architecture exists. If compiling for the host, the auxiliary 
triple flag will contain the triple describing the device and vice versa.

Reviewers: arpith-jacob, sfantao, caomhin, carlo.bertolli, ABataev, Hahnfeld, 
jlebar, hfinkel, tstellar

Reviewed By: Hahnfeld

Subscribers: rengolin, cfe-commits

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Driver/openmp-offload.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=306689&r1=306688&r2=306689&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Jun 29 08:49:03 2017
@@ -129,6 +129,13 @@ forAllAssociatedToolChains(Compilation &
   else if (JA.isDeviceOffloading(Action::OFK_Cuda))
 Work(*C.getSingleOffloadToolChain());
 
+  if (JA.isHostOffloading(Action::OFK_OpenMP)) {
+auto TCs = C.getOffloadToolChains();
+for (auto II = TCs.first, IE = TCs.second; II != IE; ++II)
+  Work(*II->second);
+  } else if (JA.isDeviceOffloading(Action::OFK_OpenMP))
+Work(*C.getSingleOffloadToolChain());
+
   //
   // TODO: Add support for other offloading programming models here.
   //
@@ -1991,6 +1998,16 @@ void Clang::ConstructJob(Compilation &C,
 CmdArgs.push_back("-aux-triple");
 CmdArgs.push_back(Args.MakeArgString(NormalizedTriple));
   }
+
+  if (IsOpenMPDevice) {
+// We have to pass the triple of the host if compiling for an OpenMP 
device.
+std::string NormalizedTriple =
+C.getSingleOffloadToolChain()
+->getTriple()
+.normalize();
+CmdArgs.push_back("-aux-triple");
+CmdArgs.push_back(Args.MakeArgString(NormalizedTriple));
+  }
 
   if (Triple.isOSWindows() && (Triple.getArch() == llvm::Triple::arm ||
Triple.getArch() == llvm::Triple::thumb)) {

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=306689&r1=306688&r2=306689&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Thu Jun 29 08:49:03 2017
@@ -936,8 +936,9 @@ bool CompilerInstance::ExecuteAction(Fro
   if (!hasTarget())
 return false;
 
-  // Create TargetInfo for the other side of CUDA compilation.
-  if (getLangOpts().CUDA && !getFrontendOpts().AuxTriple.empty()) {
+  // Create TargetInfo for the other side of CUDA and OpenMP compilation.
+  if ((getLangOpts().CUDA || getLangOpts().OpenMPIsDevice) &&
+  !getFrontendOpts().AuxTriple.empty()) {
 auto TO = std::make_shared();
 TO->Triple = getFrontendOpts().AuxTriple;
 TO->HostTriple = getTarget().getTriple().str();

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=306689&r1=306688&r2=306689&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Jun 29 08:49:03 2017
@@ -2644,6 +2644,10 @@ bool CompilerInvocation::CreateFromArgs(
   Res.getTargetOpts().HostTriple = Res.getFrontendOpts().AuxTriple;
   }
 
+  // Set the triple of the host for OpenMP device compile.
+  if (LangOpts.OpenMPIsDevice)
+Res.getTargetOpts().HostTriple = Res.getFrontendOpts().AuxTriple;
+
   // FIXME: Override value name discarding when asan or msan is used because 
the
   // backend passes depend on the name of the alloca in order to print out
   // names.

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=306689&r1=306688&r2=306689&view=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Thu Jun 29 08:49:03 2017
@@ -1043,7 +1043,7 @@ void clang::InitializePreprocessor(
   if (InitOpts.UsePredefines) {
 // FIXME: This will create multiple definitions for most of the predefined
 // macros. This is not the right way to handle this.
- 

r306691 - [OpenMP] Pass -fopenmp-is-device to preprocessing and machine specific code generation stages

2017-06-29 Thread Gheorghe-Teodor Bercea via cfe-commits
Author: gbercea
Date: Thu Jun 29 08:59:19 2017
New Revision: 306691

URL: http://llvm.org/viewvc/llvm-project?rev=306691&view=rev
Log:
[OpenMP] Pass -fopenmp-is-device to preprocessing and machine specific code 
generation stages

Summary: The preprocessing and code generation and optimization stages of the 
compiler are also passed the "-fopenmp-is-device" flag. This is used to trigger 
machine specific preprocessing and code generation when performing device 
offloading to an NVIDIA GPU via OpenMP directives.

Reviewers: arpith-jacob, caomhin, carlo.bertolli, Hahnfeld, hfinkel, tstellar

Reviewed By: Hahnfeld

Subscribers: Hahnfeld, rengolin

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/openmp-offload.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=306691&r1=306690&r2=306691&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Jun 29 08:59:19 2017
@@ -4429,10 +4429,12 @@ void Clang::ConstructJob(Compilation &C,
   // device declarations can be identified. Also, -fopenmp-is-device is passed
   // along to tell the frontend that it is generating code for a device, so 
that
   // only the relevant declarations are emitted.
-  if (IsOpenMPDevice && Inputs.size() == 2) {
+  if (IsOpenMPDevice) {
 CmdArgs.push_back("-fopenmp-is-device");
-CmdArgs.push_back("-fopenmp-host-ir-file-path");
-CmdArgs.push_back(Args.MakeArgString(Inputs.back().getFilename()));
+if (Inputs.size() == 2) {
+  CmdArgs.push_back("-fopenmp-host-ir-file-path");
+  CmdArgs.push_back(Args.MakeArgString(Inputs.back().getFilename()));
+}
   }
 
   // For all the host OpenMP offloading compile jobs we need to pass the 
targets

Modified: cfe/trunk/test/Driver/openmp-offload.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openmp-offload.c?rev=306691&r1=306690&r2=306691&view=diff
==
--- cfe/trunk/test/Driver/openmp-offload.c (original)
+++ cfe/trunk/test/Driver/openmp-offload.c Thu Jun 29 08:59:19 2017
@@ -589,3 +589,13 @@
 // CHK-UBUJOBS-ST-SAME: [[HOSTOBJ:[^\\/]+\.o]]" "{{.*}}[[HOSTASM]]"
 // CHK-UBUJOBS-ST: clang-offload-bundler{{.*}}" "-type=o" 
"-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux"
 "-outputs=
 // CHK-UBUJOBS-ST-SAME: [[RES:[^\\/]+\.o]]" 
"-inputs={{.*}}[[T1OBJ]],{{.*}}[[T2OBJ]],{{.*}}[[HOSTOBJ]]"
+
+/// ###
+
+/// Check -fopenmp-is-device is also passed when generating the *.i and *.s 
intermediate files.
+// RUN:   %clang -### -fopenmp=libomp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -save-temps -no-canonical-prefixes 
%s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-FOPENMP-IS-DEVICE %s
+
+// CHK-FOPENMP-IS-DEVICE: clang{{.*}}.i" {{.*}}" "-fopenmp-is-device"
+// CHK-FOPENMP-IS-DEVICE-NEXT: clang{{.*}}.bc" {{.*}}.i" "-fopenmp-is-device" 
"-fopenmp-host-ir-file-path"
+// CHK-FOPENMP-IS-DEVICE-NEXT: clang{{.*}}.s" {{.*}}.bc" "-fopenmp-is-device"


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


r306692 - Initialize variable and silence potentially uninitialized warning.

2017-06-29 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Thu Jun 29 09:08:10 2017
New Revision: 306692

URL: http://llvm.org/viewvc/llvm-project?rev=306692&view=rev
Log:
Initialize variable and silence potentially uninitialized warning.

Patch by Liza Sakellari!

Modified:
cfe/trunk/include/clang/Sema/Lookup.h

Modified: cfe/trunk/include/clang/Sema/Lookup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=306692&r1=306691&r2=306692&view=diff
==
--- cfe/trunk/include/clang/Sema/Lookup.h (original)
+++ cfe/trunk/include/clang/Sema/Lookup.h Thu Jun 29 09:08:10 2017
@@ -465,10 +465,9 @@ public:
 Paths = nullptr;
   }
 } else {
-  AmbiguityKind SavedAK;
+  AmbiguityKind SavedAK = Ambiguity;
   bool WasAmbiguous = false;
   if (ResultKind == Ambiguous) {
-SavedAK = Ambiguity;
 WasAmbiguous = true;
   }
   ResultKind = Found;


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


[PATCH] D34329: [clang-diff] Initial implementation.

2017-06-29 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 104664.

https://reviews.llvm.org/D34329

Files:
  include/clang/Tooling/ASTDiff/ASTDiff.h
  include/clang/Tooling/ASTDiff/ASTDiffInternal.h
  lib/Tooling/ASTDiff/ASTDiff.cpp
  lib/Tooling/ASTDiff/CMakeLists.txt
  lib/Tooling/CMakeLists.txt
  test/Tooling/clang-diff-basic.cpp
  tools/CMakeLists.txt
  tools/clang-diff/CMakeLists.txt
  tools/clang-diff/ClangDiff.cpp

Index: tools/clang-diff/ClangDiff.cpp
===
--- /dev/null
+++ tools/clang-diff/ClangDiff.cpp
@@ -0,0 +1,110 @@
+//===- ClangDiff.cpp - compare source files by AST nodes --*- C++ -*- -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file implements a tool for syntax tree based comparison using
+// Tooling/ASTDiff.
+//
+//===--===//
+
+#include "clang/Tooling/ASTDiff/ASTDiff.h"
+#include "clang/Tooling/CommonOptionsParser.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/Support/CommandLine.h"
+
+using namespace llvm;
+using namespace clang;
+using namespace clang::tooling;
+
+static cl::OptionCategory ClangDiffCategory("clang-diff options");
+
+static cl::opt
+DumpAST("ast-dump",
+cl::desc("Print the internal representation of the AST as JSON."),
+cl::init(false), cl::cat(ClangDiffCategory));
+
+static cl::opt NoCompilationDatabase(
+"no-compilation-database",
+cl::desc(
+"Do not attempt to load build settings from a compilation database"),
+cl::init(false), cl::cat(ClangDiffCategory));
+
+static cl::opt SourcePath(cl::Positional, cl::desc(""),
+   cl::Required,
+   cl::cat(ClangDiffCategory));
+
+static cl::opt DestinationPath(cl::Positional,
+cl::desc(""),
+cl::Optional,
+cl::cat(ClangDiffCategory));
+
+static std::unique_ptr getAST(const StringRef Filename) {
+  std::string ErrorMessage;
+  std::unique_ptr Compilations;
+  if (!NoCompilationDatabase)
+Compilations =
+CompilationDatabase::autoDetectFromSource(Filename, ErrorMessage);
+  if (!Compilations) {
+if (!NoCompilationDatabase)
+  llvm::errs()
+  << "Error while trying to load a compilation database, running "
+ "without flags.\n"
+  << ErrorMessage;
+Compilations = llvm::make_unique(
+".", std::vector());
+  }
+  std::array Files = {{Filename}};
+  ClangTool Tool(*Compilations, Files);
+  std::vector> ASTs;
+  Tool.buildASTs(ASTs);
+  if (ASTs.size() != Files.size())
+return nullptr;
+  return std::move(ASTs[0]);
+}
+
+int main(int argc, const char **argv) {
+  cl::HideUnrelatedOptions(ClangDiffCategory);
+  if (!cl::ParseCommandLineOptions(argc, argv)) {
+cl::PrintOptionValues();
+return 1;
+  }
+
+  if (DumpAST) {
+if (!DestinationPath.empty()) {
+  llvm::errs() << "Error: Please specify exactly one filename.\n";
+  return 1;
+}
+std::unique_ptr AST = getAST(SourcePath);
+if (!AST)
+  return 1;
+diff::SyntaxTree Tree(AST->getASTContext());
+Tree.printAsJson(llvm::outs());
+return 0;
+  }
+
+  if (DestinationPath.empty()) {
+llvm::errs() << "Error: Exactly two paths are required.\n";
+return 1;
+  }
+
+  std::unique_ptr Src = getAST(SourcePath);
+  std::unique_ptr Dst = getAST(DestinationPath);
+  if (!Src || !Dst)
+return 1;
+
+  diff::ComparisonOptions Options;
+  diff::SyntaxTree SrcTree(Src->getASTContext());
+  diff::SyntaxTree DstTree(Dst->getASTContext());
+  diff::ASTDiff DiffTool(SrcTree, DstTree, Options);
+  for (const auto &Match : DiffTool.getMatches())
+DiffTool.printMatch(llvm::outs(), Match);
+  for (const auto &Change : DiffTool.getChanges())
+DiffTool.printChange(llvm::outs(), Change);
+
+  return 0;
+}
Index: tools/clang-diff/CMakeLists.txt
===
--- /dev/null
+++ tools/clang-diff/CMakeLists.txt
@@ -0,0 +1,13 @@
+set(LLVM_LINK_COMPONENTS
+  Support
+  )
+
+add_clang_executable(clang-diff
+  ClangDiff.cpp
+  )
+
+target_link_libraries(clang-diff
+  clangFrontend
+  clangTooling
+  clangToolingASTDiff
+  )
Index: tools/CMakeLists.txt
===
--- tools/CMakeLists.txt
+++ tools/CMakeLists.txt
@@ -2,6 +2,7 @@
 
 add_clang_subdirectory(diagtool)
 add_clang_subdirectory(driver)
+add_clang_subdirectory(clang-diff)
 add_clang_subdirectory(clang-format)
 add_clang_subdirectory(clang-format-vs)
 add_clang_subdirectory(clang-fuzzer)
Index: test/Tooling/clang-diff-basic.cpp
=

[PATCH] D34784: [OpenMP] Add flag for specifying the target device architecture for OpenMP device offloading

2017-06-29 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

In https://reviews.llvm.org/D34784#795287, @hfinkel wrote:

> What happens if you have multiple targets? Maybe this should be 
> -fopenmp-targets-arch=foo,bar,whatever?
>
> Once this all lands, please make sure that you add additional test cases 
> here. Make sure that the arch is passed through to the ptx and cuda tools as 
> it should be. Make sure that the defaults work. Make sure that something 
> reasonable happens if the user specifies the option more than once (if 
> they're all the same).


Hi Hal,

At the moment only one arch is supported and it would apply to all the target 
triples under -fopenmp-targets.

I was planning to address the multiple archs problem in a future patch.

I am assuming that in the case of multiple archs, each arch in 
-fopenmp-targets-arch=A1,A2,A3 will bind to a corresponding triple in 
-fopenmp-targets=T1,T2,T3 like so: T1 with A1, T2 with A2 etc. Is this a 
practical interpretation of what should happen?

Regarding tests: more tests can be added as a separate patch once offloading is 
enabled by the patch following this one (i.e. https://reviews.llvm.org/D29654). 
There actually is a test in https://reviews.llvm.org/D29654 where I check that 
the arch is passed to ptxas and nvlink correctly using this flag. I will add 
some more test cases to cover the other situations you mentioned.

Thanks,

--Doru


Repository:
  rL LLVM

https://reviews.llvm.org/D34784



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


[PATCH] D34329: [clang-diff] Initial implementation.

2017-06-29 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes marked 2 inline comments as done.
johannes added inline comments.



Comment at: lib/Tooling/ASTDiff/ASTDiff.cpp:439
+// Computes an optimal mapping between two trees.
+class ZsMatcher {
+  const ASTDiff::Impl &DiffImpl;

arphaman wrote:
> Do you know the reason for the `ZsMatcher` name? I noticed that they used it 
> in the GumTree java implementation as well. If it's based on some paper you 
> should add a comment that mentions it.
Ok, i forgot about that, it's Zhang and Shasha's algorithm for the tree edit 
distance, basically computing the Levenshtein distance for ordered trees.


https://reviews.llvm.org/D34329



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


[PATCH] D34784: [OpenMP] Add flag for specifying the target device architecture for OpenMP device offloading

2017-06-29 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D34784#795353, @gtbercea wrote:

> In https://reviews.llvm.org/D34784#795287, @hfinkel wrote:
>
> > What happens if you have multiple targets? Maybe this should be 
> > -fopenmp-targets-arch=foo,bar,whatever?
> >
> > Once this all lands, please make sure that you add additional test cases 
> > here. Make sure that the arch is passed through to the ptx and cuda tools 
> > as it should be. Make sure that the defaults work. Make sure that something 
> > reasonable happens if the user specifies the option more than once (if 
> > they're all the same).
>
>
> Hi Hal,
>
> At the moment only one arch is supported and it would apply to all the target 
> triples under -fopenmp-targets.
>
> I was planning to address the multiple archs problem in a future patch.
>
> I am assuming that in the case of multiple archs, each arch in 
> -fopenmp-targets-arch=A1,A2,A3 will bind to a corresponding triple in 
> -fopenmp-targets=T1,T2,T3 like so: T1 with A1, T2 with A2 etc. Is this a 
> practical interpretation of what should happen?


Yea, that's what I was thinking. I'm a bit concerned that none of this 
generalizes well. To take a step back, under what circumstances do we support 
multiple targets right now?

> Regarding tests: more tests can be added as a separate patch once offloading 
> is enabled by the patch following this one (i.e. 
> https://reviews.llvm.org/D29654). There actually is a test in 
> https://reviews.llvm.org/D29654 where I check that the arch is passed to 
> ptxas and nvlink correctly using this flag. I will add some more test cases 
> to cover the other situations you mentioned.

Sounds good.

> Thanks,
> 
> --Doru




Repository:
  rL LLVM

https://reviews.llvm.org/D34784



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


[clang-tools-extra] r306705 - [clangd] Check failure of Lexer::getRawToken in GoToDeclaration.

2017-06-29 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Thu Jun 29 10:11:32 2017
New Revision: 306705

URL: http://llvm.org/viewvc/llvm-project?rev=306705&view=rev
Log:
[clangd] Check failure of Lexer::getRawToken in GoToDeclaration.

There was an access to unitialized memory because it wasn't checked.

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

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=306705&r1=306704&r2=306705&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Thu Jun 29 10:11:32 2017
@@ -400,8 +400,12 @@ SourceLocation ClangdUnit::getBeginningO
   Pos.character);
   const SourceManager &SourceMgr = Unit->getSourceManager();
   Token Result;
-  Lexer::getRawToken(PeekBeforeLocation, Result, SourceMgr,
-  Unit->getASTContext().getLangOpts(), false);
+  if (Lexer::getRawToken(PeekBeforeLocation, Result, SourceMgr,
+ Unit->getASTContext().getLangOpts(), false)) {
+// getRawToken failed, just use InputLocation.
+return InputLocation;
+  }
+
   if (Result.is(tok::raw_identifier)) {
 return Lexer::GetBeginningOfToken(PeekBeforeLocation, SourceMgr,
 Unit->getASTContext().getLangOpts());


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


[PATCH] D34633: [clang-tidy] Fix a bug in android-file-open-flag

2017-06-29 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh requested changes to this revision.
chh added a comment.
This revision now requires changes to proceed.

Please update the subject line and summary.
The new diff shows only the renaming of check name and file names.
Were the other changes for format and macro lost or are they
going to be in another change later?


https://reviews.llvm.org/D34633



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


[clang-tools-extra] r306708 - [clang-tidy][Part2] Add a new module Android and three new checks

2017-06-29 Thread Yan Wang via cfe-commits
Author: yawanng
Date: Thu Jun 29 10:40:57 2017
New Revision: 306708

URL: http://llvm.org/viewvc/llvm-project?rev=306708&view=rev
Log:
[clang-tidy][Part2] Add a new module Android and three new checks

Summary: -- creat() should be replaced by open(). [android-creat-usage] 

Reviewers: chh, alexfh, aaron.ballman, hokein

Reviewed By: hokein

Subscribers: JDevlieghere, srhines, mgorny, xazax.hun

Tags: #clang-tools-extra

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

Added:
clang-tools-extra/trunk/clang-tidy/android/CloexecCreatCheck.cpp
clang-tools-extra/trunk/clang-tidy/android/CloexecCreatCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/android-cloexec-creat.rst
clang-tools-extra/trunk/test/clang-tidy/android-cloexec-creat.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
clang-tools-extra/trunk/docs/ReleaseNotes.rst

Modified: clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp?rev=306708&r1=306707&r2=306708&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp Thu Jun 29 
10:40:57 2017
@@ -10,6 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "CloexecCreatCheck.h"
 #include "FileOpenFlagCheck.h"
 
 using namespace clang::ast_matchers;
@@ -23,6 +24,7 @@ class AndroidModule : public ClangTidyMo
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
 CheckFactories.registerCheck("android-file-open-flag");
+CheckFactories.registerCheck("android-cloexec-creat");
   }
 };
 

Modified: clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt?rev=306708&r1=306707&r2=306708&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt Thu Jun 29 
10:40:57 2017
@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyAndroidModule
   AndroidTidyModule.cpp
+  CloexecCreatCheck.cpp
   FileOpenFlagCheck.cpp
 
   LINK_LIBS

Added: clang-tools-extra/trunk/clang-tidy/android/CloexecCreatCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CloexecCreatCheck.cpp?rev=306708&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/android/CloexecCreatCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecCreatCheck.cpp Thu Jun 29 
10:40:57 2017
@@ -0,0 +1,59 @@
+//===--- CloexecCreatCheck.cpp - 
clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "CloexecCreatCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+void CloexecCreatCheck::registerMatchers(MatchFinder *Finder) {
+  auto CharPointerType = hasType(pointerType(pointee(isAnyCharacter(;
+  auto MODETType = hasType(namedDecl(hasName("mode_t")));
+
+  Finder->addMatcher(
+  callExpr(callee(functionDecl(isExternC(), returns(isInteger()),
+   hasName("creat"),
+   hasParameter(0, CharPointerType),
+   hasParameter(1, MODETType))
+  .bind("funcDecl")))
+  .bind("creatFn"),
+  this);
+}
+
+void CloexecCreatCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *MatchedCall = Result.Nodes.getNodeAs("creatFn");
+  const SourceManager &SM = *Result.SourceManager;
+
+  const std::string &ReplacementText =
+  (Twine("open (") +
+   Lexer::getSourceText(CharSourceRange::getTokenRange(
+MatchedCall->getArg(0)->getSourceRange()),
+SM, Result.Context->getLangOpts()) +
+   ", O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, " +
+   Lexer::getSourceText(CharSourceRange::getTokenRange(
+MatchedCall->getArg(1)->getSourceRange()),
+SM, Result.Context->getLangOpts()) +
+   ")")
+  .str();
+
+  diag(MatchedCall->getL

[clang-tools-extra] r306709 - [clang-tidy][Part3] Add a new module Android and three new checks.

2017-06-29 Thread Yan Wang via cfe-commits
Author: yawanng
Date: Thu Jun 29 10:42:23 2017
New Revision: 306709

URL: http://llvm.org/viewvc/llvm-project?rev=306709&view=rev
Log:
[clang-tidy][Part3] Add a new module Android and three new checks.

Summary: -- fopen() should include "e" in their mode string. 
[android-fopen-mode]

Reviewers: chh, alexfh, aaron.ballman, hokein

Reviewed By: hokein

Subscribers: JDevlieghere, srhines, mgorny, xazax.hun

Tags: #clang-tools-extra

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

Added:
clang-tools-extra/trunk/clang-tidy/android/CloexecFopenCheck.cpp
clang-tools-extra/trunk/clang-tidy/android/CloexecFopenCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/android-cloexec-fopen.rst
clang-tools-extra/trunk/test/clang-tidy/android-cloexec-fopen.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
clang-tools-extra/trunk/docs/ReleaseNotes.rst

Modified: clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp?rev=306709&r1=306708&r2=306709&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp Thu Jun 29 
10:42:23 2017
@@ -11,6 +11,7 @@
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
 #include "CloexecCreatCheck.h"
+#include "CloexecFopenCheck.h"
 #include "FileOpenFlagCheck.h"
 
 using namespace clang::ast_matchers;
@@ -25,6 +26,7 @@ public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
 CheckFactories.registerCheck("android-file-open-flag");
 CheckFactories.registerCheck("android-cloexec-creat");
+CheckFactories.registerCheck("android-cloexec-fopen");
   }
 };
 

Modified: clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt?rev=306709&r1=306708&r2=306709&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt Thu Jun 29 
10:42:23 2017
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS support)
 add_clang_library(clangTidyAndroidModule
   AndroidTidyModule.cpp
   CloexecCreatCheck.cpp
+  CloexecFopenCheck.cpp
   FileOpenFlagCheck.cpp
 
   LINK_LIBS

Added: clang-tools-extra/trunk/clang-tidy/android/CloexecFopenCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CloexecFopenCheck.cpp?rev=306709&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/android/CloexecFopenCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecFopenCheck.cpp Thu Jun 29 
10:42:23 2017
@@ -0,0 +1,74 @@
+//===--- CloexecFopenCheck.cpp - 
clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.  //
+//===--===//
+
+#include "CloexecFopenCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Type.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+namespace {
+static const char MODE = 'e';
+
+// Build the replace text. If it's string constant, add 'e' directly in the end
+// of the string. Else, add "e".
+std::string BuildReplaceText(const Expr *Arg, const SourceManager &SM,
+ const LangOptions &LangOpts) {
+  if (Arg->getLocStart().isMacroID())
+return (Lexer::getSourceText(
+CharSourceRange::getTokenRange(Arg->getSourceRange()), SM,
+LangOpts) +
+" \"" + Twine(MODE) + "\"")
+.str();
+
+  StringRef SR = cast(Arg->IgnoreParenCasts())->getString();
+  return ("\"" + SR + Twine(MODE) + "\"").str();
+}
+} // namespace
+
+void CloexecFopenCheck::registerMatchers(MatchFinder *Finder) {
+  auto CharPointerType = hasType(pointerType(pointee(isAnyCharacter(;
+
+  Finder->addMatcher(
+  callExpr(callee(functionDecl(isExternC(), returns(asString("FILE *")),
+   hasName("fopen"),
+   hasParameter(0, CharPointerType),
+   hasParameter(1, CharPointerType))
+  .bind("funcDecl")))
+  .bind("fopenFn"),
+  this);
+}
+
+void CloexecFopenCheck::check(const MatchFinder::MatchResult &Result) {

[PATCH] D34810: [Sema] -Wcomma should not warn for expressions that return void

2017-06-29 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I thought the intention of -Wcomma was to warn on practically all non-macro 
uses of the comma operator. I know it's silly to cast void to void, but I seem 
to recall that this was an intentional style-ish warning like -Wparentheses, 
which encourages `if ((x = y))` for intentional assignments in ifs.


Repository:
  rL LLVM

https://reviews.llvm.org/D34810



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


[PATCH] D34777: CodeGen: Fix invalid bitcast for coerced function argument

2017-06-29 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.

LGTM.


https://reviews.llvm.org/D34777



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


[PATCH] D34633: [clang-tidy] Fix a bug in android-file-open-flag

2017-06-29 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 104689.
yawanng added a comment.

Pull back the previous change. For some reason it's lost.


https://reviews.llvm.org/D34633

Files:
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/CloexecOpenCheck.cpp
  clang-tidy/android/CloexecOpenCheck.h
  clang-tidy/android/FileOpenFlagCheck.cpp
  clang-tidy/android/FileOpenFlagCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-cloexec-open.rst
  docs/clang-tidy/checks/android-file-open-flag.rst
  test/clang-tidy/android-cloexec-open.cpp
  test/clang-tidy/android-file-open-flag.cpp

Index: test/clang-tidy/android-file-open-flag.cpp
===
--- test/clang-tidy/android-file-open-flag.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-// RUN: %check_clang_tidy %s android-file-open-flag %t
-
-#define O_RDWR 1
-#define O_EXCL 2
-#define __O_CLOEXEC 3
-#define O_CLOEXEC __O_CLOEXEC
-
-extern "C" int open(const char *fn, int flags, ...);
-extern "C" int open64(const char *fn, int flags, ...);
-extern "C" int openat(int dirfd, const char *pathname, int flags, ...);
-
-void a() {
-  open("filename", O_RDWR);
-  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: 'open' should use O_CLOEXEC where possible [android-file-open-flag]
-  // CHECK-FIXES: O_RDWR | O_CLOEXEC
-  open("filename", O_RDWR | O_EXCL);
-  // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: 'open' should use O_CLOEXEC where
-  // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
-}
-
-void b() {
-  open64("filename", O_RDWR);
-  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: 'open64' should use O_CLOEXEC where possible [android-file-open-flag]
-  // CHECK-FIXES: O_RDWR | O_CLOEXEC
-  open64("filename", O_RDWR | O_EXCL);
-  // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: 'open64' should use O_CLOEXEC where
-  // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
-}
-
-void c() {
-  openat(0, "filename", O_RDWR);
-  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: 'openat' should use O_CLOEXEC where possible [android-file-open-flag]
-  // CHECK-FIXES: O_RDWR | O_CLOEXEC
-  openat(0, "filename", O_RDWR | O_EXCL);
-  // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: 'openat' should use O_CLOEXEC where
-  // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
-}
-
-void f() {
-  open("filename", 3);
-  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 'open' should use O_CLOEXEC where possible [android-file-open-flag]
-  // CHECK-FIXES: 3 | O_CLOEXEC
-  open64("filename", 3);
-  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'open64' should use O_CLOEXEC where possible [android-file-open-flag]
-  // CHECK-FIXES: 3 | O_CLOEXEC
-  openat(0, "filename", 3);
-  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: 'openat' should use O_CLOEXEC where possible [android-file-open-flag]
-  // CHECK-FIXES: 3 | O_CLOEXEC
-
-  int flag = 3;
-  open("filename", flag);
-  // CHECK-MESSAGES-NOT: warning:
-  open64("filename", flag);
-  // CHECK-MESSAGES-NOT: warning:
-  openat(0, "filename", flag);
-  // CHECK-MESSAGES-NOT: warning:
-}
-
-namespace i {
-int open(const char *pathname, int flags, ...);
-int open64(const char *pathname, int flags, ...);
-int openat(int dirfd, const char *pathname, int flags, ...);
-
-void d() {
-  open("filename", O_RDWR);
-  // CHECK-MESSAGES-NOT: warning:
-  open64("filename", O_RDWR);
-  // CHECK-MESSAGES-NOT: warning:
-  openat(0, "filename", O_RDWR);
-  // CHECK-MESSAGES-NOT: warning:
-}
-
-} // namespace i
-
-void e() {
-  open("filename", O_CLOEXEC);
-  // CHECK-MESSAGES-NOT: warning:
-  open("filename", O_RDWR | O_CLOEXEC);
-  // CHECK-MESSAGES-NOT: warning:
-  open("filename", O_RDWR | O_CLOEXEC | O_EXCL);
-  // CHECK-MESSAGES-NOT: warning:
-  open64("filename", O_CLOEXEC);
-  // CHECK-MESSAGES-NOT: warning:
-  open64("filename", O_RDWR | O_CLOEXEC);
-  // CHECK-MESSAGES-NOT: warning:
-  open64("filename", O_RDWR | O_CLOEXEC | O_EXCL);
-  // CHECK-MESSAGES-NOT: warning:
-  openat(0, "filename", O_CLOEXEC);
-  // CHECK-MESSAGES-NOT: warning:
-  openat(0, "filename", O_RDWR | O_CLOEXEC);
-  // CHECK-MESSAGES-NOT: warning:
-  openat(0, "filename", O_RDWR | O_CLOEXEC | O_EXCL);
-  // CHECK-MESSAGES-NOT: warning:
-}
-
-class G {
-public:
-  int open(const char *pathname, int flags, ...);
-  int open64(const char *pathname, int flags, ...);
-  int openat(int dirfd, const char *pathname, int flags, ...);
-
-  void h() {
-open("filename", O_RDWR);
-// CHECK-MESSAGES-NOT: warning:
-open64("filename", O_RDWR);
-// CHECK-MESSAGES-NOT: warning:
-openat(0, "filename", O_RDWR);
-// CHECK-MESSAGES-NOT: warning:
-  }
-};
Index: test/clang-tidy/android-cloexec-open.cpp
===
--- /dev/null
+++ test/clang-tidy/android-cloexec-open.cpp
@@ -0,0 +1,180 @@
+// RUN: %check_clang_tidy %s android-cloexec-open %t
+
+#define O_RDWR 1
+#define O_EXCL 2
+#define __O_CLOEXEC 3
+#define O_CLOEXEC __O_CLOEXEC
+#define TEMP_FAILURE_RETRY(exp) \
+  ({ 

r306715 - Fixed -Wexceptions derived-to-base false positives

2017-06-29 Thread Stephan Bergmann via cfe-commits
Author: sberg
Date: Thu Jun 29 10:58:59 2017
New Revision: 306715

URL: http://llvm.org/viewvc/llvm-project?rev=306715&view=rev
Log:
Fixed -Wexceptions derived-to-base false positives

...as introduced with recent  "Emit warning
when throw exception in destruct or dealloc functions which has a (possible
implicit) noexcept specifier".  (The equivalent of the goodReference case hit
when building LibreOffice.)

(These warnings are apparently only emitted when no errors have yet been
encountered, so it didn't work to add the test code to the end of the existing
clang/test/SemaCXX/exceptions.cpp.)

Added:
cfe/trunk/test/SemaCXX/exception-warnings.cpp
Modified:
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp

Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=306715&r1=306714&r2=306715&view=diff
==
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Thu Jun 29 10:58:59 2017
@@ -305,10 +305,14 @@ static bool isThrowCaught(const CXXThrow
 CaughtType = CaughtType->castAs()
  ->getPointeeType()
  ->getUnqualifiedDesugaredType();
+  if (ThrowType->isPointerType() && CaughtType->isPointerType()) {
+ThrowType = ThrowType->getPointeeType()->getUnqualifiedDesugaredType();
+CaughtType = CaughtType->getPointeeType()->getUnqualifiedDesugaredType();
+  }
   if (CaughtType == ThrowType)
 return true;
   const CXXRecordDecl *CaughtAsRecordType =
-  CaughtType->getPointeeCXXRecordDecl();
+  CaughtType->getAsCXXRecordDecl();
   const CXXRecordDecl *ThrowTypeAsRecordType = ThrowType->getAsCXXRecordDecl();
   if (CaughtAsRecordType && ThrowTypeAsRecordType)
 return ThrowTypeAsRecordType->isDerivedFrom(CaughtAsRecordType);

Added: cfe/trunk/test/SemaCXX/exception-warnings.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/exception-warnings.cpp?rev=306715&view=auto
==
--- cfe/trunk/test/SemaCXX/exception-warnings.cpp (added)
+++ cfe/trunk/test/SemaCXX/exception-warnings.cpp Thu Jun 29 10:58:59 2017
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s
+
+struct B {};
+struct D: B {};
+void goodPlain() throw () {
+  try {
+throw D();
+  } catch (B) {}
+}
+void goodReference() throw () {
+  try {
+throw D();
+  } catch (B &) {}
+}
+void goodPointer() throw () {
+  D d;
+  try {
+throw &d;
+  } catch (B *) {}
+}
+void badPlain() throw () { // expected-note {{non-throwing function declare 
here}}
+  try {
+throw B(); // expected-warning {{'badPlain' has a non-throwing exception 
specification but can still throw, resulting in unexpected program termination}}
+  } catch (D) {}
+}
+void badReference() throw () { // expected-note {{non-throwing function 
declare here}}
+  try {
+throw B(); // expected-warning {{'badReference' has a non-throwing 
exception specification but can still throw, resulting in unexpected program 
termination}}
+  } catch (D &) {}
+}
+void badPointer() throw () { // expected-note {{non-throwing function declare 
here}}
+  B b;
+  try {
+throw &b; // expected-warning {{'badPointer' has a non-throwing exception 
specification but can still throw, resulting in unexpected program termination}}
+  } catch (D *) {}
+}


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


[PATCH] D33333: Emit warning when throw exception in destruct or dealloc functions which has a (possible implicit) noexcept specifier

2017-06-29 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg added a comment.

see also https://reviews.llvm.org/rL306715 "Fixed -Wexceptions derived-to-base 
false positives"


Repository:
  rL LLVM

https://reviews.llvm.org/D3



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


[PATCH] D34801: [coverage] Make smaller regions for the first case of a switch.

2017-06-29 Thread Vedant Kumar via Phabricator via cfe-commits
vsk accepted this revision.
vsk added a comment.
This revision is now accepted and ready to land.

Thanks for the patch! LGTM.




Comment at: lib/CodeGen/CoverageMappingGen.cpp:686
+// FIXME: a break in a switch should terminate regions for all preceding
+// case statements, not just the most recent one.
 terminateRegion(S);

As should return/continue.


Repository:
  rL LLVM

https://reviews.llvm.org/D34801



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


[PATCH] D34824: clang-format: add an option -verbose to list the files being processed

2017-06-29 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru created this revision.
sylvestre.ledru added a project: clang.

https://reviews.llvm.org/D34824

Files:
  docs/ClangFormat.rst
  docs/ReleaseNotes.rst
  tools/clang-format/ClangFormat.cpp


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -176,6 +176,9 @@
 * Comment reflow support added. Overly long comment lines will now be reflown 
with the rest of
   the paragraph instead of just broken. Option **ReflowComments** added and 
enabled by default.
 
+* Option -verbose added to the command line.
+  Shows the list of processed files.
+
 libclang
 
 
Index: docs/ClangFormat.rst
===
--- docs/ClangFormat.rst
+++ docs/ClangFormat.rst
@@ -71,6 +71,7 @@
 Use -style="{key: value, ...}" to set specific
 parameters, e.g.:
   -style="{BasedOnStyle: llvm, IndentWidth: 8}"
+-verbose  - If set, shows the list of processed files
 
   Generic Options:
 
Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -102,6 +102,11 @@
  "SortIncludes style flag"),
 cl::cat(ClangFormatCategory));
 
+static cl::opt Verbose(
+"verbose",
+cl::desc("If set, shows the list of processed files"),
+cl::cat(ClangFormatCategory));
+
 static cl::list FileNames(cl::Positional, cl::desc("[ 
...]"),
cl::cat(ClangFormatCategory));
 
@@ -371,15 +376,20 @@
 break;
   case 1:
 Error = clang::format::format(FileNames[0]);
+if (Verbose.getNumOccurrences() != 0)
+outs() << "Formatting " << FileNames[0] << '\n';
 break;
   default:
 if (!Offsets.empty() || !Lengths.empty() || !LineRanges.empty()) {
   errs() << "error: -offset, -length and -lines can only be used for "
 "single file.\n";
   return 1;
 }
-for (unsigned i = 0; i < FileNames.size(); ++i)
+for (unsigned i = 0; i < FileNames.size(); ++i) {
   Error |= clang::format::format(FileNames[i]);
+  if (Verbose.getNumOccurrences() != 0)
+  outs() << "Formatting " << FileNames[i] << '\n';
+}
 break;
   }
   return Error ? 1 : 0;


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -176,6 +176,9 @@
 * Comment reflow support added. Overly long comment lines will now be reflown with the rest of
   the paragraph instead of just broken. Option **ReflowComments** added and enabled by default.
 
+* Option -verbose added to the command line.
+  Shows the list of processed files.
+
 libclang
 
 
Index: docs/ClangFormat.rst
===
--- docs/ClangFormat.rst
+++ docs/ClangFormat.rst
@@ -71,6 +71,7 @@
 Use -style="{key: value, ...}" to set specific
 parameters, e.g.:
   -style="{BasedOnStyle: llvm, IndentWidth: 8}"
+-verbose  - If set, shows the list of processed files
 
   Generic Options:
 
Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -102,6 +102,11 @@
  "SortIncludes style flag"),
 cl::cat(ClangFormatCategory));
 
+static cl::opt Verbose(
+"verbose",
+cl::desc("If set, shows the list of processed files"),
+cl::cat(ClangFormatCategory));
+
 static cl::list FileNames(cl::Positional, cl::desc("[ ...]"),
cl::cat(ClangFormatCategory));
 
@@ -371,15 +376,20 @@
 break;
   case 1:
 Error = clang::format::format(FileNames[0]);
+if (Verbose.getNumOccurrences() != 0)
+outs() << "Formatting " << FileNames[0] << '\n';
 break;
   default:
 if (!Offsets.empty() || !Lengths.empty() || !LineRanges.empty()) {
   errs() << "error: -offset, -length and -lines can only be used for "
 "single file.\n";
   return 1;
 }
-for (unsigned i = 0; i < FileNames.size(); ++i)
+for (unsigned i = 0; i < FileNames.size(); ++i) {
   Error |= clang::format::format(FileNames[i]);
+  if (Verbose.getNumOccurrences() != 0)
+  outs() << "Formatting " << FileNames[i] << '\n';
+}
 break;
   }
   return Error ? 1 : 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34633: [clang-tidy] Rename android-file-open-flag and fix a bug

2017-06-29 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh added a comment.

I think you also need to change docs/clang-tidy/checks/list.rst.


https://reviews.llvm.org/D34633



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


[clang-tools-extra] r306719 - [clang-tidy] Add docs to toctree

2017-06-29 Thread Yan Wang via cfe-commits
Author: yawanng
Date: Thu Jun 29 11:44:28 2017
New Revision: 306719

URL: http://llvm.org/viewvc/llvm-project?rev=306719&view=rev
Log:
[clang-tidy] Add docs to toctree

Summary: Add .rst files to toctree. Fix buildbot error.

Reviewers: chh

Reviewed By: chh

Subscribers: srhines, JDevlieghere, xazax.hun

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

Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst?rev=306719&r1=306718&r2=306719&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst Thu Jun 29 11:44:28 
2017
@@ -4,6 +4,8 @@ Clang-Tidy Checks
 =
 
 .. toctree::
+   android-cloexec-creat
+   android-cloexec-fopen
android-file-open-flag
boost-use-to-string
cert-dcl03-c (redirects to misc-static-assert) 


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


[PATCH] D34633: [clang-tidy] Rename android-file-open-flag and fix a bug

2017-06-29 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 104709.
yawanng added a comment.

Change the file name in toctree.


https://reviews.llvm.org/D34633

Files:
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/CloexecOpenCheck.cpp
  clang-tidy/android/CloexecOpenCheck.h
  clang-tidy/android/FileOpenFlagCheck.cpp
  clang-tidy/android/FileOpenFlagCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-cloexec-open.rst
  docs/clang-tidy/checks/android-file-open-flag.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/android-cloexec-open.cpp
  test/clang-tidy/android-file-open-flag.cpp

Index: test/clang-tidy/android-file-open-flag.cpp
===
--- test/clang-tidy/android-file-open-flag.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-// RUN: %check_clang_tidy %s android-file-open-flag %t
-
-#define O_RDWR 1
-#define O_EXCL 2
-#define __O_CLOEXEC 3
-#define O_CLOEXEC __O_CLOEXEC
-
-extern "C" int open(const char *fn, int flags, ...);
-extern "C" int open64(const char *fn, int flags, ...);
-extern "C" int openat(int dirfd, const char *pathname, int flags, ...);
-
-void a() {
-  open("filename", O_RDWR);
-  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: 'open' should use O_CLOEXEC where possible [android-file-open-flag]
-  // CHECK-FIXES: O_RDWR | O_CLOEXEC
-  open("filename", O_RDWR | O_EXCL);
-  // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: 'open' should use O_CLOEXEC where
-  // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
-}
-
-void b() {
-  open64("filename", O_RDWR);
-  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: 'open64' should use O_CLOEXEC where possible [android-file-open-flag]
-  // CHECK-FIXES: O_RDWR | O_CLOEXEC
-  open64("filename", O_RDWR | O_EXCL);
-  // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: 'open64' should use O_CLOEXEC where
-  // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
-}
-
-void c() {
-  openat(0, "filename", O_RDWR);
-  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: 'openat' should use O_CLOEXEC where possible [android-file-open-flag]
-  // CHECK-FIXES: O_RDWR | O_CLOEXEC
-  openat(0, "filename", O_RDWR | O_EXCL);
-  // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: 'openat' should use O_CLOEXEC where
-  // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
-}
-
-void f() {
-  open("filename", 3);
-  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 'open' should use O_CLOEXEC where possible [android-file-open-flag]
-  // CHECK-FIXES: 3 | O_CLOEXEC
-  open64("filename", 3);
-  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'open64' should use O_CLOEXEC where possible [android-file-open-flag]
-  // CHECK-FIXES: 3 | O_CLOEXEC
-  openat(0, "filename", 3);
-  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: 'openat' should use O_CLOEXEC where possible [android-file-open-flag]
-  // CHECK-FIXES: 3 | O_CLOEXEC
-
-  int flag = 3;
-  open("filename", flag);
-  // CHECK-MESSAGES-NOT: warning:
-  open64("filename", flag);
-  // CHECK-MESSAGES-NOT: warning:
-  openat(0, "filename", flag);
-  // CHECK-MESSAGES-NOT: warning:
-}
-
-namespace i {
-int open(const char *pathname, int flags, ...);
-int open64(const char *pathname, int flags, ...);
-int openat(int dirfd, const char *pathname, int flags, ...);
-
-void d() {
-  open("filename", O_RDWR);
-  // CHECK-MESSAGES-NOT: warning:
-  open64("filename", O_RDWR);
-  // CHECK-MESSAGES-NOT: warning:
-  openat(0, "filename", O_RDWR);
-  // CHECK-MESSAGES-NOT: warning:
-}
-
-} // namespace i
-
-void e() {
-  open("filename", O_CLOEXEC);
-  // CHECK-MESSAGES-NOT: warning:
-  open("filename", O_RDWR | O_CLOEXEC);
-  // CHECK-MESSAGES-NOT: warning:
-  open("filename", O_RDWR | O_CLOEXEC | O_EXCL);
-  // CHECK-MESSAGES-NOT: warning:
-  open64("filename", O_CLOEXEC);
-  // CHECK-MESSAGES-NOT: warning:
-  open64("filename", O_RDWR | O_CLOEXEC);
-  // CHECK-MESSAGES-NOT: warning:
-  open64("filename", O_RDWR | O_CLOEXEC | O_EXCL);
-  // CHECK-MESSAGES-NOT: warning:
-  openat(0, "filename", O_CLOEXEC);
-  // CHECK-MESSAGES-NOT: warning:
-  openat(0, "filename", O_RDWR | O_CLOEXEC);
-  // CHECK-MESSAGES-NOT: warning:
-  openat(0, "filename", O_RDWR | O_CLOEXEC | O_EXCL);
-  // CHECK-MESSAGES-NOT: warning:
-}
-
-class G {
-public:
-  int open(const char *pathname, int flags, ...);
-  int open64(const char *pathname, int flags, ...);
-  int openat(int dirfd, const char *pathname, int flags, ...);
-
-  void h() {
-open("filename", O_RDWR);
-// CHECK-MESSAGES-NOT: warning:
-open64("filename", O_RDWR);
-// CHECK-MESSAGES-NOT: warning:
-openat(0, "filename", O_RDWR);
-// CHECK-MESSAGES-NOT: warning:
-  }
-};
Index: test/clang-tidy/android-cloexec-open.cpp
===
--- /dev/null
+++ test/clang-tidy/android-cloexec-open.cpp
@@ -0,0 +1,180 @@
+// RUN: %check_clang_tidy %s android-cloexec-open %t
+
+#define O_RDWR 1
+#define O_EXCL 2
+#define __O_CLOEXEC 3
+#define O_CLOEXEC __O_CLOEXEC
+#define TEMP_FAILURE_RETRY(exp) \
+  ({

r306721 - CodeGen: Fix invalid bitcast for coerced function argument

2017-06-29 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Thu Jun 29 11:47:45 2017
New Revision: 306721

URL: http://llvm.org/viewvc/llvm-project?rev=306721&view=rev
Log:
CodeGen: Fix invalid bitcast for coerced function argument

Clang assumes coerced function argument is in address space 0, which is not 
always true and results in invalid bitcasts.

This patch fixes failure in OpenCL conformance test api/get_kernel_arg_info 
with amdgcn---amdgizcl triple, where non-zero alloca address space is used.

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

Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/test/CodeGenOpenCL/addr-space-struct-arg.cl

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=306721&r1=306720&r2=306721&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Jun 29 11:47:45 2017
@@ -1297,7 +1297,7 @@ static void CreateCoercedStore(llvm::Val
 
   // If store is legal, just bitcast the src pointer.
   if (SrcSize <= DstSize) {
-Dst = CGF.Builder.CreateBitCast(Dst, llvm::PointerType::getUnqual(SrcTy));
+Dst = CGF.Builder.CreateElementBitCast(Dst, SrcTy);
 BuildAggStore(CGF, Src, Dst, DstIsVolatile);
   } else {
 // Otherwise do coercion through memory. This is stupid, but
@@ -2412,8 +2412,7 @@ void CodeGenFunction::EmitFunctionProlog
 
 Address AddrToStoreInto = Address::invalid();
 if (SrcSize <= DstSize) {
-  AddrToStoreInto =
-Builder.CreateBitCast(Ptr, llvm::PointerType::getUnqual(STy));
+  AddrToStoreInto = Builder.CreateElementBitCast(Ptr, STy);
 } else {
   AddrToStoreInto =
 CreateTempAlloca(STy, Alloca.getAlignment(), "coerce");

Modified: cfe/trunk/test/CodeGenOpenCL/addr-space-struct-arg.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/addr-space-struct-arg.cl?rev=306721&r1=306720&r2=306721&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/addr-space-struct-arg.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/addr-space-struct-arg.cl Thu Jun 29 11:47:45 
2017
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -ffake-address-space-map -triple 
i686-pc-darwin | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -finclude-default-header 
-ffake-address-space-map -triple i686-pc-darwin | FileCheck 
-check-prefixes=COM,X86 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -finclude-default-header -triple 
amdgcn-amdhsa-amd-amdgizcl | FileCheck -check-prefixes=COM,AMD %s
 
 typedef struct {
   int cells[9];
@@ -8,16 +9,57 @@ typedef struct {
   int cells[16];
 } Mat4X4;
 
+struct StructOneMember {
+  int2 x;
+};
+
+struct StructTwoMember {
+  int2 x;
+  int2 y;
+};
+
+// COM-LABEL: define void @foo
 Mat4X4 __attribute__((noinline)) foo(Mat3X3 in) {
   Mat4X4 out;
   return out;
 }
 
+// COM-LABEL: define {{.*}} void @ker
+// Expect two mem copies: one for the argument "in", and one for
+// the return value.
+// X86: call void @llvm.memcpy.p0i8.p1i8.i32(i8*
+// X86: call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)*
+// AMD: call void @llvm.memcpy.p5i8.p1i8.i64(i8 addrspace(5)*
+// AMD: call void @llvm.memcpy.p1i8.p5i8.i64(i8 addrspace(1)*
 kernel void ker(global Mat3X3 *in, global Mat4X4 *out) {
   out[0] = foo(in[1]);
 }
 
-// Expect two mem copies: one for the argument "in", and one for
-// the return value.
-// CHECK: call void @llvm.memcpy.p0i8.p1i8.i32(i8*
-// CHECK: call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)*
+// AMD-LABEL: define void @FuncOneMember(%struct.StructOneMember addrspace(5)* 
byval align 8 %u)
+void FuncOneMember(struct StructOneMember u) {
+  u.x = (int2)(0, 0);
+}
+
+// AMD-LABEL: define amdgpu_kernel void @KernelOneMember
+// AMD-SAME:  (<2 x i32> %[[u_coerce:.*]])
+// AMD:  %[[u:.*]] = alloca %struct.StructOneMember, align 8, addrspace(5)
+// AMD:  %[[coerce_dive:.*]] = getelementptr inbounds %struct.StructOneMember, 
%struct.StructOneMember addrspace(5)* %[[u]], i32 0, i32 0
+// AMD:  store <2 x i32> %[[u_coerce]], <2 x i32> addrspace(5)* 
%[[coerce_dive]]
+// AMD:  call void @FuncOneMember(%struct.StructOneMember addrspace(5)* byval 
align 8 %[[u]])
+kernel void KernelOneMember(struct StructOneMember u) {
+  FuncOneMember(u);
+}
+
+// AMD-LABEL: define void @FuncTwoMember(%struct.StructTwoMember addrspace(5)* 
byval align 8 %u)
+void FuncTwoMember(struct StructTwoMember u) {
+  u.x = (int2)(0, 0);
+}
+
+// AMD-LABEL: define amdgpu_kernel void @KernelTwoMember
+// AMD-SAME:  (%struct.StructTwoMember %[[u_coerce:.*]])
+// AMD:  %[[u:.*]] = alloca %struct.StructTwoMember, align 8, addrspace(5)
+// AMD:  store %struct.StructTwoMember %[[u_coerce]], %struct.StructTwoMember 
addrspace(5)* %[[u]]
+// AMD:  call void @FuncTwoMember(%struct.StructTwoMember addrspace(5)* byval 
align 8 %[[u]])
+kernel

[PATCH] D34777: CodeGen: Fix invalid bitcast for coerced function argument

2017-06-29 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL306721: CodeGen: Fix invalid bitcast for coerced function 
argument (authored by yaxunl).

Changed prior to commit:
  https://reviews.llvm.org/D34777?vs=104505&id=104711#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34777

Files:
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/test/CodeGenOpenCL/addr-space-struct-arg.cl


Index: cfe/trunk/test/CodeGenOpenCL/addr-space-struct-arg.cl
===
--- cfe/trunk/test/CodeGenOpenCL/addr-space-struct-arg.cl
+++ cfe/trunk/test/CodeGenOpenCL/addr-space-struct-arg.cl
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -ffake-address-space-map -triple 
i686-pc-darwin | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -finclude-default-header 
-ffake-address-space-map -triple i686-pc-darwin | FileCheck 
-check-prefixes=COM,X86 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -finclude-default-header -triple 
amdgcn-amdhsa-amd-amdgizcl | FileCheck -check-prefixes=COM,AMD %s
 
 typedef struct {
   int cells[9];
@@ -8,16 +9,57 @@
   int cells[16];
 } Mat4X4;
 
+struct StructOneMember {
+  int2 x;
+};
+
+struct StructTwoMember {
+  int2 x;
+  int2 y;
+};
+
+// COM-LABEL: define void @foo
 Mat4X4 __attribute__((noinline)) foo(Mat3X3 in) {
   Mat4X4 out;
   return out;
 }
 
+// COM-LABEL: define {{.*}} void @ker
+// Expect two mem copies: one for the argument "in", and one for
+// the return value.
+// X86: call void @llvm.memcpy.p0i8.p1i8.i32(i8*
+// X86: call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)*
+// AMD: call void @llvm.memcpy.p5i8.p1i8.i64(i8 addrspace(5)*
+// AMD: call void @llvm.memcpy.p1i8.p5i8.i64(i8 addrspace(1)*
 kernel void ker(global Mat3X3 *in, global Mat4X4 *out) {
   out[0] = foo(in[1]);
 }
 
-// Expect two mem copies: one for the argument "in", and one for
-// the return value.
-// CHECK: call void @llvm.memcpy.p0i8.p1i8.i32(i8*
-// CHECK: call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)*
+// AMD-LABEL: define void @FuncOneMember(%struct.StructOneMember addrspace(5)* 
byval align 8 %u)
+void FuncOneMember(struct StructOneMember u) {
+  u.x = (int2)(0, 0);
+}
+
+// AMD-LABEL: define amdgpu_kernel void @KernelOneMember
+// AMD-SAME:  (<2 x i32> %[[u_coerce:.*]])
+// AMD:  %[[u:.*]] = alloca %struct.StructOneMember, align 8, addrspace(5)
+// AMD:  %[[coerce_dive:.*]] = getelementptr inbounds %struct.StructOneMember, 
%struct.StructOneMember addrspace(5)* %[[u]], i32 0, i32 0
+// AMD:  store <2 x i32> %[[u_coerce]], <2 x i32> addrspace(5)* 
%[[coerce_dive]]
+// AMD:  call void @FuncOneMember(%struct.StructOneMember addrspace(5)* byval 
align 8 %[[u]])
+kernel void KernelOneMember(struct StructOneMember u) {
+  FuncOneMember(u);
+}
+
+// AMD-LABEL: define void @FuncTwoMember(%struct.StructTwoMember addrspace(5)* 
byval align 8 %u)
+void FuncTwoMember(struct StructTwoMember u) {
+  u.x = (int2)(0, 0);
+}
+
+// AMD-LABEL: define amdgpu_kernel void @KernelTwoMember
+// AMD-SAME:  (%struct.StructTwoMember %[[u_coerce:.*]])
+// AMD:  %[[u:.*]] = alloca %struct.StructTwoMember, align 8, addrspace(5)
+// AMD:  store %struct.StructTwoMember %[[u_coerce]], %struct.StructTwoMember 
addrspace(5)* %[[u]]
+// AMD:  call void @FuncTwoMember(%struct.StructTwoMember addrspace(5)* byval 
align 8 %[[u]])
+kernel void KernelTwoMember(struct StructTwoMember u) {
+  FuncTwoMember(u);
+}
Index: cfe/trunk/lib/CodeGen/CGCall.cpp
===
--- cfe/trunk/lib/CodeGen/CGCall.cpp
+++ cfe/trunk/lib/CodeGen/CGCall.cpp
@@ -1297,7 +1297,7 @@
 
   // If store is legal, just bitcast the src pointer.
   if (SrcSize <= DstSize) {
-Dst = CGF.Builder.CreateBitCast(Dst, llvm::PointerType::getUnqual(SrcTy));
+Dst = CGF.Builder.CreateElementBitCast(Dst, SrcTy);
 BuildAggStore(CGF, Src, Dst, DstIsVolatile);
   } else {
 // Otherwise do coercion through memory. This is stupid, but
@@ -2412,8 +2412,7 @@
 
 Address AddrToStoreInto = Address::invalid();
 if (SrcSize <= DstSize) {
-  AddrToStoreInto =
-Builder.CreateBitCast(Ptr, llvm::PointerType::getUnqual(STy));
+  AddrToStoreInto = Builder.CreateElementBitCast(Ptr, STy);
 } else {
   AddrToStoreInto =
 CreateTempAlloca(STy, Alloca.getAlignment(), "coerce");


Index: cfe/trunk/test/CodeGenOpenCL/addr-space-struct-arg.cl
===
--- cfe/trunk/test/CodeGenOpenCL/addr-space-struct-arg.cl
+++ cfe/trunk/test/CodeGenOpenCL/addr-space-struct-arg.cl
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -ffake-address-space-map -triple i686-pc-darwin | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -finclude-default-header -ffake-address-space-map -triple i686-pc-darwin | FileCheck -check-prefixes=COM,X86 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -finclude-default-head

[PATCH] D34574: [Sema] Disable c++17 aligned new and delete operators if not implemented in the deployment target's c++ standard library

2017-06-29 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL306722: [Sema] Issue diagnostics if a new/delete expression 
generates a call to (authored by ahatanak).

Changed prior to commit:
  https://reviews.llvm.org/D34574?vs=104579&id=104712#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34574

Files:
  cfe/trunk/include/clang/AST/Decl.h
  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Basic/LangOptions.def
  cfe/trunk/include/clang/Driver/CC1Options.td
  cfe/trunk/lib/AST/Decl.cpp
  cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
  cfe/trunk/lib/Driver/ToolChains/Darwin.h
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp
  cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp

Index: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
@@ -1667,6 +1667,27 @@
   AddLinkRuntimeLib(Args, CmdArgs, CompilerRT, false, true);
 }
 
+bool Darwin::isAlignedAllocationUnavailable() const {
+  switch (TargetPlatform) {
+  case MacOS: // Earlier than 10.13.
+return TargetVersion < VersionTuple(10U, 13U, 0U);
+  case IPhoneOS:
+  case IPhoneOSSimulator:
+  case TvOS:
+  case TvOSSimulator: // Earlier than 11.0.
+return TargetVersion < VersionTuple(11U, 0U, 0U);
+  case WatchOS:
+  case WatchOSSimulator: // Earlier than 4.0.
+return TargetVersion < VersionTuple(4U, 0U, 0U);
+  }
+}
+
+void Darwin::addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
+   llvm::opt::ArgStringList &CC1Args) const {
+  if (isAlignedAllocationUnavailable())
+CC1Args.push_back("-faligned-alloc-unavailable");
+}
+
 DerivedArgList *
 Darwin::TranslateArgs(const DerivedArgList &Args, StringRef BoundArch,
   Action::OffloadKind DeviceOffloadKind) const {
Index: cfe/trunk/lib/Driver/ToolChains/Darwin.h
===
--- cfe/trunk/lib/Driver/ToolChains/Darwin.h
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.h
@@ -384,6 +384,14 @@
 return TargetVersion < VersionTuple(V0, V1, V2);
   }
 
+  /// Return true if c++17 aligned allocation/deallocation functions are not
+  /// implemented in the c++ standard library of the deployment target we are
+  /// targeting.
+  bool isAlignedAllocationUnavailable() const;
+
+  void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) const override;
+
   StringRef getPlatformFamily() const;
   static StringRef getSDKName(StringRef isysroot);
   StringRef getOSLibraryNameSuffix() const;
Index: cfe/trunk/lib/AST/Decl.cpp
===
--- cfe/trunk/lib/AST/Decl.cpp
+++ cfe/trunk/lib/AST/Decl.cpp
@@ -2630,7 +2630,7 @@
   return (proto->getParamType(1).getCanonicalType() == Context.VoidPtrTy);
 }
 
-bool FunctionDecl::isReplaceableGlobalAllocationFunction() const {
+bool FunctionDecl::isReplaceableGlobalAllocationFunction(bool *IsAligned) const {
   if (getDeclName().getNameKind() != DeclarationName::CXXOperatorName)
 return false;
   if (getDeclName().getCXXOverloadedOperator() != OO_New &&
@@ -2676,8 +2676,11 @@
 
   // In C++17, the next parameter can be a 'std::align_val_t' for aligned
   // new/delete.
-  if (Ctx.getLangOpts().AlignedAllocation && !Ty.isNull() && Ty->isAlignValT())
+  if (Ctx.getLangOpts().AlignedAllocation && !Ty.isNull() && Ty->isAlignValT()) {
+if (IsAligned)
+  *IsAligned = true;
 Consume();
+  }
 
   // Finally, if this is not a sized delete, the final parameter can
   // be a 'const std::nothrow_t&'.
Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -1646,6 +1646,27 @@
   return false;
 }
 
+// Emit a diagnostic if an aligned allocation/deallocation function that is not
+// implemented in the standard library is selected.
+static void diagnoseUnavailableAlignedAllocation(const FunctionDecl &FD,
+ SourceLocation Loc, bool IsDelete,
+ Sema &S) {
+  if (!S.getLangOpts().AlignedAllocationUnavailable)
+return;
+
+  // Return if there is a definition.
+  if (FD.isDefined())
+return;
+
+  bool IsAligned = false;
+  if (FD.isReplaceableGlobalAllocationFunction(&IsAligned) && IsAligned) {
+S.Diag(Loc, diag::warn_aligned_allocation_unavailable)
+ << IsDelete << FD.getType().getAsString()
+ << S.getASTContext().getTargetInfo().getTriple().str();
+S.Diag(Loc, diag::note_silence_unligned_allocation_unavailable);

r306722 - [Sema] Issue diagnostics if a new/delete expression generates a call to

2017-06-29 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Jun 29 11:48:40 2017
New Revision: 306722

URL: http://llvm.org/viewvc/llvm-project?rev=306722&view=rev
Log:
[Sema] Issue diagnostics if a new/delete expression generates a call to
a c++17 aligned allocation/deallocation function that is unavailable in
the standard library on Apple platforms.

The aligned functions are implemented only in the following versions or
later versions of the OSes, so clang issues diagnostics if the deployment
target being targeted is older than these:

macosx: 10.13
ios: 11.0
tvos: 11.0
watchos: 4.0

The diagnostics are issued whenever the aligned functions are selected
except when the selected function has a definition in the same file.
If there is a user-defined function available somewhere else, option
-Wno-aligned-allocation-unavailable can be used to silence the
diagnostics.

rdar://problem/32664169

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

Added:
cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp
cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/lib/Driver/ToolChains/Darwin.h
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=306722&r1=306721&r2=306722&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Thu Jun 29 11:48:40 2017
@@ -2019,7 +2019,10 @@ public:
   /// These functions have special behavior under C++1y [expr.new]:
   ///An implementation is allowed to omit a call to a replaceable global
   ///allocation function. [...]
-  bool isReplaceableGlobalAllocationFunction() const;
+  ///
+  /// If this function is an aligned allocation/deallocation function, return
+  /// true through IsAligned.
+  bool isReplaceableGlobalAllocationFunction(bool *IsAligned = nullptr) const;
 
   /// Compute the language linkage.
   LanguageLinkage getLanguageLinkage() const;

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=306722&r1=306721&r2=306722&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Jun 29 11:48:40 2017
@@ -311,6 +311,7 @@ def : DiagGroup<"nonportable-cfstrings">
 def NonVirtualDtor : DiagGroup<"non-virtual-dtor">;
 def : DiagGroup<"effc++", [NonVirtualDtor]>;
 def OveralignedType : DiagGroup<"over-aligned">;
+def AlignedAllocationUnavailable : DiagGroup<"aligned-allocation-unavailable">;
 def OldStyleCast : DiagGroup<"old-style-cast">;
 def : DiagGroup<"old-style-definition">;
 def OutOfLineDeclaration : DiagGroup<"out-of-line-declaration">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=306722&r1=306721&r2=306722&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jun 29 11:48:40 
2017
@@ -6407,6 +6407,12 @@ def warn_overaligned_type : Warning<
   "type %0 requires %1 bytes of alignment and the default allocator only "
   "guarantees %2 bytes">,
   InGroup, DefaultIgnore;
+def warn_aligned_allocation_unavailable :Warning<
+  "aligned %select{allocation|deallocation}0 function of type '%1' possibly "
+  "unavailable on %2">, InGroup, DefaultError;
+def note_silence_unligned_allocation_unavailable : Note<
+  "if you supply your own aligned allocation functions, use "
+  "-Wno-aligned-allocation-unavailable to silence this diagnostic">;
 
 def err_conditional_void_nonvoid : Error<
   "%select{left|right}1 operand to ? is void, but %select{right|left}1 operand 
"

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=306722&r1=306721&r2=306722&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Thu Jun 29 11:48:40 2017
@@ -199,6 +199,7 @@ LANGOPT(CUDADeviceApproxTranscendentals,
 
 LANGOPT(SizedDeallocation , 1, 0, "sized deallocation")
 LANGOPT(AlignedAllocation , 1, 0, "aligned allocation")

r306724 - [OpenMP] Fix test for revision D29645. NFC

2017-06-29 Thread Gheorghe-Teodor Bercea via cfe-commits
Author: gbercea
Date: Thu Jun 29 11:49:16 2017
New Revision: 306724

URL: http://llvm.org/viewvc/llvm-project?rev=306724&view=rev
Log:
[OpenMP] Fix test for revision D29645. NFC
 

Modified:
cfe/trunk/test/Driver/openmp-offload.c

Modified: cfe/trunk/test/Driver/openmp-offload.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openmp-offload.c?rev=306724&r1=306723&r2=306724&view=diff
==
--- cfe/trunk/test/Driver/openmp-offload.c (original)
+++ cfe/trunk/test/Driver/openmp-offload.c Thu Jun 29 11:49:16 2017
@@ -592,10 +592,8 @@
 
 /// ###
 
-/// Check -fopenmp-is-device is also passed when generating the *.i and *.s 
intermediate files.
-// RUN:   %clang -### -fopenmp=libomp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -save-temps -no-canonical-prefixes 
%s 2>&1 \
+/// Check -fopenmp-is-device is passed when compiling for the device.
+// RUN:   %clang -### -fopenmp=libomp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-IS-DEVICE %s
 
-// CHK-FOPENMP-IS-DEVICE: clang{{.*}}.i" {{.*}}" "-fopenmp-is-device"
-// CHK-FOPENMP-IS-DEVICE-NEXT: clang{{.*}}.bc" {{.*}}.i" "-fopenmp-is-device" 
"-fopenmp-host-ir-file-path"
-// CHK-FOPENMP-IS-DEVICE-NEXT: clang{{.*}}.s" {{.*}}.bc" "-fopenmp-is-device"
+// CHK-FOPENMP-IS-DEVICE: clang{{.*}} "-aux-triple" 
"powerpc64le-unknown-linux-gnu" {{.*}}.c" "-fopenmp-is-device" 
"-fopenmp-host-ir-file-path"


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


[clang-tools-extra] r306728 - [clang-tidy] Rename android-file-open-flag and fix a bug

2017-06-29 Thread Yan Wang via cfe-commits
Author: yawanng
Date: Thu Jun 29 12:13:29 2017
New Revision: 306728

URL: http://llvm.org/viewvc/llvm-project?rev=306728&view=rev
Log:
[clang-tidy] Rename android-file-open-flag and fix a bug

Summary:
1. Rename android-file-open-flag to android-cloexec-open.
2. Handle a case when the function is passed as an argument of a function-like 
macro.

Reviewers: chh

Reviewed By: chh

Subscribers: srhines, mgorny, JDevlieghere, xazax.hun, cfe-commits

Tags: #clang-tools-extra

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

Added:
clang-tools-extra/trunk/clang-tidy/android/CloexecOpenCheck.cpp
  - copied, changed from r306725, 
clang-tools-extra/trunk/clang-tidy/android/FileOpenFlagCheck.cpp
clang-tools-extra/trunk/clang-tidy/android/CloexecOpenCheck.h
  - copied, changed from r306725, 
clang-tools-extra/trunk/clang-tidy/android/FileOpenFlagCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/android-cloexec-open.rst
  - copied, changed from r306725, 
clang-tools-extra/trunk/docs/clang-tidy/checks/android-file-open-flag.rst
clang-tools-extra/trunk/test/clang-tidy/android-cloexec-open.cpp
Removed:
clang-tools-extra/trunk/clang-tidy/android/FileOpenFlagCheck.cpp
clang-tools-extra/trunk/clang-tidy/android/FileOpenFlagCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/android-file-open-flag.rst
clang-tools-extra/trunk/test/clang-tidy/android-file-open-flag.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp?rev=306728&r1=306727&r2=306728&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp Thu Jun 29 
12:13:29 2017
@@ -12,7 +12,7 @@
 #include "../ClangTidyModuleRegistry.h"
 #include "CloexecCreatCheck.h"
 #include "CloexecFopenCheck.h"
-#include "FileOpenFlagCheck.h"
+#include "CloexecOpenCheck.h"
 
 using namespace clang::ast_matchers;
 
@@ -24,9 +24,9 @@ namespace android {
 class AndroidModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
-CheckFactories.registerCheck("android-file-open-flag");
 CheckFactories.registerCheck("android-cloexec-creat");
 CheckFactories.registerCheck("android-cloexec-fopen");
+CheckFactories.registerCheck("android-cloexec-open");
   }
 };
 

Modified: clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt?rev=306728&r1=306727&r2=306728&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt Thu Jun 29 
12:13:29 2017
@@ -4,7 +4,7 @@ add_clang_library(clangTidyAndroidModule
   AndroidTidyModule.cpp
   CloexecCreatCheck.cpp
   CloexecFopenCheck.cpp
-  FileOpenFlagCheck.cpp
+  CloexecOpenCheck.cpp
 
   LINK_LIBS
   clangAST

Copied: clang-tools-extra/trunk/clang-tidy/android/CloexecOpenCheck.cpp (from 
r306725, clang-tools-extra/trunk/clang-tidy/android/FileOpenFlagCheck.cpp)
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CloexecOpenCheck.cpp?p2=clang-tools-extra/trunk/clang-tidy/android/CloexecOpenCheck.cpp&p1=clang-tools-extra/trunk/clang-tidy/android/FileOpenFlagCheck.cpp&r1=306725&r2=306728&rev=306728&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/FileOpenFlagCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecOpenCheck.cpp Thu Jun 29 
12:13:29 2017
@@ -1,4 +1,4 @@
-//===--- FileOpenFlagCheck.cpp - 
clang-tidy===//
+//===--- CloexecOpenCheck.cpp - 
clang-tidy-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -7,7 +7,7 @@
 //
 
//===--===//
 
-#include "FileOpenFlagCheck.h"
+#include "CloexecOpenCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Lex/Lexer.h"
@@ -21,11 +21,12 @@ namespace android {
 namespace {
 static constexpr const char *O_CLOEXEC = "O_CLOEXEC";
 
-bool HasCloseOnExecFlag(const Expr *Flags, const SourceManager &SM,
+bool hasCloseOnExecFlag(const Expr *Flags, const SourceManager &SM,
 const LangOptions &LangOpts) {
   // If

[PATCH] D34788: [ASTReader] Add test for previous change r306583 / 145692e.

2017-06-29 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks Graydon


https://reviews.llvm.org/D34788



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


r306732 - [ASTReader] Add test for previous change r306583 / 145692e.

2017-06-29 Thread Graydon Hoare via cfe-commits
Author: graydon
Date: Thu Jun 29 12:42:35 2017
New Revision: 306732

URL: http://llvm.org/viewvc/llvm-project?rev=306732&view=rev
Log:
[ASTReader] Add test for previous change r306583 / 145692e.

Summary:
Add a test for the change to ASTReader that reproduces the
logic for consolidating multiple ObjC interface definitions to the
case of multiple ObjC protocol definitions.

This test is a modified copy of the test that accompanied the original
change to interfaces, in 2ba1979.

Reviewers: bruno

Reviewed By: bruno

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/
cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Base.h
cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Derive.h
cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/H3.h
cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/module.map
cfe/trunk/test/Modules/lookup-assert-protocol.m

Added: cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Base.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Base.h?rev=306732&view=auto
==
--- cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Base.h (added)
+++ cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Base.h Thu Jun 29 
12:42:35 2017
@@ -0,0 +1,3 @@
+@protocol BaseProtocol
+- (void) test;
+@end

Added: cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Derive.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Derive.h?rev=306732&view=auto
==
--- cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Derive.h (added)
+++ cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Derive.h Thu Jun 29 
12:42:35 2017
@@ -0,0 +1,4 @@
+#include "Base.h"
+@protocol DerivedProtocol
+- (void) test2;
+@end

Added: cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/H3.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/H3.h?rev=306732&view=auto
==
--- cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/H3.h (added)
+++ cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/H3.h Thu Jun 29 
12:42:35 2017
@@ -0,0 +1 @@
+#include "Base.h"

Added: cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/module.map
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/module.map?rev=306732&view=auto
==
--- cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/module.map (added)
+++ cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/module.map Thu Jun 29 
12:42:35 2017
@@ -0,0 +1,4 @@
+module X {
+  header "H3.h"
+  export *
+}

Added: cfe/trunk/test/Modules/lookup-assert-protocol.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/lookup-assert-protocol.m?rev=306732&view=auto
==
--- cfe/trunk/test/Modules/lookup-assert-protocol.m (added)
+++ cfe/trunk/test/Modules/lookup-assert-protocol.m Thu Jun 29 12:42:35 2017
@@ -0,0 +1,17 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I 
%S/Inputs/lookup-assert-protocol %s -verify
+// expected-no-diagnostics
+
+#include "Derive.h"
+#import 
+
+__attribute__((objc_root_class))
+@interface Thing
+@end
+
+@implementation Thing
+- (void)test {
+}
+- (void)test2 {
+}
+@end


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


[PATCH] D34788: [ASTReader] Add test for previous change r306583 / 145692e.

2017-06-29 Thread Graydon Hoare via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL306732: [ASTReader] Add test for previous change r306583 / 
145692e. (authored by graydon).

Repository:
  rL LLVM

https://reviews.llvm.org/D34788

Files:
  cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Base.h
  cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Derive.h
  cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/H3.h
  cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/module.map
  cfe/trunk/test/Modules/lookup-assert-protocol.m


Index: cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/module.map
===
--- cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/module.map
+++ cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/module.map
@@ -0,0 +1,4 @@
+module X {
+  header "H3.h"
+  export *
+}
Index: cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/H3.h
===
--- cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/H3.h
+++ cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/H3.h
@@ -0,0 +1 @@
+#include "Base.h"
Index: cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Base.h
===
--- cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Base.h
+++ cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Base.h
@@ -0,0 +1,3 @@
+@protocol BaseProtocol
+- (void) test;
+@end
Index: cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Derive.h
===
--- cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Derive.h
+++ cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Derive.h
@@ -0,0 +1,4 @@
+#include "Base.h"
+@protocol DerivedProtocol
+- (void) test2;
+@end
Index: cfe/trunk/test/Modules/lookup-assert-protocol.m
===
--- cfe/trunk/test/Modules/lookup-assert-protocol.m
+++ cfe/trunk/test/Modules/lookup-assert-protocol.m
@@ -0,0 +1,17 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I 
%S/Inputs/lookup-assert-protocol %s -verify
+// expected-no-diagnostics
+
+#include "Derive.h"
+#import 
+
+__attribute__((objc_root_class))
+@interface Thing
+@end
+
+@implementation Thing
+- (void)test {
+}
+- (void)test2 {
+}
+@end


Index: cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/module.map
===
--- cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/module.map
+++ cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/module.map
@@ -0,0 +1,4 @@
+module X {
+  header "H3.h"
+  export *
+}
Index: cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/H3.h
===
--- cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/H3.h
+++ cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/H3.h
@@ -0,0 +1 @@
+#include "Base.h"
Index: cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Base.h
===
--- cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Base.h
+++ cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Base.h
@@ -0,0 +1,3 @@
+@protocol BaseProtocol
+- (void) test;
+@end
Index: cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Derive.h
===
--- cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Derive.h
+++ cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Derive.h
@@ -0,0 +1,4 @@
+#include "Base.h"
+@protocol DerivedProtocol
+- (void) test2;
+@end
Index: cfe/trunk/test/Modules/lookup-assert-protocol.m
===
--- cfe/trunk/test/Modules/lookup-assert-protocol.m
+++ cfe/trunk/test/Modules/lookup-assert-protocol.m
@@ -0,0 +1,17 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/lookup-assert-protocol %s -verify
+// expected-no-diagnostics
+
+#include "Derive.h"
+#import 
+
+__attribute__((objc_root_class))
+@interface Thing
+@end
+
+@implementation Thing
+- (void)test {
+}
+- (void)test2 {
+}
+@end
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r306733 - [libFuzzer] Do not link in libFuzzer with -fsanitize=fuzzer when producing a shared object

2017-06-29 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Jun 29 12:52:33 2017
New Revision: 306733

URL: http://llvm.org/viewvc/llvm-project?rev=306733&view=rev
Log:
[libFuzzer] Do not link in libFuzzer with -fsanitize=fuzzer when producing a 
shared object

https://reviews.llvm.org/D34791

Modified:
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/test/Driver/fuzzer.c

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=306733&r1=306732&r2=306733&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Thu Jun 29 12:52:33 2017
@@ -617,7 +617,8 @@ bool tools::addSanitizerRuntimes(const T
NonWholeStaticRuntimes, HelperStaticRuntimes,
RequiredSymbols);
   // Inject libfuzzer dependencies.
-  if (TC.getSanitizerArgs().needsFuzzer()) {
+  if (TC.getSanitizerArgs().needsFuzzer()
+  && !Args.hasArg(options::OPT_shared)) {
 addLibFuzzerRuntime(TC, Args, CmdArgs);
   }
 

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=306733&r1=306732&r2=306733&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Thu Jun 29 12:52:33 2017
@@ -1053,7 +1053,7 @@ void DarwinClang::AddLinkRuntimeLibArgs(
 AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan");
   if (Sanitize.needsTsanRt())
 AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan");
-  if (Sanitize.needsFuzzer())
+  if (Sanitize.needsFuzzer() && !Args.hasArg(options::OPT_dynamiclib))
 AddFuzzerLinkArgs(Args, CmdArgs);
   if (Sanitize.needsStatsRt()) {
 StringRef OS = isTargetMacOS() ? "osx" : "iossim";

Modified: cfe/trunk/test/Driver/fuzzer.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fuzzer.c?rev=306733&r1=306732&r2=306733&view=diff
==
--- cfe/trunk/test/Driver/fuzzer.c (original)
+++ cfe/trunk/test/Driver/fuzzer.c Thu Jun 29 12:52:33 2017
@@ -15,6 +15,10 @@
 //
 // CHECK-LIBCXX-DARWIN: -lc++
 
+// Check that we don't link in libFuzzer.a when producing a shared object.
+// RUN: %clang -fsanitize=fuzzer %s -shared -o %t.so -### 2>&1 | FileCheck 
--check-prefixes=CHECK-NOLIB-SO %s
+// CHECK-NOLIB-SO-NOT: libLLVMFuzzer.a
+
 int LLVMFuzzerTestOneInput(const char *Data, long Size) {
   return 0;
 }


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


r306734 - [libFuzzer] Add Fuzzer to the list of sanitizers which support coverage.

2017-06-29 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Jun 29 12:58:20 2017
New Revision: 306734

URL: http://llvm.org/viewvc/llvm-project?rev=306734&view=rev
Log:
[libFuzzer] Add Fuzzer to the list of sanitizers which support coverage.

Without this change, additional coverage flags specified after
-fsanitize=fuzzer would get discarded.

https://reviews.llvm.org/D34794

Modified:
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/test/Driver/fuzzer.c

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=306734&r1=306733&r2=306734&view=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Thu Jun 29 12:58:20 2017
@@ -32,7 +32,7 @@ enum : SanitizerMask {
   RequiresPIE = DataFlow,
   NeedsUnwindTables = Address | Thread | Memory | DataFlow,
   SupportsCoverage = Address | KernelAddress | Memory | Leak | Undefined |
- Integer | Nullability | DataFlow,
+ Integer | Nullability | DataFlow | Fuzzer,
   RecoverableByDefault = Undefined | Integer | Nullability,
   Unrecoverable = Unreachable | Return,
   LegacyFsanitizeRecoverMask = Undefined | Integer,

Modified: cfe/trunk/test/Driver/fuzzer.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fuzzer.c?rev=306734&r1=306733&r2=306734&view=diff
==
--- cfe/trunk/test/Driver/fuzzer.c (original)
+++ cfe/trunk/test/Driver/fuzzer.c Thu Jun 29 12:58:20 2017
@@ -15,10 +15,14 @@
 //
 // CHECK-LIBCXX-DARWIN: -lc++
 
+
 // Check that we don't link in libFuzzer.a when producing a shared object.
 // RUN: %clang -fsanitize=fuzzer %s -shared -o %t.so -### 2>&1 | FileCheck 
--check-prefixes=CHECK-NOLIB-SO %s
 // CHECK-NOLIB-SO-NOT: libLLVMFuzzer.a
 
+// RUN: %clang -fsanitize=fuzzer -fsanitize-coverage=trace-pc %s -### 2>&1 | 
FileCheck --check-prefixes=CHECK-MSG %s
+// CHECK-MSG-NOT: argument unused during compilation
+
 int LLVMFuzzerTestOneInput(const char *Data, long Size) {
   return 0;
 }


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


[PATCH] D34810: [Sema] -Wcomma should not warn for expressions that return void

2017-06-29 Thread Greg Parker via Phabricator via cfe-commits
gparker42 added a comment.

I thought void-returning functions were supposed to be allowed based on the 
description in https://reviews.llvm.org/D3976 , but later in that discussion 
the definition was changed to instead allow almost nothing.


Repository:
  rL LLVM

https://reviews.llvm.org/D34810



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


r306739 - Insert llvm_unreachable at the end of a function to silence gcc's

2017-06-29 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Jun 29 13:44:20 2017
New Revision: 306739

URL: http://llvm.org/viewvc/llvm-project?rev=306739&view=rev
Log:
Insert llvm_unreachable at the end of a function to silence gcc's
-Werror=return-type error.

This is an attempt to fix the following failing bot:

http://lab.llvm.org:8011/builders/ubuntu-gcc7.1-werror

Modified:
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=306739&r1=306738&r2=306739&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Thu Jun 29 13:44:20 2017
@@ -1680,6 +1680,7 @@ bool Darwin::isAlignedAllocationUnavaila
   case WatchOSSimulator: // Earlier than 4.0.
 return TargetVersion < VersionTuple(4U, 0U, 0U);
   }
+  llvm_unreachable("Unsupported platform");
 }
 
 void Darwin::addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,


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


[PATCH] D34725: Add sample PGO integration test to cover profile annotation and inlining.

2017-06-29 Thread David Li via Phabricator via cfe-commits
davidxl added inline comments.



Comment at: test/CodeGen/pgo-sample.c:4
+// Ensure Pass SampleProfileLoader is invoked.
+// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s 
-mllvm -debug-pass=Structure -mllvm -inline-threshold=0 -emit-llvm -o - 2>&1 | 
FileCheck %s
 // CHECK: Remove unused exception handling info

using a a negative threshold to make sure regular inline heuristic does not 
kick in?

Also how about new PM?



Comment at: test/CodeGen/pgo-sample.c:28
+// of foo:bar.
+// CHECK-NOT: call void @callee
+void foo(int x) {

SHould this be 'CHECK-NOT:  call'  as bar is also inlined?


https://reviews.llvm.org/D34725



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


[PATCH] D34784: [OpenMP] Add flag for specifying the target device architecture for OpenMP device offloading

2017-06-29 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

In https://reviews.llvm.org/D34784#795367, @hfinkel wrote:

> In https://reviews.llvm.org/D34784#795353, @gtbercea wrote:
>
> > In https://reviews.llvm.org/D34784#795287, @hfinkel wrote:
> >
> > > What happens if you have multiple targets? Maybe this should be 
> > > -fopenmp-targets-arch=foo,bar,whatever?
> > >
> > > Once this all lands, please make sure that you add additional test cases 
> > > here. Make sure that the arch is passed through to the ptx and cuda tools 
> > > as it should be. Make sure that the defaults work. Make sure that 
> > > something reasonable happens if the user specifies the option more than 
> > > once (if they're all the same).
> >
> >
> > Hi Hal,
> >
> > At the moment only one arch is supported and it would apply to all the 
> > target triples under -fopenmp-targets.
> >
> > I was planning to address the multiple archs problem in a future patch.
> >
> > I am assuming that in the case of multiple archs, each arch in 
> > -fopenmp-targets-arch=A1,A2,A3 will bind to a corresponding triple in 
> > -fopenmp-targets=T1,T2,T3 like so: T1 with A1, T2 with A2 etc. Is this a 
> > practical interpretation of what should happen?
>
>
> Yea, that's what I was thinking. I'm a bit concerned that none of this 
> generalizes well. To take a step back, under what circumstances do we support 
> multiple targets right now?


We allow -fopenmp-targets to get a list of triples. I am not aware of any 
limitations in terms of how many of these triples you can have. Even in the 
test file of this patch we have the following: 
"-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux"

> 
> 
>> Regarding tests: more tests can be added as a separate patch once offloading 
>> is enabled by the patch following this one (i.e. 
>> https://reviews.llvm.org/D29654). There actually is a test in 
>> https://reviews.llvm.org/D29654 where I check that the arch is passed to 
>> ptxas and nvlink correctly using this flag. I will add some more test cases 
>> to cover the other situations you mentioned.
> 
> Sounds good.
> 
>> Thanks,
>> 
>> --Doru

In our previous solution there might be a problem.  The same triple might be 
used multiple times just so that you can have several archs in the other flag 
(T1 and T2 being the same). There are some alternatives which I have discussed 
with @ABataev.

One solution could be to associate an arch with each triple to avoid positional 
matching of triples in one flag with archs in another flag:

  -fopenmp-targets=T1:A1,T2,T3:A2

":A1" is optional, also, in the future, we can pass other things to the 
toolchain such as "-L/a/b/c/d":

  -fopenmp-targets=T1:A1: -L/a/b/c/d,T2,T3:A2

An actual example:

  -fopenmp-targets=nvptx64-nvidia-cuda:sm_35,openmp-powerpc64le-ibm-linux-gnu


Repository:
  rL LLVM

https://reviews.llvm.org/D34784



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


[PATCH] D34810: [Sema] -Wcomma should not warn for expressions that return void

2017-06-29 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu added a comment.

Reid is correct, the whitelisted expressions was greatly reduced during code 
review so only casts to void would disable the warning.  While the last review 
did not have the description updated to reflect this, the committed code does 
have an accurate description.  What is the reason to exclude void expressions 
now?  For the function case, it is more consistent to warn on all function 
calls since we can't determine if a function returns void just by looking at 
the call site.


Repository:
  rL LLVM

https://reviews.llvm.org/D34810



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


[PATCH] D34839: [Driver] Honor -nostdinc and -isystem-after on CrossWindows

2017-06-29 Thread Dave Lee via Phabricator via cfe-commits
kastiglione created this revision.

This changes CrossWindows to look for `-nostdinc` instead of `-nostdlibinc`. In
addition, fixes a bug where `-isystem-after` options would be dropped when
called with `-nostdinc`.


https://reviews.llvm.org/D34839

Files:
  lib/Driver/ToolChains/CrossWindows.cpp
  test/Driver/windows-cross.c


Index: test/Driver/windows-cross.c
===
--- test/Driver/windows-cross.c
+++ test/Driver/windows-cross.c
@@ -80,3 +80,7 @@
 // CHECK-ISYSTEM-AFTER: "-internal-isystem" "Windows 
Kits{{[/\\]}}10{{[/\\]}}Include{{[/\\]}}10.0.10586.0{{[/\\]}}um"
 // CHECK-ISYSTEM-AFTER: "-internal-isystem" "Windows 
Kits{{[/\\]}}10{{[/\\]}}Include{{[/\\]}}10.0.10586.0{{[/\\]}}shared"
 
+// RUN: %clang -### -target armv7-windows-itanium -nostdinc -isystem-after 
"Windows Kits/10/Include/10.0.10586.0/ucrt" -c %s -o /dev/null 2>&1 \
+// RUN: | FileCheck %s --check-prefix CHECK-NOSTDINC-ISYSTEM-AFTER
+// CHECK-NOSTDINC-ISYSTEM-AFTER-NOT: "-internal-isystem" 
"[[RESOURCE_DIR]]{{(/|)}}include"
+// CHECK-NOSTDINC-ISYSTEM-AFTER: "-internal-isystem" "Windows 
Kits{{[/\\]}}10{{[/\\]}}Include{{[/\\]}}10.0.10586.0{{[/\\]}}ucrt"
Index: lib/Driver/ToolChains/CrossWindows.cpp
===
--- lib/Driver/ToolChains/CrossWindows.cpp
+++ lib/Driver/ToolChains/CrossWindows.cpp
@@ -238,17 +238,23 @@
   const Driver &D = getDriver();
   const std::string &SysRoot = D.SysRoot;
 
-  if (DriverArgs.hasArg(options::OPT_nostdlibinc))
+  auto AddSystemAfterIncludes = [&]() {
+for (const auto &P : 
DriverArgs.getAllArgValues(options::OPT_isystem_after))
+  addSystemInclude(DriverArgs, CC1Args, P);
+  };
+
+  if (DriverArgs.hasArg(options::OPT_nostdinc)) {
+AddSystemAfterIncludes();
 return;
+  }
 
   addSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/local/include");
   if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
 SmallString<128> ResourceDir(D.ResourceDir);
 llvm::sys::path::append(ResourceDir, "include");
 addSystemInclude(DriverArgs, CC1Args, ResourceDir);
   }
-  for (const auto &P : DriverArgs.getAllArgValues(options::OPT_isystem_after))
-addSystemInclude(DriverArgs, CC1Args, P);
+  AddSystemAfterIncludes();
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
 }
 
@@ -258,7 +264,7 @@
   const llvm::Triple &Triple = getTriple();
   const std::string &SysRoot = getDriver().SysRoot;
 
-  if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
+  if (DriverArgs.hasArg(options::OPT_nostdinc) ||
   DriverArgs.hasArg(options::OPT_nostdincxx))
 return;
 


Index: test/Driver/windows-cross.c
===
--- test/Driver/windows-cross.c
+++ test/Driver/windows-cross.c
@@ -80,3 +80,7 @@
 // CHECK-ISYSTEM-AFTER: "-internal-isystem" "Windows Kits{{[/\\]}}10{{[/\\]}}Include{{[/\\]}}10.0.10586.0{{[/\\]}}um"
 // CHECK-ISYSTEM-AFTER: "-internal-isystem" "Windows Kits{{[/\\]}}10{{[/\\]}}Include{{[/\\]}}10.0.10586.0{{[/\\]}}shared"
 
+// RUN: %clang -### -target armv7-windows-itanium -nostdinc -isystem-after "Windows Kits/10/Include/10.0.10586.0/ucrt" -c %s -o /dev/null 2>&1 \
+// RUN: | FileCheck %s --check-prefix CHECK-NOSTDINC-ISYSTEM-AFTER
+// CHECK-NOSTDINC-ISYSTEM-AFTER-NOT: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include"
+// CHECK-NOSTDINC-ISYSTEM-AFTER: "-internal-isystem" "Windows Kits{{[/\\]}}10{{[/\\]}}Include{{[/\\]}}10.0.10586.0{{[/\\]}}ucrt"
Index: lib/Driver/ToolChains/CrossWindows.cpp
===
--- lib/Driver/ToolChains/CrossWindows.cpp
+++ lib/Driver/ToolChains/CrossWindows.cpp
@@ -238,17 +238,23 @@
   const Driver &D = getDriver();
   const std::string &SysRoot = D.SysRoot;
 
-  if (DriverArgs.hasArg(options::OPT_nostdlibinc))
+  auto AddSystemAfterIncludes = [&]() {
+for (const auto &P : DriverArgs.getAllArgValues(options::OPT_isystem_after))
+  addSystemInclude(DriverArgs, CC1Args, P);
+  };
+
+  if (DriverArgs.hasArg(options::OPT_nostdinc)) {
+AddSystemAfterIncludes();
 return;
+  }
 
   addSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/local/include");
   if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
 SmallString<128> ResourceDir(D.ResourceDir);
 llvm::sys::path::append(ResourceDir, "include");
 addSystemInclude(DriverArgs, CC1Args, ResourceDir);
   }
-  for (const auto &P : DriverArgs.getAllArgValues(options::OPT_isystem_after))
-addSystemInclude(DriverArgs, CC1Args, P);
+  AddSystemAfterIncludes();
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
 }
 
@@ -258,7 +264,7 @@
   const llvm::Triple &Triple = getTriple();
   const std::string &SysRoot = getDriver().SysRoot;
 
-  if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
+  if (DriverArgs.hasArg(options::OPT_nostdinc) ||
   DriverArgs.hasArg(options::OPT_nostdincxx))
 return;

[PATCH] D34784: [OpenMP] Add flag for specifying the target device architecture for OpenMP device offloading

2017-06-29 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D34784#795871, @gtbercea wrote:

> In https://reviews.llvm.org/D34784#795367, @hfinkel wrote:
>
> > In https://reviews.llvm.org/D34784#795353, @gtbercea wrote:
> >
> > > In https://reviews.llvm.org/D34784#795287, @hfinkel wrote:
> > >
> > > > What happens if you have multiple targets? Maybe this should be 
> > > > -fopenmp-targets-arch=foo,bar,whatever?
> > > >
> > > > Once this all lands, please make sure that you add additional test 
> > > > cases here. Make sure that the arch is passed through to the ptx and 
> > > > cuda tools as it should be. Make sure that the defaults work. Make sure 
> > > > that something reasonable happens if the user specifies the option more 
> > > > than once (if they're all the same).
> > >
> > >
> > > Hi Hal,
> > >
> > > At the moment only one arch is supported and it would apply to all the 
> > > target triples under -fopenmp-targets.
> > >
> > > I was planning to address the multiple archs problem in a future patch.
> > >
> > > I am assuming that in the case of multiple archs, each arch in 
> > > -fopenmp-targets-arch=A1,A2,A3 will bind to a corresponding triple in 
> > > -fopenmp-targets=T1,T2,T3 like so: T1 with A1, T2 with A2 etc. Is this a 
> > > practical interpretation of what should happen?
> >
> >
> > Yea, that's what I was thinking. I'm a bit concerned that none of this 
> > generalizes well. To take a step back, under what circumstances do we 
> > support multiple targets right now?
>
>
> We allow -fopenmp-targets to get a list of triples. I am not aware of any 
> limitations in terms of how many of these triples you can have. Even in the 
> test file of this patch we have the following: 
> "-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux"
>
> > 
> > 
> >> Regarding tests: more tests can be added as a separate patch once 
> >> offloading is enabled by the patch following this one (i.e. 
> >> https://reviews.llvm.org/D29654). There actually is a test in 
> >> https://reviews.llvm.org/D29654 where I check that the arch is passed to 
> >> ptxas and nvlink correctly using this flag. I will add some more test 
> >> cases to cover the other situations you mentioned.
> > 
> > Sounds good.
> > 
> >> Thanks,
> >> 
> >> --Doru
>
> In our previous solution there might be a problem.  The same triple might be 
> used multiple times just so that you can have several archs in the other flag 
> (T1 and T2 being the same). There are some alternatives which I have 
> discussed with @ABataev.
>
> One solution could be to associate an arch with each triple to avoid 
> positional matching of triples in one flag with archs in another flag:
>
>   -fopenmp-targets=T1:A1,T2,T3:A2
>
>
> ":A1" is optional, also, in the future, we can pass other things to the 
> toolchain such as "-L/a/b/c/d":
>
>   -fopenmp-targets=T1:A1: -L/a/b/c/d,T2,T3:A2
>


Okay, good, this is exactly where I was going when I said I was worried about 
generalization. -march seems like one of many flags I might want to pass to the 
target compilation. Moreover, it doesn't seem special in what regard.

We have -Xclang and -mllvm, etc. to pass flags through to other stages of 
compilation. Could we do something similar here? Maybe something like: 
``-Xopenmp-target:openmp-powerpc64le-ibm-linux-gnu -march=pwr7``. That's 
unfortunately long, but if there's only one target, we could omit the triple?

> An actual example:
> 
>   -fopenmp-targets=nvptx64-nvidia-cuda:sm_35,openmp-powerpc64le-ibm-linux-gnu




Repository:
  rL LLVM

https://reviews.llvm.org/D34784



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


[PATCH] D34839: [Driver] Honor -nostdinc and -isystem-after on CrossWindows

2017-06-29 Thread Dave Lee via Phabricator via cfe-commits
kastiglione updated this revision to Diff 104750.
kastiglione added a comment.

fixup a test


https://reviews.llvm.org/D34839

Files:
  lib/Driver/ToolChains/CrossWindows.cpp
  test/Driver/windows-cross.c


Index: test/Driver/windows-cross.c
===
--- test/Driver/windows-cross.c
+++ test/Driver/windows-cross.c
@@ -80,3 +80,8 @@
 // CHECK-ISYSTEM-AFTER: "-internal-isystem" "Windows 
Kits{{[/\\]}}10{{[/\\]}}Include{{[/\\]}}10.0.10586.0{{[/\\]}}um"
 // CHECK-ISYSTEM-AFTER: "-internal-isystem" "Windows 
Kits{{[/\\]}}10{{[/\\]}}Include{{[/\\]}}10.0.10586.0{{[/\\]}}shared"
 
+// RUN: %clang -### -target armv7-windows-itanium -nostdinc -isystem-after 
"Windows Kits/10/Include/10.0.10586.0/ucrt" -c %s -o /dev/null 2>&1 \
+// RUN: | FileCheck %s --check-prefix CHECK-NOSTDINC-ISYSTEM-AFTER
+// CHECK-NOSTDINC-ISYSTEM-AFTER: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-NOSTDINC-ISYSTEM-AFTER-NOT: "-internal-isystem" 
"[[RESOURCE_DIR]]{{(/|)}}include"
+// CHECK-NOSTDINC-ISYSTEM-AFTER: "-internal-isystem" "Windows 
Kits{{[/\\]}}10{{[/\\]}}Include{{[/\\]}}10.0.10586.0{{[/\\]}}ucrt"
Index: lib/Driver/ToolChains/CrossWindows.cpp
===
--- lib/Driver/ToolChains/CrossWindows.cpp
+++ lib/Driver/ToolChains/CrossWindows.cpp
@@ -238,17 +238,23 @@
   const Driver &D = getDriver();
   const std::string &SysRoot = D.SysRoot;
 
-  if (DriverArgs.hasArg(options::OPT_nostdlibinc))
+  auto AddSystemAfterIncludes = [&]() {
+for (const auto &P : 
DriverArgs.getAllArgValues(options::OPT_isystem_after))
+  addSystemInclude(DriverArgs, CC1Args, P);
+  };
+
+  if (DriverArgs.hasArg(options::OPT_nostdinc)) {
+AddSystemAfterIncludes();
 return;
+  }
 
   addSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/local/include");
   if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
 SmallString<128> ResourceDir(D.ResourceDir);
 llvm::sys::path::append(ResourceDir, "include");
 addSystemInclude(DriverArgs, CC1Args, ResourceDir);
   }
-  for (const auto &P : DriverArgs.getAllArgValues(options::OPT_isystem_after))
-addSystemInclude(DriverArgs, CC1Args, P);
+  AddSystemAfterIncludes();
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
 }
 
@@ -258,7 +264,7 @@
   const llvm::Triple &Triple = getTriple();
   const std::string &SysRoot = getDriver().SysRoot;
 
-  if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
+  if (DriverArgs.hasArg(options::OPT_nostdinc) ||
   DriverArgs.hasArg(options::OPT_nostdincxx))
 return;
 


Index: test/Driver/windows-cross.c
===
--- test/Driver/windows-cross.c
+++ test/Driver/windows-cross.c
@@ -80,3 +80,8 @@
 // CHECK-ISYSTEM-AFTER: "-internal-isystem" "Windows Kits{{[/\\]}}10{{[/\\]}}Include{{[/\\]}}10.0.10586.0{{[/\\]}}um"
 // CHECK-ISYSTEM-AFTER: "-internal-isystem" "Windows Kits{{[/\\]}}10{{[/\\]}}Include{{[/\\]}}10.0.10586.0{{[/\\]}}shared"
 
+// RUN: %clang -### -target armv7-windows-itanium -nostdinc -isystem-after "Windows Kits/10/Include/10.0.10586.0/ucrt" -c %s -o /dev/null 2>&1 \
+// RUN: | FileCheck %s --check-prefix CHECK-NOSTDINC-ISYSTEM-AFTER
+// CHECK-NOSTDINC-ISYSTEM-AFTER: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-NOSTDINC-ISYSTEM-AFTER-NOT: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include"
+// CHECK-NOSTDINC-ISYSTEM-AFTER: "-internal-isystem" "Windows Kits{{[/\\]}}10{{[/\\]}}Include{{[/\\]}}10.0.10586.0{{[/\\]}}ucrt"
Index: lib/Driver/ToolChains/CrossWindows.cpp
===
--- lib/Driver/ToolChains/CrossWindows.cpp
+++ lib/Driver/ToolChains/CrossWindows.cpp
@@ -238,17 +238,23 @@
   const Driver &D = getDriver();
   const std::string &SysRoot = D.SysRoot;
 
-  if (DriverArgs.hasArg(options::OPT_nostdlibinc))
+  auto AddSystemAfterIncludes = [&]() {
+for (const auto &P : DriverArgs.getAllArgValues(options::OPT_isystem_after))
+  addSystemInclude(DriverArgs, CC1Args, P);
+  };
+
+  if (DriverArgs.hasArg(options::OPT_nostdinc)) {
+AddSystemAfterIncludes();
 return;
+  }
 
   addSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/local/include");
   if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
 SmallString<128> ResourceDir(D.ResourceDir);
 llvm::sys::path::append(ResourceDir, "include");
 addSystemInclude(DriverArgs, CC1Args, ResourceDir);
   }
-  for (const auto &P : DriverArgs.getAllArgValues(options::OPT_isystem_after))
-addSystemInclude(DriverArgs, CC1Args, P);
+  AddSystemAfterIncludes();
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
 }
 
@@ -258,7 +264,7 @@
   const llvm::Triple &Triple = getTriple();
   const std::string &SysRoot = getDriver().SysRoot;
 
-  if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
+  if (DriverArgs.hasArg(options::OPT_nostdinc) ||
   DriverArgs.hasArg(options::OPT

[clang-tools-extra] r306750 - Fix some typos in the doc

2017-06-29 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Thu Jun 29 15:26:06 2017
New Revision: 306750

URL: http://llvm.org/viewvc/llvm-project?rev=306750&view=rev
Log:
Fix some typos in the doc

Modified:

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-forwarding-reference-overload.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/performance-inefficient-vector-operation.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-forwarding-reference-overload.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-forwarding-reference-overload.rst?rev=306750&r1=306749&r2=306750&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-forwarding-reference-overload.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-forwarding-reference-overload.rst
 Thu Jun 29 15:26:06 2017
@@ -4,7 +4,7 @@ misc-forwarding-reference-overload
 ==
 
 The check looks for perfect forwarding constructors that can hide copy or move
-constructors. If a non const lvalue reference is passed to the constructor, 
the 
+constructors. If a non const lvalue reference is passed to the constructor, the
 forwarding reference parameter will be a better match than the const reference
 parameter of the copy constructor, so the perfect forwarding constructor will 
be
 called, which can be confusing.
@@ -14,7 +14,7 @@ Item 26.
 Consider the following example:
 
   .. code-block:: c++
-  
+
 class Person {
 public:
   // C1: perfect forwarding ctor
@@ -24,15 +24,15 @@ Consider the following example:
   // C2: perfect forwarding ctor with parameter default value
   template
   explicit Person(T&& n, int x = 1) {}
-  
+
   // C3: perfect forwarding ctor guarded with enable_if
   template,void>>
   explicit Person(T&& n) {}
-  
+
   // (possibly compiler generated) copy ctor
-  Person(const Person& rhs); 
+  Person(const Person& rhs);
 };
-
+
 The check warns for constructors C1 and C2, because those can hide copy and 
move
 constructors. We suppress warnings if the copy and the move constructors are 
both
 disabled (deleted or private), because there is nothing the perfect forwarding
@@ -44,6 +44,6 @@ Background
 --
 
 For deciding whether a constructor is guarded with enable_if, we consider the
-default values of the type parameters and the types of the contructor
+default values of the type parameters and the types of the constructor
 parameters. If any part of these types is std::enable_if or std::enable_if_t, 
we
 assume the constructor is guarded.

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/performance-inefficient-vector-operation.rst?rev=306750&r1=306749&r2=306750&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
 Thu Jun 29 15:26:06 2017
@@ -18,7 +18,7 @@ statement body:
 v.push_back(n);
 // This will trigger the warning since the push_back may cause multiple
 // memory reallocations in v. This can be avoid by inserting a 'reserve(n)'
-// statment before the for statment.
+// statement before the for statement.
   }
 
 
@@ -36,7 +36,7 @@ statement body:
 v.push_back(element);
 // This will trigger the warning since the 'push_back' may cause multiple
 // memory reallocations in v. This can be avoid by inserting a
-// 'reserve(data.size())' statment before the for statment.
+// 'reserve(data.size())' statement before the for statement.
   }
 
 


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


r306751 - Fix openmp-offload.c test on Windows

2017-06-29 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Jun 29 15:31:16 2017
New Revision: 306751

URL: http://llvm.org/viewvc/llvm-project?rev=306751&view=rev
Log:
Fix openmp-offload.c test on Windows

Modified:
cfe/trunk/test/Driver/openmp-offload.c

Modified: cfe/trunk/test/Driver/openmp-offload.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openmp-offload.c?rev=306751&r1=306750&r2=306751&view=diff
==
--- cfe/trunk/test/Driver/openmp-offload.c (original)
+++ cfe/trunk/test/Driver/openmp-offload.c Thu Jun 29 15:31:16 2017
@@ -593,7 +593,7 @@
 /// ###
 
 /// Check -fopenmp-is-device is passed when compiling for the device.
-// RUN:   %clang -### -fopenmp=libomp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu %s 2>&1 \
+// RUN:   %clang -### -target powerpc64le-linux -fopenmp=libomp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-IS-DEVICE %s
 
-// CHK-FOPENMP-IS-DEVICE: clang{{.*}} "-aux-triple" 
"powerpc64le-unknown-linux-gnu" {{.*}}.c" "-fopenmp-is-device" 
"-fopenmp-host-ir-file-path"
+// CHK-FOPENMP-IS-DEVICE: clang{{.*}} "-aux-triple" "powerpc64le--linux" 
{{.*}}.c" "-fopenmp-is-device" "-fopenmp-host-ir-file-path"


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


[PATCH] D34790: [NewPM] Add a flag -fexperimental-new-pass-manager=on/off/debug for printing debug output.

2017-06-29 Thread Tim Shen via Phabricator via cfe-commits
timshen updated this revision to Diff 104753.
timshen added a comment.

Use a cc1 flag -fdebug-pass-manager instead.


https://reviews.llvm.org/D34790

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Frontend/CodeGenOptions.def
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/lto-newpm-pipeline.c

Index: clang/test/CodeGen/lto-newpm-pipeline.c
===
--- /dev/null
+++ clang/test/CodeGen/lto-newpm-pipeline.c
@@ -0,0 +1,53 @@
+// REQUIRES: x86-registered-target
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -flto=full -O0 %s 2>&1 | FileCheck %s \
+// RUN:   -check-prefix=CHECK-FULL-O0
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -flto=thin -O0 %s 2>&1 | FileCheck %s \
+// RUN:   -check-prefix=CHECK-THIN-O0
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -flto=full -O1 %s 2>&1 | FileCheck %s \
+// RUN:   -check-prefix=CHECK-FULL-OPTIMIZED
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -flto=thin -O1 %s 2>&1 | FileCheck %s \
+// RUN:   -check-prefix=CHECK-THIN-OPTIMIZED
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -flto=full -O2 %s 2>&1 | FileCheck %s \
+// RUN:   -check-prefix=CHECK-FULL-OPTIMIZED
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -flto=thin -O2 %s 2>&1 | FileCheck %s \
+// RUN:   -check-prefix=CHECK-THIN-OPTIMIZED
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -flto=full -O3 %s 2>&1 | FileCheck %s \
+// RUN:   -check-prefix=CHECK-FULL-OPTIMIZED
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -flto=thin -O3 %s 2>&1 | FileCheck %s \
+// RUN:   -check-prefix=CHECK-THIN-OPTIMIZED
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -flto=full -Os %s 2>&1 | FileCheck %s \
+// RUN:   -check-prefix=CHECK-FULL-OPTIMIZED
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -flto=thin -Os %s 2>&1 | FileCheck %s \
+// RUN:   -check-prefix=CHECK-THIN-OPTIMIZED
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -flto=full -Oz %s 2>&1 | FileCheck %s \
+// RUN:   -check-prefix=CHECK-FULL-OPTIMIZED
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -flto=thin -Oz %s 2>&1 | FileCheck %s \
+// RUN:   -check-prefix=CHECK-THIN-OPTIMIZED
+
+// CHECK-FULL-O0: Starting llvm::Module pass manager run.
+// CHECK-FULL-O0: Running pass: AlwaysInlinerPass
+// CHECK-FULL-O0-NEXT: Running pass: BitcodeWriterPass
+// CHECK-FULL-O0: Finished llvm::Module pass manager run.
+
+// CHECK-THIN-O0: Starting llvm::Module pass manager run.
+// CHECK-THIN-O0: Running pass: AlwaysInlinerPass
+// CHECK-THIN-O0-NEXT: Running pass: NameAnonGlobalPass
+// CHECK-THIN-O0-NEXT: Running pass: ThinLTOBitcodeWriterPass
+// CHECK-THIN-O0: Finished llvm::Module pass manager run.
+
+// TODO: The LTO pre-link pipeline currently invokes
+//   buildPerModuleDefaultPipeline(), which contains LoopVectorizePass.
+//   This may change as the pipeline gets implemented.
+// CHECK-FULL-OPTIMIZED: Starting llvm::Function pass manager run.
+// CHECK-FULL-OPTIMIZED: Running pass: LoopVectorizePass
+// CHECK-FULL-OPTIMIZED: Running pass: BitcodeWriterPass
+
+// The ThinLTO pre-link pipeline shouldn't contain passes like
+// LoopVectorizePass.
+// CHECK-THIN-OPTIMIZED: Starting llvm::Function pass manager run.
+// CHECK-THIN-OPTIMIZED-NOT: Running pass: LoopVectorizePass
+// CHECK-THIN-OPTIMIZED: Running pass: NameAnonGlobalPass
+// CHECK-THIN-OPTIMIZED: Running pass: ThinLTOBitcodeWriterPass
+
+void Foo() {}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -476,6 +476,10 @@
   OPT_fexperimental_new_pass_manager, OPT_fno_experimental_new_pass_manager,
   /* Default */ false);
 
+  Opts.DebugPassManager =
+  Args.hasFlag(OPT_fdebug_pass_manager, OPT_fno_debug_pass_manager,
+   /* Default */ false);
+
   if (Arg *A = Args.getLastArg(OPT_fvec

[PATCH] D34790: [NewPM] Add Clang cc1 flag -fdebug-pass-manager for printing debug information.

2017-06-29 Thread Tim Shen via Phabricator via cfe-commits
timshen added a comment.

Also add @tejohnson as a reviewer, since the LTO test changed


https://reviews.llvm.org/D34790



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


[PATCH] D34606: [libcxx] Link MinGW libs for shared build

2017-06-29 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

Not quite sure how this achieves anything different from what is already in 
`cmake/config-ix.cmake` ?
https://reviews.llvm.org/D33638 addresses the remaining changes needed to build 
for windows shared and static in one build.


Repository:
  rL LLVM

https://reviews.llvm.org/D34606



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


[PATCH] D34790: [NewPM] Add Clang cc1 flag -fdebug-pass-manager for printing debug information.

2017-06-29 Thread Tim Shen via Phabricator via cfe-commits
timshen marked 2 inline comments as done.
timshen added inline comments.



Comment at: clang/include/clang/Driver/Options.td:971-973
+def fexperimental_new_pass_manager_EQ : Joined<["-"], 
"fexperimental-new-pass-manager=">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"Enables an experimental new pass manager in LLVM.">, 
Values<"on,off,debug">;

timshen wrote:
> chandlerc wrote:
> > I don't think we want to expose this flag in the driver -- it should really 
> > be a CC1-only thing for debugging.
> > 
> > As such, I think I'd just make it an independent flag:
> > 
> >   -fexperimental-new-pass-manager-debug-logging
> > 
> > Or some such. This also seems easier than having to define a new kind.
> The two small disadvantages of your suggestion is that
> 1) It's more verbose to type: `clang -fexperimental-new-pass-manager 
> -fexperimental-new-pass-manager-debug-logging`
> 2) it's the 3 states vs 4 states pattern: `clang 
> -fno-experimental-new-pass-manager 
> -fexperimental-new-pass-manager-debug-logging` doesn't make sense to me, and 
> it's good to avoid that.
> 
> What do you think about these trade offs?
As discussed offline, (2) isn't a practical issue, and (1) makes sense since 
-fexperimental-new-pass-manager will ultimately go away, but the debug flag 
remains. 


https://reviews.llvm.org/D34790



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


[PATCH] D34790: [NewPM] Add Clang cc1 flag -fdebug-pass-manager for printing debug information.

2017-06-29 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc added a comment.

This looks great to me with a CC1-layer flag. But check that others are happy 
as well, thanks!


https://reviews.llvm.org/D34790



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


[PATCH] D34784: [OpenMP] Add flag for specifying the target device architecture for OpenMP device offloading

2017-06-29 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

In https://reviews.llvm.org/D34784#795934, @hfinkel wrote:

> In https://reviews.llvm.org/D34784#795871, @gtbercea wrote:
>
> > In https://reviews.llvm.org/D34784#795367, @hfinkel wrote:
> >
> > > In https://reviews.llvm.org/D34784#795353, @gtbercea wrote:
> > >
> > > > In https://reviews.llvm.org/D34784#795287, @hfinkel wrote:
> > > >
> > > > > What happens if you have multiple targets? Maybe this should be 
> > > > > -fopenmp-targets-arch=foo,bar,whatever?
> > > > >
> > > > > Once this all lands, please make sure that you add additional test 
> > > > > cases here. Make sure that the arch is passed through to the ptx and 
> > > > > cuda tools as it should be. Make sure that the defaults work. Make 
> > > > > sure that something reasonable happens if the user specifies the 
> > > > > option more than once (if they're all the same).
> > > >
> > > >
> > > > Hi Hal,
> > > >
> > > > At the moment only one arch is supported and it would apply to all the 
> > > > target triples under -fopenmp-targets.
> > > >
> > > > I was planning to address the multiple archs problem in a future patch.
> > > >
> > > > I am assuming that in the case of multiple archs, each arch in 
> > > > -fopenmp-targets-arch=A1,A2,A3 will bind to a corresponding triple in 
> > > > -fopenmp-targets=T1,T2,T3 like so: T1 with A1, T2 with A2 etc. Is this 
> > > > a practical interpretation of what should happen?
> > >
> > >
> > > Yea, that's what I was thinking. I'm a bit concerned that none of this 
> > > generalizes well. To take a step back, under what circumstances do we 
> > > support multiple targets right now?
> >
> >
> > We allow -fopenmp-targets to get a list of triples. I am not aware of any 
> > limitations in terms of how many of these triples you can have. Even in the 
> > test file of this patch we have the following: 
> > "-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux"
> >
> > > 
> > > 
> > >> Regarding tests: more tests can be added as a separate patch once 
> > >> offloading is enabled by the patch following this one (i.e. 
> > >> https://reviews.llvm.org/D29654). There actually is a test in 
> > >> https://reviews.llvm.org/D29654 where I check that the arch is passed to 
> > >> ptxas and nvlink correctly using this flag. I will add some more test 
> > >> cases to cover the other situations you mentioned.
> > > 
> > > Sounds good.
> > > 
> > >> Thanks,
> > >> 
> > >> --Doru
> >
> > In our previous solution there might be a problem.  The same triple might 
> > be used multiple times just so that you can have several archs in the other 
> > flag (T1 and T2 being the same). There are some alternatives which I have 
> > discussed with @ABataev.
> >
> > One solution could be to associate an arch with each triple to avoid 
> > positional matching of triples in one flag with archs in another flag:
> >
> >   -fopenmp-targets=T1:A1,T2,T3:A2
> >
> >
> > ":A1" is optional, also, in the future, we can pass other things to the 
> > toolchain such as "-L/a/b/c/d":
> >
> >   -fopenmp-targets=T1:A1: -L/a/b/c/d,T2,T3:A2
> >
>
>
> Okay, good, this is exactly where I was going when I said I was worried about 
> generalization. -march seems like one of many flags I might want to pass to 
> the target compilation. Moreover, it doesn't seem special in what regard.
>
> We have -Xclang and -mllvm, etc. to pass flags through to other stages of 
> compilation. Could we do something similar here? Maybe something like: 
> ``-Xopenmp-target:openmp-powerpc64le-ibm-linux-gnu -march=pwr7``. That's 
> unfortunately long, but if there's only one target, we could omit the triple?


The triple could be omitted, absolutely.

If you have the following:

-fopenmp-targets=openmp-powerpc64le-ibm-linux-gnu 
``-Xopenmp-target:openmp-powerpc64le-ibm-linux-gnu -march=pwr7`` 
``-Xopenmp-target:openmp-powerpc64le-ibm-linux-gnu -march=pwr8``

This would end up having a toolchain called for each one of the -Xopenmp-target 
sets of flags even though a single triple was specified under the 
-fopenmp-targets. Would this be ok?

> 
> 
>> An actual example:
>> 
>>   -fopenmp-targets=nvptx64-nvidia-cuda:sm_35,openmp-powerpc64le-ibm-linux-gnu


Repository:
  rL LLVM

https://reviews.llvm.org/D34784



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


[PATCH] D34606: [libcxx] Link MinGW libs for shared build

2017-06-29 Thread Mateusz Mikuła via Phabricator via cfe-commits
mati865 added a comment.

Sorry @martell I totally forgot about it.
I'll test https://reviews.llvm.org/D33638 later today.


Repository:
  rL LLVM

https://reviews.llvm.org/D34606



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


[PATCH] D34839: [Driver] Honor -nostdinc and -isystem-after on CrossWindows

2017-06-29 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd accepted this revision.
compnerd added a comment.
This revision is now accepted and ready to land.

This seems like a good idea.  Thanks!


https://reviews.llvm.org/D34839



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


r306753 - [ODRHash] Improve typedef handling.

2017-06-29 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Thu Jun 29 15:53:04 2017
New Revision: 306753

URL: http://llvm.org/viewvc/llvm-project?rev=306753&view=rev
Log:
[ODRHash] Improve typedef handling.

Follow typedef chains to find the root type when processing types, and also
keep track of qualifiers.

Modified:
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=306753&r1=306752&r2=306753&view=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Thu Jun 29 15:53:04 2017
@@ -430,6 +430,13 @@ public:
 Hash.AddQualType(T);
   }
 
+  void AddType(const Type *T) {
+Hash.AddBoolean(T);
+if (T) {
+  Hash.AddType(T);
+}
+  }
+
   void AddNestedNameSpecifier(const NestedNameSpecifier *NNS) {
 Hash.AddNestedNameSpecifier(NNS);
   }
@@ -517,7 +524,13 @@ public:
 
   void VisitTypedefType(const TypedefType *T) {
 AddDecl(T->getDecl());
-AddQualType(T->getDecl()->getUnderlyingType().getCanonicalType());
+QualType UnderlyingType = T->getDecl()->getUnderlyingType();
+VisitQualifiers(UnderlyingType.getQualifiers());
+while (const TypedefType *Underlying =
+   dyn_cast(UnderlyingType.getTypePtr())) {
+  UnderlyingType = Underlying->getDecl()->getUnderlyingType();
+}
+AddType(UnderlyingType.getTypePtr());
 VisitType(T);
   }
 

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=306753&r1=306752&r2=306753&view=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Thu Jun 29 15:53:04 2017
@@ -1762,6 +1762,22 @@ struct S2 {
 #else
 S2 s2;
 #endif
+
+#if defined(FIRST)
+using A3 = const int;
+using B3 = volatile A3;
+struct S3 {
+  B3 x = 1;
+};
+#elif defined(SECOND)
+using A3 = volatile const int;
+using B3 = A3;
+struct S3 {
+  B3 x = 1;
+};
+#else
+S3 s3;
+#endif
 }
 
 // Keep macros contained to one file.


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


[PATCH] D34784: [OpenMP] Add flag for specifying the target device architecture for OpenMP device offloading

2017-06-29 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D34784#795980, @gtbercea wrote:

> In https://reviews.llvm.org/D34784#795934, @hfinkel wrote:
>
> > In https://reviews.llvm.org/D34784#795871, @gtbercea wrote:
> >
> > > In https://reviews.llvm.org/D34784#795367, @hfinkel wrote:
> > >
> > > > In https://reviews.llvm.org/D34784#795353, @gtbercea wrote:
> > > >
> > > > > In https://reviews.llvm.org/D34784#795287, @hfinkel wrote:
> > > > >
> > > > > > What happens if you have multiple targets? Maybe this should be 
> > > > > > -fopenmp-targets-arch=foo,bar,whatever?
> > > > > >
> > > > > > Once this all lands, please make sure that you add additional test 
> > > > > > cases here. Make sure that the arch is passed through to the ptx 
> > > > > > and cuda tools as it should be. Make sure that the defaults work. 
> > > > > > Make sure that something reasonable happens if the user specifies 
> > > > > > the option more than once (if they're all the same).
> > > > >
> > > > >
> > > > > Hi Hal,
> > > > >
> > > > > At the moment only one arch is supported and it would apply to all 
> > > > > the target triples under -fopenmp-targets.
> > > > >
> > > > > I was planning to address the multiple archs problem in a future 
> > > > > patch.
> > > > >
> > > > > I am assuming that in the case of multiple archs, each arch in 
> > > > > -fopenmp-targets-arch=A1,A2,A3 will bind to a corresponding triple in 
> > > > > -fopenmp-targets=T1,T2,T3 like so: T1 with A1, T2 with A2 etc. Is 
> > > > > this a practical interpretation of what should happen?
> > > >
> > > >
> > > > Yea, that's what I was thinking. I'm a bit concerned that none of this 
> > > > generalizes well. To take a step back, under what circumstances do we 
> > > > support multiple targets right now?
> > >
> > >
> > > We allow -fopenmp-targets to get a list of triples. I am not aware of any 
> > > limitations in terms of how many of these triples you can have. Even in 
> > > the test file of this patch we have the following: 
> > > "-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux"
> > >
> > > > 
> > > > 
> > > >> Regarding tests: more tests can be added as a separate patch once 
> > > >> offloading is enabled by the patch following this one (i.e. 
> > > >> https://reviews.llvm.org/D29654). There actually is a test in 
> > > >> https://reviews.llvm.org/D29654 where I check that the arch is passed 
> > > >> to ptxas and nvlink correctly using this flag. I will add some more 
> > > >> test cases to cover the other situations you mentioned.
> > > > 
> > > > Sounds good.
> > > > 
> > > >> Thanks,
> > > >> 
> > > >> --Doru
> > >
> > > In our previous solution there might be a problem.  The same triple might 
> > > be used multiple times just so that you can have several archs in the 
> > > other flag (T1 and T2 being the same). There are some alternatives which 
> > > I have discussed with @ABataev.
> > >
> > > One solution could be to associate an arch with each triple to avoid 
> > > positional matching of triples in one flag with archs in another flag:
> > >
> > >   -fopenmp-targets=T1:A1,T2,T3:A2
> > >
> > >
> > > ":A1" is optional, also, in the future, we can pass other things to the 
> > > toolchain such as "-L/a/b/c/d":
> > >
> > >   -fopenmp-targets=T1:A1: -L/a/b/c/d,T2,T3:A2
> > >
> >
> >
> > Okay, good, this is exactly where I was going when I said I was worried 
> > about generalization. -march seems like one of many flags I might want to 
> > pass to the target compilation. Moreover, it doesn't seem special in what 
> > regard.
> >
> > We have -Xclang and -mllvm, etc. to pass flags through to other stages of 
> > compilation. Could we do something similar here? Maybe something like: 
> > ``-Xopenmp-target:openmp-powerpc64le-ibm-linux-gnu -march=pwr7``. That's 
> > unfortunately long, but if there's only one target, we could omit the 
> > triple?
>
>
> The triple could be omitted, absolutely.
>
> If you have the following:
>
> -fopenmp-targets=openmp-powerpc64le-ibm-linux-gnu 
> ``-Xopenmp-target:openmp-powerpc64le-ibm-linux-gnu -march=pwr7`` 
> ``-Xopenmp-target:openmp-powerpc64le-ibm-linux-gnu -march=pwr8``
>
> This would end up having a toolchain called for each one of the 
> -Xopenmp-target sets of flags even though a single triple was specified under 
> the -fopenmp-targets. Would this be ok?


Why? That does not sound desirable. And could you even use these multiple 
outputs? I think you'd want to pass all of the arguments for each target triple 
to the one toolchain invocation for that target triple. Is that possible?

> 
> 
>> 
>> 
>>> An actual example:
>>> 
>>>   
>>> -fopenmp-targets=nvptx64-nvidia-cuda:sm_35,openmp-powerpc64le-ibm-linux-gnu




Repository:
  rL LLVM

https://reviews.llvm.org/D34784



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


  1   2   >