Re: [PATCH] D19816: [find-all-symbols] Add IWYU private pragma support.

2016-05-04 Thread Kim Gräsman via cfe-commits
Re semantics, you may want to link to IWYU's docs at
https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/IWYUPragmas.md
.

- Kim
Den 3 maj 2016 6:34 em skrev "Manuel Klimek via cfe-commits" <
cfe-commits@lists.llvm.org>:

> klimek added inline comments.
>
> 
> Comment at: include-fixer/find-all-symbols/FindAllSymbols.cpp:173-182
> @@ -165,1 +172,12 @@
>
> +void FindAllSymbols::addPragmaHeader(FileID ID, llvm::StringRef FilePath)
> {
> +  PragmaHeaderMap[ID] = FilePath;
> +}
> +
> +llvm::Optional FindAllSymbols::getPragmaHeader(FileID ID)
> const {
> +  auto It = PragmaHeaderMap.find(ID);
> +  if (It == PragmaHeaderMap.end())
> +return llvm::None;
> +  return It->second;
> +}
> +
> 
> It seems weird to add this and just forward the interface.
>
> 
> Comment at: include-fixer/find-all-symbols/FindAllSymbols.h:49
> @@ -45,1 +48,3 @@
>
> +  void addPragmaHeader(FileID ID, llvm::StringRef FilePath);
> +
> 
> I think the fact that those are generated via IWYU comments are an
> implementation detail, and this code doesn't care. Perhaps call it
> HeaderMapping or HeaderRemapping. Also, it's unclear what the semantics
> are, so I think this needs a comment.
>
> 
> Comment at: include-fixer/find-all-symbols/PragmaCommentHandler.h:23
> @@ +22,3 @@
> +public:
> +  PragmaCommentHandler(FindAllSymbols *Matcher) : Matcher(Matcher) {}
> +
> 
> I'd pull out an interface like HeaderMapCollector or
> ForwardingHeaderCollector, or even just pass in a std::function that
> collects the header. Or, just make this PragmaCommentHandler have a method
> to return a list of forwarding headers?
> Generally, I think this couples the two classes much more than necessary.
>
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D19816
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19816: [find-all-symbols] Add IWYU private pragma support.

2016-05-04 Thread Kim Gräsman via cfe-commits
kimgr added a subscriber: kimgr.
kimgr added a comment.

Re semantics, you may want to link to IWYU's docs at
https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/IWYUPragmas.md
.

- Kim

Den 3 maj 2016 6:34 em skrev "Manuel Klimek via cfe-commits" <
cfe-commits@lists.llvm.org>:

> klimek added inline comments.

> 

> 

>  Comment at: include-fixer/find-all-symbols/FindAllSymbols.cpp:173-182

>  @@ -165,1 +172,12 @@

> 

> +void FindAllSymbols::addPragmaHeader(FileID ID, llvm::StringRef FilePath)

>  {

>  +  PragmaHeaderMap[ID] = FilePath;

>  +}

>  +

>  +llvm::Optional FindAllSymbols::getPragmaHeader(FileID ID)

>  const {

>  +  auto It = PragmaHeaderMap.find(ID);

>  +  if (It == PragmaHeaderMap.end())

>  +return llvm::None;

>  +  return It->second;

>  +}

>  +

> 

>  

> 

> It seems weird to add this and just forward the interface.

> 

> 

>  Comment at: include-fixer/find-all-symbols/FindAllSymbols.h:49

>  @@ -45,1 +48,3 @@

> 

> +  void addPragmaHeader(FileID ID, llvm::StringRef FilePath);

>  +

> 

>  

> 

> I think the fact that those are generated via IWYU comments are an

>  implementation detail, and this code doesn't care. Perhaps call it

>  HeaderMapping or HeaderRemapping. Also, it's unclear what the semantics

>  are, so I think this needs a comment.

> 

> 

>  Comment at: include-fixer/find-all-symbols/PragmaCommentHandler.h:23

>  @@ +22,3 @@

>  +public:

>  +  PragmaCommentHandler(FindAllSymbols *Matcher) : Matcher(Matcher) {}

>  +

> 

>  

> 

> I'd pull out an interface like HeaderMapCollector or

>  ForwardingHeaderCollector, or even just pass in a std::function that

>  collects the header. Or, just make this PragmaCommentHandler have a method

>  to return a list of forwarding headers?

>  Generally, I think this couples the two classes much more than necessary.

> 

> Repository:

> 

>   rL LLVM

> 

> http://reviews.llvm.org/D19816

> 

>  ___

> 

> cfe-commits mailing list

>  cfe-commits@lists.llvm.org

>  http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits



Repository:
  rL LLVM

http://reviews.llvm.org/D19816



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


Re: [PATCH] D19851: Warn on binding reference to null in copy initialization

2016-05-04 Thread Nick Lewycky via cfe-commits
nicholas marked 2 inline comments as done.
nicholas added a comment.

Richard Smith gave me some review feedback in person, the diagnostic should not 
be generated when setting up the Steps for the initializer sequence, but 
instead when InitializerSequence::Perform is called. This appears to work 
correctly and also catches a few more cases.

I did not expand this to SK_BindReferenceToTemporary, please review this 
decision. It's also missing missing bit-field and vector element checks that 
SK_BindReference has.

Also, I'd appreciate comments on the factoring with 
CheckForNullPointerDereference which was copied+pasted from SemaExpr.cpp. 
Please review this issue too, I did not expect to land the patch the way it's 
currently written.



Comment at: test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp:39
@@ -38,3 +38,3 @@
 
-  bogus_override_if_virtual bogus;
+  bogus_override_if_virtual bogus; // expected-note{{in 
instantiation of member function 'bogus_override_if_virtual<(lambda}}
 }

aaron.ballman wrote:
> Missing `>` in the diagnostic text (I know it's not required, but it looks a 
> bit strange if that's the only part missing from the diagnostic text).
What follows lambda is the path to the file, then the closing )>. I'd rather 
not include that part. I could make it up with .* just to balance the parens, 
but I think that's not worth it.


http://reviews.llvm.org/D19851



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


Re: [PATCH] D19851: Warn on binding reference to null in copy initialization

2016-05-04 Thread Nick Lewycky via cfe-commits
nicholas updated this revision to Diff 56100.

http://reviews.llvm.org/D19851

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaInit.cpp
  test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
  test/Parser/cxx-casting.cpp
  test/SemaCXX/cstyle-cast.cpp
  test/SemaCXX/functional-cast.cpp
  test/SemaCXX/new-delete.cpp
  test/SemaCXX/static-cast.cpp

Index: test/SemaCXX/static-cast.cpp
===
--- test/SemaCXX/static-cast.cpp
+++ test/SemaCXX/static-cast.cpp
@@ -43,11 +43,11 @@
   (void)static_cast((int*)0);
   (void)static_cast((const int*)0);
   (void)static_cast((B*)0);
-  (void)static_cast(*((B*)0));
+  (void)static_cast(*((B*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)static_cast((C1*)0);
-  (void)static_cast(*((C1*)0));
+  (void)static_cast(*((C1*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)static_cast((D*)0);
-  (void)static_cast(*((D*)0));
+  (void)static_cast(*((D*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)static_cast((int A::*)0);
   (void)static_cast((void (A::*)())0);
 
Index: test/SemaCXX/new-delete.cpp
===
--- test/SemaCXX/new-delete.cpp
+++ test/SemaCXX/new-delete.cpp
@@ -444,11 +444,11 @@
 
   template
   void tfn() {
-new (*(PlacementArg*)0) T[1];
+new (*(PlacementArg*)0) T[1]; // expected-warning 2 {{binding null pointer to reference has undefined behavior}}
   }
 
   void fn() {
-tfn();
+tfn();  // expected-note {{in instantiation of function template specialization 'r150682::tfn' requested here}}
   }
 
 }
Index: test/SemaCXX/functional-cast.cpp
===
--- test/SemaCXX/functional-cast.cpp
+++ test/SemaCXX/functional-cast.cpp
@@ -126,14 +126,14 @@
   typedef A *Ap;
   (void)Ap((B*)0);
   typedef A &Ar;
-  (void)Ar(*((B*)0));
+  (void)Ar(*((B*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   typedef const B *cBp;
   (void)cBp((C1*)0);
   typedef B &Br;
-  (void)Br(*((C1*)0));
+  (void)Br(*((C1*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)Ap((D*)0);
   typedef const A &cAr;
-  (void)cAr(*((D*)0));
+  (void)cAr(*((D*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   typedef int B::*Bmp;
   (void)Bmp((int A::*)0);
   typedef void (B::*Bmfp)();
Index: test/SemaCXX/cstyle-cast.cpp
===
--- test/SemaCXX/cstyle-cast.cpp
+++ test/SemaCXX/cstyle-cast.cpp
@@ -84,11 +84,11 @@
   (void)(void*)((int*)0);
   (void)(volatile const void*)((const int*)0);
   (void)(A*)((B*)0);
-  (void)(A&)(*((B*)0));
+  (void)(A&)(*((B*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)(const B*)((C1*)0);
-  (void)(B&)(*((C1*)0));
+  (void)(B&)(*((C1*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)(A*)((D*)0);
-  (void)(const A&)(*((D*)0));
+  (void)(const A&)(*((D*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)(int B::*)((int A::*)0);
   (void)(void (B::*)())((void (A::*)())0);
   (void)(A*)((E*)0); // C-style cast ignores access control
Index: test/Parser/cxx-casting.cpp
===
--- test/Parser/cxx-casting.cpp
+++ test/Parser/cxx-casting.cpp
@@ -37,7 +37,7 @@
 // This was being incorrectly tentatively parsed.
 namespace test1 {
   template  class A {}; // expected-note 2{{here}}
-  void foo() { A(*(A*)0); }
+  void foo() { A(*(A*)0); } // expected-warning {{binding null pointer to reference has undefined behavior}}
 }
 
 typedef char* c;
Index: test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
===
--- test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
+++ test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
@@ -11,7 +11,7 @@
 
 template
 struct bogus_override_if_virtual : public T {
-  bogus_override_if_virtual() : T(*(T*)0) { }
+  bogus_override_if_virtual() : T(*(T*)0) { } // expected-warning {{binding null pointer to reference has undefined behavior}}
   int operator()() const;
 };
 
@@ -36,7 +36,7 @@
   lv(); // expected-error{{no matching function for call to object of type}}
   mlv(); // expected-error{{no matching function for call to object of type}}
 
-  bogus_override_if_virtual bogus;
+  bogus_override_if_virtual bogus; // expected-note{{in instantiation of member function 'bogus_override_if_virtual<(lambda}}
 }
 
 // Core issue 974: default arguments (8.3.6) may be specified in the
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ 

Re: [PATCH] D19816: [find-all-symbols] Add IWYU private pragma support.

2016-05-04 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 56101.
hokein marked 2 inline comments as done.
hokein added a comment.

Address review comments.


http://reviews.llvm.org/D19816

Files:
  include-fixer/find-all-symbols/CMakeLists.txt
  include-fixer/find-all-symbols/FindAllSymbols.cpp
  include-fixer/find-all-symbols/FindAllSymbols.h
  include-fixer/find-all-symbols/PragmaCommentHandler.cpp
  include-fixer/find-all-symbols/PragmaCommentHandler.h
  include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -8,11 +8,13 @@
 //===--===//
 
 #include "FindAllSymbols.h"
+#include "PragmaCommentHandler.h"
 #include "SymbolInfo.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemOptions.h"
 #include "clang/Basic/VirtualFileSystem.h"
+#include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/PCHContainerOperations.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
@@ -62,6 +64,41 @@
   std::vector Symbols;
 };
 
+class MockFindAllSymbolsAction : public clang::ASTFrontendAction {
+public:
+  MockFindAllSymbolsAction(FindAllSymbols::ResultReporter *Reporter)
+  : MatchFinder(), Collector(), Handler(&Collector),
+Matcher(Reporter, &Collector) {
+Matcher.registerMatchers(&MatchFinder);
+  }
+
+  std::unique_ptr
+  CreateASTConsumer(clang::CompilerInstance &Compiler,
+StringRef InFile) override {
+Compiler.getPreprocessor().addCommentHandler(&Handler);
+return MatchFinder.newASTConsumer();
+  }
+
+private:
+  ast_matchers::MatchFinder MatchFinder;
+  PragmaCommentHandler::HeaderMapCollector Collector;
+  PragmaCommentHandler Handler;
+  FindAllSymbols Matcher;
+};
+
+class MockFindAllSymbolsActionFactory
+: public clang::tooling::FrontendActionFactory {
+public:
+  MockFindAllSymbolsActionFactory(MockReporter *Reporter)
+  : Reporter(Reporter) {}
+  clang::FrontendAction *create() override {
+return new MockFindAllSymbolsAction(Reporter);
+  }
+
+private:
+  MockReporter *const Reporter;
+};
+
 class FindAllSymbolsTest : public ::testing::Test {
 public:
   bool hasSymbol(const SymbolInfo &Symbol) {
@@ -73,18 +110,16 @@
   }
 
   bool runFindAllSymbols(StringRef Code) {
-FindAllSymbols matcher(&Reporter);
-clang::ast_matchers::MatchFinder MatchFinder;
-matcher.registerMatchers(&MatchFinder);
-
 llvm::IntrusiveRefCntPtr InMemoryFileSystem(
 new vfs::InMemoryFileSystem);
 llvm::IntrusiveRefCntPtr Files(
 new FileManager(FileSystemOptions(), InMemoryFileSystem));
 
 std::string FileName = "symbol.cc";
-std::unique_ptr Factory =
-clang::tooling::newFrontendActionFactory(&MatchFinder);
+
+std::unique_ptr Factory(
+new MockFindAllSymbolsActionFactory(&Reporter));
+
 tooling::ToolInvocation Invocation(
 {std::string("find_all_symbols"), std::string("-fsyntax-only"),
  FileName},
@@ -371,5 +406,20 @@
   }
 }
 
+TEST_F(FindAllSymbolsTest, IWYUPrivatePragmaTest) {
+  static const char Code[] = R"(
+// IWYU pragma: private, include "bar.h"
+struct Bar {
+};
+  )";
+  runFindAllSymbols(Code);
+
+  {
+SymbolInfo Symbol =
+CreateSymbolInfo("Bar", SymbolInfo::Class, "bar.h", 3, {});
+EXPECT_TRUE(hasSymbol(Symbol));
+  }
+}
+
 } // namespace find_all_symbols
 } // namespace clang
Index: include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
===
--- include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
+++ include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
@@ -9,7 +9,12 @@
 
 #include "FindAllSymbols.h"
 #include "SymbolInfo.h"
+#include "PragmaCommentHandler.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -82,6 +87,32 @@
   std::map> Symbols;
 };
 
+class FindAllSymbolsAction : public clang::ASTFrontendAction {
+public:
+  FindAllSymbolsAction()
+  : Reporter(), MatchFinder(), Collector(),
+Handler(&Collector),
+Matcher(&Reporter, &Collector) {
+Matcher.registerMatchers(&MatchFinder);
+  }
+
+  std::unique_ptr
+  CreateASTConsumer(clang::CompilerInstance &Compiler,
+StringRef InFile) override {
+Compiler.getPreprocessor().addCommentHandler(&Handler

Re: [PATCH] D19869: Added XrefsDBManager into include-fixer and made XrefsDB return SymbolInfo.

2016-05-04 Thread Haojian Wu via cfe-commits
hokein added inline comments.


Comment at: include-fixer/InMemoryXrefsDB.cpp:24-26
@@ +23,5 @@
+for (const auto &Header : Entry.second) {
+  SymbolInfo Info;
+  Info.Name = Names.back();
+  Info.FilePath = Header;
+  for (auto IdentiferContext = Names.rbegin() + 1;

Yeah, the intention is that it's not easy to construct a **completed** instance 
at one time since it has many fields. 


http://reviews.llvm.org/D19869



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


Re: [PATCH] D19869: Added XrefsDBManager into include-fixer and made XrefsDB return SymbolInfo.

2016-05-04 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg



Comment at: include-fixer/InMemoryXrefsDB.cpp:24-26
@@ +23,5 @@
+for (const auto &Header : Entry.second) {
+  SymbolInfo Info;
+  Info.Name = Names.back();
+  Info.FilePath = Header;
+  for (auto IdentiferContext = Names.rbegin() + 1;

hokein wrote:
> Yeah, the intention is that it's not easy to construct a **completed** 
> instance at one time since it has many fields. 
Overall, I think creating an instance and then setting members should only be 
done from places very strongly coupled to the class.
Generally, I think in these cases creating static members of the class that 
construct the objects from the various data sources you have (like in this case 
from a string, and a vector) are preferable; not necessary to address 
this in this CL, but please add a FIXME.

(also, specifically regarding the comment that it's not easy to construct a 
completed instance: that is a large hint that it should be encoded somewhere 
close to the class)


Comment at: include-fixer/IncludeFixer.h:34-35
@@ -33,3 +33,4 @@
   IncludeFixerActionFactory(
-  XrefsDB &Xrefs, std::vector &Replacements,
+  XrefsDBManager &XrefsDBMgr,
+  std::vector &Replacements,
   bool MinimizeIncludePaths = true);

ioeric wrote:
> klimek wrote:
> > That seems unexpected. Why is the XrefsDBManager in the business of doing 
> > SymbolInfo -> include path mappings?
> Since the mapping was done in XrefsDB before, I kept the way it was. 
> Migrating SymbolInfo -> Include path mappings into IncludeFixer will be the 
> next step, and I'll need to discuss with Ben about where exactly we want to 
> place it.
Please add a FIXME that this is going to change.


Comment at: unittests/include-fixer/IncludeFixerTest.cpp:86
@@ +85,3 @@
+  // string without "std::" can also be fixed since fixed db results go through
+  // XrefsDBManager, and XrefsDBManager matches unqualified identifier too.
+  EXPECT_EQ("#include \nstring foo;\n",

identifiers


http://reviews.llvm.org/D19869



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


Re: [PATCH] D19869: Added XrefsDBManager into include-fixer and made XrefsDB return SymbolInfo.

2016-05-04 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 56104.
ioeric marked 8 inline comments as done.
ioeric added a comment.

- Added FIXMEs and fixed a nit.


http://reviews.llvm.org/D19869

Files:
  include-fixer/CMakeLists.txt
  include-fixer/InMemoryXrefsDB.cpp
  include-fixer/InMemoryXrefsDB.h
  include-fixer/IncludeFixer.cpp
  include-fixer/IncludeFixer.h
  include-fixer/XrefsDB.h
  include-fixer/XrefsDBManager.cpp
  include-fixer/XrefsDBManager.h
  include-fixer/YamlXrefsDB.cpp
  include-fixer/YamlXrefsDB.h
  include-fixer/find-all-symbols/SymbolInfo.h
  include-fixer/tool/ClangIncludeFixer.cpp
  unittests/include-fixer/IncludeFixerTest.cpp

Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -9,6 +9,7 @@
 
 #include "InMemoryXrefsDB.h"
 #include "IncludeFixer.h"
+#include "XrefsDBManager.h"
 #include "unittests/Tooling/RewriterTestContext.h"
 #include "clang/Tooling/Tooling.h"
 #include "gtest/gtest.h"
@@ -51,10 +52,12 @@
   {"std::string::size_type", {""}},
   {"a::b::foo", {"dir/otherdir/qux.h"}},
   };
-  auto XrefsDB =
-  llvm::make_unique(std::move(XrefsMap));
+  auto XrefsDBMgr = llvm::make_unique();
+  XrefsDBMgr->addXrefsDB(
+  llvm::make_unique(std::move(XrefsMap)));
+
   std::vector Replacements;
-  IncludeFixerActionFactory Factory(*XrefsDB, Replacements);
+  IncludeFixerActionFactory Factory(*XrefsDBMgr, Replacements);
   runOnCode(&Factory, Code, "input.cc", ExtraArgs);
   clang::RewriterTestContext Context;
   clang::FileID ID = Context.createInMemoryFile("input.cc", Code);
@@ -79,8 +82,10 @@
   "#include \n#include \"foo.h\"\nstd::string::size_type foo;\n",
   runIncludeFixer("#include \"foo.h\"\nstd::string::size_type foo;\n"));
 
-  // The fixed xrefs db doesn't know how to handle string without std::.
-  EXPECT_EQ("string foo;\n", runIncludeFixer("string foo;\n"));
+  // string without "std::" can also be fixed since fixed db results go through
+  // XrefsDBManager, and XrefsDBManager matches unqualified identifiers too.
+  EXPECT_EQ("#include \nstring foo;\n",
+runIncludeFixer("string foo;\n"));
 }
 
 TEST(IncludeFixer, IncompleteType) {
Index: include-fixer/tool/ClangIncludeFixer.cpp
===
--- include-fixer/tool/ClangIncludeFixer.cpp
+++ include-fixer/tool/ClangIncludeFixer.cpp
@@ -9,6 +9,7 @@
 
 #include "InMemoryXrefsDB.h"
 #include "IncludeFixer.h"
+#include "XrefsDBManager.h"
 #include "YamlXrefsDB.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Rewrite/Core/Rewriter.h"
@@ -48,8 +49,8 @@
   tooling::ClangTool tool(options.getCompilations(),
   options.getSourcePathList());
 
-  // Set up the data source.
-  std::unique_ptr XrefsDB;
+  // Set up data source.
+  auto XrefsDBMgr = llvm::make_unique();
   switch (DatabaseFormat) {
   case fixed: {
 // Parse input and fill the database with it.
@@ -67,19 +68,20 @@
 Headers.push_back(Header.trim());
   XrefsMap[Split.first.trim()] = std::move(Headers);
 }
-XrefsDB =
-llvm::make_unique(std::move(XrefsMap));
+XrefsDBMgr->addXrefsDB(
+llvm::make_unique(std::move(XrefsMap)));
 break;
   }
   case yaml: {
-XrefsDB = llvm::make_unique(Input);
+XrefsDBMgr->addXrefsDB(
+llvm::make_unique(Input));
 break;
   }
   }
 
   // Now run our tool.
   std::vector Replacements;
-  include_fixer::IncludeFixerActionFactory Factory(*XrefsDB, Replacements,
+  include_fixer::IncludeFixerActionFactory Factory(*XrefsDBMgr, Replacements,
MinimizeIncludePaths);
 
   tool.run(&Factory); // Always succeeds.
Index: include-fixer/find-all-symbols/SymbolInfo.h
===
--- include-fixer/find-all-symbols/SymbolInfo.h
+++ include-fixer/find-all-symbols/SymbolInfo.h
@@ -21,6 +21,7 @@
 namespace find_all_symbols {
 
 /// \brief Contains all information for a Symbol.
+// FIXME: add static members for creating complete instances.
 struct SymbolInfo {
   enum SymbolKind {
 Function,
Index: include-fixer/YamlXrefsDB.h
===
--- include-fixer/YamlXrefsDB.h
+++ include-fixer/YamlXrefsDB.h
@@ -23,7 +23,8 @@
 public:
   YamlXrefsDB(llvm::StringRef FilePath);
 
-  std::vector search(llvm::StringRef Identifier) override;
+  std::vector
+  search(llvm::StringRef Identifier) override;
 
 private:
   std::vector Symbols;
Index: include-fixer/XrefsDBManager.h
===
--- include-fixer/XrefsDBManager.h
+++ include-fixer/XrefsDBManager.h
@@ -1,38 +1,45 @@
-//===-- XrefsDB.h - Interface for symbol-header matching *- C++ -*-===//
+//===-- XrefsDBManager.h - Managing multiple XrefsDBs 

[clang-tools-extra] r268480 - Added XrefsDBManager into include-fixer and made XrefsDB return SymbolInfo.

2016-05-04 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed May  4 03:22:35 2016
New Revision: 268480

URL: http://llvm.org/viewvc/llvm-project?rev=268480&view=rev
Log:
Added XrefsDBManager into include-fixer and made XrefsDB return SymbolInfo.

Summary: Added XrefsDBManager into include-fixer and made XrefsDB return 
SymbolInfo.

Reviewers: hokein, djasper, klimek

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D19869

Added:
clang-tools-extra/trunk/include-fixer/XrefsDBManager.cpp
  - copied, changed from r268371, 
clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp
clang-tools-extra/trunk/include-fixer/XrefsDBManager.h
  - copied, changed from r268371, 
clang-tools-extra/trunk/include-fixer/XrefsDB.h
Modified:
clang-tools-extra/trunk/include-fixer/CMakeLists.txt
clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.cpp
clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.h
clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
clang-tools-extra/trunk/include-fixer/IncludeFixer.h
clang-tools-extra/trunk/include-fixer/XrefsDB.h
clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp
clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h
clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Modified: clang-tools-extra/trunk/include-fixer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/CMakeLists.txt?rev=268480&r1=268479&r2=268480&view=diff
==
--- clang-tools-extra/trunk/include-fixer/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/include-fixer/CMakeLists.txt Wed May  4 03:22:35 
2016
@@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
 add_clang_library(clangIncludeFixer
   IncludeFixer.cpp
   InMemoryXrefsDB.cpp
+  XrefsDBManager.cpp
   YamlXrefsDB.cpp
 
   LINK_LIBS

Modified: clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.cpp?rev=268480&r1=268479&r2=268480&view=diff
==
--- clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.cpp Wed May  4 
03:22:35 2016
@@ -9,10 +9,34 @@
 
 #include "InMemoryXrefsDB.h"
 
+using clang::find_all_symbols::SymbolInfo;
+
 namespace clang {
 namespace include_fixer {
 
-std::vector InMemoryXrefsDB::search(llvm::StringRef Identifier) {
+InMemoryXrefsDB::InMemoryXrefsDB(
+const std::map> &LookupTable) {
+  for (const auto &Entry : LookupTable) {
+llvm::StringRef Identifier(Entry.first);
+llvm::SmallVector Names;
+Identifier.split(Names, "::");
+for (const auto &Header : Entry.second) {
+  // FIXME: create a complete instance with static member function when it
+  // is implemented.
+  SymbolInfo Info;
+  Info.Name = Names.back();
+  Info.FilePath = Header;
+  for (auto IdentiferContext = Names.rbegin() + 1;
+   IdentiferContext != Names.rend(); ++IdentiferContext) {
+Info.Contexts.push_back(
+{SymbolInfo::ContextType::Namespace, *IdentiferContext});
+  }
+  this->LookupTable[Info.Name].push_back(Info);
+}
+  }
+}
+
+std::vector InMemoryXrefsDB::search(llvm::StringRef Identifier) {
   auto I = LookupTable.find(Identifier);
   if (I != LookupTable.end())
 return I->second;

Modified: clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.h?rev=268480&r1=268479&r2=268480&view=diff
==
--- clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.h (original)
+++ clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.h Wed May  4 03:22:35 
2016
@@ -21,13 +21,15 @@ namespace include_fixer {
 /// Xref database with fixed content.
 class InMemoryXrefsDB : public XrefsDB {
 public:
-  InMemoryXrefsDB(std::map> LookupTable)
-  : LookupTable(std::move(LookupTable)) {}
+  InMemoryXrefsDB(
+  const std::map> &LookupTable);
 
-  std::vector search(llvm::StringRef Identifier) override;
+  std::vector
+  search(llvm::StringRef Identifier) override;
 
 private:
-  std::map> LookupTable;
+  std::map>
+  LookupTable;
 };
 
 } // namespace include_fixer

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp?rev=268480&r1=268479&r2=268480&view=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Wed May  4 03

Re: [PATCH] D19869: Added XrefsDBManager into include-fixer and made XrefsDB return SymbolInfo.

2016-05-04 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268480: Added XrefsDBManager into include-fixer and made 
XrefsDB return SymbolInfo. (authored by ioeric).

Changed prior to commit:
  http://reviews.llvm.org/D19869?vs=56104&id=56105#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19869

Files:
  clang-tools-extra/trunk/include-fixer/CMakeLists.txt
  clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.cpp
  clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.h
  clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
  clang-tools-extra/trunk/include-fixer/IncludeFixer.h
  clang-tools-extra/trunk/include-fixer/XrefsDB.h
  clang-tools-extra/trunk/include-fixer/XrefsDBManager.cpp
  clang-tools-extra/trunk/include-fixer/XrefsDBManager.h
  clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp
  clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h
  clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
  clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
  clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Index: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
===
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
@@ -9,6 +9,7 @@
 
 #include "InMemoryXrefsDB.h"
 #include "IncludeFixer.h"
+#include "XrefsDBManager.h"
 #include "unittests/Tooling/RewriterTestContext.h"
 #include "clang/Tooling/Tooling.h"
 #include "gtest/gtest.h"
@@ -51,10 +52,12 @@
   {"std::string::size_type", {""}},
   {"a::b::foo", {"dir/otherdir/qux.h"}},
   };
-  auto XrefsDB =
-  llvm::make_unique(std::move(XrefsMap));
+  auto XrefsDBMgr = llvm::make_unique();
+  XrefsDBMgr->addXrefsDB(
+  llvm::make_unique(std::move(XrefsMap)));
+
   std::vector Replacements;
-  IncludeFixerActionFactory Factory(*XrefsDB, Replacements);
+  IncludeFixerActionFactory Factory(*XrefsDBMgr, Replacements);
   runOnCode(&Factory, Code, "input.cc", ExtraArgs);
   clang::RewriterTestContext Context;
   clang::FileID ID = Context.createInMemoryFile("input.cc", Code);
@@ -79,8 +82,10 @@
   "#include \n#include \"foo.h\"\nstd::string::size_type foo;\n",
   runIncludeFixer("#include \"foo.h\"\nstd::string::size_type foo;\n"));
 
-  // The fixed xrefs db doesn't know how to handle string without std::.
-  EXPECT_EQ("string foo;\n", runIncludeFixer("string foo;\n"));
+  // string without "std::" can also be fixed since fixed db results go through
+  // XrefsDBManager, and XrefsDBManager matches unqualified identifiers too.
+  EXPECT_EQ("#include \nstring foo;\n",
+runIncludeFixer("string foo;\n"));
 }
 
 TEST(IncludeFixer, IncompleteType) {
Index: clang-tools-extra/trunk/include-fixer/XrefsDB.h
===
--- clang-tools-extra/trunk/include-fixer/XrefsDB.h
+++ clang-tools-extra/trunk/include-fixer/XrefsDB.h
@@ -10,26 +10,26 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_XREFSDB_H
 #define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_XREFSDB_H
 
+#include "find-all-symbols/SymbolInfo.h"
 #include "llvm/ADT/StringRef.h"
 #include 
 
 namespace clang {
 namespace include_fixer {
 
-/// This class provides an interface for finding the header files corresponding
-/// to an indentifier in the source code.
+/// This class provides an interface for finding all `SymbolInfo`s corresponding
+/// to a symbol name from a symbol database.
 class XrefsDB {
 public:
   virtual ~XrefsDB() = default;
 
-  /// Search for header files to be included for an identifier.
-  /// \param Identifier The identifier being searched for. May or may not be
-  ///   fully qualified.
-  /// \returns A list of inclusion candidates, in a format ready for being
-  ///  pasted after an #include token.
+  /// Search for all `SymbolInfo`s corresponding to an identifier.
+  /// \param Identifier The unqualified identifier being searched for.
+  /// \returns A list of `SymbolInfo` candidates.
   // FIXME: Expose the type name so we can also insert using declarations (or
   // fix the usage)
-  virtual std::vector search(llvm::StringRef Identifier) = 0;
+  virtual std::vector
+  search(llvm::StringRef Identifier) = 0;
 };
 
 } // namespace include_fixer
Index: clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.h
===
--- clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.h
+++ clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.h
@@ -21,13 +21,15 @@
 /// Xref database with fixed content.
 class InMemoryXrefsDB : public XrefsDB {
 public:
-  InMemoryXrefsDB(std::map> LookupTable)
-  : LookupTable(std::move(LookupTable)) {}
+  InMemoryXrefsDB(
+  const std::map> &LookupTable);
 
-  std::vector search(llvm::StringRef Identifier) override;
+  std::vector
+  

[PATCH] D19909: [Attr] Add support for the `ms_hook_prologue` attribute.

2016-05-04 Thread Charles Davis via cfe-commits
cdavis5x created this revision.
cdavis5x added reviewers: aaron.ballman, rnk.
cdavis5x added a subscriber: cfe-commits.
cdavis5x added a dependency: D19908: [X86] Support the "ms-hotpatch" attribute..

Based on a patch by Michael Mueller.

This attribute specifies that a function can be hooked or patched. This
mechanism was originally devised by Microsoft for hotpatching their
binaries (which they're constantly updating to stay ahead of crackers,
script kiddies, and other ne'er-do-wells on the Internet), but it's now
commonly abused by Windows programs that want to hook API functions. It
is for this reason that this attribute was added to GCC--hence the name,
`ms_hook_prologue`.

Depends on D19908.

http://reviews.llvm.org/D19909

Files:
  include/clang/Basic/Attr.td
  lib/CodeGen/TargetInfo.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/function-attributes.c

Index: test/CodeGen/function-attributes.c
===
--- test/CodeGen/function-attributes.c
+++ test/CodeGen/function-attributes.c
@@ -108,11 +108,18 @@
   _setjmp(0);
 }
 
+// CHECK-LABEL: define void @f21
+// CHECK: [[HOTPATCH:#[0-9]+]]
+// CHECK: {
+void __attribute__((ms_hook_prologue)) f21(void) {
+}
+
 // CHECK: attributes [[NUW]] = { nounwind optsize{{.*}} }
 // CHECK: attributes [[AI]] = { alwaysinline nounwind optsize{{.*}} }
 // CHECK: attributes [[NUW_OS_RN]] = { nounwind optsize readnone{{.*}} }
 // CHECK: attributes [[ALIGN]] = { nounwind optsize alignstack=16{{.*}} }
 // CHECK: attributes [[RT]] = { nounwind optsize returns_twice{{.*}} }
+// CHECK: attributes [[HOTPATCH]] = { nounwind 
optsize{{.*}}"ms-hotpatch"{{.*}} }
 // CHECK: attributes [[NR]] = { noreturn optsize }
 // CHECK: attributes [[NUW_RN]] = { nounwind optsize readnone }
 // CHECK: attributes [[RT_CALL]] = { optsize returns_twice }
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5742,6 +5742,9 @@
 break;
 
   // Microsoft attributes:
+  case AttributeList::AT_MSHookPrologue:
+handleSimpleAttribute(S, D, Attr);
+break;
   case AttributeList::AT_MSNoVTable:
 handleSimpleAttribute(S, D, Attr);
 break;
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -1743,6 +1743,10 @@
   llvm::Function *Fn = cast(GV);
   Fn->setCallingConv(llvm::CallingConv::X86_INTR);
 }
+if (FD->hasAttr()) {
+  llvm::Function *Fn = cast(GV);
+  Fn->addFnAttr("ms-hotpatch");
+}
   }
 }
 
@@ -2073,6 +2077,10 @@
 llvm::Function *Fn = cast(GV);
 Fn->setCallingConv(llvm::CallingConv::X86_INTR);
   }
+  if (FD->hasAttr()) {
+llvm::Function *Fn = cast(GV);
+Fn->addFnAttr("ms-hotpatch");
+  }
 }
   }
 };
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -2029,6 +2029,12 @@
 
 // Microsoft-related attributes
 
+def MSHookPrologue : InheritableAttr {
+  let Spellings = [GCC<"ms_hook_prologue">];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [Undocumented];
+}
+
 def MSNoVTable : InheritableAttr, TargetSpecificAttr {
   let Spellings = [Declspec<"novtable">];
   let Subjects = SubjectList<[CXXRecord]>;


Index: test/CodeGen/function-attributes.c
===
--- test/CodeGen/function-attributes.c
+++ test/CodeGen/function-attributes.c
@@ -108,11 +108,18 @@
   _setjmp(0);
 }
 
+// CHECK-LABEL: define void @f21
+// CHECK: [[HOTPATCH:#[0-9]+]]
+// CHECK: {
+void __attribute__((ms_hook_prologue)) f21(void) {
+}
+
 // CHECK: attributes [[NUW]] = { nounwind optsize{{.*}} }
 // CHECK: attributes [[AI]] = { alwaysinline nounwind optsize{{.*}} }
 // CHECK: attributes [[NUW_OS_RN]] = { nounwind optsize readnone{{.*}} }
 // CHECK: attributes [[ALIGN]] = { nounwind optsize alignstack=16{{.*}} }
 // CHECK: attributes [[RT]] = { nounwind optsize returns_twice{{.*}} }
+// CHECK: attributes [[HOTPATCH]] = { nounwind optsize{{.*}}"ms-hotpatch"{{.*}} }
 // CHECK: attributes [[NR]] = { noreturn optsize }
 // CHECK: attributes [[NUW_RN]] = { nounwind optsize readnone }
 // CHECK: attributes [[RT_CALL]] = { optsize returns_twice }
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5742,6 +5742,9 @@
 break;
 
   // Microsoft attributes:
+  case AttributeList::AT_MSHookPrologue:
+handleSimpleAttribute(S, D, Attr);
+break;
   case AttributeList::AT_MSNoVTable:
 handleSimpleAttribute(S, D, Attr);
 break;
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++

r268481 - [Clang][Builtin][AVX512] Adding intrinsics fot cvt{u}si2s{d|s} cvt{sd|ss}2{ss|sd} instruction set

2016-05-04 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Wed May  4 03:55:11 2016
New Revision: 268481

URL: http://llvm.org/viewvc/llvm-project?rev=268481&view=rev
Log:
[Clang][Builtin][AVX512] Adding intrinsics fot cvt{u}si2s{d|s} 
cvt{sd|ss}2{ss|sd} instruction set

Differential Revision: http://reviews.llvm.org/D19765


Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=268481&r1=268480&r2=268481&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed May  4 03:55:11 2016
@@ -2259,6 +2259,15 @@ TARGET_BUILTIN(__builtin_ia32_vcvtps2ph2
 TARGET_BUILTIN(__builtin_ia32_cvtw2mask512, "UiV32s","","avx512bw")
 TARGET_BUILTIN(__builtin_ia32_cvtw2mask128, "UcV8s","","avx512bw,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_cvtw2mask256, "UsV16s","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_cvtsd2ss_round_mask, 
"V4fV4fV4fV2dUcIi","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_cvtsi2sd64, "V2dV2dLLiIi","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_cvtsi2ss32, "V4fV4fiIi","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_cvtsi2ss64, "V4fV4fLLiIi","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_cvtss2sd_round_mask, 
"V2dV2dV2dV4fUcIi","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_cvtusi2sd32, "V2dV2dUi","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_cvtusi2sd64, "V2dV2dULLiIi","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_cvtusi2ss32, "V4fV4fUiIi","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_cvtusi2ss64, "V4fV4fULLiIi","","avx512f")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=268481&r1=268480&r2=268481&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Wed May  4 03:55:11 2016
@@ -8066,6 +8066,117 @@ _mm512_mask_compressstoreu_epi32 (void *
 (__mmask16) __U);
 }
 
+#define _mm_cvt_roundsd_ss( __A, __B, __R) __extension__ ({ \
+__builtin_ia32_cvtsd2ss_round_mask ((__v4sf)( __A),\
+ (__v2df)( __B),\
+ (__v4sf) _mm_undefined_ps (),\
+ (__mmask8) -1,\
+ ( __R));\
+})
+
+#define _mm_mask_cvt_roundsd_ss( __W, __U, __A, __B, __R) __extension__ ({ \
+__builtin_ia32_cvtsd2ss_round_mask ((__v4sf)( __A),\
+ (__v2df)( __B),\
+ (__v4sf) __W,\
+ (__mmask8) __U,\
+ ( __R));\
+})
+
+#define _mm_maskz_cvt_roundsd_ss( __U, __A, __B, __R) __extension__ ({ \
+__builtin_ia32_cvtsd2ss_round_mask ((__v4sf)( __A),\
+ (__v2df)( __B),\
+ (__v4sf) _mm_setzero_ps (),\
+ (__mmask8) __U,\
+ ( __R));\
+})
+
+#define _mm_cvt_roundi64_sd( __A, __B, __R) __extension__ ({ \
+__builtin_ia32_cvtsi2sd64 ((__v2df)( __A),( __B),( __R));\
+})
+
+#define _mm_cvt_roundsi64_sd( __A, __B, __R) __extension__ ({ \
+__builtin_ia32_cvtsi2sd64 ((__v2df)( __A),( __B),( __R));\
+})
+
+#define _mm_cvt_roundsi32_ss( __A, __B, __R) __extension__ ({ \
+__builtin_ia32_cvtsi2ss32 ((__v4sf)( __A),( __B),( __R));\
+})
+
+#define _mm_cvt_roundi32_ss( __A, __B, __R) __extension__ ({ \
+__builtin_ia32_cvtsi2ss32 ((__v4sf)( __A),( __B),( __R));\
+})
+
+#define _mm_cvt_roundsi64_ss( __A, __B, __R) __extension__ ({ \
+__builtin_ia32_cvtsi2ss64 ((__v4sf)( __A),( __B),( __R));\
+})
+
+#define _mm_cvt_roundi64_ss( __A, __B, __R) __extension__ ({ \
+__builtin_ia32_cvtsi2ss64 ((__v4sf)( __A),( __B),( __R));\
+})
+
+#define _mm_cvt_roundss_sd( __A, __B, __R) __extension__ ({ \
+__builtin_ia32_cvtss2sd_round_mask ((__v2df)( __A),\
+  (__v4sf)( __B),\
+  (__v2df) _mm_undefined_pd (),\
+  (__mmask8)-1,\
+  ( __R));\
+})
+
+#define _mm_mask_cvt_roundss_sd(__W, __U,__A, __B, __R) __extension__ ({ \
+__builtin_ia32_cvtss2sd_round_mask ((__v2df)( __A),\
+  (__v4sf)( __B),\
+  (__v2df) __W,\
+  (__mmask8) __U,\
+  ( __R));\
+})
+
+#define _mm_maskz_cvt_roundss_sd( __U,__A, __B, __R) __extension__ ({ \
+__builtin_ia32_cvtss2sd_round_mask ((__v2df)( __A),\
+  (__v4sf)( __B),\
+  (__v2df) _mm_setzero_pd(),\
+  (__mmask8) __U,\
+  ( __R));\
+})
+
+static __inline__ __m128d __DEFAULT_FN_ATTRS
+_mm_cvtu32_sd (__m128d __A, unsigned __B)
+{
+  return (__m128d) __builtin_ia32_cvtusi2sd32 ((__v2df) __A, __B);
+}
+
+#define _mm_cvt_roundu64_sd( __A, __B, __R) __extension__ ({ \
+__builtin_ia32_cvtusi2sd64 ((__v2df)( __A),( __B),( __R));\
+})
+
+static __inline__ __m128d __DEFAULT_FN_ATTRS
+_mm_cvtu64_sd (__m1

[PATCH] D19910: [unwinder] Get rid of unused code

2016-05-04 Thread Asiri Rathnayake via cfe-commits
rmaprath created this revision.
rmaprath added reviewers: jroelofs, logan.
rmaprath added subscribers: cfe-commits, logan.

Hi Jon,

Spotted some obviously unused code in `Unwind-EHABI.cpp` while working on 
something else. This seem to have been introduced in revision 
`9f323e0fca08a0d60c51c4d0927cd1485b064913` by @logan. Didn't want to commit 
straight-away as I haven't touched the unwinder code yet. Feel free to commit 
on my behalf.

Thanks.

/ Asiri

http://reviews.llvm.org/D19910

Files:
  src/Unwind-EHABI.cpp

Index: src/Unwind-EHABI.cpp
===
--- src/Unwind-EHABI.cpp
+++ src/Unwind-EHABI.cpp
@@ -450,24 +450,6 @@
 
   // Walk each frame looking for a place to stop.
   for (bool handlerNotFound = true; handlerNotFound;) {
-
-#if !_LIBUNWIND_ARM_EHABI
-// Ask libuwind to get next frame (skip over first which is
-// _Unwind_RaiseException).
-int stepResult = unw_step(&cursor1);
-if (stepResult == 0) {
-  _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): unw_step() reached 
"
- "bottom => _URC_END_OF_STACK\n",
- static_cast(exception_object));
-  return _URC_END_OF_STACK;
-} else if (stepResult < 0) {
-  _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): unw_step failed => 
"
- "_URC_FATAL_PHASE1_ERROR\n",
- static_cast(exception_object));
-  return _URC_FATAL_PHASE1_ERROR;
-}
-#endif
-
 // See if frame has code to run (has personality routine).
 unw_proc_info_t frameInfo;
 if (unw_get_proc_info(&cursor1, &frameInfo) != UNW_ESUCCESS) {
@@ -566,9 +548,6 @@
 
   // Walk each frame until we reach where search phase said to stop.
   while (true) {
-// Ask libuwind to get next frame (skip over first which is
-// _Unwind_RaiseException or _Unwind_Resume).
-//
 // Resume only ever makes sense for 1 frame.
 _Unwind_State state =
 resume ? _US_UNWIND_FRAME_RESUME : _US_UNWIND_FRAME_STARTING;
@@ -585,21 +564,6 @@
   resume = false;
 }
 
-#if !_LIBUNWIND_ARM_EHABI
-int stepResult = unw_step(&cursor2);
-if (stepResult == 0) {
-  _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_step() reached 
"
- "bottom => _URC_END_OF_STACK\n",
- static_cast(exception_object));
-  return _URC_END_OF_STACK;
-} else if (stepResult < 0) {
-  _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_step failed => 
"
- "_URC_FATAL_PHASE1_ERROR\n",
- static_cast(exception_object));
-  return _URC_FATAL_PHASE2_ERROR;
-}
-#endif
-
 // Get info about this frame.
 unw_word_t sp;
 unw_proc_info_t frameInfo;


