[PATCH] D36450: [X86][Ms-InlineAsm] Extend MS Dot operator to accept "this" + struct/class pointers aliases

2017-08-08 Thread coby via Phabricator via cfe-commits
coby created this revision.
Herald added a subscriber: eraman.

MS InlineAsm Dot operator accepts "Bases" such as "this" (cpp) and class/struct 
pointer typedef.
This patch enhance its implementation with this behavior.


Repository:
  rL LLVM

https://reviews.llvm.org/D36450

Files:
  lib/Sema/SemaStmtAsm.cpp
  test/CodeGen/ms-inline-asm.c
  test/CodeGen/ms-inline-asm.cpp

Index: lib/Sema/SemaStmtAsm.cpp
===
--- lib/Sema/SemaStmtAsm.cpp
+++ lib/Sema/SemaStmtAsm.cpp
@@ -677,22 +677,32 @@
   SmallVector Members;
   Member.split(Members, ".");
 
-  LookupResult BaseResult(*this, &Context.Idents.get(Base), SourceLocation(),
-  LookupOrdinaryName);
+  NamedDecl *FoundDecl = nullptr;
 
-  if (!LookupName(BaseResult, getCurScope()))
-return true;
-  
-  if(!BaseResult.isSingleResult())
+  // MS InlineAsm uses 'this' as a base
+  if (getLangOpts().CPlusPlus && Base.equals("this")) {
+if (const Type *PT = getCurrentThisType().getTypePtrOrNull())
+  FoundDecl = PT->getPointeeType()->getAsTagDecl();
+  } else {
+LookupResult BaseResult(*this, &Context.Idents.get(Base), SourceLocation(),
+LookupOrdinaryName);
+if (LookupName(BaseResult, getCurScope()) && BaseResult.isSingleResult())
+  FoundDecl = BaseResult.getFoundDecl();
+  }
+
+  if (!FoundDecl)
 return true;
-  NamedDecl *FoundDecl = BaseResult.getFoundDecl();
+
   for (StringRef NextMember : Members) {
 const RecordType *RT = nullptr;
 if (VarDecl *VD = dyn_cast(FoundDecl))
   RT = VD->getType()->getAs();
 else if (TypedefNameDecl *TD = dyn_cast(FoundDecl)) {
   MarkAnyDeclReferenced(TD->getLocation(), TD, /*OdrUse=*/false);
-  RT = TD->getUnderlyingType()->getAs();
+  // MS InlineAsm often uses struct pointer aliases as a base
+  const QualType QT = TD->getUnderlyingType();
+  RT = isa(QT) ? QT->getPointeeType()->getAs() :
+  QT->getAs();
 } else if (TypeDecl *TD = dyn_cast(FoundDecl))
   RT = TD->getTypeForDecl()->getAs();
 else if (FieldDecl *TD = dyn_cast(FoundDecl))
Index: test/CodeGen/ms-inline-asm.c
===
--- test/CodeGen/ms-inline-asm.c
+++ test/CodeGen/ms-inline-asm.c
@@ -527,7 +527,7 @@
 typedef struct {
   int a;
   int b;
-} A;
+} A, *pA;
 
 typedef struct {
   int b1;
@@ -539,14 +539,16 @@
   A   c2;
   int c3;
   B   c4;
-} C;
+} C, *pC;
 
 void t39() {
 // CHECK-LABEL: define void @t39
   __asm mov eax, [eax].A.b
 // CHECK: mov eax, [eax].4
   __asm mov eax, [eax] A.b
 // CHECK: mov eax, [eax] .4
+  __asm mov eax, [eax] pA.b
+// CHECK: mov eax, [eax] .4
   __asm mov eax, fs:[0] A.b
 // CHECK: mov eax, fs:[$$0] .4
   __asm mov eax, [eax].B.b2.a
@@ -557,6 +559,8 @@
 // CHECK: mov eax, fs:[$$0] .8
   __asm mov eax, [eax]C.c4.b2.b
 // CHECK: mov eax, [eax].24
+  __asm mov eax, [eax]pC.c4.b2.b
+// CHECK: mov eax, [eax].24
 // CHECK: "~{eax},~{dirflag},~{fpsr},~{flags}"()
 }
 
Index: test/CodeGen/ms-inline-asm.cpp
===
--- test/CodeGen/ms-inline-asm.cpp
+++ test/CodeGen/ms-inline-asm.cpp
@@ -180,3 +180,19 @@
   A::g();
 }
 
+void t9() {
+  // CHECK-LABEL: define void @_Z2t9v()
+  struct A {
+int a;
+int b;
+void g() {
+  __asm mov eax, dword ptr [eax]this.b
+  // CHECK: call void asm sideeffect inteldialect
+  // CHECK-SAME: mov eax, dword ptr [eax].4
+  // CHECK-SAME: "~{eax},~{dirflag},~{fpsr},~{flags}"()
+}
+  };
+  A AA;
+  AA.g();
+}
+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36159: clang-format: [JS] handle single lines comments ending in `\\`.

2017-08-08 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg




Comment at: lib/Format/FormatTokenLexer.cpp:544-545
+while (BackslashPos != StringRef::npos) {
+  if (BackslashPos + 1 < FormatTok->TokenText.size() &&
+  FormatTok->TokenText[BackslashPos + 1] == '\n') {
+const char *Offset = Lex->getBufferLocation();

Just wondering whether the \n can be in the next token. Probably not, though, 
the way we set up the lexer.


https://reviews.llvm.org/D36159



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


[PATCH] D36261: [clangd] Use multiple working threads in clangd.

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

High-level question: Why can't we use llvm::ThreadPool?


https://reviews.llvm.org/D36261



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


[PATCH] D36398: [clangd] Check if CompileCommand has changed on forceReparse.

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

Also missing tests :)




Comment at: clangd/ClangdUnitStore.cpp:45
+ .first;
+Result.RemovedFile = nullptr;
+  } else if (!compileCommandsAreEqual(It->second->getCompileCommand(),

ilya-biryukov wrote:
> klimek wrote:
> > Just say RemovedFile = nullptr in the struct?
> I'd argue that having it in the code, rather than declaration makes it more 
> readable. Besides, default ctor of shared_ptr gives us nullptr anyway, so we 
> can also leave it as is and remove the assignments altogether.
> 
> I've moved `=nullptr` assignments out of the if/else bodies. Let me know if 
> it still looks ugly.
Ah, I missed that it's a smart pointer; in that case, yes, remove the = nullptr.



Comment at: clangd/ClangdUnitStore.h:45-48
+  struct RecreateResult {
+std::shared_ptr FileInCollection;
+std::shared_ptr RemovedFile;
+  };

ilya-biryukov wrote:
> klimek wrote:
> > Not obvious to me what things in there mean.
> Added a comment. Hopefully makes sense now.
Better, thanks. Now, why does this need to be shared_ptr (as opposed to 
unique_ptr)? Don't we always only have one?


https://reviews.llvm.org/D36398



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


[PATCH] D30295: [analyzer] clarify undef shift result when shift count is negative or exceeds the bit width

2017-08-08 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

It looks good to me but let's wait for Anna, NoQ, or Devin for the final word.


Repository:
  rL LLVM

https://reviews.llvm.org/D30295



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


[PATCH] D35068: [analyzer] Detect usages of unsafe I/O functions

2017-08-08 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In https://reviews.llvm.org/D35068#811437, @NoQ wrote:

> It'd look good in clang-tidy (especially if extended to provide fixits), but 
> if Daniel is interested in having this feature in the analyzer (and picked by 
> clang-tidy from there), i wouldn't mind.
>
> I wonder how noisy this check is - did you test it on large codebases? 
> Because these functions are popular, and in many cases it'd be fine to use 
> insecure functions, i wonder if it's worth it to have this check on by 
> default. Like, if it's relatively quiet - it's fine, but if it'd constitute 
> 90% of the analyzer's warnings on popular projects, that'd probably not be 
> fine.


This patch basically extends an already existing static analyzer check. Even if 
tidy might be a better fit, I wonder what is the right thing to do in this 
case. We either end up overlapping functionality with the analyzer and tidy or 
have to come up with a policy what to do in this such cases.


Repository:
  rL LLVM

https://reviews.llvm.org/D35068



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


[PATCH] D35068: [analyzer] Detect usages of unsafe I/O functions

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



Comment at: lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp:622
+}
+//===--===//
+// Check: Use of 'sprintf', 'vsprintf', 'scanf', 'wscanf', 'fscanf',

I would put a new line above and remove one bellow. 



Comment at: lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp:632
+
+void WalkAST::checkUnsafeBufferHandling(const CallExpr *CE, const FunctionDecl 
*FD) { //TODO:TESTS
+  if (!filter.check_UnsafeBufferHandling)

NoQ wrote:
> Because it also checks deprecated buffer handling, i'd rename this function 
> to `checkDeprecatedOrUnsafeBufferHandling`.
Is the TODO still relevant in this line?


Repository:
  rL LLVM

https://reviews.llvm.org/D35068



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


[PATCH] D35955: clang-format: Add preprocessor directive indentation

2017-08-08 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

Manuel: Can you take a look at the last comment here? Why does PPBranchLevel 
start at -1?


https://reviews.llvm.org/D35955



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


[PATCH] D36261: [clangd] Use multiple working threads in clangd.

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

In https://reviews.llvm.org/D36261#834902, @klimek wrote:

> High-level question: Why can't we use llvm::ThreadPool?


It is not an in-place replacement as it does not allow to prioritize new tasks 
over old ones (new tasks are usually more important for clangd as the old ones 
are often outdated when new ones are added).
I looked into using `llvm::ThreadPool` before, but decided to stay with our own 
implementation.
It gives us more flexibility over threading and it is not hard to maintain (I 
think it's under 100 lines of code, and the code is rather simple).


https://reviews.llvm.org/D36261



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


[PATCH] D36452: [clang-tidy] Fix another crash in make-unique check.

2017-08-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
Herald added subscribers: xazax.hun, JDevlieghere.

The crash happens when calling `reset` method without any preceding
operation like "->" or ".", this could happen in a subclass of the
"std::unique_ptr".


https://reviews.llvm.org/D36452

Files:
  clang-tidy/modernize/MakeSmartPtrCheck.cpp
  test/clang-tidy/modernize-make-unique.cpp


Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -415,3 +415,16 @@
   g2(t);
 }
 #undef DEFINE
+
+class UniqueFoo : public std::unique_ptr {
+ public:
+  void foo() {
+reset(new Foo);
+this->reset(new Foo);
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use std::make_unique instead
+// CHECK-FIXES: *this = std::make_unique();
+(*this).reset(new Foo);
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead
+// CHECK-FIXES: (*this) = std::make_unique();
+  }
+};
Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -199,6 +199,13 @@
 return;
   }
 
+  // There are some cases where we don't have operator ("." or "->") of the
+  // "reset" expression, e.g. call "reset()" method directly in the subclass of
+  // "std::unique_ptr<>". We skip these cases.
+  if (OperatorLoc.isInvalid()) {
+return;
+  }
+
   auto Diag = diag(ResetCallStart, "use %0 instead")
   << MakeSmartPtrFunctionName;
 


Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -415,3 +415,16 @@
   g2(t);
 }
 #undef DEFINE
+
+class UniqueFoo : public std::unique_ptr {
+ public:
+  void foo() {
+reset(new Foo);
+this->reset(new Foo);
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use std::make_unique instead
+// CHECK-FIXES: *this = std::make_unique();
+(*this).reset(new Foo);
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead
+// CHECK-FIXES: (*this) = std::make_unique();
+  }
+};
Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -199,6 +199,13 @@
 return;
   }
 
+  // There are some cases where we don't have operator ("." or "->") of the
+  // "reset" expression, e.g. call "reset()" method directly in the subclass of
+  // "std::unique_ptr<>". We skip these cases.
+  if (OperatorLoc.isInvalid()) {
+return;
+  }
+
   auto Diag = diag(ResetCallStart, "use %0 instead")
   << MakeSmartPtrFunctionName;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36398: [clangd] Check if CompileCommand has changed on forceReparse.

2017-08-08 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 110155.
ilya-biryukov added a comment.

Addressed review comments.

- Added a test for forceReparse.
- Got rid of a redundant `= nullptr` assignment.


https://reviews.llvm.org/D36398

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnitStore.cpp
  clangd/ClangdUnitStore.h
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -500,6 +500,53 @@
 }
 #endif // LLVM_ON_UNIX
 
+TEST_F(ClangdVFSTest, ForceReparseCompileCommand) {
+  MockFSProvider FS;
+  ErrorCheckingDiagConsumer DiagConsumer;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
+  ClangdServer Server(CDB, DiagConsumer, FS,
+  /*RunSynchronously=*/true);
+  // No need to sync reparses, because RunSynchronously is set
+  // to true.
+
+  auto FooCpp = getVirtualTestFilePath("foo.cpp");
+  const auto SourceContents1 = R"cpp(
+template 
+struct foo { T x; };
+)cpp";
+  const auto SourceContents2 = R"cpp(
+template 
+struct bar { T x; };
+)cpp";
+
+  FS.Files[FooCpp] = "";
+  FS.ExpectedFile = FooCpp;
+
+  // First parse files in C mode and check they produce errors.
+  CDB.ExtraClangFlags = {"-xc"};
+  Server.addDocument(FooCpp, SourceContents1);
+  EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
+  Server.addDocument(FooCpp, SourceContents2);
+  EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
+
+  // Now switch to C++ mode.
+  CDB.ExtraClangFlags = {"-xc++"};
+  // Currently, addDocument never checks if CompileCommand has changed, so we
+  // expect to see the errors.
+  Server.addDocument(FooCpp, SourceContents1);
+  EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
+  Server.addDocument(FooCpp, SourceContents2);
+  EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
+  // But forceReparse should reparse the file with proper flags.
+  Server.forceReparse(FooCpp);
+  EXPECT_FALSE(DiagConsumer.hadErrorInLastDiags());
+  // Subsequent addDocument calls should finish without errors too.
+  Server.addDocument(FooCpp, SourceContents1);
+  EXPECT_FALSE(DiagConsumer.hadErrorInLastDiags());
+  Server.addDocument(FooCpp, SourceContents2);
+  EXPECT_FALSE(DiagConsumer.hadErrorInLastDiags());
+}
+
 class ClangdCompletionTest : public ClangdVFSTest {
 protected:
   bool ContainsItem(std::vector const &Items, StringRef Name) {
Index: clangd/ClangdUnitStore.h
===
--- clangd/ClangdUnitStore.h
+++ clangd/ClangdUnitStore.h
@@ -42,6 +42,25 @@
 return It->second;
   }
 
+  struct RecreateResult {
+/// A CppFile, stored in this CppFileCollection for the corresponding
+/// filepath after calling recreateFileIfCompileCommandChanged.
+std::shared_ptr FileInCollection;
+/// If a new CppFile had to be created to account for changed
+/// CompileCommand, a previous CppFile instance will be returned in this
+/// field.
+std::shared_ptr RemovedFile;
+  };
+
+  /// Similar to getOrCreateFile, but will replace a current CppFile for \p File
+  /// with a new one if CompileCommand, provided by \p CDB has changed.
+  /// If a currently stored CppFile had to be replaced, the previous instance
+  /// will be returned in RecreateResult.RemovedFile.
+  RecreateResult recreateFileIfCompileCommandChanged(
+  PathRef File, PathRef ResourceDir, GlobalCompilationDatabase &CDB,
+  std::shared_ptr PCHs,
+  IntrusiveRefCntPtr VFS);
+
   std::shared_ptr getFile(PathRef File) {
 std::lock_guard Lock(Mutex);
 
@@ -59,6 +78,9 @@
   tooling::CompileCommand getCompileCommand(GlobalCompilationDatabase &CDB,
 PathRef File, PathRef ResourceDir);
 
+  bool compileCommandsAreEqual(tooling::CompileCommand const &LHS,
+   tooling::CompileCommand const &RHS);
+
   std::mutex Mutex;
   llvm::StringMap> OpenedFiles;
 };
Index: clangd/ClangdUnitStore.cpp
===
--- clangd/ClangdUnitStore.cpp
+++ clangd/ClangdUnitStore.cpp
@@ -9,6 +9,7 @@
 
 #include "ClangdUnitStore.h"
 #include "llvm/Support/Path.h"
+#include 
 
 using namespace clang::clangd;
 using namespace clang;
@@ -25,6 +26,32 @@
   return Result;
 }
 
+CppFileCollection::RecreateResult
+CppFileCollection::recreateFileIfCompileCommandChanged(
+PathRef File, PathRef ResourceDir, GlobalCompilationDatabase &CDB,
+std::shared_ptr PCHs,
+IntrusiveRefCntPtr VFS) {
+  auto NewCommand = getCompileCommand(CDB, File, ResourceDir);
+
+  std::lock_guard Lock(Mutex);
+
+  RecreateResult Result;
+
+  auto It = OpenedFiles.find(File);
+  if (It == OpenedFiles.end()) {
+It = OpenedFiles
+ .try_emplace(File, CppFile::Create(File, std::move(NewCommand),
+std::move(PCHs)))
+ .first;
+  }

[PATCH] D36398: [clangd] Check if CompileCommand has changed on forceReparse.

2017-08-08 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov marked an inline comment as done.
ilya-biryukov added a comment.

In https://reviews.llvm.org/D36398#834904, @klimek wrote:

> Also missing tests :)


Done :-)




Comment at: clangd/ClangdUnitStore.h:45-48
+  struct RecreateResult {
+std::shared_ptr FileInCollection;
+std::shared_ptr RemovedFile;
+  };

klimek wrote:
> ilya-biryukov wrote:
> > klimek wrote:
> > > Not obvious to me what things in there mean.
> > Added a comment. Hopefully makes sense now.
> Better, thanks. Now, why does this need to be shared_ptr (as opposed to 
> unique_ptr)? Don't we always only have one?
This `CppFile` may still be referenced from the worker threads that store a 
pending reparse task for this file. Or there may even be an active reparse on a 
separate thread.


https://reviews.llvm.org/D36398



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


[PATCH] D36453: [libclang] Fix PR34055 (incompatible update of clang-c/Index.h)

2017-08-08 Thread Nikolai Bozhenov via Phabricator via cfe-commits
n.bozhenov created this revision.

Fixes a regression introduced by r308218.


https://reviews.llvm.org/D36453

Files:
  clang/include/clang-c/Index.h


Index: clang/include/clang-c/Index.h
===
--- clang/include/clang-c/Index.h
+++ clang/include/clang-c/Index.h
@@ -3206,6 +3206,8 @@
   CXCallingConv_X86RegCall = 8,
   CXCallingConv_IntelOclBicc = 9,
   CXCallingConv_Win64 = 10,
+  /* Alias for compatibility with older versions of API. */
+  CXCallingConv_X86_64Win64 = CXCallingConv_Win64,
   CXCallingConv_X86_64SysV = 11,
   CXCallingConv_X86VectorCall = 12,
   CXCallingConv_Swift = 13,


Index: clang/include/clang-c/Index.h
===
--- clang/include/clang-c/Index.h
+++ clang/include/clang-c/Index.h
@@ -3206,6 +3206,8 @@
   CXCallingConv_X86RegCall = 8,
   CXCallingConv_IntelOclBicc = 9,
   CXCallingConv_Win64 = 10,
+  /* Alias for compatibility with older versions of API. */
+  CXCallingConv_X86_64Win64 = CXCallingConv_Win64,
   CXCallingConv_X86_64SysV = 11,
   CXCallingConv_X86VectorCall = 12,
   CXCallingConv_Swift = 13,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36453: [libclang] Fix PR34055 (incompatible update of clang-c/Index.h)

2017-08-08 Thread Nikolai Bozhenov via Phabricator via cfe-commits
n.bozhenov added a comment.

If the patch is accepted, it should also be merged into 5.0, I believe.


https://reviews.llvm.org/D36453



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


[PATCH] D36359: [clang-format] Put '/**' and '*/' on own lines in jsdocs ending in comment pragmas

2017-08-08 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 110156.
krasimir added a comment.

- Simplify getSplitAfterLastLine


https://reviews.llvm.org/D36359

Files:
  lib/Format/BreakableToken.cpp
  lib/Format/BreakableToken.h
  lib/Format/ContinuationIndenter.cpp
  unittests/Format/FormatTestJS.cpp

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -158,6 +158,53 @@
"var x = 1;\n"
"}",
getGoogleJSStyleWithColumns(20)));
+
+  // Don't break the first line of a single line short jsdoc comment pragma.
+  EXPECT_EQ("/** @returns j */",
+format("/** @returns j */",
+   getGoogleJSStyleWithColumns(20)));
+
+  // Break a single line long jsdoc comment pragma.
+  EXPECT_EQ("/**\n"
+" * @returns {string} jsdoc line 12\n"
+" */",
+format("/** @returns {string} jsdoc line 12 */",
+   getGoogleJSStyleWithColumns(20)));
+
+  EXPECT_EQ("/**\n"
+" * @returns {string} jsdoc line 12\n"
+" */",
+format("/** @returns {string} jsdoc line 12  */",
+   getGoogleJSStyleWithColumns(20)));
+
+  EXPECT_EQ("/**\n"
+" * @returns {string} jsdoc line 12\n"
+" */",
+format("/** @returns {string} jsdoc line 12*/",
+   getGoogleJSStyleWithColumns(20)));
+
+  // Fix a multiline jsdoc comment ending in a comment pragma.
+  EXPECT_EQ("/**\n"
+" * line 1\n"
+" * line 2\n"
+" * @returns {string} jsdoc line 12\n"
+" */",
+format("/** line 1\n"
+   " * line 2\n"
+   " * @returns {string} jsdoc line 12 */",
+   getGoogleJSStyleWithColumns(20)));
+
+  EXPECT_EQ("/**\n"
+" * line 1\n"
+" * line 2\n"
+" *\n"
+" * @returns j\n"
+" */",
+format("/** line 1\n"
+   " * line 2\n"
+   " *\n"
+   " * @returns j */",
+   getGoogleJSStyleWithColumns(20)));
 }
 
 TEST_F(FormatTestJS, UnderstandsJavaScriptOperators) {
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -1383,8 +1383,8 @@
 }
   }
 
-  BreakableToken::Split SplitAfterLastLine = Token->getSplitAfterLastLine(
-  TailOffset, ColumnLimit, CommentPragmasRegex);
+  BreakableToken::Split SplitAfterLastLine =
+  Token->getSplitAfterLastLine(TailOffset, ColumnLimit);
   if (SplitAfterLastLine.first != StringRef::npos) {
 if (!DryRun)
   Token->replaceWhitespaceAfterLastLine(TailOffset, SplitAfterLastLine,
Index: lib/Format/BreakableToken.h
===
--- lib/Format/BreakableToken.h
+++ lib/Format/BreakableToken.h
@@ -161,8 +161,8 @@
   ///
   /// A result having offset == StringRef::npos means that no reformat is
   /// necessary.
-  virtual Split getSplitAfterLastLine(unsigned TailOffset, unsigned ColumnLimit,
-  llvm::Regex &CommentPragmasRegex) const {
+  virtual Split getSplitAfterLastLine(unsigned TailOffset,
+  unsigned ColumnLimit) const {
 return Split(StringRef::npos, 0);
   }
 
@@ -347,8 +347,8 @@
   void replaceWhitespaceBefore(unsigned LineIndex, unsigned PreviousEndColumn,
unsigned ColumnLimit, Split SplitBefore,
WhitespaceManager &Whitespaces) override;
-  Split getSplitAfterLastLine(unsigned TailOffset, unsigned ColumnLimit,
-  llvm::Regex &CommentPragmasRegex) const override;
+  Split getSplitAfterLastLine(unsigned TailOffset,
+  unsigned ColumnLimit) const override;
 
   bool mayReflow(unsigned LineIndex,
  llvm::Regex &CommentPragmasRegex) const override;
Index: lib/Format/BreakableToken.cpp
===
--- lib/Format/BreakableToken.cpp
+++ lib/Format/BreakableToken.cpp
@@ -22,6 +22,11 @@
 #include 
 
 #define DEBUG_TYPE "format-token-breaker"
+#define DBG(A) \
+  DEBUG({  \
+llvm::dbgs() << __func__ << ":" << __LINE__ << ":" << #A << " = '" << A\
+ << "'\n"; \
+  });
 
 namespace clang {
 namespace format {
@@ -681,12 +686,18 @@
   InPPDirective, /*Newlines=*/1, ContentColumn[LineIndex] - Prefix.size());
 }
 
-BreakableToken::Split BreakableBlockComment::getSplitAfterLastLine(
-unsigned TailOffset

[PATCH] D36359: [clang-format] Put '/**' and '*/' on own lines in jsdocs ending in comment pragmas

2017-08-08 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 110157.
krasimir added a comment.

- Remove debugging


https://reviews.llvm.org/D36359

Files:
  lib/Format/BreakableToken.cpp
  lib/Format/BreakableToken.h
  lib/Format/ContinuationIndenter.cpp
  unittests/Format/FormatTestJS.cpp

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -158,6 +158,53 @@
"var x = 1;\n"
"}",
getGoogleJSStyleWithColumns(20)));
+
+  // Don't break the first line of a single line short jsdoc comment pragma.
+  EXPECT_EQ("/** @returns j */",
+format("/** @returns j */",
+   getGoogleJSStyleWithColumns(20)));
+
+  // Break a single line long jsdoc comment pragma.
+  EXPECT_EQ("/**\n"
+" * @returns {string} jsdoc line 12\n"
+" */",
+format("/** @returns {string} jsdoc line 12 */",
+   getGoogleJSStyleWithColumns(20)));
+
+  EXPECT_EQ("/**\n"
+" * @returns {string} jsdoc line 12\n"
+" */",
+format("/** @returns {string} jsdoc line 12  */",
+   getGoogleJSStyleWithColumns(20)));
+
+  EXPECT_EQ("/**\n"
+" * @returns {string} jsdoc line 12\n"
+" */",
+format("/** @returns {string} jsdoc line 12*/",
+   getGoogleJSStyleWithColumns(20)));
+
+  // Fix a multiline jsdoc comment ending in a comment pragma.
+  EXPECT_EQ("/**\n"
+" * line 1\n"
+" * line 2\n"
+" * @returns {string} jsdoc line 12\n"
+" */",
+format("/** line 1\n"
+   " * line 2\n"
+   " * @returns {string} jsdoc line 12 */",
+   getGoogleJSStyleWithColumns(20)));
+
+  EXPECT_EQ("/**\n"
+" * line 1\n"
+" * line 2\n"
+" *\n"
+" * @returns j\n"
+" */",
+format("/** line 1\n"
+   " * line 2\n"
+   " *\n"
+   " * @returns j */",
+   getGoogleJSStyleWithColumns(20)));
 }
 
 TEST_F(FormatTestJS, UnderstandsJavaScriptOperators) {
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -1383,8 +1383,8 @@
 }
   }
 
