[PATCH] D42645: New simple Checker for mmap calls

2018-02-28 Thread David CARLIER via Phabricator via cfe-commits
devnexen added a comment.

ping :)


https://reviews.llvm.org/D42645



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


[clang-tools-extra] r326310 - [clangd] A few minor fixes for STL internal header mapping.

2018-02-28 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed Feb 28 00:56:11 2018
New Revision: 326310

URL: http://llvm.org/viewvc/llvm-project?rev=326310&view=rev
Log:
[clangd] A few minor fixes for STL internal header mapping.

Modified:
clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp

Modified: clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp?rev=326310&r1=326309&r2=326310&view=diff
==
--- clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp Wed Feb 28 
00:56:11 2018
@@ -140,7 +140,7 @@ void addSystemHeadersMapping(CanonicalIn
   {"backward/binders.h$", ""},
   {"bits/algorithmfwd.h$", ""},
   {"bits/alloc_traits.h$", ""},
-  {"bits/allocator.h$", ""},
+  {"bits/allocator.h$", ""},
   {"bits/atomic_base.h$", ""},
   {"bits/atomic_lockfree_defines.h$", ""},
   {"bits/basic_ios.h$", ""},
@@ -200,12 +200,12 @@ void addSystemHeadersMapping(CanonicalIn
   {"bits/slice_array.h$", ""},
   {"bits/sstream.tcc$", ""},
   {"bits/stl_algo.h$", ""},
-  {"bits/stl_algobase.h$", ""},
+  {"bits/stl_algobase.h$", ""},
   {"bits/stl_bvector.h$", ""},
   {"bits/stl_construct.h$", ""},
   {"bits/stl_deque.h$", ""},
-  {"bits/stl_function.h$", ""},
-  {"bits/stl_heap.h$", ""},
+  {"bits/stl_function.h$", ""},
+  {"bits/stl_heap.h$", ""},
   {"bits/stl_iterator.h$", ""},
   {"bits/stl_iterator_base_funcs.h$", ""},
   {"bits/stl_iterator_base_types.h$", ""},


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


[PATCH] D43766: [clang-tidy][modernize-make-unique] Checks c++14 flag before using std::make_unique

2018-02-28 Thread Frederic Tingaud via Phabricator via cfe-commits
ftingaud updated this revision to Diff 136245.
ftingaud added a comment.

Apply clang-format on changelist.


https://reviews.llvm.org/D43766

Files:
  clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tidy/modernize/MakeSmartPtrCheck.h
  clang-tidy/modernize/MakeUniqueCheck.cpp
  clang-tidy/modernize/MakeUniqueCheck.h
  test/clang-tidy/modernize-make-unique-cxx11.cpp
  test/clang-tidy/modernize-make-unique-cxx14.cpp
  test/clang-tidy/modernize-make-unique-header.cpp
  test/clang-tidy/modernize-make-unique-macros.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
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s modernize-make-unique %t -- -- -std=c++11 \
+// RUN: %check_clang_tidy %s modernize-make-unique %t -- -- -std=c++14 \
 // RUN:   -I%S/Inputs/modernize-smart-ptr
 
 #include "unique_ptr.h"
Index: test/clang-tidy/modernize-make-unique-macros.cpp
===
--- test/clang-tidy/modernize-make-unique-macros.cpp
+++ test/clang-tidy/modernize-make-unique-macros.cpp
@@ -1,6 +1,6 @@
 // RUN: %check_clang_tidy %s modernize-make-unique %t -- \
 // RUN:   -config="{CheckOptions: [{key: modernize-make-unique.IgnoreMacros, value: 0}]}" \
-// RUN:   -- -std=c++11  -I%S/Inputs/modernize-smart-ptr
+// RUN:   -- -std=c++14  -I%S/Inputs/modernize-smart-ptr
 
 #include "unique_ptr.h"
 
Index: test/clang-tidy/modernize-make-unique-header.cpp
===
--- test/clang-tidy/modernize-make-unique-header.cpp
+++ test/clang-tidy/modernize-make-unique-header.cpp
@@ -5,7 +5,7 @@
 // RUN:  {key: modernize-make-unique.MakeSmartPtrFunctionHeader, \
 // RUN:   value: 'make_unique_util.h'} \
 // RUN: ]}" \
-// RUN:   -- -std=c++11 -I%S/Inputs/modernize-smart-ptr
+// RUN:   -- -std=c++14 -I%S/Inputs/modernize-smart-ptr
 
 #include "unique_ptr.h"
 // CHECK-FIXES: #include "make_unique_util.h"
Index: test/clang-tidy/modernize-make-unique-cxx14.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-make-unique-cxx14.cpp
@@ -0,0 +1,12 @@
+// RUN: %check_clang_tidy %s modernize-make-unique %t -- -- -std=c++14 \
+// RUN:   -I%S/Inputs/modernize-smart-ptr
+
+#include "unique_ptr.h"
+// CHECK-FIXES: #include 
+
+int main() {
+  auto my_ptr = std::unique_ptr(new int(1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use std::make_unique instead
+  // CHECK-FIXES: auto my_ptr = std::make_unique(1);
+  return 0;
+}
Index: test/clang-tidy/modernize-make-unique-cxx11.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-make-unique-cxx11.cpp
@@ -0,0 +1,11 @@
+// RUN: %check_clang_tidy %s modernize-make-unique %t -- -- -std=c++11 \
+// RUN:   -I%S/Inputs/modernize-smart-ptr
+
+#include "unique_ptr.h"
+// CHECK-FIXES-NOT: #include 
+
+int main() {
+  auto my_ptr = std::unique_ptr(new int(1));
+  // CHECK-FIXES-NOT: auto my_ptr = std::make_unique(1);
+  return 0;
+}
Index: clang-tidy/modernize/MakeUniqueCheck.h
===
--- clang-tidy/modernize/MakeUniqueCheck.h
+++ clang-tidy/modernize/MakeUniqueCheck.h
@@ -31,6 +31,8 @@
 
 protected:
   SmartPtrTypeMatcher getSmartPointerTypeMatcher() const override;
+
+  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override;
 };
 
 } // namespace modernize
Index: clang-tidy/modernize/MakeUniqueCheck.cpp
===
--- clang-tidy/modernize/MakeUniqueCheck.cpp
+++ clang-tidy/modernize/MakeUniqueCheck.cpp
@@ -36,6 +36,11 @@
 equalsBoundNode(PointerType;
 }
 
+bool MakeUniqueCheck::isLanguageVersionSupported(
+const LangOptions &LangOpts) const {
+  return LangOpts.CPlusPlus14;
+}
+
 } // namespace modernize
 } // namespace tidy
 } // namespace clang
Index: clang-tidy/modernize/MakeSmartPtrCheck.h
===
--- clang-tidy/modernize/MakeSmartPtrCheck.h
+++ clang-tidy/modernize/MakeSmartPtrCheck.h
@@ -40,6 +40,9 @@
   /// in this class.
   virtual SmartPtrTypeMatcher getSmartPointerTypeMatcher() const = 0;
 