Index: src/Unwind-EHABI.cpp
===
--- src/Unwind-EHABI.cpp
+++ src/Unwind-EHABI.cpp
@@ -450,24 +450,6 @@
 
   // Walk each frame looking for a place to stop.
   for (bool handlerNotFound = true; handlerNotFound;) {
-
-#if !_LIBUNWIND_ARM_EHABI
-// Ask libuwind to get next frame (skip over first which is
-// _Unwind_RaiseException).
-int stepResult = unw_step(&cursor1);
-if (stepResult == 0) {
-  _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): unw_step() reached "
- "bottom => _URC_END_OF_STACK\n",
- static_cast(exception_object));
-  return _URC_END_OF_STACK;
-} else if (stepResult < 0) {
-  _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): unw_step failed => "
- "_URC_FATAL_PHASE1_ERROR\n",
- static_cast(exception_object));
-  return _URC_FATAL_PHASE1_ERROR;
-}
-#endif
-
 // See if frame has code to run (has personality routine).
 unw_proc_info_t frameInfo;
 if (unw_get_proc_info(&cursor1, &frameInfo) != UNW_ESUCCESS) {
@@ -566,9 +548,6 @@
 
   // Walk each frame until we reach where search phase said to stop.
   while (true) {
-// Ask libuwind to get next frame (skip over first which is
-// _Unwind_RaiseException or _Unwind_Resume).
-//
 // Resume only ever makes sense for 1 frame.
 _Unwind_State state =
 resume ? _US_UNWIND_FRAME_RESUME : _US_UNWIND_FRAME_STARTING;
@@ -585,21 +564,6 @@
   resume = false;
 }
 
-#if !_LIBUNWIND_ARM_EHABI
-int stepResult = unw_step(&cursor2);
-if (stepResult == 0) {
-  _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_step() reached "
- "bottom => _URC_END_OF_STACK\n",
- static_cast(exception_object));
-  return _URC_END_OF_STACK;
-} else if (stepResult < 0) {
-  _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_step failed => "
-   

Re: [PATCH] D19905: clang-rename: when renaming a class, rename pointers to that class as well

2016-05-04 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

LG. Thanks!


http://reviews.llvm.org/D19905



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


Re: [PATCH] D19905: clang-rename: when renaming a class, rename pointers to that class as well

2016-05-04 Thread Manuel Klimek via cfe-commits
klimek added a comment.

(let me know if you need me to submit this)


http://reviews.llvm.org/D19905



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


Re: [PATCH] D19905: clang-rename: when renaming a class, rename pointers to that class as well

2016-05-04 Thread Manuel Klimek via cfe-commits
Note: if you intend to send more patches in the future, please consider
becoming one. It's very painless :)

On Wed, May 4, 2016 at 11:38 AM Miklos Vajna  wrote:

> vmiklos added a comment.
>
> Yes, please submit it; I'm not a committer.
>
>
> http://reviews.llvm.org/D19905
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19905: clang-rename: when renaming a class, rename pointers to that class as well

2016-05-04 Thread Manuel Klimek via cfe-commits
klimek added a comment.

Note: if you intend to send more patches in the future, please consider
becoming one. It's very painless :)


http://reviews.llvm.org/D19905



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


[clang-tools-extra] r268484 - When renaming a class, ename pointers to that class as well.

2016-05-04 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Wed May  4 04:45:44 2016
New Revision: 268484

URL: http://llvm.org/viewvc/llvm-project?rev=268484&view=rev
Log:
When renaming a class, ename pointers to that class as well.

Patch by Miklos Vajna.

Added:
clang-tools-extra/trunk/test/clang-rename/ClassTest.cpp
Modified:
clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp

Modified: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp?rev=268484&r1=268483&r2=268484&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp Wed May  4 04:45:44 
2016
@@ -45,6 +45,18 @@ public:
 return true;
   }
 
+  bool VisitVarDecl(clang::VarDecl *Decl) {
+clang::QualType Type = Decl->getType();
+const clang::RecordDecl *RecordDecl = Type->getPointeeCXXRecordDecl();
+if (RecordDecl) {
+  if (getUSRForDecl(RecordDecl) == USR) {
+// The declaration refers to a type that is to be renamed.
+LocationsFound.push_back(Decl->getTypeSpecStartLoc());
+  }
+}
+return true;
+  }
+
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {

Added: clang-tools-extra/trunk/test/clang-rename/ClassTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/ClassTest.cpp?rev=268484&view=auto
==
--- clang-tools-extra/trunk/test/clang-rename/ClassTest.cpp (added)
+++ clang-tools-extra/trunk/test/clang-rename/ClassTest.cpp Wed May  4 04:45:44 
2016
@@ -0,0 +1,15 @@
+class Cla  // CHECK: class Hector
+{
+};
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=6 -new-name=Hector %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+int main()
+{
+Cla *Pointer = 0; // CHECK: Hector *Pointer = 0;
+return 0;
+}
+
+// Use grep -FUbo 'Cla'  to get the correct offset of Cla when changing
+// this file.


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


Re: [PATCH] D17820: Clang Code Completion Filtering

2016-05-04 Thread Bianca-Cristina Cristescu via cfe-commits
CrisCristescu updated this revision to Diff 56115.
CrisCristescu added a comment.

Addresses the previous comments and adds testing for filtering. 
All the tests already in CodeCompletion are testing both the backward 
compatibility and the new functionality itself.


Repository:
  rL LLVM

http://reviews.llvm.org/D17820

Files:
  include/clang/Lex/Preprocessor.h
  include/clang/Sema/CodeCompleteConsumer.h
  lib/Lex/Lexer.cpp
  lib/Lex/Preprocessor.cpp
  lib/Sema/CodeCompleteConsumer.cpp
  test/CodeCompletion/Filtering/filter-function-name.cpp
  test/CodeCompletion/Filtering/filter-member-access.cpp
  test/CodeCompletion/Filtering/filter-namespace.cpp
  test/CodeCompletion/Filtering/filter-ordinary-name.cpp
  test/CodeCompletion/objc-message.mm
  test/Index/complete-method-decls.m
  test/Index/complete-objc-message-id.m
  test/Index/complete-objc-message.m
  test/Index/complete-recovery.m
  test/Index/complete-super.m

Index: test/Index/complete-super.m
===
--- test/Index/complete-super.m
+++ test/Index/complete-super.m
@@ -60,7 +60,7 @@
 // RUN: c-index-test -code-completion-at=%s:20:16 %s | FileCheck -check-prefix=CHECK-ADD-TO %s
 // CHECK-ADD-TO: ObjCInstanceMethodDecl:{ResultType void}{Informative add:}{TypedText to:}{Placeholder b} (20)
 
-// RUN: c-index-test -code-completion-at=%s:24:28 %s | FileCheck -check-prefix=CHECK-SELECTOR-FIRST %s
+// RUN: c-index-test -code-completion-at=%s:24:29 %s | FileCheck -check-prefix=CHECK-SELECTOR-FIRST %s
 // CHECK-SELECTOR-FIRST: ObjCClassMethodDecl:{ResultType void}{Informative select:}{TypedText first:}{Placeholder a}{HorizontalSpace  }{Text second:}{Placeholder b} (20)
 
 // Check "super" completion at the third identifier
@@ -69,7 +69,7 @@
 
 // Check "super" completion with missing '['.
 // RUN: c-index-test -code-completion-at=%s:25:10 %s | FileCheck -check-prefix=CHECK-SELECTOR-SELECTOR %s
-// RUN: c-index-test -code-completion-at=%s:25:28 %s | FileCheck -check-prefix=CHECK-SELECTOR-FIRST %s
+// RUN: c-index-test -code-completion-at=%s:25:29 %s | FileCheck -check-prefix=CHECK-SELECTOR-FIRST %s
 // RUN: c-index-test -code-completion-at=%s:25:37 %s | FileCheck -check-prefix=CHECK-SELECTOR-SECOND %s
 
 // Check "super" completion for a method declared in a category.
Index: test/Index/complete-recovery.m
===
--- test/Index/complete-recovery.m
+++ test/Index/complete-recovery.m
@@ -26,7 +26,7 @@
 // Test case for fix committed in r145441.
 // RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:9:20 %s -fms-compatibility | FileCheck -check-prefix=CHECK-CC1 %s
 
-// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:10:24 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:10:25 %s | FileCheck -check-prefix=CHECK-CC2 %s
 // CHECK-CC2: NotImplemented:{ResultType char[]}{TypedText @encode}{LeftParen (}{Placeholder type-name}{RightParen )}
 // CHECK-CC2: NotImplemented:{TypedText _Bool}
 // CHECK-CC2: VarDecl:{ResultType A *}{TypedText a}
Index: test/Index/complete-objc-message.m
===
--- test/Index/complete-objc-message.m
+++ test/Index/complete-objc-message.m
@@ -218,13 +218,13 @@
 // CHECK-CC2-NEXT: Container Kind: ObjCInterfaceDecl
 // CHECK-CC2-NEXT: Container is complete
 // CHECK-CC2-NEXT: Container USR: c:objc(cs)Foo
-// RUN: c-index-test -code-completion-at=%s:61:16 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: c-index-test -code-completion-at=%s:61:17 %s | FileCheck -check-prefix=CHECK-CC3 %s
 // CHECK-CC3: ObjCClassMethodDecl:{ResultType int}{TypedText MyClassMethod:}{Placeholder (id)}
 // CHECK-CC3: ObjCClassMethodDecl:{ResultType int}{TypedText MyPrivateMethod}
-// RUN: c-index-test -code-completion-at=%s:65:16 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// RUN: c-index-test -code-completion-at=%s:65:17 %s | FileCheck -check-prefix=CHECK-CC4 %s
 // CHECK-CC4: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)}{HorizontalSpace  }{TypedText second:}{Placeholder (id)}
 // CHECK-CC4: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyPrivateInstMethod}
-// RUN: c-index-test -code-completion-at=%s:74:9 %s | FileCheck -check-prefix=CHECK-CC5 %s
+// RUN: c-index-test -code-completion-at=%s:74:10 %s | FileCheck -check-prefix=CHECK-CC5 %s
 // CHECK-CC5: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)}{HorizontalSpace  }{TypedText second:}{Placeholder (id)}
 // CHECK-CC5: ObjCInstanceMethodDecl:{ResultType int}{TypedText MySubInstMethod}
 // RUN: c-index-test -code-completion-at=%s:82:8 %s | FileCheck -check-prefix=CHECK-CC6 %s
@@ -311,7 +311,7 @@
 // CHECK-CCI: ObjCInstanceMethodDecl:{ResultType void}{TypedText method1} (37)
 // CHECK-CCI: ObjCInstanceMethodDecl:{ResultType 

Re: [PATCH] D18035: [GCC] PR23529 Mangler part of attrbute abi_tag support

2016-05-04 Thread Dmitry Polukhin via cfe-commits
On Wed, May 4, 2016 at 12:26 AM, Richard Smith 
wrote:

> On Tue, May 3, 2016 at 12:51 PM, Dmitry Polukhin via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> DmitryPolukhin added a comment.
>>
>> Richard, could you please share your counterexample so I could test it on
>> my patch and GCC?
>>
>
> Sure:
>
>   struct __attribute__((abi_tag("X"))) Foo {};
>   void __attribute__((abi_tag("X"))) f(Foo) {}
>
> This should not generate an ABI tag for 'f', because there's one implied
> by the first parameter type. But as far as I can see, this patch doesn't
> look at the parameter types at all until after it's already streamed out
> the mangling for the function name.
>

In this example ABI tag X is explicit tag for function 'f' so it must be
always emitted. Moreover even implicit tag case handled correctly i.e. no
implicit tag for function if the tag is already used in function
parameters. Here is my example and both GCC and Clang with my patch gives
identical mangling:

struct __attribute__((abi_tag("X"))) Foo {};

// _Z1fB1X3FooB1X pretty printed 'f[abi:X](Foo[abi:X])'
void __attribute__((abi_tag("X"))) f(Foo) {}

// _Z2f13FooB1X pretty printed 'f1(Foo[abi:X])'
Foo f1(Foo) {}

As for not looking for function arguments before emitting function name.
Please take a look to makeAdditionalTagsForFunction that handles this case.
It calls getTagsFromPrefixAndTemplateArguments also takes into account
function parameters (it disables implicit tags from return type and mangles
function declaration).

I think a reasonable way to deal with this is:
>
> 1) Collect the ABI tags for the overall entity. Whenever we subsequently
> emit an ABI tag (or emit an inline namespace and suppress emitting its ABI
> tags), remove that tag from our list of ABI tags for the overall entity (if
> it's there).
> 2) Mangle up to and including the name of the entity. If there are any ABI
> tags left for the entity, do subsequent mangling into a temporary buffer
> instead of directly into the output stream.
> 3) Mangle the rest of the declaration.
> 4) If there are any ABI tags left for the overall entity, and we have not
> already mangled the return type, then mangle it to a scratch buffer (which
> we'll throw away).
> 5) If we mangled to a temporary buffer, emit any remaining ABI tags now
> followed by the contents of the temporary buffer.
>
> As for separate pass, it was my first reaction on the original patch from
>> Stefan but soon I realized that I'll have to copy parts of magnler to some
>> simplified mangler but with high probability of forgetting something and
>> with code duplication. So now I think approach which runs full mangler in
>> special mode is better and less error prone.
>>
>>
>> http://reviews.llvm.org/D18035
>>
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18035: [GCC] PR23529 Mangler part of attrbute abi_tag support

2016-05-04 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin updated this revision to Diff 56116.
DmitryPolukhin added a comment.

+ rebase
+ added testcase with Richard's example


http://reviews.llvm.org/D18035

Files:
  lib/AST/ItaniumMangle.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGenCXX/mangle-abi-tag.cpp
  test/SemaCXX/attr-abi-tag-syntax.cpp

Index: test/SemaCXX/attr-abi-tag-syntax.cpp
===
--- test/SemaCXX/attr-abi-tag-syntax.cpp
+++ test/SemaCXX/attr-abi-tag-syntax.cpp
@@ -16,28 +16,18 @@
 // expected-warning@-1 {{'abi_tag' attribute on anonymous namespace ignored}}
 
 inline namespace N __attribute__((__abi_tag__)) {}