-  BreakableToken::Split SplitAfterLastLine = Token->getSplitAfterLastLine(
-  TailOffset, ColumnLimit, CommentPragmasRegex);
+  BreakableToken::Split SplitAfterLastLine =
+  Token->getSplitAfterLastLine(TailOffset, ColumnLimit);
   if (SplitAfterLastLine.first != StringRef::npos) {
 if (!DryRun)
   Token->replaceWhitespaceAfterLastLine(TailOffset, SplitAfterLastLine,
Index: lib/Format/BreakableToken.h
===
--- lib/Format/BreakableToken.h
+++ lib/Format/BreakableToken.h
@@ -161,8 +161,8 @@
   ///
   /// A result having offset == StringRef::npos means that no reformat is
   /// necessary.
-  virtual Split getSplitAfterLastLine(unsigned TailOffset, unsigned ColumnLimit,
-  llvm::Regex &CommentPragmasRegex) const {
+  virtual Split getSplitAfterLastLine(unsigned TailOffset,
+  unsigned ColumnLimit) const {
 return Split(StringRef::npos, 0);
   }
 
@@ -347,8 +347,8 @@
   void replaceWhitespaceBefore(unsigned LineIndex, unsigned PreviousEndColumn,
unsigned ColumnLimit, Split SplitBefore,
WhitespaceManager &Whitespaces) override;
-  Split getSplitAfterLastLine(unsigned TailOffset, unsigned ColumnLimit,
-  llvm::Regex &CommentPragmasRegex) const override;
+  Split getSplitAfterLastLine(unsigned TailOffset,
+  unsigned ColumnLimit) const override;
 
   bool mayReflow(unsigned LineIndex,
  llvm::Regex &CommentPragmasRegex) const override;
Index: lib/Format/BreakableToken.cpp
===
--- lib/Format/BreakableToken.cpp
+++ lib/Format/BreakableToken.cpp
@@ -681,12 +681,18 @@
   InPPDirective, /*Newlines=*/1, ContentColumn[LineIndex] - Prefix.size());
 }
 
-BreakableToken::Split BreakableBlockComment::getSplitAfterLastLine(
-unsigned TailOffset, unsigned ColumnLimit,
-llvm::Regex &CommentPragmasRegex) const {
-  if (DelimitersOnNewline)
-return getSplit(Lines.size() - 1, TailOffset, ColumnLimit,
-CommentPragmasRegex);
+BreakableToken::Split
+BreakableBlockComment::getSplitAfterLastLine(unsigned TailOffset,
+ unsigned ColumnLimit) const {
+  if (DelimitersOnNewline) {
+// Replace the trailing whitespace of the last line with a

[PATCH] D36456: [clang-tidy] 'implicit cast' -> 'implicit conversion'

2017-08-08 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh created this revision.
Herald added subscribers: xazax.hun, JDevlieghere, mgorny.

This patch renames checks, check options and changes messages to use correct
term "implicit conversion" instead of "implicit cast" (which has been in use in
Clang AST since ~10 years, but it's still technically incorrect w.r.t. C++
standard).

- performance-implicit-cast-in-loop -> performance-implicit-conversion-in-loop
- readability-implicit-bool-cast -> readability-implicit-bool-conversion
  - readability-implicit-bool-cast.AllowConditionalIntegerCasts -> 
readability-implicit-bool-conversion.AllowIntegerConditions
  - readability-implicit-bool-cast.AllowConditionalPointerCasts -> 
readability-implicit-bool-conversion.AllowPointerConditions


https://reviews.llvm.org/D36456

Files:
  clang-tidy/performance/CMakeLists.txt
  clang-tidy/performance/ImplicitCastInLoopCheck.cpp
  clang-tidy/performance/ImplicitCastInLoopCheck.h
  clang-tidy/performance/ImplicitConversionInLoopCheck.cpp
  clang-tidy/performance/ImplicitConversionInLoopCheck.h
  clang-tidy/performance/PerformanceTidyModule.cpp
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ImplicitBoolCastCheck.cpp
  clang-tidy/readability/ImplicitBoolCastCheck.h
  clang-tidy/readability/ImplicitBoolConversionCheck.cpp
  clang-tidy/readability/ImplicitBoolConversionCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/performance-implicit-cast-in-loop.rst
  docs/clang-tidy/checks/performance-implicit-conversion-in-loop.rst
  docs/clang-tidy/checks/readability-implicit-bool-cast.rst
  docs/clang-tidy/checks/readability-implicit-bool-conversion.rst
  test/clang-tidy/performance-implicit-cast-in-loop.cpp
  test/clang-tidy/performance-implicit-conversion-in-loop.cpp
  test/clang-tidy/readability-implicit-bool-cast-allow-conditional-casts.cpp
  test/clang-tidy/readability-implicit-bool-cast-cxx98.cpp
  test/clang-tidy/readability-implicit-bool-cast.cpp
  test/clang-tidy/readability-implicit-bool-conversion-allow-in-conditions.cpp
  test/clang-tidy/readability-implicit-bool-conversion-cxx98.cpp
  test/clang-tidy/readability-implicit-bool-conversion.cpp

Index: test/clang-tidy/readability-implicit-bool-conversion.cpp
===
--- test/clang-tidy/readability-implicit-bool-conversion.cpp
+++ test/clang-tidy/readability-implicit-bool-conversion.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s readability-implicit-bool-cast %t
+// RUN: %check_clang_tidy %s readability-implicit-bool-conversion %t
 
 // We need NULL macro, but some buildbots don't like including  header
 // This is a portable way of getting it to work
@@ -13,42 +13,42 @@
 };
 
 
-// Implicit cast from bool.
+// Implicit conversion from bool.
 
-void implicitCastFromBoolSimpleCases() {
+void implicitConversionFromBoolSimpleCases() {
   bool boolean = true;
 
   functionTaking(boolean);
 
   functionTaking(boolean);
-  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: implicit cast bool -> 'int' [readability-implicit-bool-cast]
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: implicit conversion bool -> 'int' [readability-implicit-bool-conversion]
   // CHECK-FIXES: functionTaking(static_cast(boolean));
 
   functionTaking(boolean);
-  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: implicit cast bool -> 'unsigned long'
+  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: implicit conversion bool -> 'unsigned long'
   // CHECK-FIXES: functionTaking(static_cast(boolean));
 
   functionTaking(boolean);
-  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: implicit cast bool -> 'char'
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: implicit conversion bool -> 'char'
   // CHECK-FIXES: functionTaking(static_cast(boolean));
 
   functionTaking(boolean);
-  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: implicit cast bool -> 'float'
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: implicit conversion bool -> 'float'
   // CHECK-FIXES: functionTaking(static_cast(boolean));
 
   functionTaking(boolean);
-  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: implicit cast bool -> 'double'
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: implicit conversion bool -> 'double'
   // CHECK-FIXES: functionTaking(static_cast(boolean));
 }
 
-float implicitCastFromBoolInReturnValue() {
+float implicitConversionFromBoolInReturnValue() {
   bool boolean = false;
   return boolean;
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: implicit cast bool -> 'float'
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: implicit conversion bool -> 'float'
   // CHECK-FIXES: return static_cast(boolean);
 }
 
-void implicitCastFromBoolInSingleBoolExpressions(bool b1, bool b2) {
+void implicitConversionFromBoolInSingleBoolExpressions(bool b1, bool b2) {
   bool boolean = true;
   boolean = b1 ^ b2;
   boolean = b1 && b2;
@@ -58,71 +58,71 @@
   boolean = b2 != false;
 
   int integer = boolean - 3;
-  // CHECK

[PATCH] D36456: [clang-tidy] 'implicit cast' -> 'implicit conversion'

2017-08-08 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh updated this revision to Diff 110166.
alexfh added a comment.

Added redirections from the old check documents.


https://reviews.llvm.org/D36456

Files:
  clang-tidy/performance/CMakeLists.txt
  clang-tidy/performance/ImplicitCastInLoopCheck.cpp
  clang-tidy/performance/ImplicitCastInLoopCheck.h
  clang-tidy/performance/ImplicitConversionInLoopCheck.cpp
  clang-tidy/performance/ImplicitConversionInLoopCheck.h
  clang-tidy/performance/PerformanceTidyModule.cpp
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ImplicitBoolCastCheck.cpp
  clang-tidy/readability/ImplicitBoolCastCheck.h
  clang-tidy/readability/ImplicitBoolConversionCheck.cpp
  clang-tidy/readability/ImplicitBoolConversionCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/performance-implicit-cast-in-loop.rst
  docs/clang-tidy/checks/performance-implicit-conversion-in-loop.rst
  docs/clang-tidy/checks/readability-implicit-bool-cast.rst
  docs/clang-tidy/checks/readability-implicit-bool-conversion.rst
  test/clang-tidy/performance-implicit-cast-in-loop.cpp
  test/clang-tidy/performance-implicit-conversion-in-loop.cpp
  test/clang-tidy/readability-implicit-bool-cast-allow-conditional-casts.cpp
  test/clang-tidy/readability-implicit-bool-cast-cxx98.cpp
  test/clang-tidy/readability-implicit-bool-cast.cpp
  test/clang-tidy/readability-implicit-bool-conversion-allow-in-conditions.cpp
  test/clang-tidy/readability-implicit-bool-conversion-cxx98.cpp
  test/clang-tidy/readability-implicit-bool-conversion.cpp

Index: test/clang-tidy/readability-implicit-bool-conversion.cpp
===
--- test/clang-tidy/readability-implicit-bool-conversion.cpp
+++ test/clang-tidy/readability-implicit-bool-conversion.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s readability-implicit-bool-cast %t
+// RUN: %check_clang_tidy %s readability-implicit-bool-conversion %t
 
 // We need NULL macro, but some buildbots don't like including  header
 // This is a portable way of getting it to work
@@ -13,42 +13,42 @@
 };
 
 
-// Implicit cast from bool.
+// Implicit conversion from bool.
 
-void implicitCastFromBoolSimpleCases() {
+void implicitConversionFromBoolSimpleCases() {
   bool boolean = true;
 
   functionTaking(boolean);
 
   functionTaking(boolean);
-  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: implicit cast bool -> 'int' [readability-implicit-bool-cast]
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: implicit conversion bool -> 'int' [readability-implicit-bool-conversion]
   // CHECK-FIXES: functionTaking(static_cast(boolean));
 
   functionTaking(boolean);
-  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: implicit cast bool -> 'unsigned long'
+  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: implicit conversion bool -> 'unsigned long'
   // CHECK-FIXES: functionTaking(static_cast(boolean));
 
   functionTaking(boolean);
-  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: implicit cast bool -> 'char'
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: implicit conversion bool -> 'char'
   // CHECK-FIXES: functionTaking(static_cast(boolean));
 
   functionTaking(boolean);
-  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: implicit cast bool -> 'float'
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: implicit conversion bool -> 'float'
   // CHECK-FIXES: functionTaking(static_cast(boolean));
 
   functionTaking(boolean);
-  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: implicit cast bool -> 'double'
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: implicit conversion bool -> 'double'
   // CHECK-FIXES: functionTaking(static_cast(boolean));
 }
 
-float implicitCastFromBoolInReturnValue() {
+float implicitConversionFromBoolInReturnValue() {
   bool boolean = false;
   return boolean;
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: implicit cast bool -> 'float'
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: implicit conversion bool -> 'float'
   // CHECK-FIXES: return static_cast(boolean);
 }
 
-void implicitCastFromBoolInSingleBoolExpressions(bool b1, bool b2) {
+void implicitConversionFromBoolInSingleBoolExpressions(bool b1, bool b2) {
   bool boolean = true;
   boolean = b1 ^ b2;
   boolean = b1 && b2;
@@ -58,71 +58,71 @@
   boolean = b2 != false;
 
   int integer = boolean - 3;
-  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: implicit cast bool -> 'int'
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: implicit conversion bool -> 'int'
   // CHECK-FIXES: int integer = static_cast(boolean) - 3;
 
   float floating = boolean / 0.3f;
-  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: implicit cast bool -> 'float'
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: implicit conversion bool -> 'float'
   // CHECK-FIXES: float floating = static_cast(boolean) / 0.3f;
 
   char character = boolean;
-  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: implicit cast bool -> 'char'
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warni

r310345 - Revert r310291, r310300 and r310332 because of test failure on Darwin

2017-08-08 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Aug  8 04:20:17 2017
New Revision: 310345

URL: http://llvm.org/viewvc/llvm-project?rev=310345&view=rev
Log:
Revert r310291, r310300 and r310332 because of test failure on Darwin

The commit r310291 introduced the failure. r310332 was a test fix commit and
r310300 was a followup commit. I reverted these two to avoid merge conflicts
when reverting.

The 'openmp-offload.c' test is failing on Darwin because the following
run lines:
// RUN:   touch %t1.o
// RUN:   touch %t2.o
// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes %t1.o 
%t2.o 2>&1 \
// RUN:   | FileCheck -check-prefix=CHK-TWOCUBIN %s

trigger the following assertion:

Driver.cpp:3418:
assert(CachedResults.find(ActionTC) != CachedResults.end() &&
   "Result does not exist??");

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

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=310345&r1=310344&r2=310345&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue Aug  8 04:20:17 2017
@@ -524,7 +524,7 @@ void Driver::CreateOffloadingDeviceToolC
 auto &CudaTC = ToolChains[CudaTriple.str() + "/" + HostTriple.str()];
 if (!CudaTC) {
   CudaTC = llvm::make_unique(
-  *this, CudaTriple, *HostTC, C.getInputArgs(), Action::OFK_Cuda);
+  *this, CudaTriple, *HostTC, C.getInputArgs());
 }
 C.addOffloadDeviceToolChain(CudaTC.get(), Action::OFK_Cuda);
   }
@@ -582,7 +582,7 @@ void Driver::CreateOffloadingDeviceToolC
   ToolChains[TT.str() + "/" + HostTC->getTriple().str()];
   if (!CudaTC)
 CudaTC = llvm::make_unique(
-*this, TT, *HostTC, C.getInputArgs(), Action::OFK_OpenMP);
+*this, TT, *HostTC, C.getInputArgs());
   TC = CudaTC.get();
 } else
   TC = &getToolChain(C.getInputArgs(), TT);

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=310345&r1=310344&r2=310345&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Aug  8 04:20:17 2017
@@ -5316,13 +5316,7 @@ void OffloadBundler::ConstructJobMultipl
   for (unsigned I = 0; I < Outputs.size(); ++I) {
 if (I)
   UB += ',';
-SmallString<256> OutputFileName(Outputs[I].getFilename());
-// Change extension of target files for OpenMP offloading
-// to NVIDIA GPUs.
-if (DepInfo[I].DependentToolChain->getTriple().isNVPTX() &&
-JA.isOffloading(Action::OFK_OpenMP))
-  llvm::sys::path::replace_extension(OutputFileName, "cubin");
-UB += OutputFileName;
+UB += Outputs[I].getFilename();
   }
   CmdArgs.push_back(TCArgs.MakeArgString(UB));
   CmdArgs.push_back("-unbundle");

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=310345&r1=310344&r2=310345&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Tue Aug  8 04:20:17 2017
@@ -1025,128 +1025,3 @@ void tools::AddRunTimeLibs(const ToolCha
 break;
   }
 }
-
-/// Add OpenMP linker script arguments at the end of the argument list so that
-/// the fat binary is built by embedding each of the device images into the
-/// host. The linker script also defines a few symbols required by the code
-/// generation so that the images can be easily retrieved at runtime by the
-/// offloading library. This should be used only in tool chains that support
-/// linker scripts.
-void tools::AddOpenMPLinkerScript(const ToolChain &TC, Compilation &C,
-  const InputInfo &Output,
-  const InputInfoList &Inputs,
-  const ArgList &Args, ArgStringList &CmdArgs,
-  const JobAction &JA) {
-
-  // If this is not an OpenMP host toolchain, we don't need to do anything.
-  if (!JA.isHostOffloading(Action::OFK_OpenMP))
-return;
-
-  // Create temporary linker script. Keep it if save-temps is enabled.
-  const char *LKS;
-  SmallString<256> Name = llvm::sys::path::filename(Output.getFilename()

r310347 - Darwin's toolchain should be initialized before openmp offloading

2017-08-08 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Aug  8 04:22:21 2017
New Revision: 310347

URL: http://llvm.org/viewvc/llvm-project?rev=310347&view=rev
Log:
Darwin's toolchain should be initialized before openmp offloading
is processed

This fixes an 'openmp-offload.c' test failure introduced by r310263.

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

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=310347&r1=310346&r2=310347&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue Aug  8 04:22:21 2017
@@ -3224,6 +3224,12 @@ InputInfo Driver::BuildJobsForActionNoCa
   InputInfoList OffloadDependencesInputInfo;
   bool BuildingForOffloadDevice = TargetDeviceOffloadKind != Action::OFK_None;
   if (const OffloadAction *OA = dyn_cast(A)) {
+// The 'Darwin' toolchain is initialized only when its arguments are
+// computed. Get the default arguments for OFK_None to ensure that
+// initialization is performed before processing the offload action.
+// FIXME: Remove when darwin's toolchain is initialized during 
construction.
+C.getArgsForToolChain(TC, BoundArch, Action::OFK_None);
+
 // The offload action is expected to be used in four different situations.
 //
 // a) Set a toolchain/architecture/kind for a host action:


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


[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

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

Hi @gtbercea,
I couldn't reply to the email as cfe-commits didn't even register this commit 
somehow, so I'm replying here.

Unfortunately I had to revert this commit (r310291), + two others for a clean 
revert (r310300 and r310332) because it caused a test failure on macOS. This 
particular run line:

  // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes %t1.o 
%t2.o 2>&1 \
  // RUN:   | FileCheck -check-prefix=CHK-TWOCUBIN %s

Causes the following assertion failure:

  assert(CachedResults.find(ActionTC) != CachedResults.end() &&
 "Result does not exist??");

Here's a backtrace:

  * frame #0: 0x7fffbf3a2b2e libsystem_kernel.dylib`__pthread_kill + 10
frame #1: 0x7fffbf4c72de libsystem_pthread.dylib`pthread_kill + 303
frame #2: 0x7fffbf30041f libsystem_c.dylib`abort + 127
frame #3: 0x7fffbf2c9f34 libsystem_c.dylib`__assert_rtn + 320
frame #4: 0x000103a1f2d1 
clang`clang::driver::Driver::BuildJobsForActionNoCache(this=0x7fff5fbfe4e8, 
C=0x000111b11830, A=0x000111b11ed0, TC=0x000112819000, 
BoundArch=(Data = "x86_64", Length = 6), AtTopLevel=false, MultipleArchs=false, 
LinkingOutput=0x, CachedResults=size=8, 
TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:3418
frame #5: 0x000103a1cf11 
clang`clang::driver::Driver::BuildJobsForAction(this=0x7fff5fbfe4e8, 
C=0x000111b11830, A=0x000111b11ed0, TC=0x000112819000, 
BoundArch=(Data = "x86_64", Length = 6), AtTopLevel=false, MultipleArchs=false, 
LinkingOutput=0x, CachedResults=size=8, 
TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:3210
frame #6: 0x000103a1dfb3 
clang`clang::driver::Driver::BuildJobsForActionNoCache(this=0x7fff5fbfe4e8, 
C=0x000111b11830, A=0x000111b12130, TC=0x000112819000, 
BoundArch=(Data = "x86_64", Length = 6), AtTopLevel=true, MultipleArchs=false, 
LinkingOutput=0x, CachedResults=size=8, 
TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:3348
frame #7: 0x000103a1cf11 
clang`clang::driver::Driver::BuildJobsForAction(this=0x7fff5fbfe4e8, 
C=0x000111b11830, A=0x000111b121f0, TC=0x000112819000, 
BoundArch=(Data = "x86_64", Length = 6), AtTopLevel=true, MultipleArchs=false, 
LinkingOutput=0x, CachedResults=size=8, 
TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:3210
frame #8: 0x000103a1db3e 
clang`clang::driver::Driver::BuildJobsForActionNoCache(this=0x7fff5fbfe4e8, 
C=0x000111b11830, A=0x000111b11bf0, TC=0x000112819000, 
BoundArch=(Data = 0x, Length = 0), AtTopLevel=true, 
MultipleArchs=false, LinkingOutput=0x, CachedResults=size=8, 
TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:3310
frame #9: 0x000103a1cf11 
clang`clang::driver::Driver::BuildJobsForAction(this=0x7fff5fbfe4e8, 
C=0x000111b11830, A=0x000111b11bf0, TC=0x000112819000, 
BoundArch=(Data = 0x, Length = 0), AtTopLevel=true, 
MultipleArchs=false, LinkingOutput=0x, CachedResults=size=8, 
TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:3210
frame #10: 0x000103a0a5c2 
clang`clang::driver::Driver::BuildJobs(this=0x7fff5fbfe4e8, 
C=0x000111b11830) const at Driver.cpp:2843
frame #11: 0x000103a00b5c 
clang`clang::driver::Driver::BuildCompilation(this=0x7fff5fbfe4e8, 
ArgList=ArrayRef @ 0x7fff5fbfc1e8) at Driver.cpp:746
frame #12: 0x00015a52 clang`main(argc_=9, argv_=0x7fff5fbff670) 
at driver.cpp:463
frame #13: 0x7fffbf260c05 libdyld.dylib`start + 1

Could you please take a look?

Let me know if you need anything else,
Cheers,
Alex


https://reviews.llvm.org/D29654



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


[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

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

The revert commit is r310345 btw


https://reviews.llvm.org/D29654



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


[PATCH] D36458: Fix crash when current lexer is nullptr

2017-08-08 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer added a comment.

Test case?


https://reviews.llvm.org/D36458



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


[PATCH] D36456: [clang-tidy] 'implicit cast' -> 'implicit conversion'

2017-08-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D36456



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


[PATCH] D36458: Fix crash when current lexer is nullptr

2017-08-08 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

Do you mean the testcase that runs only for windows with ms-extensions flag and 
msvc includes?
I don't know if clang has that kind of tests. Does it?


https://reviews.llvm.org/D36458



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


[PATCH] D35937: [clang-tidy] Add new readability non-idiomatic static access

2017-08-08 Thread Barancsuk Lilla via Phabricator via cfe-commits
barancsuk updated this revision to Diff 110175.
barancsuk marked 4 inline comments as done.
barancsuk added a comment.

Further reviews addressed


https://reviews.llvm.org/D35937

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
  clang-tidy/readability/StaticAccessedThroughInstanceCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-static-accessed-through-instance.rst
  
test/clang-tidy/readability-static-accessed-through-instance-nesting-threshold.cpp
  test/clang-tidy/readability-static-accessed-through-instance.cpp

Index: test/clang-tidy/readability-static-accessed-through-instance.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-static-accessed-through-instance.cpp
@@ -0,0 +1,222 @@
+// RUN: %check_clang_tidy %s readability-static-accessed-through-instance %t
+
+struct C {
+  static void foo();
+  static int x;
+  int nsx;
+  void mf() {
+(void)&x;// OK, x is accessed inside the struct.
+(void)&C::x; // OK, x is accessed using a qualified-id.
+foo();   // OK, foo() is accessed inside the struct.
+  }
+  void ns() const;
+};
+
+int C::x = 0;
+
+struct CC {
+  void foo();
+  int x;
+};
+
+template  struct CT {
+  static T foo();
+  static T x;
+  int nsx;
+  void mf() {
+(void)&x;// OK, x is accessed inside the struct.
+(void)&C::x; // OK, x is accessed using a qualified-id.
+foo();   // OK, foo() is accessed inside the struct.
+  }
+};
+
+// Expressions with side effects
+C &f(int, int, int, int);
+void g() {
+  f(1, 2, 3, 4).x;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member accessed through instance  [readability-static-accessed-through-instance]
+  // CHECK-FIXES: {{^}}  f(1, 2, 3, 4).x;{{$}}
+}
+
+int i(int &);
+void j(int);
+C h();
+bool a();
+int k(bool);
+
+void f(C c) {
+  j(i(h().x));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: static member
+  // CHECK-FIXES: {{^}}  j(i(h().x));{{$}}
+
+  // The execution of h() depends on the return value of a().
+  j(k(a() && h().x));
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: static member
+  // CHECK-FIXES: {{^}}  j(k(a() && h().x));{{$}}
+
+  if ([c]() {
+c.ns();
+return c;
+  }().x == 15)
+;
+  // CHECK-MESSAGES: :[[@LINE-5]]:7: warning: static member
+  // CHECK-FIXES: {{^}}  if ([c]() {{{$}}
+}
+
+// Nested specifiers
+namespace N {
+struct V {
+  static int v;
+  struct T {
+static int t;
+struct U {
+  static int u;
+};
+  };
+};
+}
+
+void f(N::V::T::U u) {
+  N::V v;
+  v.v = 12;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
+  // CHECK-FIXES: {{^}}  N::V::v = 12;{{$}}
+
+  N::V::T w;
+  w.t = 12;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
+  // CHECK-FIXES: {{^}}  N::V::T::t = 12;{{$}}
+
+  // u.u is not changed to N::V::T::U::u; because the nesting level is over 3.
+  u.u = 12;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
+  // CHECK-FIXES: {{^}}  u.u = 12;{{$}}
+
+  using B = N::V::T::U;
+  B b;
+  b.u;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
+  // CHECK-FIXES: {{^}}  B::u;{{$}}
+}
+
+// Templates
+template  T CT::x;
+
+template  struct CCT {
+  T foo();
+  T x;
+};
+
+typedef C D;
+
+using E = D;
+
+#define FOO(c) c.foo()
+#define X(c) c.x
+
+template  void f(T t, C c) {
+  t.x; // OK, t is a template parameter.
+  c.x; // 1
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
+  // CHECK-FIXES: {{^}}  C::x; // 1{{$}}
+}
+
+template  struct S { static int x; };
+
+template <> struct S<0> { int x; };
+
+template  void h() {
+  S sN;
+  sN.x; // OK, value of N affects whether x is static or not.
+
+  S<2> s2;
+  s2.x;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
+  // CHECK-FIXES: {{^}}  S<2>::x;{{$}}
+}
+
+void static_through_instance() {
+  C *c1 = new C();
+  c1->foo(); // 1
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
+  // CHECK-FIXES: {{^}}  C::foo(); // 1{{$}}
+  c1->x; // 2
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
+  // CHECK-FIXES: {{^}}  C::x; // 2{{$}}
+  c1->nsx; // OK, nsx is a non-static member.
+
+  const C *c2 = new C();
+  c2->foo(); // 2
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
+  // CHECK-FIXES: {{^}}  C::foo(); // 2{{$}}
+
+  C::foo(); // OK, foo() is accessed using a qualified-id.
+  C::x; // OK, x is accessed using a qualified-id.
+
+  D d;
+  d.foo();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
+  // CHECK-FIXES: {{^}}  D::foo();{{$}}
+  d.x;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
+  // CHECK-FIXES: {{^}}  D::x;{{$}}
+
+  E e;
+  e.foo();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
+  // CHECK-FIXES: {{^}}  E::foo();{{$}}
+  e.x;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static memb

[PATCH] D36390: Fix overloaded static functions in SemaCodeComplete

2017-08-08 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

Please check that one


https://reviews.llvm.org/D36390



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


[PATCH] D35355: Fix templated type alias completion when using global completion cache

2017-08-08 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

Ping...


https://reviews.llvm.org/D35355



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


Re: r308722 - Fixed failing assert in code completion.

2017-08-08 Thread Alex L via cfe-commits
Ping?

On 21 July 2017 at 10:44, Alex L  wrote:

> Hans, can you please merge this to the LLVM 5.0 branch?
>
> AFAIK It's a recent regression that should get fixed in LLVM 5.0.
>
> Cheers,
> Alex
>
>
> On 21 July 2017 at 10:24, Ilya Biryukov via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ibiryukov
>> Date: Fri Jul 21 02:24:00 2017
>> New Revision: 308722
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=308722&view=rev
>> Log:
>> Fixed failing assert in code completion.
>>
>> Summary:
>> The code was accessing uninstantiated default argument.
>> This resulted in failing assertion at ParmVarDecl::getDefaultArg().
>>
>> Reviewers: erikjv, klimek, bkramer, krasimir
>>
>> Reviewed By: krasimir
>>
>> Subscribers: cfe-commits
>>
>> Differential Revision: https://reviews.llvm.org/D35682
>>
>> Added:
>> cfe/trunk/test/CodeCompletion/uninstantiated_params.cpp
>> Modified:
>> cfe/trunk/lib/Sema/SemaCodeComplete.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaC
>> odeComplete.cpp?rev=308722&r1=308721&r2=308722&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Fri Jul 21 02:24:00 2017
>> @@ -2401,10 +2401,7 @@ formatBlockPlaceholder(const PrintingPol
>>  static std::string GetDefaultValueString(const ParmVarDecl *Param,
>>   const SourceManager &SM,
>>   const LangOptions &LangOpts) {
>> -  const Expr *defaultArg = Param->getDefaultArg();
>> -  if (!defaultArg)
>> -return "";
>> -  const SourceRange SrcRange = defaultArg->getSourceRange();
>> +  const SourceRange SrcRange = Param->getDefaultArgRange();
>>CharSourceRange CharSrcRange = CharSourceRange::getTokenRange
>> (SrcRange);
>>bool Invalid = CharSrcRange.isInvalid();
>>if (Invalid)
>>
>> Added: cfe/trunk/test/CodeCompletion/uninstantiated_params.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompl
>> etion/uninstantiated_params.cpp?rev=308722&view=auto
>> 
>> ==
>> --- cfe/trunk/test/CodeCompletion/uninstantiated_params.cpp (added)
>> +++ cfe/trunk/test/CodeCompletion/uninstantiated_params.cpp Fri Jul 21
>> 02:24:00 2017
>> @@ -0,0 +1,13 @@
>> +template 
>> +struct unique_ptr {
>> +  typedef T* pointer;
>> +
>> +  void reset(pointer ptr = pointer());
>> +};
>> +
>> +void test() {
>> +  unique_ptr x;
>> +  x.
>> +  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:5 %s -o - |
>> FileCheck -check-prefix=CHECK-CC1 %s
>> +  // CHECK-CC1: [#void#]reset({#<#unique_ptr::pointer ptr =
>> pointer()#>#})
>> +}
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36458: Fix crash when current lexer is nullptr

2017-08-08 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

And if you just meant how to reproduce:

You need to parse and reparse standard  header (my current one is 
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\memory). I can 
provide the options and a command line that I have if you can't reproduce it 
with default ones...


https://reviews.llvm.org/D36458



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


[PATCH] D36208: [mips] Enable `long_call/short_call` attributes on MIPS64

2017-08-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/Basic/Attr.td:268
 def TargetMips : TargetArch<["mips", "mipsel"]>;
+def TargetAnyMips : TargetArch<["mips", "mipsel", "mips64", "mips64el"]>;
 def TargetMSP430 : TargetArch<["msp430"]>;

Can you also rename `TargetMips` to something that distinguishes it from 
`TargetAnyMips`, like we have with `TargetX86` vs `TargetAnyX86`? I'd be 
hard-pressed to notice the difference between these two target names when 
reviewing an attribute, but I'm not familiar enough with the MIPS architecture 
to have a particularly good suggestion for improvement.



Comment at: lib/Sema/SemaDeclAttr.cpp:5979-5981
+if (S.Context.getTargetInfo().getABI() != "o32")
+  S.Diag(Attr.getLoc(), diag::err_attribute_supported_by_o32)
+  << Attr.getName() << D->getLocation();

atanasyan wrote:
> aaron.ballman wrote:
> > Please do not put logic into the switch statement, but instead sink it into 
> > a helper function. We hope to remove the boilerplate switch someday, so 
> > keeping with the `handleFooAttr()` pattern is preferred. Same below.
> > 
> > Further, why is this not handled by a TargetSpecificAttr in Attr.td? See 
> > `TargetMicrosoftCXXABI` and `MSNoVTable` for an example.
> > Further, why is this not handled by a TargetSpecificAttr in Attr.td? See 
> > TargetMicrosoftCXXABI and MSNoVTable for an example.
> 
> I thought about this, but in that case compiler will show "unknown attribute 
> 'mips16' ignored" warning in case of using `mips16` on MIPS64 targets. As to 
> me this warning is not quite correct in that case because `mips16`, 
> `micromips`, `interrupt` all are known MIPS-specific attributes, but not 
> applicable on MIPS64 by various reasons.
> As to me this warning is not quite correct in that case because mips16, 
> micromips, interrupt all are known MIPS-specific attributes, but not 
> applicable on MIPS64 by various reasons.

The same is true of all target-specific attributes -- they're known to the 
compiler, but their usage is not known on that specific target architecture. I 
would not be opposed to a patch that distinguished between the two situations, 
however (completely unknown attribute/and attribute that's known to be 
prohibited).


Repository:
  rL LLVM

https://reviews.llvm.org/D36208



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


[PATCH] D35937: [clang-tidy] Add new readability non-idiomatic static access

2017-08-08 Thread Barancsuk Lilla via Phabricator via cfe-commits
barancsuk added inline comments.



Comment at: clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp:23
+  memberExpr(hasDeclaration(anyOf(cxxMethodDecl(isStaticStorageClass()),
+  varDecl(hasStaticStorageDuration(,
+ unless(isInTemplateInstantiation()))

aaron.ballman wrote:
> barancsuk wrote:
> > aaron.ballman wrote:
> > > Why not use `isStaticStorageClass()` here as well?
> > Unfortunately, `isStaticStorageClass()` misses variable declarations that 
> > do not contain the static keyword, including definitions of static 
> > variables outside of their class.
> > However, `hasStaticStorageDuration()` has no problem finding all static 
> > variable declarations correctly. 
> Under what circumstances would that make a difference? If the variable is 
> declared within the class with the static storage specifier, that declaration 
> should be sufficient for the check, regardless of how the definition looks, 
> no?
> 
> If it does make a difference, can you add a test case that demonstrates that?
`isStaticStorageClass()` does fail for the current test cases.

The reason for that is the function `hasDecl()`, that, for static variables 
with multiple declarations,  may return a declaration that does not contain the 
`static` keyword.
For example, it finds `int C::x = 0;` rather than `static int x;`
Then `isStaticStorageClass()` discards it.

However, `hasStaticStorageDuration()` works fine, because all declarations are 
static storage duration, regardless of whether the `static` keyword is present 
or not.


https://reviews.llvm.org/D35937



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


[PATCH] D36327: [OpenCL] Allow targets emit optimized pipe functions for power of 2 type sizes

2017-08-08 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added a comment.

In https://reviews.llvm.org/D36327#834032, @Anastasia wrote:

> In https://reviews.llvm.org/D36327#833891, @yaxunl wrote:
>
> > In https://reviews.llvm.org/D36327#833653, @bader wrote:
> >
> > > Hi Sam,
> > >
> > > What do you think about implementing this optimization in target specific 
> > > optimization pass? Since size/alignment is saved as function parameter in 
> > > LLVM IR, the optimization can be done in target specific components w/o 
> > > adding additional conditions to generic library.
> > >
> > > Thanks,
> > > Alexey
> >
> >
> > Hi Alexey,
> >
> > The optimization of the power-of-2 type size is implemented as a library 
> > function. Our backend lacks the capability to link in library code at ISA 
> > level, so linking of the optimized library function has to be done before 
> > any target-specific passes. It seems the only place to do this is Clang 
> > codegen since Clang/llvm does not support target-specific pre-linking 
> > passes.
>
>
> My general feeling is that it doesn't look like a generic enough change for 
> the frontend. Even though it is implemented in a generic way, not every 
> target might have a special support for the power of 2 size and also if there 
> is such a support not every implementation would handle it as a library 
> function. But I can see that perhaps LLVM is missing flexibility in the flow 
> to accommodate these needs. Any change we could try to extend the compilation 
> flow such that this target specific optimization could happen before the IR 
> linking?


It is trivial to implement the small number of specialized functions this patch 
adds in terms of the general one if desired, and the general one can continue 
to be handled as it had been.

We had actually proposed a patch (sorry I don't have the reference handy) to 
add general mechanism for targets to introduce pre-link passes, but it was not 
accepted.  We can try again, but I don't really expect more progress.


https://reviews.llvm.org/D36327



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


[PATCH] D33672: [analyzer] INT50-CPP. Do not cast to an out-of-range enumeration checker

2017-08-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D33672#830492, @gamesh411 wrote:

> As for the the loss of precision problem, in the special case of char the 
> size of char is known. However does the analysis have the necessary 
> information in this stage to know the size of an int for example? I found 
> bit-width specifying information in the llvm::Type class which is used in the 
> code generation phase. It could be done by checking on a per type basis, but 
> then again, it could possibly lead to false positives. Correct me if I am 
> wrong.


The frontend has this information available to it as well, through the 
`ASTContext`. See `getTypeSize()`, `getTypeSizeInChars()`, etc.




Comment at: lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp:74-75
+  EnumValueVector DeclValues;
+  for (const auto *D : ED->decls()) {
+const auto ECD = dyn_cast(D);
+DeclValues.push_back(ECD->getInitVal());

aaron.ballman wrote:
> Instead of enumerating over `decls()` and then casting, just enumerate over 
> `enumerators()` and  the cast isn't needed. Or, even better:
> ```
> EnumValueVector DeclValues(ED->enumerator_end() - ED->enumerator_begin());
> std::transform(ED->enumerator_begin(), ED->enumerator_end(), 
> DeclValues.begin(),
>[](const EnumConstantDecl *D) { return 
> D->getInitVal(); });
> ```
I think my suggestion was a bit more efficient than your implementation, was 
there a reason you avoided `std::transform()`?



Comment at: lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp:35
+  const DefinedOrUnknownSVal CompareValue;
+
+  const ProgramStateRef PS;

You can remove the newline.


https://reviews.llvm.org/D33672



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


[PATCH] D35755: [Solaris] gcc toolchain handling revamp

2017-08-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Aside from a coding style nit and the unanswered question that hopefully 
@tstellar can help answer, this LGTM. I'll wait to accept until we figure out 
the answer for Linux, however.




Comment at: lib/Driver/ToolChains/Solaris.cpp:208
   if (GCCInstallation.isValid()) {
-GCCVersion Version = GCCInstallation.getVersion();
-addSystemInclude(DriverArgs, CC1Args,
- getDriver().SysRoot + "/usr/gcc/" +
- Version.MajorStr + "." +
- Version.MinorStr +
- "/include/c++/" + Version.Text);
-addSystemInclude(DriverArgs, CC1Args,
- getDriver().SysRoot + "/usr/gcc/" + Version.MajorStr +
- "." + Version.MinorStr + "/include/c++/" +
- Version.Text + "/" +
- GCCInstallation.getTriple().str());
+const auto &Callback = Multilibs.includeDirsCallback();
+if (Callback) {

fedor.sergeev wrote:
> aaron.ballman wrote:
> > Shouldn't use `auto` here because the type is not spelled out in the 
> > initialization.
> I believe this is the case described in LLVM coding standard as "when the 
> type would have been abstracted away anyways". It would be 
> MultilibSet::IncludeDirsFunc, which IMO does not add anything to readability.
I've always taken that to refer to things like range-based for loop variables 
and functions that return iterators; not functions that return concrete types. 
I prefer to see the explicit type in this case so that I am able to better 
understand the arguments to be passed to the function. When it's abstracted 
behind `auto`, I have to work harder to find the information I need compared to 
when the type is explicitly spelled out.


https://reviews.llvm.org/D35755



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


[PATCH] D36101: Fix usage of right shift operator in fold expressions

2017-08-08 Thread Blitz Rakete via Phabricator via cfe-commits
Rakete added a comment.

Ping?


https://reviews.llvm.org/D36101



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


[PATCH] D36431: Add powerpc64 to compiler-rt build infrastructure.

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

This patch appears to be perfectly fine. However, it triggers a large number of 
warnings. Namely, there's a large number of `warning: ISO C forbids an empty 
translation unit [-Wpedantic]` warnings produced.
The reason is that all the code in the file is wrapped with an `if !_ARCH_PPC` 
macro. I assume that we do not want `compiler_rt` to expose builtins that 
assume an 80-bit `long double` (which is the behaviour we get now). So it seems 
to me that files that define such builtins should simply be removed from the 
`powerpc64_SOURCES` and they should `#error` on PPC.

Also, I'm getting lots of warnings from `compiler-rt/lib/builtins/atomic.c` 
such as `warning: implicit declaration of function '__c11_atomic_fetch_or' 
[-Wimplicit-function-declaration]`. It would appear that the `__c11_atomic_*` 
family of builtins isn't exposed by the build compiler (and should presumably 
be declared in a header if file is being built with a compiler that doesn't 
expose those).


https://reviews.llvm.org/D36431



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


[PATCH] D36411: Restore previous structure ABI for bitfields with 'packed' attribute for PS4 targets

2017-08-08 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

FTR, from a PS4 perspective this is all good, but we'd like somebody from 
outside our team to take a look.


https://reviews.llvm.org/D36411



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


[PATCH] D36390: Fix overloaded static functions in SemaCodeComplete

2017-08-08 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer added inline comments.



Comment at: include/clang/Sema/Sema.h:2681
+  bool PartialOverloading = false,
+  bool ExtraFirstArgument = false);
   void AddMethodCandidate(DeclAccessPair FoundDecl,

I'd prefer something like "FirstArgumentIsBase"



Comment at: lib/Sema/SemaOverload.cpp:5871
   // is irrelevant.
+
   AddMethodCandidate(Method, FoundDecl, Method->getParent(), QualType(),

Unnecessary whitespace change.



Comment at: lib/Sema/SemaOverload.cpp:6339
   } else {
+// Slice the first argument when we access static method as non-static
+if (Args.size() > 0 && ExtraFirstArgument && isa(FD)

Add a comment that the first argument is the base.



Comment at: lib/Sema/SemaOverload.cpp:6341
+if (Args.size() > 0 && ExtraFirstArgument && isa(FD)
+&& !isa(FD)) {
+  Args = Args.slice(1);

clang-format



Comment at: lib/Sema/SemaOverload.cpp:6342
+&& !isa(FD)) {
+  Args = Args.slice(1);
+}

assert that FD is a static method.


https://reviews.llvm.org/D36390



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


[PATCH] D35056: GCC ABI incompatibility when passing object with trivial copy ctor, trivial dtor, and non-trivial move ctor

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

And thanks for working on this!!


Repository:
  rL LLVM

https://reviews.llvm.org/D35056



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


[PATCH] D36453: [libclang] Fix PR34055 (incompatible update of clang-c/Index.h)

2017-08-08 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.

Thanks, looks good!


https://reviews.llvm.org/D36453



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


[PATCH] D35056: GCC ABI incompatibility when passing object with trivial copy ctor, trivial dtor, and non-trivial move ctor

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

I do not feel qualified enough to review this patch but I added few minor 
comments.




Comment at: include/clang/AST/DeclCXX.h:827
+return data().DefaultedCopyConstructorIsDeleted;
+  }
+  /// \brief \c true if a defaulted move constructor for this class would be

Is there a reason for not keeping the default (for the file) 1 empty line 
between methods? Looks like if we add one new line before and after 
`hasSimpleMoveAssignment` is will be all consistent.



Comment at: lib/Sema/SemaDeclCXX.cpp:5731
+/// registers, per C++ [class.temporary]p3.
+static bool computeCanPassInRegisters(Sema &S, CXXRecordDecl *D) {
+  if (D->isDependentType() || D->isInvalidDecl())

It would be very useful if we somehow assert if this function is called before 
the class triviality is computed?


Repository:
  rL LLVM

https://reviews.llvm.org/D35056



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


[PATCH] D35755: [Solaris] gcc toolchain handling revamp

2017-08-08 Thread Fedor Sergeev via Phabricator via cfe-commits
fedor.sergeev updated this revision to Diff 110190.
fedor.sergeev added a comment.

auto changed to MultilibSet::IncludeDirsFunc.


https://reviews.llvm.org/D35755

Files:
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Gnu.h
  lib/Driver/ToolChains/Solaris.cpp
  lib/Driver/ToolChains/Solaris.h
  lib/Frontend/InitHeaderSearch.cpp
  
test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/include/c++/4.8.2/sparc-sun-solaris2.11/bits/gthr.h
  test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/include/c++/4.8.2/typeinfo
  
test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crt1.o
  
test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtbegin.o
  
test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtend.o
  
test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9/crt1.o
  
test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9/crtbegin.o
  
test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9/crtend.o
  test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/libatomic.a
  test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/sparcv9/libatomic.a
  test/Driver/Inputs/solaris_sparc_tree/usr/lib/crti.o
  test/Driver/Inputs/solaris_sparc_tree/usr/lib/crtn.o
  test/Driver/Inputs/solaris_sparc_tree/usr/lib/ld.so.1
  test/Driver/Inputs/solaris_sparc_tree/usr/lib/sparcv9/crti.o
  test/Driver/Inputs/solaris_sparc_tree/usr/lib/sparcv9/crtn.o
  test/Driver/Inputs/solaris_sparc_tree/usr/lib/sparcv9/ld.so.1
  
test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/include/c++/4.9.4/i386-pc-solaris2.11/bits/gthr.h
  test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/include/c++/4.9.4/typeinfo
  test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/amd64/libatomic.a
  
test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64/crtbegin.o
  
test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64/crtend.o
  
test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/crtbegin.o
  
test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/crtend.o
  test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/libatomic.a
  test/Driver/Inputs/solaris_x86_tree/usr/lib/amd64/crt1.o
  test/Driver/Inputs/solaris_x86_tree/usr/lib/amd64/crti.o
  test/Driver/Inputs/solaris_x86_tree/usr/lib/amd64/crtn.o
  test/Driver/Inputs/solaris_x86_tree/usr/lib/amd64/ld.so.1
  test/Driver/Inputs/solaris_x86_tree/usr/lib/crt1.o
  test/Driver/Inputs/solaris_x86_tree/usr/lib/crti.o
  test/Driver/Inputs/solaris_x86_tree/usr/lib/crtn.o
  test/Driver/Inputs/solaris_x86_tree/usr/lib/ld.so.1
  
test/Driver/Inputs/sparc-sun-solaris2.11/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crt1.o
  
test/Driver/Inputs/sparc-sun-solaris2.11/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtbegin.o
  
test/Driver/Inputs/sparc-sun-solaris2.11/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtend.o
  test/Driver/Inputs/sparc-sun-solaris2.11/usr/lib/crti.o
  test/Driver/Inputs/sparc-sun-solaris2.11/usr/lib/crtn.o
  test/Driver/Inputs/sparc-sun-solaris2.11/usr/lib/ld.so.1
  test/Driver/solaris-header-search.cpp
  test/Driver/solaris-ld.c

Index: test/Driver/solaris-ld.c
===
--- test/Driver/solaris-ld.c
+++ test/Driver/solaris-ld.c
@@ -1,33 +1,105 @@
-// Test ld invocation on Solaris targets.
+// General tests that ld invocations on Solaris targets sane. Note that we use
+// sysroot to make these tests independent of the host system.
 
-// Check sparc-sun-solaris2.1
+// Check sparc-sun-solaris2.11, 32bit
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=sparc-sun-solaris2.11 \
-// RUN: --gcc-toolchain="" \
-// RUN: --sysroot=%S/Inputs/sparc-sun-solaris2.11 \
-// RUN:   | FileCheck %s
-// CHECK: "-cc1" "-triple" "sparc-sun-solaris2.11"
-// CHECK: ld{{.*}}"
-// CHECK: "--dynamic-linker" "{{.*}}/usr/lib/ld.so.1"
-// CHECK: "{{.*}}/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|}}crt1.o"
-// CHECK: "{{.*}}/usr/lib/crti.o"
-// CHECK: "{{.*}}/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|}}crtbegin.o"
-// CHECK: "{{.*}}/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|}}crtend.o"
-// CHECK: "{{.*}}/usr/lib/crtn.o"
-// CHECK "-lc"
-// CHECK "-lgcc_s"
-// CHECK "-lgcc"
-// CHECK "-lm"
+// RUN: --sysroot=%S/Inputs/solaris_sparc_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-SPARC32 %s
+// CHECK-LD-SPARC32-NOT: warning:
+// CHECK-LD-SPARC32: {{.*/clang}}" "-cc1" "-triple" "sparc-sun-solaris2.11"
+// CHECK-LD-SPARC32-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD-SPARC32: {{.*/ld}}"
+// CHECK-LD-SPARC32-SAME: "--dynamic-linker" "[[SYSROOT]]/usr/lib/ld.so.1"
+// CHECK-LD-SPARC32-SAME: "[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.1

[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

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

In https://reviews.llvm.org/D29654#835045, @arphaman wrote:

> Hi @gtbercea,
>  I couldn't reply to the email as cfe-commits didn't even register this 
> commit somehow, so I'm replying here.
>
> Unfortunately I had to revert this commit (r310291), + two others for a clean 
> revert (r310300 and r310332) because it caused a test failure on macOS. This 
> particular run line:
>
>   // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp 
> -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes %t1.o 
> %t2.o 2>&1 \
>   // RUN:   | FileCheck -check-prefix=CHK-TWOCUBIN %s
>
>
> Causes the following assertion failure:
>
>   assert(CachedResults.find(ActionTC) != CachedResults.end() &&
>  "Result does not exist??");
>   
>
> Here's a backtrace:
>
>   * frame #0: 0x7fffbf3a2b2e libsystem_kernel.dylib`__pthread_kill + 10
> frame #1: 0x7fffbf4c72de libsystem_pthread.dylib`pthread_kill + 303
> frame #2: 0x7fffbf30041f libsystem_c.dylib`abort + 127
> frame #3: 0x7fffbf2c9f34 libsystem_c.dylib`__assert_rtn + 320
> frame #4: 0x000103a1f2d1 
> clang`clang::driver::Driver::BuildJobsForActionNoCache(this=0x7fff5fbfe4e8,
>  C=0x000111b11830, A=0x000111b11ed0, TC=0x000112819000, 
> BoundArch=(Data = "x86_64", Length = 6), AtTopLevel=false, 
> MultipleArchs=false, LinkingOutput=0x, CachedResults=size=8, 
> TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:3418
> frame #5: 0x000103a1cf11 
> clang`clang::driver::Driver::BuildJobsForAction(this=0x7fff5fbfe4e8, 
> C=0x000111b11830, A=0x000111b11ed0, TC=0x000112819000, 
> BoundArch=(Data = "x86_64", Length = 6), AtTopLevel=false, 
> MultipleArchs=false, LinkingOutput=0x, CachedResults=size=8, 
> TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:3210
> frame #6: 0x000103a1dfb3 
> clang`clang::driver::Driver::BuildJobsForActionNoCache(this=0x7fff5fbfe4e8,
>  C=0x000111b11830, A=0x000111b12130, TC=0x000112819000, 
> BoundArch=(Data = "x86_64", Length = 6), AtTopLevel=true, 
> MultipleArchs=false, LinkingOutput=0x, CachedResults=size=8, 
> TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:3348
> frame #7: 0x000103a1cf11 
> clang`clang::driver::Driver::BuildJobsForAction(this=0x7fff5fbfe4e8, 
> C=0x000111b11830, A=0x000111b121f0, TC=0x000112819000, 
> BoundArch=(Data = "x86_64", Length = 6), AtTopLevel=true, 
> MultipleArchs=false, LinkingOutput=0x, CachedResults=size=8, 
> TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:3210
> frame #8: 0x000103a1db3e 
> clang`clang::driver::Driver::BuildJobsForActionNoCache(this=0x7fff5fbfe4e8,
>  C=0x000111b11830, A=0x000111b11bf0, TC=0x000112819000, 
> BoundArch=(Data = 0x, Length = 0), AtTopLevel=true, 
> MultipleArchs=false, LinkingOutput=0x, CachedResults=size=8, 
> TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:3310
> frame #9: 0x000103a1cf11 
> clang`clang::driver::Driver::BuildJobsForAction(this=0x7fff5fbfe4e8, 
> C=0x000111b11830, A=0x000111b11bf0, TC=0x000112819000, 
> BoundArch=(Data = 0x, Length = 0), AtTopLevel=true, 
> MultipleArchs=false, LinkingOutput=0x, CachedResults=size=8, 
> TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:3210
> frame #10: 0x000103a0a5c2 
> clang`clang::driver::Driver::BuildJobs(this=0x7fff5fbfe4e8, 
> C=0x000111b11830) const at Driver.cpp:2843
> frame #11: 0x000103a00b5c 
> clang`clang::driver::Driver::BuildCompilation(this=0x7fff5fbfe4e8, 
> ArgList=ArrayRef @ 0x7fff5fbfc1e8) at Driver.cpp:746
> frame #12: 0x00015a52 clang`main(argc_=9, 
> argv_=0x7fff5fbff670) at driver.cpp:463
> frame #13: 0x7fffbf260c05 libdyld.dylib`start + 1
>   
>
> Could you please take a look?
>
> Let me know if you need anything else,
>  Cheers,
> Alex


Hi Alex,

I have a fix for the failing test. What's the easiest way to do this? Do I have 
to commit those patches again or can you push them back in and then I also push 
the fix?

Thanks,

--Doru

--


https://reviews.llvm.org/D29654



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


r310359 - [libclang] Fix PR34055 (incompatible update of clang-c/Index.h)

2017-08-08 Thread Nikolai Bozhenov via cfe-commits
Author: n.bozhenov
Date: Tue Aug  8 07:13:50 2017
New Revision: 310359

URL: http://llvm.org/viewvc/llvm-project?rev=310359&view=rev
Log:
[libclang] Fix PR34055 (incompatible update of clang-c/Index.h)

Fixes a regression introduced by r308218.

Modified:
cfe/trunk/include/clang-c/Index.h

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=310359&r1=310358&r2=310359&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Tue Aug  8 07:13:50 2017
@@ -3206,6 +3206,8 @@ enum CXCallingConv {
   CXCallingConv_X86RegCall = 8,
   CXCallingConv_IntelOclBicc = 9,
   CXCallingConv_Win64 = 10,
+  /* Alias for compatibility with older versions of API. */
+  CXCallingConv_X86_64Win64 = CXCallingConv_Win64,
   CXCallingConv_X86_64SysV = 11,
   CXCallingConv_X86VectorCall = 12,
   CXCallingConv_Swift = 13,


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


[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

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

Great, thanks! I think that you can just revert my revert with the fix applied 
in one commit


https://reviews.llvm.org/D29654



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


[PATCH] D36453: [libclang] Fix PR34055 (incompatible update of clang-c/Index.h)

2017-08-08 Thread Nikolai Bozhenov via Phabricator via cfe-commits
n.bozhenov closed this revision.
n.bozhenov added a comment.

committed r310359


https://reviews.llvm.org/D36453



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


r310360 - [OPENMP][DEBUG] Set proper address space info if required by target.

2017-08-08 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Aug  8 07:25:14 2017
New Revision: 310360

URL: http://llvm.org/viewvc/llvm-project?rev=310360&view=rev
Log:
[OPENMP][DEBUG] Set proper address space info if required by target.

Arguments, passed to the outlined function, must have correct address
space info for proper Debug info support. Patch sets global address
space for arguments that are mapped and passed by reference.

Also, cuda-gdb does not handle reference types correctly, so reference
arguments are represented as pointers.

Added:
cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/nvptx_target_firstprivate_codegen.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=310360&r1=310359&r2=310360&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Aug  8 07:25:14 2017
@@ -2685,6 +2685,14 @@ def OMPCaptureNoInit : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
+def OMPCaptureKind : Attr {
+  // This attribute has no spellings as it is only ever created implicitly.
+  let Spellings = [];
+  let SemaHandler = 0;
+  let Args = [UnsignedArgument<"CaptureKind">];
+  let Documentation = [Undocumented];
+}
+
 def OMPDeclareSimdDecl : Attr {
   let Spellings = [Pragma<"omp", "declare simd">];
   let Subjects = SubjectList<[Function]>;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=310360&r1=310359&r2=310360&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Aug  8 07:25:14 2017
@@ -8527,6 +8527,11 @@ public:
   /// is performed.
   bool isOpenMPPrivateDecl(ValueDecl *D, unsigned Level);
 
+  /// Sets OpenMP capture kind (OMPC_private, OMPC_firstprivate, OMPC_map etc.)
+  /// for \p FD based on DSA for the provided corresponding captured 
declaration
+  /// \p D.
+  void setOpenMPCaptureKind(FieldDecl *FD, ValueDecl *D, unsigned Level);
+
   /// \brief Check if the specified variable is captured  by 'target' 
directive.
   /// \param Level Relative level of nested OpenMP construct for that the check
   /// is performed.

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=310360&r1=310359&r2=310360&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Tue Aug  8 07:25:14 2017
@@ -1325,6 +1325,32 @@ public:
   virtual void emitDoacrossOrdered(CodeGenFunction &CGF,
const OMPDependClause *C);
 
+  /// Translates the native parameter of outlined function if this is required
+  /// for target.
+  /// \param FD Field decl from captured record for the paramater.
+  /// \param NativeParam Parameter itself.
+  virtual const VarDecl *translateParameter(const FieldDecl *FD,
+const VarDecl *NativeParam) const {
+return NativeParam;
+  }
+
+  typedef llvm::function_ref
+  MappingFnType;
+  /// Maps the native argument to the address of the corresponding
+  /// target-specific argument.
+  /// \param FD Field decl from captured record for the paramater.
+  /// \param NativeParam Parameter itself.
+  /// \param TargetParam Corresponding target-specific parameter.
+  /// \param MapFn Function that maps the native parameter to the address of 
the
+  /// target-specific.
+  virtual void mapParameterAddress(CodeGenFunction &CGF, const FieldDecl *FD,
+   const VarDecl *NativeParam,
+   const VarDecl *TargetParam,
+   const MappingFnType) const {
+assert(NativeParam == TargetParam &&
+   "native and target args must be the same");
+  }
+
   /// Emits call of the outlined function with the provided arguments,
   /// translating these arguments to correct target-specific arguments.
   virtual void

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=310360&r1=310359&r2=310360&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/

RE: [PATCH] D34158: For Linux/gnu compatibility, preinclude if the file is available

2017-08-08 Thread Blower, Melanie via cfe-commits
 
fedor.sergeev added a comment.

In https://reviews.llvm.org/D34158#834298, @mibintc wrote:

> In fact I did have trouble writing the new test case to pass with the 
> gnu/Linux toolchain. In the file lib/Driver/ToolChains/Linux.cpp function 
> AddGnuIncludeArgs checks if GCCInstallation.isValid().


You should not be doing stdc-predef.h under GCCInstallation.isValid().
You are handling interaction with libc, so it has nothing to do with the 
presence or absence of gcc toolchain.

>> Thanks, Fedor.  I'm uploading another patch which pulls out the "isValid" 
>> check. Also I'm putting back the dummy sysroot tree which contains 
>> stdc-predef.h and adding a new test run to confirm that the new option 
>> fsystem-include-if-exists is actually working. 
https://reviews.llvm.org/D34158



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


[PATCH] D34158: For Linux/gnu compatibility, preinclude if the file is available

2017-08-08 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 110193.
mibintc added a comment.

Responding to @fedor.sergeev 's comment.  This is an updated patch which pulls 
out the "isValid" check on GCCInstallation. Also I'm putting back the dummy 
sysroot tree which contains stdc-predef.h and adding a new test run to confirm 
that the new option fsystem-include-if-exists is actually working.


https://reviews.llvm.org/D34158

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Lex/PreprocessorOptions.h
  lib/Driver/ToolChains/Linux.cpp
  lib/Driver/ToolChains/Linux.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/InitPreprocessor.cpp
  test/Driver/Inputs/stdc-predef/usr/include/stdc-predef.h
  test/Driver/clang_cpp.c
  test/Driver/crash-report-header.h
  test/Driver/crash-report-spaces.c
  test/Driver/crash-report.c
  test/Driver/rewrite-legacy-objc.m
  test/Driver/rewrite-map-in-diagnostics.c
  test/Driver/rewrite-objc.m
  test/Driver/stdc-predef.c
  test/Index/IBOutletCollection.m
  test/Index/annotate-macro-args.m
  test/Index/annotate-tokens-pp.c
  test/Index/annotate-tokens.c
  test/Index/c-index-getCursor-test.m
  test/Index/get-cursor-macro-args.m
  test/Index/get-cursor.cpp
  test/Preprocessor/ignore-pragmas.c
  unittests/Tooling/TestVisitor.h

Index: lib/Driver/ToolChains/Linux.h
===
--- lib/Driver/ToolChains/Linux.h
+++ lib/Driver/ToolChains/Linux.h
@@ -31,6 +31,8 @@
   void addLibStdCxxIncludePaths(
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
+  void AddGnuIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+  llvm::opt::ArgStringList &CC1Args) const;
   void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
   void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -705,6 +705,8 @@
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/include");
 
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
+
+  AddGnuIncludeArgs(DriverArgs, CC1Args);
 }
 
 static std::string DetectLibcxxIncludePath(StringRef base) {
@@ -743,6 +745,17 @@
   return "";
 }
 
+void Linux::AddGnuIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+  llvm::opt::ArgStringList &CC1Args) const {
+  if (!DriverArgs.hasArg(options::OPT_ffreestanding)) {
+// For gcc compatibility, clang will preinclude 
+// -ffreestanding suppresses this behavior.
+CC1Args.push_back("-fsystem-include-if-exists");
+CC1Args.push_back("stdc-predef.h");
+  }
+}
+
+
 void Linux::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
  llvm::opt::ArgStringList &CC1Args) const {
   // We need a detected GCC installation on Linux to provide libstdc++'s
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2503,6 +2503,10 @@
   for (const Arg *A : Args.filtered(OPT_chain_include))
 Opts.ChainedIncludes.emplace_back(A->getValue());
 
+  // Add the ordered list of -fsystem-include-if-exists.
+  for (const Arg *A : Args.filtered(OPT_fsystem_include_if_exists))
+Opts.FSystemIncludeIfExists.emplace_back(A->getValue());
+
   for (const Arg *A : Args.filtered(OPT_remap_file)) {
 std::pair Split = StringRef(A->getValue()).split(';');
 
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -70,6 +70,15 @@
   Builder.append(Twine("#include \"") + File + "\"");
 }
 
+/// AddImplicitSystemIncludeIfExists - Add an implicit system \#include of the 
+/// specified file to the predefines buffer: precheck with __has_include.
+static void AddImplicitSystemIncludeIfExists(MacroBuilder &Builder, 
+ StringRef File) {
+  Builder.append(Twine("#if __has_include( <") + File + ">)");
+  Builder.append(Twine("#include <") + File + ">");
+  Builder.append(Twine("#endif"));
+}
+
 static void AddImplicitIncludeMacros(MacroBuilder &Builder, StringRef File) {
   Builder.append(Twine("#__include_macros \"") + File + "\"");
   // Marker token to stop the __include_macros fetch loop.
@@ -1104,6 +1113,13 @@
   // Exit the command line and go back to  (2 is LC_LEAVE).
   if (!PP.getLangOpts().AsmPreprocessor)
 Builder.append("# 1 \"\" 2");
+  
+  // Process -fsystem-include-if-exists directives.
+  for (unsigned i = 0, 
+   e = InitOpts.FSystemIncludeIfExists.size(); i != e; ++i) {
+const std::string &Path = InitOpts.FSystemIncludeIfExi

[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

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

In https://reviews.llvm.org/D29654#835256, @arphaman wrote:

> Great, thanks! I think that you can just revert my revert with the fix 
> applied in one commit


Hi Alex,

I just commited the changes again.

Let me know if it still fails for you. I think the issue was actually that the 
test wasn't quite correct so I cleaned that up.

--Doru


https://reviews.llvm.org/D29654



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


[PATCH] D35755: [Solaris] gcc toolchain handling revamp

2017-08-08 Thread Fedor Sergeev via Phabricator via cfe-commits
fedor.sergeev updated this revision to Diff 110194.
fedor.sergeev added a comment.

ugh... reverting back to llvm::Triple, since plain Triple conflicts with 
clang::driver::Toolchain::Triple data member.
Built/tested on Solaris11 x86/SPARC, Linux x86.


https://reviews.llvm.org/D35755

Files:
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Gnu.h
  lib/Driver/ToolChains/Solaris.cpp
  lib/Driver/ToolChains/Solaris.h
  lib/Frontend/InitHeaderSearch.cpp
  
test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/include/c++/4.8.2/sparc-sun-solaris2.11/bits/gthr.h
  test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/include/c++/4.8.2/typeinfo
  
test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crt1.o
  
test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtbegin.o
  
test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtend.o
  
test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9/crt1.o
  
test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9/crtbegin.o
  
test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9/crtend.o
  test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/libatomic.a
  test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/sparcv9/libatomic.a
  test/Driver/Inputs/solaris_sparc_tree/usr/lib/crti.o
  test/Driver/Inputs/solaris_sparc_tree/usr/lib/crtn.o
  test/Driver/Inputs/solaris_sparc_tree/usr/lib/ld.so.1
  test/Driver/Inputs/solaris_sparc_tree/usr/lib/sparcv9/crti.o
  test/Driver/Inputs/solaris_sparc_tree/usr/lib/sparcv9/crtn.o
  test/Driver/Inputs/solaris_sparc_tree/usr/lib/sparcv9/ld.so.1
  
test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/include/c++/4.9.4/i386-pc-solaris2.11/bits/gthr.h
  test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/include/c++/4.9.4/typeinfo
  test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/amd64/libatomic.a
  
test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64/crtbegin.o
  
test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64/crtend.o
  
test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/crtbegin.o
  
test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/crtend.o
  test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/libatomic.a
  test/Driver/Inputs/solaris_x86_tree/usr/lib/amd64/crt1.o
  test/Driver/Inputs/solaris_x86_tree/usr/lib/amd64/crti.o
  test/Driver/Inputs/solaris_x86_tree/usr/lib/amd64/crtn.o
  test/Driver/Inputs/solaris_x86_tree/usr/lib/amd64/ld.so.1
  test/Driver/Inputs/solaris_x86_tree/usr/lib/crt1.o
  test/Driver/Inputs/solaris_x86_tree/usr/lib/crti.o
  test/Driver/Inputs/solaris_x86_tree/usr/lib/crtn.o
  test/Driver/Inputs/solaris_x86_tree/usr/lib/ld.so.1
  
test/Driver/Inputs/sparc-sun-solaris2.11/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crt1.o
  
test/Driver/Inputs/sparc-sun-solaris2.11/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtbegin.o
  
test/Driver/Inputs/sparc-sun-solaris2.11/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtend.o
  test/Driver/Inputs/sparc-sun-solaris2.11/usr/lib/crti.o
  test/Driver/Inputs/sparc-sun-solaris2.11/usr/lib/crtn.o
  test/Driver/Inputs/sparc-sun-solaris2.11/usr/lib/ld.so.1
  test/Driver/solaris-header-search.cpp
  test/Driver/solaris-ld.c

Index: test/Driver/solaris-ld.c
===
--- test/Driver/solaris-ld.c
+++ test/Driver/solaris-ld.c
@@ -1,33 +1,105 @@
-// Test ld invocation on Solaris targets.
+// General tests that ld invocations on Solaris targets sane. Note that we use
+// sysroot to make these tests independent of the host system.
 
-// Check sparc-sun-solaris2.1
+// Check sparc-sun-solaris2.11, 32bit
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=sparc-sun-solaris2.11 \
-// RUN: --gcc-toolchain="" \
-// RUN: --sysroot=%S/Inputs/sparc-sun-solaris2.11 \
-// RUN:   | FileCheck %s
-// CHECK: "-cc1" "-triple" "sparc-sun-solaris2.11"
-// CHECK: ld{{.*}}"
-// CHECK: "--dynamic-linker" "{{.*}}/usr/lib/ld.so.1"
-// CHECK: "{{.*}}/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|}}crt1.o"
-// CHECK: "{{.*}}/usr/lib/crti.o"
-// CHECK: "{{.*}}/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|}}crtbegin.o"
-// CHECK: "{{.*}}/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|}}crtend.o"
-// CHECK: "{{.*}}/usr/lib/crtn.o"
-// CHECK "-lc"
-// CHECK "-lgcc_s"
-// CHECK "-lgcc"
-// CHECK "-lm"
+// RUN: --sysroot=%S/Inputs/solaris_sparc_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-SPARC32 %s
+// CHECK-LD-SPARC32-NOT: warning:
+// CHECK-LD-SPARC32: {{.*/clang}}" "-cc1" "-triple" "sparc-sun-solaris2.11"
+// CHECK-LD-SPARC32-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD-SPARC32: {{.*/ld}}"
+// CHECK-LD-SPARC32-SAME: "--dyna

r310364 - Revert "[OPENMP][DEBUG] Set proper address space info if required by target."

2017-08-08 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Aug  8 07:44:43 2017
New Revision: 310364

URL: http://llvm.org/viewvc/llvm-project?rev=310364&view=rev
Log:
Revert "[OPENMP][DEBUG] Set proper address space info if required by target."

This reverts commit r310360.

Removed:
cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/nvptx_target_firstprivate_codegen.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=310364&r1=310363&r2=310364&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Aug  8 07:44:43 2017
@@ -2685,14 +2685,6 @@ def OMPCaptureNoInit : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
-def OMPCaptureKind : Attr {
-  // This attribute has no spellings as it is only ever created implicitly.
-  let Spellings = [];
-  let SemaHandler = 0;
-  let Args = [UnsignedArgument<"CaptureKind">];
-  let Documentation = [Undocumented];
-}
-
 def OMPDeclareSimdDecl : Attr {
   let Spellings = [Pragma<"omp", "declare simd">];
   let Subjects = SubjectList<[Function]>;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=310364&r1=310363&r2=310364&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Aug  8 07:44:43 2017
@@ -8527,11 +8527,6 @@ public:
   /// is performed.
   bool isOpenMPPrivateDecl(ValueDecl *D, unsigned Level);
 
-  /// Sets OpenMP capture kind (OMPC_private, OMPC_firstprivate, OMPC_map etc.)
-  /// for \p FD based on DSA for the provided corresponding captured 
declaration
-  /// \p D.
-  void setOpenMPCaptureKind(FieldDecl *FD, ValueDecl *D, unsigned Level);
-
   /// \brief Check if the specified variable is captured  by 'target' 
directive.
   /// \param Level Relative level of nested OpenMP construct for that the check
   /// is performed.

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=310364&r1=310363&r2=310364&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Tue Aug  8 07:44:43 2017
@@ -1325,32 +1325,6 @@ public:
   virtual void emitDoacrossOrdered(CodeGenFunction &CGF,
const OMPDependClause *C);
 
-  /// Translates the native parameter of outlined function if this is required
-  /// for target.
-  /// \param FD Field decl from captured record for the paramater.
-  /// \param NativeParam Parameter itself.
-  virtual const VarDecl *translateParameter(const FieldDecl *FD,
-const VarDecl *NativeParam) const {
-return NativeParam;
-  }
-
-  typedef llvm::function_ref
-  MappingFnType;
-  /// Maps the native argument to the address of the corresponding
-  /// target-specific argument.
-  /// \param FD Field decl from captured record for the paramater.
-  /// \param NativeParam Parameter itself.
-  /// \param TargetParam Corresponding target-specific parameter.
-  /// \param MapFn Function that maps the native parameter to the address of 
the
-  /// target-specific.
-  virtual void mapParameterAddress(CodeGenFunction &CGF, const FieldDecl *FD,
-   const VarDecl *NativeParam,
-   const VarDecl *TargetParam,
-   const MappingFnType) const {
-assert(NativeParam == TargetParam &&
-   "native and target args must be the same");
-  }
-
   /// Emits call of the outlined function with the provided arguments,
   /// translating these arguments to correct target-specific arguments.
   virtual void

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=310364&r1=310363&r2=310364&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Tue Aug  8 07:44:43 2017
@@ -2238,81 +2238,3 @@ void CGOpenMPRuntimeNVPTX::emitReduction
   CGF.EmitBranch(DefaultBB);
   CGF.EmitBlock(DefaultBB, /*IsFinished=*/true);
 }
-
-const VarDecl *
-CGOpenMPRuntimeNVPTX::translatePara

[PATCH] D35755: [Solaris] gcc toolchain handling revamp

2017-08-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/Driver/ToolChains/Gnu.h:253
 
+void AddDefaultGCCPrefixes(const llvm::Triple &TargetTriple,
+   SmallVectorImpl &Prefixes,

fedor.sergeev wrote:
> aaron.ballman wrote:
> > Might as well drop the `llvm::` since the namespace isn't used for 
> > `SmallVectorImpl`.
> suggested change caused a build failure since Triple resolves into 
> Toolchain::Triple data member, not to llvm::Triple.
That's really good to know, thanks (and sorry for the churn)!


https://reviews.llvm.org/D35755



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


[PATCH] D36159: clang-format: [JS] handle single lines comments ending in `\\`.

2017-08-08 Thread Martin Probst via Phabricator via cfe-commits
mprobst marked an inline comment as done.
mprobst added inline comments.



Comment at: lib/Format/FormatTokenLexer.cpp:544-545
+while (BackslashPos != StringRef::npos) {
+  if (BackslashPos + 1 < FormatTok->TokenText.size() &&
+  FormatTok->TokenText[BackslashPos + 1] == '\n') {
+const char *Offset = Lex->getBufferLocation();

klimek wrote:
> Just wondering whether the \n can be in the next token. Probably not, though, 
> the way we set up the lexer.
AFAIU (and experimentation confirms) LLVM always lexes the `\n` as separate 
whitespace from the `// ...` line comment, but for backslash escaped line 
endings after the `\\` the `\n` is inside of it - after all it's part of the 
one comment token that continues on the next line.


https://reviews.llvm.org/D36159



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


[PATCH] D35755: [Solaris] gcc toolchain handling revamp

2017-08-08 Thread Fedor Sergeev via Phabricator via cfe-commits
fedor.sergeev marked an inline comment as not done.
fedor.sergeev added inline comments.



Comment at: lib/Driver/ToolChains/Gnu.h:253
 
+void AddDefaultGCCPrefixes(const llvm::Triple &TargetTriple,
+   SmallVectorImpl &Prefixes,

aaron.ballman wrote:
> Might as well drop the `llvm::` since the namespace isn't used for 
> `SmallVectorImpl`.
suggested change caused a build failure since Triple resolves into 
Toolchain::Triple data member, not to llvm::Triple.


https://reviews.llvm.org/D35755



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


[PATCH] D36354: [clang-tidy] Implement type-based check for `gsl::owner`

2017-08-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:29
+void OwningMemoryCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus11) {
+return;

Can elide the braces.



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:32
+  }
+  const auto ownerDecl = typeAliasTemplateDecl(hasName("::gsl::owner"));
+  const auto isOwnerType = hasType(ownerDecl);

Variable names should start with an uppercase letter (here and elsewhere).



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:39
+
+  // Find delete expressions, that delete non owners.
+  Finder->addMatcher(

Can remove the comma and add a hyphen to non-owners.



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:55
+
+  // Matching initialization of owners with non owners, nor creating owners.
+  Finder->addMatcher(

non-owners



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:75
+
+  // Matching on assignment operations, where the RHS is a newly created owner,
+  // but the LHS is not an owner.

Can remove the first comma.



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:83
+
+  // Matching on initialization operations, where the initial value is a newly
+  // created owner, but the LHS is not an owner.

Can remove the first comma.



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:93
+
+  // Match on all function calls, that expect owners as arguments, but didn't
+  // get them.

Can remove the first comma.



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:101
+
+  // Matching for function calls, where one argument is a created owner, but 
the
+  // parameter type is not an owner.

Can remove the first comma.



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:108
+
+  // Matching on functions, that return an owner/resource, but don't declare
+  // their return type as owner.

Can remove the first comma.



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:117
+
+  // Match on classes, that have an owner as member, but don't declare a
+  // destructor to properly release the owner.

Can remove the first comma.



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:128
+
+void OwningMemoryCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto &Nodes = Result.Nodes;

Please split this function up into smaller functions that check only the 
individual components.



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.h:19
+
+/// Checks for common usecases for gsl::owner and enforces the unique owner 
nature
+/// of it whenever possible.

usecases -> use cases


https://reviews.llvm.org/D36354



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


r310365 - clang-format: [JS] handle single lines comments ending in `\\`.

2017-08-08 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Tue Aug  8 07:52:42 2017
New Revision: 310365

URL: http://llvm.org/viewvc/llvm-project?rev=310365&view=rev
Log:
clang-format: [JS] handle single lines comments ending in `\\`.

Summary:
Previously, clang-format would consider the following code line to be part of
the comment and incorrectly format the rest of the file.

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/FormatTokenLexer.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/FormatTokenLexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatTokenLexer.cpp?rev=310365&r1=310364&r2=310365&view=diff
==
--- cfe/trunk/lib/Format/FormatTokenLexer.cpp (original)
+++ cfe/trunk/lib/Format/FormatTokenLexer.cpp Tue Aug  8 07:52:42 2017
@@ -529,6 +529,34 @@ FormatToken *FormatTokenLexer::getNextTo
 readRawToken(*FormatTok);
   }
 
+  // JavaScript and Java do not allow to escape the end of the line with a
+  // backslash. Backslashes are syntax errors in plain source, but can occur in
+  // comments. When a single line comment ends with a \, it'll cause the next
+  // line of code to be lexed as a comment, breaking formatting. The code below
+  // finds comments that contain a backslash followed by a line break, 
truncates
+  // the comment token at the backslash, and resets the lexer to restart behind
+  // the backslash.
+  if ((Style.Language == FormatStyle::LK_JavaScript ||
+   Style.Language == FormatStyle::LK_Java) &&
+  FormatTok->is(tok::comment) && FormatTok->TokenText.startswith("//")) {
+size_t BackslashPos = FormatTok->TokenText.find('\\');
+while (BackslashPos != StringRef::npos) {
+  if (BackslashPos + 1 < FormatTok->TokenText.size() &&
+  FormatTok->TokenText[BackslashPos + 1] == '\n') {
+const char *Offset = Lex->getBufferLocation();
+Offset -= FormatTok->TokenText.size();
+Offset += BackslashPos + 1;
+resetLexer(SourceMgr.getFileOffset(Lex->getSourceLocation(Offset)));
+FormatTok->TokenText = FormatTok->TokenText.substr(0, BackslashPos + 
1);
+FormatTok->ColumnWidth = encoding::columnWidthWithTabs(
+FormatTok->TokenText, FormatTok->OriginalColumn, Style.TabWidth,
+Encoding);
+break;
+  }
+  BackslashPos = FormatTok->TokenText.find('\\', BackslashPos + 1);
+}
+  }
+
   // In case the token starts with escaped newlines, we want to
   // take them into account as whitespace - this pattern is quite frequent
   // in macro definitions.

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=310365&r1=310364&r2=310365&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Aug  8 07:52:42 2017
@@ -2074,5 +2074,27 @@ TEST_F(FormatTestJS, NestedLiterals) {
"};", FourSpaces);
 }
 
+TEST_F(FormatTestJS, BackslashesInComments) {
+  verifyFormat("// hello \\\n"
+   "if (x) foo();\n",
+   "// hello \\\n"
+   " if ( x) \n"
+   "   foo();\n");
+  verifyFormat("/* ignore \\\n"
+   " */\n"
+   "if (x) foo();\n",
+   "/* ignore \\\n"
+   " */\n"
+   " if (  x) foo();\n");
+  verifyFormat("// st \\ art\\\n"
+   "// comment"
+   "// continue \\\n"
+   "formatMe();\n",
+   "// st \\ art\\\n"
+   "// comment"
+   "// continue \\\n"
+   "formatMe( );\n");
+}
+
 } // end namespace tooling
 } // end namespace clang


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


[PATCH] D36159: clang-format: [JS] handle single lines comments ending in `\\`.

2017-08-08 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
mprobst marked 2 inline comments as done.
Closed by commit rL310365: clang-format: [JS] handle single lines comments 
ending in `\\`. (authored by mprobst).

Repository:
  rL LLVM

https://reviews.llvm.org/D36159

Files:
  cfe/trunk/lib/Format/FormatTokenLexer.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp


Index: cfe/trunk/lib/Format/FormatTokenLexer.cpp
===
--- cfe/trunk/lib/Format/FormatTokenLexer.cpp
+++ cfe/trunk/lib/Format/FormatTokenLexer.cpp
@@ -529,6 +529,34 @@
 readRawToken(*FormatTok);
   }
 
+  // JavaScript and Java do not allow to escape the end of the line with a
+  // backslash. Backslashes are syntax errors in plain source, but can occur in
+  // comments. When a single line comment ends with a \, it'll cause the next
+  // line of code to be lexed as a comment, breaking formatting. The code below
+  // finds comments that contain a backslash followed by a line break, 
truncates
+  // the comment token at the backslash, and resets the lexer to restart behind
+  // the backslash.
+  if ((Style.Language == FormatStyle::LK_JavaScript ||
+   Style.Language == FormatStyle::LK_Java) &&
+  FormatTok->is(tok::comment) && FormatTok->TokenText.startswith("//")) {
+size_t BackslashPos = FormatTok->TokenText.find('\\');
+while (BackslashPos != StringRef::npos) {
+  if (BackslashPos + 1 < FormatTok->TokenText.size() &&
+  FormatTok->TokenText[BackslashPos + 1] == '\n') {
+const char *Offset = Lex->getBufferLocation();
+Offset -= FormatTok->TokenText.size();
+Offset += BackslashPos + 1;
+resetLexer(SourceMgr.getFileOffset(Lex->getSourceLocation(Offset)));
+FormatTok->TokenText = FormatTok->TokenText.substr(0, BackslashPos + 
1);
+FormatTok->ColumnWidth = encoding::columnWidthWithTabs(
+FormatTok->TokenText, FormatTok->OriginalColumn, Style.TabWidth,
+Encoding);
+break;
+  }
+  BackslashPos = FormatTok->TokenText.find('\\', BackslashPos + 1);
+}
+  }
+
   // In case the token starts with escaped newlines, we want to
   // take them into account as whitespace - this pattern is quite frequent
   // in macro definitions.
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -2074,5 +2074,27 @@
"};", FourSpaces);
 }
 
+TEST_F(FormatTestJS, BackslashesInComments) {
+  verifyFormat("// hello \\\n"
+   "if (x) foo();\n",
+   "// hello \\\n"
+   " if ( x) \n"
+   "   foo();\n");
+  verifyFormat("/* ignore \\\n"
+   " */\n"
+   "if (x) foo();\n",
+   "/* ignore \\\n"
+   " */\n"
+   " if (  x) foo();\n");
+  verifyFormat("// st \\ art\\\n"
+   "// comment"
+   "// continue \\\n"
+   "formatMe();\n",
+   "// st \\ art\\\n"
+   "// comment"
+   "// continue \\\n"
+   "formatMe( );\n");
+}
+
 } // end namespace tooling
 } // end namespace clang


Index: cfe/trunk/lib/Format/FormatTokenLexer.cpp
===
--- cfe/trunk/lib/Format/FormatTokenLexer.cpp
+++ cfe/trunk/lib/Format/FormatTokenLexer.cpp
@@ -529,6 +529,34 @@
 readRawToken(*FormatTok);
   }
 
+  // JavaScript and Java do not allow to escape the end of the line with a
+  // backslash. Backslashes are syntax errors in plain source, but can occur in
+  // comments. When a single line comment ends with a \, it'll cause the next
+  // line of code to be lexed as a comment, breaking formatting. The code below
+  // finds comments that contain a backslash followed by a line break, truncates
+  // the comment token at the backslash, and resets the lexer to restart behind
+  // the backslash.
+  if ((Style.Language == FormatStyle::LK_JavaScript ||
+   Style.Language == FormatStyle::LK_Java) &&
+  FormatTok->is(tok::comment) && FormatTok->TokenText.startswith("//")) {
+size_t BackslashPos = FormatTok->TokenText.find('\\');
+while (BackslashPos != StringRef::npos) {
+  if (BackslashPos + 1 < FormatTok->TokenText.size() &&
+  FormatTok->TokenText[BackslashPos + 1] == '\n') {
+const char *Offset = Lex->getBufferLocation();
+Offset -= FormatTok->TokenText.size();
+Offset += BackslashPos + 1;
+resetLexer(SourceMgr.getFileOffset(Lex->getSourceLocation(Offset)));
+FormatTok->TokenText = FormatTok->TokenText.substr(0, BackslashPos + 1);
+FormatTok->ColumnWidth = encoding::columnWidthWithTabs(
+FormatTok->TokenText, FormatTok->OriginalColumn, Style.TabWidth,
+Encoding);
+break;
+   

r310367 - clang-format: [JS] fix union type spacing in object & array types.

2017-08-08 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Tue Aug  8 08:00:58 2017
New Revision: 310367

URL: http://llvm.org/viewvc/llvm-project?rev=310367&view=rev
Log:
clang-format: [JS] fix union type spacing in object & array types.

Summary:
Previously, clang-format would insert whitespace in union types nested in object
and array types, as it wouldn't recognize those as a type operator:

const x: {foo: number | null};
const x: [number | null];

While this is correct for actual binary operators, clang-format should not
insert whitespace into union and intersection types to mark those:

const x: {foo: number|null};
const x: [number|null];

This change propagates that the context is not an expression by inspecting
the preceding token and marking as non-expression if it was a type colon.

Reviewers: djasper

Subscribers: klimek

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

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=310367&r1=310366&r2=310367&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Aug  8 08:00:58 2017
@@ -372,6 +372,10 @@ private:
 
 ScopedContextCreator ContextCreator(*this, tok::l_square, BindingIncrease);
 Contexts.back().IsExpression = true;
+if (Style.Language == FormatStyle::LK_JavaScript && Parent &&
+Parent->is(TT_JsTypeColon))
+  Contexts.back().IsExpression = false;
+
 Contexts.back().ColonIsObjCMethodExpr = StartsObjCMethodExpr;
 
 while (CurrentToken) {
@@ -439,6 +443,9 @@ private:
   Contexts.back().ColonIsDictLiteral = true;
   if (Left->BlockKind == BK_BracedInit)
 Contexts.back().IsExpression = true;
+  if (Style.Language == FormatStyle::LK_JavaScript && Left->Previous &&
+  Left->Previous->is(TT_JsTypeColon))
+Contexts.back().IsExpression = false;
 
   while (CurrentToken) {
 if (CurrentToken->is(tok::r_brace)) {
@@ -531,6 +538,8 @@ private:
  !Line.First->isOneOf(tok::kw_enum, tok::kw_case)) ||
 Contexts.back().ContextKind == tok::l_paren ||  // function params
 Contexts.back().ContextKind == tok::l_square || // array type
+(!Contexts.back().IsExpression &&
+ Contexts.back().ContextKind == tok::l_brace) || // object type
 (Contexts.size() == 1 &&
  Line.MustBeDeclaration)) { // method/property declaration
   Contexts.back().IsExpression = false;

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=310367&r1=310366&r2=310367&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Aug  8 08:00:58 2017
@@ -1363,6 +1363,18 @@ TEST_F(FormatTestJS, UnionIntersectionTy
"};");
 }
 
+TEST_F(FormatTestJS, UnionIntersectionTypesInObjectType) {
+  verifyFormat("let x: {x: number|null} = {x: number | null};");
+  verifyFormat("let nested: {x: {y: number|null}};");
+  verifyFormat("let mixed: {x: [number|null, {w: number}]};");
+  verifyFormat("class X {\n"
+   "  contructor(x: {\n"
+   "a: a|null,\n"
+   "b: b|null,\n"
+   "  }) {}\n"
+   "}");
+}
+
 TEST_F(FormatTestJS, ClassDeclarations) {
   verifyFormat("class C {\n  x: string = 12;\n}");
   verifyFormat("class C {\n  x(): string => 12;\n}");


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


[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

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

Looks like it's still failing unfortunately: 
http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental_check/39182/console


https://reviews.llvm.org/D29654



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


[PATCH] D36407: [Sema] Extend -Wenum-compare to handle mixed enum comparisons in switch statements

2017-08-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Can you generate the updated patch with more context 
(https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface)?




Comment at: lib/Sema/SemaStmt.cpp:746
 
+static void checkEnumTypesInSwitchStmt(Sema &S, Expr *Cond, Expr *Case) {
+  QualType CondType = GetTypeBeforeIntegralPromotion(Cond);

`Cond` and `Case` can be declared as `const` pointers.



Comment at: lib/Sema/SemaStmt.cpp:758
+
+  SourceLocation Loc = Case->getExprLoc();
+  S.Diag(Loc, diag::warn_comparison_of_mixed_enum_types)

You can lower this in to the diagnostic.


https://reviews.llvm.org/D36407



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


[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

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

The last RUN line in the new commit triggers the same assertion failure:

  Assertion failed: (CachedResults.find(ActionTC) != CachedResults.end() && 
"Result does not exist??"), function BuildJobsForActionNoCache, file 
/Users/alex/bisect/llvm/tools/clang/lib/Driver/Driver.cpp, line 3419.

backtrace:

  * frame #0: 0x7fffbf3a2b2e libsystem_kernel.dylib`__pthread_kill + 10
frame #1: 0x7fffbf4c72de libsystem_pthread.dylib`pthread_kill + 303
frame #2: 0x7fffbf30041f libsystem_c.dylib`abort + 127
frame #3: 0x7fffbf2c9f34 libsystem_c.dylib`__assert_rtn + 320
frame #4: 0x000103a1f311 
clang`clang::driver::Driver::BuildJobsForActionNoCache(this=0x7fff5fbfe518, 
C=0x000111c01130, A=0x000111c017d0, TC=0x00011300, 
BoundArch=(Data = "x86_64", Length = 6), AtTopLevel=false, MultipleArchs=false, 
LinkingOutput=0x, CachedResults=size=8, 
TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:3418
frame #5: 0x000103a1cf51 
clang`clang::driver::Driver::BuildJobsForAction(this=0x7fff5fbfe518, 
C=0x000111c01130, A=0x000111c017d0, TC=0x00011300, 
BoundArch=(Data = "x86_64", Length = 6), AtTopLevel=false, MultipleArchs=false, 
LinkingOutput=0x, CachedResults=size=8, 
TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:3210
frame #6: 0x000103a1dff3 
clang`clang::driver::Driver::BuildJobsForActionNoCache(this=0x7fff5fbfe518, 
C=0x000111c01130, A=0x000111c01a30, TC=0x00011300, 
BoundArch=(Data = "x86_64", Length = 6), AtTopLevel=true, MultipleArchs=false, 
LinkingOutput=0x, CachedResults=size=8, 
TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:3348
frame #7: 0x000103a1cf51 
clang`clang::driver::Driver::BuildJobsForAction(this=0x7fff5fbfe518, 
C=0x000111c01130, A=0x000111c01af0, TC=0x00011300, 
BoundArch=(Data = "x86_64", Length = 6), AtTopLevel=true, MultipleArchs=false, 
LinkingOutput=0x, CachedResults=size=8, 
TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:3210
frame #8: 0x000103a1db7e 
clang`clang::driver::Driver::BuildJobsForActionNoCache(this=0x7fff5fbfe518, 
C=0x000111c01130, A=0x000111c014f0, TC=0x00011300, 
BoundArch=(Data = 0x, Length = 0), AtTopLevel=true, 
MultipleArchs=false, LinkingOutput=0x, CachedResults=size=8, 
TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:3310
frame #9: 0x000103a1cf51 
clang`clang::driver::Driver::BuildJobsForAction(this=0x7fff5fbfe518, 
C=0x000111c01130, A=0x000111c014f0, TC=0x00011300, 
BoundArch=(Data = 0x, Length = 0), AtTopLevel=true, 
MultipleArchs=false, LinkingOutput=0x, CachedResults=size=8, 
TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:3210
frame #10: 0x000103a0a602 
clang`clang::driver::Driver::BuildJobs(this=0x7fff5fbfe518, 
C=0x000111c01130) const at Driver.cpp:2843
frame #11: 0x000103a00b9c 
clang`clang::driver::Driver::BuildCompilation(this=0x7fff5fbfe518, 
ArgList=ArrayRef @ 0x7fff5fbfc218) at Driver.cpp:746
frame #12: 0x00015a92 clang`main(argc_=7, argv_=0x7fff5fbff6a8) 
at driver.cpp:463
frame #13: 0x7fffbf260c05 libdyld.dylib`start + 1
frame #14: 0x7fffbf260c05 libdyld.dylib`start + 1


https://reviews.llvm.org/D29654



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


[PATCH] D36471: [StaticAnalyzer] Try to calculate arithmetic result when operand has a range of possible values

2017-08-08 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki created this revision.

In the code below the division result should be a value between 5 and 25.

  if (a >= 10 && a <= 50) {
int b = a / 2;
  }

This patch will calculate results for additions, subtractions and divisions.

I intentionally do not try to handle all possible cases that can be handled. I 
want to know if my approach is ok.


Repository:
  rL LLVM

https://reviews.llvm.org/D36471

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  test/Analysis/eval-range.c

Index: test/Analysis/eval-range.c
===
--- test/Analysis/eval-range.c
+++ test/Analysis/eval-range.c
@@ -0,0 +1,18 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
+
+void clang_analyzer_eval(int);
+
+void test1(int a) {
+  if (a >= 10 && a <= 50) {
+int b;
+
+b = a + 2;
+clang_analyzer_eval(b >= 12 && b <= 52); // expected-warning{{TRUE}}
+
+b = a - 2;
+clang_analyzer_eval(b >= 8 && b <= 48); // expected-warning{{TRUE}}
+
+b = a / 2;
+clang_analyzer_eval(b >= 5 && b <= 25); // expected-warning{{TRUE}}
+  }
+}
Index: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -304,6 +304,8 @@
   void print(ProgramStateRef State, raw_ostream &Out, const char *nl,
  const char *sep) override;
 
+  ProgramStateRef evalRangeOp(ProgramStateRef state, SVal V) override;
+
   //===--===//
   // Implementation for interface from RangedConstraintManager.
   //===--===//
@@ -741,3 +743,65 @@
   }
   Out << nl;
 }
+
+ProgramStateRef RangeConstraintManager::evalRangeOp(ProgramStateRef St,
+SVal V) {
+  const SymExpr *SE = V.getAsSymExpr();
+  if (!SE)
+return nullptr;
+
+  const SymIntExpr *SIE = dyn_cast(SE);
+  if (!SIE)
+return nullptr;
+
+  const clang::BinaryOperatorKind Opc = SIE->getOpcode();
+
+  if (Opc != BO_Add && Opc != BO_Sub && Opc != BO_Div)
+return nullptr;
+
+  const SymExpr *LHS = SIE->getLHS();
+  const llvm::APSInt &RHS = SIE->getRHS();
+
+  if (RHS.isNegative())
+// TODO: Handle negative values.
+return nullptr;
+
+  ConstraintRangeTy Ranges = St->get();
+  for (ConstraintRangeTy::iterator I = Ranges.begin(), E = Ranges.end(); I != E;
+   ++I) {
+if (LHS == I.getKey()) {
+  const auto D = I.getData();
+  for (auto I = D.begin(); I != D.end(); ++I) {
+if (I->From().isUnsigned() != RHS.isUnsigned())
+  // TODO: Handle sign conversions.
+  return nullptr;
+if (I->From().getBitWidth() != RHS.getBitWidth())
+  // TODO: Promote values.
+  return nullptr;
+if (I->From().isNegative())
+  // TODO: Handle negative range values
+  return nullptr;
+llvm::APSInt Lower;
+llvm::APSInt Upper;
+if (Opc == BO_Add) {
+  Lower = I->From() + RHS;
+  Upper = I->To() + RHS;
+} else if (Opc == BO_Sub) {
+  if (RHS > I->From())
+return nullptr;
+  Lower = I->From() - RHS;
+  Upper = I->To() - RHS;
+} else if (Opc == BO_Div) {
+  Lower = I->From() / RHS;
+  Upper = I->To() / RHS;
+}
+SymbolRef Sym = V.getAsSymbol();
+RangeSet RS =
+getRange(St, Sym).Intersect(getBasicVals(), F, Lower, Upper);
+// TODO: This only evaluates the first range. Evaluate all ranges.
+return RS.isEmpty() ? nullptr : St->set(Sym, RS);
+  }
+}
+  }
+  return nullptr;
+}
Index: lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -98,6 +98,14 @@
   }
 
   state = state->BindExpr(B, LCtx, Result);
+
+  {
+ProgramStateRef St2 = getConstraintManager().evalRangeOp(state, Result);
+if (St2) {
+  Bldr.generateNode(B, *it, St2);
+  continue;
+}
+  }
   Bldr.generateNode(B, *it, state);
   continue;
 }
Index: include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
@@ -142,13 +142,15 @@
   /// Scan all symbols referenced by the constraints. If the symbol is not
   /// alive, remove it.
   virtual ProgramStateRef removeDeadBindings(ProgramStateRef state,
-   

[PATCH] D35937: [clang-tidy] Add new readability non-idiomatic static access

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

LGTM!




Comment at: clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp:23
+  memberExpr(hasDeclaration(anyOf(cxxMethodDecl(isStaticStorageClass()),
+  varDecl(hasStaticStorageDuration(,
+ unless(isInTemplateInstantiation()))

barancsuk wrote:
> aaron.ballman wrote:
> > barancsuk wrote:
> > > aaron.ballman wrote:
> > > > Why not use `isStaticStorageClass()` here as well?
> > > Unfortunately, `isStaticStorageClass()` misses variable declarations that 
> > > do not contain the static keyword, including definitions of static 
> > > variables outside of their class.
> > > However, `hasStaticStorageDuration()` has no problem finding all static 
> > > variable declarations correctly. 
> > Under what circumstances would that make a difference? If the variable is 
> > declared within the class with the static storage specifier, that 
> > declaration should be sufficient for the check, regardless of how the 
> > definition looks, no?
> > 
> > If it does make a difference, can you add a test case that demonstrates 
> > that?
> `isStaticStorageClass()` does fail for the current test cases.
> 
> The reason for that is the function `hasDecl()`, that, for static variables 
> with multiple declarations,  may return a declaration that does not contain 
> the `static` keyword.
> For example, it finds `int C::x = 0;` rather than `static int x;`
> Then `isStaticStorageClass()` discards it.
> 
> However, `hasStaticStorageDuration()` works fine, because all declarations 
> are static storage duration, regardless of whether the `static` keyword is 
> present or not.
Hmmm, that's unexpected (though not incorrect, from looking at the matcher 
implementations). Thank you for the explanation, I think it's fine for your 
patch.


https://reviews.llvm.org/D35937



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


[PATCH] D36411: Restore previous structure ABI for bitfields with 'packed' attribute for PS4 targets

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

LGTM!


https://reviews.llvm.org/D36411



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


[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

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

In https://reviews.llvm.org/D29654#835371, @arphaman wrote:

> The last RUN line in the new commit triggers the same assertion failure:
>
>   Assertion failed: (CachedResults.find(ActionTC) != CachedResults.end() && 
> "Result does not exist??"), function BuildJobsForActionNoCache, file 
> /Users/alex/bisect/llvm/tools/clang/lib/Driver/Driver.cpp, line 3419.
>
>
> backtrace:
>
>   * frame #0: 0x7fffbf3a2b2e libsystem_kernel.dylib`__pthread_kill + 10
> frame #1: 0x7fffbf4c72de libsystem_pthread.dylib`pthread_kill + 303
> frame #2: 0x7fffbf30041f libsystem_c.dylib`abort + 127
> frame #3: 0x7fffbf2c9f34 libsystem_c.dylib`__assert_rtn + 320
> frame #4: 0x000103a1f311 
> clang`clang::driver::Driver::BuildJobsForActionNoCache(this=0x7fff5fbfe518,
>  C=0x000111c01130, A=0x000111c017d0, TC=0x00011300, 
> BoundArch=(Data = "x86_64", Length = 6), AtTopLevel=false, 
> MultipleArchs=false, LinkingOutput=0x, CachedResults=size=8, 
> TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:3418
> frame #5: 0x000103a1cf51 
> clang`clang::driver::Driver::BuildJobsForAction(this=0x7fff5fbfe518, 
> C=0x000111c01130, A=0x000111c017d0, TC=0x00011300, 
> BoundArch=(Data = "x86_64", Length = 6), AtTopLevel=false, 
> MultipleArchs=false, LinkingOutput=0x, CachedResults=size=8, 
> TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:3210
> frame #6: 0x000103a1dff3 
> clang`clang::driver::Driver::BuildJobsForActionNoCache(this=0x7fff5fbfe518,
>  C=0x000111c01130, A=0x000111c01a30, TC=0x00011300, 
> BoundArch=(Data = "x86_64", Length = 6), AtTopLevel=true, 
> MultipleArchs=false, LinkingOutput=0x, CachedResults=size=8, 
> TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:3348
> frame #7: 0x000103a1cf51 
> clang`clang::driver::Driver::BuildJobsForAction(this=0x7fff5fbfe518, 
> C=0x000111c01130, A=0x000111c01af0, TC=0x00011300, 
> BoundArch=(Data = "x86_64", Length = 6), AtTopLevel=true, 
> MultipleArchs=false, LinkingOutput=0x, CachedResults=size=8, 
> TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:3210
> frame #8: 0x000103a1db7e 
> clang`clang::driver::Driver::BuildJobsForActionNoCache(this=0x7fff5fbfe518,
>  C=0x000111c01130, A=0x000111c014f0, TC=0x00011300, 
> BoundArch=(Data = 0x, Length = 0), AtTopLevel=true, 
> MultipleArchs=false, LinkingOutput=0x, CachedResults=size=8, 
> TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:3310
> frame #9: 0x000103a1cf51 
> clang`clang::driver::Driver::BuildJobsForAction(this=0x7fff5fbfe518, 
> C=0x000111c01130, A=0x000111c014f0, TC=0x00011300, 
> BoundArch=(Data = 0x, Length = 0), AtTopLevel=true, 
> MultipleArchs=false, LinkingOutput=0x, CachedResults=size=8, 
> TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:3210
> frame #10: 0x000103a0a602 
> clang`clang::driver::Driver::BuildJobs(this=0x7fff5fbfe518, 
> C=0x000111c01130) const at Driver.cpp:2843
> frame #11: 0x000103a00b9c 
> clang`clang::driver::Driver::BuildCompilation(this=0x7fff5fbfe518, 
> ArgList=ArrayRef @ 0x7fff5fbfc218) at Driver.cpp:746
> frame #12: 0x00015a92 clang`main(argc_=7, 
> argv_=0x7fff5fbff6a8) at driver.cpp:463
> frame #13: 0x7fffbf260c05 libdyld.dylib`start + 1
> frame #14: 0x7fffbf260c05 libdyld.dylib`start + 1
>   


Hi Alex, I'm not sure why it's failing as I can't reproduce the error locally. 
Do you have access to a machine with the configuration the test uses?


https://reviews.llvm.org/D29654



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


[clang-tools-extra] r310371 - [clang-tidy] Add new readability non-idiomatic static access check

2017-08-08 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Tue Aug  8 08:33:48 2017
New Revision: 310371

URL: http://llvm.org/viewvc/llvm-project?rev=310371&view=rev
Log:
[clang-tidy] Add new readability non-idiomatic static access check

Patch by: Lilla Barancsuk

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

Added:

clang-tools-extra/trunk/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp

clang-tools-extra/trunk/clang-tidy/readability/StaticAccessedThroughInstanceCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-static-accessed-through-instance.rst

clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance-nesting-threshold.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt?rev=310371&r1=310370&r2=310371&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt Tue Aug  8 
08:33:48 2017
@@ -25,6 +25,7 @@ add_clang_library(clangTidyReadabilityMo
   RedundantSmartptrGetCheck.cpp
   RedundantStringInitCheck.cpp
   SimplifyBooleanExprCheck.cpp
+  StaticAccessedThroughInstanceCheck.cpp
   StaticDefinitionInAnonymousNamespaceCheck.cpp
   UniqueptrDeleteReleaseCheck.cpp
 

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp?rev=310371&r1=310370&r2=310371&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp 
Tue Aug  8 08:33:48 2017
@@ -32,6 +32,7 @@
 #include "RedundantStringCStrCheck.h"
 #include "RedundantStringInitCheck.h"
 #include "SimplifyBooleanExprCheck.h"
+#include "StaticAccessedThroughInstanceCheck.h"
 #include "StaticDefinitionInAnonymousNamespaceCheck.h"
 #include "UniqueptrDeleteReleaseCheck.h"
 
@@ -70,6 +71,8 @@ public:
 "readability-redundant-function-ptr-dereference");
 CheckFactories.registerCheck(
 "readability-redundant-member-init");
+CheckFactories.registerCheck(
+"readability-static-accessed-through-instance");
 CheckFactories.registerCheck(
 "readability-static-definition-in-anonymous-namespace");
 CheckFactories.registerCheck(

Added: 
clang-tools-extra/trunk/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp?rev=310371&view=auto
==
--- 
clang-tools-extra/trunk/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
 (added)
+++ 
clang-tools-extra/trunk/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
 Tue Aug  8 08:33:48 2017
@@ -0,0 +1,90 @@
+//===--- StaticAccessedThroughInstanceCheck.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 "StaticAccessedThroughInstanceCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+static unsigned getNameSpecifierNestingLevel(const QualType &QType) {
+  if (const ElaboratedType *ElType = QType->getAs()) {
+const NestedNameSpecifier *NestedSpecifiers = ElType->getQualifier();
+unsigned NameSpecifierNestingLevel = 1;
+do {
+  NameSpecifierNestingLevel++;
+  NestedSpecifiers = NestedSpecifiers->getPrefix();
+} while (NestedSpecifiers);
+
+return NameSpecifierNestingLevel;
+  }
+  return 0;
+}
+
+void StaticAccessedThroughInstanceCheck::storeOptions(
+ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "NameSpecifierNestingThreshold",
+NameSpecifierNestingThreshold);
+}
+
+void StaticAccessedThroughInstanceCheck::registerMatchers(MatchFinder *Finder) 
{
+  Finder->addMatcher(
+  memberExpr(hasDeclaration(anyOf(cxxMethodDecl(isStaticStorageClass()),
+ 

[PATCH] D35937: [clang-tidy] Add new readability non-idiomatic static access

2017-08-08 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310371: [clang-tidy] Add new readability non-idiomatic 
static access check (authored by xazax).

Changed prior to commit:
  https://reviews.llvm.org/D35937?vs=110175&id=110209#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35937

Files:
  clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
  
clang-tools-extra/trunk/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
  
clang-tools-extra/trunk/clang-tidy/readability/StaticAccessedThroughInstanceCheck.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-static-accessed-through-instance.rst
  
clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance-nesting-threshold.cpp
  
clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance.cpp
@@ -0,0 +1,222 @@
+// RUN: %check_clang_tidy %s readability-static-accessed-through-instance %t
+
+struct C {
+  static void foo();
+  static int x;
+  int nsx;
+  void mf() {
+(void)&x;// OK, x is accessed inside the struct.
+(void)&C::x; // OK, x is accessed using a qualified-id.
+foo();   // OK, foo() is accessed inside the struct.
+  }
+  void ns() const;
+};
+
+int C::x = 0;
+
+struct CC {
+  void foo();
+  int x;
+};
+
+template  struct CT {
+  static T foo();
+  static T x;
+  int nsx;
+  void mf() {
+(void)&x;// OK, x is accessed inside the struct.
+(void)&C::x; // OK, x is accessed using a qualified-id.
+foo();   // OK, foo() is accessed inside the struct.
+  }
+};
+
+// Expressions with side effects
+C &f(int, int, int, int);
+void g() {
+  f(1, 2, 3, 4).x;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member accessed through instance  [readability-static-accessed-through-instance]
+  // CHECK-FIXES: {{^}}  f(1, 2, 3, 4).x;{{$}}
+}
+
+int i(int &);
+void j(int);
+C h();
+bool a();
+int k(bool);
+
+void f(C c) {
+  j(i(h().x));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: static member
+  // CHECK-FIXES: {{^}}  j(i(h().x));{{$}}
+
+  // The execution of h() depends on the return value of a().
+  j(k(a() && h().x));
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: static member
+  // CHECK-FIXES: {{^}}  j(k(a() && h().x));{{$}}
+
+  if ([c]() {
+c.ns();
+return c;
+  }().x == 15)
+;
+  // CHECK-MESSAGES: :[[@LINE-5]]:7: warning: static member
+  // CHECK-FIXES: {{^}}  if ([c]() {{{$}}
+}
+
+// Nested specifiers
+namespace N {
+struct V {
+  static int v;
+  struct T {
+static int t;
+struct U {
+  static int u;
+};
+  };
+};
+}
+
+void f(N::V::T::U u) {
+  N::V v;
+  v.v = 12;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
+  // CHECK-FIXES: {{^}}  N::V::v = 12;{{$}}
+
+  N::V::T w;
+  w.t = 12;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
+  // CHECK-FIXES: {{^}}  N::V::T::t = 12;{{$}}
+
+  // u.u is not changed to N::V::T::U::u; because the nesting level is over 3.
+  u.u = 12;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
+  // CHECK-FIXES: {{^}}  u.u = 12;{{$}}
+
+  using B = N::V::T::U;
+  B b;
+  b.u;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
+  // CHECK-FIXES: {{^}}  B::u;{{$}}
+}
+
+// Templates
+template  T CT::x;
+
+template  struct CCT {
+  T foo();
+  T x;
+};
+
+typedef C D;
+
+using E = D;
+
+#define FOO(c) c.foo()
+#define X(c) c.x
+
+template  void f(T t, C c) {
+  t.x; // OK, t is a template parameter.
+  c.x; // 1
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
+  // CHECK-FIXES: {{^}}  C::x; // 1{{$}}
+}
+
+template  struct S { static int x; };
+
+template <> struct S<0> { int x; };
+
+template  void h() {
+  S sN;
+  sN.x; // OK, value of N affects whether x is static or not.
+
+  S<2> s2;
+  s2.x;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
+  // CHECK-FIXES: {{^}}  S<2>::x;{{$}}
+}
+
+void static_through_instance() {
+  C *c1 = new C();
+  c1->foo(); // 1
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
+  // CHECK-FIXES: {{^}}  C::foo(); // 1{{$}}
+  c1->x; // 2
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
+  // CHECK-FIXES: {{^}}  C::x; // 2{{$}}
+  c1->nsx; // OK, nsx is a non-static member.
+
+  const C *c2 = new C();
+  c2->foo(); // 2
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
+  // CHECK-FIXES: {{^}}  C::foo(); // 2{{$}}
+
+  C::foo(); // OK, foo() is accessed u

[PATCH] D36471: [StaticAnalyzer] Try to calculate arithmetic result when operand has a range of possible values

2017-08-08 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Can't you reuse somehow some machinery already available to evaluate the 
arithmetic operators? Those should already handle most of your TODOs and 
overflows.


Repository:
  rL LLVM

https://reviews.llvm.org/D36471



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


[PATCH] D36324: Integrate Kostya's clang-proto-fuzzer with LLVM.

2017-08-08 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added a comment.

In https://reviews.llvm.org/D36324#834660, @kcc wrote:

> Why do we need LLVM_ENABLE_RTTI=ON here?


Attempting to build without it yields all kinds of protobuf errors.  For 
example:
F4944099: image.png 


https://reviews.llvm.org/D36324



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


[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

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

In https://reviews.llvm.org/D29654#835392, @gtbercea wrote:

> In https://reviews.llvm.org/D29654#835371, @arphaman wrote:
>
> > The last RUN line in the new commit triggers the same assertion failure:
> >
> >   Assertion failed: (CachedResults.find(ActionTC) != CachedResults.end() && 
> > "Result does not exist??"), function BuildJobsForActionNoCache, file 
> > /Users/alex/bisect/llvm/tools/clang/lib/Driver/Driver.cpp, line 3419.
> >
> >
> > backtrace:
> >
> >   * frame #0: 0x7fffbf3a2b2e libsystem_kernel.dylib`__pthread_kill + 10
> > frame #1: 0x7fffbf4c72de libsystem_pthread.dylib`pthread_kill + 303
> > frame #2: 0x7fffbf30041f libsystem_c.dylib`abort + 127
> > frame #3: 0x7fffbf2c9f34 libsystem_c.dylib`__assert_rtn + 320
> > frame #4: 0x000103a1f311 
> > clang`clang::driver::Driver::BuildJobsForActionNoCache(this=0x7fff5fbfe518,
> >  C=0x000111c01130, A=0x000111c017d0, TC=0x00011300, 
> > BoundArch=(Data = "x86_64", Length = 6), AtTopLevel=false, 
> > MultipleArchs=false, LinkingOutput=0x, 
> > CachedResults=size=8, TargetDeviceOffloadKind=OFK_None) const at 
> > Driver.cpp:3418
> > frame #5: 0x000103a1cf51 
> > clang`clang::driver::Driver::BuildJobsForAction(this=0x7fff5fbfe518, 
> > C=0x000111c01130, A=0x000111c017d0, TC=0x00011300, 
> > BoundArch=(Data = "x86_64", Length = 6), AtTopLevel=false, 
> > MultipleArchs=false, LinkingOutput=0x, 
> > CachedResults=size=8, TargetDeviceOffloadKind=OFK_None) const at 
> > Driver.cpp:3210
> > frame #6: 0x000103a1dff3 
> > clang`clang::driver::Driver::BuildJobsForActionNoCache(this=0x7fff5fbfe518,
> >  C=0x000111c01130, A=0x000111c01a30, TC=0x00011300, 
> > BoundArch=(Data = "x86_64", Length = 6), AtTopLevel=true, 
> > MultipleArchs=false, LinkingOutput=0x, 
> > CachedResults=size=8, TargetDeviceOffloadKind=OFK_None) const at 
> > Driver.cpp:3348
> > frame #7: 0x000103a1cf51 
> > clang`clang::driver::Driver::BuildJobsForAction(this=0x7fff5fbfe518, 
> > C=0x000111c01130, A=0x000111c01af0, TC=0x00011300, 
> > BoundArch=(Data = "x86_64", Length = 6), AtTopLevel=true, 
> > MultipleArchs=false, LinkingOutput=0x, 
> > CachedResults=size=8, TargetDeviceOffloadKind=OFK_None) const at 
> > Driver.cpp:3210
> > frame #8: 0x000103a1db7e 
> > clang`clang::driver::Driver::BuildJobsForActionNoCache(this=0x7fff5fbfe518,
> >  C=0x000111c01130, A=0x000111c014f0, TC=0x00011300, 
> > BoundArch=(Data = 0x, Length = 0), AtTopLevel=true, 
> > MultipleArchs=false, LinkingOutput=0x, 
> > CachedResults=size=8, TargetDeviceOffloadKind=OFK_None) const at 
> > Driver.cpp:3310
> > frame #9: 0x000103a1cf51 
> > clang`clang::driver::Driver::BuildJobsForAction(this=0x7fff5fbfe518, 
> > C=0x000111c01130, A=0x000111c014f0, TC=0x00011300, 
> > BoundArch=(Data = 0x, Length = 0), AtTopLevel=true, 
> > MultipleArchs=false, LinkingOutput=0x, 
> > CachedResults=size=8, TargetDeviceOffloadKind=OFK_None) const at 
> > Driver.cpp:3210
> > frame #10: 0x000103a0a602 
> > clang`clang::driver::Driver::BuildJobs(this=0x7fff5fbfe518, 
> > C=0x000111c01130) const at Driver.cpp:2843
> > frame #11: 0x000103a00b9c 
> > clang`clang::driver::Driver::BuildCompilation(this=0x7fff5fbfe518, 
> > ArgList=ArrayRef @ 0x7fff5fbfc218) at Driver.cpp:746
> > frame #12: 0x00015a92 clang`main(argc_=7, 
> > argv_=0x7fff5fbff6a8) at driver.cpp:463
> > frame #13: 0x7fffbf260c05 libdyld.dylib`start + 1
> > frame #14: 0x7fffbf260c05 libdyld.dylib`start + 1
> >   
>
>
> Hi Alex, I'm not sure why it's failing as I can't reproduce the error 
> locally. Do you have access to a machine with the configuration the test uses?


Yes, I can reproduce it on my machine.


https://reviews.llvm.org/D29654



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


[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

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

The cached results map doesn't have the key:

  (lldb) p CachedResults
  (std::__1::map, 
std::__1::allocator > >, clang::driver::InputInfo, 
std::__1::less, 
std::__1::allocator > > >, std::__1::allocator, std::__1::allocator > >, 
clang::driver::InputInfo> > >) $0 = size=8 {
[0] = {
  first = {
first = 0x000111c01320
second = "nvptx64-nvidia-cuda-host"
  }
  second = {
Data = {
  Filename = 0x7fff5fbff8f8 
"/Volumes/newAPFS/bisect/b/tools/clang/test/Driver/Output/openmp-offload.c.tmp1.o"
  InputArg = 0x7fff5fbff8f8
}
Kind = Filename
Act = 0x000111c01320
Type = TY_Object
BaseInput = 0x7fff5fbff8f8 
"/Volumes/newAPFS/bisect/b/tools/clang/test/Driver/Output/openmp-offload.c.tmp1.o"
  }
}
[1] = {
  first = {
first = 0x000111c01320
second = "x86_64-apple-darwin17.0.0-x86_64-host"
  }
  second = {
Data = {
  Filename = 0x7fff5fbff8f8 
"/Volumes/newAPFS/bisect/b/tools/clang/test/Driver/Output/openmp-offload.c.tmp1.o"
  InputArg = 0x7fff5fbff8f8
}
Kind = Filename
Act = 0x000111c01320
Type = TY_Object
BaseInput = 0x7fff5fbff8f8 
"/Volumes/newAPFS/bisect/b/tools/clang/test/Driver/Output/openmp-offload.c.tmp1.o"
  }
}
[2] = {
  first = {
first = 0x000111c01420
second = "nvptx64-nvidia-cuda-host"
  }
  second = {
Data = {
  Filename = 0x7fff5fbff949 
"/Volumes/newAPFS/bisect/b/tools/clang/test/Driver/Output/openmp-offload.c.tmp2.o"
  InputArg = 0x7fff5fbff949
}
Kind = Filename
Act = 0x000111c01420
Type = TY_Object
BaseInput = 0x7fff5fbff949 
"/Volumes/newAPFS/bisect/b/tools/clang/test/Driver/Output/openmp-offload.c.tmp2.o"
  }
}
[3] = {
  first = {
first = 0x000111c017d0
second = "nvptx64-nvidia-cuda-openmp"
  }
  second = {
Data = {
  Filename = 0x000111c048b0 
"/var/folders/sh/cpr85hld32qf79m8x7vd31bwgn/T/openmp-offload-e30496.o"
  InputArg = 0x000111c048b0
}
Kind = Filename
Act = 0x000111c017d0
Type = TY_Object
BaseInput = 0x7fff5fbff8f8 
"/Volumes/newAPFS/bisect/b/tools/clang/test/Driver/Output/openmp-offload.c.tmp1.o"
  }
}
[4] = {
  first = {
first = 0x000111c017d0
second = "x86_64-apple-darwin17.0.0-host"
  }
  second = {
Data = {
  Filename = 0x000111c04830 
"/var/folders/sh/cpr85hld32qf79m8x7vd31bwgn/T/openmp-offload-b856ec.o"
  InputArg = 0x000111c04830
}
Kind = Filename
Act = 0x000111c017d0
Type = TY_Object
BaseInput = 0x7fff5fbff8f8 
"/Volumes/newAPFS/bisect/b/tools/clang/test/Driver/Output/openmp-offload.c.tmp1.o"
  }
}
[5] = {
  first = {
first = 0x000111c01900
second = "nvptx64-nvidia-cuda-openmp"
  }
  second = {
Data = {
  Filename = 0x000111c035d0 
"/var/folders/sh/cpr85hld32qf79m8x7vd31bwgn/T/openmp-offload-be86a1.o"
  InputArg = 0x000111c035d0
}
Kind = Filename
Act = 0x000111c01900
Type = TY_Object
BaseInput = 0x7fff5fbff949 
"/Volumes/newAPFS/bisect/b/tools/clang/test/Driver/Output/openmp-offload.c.tmp2.o"
  }
}
[6] = {
  first = {
first = 0x000111c01900
second = "x86_64-apple-darwin17.0.0-host"
  }
  second = {
Data = {
  Filename = 0x000111c034e0 
"/var/folders/sh/cpr85hld32qf79m8x7vd31bwgn/T/openmp-offload-92791a.o"
  InputArg = 0x000111c034e0
}
Kind = Filename
Act = 0x000111c01900
Type = TY_Object
BaseInput = 0x7fff5fbff949 
"/Volumes/newAPFS/bisect/b/tools/clang/test/Driver/Output/openmp-offload.c.tmp2.o"
  }
}
[7] = {
  first = {
first = 0x000111c01a90
second = "nvptx64-nvidia-cuda-openmp"
  }
  second = {
Data = {
  Filename = 0x000111c03d90 
"/var/folders/sh/cpr85hld32qf79m8x7vd31bwgn/T/openmp-offload-8db204.out"
  InputArg = 0x000111c03d90
}
Kind = Filename
Act = 0x000111c01a90
Type = TY_Image
BaseInput = 0x7fff5fbff8f8 
"/Volumes/newAPFS/bisect/b/tools/clang/test/Driver/Output/openmp-offload.c.tmp1.o"
  }
}
  }

Key:

  (lldb) p ActionTC
  (std::__1::pair, std::__1::allocator > >) $1 = {
first = 0x000111c017d0
second = "x86_64-apple-darwin17.0.0-x86_64-host"
  }


https://reviews.llvm.org/D29654



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

[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

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

If you look at the map then you can see that it contains very similar keys, but 
not the exact one:

  first = {
first = 0x000111c017d0
second = "x86_64-apple-darwin17.0.0-host"
  }
  
  and
  
  first = {
first = 0x000111c01320
second = "x86_64-apple-darwin17.0.0-x86_64-host"
  }


https://reviews.llvm.org/D29654



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


[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

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

The "x86_64-apple-darwin17.0.0-x86_64-host" triple looks suspicious though


https://reviews.llvm.org/D29654



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


[PATCH] D35955: clang-format: Add preprocessor directive indentation

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

In https://reviews.llvm.org/D35955#834914, @djasper wrote:

> Manuel: Can you take a look at the last comment here? Why does PPBranchLevel 
> start at -1?


It's a perhaps too-clever implementation to make sure that we can have a 
per-branch data structure (indexed from 0) , and then making sure that we never 
index out of bounds by never going down to -1 again.
I think if we need this info, we can just make it count down to -1 again (or, 
but that's isomorphic, let it run from 0 and make sure we never index into the 
data structures at 0 :)


https://reviews.llvm.org/D35955



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


[PATCH] D36324: Integrate Kostya's clang-proto-fuzzer with LLVM.

2017-08-08 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse updated this revision to Diff 110215.
morehouse added a comment.

- Formatting and code cleanup.


https://reviews.llvm.org/D36324

Files:
  clang/CMakeLists.txt
  clang/cmake/modules/ProtobufMutator.cmake
  clang/tools/clang-fuzzer/CMakeLists.txt
  clang/tools/clang-fuzzer/ClangFuzzer.cpp
  clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
  clang/tools/clang-fuzzer/cxx_proto.proto
  clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
  clang/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp
  clang/tools/clang-fuzzer/handle-cxx/handle_cxx.h
  clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
  clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
  clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
  clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp

Index: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp
===
--- /dev/null
+++ clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp
@@ -0,0 +1,30 @@
+//==-- proto_to_cxx_main.cpp - Driver for protobuf-C++ conversion --==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements a simple driver to print a C++ program from a protobuf.
+//
+//===--===//
+#include 
+#include 
+#include 
+#include 
+
+#include "proto_to_cxx.h"
+
+int main(int argc, char **argv) {
+  for (int i = 1; i < argc; i++) {
+std::fstream in(argv[i]);
+std::string str((std::istreambuf_iterator(in)),
+std::istreambuf_iterator());
+std::cout << "// " << argv[i] << std::endl;
+std::cout << clang_fuzzer::ProtoToCxx(
+reinterpret_cast(str.data()), str.size());
+  }
+}
+
Index: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
===
--- /dev/null
+++ clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
@@ -0,0 +1,22 @@
+//==-- proto_to_cxx.h - Protobuf-C++ conversion ==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Defines functions for converting between protobufs and C++.
+//
+//===--===//
+
+#include 
+#include 
+#include 
+
+namespace clang_fuzzer {
+class Function;
+std::string FunctionToString(const Function &input);
+std::string ProtoToCxx(const uint8_t *data, size_t size);
+}
Index: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
===
--- /dev/null
+++ clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
@@ -0,0 +1,102 @@
+//==-- proto_to_cxx.cpp - Protobuf-C++ conversion --==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements functions for converting between protobufs and C++.
+//
+//===--===//
+
+#include "proto_to_cxx.h"
+#include "cxx_proto.pb.h"
+
+#include 
+#include 
+
+namespace clang_fuzzer {
+
+// Forward decls.
+std::ostream &operator<<(std::ostream &os, const BinaryOp &x);
+std::ostream &operator<<(std::ostream &os, const StatementSeq &x);
+
+// Proto to C++.
+std::ostream &operator<<(std::ostream &os, const Const &x) {
+  return os << "(" << x.val() << ")";
+}
+std::ostream &operator<<(std::ostream &os, const VarRef &x) {
+  return os << "a[" << (static_cast(x.varnum()) % 100) << "]";
+}
+std::ostream &operator<<(std::ostream &os, const Lvalue &x) {
+  return os << x.varref();
+}
+std::ostream &operator<<(std::ostream &os, const Rvalue &x) {
+if (x.has_varref()) return os << x.varref();
+if (x.has_cons())   return os << x.cons();
+if (x.has_binop())  return os << x.binop();
+return os << "1";
+}
+std::ostream &operator<<(std::ostream &os, const BinaryOp &x) {
+  os << "(" << x.left();
+  switch (x.op()) {
+case BinaryOp::PLUS: os << "+"; break;
+case BinaryOp::MINUS: os << "-"; break;
+case BinaryOp::MUL: os << "*"; break;
+case BinaryOp::DIV: os << "/"; break;
+case BinaryOp::MOD: os << "%"; break;
+case BinaryOp::XOR: os << "^"; break;
+case BinaryOp::AND: os << "&"; break;
+case BinaryOp::OR: os << "|"; break;
+case BinaryOp::EQ: os << "=="; break;
+case BinaryOp::NE: os << "!="; break;
+ca

[PATCH] D36413: Use "foo-12345.o.tmp" instead of "foo.o-12345" as temporary file name.

2017-08-08 Thread Nico Weber via Phabricator via cfe-commits
thakis closed this revision.
thakis added a comment.

r310376, thanks!


https://reviews.llvm.org/D36413



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


r310376 - Use "foo-12345.o.tmp" instead of "foo.o-12345" as temporary file name.

2017-08-08 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Aug  8 09:21:23 2017
New Revision: 310376

URL: http://llvm.org/viewvc/llvm-project?rev=310376&view=rev
Log:
Use "foo-12345.o.tmp" instead of "foo.o-12345" as temporary file name.

This helps some tools that do things based on the output's extension.

For example, we got reports from users on Windows that have a tool that scan a
build output dir (but skip .obj files). The tool would keep the "foo.obj-12345"
file open, and then when clang tried to rename the temp file to the final
output filename, that would fail. By making the tempfile end in ".obj.tmp",
tools like this could now have a rule to ignore .tmp files.
This is a less ambitious reland of https://reviews.llvm.org/D36238

https://reviews.llvm.org/D36413

Modified:
cfe/trunk/lib/Frontend/CompilerInstance.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=310376&r1=310375&r2=310376&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Tue Aug  8 09:21:23 2017
@@ -759,9 +759,15 @@ std::unique_ptr
 
   if (UseTemporary) {
 // Create a temporary file.
-SmallString<128> TempPath;
-TempPath = OutFile;
+// Insert - before the extension (if any), and because some tools
+// (noticeable, clang's own GlobalModuleIndex.cpp) glob for build
+// artifacts, also append .tmp.
+StringRef OutputExtension = llvm::sys::path::extension(OutFile);
+SmallString<128> TempPath =
+StringRef(OutFile).drop_back(OutputExtension.size());
 TempPath += "-";
+TempPath += OutputExtension;
+TempPath += ".tmp";
 int fd;
 std::error_code EC =
 llvm::sys::fs::createUniqueFile(TempPath, fd, TempPath);


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


r310377 - [OPENMP][DEBUG] Set proper address space info if required by target.

2017-08-08 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Aug  8 09:29:11 2017
New Revision: 310377

URL: http://llvm.org/viewvc/llvm-project?rev=310377&view=rev
Log:
[OPENMP][DEBUG] Set proper address space info if required by target.

Arguments, passed to the outlined function, must have correct address
space info for proper Debug info support. Patch sets global address
space for arguments that are mapped and passed by reference.

Also, cuda-gdb does not handle reference types correctly, so reference
arguments are represented as pointers.

Added:
cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/nvptx_target_firstprivate_codegen.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=310377&r1=310376&r2=310377&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Aug  8 09:29:11 2017
@@ -2685,6 +2685,14 @@ def OMPCaptureNoInit : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
+def OMPCaptureKind : Attr {
+  // This attribute has no spellings as it is only ever created implicitly.
+  let Spellings = [];
+  let SemaHandler = 0;
+  let Args = [UnsignedArgument<"CaptureKind">];
+  let Documentation = [Undocumented];
+}
+
 def OMPDeclareSimdDecl : Attr {
   let Spellings = [Pragma<"omp", "declare simd">];
   let Subjects = SubjectList<[Function]>;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=310377&r1=310376&r2=310377&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Aug  8 09:29:11 2017
@@ -8527,6 +8527,11 @@ public:
   /// is performed.
   bool isOpenMPPrivateDecl(ValueDecl *D, unsigned Level);
 
+  /// Sets OpenMP capture kind (OMPC_private, OMPC_firstprivate, OMPC_map etc.)
+  /// for \p FD based on DSA for the provided corresponding captured 
declaration
+  /// \p D.
+  void setOpenMPCaptureKind(FieldDecl *FD, ValueDecl *D, unsigned Level);
+
   /// \brief Check if the specified variable is captured  by 'target' 
directive.
   /// \param Level Relative level of nested OpenMP construct for that the check
   /// is performed.

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=310377&r1=310376&r2=310377&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Tue Aug  8 09:29:11 2017
@@ -1325,6 +1325,32 @@ public:
   virtual void emitDoacrossOrdered(CodeGenFunction &CGF,
const OMPDependClause *C);
 
+  /// Translates the native parameter of outlined function if this is required
+  /// for target.
+  /// \param FD Field decl from captured record for the paramater.
+  /// \param NativeParam Parameter itself.
+  virtual const VarDecl *translateParameter(const FieldDecl *FD,
+const VarDecl *NativeParam) const {
+return NativeParam;
+  }
+
+  typedef llvm::function_ref
+  MappingFnType;
+  /// Maps the native argument to the address of the corresponding
+  /// target-specific argument.
+  /// \param FD Field decl from captured record for the paramater.
+  /// \param NativeParam Parameter itself.
+  /// \param TargetParam Corresponding target-specific parameter.
+  /// \param MapFn Function that maps the native parameter to the address of 
the
+  /// target-specific.
+  virtual void mapParameterAddress(CodeGenFunction &CGF, const FieldDecl *FD,
+   const VarDecl *NativeParam,
+   const VarDecl *TargetParam,
+   const MappingFnType) const {
+assert(NativeParam == TargetParam &&
+   "native and target args must be the same");
+  }
+
   /// Emits call of the outlined function with the provided arguments,
   /// translating these arguments to correct target-specific arguments.
   virtual void

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=310377&r1=310376&r2=310377&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/

[PATCH] D36473: Fix broken getAttributeSpellingListIndex for pragma attributes

2017-08-08 Thread Mike Rice via Phabricator via cfe-commits
mikerice created this revision.

We noticed when implementing a new pragma that the TableGen-generated function 
getAttributeSpellingListIndex() did not work for pragma attributes.  It relies 
on the values in the enum AttributeList::Syntax and a new value 
AS_ContextSensitiveKeyword was added changing the value for AS_Pragma.  
Apparently no tests failed since no pragmas currently make use of the generated 
function.

To fix this we can move AS_Pragma back to the value that TableGen code expects. 
 Also to prevent changes in the enum from breaking that routine again I added 
calls to getAttributeSpellingListIndex() in the unroll pragma code.  That will 
cause some lit test failures if the order is changed.  I added a comment to 
remind of this issue in the future.

This assumes we don’t need/want full TableGen support for 
AS_ContextSensitiveKeyword.  It currently only appears in getAttrKind and no 
other TableGen-generated routines.


https://reviews.llvm.org/D36473

Files:
  include/clang/Sema/AttributeList.h
  lib/Sema/SemaStmtAttr.cpp


Index: lib/Sema/SemaStmtAttr.cpp
===
--- lib/Sema/SemaStmtAttr.cpp
+++ lib/Sema/SemaStmtAttr.cpp
@@ -100,16 +100,15 @@
 return nullptr;
   }
 
-  LoopHintAttr::Spelling Spelling;
+  LoopHintAttr::Spelling Spelling =
+  LoopHintAttr::Spelling(A.getAttributeSpellingListIndex());
   LoopHintAttr::OptionType Option;
   LoopHintAttr::LoopHintState State;
   if (PragmaNoUnroll) {
 // #pragma nounroll
-Spelling = LoopHintAttr::Pragma_nounroll;
 Option = LoopHintAttr::Unroll;
 State = LoopHintAttr::Disable;
   } else if (PragmaUnroll) {
-Spelling = LoopHintAttr::Pragma_unroll;
 if (ValueExpr) {
   // #pragma unroll N
   Option = LoopHintAttr::UnrollCount;
@@ -121,7 +120,6 @@
 }
   } else {
 // #pragma clang loop ...
-Spelling = LoopHintAttr::Pragma_clang_loop;
 assert(OptionLoc && OptionLoc->Ident &&
"Attribute must have valid option info.");
 Option = llvm::StringSwitch(
Index: include/clang/Sema/AttributeList.h
===
--- include/clang/Sema/AttributeList.h
+++ include/clang/Sema/AttributeList.h
@@ -106,10 +106,12 @@
 AS_Microsoft,
 /// __ptr16, alignas(...), etc.
 AS_Keyword,
-/// Context-sensitive version of a keyword attribute.
-AS_ContextSensitiveKeyword,
 /// #pragma ...
 AS_Pragma,
+// Note TableGen depends on the order above.  Do not add or change the 
order
+// without adding related code to TableGen/ClangAttrEmitter.cpp.
+/// Context-sensitive version of a keyword attribute.
+AS_ContextSensitiveKeyword,
   };
 
 private:


Index: lib/Sema/SemaStmtAttr.cpp
===
--- lib/Sema/SemaStmtAttr.cpp
+++ lib/Sema/SemaStmtAttr.cpp
@@ -100,16 +100,15 @@
 return nullptr;
   }
 
-  LoopHintAttr::Spelling Spelling;
+  LoopHintAttr::Spelling Spelling =
+  LoopHintAttr::Spelling(A.getAttributeSpellingListIndex());
   LoopHintAttr::OptionType Option;
   LoopHintAttr::LoopHintState State;
   if (PragmaNoUnroll) {
 // #pragma nounroll
-Spelling = LoopHintAttr::Pragma_nounroll;
 Option = LoopHintAttr::Unroll;
 State = LoopHintAttr::Disable;
   } else if (PragmaUnroll) {
-Spelling = LoopHintAttr::Pragma_unroll;
 if (ValueExpr) {
   // #pragma unroll N
   Option = LoopHintAttr::UnrollCount;
@@ -121,7 +120,6 @@
 }
   } else {
 // #pragma clang loop ...
-Spelling = LoopHintAttr::Pragma_clang_loop;
 assert(OptionLoc && OptionLoc->Ident &&
"Attribute must have valid option info.");
 Option = llvm::StringSwitch(
Index: include/clang/Sema/AttributeList.h
===
--- include/clang/Sema/AttributeList.h
+++ include/clang/Sema/AttributeList.h
@@ -106,10 +106,12 @@
 AS_Microsoft,
 /// __ptr16, alignas(...), etc.
 AS_Keyword,
-/// Context-sensitive version of a keyword attribute.
-AS_ContextSensitiveKeyword,
 /// #pragma ...
 AS_Pragma,
+// Note TableGen depends on the order above.  Do not add or change the order
+// without adding related code to TableGen/ClangAttrEmitter.cpp.
+/// Context-sensitive version of a keyword attribute.
+AS_ContextSensitiveKeyword,
   };
 
 private:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36471: [StaticAnalyzer] Try to calculate arithmetic result when operand has a range of possible values

2017-08-08 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki updated this revision to Diff 110220.
danielmarjamaki added a comment.

A minor code cleanup. No functional change.


Repository:
  rL LLVM

https://reviews.llvm.org/D36471

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  test/Analysis/eval-range.c

Index: test/Analysis/eval-range.c
===
--- test/Analysis/eval-range.c
+++ test/Analysis/eval-range.c
@@ -0,0 +1,18 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
+
+void clang_analyzer_eval(int);
+
+void test1(int a) {
+  if (a >= 10 && a <= 50) {
+int b;
+
+b = a + 2;
+clang_analyzer_eval(b >= 12 && b <= 52); // expected-warning{{TRUE}}
+
+b = a - 2;
+clang_analyzer_eval(b >= 8 && b <= 48); // expected-warning{{TRUE}}
+
+b = a / 2;
+clang_analyzer_eval(b >= 5 && b <= 25); // expected-warning{{TRUE}}
+  }
+}
Index: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -304,6 +304,8 @@
   void print(ProgramStateRef State, raw_ostream &Out, const char *nl,
  const char *sep) override;
 
+  ProgramStateRef evalRangeOp(ProgramStateRef state, SVal V) override;
+
   //===--===//
   // Implementation for interface from RangedConstraintManager.
   //===--===//
@@ -741,3 +743,65 @@
   }
   Out << nl;
 }
+
+ProgramStateRef RangeConstraintManager::evalRangeOp(ProgramStateRef St,
+SVal V) {
+  const SymExpr *SE = V.getAsSymExpr();
+  if (!SE)
+return nullptr;
+
+  const SymIntExpr *SIE = dyn_cast(SE);
+  if (!SIE)
+return nullptr;
+
+  const clang::BinaryOperatorKind Opc = SIE->getOpcode();
+
+  if (Opc != BO_Add && Opc != BO_Sub && Opc != BO_Div)
+return nullptr;
+
+  const SymExpr *LHS = SIE->getLHS();
+  const llvm::APSInt &RHS = SIE->getRHS();
+
+  if (RHS.isNegative())
+// TODO: Handle negative values.
+return nullptr;
+
+  ConstraintRangeTy Ranges = St->get();
+  for (ConstraintRangeTy::iterator I = Ranges.begin(), E = Ranges.end(); I != E;
+   ++I) {
+if (LHS == I.getKey()) {
+  const auto D = I.getData();
+  for (auto I = D.begin(); I != D.end(); ++I) {
+if (I->From().isUnsigned() != RHS.isUnsigned())
+  // TODO: Handle sign conversions.
+  return nullptr;
+if (I->From().getBitWidth() != RHS.getBitWidth())
+  // TODO: Promote values.
+  return nullptr;
+if (I->From().isNegative())
+  // TODO: Handle negative range values
+  return nullptr;
+llvm::APSInt Lower;
+llvm::APSInt Upper;
+if (Opc == BO_Add) {
+  Lower = I->From() + RHS;
+  Upper = I->To() + RHS;
+} else if (Opc == BO_Sub) {
+  if (RHS > I->From())
+return nullptr;
+  Lower = I->From() - RHS;
+  Upper = I->To() - RHS;
+} else if (Opc == BO_Div) {
+  Lower = I->From() / RHS;
+  Upper = I->To() / RHS;
+}
+SymbolRef Sym = V.getAsSymbol();
+RangeSet RS =
+getRange(St, Sym).Intersect(getBasicVals(), F, Lower, Upper);
+// TODO: This only evaluates the first range. Evaluate all ranges.
+return RS.isEmpty() ? nullptr : St->set(Sym, RS);
+  }
+}
+  }
+  return nullptr;
+}
Index: lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -98,7 +98,9 @@
   }
 
   state = state->BindExpr(B, LCtx, Result);
-  Bldr.generateNode(B, *it, state);
+  ProgramStateRef state2 =
+  getConstraintManager().evalRangeOp(state, Result);
+  Bldr.generateNode(B, *it, state2 ? state2 : state);
   continue;
 }
 
Index: include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
@@ -142,13 +142,15 @@
   /// Scan all symbols referenced by the constraints. If the symbol is not
   /// alive, remove it.
   virtual ProgramStateRef removeDeadBindings(ProgramStateRef state,
- SymbolReaper& SymReaper) = 0;
+ SymbolReaper &SymReaper) = 0;
 
-  virtual void print(ProgramStateRef state,
- raw_ostream &Out,
- const char* nl,
+  vir

[PATCH] D36471: [StaticAnalyzer] Try to calculate arithmetic result when operand has a range of possible values

2017-08-08 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added a comment.

In https://reviews.llvm.org/D36471#835410, @xazax.hun wrote:

> Can't you reuse somehow some machinery already available to evaluate the 
> arithmetic operators? Those should already handle most of your TODOs and 
> overflows.


Sounds good.. I have not seen that machinery.. I will look around.

To me it seems it would be nice if this machinery was builtin in APSInt so I 
could calculate (x+y) even if x and y did not have the same signedness and that 
the result would be unsigned.


Repository:
  rL LLVM

https://reviews.llvm.org/D36471



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


[PATCH] D36407: [Sema] Extend -Wenum-compare to handle mixed enum comparisons in switch statements

2017-08-08 Thread Reka Kovacs via Phabricator via cfe-commits
rnkovacs updated this revision to Diff 110219.
rnkovacs marked 2 inline comments as done.
rnkovacs added a comment.

Uploaded the full diff and addressed comments. Added `const` qualifiers to 
`GetTypeBeforeIntegralPromotion()` function.


https://reviews.llvm.org/D36407

Files:
  lib/Sema/SemaStmt.cpp
  test/Sema/switch.c
  test/SemaCXX/warn-enum-compare.cpp


Index: test/SemaCXX/warn-enum-compare.cpp
===
--- test/SemaCXX/warn-enum-compare.cpp
+++ test/SemaCXX/warn-enum-compare.cpp
@@ -209,4 +209,21 @@
   while (getBar() > x); // expected-warning  {{comparison of two values with 
different enumeration types ('Bar' and 'Foo')}}
   while (getBar() < x); // expected-warning  {{comparison of two values with 
different enumeration types ('Bar' and 'Foo')}}
 
+  switch (a) {
+case name1::F1: break;
+case name1::F3: break;
+case name2::B2: break; // expected-warning {{comparison of two values with 
different enumeration types ('name1::Foo' and 'name2::Baz')}}
+  }
+
+  switch (x) {
+case FooB: break;
+case FooC: break;
+case BarD: break; // expected-warning {{comparison of two values with 
different enumeration types ('Foo' and 'Bar')}}
+  }
+
+  switch(getBar()) {
+case BarE: break;
+case BarF: break;
+case FooA: break; // expected-warning {{comparison of two values with 
different enumeration types ('Bar' and 'Foo')}}
+  }
 }
Index: test/Sema/switch.c
===
--- test/Sema/switch.c
+++ test/Sema/switch.c
@@ -372,6 +372,7 @@
   case EE1_b: break;
   case EE1_c: break; // no-warning
   case EE1_d: break; // expected-warning {{case value not in enumerated type 
'enum ExtendedEnum1'}}
+  // expected-warning@-1 {{comparison of two values with different enumeration 
types ('enum ExtendedEnum1' and 'const enum ExtendedEnum1_unrelated')}}
   }
 }
 
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -602,10 +602,10 @@
 
 /// GetTypeBeforeIntegralPromotion - Returns the pre-promotion type of
 /// potentially integral-promoted expression @p expr.
-static QualType GetTypeBeforeIntegralPromotion(Expr *&expr) {
-  if (ExprWithCleanups *cleanups = dyn_cast(expr))
+static QualType GetTypeBeforeIntegralPromotion(const Expr *&expr) {
+  if (const auto *cleanups = dyn_cast(expr))
 expr = cleanups->getSubExpr();
-  while (ImplicitCastExpr *impcast = dyn_cast(expr)) {
+  while (const auto *impcast = dyn_cast(expr)) {
 if (impcast->getCastKind() != CK_IntegralCast) break;
 expr = impcast->getSubExpr();
   }
@@ -743,6 +743,24 @@
   return true;
 }
 
+static void checkEnumTypesInSwitchStmt(Sema &S, const Expr *Cond,
+   const Expr *Case) {
+  QualType CondType = GetTypeBeforeIntegralPromotion(Cond);
+  QualType CaseType = Case->getType();
+
+  const EnumType *CondEnumType = CondType->getAs();
+  const EnumType *CaseEnumType = CaseType->getAs();
+  if (!CondEnumType || !CaseEnumType)
+return;
+
+  if (S.Context.hasSameUnqualifiedType(CondType, CaseType))
+return;
+
+  S.Diag(Case->getExprLoc(), diag::warn_comparison_of_mixed_enum_types)
+  << CondType << CaseType << Cond->getSourceRange()
+  << Case->getSourceRange();
+}
+
 StmtResult
 Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch,
 Stmt *BodyStmt) {
@@ -760,7 +778,7 @@
 
   QualType CondType = CondExpr->getType();
 
-  Expr *CondExprBeforePromotion = CondExpr;
+  const Expr *CondExprBeforePromotion = CondExpr;
   QualType CondTypeBeforePromotion =
   GetTypeBeforeIntegralPromotion(CondExprBeforePromotion);
 
@@ -843,6 +861,8 @@
 break;
   }
 
+  checkEnumTypesInSwitchStmt(*this, CondExpr, Lo);
+
   llvm::APSInt LoVal;
 
   if (getLangOpts().CPlusPlus11) {


Index: test/SemaCXX/warn-enum-compare.cpp
===
--- test/SemaCXX/warn-enum-compare.cpp
+++ test/SemaCXX/warn-enum-compare.cpp
@@ -209,4 +209,21 @@
   while (getBar() > x); // expected-warning  {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
   while (getBar() < x); // expected-warning  {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
 
+  switch (a) {
+case name1::F1: break;
+case name1::F3: break;
+case name2::B2: break; // expected-warning {{comparison of two values with different enumeration types ('name1::Foo' and 'name2::Baz')}}
+  }
+
+  switch (x) {
+case FooB: break;
+case FooC: break;
+case BarD: break; // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+  }
+
+  switch(getBar()) {
+case BarE: break;
+case BarF: break;
+case FooA: break; // expected-warning {{comparison of two values with different enumeration types ('Bar

r310379 - Revert "[OPENMP][DEBUG] Set proper address space info if required by target."

2017-08-08 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Aug  8 09:45:36 2017
New Revision: 310379

URL: http://llvm.org/viewvc/llvm-project?rev=310379&view=rev
Log:
Revert "[OPENMP][DEBUG] Set proper address space info if required by target."

This reverts commit r310377.

Removed:
cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/nvptx_target_firstprivate_codegen.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=310379&r1=310378&r2=310379&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Aug  8 09:45:36 2017
@@ -2685,14 +2685,6 @@ def OMPCaptureNoInit : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
-def OMPCaptureKind : Attr {
-  // This attribute has no spellings as it is only ever created implicitly.
-  let Spellings = [];
-  let SemaHandler = 0;
-  let Args = [UnsignedArgument<"CaptureKind">];
-  let Documentation = [Undocumented];
-}
-
 def OMPDeclareSimdDecl : Attr {
   let Spellings = [Pragma<"omp", "declare simd">];
   let Subjects = SubjectList<[Function]>;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=310379&r1=310378&r2=310379&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Aug  8 09:45:36 2017
@@ -8527,11 +8527,6 @@ public:
   /// is performed.
   bool isOpenMPPrivateDecl(ValueDecl *D, unsigned Level);
 
-  /// Sets OpenMP capture kind (OMPC_private, OMPC_firstprivate, OMPC_map etc.)
-  /// for \p FD based on DSA for the provided corresponding captured 
declaration
-  /// \p D.
-  void setOpenMPCaptureKind(FieldDecl *FD, ValueDecl *D, unsigned Level);
-
   /// \brief Check if the specified variable is captured  by 'target' 
directive.
   /// \param Level Relative level of nested OpenMP construct for that the check
   /// is performed.

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=310379&r1=310378&r2=310379&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Tue Aug  8 09:45:36 2017
@@ -1325,32 +1325,6 @@ public:
   virtual void emitDoacrossOrdered(CodeGenFunction &CGF,
const OMPDependClause *C);
 
-  /// Translates the native parameter of outlined function if this is required
-  /// for target.
-  /// \param FD Field decl from captured record for the paramater.
-  /// \param NativeParam Parameter itself.
-  virtual const VarDecl *translateParameter(const FieldDecl *FD,
-const VarDecl *NativeParam) const {
-return NativeParam;
-  }
-
-  typedef llvm::function_ref
-  MappingFnType;
-  /// Maps the native argument to the address of the corresponding
-  /// target-specific argument.
-  /// \param FD Field decl from captured record for the paramater.
-  /// \param NativeParam Parameter itself.
-  /// \param TargetParam Corresponding target-specific parameter.
-  /// \param MapFn Function that maps the native parameter to the address of 
the
-  /// target-specific.
-  virtual void mapParameterAddress(CodeGenFunction &CGF, const FieldDecl *FD,
-   const VarDecl *NativeParam,
-   const VarDecl *TargetParam,
-   const MappingFnType) const {
-assert(NativeParam == TargetParam &&
-   "native and target args must be the same");
-  }
-
   /// Emits call of the outlined function with the provided arguments,
   /// translating these arguments to correct target-specific arguments.
   virtual void

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=310379&r1=310378&r2=310379&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Tue Aug  8 09:45:36 2017
@@ -2238,81 +2238,3 @@ void CGOpenMPRuntimeNVPTX::emitReduction
   CGF.EmitBranch(DefaultBB);
   CGF.EmitBlock(DefaultBB, /*IsFinished=*/true);
 }
-
-const VarDecl *
-CGOpenMPRuntimeNVPTX::translatePara

[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

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

In https://reviews.llvm.org/D29654#835429, @arphaman wrote:

> The "x86_64-apple-darwin17.0.0-x86_64-host" triple looks suspicious though


It looks like the triple is in the list though:

second = "x86_64-apple-darwin17.0.0-x86_64-host

it is entry [1].


https://reviews.llvm.org/D29654



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


[PATCH] D36324: Integrate Kostya's clang-proto-fuzzer with LLVM.

2017-08-08 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc added a comment.

In https://reviews.llvm.org/D36324#835415, @morehouse wrote:

> In https://reviews.llvm.org/D36324#834660, @kcc wrote:
>
> > Why do we need LLVM_ENABLE_RTTI=ON here?
>
>
> Attempting to build without it yields all kinds of protobuf errors.  For 
> example:
>  F4944099: image.png 


This is very strange, I'd like to understand more about this LLVM_ENABLE_RTTI. 
ideally, we should avoid it.


https://reviews.llvm.org/D36324



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


[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

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

Is that the last access to CachedResults before the error?


https://reviews.llvm.org/D29654



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


[PATCH] D36423: [libc++] Introsort based sorting function

2017-08-08 Thread DIVYA SHANMUGHAN via Phabricator via cfe-commits
DIVYA added a comment.

benchmarks/algorithms.bench.cpp Results

With old code (in ns)

BM_sort_std_common>/16384  : 730752

BM_sort_std_common>/32768  :  1.58E+06 

BM_sort_std_ascending>/16384:17160.5   

BM_sort_std_ascending>/32768 :   35350.1   

BM_sort_std_descending>/16384  : 35809 

BM_sort_std_descending>/32768  : 72133 

BM_sort_std_list_with_vector>/16384  : 124250

BM_sort_std_list_with_vector>/32768  : 247705

BM_sort_std_worst_quick>/16384   :   1.03E+07  

BM_sort_std_worst_quick>/32768:  4.04E+07

With new code (in ns)

BM_sort_std_common>/16384  :  
720510   
BM_sort_std_common>/32768:   
1.55E+06  
BM_sort_std_ascending>/16384: 
17164.9  
BM_sort_std_ascending>/32768: 
34726.7  
BM_sort_std_descending>/16384   :  
35671   
BM_sort_std_descending>/32768 :   
72100.7  
BM_sort_std_list_with_vector>/16384   : 
125816   
BM_sort_std_list_with_vector>/32768  :   
247450  
BM_sort_std_worst_quick>/16384  :
987016
BM_sort_std_worst_quick>/32768:  
2.14E+06


https://reviews.llvm.org/D36423



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


[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

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

In https://reviews.llvm.org/D29654#835501, @gtbercea wrote:

> Is that the last access to CachedResults before the error?


Is the assertion the last access? Yes.

There must be a discrepancy between

`UI.DependentBoundArch` in the loop above and `BoundArch` that's used to 
compute `TargetTC`, otherwise `GetTriplePlusArchString` would return the key 
that matches the `0x000111c017d0` pointer, i.e. without the additional 
x86_64.


https://reviews.llvm.org/D29654



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


[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

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

In https://reviews.llvm.org/D29654#835507, @arphaman wrote:

> In https://reviews.llvm.org/D29654#835501, @gtbercea wrote:
>
> > Is that the last access to CachedResults before the error?
>
>
> Is the assertion the last access? Yes.
>
> There must be a discrepancy between
>
> `UI.DependentBoundArch` in the loop above and `BoundArch` that's used to 
> compute `TargetTC`, otherwise `GetTriplePlusArchString` would return the key 
> that matches the `0x000111c017d0` pointer, i.e. without the additional 
> x86_64.


Maybe I misunderstood the output you pasted but it looks like ActionTC contains 
the same triple+arch that you can find in entry [1] in the map.


https://reviews.llvm.org/D29654



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


r310382 - [Availability] Don't make an availability attribute imply default visibility on macOS

2017-08-08 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Tue Aug  8 10:09:09 2017
New Revision: 310382

URL: http://llvm.org/viewvc/llvm-project?rev=310382&view=rev
Log:
[Availability] Don't make an availability attribute imply default visibility on 
macOS

Fixes PR33796, rdar://33655115

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

Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/test/CodeGen/attr-availability.c

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=310382&r1=310381&r2=310382&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Tue Aug  8 10:09:09 2017
@@ -94,6 +94,9 @@ Clang now supports the ...
 Attribute Changes in Clang
 --
 
+- The presence of __attribute__((availability(...))) on a declaration no longer
+  implies default visibility for that declaration on macOS.
+
 - ...
 
 Windows Support

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=310382&r1=310381&r2=310382&view=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Aug  8 10:09:09 2017
@@ -216,14 +216,6 @@ static Optional getVisibilit
 return getVisibilityFromAttr(A);
   }
 
-  // If we're on Mac OS X, an 'availability' for Mac OS X attribute
-  // implies visibility(default).
-  if (D->getASTContext().getTargetInfo().getTriple().isOSDarwin()) {
-for (const auto *A : D->specific_attrs())
-  if (A->getPlatform()->getName().equals("macos"))
-return DefaultVisibility;
-  }
-
   return None;
 }
 

Modified: cfe/trunk/test/CodeGen/attr-availability.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-availability.c?rev=310382&r1=310381&r2=310382&view=diff
==
--- cfe/trunk/test/CodeGen/attr-availability.c (original)
+++ cfe/trunk/test/CodeGen/attr-availability.c Tue Aug  8 10:09:09 2017
@@ -8,9 +8,9 @@
 void f2();
 void f2() { }
 
-// CHECK-10_4-LABEL: define void @f3
-// CHECK-10_5-LABEL: define void @f3
-// CHECK-10_6-LABEL: define void @f3
+// CHECK-10_4-LABEL: define hidden void @f3
+// CHECK-10_5-LABEL: define hidden void @f3
+// CHECK-10_6-LABEL: define hidden void @f3
 void f3() __attribute__((availability(macosx,introduced=10.5)));
 void f3() { }
 


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


[PATCH] D36324: Integrate Kostya's clang-proto-fuzzer with LLVM.

2017-08-08 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse updated this revision to Diff 110222.
morehouse added a comment.

- Define GOOGLE_PROTOBUF_NO_RTTI to remove RTTI requirement.


https://reviews.llvm.org/D36324

Files:
  clang/CMakeLists.txt
  clang/cmake/modules/ProtobufMutator.cmake
  clang/tools/clang-fuzzer/CMakeLists.txt
  clang/tools/clang-fuzzer/ClangFuzzer.cpp
  clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
  clang/tools/clang-fuzzer/cxx_proto.proto
  clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
  clang/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp
  clang/tools/clang-fuzzer/handle-cxx/handle_cxx.h
  clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
  clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
  clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
  clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp

Index: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp
===
--- /dev/null
+++ clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp
@@ -0,0 +1,30 @@
+//==-- proto_to_cxx_main.cpp - Driver for protobuf-C++ conversion --==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements a simple driver to print a C++ program from a protobuf.
+//
+//===--===//
+#include 
+#include 
+#include 
+#include 
+
+#include "proto_to_cxx.h"
+
+int main(int argc, char **argv) {
+  for (int i = 1; i < argc; i++) {
+std::fstream in(argv[i]);
+std::string str((std::istreambuf_iterator(in)),
+std::istreambuf_iterator());
+std::cout << "// " << argv[i] << std::endl;
+std::cout << clang_fuzzer::ProtoToCxx(
+reinterpret_cast(str.data()), str.size());
+  }
+}
+
Index: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
===
--- /dev/null
+++ clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
@@ -0,0 +1,22 @@
+//==-- proto_to_cxx.h - Protobuf-C++ conversion ==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Defines functions for converting between protobufs and C++.
+//
+//===--===//
+
+#include 
+#include 
+#include 
+
+namespace clang_fuzzer {
+class Function;
+std::string FunctionToString(const Function &input);
+std::string ProtoToCxx(const uint8_t *data, size_t size);
+}
Index: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
===
--- /dev/null
+++ clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
@@ -0,0 +1,102 @@
+//==-- proto_to_cxx.cpp - Protobuf-C++ conversion --==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements functions for converting between protobufs and C++.
+//
+//===--===//
+
+#include "proto_to_cxx.h"
+#include "cxx_proto.pb.h"
+
+#include 
+#include 
+
+namespace clang_fuzzer {
+
+// Forward decls.
+std::ostream &operator<<(std::ostream &os, const BinaryOp &x);
+std::ostream &operator<<(std::ostream &os, const StatementSeq &x);
+
+// Proto to C++.
+std::ostream &operator<<(std::ostream &os, const Const &x) {
+  return os << "(" << x.val() << ")";
+}
+std::ostream &operator<<(std::ostream &os, const VarRef &x) {
+  return os << "a[" << (static_cast(x.varnum()) % 100) << "]";
+}
+std::ostream &operator<<(std::ostream &os, const Lvalue &x) {
+  return os << x.varref();
+}
+std::ostream &operator<<(std::ostream &os, const Rvalue &x) {
+if (x.has_varref()) return os << x.varref();
+if (x.has_cons())   return os << x.cons();
+if (x.has_binop())  return os << x.binop();
+return os << "1";
+}
+std::ostream &operator<<(std::ostream &os, const BinaryOp &x) {
+  os << "(" << x.left();
+  switch (x.op()) {
+case BinaryOp::PLUS: os << "+"; break;
+case BinaryOp::MINUS: os << "-"; break;
+case BinaryOp::MUL: os << "*"; break;
+case BinaryOp::DIV: os << "/"; break;
+case BinaryOp::MOD: os << "%"; break;
+case BinaryOp::XOR: os << "^"; break;
+case BinaryOp::AND: os << "&"; break;
+case BinaryOp::OR: os << "|"; break;
+case BinaryOp::EQ: os << "=="; break;
+case BinaryOp::

[PATCH] D36191: [CodeGen] Don't make availability attributes imply default visibility on macos

2017-08-08 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310382: [Availability] Don't make an availability attribute 
imply default visibility on… (authored by epilk).

Changed prior to commit:
  https://reviews.llvm.org/D36191?vs=109218&id=110223#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36191

Files:
  cfe/trunk/docs/ReleaseNotes.rst
  cfe/trunk/lib/AST/Decl.cpp
  cfe/trunk/test/CodeGen/attr-availability.c


Index: cfe/trunk/test/CodeGen/attr-availability.c
===
--- cfe/trunk/test/CodeGen/attr-availability.c
+++ cfe/trunk/test/CodeGen/attr-availability.c
@@ -8,9 +8,9 @@
 void f2();
 void f2() { }
 
-// CHECK-10_4-LABEL: define void @f3
-// CHECK-10_5-LABEL: define void @f3
-// CHECK-10_6-LABEL: define void @f3
+// CHECK-10_4-LABEL: define hidden void @f3
+// CHECK-10_5-LABEL: define hidden void @f3
+// CHECK-10_6-LABEL: define hidden void @f3
 void f3() __attribute__((availability(macosx,introduced=10.5)));
 void f3() { }
 
Index: cfe/trunk/lib/AST/Decl.cpp
===
--- cfe/trunk/lib/AST/Decl.cpp
+++ cfe/trunk/lib/AST/Decl.cpp
@@ -216,14 +216,6 @@
 return getVisibilityFromAttr(A);
   }
 
-  // If we're on Mac OS X, an 'availability' for Mac OS X attribute
-  // implies visibility(default).
-  if (D->getASTContext().getTargetInfo().getTriple().isOSDarwin()) {
-for (const auto *A : D->specific_attrs())
-  if (A->getPlatform()->getName().equals("macos"))
-return DefaultVisibility;
-  }
-
   return None;
 }
 
Index: cfe/trunk/docs/ReleaseNotes.rst
===
--- cfe/trunk/docs/ReleaseNotes.rst
+++ cfe/trunk/docs/ReleaseNotes.rst
@@ -94,6 +94,9 @@
 Attribute Changes in Clang
 --
 
+- The presence of __attribute__((availability(...))) on a declaration no longer
+  implies default visibility for that declaration on macOS.
+
 - ...
 
 Windows Support


Index: cfe/trunk/test/CodeGen/attr-availability.c
===
--- cfe/trunk/test/CodeGen/attr-availability.c
+++ cfe/trunk/test/CodeGen/attr-availability.c
@@ -8,9 +8,9 @@
 void f2();
 void f2() { }
 
-// CHECK-10_4-LABEL: define void @f3
-// CHECK-10_5-LABEL: define void @f3
-// CHECK-10_6-LABEL: define void @f3
+// CHECK-10_4-LABEL: define hidden void @f3
+// CHECK-10_5-LABEL: define hidden void @f3
+// CHECK-10_6-LABEL: define hidden void @f3
 void f3() __attribute__((availability(macosx,introduced=10.5)));
 void f3() { }
 
Index: cfe/trunk/lib/AST/Decl.cpp
===
--- cfe/trunk/lib/AST/Decl.cpp
+++ cfe/trunk/lib/AST/Decl.cpp
@@ -216,14 +216,6 @@
 return getVisibilityFromAttr(A);
   }
 
-  // If we're on Mac OS X, an 'availability' for Mac OS X attribute
-  // implies visibility(default).
-  if (D->getASTContext().getTargetInfo().getTriple().isOSDarwin()) {
-for (const auto *A : D->specific_attrs())
-  if (A->getPlatform()->getName().equals("macos"))
-return DefaultVisibility;
-  }
-
   return None;
 }
 
Index: cfe/trunk/docs/ReleaseNotes.rst
===
--- cfe/trunk/docs/ReleaseNotes.rst
+++ cfe/trunk/docs/ReleaseNotes.rst
@@ -94,6 +94,9 @@
 Attribute Changes in Clang
 --
 
+- The presence of __attribute__((availability(...))) on a declaration no longer
+  implies default visibility for that declaration on macOS.
+
 - ...
 
 Windows Support
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36437: [clang] Get rid of "%T" expansions

2017-08-08 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.

Thanks, most of these looks like potential races between tests waiting to 
happen.


Repository:
  rL LLVM

https://reviews.llvm.org/D36437



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


[PATCH] D35056: GCC ABI incompatibility when passing object with trivial copy ctor, trivial dtor, and non-trivial move ctor

2017-08-08 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D35056#834705, @rnk wrote:

> In https://reviews.llvm.org/D35056#834689, @rsmith wrote:
>
> > I also removed some incorrect assumptions from the Win64 ABI code; this 
> > changed the behavior of one testcase from uncopyable-args.cpp 
> > (`implicitly_deleted_copy_ctor::A` is now passed indirect).
>
>
> That's probably not correct, let me take a look... I remember breaking the 
> rules for small types here.


Nevermind, everything looks good there. Thanks for untangling the mess. I only 
have comments on comments.




Comment at: include/clang/AST/DeclCXX.h:420
 
+/// \brief True if this class has at least one non-deleted copy or move
+/// constructor. That would allow passing it by registers.

Isn't this "... at least one *trivial*, non-deleted copy or move 
constructor..."?



Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:836
 
-// If this is true, the implicit copy constructor that Sema would have
-// created would not be deleted. FIXME: We should provide a more direct way
-// for CodeGen to ask whether the constructor was deleted.
-if (!RD->hasUserDeclaredCopyConstructor() &&
-!RD->hasUserDeclaredMoveConstructor() &&
-!RD->needsOverloadResolutionForMoveConstructor() &&
-!RD->hasUserDeclaredMoveAssignment() &&
-!RD->needsOverloadResolutionForMoveAssignment())
-  return RAA_Default;
-
-// Otherwise, Sema should have created an implicit copy constructor if
-// needed.
-assert(!RD->needsImplicitCopyConstructor());
-
-// We have to make sure the trivial copy constructor isn't deleted.
-for (const CXXConstructorDecl *CD : RD->ctors()) {
-  if (CD->isCopyConstructor()) {
-assert(CD->isTrivial());
-// We had at least one undeleted trivial copy ctor.  Return directly.
-if (!CD->isDeleted())
-  return RAA_Default;
+// Win64 passes objects with non-deleted, non-trivial copy ctors 
indirectly.
+//

This doesn't seem to match what we've computing, and it doesn't seem quite 
right. MSVC will pass a class with deleted, trivial copy ctors indirectly. 
Would it be correct to rephrase like this?
"If RD has at least one trivial, non-deleted copy constructor, it is passed 
directly. Otherwise, it is passed indirectly."



Comment at: test/CodeGenCXX/uncopyable-args.cpp:101
+
+// In MSVC 2013, the copy ctor is not deleted by a move assignment. In MSVC 
2015, it is.
+// WIN64-18-LABEL: declare void @"\01?foo@implicitly_deleted@@YAXUA@1@@Z"(i64

Oh dear. :(


Repository:
  rL LLVM

https://reviews.llvm.org/D35056



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


[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

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

No, entry 1 has a different pointer (0x000111c01320 vs 0x000111c017d0).

Why is there a `DependentBoundArch` if it's always empty?


https://reviews.llvm.org/D29654



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


[PATCH] D36411: Restore previous structure ABI for bitfields with 'packed' attribute for PS4 targets

2017-08-08 Thread Matthew Voss via Phabricator via cfe-commits
ormris added a comment.

Great. Thanks for the review! I don't have commit access currently.


https://reviews.llvm.org/D36411



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


[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

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

In https://reviews.llvm.org/D29654#835392, @gtbercea wrote:

> In https://reviews.llvm.org/D29654#835371, @arphaman wrote:
>
> > The last RUN line in the new commit triggers the same assertion failure:
>


...

> Hi Alex, I'm not sure why it's failing as I can't reproduce the error 
> locally. Do you have access to a machine with the configuration the test uses?

Can you reproduce if you specifically force the host target to 
x86_64-apple-darwin17.0.0 (e.g., you pass -target x86_64-apple-darwin17.0.0)?


https://reviews.llvm.org/D29654



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


[PATCH] D36475: [analyzer] Add "create_sink" annotation support to MagentaHandleChecker

2017-08-08 Thread Haowei Wu via Phabricator via cfe-commits
haowei created this revision.
Herald added a subscriber: xazax.hun.

This patch adds "mx_create_sink" annotation support to MagentaHandleChecker to 
address the false positives found in Magenta unit tests. After this patch, when 
a call to a function contains this annotation, MagentaHandleChecker will create 
a sink node which will suppress the handle leaks warnings if the leak is 
post-dominated by this function (similar to a noreturn function).

The target problem it tries to solve can be illustrated in following example:

  static bool handle_info_test(void) {
  BEGIN_TEST;
  
  mx_handle_t event;
  ASSERT_EQ(mx_event_create(0u, &event), 0, "");
  mx_handle_t duped;
  mx_status_t status = mx_handle_duplicate(event, MX_RIGHT_SAME_RIGHTS, 
&duped);
  ASSERT_EQ(status, MX_OK, "");
  // 
  }

Unlike the "assert" keyword in C++, the ASSERT_EQ macro will not terminate the 
execution of the unit test program (in other words, it will not invoke a 
noreturn function), instead it will return false and the error will be recorded 
by the unit test runner. Therefore, before this patch, the MagentaHandleChecker 
will report handle leaks on these assertion failures as the function reaches 
return and symbol that contains the acquired handles are acquired. These 
reports are not helpful as assertion failures in unit tests mean test failures. 
With the help of this patch, we add a call to a function with "mx_create_sink" 
annotation in the failure branch in definition "ASSERT_EQ". In this case, the 
MagentaHandleChecker will create a sink node in each assertion failure and 
suppress the warnings if the leaks are post-dominated by assertion failures.


https://reviews.llvm.org/D36475

Files:
  lib/StaticAnalyzer/Checkers/MagentaHandleChecker.cpp
  test/Analysis/mxhandle.c

Index: test/Analysis/mxhandle.c
===
--- test/Analysis/mxhandle.c
+++ test/Analysis/mxhandle.c
@@ -60,6 +60,8 @@
 
 void noReturnFunc() __attribute__((__noreturn__));
 
+void sinkFunc() MX_SYSCALL_PARAM_ATTR(create_sink);
+
 int leakingFunc(int argc, char* argv[]) {
   mx_handle_t sa, sb;
   mx_channel_create(0, &sa, &sb);
@@ -228,6 +230,14 @@
   noReturnFunc(); // Should not report any bugs here
 }
 
+void checkNoLeak17() {
+  mx_handle_t sa, sb;
+  if (mx_channel_create(0, &sa, &sb) < 0) {
+return;
+  }
+  sinkFunc(); // Should not report any bugs here
+}
+
 void checkLeak01() {
   mx_handle_t sa, sb;
   mx_channel_create(0, &sa, &sb);
Index: lib/StaticAnalyzer/Checkers/MagentaHandleChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MagentaHandleChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MagentaHandleChecker.cpp
@@ -123,7 +123,9 @@
   UNPROCESSED_FUNC,
   // When a bug is found in function with this flag, do not report this bug
   // Used to suppress known false positives.
-  DONOTREPORT_FUNC
+  DONOTREPORT_FUNC,
+  // When a function has 'create_sink' annotation , create a sink node.
+  SINK_FUNC
 };
 
 enum AnnotationFlag {
@@ -144,7 +146,8 @@
   // This value is not describing the possible return value of a annotated
   // function. It basically tell the checker do not report any bugs found in
   // this function. Used to suppress false positive reports.
-  DONOTREPORT
+  DONOTREPORT,
+  CREATE_SINK
 };
 
 struct ArgSpec {
@@ -416,7 +419,8 @@
{"handle_escape", ESCAPE},
{"handle_use", NOESCAPE},
{"may_fail", BIFURCATE},
-   {"suppress_warning", DONOTREPORT}};
+   {"suppress_warning", DONOTREPORT},
+   {"create_sink", CREATE_SINK}};
 
   // Hard coded FuncSpec for mx_channel_read and mx_channel_write
   // We currently don't have a clean way to annotate handles passed through
@@ -455,6 +459,10 @@
 FuncKindMap[FuncDecl] == UNPROCESSED_FUNC ||
 FuncKindMap[FuncDecl] == DONOTREPORT_FUNC)
   return false;
+if (FuncKindMap[FuncDecl] == SINK_FUNC) {
+  C.generateSink(C.getState(), C.getPredecessor());
+  return true;
+}
   }
   // Check if the function has annotation and has already been processed before
   if (FuncDeclMap.count(FuncDecl))
@@ -545,6 +553,11 @@
 FuncKindMap[FD] = DONOTREPORT_FUNC;
 return false;
   }
+  if (FS.RetAction == CREATE_SINK) {
+FuncKindMap[FD] = SINK_FUNC;
+Ctx.generateSink(Ctx.getState(), Ctx.getPredecessor());
+return true;
+  }
   SmallVector invalidateSVal;
   ProgramStateRef State = Ctx.getState();
   ASTContext &ASTCtx = State->getStateManager().getContext();
@@ -1035,13 +1048,14 @@
 HasValidAnnotation = true;
   }
   // Return type is not mx_status_t but has annotation other than
-  // SYMBOLIC|DONOTREPORT Consider it as an error
+  // SYMBOLIC|DONOTREPORT|CREATE_SINK Consider it as an error
   if (RetType.getAsString().find(SYSCALL_RETURN_TYPE_NAME) &&
-  (FS.RetAction != SYMBOLIC && FS.RetActi

  1   2   >