+  /// Returns whether the C++ version is compatible with current check.
+  virtual bool isLanguageVersionSupported(const LangOptions &LangOpts) const;
+
   static const char PointerType[];
   static const char ConstructorCall[];
   static const char ResetCall[];
Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -61,16 +61,21 @@
   Options.store(Opts, "Ignor

[clang-tools-extra] r326313 - [clangd] Prefer the definition of a TagDecl (e.g. class) as CanonicalDeclaration.

2018-02-28 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed Feb 28 01:33:15 2018
New Revision: 326313

URL: http://llvm.org/viewvc/llvm-project?rev=326313&view=rev
Log:
[clangd] Prefer the definition of a TagDecl (e.g. class) as 
CanonicalDeclaration.

Summary:
Currently, we pick the first declaration of a symbol in a TU, which is 
considered
canonical in the clangIndex, as the canonical declaration in clangd. This causes
forward declarations that might appear in a random header to be used as a
canonical declaration, which is not desirable for features like 
go-to-declaration
or include insertion.

For example, for class X, we would consider the forward declaration in fwd.h to
be the canonical declaration, while the preferred canonical declaration should
be the actual definition in x.h.
```
// fwd.h
class X;  // forward decl

// x.h
class X {};
```

This patch fixes the issue by making symbol collector favor the actual 
definition of
a TagDecl (i.e. class/struct/enum/union) found in a header file over the first 
seen
declarations in a TU. Other symbol types like functions are not handled because
using the first seen declarations as canonical declarations is usually a good
heuristic for them.

Reviewers: sammccall

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

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

Modified:
clang-tools-extra/trunk/clangd/index/FileIndex.cpp
clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
clang-tools-extra/trunk/clangd/index/SymbolCollector.h
clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp

Modified: clang-tools-extra/trunk/clangd/index/FileIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/FileIndex.cpp?rev=326313&r1=326312&r2=326313&view=diff
==
--- clang-tools-extra/trunk/clangd/index/FileIndex.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/FileIndex.cpp Wed Feb 28 01:33:15 2018
@@ -20,11 +20,6 @@ std::unique_ptr indexAST(AST
  std::shared_ptr PP,
  llvm::ArrayRef Decls) {
   SymbolCollector::Options CollectorOpts;
-  // Although we do not index symbols in main files (e.g. cpp file), 
information
-  // in main files like definition locations of class declarations will still 
be
-  // collected; thus, the index works for go-to-definition.
-  // FIXME(ioeric): get rid of `IndexMainFiles` as this is always set to false.
-  CollectorOpts.IndexMainFiles = false;
   // FIXME(ioeric): we might also want to collect include headers. We would 
need
   // to make sure all includes are canonicalized (with CanonicalIncludes), 
which
   // is not trivial given the current way of collecting symbols: we only have

Modified: clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp?rev=326313&r1=326312&r2=326313&view=diff
==
--- clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp Wed Feb 28 
01:33:15 2018
@@ -115,9 +115,7 @@ bool shouldFilterDecl(const NamedDecl *N
   //   * enum constants in unscoped enum decl (e.g. "red" in "enum {red};")
   auto InTopLevelScope = hasDeclContext(
   anyOf(namespaceDecl(), translationUnitDecl(), linkageSpecDecl()));
-  if (match(decl(allOf(Opts.IndexMainFiles
-   ? decl()
-   : decl(unless(isExpansionInMainFile())),
+  if (match(decl(allOf(unless(isExpansionInMainFile()),
anyOf(InTopLevelScope,
  hasDeclContext(enumDecl(InTopLevelScope,
  unless(isScoped())),
@@ -177,11 +175,9 @@ getIncludeHeader(const SourceManager &SM
 // For symbols defined inside macros:
 //   * use expansion location, if the symbol is formed via macro concatenation.
 //   * use spelling location, otherwise.
-llvm::Optional
-getSymbolLocation(const NamedDecl &D, SourceManager &SM,
-  const SymbolCollector::Options &Opts,
-  const clang::LangOptions& LangOpts,
-  std::string &FileURIStorage) {
+llvm::Optional getSymbolLocation(
+const NamedDecl &D, SourceManager &SM, const SymbolCollector::Options 
&Opts,
+const clang::LangOptions &LangOpts, std::string &FileURIStorage) {
   SourceLocation SpellingLoc = SM.getSpellingLoc(D.getLocation());
   if (D.getLocation().isMacroID()) {
 std::string PrintLoc = SpellingLoc.printToString(SM);
@@ -209,6 +205,19 @@ getSymbolLocation(const NamedDecl &D, So
   return std::move(Result);
 }
 
+// Checks whether \p ND is a definition of a TagDecl (class/struct/enum/union)
+// in a header file, in which case clangd would prefer to use ND as a canonical
+// declaration.
+// FI

[PATCH] D43823: [clangd] Prefer the definition of a TagDecl (e.g. class) as CanonicalDeclaration.

2018-02-28 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 136247.
ioeric marked 5 inline comments as done.
ioeric added a comment.

- Addressed review comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43823

Files:
  clangd/index/FileIndex.cpp
  clangd/index/SymbolCollector.cpp
  clangd/index/SymbolCollector.h
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -47,6 +47,7 @@
 }
 MATCHER_P(QName, Name, "") { return (arg.Scope + arg.Name).str() == Name; }
 MATCHER_P(DeclURI, P, "") { return arg.CanonicalDeclaration.FileURI == P; }
+MATCHER_P(DefURI, P, "") { return arg.Definition.FileURI == P; }
 MATCHER_P(IncludeHeader, P, "") {
   return arg.Detail && arg.Detail->IncludeHeader == P;
 }
@@ -152,17 +153,15 @@
 };
 
 TEST_F(SymbolCollectorTest, CollectSymbols) {
-  CollectorOpts.IndexMainFiles = true;
   const std::string Header = R"(
 class Foo {
   void f();
 };
 void f1();
 inline void f2() {}
 static const int KInt = 2;
 const char* kStr = "123";
-  )";
-  const std::string Main = R"(
+
 namespace {
 void ff() {} // ignore
 }
@@ -190,7 +189,7 @@
 using bar::v2;
 } // namespace foo
   )";
-  runSymbolCollector(Header, Main);
+  runSymbolCollector(Header, /*Main=*/"");
   EXPECT_THAT(Symbols,
   UnorderedElementsAreArray(
   {QName("Foo"), QName("f1"), QName("f2"), QName("KInt"),
@@ -200,7 +199,6 @@
 }
 
 TEST_F(SymbolCollectorTest, Locations) {
-  CollectorOpts.IndexMainFiles = true;
   Annotations Header(R"cpp(
 // Declared in header, defined in main.
 extern int $xdecl[[X]];
@@ -216,7 +214,7 @@
 void $printdef[[print]]() {}
 
 // Declared/defined in main only.
-int $y[[Y]];
+int Y;
   )cpp");
   runSymbolCollector(Header.code(), Main.code());
   EXPECT_THAT(
@@ -228,20 +226,16 @@
 DefRange(Main.offsetRange("clsdef"))),
   AllOf(QName("print"), DeclRange(Header.offsetRange("printdecl")),
 DefRange(Main.offsetRange("printdef"))),
-  AllOf(QName("Z"), DeclRange(Header.offsetRange("zdecl"))),
-  AllOf(QName("Y"), DeclRange(Main.offsetRange("y")),
-DefRange(Main.offsetRange("y");
+  AllOf(QName("Z"), DeclRange(Header.offsetRange("zdecl");
 }
 
 TEST_F(SymbolCollectorTest, SymbolRelativeNoFallback) {
-  CollectorOpts.IndexMainFiles = false;
   runSymbolCollector("class Foo {};", /*Main=*/"");
-  EXPECT_THAT(Symbols,
-  UnorderedElementsAre(AllOf(QName("Foo"), DeclURI(TestHeaderURI;
+  EXPECT_THAT(Symbols, UnorderedElementsAre(
+   AllOf(QName("Foo"), DeclURI(TestHeaderURI;
 }
 
 TEST_F(SymbolCollectorTest, SymbolRelativeWithFallback) {
-  CollectorOpts.IndexMainFiles = false;
   TestHeaderName = "x.h";
   TestFileName = "x.cpp";
   TestHeaderURI = URI::createFile(testPath(TestHeaderName)).toString();
@@ -253,7 +247,6 @@
 
 #ifndef LLVM_ON_WIN32
 TEST_F(SymbolCollectorTest, CustomURIScheme) {
-  CollectorOpts.IndexMainFiles = false;
   // Use test URI scheme from URITests.cpp
   CollectorOpts.URISchemes.insert(CollectorOpts.URISchemes.begin(), "unittest");
   TestHeaderName = testPath("test-root/x.h");
@@ -265,24 +258,21 @@
 #endif
 
 TEST_F(SymbolCollectorTest, InvalidURIScheme) {
-  CollectorOpts.IndexMainFiles = false;
   // Use test URI scheme from URITests.cpp
   CollectorOpts.URISchemes = {"invalid"};
   runSymbolCollector("class Foo {};", /*Main=*/"");
   EXPECT_THAT(Symbols, UnorderedElementsAre(AllOf(QName("Foo"), DeclURI("";
 }
 
 TEST_F(SymbolCollectorTest, FallbackToFileURI) {
-  CollectorOpts.IndexMainFiles = false;
   // Use test URI scheme from URITests.cpp
   CollectorOpts.URISchemes = {"invalid", "file"};
   runSymbolCollector("class Foo {};", /*Main=*/"");
   EXPECT_THAT(Symbols, UnorderedElementsAre(
AllOf(QName("Foo"), DeclURI(TestHeaderURI;
 }
 
 TEST_F(SymbolCollectorTest, IncludeEnums) {
-  CollectorOpts.IndexMainFiles = false;
   const std::string Header = R"(
 enum {
   Red
@@ -306,7 +296,6 @@
 }
 
 TEST_F(SymbolCollectorTest, IgnoreNamelessSymbols) {
-  CollectorOpts.IndexMainFiles = false;
   const std::string Header = R"(
 struct {
   int a;
@@ -318,7 +307,6 @@
 }
 
 TEST_F(SymbolCollectorTest, SymbolFormedFromMacro) {
-  CollectorOpts.IndexMainFiles = false;
 
   Annotations Header(R"(
 #define FF(name) \
@@ -342,33 +330,7 @@
 DeclURI(TestHeaderURI;
 }
 
-TEST_F(SymbolCollectorTest, SymbolFormedFromMacroInMainFile) {
-  CollectorOpts.IndexMainFiles = true;
-
-  Annotations Main(R"(
-#define FF(name) \
-  class name##_Test {};
-
-$expansion[[FF]](abc);
-
-#define FF2() \
-  class $spelling[[Test]] {};
-
-FF2();
-  )");
-  runSymbolCollector(/*Header=*

[PATCH] D43823: [clangd] Prefer the definition of a TagDecl (e.g. class) as CanonicalDeclaration.

2018-02-28 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326313: [clangd] Prefer the definition of a TagDecl (e.g. 
class) as… (authored by ioeric, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D43823

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

Index: clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
@@ -115,9 +115,7 @@
   //   * enum constants in unscoped enum decl (e.g. "red" in "enum {red};")
   auto InTopLevelScope = hasDeclContext(
   anyOf(namespaceDecl(), translationUnitDecl(), linkageSpecDecl()));
-  if (match(decl(allOf(Opts.IndexMainFiles
-   ? decl()
-   : decl(unless(isExpansionInMainFile())),
+  if (match(decl(allOf(unless(isExpansionInMainFile()),
anyOf(InTopLevelScope,
  hasDeclContext(enumDecl(InTopLevelScope,
  unless(isScoped())),
@@ -177,11 +175,9 @@
 // For symbols defined inside macros:
 //   * use expansion location, if the symbol is formed via macro concatenation.
 //   * use spelling location, otherwise.
-llvm::Optional
-getSymbolLocation(const NamedDecl &D, SourceManager &SM,
-  const SymbolCollector::Options &Opts,
-  const clang::LangOptions& LangOpts,
-  std::string &FileURIStorage) {
+llvm::Optional getSymbolLocation(
+const NamedDecl &D, SourceManager &SM, const SymbolCollector::Options &Opts,
+const clang::LangOptions &LangOpts, std::string &FileURIStorage) {
   SourceLocation SpellingLoc = SM.getSpellingLoc(D.getLocation());
   if (D.getLocation().isMacroID()) {
 std::string PrintLoc = SpellingLoc.printToString(SM);
@@ -209,6 +205,19 @@
   return std::move(Result);
 }
 
+// Checks whether \p ND is a definition of a TagDecl (class/struct/enum/union)
+// in a header file, in which case clangd would prefer to use ND as a canonical
+// declaration.
+// FIXME: handle symbol types that are not TagDecl (e.g. functions), if using
+// the the first seen declaration as canonical declaration is not a good enough
+// heuristic.
+bool isPreferredDeclaration(const NamedDecl &ND, index::SymbolRoleSet Roles) {
+  using namespace clang::ast_matchers;
+  return (Roles & static_cast(index::SymbolRole::Definition)) &&
+ llvm::isa(&ND) &&
+ match(decl(isExpansionInMainFile()), ND, ND.getASTContext()).empty();
+}
+
 } // namespace
 
 SymbolCollector::SymbolCollector(Options Opts) : Opts(std::move(Opts)) {}
@@ -241,12 +250,20 @@
 if (index::generateUSRForDecl(ND, USR))
   return true;
 
+const NamedDecl &OriginalDecl = *cast(ASTNode.OrigD);
 auto ID = SymbolID(USR);
-const Symbol* BasicSymbol = Symbols.find(ID);
+const Symbol *BasicSymbol = Symbols.find(ID);
 if (!BasicSymbol) // Regardless of role, ND is the canonical declaration.
   BasicSymbol = addDeclaration(*ND, std::move(ID));
+else if (isPreferredDeclaration(OriginalDecl, Roles))
+  // If OriginalDecl is preferred, replace the existing canonical
+  // declaration (e.g. a class forward declaration). There should be at most
+  // one duplicate as we expect to see only one preferred declaration per
+  // TU, because in practice they are definitions.
+  BasicSymbol = addDeclaration(OriginalDecl, std::move(ID));
+
 if (Roles & static_cast(index::SymbolRole::Definition))
-  addDefinition(*cast(ASTNode.OrigD), *BasicSymbol);
+  addDefinition(OriginalDecl, *BasicSymbol);
   }
   return true;
 }
@@ -271,8 +288,6 @@
   std::tie(S.Scope, S.Name) = splitQualifiedName(QName);
   S.SymInfo = index::getSymbolInfo(&ND);
   std::string FileURI;
-  // FIXME: we may want a different "canonical" heuristic than clang chooses.
-  // Clang seems to choose the first, which may not have the most information.
   if (auto DeclLoc =
   getSymbolLocation(ND, SM, Opts, ASTCtx->getLangOpts(), FileURI))
 S.CanonicalDeclaration = *DeclLoc;
Index: clang-tools-extra/trunk/clangd/index/FileIndex.cpp
===
--- clang-tools-extra/trunk/clangd/index/FileIndex.cpp
+++ clang-tools-extra/trunk/clangd/index/FileIndex.cpp
@@ -20,11 +20,6 @@
  std::shared_ptr PP,
  llvm::ArrayRef Decls) {
   SymbolCollector::Options CollectorOpts;
-  // Although we do not index symbols in main files (e.g. cpp file), information
-  // in main files like definition locations o

[PATCH] D43823: [clangd] Prefer the definition of a TagDecl (e.g. class) as CanonicalDeclaration.

2018-02-28 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/index/SymbolCollector.cpp:260
   BasicSymbol = addDeclaration(*ND, std::move(ID));
+else if (isPreferredDeclaration(OriginalDecl, Roles))
+  BasicSymbol = addDeclaration(OriginalDecl, std::move(ID));

sammccall wrote:
> This is a bit subtle and I think comment-worthy.
> We're doing a bunch of duplicated work, but at most once because we expect to 
> see only one preferred declaration per TU, because in practice they're 
> definitions?
> 
> An alternative would be to have addDeclaration loop through the redecls to 
> try to find a preferred one (and use the passed in one if none is found). 
> This would avoid any duplicated work. Up to you.
The reason why I am a bit hesitant to use `redecls` is that we wouldn't know 
whether all re-declarations would have been indexed (e.g. there might be 
implicit decls that were dropped by the index library) and passed the filters 
we had (e.g. `shouldFilterDecl`). And you are right, the duplicated work should 
usually be little. I added a comment to clarify the duplicated work.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43823



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


[PATCH] D43809: Add possibility to specify output stream for CompilerInstance

2018-02-28 Thread Kristina Bessonova via Phabricator via cfe-commits
krisb updated this revision to Diff 136251.
krisb added a comment.

@teemperor, thanks! All comments are applied.


Repository:
  rC Clang

https://reviews.llvm.org/D43809

Files:
  include/clang/Frontend/CompilerInstance.h
  lib/CodeGen/CodeGenAction.cpp
  unittests/Format/FormatTest.cpp
  unittests/Frontend/CMakeLists.txt
  unittests/Frontend/OutputStreamTest.cpp

Index: unittests/Frontend/OutputStreamTest.cpp
===
--- /dev/null
+++ unittests/Frontend/OutputStreamTest.cpp
@@ -0,0 +1,46 @@
+//===- unittests/Frontend/OutputStreamTest.cpp --- FrontendAction tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/CodeGen/BackendUtil.h"
+#include "clang/CodeGen/CodeGenAction.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/FrontendTool/Utils.h"
+#include "clang/Lex/PreprocessorOptions.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace clang;
+using namespace clang::frontend;
+
+namespace {
+
+TEST(FrontendOutputTests, TestOutputStream) {
+  auto Invocation = std::make_shared();
+  Invocation->getPreprocessorOpts().addRemappedFile(
+  "test.cc", MemoryBuffer::getMemBuffer("").release());
+  Invocation->getFrontendOpts().Inputs.push_back(
+  FrontendInputFile("test.cc", InputKind::CXX));
+  Invocation->getFrontendOpts().ProgramAction = EmitBC;
+  Invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
+  CompilerInstance Compiler;
+
+  SmallVector IRBuffer;
+  std::unique_ptr IRStream(
+  new raw_svector_ostream(IRBuffer));
+
+  Compiler.setOutputStream(std::move(IRStream));
+  Compiler.setInvocation(std::move(Invocation));
+  Compiler.createDiagnostics();
+
+  bool Success = ExecuteCompilerInvocation(&Compiler);
+  EXPECT_TRUE(Success);
+  EXPECT_TRUE(!IRBuffer.empty());
+  EXPECT_TRUE(StringRef(IRBuffer.data()).startswith("BC"));
+}
+}
Index: unittests/Frontend/CMakeLists.txt
===
--- unittests/Frontend/CMakeLists.txt
+++ unittests/Frontend/CMakeLists.txt
@@ -9,6 +9,7 @@
   CodeGenActionTest.cpp
   ParsedSourceLocationTest.cpp
   PCHPreambleTest.cpp
+  OutputStreamTest.cpp
   )
 target_link_libraries(FrontendTests
   PRIVATE
@@ -18,4 +19,5 @@
   clangLex
   clangSema
   clangCodeGen
+  clangFrontendTool
   )
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11985,7 +11985,7 @@
 {"foo", "@interface Foo\n@end\n", FormatStyle::LK_ObjC},
 };
 INSTANTIATE_TEST_CASE_P(ValidLanguages, GuessLanguageTest,
-::testing::ValuesIn(TestCases));
+::testing::ValuesIn(TestCases), );
 
 } // end namespace
 } // end namespace format
Index: lib/CodeGen/CodeGenAction.cpp
===
--- lib/CodeGen/CodeGenAction.cpp
+++ lib/CodeGen/CodeGenAction.cpp
@@ -846,7 +846,10 @@
 std::unique_ptr
 CodeGenAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
   BackendAction BA = static_cast(Act);
-  std::unique_ptr OS = GetOutputStream(CI, InFile, BA);
+  std::unique_ptr OS = CI.takeOutputStream();
+  if (!OS)
+OS = GetOutputStream(CI, InFile, BA);
+
   if (BA != Backend_EmitNothing && !OS)
 return nullptr;
 
Index: include/clang/Frontend/CompilerInstance.h
===
--- include/clang/Frontend/CompilerInstance.h
+++ include/clang/Frontend/CompilerInstance.h
@@ -183,6 +183,9 @@
   /// The list of active output files.
   std::list OutputFiles;
 
+  /// Force an output buffer.
+  std::unique_ptr OutputStream;
+
   CompilerInstance(const CompilerInstance &) = delete;
   void operator=(const CompilerInstance &) = delete;
 public:
@@ -773,6 +776,14 @@
 
   /// }
 
+  void setOutputStream(std::unique_ptr OutStream) {
+OutputStream = std::move(OutStream);
+  }
+
+  std::unique_ptr takeOutputStream() {
+return std::move(OutputStream);
+  }
+
   // Create module manager.
   void createModuleManager();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43809: Add possibility to specify output stream for CompilerInstance

2018-02-28 Thread Kristina Bessonova via Phabricator via cfe-commits
krisb updated this revision to Diff 136252.
krisb added a comment.

Reverted unintentional changes again. Sorry for that


Repository:
  rC Clang

https://reviews.llvm.org/D43809

Files:
  include/clang/Frontend/CompilerInstance.h
  lib/CodeGen/CodeGenAction.cpp
  unittests/Frontend/CMakeLists.txt
  unittests/Frontend/OutputStreamTest.cpp

Index: unittests/Frontend/OutputStreamTest.cpp
===
--- /dev/null
+++ unittests/Frontend/OutputStreamTest.cpp
@@ -0,0 +1,46 @@
+//===- unittests/Frontend/OutputStreamTest.cpp --- FrontendAction tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/CodeGen/BackendUtil.h"
+#include "clang/CodeGen/CodeGenAction.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/FrontendTool/Utils.h"
+#include "clang/Lex/PreprocessorOptions.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace clang;
+using namespace clang::frontend;
+
+namespace {
+
+TEST(FrontendOutputTests, TestOutputStream) {
+  auto Invocation = std::make_shared();
+  Invocation->getPreprocessorOpts().addRemappedFile(
+  "test.cc", MemoryBuffer::getMemBuffer("").release());
+  Invocation->getFrontendOpts().Inputs.push_back(
+  FrontendInputFile("test.cc", InputKind::CXX));
+  Invocation->getFrontendOpts().ProgramAction = EmitBC;
+  Invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
+  CompilerInstance Compiler;
+
+  SmallVector IRBuffer;
+  std::unique_ptr IRStream(
+  new raw_svector_ostream(IRBuffer));
+
+  Compiler.setOutputStream(std::move(IRStream));
+  Compiler.setInvocation(std::move(Invocation));
+  Compiler.createDiagnostics();
+
+  bool Success = ExecuteCompilerInvocation(&Compiler);
+  EXPECT_TRUE(Success);
+  EXPECT_TRUE(!IRBuffer.empty());
+  EXPECT_TRUE(StringRef(IRBuffer.data()).startswith("BC"));
+}
+}
Index: unittests/Frontend/CMakeLists.txt
===
--- unittests/Frontend/CMakeLists.txt
+++ unittests/Frontend/CMakeLists.txt
@@ -9,6 +9,7 @@
   CodeGenActionTest.cpp
   ParsedSourceLocationTest.cpp
   PCHPreambleTest.cpp
+  OutputStreamTest.cpp
   )
 target_link_libraries(FrontendTests
   PRIVATE
@@ -18,4 +19,5 @@
   clangLex
   clangSema
   clangCodeGen
+  clangFrontendTool
   )
Index: lib/CodeGen/CodeGenAction.cpp
===
--- lib/CodeGen/CodeGenAction.cpp
+++ lib/CodeGen/CodeGenAction.cpp
@@ -846,7 +846,10 @@
 std::unique_ptr
 CodeGenAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
   BackendAction BA = static_cast(Act);
-  std::unique_ptr OS = GetOutputStream(CI, InFile, BA);
+  std::unique_ptr OS = CI.takeOutputStream();
+  if (!OS)
+OS = GetOutputStream(CI, InFile, BA);
+
   if (BA != Backend_EmitNothing && !OS)
 return nullptr;
 
Index: include/clang/Frontend/CompilerInstance.h
===
--- include/clang/Frontend/CompilerInstance.h
+++ include/clang/Frontend/CompilerInstance.h
@@ -183,6 +183,9 @@
   /// The list of active output files.
   std::list OutputFiles;
 
+  /// Force an output buffer.
+  std::unique_ptr OutputStream;
+
   CompilerInstance(const CompilerInstance &) = delete;
   void operator=(const CompilerInstance &) = delete;
 public:
@@ -773,6 +776,14 @@
 
   /// }
 
+  void setOutputStream(std::unique_ptr OutStream) {
+OutputStream = std::move(OutStream);
+  }
+
+  std::unique_ptr takeOutputStream() {
+return std::move(OutputStream);
+  }
+
   // Create module manager.
   void createModuleManager();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43648: [clangd] Debounce streams of updates.

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

LGTM


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43648



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


[PATCH] D43809: Add possibility to specify output stream for CompilerInstance

2018-02-28 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rC Clang

https://reviews.llvm.org/D43809



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


[PATCH] D43630: [Driver] Fix search paths on x32

2018-02-28 Thread John Paul Adrian Glaubitz via Phabricator via cfe-commits
glaubitz added a comment.

As a heads-up, powerpcspe needs a similar treatment as it suffers from the same 
problem:

  cd build-llvm \
  CFLAGS=`dpkg-buildflags --get CFLAGS`; \
  CFLAGS="$CFLAGS `dpkg-buildflags --get CPPFLAGS`"; \
  echo $CFLAGS; \
  bin/clang++ -c $CFLAGS -std=c++11 ../lib/Fuzzer/*.cpp -IFuzzer; \
  ar ruv libFuzzer.a Fuzzer*.o
  -g -O2 -fdebug-prefix-map=/<>=. -fstack-protector-strong 
-Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2
  In file included from ../lib/Fuzzer/FuzzerCrossOver.cpp:12:
  In file included from ../lib/Fuzzer/FuzzerDefs.h:15:
  In file included from 
/usr/lib/gcc/powerpc-linux-gnuspe/7.3.0/../../../../include/c++/7.3.0/cassert:43:
  In file included from 
/usr/lib/gcc/powerpc-linux-gnuspe/7.3.0/../../../../include/powerpc-linux-gnuspe/c++/7.3.0/bits/c++config.h:533:
  In file included from 
/usr/lib/gcc/powerpc-linux-gnuspe/7.3.0/../../../../include/powerpc-linux-gnuspe/c++/7.3.0/bits/os_defines.h:39:
  /usr/include/features.h:419:12: fatal error: 'sys/cdefs.h' file not found
  #  include 
 ^
  1 error generated.
  ar: `u' modifier ignored since `D' is the default (see `U')
  ar: creating libFuzzer.a
  ar: Fuzzer*.o: No such file or directory

Full build log in: 
https://people.debian.org/~glaubitz/llvm-toolchain-4.0_4.0.1-10.log.gz

Like x32, powerpcspe is just a variant on an existing architecture, namely 
powerpc but with a different ABI and hence a suffix in the GNU triplet name 
(full triplet name is "powerpc-linux-gnuspe").


Repository:
  rC Clang

https://reviews.llvm.org/D43630



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


[PATCH] D36836: [clang-tidy] Implement sonarsource-function-cognitive-complexity check

2018-02-28 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc added a comment.

In https://reviews.llvm.org/D36836#931995, @lebedev.ri wrote:

> - Rebased
> - As advised by @aaron.ballman, moved into it's own directory/module. Please 
> review that, i'm not entirely sure i have done that fully correctly.
>
>   @chandlerc Hi! @aaron.ballman has suggested for me to try to talk to you 
> about this. Is there some precedent for the licensing 'issue' at hand? Do you 
> have any opinion? @dberlin did not react to the pings, so i'm not sure i 
> personally can come up with anything better for `LICENSE.txt`


Sadly, what you need here is legal advice for a good way to handle this, and 
I'm not a lawyer and so I can't really give you that advice.

To be clear, what you currently have isn't OK for several reasons, not least of 
which what Aaron brought up that this is not in fact a license.

> If there are no further ideas, i'll try to contact sonarsource.

Unless Danny can volunteer his time, we finish with relicensing efforts and can 
devote the foundation's lawyer's (sadly precious) time to this, I think either 
you or sonarsource working to understand the best legal way to contribute this 
would be the best way forward. Sorry that this is a tricky situation. Happy to 
have a private discussion w/ your or sonarsources's lawyer via my @llvm.org 
email address if useful.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D36836



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


[clang-tools-extra] r326314 - [clang-tidy] Add a test for readability-implicit-bool-conversion with bitfields.

2018-02-28 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Feb 28 02:30:25 2018
New Revision: 326314

URL: http://llvm.org/viewvc/llvm-project?rev=326314&view=rev
Log:
[clang-tidy] Add a test for readability-implicit-bool-conversion with bitfields.

Modified:

clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-conversion-allow-in-conditions.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-conversion-allow-in-conditions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-conversion-allow-in-conditions.cpp?rev=326314&r1=326313&r2=326314&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-conversion-allow-in-conditions.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-conversion-allow-in-conditions.cpp
 Wed Feb 28 02:30:25 2018
@@ -12,6 +12,7 @@ int* functionReturningPointer();
 
 struct Struct {
   int member;
+  unsigned bitfield : 1;
 };
 
 
@@ -23,6 +24,11 @@ void regularImplicitConversionIntegerToB
 }
 
 void implicitConversionIntegerToBoolInConditionalsIsAllowed() {
+  Struct s = {};
+  if (s.member) {}
+  if (!s.member) {}
+  if (s.bitfield) {}
+  if (!s.bitfield) {}
   if (functionReturningInt()) {}
   if (!functionReturningInt()) {}
   if (functionReturningInt() && functionReturningPointer()) {}


___
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

2018-02-28 Thread Daniel Kolozsvari via Phabricator via cfe-commits
koldaniel updated this revision to Diff 136261.
Herald added a subscriber: a.sidorin.
Herald added a reviewer: george.karpenkov.

https://reviews.llvm.org/D35068

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
  test/Analysis/security-syntax-checks.m

Index: test/Analysis/security-syntax-checks.m
===
--- test/Analysis/security-syntax-checks.m
+++ test/Analysis/security-syntax-checks.m
@@ -13,6 +13,9 @@
 # define BUILTIN(f) f
 #endif /* USE_BUILTINS */
 
+#include "Inputs/system-header-simulator-for-valist.h"
+#include "Inputs/system-header-simulator-for-simple-stream.h"
+
 typedef typeof(sizeof(int)) size_t;
 
 
@@ -212,3 +215,83 @@
   mkdtemp("XX");
 }
 
+
+//===--===
+// deprecated or unsafe buffer handling
+//===--===
+typedef int wchar_t;
+
+int sprintf(char *str, const char *format, ...);
+//int vsprintf (char *s, const char *format, va_list arg);
+int scanf(const char *format, ...);
+int wscanf(const wchar_t *format, ...);
+int fscanf(FILE *stream, const char *format, ...);
+int fwscanf(FILE *stream, const wchar_t *format, ...);
+int vscanf(const char *format, va_list arg);
+int vwscanf(const wchar_t *format, va_list arg);
+int vfscanf(FILE *stream, const char *format, va_list arg);
+int vfwscanf(FILE *stream, const wchar_t *format, va_list arg);
+int sscanf(const char *s, const char *format, ...);
+int swscanf(const wchar_t *ws, const wchar_t *format, ...);
+int vsscanf(const char *s, const char *format, va_list arg);
+int vswscanf(const wchar_t *ws, const wchar_t *format, va_list arg);
+int swprintf(wchar_t *ws, size_t len, const wchar_t *format, ...);
+int snprintf(char *s, size_t n, const char *format, ...);
+int vswprintf(wchar_t *ws, size_t len, const wchar_t *format, va_list arg);
+int vsnprintf(char *s, size_t n, const char *format, va_list arg);
+void *memcpy(void *destination, const void *source, size_t num);
+void *memmove(void *destination, const void *source, size_t num);
+char *strncpy(char *destination, const char *source, size_t num);
+char *strncat(char *destination, const char *source, size_t num);
+void *memset(void *ptr, int value, size_t num);
+
+void test_deprecated_or_unsafe_buffer_handling_1() {
+  char buf [5];
+  wchar_t wbuf [5];
+  int a;
+  FILE *file;
+  sprintf(buf, "a"); // expected-warning{{Call to function 'sprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11}}
+  scanf("%d", &a); // expected-warning{{Call to function 'scanf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'scanf_s' in case of C11}}
+  scanf("%s", buf); // expected-warning{{Call to function 'scanf' is insecure as it does not provide bounding of the memory buffer or security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'scanf_s' in case of C11}}
+  scanf("%4s", buf); // expected-warning{{Call to function 'scanf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'scanf_s' in case of C11}}
+  wscanf((const wchar_t*) L"%s", buf); // expected-warning{{Call to function 'wscanf' is insecure as it does not provide bounding of the memory buffer or security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'wscanf_s' in case of C11}}
+  fscanf(file, "%d", &a); // expected-warning{{Call to function 'fscanf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'fscanf_s' in case of C11}}
+  fscanf(file, "%s", buf); // expected-warning{{Call to function 'fscanf' is insecure as it does not provide bounding of the memory buffer or security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'fscanf_s' in case of C11}}
+  fscanf(file, "%4s", buf); // expected-warning{{Call to function 'fscanf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'fscanf_s' in case of C11}}
+  fwscanf(file, (const wchar_t*) L"%s", wbuf); // expected-warning{{Call to function 'fwscanf' is insecure as it does not provide bounding

[PATCH] D43766: [clang-tidy][modernize-make-unique] Checks c++14 flag before using std::make_unique

2018-02-28 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: test/clang-tidy/modernize-make-unique-cxx11.cpp:5
+#include "unique_ptr.h"
+// CHECK-FIXES-NOT: #include 
+

I'd better use positive assertions with the original text. Otherwise the test 
can pass if the check does any replacements except for the ones you list in 
CHECK-FIXES-NOT.



Comment at: test/clang-tidy/modernize-make-unique-header.cpp:8
 // RUN: ]}" \
-// RUN:   -- -std=c++11 -I%S/Inputs/modernize-smart-ptr
+// RUN:   -- -std=c++14 -I%S/Inputs/modernize-smart-ptr
 

As Haojian mentioned, this test still has to work in c++11.


https://reviews.llvm.org/D43766



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


[clang-tools-extra] r326321 - [clang-tidy] Fix 'add_new_check.py --udpate-docs'

2018-02-28 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Feb 28 04:21:38 2018
New Revision: 326321

URL: http://llvm.org/viewvc/llvm-project?rev=326321&view=rev
Log:
[clang-tidy] Fix 'add_new_check.py --udpate-docs'

Modified:
clang-tools-extra/trunk/clang-tidy/add_new_check.py

Modified: clang-tools-extra/trunk/clang-tidy/add_new_check.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/add_new_check.py?rev=326321&r1=326320&r2=326321&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/add_new_check.py (original)
+++ clang-tools-extra/trunk/clang-tidy/add_new_check.py Wed Feb 28 04:21:38 2018
@@ -320,9 +320,11 @@ def main():
   metavar='LANG')
   parser.add_argument(
   'module',
+  nargs='?',
   help='module directory under which to place the new tidy check (e.g., 
misc)')
   parser.add_argument(
   'check',
+  nargs='?',
   help='name of new tidy check to add (e.g. foo-do-the-stuff)')
   args = parser.parse_args()
 
@@ -330,6 +332,11 @@ def main():
 update_checks_list(os.path.dirname(sys.argv[0]))
 return
 
+  if not args.module or not args.check:
+print 'Module and check must be specified.'
+parser.print_usage()
+return
+
   module = args.module
   check_name = args.check
 


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


[PATCH] D43867: Rename a few checks from misc- to bugprone-.

2018-02-28 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh created this revision.
alexfh added reviewers: hokein, sammccall, aaron.ballman.
Herald added subscribers: mgorny, klimek.

rename_check.py {misc,bugprone}-forwarding-reference-overload
rename_check.py {misc,bugprone}-macro-repeated-side-effects
rename_check.py {misc,bugprone}-lambda-function-name
rename_check.py {misc,bugprone}-misplaced-widening-cast


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43867

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp
  clang-tidy/bugprone/ForwardingReferenceOverloadCheck.h
  clang-tidy/bugprone/LambdaFunctionNameCheck.cpp
  clang-tidy/bugprone/LambdaFunctionNameCheck.h
  clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.cpp
  clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.h
  clang-tidy/bugprone/MisplacedWideningCastCheck.cpp
  clang-tidy/bugprone/MisplacedWideningCastCheck.h
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/ForwardingReferenceOverloadCheck.cpp
  clang-tidy/misc/ForwardingReferenceOverloadCheck.h
  clang-tidy/misc/LambdaFunctionNameCheck.cpp
  clang-tidy/misc/LambdaFunctionNameCheck.h
  clang-tidy/misc/MacroRepeatedSideEffectsCheck.cpp
  clang-tidy/misc/MacroRepeatedSideEffectsCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/MisplacedWideningCastCheck.cpp
  clang-tidy/misc/MisplacedWideningCastCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-forwarding-reference-overload.rst
  docs/clang-tidy/checks/bugprone-lambda-function-name.rst
  docs/clang-tidy/checks/bugprone-macro-repeated-side-effects.rst
  docs/clang-tidy/checks/bugprone-misplaced-widening-cast.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-forwarding-reference-overload.rst
  docs/clang-tidy/checks/misc-lambda-function-name.rst
  docs/clang-tidy/checks/misc-macro-repeated-side-effects.rst
  docs/clang-tidy/checks/misc-misplaced-widening-cast.rst
  test/clang-tidy/bugprone-forwarding-reference-overload.cpp
  test/clang-tidy/bugprone-lambda-function-name.cpp
  test/clang-tidy/bugprone-macro-repeated-side-effects.c
  test/clang-tidy/bugprone-misplaced-widening-cast-explicit-only.cpp
  test/clang-tidy/bugprone-misplaced-widening-cast-implicit-enabled.cpp
  test/clang-tidy/misc-forwarding-reference-overload.cpp
  test/clang-tidy/misc-lambda-function-name.cpp
  test/clang-tidy/misc-macro-repeated-side-effects.c
  test/clang-tidy/misc-misplaced-widening-cast-explicit-only.cpp
  test/clang-tidy/misc-misplaced-widening-cast-implicit-enabled.cpp

Index: test/clang-tidy/bugprone-misplaced-widening-cast-implicit-enabled.cpp
===
--- test/clang-tidy/bugprone-misplaced-widening-cast-implicit-enabled.cpp
+++ test/clang-tidy/bugprone-misplaced-widening-cast-implicit-enabled.cpp
@@ -1,12 +1,12 @@
-// RUN: %check_clang_tidy %s misc-misplaced-widening-cast %t -- -config="{CheckOptions: [{key: misc-misplaced-widening-cast.CheckImplicitCasts, value: 1}]}" --
+// RUN: %check_clang_tidy %s bugprone-misplaced-widening-cast %t -- -config="{CheckOptions: [{key: bugprone-misplaced-widening-cast.CheckImplicitCasts, value: 1}]}" --
 
 void func(long arg) {}
 
 void assign(int a, int b) {
   long l;
 
   l = a * b;
-  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long' is ineffective, or there is loss of precision before the conversion [misc-misplaced-widening-cast]
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long' is ineffective, or there is loss of precision before the conversion [bugprone-misplaced-widening-cast]
   l = (long)(a * b);
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long'
   l = (long)a * b;
Index: test/clang-tidy/bugprone-misplaced-widening-cast-explicit-only.cpp
===
--- test/clang-tidy/bugprone-misplaced-widening-cast-explicit-only.cpp
+++ test/clang-tidy/bugprone-misplaced-widening-cast-explicit-only.cpp
@@ -1,13 +1,13 @@
-// RUN: %check_clang_tidy %s misc-misplaced-widening-cast %t -- -config="{CheckOptions: [{key: misc-misplaced-widening-cast.CheckImplicitCasts, value: 0}]}" --
+// RUN: %check_clang_tidy %s bugprone-misplaced-widening-cast %t -- -config="{CheckOptions: [{key: bugprone-misplaced-widening-cast.CheckImplicitCasts, value: 0}]}" --
 
 void func(long arg) {}
 
 void assign(int a, int b) {
   long l;
 
   l = a * b;
   l = (long)(a * b);
-  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long' is ineffective, or there is loss of precision before the conversion [misc-misplaced-widening-cast]
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long' is ineffective, or there is loss of precision before the conversion [bugprone-misplaced-widening-cast]
   l = (long)a * b;
 
   l = a << 8;
Index: test/clang-tidy/bugprone-macro-repeated-side-effects.c
==

[PATCH] D43867: Rename a few checks from misc- to bugprone-.

2018-02-28 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh updated this revision to Diff 136275.
alexfh added a comment.

- Fixed a header guard


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43867

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp
  clang-tidy/bugprone/ForwardingReferenceOverloadCheck.h
  clang-tidy/bugprone/LambdaFunctionNameCheck.cpp
  clang-tidy/bugprone/LambdaFunctionNameCheck.h
  clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.cpp
  clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.h
  clang-tidy/bugprone/MisplacedWideningCastCheck.cpp
  clang-tidy/bugprone/MisplacedWideningCastCheck.h
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/ForwardingReferenceOverloadCheck.cpp
  clang-tidy/misc/ForwardingReferenceOverloadCheck.h
  clang-tidy/misc/LambdaFunctionNameCheck.cpp
  clang-tidy/misc/LambdaFunctionNameCheck.h
  clang-tidy/misc/MacroRepeatedSideEffectsCheck.cpp
  clang-tidy/misc/MacroRepeatedSideEffectsCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/MisplacedWideningCastCheck.cpp
  clang-tidy/misc/MisplacedWideningCastCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-forwarding-reference-overload.rst
  docs/clang-tidy/checks/bugprone-lambda-function-name.rst
  docs/clang-tidy/checks/bugprone-macro-repeated-side-effects.rst
  docs/clang-tidy/checks/bugprone-misplaced-widening-cast.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-forwarding-reference-overload.rst
  docs/clang-tidy/checks/misc-lambda-function-name.rst
  docs/clang-tidy/checks/misc-macro-repeated-side-effects.rst
  docs/clang-tidy/checks/misc-misplaced-widening-cast.rst
  test/clang-tidy/bugprone-forwarding-reference-overload.cpp
  test/clang-tidy/bugprone-lambda-function-name.cpp
  test/clang-tidy/bugprone-macro-repeated-side-effects.c
  test/clang-tidy/bugprone-misplaced-widening-cast-explicit-only.cpp
  test/clang-tidy/bugprone-misplaced-widening-cast-implicit-enabled.cpp
  test/clang-tidy/misc-forwarding-reference-overload.cpp
  test/clang-tidy/misc-lambda-function-name.cpp
  test/clang-tidy/misc-macro-repeated-side-effects.c
  test/clang-tidy/misc-misplaced-widening-cast-explicit-only.cpp
  test/clang-tidy/misc-misplaced-widening-cast-implicit-enabled.cpp

Index: test/clang-tidy/bugprone-misplaced-widening-cast-implicit-enabled.cpp
===
--- test/clang-tidy/bugprone-misplaced-widening-cast-implicit-enabled.cpp
+++ test/clang-tidy/bugprone-misplaced-widening-cast-implicit-enabled.cpp
@@ -1,12 +1,12 @@
-// RUN: %check_clang_tidy %s misc-misplaced-widening-cast %t -- -config="{CheckOptions: [{key: misc-misplaced-widening-cast.CheckImplicitCasts, value: 1}]}" --
+// RUN: %check_clang_tidy %s bugprone-misplaced-widening-cast %t -- -config="{CheckOptions: [{key: bugprone-misplaced-widening-cast.CheckImplicitCasts, value: 1}]}" --
 
 void func(long arg) {}
 
 void assign(int a, int b) {
   long l;
 
   l = a * b;
-  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long' is ineffective, or there is loss of precision before the conversion [misc-misplaced-widening-cast]
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long' is ineffective, or there is loss of precision before the conversion [bugprone-misplaced-widening-cast]
   l = (long)(a * b);
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long'
   l = (long)a * b;
Index: test/clang-tidy/bugprone-misplaced-widening-cast-explicit-only.cpp
===
--- test/clang-tidy/bugprone-misplaced-widening-cast-explicit-only.cpp
+++ test/clang-tidy/bugprone-misplaced-widening-cast-explicit-only.cpp
@@ -1,13 +1,13 @@
-// RUN: %check_clang_tidy %s misc-misplaced-widening-cast %t -- -config="{CheckOptions: [{key: misc-misplaced-widening-cast.CheckImplicitCasts, value: 0}]}" --
+// RUN: %check_clang_tidy %s bugprone-misplaced-widening-cast %t -- -config="{CheckOptions: [{key: bugprone-misplaced-widening-cast.CheckImplicitCasts, value: 0}]}" --
 
 void func(long arg) {}
 
 void assign(int a, int b) {
   long l;
 
   l = a * b;
   l = (long)(a * b);
-  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long' is ineffective, or there is loss of precision before the conversion [misc-misplaced-widening-cast]
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long' is ineffective, or there is loss of precision before the conversion [bugprone-misplaced-widening-cast]
   l = (long)a * b;
 
   l = a << 8;
Index: test/clang-tidy/bugprone-macro-repeated-side-effects.c
===
--- test/clang-tidy/bugprone-macro-repeated-side-effects.c
+++ test/clang-tidy/bugprone-macro-repeated-side-effects.c
@@ -1,9 +1,9 @@
-// RUN: %check_clang_tidy %s misc-macro-repeated-side-effects %t
+// RUN: %check_cla

[PATCH] D43867: Rename a few checks from misc- to bugprone-.

2018-02-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

When we do this sort of move, do we want to keep the check under its old name 
for a deprecation period so that we are less likely to break automated scripts 
and whatnot?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43867



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


[PATCH] D43779: [Tooling] [0/1] Refactor FrontendActionFactory::create() to return std::unique_ptr<>

2018-02-28 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Do you have a way to reproduce the gcc crashes?


Repository:
  rL LLVM

https://reviews.llvm.org/D43779



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


[PATCH] D43847: [clang-tidy] Add check: replace string::find(...) == 0 with absl::StartsWith

2018-02-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I need a bit more context because I'm unfamiliar with `absl`. What is this 
module's intended use?




Comment at: clang-tidy/absl/StringFindStartswithCheck.cpp:17-19
+  auto stringClassMatcher = anyOf(cxxRecordDecl(hasName("string")),
+  cxxRecordDecl(hasName("__versa_string")),
+  cxxRecordDecl(hasName("basic_string")));

These should be using elaborated type specifiers to ensure we get the correct 
class, not some class that happens to have the same name. Also, this list 
should be configurable so that users can add their own entries to it.



Comment at: clang-tidy/absl/StringFindStartswithCheck.cpp:44-47
+  const auto *expr = result.Nodes.getNodeAs("expr");
+  const auto *needle = result.Nodes.getNodeAs("needle");
+  const auto *haystack = result.Nodes.getNodeAs("findexpr")
+ ->getImplicitObjectArgument();

Btw, these can use `auto` because the type is spelled out in the initialization.



Comment at: clang-tidy/absl/StringFindStartswithCheck.cpp:69
+  auto diag_out = diag(expr->getLocStart(),
+   (StringRef("Use ") + startswith_str +
+" instead of find() " + expr->getOpcodeStr() + " 0")

Diagnostics shouldn't start with a capital letter (or use terminating 
punctuation).



Comment at: clang-tidy/absl/StringFindStartswithCheck.cpp:72
+   .str())
+  << FixItHint::CreateReplacement(expr->getSourceRange(),
+  (startswith_str + "(" +

This fixit should be guarded in case it lands in the middle of a macro for some 
reason.



Comment at: clang-tidy/absl/StringFindStartswithCheck.h:25
+  using ClangTidyCheck::ClangTidyCheck;
+  void registerPPCallbacks(CompilerInstance &compiler) override;
+  void registerMatchers(ast_matchers::MatchFinder *finder) override;

`compiler` doesn't match our naming conventions (same goes for many other 
identifiers in the check).



Comment at: docs/ReleaseNotes.rst:60
 
+- New `absl-string-find-startswith
+  
`_
 check

The release notes should also document that this is adding an entirely new 
module to clang-tidy and what that module's purpose is.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43847



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


[PATCH] D43779: [Tooling] [0/1] Refactor FrontendActionFactory::create() to return std::unique_ptr<>

2018-02-28 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D43779#1021959, @alexfh wrote:

> Do you have a way to reproduce the gcc crashes?


Not presently.
I'm on debian sid, so gcc4.8 is a lost-for-good relic from ancient past.

I'll try to create an debian-oldstable chroot, which still has gcc4.8, maybe 
that will help.


Repository:
  rL LLVM

https://reviews.llvm.org/D43779



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


[PATCH] D43868: Rename more checks from misc- to bugprone-.

2018-02-28 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh created this revision.
alexfh added reviewers: hokein, sammccall, aaron.ballman.
Herald added subscribers: mgorny, klimek.

clang-tidy/rename_check.py {misc,bugprone}-string-integer-assignment
clang-tidy/rename_check.py {misc,bugprone}-string-literal-with-embedded-nul
clang-tidy/rename_check.py {misc,bugprone}-suspicious-enum-usage
clang-tidy/rename_check.py {misc,bugprone}-suspicious-missing-comma


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43868

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
  clang-tidy/bugprone/StringIntegerAssignmentCheck.h
  clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.cpp
  clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.h
  clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp
  clang-tidy/bugprone/SuspiciousEnumUsageCheck.h
  clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp
  clang-tidy/bugprone/SuspiciousMissingCommaCheck.h
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/StringIntegerAssignmentCheck.cpp
  clang-tidy/misc/StringIntegerAssignmentCheck.h
  clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp
  clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.h
  clang-tidy/misc/SuspiciousEnumUsageCheck.cpp
  clang-tidy/misc/SuspiciousEnumUsageCheck.h
  clang-tidy/misc/SuspiciousMissingCommaCheck.cpp
  clang-tidy/misc/SuspiciousMissingCommaCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-string-integer-assignment.rst
  docs/clang-tidy/checks/bugprone-string-literal-with-embedded-nul.rst
  docs/clang-tidy/checks/bugprone-suspicious-enum-usage.rst
  docs/clang-tidy/checks/bugprone-suspicious-missing-comma.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-string-integer-assignment.rst
  docs/clang-tidy/checks/misc-string-literal-with-embedded-nul.rst
  docs/clang-tidy/checks/misc-suspicious-enum-usage.rst
  docs/clang-tidy/checks/misc-suspicious-missing-comma.rst
  test/clang-tidy/bugprone-string-integer-assignment.cpp
  test/clang-tidy/bugprone-string-literal-with-embedded-nul.cpp
  test/clang-tidy/bugprone-suspicious-enum-usage-strict.cpp
  test/clang-tidy/bugprone-suspicious-enum-usage.cpp
  test/clang-tidy/bugprone-suspicious-missing-comma.cpp
  test/clang-tidy/misc-string-integer-assignment.cpp
  test/clang-tidy/misc-string-literal-with-embedded-nul.cpp
  test/clang-tidy/misc-suspicious-enum-usage-strict.cpp
  test/clang-tidy/misc-suspicious-enum-usage.cpp
  test/clang-tidy/misc-suspicious-missing-comma.cpp

Index: test/clang-tidy/bugprone-suspicious-missing-comma.cpp
===
--- test/clang-tidy/bugprone-suspicious-missing-comma.cpp
+++ test/clang-tidy/bugprone-suspicious-missing-comma.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-suspicious-missing-comma %t
+// RUN: %check_clang_tidy %s bugprone-suspicious-missing-comma %t
 
 const char* Cartoons[] = {
   "Bugs Bunny",
@@ -9,7 +9,7 @@
   "Fred Flintstone",
   "Popeye",
 };
-// CHECK-MESSAGES: :[[@LINE-4]]:3: warning: suspicious string literal, probably missing a comma [misc-suspicious-missing-comma]
+// CHECK-MESSAGES: :[[@LINE-4]]:3: warning: suspicious string literal, probably missing a comma [bugprone-suspicious-missing-comma]
 
 const wchar_t* Colors[] = {
   L"Red", L"Yellow", L"Blue", L"Green", L"Purple", L"Rose", L"White", L"Black"
@@ -68,7 +68,7 @@
   "a", "b", "c", "d", "e", "f",
   "g", "h", "i", "j", "k", "l"
 };
-// CHECK-MESSAGES: :[[@LINE-6]]:3: warning: suspicious string literal, probably missing a comma [misc-suspicious-missing-comma]
+// CHECK-MESSAGES: :[[@LINE-6]]:3: warning: suspicious string literal, probably missing a comma [bugprone-suspicious-missing-comma]
 
 const char* TooManyConcatenatedTokensArray[] = {
   "Dummy line",
Index: test/clang-tidy/bugprone-suspicious-enum-usage.cpp
===
--- test/clang-tidy/bugprone-suspicious-enum-usage.cpp
+++ test/clang-tidy/bugprone-suspicious-enum-usage.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-suspicious-enum-usage %t -- -config="{CheckOptions: [{key: misc-suspicious-enum-usage.StrictMode, value: 0}]}" --
+// RUN: %check_clang_tidy %s bugprone-suspicious-enum-usage %t -- -config="{CheckOptions: [{key: bugprone-suspicious-enum-usage.StrictMode, value: 0}]}" --
 
 enum Empty {
 };
Index: test/clang-tidy/bugprone-suspicious-enum-usage-strict.cpp
===
--- test/clang-tidy/bugprone-suspicious-enum-usage-strict.cpp
+++ test/clang-tidy/bugprone-suspicious-enum-usage-strict.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-suspicious-enum-usage %t -- -config="{CheckOptions: [{key: misc-suspicious-enum-usage.StrictMode, value: 1}]}" --
+// RUN: %check_clang_tidy %s bugprone-suspicious-enum-usage %t -- -config="{CheckOptions: [{key: bugprone-suspicious-enum-

[PATCH] D43867: Rename a few checks from misc- to bugprone-.

2018-02-28 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D43867#1021956, @aaron.ballman wrote:

> When we do this sort of move, do we want to keep the check under its old name 
> for a deprecation period so that we are less likely to break automated 
> scripts and whatnot?


I haven't done this for the previous ~15-20 moves. And I'm afraid this would be 
a rather significant complication of the whole process which I'm not sure how 
to automate. I hope, the release notes we provide should make the changes 
transparent enough for everyone who cares. Or do you have any evidence of these 
renames being actively harmful or at least significantly annoying?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43867



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


[PATCH] D43867: Rename a few checks from misc- to bugprone-.

2018-02-28 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.

In https://reviews.llvm.org/D43867#1021985, @alexfh wrote:

> In https://reviews.llvm.org/D43867#1021956, @aaron.ballman wrote:
>
> > When we do this sort of move, do we want to keep the check under its old 
> > name for a deprecation period so that we are less likely to break automated 
> > scripts and whatnot?
>
>
> I haven't done this for the previous ~15-20 moves. And I'm afraid this would 
> be a rather significant complication of the whole process which I'm not sure 
> how to automate. I hope, the release notes we provide should make the changes 
> transparent enough for everyone who cares. Or do you have any evidence of 
> these renames being actively harmful or at least significantly annoying?


If it's not been done before and people aren't filing bug reports about it, I'm 
certainly fine with continuing the status quo. I don't have direct evidence, 
just indirect evidence of flags being removed/renamed causing automated scripts 
to fail.

This LGTM, thank you!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43867



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


[PATCH] D43869: [clangd] Support include canonicalization in symbol leve.

2018-02-28 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added reviewers: sammccall, hokein.
Herald added subscribers: cfe-commits, jkorous-apple, ilya-biryukov, klimek.

Symbols with different canonical includes might be defined in the same header
(e.g. symbols defined in STL ). This patch adds support for mapping from
qualified symbol names to canonical headers and special mapping for symbols in 



Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43869

Files:
  clangd/index/CanonicalIncludes.cpp
  clangd/index/CanonicalIncludes.h
  clangd/index/SymbolCollector.cpp
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -547,6 +547,32 @@
 }
 #endif
 
+TEST_F(SymbolCollectorTest, STLiosfwd) {
+  CollectorOpts.CollectIncludePath = true;
+  CanonicalIncludes Includes;
+  addSystemHeadersMapping(&Includes);
+  CollectorOpts.Includes = &Includes;
+  // Symbols from  should be mapped individually.
+  TestHeaderName = testPath("iosfwd");
+  TestFileName = testPath("iosfwd.cpp");
+  std::string Header = R"(
+namespace std {
+  class no_map {};
+  class ios {};
+  class ostream {};
+  class filebuf {};
+} // namespace std
+  )";
+  runSymbolCollector(Header, /*Main=*/"");
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(
+  QName("std"),
+  AllOf(QName("std::no_map"), IncludeHeader("")),
+  AllOf(QName("std::ios"), IncludeHeader("")),
+  AllOf(QName("std::ostream"), IncludeHeader("")),
+  AllOf(QName("std::filebuf"), IncludeHeader("";
+}
+
 TEST_F(SymbolCollectorTest, IWYUPragma) {
   CollectorOpts.CollectIncludePath = true;
   CanonicalIncludes Includes;
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -154,13 +154,13 @@
 /// FIXME: we should handle .inc files whose symbols are expected be exported by
 /// their containing headers.
 llvm::Optional
-getIncludeHeader(const SourceManager &SM, SourceLocation Loc,
- const SymbolCollector::Options &Opts) {
+getIncludeHeader(llvm::StringRef QName, const SourceManager &SM,
+ SourceLocation Loc, const SymbolCollector::Options &Opts) {
   llvm::StringRef FilePath = SM.getFilename(Loc);
   if (FilePath.empty())
 return llvm::None;
   if (Opts.Includes) {
-llvm::StringRef Mapped = Opts.Includes->mapHeader(FilePath);
+llvm::StringRef Mapped = Opts.Includes->mapHeader(FilePath, QName);
 if (Mapped != FilePath)
   return (Mapped.startswith("<") || Mapped.startswith("\""))
  ? Mapped.str()
@@ -316,8 +316,8 @@
   if (Opts.CollectIncludePath && shouldCollectIncludePath(S.SymInfo.Kind)) {
 // Use the expansion location to get the #include header since this is
 // where the symbol is exposed.
-if (auto Header =
-getIncludeHeader(SM, SM.getExpansionLoc(ND.getLocation()), Opts))
+if (auto Header = getIncludeHeader(
+QName, SM, SM.getExpansionLoc(ND.getLocation()), Opts))
   Include = std::move(*Header);
   }
   S.CompletionFilterText = FilterText;
Index: clangd/index/CanonicalIncludes.h
===
--- clangd/index/CanonicalIncludes.h
+++ clangd/index/CanonicalIncludes.h
@@ -43,9 +43,18 @@
   /// Maps all files matching \p RE to \p CanonicalPath
   void addRegexMapping(llvm::StringRef RE, llvm::StringRef CanonicalPath);
 
+  /// Sets the canonical include for any symbol with \p QualifiedName.
+  /// Header mappings are ignored if \p QualifiedName matches any symbol in the
+  /// symbol mapping.
+  void addSymbolMapping(llvm::StringRef QualifiedName,
+llvm::StringRef CanonicalPath);
+
   /// \return \p Header itself if there is no mapping for it; otherwise, return
   /// a canonical header name.
-  llvm::StringRef mapHeader(llvm::StringRef Header) const;
+  /// An optional qualified symbol name can be provided to check against the
+  /// symbol mapping.
+  llvm::StringRef mapHeader(llvm::StringRef Header,
+llvm::StringRef QualifiedName = "") const;
 
 private:
   // A map from header patterns to header names. This needs to be mutable so
@@ -55,6 +64,8 @@
   // arbitrary regexes.
   mutable std::vector>
   RegexHeaderMappingTable;
+  // A map from fully qualified symbol names to header names.
+  llvm::StringMap SymbolMapping;
   // Guards Regex matching as it's not thread-safe.
   mutable std::mutex RegexMutex;
 };
@@ -68,8 +79,9 @@
 std::unique_ptr
 collectIWYUHeaderMaps(CanonicalIncludes *Includes);
 
-/// Adds mapping for system headers. Approximately, the following system headers
-/// are handled:
+/// Adds mapping for

[PATCH] D30691: [analyzer] Support for naive cross translational unit analysis

2018-02-28 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.

Thanks Gabor, this looks good to me. Please commit!


https://reviews.llvm.org/D30691



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


[PATCH] D43868: Rename more checks from misc- to bugprone-.

2018-02-28 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!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43868



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


[PATCH] D41517: mmintrin.h documentation fixes and updates

2018-02-28 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: lib/Headers/mmintrin.h:1292
 ///
-/// This intrinsic corresponds to the  VXORPS / XORPS  instruction.
+/// This intrinsic corresponds to the  XOR  instruction.
 ///

craig.topper wrote:
> kromanova wrote:
> > craig.topper wrote:
> > > PXOR?
> > For which platform/compiler? 
> >  
> > I checked, for x86_64 Linux XORPS(no avx)/VXORPS (with -mavx) is generated.
> > For PS4 we generate XORL.
> > 
> > I guess, we need to write something more generic, implying that an 
> > appropriate platform-specific XOR instruction is generated. 
> Ideally to interoperate with other mmx intrinsics it should have been a PXOR 
> into an mmx register. But apparently our mmx support is so limited that we 
> aren't capable of that and instead create it in another domain and move it 
> over.
> 
> I guess just indicate it as a utility function with no specific instruction.
D41908 fixed MMX zero constant creation so you should be able to say "This 
intrinsic corresponds to the  PXOR  instruction."


https://reviews.llvm.org/D41517



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


r326323 - [analyzer] Support for naive cross translation unit analysis

2018-02-28 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Wed Feb 28 05:23:10 2018
New Revision: 326323

URL: http://llvm.org/viewvc/llvm-project?rev=326323&view=rev
Log:
[analyzer] Support for naive cross translation unit analysis

The aim of this patch is to be minimal to enable incremental development of
the feature on the top of the tree. This patch should be an NFC when the
feature is turned off. It is turned off by default and still considered as
experimental.

Technical details are available in the EuroLLVM Talk: 
http://llvm.org/devmtg/2017-03//2017/02/20/accepted-sessions.html#7

Note that the initial prototype was done by A. Sidorin et al.: 
http://lists.llvm.org/pipermail/cfe-dev/2015-October/045730.html

Contributions to the measurements and the new version of the code: Peter 
Szecsi, Zoltan Gera, Daniel Krupp, Kareem Khazem.

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

Added:
cfe/trunk/test/Analysis/Inputs/ctu-chain.cpp
cfe/trunk/test/Analysis/Inputs/ctu-other.cpp
cfe/trunk/test/Analysis/Inputs/externalFnMap.txt
cfe/trunk/test/Analysis/ctu-main.cpp
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt
cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/CMakeLists.txt
cfe/trunk/test/Analysis/analyzer-config.cpp
cfe/trunk/tools/scan-build-py/README.md
cfe/trunk/tools/scan-build-py/libscanbuild/__init__.py
cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py
cfe/trunk/tools/scan-build-py/libscanbuild/arguments.py
cfe/trunk/tools/scan-build-py/libscanbuild/clang.py
cfe/trunk/tools/scan-build-py/libscanbuild/report.py
cfe/trunk/tools/scan-build-py/tests/unit/test_analyze.py
cfe/trunk/tools/scan-build-py/tests/unit/test_clang.py

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h?rev=326323&r1=326322&r2=326323&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h Wed Feb 28 
05:23:10 2018
@@ -308,6 +308,16 @@ private:
   /// \sa shouldDisplayNotesAsEvents
   Optional DisplayNotesAsEvents;
 
+  /// \sa getCTUDir
+  Optional CTUDir;
+
+  /// \sa getCTUIndexName
+  Optional CTUIndexName;
+
+  /// \sa naiveCTUEnabled
+  Optional NaiveCTU;
+
+
   /// A helper function that retrieves option for a given full-qualified
   /// checker name.
   /// Options for checkers can be specified via 'analyzer-config' command-line
@@ -637,6 +647,17 @@ public:
   /// to false when unset.
   bool shouldDisplayNotesAsEvents();
 
+  /// Returns the directory containing the CTU related files.
+  StringRef getCTUDir();
+
+  /// Returns the name of the file containing the CTU index of functions.
+  StringRef getCTUIndexName();
+
+  /// Returns true when naive cross translation unit analysis is enabled.
+  /// This is an experimental feature to inline functions from another
+  /// translation units.
+  bool naiveCTUEnabled();
+
 public:
   AnalyzerOptions() :
 AnalysisStoreOpt(RegionStoreModel),

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h?rev=326323&r1=326322&r2=326323&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h Wed 
Feb 28 05:23:10 2018
@@ -38,6 +38,10 @@ class CXXThisExpr;
 class MaterializeTemporaryExpr;
 class ObjCAtSynchronizedStmt;
 class ObjCForCollectionStmt;
+
+namespace cross_tu {
+class CrossTranslationUnitContext;
+}
   
 namespace ento {
 
@@ -74,6 +78,8 @@ public:
   };
 
 private:
+  cross_tu::CrossTranslationUnitContext &CTU;
+
   AnalysisManager &AMgr;
   
   AnalysisDeclContextManager &AnalysisDeclContexts;
@@ -115,10 +121,9 @@ private:
   InliningModes HowToInline;
 
 public:
-  ExprEngine(AnalysisManager &mgr, bool gcEnabled,
- SetOfConstDecls *VisitedCalleesIn,
- FunctionSummariesTy *FS,
- InliningModes HowToInlineIn);
+  ExprEngine(cross_tu::CrossTranslationUnitContext &CTU, AnalysisManager &mgr,
+ bool gcEnabled, SetOfConstDecls *VisitedCalleesIn,
+ FunctionSummariesTy *FS, Inlini

[PATCH] D43870: [clang-tidy] Another batch of checks to rename from misc- to bugprone-.

2018-02-28 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh created this revision.
alexfh added reviewers: hokein, sammccall, aaron.ballman.
Herald added subscribers: xazax.hun, mgorny, klimek.

clang-tidy/rename_check.py {misc,bugprone}-suspicious-semicolon
clang-tidy/rename_check.py {misc,bugprone}-suspicious-string-compare
clang-tidy/rename_check.py {misc,bugprone}-swapped-arguments
clang-tidy/rename_check.py {misc,bugprone}-undelegated-constructor 
--check_class_name UndelegatedConstructor


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43870

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
  clang-tidy/bugprone/SuspiciousSemicolonCheck.h
  clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp
  clang-tidy/bugprone/SuspiciousStringCompareCheck.h
  clang-tidy/bugprone/SwappedArgumentsCheck.cpp
  clang-tidy/bugprone/SwappedArgumentsCheck.h
  clang-tidy/bugprone/UndelegatedConstructorCheck.cpp
  clang-tidy/bugprone/UndelegatedConstructorCheck.h
  clang-tidy/hicpp/HICPPTidyModule.cpp
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/SuspiciousSemicolonCheck.cpp
  clang-tidy/misc/SuspiciousSemicolonCheck.h
  clang-tidy/misc/SuspiciousStringCompareCheck.cpp
  clang-tidy/misc/SuspiciousStringCompareCheck.h
  clang-tidy/misc/SwappedArgumentsCheck.cpp
  clang-tidy/misc/SwappedArgumentsCheck.h
  clang-tidy/misc/UndelegatedConstructor.cpp
  clang-tidy/misc/UndelegatedConstructor.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-suspicious-semicolon.rst
  docs/clang-tidy/checks/bugprone-suspicious-string-compare.rst
  docs/clang-tidy/checks/bugprone-swapped-arguments.rst
  docs/clang-tidy/checks/bugprone-undelegated-constructor.rst
  docs/clang-tidy/checks/hicpp-undelegated-constructor.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-suspicious-semicolon.rst
  docs/clang-tidy/checks/misc-suspicious-string-compare.rst
  docs/clang-tidy/checks/misc-swapped-arguments.rst
  docs/clang-tidy/checks/misc-undelegated-constructor.rst
  test/clang-tidy/bugprone-suspicious-semicolon-fail.cpp
  test/clang-tidy/bugprone-suspicious-semicolon.cpp
  test/clang-tidy/bugprone-suspicious-string-compare.c
  test/clang-tidy/bugprone-suspicious-string-compare.cpp
  test/clang-tidy/bugprone-swapped-arguments.cpp
  test/clang-tidy/bugprone-undelegated-constructor-cxx98.cpp
  test/clang-tidy/bugprone-undelegated-constructor.cpp
  test/clang-tidy/misc-suspicious-semicolon-fail.cpp
  test/clang-tidy/misc-suspicious-semicolon.cpp
  test/clang-tidy/misc-suspicious-string-compare.c
  test/clang-tidy/misc-suspicious-string-compare.cpp
  test/clang-tidy/misc-swapped-arguments.cpp
  test/clang-tidy/misc-undelegated-constructor-cxx98.cpp
  test/clang-tidy/misc-undelegated-constructor.cpp
  test/clang-tidy/objc-arc-and-properties.m
  test/clang-tidy/objc-no-arc-or-properties.m

Index: test/clang-tidy/objc-no-arc-or-properties.m
===
--- test/clang-tidy/objc-no-arc-or-properties.m
+++ test/clang-tidy/objc-no-arc-or-properties.m
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-suspicious-semicolon %t -- -- -fno-objc-arc -fobjc-abi-version=1
+// RUN: %check_clang_tidy %s bugprone-suspicious-semicolon %t -- -- -fno-objc-arc -fobjc-abi-version=1
 
 // This test ensures check_clang_tidy.py allows disabling Objective-C ARC and
 // Objective-C 2.0 via passing arguments after -- on the command line.
@@ -24,6 +24,6 @@
 void fail(Foo *f)
 {
   if([f shouldDoStuff]); [f nop];
-  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: potentially unintended semicolon [misc-suspicious-semicolon]
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: potentially unintended semicolon [bugprone-suspicious-semicolon]
   // CHECK-FIXES: if([f shouldDoStuff]) [f nop];
 }
Index: test/clang-tidy/objc-arc-and-properties.m
===
--- test/clang-tidy/objc-arc-and-properties.m
+++ test/clang-tidy/objc-arc-and-properties.m
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-suspicious-semicolon %t
+// RUN: %check_clang_tidy %s bugprone-suspicious-semicolon %t
 
 // This test checks if Objective-C 2.0 (@properties) and
 // Automatic Reference Counting (ARC) are enabled for .m files
@@ -16,6 +16,6 @@
 void fail(Foo *f)
 {
   if(f.shouldDoStuff); [f nop];
-  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: potentially unintended semicolon [misc-suspicious-semicolon]
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: potentially unintended semicolon [bugprone-suspicious-semicolon]
   // CHECK-FIXES: if(f.shouldDoStuff) [f nop];
 }
Index: test/clang-tidy/bugprone-undelegated-constructor.cpp
===
--- test/clang-tidy/bugprone-undelegated-constructor.cpp
+++ test/clang-tidy/bugprone-undelegated-constructor.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-undelegated-constructor %t
+// RUN: %check

[PATCH] D30691: [analyzer] Support for naive cross translational unit analysis

2018-02-28 Thread Phabricator via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rC326323: [analyzer] Support for naive cross translation unit 
analysis (authored by xazax, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D30691?vs=134431&id=136283#toc

Repository:
  rC Clang

https://reviews.llvm.org/D30691

Files:
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/CMakeLists.txt
  lib/StaticAnalyzer/Core/CallEvent.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  lib/StaticAnalyzer/Frontend/CMakeLists.txt
  test/Analysis/Inputs/ctu-chain.cpp
  test/Analysis/Inputs/ctu-other.cpp
  test/Analysis/Inputs/externalFnMap.txt
  test/Analysis/analyzer-config.cpp
  test/Analysis/ctu-main.cpp
  tools/scan-build-py/README.md
  tools/scan-build-py/libscanbuild/__init__.py
  tools/scan-build-py/libscanbuild/analyze.py
  tools/scan-build-py/libscanbuild/arguments.py
  tools/scan-build-py/libscanbuild/clang.py
  tools/scan-build-py/libscanbuild/report.py
  tools/scan-build-py/tests/unit/test_analyze.py
  tools/scan-build-py/tests/unit/test_clang.py

Index: lib/StaticAnalyzer/Core/PathDiagnostic.cpp
===
--- lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -379,11 +379,25 @@
   return None;
 }
 
+static bool compareCrossTUSourceLocs(FullSourceLoc XL, FullSourceLoc YL) {
+  std::pair XOffs = XL.getDecomposedLoc();
+  std::pair YOffs = YL.getDecomposedLoc();
+  const SourceManager &SM = XL.getManager();
+  std::pair InSameTU = SM.isInTheSameTranslationUnit(XOffs, YOffs);
+  if (InSameTU.first)
+return XL.isBeforeInTranslationUnitThan(YL);
+  const FileEntry *XFE = SM.getFileEntryForID(XL.getFileID());
+  const FileEntry *YFE = SM.getFileEntryForID(YL.getFileID());
+  if (!XFE || !YFE)
+return XFE && !YFE;
+  return XFE->getName() < YFE->getName();
+}
+
 static bool compare(const PathDiagnostic &X, const PathDiagnostic &Y) {
   FullSourceLoc XL = X.getLocation().asLocation();
   FullSourceLoc YL = Y.getLocation().asLocation();
   if (XL != YL)
-return XL.isBeforeInTranslationUnitThan(YL);
+return compareCrossTUSourceLocs(XL, YL);
   if (X.getBugType() != Y.getBugType())
 return X.getBugType() < Y.getBugType();
   if (X.getCategory() != Y.getCategory())
@@ -403,7 +417,8 @@
 SourceLocation YDL = YD->getLocation();
 if (XDL != YDL) {
   const SourceManager &SM = XL.getManager();
-  return SM.isBeforeInTranslationUnit(XDL, YDL);
+  return compareCrossTUSourceLocs(FullSourceLoc(XDL, SM),
+  FullSourceLoc(YDL, SM));
 }
   }
   PathDiagnostic::meta_iterator XI = X.meta_begin(), XE = X.meta_end();
Index: lib/StaticAnalyzer/Core/CMakeLists.txt
===
--- lib/StaticAnalyzer/Core/CMakeLists.txt
+++ lib/StaticAnalyzer/Core/CMakeLists.txt
@@ -58,6 +58,7 @@
   clangASTMatchers
   clangAnalysis
   clangBasic
+  clangCrossTU
   clangLex
   clangRewrite
   ${Z3_LINK_FILES}
Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -28,6 +28,7 @@
 #include "clang/Analysis/AnalysisDeclContext.h"
 #include "clang/Analysis/CFG.h"
 #include "clang/Analysis/ProgramPoint.h"
+#include "clang/CrossTU/CrossTranslationUnit.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
@@ -405,7 +406,27 @@
 }
   }
 
-  return {};
+  SubEngine *Engine = getState()->getStateManager().getOwningEngine();
+  AnalyzerOptions &Opts = Engine->getAnalysisManager().options;
+
+  // Try to get CTU definition only if CTUDir is provided.
+  if (!Opts.naiveCTUEnabled())
+return RuntimeDefinition();
+
+  cross_tu::CrossTranslationUnitContext &CTUCtx =
+  *Engine->getCrossTranslationUnitContext();
+  llvm::Expected CTUDeclOrError =
+  CTUCtx.getCrossTUDefinition(FD, Opts.getCTUDir(), Opts.getCTUIndexName());
+
+  if (!CTUDeclOrError) {
+handleAllErrors(CTUDeclOrError.takeError(),
+[&](const cross_tu::IndexError &IE) {
+  CTUCtx.emitCrossTUDiagnostics(IE);
+});
+return {};
+  }
+
+  return RuntimeDefinition(*CTUDeclOrError);
 }
 
 void AnyFunctionCall::getInitialStackFrameContents(
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnal

[PATCH] D30691: [analyzer] Support for naive cross translational unit analysis

2018-02-28 Thread Phabricator via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326323: [analyzer] Support for naive cross translation unit 
analysis (authored by xazax, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D30691?vs=134431&id=136282#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30691

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
  cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt
  cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  cfe/trunk/lib/StaticAnalyzer/Frontend/CMakeLists.txt
  cfe/trunk/test/Analysis/Inputs/ctu-chain.cpp
  cfe/trunk/test/Analysis/Inputs/ctu-other.cpp
  cfe/trunk/test/Analysis/Inputs/externalFnMap.txt
  cfe/trunk/test/Analysis/analyzer-config.cpp
  cfe/trunk/test/Analysis/ctu-main.cpp
  cfe/trunk/tools/scan-build-py/README.md
  cfe/trunk/tools/scan-build-py/libscanbuild/__init__.py
  cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py
  cfe/trunk/tools/scan-build-py/libscanbuild/arguments.py
  cfe/trunk/tools/scan-build-py/libscanbuild/clang.py
  cfe/trunk/tools/scan-build-py/libscanbuild/report.py
  cfe/trunk/tools/scan-build-py/tests/unit/test_analyze.py
  cfe/trunk/tools/scan-build-py/tests/unit/test_clang.py

Index: cfe/trunk/tools/scan-build-py/README.md
===
--- cfe/trunk/tools/scan-build-py/README.md
+++ cfe/trunk/tools/scan-build-py/README.md
@@ -41,6 +41,32 @@
 Use `--help` to know more about the commands.
 
 
+How to use the experimental Cross Translation Unit analysis
+---
+
+To run the CTU analysis, a compilation database file has to be created:
+
+$ intercept-build 
+
+To run the Clang Static Analyzer against a compilation database
+with CTU analysis enabled, execute:
+
+$ analyze-build --ctu
+
+For CTU analysis an additional (function-definition) collection-phase is required. 
+For debugging purposes, it is possible to separately execute the collection 
+and the analysis phase. By doing this, the intermediate files used for 
+the analysis are kept on the disk in `./ctu-dir`.
+
+# Collect and store the data required by the CTU analysis
+$ analyze-build --ctu-collect-only
+
+# Analyze using the previously collected data
+$ analyze-build --ctu-analyze-only
+
+Use `--help` to get more information about the commands.
+
+
 Limitations
 ---
 
Index: cfe/trunk/tools/scan-build-py/libscanbuild/arguments.py
===
--- cfe/trunk/tools/scan-build-py/libscanbuild/arguments.py
+++ cfe/trunk/tools/scan-build-py/libscanbuild/arguments.py
@@ -18,8 +18,8 @@
 import argparse
 import logging
 import tempfile
-from libscanbuild import reconfigure_logging
-from libscanbuild.clang import get_checkers
+from libscanbuild import reconfigure_logging, CtuConfig
+from libscanbuild.clang import get_checkers, is_ctu_capable
 
 __all__ = ['parse_args_for_intercept_build', 'parse_args_for_analyze_build',
'parse_args_for_scan_build']
@@ -98,6 +98,11 @@
 # add cdb parameter invisibly to make report module working.
 args.cdb = 'compile_commands.json'
 
+# Make ctu_dir an abspath as it is needed inside clang
+if not from_build_command and hasattr(args, 'ctu_phases') \
+and hasattr(args.ctu_phases, 'dir'):
+args.ctu_dir = os.path.abspath(args.ctu_dir)
+
 
 def validate_args_for_analyze(parser, args, from_build_command):
 """ Command line parsing is done by the argparse module, but semantic
@@ -122,6 +127,18 @@
 elif not from_build_command and not os.path.exists(args.cdb):
 parser.error(message='compilation database is missing')
 
+# If the user wants CTU mode
+if not from_build_command and hasattr(args, 'ctu_phases') \
+and hasattr(args.ctu_phases, 'dir'):
+# If CTU analyze_only, the input directory should exist
+if args.ctu_phases.analyze and not args.ctu_phases.collect \
+and not os.path.exists(args.ctu_dir):
+parser.error(message='missing CTU directory')
+# Check CTU capability via checking clang-func-mapping
+if not is_ctu_capable(args.func_map_cmd):
+parser.error(message="""This version of clang does not support CTU
+functionality or clang-func-mapping command not found.""")
+
 
 def create_intercept_parser():
 """ Creates a parser for command

[PATCH] D43870: [clang-tidy] Another batch of checks to rename from misc- to bugprone-.

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

LGTM with a couple of drive-by nits that could be fixed if you wanted to.




Comment at: docs/clang-tidy/checks/bugprone-swapped-arguments.rst:6
+
+
+Finds potentially swapped arguments by looking at implicit conversions.

Can get rid of the extra newline while you're at it.



Comment at: docs/clang-tidy/checks/bugprone-undelegated-constructor.rst:6
 
 
 Finds creation of temporary objects in constructors that look like a

Same here, if you'd like.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43870



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


[PATCH] D43766: [clang-tidy][modernize-make-unique] Checks c++14 flag before using std::make_unique

2018-02-28 Thread Frederic Tingaud via Phabricator via cfe-commits
ftingaud updated this revision to Diff 136286.
ftingaud added a comment.

Correct case of custom make_unique functions that should still work in c++11.


https://reviews.llvm.org/D43766

Files:
  clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tidy/modernize/MakeSmartPtrCheck.h
  clang-tidy/modernize/MakeUniqueCheck.cpp
  clang-tidy/modernize/MakeUniqueCheck.h
  test/clang-tidy/modernize-make-unique-cxx11.cpp
  test/clang-tidy/modernize-make-unique-cxx14.cpp
  test/clang-tidy/modernize-make-unique-macros.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
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s modernize-make-unique %t -- -- -std=c++11 \
+// RUN: %check_clang_tidy %s modernize-make-unique %t -- -- -std=c++14 \
 // RUN:   -I%S/Inputs/modernize-smart-ptr
 
 #include "unique_ptr.h"
Index: test/clang-tidy/modernize-make-unique-macros.cpp
===
--- test/clang-tidy/modernize-make-unique-macros.cpp
+++ test/clang-tidy/modernize-make-unique-macros.cpp
@@ -1,6 +1,6 @@
 // RUN: %check_clang_tidy %s modernize-make-unique %t -- \
 // RUN:   -config="{CheckOptions: [{key: modernize-make-unique.IgnoreMacros, value: 0}]}" \
-// RUN:   -- -std=c++11  -I%S/Inputs/modernize-smart-ptr
+// RUN:   -- -std=c++14  -I%S/Inputs/modernize-smart-ptr
 
 #include "unique_ptr.h"
 
Index: test/clang-tidy/modernize-make-unique-cxx14.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-make-unique-cxx14.cpp
@@ -0,0 +1,12 @@
+// RUN: %check_clang_tidy %s modernize-make-unique %t -- -- -std=c++14 \
+// RUN:   -I%S/Inputs/modernize-smart-ptr
+
+#include "unique_ptr.h"
+// CHECK-FIXES: #include 
+
+int main() {
+  auto my_ptr = std::unique_ptr(new int(1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use std::make_unique instead
+  // CHECK-FIXES: auto my_ptr = std::make_unique(1);
+  return 0;
+}
Index: test/clang-tidy/modernize-make-unique-cxx11.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-make-unique-cxx11.cpp
@@ -0,0 +1,11 @@
+// RUN: %check_clang_tidy %s modernize-make-unique %t -- -- -std=c++11 \
+// RUN:   -I%S/Inputs/modernize-smart-ptr
+
+#include "unique_ptr.h"
+// CHECK-FIXES: #include "unique_ptr.h"
+
+int main() {
+  auto my_ptr = std::unique_ptr(new int(1));
+  // CHECK-FIXES: auto my_ptr = std::unique_ptr(new int(1));
+  return 0;
+}
Index: clang-tidy/modernize/MakeUniqueCheck.h
===
--- clang-tidy/modernize/MakeUniqueCheck.h
+++ clang-tidy/modernize/MakeUniqueCheck.h
@@ -31,6 +31,13 @@
 
 protected:
   SmartPtrTypeMatcher getSmartPointerTypeMatcher() const override;
+
+  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override;
+
+private:
+  const std::string MinimumLanguageVersion;
+
+  const std::string getDefaultMinimumLanguageVersion() const;
 };
 
 } // namespace modernize
Index: clang-tidy/modernize/MakeUniqueCheck.cpp
===
--- clang-tidy/modernize/MakeUniqueCheck.cpp
+++ clang-tidy/modernize/MakeUniqueCheck.cpp
@@ -17,7 +17,13 @@
 
 MakeUniqueCheck::MakeUniqueCheck(StringRef Name,
  clang::tidy::ClangTidyContext *Context)
-: MakeSmartPtrCheck(Name, Context, "std::make_unique") {}
+: MakeSmartPtrCheck(Name, Context, "std::make_unique"),
+  MinimumLanguageVersion(Options.get("MakeUniqueLanguageVersion",
+ getDefaultMinimumLanguageVersion())) {}
+
+const std::string MakeUniqueCheck::getDefaultMinimumLanguageVersion() const {
+  return Options.get("MakeSmartPtrFunction", "").empty() ? "c++14" : "c++11";
+}
 
 MakeUniqueCheck::SmartPtrTypeMatcher
 MakeUniqueCheck::getSmartPointerTypeMatcher() const {
@@ -36,6 +42,13 @@
 equalsBoundNode(PointerType;
 }
 
+bool MakeUniqueCheck::isLanguageVersionSupported(
+const LangOptions &LangOpts) const {
+  if (MinimumLanguageVersion == "c++14")
+return LangOpts.CPlusPlus14;
+  return LangOpts.CPlusPlus11;
+}
+
 } // namespace modernize
 } // namespace tidy
 } // namespace clang
Index: clang-tidy/modernize/MakeSmartPtrCheck.h
===
--- clang-tidy/modernize/MakeSmartPtrCheck.h
+++ clang-tidy/modernize/MakeSmartPtrCheck.h
@@ -40,6 +40,9 @@
   /// in this class.
   virtual SmartPtrTypeMatcher getSmartPointerTypeMatcher() const = 0;
 
+  /// Returns whether the C++ version is compatible with current check.
+  virtual bool isLanguageVersionSupported(const LangOptions &LangOpts) const;
+
   static const char PointerType[];
   static const char

r326324 - [analyzer] Fix a compiler warning

2018-02-28 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Wed Feb 28 06:01:48 2018
New Revision: 326324

URL: http://llvm.org/viewvc/llvm-project?rev=326324&view=rev
Log:
[analyzer] Fix a compiler warning

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h?rev=326324&r1=326323&r2=326324&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h Wed 
Feb 28 06:01:48 2018
@@ -155,7 +155,8 @@ public:
 
   BugReporter& getBugReporter() { return BR; }
 
-  cross_tu::CrossTranslationUnitContext *getCrossTranslationUnitContext() {
+  cross_tu::CrossTranslationUnitContext *
+  getCrossTranslationUnitContext() override {
 return &CTU;
   }
 


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


[clang-tools-extra] r326325 - [clangd] A few more fixes for STL header mapping.

2018-02-28 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed Feb 28 06:02:18 2018
New Revision: 326325

URL: http://llvm.org/viewvc/llvm-project?rev=326325&view=rev
Log:
[clangd] A few more fixes for STL header mapping.

Modified:
clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp

Modified: clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp?rev=326325&r1=326324&r2=326325&view=diff
==
--- clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp Wed Feb 28 
06:02:18 2018
@@ -140,6 +140,7 @@ void addSystemHeadersMapping(CanonicalIn
   {"backward/binders.h$", ""},
   {"bits/algorithmfwd.h$", ""},
   {"bits/alloc_traits.h$", ""},
+  {"bits/allocated_ptr.h$", ""},
   {"bits/allocator.h$", ""},
   {"bits/atomic_base.h$", ""},
   {"bits/atomic_lockfree_defines.h$", ""},
@@ -171,6 +172,7 @@ void addSystemHeadersMapping(CanonicalIn
   {"bits/list.tcc$", ""},
   {"bits/locale_classes.h$", ""},
   {"bits/locale_classes.tcc$", ""},
+  {"bits/locale_conv.h$", ""},
   {"bits/locale_facets.h$", ""},
   {"bits/locale_facets.tcc$", ""},
   {"bits/locale_facets_nonio.h$", ""},
@@ -183,6 +185,7 @@ void addSystemHeadersMapping(CanonicalIn
   {"bits/ostream.tcc$", ""},
   {"bits/ostream_insert.h$", ""},
   {"bits/postypes.h$", ""},
+  {"bits/predefined_ops.h$", ""},
   {"bits/ptr_traits.h$", ""},
   {"bits/random.h$", ""},
   {"bits/random.tcc$", ""},
@@ -197,8 +200,10 @@ void addSystemHeadersMapping(CanonicalIn
   {"bits/regex_nfa.h$", ""},
   {"bits/shared_ptr.h$", ""},
   {"bits/shared_ptr_base.h$", ""},
+  {"bits/shared_ptr_atomic.h$", ""},
   {"bits/slice_array.h$", ""},
   {"bits/sstream.tcc$", ""},
+  {"bits/std_mutex.h$", ""},
   {"bits/stl_algo.h$", ""},
   {"bits/stl_algobase.h$", ""},
   {"bits/stl_bvector.h$", ""},
@@ -228,6 +233,7 @@ void addSystemHeadersMapping(CanonicalIn
   {"bits/streambuf.tcc$", ""},
   {"bits/streambuf_iterator.h$", ""},
   {"bits/stringfwd.h$", ""},
+  {"bits/uniform_int_dist.h$", ""},
   {"bits/unique_ptr.h$", ""},
   {"bits/unordered_map.h$", ""},
   {"bits/unordered_set.h$", ""},
@@ -374,7 +380,7 @@ void addSystemHeadersMapping(CanonicalIn
   {"bits/atomic_word.h$", ""},
   {"bits/basic_file.h$", ""},
   {"bits/c\\+\\+allocator.h$", ""},
-  {"bits/c\\+\\+config.h$", ""},
+  {"bits/c\\+\\+config.h$", ""},
   {"bits/c\\+\\+io.h$", ""},
   {"bits/c\\+\\+locale.h$", ""},
   {"bits/cpu_defines.h$", ""},


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


[PATCH] D43871: [modules] No longer include stdlib.h from mm_malloc.h.

2018-02-28 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor created this revision.
teemperor added reviewers: rsmith, v.g.vassilev, chandlerc.

The GNU C library includes headers from the `_Builtin_intrinsics` module. As 
the `_Builtin_intrinsics` module via
the `mm_malloc.h` header also includes the `stdlib.h` header from libc, we get 
a cyclic dependency with
`-fmodules` enabled. The best way to solve this is seems to be removing the 
`stdlib.h` include from `mm_malloc.h`
and make the redeclarations in there work without the include.

This patch is doing this in two steps:

1. It reverts some of the changes done in r119958 which re-added the include to 
`mm_malloc.h` and removed the forward declarations.

2. It expands the workaround in Sema::CheckEquivalentExceptionSpec to also work 
in the case where we first declare a function with a missing empty exception 
specification and then redeclare it with an empty exception specification.

The second part is necessary because the current workaround only works in the 
case where the redeclaration
is missing an empty exception specification and the `#include ` 
before our redeclaration ensured that
we always have our declarations in this expected order.

I compiled a few projects with this patch (curl, ncnn, opencv, openjpeg, 
scummvm, sqlite, zlib), and it doesn't
seem to break any compilation there.


Repository:
  rC Clang

https://reviews.llvm.org/D43871

Files:
  lib/Headers/mm_malloc.h
  lib/Sema/SemaExceptionSpec.cpp
  test/CXX/except/except.spec/libc-empty-except-sys/libc-empty-except.h
  test/CXX/except/except.spec/libc-empty-except.cpp

Index: test/CXX/except/except.spec/libc-empty-except.cpp
===
--- /dev/null
+++ test/CXX/except/except.spec/libc-empty-except.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -std=c++11 -isystem %S/libc-empty-except-sys -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
+// RUN: not %clang_cc1 -std=c++11 -I %S/libc-empty-except-sys -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+#include "libc-empty-except.h"
+
+void f() {
+  free(nullptr);
+}
Index: test/CXX/except/except.spec/libc-empty-except-sys/libc-empty-except.h
===
--- /dev/null
+++ test/CXX/except/except.spec/libc-empty-except-sys/libc-empty-except.h
@@ -0,0 +1,3 @@
+extern "C" void free(void *ptr) throw();
+// missing throw() is allowed in this case as we are in a system header.
+extern "C" void free(void *ptr);
Index: lib/Sema/SemaExceptionSpec.cpp
===
--- lib/Sema/SemaExceptionSpec.cpp
+++ lib/Sema/SemaExceptionSpec.cpp
@@ -213,6 +213,7 @@
 const FunctionProtoType *New, SourceLocation NewLoc,
 bool *MissingExceptionSpecification = nullptr,
 bool *MissingEmptyExceptionSpecification = nullptr,
+bool *ExtraEmptyExceptionSpecification = nullptr,
 bool AllowNoexceptAllMatchWithNoSpec = false, bool IsOperatorNew = false);
 
 /// Determine whether a function has an implicitly-generated exception
@@ -236,6 +237,15 @@
   return !Ty->hasExceptionSpec();
 }
 
+/// Returns true if the given function is a function/builtin with C linkage
+/// and from a system header.
+static bool isCSystemFuncOrBuiltin(FunctionDecl *D, ASTContext &Context) {
+  return (D->getLocation().isInvalid() ||
+  Context.getSourceManager().isInSystemHeader(D->getLocation()) ||
+  D->getBuiltinID()) &&
+ D->isExternC();
+}
+
 bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) {
   // Just completely ignore this under -fno-exceptions prior to C++17.
   // In C++17 onwards, the exception specification is part of the type and
@@ -247,6 +257,14 @@
   bool IsOperatorNew = OO == OO_New || OO == OO_Array_New;
   bool MissingExceptionSpecification = false;
   bool MissingEmptyExceptionSpecification = false;
+  bool ExtraEmptyExceptionSpecification = false;
+  bool *AllowExtraEmptyExceptionSpecification = nullptr;
+
+  // If both functions are from C functions from system headers, we want to
+  // know if the redeclaration has an additional empty exception specification.
+  if (isCSystemFuncOrBuiltin(Old, Context) &&
+  isCSystemFuncOrBuiltin(New, Context))
+AllowExtraEmptyExceptionSpecification = &ExtraEmptyExceptionSpecification;
 
   unsigned DiagID = diag::err_mismatched_exception_spec;
   bool ReturnValueOnError = true;
@@ -258,11 +276,12 @@
   // Check the types as written: they must match before any exception
   // specification adjustment is applied.
   if (!CheckEquivalentExceptionSpecImpl(
-*this, PDiag(DiagID), PDiag(diag::note_previous_declaration),
-Old->getType()->getAs(), Old->getLocation(),
-New->getType()->getAs(), New->getLocation(),
-&MissingExceptionSpecification, &MissingEmptyExceptionSpecification,
-/*AllowNoexceptAllMatchWithNoSpec=*/true, IsOperatorNew)) {
+  *this, PDiag(DiagID), PDiag

[PATCH] D43852: [OpenMP] Extend NVPTX SPMD implementation of combined constructs

2018-02-28 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG, with some nits




Comment at: include/clang/Driver/Options.td:1428
+def fopenmp_cuda_mode : Flag<["-"], "fopenmp-cuda-mode">, Group, 
Flags<[CC1Option, NoArgumentUnused]>;
+def fno_openmp_cuda_mode : Flag<["-"], "fno-openmp-cuda-mode">, 
Group, Flags<[NoArgumentUnused]>;
 def fno_optimize_sibling_calls : Flag<["-"], "fno-optimize-sibling-calls">, 
Group;

This flag also must be `CC1Option`



Comment at: lib/Frontend/CompilerInvocation.cpp:2533
+  Args.hasFlag(OPT_fopenmp_cuda_mode, OPT_fno_openmp_cuda_mode,
+   /*Default=*/false);
+

After some thoughts I think it is better to make `true` by default, because 
`Generic` mode is not completed yet.


Repository:
  rC Clang

https://reviews.llvm.org/D43852



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


[clang-tools-extra] r326327 - Rename a few checks from misc- to bugprone-.

2018-02-28 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Feb 28 06:47:20 2018
New Revision: 326327

URL: http://llvm.org/viewvc/llvm-project?rev=326327&view=rev
Log:
Rename a few checks from misc- to bugprone-.

Summary:
rename_check.py {misc,bugprone}-forwarding-reference-overload
rename_check.py {misc,bugprone}-macro-repeated-side-effects
rename_check.py {misc,bugprone}-lambda-function-name
rename_check.py {misc,bugprone}-misplaced-widening-cast

Reviewers: hokein, sammccall, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: klimek, cfe-commits, mgorny

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

Added:

clang-tools-extra/trunk/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp
  - copied, changed from r326321, 
clang-tools-extra/trunk/clang-tidy/misc/ForwardingReferenceOverloadCheck.cpp

clang-tools-extra/trunk/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.h
  - copied, changed from r326321, 
clang-tools-extra/trunk/clang-tidy/misc/ForwardingReferenceOverloadCheck.h
clang-tools-extra/trunk/clang-tidy/bugprone/LambdaFunctionNameCheck.cpp
  - copied, changed from r326321, 
clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/LambdaFunctionNameCheck.h
  - copied, changed from r326321, 
clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.h

clang-tools-extra/trunk/clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.cpp
  - copied, changed from r326321, 
clang-tools-extra/trunk/clang-tidy/misc/MacroRepeatedSideEffectsCheck.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.h
  - copied, changed from r326321, 
clang-tools-extra/trunk/clang-tidy/misc/MacroRepeatedSideEffectsCheck.h
clang-tools-extra/trunk/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp
  - copied, changed from r326321, 
clang-tools-extra/trunk/clang-tidy/misc/MisplacedWideningCastCheck.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/MisplacedWideningCastCheck.h
  - copied, changed from r326321, 
clang-tools-extra/trunk/clang-tidy/misc/MisplacedWideningCastCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-forwarding-reference-overload.rst
  - copied, changed from r326321, 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-forwarding-reference-overload.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-lambda-function-name.rst
  - copied, changed from r326321, 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-lambda-function-name.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-macro-repeated-side-effects.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-misplaced-widening-cast.rst
  - copied, changed from r326321, 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-misplaced-widening-cast.rst

clang-tools-extra/trunk/test/clang-tidy/bugprone-forwarding-reference-overload.cpp
  - copied, changed from r326321, 
clang-tools-extra/trunk/test/clang-tidy/misc-forwarding-reference-overload.cpp
clang-tools-extra/trunk/test/clang-tidy/bugprone-lambda-function-name.cpp
  - copied, changed from r326321, 
clang-tools-extra/trunk/test/clang-tidy/misc-lambda-function-name.cpp

clang-tools-extra/trunk/test/clang-tidy/bugprone-macro-repeated-side-effects.c
  - copied, changed from r326321, 
clang-tools-extra/trunk/test/clang-tidy/misc-macro-repeated-side-effects.c

clang-tools-extra/trunk/test/clang-tidy/bugprone-misplaced-widening-cast-explicit-only.cpp
  - copied, changed from r326321, 
clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast-explicit-only.cpp

clang-tools-extra/trunk/test/clang-tidy/bugprone-misplaced-widening-cast-implicit-enabled.cpp
  - copied, changed from r326321, 
clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast-implicit-enabled.cpp
Removed:
clang-tools-extra/trunk/clang-tidy/misc/ForwardingReferenceOverloadCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/ForwardingReferenceOverloadCheck.h
clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.h
clang-tools-extra/trunk/clang-tidy/misc/MacroRepeatedSideEffectsCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/MacroRepeatedSideEffectsCheck.h
clang-tools-extra/trunk/clang-tidy/misc/MisplacedWideningCastCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/MisplacedWideningCastCheck.h

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

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-macro-repeated-side-effects.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-misplaced-widening-cast.rst

clang-tools-extra/trunk/test/clang-tidy/misc-forwarding-reference-overload.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-lambda-function-name.

[PATCH] D43183: clang-format: introduce `CaseBlockIndent` to control indent in switch

2018-02-28 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

> I don't agree that that's the same thing. The closing brace is still neatly 
> aligned with the line of the opening brace (which happens to be just the 
> opening brace).

This invariant is not really applicable to switch statements, where code of 
each "branch" is already indented with no opening brace. :-)

I can try to change the mode so that we get either "google" style:

  switch (x) {
  case 0: {
foo():
  } break;
  }

or "regular indentation" mode (e.g. what would look like no special indentation 
rule):

  switch (x) {
  case 0:
{
  foo():
}
break;
  }

Generally, would a flag for `CaseBlockIndent` be acceptable for this purpose ?
Or should the behavior simply be selected depending on `IndentCaseLabels` ?


Repository:
  rC Clang

https://reviews.llvm.org/D43183



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


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

2018-02-28 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

ping?


Repository:
  rC Clang

https://reviews.llvm.org/D43015



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


[PATCH] D43852: [OpenMP] Extend NVPTX SPMD implementation of combined constructs

2018-02-28 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:3976-3977
+  // cuda-mode flag
+  Args.AddLastArg(CmdArgs, options::OPT_fopenmp_cuda_mode,
+  options::OPT_fno_openmp_cuda_mode);
   break;

I think most other boolean options do the following:
```lang=c++
if (Args.hasFlag(...))
  CmdArgs.push_back("...")
```

Is there a reason we need this differently here?



Comment at: lib/Frontend/CompilerInvocation.cpp:2533
+  Args.hasFlag(OPT_fopenmp_cuda_mode, OPT_fno_openmp_cuda_mode,
+   /*Default=*/false);
+

ABataev wrote:
> After some thoughts I think it is better to make `true` by default, because 
> `Generic` mode is not completed yet.
Yes, I'd also expect all SPMD constructs to default to CUDA mode. Or is there a 
case where this doesn't work? If yes, that should be explained in the summary.


Repository:
  rC Clang

https://reviews.llvm.org/D43852



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


[PATCH] D42787: clang-format: do not add extra indent when wrapping last parameter

2018-02-28 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

In https://reviews.llvm.org/D42787#994781, @djasper wrote:

> What I mean is, users will find it surprising if whether or not a parameter 
> gets wrapped leads to a different indentation internal to that parameter. I 
> have not heard of a single user that would be surprised by this extra 
> indentation.


well you have now...
I configured the tool to align AlignOperands, to I expected the operands of my 
expressions to be aligned, even if they are in a function call.

(Btw, I don't think the comma used to separate function parameters are actually 
considered "operators" by the C++ standard, so technically this is not a case 
of multiple precedences, and users may not expect it to be handled this way...)


Repository:
  rC Clang

https://reviews.llvm.org/D42787



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


[PATCH] D42729: clang-format: Fix formatting of function body followed by semicolon

2018-02-28 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

In https://reviews.llvm.org/D42729#994841, @djasper wrote:

> - Of course you find all sorts of errors while testing clang-format on a 
> large-enough codebase. That doesn't mean that users run into them much.
> - We have had about 10k clang-format users internally for several years. The 
> semicolon issue comes up but really rarely and if it does, people happily fix 
> their code not blaming clang-format.
>
>   Unrelated, my point remains that setting BlockKind in TokenAnnotator is bad 
> enough that I wouldn't want to do it for reaping this small benefit. And I 
> can't see how you could easily achieve the same thing without doing that.


Just a question though. I there a reason brace matching (and other parts of 
TokenAnnotations) are not performed before LineUnwrapping? That would probably 
allow fixing this issue more cleanly (though I am not sure I would have the 
time to actually perform this probably significant task)...


Repository:
  rC Clang

https://reviews.llvm.org/D42729



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


[PATCH] D43852: [OpenMP] Extend NVPTX SPMD implementation of combined constructs

2018-02-28 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: include/clang/Driver/Options.td:1428
+def fopenmp_cuda_mode : Flag<["-"], "fopenmp-cuda-mode">, Group, 
Flags<[CC1Option, NoArgumentUnused]>;
+def fno_openmp_cuda_mode : Flag<["-"], "fno-openmp-cuda-mode">, 
Group, Flags<[NoArgumentUnused]>;
 def fno_optimize_sibling_calls : Flag<["-"], "fno-optimize-sibling-calls">, 
Group;

ABataev wrote:
> This flag also must be `CC1Option`
If you implement Jonas's suggested fix, no need to mark it as `CC1Option`



Comment at: lib/Driver/ToolChains/Clang.cpp:3976-3977
+  // cuda-mode flag
+  Args.AddLastArg(CmdArgs, options::OPT_fopenmp_cuda_mode,
+  options::OPT_fno_openmp_cuda_mode);
   break;

Hahnfeld wrote:
> I think most other boolean options do the following:
> ```lang=c++
> if (Args.hasFlag(...))
>   CmdArgs.push_back("...")
> ```
> 
> Is there a reason we need this differently here?
Agree, this looks much better



Comment at: lib/Frontend/CompilerInvocation.cpp:2533
+  Args.hasFlag(OPT_fopenmp_cuda_mode, OPT_fno_openmp_cuda_mode,
+   /*Default=*/false);
+

Hahnfeld wrote:
> ABataev wrote:
> > After some thoughts I think it is better to make `true` by default, because 
> > `Generic` mode is not completed yet.
> Yes, I'd also expect all SPMD constructs to default to CUDA mode. Or is there 
> a case where this doesn't work? If yes, that should be explained in the 
> summary.
Cuda mode is going to be the default for all constructs, as `Generic` mode is 
not ready yet. The codegen mode is not controlled by the construct, but by the 
option completely.


Repository:
  rC Clang

https://reviews.llvm.org/D43852



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


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

2018-02-28 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

In https://reviews.llvm.org/D42684#1013005, @djasper wrote:

> Please given an explanation of what you are trying to achieve with this 
> change. Do you intend to set the penalty high so that clang-format does other 
> things first before falling back to wrapping template declarations?
>
> Why treat separate declarations differently wrt. wrapping the template 
> declarations? Will this stop at classes vs. functions? I generally have 
> doubts that this option carries it's weight. Do you have a style guide that 
> explicitly tells you to do this?


I set the penalty relatively high (200), i.e. the same penalty that I have set 
for `PenaltyBreakAssignment`, `PenaltyBreakBeforeFirstCallParameter`, and 
`PenaltyReturnTypeOnItsOwnLine`.
Basically we don't have a preference as to where the break should be, and we 
found that setting the same penalty for all these parameters (including the new 
`PenaltyBreakTemplateDeclaration`) gives really "natural" result: e.g. very 
close to how a user would optimize the code wrapping for readability.

At the moment `AlwaysBreakTemplateDeclarations` actually applies only to 
classes, thus templates are always wrapped before functions (unless it all fits 
on one line). A simpler change would have been to make 
`AlwaysBreakTemplateDeclarations` stick to its name, and let it apply to 
functions as well: but I figured with would break existing clang-format styles.


Repository:
  rC Clang

https://reviews.llvm.org/D42684



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


[PATCH] D37813: clang-format: better handle namespace macros

2018-02-28 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

> Some initial design work has been done, and Krasimir said that he's 
> interested. No timeline though :(

any update or progress maybe?


https://reviews.llvm.org/D37813



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


[PATCH] D42729: clang-format: Fix formatting of function body followed by semicolon

2018-02-28 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

In https://reviews.llvm.org/D42729#1022069, @Typz wrote:

> In https://reviews.llvm.org/D42729#994841, @djasper wrote:
>
> > - Of course you find all sorts of errors while testing clang-format on a 
> > large-enough codebase. That doesn't mean that users run into them much.
> > - We have had about 10k clang-format users internally for several years. 
> > The semicolon issue comes up but really rarely and if it does, people 
> > happily fix their code not blaming clang-format.
> >
> >   Unrelated, my point remains that setting BlockKind in TokenAnnotator is 
> > bad enough that I wouldn't want to do it for reaping this small benefit. 
> > And I can't see how you could easily achieve the same thing without doing 
> > that.
>
>
> Just a question though. I there a reason brace matching (and other parts of 
> TokenAnnotations) are not performed before LineUnwrapping? That would 
> probably allow fixing this issue more cleanly (though I am not sure I would 
> have the time to actually perform this probably significant task)...


I think this is just the way it has grown. And brace/paren matching is actually 
done in both places several times by now, I think :(.

Fundamentally, the UnwrappedLineParser had the task of splitting a source file 
into lines and only implemented what it needed for that. The TokenAnnotator 
then did a much more elaborate analysis on each line to determine token types 
and such and distinguish what a "<" actually is (comparison vs. template 
opener). Having these two things be separate makes it slightly easier for error 
recovery and such as the state space they can be in is somewhat more limited.


Repository:
  rC Clang

https://reviews.llvm.org/D42729



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


[PATCH] D32525: [clang-format] Add SpaceBeforeColon option

2018-02-28 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

ping?


https://reviews.llvm.org/D32525



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


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

2018-02-28 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

I think it's possible that this is just a bug/oversight. But I don't fully 
understand the case where it is not behaving as you expect. Can you give me an 
example (config setting + code that's not formatted as you expect)?


Repository:
  rC Clang

https://reviews.llvm.org/D42684



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


[PATCH] D42787: clang-format: do not add extra indent when wrapping last parameter

2018-02-28 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

But you *do* want extra indentation in the case of:

  function(a, 
   b +
   cc);

I understand you argument, but I don't agree at the moment. As is (without 
getting more feedback from others that clang-format is behaving unexpected 
here), I do not want to move forward with this change.


Repository:
  rC Clang

https://reviews.llvm.org/D42787



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


[PATCH] D32525: [clang-format] Add SpaceBeforeColon option

2018-02-28 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

I think this generally looks good, but needs a few more tests.




Comment at: include/clang/Format/Format.h:1204
 
+  /// \brief If ``false``, spaces will be removed before constructor 
initializer
+  /// colon.

When this file is changed, can you also run docs/tools/dump_format_style.py to 
update the docs?



Comment at: unittests/Format/FormatTest.cpp:7539
+  verifyFormat("class Foo : public Bar {};", CtorInitializerStyle);
+  verifyFormat("Foo::Foo(): foo(1) {}", CtorInitializerStyle);
+  verifyFormat("for (auto a : b) {\n}", CtorInitializerStyle);

Can you add tests for the other values of BreakConstructorInitializers 
(BCIS_BeforeColon, BCIS_BeforeComma)?


https://reviews.llvm.org/D32525



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


[PATCH] D41102: Setup clang-doc frontend framework

2018-02-28 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang-doc/BitcodeWriter.h:37
+  static constexpr unsigned SubblockIDSize = 4U;
+  static constexpr unsigned BoolSize = 1U;
+  static constexpr unsigned IntSize = 16U;

Hmm, you build with asserts enabled, right?
I tried testing this, and three tests fail with
```
clang-doc: /build/llvm/include/llvm/Bitcode/BitstreamWriter.h:122: void 
llvm::BitstreamWriter::Emit(uint32_t, unsigned int): Assertion `(Val & ~(~0U >> 
(32-NumBits))) == 0 && "High bits set!"' failed.
```
```
Failing Tests (3):
Clang Tools :: clang-doc/mapper-class-in-function.cpp
Clang Tools :: clang-doc/mapper-function.cpp
Clang Tools :: clang-doc/mapper-method.cpp

  Expected Passes: 6
  Unexpected Failures: 3
```
At least one failure is because of `BoolSize`, so i'd suspect the assertion 
itself is wrong...


https://reviews.llvm.org/D41102



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


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

2018-02-28 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

The problem I have is really related to the current 
`AlwaysBreakTemplateDeclarations` behavior, which does not apply to functions.
I set it to false, and I get this:

  template<>
  void (
  const bbb & cc);

instead of:

  template<> void (
  const bbb & cc);

Then when this is fixed the penalty for breaking after the templates part is 
hardcoded to 10 (`prec::Level::Relational`), which was not always wrapping as 
expected (that is definitely subjective, but that is the beauty of penalties...)


Repository:
  rC Clang

https://reviews.llvm.org/D42684



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


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

2018-02-28 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

If both this and https://reviews.llvm.org/D32525 are submitted, then we also 
need more tests for the combination of the two parameters.




Comment at: include/clang/Format/Format.h:852
+  /// \brief Different ways to break inheritance list.
+  enum BreakInheritanceListStyle {
+/// Break inheritance list before the colon and after the commas.

Update the docs with docs/tools/dump_format_style.py.


Repository:
  rC Clang

https://reviews.llvm.org/D43015



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


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

2018-02-28 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

In https://reviews.llvm.org/D42684#1022093, @Typz wrote:

> The problem I have is really related to the current 
> `AlwaysBreakTemplateDeclarations` behavior, which does not apply to functions.
>  I set it to false, and I get this:
>
>   template<>
>   void (
>   const bbb & cc);
>   
>
> instead of:
>
>   template<> void 
> (
>   const bbb & cc);
>   
>
> Then when this is fixed the penalty for breaking after the templates part is 
> hardcoded to 10 (`prec::Level::Relational`), which was not always wrapping as 
> expected (that is definitely subjective, but that is the beauty of 
> penalties...)


Ah, I see. However, you are misunderstanding what the parameter is meant to do 
(and I think what the name says). It is controlling whether we "always" break 
before the template declaration (even if everything would fit on just one 
line). Setting it to false, i.e. "not always" breaking, does not imply that 
there is any particular situation in which we need to keep it on the same line.

I understand what you want to achieve, but I don't think it is related to 
whether this is a function or a class declaration, i.e. clang-format also does:

  template 
  class 
  : BB {};

although the template declaration would easily fit on the same line.

So this change does not seem like the right one to make in order to get the 
options to be more intuitive and for you to get the behavior you want. I'll try 
to think about how to achieve that. Do you have any ideas?


Repository:
  rC Clang

https://reviews.llvm.org/D42684



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


[PATCH] D43183: clang-format: introduce `CaseBlockIndent` to control indent in switch

2018-02-28 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

New options for this would not be acceptable IMO. Too much cost for too little 
benefit.

I'd suggest to first make the change to fall back to the style with a regular 
block when there are statements other than break after the closing brace. That 
is always bad, no matter the indentation of the case labels:

  switch (x) {
case 1: {
  doSomething();
}
  doSomethingElse();
  break;
  }

Fixing this is good no matter what.

And then the second question is whether this style should be used or not (with 
IndentCaseLabels: false):

  switch (x) {
  case 1: {
doSomething();
  }
  }

Pro: Saves horizontal and vertical space.
Con: It's weird to have to braces in the same column.

I don't personally have an opinion here, but I'll check with a few LLVM 
developers who work with LLVM style.


Repository:
  rC Clang

https://reviews.llvm.org/D43183



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


[PATCH] D32525: [clang-format] Add SpaceBeforeColon option

2018-02-28 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 136299.
Typz marked 2 inline comments as done.
Typz added a comment.

Address review comments.


Repository:
  rC Clang

https://reviews.llvm.org/D32525

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -8933,6 +8933,103 @@
   verifyFormat("a or_eq 8;", Spaces);
 }
 
+TEST_F(FormatTest, ConfigurableSpaceBeforeColon) {
+  verifyFormat("class Foo : public Bar {};");
+  verifyFormat("Foo::Foo() : foo(1) {}");
+  verifyFormat("for (auto a : b) {\n}");
+  verifyFormat("int x = a ? b : c;");
+  verifyFormat("{\n"
+   "label0:\n"
+   "  int x = 0;\n"
+   "}");
+  verifyFormat("switch (x) {\n"
+   "case 1:\n"
+   "default:\n"
+   "}");
+
+  FormatStyle CtorInitializerStyle = getLLVMStyleWithColumns(30);
+  CtorInitializerStyle.SpaceBeforeCtorInitializerColon = false;
+  verifyFormat("class Foo : public Bar {};", CtorInitializerStyle);
+  verifyFormat("Foo::Foo(): foo(1) {}", CtorInitializerStyle);
+  verifyFormat("for (auto a : b) {\n}", CtorInitializerStyle);
+  verifyFormat("int x = a ? b : c;", CtorInitializerStyle);
+  verifyFormat("{\n"
+   "label1:\n"
+   "  int x = 0;\n"
+   "}",
+   CtorInitializerStyle);
+  verifyFormat("switch (x) {\n"
+   "case 1:\n"
+   "default:\n"
+   "}",
+   CtorInitializerStyle);
+  CtorInitializerStyle.BreakConstructorInitializers = FormatStyle::BCIS_AfterColon;
+  verifyFormat("Fooo::Fooo():\n"
+   "barr(1) {}", CtorInitializerStyle);
+  CtorInitializerStyle.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
+  verifyFormat("Fooo::Fooo()\n"
+   ": barr(1) {}", CtorInitializerStyle);
+  CtorInitializerStyle.BreakConstructorInitializers = FormatStyle::BCIS_BeforeColon;
+  verifyFormat("Fooo::Fooo()\n"
+   ": barr(1) {}", CtorInitializerStyle);
+  CtorInitializerStyle.ConstructorInitializerIndentWidth = 0;
+  verifyFormat("Fooo::Fooo()\n"
+   ": barr(1) {}", CtorInitializerStyle);
+
+  FormatStyle InheritanceStyle = getLLVMStyle();
+  InheritanceStyle.SpaceBeforeInheritanceColon = false;
+  verifyFormat("class Foo: public Bar {};", InheritanceStyle);
+  verifyFormat("Foo::Foo() : foo(1) {}", InheritanceStyle);
+  verifyFormat("for (auto a : b) {\n}", InheritanceStyle);
+  verifyFormat("int x = a ? b : c;", InheritanceStyle);
+  verifyFormat("{\n"
+   "label2:\n"
+   "  int x = 0;\n"
+   "}",
+   InheritanceStyle);
+  verifyFormat("switch (x) {\n"
+   "case 1:\n"
+   "default:\n"
+   "}",
+   InheritanceStyle);
+
+  FormatStyle ForLoopStyle = getLLVMStyle();
+  ForLoopStyle.SpaceBeforeRangeBasedForLoopColon = false;
+  verifyFormat("class Foo : public Bar {};", ForLoopStyle);
+  verifyFormat("Foo::Foo() : foo(1) {}", ForLoopStyle);
+  verifyFormat("for (auto a: b) {\n}", ForLoopStyle);
+  verifyFormat("int x = a ? b : c;", ForLoopStyle);
+  verifyFormat("{\n"
+   "label2:\n"
+   "  int x = 0;\n"
+   "}",
+   ForLoopStyle);
+  verifyFormat("switch (x) {\n"
+   "case 1:\n"
+   "default:\n"
+   "}",
+   ForLoopStyle);
+
+  FormatStyle NoSpaceStyle = getLLVMStyle();
+  NoSpaceStyle.SpaceBeforeCtorInitializerColon = false;
+  NoSpaceStyle.SpaceBeforeInheritanceColon = false;
+  NoSpaceStyle.SpaceBeforeRangeBasedForLoopColon = false;
+  verifyFormat("class Foo: public Bar {};", NoSpaceStyle);
+  verifyFormat("Foo::Foo(): foo(1) {}", NoSpaceStyle);
+  verifyFormat("for (auto a: b) {\n}", NoSpaceStyle);
+  verifyFormat("int x = a ? b : c;", NoSpaceStyle);
+  verifyFormat("{\n"
+   "label3:\n"
+   "  int x = 0;\n"
+   "}",
+   NoSpaceStyle);
+  verifyFormat("switch (x) {\n"
+   "case 1:\n"
+   "default:\n"
+   "}",
+   NoSpaceStyle);
+}
+
 TEST_F(FormatTest, AlignConsecutiveAssignments) {
   FormatStyle Alignment = getLLVMStyle();
   Alignment.AlignConsecutiveAssignments = false;
@@ -10274,6 +10371,9 @@
   CHECK_PARSE_BOOL(SpaceAfterCStyleCast);
   CHECK_PARSE_BOOL(SpaceAfterTemplateKeyword);
   CHECK_PARSE_BOOL(SpaceBeforeAssignmentOperators);
+  CHECK_PARSE_BOOL(SpaceBeforeCtorInitializerColon);
+  CHECK_PARSE_BOOL(SpaceBeforeInheritanceColon);
+  CHECK_PARSE_BOOL(SpaceBeforeRangeBasedForLoopColon);
 
   CHECK_PARSE_NESTED_BOOL(BraceWra

[PATCH] D32525: [clang-format] Add SpaceBeforeColon option

2018-02-28 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added inline comments.



Comment at: unittests/Format/FormatTest.cpp:8969
+   "barr(1) {}", CtorInitializerStyle);
+  CtorInitializerStyle.BreakConstructorInitializers = 
FormatStyle::BCIS_BeforeComma;
+  verifyFormat("Fooo::Fooo()\n"

This is a useless test if it doesn't actually have multiple initializers 
separated by a comma.



Comment at: unittests/Format/FormatTest.cpp:8971
+  verifyFormat("Fooo::Fooo()\n"
+   ": barr(1) {}", CtorInitializerStyle);
+  CtorInitializerStyle.BreakConstructorInitializers = 
FormatStyle::BCIS_BeforeColon;

Has this been formatted by clang-format? I think it'd break after the comma.


Repository:
  rC Clang

https://reviews.llvm.org/D32525



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


[PATCH] D43851: Start setting dllimport/dllexport in setGVProperties

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

getting phab to send an email to cfe-commits


https://reviews.llvm.org/D43851



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


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

2018-02-28 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 136300.
Typz marked an inline comment as done.
Typz added a comment.

Address review comments, and rebase on https://reviews.llvm.org/D32525


Repository:
  rC Clang

https://reviews.llvm.org/D43015

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -1286,15 +1286,40 @@
   verifyFormat("class ::A::B {};");
 }
 
-TEST_F(FormatTest, BreakBeforeInheritanceComma) {
-  FormatStyle StyleWithInheritanceBreak = getLLVMStyle();
-  StyleWithInheritanceBreak.BreakBeforeInheritanceComma = true;
-
-  verifyFormat("class MyClass : public X {};", StyleWithInheritanceBreak);
+TEST_F(FormatTest, BreakInheritanceStyle) {
+  FormatStyle StyleWithInheritanceBreakBeforeComma = getLLVMStyle();
+  StyleWithInheritanceBreakBeforeComma.BreakInheritanceList =
+  FormatStyle::BILS_BeforeComma;
+  verifyFormat("class MyClass : public X {};",
+   StyleWithInheritanceBreakBeforeComma);
   verifyFormat("class MyClass\n"
": public X\n"
", public Y {};",
-   StyleWithInheritanceBreak);
+   StyleWithInheritanceBreakBeforeComma);
+  verifyFormat("class AA\n"
+   ": public BB\n"
+   ", public CC {};",
+   StyleWithInheritanceBreakBeforeComma);
+  verifyFormat("struct a\n"
+   ": public aaa< // break\n"
+   "  > {};",
+   StyleWithInheritanceBreakBeforeComma);
+
+  FormatStyle StyleWithInheritanceBreakAfterColon = getLLVMStyle();
+  StyleWithInheritanceBreakAfterColon.BreakInheritanceList =
+  FormatStyle::BILS_AfterColon;
+  verifyFormat("class MyClass : public X {};",
+   StyleWithInheritanceBreakAfterColon);
+  verifyFormat("class MyClass : public X, public Y {};",
+   StyleWithInheritanceBreakAfterColon);
+  verifyFormat("class AA :\n"
+   "public BB,\n"
+   "public CC {};",
+   StyleWithInheritanceBreakAfterColon);
+  verifyFormat("struct a :\n"
+   "public aaa< // break\n"
+   "> {};",
+   StyleWithInheritanceBreakAfterColon);
 }
 
 TEST_F(FormatTest, FormatsVariableDeclarationsAfterStructOrClass) {
@@ -3696,6 +3721,23 @@
"  aa,\n"
"  bb {}",
Style);
+
+  // `ConstructorInitializerIndentWidth` actually applies to InheritanceList as well
+  Style.BreakInheritanceList = FormatStyle::BILS_BeforeColon;
+  verifyFormat("class SomeClass\n"
+   "  : public aa,\n"
+   "public bb {};",
+   Style);
+  Style.BreakInheritanceList = FormatStyle::BILS_BeforeComma;
+  verifyFormat("class SomeClass\n"
+   "  : public aa\n"
+   "  , public bb {};",
+   Style);
+  Style.BreakInheritanceList = FormatStyle::BILS_AfterColon;
+  verifyFormat("class SomeClass :\n"
+   "  public aa,\n"
+   "  public bb {};",
+   Style);
 }
 
 #ifndef EXPENSIVE_CHECKS
@@ -8976,7 +9018,7 @@
   verifyFormat("Fooo::Fooo()\n"
": barr(1) {}", CtorInitializerStyle);
 
-  FormatStyle InheritanceStyle = getLLVMStyle();
+  FormatStyle InheritanceStyle = getLLVMStyleWithColumns(30);
   InheritanceStyle.SpaceBeforeInheritanceColon = false;
   verifyFormat("class Foo: public Bar {};", InheritanceStyle);
   verifyFormat("Foo::Foo() : foo(1) {}", InheritanceStyle);
@@ -8992,6 +9034,21 @@
"default:\n"
"}",
InheritanceStyle);
+  InheritanceStyle.BreakInheritanceList = FormatStyle::BILS_AfterColon;
+  verifyFormat("class Foo:\n"
+   "public Ba {\n"
+   "}", InheritanceStyle);
+  InheritanceStyle.BreakInheritanceList = FormatStyle::BILS_BeforeComma;
+  verifyFormat("class Foo\n"
+   ": public Ba {\n"
+   "}", InheritanceStyle);
+ 

[PATCH] D41102: Setup clang-doc frontend framework

2018-02-28 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added inline comments.



Comment at: clang-doc/BitcodeWriter.h:37
+  static constexpr unsigned SubblockIDSize = 4U;
+  static constexpr unsigned BoolSize = 1U;
+  static constexpr unsigned IntSize = 16U;

lebedev.ri wrote:
> Hmm, you build with asserts enabled, right?
> I tried testing this, and three tests fail with
> ```
> clang-doc: /build/llvm/include/llvm/Bitcode/BitstreamWriter.h:122: void 
> llvm::BitstreamWriter::Emit(uint32_t, unsigned int): Assertion `(Val & ~(~0U 
> >> (32-NumBits))) == 0 && "High bits set!"' failed.
> ```
> ```
> Failing Tests (3):
> Clang Tools :: clang-doc/mapper-class-in-function.cpp
> Clang Tools :: clang-doc/mapper-function.cpp
> Clang Tools :: clang-doc/mapper-method.cpp
> 
>   Expected Passes: 6
>   Unexpected Failures: 3
> ```
> At least one failure is because of `BoolSize`, so i'd suspect the assertion 
> itself is wrong...
I do, and I've definitely seen that one triggered before but it's been because 
something was off in how the data was being outputted as I was shifting things 
around. That said, I'm not seeing it in my local build with this diff though -- 
I'll update it again just to make sure they're in sync.


https://reviews.llvm.org/D41102



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


[PATCH] D34367: CodeGen: Fix address space of indirect function argument

2018-02-28 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 136301.
yaxunl added a comment.

Revised by John's comments.

Added CallArg::copyInto and modified CallArg::getRValue() to return an 
independent r-value by default. However some cases expecting l-value not 
copied, therefore I added an optional argument to CallArg::getRValue() to 
return l-value as aggregate directly.


https://reviews.llvm.org/D34367

Files:
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGCall.h
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CGGPUBuiltin.cpp
  lib/CodeGen/CGObjCGNU.cpp
  lib/CodeGen/CGObjCMac.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/amdgcn-func-arg.cpp
  test/CodeGenOpenCL/addr-space-struct-arg.cl
  test/CodeGenOpenCL/byval.cl

Index: test/CodeGenOpenCL/byval.cl
===
--- test/CodeGenOpenCL/byval.cl
+++ test/CodeGenOpenCL/byval.cl
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn %s | FileCheck %s
-// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn---opencl %s | FileCheck %s
 
 struct A {
   int x[100];
Index: test/CodeGenOpenCL/addr-space-struct-arg.cl
===
--- test/CodeGenOpenCL/addr-space-struct-arg.cl
+++ test/CodeGenOpenCL/addr-space-struct-arg.cl
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -O0 -finclude-default-header -ffake-address-space-map -triple i686-pc-darwin | FileCheck -enable-var-scope -check-prefixes=COM,X86 %s
 // RUN: %clang_cc1 %s -emit-llvm -o - -O0 -finclude-default-header -triple amdgcn-amdhsa-amd | FileCheck -enable-var-scope -check-prefixes=COM,AMDGCN %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL2.0 -O0 -finclude-default-header -triple amdgcn-amdhsa-amd | FileCheck -enable-var-scope -check-prefixes=COM,AMDGCN,AMDGCN20 %s
 
 typedef struct {
   int cells[9];
@@ -35,6 +36,9 @@
   int2 y[20];
 };
 
+#if __OPENCL_C_VERSION__ >= 200
+struct LargeStructOneMember g_s;
+#endif
 
 // X86-LABEL: define void @foo(%struct.Mat4X4* noalias sret %agg.result, %struct.Mat3X3* byval align 4 %in)
 // AMDGCN-LABEL: define %struct.Mat4X4 @foo([9 x i32] %in.coerce)
@@ -80,10 +84,42 @@
 }
 
 // AMDGCN-LABEL: define void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %u)
+// AMDGCN-NOT: addrspacecast
+// AMDGCN:   store <2 x i32> %{{.*}}, <2 x i32> addrspace(5)*
 void FuncOneLargeMember(struct LargeStructOneMember u) {
   u.x[0] = (int2)(0, 0);
 }
 
+// AMDGCN20-LABEL: define void @test_indirect_arg_globl()
+// AMDGCN20:  %[[byval_temp:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5)
+// AMDGCN20:  %[[r0:.*]] = bitcast %struct.LargeStructOneMember addrspace(5)* %[[byval_temp]] to i8 addrspace(5)*
+// AMDGCN20:  call void @llvm.memcpy.p5i8.p1i8.i64(i8 addrspace(5)* align 8 %[[r0]], i8 addrspace(1)* align 8 bitcast (%struct.LargeStructOneMember addrspace(1)* @g_s to i8 addrspace(1)*), i64 800, i1 false)
+// AMDGCN20:  call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %[[byval_temp]])
+#if __OPENCL_C_VERSION__ >= 200
+void test_indirect_arg_globl(void) {
+  FuncOneLargeMember(g_s);
+}
+#endif
+
+// AMDGCN-LABEL: define amdgpu_kernel void @test_indirect_arg_local()
+// AMDGCN: %[[byval_temp:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5)
+// AMDGCN: %[[r0:.*]] = bitcast %struct.LargeStructOneMember addrspace(5)* %[[byval_temp]] to i8 addrspace(5)*
+// AMDGCN: call void @llvm.memcpy.p5i8.p3i8.i64(i8 addrspace(5)* align 8 %[[r0]], i8 addrspace(3)* align 8 bitcast (%struct.LargeStructOneMember addrspace(3)* @test_indirect_arg_local.l_s to i8 addrspace(3)*), i64 800, i1 false)
+// AMDGCN: call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %[[byval_temp]])
+kernel void test_indirect_arg_local(void) {
+  local struct LargeStructOneMember l_s;
+  FuncOneLargeMember(l_s);
+}
+
+// AMDGCN-LABEL: define void @test_indirect_arg_private()
+// AMDGCN: %[[p_s:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5)
+// AMDGCN-NOT: @llvm.memcpy
+// AMDGCN-NEXT: call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %[[p_s]])
+void test_indirect_arg_private(void) {
+  struct LargeStructOneMember p_s;
+  FuncOneLargeMember(p_s);
+}
+
 // AMDGCN-LABEL: define amdgpu_kernel void @KernelOneMember
 // AMDGCN-SAME:  (<2 x i32> %[[u_coerce:.*]])
 // AMDGCN:  %[[u:.*]] = alloca %struct.StructOneMember, align 8, addrspace(5)
@@ -112,7 +148,6 @@
   u.y[0] = (int2)(0, 0);
 }
 
-
 // AMDGCN-LABEL: define amdgpu_kernel void @KernelTwoMember
 // AMDGCN-SAME:  (%struct.StructTwoMember %[[u_coerce:.*]])
 // AMDGCN:  %[[u:.*]] = alloca %struct.StructTwoMember, align 8, addrspace(5)
Index: test/CodeGenCXX/amdgcn-func-arg.cpp
===
--- /dev/null
+++ test/CodeGenCXX/amdg

[PATCH] D41102: Setup clang-doc frontend framework

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

Running clang-format and fixing newlines


https://reviews.llvm.org/D41102

Files:
  CMakeLists.txt
  clang-doc/BitcodeWriter.cpp
  clang-doc/BitcodeWriter.h
  clang-doc/CMakeLists.txt
  clang-doc/ClangDoc.h
  clang-doc/Mapper.cpp
  clang-doc/Mapper.h
  clang-doc/Representation.h
  clang-doc/Serialize.cpp
  clang-doc/Serialize.h
  clang-doc/tool/CMakeLists.txt
  clang-doc/tool/ClangDocMain.cpp
  docs/clang-doc.rst
  test/CMakeLists.txt
  test/clang-doc/mapper-class-in-class.cpp
  test/clang-doc/mapper-class-in-function.cpp
  test/clang-doc/mapper-class.cpp
  test/clang-doc/mapper-enum.cpp
  test/clang-doc/mapper-function.cpp
  test/clang-doc/mapper-method.cpp
  test/clang-doc/mapper-namespace.cpp
  test/clang-doc/mapper-struct.cpp
  test/clang-doc/mapper-union.cpp

Index: test/clang-doc/mapper-union.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-union.cpp
@@ -0,0 +1,28 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@u...@d.bc --dump | FileCheck %s
+
+union D { int X; int Y; };
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@U@D'
+  // CHECK:  blob data = 'D'
+  // CHECK: 
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'D::X'
+// CHECK: 
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'D::Y'
+// CHECK: 
+  // CHECK: 
+// CHECK: 
Index: test/clang-doc/mapper-struct.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-struct.cpp
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@s...@c.bc --dump | FileCheck %s
+
+struct C { int i; };
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@S@C'
+  // CHECK:  blob data = 'C'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'C::i'
+// CHECK: 
+  // CHECK: 
+// CHECK: 
Index: test/clang-doc/mapper-namespace.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-namespace.cpp
@@ -0,0 +1,16 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@n...@a.bc --dump | FileCheck %s
+
+namespace A {}
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@N@A'
+  // CHECK:  blob data = 'A'
+// CHECK: 
Index: test/clang-doc/mapper-method.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-method.cpp
@@ -0,0 +1,30 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@S@G@F@Method#I#.bc --dump | FileCheck %s
+
+class G {
+public: 
+	int Method(int param) { return param; }
+};
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@S@G@F@Method#I#'
+  // CHECK:  blob data = 'Method'
+  // CHECK:  blob data = 'c:@S@G'
+  // CHECK: 
+  // CHECK: 
+  // CHECK:  blob data = 'c:@S@G'
+  // CHECK: 
+// CHECK:  blob data = 'int'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'param'
+  // CHECK: 
+// CHECK: 
Index: test/clang-doc/mapper-function.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-function.cpp
@@ -0,0 +1,24 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@F@F#I#.bc --dump | FileCheck %s
+
+int F(int param) { return param; }
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@F@F#I#'
+  // CHECK:  blob data = 'F'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'param'
+  // CHECK: 
+// CHECK: 
Index: test/clang-doc/mapper-enum.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-enum.cpp
@@ -0,0 +1,23 @@
+// RUN:

[PATCH] D32525: [clang-format] Add SpaceBeforeColon option

2018-02-28 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 136305.
Typz marked 2 inline comments as done.
Typz added a comment.

Address review comments


Repository:
  rC Clang

https://reviews.llvm.org/D32525

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -8933,6 +8933,114 @@
   verifyFormat("a or_eq 8;", Spaces);
 }
 
+TEST_F(FormatTest, ConfigurableSpaceBeforeColon) {
+  verifyFormat("class Foo : public Bar {};");
+  verifyFormat("Foo::Foo() : foo(1) {}");
+  verifyFormat("for (auto a : b) {\n}");
+  verifyFormat("int x = a ? b : c;");
+  verifyFormat("{\n"
+   "label0:\n"
+   "  int x = 0;\n"
+   "}");
+  verifyFormat("switch (x) {\n"
+   "case 1:\n"
+   "default:\n"
+   "}");
+
+  FormatStyle CtorInitializerStyle = getLLVMStyleWithColumns(30);
+  CtorInitializerStyle.SpaceBeforeCtorInitializerColon = false;
+  verifyFormat("class Foo : public Bar {};", CtorInitializerStyle);
+  verifyFormat("Foo::Foo(): foo(1) {}", CtorInitializerStyle);
+  verifyFormat("for (auto a : b) {\n}", CtorInitializerStyle);
+  verifyFormat("int x = a ? b : c;", CtorInitializerStyle);
+  verifyFormat("{\n"
+   "label1:\n"
+   "  int x = 0;\n"
+   "}",
+   CtorInitializerStyle);
+  verifyFormat("switch (x) {\n"
+   "case 1:\n"
+   "default:\n"
+   "}",
+   CtorInitializerStyle);
+  CtorInitializerStyle.BreakConstructorInitializers =
+  FormatStyle::BCIS_AfterColon;
+  verifyFormat("Fooo::Fooo():\n"
+   "(1),\n"
+   "(2) {}",
+   CtorInitializerStyle);
+  CtorInitializerStyle.BreakConstructorInitializers =
+  FormatStyle::BCIS_BeforeComma;
+  verifyFormat("Fooo::Fooo()\n"
+   ": (1)\n"
+   ", (2) {}",
+   CtorInitializerStyle);
+  CtorInitializerStyle.BreakConstructorInitializers =
+  FormatStyle::BCIS_BeforeColon;
+  verifyFormat("Fooo::Fooo()\n"
+   ": (1),\n"
+   "  (2) {}",
+   CtorInitializerStyle);
+  CtorInitializerStyle.ConstructorInitializerIndentWidth = 0;
+  verifyFormat("Fooo::Fooo()\n"
+   ": (1),\n"
+   "  (2) {}",
+   CtorInitializerStyle);
+
+  FormatStyle InheritanceStyle = getLLVMStyle();
+  InheritanceStyle.SpaceBeforeInheritanceColon = false;
+  verifyFormat("class Foo: public Bar {};", InheritanceStyle);
+  verifyFormat("Foo::Foo() : foo(1) {}", InheritanceStyle);
+  verifyFormat("for (auto a : b) {\n}", InheritanceStyle);
+  verifyFormat("int x = a ? b : c;", InheritanceStyle);
+  verifyFormat("{\n"
+   "label2:\n"
+   "  int x = 0;\n"
+   "}",
+   InheritanceStyle);
+  verifyFormat("switch (x) {\n"
+   "case 1:\n"
+   "default:\n"
+   "}",
+   InheritanceStyle);
+
+  FormatStyle ForLoopStyle = getLLVMStyle();
+  ForLoopStyle.SpaceBeforeRangeBasedForLoopColon = false;
+  verifyFormat("class Foo : public Bar {};", ForLoopStyle);
+  verifyFormat("Foo::Foo() : foo(1) {}", ForLoopStyle);
+  verifyFormat("for (auto a: b) {\n}", ForLoopStyle);
+  verifyFormat("int x = a ? b : c;", ForLoopStyle);
+  verifyFormat("{\n"
+   "label2:\n"
+   "  int x = 0;\n"
+   "}",
+   ForLoopStyle);
+  verifyFormat("switch (x) {\n"
+   "case 1:\n"
+   "default:\n"
+   "}",
+   ForLoopStyle);
+
+  FormatStyle NoSpaceStyle = getLLVMStyle();
+  NoSpaceStyle.SpaceBeforeCtorInitializerColon = false;
+  NoSpaceStyle.SpaceBeforeInheritanceColon = false;
+  NoSpaceStyle.SpaceBeforeRangeBasedForLoopColon = false;
+  verifyFormat("class Foo: public Bar {};", NoSpaceStyle);
+  verifyFormat("Foo::Foo(): foo(1) {}", NoSpaceStyle);
+  verifyFormat("for (auto a: b) {\n}", NoSpaceStyle);
+  verifyFormat("int x = a ? b : c;", NoSpaceStyle);
+  verifyFormat("{\n"
+   "label3:\n"
+   "  int x = 0;\n"
+   "}",
+   NoSpaceStyle);
+  verifyFormat("switch (x) {\n"
+   "case 1:\n"
+   "default:\n"
+   "}",
+   NoSpaceStyle);
+}
+
 TEST_F(FormatTest, AlignConsecutiveAssignments) {
   FormatStyle Alignment = getLLVMStyle();
   Alignment.AlignConsecutiveAssignments = false;
@@ -10274,6 +10382,9 @@
   CHECK_PARSE_BOOL(SpaceAfterCStyleCast);
   CHECK_PARSE_BOOL(SpaceAfterTem

[PATCH] D32525: [clang-format] Add SpaceBeforeColon option

2018-02-28 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added inline comments.



Comment at: unittests/Format/FormatTest.cpp:8969
+   "barr(1) {}", CtorInitializerStyle);
+  CtorInitializerStyle.BreakConstructorInitializers = 
FormatStyle::BCIS_BeforeComma;
+  verifyFormat("Fooo::Fooo()\n"

djasper wrote:
> This is a useless test if it doesn't actually have multiple initializers 
> separated by a comma.
since we are interested only in the behavior next to the colon, I think it is 
relevant... But I'll add extra parameter to make it more realistic,


Repository:
  rC Clang

https://reviews.llvm.org/D32525



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


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

2018-02-28 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 136306.
Typz added a comment.

Address review comments of https://reviews.llvm.org/D32525


Repository:
  rC Clang

https://reviews.llvm.org/D43015

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -1286,15 +1286,40 @@
   verifyFormat("class ::A::B {};");
 }
 
-TEST_F(FormatTest, BreakBeforeInheritanceComma) {
-  FormatStyle StyleWithInheritanceBreak = getLLVMStyle();
-  StyleWithInheritanceBreak.BreakBeforeInheritanceComma = true;
-
-  verifyFormat("class MyClass : public X {};", StyleWithInheritanceBreak);
+TEST_F(FormatTest, BreakInheritanceStyle) {
+  FormatStyle StyleWithInheritanceBreakBeforeComma = getLLVMStyle();
+  StyleWithInheritanceBreakBeforeComma.BreakInheritanceList =
+  FormatStyle::BILS_BeforeComma;
+  verifyFormat("class MyClass : public X {};",
+   StyleWithInheritanceBreakBeforeComma);
   verifyFormat("class MyClass\n"
": public X\n"
", public Y {};",
-   StyleWithInheritanceBreak);
+   StyleWithInheritanceBreakBeforeComma);
+  verifyFormat("class AA\n"
+   ": public BB\n"
+   ", public CC {};",
+   StyleWithInheritanceBreakBeforeComma);
+  verifyFormat("struct a\n"
+   ": public aaa< // break\n"
+   "  > {};",
+   StyleWithInheritanceBreakBeforeComma);
+
+  FormatStyle StyleWithInheritanceBreakAfterColon = getLLVMStyle();
+  StyleWithInheritanceBreakAfterColon.BreakInheritanceList =
+  FormatStyle::BILS_AfterColon;
+  verifyFormat("class MyClass : public X {};",
+   StyleWithInheritanceBreakAfterColon);
+  verifyFormat("class MyClass : public X, public Y {};",
+   StyleWithInheritanceBreakAfterColon);
+  verifyFormat("class AA :\n"
+   "public BB,\n"
+   "public CC {};",
+   StyleWithInheritanceBreakAfterColon);
+  verifyFormat("struct a :\n"
+   "public aaa< // break\n"
+   "> {};",
+   StyleWithInheritanceBreakAfterColon);
 }
 
 TEST_F(FormatTest, FormatsVariableDeclarationsAfterStructOrClass) {
@@ -3696,6 +3721,23 @@
"  aa,\n"
"  bb {}",
Style);
+
+  // `ConstructorInitializerIndentWidth` actually applies to InheritanceList as well
+  Style.BreakInheritanceList = FormatStyle::BILS_BeforeColon;
+  verifyFormat("class SomeClass\n"
+   "  : public aa,\n"
+   "public bb {};",
+   Style);
+  Style.BreakInheritanceList = FormatStyle::BILS_BeforeComma;
+  verifyFormat("class SomeClass\n"
+   "  : public aa\n"
+   "  , public bb {};",
+   Style);
+  Style.BreakInheritanceList = FormatStyle::BILS_AfterColon;
+  verifyFormat("class SomeClass :\n"
+   "  public aa,\n"
+   "  public bb {};",
+   Style);
 }
 
 #ifndef EXPENSIVE_CHECKS
@@ -8987,7 +9029,7 @@
"  (2) {}",
CtorInitializerStyle);
 
-  FormatStyle InheritanceStyle = getLLVMStyle();
+  FormatStyle InheritanceStyle = getLLVMStyleWithColumns(30);
   InheritanceStyle.SpaceBeforeInheritanceColon = false;
   verifyFormat("class Foo: public Bar {};", InheritanceStyle);
   verifyFormat("Foo::Foo() : foo(1) {}", InheritanceStyle);
@@ -9003,6 +9045,29 @@
"default:\n"
"}",
InheritanceStyle);
+  InheritanceStyle.BreakInheritanceList = FormatStyle::BILS_AfterColon;
+  verifyFormat("class Foo:\n"
+   "public aa,\n"
+   "public bb {\n"
+   "}",
+   InheritanceStyle);
+  InheritanceStyle.BreakInheritanceList = FormatStyle::BILS_BeforeComma;
+  verifyFormat("class Foo\n"
+   ": public aa\n"
+   ", public bb {\n"
+  

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

2018-02-28 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

Indeed, seems to apply to classes as well. Maybe I was mislead by my testing, 
where I did not get the case (possibly because we use 
`ConstructorInitializerAllOnOneLineOrOnePerLine=true`, so the continuation 
indenter only sees "short" class declarations unless breaking the template is 
required because the name is too long).

So just to be clear, are you saying the whole approach is not the right one, or 
simply that the "names" of each modes are not?
For the name, maybe something like may be better:

- `Never`
- `MultiLineDeclaration`, or maybe even `MultiLine`
- `Always`


Repository:
  rC Clang

https://reviews.llvm.org/D42684



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


[PATCH] D42787: clang-format: do not add extra indent when wrapping last parameter

2018-02-28 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

In https://reviews.llvm.org/D42787#1022081, @djasper wrote:

> But you *do* want extra indentation in the case of:
>
>   function(a, 
>b +
>cc);
>   
>
> I understand you argument, but I don't agree at the moment. As is (without 
> getting more feedback from others that clang-format is behaving unexpected 
> here), I do not want to move forward with this change.


Indeed, because as much as we want to keep things aligned (and avoid extra 
indentation), we want above all to make code "easier to read": we think keeping 
alignment is indeed helping, but that keeping the alignment when it adds 
confusion is not...
Now let's hear what others are thinking about this behavior.

(BTW, I imagine there is no point introducing an option for this specific, if 
this does not get accepted as default? It may be done as part of 
https://reviews.llvm.org/D32478 to minimize options, in the new mode which 
tries to align more strictly... But last time you looked at it you were not 
very enthousiastic about it either...)


Repository:
  rC Clang

https://reviews.llvm.org/D42787



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


[PATCH] D43823: [clangd] Prefer the definition of a TagDecl (e.g. class) as CanonicalDeclaration.

2018-02-28 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE326313: [clangd] Prefer the definition of a TagDecl (e.g. 
class) as… (authored by ioeric, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D43823?vs=136247&id=136248#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43823

Files:
  clangd/index/FileIndex.cpp
  clangd/index/SymbolCollector.cpp
  clangd/index/SymbolCollector.h
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -47,6 +47,7 @@
 }
 MATCHER_P(QName, Name, "") { return (arg.Scope + arg.Name).str() == Name; }
 MATCHER_P(DeclURI, P, "") { return arg.CanonicalDeclaration.FileURI == P; }
+MATCHER_P(DefURI, P, "") { return arg.Definition.FileURI == P; }
 MATCHER_P(IncludeHeader, P, "") {
   return arg.Detail && arg.Detail->IncludeHeader == P;
 }
@@ -152,17 +153,15 @@
 };
 
 TEST_F(SymbolCollectorTest, CollectSymbols) {
-  CollectorOpts.IndexMainFiles = true;
   const std::string Header = R"(
 class Foo {
   void f();
 };
 void f1();
 inline void f2() {}
 static const int KInt = 2;
 const char* kStr = "123";
-  )";
-  const std::string Main = R"(
+
 namespace {
 void ff() {} // ignore
 }
@@ -190,7 +189,7 @@
 using bar::v2;
 } // namespace foo
   )";
-  runSymbolCollector(Header, Main);
+  runSymbolCollector(Header, /*Main=*/"");
   EXPECT_THAT(Symbols,
   UnorderedElementsAreArray(
   {QName("Foo"), QName("f1"), QName("f2"), QName("KInt"),
@@ -200,7 +199,6 @@
 }
 
 TEST_F(SymbolCollectorTest, Locations) {
-  CollectorOpts.IndexMainFiles = true;
   Annotations Header(R"cpp(
 // Declared in header, defined in main.
 extern int $xdecl[[X]];
@@ -216,7 +214,7 @@
 void $printdef[[print]]() {}
 
 // Declared/defined in main only.
-int $y[[Y]];
+int Y;
   )cpp");
   runSymbolCollector(Header.code(), Main.code());
   EXPECT_THAT(
@@ -228,20 +226,16 @@
 DefRange(Main.offsetRange("clsdef"))),
   AllOf(QName("print"), DeclRange(Header.offsetRange("printdecl")),
 DefRange(Main.offsetRange("printdef"))),
-  AllOf(QName("Z"), DeclRange(Header.offsetRange("zdecl"))),
-  AllOf(QName("Y"), DeclRange(Main.offsetRange("y")),
-DefRange(Main.offsetRange("y");
+  AllOf(QName("Z"), DeclRange(Header.offsetRange("zdecl");
 }
 
 TEST_F(SymbolCollectorTest, SymbolRelativeNoFallback) {
-  CollectorOpts.IndexMainFiles = false;
   runSymbolCollector("class Foo {};", /*Main=*/"");
-  EXPECT_THAT(Symbols,
-  UnorderedElementsAre(AllOf(QName("Foo"), DeclURI(TestHeaderURI;
+  EXPECT_THAT(Symbols, UnorderedElementsAre(
+   AllOf(QName("Foo"), DeclURI(TestHeaderURI;
 }
 
 TEST_F(SymbolCollectorTest, SymbolRelativeWithFallback) {
-  CollectorOpts.IndexMainFiles = false;
   TestHeaderName = "x.h";
   TestFileName = "x.cpp";
   TestHeaderURI = URI::createFile(testPath(TestHeaderName)).toString();
@@ -253,7 +247,6 @@
 
 #ifndef LLVM_ON_WIN32
 TEST_F(SymbolCollectorTest, CustomURIScheme) {
-  CollectorOpts.IndexMainFiles = false;
   // Use test URI scheme from URITests.cpp
   CollectorOpts.URISchemes.insert(CollectorOpts.URISchemes.begin(), "unittest");
   TestHeaderName = testPath("test-root/x.h");
@@ -265,24 +258,21 @@
 #endif
 
 TEST_F(SymbolCollectorTest, InvalidURIScheme) {
-  CollectorOpts.IndexMainFiles = false;
   // Use test URI scheme from URITests.cpp
   CollectorOpts.URISchemes = {"invalid"};
   runSymbolCollector("class Foo {};", /*Main=*/"");
   EXPECT_THAT(Symbols, UnorderedElementsAre(AllOf(QName("Foo"), DeclURI("";
 }
 
 TEST_F(SymbolCollectorTest, FallbackToFileURI) {
-  CollectorOpts.IndexMainFiles = false;
   // Use test URI scheme from URITests.cpp
   CollectorOpts.URISchemes = {"invalid", "file"};
   runSymbolCollector("class Foo {};", /*Main=*/"");
   EXPECT_THAT(Symbols, UnorderedElementsAre(
AllOf(QName("Foo"), DeclURI(TestHeaderURI;
 }
 
 TEST_F(SymbolCollectorTest, IncludeEnums) {
-  CollectorOpts.IndexMainFiles = false;
   const std::string Header = R"(
 enum {
   Red
@@ -306,7 +296,6 @@
 }
 
 TEST_F(SymbolCollectorTest, IgnoreNamelessSymbols) {
-  CollectorOpts.IndexMainFiles = false;
   const std::string Header = R"(
 struct {
   int a;
@@ -318,7 +307,6 @@
 }
 
 TEST_F(SymbolCollectorTest, SymbolFormedFromMacro) {
-  CollectorOpts.IndexMainFiles = false;
 
   Annotations Header(R"(
 #define FF(name) \
@@ -342,33 +330,7 @@
 DeclURI(TestHeaderURI;
 }
 
-TEST_F(SymbolCollectorTest, SymbolFormedFromMacroInMainFile) {
-  CollectorOpts.IndexMainFiles = true;
-
-  Annotations Main(R"(
-#define FF(name) \
-  class name##_Test {};
-
-$expa

r326342 - [CUDA] Include single GPU binary, NFCI.

2018-02-28 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Wed Feb 28 09:53:46 2018
New Revision: 326342

URL: http://llvm.org/viewvc/llvm-project?rev=326342&view=rev
Log:
[CUDA] Include single GPU binary, NFCI.

Binaries for multiple architectures are combined by fatbinary,
so the current code was effectively not needed.

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

Modified:
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/CodeGen/CGCUDANV.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Driver/cuda-options.cu

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.h?rev=326342&r1=326341&r2=326342&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.h Wed Feb 28 09:53:46 2018
@@ -205,10 +205,9 @@ public:
   /// the summary and module symbol table (and not, e.g. any debug metadata).
   std::string ThinLinkBitcodeFile;
 
-  /// A list of file names passed with -fcuda-include-gpubinary options to
-  /// forward to CUDA runtime back-end for incorporating them into host-side
-  /// object file.
-  std::vector CudaGpuBinaryFileNames;
+  /// Name of file passed with -fcuda-include-gpubinary option to forward to
+  /// CUDA runtime back-end for incorporating them into host-side object file.
+  std::string CudaGpuBinaryFileName;
 
   /// The name of the file to which the backend should save YAML optimization
   /// records.

Modified: cfe/trunk/lib/CodeGen/CGCUDANV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCUDANV.cpp?rev=326342&r1=326341&r2=326342&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCUDANV.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCUDANV.cpp Wed Feb 28 09:53:46 2018
@@ -41,10 +41,10 @@ private:
   /// Keeps track of kernel launch stubs emitted in this module
   llvm::SmallVector EmittedKernels;
   llvm::SmallVector, 16> 
DeviceVars;
-  /// Keeps track of variables containing handles of GPU binaries. Populated by
+  /// Keeps track of variable containing handle of GPU binary. Populated by
   /// ModuleCtorFunction() and used to create corresponding cleanup calls in
   /// ModuleDtorFunction()
-  llvm::SmallVector GpuBinaryHandles;
+  llvm::GlobalVariable *GpuBinaryHandle = nullptr;
 
   llvm::Constant *getSetupArgumentFn() const;
   llvm::Constant *getLaunchFn() const;
@@ -245,16 +245,14 @@ llvm::Function *CGNVCUDARuntime::makeReg
 /// Creates a global constructor function for the module:
 /// \code
 /// void __cuda_module_ctor(void*) {
-/// Handle0 = __cudaRegisterFatBinary(GpuBinaryBlob0);
-/// __cuda_register_globals(Handle0);
-/// ...
-/// HandleN = __cudaRegisterFatBinary(GpuBinaryBlobN);
-/// __cuda_register_globals(HandleN);
+/// Handle = __cudaRegisterFatBinary(GpuBinaryBlob);
+/// __cuda_register_globals(Handle);
 /// }
 /// \endcode
 llvm::Function *CGNVCUDARuntime::makeModuleCtorFunction() {
-  // No need to generate ctors/dtors if there are no GPU binaries.
-  if (CGM.getCodeGenOpts().CudaGpuBinaryFileNames.empty())
+  // No need to generate ctors/dtors if there is no GPU binary.
+  std::string GpuBinaryFileName = CGM.getCodeGenOpts().CudaGpuBinaryFileName;
+  if (GpuBinaryFileName.empty())
 return nullptr;
 
   // void __cuda_register_globals(void* handle);
@@ -267,6 +265,18 @@ llvm::Function *CGNVCUDARuntime::makeMod
   llvm::StructType *FatbinWrapperTy =
   llvm::StructType::get(IntTy, IntTy, VoidPtrTy, VoidPtrTy);
 
+  // Register GPU binary with the CUDA runtime, store returned handle in a
+  // global variable and save a reference in GpuBinaryHandle to be cleaned up
+  // in destructor on exit. Then associate all known kernels with the GPU 
binary
+  // handle so CUDA runtime can figure out what to call on the GPU side.
+  llvm::ErrorOr> GpuBinaryOrErr =
+  llvm::MemoryBuffer::getFileOrSTDIN(GpuBinaryFileName);
+  if (std::error_code EC = GpuBinaryOrErr.getError()) {
+CGM.getDiags().Report(diag::err_cannot_open_file)
+<< GpuBinaryFileName << EC.message();
+return nullptr;
+  }
+
   llvm::Function *ModuleCtorFunc = llvm::Function::Create(
   llvm::FunctionType::get(VoidTy, VoidPtrTy, false),
   llvm::GlobalValue::InternalLinkage, "__cuda_module_ctor", &TheModule);
@@ -276,79 +286,56 @@ llvm::Function *CGNVCUDARuntime::makeMod
 
   CtorBuilder.SetInsertPoint(CtorEntryBB);
 
-  // For each GPU binary, register it with the CUDA runtime and store returned
-  // handle in a global variable and save the handle in GpuBinaryHandles vector
-  // to be cleaned up in destructor on exit. Then associate all known kernels
-  // with the GPU binary handle so CUDA runtime can figure out what to call on
-  // the GPU side.
-  for (co

[PATCH] D43461: [CUDA] Include single GPU binary, NFCI.

2018-02-28 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326342: [CUDA] Include single GPU binary, NFCI. (authored by 
Hahnfeld, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43461?vs=135649&id=136323#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43461

Files:
  cfe/trunk/include/clang/Frontend/CodeGenOptions.h
  cfe/trunk/lib/CodeGen/CGCUDANV.cpp
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/Driver/cuda-options.cu

Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.h
===
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.h
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.h
@@ -205,10 +205,9 @@
   /// the summary and module symbol table (and not, e.g. any debug metadata).
   std::string ThinLinkBitcodeFile;
 
-  /// A list of file names passed with -fcuda-include-gpubinary options to
-  /// forward to CUDA runtime back-end for incorporating them into host-side
-  /// object file.
-  std::vector CudaGpuBinaryFileNames;
+  /// Name of file passed with -fcuda-include-gpubinary option to forward to
+  /// CUDA runtime back-end for incorporating them into host-side object file.
+  std::string CudaGpuBinaryFileName;
 
   /// The name of the file to which the backend should save YAML optimization
   /// records.
Index: cfe/trunk/test/Driver/cuda-options.cu
===
--- cfe/trunk/test/Driver/cuda-options.cu
+++ cfe/trunk/test/Driver/cuda-options.cu
@@ -73,11 +73,10 @@
 // and that all results are included on the host side.
 // RUN: %clang -### -target x86_64-linux-gnu \
 // RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 -c %s 2>&1 \
-// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
-// RUN:-check-prefix DEVICE2 -check-prefix DEVICE-SM30 \
-// RUN:-check-prefix DEVICE2-SM35 -check-prefix HOST \
-// RUN:-check-prefix HOST-NOSAVE -check-prefix INCLUDES-DEVICE \
-// RUN:-check-prefix NOLINK %s
+// RUN: | FileCheck -check-prefixes DEVICE,DEVICE-NOSAVE,DEVICE2 \
+// RUN: -check-prefixes DEVICE-SM30,DEVICE2-SM35 \
+// RUN: -check-prefixes INCLUDES-DEVICE,INCLUDES-DEVICE2 \
+// RUN: -check-prefixes HOST,HOST-NOSAVE,NOLINK %s
 
 // Verify that device-side results are passed to the correct tool when
 // -save-temps is used.
@@ -182,17 +181,25 @@
 // DEVICE2-SAME: "-aux-triple" "x86_64--linux-gnu"
 // DEVICE2-SAME: "-fcuda-is-device"
 // DEVICE2-SM35-SAME: "-target-cpu" "sm_35"
-// DEVICE2-SAME: "-o" "[[GPUBINARY2:[^"]*]]"
+// DEVICE2-SAME: "-o" "[[PTXFILE2:[^"]*]]"
 // DEVICE2-SAME: "-x" "cuda"
 
+// Match another call to ptxas.
+// DEVICE2: ptxas
+// DEVICE2-SM35-DAG: "--gpu-name" "sm_35"
+// DEVICE2-DAG: "--output-file" "[[CUBINFILE2:[^"]*]]"
+// DEVICE2-DAG: "[[PTXFILE2]]"
+
 // Match no device-side compilation.
 // NODEVICE-NOT: "-cc1" "-triple" "nvptx64-nvidia-cuda"
 // NODEVICE-NOT: "-fcuda-is-device"
 
 // INCLUDES-DEVICE:fatbinary
 // INCLUDES-DEVICE-DAG: "--create" "[[FATBINARY:[^"]*]]"
 // INCLUDES-DEVICE-DAG: "--image=profile=sm_{{[0-9]+}},file=[[CUBINFILE]]"
 // INCLUDES-DEVICE-DAG: "--image=profile=compute_{{[0-9]+}},file=[[PTXFILE]]"
+// INCLUDES-DEVICE2-DAG: "--image=profile=sm_{{[0-9]+}},file=[[CUBINFILE2]]"
+// INCLUDES-DEVICE2-DAG: "--image=profile=compute_{{[0-9]+}},file=[[PTXFILE2]]"
 
 // Match host-side preprocessor job with -save-temps.
 // HOST-SAVE: "-cc1" "-triple" "x86_64--linux-gnu"
@@ -207,7 +214,11 @@
 // HOST-SAME: "-o" "[[HOSTOUTPUT:[^"]*]]"
 // HOST-NOSAVE-SAME: "-x" "cuda"
 // HOST-SAVE-SAME: "-x" "cuda-cpp-output"
+// There is only one GPU binary after combining it with fatbinary!
+// INCLUDES-DEVICE2-NOT: "-fcuda-include-gpubinary"
 // INCLUDES-DEVICE-SAME: "-fcuda-include-gpubinary" "[[FATBINARY]]"
+// There is only one GPU binary after combining it with fatbinary.
+// INCLUDES-DEVICE2-NOT: "-fcuda-include-gpubinary"
 
 // Match external assembler that uses compilation output.
 // HOST-AS: "-o" "{{.*}}.o" "[[HOSTOUTPUT]]"
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -4677,13 +4677,12 @@
   }
 
   if (IsCuda) {
-// Host-side cuda compilation receives device-side outputs as Inputs[1...].
-// Include them with -fcuda-include-gpubinary.
+// Host-side cuda compilation receives all device-side outputs in a single
+// fatbin as Inputs[1]. Include the binary with -fcuda-include-gpubinary.
 if (Inputs.size() > 1) {
-  for (auto I = std::next(Inputs.begin()), E = Inputs.end(); I != E; ++I) {
-CmdArgs.push_back("-fcuda-include-gpubinary");
-CmdArgs.push_back(I->getFilename());
-  }
+  assert(Inputs.size() == 2 && 

[PATCH] D32525: [clang-format] Add SpaceBeforeColon option

2018-02-28 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Ah, I thought it was somehow possible to create:

  Constructor(): aa()
   , bb() {},

but I guess clang-format always inserts a break there. Sorry for chasing you in 
circles.


Repository:
  rC Clang

https://reviews.llvm.org/D32525



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


[PATCH] D43870: [clang-tidy] Another batch of checks to rename from misc- to bugprone-.

2018-02-28 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/ReleaseNotes.rst:60
 
+- The 'misc-undelegated-constructor' check was renamed to 
`bugprone-undelegated-constructor
+  
`_

Please sort checks alphabetically. Will be also good idea to move renamed 
checks after new checks/modules.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43870



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


[PATCH] D30170: Function definition may have uninstantiated body

2018-02-28 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

The issue is still observed in trunk. Other compilers process the tests 
correctly (checked using https://godbolt.org/). For instance, the code:

  template struct C20 {
  friend void func_20() {} // expected-note{{previous definition is here}}
  };
  C20 c20i;
  void func_20() {} // expected-error{{redefinition of 'func_20'}}

is rejected by gcc 7.3:

  : In function 'void func_20()':
  :5:6: error: redefinition of 'void func_20()'
   void func_20() {} // expected-error{{redefinition of 'func_20'}}
^~~
  :2:13: note: 'void func_20()' previously declared here
   friend void func_20() {} // expected-note{{previous definition is here}}
   ^~~
  Compiler returned: 1

by ICC 18:

  (5): error: function "func_20" has already been defined
void func_20() {} // expected-error{{redefinition of 'func_20'}}
 ^
  compilation aborted for  (code 2)
  Compiler returned: 2

and by MSVC 19 2017:

  (5): error C2084: function 'void C20::func_20(void)' already has 
a body
  (2): note: see previous definition of 'func_20'
  Microsoft (R) C/C++ Optimizing Compiler Version 19.10.25017 for x64
  Copyright (C) Microsoft Corporation.  All rights reserved.
  Compiler returned: 2


https://reviews.llvm.org/D30170



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


[PATCH] D43839: Add an option to disable tail-call optimization for escaping blocks

2018-02-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Abandon this one, then, please.


https://reviews.llvm.org/D43839



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


[PATCH] D43162: [Parser] (C++) Make -Wextra-semi slightly more useful

2018-02-28 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

This is the wrong way to deal with this. The only thing that should ever be 
controlled by -W flags is whether the warnings in that group appear, not 
whether warnings in other groups appear. The principle is that -W flags should 
behave "as if" they filter the diagnostic output of Clang. (We actually depend 
on this in the implicit modules implementation, to allow modules to be reused 
in compilation modes where a different set of warning flags is enabled.) 
`isIgnored` exists only to allow the computations leading to the emission of a 
diagnostic to be skipped if the diagnostic will not actually be emitted.

The right thing to do is to add a new warning group for the 
`warn_cxx98_compat_top_level_semi` warning, and make that a subgroup of the 
`-Wextra-semi` group. That way `-Wno-extra-semi` can be used to turn off both 
the C++98 extension warning and the C++11 compatibility warning. Take a look at 
the `*BinaryLiteral` warning groups for an example of how to do this. (That 
case is a little more complex because there's also a warning group for the 
corresponding case in C.)


Repository:
  rC Clang

https://reviews.llvm.org/D43162



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


[PATCH] D43839: Add an option to disable tail-call optimization for escaping blocks

2018-02-28 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

This one is abandoned. The new phab review is here:

https://reviews.llvm.org/D43841


https://reviews.llvm.org/D43839



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


[PATCH] D43162: [Parser] (C++) Make -Wextra-semi slightly more useful

2018-02-28 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Thank you for the feedback!

In https://reviews.llvm.org/D43162#1022427, @rsmith wrote:

> This is the wrong way to deal with this. The only thing that should ever be 
> controlled by -W flags is whether the warnings in that group appear, not 
> whether warnings in other groups appear. The principle is that -W flags 
> should behave "as if" they filter the diagnostic output of Clang. (We 
> actually depend on this in the implicit modules implementation, to allow 
> modules to be reused in compilation modes where a different set of warning 
> flags is enabled.) `isIgnored` exists only to allow the computations leading 
> to the emission of a diagnostic to be skipped if the diagnostic will not 
> actually be emitted.


Aha, i see. To be noted, this is how it is currently already done for 
`warn_cxx98_compat_no_newline_eof`/`warn_no_newline_eof`
https://github.com/llvm-mirror/clang/blob/f828172bcfd7d6d10497c645c3cc5eee321cd669/lib/Lex/Lexer.cpp#L2684-L2695
https://github.com/llvm-mirror/clang/blob/f828172bcfd7d6d10497c645c3cc5eee321cd669/include/clang/Basic/DiagnosticLexKinds.td#L58-L63
So i'm guessing that^ should be fixed too?

> The right thing to do is to add a new warning group for the 
> `warn_cxx98_compat_top_level_semi` warning, and make that a subgroup of the 
> `-Wextra-semi` group. That way `-Wno-extra-semi` can be used to turn off both 
> the C++98 extension warning and the C++11 compatibility warning. Take a look 
> at the `*BinaryLiteral` warning groups for an example of how to do this. 
> (That case is a little more complex because there's also a warning group for 
> the corresponding case in C.)

I'll look into it, but *right now* this sounds like it won't do what i'm trying 
to do here. Hopefully i'm just missing the point :)


Repository:
  rC Clang

https://reviews.llvm.org/D43162



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


[PATCH] D39562: [CodeGen][ObjC] Fix an assertion failure caused by copy elision

2018-02-28 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

I'm planning to work on a new patch this week.


https://reviews.llvm.org/D39562



___
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

2018-02-28 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp:100
   void checkCall_strcat(const CallExpr *CE, const FunctionDecl *FD);
+  void checkDeprecatedOrUnsafeBufferHandling(const CallExpr *CE, const 
FunctionDecl *FD);
   void checkCall_rand(const CallExpr *CE, const FunctionDecl *FD);

80 chars



Comment at: lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp:165
+.Case("strncat", &WalkAST::checkDeprecatedOrUnsafeBufferHandling)
+.Case("memset", &WalkAST::checkDeprecatedOrUnsafeBufferHandling)
 .Case("drand48", &WalkAST::checkCall_rand)

That's a lot of duplicated `WalkAST::checkDeprecatedOrUnsafeBufferHandling`. 
Could that be simplified?



Comment at: lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp:618
+  StringRef Name = FD->getIdentifier()->getName();
+  int ArgIndex = llvm::StringSwitch(Name)
+ .Case("sprintf", 1)

That's a lot of duplication of 1/0/-1.


And also 1/0/-1 are cryptic symbols, why not use an enum with a descriptive 
name?
Maybe use
`.Cases("sprintf", "vsprintf", "vfscanf", WARN_UNSAFE)` ?


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] D43888: [clang-cl] Implement /X

2018-02-28 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: hans.

/X makes cl stop looking in %INCLUDE%. Implement this for clang-cl.

As it turns out, the return in ToolChains/MSVC.cpp, AddClangSystemIncludeArgs() 
for -nostdlibinc is already in the right place (but -nostdlibinc isn't exposed 
by clang-cl), so just alias /X to that.


https://reviews.llvm.org/D43888

Files:
  include/clang/Driver/CLCompatOptions.td
  test/Driver/cl-include.c


Index: test/Driver/cl-include.c
===
--- test/Driver/cl-include.c
+++ test/Driver/cl-include.c
@@ -10,5 +10,16 @@
 // RUN: env INCLUDE=/my/system/inc %clang_cl -### -- %s 2>&1 | FileCheck %s 
--check-prefix=STDINC
 // STDINC: "-internal-isystem" "/my/system/inc"
 
-// RUN: env INCLUDE=/my/system/inc %clang_cl -nostdinc -### -- %s 2>&1 | 
FileCheck %s --check-prefix=NOSTDINC
+// -nostdinc suppresses all of %INCLUDE%, clang resource dirs, and -imsvc dirs.
+// RUN: env INCLUDE=/my/system/inc %clang_cl -nostdinc -imsvc /my/other/inc 
-### -- %s 2>&1 | FileCheck %s --check-prefix=NOSTDINC
+// NOSTDINC: argument unused{{.*}}-imsvc
 // NOSTDINC-NOT: "-internal-isystem" "/my/system/inc"
+// NOSTDINC-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{.*}}/include"
+// NOSTDINC-NOT: "-internal-isystem" "/my/other/inc"
+
+// /X suppresses %INCLUDE% but not clang resource dirs or -imsvc dirs.
+// RUN: env INCLUDE=/my/system/inc %clang_cl /X -imsvc /my/other/inc -### -- 
%s 2>&1 | FileCheck %s --check-prefix=SLASHX
+// SLASHX-NOT: "argument unused{{.*}}-imsvc"
+// SLASHX-NOT: "-internal-isystem" "/my/system/inc"
+// SLASHX: "-internal-isystem" "{{.*}}/lib/clang/{{.*}}/include"
+// SLASHX: "-internal-isystem" "/my/other/inc"
Index: include/clang/Driver/CLCompatOptions.td
===
--- include/clang/Driver/CLCompatOptions.td
+++ include/clang/Driver/CLCompatOptions.td
@@ -164,6 +164,9 @@
   AliasArgs<["no-deprecated-declarations"]>;
 def _SLASH_vd : CLJoined<"vd">, HelpText<"Control vtordisp placement">,
   Alias;
+def _SLASH_X : CLFlag<"X">,
+  HelpText<"Don't add %INCLUDE% to the include search path">,
+  Alias;
 def _SLASH_Zc_sizedDealloc : CLFlag<"Zc:sizedDealloc">,
   HelpText<"Enable C++14 sized global deallocation functions">,
   Alias;
@@ -386,7 +389,6 @@
 def _SLASH_V : CLFlag<"V">;
 def _SLASH_WL : CLFlag<"WL">;
 def _SLASH_Wp64 : CLFlag<"Wp64">;
-def _SLASH_X : CLFlag<"X">;
 def _SLASH_Yd : CLFlag<"Yd">;
 def _SLASH_Yl : CLJoined<"Yl">;
 def _SLASH_Za : CLFlag<"Za">;


Index: test/Driver/cl-include.c
===
--- test/Driver/cl-include.c
+++ test/Driver/cl-include.c
@@ -10,5 +10,16 @@
 // RUN: env INCLUDE=/my/system/inc %clang_cl -### -- %s 2>&1 | FileCheck %s --check-prefix=STDINC
 // STDINC: "-internal-isystem" "/my/system/inc"
 
-// RUN: env INCLUDE=/my/system/inc %clang_cl -nostdinc -### -- %s 2>&1 | FileCheck %s --check-prefix=NOSTDINC
+// -nostdinc suppresses all of %INCLUDE%, clang resource dirs, and -imsvc dirs.
+// RUN: env INCLUDE=/my/system/inc %clang_cl -nostdinc -imsvc /my/other/inc -### -- %s 2>&1 | FileCheck %s --check-prefix=NOSTDINC
+// NOSTDINC: argument unused{{.*}}-imsvc
 // NOSTDINC-NOT: "-internal-isystem" "/my/system/inc"
+// NOSTDINC-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{.*}}/include"
+// NOSTDINC-NOT: "-internal-isystem" "/my/other/inc"
+
+// /X suppresses %INCLUDE% but not clang resource dirs or -imsvc dirs.
+// RUN: env INCLUDE=/my/system/inc %clang_cl /X -imsvc /my/other/inc -### -- %s 2>&1 | FileCheck %s --check-prefix=SLASHX
+// SLASHX-NOT: "argument unused{{.*}}-imsvc"
+// SLASHX-NOT: "-internal-isystem" "/my/system/inc"
+// SLASHX: "-internal-isystem" "{{.*}}/lib/clang/{{.*}}/include"
+// SLASHX: "-internal-isystem" "/my/other/inc"
Index: include/clang/Driver/CLCompatOptions.td
===
--- include/clang/Driver/CLCompatOptions.td
+++ include/clang/Driver/CLCompatOptions.td
@@ -164,6 +164,9 @@
   AliasArgs<["no-deprecated-declarations"]>;
 def _SLASH_vd : CLJoined<"vd">, HelpText<"Control vtordisp placement">,
   Alias;
+def _SLASH_X : CLFlag<"X">,
+  HelpText<"Don't add %INCLUDE% to the include search path">,
+  Alias;
 def _SLASH_Zc_sizedDealloc : CLFlag<"Zc:sizedDealloc">,
   HelpText<"Enable C++14 sized global deallocation functions">,
   Alias;
@@ -386,7 +389,6 @@
 def _SLASH_V : CLFlag<"V">;
 def _SLASH_WL : CLFlag<"WL">;
 def _SLASH_Wp64 : CLFlag<"Wp64">;
-def _SLASH_X : CLFlag<"X">;
 def _SLASH_Yd : CLFlag<"Yd">;
 def _SLASH_Yl : CLJoined<"Yl">;
 def _SLASH_Za : CLFlag<"Za">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r326354 - [Documentation] Split Clang-tidy changes in Release Notes into sections: new checks, new aliases, renamed checks; sort all of them alphabetically. Enforce 80 characters l

2018-02-28 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Wed Feb 28 11:15:49 2018
New Revision: 326354

URL: http://llvm.org/viewvc/llvm-project?rev=326354&view=rev
Log:
[Documentation] Split Clang-tidy changes in Release Notes into sections: new 
checks, new aliases, renamed checks; sort all of them alphabetically. Enforce 
80 characters line length limit. Highlight C++ keywords.

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/fuchsia-trailing-return.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-uncaught-exceptions.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=326354&r1=326353&r2=326354&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Wed Feb 28 11:15:49 2018
@@ -57,23 +57,11 @@ The improvements are...
 Improvements to clang-tidy
 --
 
-- The 'misc-misplaced-widening-cast' check was renamed to 
`bugprone-misplaced-widening-cast
-  
`_
-
-- The 'misc-lambda-function-name' check was renamed to 
`bugprone-lambda-function-name
-  
`_
-
-- The 'misc-macro-repeated-side-effects' check was renamed to 
`bugprone-macro-repeated-side-effects
-  
`_
-
-- The 'misc-forwarding-reference-overload' check was renamed to 
`bugprone-forwarding-reference-overload
-  
`_
-
-- The 'misc-incorrect-roundings' check was renamed to 
`bugprone-incorrect-roundings
-  
`_
+- New `bugprone-throw-keyword-missing
+  
`_
 check
 
-- The 'misc-string-compare' check was renamed to `readability-string-compare
-  
`_
+  Diagnoses when a temporary object that appears to be an exception is
+  constructed but not thrown.
 
 - New `cppcoreguidelines-avoid-goto
   
`_
 check
@@ -90,17 +78,23 @@ Improvements to clang-tidy
 - New `fuchsia-statically-constructed-objects
   
`_
 check
 
-  Warns if global, non-trivial objects with static storage are constructed, 
unless the 
-  object is statically initialized with a ``constexpr`` constructor or has no 
-  explicit constructor.
+  Warns if global, non-trivial objects with static storage are constructed,
+  unless the object is statically initialized with a ``constexpr`` constructor
+  or has no explicit constructor.
   
 - New `fuchsia-trailing-return
   
`_ 
check
 
   Functions that have trailing returns are disallowed, except for those 
-  using decltype specifiers and lambda with otherwise unutterable 
+  using ``decltype`` specifiers and lambda with otherwise unutterable 
   return types.
 
+- New `modernize-use-uncaught-exceptions
+  
`_
 check
+
+  Finds and replaces deprecated uses of ``std::uncaught_exception`` to
+  ``std::uncaught_exceptions``.
+
 - New `readability-simd-intrinsics
   
`_
 check
 
@@ -112,15 +106,23 @@ Improvements to clang-tidy
   `cppcoreguidelines-avoid-goto 
`_
   added.
 
-- New `bugprone-throw-keyword-missing
-  
`_
 check
+- The 'misc-forwarding-reference-overload' check was renamed to 
`bugprone-forwarding-reference-overload
+  
`_
 
-  Diagnoses when a temporary object that appears to be an exception is 
constructed but not thrown.
+- The 'misc-incorrect-roundings' check was renamed to 
`bugprone-incorrect-roundings
+  
`_
 
-- New `modernize-use-uncaught-exceptions
-  
`_
 check
+- The 'misc-lambda-function-name' check was renamed to 
`bugprone-lambda-function-name
+  


[PATCH] D43888: [clang-cl] Implement /X

2018-02-28 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm

Nicely tested too :-)


https://reviews.llvm.org/D43888



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


[PATCH] D43839: Add an option to disable tail-call optimization for escaping blocks

2018-02-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Oh, sorry, somehow I missed that it was abandoned.


https://reviews.llvm.org/D43839



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


[PATCH] D43840: [CFG] [analyzer] Fix a crash on finding construction context for implicit constructor conversion.

2018-02-28 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov accepted this revision.
george.karpenkov added a comment.
This revision is now accepted and ready to land.

Should there be a FIXME note saying that other casts should be supported?


Repository:
  rC Clang

https://reviews.llvm.org/D43840



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


[PATCH] D30170: Function definition may have uninstantiated body

2018-02-28 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.



Comment at: include/clang/AST/Decl.h:1840
+  /// there is one).
+  ///
   bool hasBody(const FunctionDecl *&Definition) const;

Please remove trailing blank comment lines here and below.



Comment at: lib/Sema/SemaDecl.cpp:11986
+  !FD->isDefined(Definition)
+  && FD->getDeclContext()->isFileContext()) {
+// If this is a friend function defined in a class template, it does not

`&&` on the end of the previous line, please.

If the intent here is to detect non-member functions, using 
`!FD->isCXXClassMember()` or `!isa(FD)` would be clearer.



Comment at: lib/Sema/SemaDecl.cpp:11995-12006
+for (auto I : FD->redecls()) {
+  if (I != FD && !I->isInvalidDecl() &&
+  I->getFriendObjectKind() != Decl::FOK_None) {
+if (FunctionDecl *Original = I->getInstantiatedFromMemberFunction()) {
+  if (Original->isThisDeclarationADefinition()) {
+Definition = I;
+break;

We should include a comment here explaining why we need to do this (that is, 
why this doesn't just fall out from the normal `isDefined` check). You can just 
quote C++ [temp.inst]p2:

> For the purpose of determining whether an instantiated redeclaration is valid 
> according to [basic.def.odr] and [class.mem], a declaration that corresponds 
> to a definition in the template is considered to be a definition.


https://reviews.llvm.org/D30170



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


[PATCH] D43842: CodeGenObjCXX: handle inalloca appropriately for msgSend variant

2018-02-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Ugh, I hate `inalloca` *so much*.

It's still an indirect return, right?  It's just that the return-slot pointer 
has to get stored to the `inalloca` allocation like any other argument?


Repository:
  rC Clang

https://reviews.llvm.org/D43842



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


[PATCH] D43804: [analyzer] Enable cfg-temporary-dtors by default?

2018-02-28 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

Currently there's no test demonstrating a different behavior from 
`cfg-temporary-dtors` being set to true?..


Repository:
  rC Clang

https://reviews.llvm.org/D43804



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


r326355 - Fix gcc -Wreturn-type warnings after r326307.

2018-02-28 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Feb 28 11:28:47 2018
New Revision: 326355

URL: http://llvm.org/viewvc/llvm-project?rev=326355&view=rev
Log:
Fix gcc -Wreturn-type warnings after r326307.

Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=326355&r1=326354&r2=326355&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Wed Feb 28 11:28:47 2018
@@ -1595,6 +1595,7 @@ computeCopyInfoForBlockCapture(const Blo
 return std::make_pair(BlockCaptureEntityKind::None, BlockFieldFlags());
   }
   }
+  llvm_unreachable("after exhaustive PrimitiveCopyKind switch");
 }
 
 /// Find the set of block captures that need to be explicitly copied or 
destroy.
@@ -1797,6 +1798,7 @@ computeDestroyInfoForBlockCapture(const
 return std::make_pair(BlockCaptureEntityKind::None, BlockFieldFlags());
   }
   }
+  llvm_unreachable("after exhaustive DestructionKind switch");
 }
 
 /// Generate the destroy-helper function for a block closure object:


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


[PATCH] D43804: [analyzer] Enable cfg-temporary-dtors by default?

2018-02-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

That's right, most analyzer-oriented tests were added explicitly by me to 
`temporaries.cpp` and `lifetime-extension.cpp` in previous patches, so they 
didn't need to be changed in this patch. There didn't seem to be many FIXME 
tests specific to my work before i started doing it - it seems that i covered 
all of them by adding a `cfg-temporary-dtors=true` run-line in previous patches.


Repository:
  rC Clang

https://reviews.llvm.org/D43804



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


[PATCH] D41102: Setup clang-doc frontend framework

2018-02-28 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Thank you for working on this!
Some more review notes.
Please look into adding a bit more tests.




Comment at: clang-doc/BitcodeWriter.cpp:179
+  assert(Inits.size() == RecordIdCount);
+  for (const auto &Init : Inits) RecordIdNameMap[Init.first] = Init.second;
+  assert(RecordIdNameMap.size() == RecordIdCount);

Since this is the only string we ever push to `Record`, can we add an assertion 
to make sure we always have enough room for it?
E.g.
```
for (const auto &Init : Inits) {
  RecordId RID = Init.first;
  RecordIdNameMap[RID] = Init.second;
  assert((1 + RecordIdNameMap[RID].size()) <= Record.size());
  // Since record was just created, it should not have any dynamic size.
  // Or move the small size into a variable and use it when declaring the 
Record and here.
}
```



Comment at: clang-doc/BitcodeWriter.cpp:230
+  prepRecordData(ID);
+  for (const char C : RecordIdNameMap[ID].Name) Record.push_back(C);
+  Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETRECORDNAME, Record);

Sadly, i can **not** prove it via godbolt (can't add LLVM as library), but i'd 
//expect// streamlining this should at least not hurt, i.e. something like
```
Record.append(RecordIdNameMap[ID].Name.begin(), RecordIdNameMap[ID].Name.end());
```
?



Comment at: clang-doc/BitcodeWriter.cpp:196
+/// \brief Emits a record name to the BLOCKINFO block.
+void ClangDocBitcodeWriter::emitRecordID(RecordId ID) {
+  assert(RecordIdNameMap[ID] && "Unknown Abbreviation");

juliehockett wrote:
> lebedev.ri wrote:
> > Hmm, so i've been staring at this and 
> > http://llvm.org/doxygen/classllvm_1_1BitstreamWriter.html and i must say 
> > i'm not fond of this indirection.
> > 
> > What i don't understand is, in previous function, we don't store `BlockId`, 
> > why do we want to store `RecordId`?
> > Aren't they both unstable, and are implementation detail?
> > Do we want to store it (`RecordId`)? If yes, please explain it as a new 
> > comment in code.
> > 
> > If no, i guess this would work too?
> > ```
> > assert(RecordIdNameMap[ID] && "Unknown Abbreviation");
> > Record.clear();
> > Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETRECORDNAME, 
> > RecordIdNameMap[ID].Name);
> > ```
> > And after that you can lower the default size of `SmallVector<> Record` 
> > down to, hm, `4`?
> I'm not entirely certain what you mean -- in `emitBlockId()`, we are storing 
> both the block id and the block name in separate records 
> (`BLOCKINFO_CODE_SETBID`, `BLOCKINFO_CODE_BLOCKNAME`, respectively). In 
> `emitRecordId()`, we're doing something slightly different, in that we emit 
> one record with both the record id and the record name (in record 
> `BLOCKINFO_CODE_SETRECORDNAME`). 
> 
> Replacing the copy loop here has the same issue as above, namely that there 
> isn't an easy way to convert between a `StringRef` and an array of `unsigned 
> char`.
Tried locally, and yes, we do need to output record id.

What we could **actually** do, is simply inline that `EmitRecord()`, first 
emitting the RID, and then the name.
```
template 
void EmitRecord(unsigned Code, int ID, const Container &Vals) {
  // If we don't have an abbrev to use, emit this in its fully unabbreviated
  // form.
  auto Count = static_cast(makeArrayRef(Vals).size());
  EmitCode(bitc::UNABBREV_RECORD);
  EmitVBR(Code, 6);
  EmitVBR(Count + 1, 6); // Including ID
  EmitVBR64(ID, 6); // 'Prefix' with ID
  for (unsigned i = 0, e = Count; i != e; ++i)
EmitVBR64(Vals[i], 6);
}
```

But that will result in rather ugly code.
So given that the record names are quite short, and all the other strings we 
output directly, maybe leave it as it is for now, until it shows in profiles?




Comment at: clang-doc/BitcodeWriter.h:37
+  static constexpr unsigned SubblockIDSize = 4U;
+  static constexpr unsigned BoolSize = 1U;
+  static constexpr unsigned IntSize = 16U;

juliehockett wrote:
> lebedev.ri wrote:
> > Hmm, you build with asserts enabled, right?
> > I tried testing this, and three tests fail with
> > ```
> > clang-doc: /build/llvm/include/llvm/Bitcode/BitstreamWriter.h:122: void 
> > llvm::BitstreamWriter::Emit(uint32_t, unsigned int): Assertion `(Val & 
> > ~(~0U >> (32-NumBits))) == 0 && "High bits set!"' failed.
> > ```
> > ```
> > Failing Tests (3):
> > Clang Tools :: clang-doc/mapper-class-in-function.cpp
> > Clang Tools :: clang-doc/mapper-function.cpp
> > Clang Tools :: clang-doc/mapper-method.cpp
> > 
> >   Expected Passes: 6
> >   Unexpected Failures: 3
> > ```
> > At least one failure is because of `BoolSize`, so i'd suspect the assertion 
> > itself is wrong...
> I do, and I've definitely seen that one triggered before but it's been 
> because something was off in how the data was being outputted as I was 
> shifting things around. That said, I'm not seeing it in my local build with 
> this diff th

r326332 - Test commit access: apply clang-format suggestion

2018-02-28 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Wed Feb 28 08:57:33 2018
New Revision: 326332

URL: http://llvm.org/viewvc/llvm-project?rev=326332&view=rev
Log:
Test commit access: apply clang-format suggestion

Modified:
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=326332&r1=326331&r2=326332&view=diff
==
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Wed Feb 28 08:57:33 2018
@@ -3823,8 +3823,8 @@ static void WriteDocumentation(RecordKee
 const Record &Deprecated = *Doc.Documentation->getValueAsDef("Deprecated");
 const StringRef Replacement = Deprecated.getValueAsString("Replacement");
 if (!Replacement.empty())
-  OS << "  This attribute has been superseded by ``"
- << Replacement << "``.";
+  OS << "  This attribute has been superseded by ``" << Replacement
+ << "``.";
 OS << "\n\n";
   }
 


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


[PATCH] D43842: CodeGenObjCXX: handle inalloca appropriately for msgSend variant

2018-02-28 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In https://reviews.llvm.org/D43842#1022498, @rjmccall wrote:

> Ugh, I hate `inalloca` *so much*.
>
> It's still an indirect return, right?  It's just that the return-slot pointer 
> has to get stored to the `inalloca` allocation like any other argument?


Correct.


Repository:
  rC Clang

https://reviews.llvm.org/D43842



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


[PATCH] D43766: [clang-tidy][modernize-make-unique] Checks c++14 flag before using std::make_unique

2018-02-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/modernize/MakeUniqueCheck.cpp:21
+: MakeSmartPtrCheck(Name, Context, "std::make_unique"),
+  MinimumLanguageVersion(Options.get("MakeUniqueLanguageVersion",
+ getDefaultMinimumLanguageVersion())) 
{}

Why is this is a user-facing option?

If it needs to be a user-facing option, you also need to implement an override 
for `storeOptions()` as well.



Comment at: clang-tidy/modernize/MakeUniqueCheck.cpp:25
+const std::string MakeUniqueCheck::getDefaultMinimumLanguageVersion() const {
+  return Options.get("MakeSmartPtrFunction", "").empty() ? "c++14" : "c++11";
+}

What is this option? Why is this returning a string literal rather than 
something less error-prone like an enumeration?


https://reviews.llvm.org/D43766



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


[PATCH] D43842: CodeGenObjCXX: handle inalloca appropriately for msgSend variant

2018-02-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Okay.  In that case, this seems correct, although it seems to me that perhaps 
`inalloca` is not actually orthogonal to anything else.  In fact, it seems to 
me that maybe `inalloca` ought to just be a bit on the CGFunctionInfo and the 
individual ABIInfos should be left alone.


Repository:
  rC Clang

https://reviews.llvm.org/D43842



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


[PATCH] D43888: [clang-cl] Implement /X

2018-02-28 Thread Nico Weber via Phabricator via cfe-commits
thakis closed this revision.
thakis added a comment.

r326357, thanks!


https://reviews.llvm.org/D43888



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


r326357 - [clang-cl] Implement /X

2018-02-28 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Feb 28 11:49:07 2018
New Revision: 326357

URL: http://llvm.org/viewvc/llvm-project?rev=326357&view=rev
Log:
[clang-cl] Implement /X

/X makes cl stop looking in %INCLUDE%. Implement this for clang-cl.

As it turns out, the return in ToolChains/MSVC.cpp, AddClangSystemIncludeArgs()
for -nostdlibinc is already in the right place (but -nostdlibinc isn't exposed
by clang-cl), so just alias /X to that.

https://reviews.llvm.org/D43888

Modified:
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/test/Driver/cl-include.c

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=326357&r1=326356&r2=326357&view=diff
==
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Wed Feb 28 11:49:07 2018
@@ -166,6 +166,9 @@ def _SLASH_wd4996 : CLFlag<"wd4996">, Al
   AliasArgs<["no-deprecated-declarations"]>;
 def _SLASH_vd : CLJoined<"vd">, HelpText<"Control vtordisp placement">,
   Alias;
+def _SLASH_X : CLFlag<"X">,
+  HelpText<"Don't add %INCLUDE% to the include search path">,
+  Alias;
 def _SLASH_Zc_sizedDealloc : CLFlag<"Zc:sizedDealloc">,
   HelpText<"Enable C++14 sized global deallocation functions">,
   Alias;
@@ -388,7 +391,6 @@ def _SLASH_u : CLFlag<"u">;
 def _SLASH_V : CLFlag<"V">;
 def _SLASH_WL : CLFlag<"WL">;
 def _SLASH_Wp64 : CLFlag<"Wp64">;
-def _SLASH_X : CLFlag<"X">;
 def _SLASH_Yd : CLFlag<"Yd">;
 def _SLASH_Yl : CLJoined<"Yl">;
 def _SLASH_Za : CLFlag<"Za">;

Modified: cfe/trunk/test/Driver/cl-include.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-include.c?rev=326357&r1=326356&r2=326357&view=diff
==
--- cfe/trunk/test/Driver/cl-include.c (original)
+++ cfe/trunk/test/Driver/cl-include.c Wed Feb 28 11:49:07 2018
@@ -10,5 +10,16 @@
 // RUN: env INCLUDE=/my/system/inc %clang_cl -### -- %s 2>&1 | FileCheck %s 
--check-prefix=STDINC
 // STDINC: "-internal-isystem" "/my/system/inc"
 
-// RUN: env INCLUDE=/my/system/inc %clang_cl -nostdinc -### -- %s 2>&1 | 
FileCheck %s --check-prefix=NOSTDINC
+// -nostdinc suppresses all of %INCLUDE%, clang resource dirs, and -imsvc dirs.
+// RUN: env INCLUDE=/my/system/inc %clang_cl -nostdinc -imsvc /my/other/inc 
-### -- %s 2>&1 | FileCheck %s --check-prefix=NOSTDINC
+// NOSTDINC: argument unused{{.*}}-imsvc
 // NOSTDINC-NOT: "-internal-isystem" "/my/system/inc"
+// NOSTDINC-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{.*}}/include"
+// NOSTDINC-NOT: "-internal-isystem" "/my/other/inc"
+
+// /X suppresses %INCLUDE% but not clang resource dirs or -imsvc dirs.
+// RUN: env INCLUDE=/my/system/inc %clang_cl /X -imsvc /my/other/inc -### -- 
%s 2>&1 | FileCheck %s --check-prefix=SLASHX
+// SLASHX-NOT: "argument unused{{.*}}-imsvc"
+// SLASHX-NOT: "-internal-isystem" "/my/system/inc"
+// SLASHX: "-internal-isystem" "{{.*}}/lib/clang/{{.*}}/include"
+// SLASHX: "-internal-isystem" "/my/other/inc"


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


  1   2   >