-// FIXME: remove this warning as soon as attribute fully supported.
-// expected-warning@-2 {{'__abi_tag__' attribute ignored}}
 
 } // namespcace N2
 
 __attribute__((abi_tag("B", "A"))) extern int a1;
-// FIXME: remove this warning as soon as attribute fully supported.
-// expected-warning@-2 {{'abi_tag' attribute ignored}}
 
 __attribute__((abi_tag("A", "B"))) extern int a1;
 // expected-note@-1 {{previous declaration is here}}
-// FIXME: remove this warning as soon as attribute fully supported.
-// expected-warning@-3 {{'abi_tag' attribute ignored}}
 
 __attribute__((abi_tag("A", "C"))) extern int a1;
 // expected-error@-1 {{'abi_tag' C missing in original declaration}}
-// FIXME: remove this warning as soon as attribute fully supported.
-// expected-warning@-3 {{'abi_tag' attribute ignored}}
 
 extern int a2;
 // expected-note@-1 {{previous declaration is here}}
 __attribute__((abi_tag("A")))extern int a2;
 // expected-error@-1 {{cannot add 'abi_tag' attribute in a redeclaration}}
-// FIXME: remove this warning as soon as attribute fully supported.
-// expected-warning@-3 {{'abi_tag' attribute ignored}}
Index: test/CodeGenCXX/mangle-abi-tag.cpp
===
--- /dev/null
+++ test/CodeGenCXX/mangle-abi-tag.cpp
@@ -0,0 +1,144 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple %itanium_abi_triple -std=c++11 -o - | FileCheck %s
+
+struct __attribute__((abi_tag("A", "B"))) A { };
+
+struct B: A { };
+
+template
+
+struct C {
+};
+
+struct D { A* p; };
+
+template
+struct __attribute__((abi_tag("C", "D"))) E {
+};
+
+struct __attribute__((abi_tag("A", "B"))) F { };
+
+A a1;
+// CHECK: @_Z2a1B1AB1B =
+
+__attribute__((abi_tag("C", "D")))
+A a2;
+// CHECK: @_Z2a2B1AB1BB1CB1D =
+
+B a3;
+// CHECK: @a3 =
+
+C a4;
+// CHECK: @_Z2a4B1AB1B =
+
+D a5;
+// CHECK: @a5 =
+
+E a6;
+// CHECK: @_Z2a6B1CB1D =
+
+E a7;
+// CHECK: @_Z2a7B1AB1BB1CB1D =
+
+template<>
+struct E {
+  static float a8;
+};
+float E::a8;
+// CHECK: @_ZN1EB1CB1DIfE2a8E =
+
+template<>
+struct E {
+  static bool a9;
+};
+bool E::a9;
+// CHECK: @_ZN1EB1CB1DI1FB1AB1BE2a9E =
+
+struct __attribute__((abi_tag("A", "B"))) A10 {
+  virtual ~A10() {}
+} a10;
+// vtable
+// CHECK: @_ZTV3A10B1AB1B =
+// typeinfo
+// CHECK: @_ZTI3A10B1AB1B =
+
+// Local variables from f13.
+// f13()::L::foo[abi:C][abi:D]()::a[abi:A][abi:B]
+// CHECK-DAG: @_ZZZ3f13vEN1L3fooB1CB1DEvE1aB1AB1B =
+// guard variable for f13()::L::foo[abi:C][abi:D]()::a[abi:A][abi:B]
+// CHECK-DAG: @_ZGVZZ3f13vEN1L3fooB1CB1DEvE1aB1AB1B =
+
+__attribute__ ((abi_tag("C", "D")))
+void* f1() {
+  return 0;
+}
+// CHECK: define {{.*}} @_Z2f1B1CB1Dv(
+
+__attribute__ ((abi_tag("C", "D")))
+A* f2() {
+  return 0;
+}
+// CHECK: define {{.*}} @_Z2f2B1AB1BB1CB1Dv(
+
+B* f3() {
+  return 0;
+}
+// CHECK: define {{.*}} @_Z2f3v(
+
+C* f4() {
+  return 0;
+}
+// CHECK: define {{.*}} @_Z2f4B1AB1Bv(
+
+D* f5() {
+  return 0;
+}
+// CHECK: define {{.*}} @_Z2f5v(
+
+E* f6() {
+  return 0;
+}
+// CHECK: define {{.*}} @_Z2f6B1CB1Dv(
+
+E* f7() {
+  return 0;
+}
+// CHECK: define {{.*}} @_Z2f7B1AB1BB1CB1Dv(
+
+void f8(E*) {
+}
+// CHECK: define {{.*}} @_Z2f8P1EB1CB1DI1AB1AB1BE(
+
+inline namespace Names1 __attribute__((__abi_tag__)) {
+class C1 {};
+}
+C1 f9() { return C1(); }
+// CHECK: @_Z2f9B6Names1v()
+
+inline namespace Names2 __attribute__((__abi_tag__("Tag1", "Tag2"))) {
+class C2 {};
+}
+C2 f10() { return C2(); }
+// CHECK: @_Z3f10B4Tag1B4Tag2v()
+
+void __attribute__((abi_tag("A"))) f11(A) {}
+// f11[abi:A](A[abi:A][abi:B])
+// CHECK: define {{.*}} @_Z3f11B1A1AB1AB1B(
+
+A f12(A) { return A(); }
+// f12(A[abi:A][abi:B])
+// CHECK: define {{.*}} @_Z3f121AB1AB1B(
+
+inline void f13() {
+  struct L {
+static E* foo() {
+  static A10 a;
+  return 0;
+}
+  };
+  L::foo();
+}
+void f11_test() {
+  f13();
+}
+// f13()::L::foo[abi:C][abi:D]()
+// CHECK: define linkonce_odr %struct.E* @_ZZ3f13vEN1L3fooB1CB1DEv(
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4694,10 +4694,6 @@
   D->addAttr(::new (S.Context)
  AbiTagAttr(Attr.getRange(), S.Context, Tags.data(), Tags.size(),
 Attr.getAttributeSpellingListIndex()));
-
-  // FIXME: remove this warning as soon

Re: [PATCH] D19654: PR27132: Proper mangling for __unaligned qualifier (now with PR27367 fixed)

2016-05-04 Thread Andrey Bokhanko via cfe-commits
andreybokhanko marked 3 inline comments as done.


Comment at: lib/AST/MicrosoftMangle.cpp:1583-1584
@@ -1579,2 +1582,4 @@
   case QMM_Result:
+// Presence of __unaligned qualifier shouldn't affect mangling here.
+Quals.removeUnaligned();
 if ((!IsPointer && Quals) || isa(T)) {

majnemer wrote:
> andreybokhanko wrote:
> > Done. Test added.
> Hmm, can you give a concrete example why we need this line?
Sure. An example is:

__unaligned int unaligned_foo3() { return 0; }

MS mangles it as

?unaligned_foo3@@YAHXZ

However, if __unaligned is taken into account, "if ((!IsPointer && Quals) || 
isa(T))" computes to true and clang adds "?A", resulting to

?unaligned_foo3@@YA?AHXZ

Yours,
Andrey



http://reviews.llvm.org/D19654



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


Re: [PATCH] D19816: [find-all-symbols] Add IWYU private pragma support.

2016-05-04 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 56120.
hokein added a comment.

Improvements based on offline discussion.


http://reviews.llvm.org/D19816

Files:
  include-fixer/find-all-symbols/CMakeLists.txt
  include-fixer/find-all-symbols/FindAllSymbols.cpp
  include-fixer/find-all-symbols/FindAllSymbols.h
  include-fixer/find-all-symbols/HeaderMapCollector.h
  include-fixer/find-all-symbols/PragmaCommentHandler.cpp
  include-fixer/find-all-symbols/PragmaCommentHandler.h
  include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -8,11 +8,14 @@
 //===--===//
 
 #include "FindAllSymbols.h"
+#include "HeaderMapCollector.h"
+#include "PragmaCommentHandler.h"
 #include "SymbolInfo.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemOptions.h"
 #include "clang/Basic/VirtualFileSystem.h"
+#include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/PCHContainerOperations.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
@@ -62,6 +65,41 @@
   std::vector Symbols;
 };
 
+class TestFindAllSymbolsAction : public clang::ASTFrontendAction {
+public:
+  TestFindAllSymbolsAction(FindAllSymbols::ResultReporter *Reporter)
+  : MatchFinder(), Collector(), Handler(&Collector),
+Matcher(Reporter, &Collector) {
+Matcher.registerMatchers(&MatchFinder);
+  }
+
+  std::unique_ptr
+  CreateASTConsumer(clang::CompilerInstance &Compiler,
+StringRef InFile) override {
+Compiler.getPreprocessor().addCommentHandler(&Handler);
+return MatchFinder.newASTConsumer();
+  }
+
+private:
+  ast_matchers::MatchFinder MatchFinder;
+  HeaderMapCollector Collector;
+  PragmaCommentHandler Handler;
+  FindAllSymbols Matcher;
+};
+
+class TestFindAllSymbolsActionFactory
+: public clang::tooling::FrontendActionFactory {
+public:
+  TestFindAllSymbolsActionFactory(MockReporter *Reporter)
+  : Reporter(Reporter) {}
+  clang::FrontendAction *create() override {
+return new TestFindAllSymbolsAction(Reporter);
+  }
+
+private:
+  MockReporter *const Reporter;
+};
+
 class FindAllSymbolsTest : public ::testing::Test {
 public:
   bool hasSymbol(const SymbolInfo &Symbol) {
@@ -73,18 +111,16 @@
   }
 
   bool runFindAllSymbols(StringRef Code) {
-FindAllSymbols matcher(&Reporter);
-clang::ast_matchers::MatchFinder MatchFinder;
-matcher.registerMatchers(&MatchFinder);
-
 llvm::IntrusiveRefCntPtr InMemoryFileSystem(
 new vfs::InMemoryFileSystem);
 llvm::IntrusiveRefCntPtr Files(
 new FileManager(FileSystemOptions(), InMemoryFileSystem));
 
 std::string FileName = "symbol.cc";
-std::unique_ptr Factory =
-clang::tooling::newFrontendActionFactory(&MatchFinder);
+
+std::unique_ptr Factory(
+new TestFindAllSymbolsActionFactory(&Reporter));
+
 tooling::ToolInvocation Invocation(
 {std::string("find_all_symbols"), std::string("-fsyntax-only"),
  FileName},
@@ -371,5 +407,20 @@
   }
 }
 
+TEST_F(FindAllSymbolsTest, IWYUPrivatePragmaTest) {
+  static const char Code[] = R"(
+// IWYU pragma: private, include "bar.h"
+struct Bar {
+};
+  )";
+  runFindAllSymbols(Code);
+
+  {
+SymbolInfo Symbol =
+CreateSymbolInfo("Bar", SymbolInfo::Class, "bar.h", 3, {});
+EXPECT_TRUE(hasSymbol(Symbol));
+  }
+}
+
 } // namespace find_all_symbols
 } // namespace clang
Index: include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
===
--- include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
+++ include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
@@ -8,8 +8,14 @@
 //===--===//
 
 #include "FindAllSymbols.h"
+#include "HeaderMapCollector.h"
+#include "PragmaCommentHandler.h"
 #include "SymbolInfo.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -82,6 +88,31 @@
   std::map> Symbols;
 };
 
+class FindAllSymbolsAction : public clang::ASTFrontendAction {
+public:
+  FindAllSymbolsAction()
+  : Reporter(), MatchFinder(), Collector(), Handler(&Collector),
+Matcher(&Reporter, &Collector) {
+Matcher.registerMatchers(&MatchFinder);
+  }
+
+  std::unique_ptr
+  CreateASTConsu

Re: [PATCH] D19816: [find-all-symbols] Add IWYU private pragma support.

2016-05-04 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 56121.
hokein added a comment.

Fix a nit.


http://reviews.llvm.org/D19816

Files:
  include-fixer/find-all-symbols/CMakeLists.txt
  include-fixer/find-all-symbols/FindAllSymbols.cpp
  include-fixer/find-all-symbols/FindAllSymbols.h
  include-fixer/find-all-symbols/HeaderMapCollector.h
  include-fixer/find-all-symbols/PragmaCommentHandler.cpp
  include-fixer/find-all-symbols/PragmaCommentHandler.h
  include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -8,11 +8,14 @@
 //===--===//
 
 #include "FindAllSymbols.h"
+#include "HeaderMapCollector.h"
+#include "PragmaCommentHandler.h"
 #include "SymbolInfo.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemOptions.h"
 #include "clang/Basic/VirtualFileSystem.h"
+#include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/PCHContainerOperations.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
@@ -62,6 +65,41 @@
   std::vector Symbols;
 };
 
+class TestFindAllSymbolsAction : public clang::ASTFrontendAction {
+public:
+  TestFindAllSymbolsAction(FindAllSymbols::ResultReporter *Reporter)
+  : MatchFinder(), Collector(), Handler(&Collector),
+Matcher(Reporter, &Collector) {
+Matcher.registerMatchers(&MatchFinder);
+  }
+
+  std::unique_ptr
+  CreateASTConsumer(clang::CompilerInstance &Compiler,
+StringRef InFile) override {
+Compiler.getPreprocessor().addCommentHandler(&Handler);
+return MatchFinder.newASTConsumer();
+  }
+
+private:
+  ast_matchers::MatchFinder MatchFinder;
+  HeaderMapCollector Collector;
+  PragmaCommentHandler Handler;
+  FindAllSymbols Matcher;
+};
+
+class TestFindAllSymbolsActionFactory
+: public clang::tooling::FrontendActionFactory {
+public:
+  TestFindAllSymbolsActionFactory(MockReporter *Reporter)
+  : Reporter(Reporter) {}
+  clang::FrontendAction *create() override {
+return new TestFindAllSymbolsAction(Reporter);
+  }
+
+private:
+  MockReporter *const Reporter;
+};
+
 class FindAllSymbolsTest : public ::testing::Test {
 public:
   bool hasSymbol(const SymbolInfo &Symbol) {
@@ -73,18 +111,16 @@
   }
 
   bool runFindAllSymbols(StringRef Code) {
-FindAllSymbols matcher(&Reporter);
-clang::ast_matchers::MatchFinder MatchFinder;
-matcher.registerMatchers(&MatchFinder);
-
 llvm::IntrusiveRefCntPtr InMemoryFileSystem(
 new vfs::InMemoryFileSystem);
 llvm::IntrusiveRefCntPtr Files(
 new FileManager(FileSystemOptions(), InMemoryFileSystem));
 
 std::string FileName = "symbol.cc";
-std::unique_ptr Factory =
-clang::tooling::newFrontendActionFactory(&MatchFinder);
+
+std::unique_ptr Factory(
+new TestFindAllSymbolsActionFactory(&Reporter));
+
 tooling::ToolInvocation Invocation(
 {std::string("find_all_symbols"), std::string("-fsyntax-only"),
  FileName},
@@ -371,5 +407,20 @@
   }
 }
 
+TEST_F(FindAllSymbolsTest, IWYUPrivatePragmaTest) {
+  static const char Code[] = R"(
+// IWYU pragma: private, include "bar.h"
+struct Bar {
+};
+  )";
+  runFindAllSymbols(Code);
+
+  {
+SymbolInfo Symbol =
+CreateSymbolInfo("Bar", SymbolInfo::Class, "bar.h", 3, {});
+EXPECT_TRUE(hasSymbol(Symbol));
+  }
+}
+
 } // namespace find_all_symbols
 } // namespace clang
Index: include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
===
--- include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
+++ include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
@@ -8,8 +8,14 @@
 //===--===//
 
 #include "FindAllSymbols.h"
+#include "HeaderMapCollector.h"
+#include "PragmaCommentHandler.h"
 #include "SymbolInfo.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -82,6 +88,31 @@
   std::map> Symbols;
 };
 
+class FindAllSymbolsAction : public clang::ASTFrontendAction {
+public:
+  FindAllSymbolsAction()
+  : Reporter(), MatchFinder(), Collector(), Handler(&Collector),
+Matcher(&Reporter, &Collector) {
+Matcher.registerMatchers(&MatchFinder);
+  }
+
+  std::unique_ptr
+  CreateASTConsumer(clang::CompilerInstance &Co

r268487 - Add a test for driver options from m_x86_Features_Group.

2016-05-04 Thread Andrey Turetskiy via cfe-commits
Author: aturetsk
Date: Wed May  4 06:10:29 2016
New Revision: 268487

URL: http://llvm.org/viewvc/llvm-project?rev=268487&view=rev
Log:
Add a test for driver options from m_x86_Features_Group.

Differential Revision: http://reviews.llvm.org/D19658

Added:
cfe/trunk/test/Driver/x86-target-features.c   (with props)

Added: cfe/trunk/test/Driver/x86-target-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/x86-target-features.c?rev=268487&view=auto
==
--- cfe/trunk/test/Driver/x86-target-features.c (added)
+++ cfe/trunk/test/Driver/x86-target-features.c Wed May  4 06:10:29 2016
@@ -0,0 +1,44 @@
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mmmx -m3dnow 
-m3dnowa %s -### -o %t.o 2>&1 | FileCheck -check-prefix=MMX %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-mmx -mno-3dnow 
-mno-3dnowa %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-MMX %s
+// MMX: "-target-feature" "+mmx" "-target-feature" "+3dnow" "-target-feature" 
"+3dnowa"
+// NO-MMX: "-target-feature" "-mmx" "-target-feature" "-3dnow" 
"-target-feature" "-3dnowa"
+
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -msse -msse2 -msse3 
-mssse3 -msse4a -msse4.1 -msse4.2 %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=SSE %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-sse -mno-sse2 
-mno-sse3 -mno-ssse3 -mno-sse4a -mno-sse4.1 -mno-sse4.2 %s -### -o %t.o 2>&1 | 
FileCheck -check-prefix=NO-SSE %s
+// SSE: "-target-feature" "+sse" "-target-feature" "+sse2" "-target-feature" 
"+sse3" "-target-feature" "+ssse3" "-target-feature" "+sse4a" "-target-feature" 
"+sse4.1" "-target-feature" "+sse4.2"
+// NO-SSE: "-target-feature" "-sse" "-target-feature" "-sse2" 
"-target-feature" "-sse3" "-target-feature" "-ssse3" "-target-feature" "-sse4a" 
"-target-feature" "-sse4.1" "-target-feature" "-sse4.2"
+
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -msse4 -maes %s -### 
-o %t.o 2>&1 | FileCheck -check-prefix=SSE4-AES %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-sse4 -mno-aes 
%s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-SSE4-AES %s
+// SSE4-AES: "-target-feature" "+sse4.2" "-target-feature" "+aes"
+// NO-SSE4-AES: "-target-feature" "-sse4.1" "-target-feature" "-aes"
+
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mavx -mavx2 
-mavx512f -mavx512cd -mavx512er -mavx512pf -mavx512dq -mavx512bw -mavx512vl 
-mavx512vbmi -mavx512ifma %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-avx -mno-avx2 
-mno-avx512f -mno-avx512cd -mno-avx512er -mno-avx512pf -mno-avx512dq 
-mno-avx512bw -mno-avx512vl -mno-avx512vbmi -mno-avx512ifma %s -### -o %t.o 
2>&1 | FileCheck -check-prefix=NO-AVX %s
+// AVX: "-target-feature" "+avx" "-target-feature" "+avx2" "-target-feature" 
"+avx512f" "-target-feature" "+avx512cd" "-target-feature" "+avx512er" 
"-target-feature" "+avx512pf" "-target-feature" "+avx512dq" "-target-feature" 
"+avx512bw" "-target-feature" "+avx512vl" "-target-feature" "+avx512vbmi" 
"-target-feature" "+avx512ifma"
+// NO-AVX: "-target-feature" "-avx" "-target-feature" "-avx2" 
"-target-feature" "-avx512f" "-target-feature" "-avx512cd" "-target-feature" 
"-avx512er" "-target-feature" "-avx512pf" "-target-feature" "-avx512dq" 
"-target-feature" "-avx512bw" "-target-feature" "-avx512vl" "-target-feature" 
"-avx512vbmi" "-target-feature" "-avx512ifma"
+
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mpclmul -mrdrnd 
-mfsgsbase -mbmi -mbmi2 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=BMI %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-pclmul 
-mno-rdrnd -mno-fsgsbase -mno-bmi -mno-bmi2 %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=NO-BMI %s
+// BMI: "-target-feature" "+pclmul" "-target-feature" "+rdrnd" 
"-target-feature" "+fsgsbase" "-target-feature" "+bmi" "-target-feature" "+bmi2"
+// NO-BMI: "-target-feature" "-pclmul" "-target-feature" "-rdrnd" 
"-target-feature" "-fsgsbase" "-target-feature" "-bmi" "-target-feature" "-bmi2"
+
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mlzcnt -mpopcnt 
-mtbm -mfma -mfma4 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=FMA %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-lzcnt 
-mno-popcnt -mno-tbm -mno-fma -mno-fma4 %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=NO-FMA %s
+// FMA: "-target-feature" "+lzcnt" "-target-feature" "+popcnt" 
"-target-feature" "+tbm" "-target-feature" "+fma" "-target-feature" "+fma4"
+// NO-FMA: "-target-feature" "-lzcnt" "-target-feature" "-popcnt" 
"-target-feature" "-tbm" "-target-feature" "-fma" "-target-feature" "-fma4"
+
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mxop -mf16c -mrtm 
-mprfchw -mrdseed %s -### -o %t.o 2>&1 | FileCheck -check-prefix=XOP %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-xop -mno-f16c 
-mno-rtm -mn

Re: [PATCH] D19658: [X86] Add -m[no-]x87 and -m[no-]80387 options to control FeatureX87

2016-05-04 Thread Andrey Turetskiy via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268487: Add a test for driver options from 
m_x86_Features_Group. (authored by aturetsk).

Changed prior to commit:
  http://reviews.llvm.org/D19658?vs=55579&id=56125#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19658

Files:
  cfe/trunk/test/Driver/x86-target-features.c

Index: cfe/trunk/test/Driver/x86-target-features.c
===
--- cfe/trunk/test/Driver/x86-target-features.c
+++ cfe/trunk/test/Driver/x86-target-features.c
@@ -0,0 +1,44 @@
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mmmx -m3dnow 
-m3dnowa %s -### -o %t.o 2>&1 | FileCheck -check-prefix=MMX %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-mmx -mno-3dnow 
-mno-3dnowa %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-MMX %s
+// MMX: "-target-feature" "+mmx" "-target-feature" "+3dnow" "-target-feature" 
"+3dnowa"
+// NO-MMX: "-target-feature" "-mmx" "-target-feature" "-3dnow" 
"-target-feature" "-3dnowa"
+
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -msse -msse2 -msse3 
-mssse3 -msse4a -msse4.1 -msse4.2 %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=SSE %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-sse -mno-sse2 
-mno-sse3 -mno-ssse3 -mno-sse4a -mno-sse4.1 -mno-sse4.2 %s -### -o %t.o 2>&1 | 
FileCheck -check-prefix=NO-SSE %s
+// SSE: "-target-feature" "+sse" "-target-feature" "+sse2" "-target-feature" 
"+sse3" "-target-feature" "+ssse3" "-target-feature" "+sse4a" "-target-feature" 
"+sse4.1" "-target-feature" "+sse4.2"
+// NO-SSE: "-target-feature" "-sse" "-target-feature" "-sse2" 
"-target-feature" "-sse3" "-target-feature" "-ssse3" "-target-feature" "-sse4a" 
"-target-feature" "-sse4.1" "-target-feature" "-sse4.2"
+
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -msse4 -maes %s -### 
-o %t.o 2>&1 | FileCheck -check-prefix=SSE4-AES %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-sse4 -mno-aes 
%s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-SSE4-AES %s
+// SSE4-AES: "-target-feature" "+sse4.2" "-target-feature" "+aes"
+// NO-SSE4-AES: "-target-feature" "-sse4.1" "-target-feature" "-aes"
+
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mavx -mavx2 
-mavx512f -mavx512cd -mavx512er -mavx512pf -mavx512dq -mavx512bw -mavx512vl 
-mavx512vbmi -mavx512ifma %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-avx -mno-avx2 
-mno-avx512f -mno-avx512cd -mno-avx512er -mno-avx512pf -mno-avx512dq 
-mno-avx512bw -mno-avx512vl -mno-avx512vbmi -mno-avx512ifma %s -### -o %t.o 
2>&1 | FileCheck -check-prefix=NO-AVX %s
+// AVX: "-target-feature" "+avx" "-target-feature" "+avx2" "-target-feature" 
"+avx512f" "-target-feature" "+avx512cd" "-target-feature" "+avx512er" 
"-target-feature" "+avx512pf" "-target-feature" "+avx512dq" "-target-feature" 
"+avx512bw" "-target-feature" "+avx512vl" "-target-feature" "+avx512vbmi" 
"-target-feature" "+avx512ifma"
+// NO-AVX: "-target-feature" "-avx" "-target-feature" "-avx2" 
"-target-feature" "-avx512f" "-target-feature" "-avx512cd" "-target-feature" 
"-avx512er" "-target-feature" "-avx512pf" "-target-feature" "-avx512dq" 
"-target-feature" "-avx512bw" "-target-feature" "-avx512vl" "-target-feature" 
"-avx512vbmi" "-target-feature" "-avx512ifma"
+
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mpclmul -mrdrnd 
-mfsgsbase -mbmi -mbmi2 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=BMI %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-pclmul 
-mno-rdrnd -mno-fsgsbase -mno-bmi -mno-bmi2 %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=NO-BMI %s
+// BMI: "-target-feature" "+pclmul" "-target-feature" "+rdrnd" 
"-target-feature" "+fsgsbase" "-target-feature" "+bmi" "-target-feature" "+bmi2"
+// NO-BMI: "-target-feature" "-pclmul" "-target-feature" "-rdrnd" 
"-target-feature" "-fsgsbase" "-target-feature" "-bmi" "-target-feature" "-bmi2"
+
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mlzcnt -mpopcnt 
-mtbm -mfma -mfma4 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=FMA %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-lzcnt 
-mno-popcnt -mno-tbm -mno-fma -mno-fma4 %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=NO-FMA %s
+// FMA: "-target-feature" "+lzcnt" "-target-feature" "+popcnt" 
"-target-feature" "+tbm" "-target-feature" "+fma" "-target-feature" "+fma4"
+// NO-FMA: "-target-feature" "-lzcnt" "-target-feature" "-popcnt" 
"-target-feature" "-tbm" "-target-feature" "-fma" "-target-feature" "-fma4"
+
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mxop -mf16c -mrtm 
-mprfchw -mrdseed %s -### -o %t.o 2>&1 | FileCheck -check-prefix=XOP %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-xop -mno-f16c 
-mno-rtm -mno-prfchw -mno-rdseed %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=NO-XOP %s
+// XOP: "-target-

[PATCH] D19905: clang-rename: when renaming a class, rename pointers to that class as well

2016-05-04 Thread Miklos Vajna via cfe-commits
vmiklos created this revision.
vmiklos added reviewers: cfe-commits, klimek.

The second "CHECK:" failed in the testcase without the code change.

http://reviews.llvm.org/D19905

Files:
  clang-rename/USRLocFinder.cpp
  test/clang-rename/ClassTest.cpp

Index: test/clang-rename/ClassTest.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTest.cpp
@@ -0,0 +1,15 @@
+class Cla  // CHECK: class Hector
+{
+};
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=6 -new-name=Hector %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+int main()
+{
+Cla *Pointer = 0; // CHECK: Hector *Pointer = 0;
+return 0;
+}
+
+// Use grep -FUbo 'Cla'  to get the correct offset of Cla when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -45,6 +45,18 @@
 return true;
   }
 
+  bool VisitVarDecl(clang::VarDecl *Decl) {
+clang::QualType Type = Decl->getType();
+const clang::RecordDecl *RecordDecl = Type->getPointeeCXXRecordDecl();
+if (RecordDecl) {
+  if (getUSRForDecl(RecordDecl) == USR) {
+// The declaration refers to a type that is to be renamed.
+LocationsFound.push_back(Decl->getTypeSpecStartLoc());
+  }
+}
+return true;
+  }
+
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {


Index: test/clang-rename/ClassTest.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTest.cpp
@@ -0,0 +1,15 @@
+class Cla  // CHECK: class Hector
+{
+};
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=6 -new-name=Hector %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+int main()
+{
+Cla *Pointer = 0; // CHECK: Hector *Pointer = 0;
+return 0;
+}
+
+// Use grep -FUbo 'Cla'  to get the correct offset of Cla when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -45,6 +45,18 @@
 return true;
   }
 
+  bool VisitVarDecl(clang::VarDecl *Decl) {
+clang::QualType Type = Decl->getType();
+const clang::RecordDecl *RecordDecl = Type->getPointeeCXXRecordDecl();
+if (RecordDecl) {
+  if (getUSRForDecl(RecordDecl) == USR) {
+// The declaration refers to a type that is to be renamed.
+LocationsFound.push_back(Decl->getTypeSpecStartLoc());
+  }
+}
+return true;
+  }
+
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19905: clang-rename: when renaming a class, rename pointers to that class as well

2016-05-04 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Yes, please submit it; I'm not a committer.


http://reviews.llvm.org/D19905



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


r268483 - [Sparc] Implement __builtin_setjmp, __builtin_longjmp back-end.

2016-05-04 Thread Chris Dewhurst via cfe-commits
Author: lerochris
Date: Wed May  4 04:33:30 2016
New Revision: 268483

URL: http://llvm.org/viewvc/llvm-project?rev=268483&view=rev
Log:
[Sparc] Implement __builtin_setjmp, __builtin_longjmp back-end.

This code implements builtin_setjmp and builtin_longjmp exception handling 
intrinsics for 32-bit Sparc back-ends.

The code started as a mash-up of the PowerPC and X86 versions, although there 
are sufficient differences to both that had to be made for Sparc handling.

Note: I have manual tests running. I'll work on a unit test and add that to the 
rest of this diff in the next day.

Also, this implementation is only for 32-bit Sparc. I haven't focussed on a 
64-bit version, although I have left the code in a prepared state for 
implementing this, including detecting pointer size and comments indicating 
where I suspect there may be differences.

Differential Revision: http://reviews.llvm.org/D19798

Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=268483&r1=268482&r2=268483&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed May  4 04:33:30 2016
@@ -6447,6 +6447,10 @@ public:
   }
 }
   }
