r270029 - clang-format: [JS] Fix spacing in destructuring assignments.

2016-05-19 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Thu May 19 02:18:07 2016
New Revision: 270029

URL: http://llvm.org/viewvc/llvm-project?rev=270029&view=rev
Log:
clang-format: [JS] Fix spacing in destructuring assignments.

Before:
  const[a, b, c] = [1, 2, 3];

After:
  const [a, b, c] = [1, 2, 3];

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=270029&r1=270028&r2=270029&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu May 19 02:18:07 2016
@@ -2083,7 +2083,7 @@ bool TokenAnnotator::spaceRequiredBefore
 Left.isOneOf(Keywords.kw_function, Keywords.kw_yield))
   return false;
 if (Left.isOneOf(Keywords.kw_let, Keywords.kw_var, Keywords.kw_in,
- Keywords.kw_of) &&
+ Keywords.kw_of, tok::kw_const) &&
 (!Left.Previous || !Left.Previous->is(tok::period)))
   return true;
 if (Left.is(tok::kw_default) && Left.Previous &&

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=270029&r1=270028&r2=270029&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Thu May 19 02:18:07 2016
@@ -148,6 +148,7 @@ TEST_F(FormatTestJS, CppKeywords) {
 
 TEST_F(FormatTestJS, ES6DestructuringAssignment) {
   verifyFormat("var [a, b, c] = [1, 2, 3];");
+  verifyFormat("const [a, b, c] = [1, 2, 3];");
   verifyFormat("let [a, b, c] = [1, 2, 3];");
   verifyFormat("var {a, b} = {a: 1, b: 2};");
   verifyFormat("let {a, b} = {a: 1, b: 2};");


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


Re: [PATCH] D15089: Patch to google checks in clang-tidy

2016-05-19 Thread Haojian Wu via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


Repository:
  rL LLVM

http://reviews.llvm.org/D15089



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


Re: [PATCH] D20370: [include-fixer] Sort headers after inserting new headers.

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

- Passed Headers into IncludeFixerActionFactory so that we can know which 
headers are added.


http://reviews.llvm.org/D20370

Files:
  include-fixer/CMakeLists.txt
  include-fixer/IncludeFixer.cpp
  include-fixer/IncludeFixer.h
  include-fixer/tool/ClangIncludeFixer.cpp
  include-fixer/tool/clang-include-fixer.py
  unittests/include-fixer/IncludeFixerTest.cpp

Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -73,69 +73,71 @@
   SymbolIndexMgr->addSymbolIndex(
   llvm::make_unique(Symbols));
 
+  std::set Headers;
   std::vector Replacements;
-  IncludeFixerActionFactory Factory(*SymbolIndexMgr, Replacements);
+  IncludeFixerActionFactory Factory(*SymbolIndexMgr, Headers, Replacements,
+"llvm");
   runOnCode(&Factory, Code, "input.cc", ExtraArgs);
   clang::RewriterTestContext Context;
   clang::FileID ID = Context.createInMemoryFile("input.cc", Code);
   clang::tooling::applyAllReplacements(Replacements, Context.Rewrite);
   return Context.getRewrittenText(ID);
 }
 
 TEST(IncludeFixer, Typo) {
-  EXPECT_EQ("#include \nstd::string foo;\n",
+  EXPECT_EQ("#include \n\nstd::string foo;\n",
 runIncludeFixer("std::string foo;\n"));
 
   EXPECT_EQ(
-  "// comment\n#include \n#include \"foo.h\"\nstd::string foo;\n"
+  "// comment\n#include \"foo.h\"\n#include \nstd::string foo;\n"
   "#include \"dir/bar.h\"\n",
   runIncludeFixer("// comment\n#include \"foo.h\"\nstd::string foo;\n"
   "#include \"dir/bar.h\"\n"));
 
-  EXPECT_EQ("#include \n#include \"foo.h\"\nstd::string foo;\n",
+  EXPECT_EQ("#include \"foo.h\"\n#include \nstd::string foo;\n",
 runIncludeFixer("#include \"foo.h\"\nstd::string foo;\n"));
 
   EXPECT_EQ(
-  "#include \n#include \"foo.h\"\nstd::string::size_type foo;\n",
+  "#include \"foo.h\"\n#include \nstd::string::size_type foo;\n",
   runIncludeFixer("#include \"foo.h\"\nstd::string::size_type foo;\n"));
 
   // string without "std::" can also be fixed since fixed db results go through
   // SymbolIndexManager, and SymbolIndexManager matches unqualified identifiers
   // too.
-  EXPECT_EQ("#include \nstring foo;\n",
+  EXPECT_EQ("#include \n\nstring foo;\n",
 runIncludeFixer("string foo;\n"));
 }
 
 TEST(IncludeFixer, IncompleteType) {
   EXPECT_EQ(
-  "#include \n#include \"foo.h\"\n"
+  "#include \"foo.h\"\n#include \n"
   "namespace std {\nclass string;\n}\nstring foo;\n",
   runIncludeFixer("#include \"foo.h\"\n"
   "namespace std {\nclass string;\n}\nstring foo;\n"));
 }
 
 TEST(IncludeFixer, MinimizeInclude) {
   std::vector IncludePath = {"-Idir/"};
-  EXPECT_EQ("#include \"otherdir/qux.h\"\na::b::foo bar;\n",
+  EXPECT_EQ("#include \"otherdir/qux.h\"\n\na::b::foo bar;\n",
 runIncludeFixer("a::b::foo bar;\n", IncludePath));
 
   IncludePath = {"-isystemdir"};
-  EXPECT_EQ("#include \na::b::foo bar;\n",
+  EXPECT_EQ("#include \n\na::b::foo bar;\n",
 runIncludeFixer("a::b::foo bar;\n", IncludePath));
 
   IncludePath = {"-iquotedir"};
-  EXPECT_EQ("#include \"otherdir/qux.h\"\na::b::foo bar;\n",
+  EXPECT_EQ("#include \"otherdir/qux.h\"\n\na::b::foo bar;\n",
 runIncludeFixer("a::b::foo bar;\n", IncludePath));
 
   IncludePath = {"-Idir", "-Idir/otherdir"};
-  EXPECT_EQ("#include \"qux.h\"\na::b::foo bar;\n",
+  EXPECT_EQ("#include \"qux.h\"\n\na::b::foo bar;\n",
 runIncludeFixer("a::b::foo bar;\n", IncludePath));
 }
 
 TEST(IncludeFixer, NestedName) {
   // Some tests don't pass for target *-win32.
   std::vector args = {"-target", "x86_64-unknown-unknown"};
-  EXPECT_EQ("#include \"dir/otherdir/qux.h\"\n"
+  EXPECT_EQ("#include \"dir/otherdir/qux.h\"\n\n"
 "int x = a::b::foo(0);\n",
 runIncludeFixer("int x = a::b::foo(0);\n", args));
 
@@ -145,36 +147,52 @@
   EXPECT_EQ("#define FOO(x) a::##x\nint x = FOO(b::foo);\n",
 runIncludeFixer("#define FOO(x) a::##x\nint x = FOO(b::foo);\n"));
 
-  EXPECT_EQ("#include \"dir/otherdir/qux.h\"\n"
+  EXPECT_EQ("#include \"dir/otherdir/qux.h\"\n\n"
 "namespace a {}\nint a = a::b::foo(0);\n",
 runIncludeFixer("namespace a {}\nint a = a::b::foo(0);\n", args));
 }
 
 TEST(IncludeFixer, MultipleMissingSymbols) {
-  EXPECT_EQ("#include \nstd::string bar;\nstd::sting foo;\n",
+  EXPECT_EQ("#include \n\nstd::string bar;\nstd::sting foo;\n",
 runIncludeFixer("std::string bar;\nstd::sting foo;\n"));
 }
 
 TEST(IncludeFixer, ScopedNamespaceSymbols) {
-  EXPECT_EQ("#include \"bar.h\"\nnamespace a { b::bar b; }\n",
-runIncludeFixer("namespace a { b::bar b; }\n"));
-  EXPECT_EQ("#include \"bar.h\"\nnamespace A { a::b::bar b; }\n",
-   

Re: [PATCH] D20370: [include-fixer] Sort headers after inserting new headers.

2016-05-19 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lgtm


http://reviews.llvm.org/D20370



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


[clang-tools-extra] r270031 - [include-fixer] Sort headers after inserting new headers.

2016-05-19 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu May 19 03:21:09 2016
New Revision: 270031

URL: http://llvm.org/viewvc/llvm-project?rev=270031&view=rev
Log:
[include-fixer] Sort headers after inserting new headers.

Summary: [include-fixer] Sort headers after inserting new headers.

Reviewers: bkramer

Subscribers: klimek, djasper, hokein, cfe-commits

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

Modified:
clang-tools-extra/trunk/include-fixer/CMakeLists.txt
clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
clang-tools-extra/trunk/include-fixer/IncludeFixer.h
clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py
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=270031&r1=270030&r2=270031&view=diff
==
--- clang-tools-extra/trunk/include-fixer/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/include-fixer/CMakeLists.txt Thu May 19 03:21:09 
2016
@@ -11,6 +11,7 @@ add_clang_library(clangIncludeFixer
   LINK_LIBS
   clangAST
   clangBasic
+  clangFormat
   clangFrontend
   clangLex
   clangParse

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=270031&r1=270030&r2=270031&view=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Thu May 19 03:21:09 
2016
@@ -8,6 +8,7 @@
 
//===--===//
 
 #include "IncludeFixer.h"
+#include "clang/Format/Format.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/Preprocessor.h"
@@ -58,8 +59,9 @@ private:
 class Action : public clang::ASTFrontendAction,
public clang::ExternalSemaSource {
 public:
-  explicit Action(SymbolIndexManager &SymbolIndexMgr, bool 
MinimizeIncludePaths)
-  : SymbolIndexMgr(SymbolIndexMgr),
+  explicit Action(SymbolIndexManager &SymbolIndexMgr, StringRef StyleName,
+  bool MinimizeIncludePaths)
+  : SymbolIndexMgr(SymbolIndexMgr), FallbackStyle(StyleName),
 MinimizeIncludePaths(MinimizeIncludePaths) {}
 
   std::unique_ptr
@@ -234,26 +236,61 @@ public:
 return IsSystem ? '<' + Suggestion + '>' : '"' + Suggestion + '"';
   }
 
+  /// Insert all headers before the first #include in \p Code and run
+  /// clang-format to sort all headers.
+  /// \return Replacements for inserting and sorting headers.
+  std::vector
+  CreateReplacementsForHeaders(StringRef Code,
+   const std::set &Headers) {
+std::set ExistingHeaders;
+
+// Create replacements for new headers.
+clang::tooling::Replacements Insertions;
+if (FirstIncludeOffset == -1U) {
+  // FIXME: skip header guards.
+  FirstIncludeOffset = 0;
+  // If there is no existing #include, then insert an empty line after new
+  // header block.
+  if (Code.front() != '\n')
+Insertions.insert(
+clang::tooling::Replacement(Filename, FirstIncludeOffset, 0, 
"\n"));
+}
+// Keep inserting new headers before the first header.
+for (StringRef Header : Headers) {
+  std::string Text = "#include " + Header.str() + "\n";
+  Insertions.insert(
+  clang::tooling::Replacement(Filename, FirstIncludeOffset, 0, Text));
+}
+DEBUG(llvm::dbgs() << "Header insertions:\n");
+for (const auto &R : Insertions) {
+  DEBUG(llvm::dbgs() << R.toString() << "\n");
+}
+
+clang::format::FormatStyle Style =
+clang::format::getStyle("file", Filename, FallbackStyle);
+clang::tooling::Replacements Replaces =
+formatReplacements(Code, Insertions, Style);
+// FIXME: remove this when `clang::tooling::Replacements` is implemented as
+// `std::vector`.
+std::vector Results;
+std::copy(Replaces.begin(), Replaces.end(), std::back_inserter(Results));
+return Results;
+  }
+
   /// Generate replacements for the suggested includes.
   /// \return true if changes will be made, false otherwise.
   bool Rewrite(clang::SourceManager &SourceManager,
clang::HeaderSearch &HeaderSearch,
-   std::vector &replacements) {
+   std::set &Headers,
+   std::vector &Replacements) {
 if (Untried.empty())
   return false;
 
 const auto &ToTry = UntriedList.front();
-std::string ToAdd = "#include " +
-minimizeInclude(ToTry, SourceManager, HeaderSearch) +
-"\n";
-DEBUG(llvm::dbgs() << "Adding " <

Re: [PATCH] D20370: [include-fixer] Sort headers after inserting new headers.

2016-05-19 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270031: [include-fixer] Sort headers after inserting new 
headers. (authored by ioeric).

Changed prior to commit:
  http://reviews.llvm.org/D20370?vs=57745&id=57746#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20370

Files:
  clang-tools-extra/trunk/include-fixer/CMakeLists.txt
  clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
  clang-tools-extra/trunk/include-fixer/IncludeFixer.h
  clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
  clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py
  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
@@ -70,69 +70,71 @@
   SymbolIndexMgr->addSymbolIndex(
   llvm::make_unique(Symbols));
 
+  std::set Headers;
   std::vector Replacements;
-  IncludeFixerActionFactory Factory(*SymbolIndexMgr, Replacements);
+  IncludeFixerActionFactory Factory(*SymbolIndexMgr, Headers, Replacements,
+"llvm");
   runOnCode(&Factory, Code, "input.cc", ExtraArgs);
   clang::RewriterTestContext Context;
   clang::FileID ID = Context.createInMemoryFile("input.cc", Code);
   clang::tooling::applyAllReplacements(Replacements, Context.Rewrite);
   return Context.getRewrittenText(ID);
 }
 
 TEST(IncludeFixer, Typo) {
-  EXPECT_EQ("#include \nstd::string foo;\n",
+  EXPECT_EQ("#include \n\nstd::string foo;\n",
 runIncludeFixer("std::string foo;\n"));
 
   EXPECT_EQ(
-  "// comment\n#include \n#include \"foo.h\"\nstd::string foo;\n"
+  "// comment\n#include \"foo.h\"\n#include \nstd::string foo;\n"
   "#include \"dir/bar.h\"\n",
   runIncludeFixer("// comment\n#include \"foo.h\"\nstd::string foo;\n"
   "#include \"dir/bar.h\"\n"));
 
-  EXPECT_EQ("#include \n#include \"foo.h\"\nstd::string foo;\n",
+  EXPECT_EQ("#include \"foo.h\"\n#include \nstd::string foo;\n",
 runIncludeFixer("#include \"foo.h\"\nstd::string foo;\n"));
 
   EXPECT_EQ(
-  "#include \n#include \"foo.h\"\nstd::string::size_type foo;\n",
+  "#include \"foo.h\"\n#include \nstd::string::size_type foo;\n",
   runIncludeFixer("#include \"foo.h\"\nstd::string::size_type foo;\n"));
 
   // string without "std::" can also be fixed since fixed db results go through
   // SymbolIndexManager, and SymbolIndexManager matches unqualified identifiers
   // too.
-  EXPECT_EQ("#include \nstring foo;\n",
+  EXPECT_EQ("#include \n\nstring foo;\n",
 runIncludeFixer("string foo;\n"));
 }
 
 TEST(IncludeFixer, IncompleteType) {
   EXPECT_EQ(
-  "#include \n#include \"foo.h\"\n"
+  "#include \"foo.h\"\n#include \n"
   "namespace std {\nclass string;\n}\nstring foo;\n",
   runIncludeFixer("#include \"foo.h\"\n"
   "namespace std {\nclass string;\n}\nstring foo;\n"));
 }
 
 TEST(IncludeFixer, MinimizeInclude) {
   std::vector IncludePath = {"-Idir/"};
-  EXPECT_EQ("#include \"otherdir/qux.h\"\na::b::foo bar;\n",
+  EXPECT_EQ("#include \"otherdir/qux.h\"\n\na::b::foo bar;\n",
 runIncludeFixer("a::b::foo bar;\n", IncludePath));
 
   IncludePath = {"-isystemdir"};
-  EXPECT_EQ("#include \na::b::foo bar;\n",
+  EXPECT_EQ("#include \n\na::b::foo bar;\n",
 runIncludeFixer("a::b::foo bar;\n", IncludePath));
 
   IncludePath = {"-iquotedir"};
-  EXPECT_EQ("#include \"otherdir/qux.h\"\na::b::foo bar;\n",
+  EXPECT_EQ("#include \"otherdir/qux.h\"\n\na::b::foo bar;\n",
 runIncludeFixer("a::b::foo bar;\n", IncludePath));
 
   IncludePath = {"-Idir", "-Idir/otherdir"};
-  EXPECT_EQ("#include \"qux.h\"\na::b::foo bar;\n",
+  EXPECT_EQ("#include \"qux.h\"\n\na::b::foo bar;\n",
 runIncludeFixer("a::b::foo bar;\n", IncludePath));
 }
 
 TEST(IncludeFixer, NestedName) {
   // Some tests don't pass for target *-win32.
   std::vector args = {"-target", "x86_64-unknown-unknown"};
-  EXPECT_EQ("#include \"dir/otherdir/qux.h\"\n"
+  EXPECT_EQ("#include \"dir/otherdir/qux.h\"\n\n"
 "int x = a::b::foo(0);\n",
 runIncludeFixer("int x = a::b::foo(0);\n", args));
 
@@ -142,36 +144,52 @@
   EXPECT_EQ("#define FOO(x) a::##x\nint x = FOO(b::foo);\n",
 runIncludeFixer("#define FOO(x) a::##x\nint x = FOO(b::foo);\n"));
 
-  EXPECT_EQ("#include \"dir/otherdir/qux.h\"\n"
+  EXPECT_EQ("#include \"dir/otherdir/qux.h\"\n\n"
 "namespace a {}\nint a = a::b::foo(0);\n",
 runIncludeFixer("namespace a {}\nint a = a::b::foo(0);\n", args));
 }
 
 TEST(IncludeFixer, MultipleMissingSymbols) {
-  EXPECT_EQ("#include \nstd::string bar;\nstd::sting foo;\n",
+  EXPECT_EQ("#include \n\nstd::string bar;\nstd:

Re: [clang-tools-extra] r261991 - [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.

2016-05-19 Thread Edoardo P. via cfe-commits
Is it possible to port this commit to 3.8.1?

Cheers,
Edward-san

2016-02-26 10:19 GMT+01:00 Haojian Wu via cfe-commits
:
> Author: hokein
> Date: Fri Feb 26 03:19:33 2016
> New Revision: 261991
>
> URL: http://llvm.org/viewvc/llvm-project?rev=261991&view=rev
> Log:
> [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.
>
> Summary:
> The clang-tidy will trigger an assertion if it's not in the building 
> directory.
>
> TEST:
> cd /
> ./build/bin/clang-tidy --checks=-*,modernize-use-nullptr -p build 
> tools/clang/tools/extra/clang-tidy/ClangTidy.cpp
>
> The crash issue is gone after applying this patch.
>
> Fixes PR24834, PR26241
>
> Reviewers: bkramer, alexfh
>
> Subscribers: rizsotto.mailinglist, cfe-commits
>
> Differential Revision: http://reviews.llvm.org/D17335
>
> Added:
> clang-tools-extra/trunk/test/clang-tidy/Inputs/compilation-database/
> 
> clang-tools-extra/trunk/test/clang-tidy/Inputs/compilation-database/template.json
> clang-tools-extra/trunk/test/clang-tidy/clang-tidy-run-with-database.cpp
> Modified:
> clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
> clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
> clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
>
> Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=261991&r1=261990&r2=261991&view=diff
> ==
> --- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
> +++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Fri Feb 26 03:19:33 2016
> @@ -107,6 +107,10 @@ public:
>  DiagPrinter->BeginSourceFile(LangOpts);
>}
>
> +  SourceManager& getSourceManager() {
> +return SourceMgr;
> +  }
> +
>void reportDiagnostic(const ClangTidyError &Error) {
>  const ClangTidyMessage &Message = Error.Message;
>  SourceLocation Loc = getLocation(Message.FilePath, Message.FileOffset);
> @@ -124,7 +128,10 @@ public:
>auto Diag = Diags.Report(Loc, Diags.getCustomDiagID(Level, "%0 [%1]"))
><< Message.Message << Name;
>for (const tooling::Replacement &Fix : Error.Fix) {
> -SourceLocation FixLoc = getLocation(Fix.getFilePath(), 
> Fix.getOffset());
> +SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
> +Files.makeAbsolutePath(FixAbsoluteFilePath);
> +SourceLocation FixLoc =
> +getLocation(FixAbsoluteFilePath, Fix.getOffset());
>  SourceLocation FixEndLoc = FixLoc.getLocWithOffset(Fix.getLength());
>  Diag << FixItHint::CreateReplacement(SourceRange(FixLoc, FixEndLoc),
>   Fix.getReplacementText());
> @@ -232,6 +239,13 @@ ClangTidyASTConsumerFactory::CreateASTCo
>Context.setCurrentFile(File);
>Context.setASTContext(&Compiler.getASTContext());
>
> +  auto WorkingDir = Compiler.getSourceManager()
> +.getFileManager()
> +.getVirtualFileSystem()
> +->getCurrentWorkingDirectory();
> +  if (WorkingDir)
> +Context.setCurrentBuildDirectory(WorkingDir.get());
> +
>std::vector> Checks;
>CheckFactories->createChecks(&Context, Checks);
>
> @@ -446,8 +460,24 @@ runClangTidy(std::unique_ptr  void handleErrors(const std::vector &Errors, bool Fix,
>unsigned &WarningsAsErrorsCount) {
>ErrorReporter Reporter(Fix);
> -  for (const ClangTidyError &Error : Errors)
> +  vfs::FileSystem &FileSystem =
> +  *Reporter.getSourceManager().getFileManager().getVirtualFileSystem();
> +  auto InitialWorkingDir = FileSystem.getCurrentWorkingDirectory();
> +  if (!InitialWorkingDir)
> +llvm::report_fatal_error("Cannot get current working path.");
> +
> +  for (const ClangTidyError &Error : Errors) {
> +if (!Error.BuildDirectory.empty()) {
> +  // By default, the working directory of file system is the current
> +  // clang-tidy running directory.
> +  //
> +  // Change the directory to the one used during the analysis.
> +  FileSystem.setCurrentWorkingDirectory(Error.BuildDirectory);
> +}
>  Reporter.reportDiagnostic(Error);
> +// Return to the initial directory to correctly resolve next Error.
> +FileSystem.setCurrentWorkingDirectory(InitialWorkingDir.get());
> +  }
>Reporter.Finish();
>WarningsAsErrorsCount += Reporter.getWarningsAsErrorsCount();
>  }
>
> Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=261991&r1=261990&r2=261991&view=diff
> ==
> --- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/ClangTid

Re: [PATCH] D15089: Patch to google checks in clang-tidy

2016-05-19 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

As Eugene noted, the patch is seriously out of date. The only place where an 
old URL is still used, is docs/clang-tidy/checks/google-runtime-int.rst. 
However, we should check if style guide links can be added for other checks.


Repository:
  rL LLVM

http://reviews.llvm.org/D15089



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


[PATCH] D20419: [Sparc] Add software float option -msoft-float

2016-05-19 Thread Jacob Baungard Hansen via cfe-commits
jacob_hansen created this revision.
jacob_hansen added reviewers: jyknight, lero_chris.
jacob_hansen added a subscriber: cfe-commits.
Herald added a subscriber: jyknight.

Following patch D19265 which enable software floating point support in the 
Sparc backend, this patch enables the option to be enabled in the front-end 
using the -msoft-float option.

The user should ensure a library (such as the builtins from Compiler-RT) that 
includes the software floating point routines is provided.

http://reviews.llvm.org/D20419

Files:
  lib/Basic/Targets.cpp
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h
  test/CodeGen/function-target-features.c
  test/Driver/sparc-float.c

Index: test/Driver/sparc-float.c
===
--- test/Driver/sparc-float.c
+++ test/Driver/sparc-float.c
@@ -18,7 +18,25 @@
 // RUN: %clang -c %s -### -o %t.o 2>&1 \
 // RUN: -target sparc-linux-gnu -msoft-float \
 // RUN:   | FileCheck --check-prefix=CHECK-SOFT %s
-// CHECK-SOFT: error: unsupported option '-msoft-float'
+// CHECK-SOFT: "-target-feature" "+soft-float"
+//
+// -mfloat-abi=soft
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target sparc-linux-gnu -mfloat-abi=soft \
+// RUN:   | FileCheck --check-prefix=CHECK-FLOATABISOFT %s
+// CHECK-FLOATABISOFT: "-target-feature" "+soft-float"
+//
+// -mfloat-abi=hard
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target sparc-linux-gnu -mfloat-abi=hard \
+// RUN:   | FileCheck --check-prefix=CHECK-FLOATABIHARD %s
+// CHECK-FLOATABIHARD-NOT: "-target-feature" "+soft-float"
+//
+// check invalid -mfloat-abi
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target sparc-linux-gnu -mfloat-abi=x \
+// RUN:   | FileCheck --check-prefix=CHECK-ERRMSG %s
+// CHECK-ERRMSG: error: invalid float ABI '-mfloat-abi=x'
 //
 // Default sparc64
 // RUN: %clang -c %s -### -o %t.o 2>&1 \
@@ -37,4 +55,22 @@
 // RUN: %clang -c %s -### -o %t.o 2>&1 \
 // RUN: -target sparc64-linux-gnu -msoft-float \
 // RUN:   | FileCheck --check-prefix=CHECK-SOFT-SPARC64 %s
-// CHECK-SOFT-SPARC64: error: unsupported option '-msoft-float'
+// CHECK-SOFT-SPARC64: "-target-feature" "+soft-float"
+//
+// -mfloat-abi=soft
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target sparc64-linux-gnu -mfloat-abi=soft \
+// RUN:   | FileCheck --check-prefix=CHECK-FLOATABISOFT64 %s
+// CHECK-FLOATABISOFT64: "-target-feature" "+soft-float"
+//
+// -mfloat-abi=hard
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target sparc64-linux-gnu -mfloat-abi=hard \
+// RUN:   | FileCheck --check-prefix=CHECK-FLOATABIHARD64 %s
+// CHECK-FLOATABIHARD64-NOT: "-target-feature" "+soft-float"
+//
+// check invalid -mfloat-abi
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target sparc64-linux-gnu -mfloat-abi=x \
+// RUN:   | FileCheck --check-prefix=CHECK-ERRMSG64 %s
+// CHECK-ERRMSG64: error: invalid float ABI '-mfloat-abi=x'
Index: test/CodeGen/function-target-features.c
===
--- test/CodeGen/function-target-features.c
+++ test/CodeGen/function-target-features.c
@@ -9,7 +9,6 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-cpu corei7 -target-feature +avx | FileCheck %s -check-prefix=CORE-CPU-AND-FEATURES
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-cpu x86-64 | FileCheck %s -check-prefix=X86-64-CPU
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-cpu corei7-avx -target-feature -avx | FileCheck %s -check-prefix=AVX-MINUS-FEATURE
-// RUN: %clang_cc1 -triple sparc-unknown-unknown -emit-llvm -o - %s -target-feature +soft-float | FileCheck %s -check-prefix=NO-SOFT-FLOAT
 // RUN: %clang_cc1 -triple arm-unknown-unknown -emit-llvm -o - %s -target-feature +soft-float | FileCheck %s -check-prefix=SOFT-FLOAT
 // RUN: %clang_cc1 -triple mips-unknown-unknown -emit-llvm -o - %s -target-feature +soft-float | FileCheck %s -check-prefix=SOFT-FLOAT
 
@@ -23,4 +22,3 @@
 // X86-64-CPU: "target-cpu"="x86-64"
 // AVX-MINUS-FEATURE: "target-features"={{.*}}-avx
 // SOFT-FLOAT: "target-features"={{.*}}+soft-float
-// NO-SOFT-FLOAT-NOT: "target-features"={{.*}}+soft-float
Index: lib/Driver/Tools.h
===
--- lib/Driver/Tools.h
+++ lib/Driver/Tools.h
@@ -777,6 +777,16 @@
 FloatABI getPPCFloatABI(const Driver &D, const llvm::opt::ArgList &Args);
 } // end namespace ppc
 
+namespace sparc {
+enum class FloatABI {
+  Invalid,
+  Soft,
+  Hard,
+};
+
+FloatABI getSparcFloatABI(const Driver &D, const llvm::opt::ArgList &Args);
+} // end namespace sparc
+
 namespace XCore {
 // For XCore, we do not need to instantiate tools for PreProcess, PreCompile and
 // Compile.
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -1640,26 +1640,65 @@
   return "";
 }
 
-void Clang::Add

[clang-tools-extra] r270032 - [clang-tidy] Fix doc titles.

2016-05-19 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu May 19 04:29:46 2016
New Revision: 270032

URL: http://llvm.org/viewvc/llvm-project?rev=270032&view=rev
Log:
[clang-tidy] Fix doc titles.

Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-references.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-incorrect-roundings.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-virtual-near-miss.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/performance-implicit-cast-in-loop.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-references.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-references.rst?rev=270032&r1=270031&r2=270032&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-references.rst 
(original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-references.rst 
Thu May 19 04:29:46 2016
@@ -1,3 +1,5 @@
+.. title:: clang-tidy - google-runtime-references
+
 google-runtime-references
 =
 

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst?rev=270032&r1=270031&r2=270032&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst 
(original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst 
Thu May 19 04:29:46 2016
@@ -1,3 +1,5 @@
+.. title:: clang-tidy - misc-definitions-in-headers
+
 misc-definitions-in-headers
 ===
 

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-incorrect-roundings.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-incorrect-roundings.rst?rev=270032&r1=270031&r2=270032&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-incorrect-roundings.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-incorrect-roundings.rst 
Thu May 19 04:29:46 2016
@@ -1,3 +1,5 @@
+.. title:: clang-tidy - misc-incorrect-roundings
+
 misc-incorrect-roundings
 
 

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-virtual-near-miss.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-virtual-near-miss.rst?rev=270032&r1=270031&r2=270032&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-virtual-near-miss.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-virtual-near-miss.rst 
Thu May 19 04:29:46 2016
@@ -1,7 +1,10 @@
+.. title:: clang-tidy - misc-virtual-near-miss
+
 misc-virtual-near-miss
 ==
 
-Warn if a function is a near miss (ie. the name is very similar and the 
function signiture is the same) to a virtual function from a base class.
+Warn if a function is a near miss (ie. the name is very similar and the 
function
+signiture is the same) to a virtual function from a base class.
 
 Example:
 

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/performance-implicit-cast-in-loop.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/performance-implicit-cast-in-loop.rst?rev=270032&r1=270031&r2=270032&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/performance-implicit-cast-in-loop.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/performance-implicit-cast-in-loop.rst
 Thu May 19 04:29:46 2016
@@ -1,3 +1,5 @@
+.. title:: clang-tidy - performance-implicit-cast-in-loop
+
 performance-implicit-cast-in-loop
 =
 


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


[clang-tools-extra] r270033 - [clang-tidy] Fix/add style guide links.

2016-05-19 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu May 19 04:31:30 2016
New Revision: 270033

URL: http://llvm.org/viewvc/llvm-project?rev=270033&view=rev
Log:
[clang-tidy] Fix/add style guide links.

Thanks to Tim Halloran for the initial patch (http://reviews.llvm.org/D15089)!

Modified:
clang-tools-extra/trunk/clang-tidy/google/GlobalNamesInHeadersCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/google-global-names-in-headers.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-todo.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-int.rst

Modified: clang-tools-extra/trunk/clang-tidy/google/GlobalNamesInHeadersCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/GlobalNamesInHeadersCheck.h?rev=270033&r1=270032&r2=270033&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/google/GlobalNamesInHeadersCheck.h 
(original)
+++ clang-tools-extra/trunk/clang-tidy/google/GlobalNamesInHeadersCheck.h Thu 
May 19 04:31:30 2016
@@ -23,7 +23,7 @@ namespace readability {
 ///
 /// The check supports these options:
 ///   - `HeaderFileExtensions`: a comma-separated list of filename extensions
-/// of header files (The filename extensions should not contain "." 
prefix).
+/// of header files (the filename extensions should not contain "." 
prefix).
 /// "h" by default.
 /// For extension-less header files, using an empty string or leaving an
 /// empty string between "," if there are other filename extensions.

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/google-global-names-in-headers.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/google-global-names-in-headers.rst?rev=270033&r1=270032&r2=270033&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/google-global-names-in-headers.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/google-global-names-in-headers.rst
 Thu May 19 04:31:30 2016
@@ -5,3 +5,13 @@ google-global-names-in-headers
 
 Flag global namespace pollution in header files.
 Right now it only triggers on ``using`` declarations and directives.
+
+The check supports these options:
+  - `HeaderFileExtensions`: a comma-separated list of filename extensions
+of header files (the filename extensions should not contain "." prefix).
+"h" by default.
+For extension-less header files, using an empty string or leaving an
+empty string between "," if there are other filename extensions.
+
+The relevant style guide section is
+https://google.github.io/styleguide/cppguide.html#Namespaces.

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-todo.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-todo.rst?rev=270033&r1=270032&r2=270033&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-todo.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-todo.rst 
Thu May 19 04:31:30 2016
@@ -5,4 +5,7 @@ google-readability-todo
 
 Finds TODO comments without a username or bug number.
 
+The relevant style guide section is
+https://google.github.io/styleguide/cppguide.html#TODO_Comments.
+
 Corresponding cpplint.py check: `readability/todo`

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-int.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-int.rst?rev=270033&r1=270032&r2=270033&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-int.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-int.rst Thu 
May 19 04:31:30 2016
@@ -7,6 +7,6 @@ Finds uses of ``short``, ``long`` and ``
 with ``u?intXX(_t)?``.
 
 The corresponding style guide rule:
-https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Integer_Types.
+https://google.github.io/styleguide/cppguide.html#Integer_Types.
 
 Correspondig cpplint.py check: `runtime/int`.


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


Re: [PATCH] D15089: Patch to google checks in clang-tidy

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

Anyways, committed all useful changes from here in r270033. Thank you for the 
patch!


Repository:
  rL LLVM

http://reviews.llvm.org/D15089



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


[PATCH] D20420: [find-all-symbol] Add macro support.

2016-05-19 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: bkramer.
hokein added subscribers: ioeric, cfe-commits.

http://reviews.llvm.org/D20420

Files:
  include-fixer/find-all-symbols/CMakeLists.txt
  include-fixer/find-all-symbols/FindAllMacros.cpp
  include-fixer/find-all-symbols/FindAllMacros.h
  include-fixer/find-all-symbols/FindAllSymbols.cpp
  include-fixer/find-all-symbols/FindAllSymbols.h
  include-fixer/find-all-symbols/SymbolInfo.cpp
  include-fixer/find-all-symbols/SymbolInfo.h
  include-fixer/find-all-symbols/SymbolReporter.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
@@ -7,10 +7,12 @@
 //
 //===--===//
 
+#include "FindAllMacros.h"
 #include "FindAllSymbols.h"
 #include "HeaderMapCollector.h"
 #include "PragmaCommentHandler.h"
 #include "SymbolInfo.h"
+#include "SymbolReporter.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemOptions.h"
@@ -31,17 +33,16 @@
 
 static const char HeaderName[] = "symbols.h";
 
-class MockReporter
-: public clang::find_all_symbols::FindAllSymbols::ResultReporter {
+class TestSymbolReporter : public clang::find_all_symbols::SymbolReporter {
 public:
-  ~MockReporter() override {}
+  ~TestSymbolReporter() override {}
 
-  void reportResult(llvm::StringRef FileName,
+  void reportSymbol(llvm::StringRef FileName,
 const SymbolInfo &Symbol) override {
 Symbols.push_back(Symbol);
   }
 
-  bool hasSymbol(const SymbolInfo &Symbol) {
+  bool hasSymbol(const SymbolInfo &Symbol) const {
 for (const auto &S : Symbols) {
   if (S == Symbol)
 return true;
@@ -55,20 +56,23 @@
 
 class TestFindAllSymbolsAction : public clang::ASTFrontendAction {
 public:
-  TestFindAllSymbolsAction(FindAllSymbols::ResultReporter *Reporter)
-  : MatchFinder(), Collector(), Handler(&Collector),
+  TestFindAllSymbolsAction(SymbolReporter *Reporter)
+  : Reporter(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);
+Compiler.getPreprocessor().addPPCallbacks(llvm::make_unique(
+Reporter, &Collector, &Compiler.getSourceManager()));
 return MatchFinder.newASTConsumer();
   }
 
 private:
+  SymbolReporter *Reporter;
   ast_matchers::MatchFinder MatchFinder;
   HeaderMapCollector Collector;
   PragmaCommentHandler Handler;
@@ -78,14 +82,14 @@
 class TestFindAllSymbolsActionFactory
 : public clang::tooling::FrontendActionFactory {
 public:
-  TestFindAllSymbolsActionFactory(MockReporter *Reporter)
+  TestFindAllSymbolsActionFactory(TestSymbolReporter *Reporter)
   : Reporter(Reporter) {}
   clang::FrontendAction *create() override {
 return new TestFindAllSymbolsAction(Reporter);
   }
 
 private:
-  MockReporter *const Reporter;
+  TestSymbolReporter *const Reporter;
 };
 
 class FindAllSymbolsTest : public ::testing::Test {
@@ -378,5 +382,42 @@
   EXPECT_TRUE(hasSymbol(Symbol));
 }
 
+TEST_F(FindAllSymbolsTest, MacroTest) {
+  static const char Code[] = R"(
+#define X
+#define Y 1
+#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
+  )";
+  runFindAllSymbols(Code);
+  SymbolInfo Symbol =
+  SymbolInfo("X", SymbolInfo::SymbolKind::Macro, HeaderName, 2, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("Y", SymbolInfo::SymbolKind::Macro, HeaderName, 3, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("MAX", SymbolInfo::SymbolKind::Macro, HeaderName, 4, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+}
+
+TEST_F(FindAllSymbolsTest, MacroTestWithIWYU) {
+  static const char Code[] = R"(
+// IWYU pragma: private, include "bar.h"
+#define X
+#define Y 1
+#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
+  )";
+  runFindAllSymbols(Code);
+  SymbolInfo Symbol =
+  SymbolInfo("X", SymbolInfo::SymbolKind::Macro, "bar.h", 3, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("Y", SymbolInfo::SymbolKind::Macro, "bar.h", 4, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("MAX", SymbolInfo::SymbolKind::Macro, "bar.h", 5, {});
+  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/F

Re: [PATCH] D20420: [find-all-symbol] Add macro support.

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

Fix code-style.


http://reviews.llvm.org/D20420

Files:
  include-fixer/find-all-symbols/CMakeLists.txt
  include-fixer/find-all-symbols/FindAllMacros.cpp
  include-fixer/find-all-symbols/FindAllMacros.h
  include-fixer/find-all-symbols/FindAllSymbols.cpp
  include-fixer/find-all-symbols/FindAllSymbols.h
  include-fixer/find-all-symbols/SymbolInfo.cpp
  include-fixer/find-all-symbols/SymbolInfo.h
  include-fixer/find-all-symbols/SymbolReporter.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
@@ -7,10 +7,12 @@
 //
 //===--===//
 
+#include "FindAllMacros.h"
 #include "FindAllSymbols.h"
 #include "HeaderMapCollector.h"
 #include "PragmaCommentHandler.h"
 #include "SymbolInfo.h"
+#include "SymbolReporter.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemOptions.h"
@@ -31,17 +33,16 @@
 
 static const char HeaderName[] = "symbols.h";
 
-class MockReporter
-: public clang::find_all_symbols::FindAllSymbols::ResultReporter {
+class TestSymbolReporter : public clang::find_all_symbols::SymbolReporter {
 public:
-  ~MockReporter() override {}
+  ~TestSymbolReporter() override {}
 
-  void reportResult(llvm::StringRef FileName,
+  void reportSymbol(llvm::StringRef FileName,
 const SymbolInfo &Symbol) override {
 Symbols.push_back(Symbol);
   }
 
-  bool hasSymbol(const SymbolInfo &Symbol) {
+  bool hasSymbol(const SymbolInfo &Symbol) const {
 for (const auto &S : Symbols) {
   if (S == Symbol)
 return true;
@@ -55,20 +56,23 @@
 
 class TestFindAllSymbolsAction : public clang::ASTFrontendAction {
 public:
-  TestFindAllSymbolsAction(FindAllSymbols::ResultReporter *Reporter)
-  : MatchFinder(), Collector(), Handler(&Collector),
+  TestFindAllSymbolsAction(SymbolReporter *Reporter)
+  : Reporter(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);
+Compiler.getPreprocessor().addPPCallbacks(llvm::make_unique(
+Reporter, &Collector, &Compiler.getSourceManager()));
 return MatchFinder.newASTConsumer();
   }
 
 private:
+  SymbolReporter *Reporter;
   ast_matchers::MatchFinder MatchFinder;
   HeaderMapCollector Collector;
   PragmaCommentHandler Handler;
@@ -78,14 +82,14 @@
 class TestFindAllSymbolsActionFactory
 : public clang::tooling::FrontendActionFactory {
 public:
-  TestFindAllSymbolsActionFactory(MockReporter *Reporter)
+  TestFindAllSymbolsActionFactory(TestSymbolReporter *Reporter)
   : Reporter(Reporter) {}
   clang::FrontendAction *create() override {
 return new TestFindAllSymbolsAction(Reporter);
   }
 
 private:
-  MockReporter *const Reporter;
+  TestSymbolReporter *const Reporter;
 };
 
 class FindAllSymbolsTest : public ::testing::Test {
@@ -378,5 +382,42 @@
   EXPECT_TRUE(hasSymbol(Symbol));
 }
 
+TEST_F(FindAllSymbolsTest, MacroTest) {
+  static const char Code[] = R"(
+#define X
+#define Y 1
+#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
+  )";
+  runFindAllSymbols(Code);
+  SymbolInfo Symbol =
+  SymbolInfo("X", SymbolInfo::SymbolKind::Macro, HeaderName, 2, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("Y", SymbolInfo::SymbolKind::Macro, HeaderName, 3, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("MAX", SymbolInfo::SymbolKind::Macro, HeaderName, 4, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+}
+
+TEST_F(FindAllSymbolsTest, MacroTestWithIWYU) {
+  static const char Code[] = R"(
+// IWYU pragma: private, include "bar.h"
+#define X
+#define Y 1
+#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
+  )";
+  runFindAllSymbols(Code);
+  SymbolInfo Symbol =
+  SymbolInfo("X", SymbolInfo::SymbolKind::Macro, "bar.h", 3, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("Y", SymbolInfo::SymbolKind::Macro, "bar.h", 4, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("MAX", SymbolInfo::SymbolKind::Macro, "bar.h", 5, {});
+  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
+++

Re: [PATCH] D20419: [Sparc] Add software float option -msoft-float

2016-05-19 Thread Jacob Baungard Hansen via cfe-commits
jacob_hansen updated this revision to Diff 57755.
jacob_hansen added a comment.

- Corrected an error causing the "target-features"="+soft-float" attribute to 
not be correctly set
- Improved the function-target-features test


http://reviews.llvm.org/D20419

Files:
  lib/Basic/Targets.cpp
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h
  test/CodeGen/function-target-features.c
  test/Driver/sparc-float.c

Index: test/Driver/sparc-float.c
===
--- test/Driver/sparc-float.c
+++ test/Driver/sparc-float.c
@@ -18,7 +18,25 @@
 // RUN: %clang -c %s -### -o %t.o 2>&1 \
 // RUN: -target sparc-linux-gnu -msoft-float \
 // RUN:   | FileCheck --check-prefix=CHECK-SOFT %s
-// CHECK-SOFT: error: unsupported option '-msoft-float'
+// CHECK-SOFT: "-target-feature" "+soft-float"
+//
+// -mfloat-abi=soft
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target sparc-linux-gnu -mfloat-abi=soft \
+// RUN:   | FileCheck --check-prefix=CHECK-FLOATABISOFT %s
+// CHECK-FLOATABISOFT: "-target-feature" "+soft-float"
+//
+// -mfloat-abi=hard
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target sparc-linux-gnu -mfloat-abi=hard \
+// RUN:   | FileCheck --check-prefix=CHECK-FLOATABIHARD %s
+// CHECK-FLOATABIHARD-NOT: "-target-feature" "+soft-float"
+//
+// check invalid -mfloat-abi
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target sparc-linux-gnu -mfloat-abi=x \
+// RUN:   | FileCheck --check-prefix=CHECK-ERRMSG %s
+// CHECK-ERRMSG: error: invalid float ABI '-mfloat-abi=x'
 //
 // Default sparc64
 // RUN: %clang -c %s -### -o %t.o 2>&1 \
@@ -37,4 +55,22 @@
 // RUN: %clang -c %s -### -o %t.o 2>&1 \
 // RUN: -target sparc64-linux-gnu -msoft-float \
 // RUN:   | FileCheck --check-prefix=CHECK-SOFT-SPARC64 %s
-// CHECK-SOFT-SPARC64: error: unsupported option '-msoft-float'
+// CHECK-SOFT-SPARC64: "-target-feature" "+soft-float"
+//
+// -mfloat-abi=soft
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target sparc64-linux-gnu -mfloat-abi=soft \
+// RUN:   | FileCheck --check-prefix=CHECK-FLOATABISOFT64 %s
+// CHECK-FLOATABISOFT64: "-target-feature" "+soft-float"
+//
+// -mfloat-abi=hard
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target sparc64-linux-gnu -mfloat-abi=hard \
+// RUN:   | FileCheck --check-prefix=CHECK-FLOATABIHARD64 %s
+// CHECK-FLOATABIHARD64-NOT: "-target-feature" "+soft-float"
+//
+// check invalid -mfloat-abi
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target sparc64-linux-gnu -mfloat-abi=x \
+// RUN:   | FileCheck --check-prefix=CHECK-ERRMSG64 %s
+// CHECK-ERRMSG64: error: invalid float ABI '-mfloat-abi=x'
Index: test/CodeGen/function-target-features.c
===
--- test/CodeGen/function-target-features.c
+++ test/CodeGen/function-target-features.c
@@ -9,7 +9,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-cpu corei7 -target-feature +avx | FileCheck %s -check-prefix=CORE-CPU-AND-FEATURES
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-cpu x86-64 | FileCheck %s -check-prefix=X86-64-CPU
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-cpu corei7-avx -target-feature -avx | FileCheck %s -check-prefix=AVX-MINUS-FEATURE
-// RUN: %clang_cc1 -triple sparc-unknown-unknown -emit-llvm -o - %s -target-feature +soft-float | FileCheck %s -check-prefix=NO-SOFT-FLOAT
+// RUN: %clang_cc1 -triple sparc-unknown-unknown -emit-llvm -o - %s -target-feature +soft-float | FileCheck %s -check-prefix=SOFT-FLOAT
 // RUN: %clang_cc1 -triple arm-unknown-unknown -emit-llvm -o - %s -target-feature +soft-float | FileCheck %s -check-prefix=SOFT-FLOAT
 // RUN: %clang_cc1 -triple mips-unknown-unknown -emit-llvm -o - %s -target-feature +soft-float | FileCheck %s -check-prefix=SOFT-FLOAT
 
@@ -23,4 +23,3 @@
 // X86-64-CPU: "target-cpu"="x86-64"
 // AVX-MINUS-FEATURE: "target-features"={{.*}}-avx
 // SOFT-FLOAT: "target-features"={{.*}}+soft-float
-// NO-SOFT-FLOAT-NOT: "target-features"={{.*}}+soft-float
Index: lib/Driver/Tools.h
===
--- lib/Driver/Tools.h
+++ lib/Driver/Tools.h
@@ -777,6 +777,16 @@
 FloatABI getPPCFloatABI(const Driver &D, const llvm::opt::ArgList &Args);
 } // end namespace ppc
 
+namespace sparc {
+enum class FloatABI {
+  Invalid,
+  Soft,
+  Hard,
+};
+
+FloatABI getSparcFloatABI(const Driver &D, const llvm::opt::ArgList &Args);
+} // end namespace sparc
+
 namespace XCore {
 // For XCore, we do not need to instantiate tools for PreProcess, PreCompile and
 // Compile.
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -1640,26 +1640,65 @@
   return "";
 }
 
-void Clang::AddSparcTargetArgs(const ArgList &Args,
-   ArgStringList &CmdArgs) const {
-  const Driver &D = getToolCh

Re: [PATCH] D19324: [ASTMatchers] new forEachOverriden matcher

2016-05-19 Thread Clement Courbet via cfe-commits
courbet updated this revision to Diff 57756.
courbet added a comment.

Rebase on HEAD.


http://reviews.llvm.org/D19324

Files:
  docs/LibASTMatchersReference.html
  include/clang/AST/ASTContext.h
  include/clang/AST/DeclCXX.h
  include/clang/ASTMatchers/ASTMatchers.h
  lib/AST/ASTContext.cpp
  lib/AST/DeclCXX.cpp
  unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1975,5 +1975,49 @@
   EXPECT_TRUE(notMatches(CppString2, returnStmt(forFunction(hasName("F");
 }
 
+TEST(Matcher, ForEachOverriden) {
+  const auto ForEachOverriddenInClass = [](const char *ClassName) {
+return cxxMethodDecl(ofClass(hasName(ClassName)), isVirtual(),
+ forEachOverridden(cxxMethodDecl().bind("overridden")))
+.bind("override");
+  };
+  constexpr const char Code1[] = "class A { virtual void f(); };"
+ "class B : public A { void f(); };"
+ "class C : public B { void f(); };";
+  // C::f overrides A::f.
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("C"),
+  llvm::make_unique>("override", "f", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("C"),
+  llvm::make_unique>("overridden", "f",
+  1)));
+  // B::f overrides A::f.
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("override", "f", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("overridden", "f",
+  1)));
+  // A::f overrides nothing.
+  EXPECT_TRUE(notMatches(Code1, ForEachOverriddenInClass("A")));
+
+  constexpr const char Code2[] =
+  "class A1 { virtual void f(); };"
+  "class A2 { virtual void f(); };"
+  "class B : public A1, public A2 { void f(); };";
+  // B::f overrides A1::f and A2::f. This produces two matches.
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code2, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("override", "f", 2)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code2, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("overridden", "f",
+  2)));
+  // A1::f overrides nothing.
+  EXPECT_TRUE(notMatches(Code2, ForEachOverriddenInClass("A1")));
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1632,6 +1632,13 @@
   return getASTContext().overridden_methods_size(this);
 }
 
+CXXMethodDecl::overridden_method_range
+CXXMethodDecl::overridden_methods() const {
+  if (isa(this))
+return overridden_method_range(nullptr, nullptr);
+  return getASTContext().overridden_methods(this);
+}
+
 QualType CXXMethodDecl::getThisType(ASTContext &C) const {
   // C++ 9.3.2p1: The type of this in a member function of a class X is X*.
   // If the member function is declared const, the type of this is const X*,
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1255,33 +1255,36 @@
 ASTContext::overridden_cxx_method_iterator
 ASTContext::overridden_methods_begin(const CXXMethodDecl *Method) const {
   llvm::DenseMap::const_iterator Pos
-= OverriddenMethods.find(Method->getCanonicalDecl());
+  = OverriddenMethods.find(Method->getCanonicalDecl());
   if (Pos == OverriddenMethods.end())
 return nullptr;
-
   return Pos->second.begin();
 }
 
 ASTContext::overridden_cxx_method_iterator
 ASTContext::overridden_methods_end(const CXXMethodDecl *Method) const {
   llvm::DenseMap::const_iterator Pos
-= OverriddenMethods.find(Method->getCanonicalDecl());
+  = OverriddenMethods.find(Method->getCanonicalDecl());
   if (Pos == OverriddenMethods.end())
 return nullptr;
-
   return Pos->second.end();
 }
 
 unsigned
 ASTContext::overridden_methods_size(const CXXMethodDecl *Method) const {
   llvm::DenseMap::const_iterator Pos
-= OverriddenMethods.find(Method->getCanonicalDecl());
+  = OverriddenMethods.find(Method->getCanonicalDecl());
   if (Pos == OverriddenMethods.end())
 return 0;
-
   return Pos->second.size();
 }
 
+ASTContext::overridden_method_range
+ASTContext::overridden_methods(const CXXMethodDecl *Method) const {
+  return overridden_method_range(overridden_methods_begin(Method),
+ overridden_methods_end(Method));
+}
+
 void ASTContext::addOverriddenMethod(const CXXMethodDecl *Method, 

r270034 - [X86][SSE2] Sync with llvm/test/CodeGen/X86/sse2-intrinsics-fast-isel.ll

2016-05-19 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu May 19 04:52:59 2016
New Revision: 270034

URL: http://llvm.org/viewvc/llvm-project?rev=270034&view=rev
Log:
[X86][SSE2] Sync with llvm/test/CodeGen/X86/sse2-intrinsics-fast-isel.ll

Modified:
cfe/trunk/test/CodeGen/sse2-builtins.c

Modified: cfe/trunk/test/CodeGen/sse2-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sse2-builtins.c?rev=270034&r1=270033&r2=270034&view=diff
==
--- cfe/trunk/test/CodeGen/sse2-builtins.c (original)
+++ cfe/trunk/test/CodeGen/sse2-builtins.c Thu May 19 04:52:59 2016
@@ -6,6 +6,8 @@
 
 #include 
 
+// NOTE: This should match the tests in 
llvm/test/CodeGen/X86/sse2-intrinsics-fast-isel.ll
+
 __m128i test_mm_add_epi8(__m128i A, __m128i B) {
   // CHECK-LABEL: test_mm_add_epi8
   // CHECK: add <16 x i8>
@@ -38,31 +40,34 @@ __m128d test_mm_add_pd(__m128d A, __m128
 
 __m128d test_mm_add_sd(__m128d A, __m128d B) {
   // CHECK-LABEL: test_mm_add_sd
+  // CHECK: extractelement <2 x double> %{{.*}}, i32 0
+  // CHECK: extractelement <2 x double> %{{.*}}, i32 0
   // CHECK: fadd double
+  // CHECK: insertelement <2 x double> %{{.*}}, double %{{.*}}, i32 0
   return _mm_add_sd(A, B);
 }
 
 __m128i test_mm_adds_epi8(__m128i A, __m128i B) {
   // CHECK-LABEL: test_mm_adds_epi8
-  // CHECK: call <16 x i8> @llvm.x86.sse2.padds.b
+  // CHECK: call <16 x i8> @llvm.x86.sse2.padds.b(<16 x i8> %{{.*}}, <16 x i8> 
%{{.*}})
   return _mm_adds_epi8(A, B);
 }
 
 __m128i test_mm_adds_epi16(__m128i A, __m128i B) {
   // CHECK-LABEL: test_mm_adds_epi16
-  // CHECK: call <8 x i16> @llvm.x86.sse2.padds.w
+  // CHECK: call <8 x i16> @llvm.x86.sse2.padds.w(<8 x i16> %{{.*}}, <8 x i16> 
%{{.*}})
   return _mm_adds_epi16(A, B);
 }
 
 __m128i test_mm_adds_epu8(__m128i A, __m128i B) {
   // CHECK-LABEL: test_mm_adds_epu8
-  // CHECK: call <16 x i8> @llvm.x86.sse2.paddus.b
+  // CHECK: call <16 x i8> @llvm.x86.sse2.paddus.b(<16 x i8> %{{.*}}, <16 x 
i8> %{{.*}})
   return _mm_adds_epu8(A, B);
 }
 
 __m128i test_mm_adds_epu16(__m128i A, __m128i B) {
   // CHECK-LABEL: test_mm_adds_epu16
-  // CHECK: call <8 x i16> @llvm.x86.sse2.paddus.w
+  // CHECK: call <8 x i16> @llvm.x86.sse2.paddus.w(<8 x i16> %{{.*}}, <8 x 
i16> %{{.*}})
   return _mm_adds_epu16(A, B);
 }
 
@@ -78,15 +83,29 @@ __m128i test_mm_and_si128(__m128i A, __m
   return _mm_and_si128(A, B);
 }
 
+__m128d test_mm_andnot_pd(__m128d A, __m128d B) {
+  // CHECK-LABEL: test_mm_andnot_pd
+  // CHECK: xor <4 x i32> %{{.*}}, 
+  // CHECK: and <4 x i32>
+  return _mm_andnot_pd(A, B);
+}
+
+__m128i test_mm_andnot_si128(__m128i A, __m128i B) {
+  // CHECK-LABEL: test_mm_andnot_si128
+  // CHECK: xor <2 x i64> %{{.*}}, 
+  // CHECK: and <2 x i64>
+  return _mm_andnot_si128(A, B);
+}
+
 __m128i test_mm_avg_epu8(__m128i A, __m128i B) {
   // CHECK-LABEL: test_mm_avg_epu8
-  // CHECK: call <16 x i8> @llvm.x86.sse2.pavg.b
+  // CHECK: call <16 x i8> @llvm.x86.sse2.pavg.b(<16 x i8> %{{.*}}, <16 x i8> 
%{{.*}})
   return _mm_avg_epu8(A, B);
 }
 
 __m128i test_mm_avg_epu16(__m128i A, __m128i B) {
   // CHECK-LABEL: test_mm_avg_epu16
-  // CHECK: call <8 x i16> @llvm.x86.sse2.pavg.w
+  // CHECK: call <8 x i16> @llvm.x86.sse2.pavg.w(<8 x i16> %{{.*}}, <8 x i16> 
%{{.*}})
   return _mm_avg_epu16(A, B);
 }
 
@@ -147,6 +166,10 @@ __m128d test_mm_cmpge_pd(__m128d A, __m1
 __m128d test_mm_cmpge_sd(__m128d A, __m128d B) {
   // CHECK-LABEL: test_mm_cmpge_sd
   // CHECK: call <2 x double> @llvm.x86.sse2.cmp.sd(<2 x double> %{{.*}}, <2 x 
double> %{{.*}}, i8 2)
+  // CHECK: extractelement <2 x double> %{{.*}}, i32 0
+  // CHECK: insertelement <2 x double> undef, double %{{.*}}, i32 0
+  // CHECK: extractelement <2 x double> %{{.*}}, i32 1
+  // CHECK: insertelement <2 x double> %{{.*}}, double %{{.*}}, i32 1
   return _mm_cmpge_sd(A, B);
 }
 
@@ -177,6 +200,10 @@ __m128d test_mm_cmpgt_pd(__m128d A, __m1
 __m128d test_mm_cmpgt_sd(__m128d A, __m128d B) {
   // CHECK-LABEL: test_mm_cmpgt_sd
   // CHECK: call <2 x double> @llvm.x86.sse2.cmp.sd(<2 x double> %{{.*}}, <2 x 
double> %{{.*}}, i8 1)
+  // CHECK: extractelement <2 x double> %{{.*}}, i32 0
+  // CHECK: insertelement <2 x double> undef, double %{{.*}}, i32 0
+  // CHECK: extractelement <2 x double> %{{.*}}, i32 1
+  // CHECK: insertelement <2 x double> %{{.*}}, double %{{.*}}, i32 1
   return _mm_cmpgt_sd(A, B);
 }
 
@@ -308,73 +335,73 @@ __m128d test_mm_cmpunord_sd(__m128d A, _
 
 int test_mm_comieq_sd(__m128d A, __m128d B) {
   // CHECK-LABEL: test_mm_comieq_sd
-  // CHECK: call i32 @llvm.x86.sse2.comieq.sd
+  // CHECK: call i32 @llvm.x86.sse2.comieq.sd(<2 x double> %{{.*}}, <2 x 
double> %{{.*}})
   return _mm_comieq_sd(A, B);
 }
 
 int test_mm_comige_sd(__m128d A, __m128d B) {
   // CHECK-LABEL: test_mm_comige_sd
-  // CHECK: call i32 @llvm.x86.sse2.comige.sd
+  // CHECK: call i32 @llvm.x86.sse2.comige.sd(<2 x double> %{{.*}}, <2 x 
double> %{{.*}})
   return _mm_comige_sd(A, B);
 }
 
 in

Re: [PATCH] D19324: [ASTMatchers] new forEachOverriden matcher

2016-05-19 Thread Clement Courbet via cfe-commits
courbet updated this revision to Diff 57757.
courbet added a comment.

clang-format diff


http://reviews.llvm.org/D19324

Files:
  docs/LibASTMatchersReference.html
  include/clang/AST/ASTContext.h
  include/clang/AST/DeclCXX.h
  include/clang/ASTMatchers/ASTMatchers.h
  lib/AST/ASTContext.cpp
  lib/AST/DeclCXX.cpp
  unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1975,5 +1975,49 @@
   EXPECT_TRUE(notMatches(CppString2, returnStmt(forFunction(hasName("F");
 }
 
+TEST(Matcher, ForEachOverriden) {
+  const auto ForEachOverriddenInClass = [](const char *ClassName) {
+return cxxMethodDecl(ofClass(hasName(ClassName)), isVirtual(),
+ forEachOverridden(cxxMethodDecl().bind("overridden")))
+.bind("override");
+  };
+  constexpr const char Code1[] = "class A { virtual void f(); };"
+ "class B : public A { void f(); };"
+ "class C : public B { void f(); };";
+  // C::f overrides A::f.
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("C"),
+  llvm::make_unique>("override", "f", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("C"),
+  llvm::make_unique>("overridden", "f",
+  1)));
+  // B::f overrides A::f.
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("override", "f", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("overridden", "f",
+  1)));
+  // A::f overrides nothing.
+  EXPECT_TRUE(notMatches(Code1, ForEachOverriddenInClass("A")));
+
+  constexpr const char Code2[] =
+  "class A1 { virtual void f(); };"
+  "class A2 { virtual void f(); };"
+  "class B : public A1, public A2 { void f(); };";
+  // B::f overrides A1::f and A2::f. This produces two matches.
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code2, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("override", "f", 2)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code2, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("overridden", "f",
+  2)));
+  // A1::f overrides nothing.
+  EXPECT_TRUE(notMatches(Code2, ForEachOverriddenInClass("A1")));
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1632,6 +1632,13 @@
   return getASTContext().overridden_methods_size(this);
 }
 
+CXXMethodDecl::overridden_method_range
+CXXMethodDecl::overridden_methods() const {
+  if (isa(this))
+return overridden_method_range(nullptr, nullptr);
+  return getASTContext().overridden_methods(this);
+}
+
 QualType CXXMethodDecl::getThisType(ASTContext &C) const {
   // C++ 9.3.2p1: The type of this in a member function of a class X is X*.
   // If the member function is declared const, the type of this is const X*,
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1254,34 +1254,37 @@
 
 ASTContext::overridden_cxx_method_iterator
 ASTContext::overridden_methods_begin(const CXXMethodDecl *Method) const {
-  llvm::DenseMap::const_iterator Pos
-= OverriddenMethods.find(Method->getCanonicalDecl());
+  llvm::DenseMap::const_iterator Pos =
+  OverriddenMethods.find(Method->getCanonicalDecl());
   if (Pos == OverriddenMethods.end())
 return nullptr;
-
   return Pos->second.begin();
 }
 
 ASTContext::overridden_cxx_method_iterator
 ASTContext::overridden_methods_end(const CXXMethodDecl *Method) const {
-  llvm::DenseMap::const_iterator Pos
-= OverriddenMethods.find(Method->getCanonicalDecl());
+  llvm::DenseMap::const_iterator Pos =
+  OverriddenMethods.find(Method->getCanonicalDecl());
   if (Pos == OverriddenMethods.end())
 return nullptr;
-
   return Pos->second.end();
 }
 
 unsigned
 ASTContext::overridden_methods_size(const CXXMethodDecl *Method) const {
-  llvm::DenseMap::const_iterator Pos
-= OverriddenMethods.find(Method->getCanonicalDecl());
+  llvm::DenseMap::const_iterator Pos =
+  OverriddenMethods.find(Method->getCanonicalDecl());
   if (Pos == OverriddenMethods.end())
 return 0;
-
   return Pos->second.size();
 }
 
+ASTContext::overridden_method_range
+ASTContext::overridden_methods(const CXXMethodDecl *Method) const {
+  return overridden_method_range(overridden_methods_begin(Method),
+ overridden_metho

Re: [PATCH] D19324: [ASTMatchers] new forEachOverriden matcher

2016-05-19 Thread Clement Courbet via cfe-commits
courbet added inline comments.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:3776
@@ +3775,3 @@
+  bool Matched = false;
+  for (const auto *Overridden : Node.overridden_methods()) {
+BoundNodesTreeBuilder OverriddenBuilder(*Builder);

Thanks for the pointer !


http://reviews.llvm.org/D19324



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


Re: [PATCH] D20420: [find-all-symbol] Add macro support.

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


Comment at: include-fixer/find-all-symbols/FindAllMacros.h:22
@@ +21,3 @@
+
+/// \brief A preprocessor collects macro symbols. The contexts of a macro will
+/// be ignored since they are not available during preprocessing period.

nit: "A preprocessor that collects..."


Comment at: include-fixer/find-all-symbols/FindAllMacros.h:36
@@ +35,3 @@
+  SymbolReporter *const Reporter;
+  // A remapping header file collector allowing clients include a different
+  // header.

nit: "allowing clients to include..."


Comment at: include-fixer/find-all-symbols/FindAllMacros.h:39
@@ +38,3 @@
+  HeaderMapCollector *const Collector;
+  // SourceManager.
+  SourceManager *const SM;

This comment does not introduce useful information IMO.


Comment at: include-fixer/find-all-symbols/SymbolReporter.h:18
@@ +17,3 @@
+
+/// \brief An interface for classes collect symbols.
+class SymbolReporter {

This doesn't make sense to me? 

Also, I think it should be "An interface for classes that/to collect symbols" 
grammatically.


http://reviews.llvm.org/D20420



___
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-19 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin added a comment.

One more friendly ping.. :(


http://reviews.llvm.org/D18035



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


r270039 - [Sema] Allow an external sema source to handle delayed typo corrections.

2016-05-19 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu May 19 05:46:10 2016
New Revision: 270039

URL: http://llvm.org/viewvc/llvm-project?rev=270039&view=rev
Log:
[Sema] Allow an external sema source to handle delayed typo corrections.

This probably isn't perfectly perfect but allows correcting function calls
again.

Modified:
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/unittests/Sema/ExternalSemaSourceTest.cpp

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=270039&r1=270038&r2=270039&view=diff
==
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Thu May 19 05:46:10 2016
@@ -4781,11 +4781,19 @@ TypoExpr *Sema::CorrectTypoDelayed(
 const ObjCObjectPointerType *OPT) {
   assert(CCC && "CorrectTypoDelayed requires a CorrectionCandidateCallback");
 
-  TypoCorrection Empty;
   auto Consumer = makeTypoCorrectionConsumer(
   TypoName, LookupKind, S, SS, std::move(CCC), MemberContext,
   EnteringContext, OPT, Mode == CTK_ErrorRecovery);
 
+  // Give the external sema source a chance to correct the typo.
+  TypoCorrection ExternalTypo;
+  if (ExternalSource && Consumer) {
+ExternalTypo = ExternalSource->CorrectTypo(
+TypoName, LookupKind, S, SS, *CCC, MemberContext, EnteringContext, 
OPT);
+if (ExternalTypo)
+  Consumer->addCorrection(ExternalTypo);
+  }
+
   if (!Consumer || Consumer->empty())
 return nullptr;
 
@@ -4793,7 +4801,7 @@ TypoExpr *Sema::CorrectTypoDelayed(
   // is not more that about a third of the length of the typo's identifier.
   unsigned ED = Consumer->getBestEditDistance(true);
   IdentifierInfo *Typo = TypoName.getName().getAsIdentifierInfo();
-  if (ED > 0 && Typo->getName().size() / ED < 3)
+  if (!ExternalTypo && ED > 0 && Typo->getName().size() / ED < 3)
 return nullptr;
 
   ExprEvalContexts.back().NumTypos++;

Modified: cfe/trunk/unittests/Sema/ExternalSemaSourceTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Sema/ExternalSemaSourceTest.cpp?rev=270039&r1=270038&r2=270039&view=diff
==
--- cfe/trunk/unittests/Sema/ExternalSemaSourceTest.cpp (original)
+++ cfe/trunk/unittests/Sema/ExternalSemaSourceTest.cpp Thu May 19 05:46:10 2016
@@ -39,19 +39,18 @@ public:
   bool Result;
 };
 
-// \brief Counts the number of err_using_directive_member_suggest diagnostics
-// correcting from one namespace to another while still passing all diagnostics
-// along a chain of consumers.
-class NamespaceDiagnosticWatcher : public clang::DiagnosticConsumer {
+/// Counts the number of typo-correcting diagnostics correcting from one name 
to
+/// another while still passing all diagnostics along a chain of consumers.
+class DiagnosticWatcher : public clang::DiagnosticConsumer {
   DiagnosticConsumer *Chained;
-  std::string FromNS;
-  std::string ToNS;
+  std::string FromName;
+  std::string ToName;
 
 public:
-  NamespaceDiagnosticWatcher(StringRef From, StringRef To)
-  : Chained(nullptr), FromNS(From), ToNS("'"), SeenCount(0) {
-ToNS.append(To);
-ToNS.append("'");
+  DiagnosticWatcher(StringRef From, StringRef To)
+  : Chained(nullptr), FromName(From), ToName("'"), SeenCount(0) {
+ToName.append(To);
+ToName.append("'");
   }
 
   void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
@@ -61,7 +60,12 @@ public:
 if (Info.getID() - 1 == diag::err_using_directive_member_suggest) {
   const IdentifierInfo *Ident = Info.getArgIdentifier(0);
   const std::string &CorrectedQuotedStr = Info.getArgStdStr(1);
-  if (Ident->getName() == FromNS && CorrectedQuotedStr == ToNS)
+  if (Ident->getName() == FromName && CorrectedQuotedStr == ToName)
+++SeenCount;
+} else if (Info.getID() == diag::err_no_member_suggest) {
+  auto Ident = DeclarationName::getFromOpaqueInteger(Info.getRawArg(0));
+  const std::string &CorrectedQuotedStr = Info.getArgStdStr(3);
+  if (Ident.getAsString() == FromName && CorrectedQuotedStr == ToName)
 ++SeenCount;
 }
   }
@@ -78,7 +82,7 @@ public:
 return false;
   }
 
-  NamespaceDiagnosticWatcher *Chain(DiagnosticConsumer *ToChain) {
+  DiagnosticWatcher *Chain(DiagnosticConsumer *ToChain) {
 Chained = ToChain;
 return this;
   }
@@ -130,11 +134,53 @@ public:
   int CallCount;
 };
 
-// \brief Chains together a vector of NamespaceDiagnosticWatchers and
+class FunctionTypoProvider : public clang::ExternalSemaSource {
+  std::string CorrectFrom;
+  std::string CorrectTo;
+  Sema *CurrentSema;
+
+public:
+  FunctionTypoProvider(StringRef From, StringRef To)
+  : CorrectFrom(From), CorrectTo(To), CurrentSema(nullptr), CallCount(0) {}
+
+  void InitializeSema(Sema &S) override { CurrentSema = &S; }
+
+  void ForgetSema() override { CurrentSema = nullptr; }
+
+  TypoCorrection CorrectTypo(const Declaration

r270042 - [X86][SSE2] Added _mm_cast* and _mm_set* tests

2016-05-19 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu May 19 06:03:48 2016
New Revision: 270042

URL: http://llvm.org/viewvc/llvm-project?rev=270042&view=rev
Log:
[X86][SSE2] Added _mm_cast* and _mm_set* tests

Modified:
cfe/trunk/test/CodeGen/sse2-builtins.c

Modified: cfe/trunk/test/CodeGen/sse2-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sse2-builtins.c?rev=270042&r1=270041&r2=270042&view=diff
==
--- cfe/trunk/test/CodeGen/sse2-builtins.c (original)
+++ cfe/trunk/test/CodeGen/sse2-builtins.c Thu May 19 06:03:48 2016
@@ -121,6 +121,42 @@ __m128i test_mm_bsrli_si128(__m128i A) {
   return _mm_bsrli_si128(A, 5);
 }
 
+__m128 test_mm_castpd_ps(__m128d A) {
+  // CHECK-LABEL: test_mm_castpd_ps
+  // CHECK: bitcast <2 x double> %{{.*}} to <4 x float>
+  return _mm_castpd_ps(A);
+}
+
+__m128i test_mm_castpd_si128(__m128d A) {
+  // CHECK-LABEL: test_mm_castpd_si128
+  // CHECK: bitcast <2 x double> %{{.*}} to <2 x i64>
+  return _mm_castpd_si128(A);
+}
+
+__m128d test_mm_castps_pd(__m128 A) {
+  // CHECK-LABEL: test_mm_castps_pd
+  // CHECK: bitcast <4 x float> %{{.*}} to <2 x double>
+  return _mm_castps_pd(A);
+}
+
+__m128i test_mm_castps_si128(__m128 A) {
+  // CHECK-LABEL: test_mm_castps_si128
+  // CHECK: bitcast <4 x float> %{{.*}} to <2 x i64>
+  return _mm_castps_si128(A);
+}
+
+__m128d test_mm_castsi128_pd(__m128i A) {
+  // CHECK-LABEL: test_mm_castsi128_pd
+  // CHECK: bitcast <2 x i64> %{{.*}} to <2 x double>
+  return _mm_castsi128_pd(A);
+}
+
+__m128 test_mm_castsi128_ps(__m128i A) {
+  // CHECK-LABEL: test_mm_castsi128_ps
+  // CHECK: bitcast <2 x i64> %{{.*}} to <4 x float>
+  return _mm_castsi128_ps(A);
+}
+
 void test_mm_clflush(void* A) {
   // CHECK-LABEL: test_mm_clflush
   // CHECK: call void @llvm.x86.sse2.clflush(i8* %{{.*}})
@@ -778,6 +814,206 @@ __m128i test_mm_sad_epu8(__m128i A, __m1
   return _mm_sad_epu8(A, B);
 }
 
+__m128i test_mm_set_epi8(char A, char B, char C, char D,
+ char E, char F, char G, char H,
+ char I, char J, char K, char L,
+ char M, char N, char O, char P) {
+  // CHECK-LABEL: test_mm_set_epi8
+  // CHECK: insertelement <16 x i8> undef, i8 %{{.*}}, i32 0
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 1
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 2
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 3
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 4
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 5
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 6
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 7
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 8
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 9
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 10
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 11
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 12
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 13
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 14
+  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 15
+  return _mm_set_epi8(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P);
+}
+
+__m128i test_mm_set_epi16(short A, short B, short C, short D,
+  short E, short F, short G, short H) {
+  // CHECK-LABEL: test_mm_set_epi16
+  // CHECK: insertelement <8 x i16> undef, i16 %{{.*}}, i32 0
+  // CHECK: insertelement <8 x i16> %{{.*}}, i16 %{{.*}}, i32 1
+  // CHECK: insertelement <8 x i16> %{{.*}}, i16 %{{.*}}, i32 2
+  // CHECK: insertelement <8 x i16> %{{.*}}, i16 %{{.*}}, i32 3
+  // CHECK: insertelement <8 x i16> %{{.*}}, i16 %{{.*}}, i32 4
+  // CHECK: insertelement <8 x i16> %{{.*}}, i16 %{{.*}}, i32 5
+  // CHECK: insertelement <8 x i16> %{{.*}}, i16 %{{.*}}, i32 6
+  // CHECK: insertelement <8 x i16> %{{.*}}, i16 %{{.*}}, i32 7
+  return _mm_set_epi16(A, B, C, D, E, F, G, H);
+}
+
+__m128i test_mm_set_epi32(int A, int B, int C, int D) {
+  // CHECK-LABEL: test_mm_set_epi32
+  // CHECK: insertelement <4 x i32> undef, i32 %{{.*}}, i32 0
+  // CHECK: insertelement <4 x i32> %{{.*}}, i32 %{{.*}}, i32 1
+  // CHECK: insertelement <4 x i32> %{{.*}}, i32 %{{.*}}, i32 2
+  // CHECK: insertelement <4 x i32> %{{.*}}, i32 %{{.*}}, i32 3
+  return _mm_set_epi32(A, B, C, D);
+}
+
+__m128i test_mm_set_epi64(__m64 A, __m64 B) {
+  // CHECK-LABEL: test_mm_set_epi64
+  // CHECK: insertelement <2 x i64> undef, i64 %{{.*}}, i32 0
+  // CHECK: insertelement <2 x i64> %{{.*}}, i64 %{{.*}}, i32 1
+  return _mm_set_epi64(A, B);
+}
+
+__m128i test_mm_set_epi64x(long long A, long long B) {
+  // CHECK-LABEL: test_mm_set_epi64x
+  // CHECK: insertelement <2 x i64> undef, i64 %{{.*}}, i32 0
+  // CHECK: insertelement <2 x i64> %{{.*}}, i64 %{{.*}}, i32 1
+  return _mm_set_epi64x(A, B);
+}
+
+__m128d test_mm_set_pd(doub

r270043 - [X86][SSE2] Added _mm_move_* tests

2016-05-19 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu May 19 06:18:49 2016
New Revision: 270043

URL: http://llvm.org/viewvc/llvm-project?rev=270043&view=rev
Log:
[X86][SSE2] Added _mm_move_* tests

Modified:
cfe/trunk/test/CodeGen/sse2-builtins.c

Modified: cfe/trunk/test/CodeGen/sse2-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sse2-builtins.c?rev=270043&r1=270042&r2=270043&view=diff
==
--- cfe/trunk/test/CodeGen/sse2-builtins.c (original)
+++ cfe/trunk/test/CodeGen/sse2-builtins.c Thu May 19 06:18:49 2016
@@ -721,6 +721,21 @@ __m128d test_mm_min_sd(__m128d A, __m128
   return _mm_min_sd(A, B);
 }
 
+__m128i test_mm_move_epi64(__m128i A) {
+  // CHECK-LABEL: test_mm_move_epi64
+  // CHECK: shufflevector <2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <2 x i32> 
+  return _mm_move_epi64(A);
+}
+
+__m128d test_mm_move_sd(__m128d A, __m128d B) {
+  // CHECK-LABEL: test_mm_move_sd
+  // CHECK: extractelement <2 x double> %{{.*}}, i32 0
+  // CHECK: insertelement <2 x double> undef, double %{{.*}}, i32 0
+  // CHECK: extractelement <2 x double> %{{.*}}, i32 1
+  // CHECK: insertelement <2 x double> %{{.*}}, double %{{.*}}, i32 1
+  return _mm_move_sd(A, B);
+}
+
 int test_mm_movemask_epi8(__m128i A) {
   // CHECK-LABEL: test_mm_movemask_epi8
   // CHECK: call i32 @llvm.x86.sse2.pmovmskb.128(<16 x i8> %{{.*}})


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


Re: [PATCH] D19783: Fix cv-qualification of '*this' captures (and nasty bug PR27507 introduced by commit 263921 "Implement Lambda Capture of *this by Value as [=, *this]")

2016-05-19 Thread Faisal Vali via cfe-commits
faisalv added inline comments.


Comment at: lib/Parse/ParseDeclCXX.cpp:3651
@@ -3652,1 +3650,3 @@
+  case AttributeList::AT_Unused:
+return !ScopeName && AttrName->getName().equals("maybe_unused");
   default:

This whitespace change shouldn't have been included - as an aside - we still 
strive unix style line endings right?


http://reviews.llvm.org/D19783



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


Re: [PATCH] D20243: [PCH] Disable inclusion of timestamps when generating pch files on windows.

2016-05-19 Thread pierre gousseau via cfe-commits
pgousseau added a comment.

In http://reviews.llvm.org/D20243#433615, @thakis wrote:

> Did you see http://reviews.llvm.org/D19815 ? Does that help? Warren might 
> have opinions on this.


Yes thanks, I agree with Warren, this is a separate issue.
In the test I am adding I avoid the issue that Warren's review is for by only 
using '#pragma once' in a sub header of the PCH.


http://reviews.llvm.org/D20243



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


[clang-tools-extra] r270045 - [include-fixer] Remove obsolete windows hack.

2016-05-19 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu May 19 06:39:56 2016
New Revision: 270045

URL: http://llvm.org/viewvc/llvm-project?rev=270045&view=rev
Log:
[include-fixer] Remove obsolete windows hack.

Modified:
clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Modified: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp?rev=270045&r1=270044&r2=270045&view=diff
==
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Thu 
May 19 06:39:56 2016
@@ -132,11 +132,9 @@ TEST(IncludeFixer, MinimizeInclude) {
 }
 
 TEST(IncludeFixer, NestedName) {
-  // Some tests don't pass for target *-win32.
-  std::vector args = {"-target", "x86_64-unknown-unknown"};
   EXPECT_EQ("#include \"dir/otherdir/qux.h\"\n\n"
 "int x = a::b::foo(0);\n",
-runIncludeFixer("int x = a::b::foo(0);\n", args));
+runIncludeFixer("int x = a::b::foo(0);\n"));
 
   // FIXME: Handle simple macros.
   EXPECT_EQ("#define FOO a::b::foo\nint x = FOO;\n",
@@ -146,7 +144,7 @@ TEST(IncludeFixer, NestedName) {
 
   EXPECT_EQ("#include \"dir/otherdir/qux.h\"\n\n"
 "namespace a {}\nint a = a::b::foo(0);\n",
-runIncludeFixer("namespace a {}\nint a = a::b::foo(0);\n", args));
+runIncludeFixer("namespace a {}\nint a = a::b::foo(0);\n"));
 }
 
 TEST(IncludeFixer, MultipleMissingSymbols) {


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


Re: [PATCH] D20420: [find-all-symbol] Add macro support.

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

Address comments.


http://reviews.llvm.org/D20420

Files:
  include-fixer/find-all-symbols/CMakeLists.txt
  include-fixer/find-all-symbols/FindAllMacros.cpp
  include-fixer/find-all-symbols/FindAllMacros.h
  include-fixer/find-all-symbols/FindAllSymbols.cpp
  include-fixer/find-all-symbols/FindAllSymbols.h
  include-fixer/find-all-symbols/SymbolInfo.cpp
  include-fixer/find-all-symbols/SymbolInfo.h
  include-fixer/find-all-symbols/SymbolReporter.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
@@ -7,10 +7,12 @@
 //
 //===--===//
 
+#include "FindAllMacros.h"
 #include "FindAllSymbols.h"
 #include "HeaderMapCollector.h"
 #include "PragmaCommentHandler.h"
 #include "SymbolInfo.h"
+#include "SymbolReporter.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemOptions.h"
@@ -31,17 +33,16 @@
 
 static const char HeaderName[] = "symbols.h";
 
-class MockReporter
-: public clang::find_all_symbols::FindAllSymbols::ResultReporter {
+class TestSymbolReporter : public clang::find_all_symbols::SymbolReporter {
 public:
-  ~MockReporter() override {}
+  ~TestSymbolReporter() override {}
 
-  void reportResult(llvm::StringRef FileName,
+  void reportSymbol(llvm::StringRef FileName,
 const SymbolInfo &Symbol) override {
 Symbols.push_back(Symbol);
   }
 
-  bool hasSymbol(const SymbolInfo &Symbol) {
+  bool hasSymbol(const SymbolInfo &Symbol) const {
 for (const auto &S : Symbols) {
   if (S == Symbol)
 return true;
@@ -55,20 +56,23 @@
 
 class TestFindAllSymbolsAction : public clang::ASTFrontendAction {
 public:
-  TestFindAllSymbolsAction(FindAllSymbols::ResultReporter *Reporter)
-  : MatchFinder(), Collector(), Handler(&Collector),
+  TestFindAllSymbolsAction(SymbolReporter *Reporter)
+  : Reporter(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);
+Compiler.getPreprocessor().addPPCallbacks(llvm::make_unique(
+Reporter, &Collector, &Compiler.getSourceManager()));
 return MatchFinder.newASTConsumer();
   }
 
 private:
+  SymbolReporter *const Reporter;
   ast_matchers::MatchFinder MatchFinder;
   HeaderMapCollector Collector;
   PragmaCommentHandler Handler;
@@ -78,14 +82,14 @@
 class TestFindAllSymbolsActionFactory
 : public clang::tooling::FrontendActionFactory {
 public:
-  TestFindAllSymbolsActionFactory(MockReporter *Reporter)
+  TestFindAllSymbolsActionFactory(TestSymbolReporter *Reporter)
   : Reporter(Reporter) {}
   clang::FrontendAction *create() override {
 return new TestFindAllSymbolsAction(Reporter);
   }
 
 private:
-  MockReporter *const Reporter;
+  TestSymbolReporter *const Reporter;
 };
 
 class FindAllSymbolsTest : public ::testing::Test {
@@ -122,7 +126,7 @@
   }
 
 private:
-  MockReporter Reporter;
+  TestSymbolReporter Reporter;
 };
 
 TEST_F(FindAllSymbolsTest, VariableSymbols) {
@@ -378,5 +382,42 @@
   EXPECT_TRUE(hasSymbol(Symbol));
 }
 
+TEST_F(FindAllSymbolsTest, MacroTest) {
+  static const char Code[] = R"(
+#define X
+#define Y 1
+#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
+  )";
+  runFindAllSymbols(Code);
+  SymbolInfo Symbol =
+  SymbolInfo("X", SymbolInfo::SymbolKind::Macro, HeaderName, 2, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("Y", SymbolInfo::SymbolKind::Macro, HeaderName, 3, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("MAX", SymbolInfo::SymbolKind::Macro, HeaderName, 4, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+}
+
+TEST_F(FindAllSymbolsTest, MacroTestWithIWYU) {
+  static const char Code[] = R"(
+// IWYU pragma: private, include "bar.h"
+#define X
+#define Y 1
+#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
+  )";
+  runFindAllSymbols(Code);
+  SymbolInfo Symbol =
+  SymbolInfo("X", SymbolInfo::SymbolKind::Macro, "bar.h", 3, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("Y", SymbolInfo::SymbolKind::Macro, "bar.h", 4, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("MAX", SymbolInfo::SymbolKind::Macro, "bar.h", 5, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+}
+
 } // namespace find_all_symbols
 } // namespace clang
Ind

[PATCH] D20422: [MSVC2015] dllexport for defaulted special class members

2016-05-19 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin created this revision.
DmitryPolukhin added a reviewer: rnk.
DmitryPolukhin added a subscriber: cfe-commits.

Clang doesn't dllexport defaulted special member function defaulted inside 
class but does it if they defaulted outside class. MSVC doesn't make any 
distinction where they were defaulted. Also MSVC 2013 and 2015 export different 
set of members. MSVC2015 doesn't emit trivial defaulted x-tors but does emit 
copy assign operator.


http://reviews.llvm.org/D20422

Files:
  lib/Sema/SemaDeclCXX.cpp
  test/CodeGenCXX/dllexport-members.cpp
  test/CodeGenCXX/dllexport.cpp

Index: test/CodeGenCXX/dllexport.cpp
===
--- test/CodeGenCXX/dllexport.cpp
+++ test/CodeGenCXX/dllexport.cpp
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases -disable-llvm-optzns -o - %s -w -fms-compatibility-version=19.00 | FileCheck --check-prefix=MSC --check-prefix=M32 -check-prefix=MSVC2015 %s
-// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases -disable-llvm-optzns -o - %s -w -fms-compatibility-version=18.00 | FileCheck --check-prefix=MSC --check-prefix=M32 -check-prefix=MSVC2013 %s
+// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases -disable-llvm-optzns -o - %s -w -fms-compatibility-version=19.00 | FileCheck --check-prefix=MSC --check-prefix=M32 -check-prefix=MSVC2015 -check-prefix=M32MSVC2015 %s
+// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases -disable-llvm-optzns -o - %s -w -fms-compatibility-version=18.00 | FileCheck --check-prefix=MSC --check-prefix=M32 -check-prefix=MSVC2013 -check-prefix=M32MSVC2013 %s
 
-// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w -fms-compatibility-version=19.00 | FileCheck --check-prefix=MSC --check-prefix=M64 -check-prefix=MSVC2015 %s
-// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w -fms-compatibility-version=18.00 | FileCheck --check-prefix=MSC --check-prefix=M64 -check-prefix=MSVC2013 %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w -fms-compatibility-version=19.00 | FileCheck --check-prefix=MSC --check-prefix=M64 -check-prefix=MSVC2015 -check-prefix=M64MSVC2015 %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w -fms-compatibility-version=18.00 | FileCheck --check-prefix=MSC --check-prefix=M64 -check-prefix=MSVC2013 -check-prefix=M64MSVC2013 %s
 
 // RUN: %clang_cc1 -triple i686-windows-gnu-emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w | FileCheck --check-prefix=GNU --check-prefix=G32 %s
 // RUN: %clang_cc1 -triple x86_64-windows-gnu  -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w | FileCheck --check-prefix=GNU --check-prefix=G64 %s
@@ -561,7 +561,7 @@
 
   // Explicitly defaulted copy constructur:
   T(const T&) = default;
-  // M32-DAG: define weak_odr dllexport x86_thiscallcc %struct.T* @"\01??0T@@QAE@ABU0@@Z"
+  // M32MSVC2013-DAG: define weak_odr dllexport x86_thiscallcc %struct.T* @"\01??0T@@QAE@ABU0@@Z"
 
   void a() {}
   // M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01?a@T@@QAEXXZ"
@@ -647,9 +647,34 @@
 
 struct __declspec(dllexport) DefaultedCtorsDtors {
   DefaultedCtorsDtors() = default;
-  // M32-DAG: define weak_odr dllexport x86_thiscallcc %struct.DefaultedCtorsDtors* @"\01??0DefaultedCtorsDtors@@QAE@XZ"
+  // M32MSVC2013-DAG: define weak_odr dllexport x86_thiscallcc %struct.DefaultedCtorsDtors* @"\01??0DefaultedCtorsDtors@@QAE@XZ"
   ~DefaultedCtorsDtors() = default;
-  // M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01??1DefaultedCtorsDtors@@QAE@XZ"
+  // M32MSVC2013-DAG: define weak_odr dllexport x86_thiscallcc void @"\01??1DefaultedCtorsDtors@@QAE@XZ"
+};
+
+// Export defaulted member function definitions declared inside class.
+struct __declspec(dllexport) ExportDefaultedInclassDefs {
+  ExportDefaultedInclassDefs() = default;
+  // M32VS2013-DAG: define weak_odr dllexport x86_thiscallcc %struct.ExportDefaultedInclassDefs* @"\01??0ExportDefaultedInclassDefs@@QAE@XZ"(%struct.ExportDefaultedInclassDefs* returned %this)
+  // M64VS2013-DAG: define weak_odr dllexport%struct.ExportDefaultedInclassDefs* @"\01??0ExportDefaultedInclassDefs@@QEAA@XZ"(%struct.ExportDefaultedInclassDefs* returned %this)
+  // M32VS2015-NOT: define weak_odr dllexport x86_thiscallcc %struct.ExportDefaultedInclassDefs* @"\01??0ExportDefaultedInclassDefs@@QAE@XZ"(%struct.Ex

r270047 - [Clang][AVX512][intrinsics] continue completing missing set intrinsics

2016-05-19 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Thu May 19 07:07:49 2016
New Revision: 270047

URL: http://llvm.org/viewvc/llvm-project?rev=270047&view=rev
Log:
[Clang][AVX512][intrinsics] continue completing missing set intrinsics

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


Modified:
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=270047&r1=270046&r2=270047&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Thu May 19 07:07:49 2016
@@ -8983,6 +8983,21 @@ _mm512_mask_set1_epi64 (__m512i __O, __m
  __M);
 }
 
+static __inline __m512i __DEFAULT_FN_ATTRS
+_mm512_set_epi32 (int __A, int __B, int __C, int __D,
+ int __E, int __F, int __G, int __H,
+ int __I, int __J, int __K, int __L,
+ int __M, int __N, int __O, int __P)
+{
+  return __extension__ (__m512i)(__v16si)
+  { __P, __O, __N, __M, __L, __K, __J, __I,
+__H, __G, __F, __E, __D, __C, __B, __A };
+}
+
+#define _mm512_setr_epi32(e0,e1,e2,e3,e4,e5,e6,e7,   \
+   e8,e9,e10,e11,e12,e13,e14,e15)  \
+  _mm512_set_epi32(e15,e14,e13,e12,e11,e10,e9,e8,e7,e6,e5,e4,e3,e2,e1,e0)
+  
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 _mm512_set_epi64 (long long __A, long long __B, long long __C,
  long long __D, long long __E, long long __F,
@@ -8992,6 +9007,9 @@ _mm512_set_epi64 (long long __A, long lo
   { __H, __G, __F, __E, __D, __C, __B, __A };
 }
 
+#define _mm512_setr_epi64(e0,e1,e2,e3,e4,e5,e6,e7)   \
+  _mm512_set_epi64(e7,e6,e5,e4,e3,e2,e1,e0)
+
 static __inline__ __m512d __DEFAULT_FN_ATTRS
 _mm512_set_pd (double __A, double __B, double __C, double __D,
 double __E, double __F, double __G, double __H)
@@ -9000,6 +9018,9 @@ _mm512_set_pd (double __A, double __B, d
   { __H, __G, __F, __E, __D, __C, __B, __A };
 }
 
+#define _mm512_setr_pd(e0,e1,e2,e3,e4,e5,e6,e7)  \
+  _mm512_set_pd(e7,e6,e5,e4,e3,e2,e1,e0)
+
 static __inline__ __m512 __DEFAULT_FN_ATTRS
 _mm512_set_ps (float __A, float __B, float __C, float __D,
 float __E, float __F, float __G, float __H,
@@ -9011,6 +9032,9 @@ _mm512_set_ps (float __A, float __B, flo
 __H, __G, __F, __E, __D, __C, __B, __A };
 }
 
+#define _mm512_setr_ps(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15) \
+  _mm512_set_ps(e15,e14,e13,e12,e11,e10,e9,e8,e7,e6,e5,e4,e3,e2,e1,e0)
+
 #undef __DEFAULT_FN_ATTRS
 
 #endif // __AVX512FINTRIN_H

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=270047&r1=270046&r2=270047&view=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Thu May 19 07:07:49 2016
@@ -6521,6 +6521,74 @@ __m512i test_mm512_mask_set1_epi32 (__m5
   return _mm512_mask_set1_epi32 ( __O, __M, __A);
 }
 
+__m512i test_mm512_set_epi32 (int __A, int __B, int __C, int __D,
+   int __E, int __F, int __G, int __H,
+   int __I, int __J, int __K, int __L,
+   int __M, int __N, int __O, int __P)
+{
+ //CHECK-LABLE: @test_mm512_set_epi32
+ //CHECK: insertelement{{.*}}i32 0
+//CHECK: insertelement{{.*}}i32 1
+//CHECK: insertelement{{.*}}i32 2
+//CHECK: insertelement{{.*}}i32 3
+//CHECK: insertelement{{.*}}i32 4
+//CHECK: insertelement{{.*}}i32 5
+//CHECK: insertelement{{.*}}i32 6
+//CHECK: insertelement{{.*}}i32 7
+//CHECK: insertelement{{.*}}i32 8
+//CHECK: insertelement{{.*}}i32 9
+//CHECK: insertelement{{.*}}i32 10
+//CHECK: insertelement{{.*}}i32 11
+//CHECK: insertelement{{.*}}i32 12
+//CHECK: insertelement{{.*}}i32 13
+//CHECK: insertelement{{.*}}i32 14
+//CHECK: insertelement{{.*}}i32 15
+ return _mm512_set_epi32( __A, __B, __C, __D,__E, __F, __G, __H,
+  __I, __J, __K, __L,__M, __N, __O, __P);
+}
+
+__m512i test_mm512_setr_epi32 (int __A, int __B, int __C, int __D,
+   int __E, int __F, int __G, int __H,
+   int __I, int __J, int __K, int __L,
+   int __M, int __N, int __O, int __P)
+{
+//CHECK-LABLE: @test_mm512_setr_epi32
+ //CHECK: %0 = load{{.*}}%__P.addr, align 4
+ //CHECK: %1 = load{{.*}}%__O.addr, align 4
+ //CHECK: %2 = load{{.*}}%__N.addr, align 4
+ //CHECK: %3 = load{{.*}}%__M.addr, align 4
+ //CHECK: %4 = load{{.*}}%__L.addr, align 4
+ //CHECK: %5 = load{{.*}}%__K.addr, align 4
+ //CHECK: %6 = load{{.*}}%__J.addr, align 4
+ //CHECK: %7 = load{{.*}}%__I.addr, align 4
+ //CHECK: %8 = load{{.*}}%__H.addr, align 4
+ //CHECK: %9 = load{{.*}}%__G.addr, align 4
+ //CHECK: %10 = load{{.*}}%__F.addr, align 4
+ //CHECK: %11 = load{{.*}}%__E.addr, align 4
+ //CHECK: %12 =

[PATCH] D20424: [include-fixer] Make search handle fully qualified names correctly.

2016-05-19 Thread Benjamin Kramer via cfe-commits
bkramer created this revision.
bkramer added reviewers: hokein, ioeric.
bkramer added a subscriber: cfe-commits.

If a search string starts with "::" we don't want to return any results
for suffixes of that string.

http://reviews.llvm.org/D20424

Files:
  include-fixer/SymbolIndexManager.cpp
  unittests/include-fixer/IncludeFixerTest.cpp

Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -103,6 +103,12 @@
   // too.
   EXPECT_EQ("#include \n\nstring foo;\n",
 runIncludeFixer("string foo;\n"));
+
+  // Fully qualified name.
+  EXPECT_EQ("#include \n\n::std::string foo;\n",
+runIncludeFixer("::std::string foo;\n"));
+  // Should not match std::string.
+  EXPECT_EQ("::string foo;\n", runIncludeFixer("::string foo;\n"));
 }
 
 TEST(IncludeFixer, IncompleteType) {
Index: include-fixer/SymbolIndexManager.cpp
===
--- include-fixer/SymbolIndexManager.cpp
+++ include-fixer/SymbolIndexManager.cpp
@@ -24,6 +24,12 @@
   llvm::SmallVector Names;
   Identifier.split(Names, "::");
 
+  bool IsFullyQualified = false;
+  if (Identifier.startswith("::")) {
+Names.erase(Names.begin()); // Drop first (empty) element.
+IsFullyQualified = true;
+  }
+
   // As long as we don't find a result keep stripping name parts from the end.
   // This is to support nested classes which aren't recorded in the database.
   // Eventually we will either hit a class (namespaces aren't in the database
@@ -61,6 +67,11 @@
   }
 }
 
+// If the name was qualified we only want to add results if we 
evaluated
+// all contexts.
+if (IsFullyQualified)
+  IsMatched &= SymbolContext == Symbol.getContexts().end();
+
 // FIXME: Support full match. At this point, we only find symbols in
 // database which end with the same contexts with the identifier.
 if (IsMatched && IdentiferContext == Names.rend()) {


Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -103,6 +103,12 @@
   // too.
   EXPECT_EQ("#include \n\nstring foo;\n",
 runIncludeFixer("string foo;\n"));
+
+  // Fully qualified name.
+  EXPECT_EQ("#include \n\n::std::string foo;\n",
+runIncludeFixer("::std::string foo;\n"));
+  // Should not match std::string.
+  EXPECT_EQ("::string foo;\n", runIncludeFixer("::string foo;\n"));
 }
 
 TEST(IncludeFixer, IncompleteType) {
Index: include-fixer/SymbolIndexManager.cpp
===
--- include-fixer/SymbolIndexManager.cpp
+++ include-fixer/SymbolIndexManager.cpp
@@ -24,6 +24,12 @@
   llvm::SmallVector Names;
   Identifier.split(Names, "::");
 
+  bool IsFullyQualified = false;
+  if (Identifier.startswith("::")) {
+Names.erase(Names.begin()); // Drop first (empty) element.
+IsFullyQualified = true;
+  }
+
   // As long as we don't find a result keep stripping name parts from the end.
   // This is to support nested classes which aren't recorded in the database.
   // Eventually we will either hit a class (namespaces aren't in the database
@@ -61,6 +67,11 @@
   }
 }
 
+// If the name was qualified we only want to add results if we evaluated
+// all contexts.
+if (IsFullyQualified)
+  IsMatched &= SymbolContext == Symbol.getContexts().end();
+
 // FIXME: Support full match. At this point, we only find symbols in
 // database which end with the same contexts with the identifier.
 if (IsMatched && IdentiferContext == Names.rend()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20089: Adding a TargetParser for AArch64

2016-05-19 Thread jojo.ma via cfe-commits
jojo added inline comments.


Comment at: lib/Support/TargetParser.cpp:441
@@ +440,3 @@
+  if (Extensions & AArch64::AEK_PROFILE)
+Features.push_back("+spe");
+

bsmith wrote:
> For ARM there is a table that defines these extensions and how they map to 
> backend features, it would be good to do this in a similar manner.
There is a similar one for aarch64.But only in the context of switch-case,they 
can be map to backend features by table look-up. eg,getArchExtName().
We need to judge the value of "Extensions" by means of bit operations here.It 
is not possible to use the table.


Comment at: lib/Support/TargetParser.cpp:770
@@ +769,3 @@
+  if (A.ID == ARM::AK_ARMV8_2A)
+Features.push_back("+v8.2a");
+  return A.ID;

bsmith wrote:
> Why do we need to add these features explicitly, can't we just pass through 
> the correct triple?
Sometimes people do not give a complete and standardized triple, which leads to 
the obtaining of these features by triple impossible.
It maybe safer to add these features by "-march".


Repository:
  rL LLVM

http://reviews.llvm.org/D20089



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


Re: [PATCH] D20424: [include-fixer] Make search handle fully qualified names correctly.

2016-05-19 Thread Haojian Wu via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM with one nit.



Comment at: include-fixer/SymbolIndexManager.cpp:73
@@ +72,3 @@
+if (IsFullyQualified)
+  IsMatched &= SymbolContext == Symbol.getContexts().end();
+

Might be `IsMatched &= (SymbolContext == Symbol.getContexts().end());` for 
reading clearly?


http://reviews.llvm.org/D20424



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


[clang-tools-extra] r270055 - [include-fixer] Make search handle fully qualified names correctly.

2016-05-19 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu May 19 07:41:56 2016
New Revision: 270055

URL: http://llvm.org/viewvc/llvm-project?rev=270055&view=rev
Log:
[include-fixer] Make search handle fully qualified names correctly.

If a search string starts with "::" we don't want to return any results
for suffixes of that string.

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

Modified:
clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp?rev=270055&r1=270054&r2=270055&view=diff
==
--- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp Thu May 19 
07:41:56 2016
@@ -24,6 +24,12 @@ SymbolIndexManager::search(llvm::StringR
   llvm::SmallVector Names;
   Identifier.split(Names, "::");
 
+  bool IsFullyQualified = false;
+  if (Identifier.startswith("::")) {
+Names.erase(Names.begin()); // Drop first (empty) element.
+IsFullyQualified = true;
+  }
+
   // As long as we don't find a result keep stripping name parts from the end.
   // This is to support nested classes which aren't recorded in the database.
   // Eventually we will either hit a class (namespaces aren't in the database
@@ -61,6 +67,11 @@ SymbolIndexManager::search(llvm::StringR
   }
 }
 
+// If the name was qualified we only want to add results if we 
evaluated
+// all contexts.
+if (IsFullyQualified)
+  IsMatched &= (SymbolContext == Symbol.getContexts().end());
+
 // FIXME: Support full match. At this point, we only find symbols in
 // database which end with the same contexts with the identifier.
 if (IsMatched && IdentiferContext == Names.rend()) {

Modified: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp?rev=270055&r1=270054&r2=270055&view=diff
==
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Thu 
May 19 07:41:56 2016
@@ -103,6 +103,12 @@ TEST(IncludeFixer, Typo) {
   // too.
   EXPECT_EQ("#include \n\nstring foo;\n",
 runIncludeFixer("string foo;\n"));
+
+  // Fully qualified name.
+  EXPECT_EQ("#include \n\n::std::string foo;\n",
+runIncludeFixer("::std::string foo;\n"));
+  // Should not match std::string.
+  EXPECT_EQ("::string foo;\n", runIncludeFixer("::string foo;\n"));
 }
 
 TEST(IncludeFixer, IncompleteType) {


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


Re: [PATCH] D20424: [include-fixer] Make search handle fully qualified names correctly.

2016-05-19 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270055: [include-fixer] Make search handle fully qualified 
names correctly. (authored by d0k).

Changed prior to commit:
  http://reviews.llvm.org/D20424?vs=57766&id=57772#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20424

Files:
  clang-tools-extra/trunk/include-fixer/SymbolIndexManager.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
@@ -103,6 +103,12 @@
   // too.
   EXPECT_EQ("#include \n\nstring foo;\n",
 runIncludeFixer("string foo;\n"));
+
+  // Fully qualified name.
+  EXPECT_EQ("#include \n\n::std::string foo;\n",
+runIncludeFixer("::std::string foo;\n"));
+  // Should not match std::string.
+  EXPECT_EQ("::string foo;\n", runIncludeFixer("::string foo;\n"));
 }
 
 TEST(IncludeFixer, IncompleteType) {
Index: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
===
--- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
+++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
@@ -24,6 +24,12 @@
   llvm::SmallVector Names;
   Identifier.split(Names, "::");
 
+  bool IsFullyQualified = false;
+  if (Identifier.startswith("::")) {
+Names.erase(Names.begin()); // Drop first (empty) element.
+IsFullyQualified = true;
+  }
+
   // As long as we don't find a result keep stripping name parts from the end.
   // This is to support nested classes which aren't recorded in the database.
   // Eventually we will either hit a class (namespaces aren't in the database
@@ -61,6 +67,11 @@
   }
 }
 
+// If the name was qualified we only want to add results if we 
evaluated
+// all contexts.
+if (IsFullyQualified)
+  IsMatched &= (SymbolContext == Symbol.getContexts().end());
+
 // FIXME: Support full match. At this point, we only find symbols in
 // database which end with the same contexts with the identifier.
 if (IsMatched && IdentiferContext == Names.rend()) {


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
@@ -103,6 +103,12 @@
   // too.
   EXPECT_EQ("#include \n\nstring foo;\n",
 runIncludeFixer("string foo;\n"));
+
+  // Fully qualified name.
+  EXPECT_EQ("#include \n\n::std::string foo;\n",
+runIncludeFixer("::std::string foo;\n"));
+  // Should not match std::string.
+  EXPECT_EQ("::string foo;\n", runIncludeFixer("::string foo;\n"));
 }
 
 TEST(IncludeFixer, IncompleteType) {
Index: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
===
--- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
+++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
@@ -24,6 +24,12 @@
   llvm::SmallVector Names;
   Identifier.split(Names, "::");
 
+  bool IsFullyQualified = false;
+  if (Identifier.startswith("::")) {
+Names.erase(Names.begin()); // Drop first (empty) element.
+IsFullyQualified = true;
+  }
+
   // As long as we don't find a result keep stripping name parts from the end.
   // This is to support nested classes which aren't recorded in the database.
   // Eventually we will either hit a class (namespaces aren't in the database
@@ -61,6 +67,11 @@
   }
 }
 
+// If the name was qualified we only want to add results if we evaluated
+// all contexts.
+if (IsFullyQualified)
+  IsMatched &= (SymbolContext == Symbol.getContexts().end());
+
 // FIXME: Support full match. At this point, we only find symbols in
 // database which end with the same contexts with the identifier.
 if (IsMatched && IdentiferContext == Names.rend()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20198: clang-format: [JS] sort ES6 imports.

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

lg


http://reviews.llvm.org/D20198



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


[PATCH] D20428: Tracking exception specification source locations

2016-05-19 Thread Aaron Ballman via cfe-commits
aaron.ballman created this revision.
aaron.ballman added a reviewer: rsmith.
aaron.ballman added subscribers: cfe-commits, hintonda, alexfh.

We do not currently track the source locations for exception specifications 
such that their source range can be queried through the AST. This leads to 
trying to write more complex code to determine the source range for uses like 
FixItHints (see D18575 for an example). In addition to use within tools like 
clang-tidy, I think this information may become more important to track as 
exception specifications become more integrated into the type system.

One thing this patch is missing is a test case. I'm not certain of the best way 
to test this functionality in isolation; suggestions welcome.

http://reviews.llvm.org/D20428

Files:
  include/clang/AST/Decl.h
  include/clang/AST/TypeLoc.h
  lib/AST/Decl.cpp
  lib/Sema/SemaType.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp

Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -572,6 +572,7 @@
   Record.AddSourceLocation(TL.getLocalRangeBegin());
   Record.AddSourceLocation(TL.getLParenLoc());
   Record.AddSourceLocation(TL.getRParenLoc());
+  Record.AddSourceRange(TL.getExceptionSpecRange());
   Record.AddSourceLocation(TL.getLocalRangeEnd());
   for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i)
 Record.AddDeclRef(TL.getParam(i));
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -5812,6 +5812,8 @@
   TL.setLocalRangeBegin(ReadSourceLocation(Record, Idx));
   TL.setLParenLoc(ReadSourceLocation(Record, Idx));
   TL.setRParenLoc(ReadSourceLocation(Record, Idx));
+  TL.setExceptionSpecRange(SourceRange(ReadSourceLocation(Record, Idx),
+   ReadSourceLocation(Record, Idx)));
   TL.setLocalRangeEnd(ReadSourceLocation(Record, Idx));
   for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i) {
 TL.setParam(i, ReadDeclAs(Record, Idx));
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -4919,6 +4919,7 @@
   NewTL.setLocalRangeBegin(TL.getLocalRangeBegin());
   NewTL.setLParenLoc(TL.getLParenLoc());
   NewTL.setRParenLoc(TL.getRParenLoc());
+  NewTL.setExceptionSpecRange(TL.getExceptionSpecRange());
   NewTL.setLocalRangeEnd(TL.getLocalRangeEnd());
   for (unsigned i = 0, e = NewTL.getNumParams(); i != e; ++i)
 NewTL.setParam(i, ParamDecls[i]);
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -5065,7 +5065,7 @@
 ParmVarDecl *Param = cast(FTI.Params[i].Param);
 TL.setParam(tpi++, Param);
   }
-  // FIXME: exception specs
+  TL.setExceptionSpecRange(FTI.getExceptionSpecRange());
 }
 void VisitParenTypeLoc(ParenTypeLoc TL) {
   assert(Chunk.Kind == DeclaratorChunk::Paren);
Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -2935,6 +2935,18 @@
   return RTRange;
 }
 
+SourceRange FunctionDecl::getExceptionSpecSourceRange() const {
+  const TypeSourceInfo *TSI = getTypeSourceInfo();
+  if (!TSI)
+return SourceRange();
+  FunctionTypeLoc FTL =
+TSI->getTypeLoc().IgnoreParens().getAs();
+  if (!FTL)
+return SourceRange();
+
+  return FTL.getExceptionSpecRange();
+}
+
 const Attr *FunctionDecl::getUnusedResultAttr() const {
   QualType RetType = getReturnType();
   if (RetType->isRecordType()) {
Index: include/clang/AST/TypeLoc.h
===
--- include/clang/AST/TypeLoc.h
+++ include/clang/AST/TypeLoc.h
@@ -1248,6 +1248,7 @@
   SourceLocation LocalRangeBegin;
   SourceLocation LParenLoc;
   SourceLocation RParenLoc;
+  SourceRange ExceptionSpecRange;
   SourceLocation LocalRangeEnd;
 };
 
@@ -1289,6 +1290,13 @@
 return SourceRange(getLParenLoc(), getRParenLoc());
   }
 
+  SourceRange getExceptionSpecRange() const {
+return this->getLocalData()->ExceptionSpecRange;
+  }
+  void setExceptionSpecRange(SourceRange R) {
+this->getLocalData()->ExceptionSpecRange = R;
+  }
+
   ArrayRef getParams() const {
 return llvm::makeArrayRef(getParmArray(), getNumParams());
   }
@@ -1318,6 +1326,7 @@
 setLocalRangeBegin(Loc);
 setLParenLoc(Loc);
 setRParenLoc(Loc);
+setExceptionSpecRange(SourceRange(Loc));
 setLocalRangeEnd(Loc);
 for (unsigned i = 0, e = getNumParams(); i != e; ++i)
   setParam(i, nullptr);
Index: include/clang/AST/Decl.h
===
--- include/clang/AST/Decl.h
+++ includ

r270058 - [ARM] Fix cdp intrinsic

2016-05-19 Thread Ranjeet Singh via cfe-commits
Author: rsingh
Date: Thu May 19 08:04:34 2016
New Revision: 270058

URL: http://llvm.org/viewvc/llvm-project?rev=270058&view=rev
Log:
[ARM] Fix cdp intrinsic

- Fixed cdp intrinsic to only accept compile time
  constant values previously you could pass in a
  variable to the builtin which would result in
  illegal llvm assembly output

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


Modified:
cfe/trunk/include/clang/Basic/BuiltinsARM.def
cfe/trunk/test/CodeGen/builtins-arm.c
cfe/trunk/test/Sema/builtins-arm.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsARM.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsARM.def?rev=270058&r1=270057&r2=270058&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsARM.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsARM.def Thu May 19 08:04:34 2016
@@ -52,8 +52,8 @@ BUILTIN(__builtin_arm_mcr, "vUIiUIiUiUIi
 BUILTIN(__builtin_arm_mcr2, "vUIiUIiUiUIiUIiUIi", "")
 BUILTIN(__builtin_arm_mrc, "UiUIiUIiUIiUIiUIi", "")
 BUILTIN(__builtin_arm_mrc2, "UiUIiUIiUIiUIiUIi", "")
-BUILTIN(__builtin_arm_cdp, "vUiUiUiUiUiUi", "")
-BUILTIN(__builtin_arm_cdp2, "vUiUiUiUiUiUi", "")
+BUILTIN(__builtin_arm_cdp, "vUIiUIiUIiUIiUIiUIi", "")
+BUILTIN(__builtin_arm_cdp2, "vUIiUIiUIiUIiUIiUIi", "")
 BUILTIN(__builtin_arm_mcrr, "vUIiUIiUiUiUIi", "")
 BUILTIN(__builtin_arm_mcrr2, "vUIiUIiUiUiUIi", "")
 

Modified: cfe/trunk/test/CodeGen/builtins-arm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-arm.c?rev=270058&r1=270057&r2=270058&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-arm.c (original)
+++ cfe/trunk/test/CodeGen/builtins-arm.c Thu May 19 08:04:34 2016
@@ -84,6 +84,20 @@ void prefetch(int i) {
 // CHECK: call {{.*}} @llvm.prefetch(i8* %{{.*}}, i32 1, i32 3, i32 0)
 }
 
+void cdp() {
+  // CHECK: define void @cdp()
+  // CHECK: call void @llvm.arm.cdp(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6)
+  // CHECK-NEXT: ret void
+  __builtin_arm_cdp(1, 2, 3, 4, 5, 6);
+}
+
+void cdp2() {
+  // CHECK: define void @cdp2()
+  // CHECK: call void @llvm.arm.cdp2(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6)
+  // CHECK-NEXT: ret void
+  __builtin_arm_cdp2(1, 2, 3, 4, 5, 6);
+}
+
 unsigned mrc() {
   // CHECK: define i32 @mrc()
   // CHECK: [[R:%.*]] = call i32 @llvm.arm.mrc(i32 15, i32 0, i32 13, i32 0, 
i32 3)

Modified: cfe/trunk/test/Sema/builtins-arm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/builtins-arm.c?rev=270058&r1=270057&r2=270058&view=diff
==
--- cfe/trunk/test/Sema/builtins-arm.c (original)
+++ cfe/trunk/test/Sema/builtins-arm.c Thu May 19 08:04:34 2016
@@ -48,6 +48,18 @@ void test5() {
 }
 
 void test6(int a, int b, int c) {
+  __builtin_arm_cdp(a, 2, 3, 4, 5, 6); // expected-error {{argument to 
'__builtin_arm_cdp' must be a constant integer}}
+  __builtin_arm_cdp(1, a, 3, 4, 5, 6); // expected-error {{argument to 
'__builtin_arm_cdp' must be a constant integer}}
+  __builtin_arm_cdp(1, 2, a, 4, 5, 6); // expected-error {{argument to 
'__builtin_arm_cdp' must be a constant integer}}
+  __builtin_arm_cdp(1, 2, 3, a, 5, 6); // expected-error {{argument to 
'__builtin_arm_cdp' must be a constant integer}}
+  __builtin_arm_cdp(1, 2, 3, 4, 5, a); // expected-error {{argument to 
'__builtin_arm_cdp' must be a constant integer}}
+
+  __builtin_arm_cdp2(a, 2, 3, 4, 5, 6); // expected-error {{argument to 
'__builtin_arm_cdp2' must be a constant integer}}
+  __builtin_arm_cdp2(1, a, 3, 4, 5, 6); // expected-error {{argument to 
'__builtin_arm_cdp2' must be a constant integer}}
+  __builtin_arm_cdp2(1, 2, a, 4, 5, 6); // expected-error {{argument to 
'__builtin_arm_cdp2' must be a constant integer}}
+  __builtin_arm_cdp2(1, 2, 3, a, 5, 6); // expected-error {{argument to 
'__builtin_arm_cdp2' must be a constant integer}}
+  __builtin_arm_cdp2(1, 2, 3, 4, 5, a); // expected-error {{argument to 
'__builtin_arm_cdp2' must be a constant integer}}
+
   __builtin_arm_mrc( a, 0, 13, 0, 3); // expected-error {{argument to 
'__builtin_arm_mrc' must be a constant integer}}
   __builtin_arm_mrc(15, a, 13, 0, 3); // expected-error {{argument to 
'__builtin_arm_mrc' must be a constant integer}}
   __builtin_arm_mrc(15, 0,  a, 0, 3); // expected-error {{argument to 
'__builtin_arm_mrc' must be a constant integer}}


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


Re: [PATCH] D20394: Fix cdp intrinsic

2016-05-19 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270058: [ARM] Fix cdp intrinsic (authored by rsingh).

Changed prior to commit:
  http://reviews.llvm.org/D20394?vs=57698&id=5#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20394

Files:
  cfe/trunk/include/clang/Basic/BuiltinsARM.def
  cfe/trunk/test/CodeGen/builtins-arm.c
  cfe/trunk/test/Sema/builtins-arm.c

Index: cfe/trunk/include/clang/Basic/BuiltinsARM.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsARM.def
+++ cfe/trunk/include/clang/Basic/BuiltinsARM.def
@@ -52,8 +52,8 @@
 BUILTIN(__builtin_arm_mcr2, "vUIiUIiUiUIiUIiUIi", "")
 BUILTIN(__builtin_arm_mrc, "UiUIiUIiUIiUIiUIi", "")
 BUILTIN(__builtin_arm_mrc2, "UiUIiUIiUIiUIiUIi", "")
-BUILTIN(__builtin_arm_cdp, "vUiUiUiUiUiUi", "")
-BUILTIN(__builtin_arm_cdp2, "vUiUiUiUiUiUi", "")
+BUILTIN(__builtin_arm_cdp, "vUIiUIiUIiUIiUIiUIi", "")
+BUILTIN(__builtin_arm_cdp2, "vUIiUIiUIiUIiUIiUIi", "")
 BUILTIN(__builtin_arm_mcrr, "vUIiUIiUiUiUIi", "")
 BUILTIN(__builtin_arm_mcrr2, "vUIiUIiUiUiUIi", "")
 
Index: cfe/trunk/test/CodeGen/builtins-arm.c
===
--- cfe/trunk/test/CodeGen/builtins-arm.c
+++ cfe/trunk/test/CodeGen/builtins-arm.c
@@ -84,6 +84,20 @@
 // CHECK: call {{.*}} @llvm.prefetch(i8* %{{.*}}, i32 1, i32 3, i32 0)
 }
 
+void cdp() {
+  // CHECK: define void @cdp()
+  // CHECK: call void @llvm.arm.cdp(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6)
+  // CHECK-NEXT: ret void
+  __builtin_arm_cdp(1, 2, 3, 4, 5, 6);
+}
+
+void cdp2() {
+  // CHECK: define void @cdp2()
+  // CHECK: call void @llvm.arm.cdp2(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6)
+  // CHECK-NEXT: ret void
+  __builtin_arm_cdp2(1, 2, 3, 4, 5, 6);
+}
+
 unsigned mrc() {
   // CHECK: define i32 @mrc()
   // CHECK: [[R:%.*]] = call i32 @llvm.arm.mrc(i32 15, i32 0, i32 13, i32 0, 
i32 3)
Index: cfe/trunk/test/Sema/builtins-arm.c
===
--- cfe/trunk/test/Sema/builtins-arm.c
+++ cfe/trunk/test/Sema/builtins-arm.c
@@ -48,6 +48,18 @@
 }
 
 void test6(int a, int b, int c) {
+  __builtin_arm_cdp(a, 2, 3, 4, 5, 6); // expected-error {{argument to 
'__builtin_arm_cdp' must be a constant integer}}
+  __builtin_arm_cdp(1, a, 3, 4, 5, 6); // expected-error {{argument to 
'__builtin_arm_cdp' must be a constant integer}}
+  __builtin_arm_cdp(1, 2, a, 4, 5, 6); // expected-error {{argument to 
'__builtin_arm_cdp' must be a constant integer}}
+  __builtin_arm_cdp(1, 2, 3, a, 5, 6); // expected-error {{argument to 
'__builtin_arm_cdp' must be a constant integer}}
+  __builtin_arm_cdp(1, 2, 3, 4, 5, a); // expected-error {{argument to 
'__builtin_arm_cdp' must be a constant integer}}
+
+  __builtin_arm_cdp2(a, 2, 3, 4, 5, 6); // expected-error {{argument to 
'__builtin_arm_cdp2' must be a constant integer}}
+  __builtin_arm_cdp2(1, a, 3, 4, 5, 6); // expected-error {{argument to 
'__builtin_arm_cdp2' must be a constant integer}}
+  __builtin_arm_cdp2(1, 2, a, 4, 5, 6); // expected-error {{argument to 
'__builtin_arm_cdp2' must be a constant integer}}
+  __builtin_arm_cdp2(1, 2, 3, a, 5, 6); // expected-error {{argument to 
'__builtin_arm_cdp2' must be a constant integer}}
+  __builtin_arm_cdp2(1, 2, 3, 4, 5, a); // expected-error {{argument to 
'__builtin_arm_cdp2' must be a constant integer}}
+
   __builtin_arm_mrc( a, 0, 13, 0, 3); // expected-error {{argument to 
'__builtin_arm_mrc' must be a constant integer}}
   __builtin_arm_mrc(15, a, 13, 0, 3); // expected-error {{argument to 
'__builtin_arm_mrc' must be a constant integer}}
   __builtin_arm_mrc(15, 0,  a, 0, 3); // expected-error {{argument to 
'__builtin_arm_mrc' must be a constant integer}}


Index: cfe/trunk/include/clang/Basic/BuiltinsARM.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsARM.def
+++ cfe/trunk/include/clang/Basic/BuiltinsARM.def
@@ -52,8 +52,8 @@
 BUILTIN(__builtin_arm_mcr2, "vUIiUIiUiUIiUIiUIi", "")
 BUILTIN(__builtin_arm_mrc, "UiUIiUIiUIiUIiUIi", "")
 BUILTIN(__builtin_arm_mrc2, "UiUIiUIiUIiUIiUIi", "")
-BUILTIN(__builtin_arm_cdp, "vUiUiUiUiUiUi", "")
-BUILTIN(__builtin_arm_cdp2, "vUiUiUiUiUiUi", "")
+BUILTIN(__builtin_arm_cdp, "vUIiUIiUIiUIiUIiUIi", "")
+BUILTIN(__builtin_arm_cdp2, "vUIiUIiUIiUIiUIiUIi", "")
 BUILTIN(__builtin_arm_mcrr, "vUIiUIiUiUiUIi", "")
 BUILTIN(__builtin_arm_mcrr2, "vUIiUIiUiUiUIi", "")
 
Index: cfe/trunk/test/CodeGen/builtins-arm.c
===
--- cfe/trunk/test/CodeGen/builtins-arm.c
+++ cfe/trunk/test/CodeGen/builtins-arm.c
@@ -84,6 +84,20 @@
 // CHECK: call {{.*}} @llvm.prefetch(i8* %{{.*}}, i32 1, i32 3, i32 0)
 }
 
+void cdp() {
+  // CHECK: define void @cdp()
+  // CHECK: call void @llvm.arm.cdp(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6)
+  // CHECK-NEXT: ret void
+  __builtin_arm_cdp(1, 2, 3, 4, 

[PATCH] D20429: [clang-tidy] Handle using-decls with more than one shadow decl.

2016-05-19 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: alexfh.
hokein added subscribers: djasper, cfe-commits.

http://reviews.llvm.org/D20429

Files:
  clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tidy/misc/UnusedUsingDeclsCheck.h
  test/clang-tidy/misc-unused-using-decls.cpp

Index: test/clang-tidy/misc-unused-using-decls.cpp
===
--- test/clang-tidy/misc-unused-using-decls.cpp
+++ test/clang-tidy/misc-unused-using-decls.cpp
@@ -31,6 +31,8 @@
 template  int UsedTemplateFunc() { return 1; }
 template  int UnusedTemplateFunc() { return 1; }
 template  int UsedInTemplateFunc() { return 1; }
+void OverloadFunc(int);
+void OverloadFunc(double);
 
 class ostream {
 public:
@@ -79,6 +81,10 @@
   UsedInTemplateFunc();
 }
 
+using n::OverloadFunc; // OverloadFunc
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'OverloadFunc' is unused
+// CHECK-FIXES: {{^}}// OverloadFunc
+
 #define DEFINE_INT(name)\
   namespace INT {   \
   static const int _##name = 1; \
Index: clang-tidy/misc/UnusedUsingDeclsCheck.h
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.h
+++ clang-tidy/misc/UnusedUsingDeclsCheck.h
@@ -11,7 +11,8 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_UNUSED_USING_DECLS_H
 
 #include "../ClangTidy.h"
-#include "llvm/ADT/DenseMap.h"
+#include 
+#include 
 
 namespace clang {
 namespace tidy {
@@ -32,8 +33,16 @@
 private:
   void removeFromFoundDecls(const Decl *D);
 
-  llvm::DenseMap FoundDecls;
-  llvm::DenseMap FoundRanges;
+  struct UsingDeclContext {
+explicit UsingDeclContext(const UsingDecl *FoundUsingDecl)
+: FoundUsingDecl(FoundUsingDecl), IsUsed(false) {}
+std::set UsingTargetDecls;
+const UsingDecl *FoundUsingDecl;
+CharSourceRange UsingDeclRange;
+bool IsUsed;
+  };
+
+  std::vector Contexts;
 };
 
 } // namespace misc
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -18,6 +18,24 @@
 namespace tidy {
 namespace misc {
 
+namespace {
+bool IsValidDecl(const Decl *TargetDecl) {
+  // Ignores using-declarations defined in macros.
+  if (TargetDecl->getLocation().isMacroID())
+return false;
+
+  // Ignores using-declarations defined in class definition.
+  if (isa(TargetDecl->getDeclContext())) {
+llvm::errs() << "context\n";
+return false;
+  }
+
+  return isa(TargetDecl) || isa(TargetDecl) ||
+ isa(TargetDecl) || isa(TargetDecl) ||
+ isa(TargetDecl);
+}
+} // namespace
+
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
@@ -30,33 +48,20 @@
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
   if (const auto *Using = Result.Nodes.getNodeAs("using")) {
-// FIXME: Implement the correct behavior for using declarations with more
-// than one shadow.
-if (Using->shadow_size() != 1)
-  return;
-const auto *TargetDecl =
-Using->shadow_begin()->getTargetDecl()->getCanonicalDecl();
-
-// Ignores using-declarations defined in macros.
-if (TargetDecl->getLocation().isMacroID())
-  return;
-
-// Ignores using-declarations defined in class definition.
-if (isa(TargetDecl->getDeclContext()))
-  return;
-
-if (!isa(TargetDecl) && !isa(TargetDecl) &&
-!isa(TargetDecl) && !isa(TargetDecl) &&
-!isa(TargetDecl))
-  return;
-
-FoundDecls[TargetDecl] = Using;
-FoundRanges[TargetDecl] = CharSourceRange::getCharRange(
+UsingDeclContext Context(Using);
+Context.UsingDeclRange = CharSourceRange::getCharRange(
 Using->getLocStart(),
 Lexer::findLocationAfterToken(
 Using->getLocEnd(), tok::semi, *Result.SourceManager,
 Result.Context->getLangOpts(),
 /*SkipTrailingWhitespaceAndNewLine=*/true));
+for (const auto It : Using->shadows()) {
+  const auto *TargetDecl = It->getTargetDecl()->getCanonicalDecl();
+  if (IsValidDecl(TargetDecl))
+Context.UsingTargetDecls.insert(TargetDecl);
+}
+if (!Context.UsingTargetDecls.empty())
+  Contexts.push_back(Context);
 return;
   }
 
@@ -93,20 +98,24 @@
 }
 
 void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {
-  auto I = FoundDecls.find(D->getCanonicalDecl());
-  if (I != FoundDecls.end())
-I->second = nullptr;
+  for (auto &Context : Contexts) {
+if (Context.UsingTargetDecls.find(D->getCanonicalDecl()) !=
+Context.UsingTargetDecls.end()) {
+  Context.IsUsed = true;
+  break;
+}
+  }
 }
 
 void UnusedUsingDeclsCheck::onEndOfTranslationUnit() {
-  for (const auto &FoundDecl : FoundDecls) {
-if (FoundDecl.sec

Re: [PATCH] D20428: Tracking exception specification source locations

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

Full context diff, please.

> I'm not certain of the best way to test this functionality in isolation;


Same way other locations/ranges are tested in 
unittests/AST/SourceLocationTest.cpp?


http://reviews.llvm.org/D20428



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


[clang-tools-extra] r270059 - [include-fixer] Remove an unused local variable ExistingHeaders.

2016-05-19 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu May 19 08:23:27 2016
New Revision: 270059

URL: http://llvm.org/viewvc/llvm-project?rev=270059&view=rev
Log:
[include-fixer] Remove an unused local variable ExistingHeaders.

Modified:
clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp

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=270059&r1=270058&r2=270059&view=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Thu May 19 08:23:27 
2016
@@ -242,8 +242,6 @@ public:
   std::vector
   CreateReplacementsForHeaders(StringRef Code,
const std::set &Headers) {
-std::set ExistingHeaders;
-
 // Create replacements for new headers.
 clang::tooling::Replacements Insertions;
 if (FirstIncludeOffset == -1U) {


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


Re: [PATCH] D20428: Tracking exception specification source locations

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

In http://reviews.llvm.org/D20428#434238, @alexfh wrote:

> Full context diff, please.


Pardon my complete ignorance, but how? I generated the diff from svn the usual 
way, so I assume I've missed some step.

> > I'm not certain of the best way to test this functionality in isolation;

> 

> 

> Same way other locations/ranges are tested in 
> unittests/AST/SourceLocationTest.cpp?


Ah, good point, we have unit tests for this sort of thing. I'll add some unit 
tests and generate a new patch. Thanks!


http://reviews.llvm.org/D20428



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


Re: [PATCH] D20429: [clang-tidy] Handle using-decls with more than one shadow decl.

2016-05-19 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
This revision now requires changes to proceed.


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:22
@@ +21,3 @@
+namespace {
+bool IsValidDecl(const Decl *TargetDecl) {
+  // Ignores using-declarations defined in macros.

This method assumes a rather non-trivial definition of "valid". Please add a 
comment what exactly this method does.

Also, static is preferred to anonymous namespaces for functions in LLVM style 
(http://llvm.org/docs/CodingStandards.html#anonymous-namespaces):
| ... make anonymous namespaces as small as possible, and only use them for 
class declarations. ...


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:29
@@ +28,3 @@
+  if (isa(TargetDecl->getDeclContext())) {
+llvm::errs() << "context\n";
+return false;

Debug output?


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:102
@@ +101,3 @@
+  for (auto &Context : Contexts) {
+if (Context.UsingTargetDecls.find(D->getCanonicalDecl()) !=
+Context.UsingTargetDecls.end()) {

.count() for sets is as effective, but results in clearer code.


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.h:39
@@ +38,3 @@
+: FoundUsingDecl(FoundUsingDecl), IsUsed(false) {}
+std::set UsingTargetDecls;
+const UsingDecl *FoundUsingDecl;

`SmallPtrSet` should be more efficient here.


Comment at: test/clang-tidy/misc-unused-using-decls.cpp:86
@@ +85,3 @@
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'OverloadFunc' is 
unused
+// CHECK-FIXES: {{^}}// OverloadFunc
+

Not for this patch, but it makes sense to remove trailing comments on deleted 
lines.


http://reviews.llvm.org/D20429



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


Re: [PATCH] D20428: Tracking exception specification source locations

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

In http://reviews.llvm.org/D20428#434242, @aaron.ballman wrote:

> In http://reviews.llvm.org/D20428#434238, @alexfh wrote:
>
> > Full context diff, please.
>
>
> Pardon my complete ignorance, but how? I generated the diff from svn the 
> usual way, so I assume I've missed some step.


There are at least two ways to do this:

1. both `git diff` and `svn diff` can be convinced to produce diffs with full 
context: 
http://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface
2. I find arcanist a very useful alternative to using web-interface for posting 
diffs: 
http://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-command-line


http://reviews.llvm.org/D20428



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


Re: [PATCH] D20429: [clang-tidy] Handle using-decls with more than one shadow decl.

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

Address comments.


http://reviews.llvm.org/D20429

Files:
  clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tidy/misc/UnusedUsingDeclsCheck.h
  test/clang-tidy/misc-unused-using-decls.cpp

Index: test/clang-tidy/misc-unused-using-decls.cpp
===
--- test/clang-tidy/misc-unused-using-decls.cpp
+++ test/clang-tidy/misc-unused-using-decls.cpp
@@ -31,6 +31,8 @@
 template  int UsedTemplateFunc() { return 1; }
 template  int UnusedTemplateFunc() { return 1; }
 template  int UsedInTemplateFunc() { return 1; }
+void OverloadFunc(int);
+void OverloadFunc(double);
 
 class ostream {
 public:
@@ -79,6 +81,10 @@
   UsedInTemplateFunc();
 }
 
+using n::OverloadFunc; // OverloadFunc
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'OverloadFunc' is unused
+// CHECK-FIXES: {{^}}// OverloadFunc
+
 #define DEFINE_INT(name)\
   namespace INT {   \
   static const int _##name = 1; \
Index: clang-tidy/misc/UnusedUsingDeclsCheck.h
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.h
+++ clang-tidy/misc/UnusedUsingDeclsCheck.h
@@ -11,7 +11,8 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_UNUSED_USING_DECLS_H
 
 #include "../ClangTidy.h"
-#include "llvm/ADT/DenseMap.h"
+#include 
+#include 
 
 namespace clang {
 namespace tidy {
@@ -32,8 +33,16 @@
 private:
   void removeFromFoundDecls(const Decl *D);
 
-  llvm::DenseMap FoundDecls;
-  llvm::DenseMap FoundRanges;
+  struct UsingDeclContext {
+explicit UsingDeclContext(const UsingDecl *FoundUsingDecl)
+: FoundUsingDecl(FoundUsingDecl), IsUsed(false) {}
+std::set UsingTargetDecls;
+const UsingDecl *FoundUsingDecl;
+CharSourceRange UsingDeclRange;
+bool IsUsed;
+  };
+
+  std::vector Contexts;
 };
 
 } // namespace misc
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -18,6 +18,25 @@
 namespace tidy {
 namespace misc {
 
+// A function that helps to tell whether a TargetDecl will be checked.
+// We only check a TargetDecl if :
+//   * The corresponding UsingDecl is not defined in macros or in class
+// definitions.
+//   * Only variable, function and class types are considered.
+static bool IsCheckable(const Decl *TargetDecl) {
+  // Ignores using-declarations defined in macros.
+  if (TargetDecl->getLocation().isMacroID())
+return false;
+
+  // Ignores using-declarations defined in class definition.
+  if (isa(TargetDecl->getDeclContext()))
+return false;
+
+  return isa(TargetDecl) || isa(TargetDecl) ||
+ isa(TargetDecl) || isa(TargetDecl) ||
+ isa(TargetDecl);
+}
+
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
@@ -30,33 +49,20 @@
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
   if (const auto *Using = Result.Nodes.getNodeAs("using")) {
-// FIXME: Implement the correct behavior for using declarations with more
-// than one shadow.
-if (Using->shadow_size() != 1)
-  return;
-const auto *TargetDecl =
-Using->shadow_begin()->getTargetDecl()->getCanonicalDecl();
-
-// Ignores using-declarations defined in macros.
-if (TargetDecl->getLocation().isMacroID())
-  return;
-
-// Ignores using-declarations defined in class definition.
-if (isa(TargetDecl->getDeclContext()))
-  return;
-
-if (!isa(TargetDecl) && !isa(TargetDecl) &&
-!isa(TargetDecl) && !isa(TargetDecl) &&
-!isa(TargetDecl))
-  return;
-
-FoundDecls[TargetDecl] = Using;
-FoundRanges[TargetDecl] = CharSourceRange::getCharRange(
+UsingDeclContext Context(Using);
+Context.UsingDeclRange = CharSourceRange::getCharRange(
 Using->getLocStart(),
 Lexer::findLocationAfterToken(
 Using->getLocEnd(), tok::semi, *Result.SourceManager,
 Result.Context->getLangOpts(),
 /*SkipTrailingWhitespaceAndNewLine=*/true));
+for (const auto It : Using->shadows()) {
+  const auto *TargetDecl = It->getTargetDecl()->getCanonicalDecl();
+  if (IsCheckable(TargetDecl))
+Context.UsingTargetDecls.insert(TargetDecl);
+}
+if (!Context.UsingTargetDecls.empty())
+  Contexts.push_back(Context);
 return;
   }
 
@@ -93,20 +99,23 @@
 }
 
 void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {
-  auto I = FoundDecls.find(D->getCanonicalDecl());
-  if (I != FoundDecls.end())
-I->second = nullptr;
+  for (auto &Context : Contexts) {
+if (Context.UsingTargetDecls.count(D->getCanonicalDecl()) > 0) {
+ 

Re: [PATCH] D20429: [clang-tidy] Handle using-decls with more than one shadow decl.

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

Forgot a comments.


http://reviews.llvm.org/D20429

Files:
  clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tidy/misc/UnusedUsingDeclsCheck.h
  test/clang-tidy/misc-unused-using-decls.cpp

Index: test/clang-tidy/misc-unused-using-decls.cpp
===
--- test/clang-tidy/misc-unused-using-decls.cpp
+++ test/clang-tidy/misc-unused-using-decls.cpp
@@ -31,6 +31,8 @@
 template  int UsedTemplateFunc() { return 1; }
 template  int UnusedTemplateFunc() { return 1; }
 template  int UsedInTemplateFunc() { return 1; }
+void OverloadFunc(int);
+void OverloadFunc(double);
 
 class ostream {
 public:
@@ -79,6 +81,10 @@
   UsedInTemplateFunc();
 }
 
+using n::OverloadFunc; // OverloadFunc
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'OverloadFunc' is unused
+// CHECK-FIXES: {{^}}// OverloadFunc
+
 #define DEFINE_INT(name)\
   namespace INT {   \
   static const int _##name = 1; \
Index: clang-tidy/misc/UnusedUsingDeclsCheck.h
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.h
+++ clang-tidy/misc/UnusedUsingDeclsCheck.h
@@ -11,7 +11,8 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_UNUSED_USING_DECLS_H
 
 #include "../ClangTidy.h"
-#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallPtrSet.h"
+#include 
 
 namespace clang {
 namespace tidy {
@@ -32,8 +33,16 @@
 private:
   void removeFromFoundDecls(const Decl *D);
 
-  llvm::DenseMap FoundDecls;
-  llvm::DenseMap FoundRanges;
+  struct UsingDeclContext {
+explicit UsingDeclContext(const UsingDecl *FoundUsingDecl)
+: FoundUsingDecl(FoundUsingDecl), IsUsed(false) {}
+llvm::SmallPtrSet UsingTargetDecls;
+const UsingDecl *FoundUsingDecl;
+CharSourceRange UsingDeclRange;
+bool IsUsed;
+  };
+
+  std::vector Contexts;
 };
 
 } // namespace misc
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -18,6 +18,25 @@
 namespace tidy {
 namespace misc {
 
+// A function that helps to tell whether a TargetDecl will be checked.
+// We only check a TargetDecl if :
+//   * The corresponding UsingDecl is not defined in macros or in class
+// definitions.
+//   * Only variable, function and class types are considered.
+static bool IsCheckable(const Decl *TargetDecl) {
+  // Ignores using-declarations defined in macros.
+  if (TargetDecl->getLocation().isMacroID())
+return false;
+
+  // Ignores using-declarations defined in class definition.
+  if (isa(TargetDecl->getDeclContext()))
+return false;
+
+  return isa(TargetDecl) || isa(TargetDecl) ||
+ isa(TargetDecl) || isa(TargetDecl) ||
+ isa(TargetDecl);
+}
+
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
@@ -30,33 +49,20 @@
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
   if (const auto *Using = Result.Nodes.getNodeAs("using")) {
-// FIXME: Implement the correct behavior for using declarations with more
-// than one shadow.
-if (Using->shadow_size() != 1)
-  return;
-const auto *TargetDecl =
-Using->shadow_begin()->getTargetDecl()->getCanonicalDecl();
-
-// Ignores using-declarations defined in macros.
-if (TargetDecl->getLocation().isMacroID())
-  return;
-
-// Ignores using-declarations defined in class definition.
-if (isa(TargetDecl->getDeclContext()))
-  return;
-
-if (!isa(TargetDecl) && !isa(TargetDecl) &&
-!isa(TargetDecl) && !isa(TargetDecl) &&
-!isa(TargetDecl))
-  return;
-
-FoundDecls[TargetDecl] = Using;
-FoundRanges[TargetDecl] = CharSourceRange::getCharRange(
+UsingDeclContext Context(Using);
+Context.UsingDeclRange = CharSourceRange::getCharRange(
 Using->getLocStart(),
 Lexer::findLocationAfterToken(
 Using->getLocEnd(), tok::semi, *Result.SourceManager,
 Result.Context->getLangOpts(),
 /*SkipTrailingWhitespaceAndNewLine=*/true));
+for (const auto It : Using->shadows()) {
+  const auto *TargetDecl = It->getTargetDecl()->getCanonicalDecl();
+  if (IsCheckable(TargetDecl))
+Context.UsingTargetDecls.insert(TargetDecl);
+}
+if (!Context.UsingTargetDecls.empty())
+  Contexts.push_back(Context);
 return;
   }
 
@@ -93,20 +99,23 @@
 }
 
 void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {
-  auto I = FoundDecls.find(D->getCanonicalDecl());
-  if (I != FoundDecls.end())
-I->second = nullptr;
+  for (auto &Context : Contexts) {
+if (Context.UsingTargetDecls.count(D->getCanonicalDecl()) > 0) {
+  Co

Re: [PATCH] D20429: [clang-tidy] Handle using-decls with more than one shadow decl.

2016-05-19 Thread Haojian Wu via cfe-commits
hokein marked an inline comment as done.


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:22
@@ +21,3 @@
+namespace {
+bool IsValidDecl(const Decl *TargetDecl) {
+  // Ignores using-declarations defined in macros.

alexfh wrote:
> This method assumes a rather non-trivial definition of "valid". Please add a 
> comment what exactly this method does.
> 
> Also, static is preferred to anonymous namespaces for functions in LLVM style 
> (http://llvm.org/docs/CodingStandards.html#anonymous-namespaces):
> | ... make anonymous namespaces as small as possible, and only use them for 
> class declarations. ...
I have renamed to `IsCheckable`, but it doesn't make more sense here. Do you 
have better suggestion on the function name? 


Comment at: test/clang-tidy/misc-unused-using-decls.cpp:86
@@ +85,3 @@
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'OverloadFunc' is 
unused
+// CHECK-FIXES: {{^}}// OverloadFunc
+

Will do it in a follow-up.


http://reviews.llvm.org/D20429



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


Re: [clang-tools-extra] r261991 - [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.

2016-05-19 Thread Hans Wennborg via cfe-commits
+Tom who manages 3.8.1
+Alex who's owner of clang-tidy: is this ok for 3.8.1?

On Thu, May 19, 2016 at 1:56 AM, Edoardo P. via cfe-commits
 wrote:
> Is it possible to port this commit to 3.8.1?
>
> Cheers,
> Edward-san
>
> 2016-02-26 10:19 GMT+01:00 Haojian Wu via cfe-commits
> :
>> Author: hokein
>> Date: Fri Feb 26 03:19:33 2016
>> New Revision: 261991
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=261991&view=rev
>> Log:
>> [clang-tidy] Fix a crash issue when clang-tidy runs with compilation 
>> database.
>>
>> Summary:
>> The clang-tidy will trigger an assertion if it's not in the building 
>> directory.
>>
>> TEST:
>> cd /
>> ./build/bin/clang-tidy --checks=-*,modernize-use-nullptr -p build 
>> tools/clang/tools/extra/clang-tidy/ClangTidy.cpp
>>
>> The crash issue is gone after applying this patch.
>>
>> Fixes PR24834, PR26241
>>
>> Reviewers: bkramer, alexfh
>>
>> Subscribers: rizsotto.mailinglist, cfe-commits
>>
>> Differential Revision: http://reviews.llvm.org/D17335
>>
>> Added:
>> clang-tools-extra/trunk/test/clang-tidy/Inputs/compilation-database/
>> 
>> clang-tools-extra/trunk/test/clang-tidy/Inputs/compilation-database/template.json
>> clang-tools-extra/trunk/test/clang-tidy/clang-tidy-run-with-database.cpp
>> Modified:
>> clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
>> clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
>> clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
>>
>> Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=261991&r1=261990&r2=261991&view=diff
>> ==
>> --- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
>> +++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Fri Feb 26 03:19:33 2016
>> @@ -107,6 +107,10 @@ public:
>>  DiagPrinter->BeginSourceFile(LangOpts);
>>}
>>
>> +  SourceManager& getSourceManager() {
>> +return SourceMgr;
>> +  }
>> +
>>void reportDiagnostic(const ClangTidyError &Error) {
>>  const ClangTidyMessage &Message = Error.Message;
>>  SourceLocation Loc = getLocation(Message.FilePath, Message.FileOffset);
>> @@ -124,7 +128,10 @@ public:
>>auto Diag = Diags.Report(Loc, Diags.getCustomDiagID(Level, "%0 [%1]"))
>><< Message.Message << Name;
>>for (const tooling::Replacement &Fix : Error.Fix) {
>> -SourceLocation FixLoc = getLocation(Fix.getFilePath(), 
>> Fix.getOffset());
>> +SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
>> +Files.makeAbsolutePath(FixAbsoluteFilePath);
>> +SourceLocation FixLoc =
>> +getLocation(FixAbsoluteFilePath, Fix.getOffset());
>>  SourceLocation FixEndLoc = FixLoc.getLocWithOffset(Fix.getLength());
>>  Diag << FixItHint::CreateReplacement(SourceRange(FixLoc, FixEndLoc),
>>   Fix.getReplacementText());
>> @@ -232,6 +239,13 @@ ClangTidyASTConsumerFactory::CreateASTCo
>>Context.setCurrentFile(File);
>>Context.setASTContext(&Compiler.getASTContext());
>>
>> +  auto WorkingDir = Compiler.getSourceManager()
>> +.getFileManager()
>> +.getVirtualFileSystem()
>> +->getCurrentWorkingDirectory();
>> +  if (WorkingDir)
>> +Context.setCurrentBuildDirectory(WorkingDir.get());
>> +
>>std::vector> Checks;
>>CheckFactories->createChecks(&Context, Checks);
>>
>> @@ -446,8 +460,24 @@ runClangTidy(std::unique_ptr>  void handleErrors(const std::vector &Errors, bool Fix,
>>unsigned &WarningsAsErrorsCount) {
>>ErrorReporter Reporter(Fix);
>> -  for (const ClangTidyError &Error : Errors)
>> +  vfs::FileSystem &FileSystem =
>> +  *Reporter.getSourceManager().getFileManager().getVirtualFileSystem();
>> +  auto InitialWorkingDir = FileSystem.getCurrentWorkingDirectory();
>> +  if (!InitialWorkingDir)
>> +llvm::report_fatal_error("Cannot get current working path.");
>> +
>> +  for (const ClangTidyError &Error : Errors) {
>> +if (!Error.BuildDirectory.empty()) {
>> +  // By default, the working directory of file system is the current
>> +  // clang-tidy running directory.
>> +  //
>> +  // Change the directory to the one used during the analysis.
>> +  FileSystem.setCurrentWorkingDirectory(Error.BuildDirectory);
>> +}
>>  Reporter.reportDiagnostic(Error);
>> +// Return to the initial directory to correctly resolve next Error.
>> +FileSystem.setCurrentWorkingDirectory(InitialWorkingDir.get());
>> +  }
>>Reporter.Finish();
>>WarningsAsErrorsCount += Reporter.getWarningsAsErrorsCount();
>>  }
>>
>> Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnos

Re: [PATCH] D20198: clang-format: [JS] sort ES6 imports.

2016-05-19 Thread Martin Probst via cfe-commits
mprobst updated this revision to Diff 57794.
mprobst added a comment.

- correctly insert breaks after import block


http://reviews.llvm.org/D20198

Files:
  include/clang/Format/Format.h
  lib/Format/CMakeLists.txt
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/FormatTokenLexer.cpp
  lib/Format/FormatTokenLexer.h
  lib/Format/SortJavaScriptImports.cpp
  lib/Format/SortJavaScriptImports.h
  lib/Format/TokenAnalyzer.cpp
  lib/Format/TokenAnalyzer.h
  unittests/Format/CMakeLists.txt
  unittests/Format/SortImportsTestJS.cpp

Index: unittests/Format/SortImportsTestJS.cpp
===
--- /dev/null
+++ unittests/Format/SortImportsTestJS.cpp
@@ -0,0 +1,180 @@
+//===- unittest/Format/SortImportsTestJS.cpp - JS import sort unit tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "FormatTestUtils.h"
+#include "clang/Format/Format.h"
+#include "llvm/Support/Debug.h"
+#include "gtest/gtest.h"
+
+#define DEBUG_TYPE "format-test"
+
+namespace clang {
+namespace format {
+namespace {
+
+class SortImportsTestJS : public ::testing::Test {
+protected:
+  std::string sort(StringRef Code, unsigned Offset = 0, unsigned Length = 0) {
+StringRef FileName = "input.js";
+if (Length == 0U)
+  Length = Code.size() - Offset;
+std::vector Ranges(1, tooling::Range(Offset, Length));
+std::string Sorted =
+applyAllReplacements(Code, sortIncludes(Style, Code, Ranges, FileName));
+return applyAllReplacements(Sorted,
+reformat(Style, Sorted, Ranges, FileName));
+  }
+
+  void verifySort(llvm::StringRef Expected, llvm::StringRef Code,
+  unsigned Offset = 0, unsigned Length = 0) {
+std::string Result = sort(Code, Offset, Length);
+EXPECT_EQ(Expected.str(), Result) << "Expected:\n"
+  << Expected << "\nActual:\n"
+  << Result;
+  }
+
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript);
+};
+
+TEST_F(SortImportsTestJS, AlreadySorted) {
+  verifySort("import {sym} from 'a';\n"
+ "import {sym} from 'b';\n"
+ "import {sym} from 'c';\n"
+ "\n"
+ "let x = 1;",
+ "import {sym} from 'a';\n"
+ "import {sym} from 'b';\n"
+ "import {sym} from 'c';\n"
+ "\n"
+ "let x = 1;");
+}
+
+TEST_F(SortImportsTestJS, BasicSorting) {
+  verifySort("import {sym} from 'a';\n"
+ "import {sym} from 'b';\n"
+ "import {sym} from 'c';\n"
+ "\n"
+ "let x = 1;",
+ "import {sym} from 'a';\n"
+ "import {sym} from 'c';\n"
+ "import {sym} from 'b';\n"
+ "let x = 1;");
+}
+
+TEST_F(SortImportsTestJS, Comments) {
+  verifySort("/** @fileoverview This is a great file. */\n"
+ "// A very important import follows.\n"
+ "import {sym} from 'a'; /* more comments */\n"
+ "import {sym} from 'b'; // from //foo:bar\n",
+ "/** @fileoverview This is a great file. */\n"
+ "import {sym} from 'b'; // from //foo:bar\n"
+ "// A very important import follows.\n"
+ "import {sym} from 'a'; /* more comments */\n");
+}
+
+TEST_F(SortImportsTestJS, SortStar) {
+  verifySort("import * as foo from 'a';\n"
+ "import {sym} from 'a';\n"
+ "import * as bar from 'b';\n",
+ "import {sym} from 'a';\n"
+ "import * as foo from 'a';\n"
+ "import * as bar from 'b';\n");
+}
+
+TEST_F(SortImportsTestJS, AliasesSymbols) {
+  verifySort("import {sym1 as alias1} from 'b';\n"
+ "import {sym2 as alias2, sym3 as alias3} from 'c';\n",
+ "import {sym2 as alias2, sym3 as alias3} from 'c';\n"
+ "import {sym1 as alias1} from 'b';\n");
+}
+
+TEST_F(SortImportsTestJS, GroupImports) {
+  verifySort("import {a} from 'absolute';\n"
+ "\n"
+ "import {b} from '../parent';\n"
+ "import {b} from '../parent/nested';\n"
+ "\n"
+ "import {b} from './relative/path';\n"
+ "import {b} from './relative/path/nested';\n"
+ "\n"
+ "let x = 1;\n",
+ "import {b} from './relative/path/nested';\n"
+ "import {b} from './relative/path';\n"
+ "import {b} from '../parent/nested';\n"
+ "import {b} from '../parent';\n"
+ "import {a} from 'absolute';\n"
+ "let x = 1;\n");
+}
+
+TEST_F(SortImportsTestJS, Exports) {
+  verifySort("import {S} from 'bpath';\n"
+ "\n"
+ "import {T} from './cpath';\n"
+ "\n"

Re: [PATCH] D20198: clang-format: [JS] sort ES6 imports.

2016-05-19 Thread Martin Probst via cfe-commits
mprobst updated this revision to Diff 57795.
mprobst added a comment.

- ranges


http://reviews.llvm.org/D20198

Files:
  include/clang/Format/Format.h
  lib/Format/CMakeLists.txt
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/FormatTokenLexer.cpp
  lib/Format/FormatTokenLexer.h
  lib/Format/SortJavaScriptImports.cpp
  lib/Format/SortJavaScriptImports.h
  lib/Format/TokenAnalyzer.cpp
  lib/Format/TokenAnalyzer.h
  unittests/Format/CMakeLists.txt
  unittests/Format/SortImportsTestJS.cpp

Index: unittests/Format/SortImportsTestJS.cpp
===
--- /dev/null
+++ unittests/Format/SortImportsTestJS.cpp
@@ -0,0 +1,194 @@
+//===- unittest/Format/SortImportsTestJS.cpp - JS import sort unit tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "FormatTestUtils.h"
+#include "clang/Format/Format.h"
+#include "llvm/Support/Debug.h"
+#include "gtest/gtest.h"
+
+#define DEBUG_TYPE "format-test"
+
+namespace clang {
+namespace format {
+namespace {
+
+class SortImportsTestJS : public ::testing::Test {
+protected:
+  std::string sort(StringRef Code, unsigned Offset = 0, unsigned Length = 0) {
+StringRef FileName = "input.js";
+if (Length == 0U)
+  Length = Code.size() - Offset;
+std::vector Ranges(1, tooling::Range(Offset, Length));
+std::string Sorted =
+applyAllReplacements(Code, sortIncludes(Style, Code, Ranges, FileName));
+return applyAllReplacements(Sorted,
+reformat(Style, Sorted, Ranges, FileName));
+  }
+
+  void verifySort(llvm::StringRef Expected, llvm::StringRef Code,
+  unsigned Offset = 0, unsigned Length = 0) {
+std::string Result = sort(Code, Offset, Length);
+EXPECT_EQ(Expected.str(), Result) << "Expected:\n"
+  << Expected << "\nActual:\n"
+  << Result;
+  }
+
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript);
+};
+
+TEST_F(SortImportsTestJS, AlreadySorted) {
+  verifySort("import {sym} from 'a';\n"
+ "import {sym} from 'b';\n"
+ "import {sym} from 'c';\n"
+ "\n"
+ "let x = 1;",
+ "import {sym} from 'a';\n"
+ "import {sym} from 'b';\n"
+ "import {sym} from 'c';\n"
+ "\n"
+ "let x = 1;");
+}
+
+TEST_F(SortImportsTestJS, BasicSorting) {
+  verifySort("import {sym} from 'a';\n"
+ "import {sym} from 'b';\n"
+ "import {sym} from 'c';\n"
+ "\n"
+ "let x = 1;",
+ "import {sym} from 'a';\n"
+ "import {sym} from 'c';\n"
+ "import {sym} from 'b';\n"
+ "let x = 1;");
+}
+
+TEST_F(SortImportsTestJS, Comments) {
+  verifySort("/** @fileoverview This is a great file. */\n"
+ "// A very important import follows.\n"
+ "import {sym} from 'a'; /* more comments */\n"
+ "import {sym} from 'b'; // from //foo:bar\n",
+ "/** @fileoverview This is a great file. */\n"
+ "import {sym} from 'b'; // from //foo:bar\n"
+ "// A very important import follows.\n"
+ "import {sym} from 'a'; /* more comments */\n");
+}
+
+TEST_F(SortImportsTestJS, SortStar) {
+  verifySort("import * as foo from 'a';\n"
+ "import {sym} from 'a';\n"
+ "import * as bar from 'b';\n",
+ "import {sym} from 'a';\n"
+ "import * as foo from 'a';\n"
+ "import * as bar from 'b';\n");
+}
+
+TEST_F(SortImportsTestJS, AliasesSymbols) {
+  verifySort("import {sym1 as alias1} from 'b';\n"
+ "import {sym2 as alias2, sym3 as alias3} from 'c';\n",
+ "import {sym2 as alias2, sym3 as alias3} from 'c';\n"
+ "import {sym1 as alias1} from 'b';\n");
+}
+
+TEST_F(SortImportsTestJS, GroupImports) {
+  verifySort("import {a} from 'absolute';\n"
+ "\n"
+ "import {b} from '../parent';\n"
+ "import {b} from '../parent/nested';\n"
+ "\n"
+ "import {b} from './relative/path';\n"
+ "import {b} from './relative/path/nested';\n"
+ "\n"
+ "let x = 1;\n",
+ "import {b} from './relative/path/nested';\n"
+ "import {b} from './relative/path';\n"
+ "import {b} from '../parent/nested';\n"
+ "import {b} from '../parent';\n"
+ "import {a} from 'absolute';\n"
+ "let x = 1;\n");
+}
+
+TEST_F(SortImportsTestJS, Exports) {
+  verifySort("import {S} from 'bpath';\n"
+ "\n"
+ "import {T} from './cpath';\n"
+ "\n"
+ "export {A, B} from '

r270069 - [driver] Do not pass install dir to the MultilibSet include dirs callback

2016-05-19 Thread Simon Atanasyan via cfe-commits
Author: atanasyan
Date: Thu May 19 10:07:21 2016
New Revision: 270069

URL: http://llvm.org/viewvc/llvm-project?rev=270069&view=rev
Log:
[driver] Do not pass install dir to the MultilibSet include dirs callback

All additional include directories are relative to the toolchain install
folder. So let's do not pass this folder to each callback to simplify
and slightly reduce the code.

Modified:
cfe/trunk/include/clang/Driver/Multilib.h
cfe/trunk/lib/Driver/ToolChains.cpp

Modified: cfe/trunk/include/clang/Driver/Multilib.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Multilib.h?rev=270069&r1=270068&r2=270069&view=diff
==
--- cfe/trunk/include/clang/Driver/Multilib.h (original)
+++ cfe/trunk/include/clang/Driver/Multilib.h Thu May 19 10:07:21 2016
@@ -99,8 +99,7 @@ public:
   typedef multilib_list::iterator iterator;
   typedef multilib_list::const_iterator const_iterator;
 
-  typedef std::function(StringRef InstallDir,
- const Multilib &M)>
+  typedef std::function(const Multilib &M)>
   IncludeDirsFunc;
 
   typedef llvm::function_ref FilterCallback;

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=270069&r1=270068&r2=270069&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu May 19 10:07:21 2016
@@ -1923,16 +1923,12 @@ static bool findMIPSMultilibs(const Driv
 .Maybe(Nan2008)
 .FilterOut(".*sof/nan2008")
 .FilterOut(NonExistent)
-.setIncludeDirsCallback([](StringRef InstallDir,
-   const Multilib &M) {
-  std::vector Dirs;
-  Dirs.push_back((InstallDir + "/include").str());
-  std::string SysRootInc =
-  InstallDir.str() + "/../../../../sysroot";
+.setIncludeDirsCallback([](const Multilib &M) {
+  std::vector Dirs({"/include"});
   if (StringRef(M.includeSuffix()).startswith("/uclibc"))
-Dirs.push_back(SysRootInc + "/uclibc/usr/include");
+Dirs.push_back("/../../../../sysroot/uclibc/usr/include");
   else
-Dirs.push_back(SysRootInc + "/usr/include");
+Dirs.push_back("/../../../../sysroot/usr/include");
   return Dirs;
 });
   }
@@ -1954,12 +1950,9 @@ static bool findMIPSMultilibs(const Driv
 MuslMipsMultilibs = MultilibSet().Either(MArchMipsR2, MArchMipselR2);
 
 // Specify the callback that computes the include directories.
-MuslMipsMultilibs.setIncludeDirsCallback([](StringRef InstallDir,
-const Multilib &M) {
-  std::vector Dirs;
-  Dirs.push_back(
-  (InstallDir + "/../sysroot" + M.osSuffix() + "/usr/include").str());
-  return Dirs;
+MuslMipsMultilibs.setIncludeDirsCallback([](const Multilib &M) {
+  return std::vector(
+  {"/../sysroot" + M.osSuffix() + "/usr/include"});
 });
   }
 
@@ -2006,16 +1999,13 @@ static bool findMIPSMultilibs(const Driv
 .FilterOut("/mips16.*/64")
 .FilterOut("/micromips.*/64")
 .FilterOut(NonExistent)
-.setIncludeDirsCallback([](StringRef InstallDir,
-   const Multilib &M) {
-  std::vector Dirs;
-  Dirs.push_back((InstallDir + "/include").str());
-  std::string SysRootInc =
-  InstallDir.str() + "/../../../../mips-linux-gnu";
+.setIncludeDirsCallback([](const Multilib &M) {
+  std::vector Dirs({"/include"});
   if (StringRef(M.includeSuffix()).startswith("/uclibc"))
-Dirs.push_back(SysRootInc + "/libc/uclibc/usr/include");
+Dirs.push_back(
+"/../../../../mips-linux-gnu/libc/uclibc/usr/include");
   else
-Dirs.push_back(SysRootInc + "/libc/usr/include");
+Dirs.push_back("/../../../../mips-linux-gnu/libc/usr/include");
   return Dirs;
 });
   }
@@ -2059,13 +2049,9 @@ static bool findMIPSMultilibs(const Driv
 .Maybe(MAbi64)
 .Maybe(LittleEndian)
 .FilterOut(NonExistent)
-.setIncludeDirsCallback([](StringRef InstallDir,
-   const Multilib &M) {
-  std::vector Dirs;
-  Dirs.push_back((InstallDir + "/include").str());
-  Dirs.push_back(
-  (InstallDir + "/../../../../sysroot/usr/include").str());
-  return Dirs;
+.setIncludeDirsCallback([](const Multilib &M) {
+  return std::vector(
+ 

r270068 - [driver] Do not pass target triple to the MultilibSet include dirs callback

2016-05-19 Thread Simon Atanasyan via cfe-commits
Author: atanasyan
Date: Thu May 19 10:07:00 2016
New Revision: 270068

URL: http://llvm.org/viewvc/llvm-project?rev=270068&view=rev
Log:
[driver] Do not pass target triple to the MultilibSet include dirs callback

No one callback uses target triple so we can escape passing the unused
argument.

Modified:
cfe/trunk/include/clang/Driver/Multilib.h
cfe/trunk/lib/Driver/ToolChains.cpp

Modified: cfe/trunk/include/clang/Driver/Multilib.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Multilib.h?rev=270068&r1=270067&r2=270068&view=diff
==
--- cfe/trunk/include/clang/Driver/Multilib.h (original)
+++ cfe/trunk/include/clang/Driver/Multilib.h Thu May 19 10:07:00 2016
@@ -99,9 +99,9 @@ public:
   typedef multilib_list::iterator iterator;
   typedef multilib_list::const_iterator const_iterator;
 
-  typedef std::function(
-  StringRef InstallDir, StringRef Triple, const Multilib &M)>
-  IncludeDirsFunc;
+  typedef std::function(StringRef InstallDir,
+ const Multilib &M)>
+  IncludeDirsFunc;
 
   typedef llvm::function_ref FilterCallback;
 

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=270068&r1=270067&r2=270068&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu May 19 10:07:00 2016
@@ -1924,7 +1924,7 @@ static bool findMIPSMultilibs(const Driv
 .FilterOut(".*sof/nan2008")
 .FilterOut(NonExistent)
 .setIncludeDirsCallback([](StringRef InstallDir,
-   StringRef TripleStr, const Multilib &M) 
{
+   const Multilib &M) {
   std::vector Dirs;
   Dirs.push_back((InstallDir + "/include").str());
   std::string SysRootInc =
@@ -1954,8 +1954,8 @@ static bool findMIPSMultilibs(const Driv
 MuslMipsMultilibs = MultilibSet().Either(MArchMipsR2, MArchMipselR2);
 
 // Specify the callback that computes the include directories.
-MuslMipsMultilibs.setIncludeDirsCallback([](
-StringRef InstallDir, StringRef TripleStr, const Multilib &M) {
+MuslMipsMultilibs.setIncludeDirsCallback([](StringRef InstallDir,
+const Multilib &M) {
   std::vector Dirs;
   Dirs.push_back(
   (InstallDir + "/../sysroot" + M.osSuffix() + "/usr/include").str());
@@ -2007,7 +2007,7 @@ static bool findMIPSMultilibs(const Driv
 .FilterOut("/micromips.*/64")
 .FilterOut(NonExistent)
 .setIncludeDirsCallback([](StringRef InstallDir,
-   StringRef TripleStr, const Multilib &M) 
{
+   const Multilib &M) {
   std::vector Dirs;
   Dirs.push_back((InstallDir + "/include").str());
   std::string SysRootInc =
@@ -2060,7 +2060,7 @@ static bool findMIPSMultilibs(const Driv
 .Maybe(LittleEndian)
 .FilterOut(NonExistent)
 .setIncludeDirsCallback([](StringRef InstallDir,
-   StringRef TripleStr, const Multilib &M) 
{
+   const Multilib &M) {
   std::vector Dirs;
   Dirs.push_back((InstallDir + "/include").str());
   Dirs.push_back(
@@ -2540,8 +2540,7 @@ void MipsLLVMToolChain::AddClangSystemIn
 
   const auto &Callback = Multilibs.includeDirsCallback();
   if (Callback) {
-const auto IncludePaths =
-Callback(D.getInstalledDir(), getTripleString(), SelectedMultilib);
+const auto IncludePaths = Callback(D.getInstalledDir(), SelectedMultilib);
 for (const auto &Path : IncludePaths)
   addExternCSystemIncludeIfExists(DriverArgs, CC1Args, Path);
   }
@@ -2588,8 +2587,8 @@ void MipsLLVMToolChain::AddClangCXXStdli
 
   const auto &Callback = Multilibs.includeDirsCallback();
   if (Callback) {
-const auto IncludePaths = Callback(getDriver().getInstalledDir(),
-   getTripleString(), SelectedMultilib);
+const auto IncludePaths =
+Callback(getDriver().getInstalledDir(), SelectedMultilib);
 for (const auto &Path : IncludePaths) {
   if (llvm::sys::fs::exists(Path + "/c++/v1")) {
 addSystemInclude(DriverArgs, CC1Args, Path + "/c++/v1");
@@ -3971,7 +3970,6 @@ void Linux::AddClangSystemIncludeArgs(co
 const auto &Callback = Multilibs.includeDirsCallback();
 if (Callback) {
   const auto IncludePaths = Callback(GCCInstallation.getInstallPath(),
- GCCInstallation.getTriple().str(),
  GCCInstallation.getMultilib());
   for (con

Re: [PATCH] D14326: ASTImporter: expressions, pt.2

2016-05-19 Thread Aleksei Sidorin via cfe-commits
a.sidorin updated this revision to Diff 57796.
a.sidorin marked an inline comment as done.
a.sidorin added a comment.

Add some basic tests for ExpressionTraitExpr and ArrayTypeTraitExpr.


http://reviews.llvm.org/D14326

Files:
  include/clang/AST/ASTImporter.h
  include/clang/AST/DeclFriend.h
  lib/AST/ASTImporter.cpp
  test/ASTMerge/Inputs/class3.cpp
  test/ASTMerge/Inputs/exprs3.cpp
  test/ASTMerge/class2.cpp
  test/ASTMerge/exprs.cpp
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -466,5 +466,48 @@
 }
 
 
+const internal::VariadicDynCastAllOfMatcher vaArgExpr;
+
+/// \brief Matches the decayed type, whose original type matches \c InnerMatcher
+AST_MATCHER_P(DecayedType, hasOriginalType, internal::Matcher,
+  InnerType) {
+  return InnerType.matches(Node.getOriginalType(), Finder, Builder);
+}
+
+TEST(ImportExpr, ImportVAArgExpr) {
+  MatchVerifier Verifier;
+  EXPECT_TRUE(
+testImport(
+  "void declToImport(__builtin_va_list list, ...) {"
+  "  (void)__builtin_va_arg(list, int); }",
+  Lang_CXX, "", Lang_CXX, Verifier,
+  functionDecl(
+hasParameter(0,
+ varDecl(
+   hasName("list"),
+   hasType(
+ decayedType(
+   hasOriginalType(
+ typedefType(
+   hasDeclaration(
+ typedefDecl(
+   hasName("__builtin_va_list"),
+   hasType(
+ constantArrayType(
+   hasSize(1),
+   hasElementType(
+ qualType(
+   recordType(),
+   asString("struct __va_list_tag"
+  ),
+hasBody(
+  compoundStmt(
+has(
+  cStyleCastExpr(
+hasSourceExpression(
+  vaArgExpr();
+}
+
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: test/ASTMerge/exprs.cpp
===
--- /dev/null
+++ test/ASTMerge/exprs.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -fcxx-exceptions -emit-pch -o %t.1.ast %S/Inputs/exprs3.cpp
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -fcxx-exceptions -ast-merge %t.1.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+static_assert(Ch1 == 'a');
+static_assert(Ch2 == 'b');
+static_assert(Ch3 == 'c');
+
+static_assert(Ch4 == L'd');
+static_assert(Ch5 == L'e');
+static_assert(Ch6 == L'f');
+
+static_assert(C1 == 12);
+static_assert(C2 == 13);
+
+static_assert(C3 == 12);
+static_assert(C4 == 13);
+
+static_assert(C5 == 22L);
+static_assert(C6 == 23L);
+
+static_assert(C7 == 66LL);
+static_assert(C8 == 67ULL);
+
+static_assert(bval1 == true);
+static_assert(bval2 == false);
+
+static_assert(ExpressionTrait == false);
+
+static_assert(ArrayRank == 2);
+static_assert(ArrayExtent == 20);
+
+void testImport(int *x, const S1 &cs1, S1 &s1) {
+  testNewThrowDelete();
+  testArrayElement(nullptr, 12);
+  testTernaryOp(0, 1, 2);
+  testConstCast(cs1);
+  testStaticCast(s1);
+  testReinterpretCast(s1);
+  testDynamicCast(s1);
+  testScalarInit(42);
+  testOffsetOf();
+  testDefaultArg(12);
+  useTemplateType();
+}
Index: test/ASTMerge/class2.cpp
===
--- /dev/null
+++ test/ASTMerge/class2.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -emit-pch -o %t.1.ast %S/Inputs/class3.cpp
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -ast-merge %t.1.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+class C3 {
+  int method_1(C2 *x) {
+return x->x;
+  }
+};
Index: test/ASTMerge/Inputs/exprs3.cpp
===
--- /dev/null
+++ test/ASTMerge/Inputs/exprs3.cpp
@@ -0,0 +1,131 @@
+// Integer literals
+const char Ch1 = 'a';
+const signed char Ch2 = 'b';
+const unsigned char Ch3 = 'c';
+
+const wchar_t Ch4 = L'd';
+const signed wchar_t Ch5 = L'e';
+const unsigned wchar_t Ch6 = L'f';
+
+const short C1 = 12;
+const unsigned short C2 = 13;
+
+const int C3 = 12;
+const unsigned int C4 = 13;
+
+const long C5 = 22;
+const unsigned long C6 = 23;
+
+const long long C7 = 66;
+const unsigned long long C8 = 67;
+
+
+// String literals
+const char str1[] = "ABCD";
+const char str2[] = "ABCD" "0123";
+
+const wchar_t ws

Re: [PATCH] D20198: clang-format: [JS] sort ES6 imports.

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


Comment at: lib/Format/SortJavaScriptImports.cpp:160
@@ +159,3 @@
+  if (i + 1 < e) {
+// Insert breaks between imports.
+ReferencesText += "\n";

Between categories of imports and imports and exports, right?


Comment at: lib/Format/SortJavaScriptImports.cpp:170-171
@@ +169,4 @@
+// Separate references from the main code body of the file.
+if (FirstNonImportLine && FirstNonImportLine->First->NewlinesBefore < 2)
+  ReferencesText += "\n";
+

Shouldn't we add 2 if NewlinesBefore is 0? Or is that syntactically impossible?


http://reviews.llvm.org/D20198



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


Re: [PATCH] D20428: Tracking exception specification source locations

2016-05-19 Thread Aaron Ballman via cfe-commits
aaron.ballman updated this revision to Diff 57798.
aaron.ballman added a comment.

For noexcept specifications without an expression, now tracking the full source 
range. Also, added tests.


http://reviews.llvm.org/D20428

Files:
  include/clang/AST/Decl.h
  include/clang/AST/TypeLoc.h
  lib/AST/Decl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Sema/SemaType.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  unittests/AST/SourceLocationTest.cpp

Index: unittests/AST/SourceLocationTest.cpp
===
--- unittests/AST/SourceLocationTest.cpp
+++ unittests/AST/SourceLocationTest.cpp
@@ -580,5 +580,44 @@
   Language::Lang_CXX11));
 }
 
+class ExceptionSpecRangeVerifier : public RangeVerifier {
+protected:
+  SourceRange getRange(const TypeLoc &Node) override {
+auto T =
+  Node.getUnqualifiedLoc().castAs();
+assert(!T.isNull());
+return T.getExceptionSpecRange();
+  }
+};
+
+TEST(FunctionDecl, ExceptionSpecifications) {
+  ExceptionSpecRangeVerifier Verifier;
+
+  Verifier.expectRange(1, 10, 1, 16);
+  EXPECT_TRUE(Verifier.match("void f() throw();\n", loc(functionType(;
+
+  Verifier.expectRange(1, 10, 1, 34);
+  EXPECT_TRUE(Verifier.match("void f() throw(void(void) throw());\n",
+ loc(functionType(;
+
+  Verifier.expectRange(1, 10, 1, 19);
+  std::vector Args;
+  Args.push_back("-fms-extensions");
+  EXPECT_TRUE(Verifier.match("void f() throw(...);\n", loc(functionType()),
+ Args, Language::Lang_CXX));
+
+  Verifier.expectRange(1, 10, 1, 17);
+  EXPECT_TRUE(Verifier.match("void f() noexcept;\n", loc(functionType()),
+ Language::Lang_CXX11));
+
+  Verifier.expectRange(1, 10, 1, 24);
+  EXPECT_TRUE(Verifier.match("void f() noexcept(false);\n", loc(functionType()),
+ Language::Lang_CXX11));
+
+  Verifier.expectRange(1, 10, 1, 32);
+  EXPECT_TRUE(Verifier.match("void f() noexcept(noexcept(1+1));\n",
+ loc(functionType()), Language::Lang_CXX11));
+}
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -572,6 +572,7 @@
   Record.AddSourceLocation(TL.getLocalRangeBegin());
   Record.AddSourceLocation(TL.getLParenLoc());
   Record.AddSourceLocation(TL.getRParenLoc());
+  Record.AddSourceRange(TL.getExceptionSpecRange());
   Record.AddSourceLocation(TL.getLocalRangeEnd());
   for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i)
 Record.AddDeclRef(TL.getParam(i));
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -5812,6 +5812,8 @@
   TL.setLocalRangeBegin(ReadSourceLocation(Record, Idx));
   TL.setLParenLoc(ReadSourceLocation(Record, Idx));
   TL.setRParenLoc(ReadSourceLocation(Record, Idx));
+  TL.setExceptionSpecRange(SourceRange(ReadSourceLocation(Record, Idx),
+   ReadSourceLocation(Record, Idx)));
   TL.setLocalRangeEnd(ReadSourceLocation(Record, Idx));
   for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i) {
 TL.setParam(i, ReadDeclAs(Record, Idx));
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -4919,6 +4919,7 @@
   NewTL.setLocalRangeBegin(TL.getLocalRangeBegin());
   NewTL.setLParenLoc(TL.getLParenLoc());
   NewTL.setRParenLoc(TL.getRParenLoc());
+  NewTL.setExceptionSpecRange(TL.getExceptionSpecRange());
   NewTL.setLocalRangeEnd(TL.getLocalRangeEnd());
   for (unsigned i = 0, e = NewTL.getNumParams(); i != e; ++i)
 NewTL.setParam(i, ParamDecls[i]);
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -5065,7 +5065,7 @@
 ParmVarDecl *Param = cast(FTI.Params[i].Param);
 TL.setParam(tpi++, Param);
   }
-  // FIXME: exception specs
+  TL.setExceptionSpecRange(FTI.getExceptionSpecRange());
 }
 void VisitParenTypeLoc(ParenTypeLoc TL) {
   assert(Chunk.Kind == DeclaratorChunk::Paren);
Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -3400,7 +3400,8 @@
 
   // If we already had a dynamic specification, parse the noexcept for,
   // recovery, but emit a diagnostic and don't store the results.
-  SourceRange NoexceptRange;
+  SourceRange NoexceptRange(Tok.getLocation(),
+Tok.getEndLoc().getLocWithOffset(-1));
   ExceptionSpecificationType NoexceptType = EST_None;
 
   SourceLocation Keywor

r270067 - [driver][mips] Hardcode triple name in case of CodeSourcery toolchain. NFC

2016-05-19 Thread Simon Atanasyan via cfe-commits
Author: atanasyan
Date: Thu May 19 10:05:22 2016
New Revision: 270067

URL: http://llvm.org/viewvc/llvm-project?rev=270067&view=rev
Log:
[driver][mips] Hardcode triple name in case of CodeSourcery toolchain. NFC

CodeSourcery toolchain is a standalone toolchain which always uses
the same triple name in its paths. It is independent from target
triple used by the driver.

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

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=270067&r1=270066&r2=270067&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu May 19 10:05:22 2016
@@ -2011,7 +2011,7 @@ static bool findMIPSMultilibs(const Driv
   std::vector Dirs;
   Dirs.push_back((InstallDir + "/include").str());
   std::string SysRootInc =
-  InstallDir.str() + "/../../../../" + TripleStr.str();
+  InstallDir.str() + "/../../../../mips-linux-gnu";
   if (StringRef(M.includeSuffix()).startswith("/uclibc"))
 Dirs.push_back(SysRootInc + "/libc/uclibc/usr/include");
   else


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


Re: [PATCH] D20428: Tracking exception specification source locations

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

In http://reviews.llvm.org/D20428#434270, @alexfh wrote:

> In http://reviews.llvm.org/D20428#434242, @aaron.ballman wrote:
>
> > In http://reviews.llvm.org/D20428#434238, @alexfh wrote:
> >
> > > Full context diff, please.
> >
> >
> > Pardon my complete ignorance, but how? I generated the diff from svn the 
> > usual way, so I assume I've missed some step.
>
>
> There are at least two ways to do this:
>
> 1. both `git diff` and `svn diff` can be convinced to produce diffs with full 
> context: 
> http://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface
> 2. I find arcanist a very useful alternative to using web-interface for 
> posting diffs: 
> http://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-command-line


Hmm, so (1) it's strange that I've yet to run into this before today, and (2) 
I'm on Windows using TortoiseSVN, so the command line help isn't overly helpful 
and it seems Tortoise doesn't have this functionality with its Create Patch 
menu item or related options. Sorry for the lack of context in my latest 
upload, but it does have two important changes:

1. noexcept now tracks its full source range, not just the start location of 
the noexcept token,
2. now, with actual tests.


http://reviews.llvm.org/D20428



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


Re: [PATCH] D20198: clang-format: [JS] sort ES6 imports.

2016-05-19 Thread Martin Probst via cfe-commits
mprobst marked 2 inline comments as done.
mprobst added a comment.

Thanks for the review, appreciated!



Comment at: lib/Format/SortJavaScriptImports.cpp:160
@@ +159,3 @@
+  if (i + 1 < e) {
+// Insert breaks between imports.
+ReferencesText += "\n";

klimek wrote:
> Between categories of imports and imports and exports, right?
Added a comment.


Comment at: lib/Format/SortJavaScriptImports.cpp:170-171
@@ +169,4 @@
+// Separate references from the main code body of the file.
+if (FirstNonImportLine && FirstNonImportLine->First->NewlinesBefore < 2)
+  ReferencesText += "\n";
+

klimek wrote:
> Shouldn't we add 2 if NewlinesBefore is 0? Or is that syntactically 
> impossible?
The next token is on a new line, so it gets a wrap just from that already. I've 
added a test though.


http://reviews.llvm.org/D20198



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


[PATCH] D20437: [MSVC] Support of __unaligned qualifier for function types

2016-05-19 Thread Andrey Bokhanko via cfe-commits
andreybokhanko created this revision.
andreybokhanko added reviewers: rnk, majnemer.
andreybokhanko added a subscriber: cfe-commits.

This adds support of MS-specific "__unaligned" qualifier for function types and 
fixes errors described by David Majnemer in this thread: 
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160509/thread.html#158098

Yours,
Andrey
=
Software Engineer
Intel Compiler Team

http://reviews.llvm.org/D20437

Files:
  include/clang/AST/Type.h
  include/clang/Sema/DeclSpec.h
  lib/AST/DeclCXX.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenCXX/mangle-ms-cxx11.cpp
  test/Sema/MicrosoftExtensions.c
  test/SemaCXX/MicrosoftExtensions.cpp

Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1643,7 +1643,7 @@
 
   QualType ClassTy = C.getTypeDeclType(getParent());
   ClassTy = C.getQualifiedType(ClassTy,
-   Qualifiers::fromCVRMask(getTypeQualifiers()));
+   Qualifiers::fromCVRUMask(getTypeQualifiers()));
   return C.getPointerType(ClassTy);
 }
 
Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -1447,7 +1447,8 @@
   if (HasRestrict)
 Out << 'I';
 
-  if (!PointeeType.isNull() && PointeeType.getLocalQualifiers().hasUnaligned())
+  if (Quals.hasUnaligned() ||
+  (!PointeeType.isNull() && PointeeType.getLocalQualifiers().hasUnaligned()))
 Out << 'F';
 }
 
@@ -1822,7 +1823,7 @@
   // If this is a C++ instance method, mangle the CVR qualifiers for the
   // this pointer.
   if (HasThisQuals) {
-Qualifiers Quals = Qualifiers::fromCVRMask(Proto->getTypeQuals());
+Qualifiers Quals = Qualifiers::fromCVRUMask(Proto->getTypeQuals());
 manglePointerExtQualifiers(Quals, /*PointeeType=*/QualType());
 mangleRefQualifier(Proto->getRefQualifier());
 mangleQualifiers(Quals, /*IsMember=*/false);
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -2668,8 +2668,8 @@
 { "const", DeclSpec::TQ_const, ConstQualLoc },
 { "volatile", DeclSpec::TQ_volatile, VolatileQualLoc },
 { "restrict", DeclSpec::TQ_restrict, RestrictQualLoc },
-{ "_Atomic", DeclSpec::TQ_atomic, AtomicQualLoc },
-{ "__unaligned", DeclSpec::TQ_unaligned, UnalignedQualLoc }
+{ "__unaligned", DeclSpec::TQ_unaligned, UnalignedQualLoc },
+{ "_Atomic", DeclSpec::TQ_atomic, AtomicQualLoc }
   };
 
   SmallString<32> QualStr;
Index: lib/Sema/DeclSpec.cpp
===
--- lib/Sema/DeclSpec.cpp
+++ lib/Sema/DeclSpec.cpp
@@ -796,8 +796,8 @@
   case TQ_const:TQ_constLoc = Loc; return false;
   case TQ_restrict: TQ_restrictLoc = Loc; return false;
   case TQ_volatile: TQ_volatileLoc = Loc; return false;
-  case TQ_atomic:   TQ_atomicLoc = Loc; return false;
   case TQ_unaligned: TQ_unalignedLoc = Loc; return false;
+  case TQ_atomic:   TQ_atomicLoc = Loc; return false;
   }
 
   llvm_unreachable("Unknown type qualifier!");
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -934,6 +934,7 @@
   else
 Record = cast(ContextDecl);
 
+  CXXThisTypeQuals &= Qualifiers::FastMask;
   S.CXXThisTypeOverride
 = S.Context.getPointerType(
 S.Context.getRecordType(Record).withCVRQualifiers(CXXThisTypeQuals));
Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -215,6 +215,12 @@
 return Qs;
   }
 
+  static Qualifiers fromCVRUMask(unsigned CVRU) {
+Qualifiers Qs;
+Qs.addCVRUQualifiers(CVRU);
+return Qs;
+  }
+
   // Deserialize qualifiers from an opaque representation.
   static Qualifiers fromOpaqueValue(unsigned opaque) {
 Qualifiers Qs;
@@ -265,6 +271,10 @@
 assert(!(mask & ~CVRMask) && "bitmask contains non-CVR bits");
 Mask |= mask;
   }
+  void addCVRUQualifiers(unsigned mask) {
+assert(!(mask & ~CVRMask & ~UMask) && "bitmask contains non-CVRU bits");
+Mask |= mask;
+  }
 
   bool hasUnaligned() const { return Mask & UMask; }
   void setUnaligned(bool flag) {
@@ -1372,7 +1382,7 @@
 ///
 /// C++ 8.3.5p4: The return type, the parameter type list and the
 /// cv-qualifier-seq, [...], are part of the function type.
-unsigned TypeQuals : 3;
+unsigned TypeQuals : 4;
 
 /// \brief The ref-qualifier associated with a \c FunctionProtoType.
 ///
Index: include/clang/Sema/DeclSpec.h
===
--- include/clang/Sema/DeclSpec.h
+++ include/clang/Sema/DeclSpec

Re: r269220 - [MSVC] Implementation of __unaligned as a proper type qualifier

2016-05-19 Thread Andrey Bokhanko via cfe-commits
David,

All these cases are handled properly now.

Could you, please, review?

http://reviews.llvm.org/D20437

Yours,
Andrey


On Sat, May 14, 2016 at 6:11 AM, David Majnemer 
wrote:

> FYI, the following is a little shorter:
> using Ty = int () __unaligned;
>
> Also, this case (in C mode) is interesting:
> void f(int x[__unaligned 4]);
>
> DeclaratorChunk::getArray will truncate the TypeQuals
> because ArrayTypeInfo's TypeQuals doesn't have enough bits.
>
> similar issues arise with:
> struct A;
>
> void (A::*__unaligned vpa)();
>
> On Fri, May 13, 2016 at 4:03 PM,  wrote:
>
>> Hi David,
>>
>> Thanks for letting me know -- will investigate after the weekend.
>>
>> Yours,
>> Andrey
>>
>> Отправлено с iPad
>>
>> 13 мая 2016 г., в 20:33, David Majnemer 
>> написал(а):
>>
>> This seems to crash clang:
>> struct S {
>>   void f() __unaligned;
>> };
>> void S::f() __unaligned {
>> }
>>
>> clang/lib/Sema/DeclSpec.cpp:214: static clang::DeclaratorChunk
>> clang::DeclaratorChunk::getFunction(bool, bool, clang::SourceLocation,
>> clang::DeclaratorChunk::ParamInfo *, unsigned int, clang::SourceLocation,
>> clang::SourceLocation, unsigned int, bool, clang::SourceLocation,
>> clang::SourceLocation, clang::SourceLocation, clang::SourceLocation,
>> clang::SourceLocation, clang::ExceptionSpecificationType,
>> clang::SourceRange, ParsedType *, clang::SourceRange *, unsigned int,
>> clang::Expr *, CachedTokens *, clang::SourceLocation,
>> clang::SourceLocation, clang::Declarator &, TypeResult): Assertion
>> `I.Fun.TypeQuals == TypeQuals && "bitfield overflow"' failed.
>>
>>
>> On Wed, May 11, 2016 at 11:38 AM, Andrey Bokhanko via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: asbokhan
>>> Date: Wed May 11 13:38:21 2016
>>> New Revision: 269220
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=269220&view=rev
>>> Log:
>>> [MSVC] Implementation of __unaligned as a proper type qualifier
>>>
>>> This patch implements __unaligned (MS extension) as a proper type
>>> qualifier
>>> (before that, it was implemented as an ignored attribute).
>>>
>>> It also fixes PR27367 and PR27666.
>>>
>>> Differential Revision: http://reviews.llvm.org/D20103
>>>
>>> Modified:
>>> cfe/trunk/include/clang/AST/Type.h
>>> cfe/trunk/include/clang/Basic/AddressSpaces.h
>>> cfe/trunk/include/clang/Basic/Attr.td
>>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>> cfe/trunk/include/clang/Sema/DeclSpec.h
>>> cfe/trunk/include/clang/Sema/Sema.h
>>> cfe/trunk/lib/AST/MicrosoftMangle.cpp
>>> cfe/trunk/lib/AST/TypePrinter.cpp
>>> cfe/trunk/lib/Parse/ParseDecl.cpp
>>> cfe/trunk/lib/Parse/ParseTentative.cpp
>>> cfe/trunk/lib/Sema/DeclSpec.cpp
>>> cfe/trunk/lib/Sema/SemaCodeComplete.cpp
>>> cfe/trunk/lib/Sema/SemaDecl.cpp
>>> cfe/trunk/lib/Sema/SemaDeclObjC.cpp
>>> cfe/trunk/lib/Sema/SemaExpr.cpp
>>> cfe/trunk/lib/Sema/SemaOverload.cpp
>>> cfe/trunk/lib/Sema/SemaType.cpp
>>> cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
>>> cfe/trunk/test/CodeGenCXX/mangle-ms-cxx14.cpp
>>> cfe/trunk/test/Sema/MicrosoftExtensions.c
>>> cfe/trunk/test/Sema/address_spaces.c
>>> cfe/trunk/test/Sema/invalid-assignment-constant-address-space.c
>>> cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
>>>
>>> Modified: cfe/trunk/include/clang/AST/Type.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=269220&r1=269219&r2=269220&view=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/AST/Type.h (original)
>>> +++ cfe/trunk/include/clang/AST/Type.h Wed May 11 13:38:21 2016
>>> @@ -111,6 +111,7 @@ namespace clang {
>>>  /// The collection of all-type qualifiers we support.
>>>  /// Clang supports five independent qualifiers:
>>>  /// * C99: const, volatile, and restrict
>>> +/// * MS: __unaligned
>>>  /// * Embedded C (TR18037): address spaces
>>>  /// * Objective C: the GC attributes (none, weak, or strong)
>>>  class Qualifiers {
>>> @@ -152,8 +153,8 @@ public:
>>>
>>>enum {
>>>  /// The maximum supported address space number.
>>> -/// 24 bits should be enough for anyone.
>>> -MaxAddressSpace = 0xffu,
>>> +/// 23 bits should be enough for anyone.
>>> +MaxAddressSpace = 0x7fu,
>>>
>>>  /// The width of the "fast" qualifier mask.
>>>  FastWidth = 3,
>>> @@ -265,6 +266,13 @@ public:
>>>  Mask |= mask;
>>>}
>>>
>>> +  bool hasUnaligned() const { return Mask & UMask; }
>>> +  void setUnaligned(bool flag) {
>>> +Mask = (Mask & ~UMask) | (flag ? UMask : 0);
>>> +  }
>>> +  void removeUnaligned() { Mask &= ~UMask; }
>>> +  void addUnaligned() { Mask |= UMask; }
>>> +
>>>bool hasObjCGCAttr() const { return Mask & GCAttrMask; }
>>>GC getObjCGCAttr() const { return GC((Mask & GCAttrMask) >>
>>> GCAttrShift); }
>>>void setObjCGCAttr(GC type) {
>>> @@ -433,7 +441,9 @@ public:
>>> // ObjC lifetime qual

Re: [PATCH] D20428: Tracking exception specification source locations

2016-05-19 Thread don hinton via cfe-commits
hintonda added a comment.

I can already catch all of these cases, but I can't catch this one, will this 
catch it too?

  void g(void (*fp)(void) throw()) throw();
  ^^^


http://reviews.llvm.org/D20428



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


Re: [PATCH] D20437: [MSVC] Support of __unaligned qualifier for function types

2016-05-19 Thread David Majnemer via cfe-commits
majnemer added inline comments.


Comment at: include/clang/Sema/DeclSpec.h:1152-1169
@@ -1153,19 +1151,20 @@
 
   struct ArrayTypeInfo : TypeInfoCommon {
-/// The type qualifiers for the array: const/volatile/restrict/_Atomic.
-unsigned TypeQuals : 4;
+/// The type qualifiers for the array:
+/// const/volatile/restrict/__unaligned/_Atomic.
+unsigned TypeQuals : 5;
 
 /// True if this dimension included the 'static' keyword.
 bool hasStatic : 1;
 
 /// True if this dimension was [*].  In this case, NumElts is null.
 bool isStar : 1;
 
 /// This is the size of the array, or null if [] or [*] was specified.
 /// Since the parser is multi-purpose, and we don't want to impose a root
 /// expression class on all clients, NumElts is untyped.
 Expr *NumElts;
 
 void destroy() {}
   };
 

Should `__unaligned` actually be carried here or does MSVC discard the 
qualifier here?


Comment at: include/clang/Sema/DeclSpec.h:1414-1418
@@ -1414,7 +1413,7 @@
 
   struct MemberPointerTypeInfo : TypeInfoCommon {
-/// The type qualifiers: const/volatile/restrict/_Atomic.
-unsigned TypeQuals : 4;
+/// The type qualifiers: const/volatile/restrict/__unaligned/_Atomic.
+unsigned TypeQuals : 5;
 // CXXScopeSpec has a constructor, so it can't be a direct member.
 // So we need some pointer-aligned storage and a bit of trickery.
 union {

Ditto.  Do we need storage for this bit or should we make sure it got discarded 
earlier?


http://reviews.llvm.org/D20437



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


Re: [PATCH] D20415: Update Clang for D20147 ("DebugInfo: New metadata representation for global variables.")

2016-05-19 Thread Peter Collingbourne via cfe-commits
pcc updated this revision to Diff 57809.
pcc added a comment.

- Add a test for DW_OP_stack_value


http://reviews.llvm.org/D20415

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/2009-10-20-GlobalDebug.c
  test/CodeGen/2010-08-10-DbgConstant.c
  test/CodeGen/debug-info-packed-struct.c
  test/CodeGen/debug-info-static.c
  test/CodeGenCXX/debug-info-access.cpp
  test/CodeGenCXX/debug-info-alias.cpp
  test/CodeGenCXX/debug-info-anon-namespace.cpp
  test/CodeGenCXX/debug-info-anon-union-vars.cpp
  test/CodeGenCXX/debug-info-method.cpp
  test/CodeGenCXX/debug-info-namespace.cpp
  test/CodeGenCXX/debug-info-static-member.cpp
  test/CodeGenCXX/debug-info-template-explicit-specialization.cpp
  test/CodeGenCXX/debug-info-template-member.cpp
  test/CodeGenCXX/debug-info-template.cpp
  test/CodeGenCXX/debug-info-uuid.cpp
  test/CodeGenCXX/debug-info.cpp
  test/CodeGenCXX/debug-lambda-expressions.cpp
  test/CodeGenCXX/inline-dllexport-member.cpp
  test/Driver/darwin-debug-flags.c
  test/Modules/ExtDebugInfo.cpp
  test/Modules/ExtDebugInfo.m

Index: test/Modules/ExtDebugInfo.m
===
--- test/Modules/ExtDebugInfo.m
+++ test/Modules/ExtDebugInfo.m
@@ -34,14 +34,8 @@
   return [c property];
 }
 
-// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClassWithPrivateIVars",
-// CHECK-SAME: flags: DIFlagObjcClassComplete
-
 // CHECK: ![[MOD:.*]] = !DIModule(scope: null, name: "DebugObjC
 
-// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "hidden_ivar",
-// CHECK-SAME:   flags: DIFlagPrivate)
-
 // CHECK: !DIGlobalVariable(name: "GlobalUnion",
 // CHECK-SAME:  type: ![[GLOBAL_UNION:[0-9]+]]
 // CHECK: ![[GLOBAL_UNION]] = distinct !DICompositeType(tag: DW_TAG_union_type,
@@ -52,10 +46,11 @@
 // CHECK: ![[GLOBAL_STRUCT]] = distinct !DICompositeType(tag: DW_TAG_structure_type,
 // CHECK-SAME:elements: !{{[0-9]+}})
 
-// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "TypedefUnion",
-// CHECK-SAME:   baseType: ![[TD_UNION:.*]])
-// CHECK: ![[TD_UNION]] = !DICompositeType(tag: DW_TAG_union_type,
-// CHECK-SAME: flags: DIFlagFwdDecl)
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClassWithPrivateIVars",
+// CHECK-SAME: flags: DIFlagObjcClassComplete
+
+// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "hidden_ivar",
+// CHECK-SAME:   flags: DIFlagPrivate)
 
 // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "TypedefEnum",
 // CHECK-SAME:   baseType: ![[TD_ENUM:.*]])
@@ -67,6 +62,11 @@
 // CHECK: ![[TD_STRUCT]] = !DICompositeType(tag: DW_TAG_structure_type,
 // CHECK-SAME: flags: DIFlagFwdDecl)
 
+// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "TypedefUnion",
+// CHECK-SAME:   baseType: ![[TD_UNION:.*]])
+// CHECK: ![[TD_UNION]] = !DICompositeType(tag: DW_TAG_union_type,
+// CHECK-SAME: flags: DIFlagFwdDecl)
+
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass",
 // CHECK-SAME: scope: ![[MOD]],
 // CHECK-SAME: flags: DIFlagFwdDecl)
Index: test/Modules/ExtDebugInfo.cpp
===
--- test/Modules/ExtDebugInfo.cpp
+++ test/Modules/ExtDebugInfo.cpp
@@ -67,20 +67,14 @@
   anon.i = GlobalStruct.i = GlobalUnion.i = GlobalEnum;
 }
 
-
-// CHECK: ![[STRUCT:.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Struct",
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum",
 // CHECK-SAME: scope: ![[NS:[0-9]+]],
 // CHECK-SAME: flags: DIFlagFwdDecl,
-// CHECK-SAME: identifier: "_ZTSN8DebugCXX6StructE")
+// CHECK-SAME: identifier:  "_ZTSN8DebugCXX4EnumE")
 
 // CHECK: ![[NS]] = !DINamespace(name: "DebugCXX", scope: ![[MOD:[0-9]+]],
 // CHECK: ![[MOD]] = !DIModule(scope: null, name: {{.*}}DebugCXX
 
-// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum",
-// CHECK-SAME: scope: ![[NS]],
-// CHECK-SAME: flags: DIFlagFwdDecl,
-// CHECK-SAME: identifier:  "_ZTSN8DebugCXX4EnumE")
-
 // This type is anchored in the module by an explicit template instantiation.
 // CHECK: !DICompositeType(tag: DW_TAG_class_type,
 // CHECK-SAME: name: "Template >",
@@ -119,7 +113,12 @@
 // CHECK-SAME: identifier: "_ZTSN8DebugCXX1AIJvEEE")
 
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "static_member",
-// CHECK-SAME:   scope: ![[STRUCT]]
+// CHECK-SAME:   scope: ![[STRUCT:[0-9]*]]
+
+// CHECK: ![[STRUCT]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Struct",
+// CHECK-SAME: scope: ![[NS]],
+// CHECK-SAME: flags: DIFlagFwdDecl,
+// CHECK-SAME: identifier: "_ZTSN8DebugCXX6StructE")
 
 // CHECK: !DICompositeT

Re: [PATCH] D20401: [Lexer] Don't merge macro args from different macro files

2016-05-19 Thread Vedant Kumar via cfe-commits
vsk updated this revision to Diff 57810.
vsk added a comment.

- Fix explanation of the test case in test/CoverageMapping.


http://reviews.llvm.org/D20401

Files:
  lib/Lex/TokenLexer.cpp
  test/CoverageMapping/Inputs/macros.h
  test/CoverageMapping/include-macros.c
  unittests/Lex/LexerTest.cpp

Index: unittests/Lex/LexerTest.cpp
===
--- unittests/Lex/LexerTest.cpp
+++ unittests/Lex/LexerTest.cpp
@@ -58,8 +58,7 @@
 Target = TargetInfo::CreateTargetInfo(Diags, TargetOpts);
   }
 
-  std::vector CheckLex(StringRef Source,
-  ArrayRef ExpectedTokens) {
+  std::vector Lex(StringRef Source) {
 std::unique_ptr Buf =
 llvm::MemoryBuffer::getMemBuffer(Source);
 SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(Buf)));
@@ -82,6 +81,12 @@
   toks.push_back(tok);
 }
 
+return toks;
+  }
+
+  std::vector CheckLex(StringRef Source,
+  ArrayRef ExpectedTokens) {
+auto toks = Lex(Source);
 EXPECT_EQ(ExpectedTokens.size(), toks.size());
 for (unsigned i = 0, e = ExpectedTokens.size(); i != e; ++i) {
   EXPECT_EQ(ExpectedTokens[i], toks[i].getKind());
@@ -358,4 +363,21 @@
   EXPECT_EQ("N", Lexer::getImmediateMacroName(idLoc4, SourceMgr, LangOpts));
 }
 
+TEST_F(LexerTest, DontMergeMacroArgsFromDifferentMacroFiles) {
+  std::vector toks =
+  Lex("#define helper1 0\n"
+  "void helper2(const char *, ...);\n"
+  "#define M1(a, ...) helper2(a, ##__VA_ARGS__)\n"
+  "#define M2(a, ...) M1(a, helper1, ##__VA_ARGS__)\n"
+  "void f1() { M2(\"a\", \"b\"); }");
+
+  // Check the file corresponding to the "helper1" macro arg in M2.
+  //
+  // The lexer used to report its size as 31, meaning that the end of the
+  // expansion would be on the *next line* (just past `M2("a", "b")`). Make
+  // sure that we get the correct end location (the comma after "helper1").
+  SourceLocation helper1ArgLoc = toks[20].getLocation();
+  EXPECT_EQ(SourceMgr.getFileIDSize(SourceMgr.getFileID(helper1ArgLoc)), 8U);
+}
+
 } // anonymous namespace
Index: test/CoverageMapping/include-macros.c
===
--- /dev/null
+++ test/CoverageMapping/include-macros.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name include-macros.c %s | FileCheck %s
+
+#include "Inputs/macros.h"
+
+void f1() {
+  M2("a", "b");
+}
+
+// CHECK-LABEL: f1:
+// CHECK-NEXT:   File 0, 5:11 -> 7:2 = #0
+// CHECK-NEXT:   Expansion,File 0, 6:3 -> 6:5 = #0 (Expanded file = 1)
+// CHECK-NEXT:   File 1, 13:20 -> 13:50 = #0
+// CHECK-NEXT:   Expansion,File 1, 13:20 -> 13:22 = #0 (Expanded file = 2)
+// CHECK-NEXT:   File 2, 7:20 -> 7:46 = #0
+// CHECK-NEXT:   Expansion,File 2, 7:33 -> 7:44 = #0 (Expanded file = 3)
+// CHECK-NEXT:   File 3, 13:26 -> 13:34 = #0
+// CHECK-NEXT:   Expansion,File 3, 13:26 -> 13:33 = #0 (Expanded file = 4)
+// CHECK-NEXT:   File 4, 3:17 -> 3:18 = #0
Index: test/CoverageMapping/Inputs/macros.h
===
--- /dev/null
+++ test/CoverageMapping/Inputs/macros.h
@@ -0,0 +1,13 @@
+// Assorted macros to help test #include behavior across file boundaries.
+
+#define helper1 0
+
+void helper2(const char *, ...);
+
+#define M1(a, ...) helper2(a, ##__VA_ARGS__);
+
+// Note: M2 stresses vararg macro functions with macro arguments. The spelling
+// locations of the args used to be set to the expansion site, leading to
+// crashes (region LineEnd < LineStart). The regression test requires M2's line
+// number to be greater than the line number containing the expansion.
+#define M2(a, ...) M1(a, helper1, ##__VA_ARGS__);
Index: lib/Lex/TokenLexer.cpp
===
--- lib/Lex/TokenLexer.cpp
+++ lib/Lex/TokenLexer.cpp
@@ -787,6 +787,9 @@
 if (CurLoc.isFileID() != NextLoc.isFileID())
   break; // Token from different kind of FileID.
 
+if (CurLoc.isMacroID() && !SM.isWrittenInSameFile(CurLoc, NextLoc))
+  break; // Token from a different macro.
+
 int RelOffs;
 if (!SM.isInSameSLocAddrSpace(CurLoc, NextLoc, &RelOffs))
   break; // Token from different local/loaded location.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18575: [clang-tidy] New checker to replace deprecated throw() specifications

2016-05-19 Thread don hinton via cfe-commits
hintonda updated this revision to Diff 57811.
hintonda added a comment.

Adjust matcher, add better error checking, and additional test cases.

We can now parse all dynamic exception specifications, but haven't
been able to develop a matcher that will find the following function
declaration without finding other nodes that aren't parsable.

  void g(void (*fp)(void) throw());


http://reviews.llvm.org/D18575

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseNoexceptCheck.cpp
  clang-tidy/modernize/UseNoexceptCheck.h
  clang-tidy/modernize/UseOverrideCheck.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/modernize-use-noexcept.rst
  test/clang-tidy/modernize-use-noexcept-macro.cpp
  test/clang-tidy/modernize-use-noexcept.cpp

Index: test/clang-tidy/modernize-use-noexcept.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-noexcept.cpp
@@ -0,0 +1,59 @@
+// RUN: %check_clang_tidy %s modernize-use-noexcept %t -- \
+// RUN:   -- -std=c++11
+
+class A {};
+class B {};
+
+void foo() throw();
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'foo' uses dynamic exception specification 'throw()' [modernize-use-noexcept]
+// CHECK-FIXES: void foo() noexcept;
+
+void bar() throw(...);
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bar' uses dynamic exception specification 'throw(...)' [modernize-use-noexcept]
+// CHECK-FIXES: void bar() noexcept(false);
+
+void foobar() throw(A, B)
+{}
+// CHECK-MESSAGES: :[[@LINE-2]]:6: warning: function 'foobar' uses dynamic exception specification 'throw(A, B)' [modernize-use-noexcept]
+// CHECK-FIXES: void foobar() noexcept(false)
+
+void baz(int = (throw A(), 0)) throw(A, B) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'baz' uses dynamic exception specification 'throw(A, B)' [modernize-use-noexcept]
+// CHECK-FIXES: void baz(int = (throw A(), 0)) noexcept(false) {}
+
+// We can fix this one because the matcher finds the trailing throw().
+void f(void (*fp)(void) throw()) throw(char);
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'f' uses dynamic exception specification 'throw()' [modernize-use-noexcept]
+// CHECK-MESSAGES: :[[@LINE-2]]:6: warning: function 'f' uses dynamic exception specification 'throw(char)' [modernize-use-noexcept]
+// CHECK-FIXES: void f(void (*fp)(void) noexcept) noexcept(false);
+
+// FIXME: We can't fix this one -- need help developing an appropriate matcher.
+void g(void (*fp)(void) throw());
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'g' uses dynamic exception specification 'throw()' [modernize-use-noexcept]
+// CHECK-FIXES: void g(void (*fp)(void) noexcept);
+
+void j() throw(int(int) throw(void(void) throw(int)));
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'j' uses dynamic exception specification 'throw(int(int) throw(void(void) throw(int)))' [modernize-use-noexcept]
+// CHECK-FIXES: void j() noexcept(false);
+
+void k() throw(int(int));
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'k' uses dynamic exception specification 'throw(int(int))' [modernize-use-noexcept]
+// CHECK-FIXES: void k() noexcept(false);
+
+// Should not trigger a replacement.
+void titi() noexcept {}
+void toto() noexcept(true) {}
+
+
+class Y {
+  Y() throw() = default;
+};
+// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: function 'Y' uses dynamic exception specification 'throw()' [modernize-use-noexcept]
+// CHECK-FIXES: Y() noexcept = default;
+
+// We can't find this
+#define xxx X() throw() = default
+class X {
+  xxx;
+};
+
Index: test/clang-tidy/modernize-use-noexcept-macro.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-noexcept-macro.cpp
@@ -0,0 +1,24 @@
+// RUN: %check_clang_tidy %s modernize-use-noexcept %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-noexcept.ReplacementString, value: 'NOEXCEPT'}]}" \
+// RUN:   -- -std=c++11
+
+// Example definition of NOEXCEPT -- simplified test to see if noexcept is supported. 
+#if (__has_feature(cxx_noexcept))
+#define NOEXCEPT noexcept
+#else
+#define NOEXCEPT throw()
+#endif
+
+void bar() throw() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bar' uses dynamic exception specification 'throw()' [modernize-use-noexcept]
+// CHECK-FIXES: void bar() NOEXCEPT {}
+
+// Should not trigger a FixItHint, since macros only support noexcept, and this
+// case throws.
+class A {};
+class B {};
+void foobar() throw(A, B);
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'foobar' uses dynamic exception specification 'throw(A, B)' [modernize-use-noexcept]
+
+// Should not trigger a replacement.
+void foo() noexcept(true);
Index: docs/clang-tidy/checks/modernize-use-noexcept.rst
===
--- /dev/null
+++ docs/clang-tidy/check

Re: [PATCH] D18575: [clang-tidy] New checker to replace deprecated throw() specifications

2016-05-19 Thread don hinton via cfe-commits
hintonda added a comment.

Btw, this version can successfully check libcxx.


http://reviews.llvm.org/D18575



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


Re: [PATCH] D20420: [find-all-symbol] Add macro support.

2016-05-19 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

In the future I'd prefer to do renaming changes 
(ResultReporter->SymbolReporter) in a separate change, but this is fine now.



Comment at: include-fixer/find-all-symbols/SymbolReporter.h:1
@@ +1,2 @@
+//===-- SymbolReporter.h - find all symbols--*- C++ 
-*-===//
+//

find all symbols?


http://reviews.llvm.org/D20420



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


r270079 - [X86][SSE2] Fixed shuffle of results in _mm_cmpnge_sd/_mm_cmpngt_sd tests

2016-05-19 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu May 19 11:48:59 2016
New Revision: 270079

URL: http://llvm.org/viewvc/llvm-project?rev=270079&view=rev
Log:
[X86][SSE2] Fixed shuffle of results in _mm_cmpnge_sd/_mm_cmpngt_sd tests

Modified:
cfe/trunk/test/CodeGen/sse2-builtins.c

Modified: cfe/trunk/test/CodeGen/sse2-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sse2-builtins.c?rev=270079&r1=270078&r2=270079&view=diff
==
--- cfe/trunk/test/CodeGen/sse2-builtins.c (original)
+++ cfe/trunk/test/CodeGen/sse2-builtins.c Thu May 19 11:48:59 2016
@@ -306,6 +306,10 @@ __m128d test_mm_cmpnge_pd(__m128d A, __m
 __m128d test_mm_cmpnge_sd(__m128d A, __m128d B) {
   // CHECK-LABEL: test_mm_cmpnge_sd
   // CHECK: call <2 x double> @llvm.x86.sse2.cmp.sd(<2 x double> %{{.*}}, <2 x 
double> %{{.*}}, i8 6)
+  // CHECK: extractelement <2 x double> %{{.*}}, i32 0
+  // CHECK: insertelement <2 x double> undef, double %{{.*}}, i32 0
+  // CHECK: extractelement <2 x double> %{{.*}}, i32 1
+  // CHECK: insertelement <2 x double> %{{.*}}, double %{{.*}}, i32 1
   return _mm_cmpnge_sd(A, B);
 }
 
@@ -318,6 +322,10 @@ __m128d test_mm_cmpngt_pd(__m128d A, __m
 __m128d test_mm_cmpngt_sd(__m128d A, __m128d B) {
   // CHECK-LABEL: test_mm_cmpngt_sd
   // CHECK: call <2 x double> @llvm.x86.sse2.cmp.sd(<2 x double> %{{.*}}, <2 x 
double> %{{.*}}, i8 5)
+  // CHECK: extractelement <2 x double> %{{.*}}, i32 0
+  // CHECK: insertelement <2 x double> undef, double %{{.*}}, i32 0
+  // CHECK: extractelement <2 x double> %{{.*}}, i32 1
+  // CHECK: insertelement <2 x double> %{{.*}}, double %{{.*}}, i32 1
   return _mm_cmpngt_sd(A, B);
 }
 


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


[clang-tools-extra] r270082 - [include-fixer] Fix unused variable warning in Release builds.

2016-05-19 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu May 19 11:57:57 2016
New Revision: 270082

URL: http://llvm.org/viewvc/llvm-project?rev=270082&view=rev
Log:
[include-fixer] Fix unused variable warning in Release builds.

Modified:
clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp

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=270082&r1=270081&r2=270082&view=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Thu May 19 11:57:57 
2016
@@ -259,10 +259,11 @@ public:
   Insertions.insert(
   clang::tooling::Replacement(Filename, FirstIncludeOffset, 0, Text));
 }
-DEBUG(llvm::dbgs() << "Header insertions:\n");
-for (const auto &R : Insertions) {
-  DEBUG(llvm::dbgs() << R.toString() << "\n");
-}
+DEBUG({
+  llvm::dbgs() << "Header insertions:\n";
+  for (const auto &R : Insertions)
+llvm::dbgs() << R.toString() << '\n';
+});
 
 clang::format::FormatStyle Style =
 clang::format::getStyle("file", Filename, FallbackStyle);


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


Re: [PATCH] D20383: PCH + Module: make sure we write out macros associated with builtin identifiers

2016-05-19 Thread Manman Ren via cfe-commits
manmanren added a comment.

Thanks Bruno



Comment at: lib/Serialization/ASTWriter.cpp:2191
@@ -2191,1 +2190,3 @@
+// We write out exported module macros for PCH as well.
+if (true) {
   auto Leafs = PP.getLeafModuleMacros(Name);

bruno wrote:
> Is this intended?
I was trying to make sure people get that it is the only thing this patch 
changes :) I will remove it if we are okay with this approach.



http://reviews.llvm.org/D20383



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


r270083 - [X86][SSE] Sync with llvm/test/CodeGen/X86/sse-intrinsics-fast-isel.ll

2016-05-19 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu May 19 12:11:31 2016
New Revision: 270083

URL: http://llvm.org/viewvc/llvm-project?rev=270083&view=rev
Log:
[X86][SSE] Sync with llvm/test/CodeGen/X86/sse-intrinsics-fast-isel.ll

sse-builtins.c now just covers SSE1 intrinsics

Modified:
cfe/trunk/test/CodeGen/sse-builtins.c

Modified: cfe/trunk/test/CodeGen/sse-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sse-builtins.c?rev=270083&r1=270082&r2=270083&view=diff
==
--- cfe/trunk/test/CodeGen/sse-builtins.c (original)
+++ cfe/trunk/test/CodeGen/sse-builtins.c Thu May 19 12:11:31 2016
@@ -1,8 +1,11 @@
-// RUN: %clang_cc1 -ffreestanding -triple x86_64-apple-macosx10.8.0 
-target-feature +sse4.1 -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -target-feature +sse 
-emit-llvm -o - -Werror | FileCheck %s
 
-#include 
-#include 
-#include 
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+
+#include 
+
+// NOTE: This should match the tests in 
llvm/test/CodeGen/X86/sse-intrinsics-fast-isel.ll
 
 __m128 test_mm_add_ps(__m128 A, __m128 B) {
   // CHECK-LABEL: test_mm_add_ps
@@ -10,134 +13,144 @@ __m128 test_mm_add_ps(__m128 A, __m128 B
   return _mm_add_ps(A, B);
 }
 
+__m128 test_mm_add_ss(__m128 A, __m128 B) {
+  // CHECK-LABEL: test_mm_add_ss
+  // CHECK: extractelement <4 x float> %{{.*}}, i32 0
+  // CHECK: extractelement <4 x float> %{{.*}}, i32 0
+  // CHECK: fadd float
+  // CHECK: insertelement <4 x float> %{{.*}}, float %{{.*}}, i32 0
+  return _mm_add_ss(A, B);
+}
+
 __m128 test_mm_and_ps(__m128 A, __m128 B) {
   // CHECK-LABEL: test_mm_and_ps
-  // CHECK: and <4 x i32> %{{.*}}, %{{.*}}
+  // CHECK: and <4 x i32>
   return _mm_and_ps(A, B);
 }
 
-__m128 test_mm_div_ps(__m128 A, __m128 B) {
-  // CHECK-LABEL: test_mm_div_ps
-  // CHECK: fdiv <4 x float>
-  return _mm_div_ps(A, B);
+__m128 test_mm_andnot_ps(__m128 A, __m128 B) {
+  // CHECK-LABEL: test_mm_andnot_ps
+  // CHECK: xor <4 x i32> %{{.*}}, 
+  // CHECK: and <4 x i32>
+  return _mm_andnot_ps(A, B);
 }
 
-__m128 test_mm_mul_ps(__m128 A, __m128 B) {
-  // CHECK-LABEL: test_mm_mul_ps
-  // CHECK: fmul <4 x float>
-  return _mm_mul_ps(A, B);
+__m128 test_mm_cmpeq_ps(__m128 __a, __m128 __b) {
+  // CHECK-LABEL: @test_mm_cmpeq_ps
+  // CHECK: @llvm.x86.sse.cmp.ps(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i8 
0)
+  return _mm_cmpeq_ps(__a, __b);
 }
 
-__m128 test_mm_or_ps(__m128 A, __m128 B) {
-  // CHECK-LABEL: test_mm_or_ps
-  // CHECK: or <4 x i32> %{{.*}}, %{{.*}}
-  return _mm_or_ps(A, B);
+__m128 test_mm_cmpeq_ss(__m128 __a, __m128 __b) {
+  // CHECK-LABEL: @test_mm_cmpeq_ss
+  // CHECK: @llvm.x86.sse.cmp.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i8 
0)
+  return _mm_cmpeq_ss(__a, __b);
 }
 
-__m128 test_mm_sub_ps(__m128 A, __m128 B) {
-  // CHECK-LABEL: test_mm_sub_ps
-  // CHECK: fsub <4 x float>
-  return _mm_sub_ps(A, B);
+__m128 test_mm_cmpge_ps(__m128 __a, __m128 __b) {
+  // CHECK-LABEL: @test_mm_cmpge_ps
+  // CHECK: @llvm.x86.sse.cmp.ps(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i8 
2)
+  return _mm_cmpge_ps(__a, __b);
 }
 
-__m128 test_mm_xor_ps(__m128 A, __m128 B) {
-  // CHECK-LABEL: test_mm_xor_ps
-  // CHECK: xor <4 x i32> %{{.*}}, %{{.*}}
-  return _mm_xor_ps(A, B);
+__m128 test_mm_cmpge_ss(__m128 __a, __m128 __b) {
+  // CHECK-LABEL: @test_mm_cmpge_ss
+  // CHECK: @llvm.x86.sse.cmp.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i8 
2)
+  // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> 

+  return _mm_cmpge_ss(__a, __b);
 }
 
-__m128 test_rsqrt_ss(__m128 x) {
-  // CHECK: define {{.*}} @test_rsqrt_ss
-  // CHECK: call <4 x float> @llvm.x86.sse.rsqrt.ss
-  // CHECK: extractelement <4 x float> {{.*}}, i32 0
-  // CHECK: extractelement <4 x float> {{.*}}, i32 1
-  // CHECK: extractelement <4 x float> {{.*}}, i32 2
-  // CHECK: extractelement <4 x float> {{.*}}, i32 3
-  return _mm_rsqrt_ss(x);
+__m128 test_mm_cmpgt_ps(__m128 __a, __m128 __b) {
+  // CHECK-LABEL: @test_mm_cmpgt_ps
+  // CHECK: @llvm.x86.sse.cmp.ps(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i8 
1)
+  return _mm_cmpgt_ps(__a, __b);
 }
 
-__m128 test_rcp_ss(__m128 x) {
-  // CHECK: define {{.*}} @test_rcp_ss
-  // CHECK: call <4 x float> @llvm.x86.sse.rcp.ss
-  // CHECK: extractelement <4 x float> {{.*}}, i32 0
-  // CHECK: extractelement <4 x float> {{.*}}, i32 1
-  // CHECK: extractelement <4 x float> {{.*}}, i32 2
-  // CHECK: extractelement <4 x float> {{.*}}, i32 3
-  return _mm_rcp_ss(x);
+__m128 test_mm_cmpgt_ss(__m128 __a, __m128 __b) {
+  // CHECK-LABEL: @test_mm_cmpgt_ss
+  // CHECK: @llvm.x86.sse.cmp.ss(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i8 
1)
+  // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> 

+  return _mm_cmpgt_ss(__a, __b);
 }
 
-__m128 test_sqrt_ss(__m128 x) {
-  // CHECK: define {{.*}} @test_sqrt_ss
-  // CHECK: call <4 x float> @llvm.x86.sse.sqr

Re: [PATCH] D20428: Tracking exception specification source locations

2016-05-19 Thread Aaron Ballman via cfe-commits
aaron.ballman updated this revision to Diff 57816.
aaron.ballman added a comment.

Added test cases for parameter types that have exception specifications.


http://reviews.llvm.org/D20428

Files:
  include/clang/AST/Decl.h
  include/clang/AST/TypeLoc.h
  lib/AST/Decl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Sema/SemaType.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  unittests/AST/SourceLocationTest.cpp

Index: unittests/AST/SourceLocationTest.cpp
===
--- unittests/AST/SourceLocationTest.cpp
+++ unittests/AST/SourceLocationTest.cpp
@@ -580,5 +580,72 @@
   Language::Lang_CXX11));
 }
 
+class ExceptionSpecRangeVerifier : public RangeVerifier {
+protected:
+  SourceRange getRange(const TypeLoc &Node) override {
+auto T =
+  Node.getUnqualifiedLoc().castAs();
+assert(!T.isNull());
+return T.getExceptionSpecRange();
+  }
+};
+
+class ParmVarExceptionSpecRangeVerifier : public RangeVerifier {
+protected:
+  SourceRange getRange(const ParmVarDecl &Node) override {
+if (const TypeSourceInfo *TSI = Node.getTypeSourceInfo()) {
+  TypeLoc TL = TSI->getTypeLoc();
+  if (TL.getType()->isPointerType()) {
+TL = TL.getNextTypeLoc().IgnoreParens();
+if (auto FPTL = TL.getAs()) {
+  return FPTL.getExceptionSpecRange();
+}
+  }
+}
+return SourceRange();
+  }
+};
+
+TEST(FunctionDecl, ExceptionSpecifications) {
+  ExceptionSpecRangeVerifier Verifier;
+
+  Verifier.expectRange(1, 10, 1, 16);
+  EXPECT_TRUE(Verifier.match("void f() throw();\n", loc(functionType(;
+
+  Verifier.expectRange(1, 10, 1, 34);
+  EXPECT_TRUE(Verifier.match("void f() throw(void(void) throw());\n",
+ loc(functionType(;
+
+  Verifier.expectRange(1, 10, 1, 19);
+  std::vector Args;
+  Args.push_back("-fms-extensions");
+  EXPECT_TRUE(Verifier.match("void f() throw(...);\n", loc(functionType()),
+ Args, Language::Lang_CXX));
+
+  Verifier.expectRange(1, 10, 1, 17);
+  EXPECT_TRUE(Verifier.match("void f() noexcept;\n", loc(functionType()),
+ Language::Lang_CXX11));
+
+  Verifier.expectRange(1, 10, 1, 24);
+  EXPECT_TRUE(Verifier.match("void f() noexcept(false);\n", loc(functionType()),
+ Language::Lang_CXX11));
+
+  Verifier.expectRange(1, 10, 1, 32);
+  EXPECT_TRUE(Verifier.match("void f() noexcept(noexcept(1+1));\n",
+ loc(functionType()), Language::Lang_CXX11));
+
+  ParmVarExceptionSpecRangeVerifier Verifier2;
+  Verifier2.expectRange(1, 25, 1, 31);
+  EXPECT_TRUE(Verifier2.match("void g(void (*fp)(void) throw());\n",
+  parmVarDecl(hasType(pointerType(pointee(
+  parenType(innerType(functionType();
+
+  Verifier2.expectRange(1, 25, 1, 38);
+  EXPECT_TRUE(Verifier2.match("void g(void (*fp)(void) noexcept(true));\n",
+  parmVarDecl(hasType(pointerType(pointee(
+  parenType(innerType(functionType())),
+  Language::Lang_CXX11));
+}
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -572,6 +572,7 @@
   Record.AddSourceLocation(TL.getLocalRangeBegin());
   Record.AddSourceLocation(TL.getLParenLoc());
   Record.AddSourceLocation(TL.getRParenLoc());
+  Record.AddSourceRange(TL.getExceptionSpecRange());
   Record.AddSourceLocation(TL.getLocalRangeEnd());
   for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i)
 Record.AddDeclRef(TL.getParam(i));
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -5812,6 +5812,8 @@
   TL.setLocalRangeBegin(ReadSourceLocation(Record, Idx));
   TL.setLParenLoc(ReadSourceLocation(Record, Idx));
   TL.setRParenLoc(ReadSourceLocation(Record, Idx));
+  TL.setExceptionSpecRange(SourceRange(ReadSourceLocation(Record, Idx),
+   ReadSourceLocation(Record, Idx)));
   TL.setLocalRangeEnd(ReadSourceLocation(Record, Idx));
   for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i) {
 TL.setParam(i, ReadDeclAs(Record, Idx));
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -4919,6 +4919,7 @@
   NewTL.setLocalRangeBegin(TL.getLocalRangeBegin());
   NewTL.setLParenLoc(TL.getLParenLoc());
   NewTL.setRParenLoc(TL.getRParenLoc());
+  NewTL.setExceptionSpecRange(TL.getExceptionSpecRange());
   NewTL.setLocalRangeEnd(TL.getLocalRangeEnd());
   for (unsigned i = 0, e = NewTL.getNumPara

Re: [PATCH] D20428: Tracking exception specification source locations

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

In http://reviews.llvm.org/D20428#434420, @hintonda wrote:

> I can already catch all of these cases, but I can't catch this one, will this 
> catch it too?
>
>   void g(void (*fp)(void) throw()) throw();
>   ^^^
>
>
> Actually, I can catch it, but I haven't been able to create an ASTMatcher 
> that will only include FunctionDecl's -- even using functionDecl() still 
> returns all Decl's, not just FunctionDecl's.


Yes, this information is also tracked as part of my patch. I've added a few 
more test cases for it, thank you!

Assuming that @rsmith thinks my direction is reasonable for tracking source 
information, I strongly prefer to gate your patch on this one. Your custom 
parser may work fine, but I don't think it should be required since we already 
have this information from the real parser. Might as well thread the 
information through so that it can be used by tooling.


http://reviews.llvm.org/D20428



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


Re: [PATCH] D20428: Tracking exception specification source locations

2016-05-19 Thread don hinton via cfe-commits
hintonda added a comment.

Sure that sounds good to me.  However, I would like to learn how to write 
better ASTMatchers.

In any case, this has been a great learning experience.


http://reviews.llvm.org/D20428



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


[PATCH] [clang] Emit ObjC method and block annotation attributes to IR

2016-05-19 Thread Max Bazaliy via cfe-commits
Hey,

For some reason clang does not emit ObjC method and block annotations to
IR. Here is a fix for that.

-- 
Max Bazaliy


objc_blocks_emit_ir.patch
Description: Binary data
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r270084 - [CUDA] Allow sm_50,52,53 GPUs

2016-05-19 Thread Artem Belevich via cfe-commits
Author: tra
Date: Thu May 19 12:47:47 2016
New Revision: 270084

URL: http://llvm.org/viewvc/llvm-project?rev=270084&view=rev
Log:
[CUDA] Allow sm_50,52,53 GPUs

LLVM accepts them since r233575.

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

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/test/CodeGen/nvptx-cpus.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=270084&r1=270083&r2=270084&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu May 19 12:47:47 2016
@@ -1689,6 +1689,9 @@ class NVPTXTargetInfo : public TargetInf
 GK_SM30,
 GK_SM35,
 GK_SM37,
+GK_SM50,
+GK_SM52,
+GK_SM53,
   } GPU;
 
 public:
@@ -1787,6 +1790,15 @@ public:
   case GK_SM37:
 CUDAArchCode = "370";
 break;
+  case GK_SM50:
+CUDAArchCode = "500";
+break;
+  case GK_SM52:
+CUDAArchCode = "520";
+break;
+  case GK_SM53:
+CUDAArchCode = "530";
+break;
   default:
 llvm_unreachable("Unhandled target CPU");
   }
@@ -1836,6 +1848,9 @@ public:
   .Case("sm_30", GK_SM30)
   .Case("sm_35", GK_SM35)
   .Case("sm_37", GK_SM37)
+  .Case("sm_50", GK_SM50)
+  .Case("sm_52", GK_SM52)
+  .Case("sm_53", GK_SM53)
   .Default(GK_NONE);
 
 return GPU != GK_NONE;

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=270084&r1=270083&r2=270084&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu May 19 12:47:47 2016
@@ -1750,6 +1750,10 @@ void Generic_GCC::CudaInstallationDetect
   } else if (GpuArch == "compute_35") {
 CudaLibDeviceMap["sm_35"] = FilePath;
 CudaLibDeviceMap["sm_37"] = FilePath;
+  } else if (GpuArch == "compute_50") {
+CudaLibDeviceMap["sm_50"] = FilePath;
+CudaLibDeviceMap["sm_52"] = FilePath;
+CudaLibDeviceMap["sm_53"] = FilePath;
   }
 }
 

Modified: cfe/trunk/test/CodeGen/nvptx-cpus.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/nvptx-cpus.c?rev=270084&r1=270083&r2=270084&view=diff
==
--- cfe/trunk/test/CodeGen/nvptx-cpus.c (original)
+++ cfe/trunk/test/CodeGen/nvptx-cpus.c Thu May 19 12:47:47 2016
@@ -3,6 +3,9 @@
 // RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_30 -O3 -S -o 
%t %s -emit-llvm
 // RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_35 -O3 -S -o 
%t %s -emit-llvm
 // RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_37 -O3 -S -o 
%t %s -emit-llvm
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_50 -O3 -S -o 
%t %s -emit-llvm
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_52 -O3 -S -o 
%t %s -emit-llvm
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_53 -O3 -S -o 
%t %s -emit-llvm
 
 // Make sure clang accepts all supported architectures.
 


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


Re: [PATCH] D20405: [CUDA] allow sm_50,52,53 GPUs

2016-05-19 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270084: [CUDA] Allow sm_50,52,53 GPUs (authored by tra).

Changed prior to commit:
  http://reviews.llvm.org/D20405?vs=57715&id=57822#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20405

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/Driver/ToolChains.cpp
  cfe/trunk/test/CodeGen/nvptx-cpus.c

Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -1750,6 +1750,10 @@
   } else if (GpuArch == "compute_35") {
 CudaLibDeviceMap["sm_35"] = FilePath;
 CudaLibDeviceMap["sm_37"] = FilePath;
+  } else if (GpuArch == "compute_50") {
+CudaLibDeviceMap["sm_50"] = FilePath;
+CudaLibDeviceMap["sm_52"] = FilePath;
+CudaLibDeviceMap["sm_53"] = FilePath;
   }
 }
 
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -1689,6 +1689,9 @@
 GK_SM30,
 GK_SM35,
 GK_SM37,
+GK_SM50,
+GK_SM52,
+GK_SM53,
   } GPU;
 
 public:
@@ -1787,6 +1790,15 @@
   case GK_SM37:
 CUDAArchCode = "370";
 break;
+  case GK_SM50:
+CUDAArchCode = "500";
+break;
+  case GK_SM52:
+CUDAArchCode = "520";
+break;
+  case GK_SM53:
+CUDAArchCode = "530";
+break;
   default:
 llvm_unreachable("Unhandled target CPU");
   }
@@ -1836,6 +1848,9 @@
   .Case("sm_30", GK_SM30)
   .Case("sm_35", GK_SM35)
   .Case("sm_37", GK_SM37)
+  .Case("sm_50", GK_SM50)
+  .Case("sm_52", GK_SM52)
+  .Case("sm_53", GK_SM53)
   .Default(GK_NONE);
 
 return GPU != GK_NONE;
Index: cfe/trunk/test/CodeGen/nvptx-cpus.c
===
--- cfe/trunk/test/CodeGen/nvptx-cpus.c
+++ cfe/trunk/test/CodeGen/nvptx-cpus.c
@@ -3,6 +3,9 @@
 // RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_30 -O3 -S -o 
%t %s -emit-llvm
 // RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_35 -O3 -S -o 
%t %s -emit-llvm
 // RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_37 -O3 -S -o 
%t %s -emit-llvm
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_50 -O3 -S -o 
%t %s -emit-llvm
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_52 -O3 -S -o 
%t %s -emit-llvm
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_53 -O3 -S -o 
%t %s -emit-llvm
 
 // Make sure clang accepts all supported architectures.
 


Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -1750,6 +1750,10 @@
   } else if (GpuArch == "compute_35") {
 CudaLibDeviceMap["sm_35"] = FilePath;
 CudaLibDeviceMap["sm_37"] = FilePath;
+  } else if (GpuArch == "compute_50") {
+CudaLibDeviceMap["sm_50"] = FilePath;
+CudaLibDeviceMap["sm_52"] = FilePath;
+CudaLibDeviceMap["sm_53"] = FilePath;
   }
 }
 
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -1689,6 +1689,9 @@
 GK_SM30,
 GK_SM35,
 GK_SM37,
+GK_SM50,
+GK_SM52,
+GK_SM53,
   } GPU;
 
 public:
@@ -1787,6 +1790,15 @@
   case GK_SM37:
 CUDAArchCode = "370";
 break;
+  case GK_SM50:
+CUDAArchCode = "500";
+break;
+  case GK_SM52:
+CUDAArchCode = "520";
+break;
+  case GK_SM53:
+CUDAArchCode = "530";
+break;
   default:
 llvm_unreachable("Unhandled target CPU");
   }
@@ -1836,6 +1848,9 @@
   .Case("sm_30", GK_SM30)
   .Case("sm_35", GK_SM35)
   .Case("sm_37", GK_SM37)
+  .Case("sm_50", GK_SM50)
+  .Case("sm_52", GK_SM52)
+  .Case("sm_53", GK_SM53)
   .Default(GK_NONE);
 
 return GPU != GK_NONE;
Index: cfe/trunk/test/CodeGen/nvptx-cpus.c
===
--- cfe/trunk/test/CodeGen/nvptx-cpus.c
+++ cfe/trunk/test/CodeGen/nvptx-cpus.c
@@ -3,6 +3,9 @@
 // RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_30 -O3 -S -o %t %s -emit-llvm
 // RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_35 -O3 -S -o %t %s -emit-llvm
 // RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_37 -O3 -S -o %t %s -emit-llvm
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_50 -O3 -S -o %t %s -emit-llvm
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -ta

r270085 - Don't rely on value numbers in test, those are fragile and change in Release (no asserts) builds.

2016-05-19 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu May 19 12:57:35 2016
New Revision: 270085

URL: http://llvm.org/viewvc/llvm-project?rev=270085&view=rev
Log:
Don't rely on value numbers in test, those are fragile and change in Release 
(no asserts) builds.

Modified:
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=270085&r1=270084&r2=270085&view=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Thu May 19 12:57:35 2016
@@ -1012,13 +1012,13 @@ __m256d test_mm512_extractf64x4_pd(__m51
 }
 
 __m256d test_mm512_mask_extractf64x4_pd(__m256d  __W,__mmask8  __U,__m512d 
__A){
- //CHECK-LABLE:@test_mm512_mask_extractf64x4_pd
+ //CHECK-LABEL:@test_mm512_mask_extractf64x4_pd
  //CHECL:@llvm.x86.avx512.mask.vextractf64x4.512
  return _mm512_mask_extractf64x4_pd( __W, __U, __A, 1);
 }
 
 __m256d test_mm512_maskz_extractf64x4_pd(__mmask8  __U,__m512d __A){
- //CHECK-LABLE:@test_mm512_maskz_extractf64x4_pd
+ //CHECK-LABEL:@test_mm512_maskz_extractf64x4_pd
  //CHECL:@llvm.x86.avx512.mask.vextractf64x4.512
  return _mm512_maskz_extractf64x4_pd( __U, __A, 1);
 }
@@ -1031,13 +1031,13 @@ __m128 test_mm512_extractf32x4_ps(__m512
 }
 
 __m128 test_mm512_mask_extractf32x4_ps(__m128 __W, __mmask8  __U,__m512d __A){
- //CHECK-LABLE:@test_mm512_mask_extractf32x4_ps
+ //CHECK-LABEL:@test_mm512_mask_extractf32x4_ps
  //CHECL: @llvm.x86.avx512.mask.vextractf32x4.512
  return _mm512_mask_extractf32x4_ps( __W, __U, __A, 1);
 }
 
 __m128 test_mm512_maskz_extractf32x4_ps( __mmask8  __U,__m512d __A){
- //CHECK-LABLE:@test_mm512_maskz_extractf32x4_ps
+ //CHECK-LABEL:@test_mm512_maskz_extractf32x4_ps
  //CHECL: @llvm.x86.avx512.mask.vextractf32x4.512
  return _mm512_maskz_extractf32x4_ps(  __U, __A, 1);
 }
@@ -1453,7 +1453,7 @@ __m512i test_mm512_mask_andnot_epi32 (__
 
 __m512i test_mm512_andnot_si512(__m512i __A, __m512i __B)
 {
-  //CHECK-LABLE: @test_mm512_andnot_si512
+  //CHECK-LABEL: @test_mm512_andnot_si512
   //CHECK: load {{.*}}%__A.addr.i, align 64
   //CHECK: %neg.i = xor{{.*}}, 
   //CHECK: load {{.*}}%__B.addr.i, align 64
@@ -6516,7 +6516,7 @@ __m512i test_mm512_maskz_min_epu64 (__mm
 
 __m512i test_mm512_mask_set1_epi32 (__m512i __O, __mmask16 __M, int __A)
 {
-//CHECK-LABLE: @test_mm512_mask_set1_epi32
+//CHECK-LABEL: @test_mm512_mask_set1_epi32
 //CHECK: @llvm.x86.avx512.mask.pbroadcast.d.gpr.512
   return _mm512_mask_set1_epi32 ( __O, __M, __A);
 }
@@ -6526,7 +6526,7 @@ __m512i test_mm512_set_epi32 (int __A, i
int __I, int __J, int __K, int __L,
int __M, int __N, int __O, int __P)
 {
- //CHECK-LABLE: @test_mm512_set_epi32
+ //CHECK-LABEL: @test_mm512_set_epi32
  //CHECK: insertelement{{.*}}i32 0
 //CHECK: insertelement{{.*}}i32 1
 //CHECK: insertelement{{.*}}i32 2
@@ -6552,24 +6552,24 @@ __m512i test_mm512_setr_epi32 (int __A,
int __I, int __J, int __K, int __L,
int __M, int __N, int __O, int __P)
 {
-//CHECK-LABLE: @test_mm512_setr_epi32
- //CHECK: %0 = load{{.*}}%__P.addr, align 4
- //CHECK: %1 = load{{.*}}%__O.addr, align 4
- //CHECK: %2 = load{{.*}}%__N.addr, align 4
- //CHECK: %3 = load{{.*}}%__M.addr, align 4
- //CHECK: %4 = load{{.*}}%__L.addr, align 4
- //CHECK: %5 = load{{.*}}%__K.addr, align 4
- //CHECK: %6 = load{{.*}}%__J.addr, align 4
- //CHECK: %7 = load{{.*}}%__I.addr, align 4
- //CHECK: %8 = load{{.*}}%__H.addr, align 4
- //CHECK: %9 = load{{.*}}%__G.addr, align 4
- //CHECK: %10 = load{{.*}}%__F.addr, align 4
- //CHECK: %11 = load{{.*}}%__E.addr, align 4
- //CHECK: %12 = load{{.*}}%__D.addr, align 4
- //CHECK: %13 = load{{.*}}%__C.addr, align 4
- //CHECK: %14 = load{{.*}}%__B.addr, align 4
- //CHECK: %15 = load{{.*}}%__A.addr, align 4
- //CHECK: insertelement{{.*}}i32 0
+//CHECK-LABEL: @test_mm512_setr_epi32
+//CHECK: load{{.*}}%__P.addr, align 4
+//CHECK: load{{.*}}%__O.addr, align 4
+//CHECK: load{{.*}}%__N.addr, align 4
+//CHECK: load{{.*}}%__M.addr, align 4
+//CHECK: load{{.*}}%__L.addr, align 4
+//CHECK: load{{.*}}%__K.addr, align 4
+//CHECK: load{{.*}}%__J.addr, align 4
+//CHECK: load{{.*}}%__I.addr, align 4
+//CHECK: load{{.*}}%__H.addr, align 4
+//CHECK: load{{.*}}%__G.addr, align 4
+//CHECK: load{{.*}}%__F.addr, align 4
+//CHECK: load{{.*}}%__E.addr, align 4
+//CHECK: load{{.*}}%__D.addr, align 4
+//CHECK: load{{.*}}%__C.addr, align 4
+//CHECK: load{{.*}}%__B.addr, align 4
+//CHECK: load{{.*}}%__A.addr, align 4
+//CHECK: insertelement{{.*}}i32 0
 //CHECK: insertelement{{.*}}i32 1
 //CHECK: insertelement{{.*}}i32 2
 //CHECK: insertelement{{.*}}i32 3
@@ -6591,7 +6591,7 @@ __m512i test_mm512_setr_epi32 (int __A,
 
 __m512i test_mm512_mask_set1_epi64 (__m512i __O, __mmask8 __M, long long _

Re: [PATCH] D20141: Check for nullptr argument.

2016-05-19 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270086: Check for nullptr argument. (authored by tra).

Changed prior to commit:
  http://reviews.llvm.org/D20141?vs=56832&id=57825#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20141

Files:
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -2082,7 +2082,7 @@
 
   // Check that D is not yet in DiagnosedConflictingDefinitions is required
   // to make sure that we issue an error only once.
-  if (lookupRepresentativeDecl(MangledName, OtherGD) &&
+  if (D && lookupRepresentativeDecl(MangledName, OtherGD) &&
   (D->getCanonicalDecl() != OtherGD.getCanonicalDecl().getDecl()) &&
   (OtherD = dyn_cast(OtherGD.getDecl())) &&
   OtherD->hasInit() &&
@@ -2301,7 +2301,7 @@
 
 unsigned CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D,
  unsigned AddrSpace) {
-  if (LangOpts.CUDA && LangOpts.CUDAIsDevice) {
+  if (D && LangOpts.CUDA && LangOpts.CUDAIsDevice) {
 if (D->hasAttr())
   AddrSpace = getContext().getTargetAddressSpace(LangAS::cuda_constant);
 else if (D->hasAttr())


Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -2082,7 +2082,7 @@
 
   // Check that D is not yet in DiagnosedConflictingDefinitions is required
   // to make sure that we issue an error only once.
-  if (lookupRepresentativeDecl(MangledName, OtherGD) &&
+  if (D && lookupRepresentativeDecl(MangledName, OtherGD) &&
   (D->getCanonicalDecl() != OtherGD.getCanonicalDecl().getDecl()) &&
   (OtherD = dyn_cast(OtherGD.getDecl())) &&
   OtherD->hasInit() &&
@@ -2301,7 +2301,7 @@
 
 unsigned CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D,
  unsigned AddrSpace) {
-  if (LangOpts.CUDA && LangOpts.CUDAIsDevice) {
+  if (D && LangOpts.CUDA && LangOpts.CUDAIsDevice) {
 if (D->hasAttr())
   AddrSpace = getContext().getTargetAddressSpace(LangAS::cuda_constant);
 else if (D->hasAttr())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r270086 - Check for nullptr argument.

2016-05-19 Thread Artem Belevich via cfe-commits
Author: tra
Date: Thu May 19 13:00:18 2016
New Revision: 270086

URL: http://llvm.org/viewvc/llvm-project?rev=270086&view=rev
Log:
Check for nullptr argument.

Addresses static analysis report in PR15492.

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

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

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=270086&r1=270085&r2=270086&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu May 19 13:00:18 2016
@@ -2082,7 +2082,7 @@ CodeGenModule::GetOrCreateLLVMGlobal(Str
 
   // Check that D is not yet in DiagnosedConflictingDefinitions is required
   // to make sure that we issue an error only once.
-  if (lookupRepresentativeDecl(MangledName, OtherGD) &&
+  if (D && lookupRepresentativeDecl(MangledName, OtherGD) &&
   (D->getCanonicalDecl() != OtherGD.getCanonicalDecl().getDecl()) &&
   (OtherD = dyn_cast(OtherGD.getDecl())) &&
   OtherD->hasInit() &&
@@ -2301,7 +2301,7 @@ CharUnits CodeGenModule::GetTargetTypeSt
 
 unsigned CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D,
  unsigned AddrSpace) {
-  if (LangOpts.CUDA && LangOpts.CUDAIsDevice) {
+  if (D && LangOpts.CUDA && LangOpts.CUDAIsDevice) {
 if (D->hasAttr())
   AddrSpace = getContext().getTargetAddressSpace(LangAS::cuda_constant);
 else if (D->hasAttr())


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


r270089 - [MS ABI] Ignore transparent contexts when determining the effective context

2016-05-19 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Thu May 19 13:15:53 2016
New Revision: 270089

URL: http://llvm.org/viewvc/llvm-project?rev=270089&view=rev
Log:
[MS ABI] Ignore transparent contexts when determining the effective context

We didn't skip over extern "C++" contexts, causing us to mangle things
which don't need to be mangled.

Modified:
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms.cpp

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=270089&r1=270088&r2=270089&view=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Thu May 19 13:15:53 2016
@@ -94,7 +94,7 @@ static const DeclContext *getEffectiveDe
 return getEffectiveDeclContext(cast(DC));
   }
 
-  return DC;
+  return DC->getRedeclContext();
 }
 
 static const DeclContext *getEffectiveParentContext(const DeclContext *DC) {

Modified: cfe/trunk/test/CodeGenCXX/mangle-ms.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms.cpp?rev=270089&r1=270088&r2=270089&view=diff
==
--- cfe/trunk/test/CodeGenCXX/mangle-ms.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-ms.cpp Thu May 19 13:15:53 2016
@@ -4,6 +4,11 @@
 int a;
 // CHECK-DAG: @"\01?a@@3HA"
 
+extern "C++" {
+static int __attribute__((used)) ignore_transparent_context;
+// CHECK-DAG: @ignore_transparent_context
+}
+
 namespace N {
   int b;
 // CHECK-DAG: @"\01?b@N@@3HA"


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


Re: [clang-tools-extra] r261991 - [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.

2016-05-19 Thread Alexander Kornienko via cfe-commits
On Thu, May 19, 2016 at 4:45 PM, Hans Wennborg  wrote:

> +Tom who manages 3.8.1
> +Alex who's owner of clang-tidy: is this ok for 3.8.1?
>

Yes, would be nice to have this in 3.8.1. This fixes a rather annoying
problem.


>
> On Thu, May 19, 2016 at 1:56 AM, Edoardo P. via cfe-commits
>  wrote:
> > Is it possible to port this commit to 3.8.1?
> >
> > Cheers,
> > Edward-san
> >
> > 2016-02-26 10:19 GMT+01:00 Haojian Wu via cfe-commits
> > :
> >> Author: hokein
> >> Date: Fri Feb 26 03:19:33 2016
> >> New Revision: 261991
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=261991&view=rev
> >> Log:
> >> [clang-tidy] Fix a crash issue when clang-tidy runs with compilation
> database.
> >>
> >> Summary:
> >> The clang-tidy will trigger an assertion if it's not in the building
> directory.
> >>
> >> TEST:
> >> cd /
> >> ./build/bin/clang-tidy --checks=-*,modernize-use-nullptr -p build
> tools/clang/tools/extra/clang-tidy/ClangTidy.cpp
> >>
> >> The crash issue is gone after applying this patch.
> >>
> >> Fixes PR24834, PR26241
> >>
> >> Reviewers: bkramer, alexfh
> >>
> >> Subscribers: rizsotto.mailinglist, cfe-commits
> >>
> >> Differential Revision: http://reviews.llvm.org/D17335
> >>
> >> Added:
> >> clang-tools-extra/trunk/test/clang-tidy/Inputs/compilation-database/
> >>
>  
> clang-tools-extra/trunk/test/clang-tidy/Inputs/compilation-database/template.json
> >>
>  clang-tools-extra/trunk/test/clang-tidy/clang-tidy-run-with-database.cpp
> >> Modified:
> >> clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
> >> clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
> >> clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
> >>
> >> Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
> >> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=261991&r1=261990&r2=261991&view=diff
> >>
> ==
> >> --- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
> >> +++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Fri Feb 26
> 03:19:33 2016
> >> @@ -107,6 +107,10 @@ public:
> >>  DiagPrinter->BeginSourceFile(LangOpts);
> >>}
> >>
> >> +  SourceManager& getSourceManager() {
> >> +return SourceMgr;
> >> +  }
> >> +
> >>void reportDiagnostic(const ClangTidyError &Error) {
> >>  const ClangTidyMessage &Message = Error.Message;
> >>  SourceLocation Loc = getLocation(Message.FilePath,
> Message.FileOffset);
> >> @@ -124,7 +128,10 @@ public:
> >>auto Diag = Diags.Report(Loc, Diags.getCustomDiagID(Level, "%0
> [%1]"))
> >><< Message.Message << Name;
> >>for (const tooling::Replacement &Fix : Error.Fix) {
> >> -SourceLocation FixLoc = getLocation(Fix.getFilePath(),
> Fix.getOffset());
> >> +SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
> >> +Files.makeAbsolutePath(FixAbsoluteFilePath);
> >> +SourceLocation FixLoc =
> >> +getLocation(FixAbsoluteFilePath, Fix.getOffset());
> >>  SourceLocation FixEndLoc =
> FixLoc.getLocWithOffset(Fix.getLength());
> >>  Diag << FixItHint::CreateReplacement(SourceRange(FixLoc,
> FixEndLoc),
> >>   Fix.getReplacementText());
> >> @@ -232,6 +239,13 @@ ClangTidyASTConsumerFactory::CreateASTCo
> >>Context.setCurrentFile(File);
> >>Context.setASTContext(&Compiler.getASTContext());
> >>
> >> +  auto WorkingDir = Compiler.getSourceManager()
> >> +.getFileManager()
> >> +.getVirtualFileSystem()
> >> +->getCurrentWorkingDirectory();
> >> +  if (WorkingDir)
> >> +Context.setCurrentBuildDirectory(WorkingDir.get());
> >> +
> >>std::vector> Checks;
> >>CheckFactories->createChecks(&Context, Checks);
> >>
> >> @@ -446,8 +460,24 @@ runClangTidy(std::unique_ptr >>  void handleErrors(const std::vector &Errors, bool Fix,
> >>unsigned &WarningsAsErrorsCount) {
> >>ErrorReporter Reporter(Fix);
> >> -  for (const ClangTidyError &Error : Errors)
> >> +  vfs::FileSystem &FileSystem =
> >> +
> *Reporter.getSourceManager().getFileManager().getVirtualFileSystem();
> >> +  auto InitialWorkingDir = FileSystem.getCurrentWorkingDirectory();
> >> +  if (!InitialWorkingDir)
> >> +llvm::report_fatal_error("Cannot get current working path.");
> >> +
> >> +  for (const ClangTidyError &Error : Errors) {
> >> +if (!Error.BuildDirectory.empty()) {
> >> +  // By default, the working directory of file system is the
> current
> >> +  // clang-tidy running directory.
> >> +  //
> >> +  // Change the directory to the one used during the analysis.
> >> +  FileSystem.setCurrentWorkingDirectory(Error.BuildDirectory);
> >> +}
> >>  Reporter.reportDiagnostic(Error);
> >> +// Return to the initial directory to correctly resolve next Error.
> >> 

Re: [PATCH] D20341: [CUDA] Enable fusing FP ops for CUDA by default.

2016-05-19 Thread Justin Lebar via cfe-commits
jlebar accepted this revision.
jlebar added a comment.
This revision is now accepted and ready to land.

Well, if the CUDA documentation says so...let's do it.  :)  Thanks for your 
patience, everyone.


http://reviews.llvm.org/D20341



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


Re: [PATCH] D20341: [CUDA] Enable fusing FP ops for CUDA by default.

2016-05-19 Thread Artem Belevich via cfe-commits
tra added a subscriber: chandlerc.
tra added a comment.

Short version of offline discussion with @chandlerc : Default of 
-ffp-contract=fast for CUDA is fine.


http://reviews.llvm.org/D20341



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


r270094 - [CUDA] Enable fusing FP ops (-ffp-contract=fast) for CUDA by default.

2016-05-19 Thread Artem Belevich via cfe-commits
Author: tra
Date: Thu May 19 13:44:45 2016
New Revision: 270094

URL: http://llvm.org/viewvc/llvm-project?rev=270094&view=rev
Log:
[CUDA] Enable fusing FP ops (-ffp-contract=fast) for CUDA by default.

This matches default nvcc behavior and gives substantial
performance boost on GPU where fmad is much cheaper compared to add+mul.

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

Added:
cfe/trunk/test/CodeGenCUDA/fp-contract.cu
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=270094&r1=270093&r2=270094&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu May 19 13:44:45 2016
@@ -2255,10 +2255,15 @@ bool CompilerInvocation::CreateFromArgs(
   LangOpts.ObjCExceptions = 1;
   }
 
-  // During CUDA device-side compilation, the aux triple is the triple used for
-  // host compilation.
-  if (LangOpts.CUDA && LangOpts.CUDAIsDevice) {
-Res.getTargetOpts().HostTriple = Res.getFrontendOpts().AuxTriple;
+  if (LangOpts.CUDA) {
+// During CUDA device-side compilation, the aux triple is the
+// triple used for host compilation.
+if (LangOpts.CUDAIsDevice)
+  Res.getTargetOpts().HostTriple = Res.getFrontendOpts().AuxTriple;
+
+// Set default FP_CONTRACT to FAST.
+if (!Args.hasArg(OPT_ffp_contract))
+  Res.getCodeGenOpts().setFPContractMode(CodeGenOptions::FPC_Fast);
   }
 
   // FIXME: Override value name discarding when asan or msan is used because 
the

Added: cfe/trunk/test/CodeGenCUDA/fp-contract.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/fp-contract.cu?rev=270094&view=auto
==
--- cfe/trunk/test/CodeGenCUDA/fp-contract.cu (added)
+++ cfe/trunk/test/CodeGenCUDA/fp-contract.cu Thu May 19 13:44:45 2016
@@ -0,0 +1,32 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// By default we should fuse multiply/add into fma instruction.
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
+// RUN:   -disable-llvm-passes -o - %s | FileCheck -check-prefix ENABLED %s
+
+// Explicit -ffp-contract=fast
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
+// RUN:   -ffp-contract=fast -disable-llvm-passes -o - %s \
+// RUN:   | FileCheck -check-prefix ENABLED %s
+
+// Explicit -ffp-contract=on -- fusing by front-end (disabled).
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
+// RUN:   -ffp-contract=on -disable-llvm-passes -o - %s \
+// RUN:   | FileCheck -check-prefix DISABLED %s
+
+// Explicit -ffp-contract=off should disable instruction fusing.
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
+// RUN:   -ffp-contract=off -disable-llvm-passes -o - %s \
+// RUN:   | FileCheck -check-prefix DISABLED %s
+
+
+#include "Inputs/cuda.h"
+
+__host__ __device__ float func(float a, float b, float c) { return a + b * c; }
+// ENABLED:   fma.rn.f32
+// ENABLED-NEXT:  st.param.f32
+
+// DISABLED:  mul.rn.f32
+// DISABLED-NEXT: add.rn.f32
+// DISABLED-NEXT: st.param.f32


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


Re: [PATCH] D20341: [CUDA] Enable fusing FP ops for CUDA by default.

2016-05-19 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270094: [CUDA] Enable fusing FP ops (-ffp-contract=fast) for 
CUDA by default. (authored by tra).

Changed prior to commit:
  http://reviews.llvm.org/D20341?vs=57541&id=57833#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20341

Files:
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGenCUDA/fp-contract.cu

Index: cfe/trunk/test/CodeGenCUDA/fp-contract.cu
===
--- cfe/trunk/test/CodeGenCUDA/fp-contract.cu
+++ cfe/trunk/test/CodeGenCUDA/fp-contract.cu
@@ -0,0 +1,32 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// By default we should fuse multiply/add into fma instruction.
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
+// RUN:   -disable-llvm-passes -o - %s | FileCheck -check-prefix ENABLED %s
+
+// Explicit -ffp-contract=fast
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
+// RUN:   -ffp-contract=fast -disable-llvm-passes -o - %s \
+// RUN:   | FileCheck -check-prefix ENABLED %s
+
+// Explicit -ffp-contract=on -- fusing by front-end (disabled).
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
+// RUN:   -ffp-contract=on -disable-llvm-passes -o - %s \
+// RUN:   | FileCheck -check-prefix DISABLED %s
+
+// Explicit -ffp-contract=off should disable instruction fusing.
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
+// RUN:   -ffp-contract=off -disable-llvm-passes -o - %s \
+// RUN:   | FileCheck -check-prefix DISABLED %s
+
+
+#include "Inputs/cuda.h"
+
+__host__ __device__ float func(float a, float b, float c) { return a + b * c; }
+// ENABLED:   fma.rn.f32
+// ENABLED-NEXT:  st.param.f32
+
+// DISABLED:  mul.rn.f32
+// DISABLED-NEXT: add.rn.f32
+// DISABLED-NEXT: st.param.f32
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -2255,10 +2255,15 @@
   LangOpts.ObjCExceptions = 1;
   }
 
-  // During CUDA device-side compilation, the aux triple is the triple used for
-  // host compilation.
-  if (LangOpts.CUDA && LangOpts.CUDAIsDevice) {
-Res.getTargetOpts().HostTriple = Res.getFrontendOpts().AuxTriple;
+  if (LangOpts.CUDA) {
+// During CUDA device-side compilation, the aux triple is the
+// triple used for host compilation.
+if (LangOpts.CUDAIsDevice)
+  Res.getTargetOpts().HostTriple = Res.getFrontendOpts().AuxTriple;
+
+// Set default FP_CONTRACT to FAST.
+if (!Args.hasArg(OPT_ffp_contract))
+  Res.getCodeGenOpts().setFPContractMode(CodeGenOptions::FPC_Fast);
   }
 
   // FIXME: Override value name discarding when asan or msan is used because 
the


Index: cfe/trunk/test/CodeGenCUDA/fp-contract.cu
===
--- cfe/trunk/test/CodeGenCUDA/fp-contract.cu
+++ cfe/trunk/test/CodeGenCUDA/fp-contract.cu
@@ -0,0 +1,32 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// By default we should fuse multiply/add into fma instruction.
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
+// RUN:   -disable-llvm-passes -o - %s | FileCheck -check-prefix ENABLED %s
+
+// Explicit -ffp-contract=fast
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
+// RUN:   -ffp-contract=fast -disable-llvm-passes -o - %s \
+// RUN:   | FileCheck -check-prefix ENABLED %s
+
+// Explicit -ffp-contract=on -- fusing by front-end (disabled).
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
+// RUN:   -ffp-contract=on -disable-llvm-passes -o - %s \
+// RUN:   | FileCheck -check-prefix DISABLED %s
+
+// Explicit -ffp-contract=off should disable instruction fusing.
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -S \
+// RUN:   -ffp-contract=off -disable-llvm-passes -o - %s \
+// RUN:   | FileCheck -check-prefix DISABLED %s
+
+
+#include "Inputs/cuda.h"
+
+__host__ __device__ float func(float a, float b, float c) { return a + b * c; }
+// ENABLED:   fma.rn.f32
+// ENABLED-NEXT:  st.param.f32
+
+// DISABLED:  mul.rn.f32
+// DISABLED-NEXT: add.rn.f32
+// DISABLED-NEXT: st.param.f32
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -2255,10 +2255,15 @@
   LangOpts.ObjCExceptions = 1;
   }
 
-  // During CUDA device-side compilation, the aux triple is the triple used for
-  // host compilation.
-  if (LangOpts.CUDA && LangOpts.CUDAIsDevice) {
-Res.getTargetOpts().HostTriple = Res.getFrontendOpts().AuxTriple;
+  if (LangOpts.CUDA) {
+// During CUDA device-side compilation, the aux triple is the
+//

Re: [PATCH] D20422: [MSVC2015] dllexport for defaulted special class members

2016-05-19 Thread Reid Kleckner via cfe-commits
rnk added inline comments.


Comment at: lib/Sema/SemaDeclCXX.cpp:4814
@@ -4813,3 +4813,3 @@
 // we have a definition.
 auto *CXXC = dyn_cast(MD);
 if ((MD->isMoveAssignmentOperator() ||

nit, can you rename this Ctor? I definitely know that that is, but not 
necessarily CXXC.


Comment at: lib/Sema/SemaDeclCXX.cpp:13111
@@ -13090,3 +13110,3 @@
   llvm_unreachable("Invalid special member.");
 }
   } else {

Can we add `if (InClassDef) ActOnFinishInlineFunctionDef(MD);` here instead? If 
the decl doesn't have dllexport, we will just defer it until its referenced, 
which seems OK.


http://reviews.llvm.org/D20422



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


Re: r266719 - Warn if function or variable cannot be implicitly instantiated

2016-05-19 Thread Serge Pavlov via cfe-commits
In this case moving implementation of `Singleton::getInstance()` into a
.cpp file would prevent compiler from instantiation of the method body when
it sees `Singleton::getInstance()`. In this case
`Singleton::getInstance()` must be instantiated in some source file
either explicitly or implicitly. If inline implementation for
`Singleton::getInstance()` is provided in the header, where
`Singleton` is defined, the method body is instantiated implicitly when
it is required. But the static field `instance` referenced in the method
still must be instantiated in some source file explicitly or implicitly. So
from viewpoint of convenience, moving the implementation of template
`Singleton::getInstance()` into source file does not look as more
inflexible solution.

Probably it is more convenient to put the template for the static member to
header file too:

template 
T *Singleton::instance = nullptr;


In this case both the method and corresponding static member are
instantiated implicitly by compiler, no warning occurs.
Can it be an acceptable solution?

If there is intention to limit `Singleton` to some selected types, explicit
instantiation declaration may help. Adding the declarations like:

extern template Foo *Singleton::instance;


prevents from warnings.

Or you think that the message should propose moving static member
definition into header file as well?


Thanks,
--Serge

2016-05-19 9:15 GMT+06:00 Sean Silva :

>
>
> On Thu, Apr 21, 2016 at 12:44 AM, Serge Pavlov 
> wrote:
>
>> Let me demonstrate the problem using excerpt from v8 sources:
>>
>> -- lithium.h 
>> template 
>> struct LSubKindOperand {
>>   static int* Create(int index) { return &cache[index]; }
>>   static void SetUpCache();
>>   static int* cache;
>> };
>>
>> struct LOperand {
>>   static void SetUpCaches();
>> };
>>
>> #define LITHIUM_OPERAND_LIST(V)   \
>>   V(DoubleRegister,  1,   16)
>>
>> #define LITHIUM_TYPEDEF_SUBKIND_OPERAND_CLASS(name, type, number)   \
>> typedef LSubKindOperand L##name;
>> LITHIUM_OPERAND_LIST(LITHIUM_TYPEDEF_SUBKIND_OPERAND_CLASS)
>> /* Expands to: typedef LSubKindOperand<1, 16> LDoubleRegister; */
>> #undef LITHIUM_TYPEDEF_SUBKIND_OPERAND_CLASS
>>
>> -- lithium.cc
>> #include "lithium.h"
>>
>> template
>> int* LSubKindOperand::cache = 0;
>>
>> template
>> void LSubKindOperand::SetUpCache() {
>>   cache = new int[kNumCachedOperands];
>> }
>>
>> void LOperand::SetUpCaches() {
>> #define LITHIUM_OPERAND_SETUP(name, type, number) L##name::SetUpCache();
>>   LITHIUM_OPERAND_LIST(LITHIUM_OPERAND_SETUP)
>>   /* Expands to: LDoubleRegister::SetUpCache(); */
>> #undef LITHIUM_OPERAND_SETUP
>> }
>>
>> -- lithium-x64.cc ---
>> #include "lithium.h"
>>
>> int* GetNextSpillSlot(int kind) {
>>   return LSubKindOperand<1,16>::Create(0);
>> }
>>
>> int main(int argc, char *argv[]) {
>>   return 0;
>> }
>>
>> -- build.sh -
>> g++ lithium.cc lithium-x64.cc
>> -
>>
>> When compiler generates code for 'GetNextSpillSlot' it implicitly
>> instantiates the method 'Create'. It can do it as definition of the
>> template entity 'LSubKindOperand::Create' is available from lithium.h. Then
>> it attempts to instantiate static field 'LSubKindOperand::cache', as it is
>> used in the body of just instantiated method 'Create'. But definition of
>> this template entity  is not available while compiling lithium-x64.cc.
>> Failure to implicitly instantiate a template is not an error, but this
>> template must be instantiated somewhere else otherwise linker founds
>> undefined references.
>>
>> Indeed, 'LSubKindOperand<1,16>::cache' is instantiated while compiling
>> lithium.cc. Method 'LOperand::SetUpCaches' is not a template, it references
>> 'LSubKindOperand::SetUpCache', which in turn uses 'LSubKindOperand::cache'.
>> Definitions of these templates are available in lithium.cc, compiler
>> instantiates them and the program builds successfully. This solution is
>> fragile however, if lithium-x64.cc referenced
>> 'LSubKindOperand<1,1>::Create', the build would break because in lithium.cc
>> this specialization is not instantiated.
>>
>> Putting templates definitions into source files rather than headers is
>> similar to moving forward declarations into source files. It makes sense if
>> user wants to encapsulate some functionality. In this example he should
>> also move the definition 'LSubKindOperand::Create' to source file, just for
>> the sake of encapsulation. This would prevent compiler from implicit
>> instantiation of this method and thus from instantiation of the static
>> field as well.
>>
>> If encapsulation is not an aim, moving template definition into header
>> seems to be more natural solution. It would allow for compiler to
>> instantiate all 

[PATCH] D20444: [OpenCL] Include opencl-c.h by default as a module

2016-05-19 Thread Yaxun Liu via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: Anastasia, pxli168, bader, rsmith.
yaxunl added a subscriber: cfe-commits.

Include opencl-c.h by default as a module to utilize the automatic AST caching 
mechanism of module.

Add an option -fno-default-header to disable default header for OpenCL.

This is an attempting effort to elicit further discussions.

http://reviews.llvm.org/D20444

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Driver/CC1Options.td
  include/clang/Frontend/CompilerInvocation.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Headers/module.modulemap
  test/CodeGenOpenCL/bool_cast.cl
  test/Headers/opencl-c-header.cl
  test/Parser/opencl-atomics-cl20.cl

Index: test/Parser/opencl-atomics-cl20.cl
===
--- test/Parser/opencl-atomics-cl20.cl
+++ test/Parser/opencl-atomics-cl20.cl
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only
+// ToDo: a bug causing cached AST of header containing typedef of atomic_int for CL1.0. After the bug is fixed
+// -fno-default-header should be removed.
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -fno-default-header
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -fsyntax-only -cl-std=CL2.0 -DCL20
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -fsyntax-only -cl-std=CL2.0 -DCL20 -DEXT
 
Index: test/Headers/opencl-c-header.cl
===
--- test/Headers/opencl-c-header.cl
+++ test/Headers/opencl-c-header.cl
@@ -1,9 +1,14 @@
-// RUN: %clang_cc1 -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| FileCheck %s
-// RUN: %clang_cc1 -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| FileCheck %s
-// RUN: %clang_cc1 -internal-isystem ../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s -cl-std=CL2.0| FileCheck %s
+// RUN: %clang_cc1 -fno-default-header -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fno-default-header -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| FileCheck %s
+// RUN: %clang_cc1 -fno-default-header -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| FileCheck %s
+// RUN: %clang_cc1 -fno-default-header -internal-isystem ../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s -cl-std=CL2.0| FileCheck %s
 
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -verify -fno-default-header -DNO_HEADER %s
 // CHECK: _Z16convert_char_rtec
 char f(char x) {
   return convert_char_rte(x);
+#ifdef NO_HEADER
+  //expected-warning@-2{{implicit declaration of function 'convert_char_rte' is invalid in C99}}
+#endif
 }
Index: test/CodeGenOpenCL/bool_cast.cl
===
--- test/CodeGenOpenCL/bool_cast.cl
+++ test/CodeGenOpenCL/bool_cast.cl
@@ -1,9 +1,5 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -O0 | FileCheck %s
 
-typedef unsigned char uchar4 __attribute((ext_vector_type(4)));
-typedef unsigned int int4 __attribute((ext_vector_type(4)));
-typedef float float4 __attribute((ext_vector_type(4)));
-
 // CHECK-LABEL: define void @ker()
 void kernel ker() {
   bool t = true;
Index: lib/Headers/module.modulemap
===
--- lib/Headers/module.modulemap
+++ lib/Headers/module.modulemap
@@ -155,6 +155,11 @@
   header "vecintrin.h"
 }
   }
+  
+  explicit module opencl_c {
+requires opencl
+header "opencl-c.h"
+  }
 }
 
 module _Builtin_stddef_max_align_t [system] [extern_c] {
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1400,6 +1400,7 @@
 
 void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
  const llvm::Triple &T,
+ PreprocessorOptions &PPOpts,
  LangStandard::Kind LangStd) {
   // Set some properties which depend solely on the input kind; it would be nice
   // to move these to the language standard, and have the driver resolve the
@@ -1481,6 +1482,9 @@
 Opts.DefaultFPContract = 1;
 Opts.NativeHalfType = 1;
 Opts.NativeHalfArgsAndReturns = 1;
+// Include default header file for OpenCL.
+if (!Opts.NoDefaultHeader)
+  PPOpts.Includes.push_back("opencl-c.h");
   }
 
   Opts.CUDA = IK == IK_CUDA || IK == IK_PreprocessedCuda ||
@@ -1521,6 +1525,7 @@
 
 static void ParseLangArgs(LangOptions &Opts, ArgList &Args, Inp

Re: [PATCH] D20392: [CodeView] Modify emitTypeInformation to use MemoryTypeTableBuilder

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

lgtm


http://reviews.llvm.org/D20392



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


[PATCH] D20446: clang-rename: fix renaming members when referenced as macro arguments

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

The second check failed, FOO(C.X) wasn't renamed to FOO(C.Y).

http://reviews.llvm.org/D20446

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

Index: test/clang-rename/MemberExprMacro.cpp
===
--- /dev/null
+++ test/clang-rename/MemberExprMacro.cpp
@@ -0,0 +1,25 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=151 -new-name=Y %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class C
+{
+public:
+  int X;
+};
+
+int foo(int x)
+{
+  return 0;
+}
+#define FOO(a) foo(a)
+
+int main()
+{
+  C C;
+  C.X = 1; // CHECK: C.Y
+  FOO(C.X); // CHECK: C.Y
+  int y = C.X; // CHECK: C.Y
+}
+
+// Use grep -FUbo 'C'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -103,7 +103,14 @@
   bool VisitMemberExpr(const MemberExpr *Expr) {
 const auto *Decl = Expr->getFoundDecl().getDecl();
 if (getUSRForDecl(Decl) == USR) {
-  LocationsFound.push_back(Expr->getMemberLoc());
+  SourceLocation Location = Expr->getMemberLoc();
+  if (Location.isMacroID()) {
+// The location is expanded from a macro, look up the original spelling
+// location.
+const ASTContext &Context = Decl->getASTContext();
+Location = Context.getSourceManager().getSpellingLoc(Location);
+  }
+  LocationsFound.push_back(Location);
 }
 return true;
   }


Index: test/clang-rename/MemberExprMacro.cpp
===
--- /dev/null
+++ test/clang-rename/MemberExprMacro.cpp
@@ -0,0 +1,25 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=151 -new-name=Y %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class C
+{
+public:
+  int X;
+};
+
+int foo(int x)
+{
+  return 0;
+}
+#define FOO(a) foo(a)
+
+int main()
+{
+  C C;
+  C.X = 1; // CHECK: C.Y
+  FOO(C.X); // CHECK: C.Y
+  int y = C.X; // CHECK: C.Y
+}
+
+// Use grep -FUbo 'C'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -103,7 +103,14 @@
   bool VisitMemberExpr(const MemberExpr *Expr) {
 const auto *Decl = Expr->getFoundDecl().getDecl();
 if (getUSRForDecl(Decl) == USR) {
-  LocationsFound.push_back(Expr->getMemberLoc());
+  SourceLocation Location = Expr->getMemberLoc();
+  if (Location.isMacroID()) {
+// The location is expanded from a macro, look up the original spelling
+// location.
+const ASTContext &Context = Decl->getASTContext();
+Location = Context.getSourceManager().getSpellingLoc(Location);
+  }
+  LocationsFound.push_back(Location);
 }
 return true;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r270107 - [CUDA] Split device-var-init.cu tests into separate Sema and CodeGen parts.

2016-05-19 Thread Artem Belevich via cfe-commits
Author: tra
Date: Thu May 19 15:13:39 2016
New Revision: 270107

URL: http://llvm.org/viewvc/llvm-project?rev=270107&view=rev
Log:
[CUDA] Split device-var-init.cu tests into separate Sema and CodeGen parts.

Codegen tests for device-side variable initialization are subset of test
cases used to verify Sema's part of the job.
Including CodeGenCUDA/device-var-init.cu from SemaCUDA makes it easier to
keep both sides in sync.

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

Added:
cfe/trunk/test/SemaCUDA/device-var-init.cu
  - copied, changed from r270094, 
cfe/trunk/test/CodeGenCUDA/device-var-init.cu
Modified:
cfe/trunk/test/CodeGenCUDA/device-var-init.cu

Modified: cfe/trunk/test/CodeGenCUDA/device-var-init.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/device-var-init.cu?rev=270107&r1=270106&r2=270107&view=diff
==
--- cfe/trunk/test/CodeGenCUDA/device-var-init.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/device-var-init.cu Thu May 19 15:13:39 2016
@@ -5,8 +5,6 @@
 
 // RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -std=c++11 \
 // RUN: -fno-threadsafe-statics -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -std=c++11 \
-// RUN: -emit-llvm -DERROR_CASE -verify -o /dev/null %s
 
 #ifdef __clang__
 #include "Inputs/cuda.h"
@@ -89,21 +87,6 @@ __constant__ int c_v;
 
 __device__ int d_v_i = 1;
 // CHECK: @d_v_i = addrspace(1) externally_initialized global i32 1,
-#ifdef ERROR_CASE
-__shared__ int s_v_i = 1;
-// expected-error@-1 {{initialization is not supported for __shared__ 
variables.}}
-#endif
-__constant__ int c_v_i = 1;
-// CHECK: @c_v_i = addrspace(4) externally_initialized global i32 1,
-
-#ifdef ERROR_CASE
-__device__ int d_v_f = f();
-// expected-error@-1 {{dynamic initialization is not supported for __device__, 
__constant__, and __shared__ variables.}}
-__shared__ int s_v_f = f();
-// expected-error@-1 {{initialization is not supported for __shared__ 
variables.}}
-__constant__ int c_v_f = f();
-// expected-error@-1 {{dynamic initialization is not supported for __device__, 
__constant__, and __shared__ variables.}}
-#endif
 
 __device__ T d_t;
 // CHECK: @d_t = addrspace(1) externally_initialized global %struct.T 
zeroinitializer
@@ -113,11 +96,7 @@ __constant__ T c_t;
 // CHECK: @c_t = addrspace(4) externally_initialized global %struct.T 
zeroinitializer,
 
 __device__ T d_t_i = {2};
-// CHECKL @d_t_i = addrspace(1) externally_initialized global %struct.T { i32 
2 },
-#ifdef ERROR_CASE
-__shared__ T s_t_i = {2};
-// expected-error@-1 {{initialization is not supported for __shared__ 
variables.}}
-#endif
+// CHECK: @d_t_i = addrspace(1) externally_initialized global %struct.T { i32 
2 },
 __constant__ T c_t_i = {2};
 // CHECK: @c_t_i = addrspace(4) externally_initialized global %struct.T { i32 
2 },
 
@@ -128,118 +107,18 @@ __shared__ EC s_ec;
 __constant__ EC c_ec;
 // CHECK: @c_ec = addrspace(4) externally_initialized global %struct.EC 
zeroinitializer,
 
-#if ERROR_CASE
-__device__ EC d_ec_i(3);
-// expected-error@-1 {{dynamic initialization is not supported for __device__, 
__constant__, and __shared__ variables.}}
-__shared__ EC s_ec_i(3);
-// expected-error@-1 {{initialization is not supported for __shared__ 
variables.}}
-__constant__ EC c_ec_i(3);
-// expected-error@-1 {{dynamic initialization is not supported for __device__, 
__constant__, and __shared__ variables.}}
-
-__device__ EC d_ec_i2 = {3};
-// expected-error@-1 {{dynamic initialization is not supported for __device__, 
__constant__, and __shared__ variables.}}
-__shared__ EC s_ec_i2 = {3};
-// expected-error@-1 {{initialization is not supported for __shared__ 
variables.}}
-__constant__ EC c_ec_i2 = {3};
-// expected-error@-1 {{dynamic initialization is not supported for __device__, 
__constant__, and __shared__ variables.}}
-#endif
-
 __device__ ETC d_etc;
-// CHETCK: @d_etc = addrspace(1) externally_initialized global %struct.ETC 
zeroinitializer,
+// CHECK: @d_etc = addrspace(1) externally_initialized global %struct.ETC 
zeroinitializer,
 __shared__ ETC s_etc;
-// CHETCK: @s_etc = addrspace(3) global %struct.ETC undef,
+// CHECK: @s_etc = addrspace(3) global %struct.ETC undef,
 __constant__ ETC c_etc;
-// CHETCK: @c_etc = addrspace(4) externally_initialized global %struct.ETC 
zeroinitializer,
-
-#if ERROR_CASE
-__device__ ETC d_etc_i(3);
-// expected-error@-1 {{dynamic initialization is not supported for __device__, 
__constant__, and __shared__ variables.}}
-__shared__ ETC s_etc_i(3);
-// expected-error@-1 {{initialization is not supported for __shared__ 
variables.}}
-__constant__ ETC c_etc_i(3);
-// expected-error@-1 {{dynamic initialization is not supported for __device__, 
__constant__, and __shared__ variables.}}
-
-__device__ ETC d_etc_i2 = {3};
-// expected-error@-1 {{dynamic initialization is not supported for __device__, 
__con

Re: [PATCH] D20140: [CUDA] Do not allow non-empty destructors for global device-side variables.

2016-05-19 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270108: [CUDA] Do not allow non-empty destructors for global 
device-side variables. (authored by tra).

Changed prior to commit:
  http://reviews.llvm.org/D20140?vs=56829&id=57849#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20140

Files:
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/SemaCUDA.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/CodeGenCUDA/device-var-init.cu
  cfe/trunk/test/SemaCUDA/device-var-init.cu

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -9036,6 +9036,7 @@
   /// \return true if \p CD can be considered empty according to CUDA
   /// (E.2.3.1 in CUDA 7.5 Programming guide).
   bool isEmptyCudaConstructor(SourceLocation Loc, CXXConstructorDecl *CD);
+  bool isEmptyCudaDestructor(SourceLocation Loc, CXXDestructorDecl *CD);
 
   /// \name Code completion
   //@{
Index: cfe/trunk/test/CodeGenCUDA/device-var-init.cu
===
--- cfe/trunk/test/CodeGenCUDA/device-var-init.cu
+++ cfe/trunk/test/CodeGenCUDA/device-var-init.cu
@@ -24,6 +24,16 @@
   __device__ EC(int) {}  // -- not allowed
 };
 
+// empty destructor
+struct ED {
+  __device__ ~ED() {} // -- allowed
+};
+
+struct ECD {
+  __device__ ECD() {} // -- allowed
+  __device__ ~ECD() {}// -- allowed
+};
+
 // empty templated constructor -- allowed with no arguments
 struct ETC {
   template  __device__ ETC(T...) {}
@@ -35,6 +45,12 @@
   __device__ UC();
 };
 
+// undefined destructor -- not allowed
+struct UD {
+  int ud;
+  __device__ ~UD();
+};
+
 // empty constructor w/ initializer list -- not allowed
 struct ECI {
   int eci;
@@ -47,12 +63,23 @@
   __device__ NEC() { nec = 1; }
 };
 
+// non-empty destructor -- not allowed
+struct NED {
+  int ned;
+  __device__ ~NED() { ned = 1; }
+};
+
 // no-constructor,  virtual method -- not allowed
 struct NCV {
   int ncv;
   __device__ virtual void vm() {}
 };
 
+// virtual destructor -- not allowed.
+struct VD {
+  __device__ virtual ~VD() {}
+};
+
 // dynamic in-class field initializer -- not allowed
 __device__ int f();
 struct NCF {
@@ -107,6 +134,20 @@
 __constant__ EC c_ec;
 // CHECK: @c_ec = addrspace(4) externally_initialized global %struct.EC zeroinitializer,
 
+__device__ ED d_ed;
+// CHECK: @d_ed = addrspace(1) externally_initialized global %struct.ED zeroinitializer,
+__shared__ ED s_ed;
+// CHECK: @s_ed = addrspace(3) global %struct.ED undef,
+__constant__ ED c_ed;
+// CHECK: @c_ed = addrspace(4) externally_initialized global %struct.ED zeroinitializer,
+
+__device__ ECD d_ecd;
+// CHECK: @d_ecd = addrspace(1) externally_initialized global %struct.ECD zeroinitializer,
+__shared__ ECD s_ecd;
+// CHECK: @s_ecd = addrspace(3) global %struct.ECD undef,
+__constant__ ECD c_ecd;
+// CHECK: @c_ecd = addrspace(4) externally_initialized global %struct.ECD zeroinitializer,
+
 __device__ ETC d_etc;
 // CHECK: @d_etc = addrspace(1) externally_initialized global %struct.ETC zeroinitializer,
 __shared__ ETC s_etc;
@@ -180,6 +221,17 @@
   NEC nec[2];
 };
 
+
+// Inherited from or incapsulated class with non-empty desstructor --
+// not allowed
+struct T_B_NED : NED {};
+struct T_F_NED {
+  NED ned;
+};
+struct T_FA_NED {
+  NED ned[2];
+};
+
 // We should not emit global initializers for device-side variables.
 // CHECK-NOT: @__cxx_global_var_init
 
@@ -190,16 +242,26 @@
   // CHECK-NOT: call
   EC ec;
   // CHECK:   call void @_ZN2ECC1Ev(%struct.EC* %ec)
+  ED ed;
+  // CHECK-NOT: call
+  ECD ecd;
+  // CHECK:   call void @_ZN3ECDC1Ev(%struct.ECD* %ecd)
   ETC etc;
   // CHECK:   call void @_ZN3ETCC1IJEEEDpT_(%struct.ETC* %etc)
   UC uc;
   // CHECK:   call void @_ZN2UCC1Ev(%struct.UC* %uc)
+  UD ud;
+  // CHECK-NOT: call
   ECI eci;
   // CHECK:   call void @_ZN3ECIC1Ev(%struct.ECI* %eci)
   NEC nec;
   // CHECK:   call void @_ZN3NECC1Ev(%struct.NEC* %nec)
+  NED ned;
+  // CHECK:   call void @_ZN3NCVC1Ev(%struct.NCV* %ncv)
   NCV ncv;
   // CHECK-NOT: call
+  VD vd;
+  // CHECK:   call void @_ZN2VDC1Ev(%struct.VD* %vd)
   NCF ncf;
   // CHECK:   call void @_ZN3NCFC1Ev(%struct.NCF* %ncf)
   NCFS ncfs;
@@ -226,17 +288,31 @@
   // CHECK:   call void @_ZN7T_F_NECC1Ev(%struct.T_F_NEC* %t_f_nec)
   T_FA_NEC t_fa_nec;
   // CHECK:   call void @_ZN8T_FA_NECC1Ev(%struct.T_FA_NEC* %t_fa_nec)
+  T_B_NED t_b_ned;
+  // CHECK-NOT: call
+  T_F_NED t_f_ned;
+  // CHECK-NOT: call
+  T_FA_NED t_fa_ned;
+  // CHECK-NOT: call
   static __shared__ EC s_ec;
   // CHECK-NOT: call void @_ZN2ECC1Ev(%struct.EC* addrspacecast (%struct.EC addrspace(3)* @_ZZ2dfvE4s_ec to %struct.EC*))
   static __shared__ ETC s_etc;
   // CHECK-NOT: call void @_ZN3ETCC1IJEEEDpT_(%struct.ETC* addrspacecast (%struct.ETC addrspace(3)* @_ZZ2dfvE5s_etc to %struct.ETC*))
 
   // anchor point separating con

Re: [PATCH] D20139: [CUDA] Split device-var-init.cu tests into separate Sema and CodeGen parts.

2016-05-19 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270107: [CUDA] Split device-var-init.cu tests into separate 
Sema and CodeGen parts. (authored by tra).

Changed prior to commit:
  http://reviews.llvm.org/D20139?vs=56824&id=57848#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20139

Files:
  cfe/trunk/test/CodeGenCUDA/device-var-init.cu
  cfe/trunk/test/SemaCUDA/device-var-init.cu

Index: cfe/trunk/test/CodeGenCUDA/device-var-init.cu
===
--- cfe/trunk/test/CodeGenCUDA/device-var-init.cu
+++ cfe/trunk/test/CodeGenCUDA/device-var-init.cu
@@ -5,8 +5,6 @@
 
 // RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -std=c++11 \
 // RUN: -fno-threadsafe-statics -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -std=c++11 \
-// RUN: -emit-llvm -DERROR_CASE -verify -o /dev/null %s
 
 #ifdef __clang__
 #include "Inputs/cuda.h"
@@ -89,21 +87,6 @@
 
 __device__ int d_v_i = 1;
 // CHECK: @d_v_i = addrspace(1) externally_initialized global i32 1,
-#ifdef ERROR_CASE
-__shared__ int s_v_i = 1;
-// expected-error@-1 {{initialization is not supported for __shared__ variables.}}
-#endif
-__constant__ int c_v_i = 1;
-// CHECK: @c_v_i = addrspace(4) externally_initialized global i32 1,
-
-#ifdef ERROR_CASE
-__device__ int d_v_f = f();
-// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}}
-__shared__ int s_v_f = f();
-// expected-error@-1 {{initialization is not supported for __shared__ variables.}}
-__constant__ int c_v_f = f();
-// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}}
-#endif
 
 __device__ T d_t;
 // CHECK: @d_t = addrspace(1) externally_initialized global %struct.T zeroinitializer
@@ -113,11 +96,7 @@
 // CHECK: @c_t = addrspace(4) externally_initialized global %struct.T zeroinitializer,
 
 __device__ T d_t_i = {2};
-// CHECKL @d_t_i = addrspace(1) externally_initialized global %struct.T { i32 2 },
-#ifdef ERROR_CASE
-__shared__ T s_t_i = {2};
-// expected-error@-1 {{initialization is not supported for __shared__ variables.}}
-#endif
+// CHECK: @d_t_i = addrspace(1) externally_initialized global %struct.T { i32 2 },
 __constant__ T c_t_i = {2};
 // CHECK: @c_t_i = addrspace(4) externally_initialized global %struct.T { i32 2 },
 
@@ -128,118 +107,18 @@
 __constant__ EC c_ec;
 // CHECK: @c_ec = addrspace(4) externally_initialized global %struct.EC zeroinitializer,
 
-#if ERROR_CASE
-__device__ EC d_ec_i(3);
-// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}}
-__shared__ EC s_ec_i(3);
-// expected-error@-1 {{initialization is not supported for __shared__ variables.}}
-__constant__ EC c_ec_i(3);
-// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}}
-
-__device__ EC d_ec_i2 = {3};
-// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}}
-__shared__ EC s_ec_i2 = {3};
-// expected-error@-1 {{initialization is not supported for __shared__ variables.}}
-__constant__ EC c_ec_i2 = {3};
-// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}}
-#endif
-
 __device__ ETC d_etc;
-// CHETCK: @d_etc = addrspace(1) externally_initialized global %struct.ETC zeroinitializer,
+// CHECK: @d_etc = addrspace(1) externally_initialized global %struct.ETC zeroinitializer,
 __shared__ ETC s_etc;
-// CHETCK: @s_etc = addrspace(3) global %struct.ETC undef,
+// CHECK: @s_etc = addrspace(3) global %struct.ETC undef,
 __constant__ ETC c_etc;
-// CHETCK: @c_etc = addrspace(4) externally_initialized global %struct.ETC zeroinitializer,
-
-#if ERROR_CASE
-__device__ ETC d_etc_i(3);
-// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}}
-__shared__ ETC s_etc_i(3);
-// expected-error@-1 {{initialization is not supported for __shared__ variables.}}
-__constant__ ETC c_etc_i(3);
-// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}}
-
-__device__ ETC d_etc_i2 = {3};
-// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}}
-__shared__ ETC s_etc_i2 = {3};
-// expected-error@-1 {{initialization is not supported for __shared__ variables.}}
-__constant__ ETC c_etc_i2 = {3};
-// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}}
-
-__device__ UC d_uc;
-// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}}
-__shared__ UC s_uc;
-// expected-error@-1 {{initializati

r270108 - [CUDA] Do not allow non-empty destructors for global device-side variables.

2016-05-19 Thread Artem Belevich via cfe-commits
Author: tra
Date: Thu May 19 15:13:53 2016
New Revision: 270108

URL: http://llvm.org/viewvc/llvm-project?rev=270108&view=rev
Log:
[CUDA] Do not allow non-empty destructors for global device-side variables.

According to Cuda Programming guide (v7.5, E2.3.1):
> __device__, __constant__ and __shared__ variables defined in namespace
> scope, that are of class type, cannot have a non-empty constructor or a
> non-empty destructor.

Clang already deals with device-side constructors (see D15305).
This patch enforces similar rules for destructors.

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

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaCUDA.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CodeGenCUDA/device-var-init.cu
cfe/trunk/test/SemaCUDA/device-var-init.cu

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=270108&r1=270107&r2=270108&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu May 19 15:13:53 2016
@@ -9036,6 +9036,7 @@ public:
   /// \return true if \p CD can be considered empty according to CUDA
   /// (E.2.3.1 in CUDA 7.5 Programming guide).
   bool isEmptyCudaConstructor(SourceLocation Loc, CXXConstructorDecl *CD);
+  bool isEmptyCudaDestructor(SourceLocation Loc, CXXDestructorDecl *CD);
 
   /// \name Code completion
   //@{

Modified: cfe/trunk/lib/Sema/SemaCUDA.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCUDA.cpp?rev=270108&r1=270107&r2=270108&view=diff
==
--- cfe/trunk/lib/Sema/SemaCUDA.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCUDA.cpp Thu May 19 15:13:53 2016
@@ -372,7 +372,7 @@ bool Sema::isEmptyCudaConstructor(Source
 return false;
 
   // The only form of initializer allowed is an empty constructor.
-  // This will recursively checks all base classes and member initializers
+  // This will recursively check all base classes and member initializers
   if (!llvm::all_of(CD->inits(), [&](const CXXCtorInitializer *CI) {
 if (const CXXConstructExpr *CE =
 dyn_cast(CI->getInit()))
@@ -381,6 +381,54 @@ bool Sema::isEmptyCudaConstructor(Source
   }))
 return false;
 
+  return true;
+}
+
+bool Sema::isEmptyCudaDestructor(SourceLocation Loc, CXXDestructorDecl *DD) {
+  // No destructor -> no problem.
+  if (!DD)
+return true;
+
+  if (!DD->isDefined() && DD->isTemplateInstantiation())
+InstantiateFunctionDefinition(Loc, DD->getFirstDecl());
+
+  // (E.2.3.1, CUDA 7.5) A destructor for a class type is considered
+  // empty at a point in the translation unit, if it is either a
+  // trivial constructor
+  if (DD->isTrivial())
+return true;
+
+  // ... or it satisfies all of the following conditions:
+  // The destructor function has been defined.
+  // and the function body is an empty compound statement.
+  if (!DD->hasTrivialBody())
+return false;
+
+  const CXXRecordDecl *ClassDecl = DD->getParent();
+
+  // Its class has no virtual functions and no virtual base classes.
+  if (ClassDecl->isDynamicClass())
+return false;
+
+  // Only empty destructors are allowed. This will recursively check
+  // destructors for all base classes...
+  if (!llvm::all_of(ClassDecl->bases(), [&](const CXXBaseSpecifier &BS) {
+if (CXXRecordDecl *RD = BS.getType()->getAsCXXRecordDecl())
+  return isEmptyCudaDestructor(Loc, RD->getDestructor());
+return true;
+  }))
+return false;
+
+  // ... and member fields.
+  if (!llvm::all_of(ClassDecl->fields(), [&](const FieldDecl *Field) {
+if (CXXRecordDecl *RD = Field->getType()
+->getBaseElementTypeUnsafe()
+->getAsCXXRecordDecl())
+  return isEmptyCudaDestructor(Loc, RD->getDestructor());
+return true;
+  }))
+return false;
+
   return true;
 }
 

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=270108&r1=270107&r2=270108&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu May 19 15:13:53 2016
@@ -10442,6 +10442,12 @@ Sema::FinalizeDeclaration(Decl *ThisDecl
 AllowedInit = VD->getInit()->isConstantInitializer(
 Context, VD->getType()->isReferenceType());
 
+  // Also make sure that destructor, if there is one, is empty.
+  if (AllowedInit)
+if (CXXRecordDecl *RD = VD->getType()->getAsCXXRecordDecl())
+  AllowedInit =
+  isEmptyCudaDestructor(VD->getLocation(), RD->getDestructor());
+
   if (!AllowedInit) {
 Diag(VD->getLocation(), VD->hasAttr()

Re: r270039 - [Sema] Allow an external sema source to handle delayed typo corrections.

2016-05-19 Thread Evgenii Stepanov via cfe-commits
Looks like this commit broke the bot:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-
bootstrap/builds/11738/steps/check-clang%20ubsan/logs/stdio

On Thu, May 19, 2016 at 3:52 AM, Benjamin Kramer via cfe-commits
 wrote:
> Author: d0k
> Date: Thu May 19 05:46:10 2016
> New Revision: 270039
>
> URL: http://llvm.org/viewvc/llvm-project?rev=270039&view=rev
> Log:
> [Sema] Allow an external sema source to handle delayed typo corrections.
>
> This probably isn't perfectly perfect but allows correcting function calls
> again.
>
> Modified:
> cfe/trunk/lib/Sema/SemaLookup.cpp
> cfe/trunk/unittests/Sema/ExternalSemaSourceTest.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=270039&r1=270038&r2=270039&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaLookup.cpp Thu May 19 05:46:10 2016
> @@ -4781,11 +4781,19 @@ TypoExpr *Sema::CorrectTypoDelayed(
>  const ObjCObjectPointerType *OPT) {
>assert(CCC && "CorrectTypoDelayed requires a CorrectionCandidateCallback");
>
> -  TypoCorrection Empty;
>auto Consumer = makeTypoCorrectionConsumer(
>TypoName, LookupKind, S, SS, std::move(CCC), MemberContext,
>EnteringContext, OPT, Mode == CTK_ErrorRecovery);
>
> +  // Give the external sema source a chance to correct the typo.
> +  TypoCorrection ExternalTypo;
> +  if (ExternalSource && Consumer) {
> +ExternalTypo = ExternalSource->CorrectTypo(
> +TypoName, LookupKind, S, SS, *CCC, MemberContext, EnteringContext, 
> OPT);
> +if (ExternalTypo)
> +  Consumer->addCorrection(ExternalTypo);
> +  }
> +
>if (!Consumer || Consumer->empty())
>  return nullptr;
>
> @@ -4793,7 +4801,7 @@ TypoExpr *Sema::CorrectTypoDelayed(
>// is not more that about a third of the length of the typo's identifier.
>unsigned ED = Consumer->getBestEditDistance(true);
>IdentifierInfo *Typo = TypoName.getName().getAsIdentifierInfo();
> -  if (ED > 0 && Typo->getName().size() / ED < 3)
> +  if (!ExternalTypo && ED > 0 && Typo->getName().size() / ED < 3)
>  return nullptr;
>
>ExprEvalContexts.back().NumTypos++;
>
> Modified: cfe/trunk/unittests/Sema/ExternalSemaSourceTest.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Sema/ExternalSemaSourceTest.cpp?rev=270039&r1=270038&r2=270039&view=diff
> ==
> --- cfe/trunk/unittests/Sema/ExternalSemaSourceTest.cpp (original)
> +++ cfe/trunk/unittests/Sema/ExternalSemaSourceTest.cpp Thu May 19 05:46:10 
> 2016
> @@ -39,19 +39,18 @@ public:
>bool Result;
>  };
>
> -// \brief Counts the number of err_using_directive_member_suggest diagnostics
> -// correcting from one namespace to another while still passing all 
> diagnostics
> -// along a chain of consumers.
> -class NamespaceDiagnosticWatcher : public clang::DiagnosticConsumer {
> +/// Counts the number of typo-correcting diagnostics correcting from one 
> name to
> +/// another while still passing all diagnostics along a chain of consumers.
> +class DiagnosticWatcher : public clang::DiagnosticConsumer {
>DiagnosticConsumer *Chained;
> -  std::string FromNS;
> -  std::string ToNS;
> +  std::string FromName;
> +  std::string ToName;
>
>  public:
> -  NamespaceDiagnosticWatcher(StringRef From, StringRef To)
> -  : Chained(nullptr), FromNS(From), ToNS("'"), SeenCount(0) {
> -ToNS.append(To);
> -ToNS.append("'");
> +  DiagnosticWatcher(StringRef From, StringRef To)
> +  : Chained(nullptr), FromName(From), ToName("'"), SeenCount(0) {
> +ToName.append(To);
> +ToName.append("'");
>}
>
>void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
> @@ -61,7 +60,12 @@ public:
>  if (Info.getID() - 1 == diag::err_using_directive_member_suggest) {
>const IdentifierInfo *Ident = Info.getArgIdentifier(0);
>const std::string &CorrectedQuotedStr = Info.getArgStdStr(1);
> -  if (Ident->getName() == FromNS && CorrectedQuotedStr == ToNS)
> +  if (Ident->getName() == FromName && CorrectedQuotedStr == ToName)
> +++SeenCount;
> +} else if (Info.getID() == diag::err_no_member_suggest) {
> +  auto Ident = DeclarationName::getFromOpaqueInteger(Info.getRawArg(0));
> +  const std::string &CorrectedQuotedStr = Info.getArgStdStr(3);
> +  if (Ident.getAsString() == FromName && CorrectedQuotedStr == ToName)
>  ++SeenCount;
>  }
>}
> @@ -78,7 +82,7 @@ public:
>  return false;
>}
>
> -  NamespaceDiagnosticWatcher *Chain(DiagnosticConsumer *ToChain) {
> +  DiagnosticWatcher *Chain(DiagnosticConsumer *ToChain) {
>  Chained = ToChain;
>  return this;
>}
> @@ -130,11 +134,53 @@ public:
>int CallCount;
>  };
>
> -// \brief Chains together a vector of NamespaceDiagnosticWatchers and
> +class Func

Re: r270047 - [Clang][AVX512][intrinsics] continue completing missing set intrinsics

2016-05-19 Thread Steven Wu via cfe-commits
Hi Michael

This commit seems break darwin LTO bootstrap bot. 
http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_check/7916/
Also breaks the Asan Ubsan bot:
http://lab.llvm.org:8080/green/job/clang-stage2-cmake-RgSan_check/1742/

Can you talk a look? I don't why the failure doesn't show up in other 
configuration. Let me know if you need any help.

Thanks

Steven


> On May 19, 2016, at 5:07 AM, Michael Zuckerman via cfe-commits 
>  wrote:
> 
> Author: mzuckerm
> Date: Thu May 19 07:07:49 2016
> New Revision: 270047
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=270047&view=rev
> Log:
> [Clang][AVX512][intrinsics] continue completing missing set intrinsics
> 
> Differential Revision: http://reviews.llvm.org/D20160
> 
> 
> Modified:
>cfe/trunk/lib/Headers/avx512fintrin.h
>cfe/trunk/test/CodeGen/avx512f-builtins.c
> 
> Modified: cfe/trunk/lib/Headers/avx512fintrin.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=270047&r1=270046&r2=270047&view=diff
> ==
> --- cfe/trunk/lib/Headers/avx512fintrin.h (original)
> +++ cfe/trunk/lib/Headers/avx512fintrin.h Thu May 19 07:07:49 2016
> @@ -8983,6 +8983,21 @@ _mm512_mask_set1_epi64 (__m512i __O, __m
>  __M);
> }
> 
> +static __inline __m512i __DEFAULT_FN_ATTRS
> +_mm512_set_epi32 (int __A, int __B, int __C, int __D,
> + int __E, int __F, int __G, int __H,
> + int __I, int __J, int __K, int __L,
> + int __M, int __N, int __O, int __P)
> +{
> +  return __extension__ (__m512i)(__v16si)
> +  { __P, __O, __N, __M, __L, __K, __J, __I,
> +__H, __G, __F, __E, __D, __C, __B, __A };
> +}
> +
> +#define _mm512_setr_epi32(e0,e1,e2,e3,e4,e5,e6,e7,   \
> +   e8,e9,e10,e11,e12,e13,e14,e15)  \
> +  _mm512_set_epi32(e15,e14,e13,e12,e11,e10,e9,e8,e7,e6,e5,e4,e3,e2,e1,e0)
> +  
> static __inline__ __m512i __DEFAULT_FN_ATTRS
> _mm512_set_epi64 (long long __A, long long __B, long long __C,
>  long long __D, long long __E, long long __F,
> @@ -8992,6 +9007,9 @@ _mm512_set_epi64 (long long __A, long lo
>   { __H, __G, __F, __E, __D, __C, __B, __A };
> }
> 
> +#define _mm512_setr_epi64(e0,e1,e2,e3,e4,e5,e6,e7)   \
> +  _mm512_set_epi64(e7,e6,e5,e4,e3,e2,e1,e0)
> +
> static __inline__ __m512d __DEFAULT_FN_ATTRS
> _mm512_set_pd (double __A, double __B, double __C, double __D,
> double __E, double __F, double __G, double __H)
> @@ -9000,6 +9018,9 @@ _mm512_set_pd (double __A, double __B, d
>   { __H, __G, __F, __E, __D, __C, __B, __A };
> }
> 
> +#define _mm512_setr_pd(e0,e1,e2,e3,e4,e5,e6,e7)  \
> +  _mm512_set_pd(e7,e6,e5,e4,e3,e2,e1,e0)
> +
> static __inline__ __m512 __DEFAULT_FN_ATTRS
> _mm512_set_ps (float __A, float __B, float __C, float __D,
> float __E, float __F, float __G, float __H,
> @@ -9011,6 +9032,9 @@ _mm512_set_ps (float __A, float __B, flo
> __H, __G, __F, __E, __D, __C, __B, __A };
> }
> 
> +#define 
> _mm512_setr_ps(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15) \
> +  _mm512_set_ps(e15,e14,e13,e12,e11,e10,e9,e8,e7,e6,e5,e4,e3,e2,e1,e0)
> +
> #undef __DEFAULT_FN_ATTRS
> 
> #endif // __AVX512FINTRIN_H
> 
> Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=270047&r1=270046&r2=270047&view=diff
> ==
> --- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
> +++ cfe/trunk/test/CodeGen/avx512f-builtins.c Thu May 19 07:07:49 2016
> @@ -6521,6 +6521,74 @@ __m512i test_mm512_mask_set1_epi32 (__m5
>   return _mm512_mask_set1_epi32 ( __O, __M, __A);
> }
> 
> +__m512i test_mm512_set_epi32 (int __A, int __B, int __C, int __D,
> +   int __E, int __F, int __G, int __H,
> +   int __I, int __J, int __K, int __L,
> +   int __M, int __N, int __O, int __P)
> +{
> + //CHECK-LABLE: @test_mm512_set_epi32
> + //CHECK: insertelement{{.*}}i32 0
> +//CHECK: insertelement{{.*}}i32 1
> +//CHECK: insertelement{{.*}}i32 2
> +//CHECK: insertelement{{.*}}i32 3
> +//CHECK: insertelement{{.*}}i32 4
> +//CHECK: insertelement{{.*}}i32 5
> +//CHECK: insertelement{{.*}}i32 6
> +//CHECK: insertelement{{.*}}i32 7
> +//CHECK: insertelement{{.*}}i32 8
> +//CHECK: insertelement{{.*}}i32 9
> +//CHECK: insertelement{{.*}}i32 10
> +//CHECK: insertelement{{.*}}i32 11
> +//CHECK: insertelement{{.*}}i32 12
> +//CHECK: insertelement{{.*}}i32 13
> +//CHECK: insertelement{{.*}}i32 14
> +//CHECK: insertelement{{.*}}i32 15
> + return _mm512_set_epi32( __A, __B, __C, __D,__E, __F, __G, __H,
> +  __I, __J, __K, __L,__M, __N, __O, __P);
> +}
> +
> +__m512i test_mm512_setr_epi32 (int __A, int __B, int __C, int __D,
> +   int __E, int __F, int __G, int __H,
> +   int __I, int __J, int __K, int _

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

2016-05-19 Thread Charles Davis via cfe-commits
cdavis5x added a comment.

For now, I've disallowed it with `naked` and `always_inline`/`__forceinline` 
attributes. Do any other attributes affect prologue generation in a way that 
might interfere with `ms_hook_prologue`? AFAICT, GCC only disallows 
`ms_hook_prologue` on a) nested functions and b) functions compiled with 
`-mfentry` (neither of which we support, AFAIK).



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

aaron.ballman wrote:
> I am wondering whether we want this to be a target-specific attribute or not. 
> Right now, this attribute will be silently accepted for CPUs that MSVC does 
> not support, for instance. If we made the attribute target-specific, then 
> users would get appropriate diagnostics for those architectures.
For now, I've limited it to architectures that Windows supports.


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] D19909: [Attr] Add support for the `ms_hook_prologue` attribute.

2016-05-19 Thread Charles Davis via cfe-commits
cdavis5x updated this revision to Diff 57853.
cdavis5x marked an inline comment as done.
cdavis5x added a comment.

- Add Sema tests for the `ms_hook_prologue` attribute.
- Disallow `ms_hook_prologue` on architectures that Windows doesn't support.
- Disallow `ms_hook_prologue` with the `naked` and `always_inline` attributes.


http://reviews.llvm.org/D19909

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

Index: test/Sema/attr-ms-hook-prologue.c
===
--- /dev/null
+++ test/Sema/attr-ms-hook-prologue.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple i386-pc-linux -fms-extensions -fsyntax-only -verify %s
+
+int __attribute__((ms_hook_prologue)) foo(int a, int b) {
+  return a+b;
+}
+
+// expected-note@+2{{conflicting attribute is here}}
+// expected-error@+1{{'naked' and 'ms_hook_prologue' attributes are not compatible}}
+__declspec(naked) int __attribute__((ms_hook_prologue)) bar(int a, int b) {
+}
+
+// expected-note@+2{{conflicting attribute is here}}
+// expected-error@+1{{'__forceinline' and 'ms_hook_prologue' attributes are not compatible}}
+__forceinline int __attribute__((ms_hook_prologue)) baz(int a, int b) {
+  return a-b;
+}
+
+// expected-warning@+1{{'ms_hook_prologue' attribute only applies to functions}}
+int x __attribute__((ms_hook_prologue));
+
+// expected-error@+1{{'ms_hook_prologue' attribute takes no arguments}}
+int f(int a, int b) __attribute__((ms_hook_prologue(2)));
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{{.*}}"patchable-function"="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
@@ -1663,15 +1663,6 @@
 D->addAttr(CA);
 }
 
-static void handleNakedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (checkAttrMutualExclusion(S, D, Attr.getRange(),
- Attr.getName()))
-return;
-
-  D->addAttr(::new (S.Context) NakedAttr(Attr.getRange(), S.Context,
- Attr.getAttributeSpellingListIndex()));
-}
-
 static void handleNoReturnAttr(Sema &S, Decl *D, const AttributeList &attr) {
   if (hasDeclarator(D)) return;
 
@@ -3672,7 +3663,9 @@
 static void handleAlwaysInlineAttr(Sema &S, Decl *D,
const AttributeList &Attr) {
   if (checkAttrMutualExclusion(S, D, Attr.getRange(),
-  Attr.getName()))
+  Attr.getName()) ||
+  checkAttrMutualExclusion(S, D, Attr.getRange(),
+   Attr.getName()))
 return;
 
   if (AlwaysInlineAttr *Inline = S.mergeAlwaysInlineAttr(
@@ -5525,7 +5518,8 @@
 handleHotAttr(S, D, Attr);
 break;
   case AttributeList::AT_Naked:
-handleNakedAttr(S, D, Attr);
+handleSimpleAttributeWithExclusions(S, D, Attr);
 break;
   case AttributeList::AT_NoReturn:
 handleNoReturnAttr(S, D, Attr);
@@ -5748,6 +5742,10 @@
 break;
 
   // Microsoft attributes:
+  case AttributeList::AT_MSHookPrologue:
+handleSimpleAttributeWithExclusions(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
@@ -1749,6 +1749,10 @@
   llvm::Function *Fn = cast(GV);
   Fn->setCallingConv(llvm::CallingConv::X86_INTR);
 }
+if (FD->hasAttr()) {
+  llvm::Function *Fn = cast(GV);
+  Fn->addFnAttr("patchable-function", "ms-hotpatch");
+}
   }
 }
 
@@ -2079,6 +2083,10 @@
 llvm::Function *Fn = cast(GV);
 Fn->setCallingConv(llvm::CallingConv::X86_INTR);
   }
+  if (FD->hasAttr()) {
+llvm::Functio

  1   2   >