+
+  bool hasSjLjLowering() const override {
+return true;
+  }
 };
 
 // SPARCV8el is the 32-bit little-endian mode selected by Triple::sparcel.


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


r268488 - Add missing -mno-cx16 driver option.

2016-05-04 Thread Andrey Turetskiy via cfe-commits
Author: aturetsk
Date: Wed May  4 06:19:41 2016
New Revision: 268488

URL: http://llvm.org/viewvc/llvm-project?rev=268488&view=rev
Log:
Add missing -mno-cx16 driver option.

Differential Revision: http://reviews.llvm.org/D19658

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/test/Driver/x86-target-features.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=268488&r1=268487&r2=268488&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed May  4 06:19:41 2016
@@ -1410,6 +1410,7 @@ def mno_prfchw : Flag<["-"], "mno-prfchw
 def mno_rdseed : Flag<["-"], "mno-rdseed">, Group;
 def mno_adx : Flag<["-"], "mno-adx">, Group;
 def mno_sha : Flag<["-"], "mno-sha">, Group;
+def mno_cx16 : Flag<["-"], "mno-cx16">, Group;
 def mno_fxsr : Flag<["-"], "mno-fxsr">, Group;
 def mno_xsave : Flag<["-"], "mno-xsave">, Group;
 def mno_xsaveopt : Flag<["-"], "mno-xsaveopt">, Group;

Modified: cfe/trunk/test/Driver/x86-target-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/x86-target-features.c?rev=268488&r1=268487&r2=268488&view=diff
==
--- cfe/trunk/test/Driver/x86-target-features.c (original)
+++ cfe/trunk/test/Driver/x86-target-features.c Wed May  4 06:19:41 2016
@@ -34,9 +34,9 @@
 // NO-XOP: "-target-feature" "-xop" "-target-feature" "-f16c" 
"-target-feature" "-rtm" "-target-feature" "-prfchw" "-target-feature" "-rdseed"
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -msha -mpku -madx 
-mcx16 -mfxsr %s -### -o %t.o 2>&1 | FileCheck -check-prefix=SHA %s
-// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-sha -mno-pku 
-mno-adx -mno-fxsr %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-SHA %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-sha -mno-pku 
-mno-adx -mno-cx16 -mno-fxsr %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=NO-SHA %s
 // SHA: "-target-feature" "+sha" "-target-feature" "+pku" "-target-feature" 
"+adx" "-target-feature" "+cx16" "-target-feature" "+fxsr"
-// NO-SHA: "-target-feature" "-sha" "-target-feature" "-pku" "-target-feature" 
"-adx" "-target-feature" "-fxsr"
+// NO-SHA: "-target-feature" "-sha" "-target-feature" "-pku" "-target-feature" 
"-adx" "-target-feature" "-cx16" "-target-feature" "-fxsr"
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mxsave -mxsaveopt 
-mxsavec -mxsaves %s -### -o %t.o 2>&1 | FileCheck -check-prefix=XSAVE %s
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-xsave 
-mno-xsaveopt -mno-xsavec -mno-xsaves %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=NO-XSAVE %s


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


r268489 - [X86] Add -m[no-]x87 and -m[no-]80387 options to control FeatureX87.

2016-05-04 Thread Andrey Turetskiy via cfe-commits
Author: aturetsk
Date: Wed May  4 06:28:22 2016
New Revision: 268489

URL: http://llvm.org/viewvc/llvm-project?rev=268489&view=rev
Log:
[X86] Add -m[no-]x87 and -m[no-]80387 options to control FeatureX87.

Add -m[no-]x87 and -m[no-]80387 options to control FeatureX87.
-m[no-]80387 options is added for compatibility with GCC.

Differential Revision: http://reviews.llvm.org/D19658

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/test/Driver/x86-target-features.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=268489&r1=268488&r2=268489&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed May  4 06:28:22 2016
@@ -1370,6 +1370,8 @@ def mno_relax_all : Flag<["-"], "mno-rel
 def mno_rtd: Flag<["-"], "mno-rtd">, Group;
 def mno_soft_float : Flag<["-"], "mno-soft-float">, Group;
 def mno_stackrealign : Flag<["-"], "mno-stackrealign">, Group;
+def mno_x87 : Flag<["-"], "mno-x87">, Group;
+def mno_80387 : Flag<["-"], "mno-80387">, Alias;
 def mno_sse2 : Flag<["-"], "mno-sse2">, Group;
 def mno_sse3 : Flag<["-"], "mno-sse3">, Group;
 def mno_sse4a : Flag<["-"], "mno-sse4a">, Group;
@@ -1547,6 +1549,8 @@ def mno_implicit_float : Flag<["-"], "mn
 def mimplicit_float : Flag<["-"], "mimplicit-float">, Group;
 def mrecip : Flag<["-"], "mrecip">, Group;
 def mrecip_EQ : CommaJoined<["-"], "mrecip=">, Group, 
Flags<[CC1Option]>;
+def mx87 : Flag<["-"], "mx87">, Group;
+def m80387 : Flag<["-"], "m80387">, Alias;
 def msse2 : Flag<["-"], "msse2">, Group;
 def msse3 : Flag<["-"], "msse3">, Group;
 def msse4a : Flag<["-"], "msse4a">, Group;

Modified: cfe/trunk/test/Driver/x86-target-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/x86-target-features.c?rev=268489&r1=268488&r2=268489&view=diff
==
--- cfe/trunk/test/Driver/x86-target-features.c (original)
+++ cfe/trunk/test/Driver/x86-target-features.c Wed May  4 06:28:22 2016
@@ -1,3 +1,10 @@
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mx87 %s -### -o 
%t.o 2>&1 | FileCheck -check-prefix=X87 %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-x87 %s -### -o 
%t.o 2>&1 | FileCheck -check-prefix=NO-X87 %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -m80387 %s -### -o 
%t.o 2>&1 | FileCheck -check-prefix=X87 %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-80387 %s -### 
-o %t.o 2>&1 | FileCheck -check-prefix=NO-X87 %s
+// X87: "-target-feature" "+x87"
+// NO-X87: "-target-feature" "-x87"
+
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mmmx -m3dnow 
-m3dnowa %s -### -o %t.o 2>&1 | FileCheck -check-prefix=MMX %s
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-mmx -mno-3dnow 
-mno-3dnowa %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-MMX %s
 // MMX: "-target-feature" "+mmx" "-target-feature" "+3dnow" "-target-feature" 
"+3dnowa"


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


Re: [PATCH] D19658: [X86] Add -m[no-]x87 and -m[no-]80387 options to control FeatureX87

2016-05-04 Thread Andrey Turetskiy via cfe-commits
aturetsk added a comment.

Hi,
Thanks for the review.

Committed:

1. Add a test for driver options from m_x86_Features_Group 
(http://reviews.llvm.org/rL268487)
2. Add missing -mno-cx16 driver option (http://reviews.llvm.org/rL268488)
3. Add -m[no-]x87 and -m[no-]80387 options to control FeatureX87 
(http://reviews.llvm.org/rL268489)


Repository:
  rL LLVM

http://reviews.llvm.org/D19658



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


Re: [PATCH] D19877: [clang-tidy] Speedup misc-static-assert.

2016-05-04 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Thank you for finding and fixing this! I think I used to suggest the wrong 
pattern, now I won't.


Repository:
  rL LLVM

http://reviews.llvm.org/D19877



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


Re: [PATCH] D19905: clang-rename: when renaming a class, rename pointers to that class as well

2016-05-04 Thread Manuel Klimek via cfe-commits
klimek closed this revision.
klimek added a comment.

Submitted as r268484


http://reviews.llvm.org/D19905



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


[PATCH] D19913: Added static creators that create complete instances of SymbolInfo.

2016-05-04 Thread Eric Liu via cfe-commits
ioeric created this revision.
ioeric added reviewers: klimek, hokein.
ioeric added a subscriber: cfe-commits.

Added static creators that create complete instances of SymbolInfo.

http://reviews.llvm.org/D19913

Files:
  include-fixer/InMemoryXrefsDB.cpp
  include-fixer/find-all-symbols/SymbolInfo.cpp
  include-fixer/find-all-symbols/SymbolInfo.h

Index: include-fixer/find-all-symbols/SymbolInfo.h
===
--- include-fixer/find-all-symbols/SymbolInfo.h
+++ include-fixer/find-all-symbols/SymbolInfo.h
@@ -21,7 +21,6 @@
 namespace find_all_symbols {
 
 /// \brief Contains all information for a Symbol.
-// FIXME: add static members for creating complete instances.
 struct SymbolInfo {
   enum SymbolKind {
 Function,
@@ -87,6 +86,33 @@
   bool operator==(const SymbolInfo &Symbol) const;
 
   bool operator<(const SymbolInfo &Symbol) const;
+
+  static SymbolInfo
+  CreateFunctionSymbolInfo(const std::string &Name, const std::string &FilePath,
+   const std::vector &Contexts, int LineNumber,
+   const FunctionInfo &FuncInfo);
+
+  static SymbolInfo CreateClassSymbolInfo(const std::string &Name,
+  const std::string &FilePath,
+  const std::vector &Contexts,
+  int LineNumber);
+
+  static SymbolInfo
+  CreateVariableSymbolInfo(const std::string &Name, const std::string &FilePath,
+   const std::vector &Contexts, int LineNumber,
+   const VariableInfo &VarInfo);
+
+  static SymbolInfo
+  CreateTypedefNameSymbolInfo(const std::string &Name,
+  const std::string &FilePath,
+  const std::vector &Contexts,
+  int LineNumber, const TypedefNameInfo &TDInfo);
+
+private:
+  static void SetCommonInfo(const std::string &Name, SymbolKind Kind,
+const std::string &FilePath,
+const std::vector &Contexts,
+int LineNumber, SymbolInfo *Info);
 };
 
 /// \brief Write SymbolInfos to a stream (YAML format).
Index: include-fixer/find-all-symbols/SymbolInfo.cpp
===
--- include-fixer/find-all-symbols/SymbolInfo.cpp
+++ include-fixer/find-all-symbols/SymbolInfo.cpp
@@ -87,6 +87,57 @@
 namespace clang {
 namespace find_all_symbols {
 
+void SymbolInfo::SetCommonInfo(const std::string &Name,
+SymbolKind Kind, const std::string &FilePath,
+const std::vector &Contexts,
+int LineNumber, SymbolInfo *Info) {
+  Info->Name = Name;
+  Info->Type = Kind;
+  Info->FilePath = FilePath;
+  Info->Contexts = Contexts;
+  Info->LineNumber = LineNumber;
+}
+
+SymbolInfo SymbolInfo::CreateFunctionSymbolInfo(
+const std::string &Name, const std::string &FilePath,
+const std::vector &Contexts, int LineNumber,
+const FunctionInfo &FuncInfo) {
+
+  SymbolInfo Ret;
+  SetCommonInfo(Name, Function, FilePath, Contexts, LineNumber, &Ret);
+  Ret.FunctionInfos = FuncInfo;
+  return Ret;
+}
+
+SymbolInfo SymbolInfo::CreateClassSymbolInfo(
+const std::string &Name, const std::string &FilePath,
+const std::vector &Contexts, int LineNumber) {
+
+  SymbolInfo Ret;
+  SetCommonInfo(Name, Class, FilePath, Contexts, LineNumber, &Ret);
+  return Ret;
+}
+
+SymbolInfo SymbolInfo::CreateVariableSymbolInfo(
+const std::string &Name, const std::string &FilePath,
+const std::vector &Contexts, int LineNumber,
+const VariableInfo &VarInfo) {
+  SymbolInfo Ret;
+  SetCommonInfo(Name, Variable, FilePath, Contexts, LineNumber, &Ret);
+  Ret.VariableInfos = VarInfo;
+  return Ret;
+}
+
+SymbolInfo SymbolInfo::CreateTypedefNameSymbolInfo(
+const std::string &Name, const std::string &FilePath,
+const std::vector &Contexts, int LineNumber,
+const TypedefNameInfo &TDInfo) {
+  SymbolInfo Ret;
+  SetCommonInfo(Name, TypedefName, FilePath, Contexts, LineNumber, &Ret);
+  Ret.TypedefNameInfos = TDInfo;
+  return Ret;
+}
+
 bool SymbolInfo::operator==(const SymbolInfo &Symbol) const {
   return Name == Symbol.Name && FilePath == Symbol.FilePath &&
  LineNumber == Symbol.LineNumber && Contexts == Symbol.Contexts;
Index: include-fixer/InMemoryXrefsDB.cpp
===
--- include-fixer/InMemoryXrefsDB.cpp
+++ include-fixer/InMemoryXrefsDB.cpp
@@ -21,16 +21,17 @@
 llvm::SmallVector Names;
 Identifier.split(Names, "::");
 for (const auto &Header : Entry.second) {
-  // FIXME: create a complete instance with static member function when it
-  // is implemented.
-  SymbolInfo Info;
-  Info.Name = Names.back();
-  Info.FilePath = Header;
+  // Since we don't have all symbol

Re: [PATCH] D19816: [find-all-symbols] Add IWYU private pragma support.

2016-05-04 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: include-fixer/find-all-symbols/FindAllSymbols.h:48
@@ +47,3 @@
+  explicit FindAllSymbols(ResultReporter *Reporter,
+  HeaderMapCollector *Collector)
+  : Reporter(Reporter), Collector(Collector) {}

I'd pass in the HeaderMap here.


Comment at: include-fixer/find-all-symbols/PragmaCommentHandler.h:22
@@ +21,3 @@
+
+/// \brief PragmaCommentHandler handle all pragma comment. It supports a way 
for
+/// clients to control their include path.

"PragmaCommentHandler handle all pragma comment"
This comment doesn't really tell me anything new.

Perhaps:
PragmaCommentHandler parses comments on include files to determine when we 
should include a different header from the header that directly defines a 
symbol.


Comment at: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp:418
@@ +417,3 @@
+
+  {
+SymbolInfo Symbol =

Any reason for the extra block here?


http://reviews.llvm.org/D19816



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


r268490 - [ASTMatchers] New matcher forFunction

2016-05-04 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Wed May  4 06:59:39 2016
New Revision: 268490

URL: http://llvm.org/viewvc/llvm-project?rev=268490&view=rev
Log:
[ASTMatchers] New matcher forFunction

Summary: Matcher proposed in the review of checker misc-assign-operator (name 
pending). Its goal is to find the direct enclosing function declaration of a 
statement and run the inner matcher on it. Two version is attached in this 
patch (thus it will not compile), to be decided which approach to take. The 
second one always chooses one single parent while the first one does a 
depth-first search upwards (thus a height-first search) and returns the first 
positive match of the inner matcher (thus it always returns zero or one 
matches, not more). Further questions: is it enough to implement it in-place, 
or ASTMatchersInternals or maybe ASTMatchFinder should be involved?

Reviewers: sbenza

Subscribers: aaron.ballman, klimek, o.gyorgy, xazax.hun, cfe-commits

Differential Revision: http://reviews.llvm.org/D19357

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=268490&r1=268489&r2=268490&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Wed May  4 06:59:39 2016
@@ -4923,6 +4923,20 @@ alignof.
 
 
 
+MatcherStmt>forFunctionMatcherFunctionDecl>
 InnerMatcher
+Matches declaration of 
the function the statemenet belongs to
+
+Given:
+F& operator=(const F& o) {
+  std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; });
+  return *this;
+}
+returnStmt(forFunction(hasName("operator=")))
+  matches 'return *this'
+  but does match 'return > 0'
+
+
+
 MatcherStmt>sizeOfExprMatcherUnaryExprOrTypeTraitExpr>
  InnerMatcher
 Same as 
unaryExprOrTypeTraitExpr, but only matching
 sizeof.

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=268490&r1=268489&r2=268490&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Wed May  4 06:59:39 2016
@@ -5108,6 +5108,45 @@ AST_MATCHER_FUNCTION(internal::Matcher 0; });
+///   return *this;
+/// }
+/// \endcode
+/// returnStmt(forFunction(hasName("operator=")))
+///   matches 'return *this'
+///   but does match 'return > 0'
+AST_MATCHER_P(Stmt, forFunction, internal::Matcher,
+  InnerMatcher) {
+  const auto &Parents = Finder->getASTContext().getParents(Node);
+
+  llvm::SmallVector Stack(Parents.begin(),
+Parents.end());
+  while(!Stack.empty()) {
+const auto &CurNode = Stack.back();
+Stack.pop_back();
+if(const auto *FuncDeclNode = CurNode.get()) {
+  if(InnerMatcher.matches(*FuncDeclNode, Finder, Builder)) {
+return true;
+  }
+} else if(const auto *LambdaExprNode = CurNode.get()) {
+  if(InnerMatcher.matches(*LambdaExprNode->getCallOperator(),
+  Finder, Builder)) {
+return true;
+  }
+} else {
+  for(const auto &Parent: Finder->getASTContext().getParents(CurNode))
+Stack.push_back(Parent);
+}
+  }
+  return false;
+}
+
 } // end namespace ast_matchers
 } // end namespace clang
 

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=268490&r1=268489&r2=268490&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Wed May  4 06:59:39 2016
@@ -184,6 +184,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(forEachDescendant);
   REGISTER_MATCHER(forEachSwitchCase);
   REGISTER_MATCHER(forField);
+  REGISTER_MATCHER(forFunction);
   REGISTER_MATCHER(forStmt);
   REGISTER_MATCHER(friendDecl);
   REGISTER_MATCHER(functionDecl);

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=268490&r1=268489&r2=268490&view=diff
==
--- cfe/trunk/unittests/ASTMatcher

[clang-tools-extra] r268492 - [clang-tidy] New: checker misc-unconventional-assign-operator replacing misc-assign-operator-signature

2016-05-04 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Wed May  4 07:02:22 2016
New Revision: 268492

URL: http://llvm.org/viewvc/llvm-project?rev=268492&view=rev
Log:
[clang-tidy] New: checker misc-unconventional-assign-operator replacing 
misc-assign-operator-signature

Summary: Finds return statements in assign operator bodies where the return 
value is different from '*this'. Only assignment operators with correct return 
value Class& are checked.

Reviewers: aaron.ballman, alexfh, sbenza

Subscribers: o.gyorgy, baloghadamsoftware, LegalizeAdulthood, aaron.ballman, 
Eugene.Zelenko, xazax.hun, cfe-commits

Differential Revision: http://reviews.llvm.org/D18265

Added:

clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unconventional-assign-operator.rst

clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp
Removed:
clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-assign-operator-signature.rst
clang-tools-extra/trunk/test/clang-tidy/misc-assign-operator-signature.cpp
Modified:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp?rev=268492&r1=268491&r2=268492&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 Wed May  4 07:02:22 2016
@@ -10,7 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
-#include "../misc/AssignOperatorSignatureCheck.h"
+#include "../misc/UnconventionalAssignOperatorCheck.h"
 #include "InterfacesGlobalInitCheck.h"
 #include "ProBoundsArrayToPointerDecayCheck.h"
 #include "ProBoundsConstantArrayIndexCheck.h"
@@ -53,7 +53,7 @@ public:
 "cppcoreguidelines-pro-type-union-access");
 CheckFactories.registerCheck(
 "cppcoreguidelines-pro-type-vararg");
-CheckFactories.registerCheck(
+CheckFactories.registerCheck(
 "cppcoreguidelines-c-copy-assignment-signature");
   }
 };

Removed: 
clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp?rev=268491&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp 
(removed)
@@ -1,80 +0,0 @@
-//===--- AssignOperatorSignatureCheck.cpp - clang-tidy --*- C++ 
-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#include "AssignOperatorSignatureCheck.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/ASTMatchers/ASTMatchers.h"
-
-using namespace clang::ast_matchers;
-
-namespace clang {
-namespace tidy {
-namespace misc {
-
-void AssignOperatorSignatureCheck::registerMatchers(
-ast_matchers::MatchFinder *Finder) {
-  // Only register the matchers for C++; the functionality currently does not
-  // provide any benefit to other languages, despite being benign.
-  if (!getLangOpts().CPlusPlus)
-return;
-
-  const auto HasGoodReturnType = cxxMethodDecl(returns(
-  lValueReferenceType(pointee(unless(isConstQualified()),
-  hasDeclaration(equalsBoundNode("class"));
-
-  const auto IsSelf = qualType(
-  anyOf(hasDeclaration(equalsBoundNode("class")),
-referenceType(pointee(hasDeclaration(equalsBoundNode("class"));
-  const auto IsAssign =
-  cxxMethodDecl(unless(anyOf(isDeleted(), isPrivate(), isImplicit())),
-hasName("operator="), ofClass(recordDecl().bind("class")))
-  .bind("method");
-  const auto IsSelfAssign =
-  cxxMethodDecl(IsAssign, hasParameter(0, parmVarDecl(hasType(IsSelf
-  .bind("method");
-
-  Finder->addMatcher(
-  cxxMethodDecl(IsA

Re: [PATCH] D12761: MPI-Checker patch for Clang Static Analyzer

2016-05-04 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

Anna, will you commit this, or do you want me to commit the patches?


http://reviews.llvm.org/D12761



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


Re: [PATCH] D19816: [find-all-symbols] Add IWYU private pragma support.

2016-05-04 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 56130.
hokein marked an inline comment as done.
hokein added a comment.

Update.


http://reviews.llvm.org/D19816

Files:
  include-fixer/find-all-symbols/CMakeLists.txt
  include-fixer/find-all-symbols/FindAllSymbols.cpp
  include-fixer/find-all-symbols/FindAllSymbols.h
  include-fixer/find-all-symbols/HeaderMapCollector.h
  include-fixer/find-all-symbols/PragmaCommentHandler.cpp
  include-fixer/find-all-symbols/PragmaCommentHandler.h
  include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -8,11 +8,14 @@
 //===--===//
 
 #include "FindAllSymbols.h"
+#include "HeaderMapCollector.h"
+#include "PragmaCommentHandler.h"
 #include "SymbolInfo.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemOptions.h"
 #include "clang/Basic/VirtualFileSystem.h"
+#include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/PCHContainerOperations.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
@@ -62,6 +65,41 @@
   std::vector Symbols;
 };
 
+class TestFindAllSymbolsAction : public clang::ASTFrontendAction {
+public:
+  TestFindAllSymbolsAction(FindAllSymbols::ResultReporter *Reporter)
+  : MatchFinder(), Collector(), Handler(&Collector),
+Matcher(Reporter, &Collector) {
+Matcher.registerMatchers(&MatchFinder);
+  }
+
+  std::unique_ptr
+  CreateASTConsumer(clang::CompilerInstance &Compiler,
+StringRef InFile) override {
+Compiler.getPreprocessor().addCommentHandler(&Handler);
+return MatchFinder.newASTConsumer();
+  }
+
+private:
+  ast_matchers::MatchFinder MatchFinder;
+  HeaderMapCollector Collector;
+  PragmaCommentHandler Handler;
+  FindAllSymbols Matcher;
+};
+
+class TestFindAllSymbolsActionFactory
+: public clang::tooling::FrontendActionFactory {
+public:
+  TestFindAllSymbolsActionFactory(MockReporter *Reporter)
+  : Reporter(Reporter) {}
+  clang::FrontendAction *create() override {
+return new TestFindAllSymbolsAction(Reporter);
+  }
+
+private:
+  MockReporter *const Reporter;
+};
+
 class FindAllSymbolsTest : public ::testing::Test {
 public:
   bool hasSymbol(const SymbolInfo &Symbol) {
@@ -73,18 +111,16 @@
   }
 
   bool runFindAllSymbols(StringRef Code) {
-FindAllSymbols matcher(&Reporter);
-clang::ast_matchers::MatchFinder MatchFinder;
-matcher.registerMatchers(&MatchFinder);
-
 llvm::IntrusiveRefCntPtr InMemoryFileSystem(
 new vfs::InMemoryFileSystem);
 llvm::IntrusiveRefCntPtr Files(
 new FileManager(FileSystemOptions(), InMemoryFileSystem));
 
 std::string FileName = "symbol.cc";
-std::unique_ptr Factory =
-clang::tooling::newFrontendActionFactory(&MatchFinder);
+
+std::unique_ptr Factory(
+new TestFindAllSymbolsActionFactory(&Reporter));
+
 tooling::ToolInvocation Invocation(
 {std::string("find_all_symbols"), std::string("-fsyntax-only"),
  FileName},
@@ -371,5 +407,20 @@
   }
 }
 
+TEST_F(FindAllSymbolsTest, IWYUPrivatePragmaTest) {
+  static const char Code[] = R"(
+// IWYU pragma: private, include "bar.h"
+struct Bar {
+};
+  )";
+  runFindAllSymbols(Code);
+
+  {
+SymbolInfo Symbol =
+CreateSymbolInfo("Bar", SymbolInfo::Class, "bar.h", 3, {});
+EXPECT_TRUE(hasSymbol(Symbol));
+  }
+}
+
 } // namespace find_all_symbols
 } // namespace clang
Index: include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
===
--- include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
+++ include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
@@ -8,8 +8,14 @@
 //===--===//
 
 #include "FindAllSymbols.h"
+#include "HeaderMapCollector.h"
+#include "PragmaCommentHandler.h"
 #include "SymbolInfo.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -82,6 +88,31 @@
   std::map> Symbols;
 };
 
+class FindAllSymbolsAction : public clang::ASTFrontendAction {
+public:
+  FindAllSymbolsAction()
+  : Reporter(), MatchFinder(), Collector(), Handler(&Collector),
+Matcher(&Reporter, &Collector) {
+Matcher.registerMatchers(&MatchFinder);
+  }
+
+  std::unique_ptr
+  CreateA

Re: [PATCH] D19816: [find-all-symbols] Add IWYU private pragma support.

2016-05-04 Thread Haojian Wu via cfe-commits
hokein added inline comments.


Comment at: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp:418
@@ +417,3 @@
+
+  {
+SymbolInfo Symbol =

klimek wrote:
> Any reason for the extra block here?
Because I want to keep consistence with other test cases here.


http://reviews.llvm.org/D19816



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


[clang-tools-extra] r268494 - [clang-tidy] Remove STL dependency from a test.

2016-05-04 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Wed May  4 07:17:55 2016
New Revision: 268494

URL: http://llvm.org/viewvc/llvm-project?rev=268494&view=rev
Log:
[clang-tidy] Remove STL dependency from a test.

Modified:

clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp?rev=268494&r1=268493&r2=268494&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp 
Wed May  4 07:17:55 2016
@@ -1,6 +1,16 @@
 // RUN: %check_clang_tidy %s misc-unconventional-assign-operator %t -- -- 
-std=c++11 -isystem %S/Inputs/Headers
 
-#include 
+namespace std {
+template 
+struct remove_reference { typedef T type; };
+template 
+struct remove_reference { typedef T type; };
+template 
+struct remove_reference { typedef T type; };
+template 
+typename remove_reference::type &&move(T &&t);
+}
+
 
 struct Good {
   Good& operator=(const Good&);


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


Re: [PATCH] D19913: Added static creators that create complete instances of SymbolInfo.

2016-05-04 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: include-fixer/find-all-symbols/SymbolInfo.h:90-93
@@ +89,6 @@
+
+  static SymbolInfo
+  CreateFunctionSymbolInfo(const std::string &Name, const std::string 
&FilePath,
+   const std::vector &Contexts, int 
LineNumber,
+   const FunctionInfo &FuncInfo);
+

To some degree this looks like we actually want a class hierarchy. But 
currently only ClassSymbolInfo is used?


http://reviews.llvm.org/D19913



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


Re: [PATCH] D19816: [find-all-symbols] Add IWYU private pragma support.

2016-05-04 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp:418
@@ +417,3 @@
+
+  {
+SymbolInfo Symbol =

Why are the other test cases using an extra block?


http://reviews.llvm.org/D19816



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


Re: [PATCH] D19913: Added static creators that create complete instances of SymbolInfo.

2016-05-04 Thread Haojian Wu via cfe-commits
hokein added a comment.

Not sure whether this is what @klimek expected..

You also need to update the FindAllSymbolsTests code (there is a 
CreateSymbolInfo function there).



Comment at: include-fixer/find-all-symbols/SymbolInfo.cpp:91
@@ +90,3 @@
+void SymbolInfo::SetCommonInfo(const std::string &Name,
+SymbolKind Kind, const std::string &FilePath,
+const std::vector &Contexts,

code indentation.


Comment at: include-fixer/find-all-symbols/SymbolInfo.cpp:105
@@ +104,3 @@
+const FunctionInfo &FuncInfo) {
+
+  SymbolInfo Ret;

A extra blank line.


Comment at: include-fixer/find-all-symbols/SymbolInfo.cpp:115
@@ +114,3 @@
+const std::vector &Contexts, int LineNumber) {
+
+  SymbolInfo Ret;

The same.


Comment at: include-fixer/find-all-symbols/SymbolInfo.h:91
@@ +90,3 @@
+  static SymbolInfo
+  CreateFunctionSymbolInfo(const std::string &Name, const std::string 
&FilePath,
+   const std::vector &Contexts, int 
LineNumber,

Use llvm::StringRef instead of `std::string&`.


http://reviews.llvm.org/D19913



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


Re: [PATCH] D19913: Added static creators that create complete instances of SymbolInfo.

2016-05-04 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: include-fixer/find-all-symbols/SymbolInfo.h:90-93
@@ +89,6 @@
+
+  static SymbolInfo
+  CreateFunctionSymbolInfo(const std::string &Name, const std::string 
&FilePath,
+   const std::vector &Contexts, int 
LineNumber,
+   const FunctionInfo &FuncInfo);
+

klimek wrote:
> To some degree this looks like we actually want a class hierarchy. But 
> currently only ClassSymbolInfo is used?
At this point yes, since Symbolnfo is only created in InMemoryXrefsDB and 
FindAllSymbols now, and it is not trivial to change FindAllSymbols to use these 
creators. 

But one immediate use case I can foresee is converting proto buffer SymbolInfo 
to clang SymbolInfo when integrating with Google3 XrefsDB. 


http://reviews.llvm.org/D19913



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


Re: [PATCH] D19913: Added static creators that create complete instances of SymbolInfo.

2016-05-04 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: include-fixer/find-all-symbols/SymbolInfo.h:90-93
@@ +89,6 @@
+
+  static SymbolInfo
+  CreateFunctionSymbolInfo(const std::string &Name, const std::string 
&FilePath,
+   const std::vector &Contexts, int 
LineNumber,
+   const FunctionInfo &FuncInfo);
+

ioeric wrote:
> klimek wrote:
> > To some degree this looks like we actually want a class hierarchy. But 
> > currently only ClassSymbolInfo is used?
> At this point yes, since Symbolnfo is only created in InMemoryXrefsDB and 
> FindAllSymbols now, and it is not trivial to change FindAllSymbols to use 
> these creators. 
> 
> But one immediate use case I can foresee is converting proto buffer 
> SymbolInfo to clang SymbolInfo when integrating with Google3 XrefsDB. 
I think at this point YAGNI applies and we shouldn't create stuff that we don't 
use yet - code generally starts to rot when it's not used ;)


http://reviews.llvm.org/D19913



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


Re: [PATCH] D19827: Do not disable completely loop unroll when optimizing for size.

2016-05-04 Thread Marianne Mailhot-Sarrasin via cfe-commits
mamai retitled this revision from "Do not disable completely loop unroll 
according to optimization level." to "Do not disable completely loop unroll 
when optimizing for size.".
mamai updated the summary for this revision.
mamai updated this revision to Diff 56133.
mamai added a comment.

Modified the patch not to affect /O1 optimization level.


Repository:
  rL LLVM

http://reviews.llvm.org/D19827

Files:
  lib/Frontend/CompilerInvocation.cpp

Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -513,7 +513,7 @@
 getAllNoBuiltinFuncValues(Args, Opts.NoBuiltinFuncs);
   Opts.UnrollLoops =
   Args.hasFlag(OPT_funroll_loops, OPT_fno_unroll_loops,
-   (Opts.OptimizationLevel > 1 && !Opts.OptimizeSize));
+   (Opts.OptimizationLevel > 1));
   Opts.RerollLoops = Args.hasArg(OPT_freroll_loops);
 
   Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -513,7 +513,7 @@
 getAllNoBuiltinFuncValues(Args, Opts.NoBuiltinFuncs);
   Opts.UnrollLoops =
   Args.hasFlag(OPT_funroll_loops, OPT_fno_unroll_loops,
-   (Opts.OptimizationLevel > 1 && !Opts.OptimizeSize));
+   (Opts.OptimizationLevel > 1));
   Opts.RerollLoops = Args.hasArg(OPT_freroll_loops);
 
   Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19725: [Coverage] Fix an issue where a coverage region might not be created for a macro containing for or while statements.

2016-05-04 Thread Igor Kudrin via cfe-commits

Thank you!

On 02.05.2016 06:40, Justin Bogner wrote:

Igor Kudrin  writes:
  
+  /// \brief Check whether a region with bounds \c StartLoc and \c EndLoc

+  /// is already added to \c SourceRegions.
+  bool isRegionAlreadyAdded(SourceLocation StartLoc, SourceLocation EndLoc) {
+return SourceRegions.rend() !=
+   std::find_if(SourceRegions.rbegin(), SourceRegions.rend(),
Any particular reason for rbegin/rend? I guess you expect the match to
be near the end of the list when it exists?


Yes, exactly. I suppose that if that region exists, it's probably added 
recently.

+[=](const SourceMappingRegion &Region) {

There's no good reason to capture by value here. Best to use [&] for
efficiency.


OK.

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


Re: [PATCH] D18821: Add bugprone-bool-to-integer-conversion

2016-05-04 Thread Piotr Padlewski via cfe-commits
Prazek retitled this revision from "Add modernize-bool-to-integer-conversion" 
to "Add bugprone-bool-to-integer-conversion".
Prazek updated this revision to Diff 56138.
Prazek added a comment.

It seems that it works right now.
The other funny thing that the check found is cases like

bool b;
if (b == true)

I will update the llvm/clang changes today.
Do you want to see only the changes that clang-tidy made, or do you want to see 
it after some changing that I will do?


http://reviews.llvm.org/D18821

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/bugprone/BoolToIntegerConversionCheck.cpp
  clang-tidy/bugprone/BoolToIntegerConversionCheck.h
  clang-tidy/bugprone/BugProneModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/plugin/CMakeLists.txt
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-bool-to-integer-conversion.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/bugprone-bool-to-integer-conversion.cpp

Index: test/clang-tidy/bugprone-bool-to-integer-conversion.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-bool-to-integer-conversion.cpp
@@ -0,0 +1,79 @@
+// RUN: %check_clang_tidy %s bugprone-bool-to-integer-conversion %t
+
+const int is42Answer = true;
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: implicitly converting bool literal to 'int'; use integer literal instead [bugprone-bool-to-integer-conversion]
+// CHECK-FIXES: const int is42Answer = 1;{{$}}
+
+volatile int noItsNot = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: implicitly converting bool literal to 'int'; {{..}}
+// CHECK-FIXES: volatile int noItsNot = 0;{{$}}
+int a = 42;
+int az = a;
+
+long long ll = true;
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: implicitly converting bool literal to 'long long';{{..}}
+// CHECK-FIXES: long long ll = 1;{{$}}
+
+void fun(int) {}
+#define ONE true
+
+// No fixup for macros.
+int one = ONE;
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: implicitly converting bool literal to 'int' inside a macro; use integer literal instead [bugprone-bool-to-integer-conversion]
+
+void test() {
+  fun(ONE);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: implicitly converting bool{{..}}
+
+  fun(42);
+  fun(true);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: implicitly {{..}}
+// CHECK-FIXES: fun(1);{{$}}
+}
+
+char c = true;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: implicitly {{..}}
+// CHECK-FIXES: char c = 1;
+
+float f = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: implicitly converting bool literal to 'float';{{..}}
+// CHECK-FIXES: float f = 0;
+
+struct Blah {
+  Blah(int blah) { }
+};
+
+const int &ref = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: implicitly converting bool literal to 'int'{{..}}
+// CHECK-FIXES: const int &ref = 0;
+
+Blah bla = true;
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: implicitly converting bool literal to 'int'{{..}}
+// CHECK-FIXES: Blah bla = 1;
+
+Blah bla2 = 1;
+
+char c2 = 1;
+char c3 = '0';
+bool b = true;
+
+// Don't warn of bitfields of size 1. Unfortunately we can't just
+// change type of flag to bool, because some compilers like MSVC doesn't
+// pack bitfields of different types.
+struct BitFields {
+  BitFields() : a(true), flag(false) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: implicitly converting
+// CHECK-FIXES: BitFields() : a(1), flag(false) {}
+
+  unsigned a : 3;
+  unsigned flag : 1;
+};
+
+void testBitFields() {
+  BitFields b;
+  b.flag = true;
+  b.a = true;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: implicitly converting
+// CHECK-FIXES: b.a = 1;
+}
+
Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -67,7 +67,9 @@
 
 * Clang static analyzer checks are named starting with ``clang-analyzer-``.
 
-* Checks related to Boost library starts with ``boost-``. 
+* Checks related to Boost library starts with ``boost-``.
+
+* The ``bugprone-*`` checks target code that have some potential bugs.
   
 Clang diagnostics are treated in a similar way as check diagnostics. Clang
 diagnostics are displayed by clang-tidy and can be filtered out using
@@ -347,6 +349,8 @@
 
 * `C++ Core Guidelines
   `_
+* potential `bugprone code
+  `_
 * `CERT Secure Coding Standards
   `_
 * `Google Style Guide
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -90,6 +90,7 @@
misc-unused-raii
misc-unused-using-decls
misc-virtual-near-miss
+   modernize

Re: [PATCH] D19812: [OpenMP] Check for associated statements with hasAssociatedStmt() when scanning for device code.

2016-05-04 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


http://reviews.llvm.org/D19812



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


Re: [PATCH] D19913: Added static creators that create complete instances of SymbolInfo.

2016-05-04 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 56139.
ioeric marked 7 inline comments as done.
ioeric added a comment.

Use static creator functions in SymbolInfo in FindAllSymbolTests, and make 
SymbolInfo::operator== compare all fields.


http://reviews.llvm.org/D19913

Files:
  include-fixer/find-all-symbols/SymbolInfo.cpp
  include-fixer/find-all-symbols/SymbolInfo.h
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -46,18 +46,6 @@
 return false;
   }
 
-  bool getSymbolExtraInfo(SymbolInfo *Symbol) {
-for (const auto &S : Symbols) {
-  if (S == *Symbol) {
-Symbol->FunctionInfos = S.FunctionInfos;
-Symbol->TypedefNameInfos = S.TypedefNameInfos;
-Symbol->VariableInfos = S.VariableInfos;
-return true;
-  }
-}
-return false;
-  }
-
 private:
   std::vector Symbols;
 };
@@ -68,10 +56,6 @@
 return Reporter.hasSymbol(Symbol);
   }
 
-  bool getSymbolExtraInfo(SymbolInfo &Symbol) {
-return Reporter.getSymbolExtraInfo(&Symbol);
-  }
-
   bool runFindAllSymbols(StringRef Code) {
 FindAllSymbols matcher(&Reporter);
 clang::ast_matchers::MatchFinder MatchFinder;
@@ -87,7 +71,7 @@
 clang::tooling::newFrontendActionFactory(&MatchFinder);
 tooling::ToolInvocation Invocation(
 {std::string("find_all_symbols"), std::string("-fsyntax-only"),
- FileName},
+ std::string("-std=c++11"), FileName},
 Factory->create(), Files.get(),
 std::make_shared());
 
@@ -105,10 +89,9 @@
   MockReporter Reporter;
 };
 
-SymbolInfo
-CreateSymbolInfo(StringRef Name, SymbolInfo::SymbolKind Type,
- const std::string FilePath, int LineNumber,
- const std::vector &Contexts) {
+SymbolInfo CreateSymbolInfo(StringRef Name, SymbolInfo::SymbolKind Type,
+const std::string FilePath, int LineNumber,
+const std::vector &Contexts) {
   SymbolInfo Symbol;
   Symbol.Name = Name;
   Symbol.Type = Type;
@@ -127,29 +110,19 @@
   })";
   runFindAllSymbols(Code);
 
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("xargc", SymbolInfo::Variable, HeaderName, 2, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("int", Symbol.VariableInfos.getValue().Type);
-  }
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("", SymbolInfo::Variable, HeaderName, 4,
- {{SymbolInfo::Namespace, "na"}});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("_Bool", Symbol.VariableInfos.getValue().Type);
-  }
-  {
-SymbolInfo Symbol = CreateSymbolInfo(
-"", SymbolInfo::Variable, HeaderName, 5,
-{{SymbolInfo::Namespace, "nb"}, {SymbolInfo::Namespace, "na"}});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("const long long *", Symbol.VariableInfos.getValue().Type);
-  }
+  SymbolInfo Symbol =
+  SymbolInfo::CreateVariableSymbolInfo("xargc", HeaderName, {}, 2, {"int"});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo::CreateVariableSymbolInfo(
+  "", HeaderName, {{SymbolInfo::Namespace, "na"}}, 4, {"_Bool"});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo::CreateVariableSymbolInfo(
+  "", HeaderName,
+  {{SymbolInfo::Namespace, "nb"}, {SymbolInfo::Namespace, "na"}}, 5,
+  {"const long long *"});
+  EXPECT_TRUE(hasSymbol(Symbol));
 }
 
 TEST_F(FindAllSymbolsTest, ExternCSymbols) {
@@ -162,19 +135,12 @@
   })";
   runFindAllSymbols(Code);
 
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("C_Func", SymbolInfo::Function, HeaderName, 3, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("int", Symbol.FunctionInfos.getValue().ReturnType);
-EXPECT_TRUE(Symbol.FunctionInfos.getValue().ParameterTypes.empty());
-  }
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("C_struct", SymbolInfo::Class, HeaderName, 4, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-  }
+  SymbolInfo Symbol = SymbolInfo::CreateFunctionSymbolInfo("C_Func", HeaderName,
+   {}, 3, {"int", {}});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo::CreateClassSymbolInfo("C_struct", HeaderName, {}, 4);
+  EXPECT_TRUE(hasSymbol(Symbol));
 }
 
 TEST_F(FindAllSymbolsTest, CXXRecordSymbols) {
@@ -193,16 +159,12 @@
   )";
   runFindAllSymbols(Code);
 
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("Glob", SymbolInfo::Class, HeaderName, 2, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-  }
-  {
-SymbolInfo Symbol = CreateSymbolInfo("A", SymbolInfo::Class, HeaderName, 6,
-

Re: [PATCH] D19913: Added static creators that create complete instances of SymbolInfo.

2016-05-04 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 56143.
ioeric added a comment.

- Use static creator functions in SymbolInfo in FindAllSymbolTests, and make 
SymbolInfo::operator== compare all fields.


http://reviews.llvm.org/D19913

Files:
  include-fixer/InMemoryXrefsDB.cpp
  include-fixer/find-all-symbols/SymbolInfo.cpp
  include-fixer/find-all-symbols/SymbolInfo.h
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -46,18 +46,6 @@
 return false;
   }
 
-  bool getSymbolExtraInfo(SymbolInfo *Symbol) {
-for (const auto &S : Symbols) {
-  if (S == *Symbol) {
-Symbol->FunctionInfos = S.FunctionInfos;
-Symbol->TypedefNameInfos = S.TypedefNameInfos;
-Symbol->VariableInfos = S.VariableInfos;
-return true;
-  }
-}
-return false;
-  }
-
 private:
   std::vector Symbols;
 };
@@ -68,10 +56,6 @@
 return Reporter.hasSymbol(Symbol);
   }
 
-  bool getSymbolExtraInfo(SymbolInfo &Symbol) {
-return Reporter.getSymbolExtraInfo(&Symbol);
-  }
-
   bool runFindAllSymbols(StringRef Code) {
 FindAllSymbols matcher(&Reporter);
 clang::ast_matchers::MatchFinder MatchFinder;
@@ -87,7 +71,7 @@
 clang::tooling::newFrontendActionFactory(&MatchFinder);
 tooling::ToolInvocation Invocation(
 {std::string("find_all_symbols"), std::string("-fsyntax-only"),
- FileName},
+ std::string("-std=c++11"), FileName},
 Factory->create(), Files.get(),
 std::make_shared());
 
@@ -105,10 +89,9 @@
   MockReporter Reporter;
 };
 
-SymbolInfo
-CreateSymbolInfo(StringRef Name, SymbolInfo::SymbolKind Type,
- const std::string FilePath, int LineNumber,
- const std::vector &Contexts) {
+SymbolInfo CreateSymbolInfo(StringRef Name, SymbolInfo::SymbolKind Type,
+const std::string FilePath, int LineNumber,
+const std::vector &Contexts) {
   SymbolInfo Symbol;
   Symbol.Name = Name;
   Symbol.Type = Type;
@@ -127,29 +110,19 @@
   })";
   runFindAllSymbols(Code);
 
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("xargc", SymbolInfo::Variable, HeaderName, 2, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("int", Symbol.VariableInfos.getValue().Type);
-  }
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("", SymbolInfo::Variable, HeaderName, 4,
- {{SymbolInfo::Namespace, "na"}});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("_Bool", Symbol.VariableInfos.getValue().Type);
-  }
-  {
-SymbolInfo Symbol = CreateSymbolInfo(
-"", SymbolInfo::Variable, HeaderName, 5,
-{{SymbolInfo::Namespace, "nb"}, {SymbolInfo::Namespace, "na"}});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("const long long *", Symbol.VariableInfos.getValue().Type);
-  }
+  SymbolInfo Symbol =
+  SymbolInfo::CreateVariableSymbolInfo("xargc", HeaderName, {}, 2, {"int"});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo::CreateVariableSymbolInfo(
+  "", HeaderName, {{SymbolInfo::Namespace, "na"}}, 4, {"_Bool"});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo::CreateVariableSymbolInfo(
+  "", HeaderName,
+  {{SymbolInfo::Namespace, "nb"}, {SymbolInfo::Namespace, "na"}}, 5,
+  {"const long long *"});
+  EXPECT_TRUE(hasSymbol(Symbol));
 }
 
 TEST_F(FindAllSymbolsTest, ExternCSymbols) {
@@ -162,19 +135,12 @@
   })";
   runFindAllSymbols(Code);
 
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("C_Func", SymbolInfo::Function, HeaderName, 3, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("int", Symbol.FunctionInfos.getValue().ReturnType);
-EXPECT_TRUE(Symbol.FunctionInfos.getValue().ParameterTypes.empty());
-  }
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("C_struct", SymbolInfo::Class, HeaderName, 4, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-  }
+  SymbolInfo Symbol = SymbolInfo::CreateFunctionSymbolInfo("C_Func", HeaderName,
+   {}, 3, {"int", {}});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo::CreateClassSymbolInfo("C_struct", HeaderName, {}, 4);
+  EXPECT_TRUE(hasSymbol(Symbol));
 }
 
 TEST_F(FindAllSymbolsTest, CXXRecordSymbols) {
@@ -193,16 +159,12 @@
   )";
   runFindAllSymbols(Code);
 
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("Glob", SymbolInfo::Class, HeaderName, 2, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-  }
-  {
-SymbolInfo Symbol = CreateSymbolInfo("A", SymbolInfo::Class, HeaderName, 6,
-   

Re: [PATCH] D19913: Added static creators that create complete instances of SymbolInfo.

2016-05-04 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 56145.
ioeric added a comment.

- Use template to compare llvm::Optional types.


http://reviews.llvm.org/D19913

Files:
  include-fixer/InMemoryXrefsDB.cpp
  include-fixer/find-all-symbols/SymbolInfo.cpp
  include-fixer/find-all-symbols/SymbolInfo.h
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -46,18 +46,6 @@
 return false;
   }
 
-  bool getSymbolExtraInfo(SymbolInfo *Symbol) {
-for (const auto &S : Symbols) {
-  if (S == *Symbol) {
-Symbol->FunctionInfos = S.FunctionInfos;
-Symbol->TypedefNameInfos = S.TypedefNameInfos;
-Symbol->VariableInfos = S.VariableInfos;
-return true;
-  }
-}
-return false;
-  }
-
 private:
   std::vector Symbols;
 };
@@ -68,10 +56,6 @@
 return Reporter.hasSymbol(Symbol);
   }
 
-  bool getSymbolExtraInfo(SymbolInfo &Symbol) {
-return Reporter.getSymbolExtraInfo(&Symbol);
-  }
-
   bool runFindAllSymbols(StringRef Code) {
 FindAllSymbols matcher(&Reporter);
 clang::ast_matchers::MatchFinder MatchFinder;
@@ -87,7 +71,7 @@
 clang::tooling::newFrontendActionFactory(&MatchFinder);
 tooling::ToolInvocation Invocation(
 {std::string("find_all_symbols"), std::string("-fsyntax-only"),
- FileName},
+ std::string("-std=c++11"), FileName},
 Factory->create(), Files.get(),
 std::make_shared());
 
@@ -105,10 +89,9 @@
   MockReporter Reporter;
 };
 
-SymbolInfo
-CreateSymbolInfo(StringRef Name, SymbolInfo::SymbolKind Type,
- const std::string FilePath, int LineNumber,
- const std::vector &Contexts) {
+SymbolInfo CreateSymbolInfo(StringRef Name, SymbolInfo::SymbolKind Type,
+const std::string FilePath, int LineNumber,
+const std::vector &Contexts) {
   SymbolInfo Symbol;
   Symbol.Name = Name;
   Symbol.Type = Type;
@@ -127,29 +110,19 @@
   })";
   runFindAllSymbols(Code);
 
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("xargc", SymbolInfo::Variable, HeaderName, 2, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("int", Symbol.VariableInfos.getValue().Type);
-  }
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("", SymbolInfo::Variable, HeaderName, 4,
- {{SymbolInfo::Namespace, "na"}});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("_Bool", Symbol.VariableInfos.getValue().Type);
-  }
-  {
-SymbolInfo Symbol = CreateSymbolInfo(
-"", SymbolInfo::Variable, HeaderName, 5,
-{{SymbolInfo::Namespace, "nb"}, {SymbolInfo::Namespace, "na"}});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("const long long *", Symbol.VariableInfos.getValue().Type);
-  }
+  SymbolInfo Symbol =
+  SymbolInfo::CreateVariableSymbolInfo("xargc", HeaderName, {}, 2, {"int"});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo::CreateVariableSymbolInfo(
+  "", HeaderName, {{SymbolInfo::Namespace, "na"}}, 4, {"_Bool"});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo::CreateVariableSymbolInfo(
+  "", HeaderName,
+  {{SymbolInfo::Namespace, "nb"}, {SymbolInfo::Namespace, "na"}}, 5,
+  {"const long long *"});
+  EXPECT_TRUE(hasSymbol(Symbol));
 }
 
 TEST_F(FindAllSymbolsTest, ExternCSymbols) {
@@ -162,19 +135,12 @@
   })";
   runFindAllSymbols(Code);
 
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("C_Func", SymbolInfo::Function, HeaderName, 3, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("int", Symbol.FunctionInfos.getValue().ReturnType);
-EXPECT_TRUE(Symbol.FunctionInfos.getValue().ParameterTypes.empty());
-  }
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("C_struct", SymbolInfo::Class, HeaderName, 4, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-  }
+  SymbolInfo Symbol = SymbolInfo::CreateFunctionSymbolInfo("C_Func", HeaderName,
+   {}, 3, {"int", {}});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo::CreateClassSymbolInfo("C_struct", HeaderName, {}, 4);
+  EXPECT_TRUE(hasSymbol(Symbol));
 }
 
 TEST_F(FindAllSymbolsTest, CXXRecordSymbols) {
@@ -193,16 +159,12 @@
   )";
   runFindAllSymbols(Code);
 
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("Glob", SymbolInfo::Class, HeaderName, 2, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-  }
-  {
-SymbolInfo Symbol = CreateSymbolInfo("A", SymbolInfo::Class, HeaderName, 6,
- {{SymbolInfo::Namespace, "na"}});
-EXPECT_T

Re: [PATCH] D19913: Added static creators that create complete instances of SymbolInfo.

2016-05-04 Thread Haojian Wu via cfe-commits
hokein added inline comments.


Comment at: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp:92
@@ -107,5 +91,3 @@
 
-SymbolInfo
-CreateSymbolInfo(StringRef Name, SymbolInfo::SymbolKind Type,
- const std::string FilePath, int LineNumber,
- const std::vector &Contexts) {
+SymbolInfo CreateSymbolInfo(StringRef Name, SymbolInfo::SymbolKind Type,
+const std::string FilePath, int LineNumber,

You can remove it now.


http://reviews.llvm.org/D19913



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


Re: [PATCH] D19913: Added static creators that create complete instances of SymbolInfo.

2016-05-04 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 56147.
ioeric added a comment.

- Removed unused function in unit test.


http://reviews.llvm.org/D19913

Files:
  include-fixer/InMemoryXrefsDB.cpp
  include-fixer/find-all-symbols/SymbolInfo.cpp
  include-fixer/find-all-symbols/SymbolInfo.h
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -46,18 +46,6 @@
 return false;
   }
 
-  bool getSymbolExtraInfo(SymbolInfo *Symbol) {
-for (const auto &S : Symbols) {
-  if (S == *Symbol) {
-Symbol->FunctionInfos = S.FunctionInfos;
-Symbol->TypedefNameInfos = S.TypedefNameInfos;
-Symbol->VariableInfos = S.VariableInfos;
-return true;
-  }
-}
-return false;
-  }
-
 private:
   std::vector Symbols;
 };
@@ -68,10 +56,6 @@
 return Reporter.hasSymbol(Symbol);
   }
 
-  bool getSymbolExtraInfo(SymbolInfo &Symbol) {
-return Reporter.getSymbolExtraInfo(&Symbol);
-  }
-
   bool runFindAllSymbols(StringRef Code) {
 FindAllSymbols matcher(&Reporter);
 clang::ast_matchers::MatchFinder MatchFinder;
@@ -87,7 +71,7 @@
 clang::tooling::newFrontendActionFactory(&MatchFinder);
 tooling::ToolInvocation Invocation(
 {std::string("find_all_symbols"), std::string("-fsyntax-only"),
- FileName},
+ std::string("-std=c++11"), FileName},
 Factory->create(), Files.get(),
 std::make_shared());
 
@@ -105,19 +89,6 @@
   MockReporter Reporter;
 };
 
-SymbolInfo
-CreateSymbolInfo(StringRef Name, SymbolInfo::SymbolKind Type,
- const std::string FilePath, int LineNumber,
- const std::vector &Contexts) {
-  SymbolInfo Symbol;
-  Symbol.Name = Name;
-  Symbol.Type = Type;
-  Symbol.FilePath = FilePath;
-  Symbol.LineNumber = LineNumber;
-  Symbol.Contexts = Contexts;
-  return Symbol;
-}
-
 TEST_F(FindAllSymbolsTest, VariableSymbols) {
   static const char Code[] = R"(
   extern int xargc;
@@ -127,29 +98,19 @@
   })";
   runFindAllSymbols(Code);
 
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("xargc", SymbolInfo::Variable, HeaderName, 2, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("int", Symbol.VariableInfos.getValue().Type);
-  }
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("", SymbolInfo::Variable, HeaderName, 4,
- {{SymbolInfo::Namespace, "na"}});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("_Bool", Symbol.VariableInfos.getValue().Type);
-  }
-  {
-SymbolInfo Symbol = CreateSymbolInfo(
-"", SymbolInfo::Variable, HeaderName, 5,
-{{SymbolInfo::Namespace, "nb"}, {SymbolInfo::Namespace, "na"}});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("const long long *", Symbol.VariableInfos.getValue().Type);
-  }
+  SymbolInfo Symbol =
+  SymbolInfo::CreateVariableSymbolInfo("xargc", HeaderName, {}, 2, {"int"});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo::CreateVariableSymbolInfo(
+  "", HeaderName, {{SymbolInfo::Namespace, "na"}}, 4, {"_Bool"});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo::CreateVariableSymbolInfo(
+  "", HeaderName,
+  {{SymbolInfo::Namespace, "nb"}, {SymbolInfo::Namespace, "na"}}, 5,
+  {"const long long *"});
+  EXPECT_TRUE(hasSymbol(Symbol));
 }
 
 TEST_F(FindAllSymbolsTest, ExternCSymbols) {
@@ -162,19 +123,12 @@
   })";
   runFindAllSymbols(Code);
 
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("C_Func", SymbolInfo::Function, HeaderName, 3, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("int", Symbol.FunctionInfos.getValue().ReturnType);
-EXPECT_TRUE(Symbol.FunctionInfos.getValue().ParameterTypes.empty());
-  }
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("C_struct", SymbolInfo::Class, HeaderName, 4, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-  }
+  SymbolInfo Symbol = SymbolInfo::CreateFunctionSymbolInfo("C_Func", HeaderName,
+   {}, 3, {"int", {}});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo::CreateClassSymbolInfo("C_struct", HeaderName, {}, 4);
+  EXPECT_TRUE(hasSymbol(Symbol));
 }
 
 TEST_F(FindAllSymbolsTest, CXXRecordSymbols) {
@@ -193,16 +147,12 @@
   )";
   runFindAllSymbols(Code);
 
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("Glob", SymbolInfo::Class, HeaderName, 2, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-  }
-  {
-SymbolInfo Symbol = CreateSymbolInfo("A", SymbolInfo::Class, HeaderName, 6,
- {{SymbolInfo::Namespace, "na"}});
-  

[PATCH] D19918: AMDGPU/SI: Use amdgpu_kernel calling convention for OpenCL kernels.

2016-05-04 Thread Nikolay Haustov via cfe-commits
nhaustov created this revision.
nhaustov added reviewers: tstellarAMD, arsenm.
nhaustov added a subscriber: cfe-commits.

http://reviews.llvm.org/D19918

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGenOpenCL/amdgpu-calling-conv.cl
  test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl

Index: test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
===
--- test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
+++ test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
@@ -5,23 +5,23 @@
 
 __attribute__((amdgpu_num_vgpr(64))) // expected-no-diagnostics
 kernel void test_num_vgpr64() {
-// CHECK: define void @test_num_vgpr64() [[ATTR_VGPR64:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_vgpr64() [[ATTR_VGPR64:#[0-9]+]]
 }
 
 __attribute__((amdgpu_num_sgpr(32))) // expected-no-diagnostics
 kernel void test_num_sgpr32() {
-// CHECK: define void @test_num_sgpr32() [[ATTR_SGPR32:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_sgpr32() [[ATTR_SGPR32:#[0-9]+]]
 }
 
 __attribute__((amdgpu_num_vgpr(64), amdgpu_num_sgpr(32))) // 
expected-no-diagnostics
 kernel void test_num_vgpr64_sgpr32() {
-// CHECK: define void @test_num_vgpr64_sgpr32() [[ATTR_VGPR64_SGPR32:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_vgpr64_sgpr32() 
[[ATTR_VGPR64_SGPR32:#[0-9]+]]
 
 }
 
 __attribute__((amdgpu_num_sgpr(20), amdgpu_num_vgpr(40))) // 
expected-no-diagnostics
 kernel void test_num_sgpr20_vgpr40() {
-// CHECK: define void @test_num_sgpr20_vgpr40() [[ATTR_SGPR20_VGPR40:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_sgpr20_vgpr40() 
[[ATTR_SGPR20_VGPR40:#[0-9]+]]
 }
 
 __attribute__((amdgpu_num_vgpr(0))) // expected-no-diagnostics
Index: test/CodeGenOpenCL/amdgpu-calling-conv.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/amdgpu-calling-conv.cl
@@ -0,0 +1,12 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | 
FileCheck %s
+
+// CHECK: define amdgpu_kernel void @calling_conv_amdgpu_kernel()
+kernel void calling_conv_amdgpu_kernel()
+{
+}
+
+// CHECK: define void @calling_conv_none()
+void calling_conv_none()
+{
+}
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -6826,6 +6826,14 @@
   if (!FD)
 return;
 
+  if (M.getLangOpts().OpenCL) {
+if (FD->hasAttr()) {
+  // Set amdgpu_kernel calling convention for OpenCL kernels.
+  llvm::Function *Fn = cast(GV);
+  Fn->setCallingConv(llvm::CallingConv::AMDGPU_KERNEL);
+}
+  }
+
   if (const auto Attr = FD->getAttr()) {
 llvm::Function *F = cast(GV);
 uint32_t NumVGPR = Attr->getNumVGPR();


Index: test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
===
--- test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
+++ test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
@@ -5,23 +5,23 @@
 
 __attribute__((amdgpu_num_vgpr(64))) // expected-no-diagnostics
 kernel void test_num_vgpr64() {
-// CHECK: define void @test_num_vgpr64() [[ATTR_VGPR64:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_vgpr64() [[ATTR_VGPR64:#[0-9]+]]
 }
 
 __attribute__((amdgpu_num_sgpr(32))) // expected-no-diagnostics
 kernel void test_num_sgpr32() {
-// CHECK: define void @test_num_sgpr32() [[ATTR_SGPR32:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_sgpr32() [[ATTR_SGPR32:#[0-9]+]]
 }
 
 __attribute__((amdgpu_num_vgpr(64), amdgpu_num_sgpr(32))) // expected-no-diagnostics
 kernel void test_num_vgpr64_sgpr32() {
-// CHECK: define void @test_num_vgpr64_sgpr32() [[ATTR_VGPR64_SGPR32:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_vgpr64_sgpr32() [[ATTR_VGPR64_SGPR32:#[0-9]+]]
 
 }
 
 __attribute__((amdgpu_num_sgpr(20), amdgpu_num_vgpr(40))) // expected-no-diagnostics
 kernel void test_num_sgpr20_vgpr40() {
-// CHECK: define void @test_num_sgpr20_vgpr40() [[ATTR_SGPR20_VGPR40:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_sgpr20_vgpr40() [[ATTR_SGPR20_VGPR40:#[0-9]+]]
 }
 
 __attribute__((amdgpu_num_vgpr(0))) // expected-no-diagnostics
Index: test/CodeGenOpenCL/amdgpu-calling-conv.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/amdgpu-calling-conv.cl
@@ -0,0 +1,12 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define amdgpu_kernel void @calling_conv_amdgpu_kernel()
+kernel void calling_conv_amdgpu_kernel()
+{
+}
+
+// CHECK: define void @calling_conv_none()
+void calling_conv_none()
+{
+}
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -6826,6 +6826,14 @@
   if (!FD)
 return;
 
+  if (M.getLangOpts().OpenCL) {
+if (FD->hasAttr()) {
+  // Set amdgpu_kernel 

Re: [PATCH] D19913: Added static creators that create complete instances of SymbolInfo.

2016-05-04 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 56148.
ioeric added a comment.

- Removed SetCommonInfo declaration from header.


http://reviews.llvm.org/D19913

Files:
  include-fixer/InMemoryXrefsDB.cpp
  include-fixer/find-all-symbols/SymbolInfo.cpp
  include-fixer/find-all-symbols/SymbolInfo.h
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -46,18 +46,6 @@
 return false;
   }
 
-  bool getSymbolExtraInfo(SymbolInfo *Symbol) {
-for (const auto &S : Symbols) {
-  if (S == *Symbol) {
-Symbol->FunctionInfos = S.FunctionInfos;
-Symbol->TypedefNameInfos = S.TypedefNameInfos;
-Symbol->VariableInfos = S.VariableInfos;
-return true;
-  }
-}
-return false;
-  }
-
 private:
   std::vector Symbols;
 };
@@ -68,10 +56,6 @@
 return Reporter.hasSymbol(Symbol);
   }
 
-  bool getSymbolExtraInfo(SymbolInfo &Symbol) {
-return Reporter.getSymbolExtraInfo(&Symbol);
-  }
-
   bool runFindAllSymbols(StringRef Code) {
 FindAllSymbols matcher(&Reporter);
 clang::ast_matchers::MatchFinder MatchFinder;
@@ -87,7 +71,7 @@
 clang::tooling::newFrontendActionFactory(&MatchFinder);
 tooling::ToolInvocation Invocation(
 {std::string("find_all_symbols"), std::string("-fsyntax-only"),
- FileName},
+ std::string("-std=c++11"), FileName},
 Factory->create(), Files.get(),
 std::make_shared());
 
@@ -105,19 +89,6 @@
   MockReporter Reporter;
 };
 
-SymbolInfo
-CreateSymbolInfo(StringRef Name, SymbolInfo::SymbolKind Type,
- const std::string FilePath, int LineNumber,
- const std::vector &Contexts) {
-  SymbolInfo Symbol;
-  Symbol.Name = Name;
-  Symbol.Type = Type;
-  Symbol.FilePath = FilePath;
-  Symbol.LineNumber = LineNumber;
-  Symbol.Contexts = Contexts;
-  return Symbol;
-}
-
 TEST_F(FindAllSymbolsTest, VariableSymbols) {
   static const char Code[] = R"(
   extern int xargc;
@@ -127,29 +98,19 @@
   })";
   runFindAllSymbols(Code);
 
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("xargc", SymbolInfo::Variable, HeaderName, 2, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("int", Symbol.VariableInfos.getValue().Type);
-  }
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("", SymbolInfo::Variable, HeaderName, 4,
- {{SymbolInfo::Namespace, "na"}});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("_Bool", Symbol.VariableInfos.getValue().Type);
-  }
-  {
-SymbolInfo Symbol = CreateSymbolInfo(
-"", SymbolInfo::Variable, HeaderName, 5,
-{{SymbolInfo::Namespace, "nb"}, {SymbolInfo::Namespace, "na"}});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("const long long *", Symbol.VariableInfos.getValue().Type);
-  }
+  SymbolInfo Symbol =
+  SymbolInfo::CreateVariableSymbolInfo("xargc", HeaderName, {}, 2, {"int"});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo::CreateVariableSymbolInfo(
+  "", HeaderName, {{SymbolInfo::Namespace, "na"}}, 4, {"_Bool"});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo::CreateVariableSymbolInfo(
+  "", HeaderName,
+  {{SymbolInfo::Namespace, "nb"}, {SymbolInfo::Namespace, "na"}}, 5,
+  {"const long long *"});
+  EXPECT_TRUE(hasSymbol(Symbol));
 }
 
 TEST_F(FindAllSymbolsTest, ExternCSymbols) {
@@ -162,19 +123,12 @@
   })";
   runFindAllSymbols(Code);
 
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("C_Func", SymbolInfo::Function, HeaderName, 3, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("int", Symbol.FunctionInfos.getValue().ReturnType);
-EXPECT_TRUE(Symbol.FunctionInfos.getValue().ParameterTypes.empty());
-  }
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("C_struct", SymbolInfo::Class, HeaderName, 4, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-  }
+  SymbolInfo Symbol = SymbolInfo::CreateFunctionSymbolInfo("C_Func", HeaderName,
+   {}, 3, {"int", {}});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo::CreateClassSymbolInfo("C_struct", HeaderName, {}, 4);
+  EXPECT_TRUE(hasSymbol(Symbol));
 }
 
 TEST_F(FindAllSymbolsTest, CXXRecordSymbols) {
@@ -193,16 +147,12 @@
   )";
   runFindAllSymbols(Code);
 
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("Glob", SymbolInfo::Class, HeaderName, 2, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-  }
-  {
-SymbolInfo Symbol = CreateSymbolInfo("A", SymbolInfo::Class, HeaderName, 6,
- {{SymbolInfo::Namespace, "na

[PATCH] D19920: [libunwind][ARM] Improve unwinder stack usage on baremetal targets - part 1

2016-05-04 Thread Asiri Rathnayake via cfe-commits
rmaprath created this revision.
rmaprath added a reviewer: jroelofs.
rmaprath added a subscriber: cfe-commits.
Herald added subscribers: rengolin, aemerson.

Currently, `unw_context_t` and `unw_cursor_t` are sized to allow the virtual 
register set of any target supported by libunwind. This does not work well for 
baremetal ARM targets (where memory is at a premium).

This patch makes `unw_context_t` and `unw_cursor_t` use just enough space to 
hold the ARM virtual register set on baremetal arm targets.

The various `Registers_xxx` definitions (and their dependencies) had to be 
conditionally compiled out in order to allow each of the targets to perform 
size checks independently.

This change saves about 1500 bytes of stack on ARM v7 (similar amount on 
AArch32).

http://reviews.llvm.org/D19920

Files:
  include/libunwind.h
  src/CompactUnwinder.hpp
  src/Registers.hpp
  src/UnwindCursor.hpp
  src/libunwind.cpp

Index: src/libunwind.cpp
===
--- src/libunwind.cpp
+++ src/libunwind.cpp
@@ -45,30 +45,29 @@
   _LIBUNWIND_TRACE_API("unw_init_local(cursor=%p, context=%p)\n",
static_cast(cursor),
static_cast(context));
-  // Use "placement new" to allocate UnwindCursor in the cursor buffer.
 #if defined(__i386__)
-  new ((void *)cursor) UnwindCursor(
- context, LocalAddressSpace::sThisAddressSpace);
+# define REGISTER_KIND Registers_x86
 #elif defined(__x86_64__)
-  new ((void *)cursor) UnwindCursor(
- context, LocalAddressSpace::sThisAddressSpace);
+# define REGISTER_KIND Registers_x86_64
 #elif defined(__ppc__)
-  new ((void *)cursor) UnwindCursor(
- context, LocalAddressSpace::sThisAddressSpace);
+# define REGISTER_KIND Registers_ppc
 #elif defined(__arm64__) || defined(__aarch64__)
-  new ((void *)cursor) UnwindCursor(
- context, LocalAddressSpace::sThisAddressSpace);
+# define REGISTER_KIND Registers_arm64
 #elif _LIBUNWIND_ARM_EHABI
-  new ((void *)cursor) UnwindCursor(
- context, LocalAddressSpace::sThisAddressSpace);
+# define REGISTER_KIND Registers_arm
 #elif defined(__or1k__)
-  new ((void *)cursor) UnwindCursor(
- context, LocalAddressSpace::sThisAddressSpace);
+# define REGISTER_KIND Registers_or1k
 #elif defined(__mips__)
-#warning The MIPS architecture is not supported.
+# warning The MIPS architecture is not supported.
 #else
-#error Architecture not supported
+# error Architecture not supported
 #endif
+  static_assert(sizeof(UnwindCursor) <=
+sizeof(unw_cursor_t), "Unwind cursor does not fit in unw_cursor_t");
+  // Use "placement new" to allocate UnwindCursor in the cursor buffer.
+  new ((void *)cursor) UnwindCursor(
+ context, LocalAddressSpace::sThisAddressSpace);
+#undef REGISTER_KIND
   AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
   co->setInfoBasedOnIPRegister();
 
Index: src/UnwindCursor.hpp
===
--- src/UnwindCursor.hpp
+++ src/UnwindCursor.hpp
@@ -481,30 +481,36 @@
 return stepWithCompactEncoding(dummy);
   }
 
+#if defined(__x86_64__)
   int stepWithCompactEncoding(Registers_x86_64 &) {
 return CompactUnwinder_x86_64::stepWithCompactEncoding(
 _info.format, _info.start_ip, _addressSpace, _registers);
   }
 
+#elif defined(__i386__)
   int stepWithCompactEncoding(Registers_x86 &) {
 return CompactUnwinder_x86::stepWithCompactEncoding(
 _info.format, (uint32_t)_info.start_ip, _addressSpace, _registers);
   }
 
+#elif defined(__ppc__)
   int stepWithCompactEncoding(Registers_ppc &) {
 return UNW_EINVAL;
   }
 
+#elif defined(__arm64__) || defined(__aarch64__)
   int stepWithCompactEncoding(Registers_arm64 &) {
 return CompactUnwinder_arm64::stepWithCompactEncoding(
 _info.format, _info.start_ip, _addressSpace, _registers);
   }
+#endif
 
   bool compactSaysUseDwarf(uint32_t *offset=NULL) const {
 R dummy;
 return compactSaysUseDwarf(dummy, offset);
   }
 
+#if defined(__x86_64__)
   bool compactSaysUseDwarf(Registers_x86_64 &, uint32_t *offset) const {
 if ((_info.format & UNWIND_X86_64_MODE_MASK) == UNWIND_X86_64_MODE_DWARF) {
   if (offset)
@@ -514,6 +520,7 @@
 return false;
   }
 
+#elif defined(__i386__)
   bool compactSaysUseDwarf(Registers_x86 &, uint32_t *offset) const {
 if ((_info.format & UNWIND_X86_MODE_MASK) == UNWIND_X86_MODE_DWARF) {
   if (offset)
@@ -523,45 +530,54 @@
 return false;
   }
 
+#elif defined(__ppc__)
   bool compactSaysUseDwarf(Registers_ppc &, uint32_t *) const {
 return true;
   }
 
+#elif defined(__arm64__) || defined(__aarch64__)
   bool compactSaysUseDwarf(Registers_arm64 &, uint32_t *offset) const {
 if ((_info.format & UNWIND_ARM64_MODE_MASK) == UNWIND_ARM64_

Re: [PATCH] D19913: Added static creators that create complete instances of SymbolInfo.

2016-05-04 Thread Haojian Wu via cfe-commits
hokein added a comment.

It looks good to me now, but need to wait @klimek acceptance.



Comment at: include-fixer/find-all-symbols/SymbolInfo.h:98-101
@@ +97,6 @@
+
+  static SymbolInfo
+  CreateFunctionSymbolInfo(const std::string &Name, const std::string 
&FilePath,
+   const std::vector &Contexts, int 
LineNumber,
+   const FunctionInfo &FuncInfo);
+

However, changing `SymbolInfo` to class requires us to add many setters/getters 
in it.

Currently the `SymbolInfo` is like `ClangTidyOptions` structure. 


http://reviews.llvm.org/D19913



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


Re: [PATCH] D19920: [libunwind][ARM] Improve unwinder stack usage on baremetal targets - part 1

2016-05-04 Thread Tim Northover via cfe-commits
t.p.northover added a subscriber: t.p.northover.
t.p.northover added a comment.

I think it would be better to use a generic method so the size is minimal 
everywhere rather than making ARM a special case. Possibly move the #define 
bits from libunwind.cpp to __libunwind_config.h and use REGISTER_KIND to 
declare unw_context_t?



Comment at: src/CompactUnwinder.hpp:490
@@ -488,3 +489,3 @@
 
-
+#elif defined(__arm64__) || defined(__aarch64__)
 /// CompactUnwinder_arm64 uses a compact unwind info to virtually "step" (aka

`__aarch64__` is defined for iOS too, so no need for both.


http://reviews.llvm.org/D19920



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


Re: [PATCH] D19920: [libunwind][ARM] Improve unwinder stack usage on baremetal targets - part 1

2016-05-04 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

Wouldn't this break cross unwinding?


http://reviews.llvm.org/D19920



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


Re: [PATCH] D19920: [libunwind][ARM] Improve unwinder stack usage on baremetal targets - part 1

2016-05-04 Thread Renato Golin via cfe-commits
rengolin added a comment.

I agree with Tim, I think this should be more generic.


http://reviews.llvm.org/D19920



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


Re: [PATCH] D19920: [libunwind][ARM] Improve unwinder stack usage on baremetal targets - part 1

2016-05-04 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In http://reviews.llvm.org/D19920#421131, @t.p.northover wrote:

> I think it would be better to use a generic method so the size is minimal 
> everywhere rather than making ARM a special case. Possibly move the #define 
> bits from libunwind.cpp to __libunwind_config.h and use REGISTER_KIND to 
> declare unw_context_t?


Wouldn't this make `libunwind.h` depend on `Registers_xxx` types? I thought the 
whole idea of statically allocated buffers was to keep these two separate. I 
may be wrong though, pretty new to unwinder.

Thanks.

/ Asiri


http://reviews.llvm.org/D19920



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


Re: [PATCH] D19920: [libunwind][ARM] Improve unwinder stack usage on baremetal targets - part 1

2016-05-04 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In http://reviews.llvm.org/D19920#421145, @jroelofs wrote:

> Wouldn't this break cross unwinding?


I wasn't aware of cross unwinding, I think you are referring to [1]. Thanks for 
the pointer.

Would it make sense to support a libunwind build that only supports native 
unwinding? For baremetal (embedded) applications, I don't think cross unwinding 
(if I understand it correctly) makes a lot of sense.

Thanks!

/ Asiri

[1] http://www.nongnu.org/libunwind/man/libunwind(3).html#section_4


http://reviews.llvm.org/D19920



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


Re: [PATCH] D19827: Do not disable completely loop unroll when optimizing for size.

2016-05-04 Thread Reid Kleckner via cfe-commits
rnk added a subscriber: rnk.
rnk accepted this revision.
rnk added a reviewer: rnk.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm

To be clear, loop unrolling just lowers its size threshold when -Os is on:

  // Apply size attributes
  if (L->getHeader()->getParent()->optForSize()) {
UP.Threshold = UP.OptSizeThreshold;
UP.PartialThreshold = UP.PartialOptSizeThreshold;
  }

So this does more than enabling loop unrolling when pragmas are present. 
However, it that behavior is wrong then we should fix it in LLVM.


Repository:
  rL LLVM

http://reviews.llvm.org/D19827



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


Re: [PATCH] D19920: [libunwind][ARM] Improve unwinder stack usage on baremetal targets - part 1

2016-05-04 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

In http://reviews.llvm.org/D19920#421173, @rmaprath wrote:

> In http://reviews.llvm.org/D19920#421145, @jroelofs wrote:
>
> > Wouldn't this break cross unwinding?
>
>
> I wasn't aware of cross unwinding, I think you are referring to [1]. Thanks 
> for the pointer.
>
> Would it make sense to support a libunwind build that only supports native 
> unwinding? For baremetal (embedded) applications, I don't think cross 
> unwinding (if I understand it correctly) makes a lot of sense.
>
> Thanks!
>
> / Asiri
>
> [1] http://www.nongnu.org/libunwind/man/libunwind(3).html#section_4


Yeah, that's what I'm referring to. I have no idea if it's currently working or 
not, but *adding* a build mode that only supports native unwinding sounds like 
a good idea.


http://reviews.llvm.org/D19920



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


r268509 - Do not disable completely loop unroll when optimizing for size.

2016-05-04 Thread Marianne Mailhot-Sarrasin via cfe-commits
Author: mamai
Date: Wed May  4 10:26:28 2016
New Revision: 268509

URL: http://llvm.org/viewvc/llvm-project?rev=268509&view=rev
Log:
Do not disable completely loop unroll when optimizing for size.

Let the loop unroll pass handle /Os. It already checks that option and adjust 
its thresholds accordingly. Also, will allow the #pragma unroll to have an 
effect in /Os.

Differential Revision: http://reviews.llvm.org/D19827

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

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=268509&r1=268508&r2=268509&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed May  4 10:26:28 2016
@@ -513,7 +513,7 @@ static bool ParseCodeGenArgs(CodeGenOpti
 getAllNoBuiltinFuncValues(Args, Opts.NoBuiltinFuncs);
   Opts.UnrollLoops =
   Args.hasFlag(OPT_funroll_loops, OPT_fno_unroll_loops,
-   (Opts.OptimizationLevel > 1 && !Opts.OptimizeSize));
+   (Opts.OptimizationLevel > 1));
   Opts.RerollLoops = Args.hasArg(OPT_freroll_loops);
 
   Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);


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


Re: [PATCH] D19827: Do not disable completely loop unroll when optimizing for size.

2016-05-04 Thread Marianne Mailhot-Sarrasin via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268509: Do not disable completely loop unroll when 
optimizing for size. (authored by mamai).

Changed prior to commit:
  http://reviews.llvm.org/D19827?vs=56133&id=56158#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19827

Files:
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -513,7 +513,7 @@
 getAllNoBuiltinFuncValues(Args, Opts.NoBuiltinFuncs);
   Opts.UnrollLoops =
   Args.hasFlag(OPT_funroll_loops, OPT_fno_unroll_loops,
-   (Opts.OptimizationLevel > 1 && !Opts.OptimizeSize));
+   (Opts.OptimizationLevel > 1));
   Opts.RerollLoops = Args.hasArg(OPT_freroll_loops);
 
   Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);


Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -513,7 +513,7 @@
 getAllNoBuiltinFuncValues(Args, Opts.NoBuiltinFuncs);
   Opts.UnrollLoops =
   Args.hasFlag(OPT_funroll_loops, OPT_fno_unroll_loops,
-   (Opts.OptimizationLevel > 1 && !Opts.OptimizeSize));
+   (Opts.OptimizationLevel > 1));
   Opts.RerollLoops = Args.hasArg(OPT_freroll_loops);
 
   Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r268510 - Fixed some spelling errors in assert messages. No functional change. Thanks to giffu...@yahoo.com for the report.

2016-05-04 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed May  4 10:35:50 2016
New Revision: 268510

URL: http://llvm.org/viewvc/llvm-project?rev=268510&view=rev
Log:
Fixed some spelling errors in assert messages. No functional change. Thanks to 
giffu...@yahoo.com for the report.

Modified:
libcxx/trunk/include/experimental/string_view

Modified: libcxx/trunk/include/experimental/string_view
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/string_view?rev=268510&r1=268509&r2=268510&view=diff
==
--- libcxx/trunk/include/experimental/string_view (original)
+++ libcxx/trunk/include/experimental/string_view Wed May  4 10:35:50 2016
@@ -227,7 +227,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
 basic_string_view(const _CharT* __s, size_type __len)
 : __data(__s), __size(__len)
 {
-// _LIBCPP_ASSERT(__len == 0 || __s != nullptr, 
"string_view::string_view(_CharT *, size_t): recieved nullptr");
+// _LIBCPP_ASSERT(__len == 0 || __s != nullptr, 
"string_view::string_view(_CharT *, size_t): received nullptr");
 }
 
 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
@@ -413,7 +413,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
 size_type find(basic_string_view __s, size_type __pos = 0) const 
_NOEXCEPT
 {
-_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, 
"string_view::find(): recieved nullptr");
+_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, 
"string_view::find(): received nullptr");
 return _VSTD::__str_find
 (data(), size(), __s.data(), __pos, __s.size());
 }
@@ -428,7 +428,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
 size_type find(const _CharT* __s, size_type __pos, size_type __n) const
 {
-_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find(): 
recieved nullptr");
+_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find(): 
received nullptr");
 return _VSTD::__str_find
 (data(), size(), __s, __pos, __n);
 }
@@ -436,7 +436,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
 size_type find(const _CharT* __s, size_type __pos = 0) const
 {
-_LIBCPP_ASSERT(__s != nullptr, "string_view::find(): recieved 
nullptr");
+_LIBCPP_ASSERT(__s != nullptr, "string_view::find(): received 
nullptr");
 return _VSTD::__str_find
 (data(), size(), __s, __pos, traits_type::length(__s));
 }
@@ -445,7 +445,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
 size_type rfind(basic_string_view __s, size_type __pos = npos) const 
_NOEXCEPT
 {
-_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, 
"string_view::find(): recieved nullptr");
+_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, 
"string_view::find(): received nullptr");
 return _VSTD::__str_rfind
 (data(), size(), __s.data(), __pos, __s.size());
 }
@@ -460,7 +460,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
 size_type rfind(const _CharT* __s, size_type __pos, size_type __n) 
const
 {
-_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::rfind(): 
recieved nullptr");
+_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::rfind(): 
received nullptr");
 return _VSTD::__str_rfind
 (data(), size(), __s, __pos, __n);
 }
@@ -468,7 +468,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
 size_type rfind(const _CharT* __s, size_type __pos=npos) const
 {
-_LIBCPP_ASSERT(__s != nullptr, "string_view::rfind(): recieved 
nullptr");
+_LIBCPP_ASSERT(__s != nullptr, "string_view::rfind(): received 
nullptr");
 return _VSTD::__str_rfind
 (data(), size(), __s, __pos, traits_type::length(__s));
 }
@@ -477,7 +477,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
 size_type find_first_of(basic_string_view __s, size_type __pos = 0) 
const _NOEXCEPT
 {
-_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, 
"string_view::find_first_of(): recieved nullptr");
+_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, 
"string_view::find_first_of(): received nullptr");
 return _VSTD::__str_find_first_of
 (data(), size(), __s.data(), __pos, __s.size());
 }
@@ -489,7 +489,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VI

Re: [PATCH] D19920: [libunwind][ARM] Improve unwinder stack usage on baremetal targets - part 1

2016-05-04 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In http://reviews.llvm.org/D19920#421189, @jroelofs wrote:

> In http://reviews.llvm.org/D19920#421173, @rmaprath wrote:
>
> > In http://reviews.llvm.org/D19920#421145, @jroelofs wrote:
> >
> > > Wouldn't this break cross unwinding?
> >
> >
> > I wasn't aware of cross unwinding, I think you are referring to [1]. Thanks 
> > for the pointer.
> >
> > Would it make sense to support a libunwind build that only supports native 
> > unwinding? For baremetal (embedded) applications, I don't think cross 
> > unwinding (if I understand it correctly) makes a lot of sense.
> >
> > Thanks!
> >
> > / Asiri
> >
> > [1] http://www.nongnu.org/libunwind/man/libunwind(3).html#section_4
>
>
> Yeah, that's what I'm referring to. I have no idea if it's currently working 
> or not, but *adding* a build mode that only supports native unwinding sounds 
> like a good idea.


Makes sense. I will update the patch to hide behind a build option.

@rengolin, @t.p.northover: From what I gathered so far, `libunwind.h` is 
supposed to be platform independent, so we cannot make the size computation 
generic as suggested (without tying up `libunwind.h` into library sources).

We could, on the other hand, do this tightening for all the supported 
architectures (for the new, native-only libunwind build suggested by @jroelofs) 
with appropriate asserts in place so that we maintain these tight bounds as we 
move forward. Not sure if that effort would be worth though, given that for 
most non-ARM targets, unwinder stack usage is not a huge concern.

Cheers,

/ Asiri


http://reviews.llvm.org/D19920



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


Re: [PATCH] D19536: [CodeGenObjCXX] Fix handling of blocks in lambda

2016-05-04 Thread John McCall via cfe-commits
rjmccall added a comment.

Yes, that looks good, thanks.


http://reviews.llvm.org/D19536



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


Re: [PATCH] D18815: [ObjC] Enter a new evaluation context before calling BuildBlockForLambdaConversion.

2016-05-04 Thread John McCall via cfe-commits
rjmccall added a comment.

LGTM.


http://reviews.llvm.org/D18815



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


r268511 - [Coverage] Fix an issue where a coverage region might not be created for a macro containing a loop statement.

2016-05-04 Thread Igor Kudrin via cfe-commits
Author: ikudrin
Date: Wed May  4 10:38:26 2016
New Revision: 268511

URL: http://llvm.org/viewvc/llvm-project?rev=268511&view=rev
Log:
[Coverage] Fix an issue where a coverage region might not be created for a 
macro containing a loop statement.

The issue happened when a macro contained a full for or
while statement, which body ended at the end of the macro.

Differential Revision: http://reviews.llvm.org/D19725

Modified:
cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
cfe/trunk/test/CoverageMapping/macroscopes.cpp

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=268511&r1=268510&r2=268511&view=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Wed May  4 10:38:26 2016
@@ -443,15 +443,31 @@ struct CounterCoverageMappingBuilder
 return ExitCount;
   }
 
+  /// \brief Check whether a region with bounds \c StartLoc and \c EndLoc
+  /// is already added to \c SourceRegions.
+  bool isRegionAlreadyAdded(SourceLocation StartLoc, SourceLocation EndLoc) {
+return SourceRegions.rend() !=
+   std::find_if(SourceRegions.rbegin(), SourceRegions.rend(),
+[&](const SourceMappingRegion &Region) {
+  return Region.getStartLoc() == StartLoc &&
+ Region.getEndLoc() == EndLoc;
+});
+  }
+
   /// \brief Adjust the most recently visited location to \c EndLoc.
   ///
   /// This should be used after visiting any statements in non-source order.
   void adjustForOutOfOrderTraversal(SourceLocation EndLoc) {
 MostRecentLocation = EndLoc;
-// Avoid adding duplicate regions if we have a completed region on the top
-// of the stack and are adjusting to the end of a virtual file.
+// The code region for a whole macro is created in handleFileExit() when
+// it detects exiting of the virtual file of that macro. If we visited
+// statements in non-source order, we might already have such a region
+// added, for example, if a body of a loop is divided among multiple
+// macros. Avoid adding duplicate regions in such case.
 if (getRegion().hasEndLoc() &&
-MostRecentLocation == getEndOfFileOrMacro(MostRecentLocation))
+MostRecentLocation == getEndOfFileOrMacro(MostRecentLocation) &&
+isRegionAlreadyAdded(getStartOfFileOrMacro(MostRecentLocation),
+ MostRecentLocation))
   MostRecentLocation = getIncludeOrExpansionLoc(MostRecentLocation);
   }
 

Modified: cfe/trunk/test/CoverageMapping/macroscopes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/macroscopes.cpp?rev=268511&r1=268510&r2=268511&view=diff
==
--- cfe/trunk/test/CoverageMapping/macroscopes.cpp (original)
+++ cfe/trunk/test/CoverageMapping/macroscopes.cpp Wed May  4 10:38:26 2016
@@ -22,6 +22,17 @@
 #define starts_a_while while (x < 5)
 #define simple_stmt ++x
 
+#define macro_with_for  \
+  x = 3;\
+  for (int i = 0; i < x; ++i) { \
+  }
+
+#define macro_with_while \
+  x = 4; \
+  while (x < 5) {\
+++x; \
+  }
+
 // CHECK: main
 // CHECK-NEXT: File 0, [[@LINE+1]]:12 -> {{[0-9]+}}:2 = #0
 int main() {
@@ -64,6 +75,11 @@ int main() {
 simple_stmt;
   ends_a_scope
 
+  // CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:17 = #0
+  macro_with_for
+  // CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:19 = #0
+  macro_with_while
+
   return 0;
 }
 
@@ -103,3 +119,10 @@ int main() {
 // CHECK-NEXT: File 11, 22:31 -> 22:36 = (#0 + #9)
 // CHECK-NEXT: File 12, 23:21 -> 23:24 = #9
 // CHECK-NEXT: File 13, 6:3 -> 7:4 = #9
+// CHECK-NEXT: File 14, 26:3 -> 28:4 = #0
+// CHECK-NEXT: File 14, 27:19 -> 27:24 = (#0 + #10)
+// CHECK-NEXT: File 14, 27:26 -> 27:29 = #10
+// CHECK-NEXT: File 14, 27:31 -> 28:4 = #10
+// CHECK-NEXT: File 15, 31:3 -> 34:4 = #0
+// CHECK-NEXT: File 15, 32:10 -> 32:15 = (#0 + #11)
+// CHECK-NEXT: File 15, 32:17 -> 34:4 = #11


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


Re: [PATCH] D19725: [Coverage] Fix an issue where a coverage region might not be created for a macro containing for or while statements.

2016-05-04 Thread Igor Kudrin via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268511: [Coverage] Fix an issue where a coverage region 
might not be created for a… (authored by ikudrin).

Changed prior to commit:
  http://reviews.llvm.org/D19725?vs=55602&id=56159#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19725

Files:
  cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
  cfe/trunk/test/CoverageMapping/macroscopes.cpp

Index: cfe/trunk/test/CoverageMapping/macroscopes.cpp
===
--- cfe/trunk/test/CoverageMapping/macroscopes.cpp
+++ cfe/trunk/test/CoverageMapping/macroscopes.cpp
@@ -22,6 +22,17 @@
 #define starts_a_while while (x < 5)
 #define simple_stmt ++x
 
+#define macro_with_for  \
+  x = 3;\
+  for (int i = 0; i < x; ++i) { \
+  }
+
+#define macro_with_while \
+  x = 4; \
+  while (x < 5) {\
+++x; \
+  }
+
 // CHECK: main
 // CHECK-NEXT: File 0, [[@LINE+1]]:12 -> {{[0-9]+}}:2 = #0
 int main() {
@@ -64,6 +75,11 @@
 simple_stmt;
   ends_a_scope
 
+  // CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:17 = #0
+  macro_with_for
+  // CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:19 = #0
+  macro_with_while
+
   return 0;
 }
 
@@ -103,3 +119,10 @@
 // CHECK-NEXT: File 11, 22:31 -> 22:36 = (#0 + #9)
 // CHECK-NEXT: File 12, 23:21 -> 23:24 = #9
 // CHECK-NEXT: File 13, 6:3 -> 7:4 = #9
+// CHECK-NEXT: File 14, 26:3 -> 28:4 = #0
+// CHECK-NEXT: File 14, 27:19 -> 27:24 = (#0 + #10)
+// CHECK-NEXT: File 14, 27:26 -> 27:29 = #10
+// CHECK-NEXT: File 14, 27:31 -> 28:4 = #10
+// CHECK-NEXT: File 15, 31:3 -> 34:4 = #0
+// CHECK-NEXT: File 15, 32:10 -> 32:15 = (#0 + #11)
+// CHECK-NEXT: File 15, 32:17 -> 34:4 = #11
Index: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
===
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
@@ -443,15 +443,31 @@
 return ExitCount;
   }
 
+  /// \brief Check whether a region with bounds \c StartLoc and \c EndLoc
+  /// is already added to \c SourceRegions.
+  bool isRegionAlreadyAdded(SourceLocation StartLoc, SourceLocation EndLoc) {
+return SourceRegions.rend() !=
+   std::find_if(SourceRegions.rbegin(), SourceRegions.rend(),
+[&](const SourceMappingRegion &Region) {
+  return Region.getStartLoc() == StartLoc &&
+ Region.getEndLoc() == EndLoc;
+});
+  }
+
   /// \brief Adjust the most recently visited location to \c EndLoc.
   ///
   /// This should be used after visiting any statements in non-source order.
   void adjustForOutOfOrderTraversal(SourceLocation EndLoc) {
 MostRecentLocation = EndLoc;
-// Avoid adding duplicate regions if we have a completed region on the top
-// of the stack and are adjusting to the end of a virtual file.
+// The code region for a whole macro is created in handleFileExit() when
+// it detects exiting of the virtual file of that macro. If we visited
+// statements in non-source order, we might already have such a region
+// added, for example, if a body of a loop is divided among multiple
+// macros. Avoid adding duplicate regions in such case.
 if (getRegion().hasEndLoc() &&
-MostRecentLocation == getEndOfFileOrMacro(MostRecentLocation))
+MostRecentLocation == getEndOfFileOrMacro(MostRecentLocation) &&
+isRegionAlreadyAdded(getStartOfFileOrMacro(MostRecentLocation),
+ MostRecentLocation))
   MostRecentLocation = getIncludeOrExpansionLoc(MostRecentLocation);
   }
 


Index: cfe/trunk/test/CoverageMapping/macroscopes.cpp
===
--- cfe/trunk/test/CoverageMapping/macroscopes.cpp
+++ cfe/trunk/test/CoverageMapping/macroscopes.cpp
@@ -22,6 +22,17 @@
 #define starts_a_while while (x < 5)
 #define simple_stmt ++x
 
+#define macro_with_for  \
+  x = 3;\
+  for (int i = 0; i < x; ++i) { \
+  }
+
+#define macro_with_while \
+  x = 4; \
+  while (x < 5) {\
+++x; \
+  }
+
 // CHECK: main
 // CHECK-NEXT: File 0, [[@LINE+1]]:12 -> {{[0-9]+}}:2 = #0
 int main() {
@@ -64,6 +75,11 @@
 simple_stmt;
   ends_a_scope
 
+  // CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:17 = #0
+  macro_with_for
+  // CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:19 = #0
+  macro_with_while
+
   return 0;
 }
 
@@ -103,3 +119,10 @@
 // CHECK-NEXT: File 11, 22:31 -> 22:36 = (#0 + #9)
 // CHECK-NEXT: File 12, 23:21 -> 23:24 = #9
 // CHECK-NEXT: File 13, 6:3 -> 7:4 = #9
+// CHECK-NEXT: File 14, 26:3 -> 28:4 = #0
+// CHECK-NEXT: File 14, 27:19 -> 27:24 = (#0 + #10)
+// CHECK-NEXT: File 14, 27:26 -> 27:29 = #10
+// CHECK-NEXT: File 14, 27

Re: [PATCH] D19913: Added static creators that create complete instances of SymbolInfo.

2016-05-04 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: include-fixer/find-all-symbols/SymbolInfo.h:98-101
@@ +97,6 @@
+
+  static SymbolInfo
+  CreateFunctionSymbolInfo(const std::string &Name, const std::string 
&FilePath,
+   const std::vector &Contexts, int 
LineNumber,
+   const FunctionInfo &FuncInfo);
+

hokein wrote:
> However, changing `SymbolInfo` to class requires us to add many 
> setters/getters in it.
> 
> Currently the `SymbolInfo` is like `ClangTidyOptions` structure. 
So, multiple thoughts:
- generally, I think symbol info would better be an immutable type; that would 
mean that we wouldn't have setters, just getters, and initialize everything in 
the constructor
- afaik llvm/clang style  doesn't require accessors just because something is a 
class
- I believe ClangTidyOptions is a very different use case



http://reviews.llvm.org/D19913



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


Re: [PATCH] D19920: [libunwind][ARM] Improve unwinder stack usage on baremetal targets - part 1

2016-05-04 Thread Ben Craig via cfe-commits
bcraig added a subscriber: bcraig.
bcraig added a comment.

> We could, on the other hand, do this tightening for all the supported 
> architectures (for the new, native-only libunwind build suggested by 
> @jroelofs) with appropriate asserts in place so that we maintain these tight 
> bounds as we move forward. Not sure if that effort would be worth though, 
> given that for most non-ARM targets, unwinder stack usage is not a huge 
> concern.


libunwind doesn't currently support Hexagon, but it has been investigated some 
there.  Hexagon would care about stack usage as well.  I wouldn't be surprised 
if some embedded MIPS and Power targets also cared.  I don't think any of those 
targets come close to using 1K for their unwind context.


http://reviews.llvm.org/D19920



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


Re: [PATCH] D19920: [libunwind][ARM] Improve unwinder stack usage on baremetal targets - part 1

2016-05-04 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In http://reviews.llvm.org/D19920#421230, @bcraig wrote:

> > We could, on the other hand, do this tightening for all the supported 
> > architectures (for the new, native-only libunwind build suggested by 
> > @jroelofs) with appropriate asserts in place so that we maintain these 
> > tight bounds as we move forward. Not sure if that effort would be worth 
> > though, given that for most non-ARM targets, unwinder stack usage is not a 
> > huge concern.
>
>
> libunwind doesn't currently support Hexagon, but it has been investigated 
> some there.  Hexagon would care about stack usage as well.  I wouldn't be 
> surprised if some embedded MIPS and Power targets also cared.  I don't think 
> any of those targets come close to using 1K for their unwind context.


Right, in that case, I will do the tightening for all the existing 
architectures. Will add a comment explaining the expected behaviour for future 
changes as well.

Thanks.

/ Asiri


http://reviews.llvm.org/D19920



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


Re: [PATCH] D19412: [libcxx] Refactor pthread usage - II

2016-05-04 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

@mclow.lists, @EricWF: Gentle ping.


http://reviews.llvm.org/D19412



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


Re: [PATCH] D19666: [ubsan] Add -fubsan-strip-path-components=N

2016-05-04 Thread Filipe Cabecinhas via cfe-commits
filcab updated this revision to Diff 56164.
filcab added a comment.

Remove unneeded comments.
Simplify code.


http://reviews.llvm.org/D19666

Files:
  docs/UndefinedBehaviorSanitizer.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGExpr.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/ubsan-strip-path-components.cpp
  test/Driver/fubsan-strip-path-components.cpp

Index: test/Driver/fubsan-strip-path-components.cpp
===
--- /dev/null
+++ test/Driver/fubsan-strip-path-components.cpp
@@ -0,0 +1,2 @@
+// RUN: %clang %s -### -o %t.o -fsanitize-undefined-strip-path-components=42 2>&1 | FileCheck %s
+// CHECK: "-fsanitize-undefined-strip-path-components=42"
Index: test/CodeGen/ubsan-strip-path-components.cpp
===
--- /dev/null
+++ test/CodeGen/ubsan-strip-path-components.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=0 | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=2 | FileCheck %s -check-prefix=REMOVE-FIRST-TWO -check-prefix=CHECK
+
+// Try to strip too much:
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-9 | FileCheck %s -check-prefix=LAST-ONLY
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=9 | FileCheck %s -check-prefix=LAST-ONLY
+
+// Check stripping from the file name
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-2 | FileCheck %s -check-prefix=LAST-TWO
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-1 | FileCheck %s -check-prefix=LAST-ONLY
+
+// REGULAR: @[[SRC:[0-9.a-zA-Z_]+]] =  private unnamed_addr constant [{{.*}} x i8] c"{{.*test.CodeGen.ubsan-strip-path-components\.cpp}}\00", align 1
+
+// REMOVE-FIRST-TWO: @[[STR:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"{{([^\\/]*)?(.[^\\/]+).}}[[REST:.*ubsan-strip-path-components\.cpp]]\00", align 1
+// REMOVE-FIRST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"[[REST]]\00", align 1
+
+// LAST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"CodeGen{{.}}ubsan-strip-path-components.cpp\00", align 1
+// LAST-ONLY: @[[SRC:[0-9.a-zA-Z_]+]] =private unnamed_addr constant [{{.*}} x i8] c"ubsan-strip-path-components.cpp\00", align 1
+
+// CHECK: @[[STATIC_DATA:[0-9.a-zA-Z_]+]] = private unnamed_addr global { { [{{.*}} x i8]*, i32, i32 } } { { [{{.*}} x i8]*, i32, i32 } { [{{.*}} x i8]* @[[SRC]], i32 [[@LINE+6]], i32 3 } }
+void g(const char *);
+void f() {
+  // CHECK-LABEL: @_Z1fv(
+  g(__FILE__);
+  // CHECK: call void @__ubsan_handle_builtin_unreachable(i8* bitcast ({ { [{{.*}} x i8]*, i32, i32 } }* @[[STATIC_DATA]] to i8*)) {{.*}}, !nosanitize
+  __builtin_unreachable();
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -782,6 +782,9 @@
   Opts.CudaGpuBinaryFileNames =
   Args.getAllArgValues(OPT_fcuda_include_gpubinary);
 
+  Opts.EmitCheckPathComponentsToStrip = getLastArgIntValue(
+  Args, OPT_fsanitize_undefined_strip_path_components_EQ, 0, Diags);
+
   return Success;
 }
 
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5595,6 +5595,10 @@
   if (Arg *A = Args.getLastArg(options::OPT_fshow_overloads_EQ))
 A->render(Args, CmdArgs);
 
+  if (Arg *A = Args.getLastArg(
+  options::OPT_fsanitize_undefined_strip_path_components_EQ))
+A->render(Args, CmdArgs);
+
   // -fdollars-in-identifiers default varies depending on platform and
   // language; only pass if specified.
   if (Arg *A = Args.getLastArg(options::OPT_fdollars_in_identifiers,
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -32,6 +32,7 @@
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Transforms/Utils/SanitizerStats.h"
 
 using namespace clang;
@@ -2367,7 +2368,38 @@
 
   PresumedLoc PLoc = getContext().getSourceManager().getPresumedLoc(Loc);
   if (PLoc.isValid()) {
-auto FilenameGV = CGM.GetAddrOfConstantCString(PLoc.getFilename(), ".src");
+StringRef FilenameString = PLoc.getF

[PATCH] D19925: Fixed test not to depend on loop unrolling pass

2016-05-04 Thread Marianne Mailhot-Sarrasin via cfe-commits
mamai created this revision.
mamai added a reviewer: compnerd.
mamai added a subscriber: cfe-commits.
mamai set the repository for this revision to rL LLVM.

This test have been broken by http://reviews.llvm.org/D19827, which re-enables 
loop unrolling at /Os. Since the goal of this test does not seem related 
unrolling, just disabled loop unroll pass when compiling this test.

Repository:
  rL LLVM

http://reviews.llvm.org/D19925

Files:
  test/CodeGenObjCXX/arc-cxx11-init-list.mm

Index: test/CodeGenObjCXX/arc-cxx11-init-list.mm
===
--- test/CodeGenObjCXX/arc-cxx11-init-list.mm
+++ test/CodeGenObjCXX/arc-cxx11-init-list.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple armv7-ios5.0 -std=c++11 -fobjc-arc -Os -emit-llvm 
-o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple armv7-ios5.0 -std=c++11 -fobjc-arc -Os 
-fno-unroll-loops -emit-llvm -o - %s | FileCheck %s
 
 typedef __SIZE_TYPE__ size_t;
 


Index: test/CodeGenObjCXX/arc-cxx11-init-list.mm
===
--- test/CodeGenObjCXX/arc-cxx11-init-list.mm
+++ test/CodeGenObjCXX/arc-cxx11-init-list.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple armv7-ios5.0 -std=c++11 -fobjc-arc -Os -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple armv7-ios5.0 -std=c++11 -fobjc-arc -Os -fno-unroll-loops -emit-llvm -o - %s | FileCheck %s
 
 typedef __SIZE_TYPE__ size_t;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r268523 - Update test CHECK lines after r268509. NFC.

2016-05-04 Thread Pete Cooper via cfe-commits
Author: pete
Date: Wed May  4 12:37:27 2016
New Revision: 268523

URL: http://llvm.org/viewvc/llvm-project?rev=268523&view=rev
Log:
Update test CHECK lines after r268509.  NFC.

r268509 causes this test case to be fully unrolled, so checking for an icmp is
no longer valid.  Given that this test is for ARC anyway, checking for the icmp 
seems
unecessary.

Modified:
cfe/trunk/test/CodeGenObjCXX/arc-cxx11-init-list.mm

Modified: cfe/trunk/test/CodeGenObjCXX/arc-cxx11-init-list.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/arc-cxx11-init-list.mm?rev=268523&r1=268522&r2=268523&view=diff
==
--- cfe/trunk/test/CodeGenObjCXX/arc-cxx11-init-list.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/arc-cxx11-init-list.mm Wed May  4 12:37:27 2016
@@ -31,7 +31,6 @@ extern "C" void multiple() { function({
 // CHECK-NEXT: [[CAST:%.*]] = bitcast [{{[0-9]+}} x %0*]* %{{.*}} to i8**
 // CHECK-NEXT: store i8* [[INSTANCE]], i8** [[CAST]],
 // CHECK: call void @objc_release(i8* {{.*}})
-// CHECK-NEXT: icmp eq
 
 void external();
 


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


Re: [PATCH] D19925: Fixed test not to depend on loop unrolling pass

2016-05-04 Thread Marianne Mailhot-Sarrasin via cfe-commits
mamai abandoned this revision.
mamai added a comment.

The test have been fixed otherwise in rev 268523.


Repository:
  rL LLVM

http://reviews.llvm.org/D19925



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


Re: [PATCH] D19846: [clang-tidy] Lift parsing of sequence of names functions to utils.

2016-05-04 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 56173.
etienneb marked 4 inline comments as done.
etienneb added a comment.

address alexfh comments


http://reviews.llvm.org/D19846

Files:
  clang-tidy/misc/DanglingHandleCheck.cpp
  clang-tidy/misc/SuspiciousStringCompareCheck.cpp
  clang-tidy/performance/FasterStringFindCheck.cpp
  clang-tidy/utils/CMakeLists.txt
  clang-tidy/utils/OptionsUtils.cpp
  clang-tidy/utils/OptionsUtils.h

Index: clang-tidy/utils/OptionsUtils.h
===
--- /dev/null
+++ clang-tidy/utils/OptionsUtils.h
@@ -0,0 +1,31 @@
+//===--- DanglingHandleCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_OPTIONUTILS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_OPTIONUTILS_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace utils {
+namespace options {
+
+/// \brief Parse a semicolon separated list of strings.
+std::vector parseStrings(StringRef Option);
+
+/// \brief Serialize a sequence of names that can be parsed by 'parseStrings'.
+std::string serializeStrings(ArrayRef Strings);
+
+} // namespace options
+} // namespace utils
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_OPTIONUTILS_H
Index: clang-tidy/utils/OptionsUtils.cpp
===
--- /dev/null
+++ clang-tidy/utils/OptionsUtils.cpp
@@ -0,0 +1,38 @@
+//===--- DanglingHandleCheck.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "OptionsUtils.h"
+
+namespace clang {
+namespace tidy {
+namespace utils {
+namespace options {
+
+static const char StringsDelimiter[] = ";";
+
+std::vector parseStrings(StringRef Option) {
+  SmallVector Names;
+  Option.split(Names, StringsDelimiter);
+  std::vector Result;
+  for (StringRef &Name : Names) {
+Name = Name.trim();
+if (!Name.empty())
+  Result.push_back(Name);
+  }
+  return Result;
+}
+
+std::string serializeStrings(ArrayRef Strings) {
+  return llvm::join(Strings.begin(), Strings.end(), StringsDelimiter);
+}
+
+} // namespace options
+} // namespace utils
+} // namespace tidy
+} // namespace clang
Index: clang-tidy/utils/CMakeLists.txt
===
--- clang-tidy/utils/CMakeLists.txt
+++ clang-tidy/utils/CMakeLists.txt
@@ -3,11 +3,12 @@
 add_clang_library(clangTidyUtils
   DeclRefExprUtils.cpp
   FixItHintUtils.cpp
-  HeaderGuard.cpp
   HeaderFileExtensionsUtils.cpp
+  HeaderGuard.cpp
   IncludeInserter.cpp
   IncludeSorter.cpp
   LexerUtils.cpp
+  OptionsUtils.cpp
   TypeTraits.cpp
 
   LINK_LIBS
Index: clang-tidy/performance/FasterStringFindCheck.cpp
===
--- clang-tidy/performance/FasterStringFindCheck.cpp
+++ clang-tidy/performance/FasterStringFindCheck.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 #include "FasterStringFindCheck.h"
+#include "../utils/OptionsUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "llvm/ADT/Optional.h"
@@ -21,20 +22,6 @@
 
 namespace {
 
-static const char StringLikeClassesDelimiter[] = ";";
-
-std::vector ParseClasses(StringRef Option) {
-  SmallVector Classes;
-  Option.split(Classes, StringLikeClassesDelimiter);
-  std::vector Result;
-  for (StringRef &Class : Classes) {
-Class = Class.trim();
-if (!Class.empty())
-  Result.push_back(Class);
-  }
-  return Result;
-}
-
 llvm::Optional MakeCharacterLiteral(const StringLiteral *Literal) {
   std::string Result;
   {
@@ -64,14 +51,13 @@
 FasterStringFindCheck::FasterStringFindCheck(StringRef Name,
  ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
-  StringLikeClasses(
-  ParseClasses(Options.get("StringLikeClasses", "std::basic_string"))) {
+  StringLikeClasses(utils::options::parseStrings(
+  Options.get("StringLikeClasses", "std::basic_string"))) {
 }
 
 void FasterStringFindCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
   Options.store(Opts, "StringLikeClasses",
-llvm::join(StringLikeClasses.begin(), StringLikeClasses.end(),
-   StringLikeClassesDelimiter));
+utils::options::serializeStrings(StringLikeClasses));
 }
 
 void Faste

Re: [PATCH] D19876: Add an AST matcher for string-literal length

2016-05-04 Thread Etienne Bergeron via cfe-commits
etienneb added a comment.

Aaron? could you comment on it?



Comment at: include/clang/ASTMatchers/ASTMatchers.h:1575
@@ +1574,3 @@
+/// \code
+///   char *s = "abcd"; wchar_t *ws = L"abcd";
+///   char *t = "a";

aaron.ballman wrote:
> Split these onto two lines?
If I look around, it seems to be more consistent to keep it on the same line 
(line 1563)

```
///   char *s = "abcd"; wchar_t *ws = L"abcd";
```

```
///   int array[4] = {1}; vector int myvec = (vector int)(1, 2);
```

```
///   char ch = 'a'; wchar_t chw = L'a';
``


Comment at: include/clang/ASTMatchers/ASTMatchers.h:1578
@@ +1577,3 @@
+/// \endcode
+AST_MATCHER_P(StringLiteral, lengthIs, unsigned, N) {
+  return Node.getLength() == N;

etienneb wrote:
> aaron.ballman wrote:
> > Perhaps we can adjust the `hasSize()` matcher instead? It currently works 
> > with ConstantArrayType, but it seems reasonable for it to also work with 
> > StringLiteral.
> I didn't like the term "size" as it typically refer to the size in bytes.
> Which is not the same for a wide-string.
> 
> Now, there is two different convention for naming matchers:
>   hasLength   and  lengthIs  ?
> 
> Any toughs on that?
> 
> 
Here is the matcher for hasSize
```
AST_MATCHER_P(ConstantArrayType, hasSize, unsigned, N) {
  return Node.getSize() == N;
}
```

It's getting the getSize attribute. I believe we should stick with the name of 
the attribute.
But, I'm not sure if we should use hasLength, or lengthIs.


http://reviews.llvm.org/D19876



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


r268527 - [ObjC] Enter a new evaluation context before calling

2016-05-04 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Wed May  4 13:07:20 2016
New Revision: 268527

URL: http://llvm.org/viewvc/llvm-project?rev=268527&view=rev
Log:
[ObjC] Enter a new evaluation context before calling
BuildBlockForLambdaConversion.

Previously, clang would build an incorrect AST for the following code:

id test() {
  return @{@"a": [](){}, @"b": [](){}};
}

ReturnStmt 0x10d080448
`-ExprWithCleanups 0x10d080428
  |-cleanup Block 0x10d0801f0 // points to the second BlockDecl
...
-BlockDecl 0x10d07f150 // First block
...
-BlockDecl 0x10d0801f0 // Second block
...
 `-ExprWithCleanups 0x10d0801d0
   |-cleanup Block 0x10d07f150 // points to the first BlockDecl

To fix the bug, this commit enters a new evaluation context to reset
ExprNeedsCleanups before each block is parsed.

rdar://problem/16879958

Differential Revision: http://reviews.llvm.org/D18815

Added:
cfe/trunk/test/SemaObjCXX/block-cleanup.mm
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=268527&r1=268526&r2=268527&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed May  4 13:07:20 2016
@@ -6229,9 +6229,12 @@ ExprResult Sema::BuildCXXMemberCallExpr(
   // follows the normal lifetime rules for block literals instead of being
   // autoreleased.
   DiagnosticErrorTrap Trap(Diags);
+  PushExpressionEvaluationContext(PotentiallyEvaluated);
   ExprResult Exp = BuildBlockForLambdaConversion(E->getExprLoc(),
  E->getExprLoc(),
  Method, E);
+  PopExpressionEvaluationContext();
+
   if (Exp.isInvalid())
 Diag(E->getExprLoc(), diag::note_lambda_to_block_conv);
   return Exp;

Added: cfe/trunk/test/SemaObjCXX/block-cleanup.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/block-cleanup.mm?rev=268527&view=auto
==
--- cfe/trunk/test/SemaObjCXX/block-cleanup.mm (added)
+++ cfe/trunk/test/SemaObjCXX/block-cleanup.mm Wed May  4 13:07:20 2016
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11.0 -std=gnu++11 -o 
/dev/null -x objective-c++ -fblocks -ast-dump %s 2>&1 | FileCheck %s
+
+// CHECK:  -FunctionDecl {{.*}} test 'id (void)'
+// CHECK-NEXT:   -CompoundStmt
+// CHECK-NEXT: -ReturnStmt
+// CHECK-NEXT:   -ExprWithCleanups
+// CHECK-NEXT: -cleanup Block
+// CHECK-NEXT: -cleanup Block
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys 
count:(unsigned long)cnt;
+@end
+
+id test() {
+  return @{@"a": [](){}, @"b": [](){}};
+}


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


Re: [PATCH] D18815: [ObjC] Enter a new evaluation context before calling BuildBlockForLambdaConversion.

2016-05-04 Thread Akira Hatanaka via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268527: [ObjC] Enter a new evaluation context before calling 
(authored by ahatanak).

Changed prior to commit:
  http://reviews.llvm.org/D18815?vs=56092&id=56178#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18815

Files:
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/test/SemaObjCXX/block-cleanup.mm

Index: cfe/trunk/test/SemaObjCXX/block-cleanup.mm
===
--- cfe/trunk/test/SemaObjCXX/block-cleanup.mm
+++ cfe/trunk/test/SemaObjCXX/block-cleanup.mm
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11.0 -std=gnu++11 -o 
/dev/null -x objective-c++ -fblocks -ast-dump %s 2>&1 | FileCheck %s
+
+// CHECK:  -FunctionDecl {{.*}} test 'id (void)'
+// CHECK-NEXT:   -CompoundStmt
+// CHECK-NEXT: -ReturnStmt
+// CHECK-NEXT:   -ExprWithCleanups
+// CHECK-NEXT: -cleanup Block
+// CHECK-NEXT: -cleanup Block
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys 
count:(unsigned long)cnt;
+@end
+
+id test() {
+  return @{@"a": [](){}, @"b": [](){}};
+}
Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -6229,9 +6229,12 @@
   // follows the normal lifetime rules for block literals instead of being
   // autoreleased.
   DiagnosticErrorTrap Trap(Diags);
+  PushExpressionEvaluationContext(PotentiallyEvaluated);
   ExprResult Exp = BuildBlockForLambdaConversion(E->getExprLoc(),
  E->getExprLoc(),
  Method, E);
+  PopExpressionEvaluationContext();
+
   if (Exp.isInvalid())
 Diag(E->getExprLoc(), diag::note_lambda_to_block_conv);
   return Exp;


Index: cfe/trunk/test/SemaObjCXX/block-cleanup.mm
===
--- cfe/trunk/test/SemaObjCXX/block-cleanup.mm
+++ cfe/trunk/test/SemaObjCXX/block-cleanup.mm
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11.0 -std=gnu++11 -o /dev/null -x objective-c++ -fblocks -ast-dump %s 2>&1 | FileCheck %s
+
+// CHECK:  -FunctionDecl {{.*}} test 'id (void)'
+// CHECK-NEXT:   -CompoundStmt
+// CHECK-NEXT: -ReturnStmt
+// CHECK-NEXT:   -ExprWithCleanups
+// CHECK-NEXT: -cleanup Block
+// CHECK-NEXT: -cleanup Block
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
+@end
+
+id test() {
+  return @{@"a": [](){}, @"b": [](){}};
+}
Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -6229,9 +6229,12 @@
   // follows the normal lifetime rules for block literals instead of being
   // autoreleased.
   DiagnosticErrorTrap Trap(Diags);
+  PushExpressionEvaluationContext(PotentiallyEvaluated);
   ExprResult Exp = BuildBlockForLambdaConversion(E->getExprLoc(),
  E->getExprLoc(),
  Method, E);
+  PopExpressionEvaluationContext();
+
   if (Exp.isInvalid())
 Diag(E->getExprLoc(), diag::note_lambda_to_block_conv);
   return Exp;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19876: Add an AST matcher for string-literal length

2016-05-04 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:1575
@@ +1574,3 @@
+/// \code
+///   char *s = "abcd"; wchar_t *ws = L"abcd";
+///   char *t = "a";

etienneb wrote:
> aaron.ballman wrote:
> > Split these onto two lines?
> If I look around, it seems to be more consistent to keep it on the same line 
> (line 1563)
> 
> ```
> ///   char *s = "abcd"; wchar_t *ws = L"abcd";
> ```
> 
> ```
> ///   int array[4] = {1}; vector int myvec = (vector int)(1, 2);
> ```
> 
> ```
> ///   char ch = 'a'; wchar_t chw = L'a';
> ``
I don't have a strong opinion on it; however, since these get turned into 
examples that are on the website, I would weakly prefer the examples not be 
hideous. :-P


Comment at: include/clang/ASTMatchers/ASTMatchers.h:1578
@@ +1577,3 @@
+/// \endcode
+AST_MATCHER_P(StringLiteral, lengthIs, unsigned, N) {
+  return Node.getLength() == N;

etienneb wrote:
> etienneb wrote:
> > aaron.ballman wrote:
> > > Perhaps we can adjust the `hasSize()` matcher instead? It currently works 
> > > with ConstantArrayType, but it seems reasonable for it to also work with 
> > > StringLiteral.
> > I didn't like the term "size" as it typically refer to the size in bytes.
> > Which is not the same for a wide-string.
> > 
> > Now, there is two different convention for naming matchers:
> >   hasLength   and  lengthIs  ?
> > 
> > Any toughs on that?
> > 
> > 
> Here is the matcher for hasSize
> ```
> AST_MATCHER_P(ConstantArrayType, hasSize, unsigned, N) {
>   return Node.getSize() == N;
> }
> ```
> 
> It's getting the getSize attribute. I believe we should stick with the name 
> of the attribute.
> But, I'm not sure if we should use hasLength, or lengthIs.
I'm not too worried about size vs length (for instance, std::string has both). 
I would imagine this being implemented the same way we do other things with 
variance in API but not concept. See GetBodyMatcher in ASTMatchersInternal.h 
(and others near there) as an example.

I prefer hasSize because the two concepts are quite similar. For instance, a 
string literal's type is of a constant array type already.


http://reviews.llvm.org/D19876



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


Re: [PATCH] D18919: [Clang-tidy] Add check "modernize use using"

2016-05-04 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

In http://reviews.llvm.org/D18919#419902, @curdeius wrote:

> I'm really interested in the manner this check works when a typedef has 
> multiple declarations in it (same example as in the comment):
>
>   typedef int m_int, *m_int_p, &m_int_r, m_int_arr[10], (&m_int_fun)(int, 
> int);
>
>
> I tried to implement such a check once, but this was the hard part. FYI, 
> that's my stub: 
> https://github.com/llvm-mirror/clang-tools-extra/compare/master...mkurdej:feature/use-using.


I don't think that this featcher is necessary. I don't know a lot of code using 
it. I am curious how this check will behave.


Repository:
  rL LLVM

http://reviews.llvm.org/D18919



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


Re: [PATCH] D18919: [Clang-tidy] Add check "modernize use using"

2016-05-04 Thread Aaron Ballman via cfe-commits
On Wed, May 4, 2016 at 2:41 PM, Piotr Padlewski via cfe-commits
 wrote:
> Prazek added a comment.
>
> In http://reviews.llvm.org/D18919#419902, @curdeius wrote:
>
>> I'm really interested in the manner this check works when a typedef has 
>> multiple declarations in it (same example as in the comment):
>>
>>   typedef int m_int, *m_int_p, &m_int_r, m_int_arr[10], (&m_int_fun)(int, 
>> int);
>>
>>
>> I tried to implement such a check once, but this was the hard part. FYI, 
>> that's my stub: 
>> https://github.com/llvm-mirror/clang-tools-extra/compare/master...mkurdej:feature/use-using.
>
>
> I don't think that this featcher is necessary. I don't know a lot of code 
> using it. I am curious how this check will behave.

FWIW, this is a very common pattern in Win32 headers. You most often see it as:

typedef struct _THING {
  // members
} THING, *LPTHING;

You'll also see:

typedef THING THING32, *LPTHING32;

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


Re: [PATCH] D19536: [CodeGenObjCXX] Fix handling of blocks in lambda

2016-05-04 Thread Akira Hatanaka via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268532: [CodeGenObjCXX] Fix handling of blocks in lambda. 
(authored by ahatanak).

Changed prior to commit:
  http://reviews.llvm.org/D19536?vs=56090&id=56183#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19536

Files:
  cfe/trunk/lib/CodeGen/CGBlocks.cpp
  cfe/trunk/test/CodeGenObjCXX/block-nested-in-lambda.cpp

Index: cfe/trunk/test/CodeGenObjCXX/block-nested-in-lambda.cpp
===
--- cfe/trunk/test/CodeGenObjCXX/block-nested-in-lambda.cpp
+++ cfe/trunk/test/CodeGenObjCXX/block-nested-in-lambda.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm -std=c++11 -fblocks -o - %s | FileCheck %s
+
+// CHECK: %[[BLOCK_CAPTURED0:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>, <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>* %[[BLOCK:.*]], i32 0, i32 5
+// CHECK: %[[V0:.*]] = getelementptr inbounds %[[LAMBDA_CLASS:.*]], %[[LAMBDA_CLASS]]* %[[THIS:.*]], i32 0, i32 0
+// CHECK: %[[V1:.*]] = load i32*, i32** %[[V0]], align 8
+// CHECK: store i32* %[[V1]], i32** %[[BLOCK_CAPTURED0]], align 8
+// CHECK: %[[BLOCK_CAPTURED1:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>, <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>* %[[BLOCK]], i32 0, i32 6
+// CHECK: %[[V2:.*]] = getelementptr inbounds %[[LAMBDA_CLASS]], %[[LAMBDA_CLASS]]* %[[THIS]], i32 0, i32 1
+// CHECK: %[[V3:.*]] = load i32*, i32** %[[V2]], align 8
+// CHECK: store i32* %[[V3]], i32** %[[BLOCK_CAPTURED1]], align 8
+
+void foo1(int &, int &);
+
+void block_in_lambda(int &s1, int &s2) {
+  auto lambda = [&s1, &s2]() {
+auto block = ^{
+  foo1(s1, s2);
+};
+block();
+  };
+
+  lambda();
+}
Index: cfe/trunk/lib/CodeGen/CGBlocks.cpp
===
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp
@@ -780,35 +780,34 @@
 // Compute the address of the thing we're going to move into the
 // block literal.
 Address src = Address::invalid();
-if (BlockInfo && CI.isNested()) {
-  // We need to use the capture from the enclosing block.
-  const CGBlockInfo::Capture &enclosingCapture =
-BlockInfo->getCapture(variable);
-
-  // This is a [[type]]*, except that a byref entry wil just be an i8**.
-  src = Builder.CreateStructGEP(LoadBlockStruct(),
-enclosingCapture.getIndex(),
-enclosingCapture.getOffset(),
-"block.capture.addr");
-} else if (blockDecl->isConversionFromLambda()) {
+
+if (blockDecl->isConversionFromLambda()) {
   // The lambda capture in a lambda's conversion-to-block-pointer is
   // special; we'll simply emit it directly.
   src = Address::invalid();
-} else {
-  // Just look it up in the locals map, which will give us back a
-  // [[type]]*.  If that doesn't work, do the more elaborate DRE
-  // emission.
-  auto it = LocalDeclMap.find(variable);
-  if (it != LocalDeclMap.end()) {
-src = it->second;
+} else if (CI.isByRef()) {
+  if (BlockInfo && CI.isNested()) {
+// We need to use the capture from the enclosing block.
+const CGBlockInfo::Capture &enclosingCapture =
+BlockInfo->getCapture(variable);
+
+// This is a [[type]]*, except that a byref entry wil just be an i8**.
+src = Builder.CreateStructGEP(LoadBlockStruct(),
+  enclosingCapture.getIndex(),
+  enclosingCapture.getOffset(),
+  "block.capture.addr");
   } else {
-DeclRefExpr declRef(
-const_cast(variable),
-/*RefersToEnclosingVariableOrCapture*/ CI.isNested(), type,
-VK_LValue, SourceLocation());
-src = EmitDeclRefLValue(&declRef).getAddress();
+auto I = LocalDeclMap.find(variable);
+assert(I != LocalDeclMap.end());
+src = I->second;
   }
-}
+} else {
+  DeclRefExpr declRef(const_cast(variable),
+  /*RefersToEnclosingVariableOrCapture*/ CI.isNested(),
+  type.getNonReferenceType(), VK_LValue,
+  SourceLocation());
+  src = EmitDeclRefLValue(&declRef).getAddress();
+};
 
 // For byrefs, we just write the pointer to the byref struct into
 // the block field.  There's no need to chase the forwarding
@@ -842,8 +841,7 @@
 
 // If it's a reference variable, copy the reference into the block field.
 } else if (type->isReferenceType()) {
-  llvm::Value *ref = Builder.CreateLoad(src, "ref.val");
-  Builder.CreateStore(ref, blockField);
+  Buil

r268532 - [CodeGenObjCXX] Fix handling of blocks in lambda.

2016-05-04 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Wed May  4 13:40:33 2016
New Revision: 268532

URL: http://llvm.org/viewvc/llvm-project?rev=268532&view=rev
Log:
[CodeGenObjCXX] Fix handling of blocks in lambda.

This fixes a crash that occurs when a block captures a reference that is
captured by its enclosing lambda.

rdar://problem/18586651

Differential Revision: http://reviews.llvm.org/D19536

Added:
cfe/trunk/test/CodeGenObjCXX/block-nested-in-lambda.cpp
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=268532&r1=268531&r2=268532&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Wed May  4 13:40:33 2016
@@ -780,35 +780,34 @@ llvm::Value *CodeGenFunction::EmitBlockL
 // Compute the address of the thing we're going to move into the
 // block literal.
 Address src = Address::invalid();
-if (BlockInfo && CI.isNested()) {
-  // We need to use the capture from the enclosing block.
-  const CGBlockInfo::Capture &enclosingCapture =
-BlockInfo->getCapture(variable);
-
-  // This is a [[type]]*, except that a byref entry wil just be an i8**.
-  src = Builder.CreateStructGEP(LoadBlockStruct(),
-enclosingCapture.getIndex(),
-enclosingCapture.getOffset(),
-"block.capture.addr");
-} else if (blockDecl->isConversionFromLambda()) {
+
+if (blockDecl->isConversionFromLambda()) {
   // The lambda capture in a lambda's conversion-to-block-pointer is
   // special; we'll simply emit it directly.
   src = Address::invalid();
-} else {
-  // Just look it up in the locals map, which will give us back a
-  // [[type]]*.  If that doesn't work, do the more elaborate DRE
-  // emission.
-  auto it = LocalDeclMap.find(variable);
-  if (it != LocalDeclMap.end()) {
-src = it->second;
+} else if (CI.isByRef()) {
+  if (BlockInfo && CI.isNested()) {
+// We need to use the capture from the enclosing block.
+const CGBlockInfo::Capture &enclosingCapture =
+BlockInfo->getCapture(variable);
+
+// This is a [[type]]*, except that a byref entry wil just be an i8**.
+src = Builder.CreateStructGEP(LoadBlockStruct(),
+  enclosingCapture.getIndex(),
+  enclosingCapture.getOffset(),
+  "block.capture.addr");
   } else {
-DeclRefExpr declRef(
-const_cast(variable),
-/*RefersToEnclosingVariableOrCapture*/ CI.isNested(), type,
-VK_LValue, SourceLocation());
-src = EmitDeclRefLValue(&declRef).getAddress();
+auto I = LocalDeclMap.find(variable);
+assert(I != LocalDeclMap.end());
+src = I->second;
   }
-}
+} else {
+  DeclRefExpr declRef(const_cast(variable),
+  /*RefersToEnclosingVariableOrCapture*/ CI.isNested(),
+  type.getNonReferenceType(), VK_LValue,
+  SourceLocation());
+  src = EmitDeclRefLValue(&declRef).getAddress();
+};
 
 // For byrefs, we just write the pointer to the byref struct into
 // the block field.  There's no need to chase the forwarding
@@ -842,8 +841,7 @@ llvm::Value *CodeGenFunction::EmitBlockL
 
 // If it's a reference variable, copy the reference into the block field.
 } else if (type->isReferenceType()) {
-  llvm::Value *ref = Builder.CreateLoad(src, "ref.val");
-  Builder.CreateStore(ref, blockField);
+  Builder.CreateStore(src.getPointer(), blockField);
 
 // If this is an ARC __strong block-pointer variable, don't do a
 // block copy.

Added: cfe/trunk/test/CodeGenObjCXX/block-nested-in-lambda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/block-nested-in-lambda.cpp?rev=268532&view=auto
==
--- cfe/trunk/test/CodeGenObjCXX/block-nested-in-lambda.cpp (added)
+++ cfe/trunk/test/CodeGenObjCXX/block-nested-in-lambda.cpp Wed May  4 13:40:33 
2016
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm -std=c++11 
-fblocks -o - %s | FileCheck %s
+
+// CHECK: %[[BLOCK_CAPTURED0:.*]] = getelementptr inbounds <{ i8*, i32, i32, 
i8*, %struct.__block_descriptor*, i32*, i32* }>, <{ i8*, i32, i32, i8*, 
%struct.__block_descriptor*, i32*, i32* }>* %[[BLOCK:.*]], i32 0, i32 5
+// CHECK: %[[V0:.*]] = getelementptr inbounds %[[LAMBDA_CLASS:.*]], 
%[[LAMBDA_CLASS]]* %[[THIS:.*]], i32 0, i32 0
+// CHECK: %[[V1:.*]] = load i32*, i32** %[[V0]], align 8
+// CHECK: store i32* %[[V1]], i32** %[[BLOCK_CAPTURED0]], align 8
+// CHECK: 

Re: [PATCH] D19909: [Attr] Add support for the `ms_hook_prologue` attribute.

2016-05-04 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

Generally, I think this should make use of the patchable function functionality 
from http://reviews.llvm.org/D19046 when lowering, but I do have some comments 
on the attribute itself as well.



Comment at: include/clang/Basic/Attr.td:2032
@@ -2031,1 +2031,3 @@
 
+def MSHookPrologue : InheritableAttr {
+  let Spellings = [GCC<"ms_hook_prologue">];

Does this attribute appertain to all targets, or only targets that MSVC 
supports?


Comment at: include/clang/Basic/Attr.td:2035
@@ +2034,3 @@
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [Undocumented];
+}

Please, no undocumented new attributes.


http://reviews.llvm.org/D19909



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


Re: [PATCH] D19851: Warn on binding reference to null in copy initialization

2016-05-04 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

This generally LGTM, but you should wait for @rsmith to sign off before 
committing.



Comment at: test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp:39
@@ -38,3 +38,3 @@
 
-  bogus_override_if_virtual bogus;
+  bogus_override_if_virtual bogus; // expected-note{{in 
instantiation of member function 'bogus_override_if_virtual<(lambda}}
 }

Yeah, totally not worth it then. Thank you for the explanation.


http://reviews.llvm.org/D19851



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


Re: [PATCH] D19754: Allow 'nodebug' on local variables

2016-05-04 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


http://reviews.llvm.org/D19754



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


Re: [PATCH] D16962: clang-tidy: avoid std::bind

2016-05-04 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/readability/ReadabilityTidyModule.cpp:17
@@ -15,2 +16,2 @@
 #include "ContainerSizeEmptyCheck.h"
 #include "DeletedDefaultCheck.h"

I believe we use "modernize" to really mean "migrate from the old way to the 
new way", which this definitely fits into since I think the point to this check 
is to replace bind with better alternatives.


http://reviews.llvm.org/D16962



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


Re: [PATCH] D19062: Add functions in ctype.h to builtin function database (Fix)

2016-05-04 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D19062#41, @twoh wrote:

> Ping. Can someone please commit this patch for me? Thanks!


Can you rebase the diff on ToT and update the review with the new patch? When I 
try to apply, I get merge conflicts. Thanks!


http://reviews.llvm.org/D19062



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


Re: [Clang] Convergent Attribute

2016-05-04 Thread Aaron Ballman via cfe-commits
On Tue, May 3, 2016 at 12:18 PM, Ettore Speziale
 wrote:
> Hello,
>
> the attached patch introduces the `convergent` attribute.
>
> It is meant to be lowered into the LLVM `convergent` attribute, to restrict 
> optimizations of attributed functions — e.g. you can attach convergent to 
> OpenCL’s barrier, and thus prevent a call site being moved to another 
> position which is not control equivalent.

I would appreciate a bit more background on this attribute's
semantics. How would a user know when to add this attribute to their
function definition? Are there other attributes that cannot be used in
conjunction with this one? Should this apply to member functions? What
about Objective-C methods?

> diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td
> index df41aeb..eafafc6 100644
> --- a/include/clang/Basic/Attr.td
> +++ b/include/clang/Basic/Attr.td
> @@ -580,6 +580,12 @@ def Constructor : InheritableAttr {
>let Documentation = [Undocumented];
>  }
>
> +def Convergent : InheritableAttr {
> +  let Spellings = [GNU<"convergent">];

Is there a reason to not support this under CXX11<"clang",
"convergent"> as well?

> +  let Subjects = SubjectList<[Function]>;
> +  let Documentation = [Undocumented];

Please, no new undocumented attributes.

> +}
> +
>  def CUDAConstant : InheritableAttr {
>let Spellings = [GNU<"constant">];
>let Subjects = SubjectList<[Var]>;
> diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp
> index 50ea7f7..3e69c79 100644
> --- a/lib/CodeGen/CGCall.cpp
> +++ b/lib/CodeGen/CGCall.cpp
> @@ -1626,6 +1626,8 @@ void CodeGenModule::ConstructAttributeList(
>FuncAttrs.addAttribute(llvm::Attribute::NoReturn);
>  if (TargetDecl->hasAttr())
>FuncAttrs.addAttribute(llvm::Attribute::NoDuplicate);
> +if (TargetDecl->hasAttr())
> +  FuncAttrs.addAttribute(llvm::Attribute::Convergent);
>
>  if (const FunctionDecl *Fn = dyn_cast(TargetDecl)) {
>AddAttributesFromFunctionProtoType(
> diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
> index cbc95dc..847ed6c 100644
> --- a/lib/Sema/SemaDeclAttr.cpp
> +++ b/lib/Sema/SemaDeclAttr.cpp
> @@ -5426,6 +5426,9 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, 
> Decl *D,
>case AttributeList::AT_Constructor:
>  handleConstructorAttr(S, D, Attr);
>  break;
> +  case AttributeList::AT_Convergent:
> +handleSimpleAttribute(S, D, Attr);
> +break;
>case AttributeList::AT_CXX11NoReturn:
>  handleSimpleAttribute(S, D, Attr);
>  break;
> diff --git a/test/CodeGen/attr-convergent.c b/test/CodeGen/attr-convergent.c
> new file mode 100644
> index 000..d759e75
> --- /dev/null
> +++ b/test/CodeGen/attr-convergent.c
> @@ -0,0 +1,18 @@
> +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 %s -emit-llvm -o - | 
> FileCheck %s
> +
> +int f0(void) __attribute__((convergent));
> +
> +int f1(void) {
> +  return f0();
> +}
> +
> +// CHECK: define i32 @f1() [[ATTR_1:#[0-9]+]] {
> +// CHECK:   [[RET:%.+]] = call i32 @f0() [[ATTR_CS:#[0-9]+]]
> +// CHECK:   ret i32 [[RET]]
> +// CHECK: }
> +
> +// CHECK: declare i32 @f0() [[ATTR_0:#[0-9]+]]
> +
> +// CHECK-NOT: attributes [[ATTR_1]] = { convergent {{.*}} }
> +// CHECK: attributes [[ATTR_0]] = { convergent {{.*}} }
> +// CHECK: attributes [[ATTR_CS]] = { convergent }
> diff --git a/test/Sema/attr-convergent.c b/test/Sema/attr-convergent.c
> new file mode 100644
> index 000..d9a9db9
> --- /dev/null
> +++ b/test/Sema/attr-convergent.c
> @@ -0,0 +1,7 @@
> +// RUN: %clang_cc1 %s -verify -fsyntax-only
> +
> +int t0 __attribute__((convergent)); // expected-warning {{'convergent' 
> attribute only applies to functions}}
> +
> +void t1() __attribute__((convergent));
> +
> +void t2() __attribute__((convergent(2))); // expected-error {{'convergent' 
> attribute takes no arguments}}
>

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


[PATCH] D19930: [Lifetime] Add lifetime markers for C++ lifetime-extended temporaries

2016-05-04 Thread Tim Shen via cfe-commits
timshen created this revision.
timshen added a reviewer: rsmith.
timshen added a subscriber: cfe-commits.

Use pushCleanupAfterFullExpr to add lifetime.end markers for 
lifetime-extended temporaries, similar to the way destructor calls get 
generated.

It does not change the AST representation. It doesn't generate normal temporary
lifetime markers, since normal temporaries appear in substantially different
places, which could be done in a separate patch.

http://reviews.llvm.org/D19930

Files:
  lib/CodeGen/CGCleanup.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/EHScopeStack.h
  test/CodeGen/lifetime-extended-temporaries.cpp

Index: test/CodeGen/lifetime-extended-temporaries.cpp
===
--- /dev/null
+++ test/CodeGen/lifetime-extended-temporaries.cpp
@@ -0,0 +1,131 @@
+// RUN: %clang_cc1 %s -std=c++11 -O1 -DWITH_DTOR -triple x86_64 -emit-llvm -o - | FileCheck -check-prefix=CHECK-DTOR %s
+// RUN: %clang_cc1 %s -std=c++11 -O1 -triple x86_64 -emit-llvm -o - | FileCheck -check-prefix=CHECK-NO-DTOR %s
+
+struct A {
+  A();
+#ifdef WITH_DTOR
+  ~A();
+#endif
+  char a[1024];
+  operator bool() const;
+};
+
+template 
+void Foo(T &&);
+
+template 
+void Bar(T &&);
+
+template 
+T Baz();
+
+void Test1() {
+  // CHECK-DTOR-LABEL: Test1
+  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR:[0-9]+]])
+  // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
+  // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR]])
+  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR]])
+  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR:[0-9]+]])
+  // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
+  // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR]])
+  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR]])
+  // CHECK-DTOR: }
+
+  // CHECK-NO-DTOR-LABEL: Test1
+  // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR:[0-9]+]])
+  // CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
+  // CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR]])
+  // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR:[0-9]+]])
+  // CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
+  // CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR]])
+  // CHECK-NO-DTOR: }
+  {
+const A &a = A{};
+Foo(a);
+  }
+  {
+const A &a = A{};
+Foo(a);
+  }
+}
+
+void Test2() {
+  // CHECK-DTOR-LABEL: Test2
+  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR1:[0-9]+]])
+  // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR1:[^ ]+]])
+  // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR2:[0-9]+]])
+  // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR2:[^ ]+]])
+  // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR2]])
+  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR2]])
+  // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR1]])
+  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR1]])
+  // CHECK-DTOR: }
+
+  // CHECK-NO-DTOR-LABEL: Test2
+  // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR1:[0-9]+]])
+  // CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR1:[^ ]+]])
+  // CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR2:[0-9]+]])
+  // CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR2:[^ ]+]])
+  // CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR2]])
+  // CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR1]])
+  // CHECK-NO-DTOR: }
+  const A &a = A{};
+  Foo(a);
+  const A &b = A{};
+  Foo(b);
+}
+
+void Test3() {
+  // CHECK-DTOR-LABEL: Test3
+  // CHECK-DTOR: entry:
+  // CHECK-DTOR: call void @llvm.lifetime.start
+  // CHECK-DTOR: call void @llvm.lifetime.start
+  // CHECK-DTOR: if.then:
+  // CHECK-DTOR: call void @llvm.lifetime.end
+  // CHECK-DTOR: cleanup{{.*}}:
+  // CHECK-DTOR: call void @llvm.lifetime.end
+  // CHECK-DTOR: cleanup{{.*}}:
+  // CHECK-DTOR: call void @llvm.lifetime.end
+  // CHECK-DTOR: }
+  const A &a = A{};
+  if (const A &b = A(a)) {
+Foo(b);
+return;
+  }
+  Bar(a);
+}
+
+void Test4() {
+  // CHECK-DTOR-LABEL: Test4
+  // CHECK-DTOR: entry:
+  // CHECK-DTOR: call void @llvm.lifetime.start
+  // CHECK-DTOR: for.cond.cleanup:
+  // CHECK-DTOR: call void @llvm.lifetime.end
+  // CHECK-DTOR: for.body:
+ 

[PATCH] D19932: [OpenCL] Add to_{global|local|private} builtin functions.

2016-05-04 Thread Yaxun Liu via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: Anastasia, pxli168.
yaxunl added subscribers: cfe-commits, tstellarAMD.

OpenCL builtin functions to_{global|local|private} accepts argument of pointer 
type to arbitrary pointee type, and return a pointer to the same pointee type 
in different addr space, i.e.

  global gentype *to_global(gentype *p);

It is not desirable to declare it as

  global void *to_global(void *);

in opencl header file since it misses diagnostics and generates extra bitcasts.

This patch implements these builtin functions as Clang builtin functions. In 
the builtin def file they are defined to have signature void*(void*). When 
handling call expressions, their declarations are re-written to have correct 
parameter type and return type corresponding to the call argument.

http://reviews.llvm.org/D19932

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/Decl.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaExpr.cpp
  test/CodeGenOpenCL/to_addr_builtin.cl
  test/SemaOpenCL/to_addr_builtin.cl

Index: test/SemaOpenCL/to_addr_builtin.cl
===
--- /dev/null
+++ test/SemaOpenCL/to_addr_builtin.cl
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -verify -fsyntax-only -cl-std=CL2.0 %s
+
+void test(void) {
+  global int *glob;
+  local int *loc;
+  constant int *con;
+
+  glob = to_global(glob, loc);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' needs OpenCL version 2.0 or above}}
+#else
+  // expected-error@-4{{invalid number of arguments to function: 'to_global'}}
+#endif
+
+  int x;
+  glob = to_global(x);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' needs OpenCL version 2.0 or above}}
+#else
+  // expected-error@-4{{invalid argument x to function: 'to_global'}}
+#endif
+
+  glob = to_global(con);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' needs OpenCL version 2.0 or above}}
+#else
+  // expected-error@-4{{invalid argument con to function: 'to_global'}}
+#endif
+
+  loc = to_global(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' needs OpenCL version 2.0 or above}}
+#else
+  // expected-error@-4{{assigning '__global int *' to '__local int *' changes address space of pointer}}
+#endif
+
+}
Index: test/CodeGenOpenCL/to_addr_builtin.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/to_addr_builtin.cl
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+
+typedef struct {
+  float x,y,z;
+} A;
+typedef private A *PA;
+typedef global A *GA;
+
+void test(void) {
+  global int *glob;
+  local int *loc;
+  private int *priv;
+  generic int *gen;
+
+  //CHECK: call i32 addrspace(1)* @_Z9to_globalPU3AS1v(i32 addrspace(1)* %{{.*}})
+  glob = to_global(glob);
+  
+  //CHECK: call i32 addrspace(1)* @_Z9to_globalPU3AS3v(i32 addrspace(3)* %{{.*}})
+  glob = to_global(loc);
+ 
+   //CHECK: call i32 addrspace(1)* @_Z9to_globalPv(i32* %{{.*}})
+  glob = to_global(priv);
+ 
+   //CHECK: call i32 addrspace(1)* @_Z9to_globalPU3AS4v(i32 addrspace(4)* %{{.*}})
+  glob = to_global(gen);
+  
+  //CHECK: call i32 addrspace(3)* @_Z8to_localPU3AS1v(i32 addrspace(1)* %{{.*}})
+  loc = to_local(glob);
+
+  //CHECK: call i32 addrspace(3)* @_Z8to_localPU3AS3v(i32 addrspace(3)* %{{.*}})
+  loc = to_local(loc);
+
+  //CHECK: call i32 addrspace(3)* @_Z8to_localPv(i32* %{{.*}})
+  loc = to_local(priv);
+
+  //CHECK: call i32 addrspace(3)* @_Z8to_localPU3AS4v(i32 addrspace(4)* %{{.*}})
+  loc = to_local(gen);
+
+  //CHECK: call i32* @_Z10to_privatePU3AS1v(i32 addrspace(1)* %{{.*}})
+  priv = to_private(glob);
+
+  //CHECK: call i32* @_Z10to_privatePU3AS3v(i32 addrspace(3)* %{{.*}})
+  priv = to_private(loc);
+
+  //CHECK: call i32* @_Z10to_privatePv(i32* %{{.*}})
+  priv = to_private(priv);
+
+  //CHECK: call i32* @_Z10to_privatePU3AS4v(i32 addrspace(4)* %{{.*}})
+  priv = to_private(gen);
+
+  PA pA;
+  GA gA = to_global(pA);
+  };
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -5055,6 +5055,61 @@
   return Callee->getMinRequiredArguments() <= NumArgs;
 }
 
+/// OpenCL to_addr function accepts pointers to arbitrary type as argument.
+/// This function change the original declaration to match the argument.
+/// \return nullptr if this builtin is not OpenCL to_addr builtin function or
+/// there is no need to change the function declaration.
+static FunctionDecl *
+rewriteBuiltinFunctionDeclForOpenCLToAddr(Sema *Sema, ASTContext &Context,
+  const FunctionDecl *FDecl,
+  MultiExprArg ArgExprs) {
+  au

  1   2   >