Re: [PATCH] D20909: [clang-tidy] Ignore function context in misc-unused-using-decls.

2016-06-03 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 59492.
hokein added a comment.

Address code comments.


http://reviews.llvm.org/D20909

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
@@ -17,6 +17,8 @@
   static int ii;
 };
 template  class J {};
+class G;
+class H;
 
 class Base {
  public:
@@ -99,6 +101,24 @@
 USING_FUNC
 #undef USING_FUNC
 
+namespace N1 {
+// n::G is used in namespace N2.
+// Currently, the check doesn't support multiple scopes. All the relevant
+// using-decls will be marked as used once we see an usage even the usage is in
+// other scope.
+using n::G;
+}
+
+namespace N2 {
+using n::G;
+void f(G g);
+}
+
+void IgnoreFunctionScope() {
+// Using-decls defined in function scope will be ignored.
+using n::H;
+}
+
 // - Usages -
 void f(B b);
 void g() {
@@ -112,4 +132,3 @@
   UsedTemplateFunc();
   cout << endl;
 }
-
Index: clang-tidy/misc/UnusedUsingDeclsCheck.h
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.h
+++ clang-tidy/misc/UnusedUsingDeclsCheck.h
@@ -36,9 +36,15 @@
   struct UsingDeclContext {
 explicit UsingDeclContext(const UsingDecl *FoundUsingDecl)
 : FoundUsingDecl(FoundUsingDecl), IsUsed(false) {}
+// A set saves all UsingShadowDecls introduced by a UsingDecl. A UsingDecl
+// can introduce multiple UsingShadowDecls in some cases (such as
+// overloaded functions).
 llvm::SmallPtrSet UsingTargetDecls;
+// The original UsingDecl.
 const UsingDecl *FoundUsingDecl;
+// The source range of the UsingDecl.
 CharSourceRange UsingDeclRange;
+// Whether the UsingDecl is used.
 bool IsUsed;
   };
 
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -41,11 +41,17 @@
   if (const auto *Using = Result.Nodes.getNodeAs("using")) {
 // Ignores using-declarations defined in macros.
 if (Using->getLocation().isMacroID())
-  return ;
+  return;
 
 // Ignores using-declarations defined in class definition.
 if (isa(Using->getDeclContext()))
-  return ;
+  return;
+
+// FIXME: We ignore using-decls defined in function definitions at the
+// moment because of false positives caused by ADL and different function
+// scopes.
+if (isa(Using->getDeclContext()))
+  return;
 
 UsingDeclContext Context(Using);
 Context.UsingDeclRange = CharSourceRange::getCharRange(
@@ -97,11 +103,14 @@
 }
 
 void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {
+  // FIXME: Currently, we don't handle the using-decls being used in different
+  // scopes (such as different namespaces, different functions). Instead of
+  // giving an incorrect message, we mark all of them as used.
+  //
+  // FIXME: Use a more efficient way to find a matching context.
   for (auto &Context : Contexts) {
-if (Context.UsingTargetDecls.count(D->getCanonicalDecl()) > 0) {
+if (Context.UsingTargetDecls.count(D->getCanonicalDecl()) > 0)
   Context.IsUsed = true;
-  break;
-}
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r271632 - [clang-tidy] Ignore function context in misc-unused-using-decls.

2016-06-03 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Jun  3 03:05:11 2016
New Revision: 271632

URL: http://llvm.org/viewvc/llvm-project?rev=271632&view=rev
Log:
[clang-tidy] Ignore function context in misc-unused-using-decls.

Summary: Make the check's behavior more correct when handling using-decls in 
multiple scopes.

Reviewers: alexfh

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.h
clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp?rev=271632&r1=271631&r2=271632&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp Fri Jun  
3 03:05:11 2016
@@ -41,11 +41,17 @@ void UnusedUsingDeclsCheck::check(const
   if (const auto *Using = Result.Nodes.getNodeAs("using")) {
 // Ignores using-declarations defined in macros.
 if (Using->getLocation().isMacroID())
-  return ;
+  return;
 
 // Ignores using-declarations defined in class definition.
 if (isa(Using->getDeclContext()))
-  return ;
+  return;
+
+// FIXME: We ignore using-decls defined in function definitions at the
+// moment because of false positives caused by ADL and different function
+// scopes.
+if (isa(Using->getDeclContext()))
+  return;
 
 UsingDeclContext Context(Using);
 Context.UsingDeclRange = CharSourceRange::getCharRange(
@@ -97,11 +103,14 @@ void UnusedUsingDeclsCheck::check(const
 }
 
 void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {
+  // FIXME: Currently, we don't handle the using-decls being used in different
+  // scopes (such as different namespaces, different functions). Instead of
+  // giving an incorrect message, we mark all of them as used.
+  //
+  // FIXME: Use a more efficient way to find a matching context.
   for (auto &Context : Contexts) {
-if (Context.UsingTargetDecls.count(D->getCanonicalDecl()) > 0) {
+if (Context.UsingTargetDecls.count(D->getCanonicalDecl()) > 0)
   Context.IsUsed = true;
-  break;
-}
   }
 }
 

Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.h?rev=271632&r1=271631&r2=271632&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.h Fri Jun  3 
03:05:11 2016
@@ -36,9 +36,15 @@ private:
   struct UsingDeclContext {
 explicit UsingDeclContext(const UsingDecl *FoundUsingDecl)
 : FoundUsingDecl(FoundUsingDecl), IsUsed(false) {}
+// A set saves all UsingShadowDecls introduced by a UsingDecl. A UsingDecl
+// can introduce multiple UsingShadowDecls in some cases (such as
+// overloaded functions).
 llvm::SmallPtrSet UsingTargetDecls;
+// The original UsingDecl.
 const UsingDecl *FoundUsingDecl;
+// The source range of the UsingDecl.
 CharSourceRange UsingDeclRange;
+// Whether the UsingDecl is used.
 bool IsUsed;
   };
 

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp?rev=271632&r1=271631&r2=271632&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp Fri Jun 
 3 03:05:11 2016
@@ -17,6 +17,8 @@ class I {
   static int ii;
 };
 template  class J {};
+class G;
+class H;
 
 class Base {
  public:
@@ -99,6 +101,24 @@ DEFINE_INT(test);
 USING_FUNC
 #undef USING_FUNC
 
+namespace N1 {
+// n::G is used in namespace N2.
+// Currently, the check doesn't support multiple scopes. All the relevant
+// using-decls will be marked as used once we see an usage even the usage is in
+// other scope.
+using n::G;
+}
+
+namespace N2 {
+using n::G;
+void f(G g);
+}
+
+void IgnoreFunctionScope() {
+// Using-decls defined in function scope will be ignored.
+using n::H;
+}
+
 // - Usages -
 void f(B b);
 void g() {
@@ -112,4 +132,3 @@ void g() {
   UsedTemplateFunc();
   cout << endl;
 }
-


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


Re: [PATCH] D20909: [clang-tidy] Ignore function context in misc-unused-using-decls.

2016-06-03 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271632: [clang-tidy] Ignore function context in 
misc-unused-using-decls. (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D20909?vs=59492&id=59494#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20909

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

Index: clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
@@ -17,6 +17,8 @@
   static int ii;
 };
 template  class J {};
+class G;
+class H;
 
 class Base {
  public:
@@ -99,6 +101,24 @@
 USING_FUNC
 #undef USING_FUNC
 
+namespace N1 {
+// n::G is used in namespace N2.
+// Currently, the check doesn't support multiple scopes. All the relevant
+// using-decls will be marked as used once we see an usage even the usage is in
+// other scope.
+using n::G;
+}
+
+namespace N2 {
+using n::G;
+void f(G g);
+}
+
+void IgnoreFunctionScope() {
+// Using-decls defined in function scope will be ignored.
+using n::H;
+}
+
 // - Usages -
 void f(B b);
 void g() {
@@ -112,4 +132,3 @@
   UsedTemplateFunc();
   cout << endl;
 }
-
Index: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.h
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.h
@@ -36,9 +36,15 @@
   struct UsingDeclContext {
 explicit UsingDeclContext(const UsingDecl *FoundUsingDecl)
 : FoundUsingDecl(FoundUsingDecl), IsUsed(false) {}
+// A set saves all UsingShadowDecls introduced by a UsingDecl. A UsingDecl
+// can introduce multiple UsingShadowDecls in some cases (such as
+// overloaded functions).
 llvm::SmallPtrSet UsingTargetDecls;
+// The original UsingDecl.
 const UsingDecl *FoundUsingDecl;
+// The source range of the UsingDecl.
 CharSourceRange UsingDeclRange;
+// Whether the UsingDecl is used.
 bool IsUsed;
   };
 
Index: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -41,11 +41,17 @@
   if (const auto *Using = Result.Nodes.getNodeAs("using")) {
 // Ignores using-declarations defined in macros.
 if (Using->getLocation().isMacroID())
-  return ;
+  return;
 
 // Ignores using-declarations defined in class definition.
 if (isa(Using->getDeclContext()))
-  return ;
+  return;
+
+// FIXME: We ignore using-decls defined in function definitions at the
+// moment because of false positives caused by ADL and different function
+// scopes.
+if (isa(Using->getDeclContext()))
+  return;
 
 UsingDeclContext Context(Using);
 Context.UsingDeclRange = CharSourceRange::getCharRange(
@@ -97,11 +103,14 @@
 }
 
 void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {
+  // FIXME: Currently, we don't handle the using-decls being used in different
+  // scopes (such as different namespaces, different functions). Instead of
+  // giving an incorrect message, we mark all of them as used.
+  //
+  // FIXME: Use a more efficient way to find a matching context.
   for (auto &Context : Contexts) {
-if (Context.UsingTargetDecls.count(D->getCanonicalDecl()) > 0) {
+if (Context.UsingTargetDecls.count(D->getCanonicalDecl()) > 0)
   Context.IsUsed = true;
-  break;
-}
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20902: [include-fixer] added GNU symbols hardcoded header mapping.

2016-06-03 Thread Benjamin Kramer via cfe-commits
bkramer added a comment.

There are still headers in this list that aren't part of glibc, like curses. 
I'd rather have those not in the list right now and add stuff as-needed later. 
I hope that other packages usually found in /usr/include are saner so we don't 
need to add a header map for them.


http://reviews.llvm.org/D20902



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


[PATCH] D20950: [include-fixer] Don't add missing header if the unindentified symbol isn't from the main file.

2016-06-03 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: bkramer.
hokein added a subscriber: cfe-commits.

The further solution is to add the missing header to the file where the
symbol comes from.

http://reviews.llvm.org/D20950

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

Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -44,6 +44,8 @@
   llvm::MemoryBuffer::getMemBuffer("\n"));
   InMemoryFileSystem->addFile("dir/otherdir/qux.h", 0,
   llvm::MemoryBuffer::getMemBuffer("\n"));
+  InMemoryFileSystem->addFile("header.h", 0,
+  llvm::MemoryBuffer::getMemBuffer("bar b;"));
   return Invocation.run();
 }
 
@@ -186,6 +188,11 @@
 runIncludeFixer("int test = a::b::Green;\n"));
 }
 
+TEST(IncludeFixer, IgnoreSymbolFromHeader) {
+  std::string Code = "#include \"header.h\"";
+  EXPECT_EQ(Code, runIncludeFixer(Code));
+}
+
 // FIXME: add test cases for inserting and sorting multiple headers when
 // include-fixer supports multiple headers insertion.
 TEST(IncludeFixer, InsertAndSortSingleHeader) {
Index: include-fixer/IncludeFixer.cpp
===
--- include-fixer/IncludeFixer.cpp
+++ include-fixer/IncludeFixer.cpp
@@ -86,6 +86,15 @@
 if (getCompilerInstance().getSema().isSFINAEContext())
   return clang::TypoCorrection();
 
+// We currently ignore the unidentified symbol which is not from the
+// main file.
+//
+// FIXME: Add the missing header to the header file where the symbol comes
+// from.
+if (!getCompilerInstance().getSourceManager().isWrittenInMainFile(
+Typo.getLoc()))
+  return clang::TypoCorrection();
+
 std::string TypoScopeString;
 if (S) {
   // FIXME: Currently we only use namespace contexts. Use other context


Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -44,6 +44,8 @@
   llvm::MemoryBuffer::getMemBuffer("\n"));
   InMemoryFileSystem->addFile("dir/otherdir/qux.h", 0,
   llvm::MemoryBuffer::getMemBuffer("\n"));
+  InMemoryFileSystem->addFile("header.h", 0,
+  llvm::MemoryBuffer::getMemBuffer("bar b;"));
   return Invocation.run();
 }
 
@@ -186,6 +188,11 @@
 runIncludeFixer("int test = a::b::Green;\n"));
 }
 
+TEST(IncludeFixer, IgnoreSymbolFromHeader) {
+  std::string Code = "#include \"header.h\"";
+  EXPECT_EQ(Code, runIncludeFixer(Code));
+}
+
 // FIXME: add test cases for inserting and sorting multiple headers when
 // include-fixer supports multiple headers insertion.
 TEST(IncludeFixer, InsertAndSortSingleHeader) {
Index: include-fixer/IncludeFixer.cpp
===
--- include-fixer/IncludeFixer.cpp
+++ include-fixer/IncludeFixer.cpp
@@ -86,6 +86,15 @@
 if (getCompilerInstance().getSema().isSFINAEContext())
   return clang::TypoCorrection();
 
+// We currently ignore the unidentified symbol which is not from the
+// main file.
+//
+// FIXME: Add the missing header to the header file where the symbol comes
+// from.
+if (!getCompilerInstance().getSourceManager().isWrittenInMainFile(
+Typo.getLoc()))
+  return clang::TypoCorrection();
+
 std::string TypoScopeString;
 if (S) {
   // FIXME: Currently we only use namespace contexts. Use other context
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20898: [clang-format] skip empty lines and comments in the top of the code when inserting new headers.

2016-06-03 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 59497.
ioeric added a comment.

- Use FormatTokenLexer to skip comments.


http://reviews.llvm.org/D20898

Files:
  lib/Format/Format.cpp
  unittests/Format/CleanupTest.cpp

Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -465,13 +465,13 @@
 
 TEST_F(CleanUpReplacementsTest, InsertMultipleNewHeadersAndSortLLVM) {
   std::string Code = "\nint x;";
-  std::string Expected = "#include \"fix.h\"\n"
+  std::string Expected = "\n#include \"fix.h\"\n"
  "#include \"a.h\"\n"
  "#include \"b.h\"\n"
  "#include \"c.h\"\n"
  "#include \n"
  "#include \n"
- "\nint x;";
+ "int x;";
   tooling::Replacements Replaces = {createInsertion("#include \"a.h\""),
 createInsertion("#include \"c.h\""),
 createInsertion("#include \"b.h\""),
@@ -483,13 +483,13 @@
 
 TEST_F(CleanUpReplacementsTest, InsertMultipleNewHeadersAndSortGoogle) {
   std::string Code = "\nint x;";
-  std::string Expected = "#include \"fix.h\"\n"
+  std::string Expected = "\n#include \"fix.h\"\n"
  "#include \n"
  "#include \n"
  "#include \"a.h\"\n"
  "#include \"b.h\"\n"
  "#include \"c.h\"\n"
- "\nint x;";
+ "int x;";
   tooling::Replacements Replaces = {createInsertion("#include \"a.h\""),
 createInsertion("#include \"c.h\""),
 createInsertion("#include \"b.h\""),
@@ -502,21 +502,22 @@
 
 TEST_F(CleanUpReplacementsTest, FormatCorrectLineWhenHeadersAreInserted) {
   std::string Code = "\n"
+ "int x;\n"
  "inta;\n"
  "inta;\n"
  "inta;";
 
-  std::string Expected = "#include \"x.h\"\n"
+  std::string Expected = "\n#include \"x.h\"\n"
  "#include \"y.h\"\n"
  "#include \"clang/x/x.h\"\n"
  "#include \n"
  "#include \n"
- "\n"
+ "int x;\n"
  "inta;\n"
  "int b;\n"
  "inta;";
   tooling::Replacements Replaces = {
-  createReplacement(getOffset(Code, 3, 8), 1, "b"),
+  createReplacement(getOffset(Code, 4, 8), 1, "b"),
   createInsertion("#include "),
   createInsertion("#include "),
   createInsertion("#include \"clang/x/x.h\""),
@@ -537,6 +538,76 @@
   EXPECT_EQ(Expected, formatAndApply(Code, Replaces));
 }
 
+TEST_F(CleanUpReplacementsTest, SkippedTopComment) {
+  std::string Code = "// comment\n"
+ "\n"
+ "   // comment\n";
+  std::string Expected = "// comment\n"
+ "\n"
+ "   // comment\n"
+ "#include \n";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, SkippedMixedComments) {
+  std::string Code = "// comment\n"
+ "// comment \\\n"
+ " comment continued\n"
+ "/*\n"
+ "* comment\n"
+ "*/\n";
+  std::string Expected = "// comment\n"
+ "// comment \\\n"
+ " comment continued\n"
+ "/*\n"
+ "* comment\n"
+ "*/\n"
+ "#include \n";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, MultipleBlockCommentsInOneLine) {
+  std::string Code = "/*\n"
+ "* comment\n"
+ "*/ /* comment\n"
+ "*/\n"
+ "\n\n"
+ "/* c1 */ /*c2 */\n";
+  std::string Expected = "/*\n"
+ "* comment\n"
+ "*/ /* comment\n"
+ "*/\n"
+ "\n\n"
+ "/* c1 */ /*c2 */\n"
+ "#include \n";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, CodeAfterComments) {
+  std::string Code = "/*\n"
+ "* comment\n"
+ "*/ /* comment\n"
+ "*/\n"
+ "\n\n"
+ "/* 

Re: [PATCH] D20902: [include-fixer] added GNU symbols hardcoded header mapping.

2016-06-03 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 59499.
ioeric added a comment.

- Removed non glibc header mapping.


http://reviews.llvm.org/D20902

Files:
  include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp

Index: include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp
===
--- include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp
+++ include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp
@@ -77,9 +77,6 @@
   {"include/xsavesintrin.h", ""},
   {"include/xtestintrin.h", ""},
   {"include/_G_config.h", ""},
-  {"include/alloca.h", ""},
-  {"include/asm-generic/errno-base.h", ""},
-  {"include/asm-generic/errno.h", ""},
   {"include/assert.h", ""},
   {"algorithm", ""},
   {"array", ""},
@@ -269,33 +266,23 @@
   {"vector", ""},
   {"include/complex.h", ""},
   {"include/ctype.h", ""},
-  {"include/endian.h", ""},
   {"include/errno.h", ""},
-  {"include/features.h", ""},
   {"include/fenv.h", ""},
   {"include/inttypes.h", ""},
-  {"include/libintl.h", ""},
   {"include/libio.h", ""},
   {"include/limits.h", ""},
-  {"include/linux/limits.h", ""},
   {"include/locale.h", ""},
   {"include/math.h", ""},
-  {"include/pthread.h", ""},
-  {"include/sched.h", ""},
   {"include/setjmp.h", ""},
   {"include/signal.h", ""},
-  {"include/stdc-predef.h", ""},
   {"include/stdint.h", ""},
   {"include/stdio.h", ""},
   {"include/stdlib.h", ""},
   {"include/string.h", ""},
   {"include/time.h", ""},
   {"include/wchar.h", ""},
   {"include/wctype.h", ""},
-  {"bits/byteswap-16.h", ""},
-  {"bits/byteswap.h", ""},
   {"bits/cmathcalls.h", ""},
-  {"bits/endian.h", ""},
   {"bits/errno.h", ""},
   {"bits/fenv.h", ""},
   {"bits/huge_val.h", ""},
@@ -309,34 +296,21 @@
   {"bits/nan.h", ""},
   {"bits/posix1_lim.h", ""},
   {"bits/posix2_lim.h", ""},
-  {"bits/pthreadtypes.h", ""},
-  {"bits/sched.h", ""},
-  {"bits/select.h", ""},
   {"bits/setjmp.h", ""},
   {"bits/sigaction.h", ""},
   {"bits/sigcontext.h", ""},
   {"bits/siginfo.h", ""},
   {"bits/signum.h", ""},
   {"bits/sigset.h", ""},
   {"bits/sigstack.h", ""},
-  {"bits/sigthread.h", ""},
   {"bits/stdio_lim.h", ""},
   {"bits/sys_errlist.h", ""},
   {"bits/time.h", ""},
   {"bits/timex.h", ""},
-  {"bits/types.h", ""},
   {"bits/typesizes.h", ""},
-  {"bits/waitflags.h", ""},
-  {"bits/waitstatus.h", ""},
   {"bits/wchar.h", ""},
   {"bits/wordsize.h", ""},
   {"bits/xopen_lim.h", ""},
-  {"gnu/stubs-64.h", ""},
-  {"sys/cdefs.h", ""},
-  {"sys/select.h", ""},
-  {"sys/sysmacros.h", ""},
-  {"sys/types.h", ""},
-  {"sys/ucontext.h", ""},
   {"include/xlocale.h", ""},
   {"bits/atomic_word.h", ""},
   {"bits/basic_file.h", ""},
@@ -352,6 +326,322 @@
   {"bits/gthr.h", ""},
   {"bits/opt_random.h", ""},
   {"bits/os_defines.h", ""},
+  // GNU C headers
+  {"include/aio.h", ""},
+  {"include/aliases.h", ""},
+  {"include/alloca.h", ""},
+  {"include/ar.h", ""},
+  {"include/argp.h", ""},
+  {"include/argz.h", ""},
+  {"include/arpa/nameser.h", ""},
+  {"include/arpa/nameser_compat.h", ""},
+  {"include/byteswap.h", ""},
+  {"include/cpio.h", ""},
+  {"include/crypt.h", ""},
+  {"include/dirent.h", ""},
+  {"include/dlfcn.h", ""},
+  {"include/elf.h", ""},
+  {"include/endian.h", ""},
+  {"include/envz.h", ""},
+  {"include/err.h", ""},
+  {"include/error.h", ""},
+  {"include/execinfo.h", ""},
+  {"include/fcntl.h", ""},
+  {"include/features.h", ""},
+  {"include/fenv.h", ""},
+  {"include/fmtmsg.h", ""},
+  {"include/fnmatch.h", ""},
+  {"include/fstab.h", ""},
+  {"include/fts.h", ""},
+  {"include/ftw.h", ""},
+  {"include/gconv.h", ""},
+  {"include/getopt.h", ""},
+  {"include/glob.h", ""},
+  {"include/grp.h", ""},
+  {"include/gshadow.h", ""},
+  {"include/iconv.h", ""},
+  {"include/ifaddrs.h", ""},
+  {"include/kdb.h", ""},
+  {"include/langinfo.h", ""},
+  {"include/libgen.h", ""},
+  {"include/libintl.h", ""},
+  {"include/link.h", ""},
+  {"include/malloc.h", ""},
+  {"include/mcheck.h", ""},
+  {"include/memory.h", ""},
+  {"include/mntent.h", ""},
+  {"include/monetary.h", ""},
+  {"include/mqueue.h", ""},
+  {"include/netdb.h", ""},
+  {"include/netinet/in.h", ""},
+  {"include/nl_types.h", ""},
+  {"include/nss.h", ""},
+  {"include/obstack.h", ""},
+  {"include/panel.h", ""},
+  {"include/paths.h", ""},
+  {"include/printf.h", ""},
+  {"include/profile.h", ""},
+  {"include/pthread.h", ""},
+  {"include/pty.h", ""},
+  {"include/pwd.h", ""},
+  {"i

[libcxx] r271634 - [libcxx] Fix thread join.pass.cpp segfault after r271475

2016-06-03 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Fri Jun  3 03:45:26 2016
New Revision: 271634

URL: http://llvm.org/viewvc/llvm-project?rev=271634&view=rev
Log:
[libcxx] Fix thread join.pass.cpp segfault after r271475

Some pthread implementations do not like being called pthead_join()
with the pthread_t argument set to 0, and causes a segfault. This
patch fixes this issue by validating the pthread_t argument before
invoking pthread_join().

NFC.

Differential revision: http://reviews.llvm.org/D20929

Change-Id: Ief817c57bd0e1f43cbaa03061e02417d6a180c38
Reviewers: EricWF

Modified:
libcxx/trunk/src/thread.cpp

Modified: libcxx/trunk/src/thread.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/thread.cpp?rev=271634&r1=271633&r2=271634&view=diff
==
--- libcxx/trunk/src/thread.cpp (original)
+++ libcxx/trunk/src/thread.cpp Fri Jun  3 03:45:26 2016
@@ -46,14 +46,17 @@ thread::~thread()
 void
 thread::join()
 {
-int ec = __libcpp_thread_join(&__t_);
+int ec = EINVAL;
+if (__t_ != 0)
+{
+ec = __libcpp_thread_join(&__t_);
+if (ec == 0)
+__t_ = 0;
+}
 #ifndef _LIBCPP_NO_EXCEPTIONS
 if (ec)
 throw system_error(error_code(ec, system_category()), "thread::join 
failed");
-#else
-(void)ec;
 #endif  // _LIBCPP_NO_EXCEPTIONS
-__t_ = 0;
 }
 
 void


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


Re: [PATCH] D20898: [clang-format] skip empty lines and comments in the top of the code when inserting new headers.

2016-06-03 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: lib/Format/Format.cpp:1484
@@ +1483,3 @@
+  Environment::CreateVirtualEnvironment(Code, FileName, /*Ranges=*/{});
+  FormatTokenLexer Lexer(Env->getSourceManager(), Env->getFileID(), Style,
+ encoding::detectEncoding(Code));

Thinking about this some more, I think the FormatTokenLexer already does too 
much. Maybe just use a regular lexer?

  const SourceManager& SourceMgr = Env->getSourceManager();
  Lexer Lex(Env->getFileID(), SourceMgr.getBuffer(Env->getFileID()), SourceMgr,
getFormattingLangOpts(Style));
  Token Tok;
  int MinInsertOffset = Code.size();
  while (Lex.LexFromRawLexer(&Tok)) {
if (Tok.isNot(tok::comment)) {
  MinInsertOffset = SourceMgr.getFileOffset(Tok.getLocation());
  break;
}
  } 


http://reviews.llvm.org/D20898



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


Re: [PATCH] D20908: Add a few missing Clang regression tests

2016-06-03 Thread Sjoerd Meijer via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271636: Add a few missing Clang regression tests for 
Cortex-A53, Cortex-A57, Cortex-A72 (authored by SjoerdMeijer).

Changed prior to commit:
  http://reviews.llvm.org/D20908?vs=59371&id=59500#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20908

Files:
  cfe/trunk/test/Preprocessor/arm-target-features.c

Index: cfe/trunk/test/Preprocessor/arm-target-features.c
===
--- cfe/trunk/test/Preprocessor/arm-target-features.c
+++ cfe/trunk/test/Preprocessor/arm-target-features.c
@@ -301,8 +301,14 @@
 // Test whether predefines are as expected when targeting ARMv8-A Cortex 
implementations
 // RUN: %clang -target armv8 -mcpu=cortex-a32 -x c -E -dM %s -o - | FileCheck 
-match-full-lines --check-prefix=ARMV8 %s
 // RUN: %clang -target armv8 -mthumb -mcpu=cortex-a32 -x c -E -dM %s -o - | 
FileCheck -match-full-lines --check-prefix=ARMV8 %s
+// RUN: %clang -target armv8 -mcpu=cortex-a35 -x c -E -dM %s -o - | FileCheck 
-match-full-lines --check-prefix=ARMV8 %s
+// RUN: %clang -target armv8 -mthumb -mcpu=cortex-a35 -x c -E -dM %s -o - | 
FileCheck -match-full-lines --check-prefix=ARMV8 %s
 // RUN: %clang -target armv8 -mcpu=cortex-a53 -x c -E -dM %s -o - | FileCheck 
-match-full-lines --check-prefix=ARMV8 %s
 // RUN: %clang -target armv8 -mthumb -mcpu=cortex-a53 -x c -E -dM %s -o - | 
FileCheck -match-full-lines --check-prefix=ARMV8 %s
+// RUN: %clang -target armv8 -mcpu=cortex-a57 -x c -E -dM %s -o - | FileCheck 
-match-full-lines --check-prefix=ARMV8 %s
+// RUN: %clang -target armv8 -mthumb -mcpu=cortex-a57 -x c -E -dM %s -o - | 
FileCheck -match-full-lines --check-prefix=ARMV8 %s
+// RUN: %clang -target armv8 -mcpu=cortex-a72 -x c -E -dM %s -o - | FileCheck 
-match-full-lines --check-prefix=ARMV8 %s
+// RUN: %clang -target armv8 -mthumb -mcpu=cortex-a72 -x c -E -dM %s -o - | 
FileCheck -match-full-lines --check-prefix=ARMV8 %s
 // RUN: %clang -target armv8 -mcpu=cortex-a73 -x c -E -dM %s -o - | FileCheck 
-match-full-lines --check-prefix=ARMV8 %s
 // RUN: %clang -target armv8 -mthumb -mcpu=cortex-a73 -x c -E -dM %s -o - | 
FileCheck -match-full-lines --check-prefix=ARMV8 %s
 // ARMV8:#define __ARM_ARCH_EXT_IDIV__ 1


Index: cfe/trunk/test/Preprocessor/arm-target-features.c
===
--- cfe/trunk/test/Preprocessor/arm-target-features.c
+++ cfe/trunk/test/Preprocessor/arm-target-features.c
@@ -301,8 +301,14 @@
 // Test whether predefines are as expected when targeting ARMv8-A Cortex implementations
 // RUN: %clang -target armv8 -mcpu=cortex-a32 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=ARMV8 %s
 // RUN: %clang -target armv8 -mthumb -mcpu=cortex-a32 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=ARMV8 %s
+// RUN: %clang -target armv8 -mcpu=cortex-a35 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=ARMV8 %s
+// RUN: %clang -target armv8 -mthumb -mcpu=cortex-a35 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=ARMV8 %s
 // RUN: %clang -target armv8 -mcpu=cortex-a53 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=ARMV8 %s
 // RUN: %clang -target armv8 -mthumb -mcpu=cortex-a53 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=ARMV8 %s
+// RUN: %clang -target armv8 -mcpu=cortex-a57 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=ARMV8 %s
+// RUN: %clang -target armv8 -mthumb -mcpu=cortex-a57 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=ARMV8 %s
+// RUN: %clang -target armv8 -mcpu=cortex-a72 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=ARMV8 %s
+// RUN: %clang -target armv8 -mthumb -mcpu=cortex-a72 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=ARMV8 %s
 // RUN: %clang -target armv8 -mcpu=cortex-a73 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=ARMV8 %s
 // RUN: %clang -target armv8 -mthumb -mcpu=cortex-a73 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=ARMV8 %s
 // ARMV8:#define __ARM_ARCH_EXT_IDIV__ 1
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r271636 - Add a few missing Clang regression tests for Cortex-A53, Cortex-A57, Cortex-A72

2016-06-03 Thread Sjoerd Meijer via cfe-commits
Author: sjoerdmeijer
Date: Fri Jun  3 03:47:56 2016
New Revision: 271636

URL: http://llvm.org/viewvc/llvm-project?rev=271636&view=rev
Log:
Add a few missing Clang regression tests for Cortex-A53, Cortex-A57, Cortex-A72

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

Modified:
cfe/trunk/test/Preprocessor/arm-target-features.c

Modified: cfe/trunk/test/Preprocessor/arm-target-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/arm-target-features.c?rev=271636&r1=271635&r2=271636&view=diff
==
--- cfe/trunk/test/Preprocessor/arm-target-features.c (original)
+++ cfe/trunk/test/Preprocessor/arm-target-features.c Fri Jun  3 03:47:56 2016
@@ -301,8 +301,14 @@
 // Test whether predefines are as expected when targeting ARMv8-A Cortex 
implementations
 // RUN: %clang -target armv8 -mcpu=cortex-a32 -x c -E -dM %s -o - | FileCheck 
-match-full-lines --check-prefix=ARMV8 %s
 // RUN: %clang -target armv8 -mthumb -mcpu=cortex-a32 -x c -E -dM %s -o - | 
FileCheck -match-full-lines --check-prefix=ARMV8 %s
+// RUN: %clang -target armv8 -mcpu=cortex-a35 -x c -E -dM %s -o - | FileCheck 
-match-full-lines --check-prefix=ARMV8 %s
+// RUN: %clang -target armv8 -mthumb -mcpu=cortex-a35 -x c -E -dM %s -o - | 
FileCheck -match-full-lines --check-prefix=ARMV8 %s
 // RUN: %clang -target armv8 -mcpu=cortex-a53 -x c -E -dM %s -o - | FileCheck 
-match-full-lines --check-prefix=ARMV8 %s
 // RUN: %clang -target armv8 -mthumb -mcpu=cortex-a53 -x c -E -dM %s -o - | 
FileCheck -match-full-lines --check-prefix=ARMV8 %s
+// RUN: %clang -target armv8 -mcpu=cortex-a57 -x c -E -dM %s -o - | FileCheck 
-match-full-lines --check-prefix=ARMV8 %s
+// RUN: %clang -target armv8 -mthumb -mcpu=cortex-a57 -x c -E -dM %s -o - | 
FileCheck -match-full-lines --check-prefix=ARMV8 %s
+// RUN: %clang -target armv8 -mcpu=cortex-a72 -x c -E -dM %s -o - | FileCheck 
-match-full-lines --check-prefix=ARMV8 %s
+// RUN: %clang -target armv8 -mthumb -mcpu=cortex-a72 -x c -E -dM %s -o - | 
FileCheck -match-full-lines --check-prefix=ARMV8 %s
 // RUN: %clang -target armv8 -mcpu=cortex-a73 -x c -E -dM %s -o - | FileCheck 
-match-full-lines --check-prefix=ARMV8 %s
 // RUN: %clang -target armv8 -mthumb -mcpu=cortex-a73 -x c -E -dM %s -o - | 
FileCheck -match-full-lines --check-prefix=ARMV8 %s
 // ARMV8:#define __ARM_ARCH_EXT_IDIV__ 1


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


Re: [PATCH] D20929: [libcxx] Fix join.pass.cpp segfault after r271475

2016-06-03 Thread Asiri Rathnayake via cfe-commits
rmaprath closed this revision.
rmaprath added a comment.

Thanks. Fixed in r271634.


http://reviews.llvm.org/D20929



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


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

2016-06-03 Thread Clement Courbet via cfe-commits
courbet updated this revision to Diff 59502.
courbet added a comment.

Rebase on origin/master


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
@@ -1997,5 +1997,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
@@ -1635,6 +1635,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

Re: [PATCH] D20874: [libcxx] Two more threading dependencies

2016-06-03 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 59507.
rmaprath added a comment.

Added a comment about `~std::thread()` hook.

@EricWF: Gentle ping.


http://reviews.llvm.org/D20874

Files:
  include/__threading_support
  src/thread.cpp

Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -39,8 +39,10 @@
 
 thread::~thread()
 {
+// custom hook allowing thread implementations to control
+// the ~std::tread() behavior.
 if (__t_ != 0)
-terminate();
+__libcpp_thread_terminate();
 }
 
 void
@@ -133,7 +135,7 @@
 ts.tv_nsec = giga::num - 1;
 }
 
-while (nanosleep(&ts, &ts) == -1 && errno == EINTR)
+while (__libcpp_thread_nanosleep(&ts, &ts) == -1 && errno == EINTR)
 ;
 }
 }
Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -22,6 +22,8 @@
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 #include 
 #include 
+#include 
+#include 
 #endif
 
 _LIBCPP_BEGIN_NAMESPACE_STD
@@ -156,6 +158,12 @@
 }
 
 inline _LIBCPP_ALWAYS_INLINE
+int __libcpp_thread_nanosleep(const timespec *req, timespec *rem)
+{
+return nanosleep(req, rem);
+}
+
+inline _LIBCPP_ALWAYS_INLINE
 int __libcpp_thread_join(__libcpp_thread_t* __t)
 {
 return pthread_join(*__t, 0);
@@ -173,6 +181,12 @@
 sched_yield();
 }
 
+inline _LIBCPP_ALWAYS_INLINE
+void __libcpp_thread_terminate()
+{
+std::terminate();
+}
+
 // Thread local storage
 typedef pthread_key_t __libcpp_tl_key;
 


Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -39,8 +39,10 @@
 
 thread::~thread()
 {
+// custom hook allowing thread implementations to control
+// the ~std::tread() behavior.
 if (__t_ != 0)
-terminate();
+__libcpp_thread_terminate();
 }
 
 void
@@ -133,7 +135,7 @@
 ts.tv_nsec = giga::num - 1;
 }
 
-while (nanosleep(&ts, &ts) == -1 && errno == EINTR)
+while (__libcpp_thread_nanosleep(&ts, &ts) == -1 && errno == EINTR)
 ;
 }
 }
Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -22,6 +22,8 @@
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 #include 
 #include 
+#include 
+#include 
 #endif
 
 _LIBCPP_BEGIN_NAMESPACE_STD
@@ -156,6 +158,12 @@
 }
 
 inline _LIBCPP_ALWAYS_INLINE
+int __libcpp_thread_nanosleep(const timespec *req, timespec *rem)
+{
+return nanosleep(req, rem);
+}
+
+inline _LIBCPP_ALWAYS_INLINE
 int __libcpp_thread_join(__libcpp_thread_t* __t)
 {
 return pthread_join(*__t, 0);
@@ -173,6 +181,12 @@
 sched_yield();
 }
 
+inline _LIBCPP_ALWAYS_INLINE
+void __libcpp_thread_terminate()
+{
+std::terminate();
+}
+
 // Thread local storage
 typedef pthread_key_t __libcpp_tl_key;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20898: [clang-format] skip empty lines and comments in the top of the code when inserting new headers.

2016-06-03 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 59508.
ioeric added a comment.

- Use regular Lexer instead of FormatTokenLexer.


http://reviews.llvm.org/D20898

Files:
  lib/Format/Format.cpp
  unittests/Format/CleanupTest.cpp

Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -465,13 +465,13 @@
 
 TEST_F(CleanUpReplacementsTest, InsertMultipleNewHeadersAndSortLLVM) {
   std::string Code = "\nint x;";
-  std::string Expected = "#include \"fix.h\"\n"
+  std::string Expected = "\n#include \"fix.h\"\n"
  "#include \"a.h\"\n"
  "#include \"b.h\"\n"
  "#include \"c.h\"\n"
  "#include \n"
  "#include \n"
- "\nint x;";
+ "int x;";
   tooling::Replacements Replaces = {createInsertion("#include \"a.h\""),
 createInsertion("#include \"c.h\""),
 createInsertion("#include \"b.h\""),
@@ -483,13 +483,13 @@
 
 TEST_F(CleanUpReplacementsTest, InsertMultipleNewHeadersAndSortGoogle) {
   std::string Code = "\nint x;";
-  std::string Expected = "#include \"fix.h\"\n"
+  std::string Expected = "\n#include \"fix.h\"\n"
  "#include \n"
  "#include \n"
  "#include \"a.h\"\n"
  "#include \"b.h\"\n"
  "#include \"c.h\"\n"
- "\nint x;";
+ "int x;";
   tooling::Replacements Replaces = {createInsertion("#include \"a.h\""),
 createInsertion("#include \"c.h\""),
 createInsertion("#include \"b.h\""),
@@ -502,21 +502,22 @@
 
 TEST_F(CleanUpReplacementsTest, FormatCorrectLineWhenHeadersAreInserted) {
   std::string Code = "\n"
+ "int x;\n"
  "inta;\n"
  "inta;\n"
  "inta;";
 
-  std::string Expected = "#include \"x.h\"\n"
+  std::string Expected = "\n#include \"x.h\"\n"
  "#include \"y.h\"\n"
  "#include \"clang/x/x.h\"\n"
  "#include \n"
  "#include \n"
- "\n"
+ "int x;\n"
  "inta;\n"
  "int b;\n"
  "inta;";
   tooling::Replacements Replaces = {
-  createReplacement(getOffset(Code, 3, 8), 1, "b"),
+  createReplacement(getOffset(Code, 4, 8), 1, "b"),
   createInsertion("#include "),
   createInsertion("#include "),
   createInsertion("#include \"clang/x/x.h\""),
@@ -537,6 +538,76 @@
   EXPECT_EQ(Expected, formatAndApply(Code, Replaces));
 }
 
+TEST_F(CleanUpReplacementsTest, SkippedTopComment) {
+  std::string Code = "// comment\n"
+ "\n"
+ "   // comment\n";
+  std::string Expected = "// comment\n"
+ "\n"
+ "   // comment\n"
+ "#include \n";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, SkippedMixedComments) {
+  std::string Code = "// comment\n"
+ "// comment \\\n"
+ " comment continued\n"
+ "/*\n"
+ "* comment\n"
+ "*/\n";
+  std::string Expected = "// comment\n"
+ "// comment \\\n"
+ " comment continued\n"
+ "/*\n"
+ "* comment\n"
+ "*/\n"
+ "#include \n";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, MultipleBlockCommentsInOneLine) {
+  std::string Code = "/*\n"
+ "* comment\n"
+ "*/ /* comment\n"
+ "*/\n"
+ "\n\n"
+ "/* c1 */ /*c2 */\n";
+  std::string Expected = "/*\n"
+ "* comment\n"
+ "*/ /* comment\n"
+ "*/\n"
+ "\n\n"
+ "/* c1 */ /*c2 */\n"
+ "#include \n";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, CodeAfterComments) {
+  std::string Code = "/*\n"
+ "* comment\n"
+ "*/ /* comment\n"
+ "*/\n"
+ "\n\n"
+ 

Re: [PATCH] D20898: [clang-format] skip empty lines and comments in the top of the code when inserting new headers.

2016-06-03 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 59510.
ioeric marked an inline comment as done.
ioeric added a comment.

- Switch back to range-base looping for Lines.


http://reviews.llvm.org/D20898

Files:
  lib/Format/Format.cpp
  unittests/Format/CleanupTest.cpp

Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -465,13 +465,13 @@
 
 TEST_F(CleanUpReplacementsTest, InsertMultipleNewHeadersAndSortLLVM) {
   std::string Code = "\nint x;";
-  std::string Expected = "#include \"fix.h\"\n"
+  std::string Expected = "\n#include \"fix.h\"\n"
  "#include \"a.h\"\n"
  "#include \"b.h\"\n"
  "#include \"c.h\"\n"
  "#include \n"
  "#include \n"
- "\nint x;";
+ "int x;";
   tooling::Replacements Replaces = {createInsertion("#include \"a.h\""),
 createInsertion("#include \"c.h\""),
 createInsertion("#include \"b.h\""),
@@ -483,13 +483,13 @@
 
 TEST_F(CleanUpReplacementsTest, InsertMultipleNewHeadersAndSortGoogle) {
   std::string Code = "\nint x;";
-  std::string Expected = "#include \"fix.h\"\n"
+  std::string Expected = "\n#include \"fix.h\"\n"
  "#include \n"
  "#include \n"
  "#include \"a.h\"\n"
  "#include \"b.h\"\n"
  "#include \"c.h\"\n"
- "\nint x;";
+ "int x;";
   tooling::Replacements Replaces = {createInsertion("#include \"a.h\""),
 createInsertion("#include \"c.h\""),
 createInsertion("#include \"b.h\""),
@@ -502,21 +502,22 @@
 
 TEST_F(CleanUpReplacementsTest, FormatCorrectLineWhenHeadersAreInserted) {
   std::string Code = "\n"
+ "int x;\n"
  "inta;\n"
  "inta;\n"
  "inta;";
 
-  std::string Expected = "#include \"x.h\"\n"
+  std::string Expected = "\n#include \"x.h\"\n"
  "#include \"y.h\"\n"
  "#include \"clang/x/x.h\"\n"
  "#include \n"
  "#include \n"
- "\n"
+ "int x;\n"
  "inta;\n"
  "int b;\n"
  "inta;";
   tooling::Replacements Replaces = {
-  createReplacement(getOffset(Code, 3, 8), 1, "b"),
+  createReplacement(getOffset(Code, 4, 8), 1, "b"),
   createInsertion("#include "),
   createInsertion("#include "),
   createInsertion("#include \"clang/x/x.h\""),
@@ -537,6 +538,76 @@
   EXPECT_EQ(Expected, formatAndApply(Code, Replaces));
 }
 
+TEST_F(CleanUpReplacementsTest, SkippedTopComment) {
+  std::string Code = "// comment\n"
+ "\n"
+ "   // comment\n";
+  std::string Expected = "// comment\n"
+ "\n"
+ "   // comment\n"
+ "#include \n";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, SkippedMixedComments) {
+  std::string Code = "// comment\n"
+ "// comment \\\n"
+ " comment continued\n"
+ "/*\n"
+ "* comment\n"
+ "*/\n";
+  std::string Expected = "// comment\n"
+ "// comment \\\n"
+ " comment continued\n"
+ "/*\n"
+ "* comment\n"
+ "*/\n"
+ "#include \n";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, MultipleBlockCommentsInOneLine) {
+  std::string Code = "/*\n"
+ "* comment\n"
+ "*/ /* comment\n"
+ "*/\n"
+ "\n\n"
+ "/* c1 */ /*c2 */\n";
+  std::string Expected = "/*\n"
+ "* comment\n"
+ "*/ /* comment\n"
+ "*/\n"
+ "\n\n"
+ "/* c1 */ /*c2 */\n"
+ "#include \n";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, CodeAfterComments) {
+  std::string Code = "/*\n"
+ "* comment\n"
+ "*/ /* comment\n"
+ "*/\n"
+   

Re: [PATCH] D20898: [clang-format] skip empty lines and comments in the top of the code when inserting new headers.

2016-06-03 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 59511.
ioeric added a comment.

- Nits fixed.


http://reviews.llvm.org/D20898

Files:
  lib/Format/Format.cpp
  unittests/Format/CleanupTest.cpp

Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -465,13 +465,13 @@
 
 TEST_F(CleanUpReplacementsTest, InsertMultipleNewHeadersAndSortLLVM) {
   std::string Code = "\nint x;";
-  std::string Expected = "#include \"fix.h\"\n"
+  std::string Expected = "\n#include \"fix.h\"\n"
  "#include \"a.h\"\n"
  "#include \"b.h\"\n"
  "#include \"c.h\"\n"
  "#include \n"
  "#include \n"
- "\nint x;";
+ "int x;";
   tooling::Replacements Replaces = {createInsertion("#include \"a.h\""),
 createInsertion("#include \"c.h\""),
 createInsertion("#include \"b.h\""),
@@ -483,13 +483,13 @@
 
 TEST_F(CleanUpReplacementsTest, InsertMultipleNewHeadersAndSortGoogle) {
   std::string Code = "\nint x;";
-  std::string Expected = "#include \"fix.h\"\n"
+  std::string Expected = "\n#include \"fix.h\"\n"
  "#include \n"
  "#include \n"
  "#include \"a.h\"\n"
  "#include \"b.h\"\n"
  "#include \"c.h\"\n"
- "\nint x;";
+ "int x;";
   tooling::Replacements Replaces = {createInsertion("#include \"a.h\""),
 createInsertion("#include \"c.h\""),
 createInsertion("#include \"b.h\""),
@@ -502,21 +502,22 @@
 
 TEST_F(CleanUpReplacementsTest, FormatCorrectLineWhenHeadersAreInserted) {
   std::string Code = "\n"
+ "int x;\n"
  "inta;\n"
  "inta;\n"
  "inta;";
 
-  std::string Expected = "#include \"x.h\"\n"
+  std::string Expected = "\n#include \"x.h\"\n"
  "#include \"y.h\"\n"
  "#include \"clang/x/x.h\"\n"
  "#include \n"
  "#include \n"
- "\n"
+ "int x;\n"
  "inta;\n"
  "int b;\n"
  "inta;";
   tooling::Replacements Replaces = {
-  createReplacement(getOffset(Code, 3, 8), 1, "b"),
+  createReplacement(getOffset(Code, 4, 8), 1, "b"),
   createInsertion("#include "),
   createInsertion("#include "),
   createInsertion("#include \"clang/x/x.h\""),
@@ -537,6 +538,76 @@
   EXPECT_EQ(Expected, formatAndApply(Code, Replaces));
 }
 
+TEST_F(CleanUpReplacementsTest, SkippedTopComment) {
+  std::string Code = "// comment\n"
+ "\n"
+ "   // comment\n";
+  std::string Expected = "// comment\n"
+ "\n"
+ "   // comment\n"
+ "#include \n";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, SkippedMixedComments) {
+  std::string Code = "// comment\n"
+ "// comment \\\n"
+ " comment continued\n"
+ "/*\n"
+ "* comment\n"
+ "*/\n";
+  std::string Expected = "// comment\n"
+ "// comment \\\n"
+ " comment continued\n"
+ "/*\n"
+ "* comment\n"
+ "*/\n"
+ "#include \n";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, MultipleBlockCommentsInOneLine) {
+  std::string Code = "/*\n"
+ "* comment\n"
+ "*/ /* comment\n"
+ "*/\n"
+ "\n\n"
+ "/* c1 */ /*c2 */\n";
+  std::string Expected = "/*\n"
+ "* comment\n"
+ "*/ /* comment\n"
+ "*/\n"
+ "\n\n"
+ "/* c1 */ /*c2 */\n"
+ "#include \n";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, CodeAfterComments) {
+  std::string Code = "/*\n"
+ "* comment\n"
+ "*/ /* comment\n"
+ "*/\n"
+ "\n\n"
+ "/* c1 */ /*c2 */\n"
+ 

Re: [PATCH] D20902: [include-fixer] added GNU symbols hardcoded header mapping.

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

lg, thanks!


http://reviews.llvm.org/D20902



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


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

2016-06-03 Thread Clement Courbet via cfe-commits
courbet added a comment.

@sbenza @aaron.ballman I don't have write access. Can one of you submit this on 
my behalf ? Thanks !


http://reviews.llvm.org/D19324



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


[clang-tools-extra] r271637 - [include-fixer] added GNU symbols hardcoded header mapping.

2016-06-03 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Fri Jun  3 04:25:03 2016
New Revision: 271637

URL: http://llvm.org/viewvc/llvm-project?rev=271637&view=rev
Log:
[include-fixer] added GNU symbols hardcoded header mapping.

Summary: [include-fixer] added GNU symbols hardcoded header mapping.

Reviewers: klimek, bkramer

Subscribers: cfe-commits, hokein

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

Modified:

clang-tools-extra/trunk/include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp?rev=271637&r1=271636&r2=271637&view=diff
==
--- 
clang-tools-extra/trunk/include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp 
(original)
+++ 
clang-tools-extra/trunk/include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp 
Fri Jun  3 04:25:03 2016
@@ -77,9 +77,6 @@ const HeaderMapCollector::HeaderMap *get
   {"include/xsavesintrin.h", ""},
   {"include/xtestintrin.h", ""},
   {"include/_G_config.h", ""},
-  {"include/alloca.h", ""},
-  {"include/asm-generic/errno-base.h", ""},
-  {"include/asm-generic/errno.h", ""},
   {"include/assert.h", ""},
   {"algorithm", ""},
   {"array", ""},
@@ -269,22 +266,15 @@ const HeaderMapCollector::HeaderMap *get
   {"vector", ""},
   {"include/complex.h", ""},
   {"include/ctype.h", ""},
-  {"include/endian.h", ""},
   {"include/errno.h", ""},
-  {"include/features.h", ""},
   {"include/fenv.h", ""},
   {"include/inttypes.h", ""},
-  {"include/libintl.h", ""},
   {"include/libio.h", ""},
   {"include/limits.h", ""},
-  {"include/linux/limits.h", ""},
   {"include/locale.h", ""},
   {"include/math.h", ""},
-  {"include/pthread.h", ""},
-  {"include/sched.h", ""},
   {"include/setjmp.h", ""},
   {"include/signal.h", ""},
-  {"include/stdc-predef.h", ""},
   {"include/stdint.h", ""},
   {"include/stdio.h", ""},
   {"include/stdlib.h", ""},
@@ -292,10 +282,7 @@ const HeaderMapCollector::HeaderMap *get
   {"include/time.h", ""},
   {"include/wchar.h", ""},
   {"include/wctype.h", ""},
-  {"bits/byteswap-16.h", ""},
-  {"bits/byteswap.h", ""},
   {"bits/cmathcalls.h", ""},
-  {"bits/endian.h", ""},
   {"bits/errno.h", ""},
   {"bits/fenv.h", ""},
   {"bits/huge_val.h", ""},
@@ -309,9 +296,6 @@ const HeaderMapCollector::HeaderMap *get
   {"bits/nan.h", ""},
   {"bits/posix1_lim.h", ""},
   {"bits/posix2_lim.h", ""},
-  {"bits/pthreadtypes.h", ""},
-  {"bits/sched.h", ""},
-  {"bits/select.h", ""},
   {"bits/setjmp.h", ""},
   {"bits/sigaction.h", ""},
   {"bits/sigcontext.h", ""},
@@ -319,24 +303,14 @@ const HeaderMapCollector::HeaderMap *get
   {"bits/signum.h", ""},
   {"bits/sigset.h", ""},
   {"bits/sigstack.h", ""},
-  {"bits/sigthread.h", ""},
   {"bits/stdio_lim.h", ""},
   {"bits/sys_errlist.h", ""},
   {"bits/time.h", ""},
   {"bits/timex.h", ""},
-  {"bits/types.h", ""},
   {"bits/typesizes.h", ""},
-  {"bits/waitflags.h", ""},
-  {"bits/waitstatus.h", ""},
   {"bits/wchar.h", ""},
   {"bits/wordsize.h", ""},
   {"bits/xopen_lim.h", ""},
-  {"gnu/stubs-64.h", ""},
-  {"sys/cdefs.h", ""},
-  {"sys/select.h", ""},
-  {"sys/sysmacros.h", ""},
-  {"sys/types.h", ""},
-  {"sys/ucontext.h", ""},
   {"include/xlocale.h", ""},
   {"bits/atomic_word.h", ""},
   {"bits/basic_file.h", ""},
@@ -352,6 +326,322 @@ const HeaderMapCollector::HeaderMap *get
   {"bits/gthr.h", ""},
   {"bits/opt_random.h", ""},
   {"bits/os_defines.h", ""},
+  // GNU C headers
+  {"include/aio.h", ""},
+  {"include/aliases.h", ""},
+  {"include/alloca.h", ""},
+  {"include/ar.h", ""},
+  {"include/argp.h", ""},
+  {"include/argz.h", ""},
+  {"include/arpa/nameser.h", ""},
+  {"include/arpa/nameser_compat.h", ""},
+  {"include/byteswap.h", ""},
+  {"include/cpio.h", ""},
+  {"include/crypt.h", ""},
+  {"include/dirent.h", ""},
+  {"include/dlfcn.h", ""},
+  {"include/elf.h", ""},
+  {"include/endian.h", ""},
+  {"include/envz.h", ""},
+  {"include/err.h", ""},
+  {"include/error.h", ""},
+  {"include/execinfo.h", ""},
+  {"include/fcntl.h", ""},
+  {"include/features.h", ""},
+  {"include/fenv.h", ""},
+  {"include/fmtmsg.h", ""},
+  {"include/fnmatch.h", ""},
+  {"include/fstab.h", ""},
+  {"include/fts.h", ""},
+  {"include/ftw.h", ""},
+  {"include/gconv.h", ""},
+  {"include/getopt.h", ""},
+  {"include/glob.h", ""},
+  {"include/grp.h", ""},
+  {"include/gshadow.h", ""},
+  {"include/iconv.h", ""},
+  {"includ

Re: [PATCH] D20902: [include-fixer] added GNU symbols hardcoded header mapping.

2016-06-03 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271637: [include-fixer] added GNU symbols hardcoded header 
mapping. (authored by ioeric).

Changed prior to commit:
  http://reviews.llvm.org/D20902?vs=59499&id=59513#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20902

Files:
  clang-tools-extra/trunk/include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp

Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp
===
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp
@@ -77,9 +77,6 @@
   {"include/xsavesintrin.h", ""},
   {"include/xtestintrin.h", ""},
   {"include/_G_config.h", ""},
-  {"include/alloca.h", ""},
-  {"include/asm-generic/errno-base.h", ""},
-  {"include/asm-generic/errno.h", ""},
   {"include/assert.h", ""},
   {"algorithm", ""},
   {"array", ""},
@@ -269,33 +266,23 @@
   {"vector", ""},
   {"include/complex.h", ""},
   {"include/ctype.h", ""},
-  {"include/endian.h", ""},
   {"include/errno.h", ""},
-  {"include/features.h", ""},
   {"include/fenv.h", ""},
   {"include/inttypes.h", ""},
-  {"include/libintl.h", ""},
   {"include/libio.h", ""},
   {"include/limits.h", ""},
-  {"include/linux/limits.h", ""},
   {"include/locale.h", ""},
   {"include/math.h", ""},
-  {"include/pthread.h", ""},
-  {"include/sched.h", ""},
   {"include/setjmp.h", ""},
   {"include/signal.h", ""},
-  {"include/stdc-predef.h", ""},
   {"include/stdint.h", ""},
   {"include/stdio.h", ""},
   {"include/stdlib.h", ""},
   {"include/string.h", ""},
   {"include/time.h", ""},
   {"include/wchar.h", ""},
   {"include/wctype.h", ""},
-  {"bits/byteswap-16.h", ""},
-  {"bits/byteswap.h", ""},
   {"bits/cmathcalls.h", ""},
-  {"bits/endian.h", ""},
   {"bits/errno.h", ""},
   {"bits/fenv.h", ""},
   {"bits/huge_val.h", ""},
@@ -309,34 +296,21 @@
   {"bits/nan.h", ""},
   {"bits/posix1_lim.h", ""},
   {"bits/posix2_lim.h", ""},
-  {"bits/pthreadtypes.h", ""},
-  {"bits/sched.h", ""},
-  {"bits/select.h", ""},
   {"bits/setjmp.h", ""},
   {"bits/sigaction.h", ""},
   {"bits/sigcontext.h", ""},
   {"bits/siginfo.h", ""},
   {"bits/signum.h", ""},
   {"bits/sigset.h", ""},
   {"bits/sigstack.h", ""},
-  {"bits/sigthread.h", ""},
   {"bits/stdio_lim.h", ""},
   {"bits/sys_errlist.h", ""},
   {"bits/time.h", ""},
   {"bits/timex.h", ""},
-  {"bits/types.h", ""},
   {"bits/typesizes.h", ""},
-  {"bits/waitflags.h", ""},
-  {"bits/waitstatus.h", ""},
   {"bits/wchar.h", ""},
   {"bits/wordsize.h", ""},
   {"bits/xopen_lim.h", ""},
-  {"gnu/stubs-64.h", ""},
-  {"sys/cdefs.h", ""},
-  {"sys/select.h", ""},
-  {"sys/sysmacros.h", ""},
-  {"sys/types.h", ""},
-  {"sys/ucontext.h", ""},
   {"include/xlocale.h", ""},
   {"bits/atomic_word.h", ""},
   {"bits/basic_file.h", ""},
@@ -352,6 +326,322 @@
   {"bits/gthr.h", ""},
   {"bits/opt_random.h", ""},
   {"bits/os_defines.h", ""},
+  // GNU C headers
+  {"include/aio.h", ""},
+  {"include/aliases.h", ""},
+  {"include/alloca.h", ""},
+  {"include/ar.h", ""},
+  {"include/argp.h", ""},
+  {"include/argz.h", ""},
+  {"include/arpa/nameser.h", ""},
+  {"include/arpa/nameser_compat.h", ""},
+  {"include/byteswap.h", ""},
+  {"include/cpio.h", ""},
+  {"include/crypt.h", ""},
+  {"include/dirent.h", ""},
+  {"include/dlfcn.h", ""},
+  {"include/elf.h", ""},
+  {"include/endian.h", ""},
+  {"include/envz.h", ""},
+  {"include/err.h", ""},
+  {"include/error.h", ""},
+  {"include/execinfo.h", ""},
+  {"include/fcntl.h", ""},
+  {"include/features.h", ""},
+  {"include/fenv.h", ""},
+  {"include/fmtmsg.h", ""},
+  {"include/fnmatch.h", ""},
+  {"include/fstab.h", ""},
+  {"include/fts.h", ""},
+  {"include/ftw.h", ""},
+  {"include/gconv.h", ""},
+  {"include/getopt.h", ""},
+  {"include/glob.h", ""},
+  {"include/grp.h", ""},
+  {"include/gshadow.h", ""},
+  {"include/iconv.h", ""},
+  {"include/ifaddrs.h", ""},
+  {"include/kdb.h", ""},
+  {"include/langinfo.h", ""},
+  {"include/libgen.h", ""},
+  {"include/libintl.h", ""},
+  {"include/link.h", ""},
+  {"include/malloc.h", ""},
+  {"include/mcheck.h", ""},
+  {"include/memory.h", ""},
+  {"include/mntent.h", ""},
+  {"include/monetary.h", ""},
+  {"include/mqueue.h", ""},
+  {"include/netdb.h", ""},
+  {"include/netinet/in.h", ""},
+  {"include/nl_types.h", ""},
+  {"include/nss.

[clang-tools-extra] r271638 - [include-fixer] fixed a wrong header mapping.

2016-06-03 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Fri Jun  3 04:33:22 2016
New Revision: 271638

URL: http://llvm.org/viewvc/llvm-project?rev=271638&view=rev
Log:
[include-fixer] fixed a wrong header mapping.

Modified:

clang-tools-extra/trunk/include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp?rev=271638&r1=271637&r2=271638&view=diff
==
--- 
clang-tools-extra/trunk/include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp 
(original)
+++ 
clang-tools-extra/trunk/include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp 
Fri Jun  3 04:33:22 2016
@@ -63,7 +63,7 @@ const HeaderMapCollector::HeaderMap *get
   {"include/stdalign.h", ""},
   {"include/stdarg.h", ""},
   {"include/stdbool.h", ""},
-  {"include/stddef.h", ""},
+  {"include/stddef.h", ""},
   {"include/stdint.h", ""},
   {"include/tbmintrin.h", ""},
   {"include/tmmintrin.h", ""},


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


Re: [PATCH] D20328: [libcxx] Externally threaded libc++ variant

2016-06-03 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 59519.
rmaprath added a comment.

Added a comment about `__static_threading` and `__dynamic_threading` header 
includes.

@EricWF: Ping (sorry).


http://reviews.llvm.org/D20328

Files:
  CMakeLists.txt
  include/__config
  include/__config_site.in
  include/__dynamic_threading
  include/__threading_support
  include/thread
  lib/CMakeLists.txt
  src/algorithm.cpp
  src/memory.cpp
  src/mutex.cpp
  src/thread.cpp
  test/CMakeLists.txt
  test/libcxx/test/config.py
  test/lit.site.cfg.in
  
test/std/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
  
test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
  
test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp
  
test/std/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
  test/std/thread/thread.threads/thread.thread.class/types.pass.cpp
  test/support/external_threads.cpp

Index: test/support/external_threads.cpp
===
--- /dev/null
+++ test/support/external_threads.cpp
@@ -0,0 +1,340 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+#ifndef SUPPORT_EXTERNAL_THREADS
+#define SUPPORT_EXTERNAL_THREADS
+
+#include <__threading_support>
+
+// Only define these symbols if using the __dynamic_threading header
+#if defined(_LIBCPP_DYNAMIC_THREADING)
+
+#include 
+#include 
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+/* In the pthread-based (or statically-threaded) libc++ variant, pthread
+   primitives (like pthread_mutex_t) become part of the internal states of the
+   corresponding C++ constructs (e.g. C++ mutex class holds an internal
+   pthread_mutex_t object). In contrast, in the externally-threaded libc++
+   variant, C++ constructs hold (opaque) pointers to the underlying platform-
+   defined threading primitives. The following macros are used to convert the
+   opaque pointer types held within the C++ constructs and cast them as pointers
+   to the appropriate platform-defined thread primitive type (in this case,
+   pthread types again).
+*/
+#define AS_PTHREAD_MUTPTR(x) reinterpret_cast(x)
+#define AS_PTHREAD_CONDPTR(x) reinterpret_cast(x)
+#define AS_PTHREAD_TPTR(x) reinterpret_cast(x)
+#define AS_PTHREAD_KPTR(x) reinterpret_cast(x)
+
+//-- Mutex --//
+
+/* This method is invoked from within the std::recursive_mutex constructor, as
+   such, it does not need to be thread-safe when initializing the *__m pointer.
+*/
+int __libcpp_recursive_mutex_init(__libcpp_mutex_t* __m)
+{
+// Populate the internal opaque pointer *__m
+pthread_mutex_t *mut = (pthread_mutex_t*) malloc(sizeof(pthread_mutex_t));
+if (mut == nullptr)
+return -1;
+*__m = reinterpret_cast<__libcpp_mutex_t> (mut);
+
+// Initialize the allocated pthread_mutex_t object as a recursive mutex
+pthread_mutexattr_t attr;
+int __ec = pthread_mutexattr_init(&attr);
+if (__ec)
+  goto fail;
+
+__ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+if (__ec)
+{
+pthread_mutexattr_destroy(&attr);
+goto fail;
+}
+
+__ec = pthread_mutex_init(AS_PTHREAD_MUTPTR(*__m), &attr);
+if (__ec)
+{
+pthread_mutexattr_destroy(&attr);
+goto fail;
+}
+
+__ec = pthread_mutexattr_destroy(&attr);
+if (__ec)
+{
+pthread_mutex_destroy(AS_PTHREAD_MUTPTR(*__m));
+goto fail;
+}
+
+return 0;
+
+fail:
+free(*__m);
+return __ec;
+}
+
+/* C++11 standard requires mutex and condition_variable constructors to be
+   constexpr qualifying. This prohibits any prospects of calling a runtime
+   initialization routine from within mutex / condition_varialbe constructors.
+   For this reason, the external thread API must adopt an initialize-on-first-
+   use policy for mutexes and condition variables. With this strategy, we need
+   to be especially careful when initializing the internal opaque pointer *__m,
+   as multiple threads could attempt to lock the same mutex at once. In the
+   following routine, I've used a plain pthread mutex to make this initialization
+   thread-safe. It's also possible to use atomic compare-exchange builtins (where
+   available) to achieve the same goal.
+*/
+pthread_mutex_t mutex_init_access = PTHREAD_MUTEX_INITIALIZER;
+
+int mutex_safe_init(volatile __libcpp_mutex_t* __m) {
+pthread_mutex_lock(&mutex_init_access);
+if (*__m == nullptr) {
+pthread_mutex_t *mut = (pthread_mutex_t*) malloc(sizeof(pthread_mutex_t));
+

r271647 - [mips] Slightly simplify MipsTargetInfo::setDataLayout(). NFC.

2016-06-03 Thread Daniel Sanders via cfe-commits
Author: dsanders
Date: Fri Jun  3 05:11:01 2016
New Revision: 271647

URL: http://llvm.org/viewvc/llvm-project?rev=271647&view=rev
Log:
[mips] Slightly simplify MipsTargetInfo::setDataLayout(). NFC.

Summary:

Reviewers: atanasyan

Subscribers: atanasyan, cfe-commits

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

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

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=271647&r1=271646&r2=271647&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Jun  3 05:11:01 2016
@@ -7009,25 +7009,21 @@ public:
 
 class MipsTargetInfo : public TargetInfo {
   void setDataLayout() {
-if (BigEndian) {
-  if (ABI == "o32")
-resetDataLayout("E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64");
-  else if (ABI == "n32")
-resetDataLayout("E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128");
-  else if (ABI == "n64")
-resetDataLayout("E-m:m-i8:8:32-i16:16:32-i64:64-n32:64-S128");
-  else
-llvm_unreachable("Invalid ABI");
-} else {
-  if (ABI == "o32")
-resetDataLayout("e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64");
-  else if (ABI == "n32")
-resetDataLayout("e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128");
-  else if (ABI == "n64")
-resetDataLayout("e-m:m-i8:8:32-i16:16:32-i64:64-n32:64-S128");
-  else
-llvm_unreachable("Invalid ABI");
-}
+StringRef Layout;
+
+if (ABI == "o32")
+  Layout = "m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64";
+else if (ABI == "n32")
+  Layout = "m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128";
+else if (ABI == "n64")
+  Layout = "m:m-i8:8:32-i16:16:32-i64:64-n32:64-S128";
+else
+  llvm_unreachable("Invalid ABI");
+
+if (BigEndian)
+  resetDataLayout(("E-" + Layout).str());
+else
+  resetDataLayout(("e-" + Layout).str());
   }
 
 


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


Re: [PATCH] D20950: [include-fixer] Don't add missing header if the unindentified symbol isn't from the main file.

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

LG. It's a bit sad but I guess the cases where that legitimately can happen due 
to template weirdness are far outweighed by the cases where we have a non-self 
contained header. The cases I've been thinking of are stuff like:

header.h:

  template 
  class Foo {
T t;
  };

test.cc:

  #include "header.h"
  
  class Bar;
  Foo f;

Here we'd have to include the header for Bar into test.cc, but figuring that 
out is hard. Ignoring all of that for now is fine.


http://reviews.llvm.org/D20950



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


[clang-tools-extra] r271660 - [include-fixer] Don't add missing header if the unindentified symbol isn't from the main file.

2016-06-03 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Jun  3 06:26:02 2016
New Revision: 271660

URL: http://llvm.org/viewvc/llvm-project?rev=271660&view=rev
Log:
[include-fixer] Don't add missing header if the unindentified symbol isn't from 
the main file.

Summary:
The further solution is to add the missing header to the file where the
symbol comes from.

Reviewers: bkramer

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.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=271660&r1=271659&r2=271660&view=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Fri Jun  3 06:26:02 
2016
@@ -86,6 +86,29 @@ public:
 if (getCompilerInstance().getSema().isSFINAEContext())
   return clang::TypoCorrection();
 
+// We currently ignore the unidentified symbol which is not from the
+// main file.
+//
+// However, this is not always true due to templates in a non-self 
contained
+// header, consider the case:
+//
+//   // header.h
+//   template 
+//   class Foo {
+// T t;
+//   };
+//
+//   // test.cc
+//   // We need to add  in test.cc instead of header.h.
+//   class Bar;
+//   Foo foo;
+//
+// FIXME: Add the missing header to the header file where the symbol comes
+// from.
+if (!getCompilerInstance().getSourceManager().isWrittenInMainFile(
+Typo.getLoc()))
+  return clang::TypoCorrection();
+
 std::string TypoScopeString;
 if (S) {
   // FIXME: Currently we only use namespace contexts. Use other context

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=271660&r1=271659&r2=271660&view=diff
==
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Fri 
Jun  3 06:26:02 2016
@@ -44,6 +44,8 @@ static bool runOnCode(tooling::ToolActio
   llvm::MemoryBuffer::getMemBuffer("\n"));
   InMemoryFileSystem->addFile("dir/otherdir/qux.h", 0,
   llvm::MemoryBuffer::getMemBuffer("\n"));
+  InMemoryFileSystem->addFile("header.h", 0,
+  llvm::MemoryBuffer::getMemBuffer("bar b;"));
   return Invocation.run();
 }
 
@@ -186,6 +188,11 @@ TEST(IncludeFixer, EnumConstantSymbols)
 runIncludeFixer("int test = a::b::Green;\n"));
 }
 
+TEST(IncludeFixer, IgnoreSymbolFromHeader) {
+  std::string Code = "#include \"header.h\"";
+  EXPECT_EQ(Code, runIncludeFixer(Code));
+}
+
 // FIXME: add test cases for inserting and sorting multiple headers when
 // include-fixer supports multiple headers insertion.
 TEST(IncludeFixer, InsertAndSortSingleHeader) {


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


Re: [PATCH] D20950: [include-fixer] Don't add missing header if the unindentified symbol isn't from the main file.

2016-06-03 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271660: [include-fixer] Don't add missing header if the 
unindentified symbol isn't… (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D20950?vs=59496&id=59529#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20950

Files:
  clang-tools-extra/trunk/include-fixer/IncludeFixer.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
@@ -44,6 +44,8 @@
   llvm::MemoryBuffer::getMemBuffer("\n"));
   InMemoryFileSystem->addFile("dir/otherdir/qux.h", 0,
   llvm::MemoryBuffer::getMemBuffer("\n"));
+  InMemoryFileSystem->addFile("header.h", 0,
+  llvm::MemoryBuffer::getMemBuffer("bar b;"));
   return Invocation.run();
 }
 
@@ -186,6 +188,11 @@
 runIncludeFixer("int test = a::b::Green;\n"));
 }
 
+TEST(IncludeFixer, IgnoreSymbolFromHeader) {
+  std::string Code = "#include \"header.h\"";
+  EXPECT_EQ(Code, runIncludeFixer(Code));
+}
+
 // FIXME: add test cases for inserting and sorting multiple headers when
 // include-fixer supports multiple headers insertion.
 TEST(IncludeFixer, InsertAndSortSingleHeader) {
Index: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
===
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
@@ -86,6 +86,29 @@
 if (getCompilerInstance().getSema().isSFINAEContext())
   return clang::TypoCorrection();
 
+// We currently ignore the unidentified symbol which is not from the
+// main file.
+//
+// However, this is not always true due to templates in a non-self 
contained
+// header, consider the case:
+//
+//   // header.h
+//   template 
+//   class Foo {
+// T t;
+//   };
+//
+//   // test.cc
+//   // We need to add  in test.cc instead of header.h.
+//   class Bar;
+//   Foo foo;
+//
+// FIXME: Add the missing header to the header file where the symbol comes
+// from.
+if (!getCompilerInstance().getSourceManager().isWrittenInMainFile(
+Typo.getLoc()))
+  return clang::TypoCorrection();
+
 std::string TypoScopeString;
 if (S) {
   // FIXME: Currently we only use namespace contexts. Use other context


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
@@ -44,6 +44,8 @@
   llvm::MemoryBuffer::getMemBuffer("\n"));
   InMemoryFileSystem->addFile("dir/otherdir/qux.h", 0,
   llvm::MemoryBuffer::getMemBuffer("\n"));
+  InMemoryFileSystem->addFile("header.h", 0,
+  llvm::MemoryBuffer::getMemBuffer("bar b;"));
   return Invocation.run();
 }
 
@@ -186,6 +188,11 @@
 runIncludeFixer("int test = a::b::Green;\n"));
 }
 
+TEST(IncludeFixer, IgnoreSymbolFromHeader) {
+  std::string Code = "#include \"header.h\"";
+  EXPECT_EQ(Code, runIncludeFixer(Code));
+}
+
 // FIXME: add test cases for inserting and sorting multiple headers when
 // include-fixer supports multiple headers insertion.
 TEST(IncludeFixer, InsertAndSortSingleHeader) {
Index: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
===
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
@@ -86,6 +86,29 @@
 if (getCompilerInstance().getSema().isSFINAEContext())
   return clang::TypoCorrection();
 
+// We currently ignore the unidentified symbol which is not from the
+// main file.
+//
+// However, this is not always true due to templates in a non-self contained
+// header, consider the case:
+//
+//   // header.h
+//   template 
+//   class Foo {
+// T t;
+//   };
+//
+//   // test.cc
+//   // We need to add  in test.cc instead of header.h.
+//   class Bar;
+//   Foo foo;
+//
+// FIXME: Add the missing header to the header file where the symbol comes
+// from.
+if (!getCompilerInstance().getSourceManager().isWrittenInMainFile(
+Typo.getLoc()))
+  return clang::TypoCorrection();
+
 std::string TypoScopeString;
 if (S) {
   // FIXME: Currently we only use namespace contexts. Use other context
_

Re: [PATCH] D16989: Change interpretation of function definition in friend declaration of template class.

2016-06-03 Thread Serge Pavlov via cfe-commits
sepavloff updated this revision to Diff 59532.
sepavloff added a comment.

Fixed test for friend functions.


http://reviews.llvm.org/D16989

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/PR25848.cpp
  test/SemaCXX/friend2.cpp

Index: test/SemaCXX/friend2.cpp
===
--- /dev/null
+++ test/SemaCXX/friend2.cpp
@@ -0,0 +1,145 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+// If a friend function is defined in several non-template classes,
+// it is an error.
+
+void func1(int);
+struct C1a {
+  friend void func1(int) {}  // expected-note{{previous definition is here}}
+};
+struct C1b {
+  friend void func1(int) {}  // expected-error{{redefinition of 'func1'}}
+};
+
+
+// If a friend function is defined in both non-template and template
+// classes it is an error only if the template is instantiated.
+
+void func2(int);
+struct C2a {
+  friend void func2(int) {}
+};
+template struct C2b {
+  friend void func2(int) {}
+};
+
+void func3(int);
+struct C3a {
+  friend void func3(int) {}  // expected-note{{previous definition is here}}
+};
+template struct C3b {
+  friend void func3(int) {}  // expected-error{{redefinition of 'func3'}}
+};
+C3b c3;  // expected-note{{in instantiation of template class 'C3b' requested here}}
+
+
+// If a friend function is defined in several template classes it is an error
+// only if several templates are instantiated.
+
+void func4(int);
+template struct C4a {
+  friend void func4(int) {}
+};
+template struct C4b {
+  friend void func4(int) {}
+};
+
+
+void func5(int);
+template struct C5a {
+  friend void func5(int) {}
+};
+template struct C5b {
+  friend void func5(int) {}
+};
+C5a c5a;
+
+void func6(int);
+template struct C6a {
+  friend void func6(int) {}  // expected-note{{previous definition is here}}
+};
+template struct C6b {
+  friend void func6(int) {}  // expected-error{{redefinition of 'func6'}}
+};
+C6a c6a;
+C6b c6b;  // expected-note{{in instantiation of template class 'C6b' requested here}}
+
+void func7(int);
+template struct C7 {
+  friend void func7(int) {}  // expected-error{{redefinition of 'func7'}}
+ // expected-note@-1{{previous definition is here}}
+};
+C7 c7a;
+C7 c7b;  // expected-note{{in instantiation of template class 'C7' requested here}}
+
+
+// Even if clases are not instantiated and hence friend functions defined in them are not
+// available, their declarations can be checked.
+
+void func8(int);  // expected-note{{previous declaration is here}}
+template struct C8a {
+  friend long func8(int);  // expected-error{{functions that differ only in their return type cannot be overloaded}}
+};
+
+void func9(int);  // expected-note{{previous declaration is here}}
+template struct C9a {
+  friend int func9(int);  // expected-error{{functions that differ only in their return type cannot be overloaded}}
+};
+
+void func10(int);  // expected-note{{previous declaration is here}}
+template struct C10a {
+  friend int func10(int);  // expected-error{{functions that differ only in their return type cannot be overloaded}}
+};
+
+
+namespace pr22307 {
+
+struct t {
+  friend int leak(t);
+};
+
+template
+struct m {
+  friend int leak(t) { return sizeof(v); }  // expected-error{{redefinition of 'leak'}} expected-note{{previous definition is here}}
+};
+
+template struct m;
+template struct m;  // expected-note{{in instantiation of template class 'pr22307::m' requested here}}
+
+int main() {
+  leak(t());
+}
+
+}
+
+namespace pr17923 {
+
+void f(unsigned long long);
+
+template struct X {
+  friend void f(unsigned long long) {
+ T t;
+  }
+};
+
+int main() { f(1234); }
+
+}
+
+namespace pr17923a {
+
+int get();
+
+template< int value >
+class set {
+  friend int get()
+{ return value; } // return 0; is OK
+};
+
+template class set< 5 >;
+
+int main() {
+  get();
+}
+
+}
Index: test/SemaCXX/PR25848.cpp
===
--- /dev/null
+++ test/SemaCXX/PR25848.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A;
+
+inline int g();  // expected-warning{{inline function 'g' is not defined}}
+
+template
+struct R {
+  friend int g() {
+return M;
+  }
+};
+
+void m() {
+  g();  // expected-note{{used here}}
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -8563,6 +8563,36 @@
   return NewFD;
 }
 
+/// \brief Checks if the new declaration declared in dependent context must be
+/// put in the same redeclaration chain as the specified declaration.
+///
+/// \param D Declaration that is checked.
+/// \param PrevDecl Previous declaration found with proper lookup method for the
+/// same declaration name.
+/// \returns True if D must be added to the redeclaration chain which PrevDecl
+///  belongs to.
+///
+bool Sema::shouldLinkDepend

Re: [PATCH] D20898: [clang-format] skip empty lines and comments in the top of the code when inserting new headers.

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

Looks good.


http://reviews.llvm.org/D20898



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


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

2016-06-03 Thread Clement Courbet via cfe-commits
courbet added a comment.

That could work :) I'm not sure my commit history is considered a "track record 
of submitting high quality patches" but I'll give it a try.


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] D20133: [OpenCL] Fix __builtin_astype for vec3 types.

2016-06-03 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: lib/CodeGen/CGExprScalar.cpp:3394
@@ +3393,3 @@
+  if (NumElementsDst == 4)
+Args.push_back(llvm::UndefValue::get(CGF.Int32Ty));
+  llvm::Constant *Mask = llvm::ConstantVector::get(Args);

should this be 3 unstead of undef?


Comment at: lib/CodeGen/CGExprScalar.cpp:3428
@@ -3429,3 +3427,3 @@
   }
 
   return Builder.CreateBitCast(Src, DstTy, "astype");

I see. Not related to your change, but I was just wondering if it would be 
better to change this to a Clang builtin with a custom check at some point. It 
would be easier to understand and we can avoid all this parsing/AST handling 
complications.


Comment at: test/CodeGenOpenCL/as_type.cl:8
@@ +7,3 @@
+
+//CHECK: define spir_func <3 x i8> @f1(<4 x i8> %[[x:.*]])
+//CHECK: %[[astype:.*]] = shufflevector <4 x i8> %[[x]], <4 x i8> undef, <3 x 
i32> 

So what happens if the number of bytes don't match?


Comment at: test/CodeGenOpenCL/as_type.cl:46
@@ +45,3 @@
+//CHECK: define spir_func i32 @f6(<4 x i8> %[[x:.*]])
+//CHECK: %[[astype]] = bitcast <4 x i8> %[[x]] to i32
+//CHECK: ret i32 %[[astype]]

Would it make sense to check that shufflevector is not generated?


Comment at: test/CodeGenOpenCL/as_type.cl:53
@@ +52,3 @@
+//CHECK: define spir_func <3 x i8> @f7(<3 x i8> %[[x:.*]])
+//CHECK: ret <3 x i8> %[[x]]
+char3 f7(char3 x) {

Could we add CHECK-NOT bitcast here?


http://reviews.llvm.org/D20133



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


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

2016-06-03 Thread Piotr Padlewski via cfe-commits
Just ask Chris for the access :)
03.06.2016 11:26 AM "Clement Courbet via cfe-commits" <
cfe-commits@lists.llvm.org> napisał(a):

> courbet added a comment.
>
> @sbenza @aaron.ballman I don't have write access. Can one of you submit
> this on my behalf ? Thanks !
>
>
> http://reviews.llvm.org/D19324
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2016-06-03 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin added a comment.

In http://reviews.llvm.org/D18035#447473, @hfinkel wrote:

> FYI: There is now a specification, see: 
> http://sourcerytools.com/pipermail/cxx-abi-dev/2016-June/002919.html


For the records, this patch implements GCC 6 abi_tag semantic and to the best 
of my knowledge mangles everything same as GCC 6. To support GCC 5 semantic 
Clang will need -fabi-version command line flag to support multiple ABI 
versions. But as far as I can see, Richard is not going to approve this patch 
so it seems to be dead end.


http://reviews.llvm.org/D18035



___
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-06-03 Thread Hal Finkel via cfe-commits
hfinkel added a comment.

In http://reviews.llvm.org/D18035#448002, @DmitryPolukhin wrote:

> In http://reviews.llvm.org/D18035#447473, @hfinkel wrote:
>
> > FYI: There is now a specification, see: 
> > http://sourcerytools.com/pipermail/cxx-abi-dev/2016-June/002919.html
>
>
>


...

> But as far as I can see, Richard is not going to approve this patch so it 
> seems to be dead end.


At the last C++ committee meeting, I observed Richard reaching out to the 
Redhat folks to ask for a specification so that we could make sure we 
implemented this feature properly (i.e. as intended). Based on that, I'm fairly 
certain he's interested in seeing a solution here.  We just received the first 
draft of that specification yesterday. As far as I can tell, Richard also is 
very busy, like many of us, and it can take time to get to things, even 
important things. I understand why this is frustrating, but please don't become 
discouraged.

Richard, can you comment on whether you still want the refactoring you 
suggested in light of Dmitry's responses?


http://reviews.llvm.org/D18035



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


Re: [PATCH] D20857: [clang-tidy] Add modernize-explicit-operator-bool check.

2016-06-03 Thread Murray Cumming via cfe-commits
murrayc updated this revision to Diff 59537.
murrayc added a comment.

Combined into one check. Also specifies C++11 for the test.


http://reviews.llvm.org/D20857

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ExplicitOperatorBoolCheck.cpp
  clang-tidy/modernize/ExplicitOperatorBoolCheck.h
  clang-tidy/modernize/ModernizeTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-explicit-operator-bool.rst
  test/clang-tidy/modernize-explicit-operator-bool-void-pointer.cpp
  test/clang-tidy/modernize-explicit-operator-bool.cpp

Index: test/clang-tidy/modernize-explicit-operator-bool.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-explicit-operator-bool.cpp
@@ -0,0 +1,19 @@
+// RUN: %check_clang_tidy %s modernize-explicit-operator-bool %t -- -- -std=c++11
+
+// This should trigger the check:
+class SomethingBad {
+  operator bool() const {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator bool declaration is not explicit [modernize-explicit-operator-bool]
+return something != 0;
+  }
+
+  int something = 0;
+};
+
+class SomethingGood {
+  explicit operator bool() const {
+return something != 0;
+  }
+
+  int something = 0;
+};
Index: test/clang-tidy/modernize-explicit-operator-bool-void-pointer.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-explicit-operator-bool-void-pointer.cpp
@@ -0,0 +1,46 @@
+// RUN: %check_clang_tidy %s modernize-explicit-operator-bool %t -- -- -std=c++11
+
+// This should trigger the check:
+class SomethingBad {
+  operator const void *() const {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: implicit operator const void* declaration should probably be explicit operator bool [modernize-explicit-operator-bool]
+return reinterpret_cast(something != 0);
+  }
+
+  int something = 0;
+};
+
+class SomethingGood {
+  //Note: Use modernize-explicit-operator-bool to check for implicit operator bool.
+  explicit operator bool() const {
+return something != 0;
+  }
+
+  int something = 0;
+};
+
+class SomethingGoodExplicitConstVoidPtr {
+  explicit operator const void *() const {
+return &something;
+  }
+
+  const int something = 0;
+};
+
+class SomethingGoodExplicitNonConstVoidPtr {
+  explicit operator void *() {
+return &something;
+  }
+
+  int something = 0;
+};
+
+class SomethingGoodNonConstVoidPtr {
+  // A non-const void* is unlikely to to be meant as operator bool before C++11
+  // let us use explicit.
+  operator void *() {
+return &something;
+  }
+
+  int something = 0;
+};
Index: docs/clang-tidy/checks/modernize-explicit-operator-bool.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/modernize-explicit-operator-bool.rst
@@ -0,0 +1,28 @@
+.. title:: clang-tidy - modernize-explicit-operator-bool
+
+modernize-explicit-operator-bool
+
+
+This check finds implicit ``operator bool`` overloads and inserts the
+``explicit`` keyword, which is available since C++11.
+
+Without the ``explicit`` keyword, the implicit ``bool`` overload can allow
+objects to be compared accidentally. For instance, even when objects `a` and
+`b` have no ``operator ==`` overloads, an implicit ``operator bool`` would allow
+`a == b` to compile because both `a` and `b` can be implictly converted to
+``bool``.
+
+This check also finds implicit ``operator const void*`` overloads. These were
+often used before C++11 to avoid implicit conversions to ``bool`` when providing
+an ``operator bool`` overload.
+
+To disable the check for ``operator const void*`` overloads, you may set
+The :option:`WarnOnOperatorVoidPointer` option to 1.
+
+.. code-block:: c++
+
+  operator bool () const;
+
+  // becomes
+
+  explicit operator bool () const;
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -93,6 +93,7 @@
misc-virtual-near-miss
modernize-avoid-bind
modernize-deprecated-headers
+   modernize-explicit-operator-bool
modernize-loop-convert
modernize-make-shared
modernize-make-unique
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -190,6 +190,13 @@
 
   Replaces C standard library headers with their C++ alternatives.
 
+- New `modernize-explicit-operator-bool
+  `_ check
+
+  Adds the ``explicit`` keyword to ``operator bool`` overloads.
+  Also finds ``operator const void*`` overloads, which should often be
+  ``explicit operator bool`` overloads.
+
 - New `modernize-make-shared
   `

Re: [PATCH] D20732: Don't use static variables in LambdaCapture

2016-06-03 Thread John Brawn via cfe-commits
john.brawn added a comment.

Ping


Repository:
  rL LLVM

http://reviews.llvm.org/D20732



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


r271664 - [clang-format] skip empty lines and comments in the top of the code when inserting new headers.

2016-06-03 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Fri Jun  3 07:52:59 2016
New Revision: 271664

URL: http://llvm.org/viewvc/llvm-project?rev=271664&view=rev
Log:
[clang-format] skip empty lines and comments in the top of the code when 
inserting new headers.

Summary:
[clang-format] skip empty lines and comments in the top of the code when 
inserting new headers.

Pair-programmed with @hokein

Reviewers: djasper

Subscribers: ioeric, cfe-commits, hokein, klimek

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

Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/CleanupTest.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=271664&r1=271663&r2=271664&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Fri Jun  3 07:52:59 2016
@@ -1469,6 +1469,20 @@ fixCppIncludeInsertions(StringRef Code,
   StringRef FileName = Replaces.begin()->getFilePath();
   IncludeCategoryManager Categories(Style, FileName);
 
+  std::unique_ptr Env =
+  Environment::CreateVirtualEnvironment(Code, FileName, /*Ranges=*/{});
+  const SourceManager &SourceMgr = Env->getSourceManager();
+  Lexer Lex(Env->getFileID(), SourceMgr.getBuffer(Env->getFileID()), SourceMgr,
+getFormattingLangOpts(Style));
+  Token Tok;
+  // All new headers should be inserted after this offset.
+  int MinInsertOffset = Code.size();
+  while (!Lex.LexFromRawLexer(Tok)) {
+if (Tok.isNot(tok::comment)) {
+  MinInsertOffset = SourceMgr.getFileOffset(Tok.getLocation());
+  break;
+}
+  }
   // Record the offset of the end of the last include in each category.
   std::map CategoryEndOffsets;
   // All possible priorities.
@@ -1477,10 +1491,11 @@ fixCppIncludeInsertions(StringRef Code,
   for (const auto &Category : Style.IncludeCategories)
 Priorities.insert(Category.Priority);
   int FirstIncludeOffset = -1;
-  int Offset = 0;
-  int AfterHeaderGuard = 0;
+  bool HeaderGuardFound = false;
+  StringRef TrimmedCode = Code.drop_front(MinInsertOffset);
   SmallVector Lines;
-  Code.split(Lines, '\n');
+  TrimmedCode.split(Lines, '\n');
+  int Offset = MinInsertOffset;
   for (auto Line : Lines) {
 if (IncludeRegex.match(Line, &Matches)) {
   StringRef IncludeName = Matches[2];
@@ -1492,22 +1507,22 @@ fixCppIncludeInsertions(StringRef Code,
 }
 Offset += Line.size() + 1;
 // FIXME: make header guard matching stricter, e.g. consider #ifndef.
-if (AfterHeaderGuard == 0 && DefineRegex.match(Line))
-  AfterHeaderGuard = Offset;
+if (!HeaderGuardFound && DefineRegex.match(Line)) {
+  HeaderGuardFound = true;
+  MinInsertOffset = Offset;
+}
   }
 
   // Populate CategoryEndOfssets:
   // - Ensure that CategoryEndOffset[Highest] is always populated.
   // - If CategoryEndOffset[Priority] isn't set, use the next higher value that
   //   is set, up to CategoryEndOffset[Highest].
-  // FIXME: skip comment section in the beginning of the code if there is no
-  // existing #include and #define.
   auto Highest = Priorities.begin();
   if (CategoryEndOffsets.find(*Highest) == CategoryEndOffsets.end()) {
 if (FirstIncludeOffset >= 0)
   CategoryEndOffsets[*Highest] = FirstIncludeOffset;
 else
-  CategoryEndOffsets[*Highest] = AfterHeaderGuard;
+  CategoryEndOffsets[*Highest] = MinInsertOffset;
   }
   // By this point, CategoryEndOffset[Highest] is always set appropriately:
   //  - to an appropriate location before/after existing #includes, or

Modified: cfe/trunk/unittests/Format/CleanupTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/CleanupTest.cpp?rev=271664&r1=271663&r2=271664&view=diff
==
--- cfe/trunk/unittests/Format/CleanupTest.cpp (original)
+++ cfe/trunk/unittests/Format/CleanupTest.cpp Fri Jun  3 07:52:59 2016
@@ -465,13 +465,13 @@ TEST_F(CleanUpReplacementsTest, InsertMu
 
 TEST_F(CleanUpReplacementsTest, InsertMultipleNewHeadersAndSortLLVM) {
   std::string Code = "\nint x;";
-  std::string Expected = "#include \"fix.h\"\n"
+  std::string Expected = "\n#include \"fix.h\"\n"
  "#include \"a.h\"\n"
  "#include \"b.h\"\n"
  "#include \"c.h\"\n"
  "#include \n"
  "#include \n"
- "\nint x;";
+ "int x;";
   tooling::Replacements Replaces = {createInsertion("#include \"a.h\""),
 createInsertion("#include \"c.h\""),
 createInsertion("#include \"b.h\""),
@@ -483,13 +483,13 @@ TEST_F(CleanUpReplacementsTest, InsertMu
 
 TEST_F(CleanUpReplacementsTest, InsertMultipleNewHeadersAndSortGoogle) {
   std::string Code = "\nint x;";
-  std::string Expected = 

Re: [PATCH] D20898: [clang-format] skip empty lines and comments in the top of the code when inserting new headers.

2016-06-03 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271664: [clang-format] skip empty lines and comments in the 
top of the code when… (authored by ioeric).

Changed prior to commit:
  http://reviews.llvm.org/D20898?vs=59511&id=59538#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20898

Files:
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/unittests/Format/CleanupTest.cpp

Index: cfe/trunk/unittests/Format/CleanupTest.cpp
===
--- cfe/trunk/unittests/Format/CleanupTest.cpp
+++ cfe/trunk/unittests/Format/CleanupTest.cpp
@@ -465,13 +465,13 @@
 
 TEST_F(CleanUpReplacementsTest, InsertMultipleNewHeadersAndSortLLVM) {
   std::string Code = "\nint x;";
-  std::string Expected = "#include \"fix.h\"\n"
+  std::string Expected = "\n#include \"fix.h\"\n"
  "#include \"a.h\"\n"
  "#include \"b.h\"\n"
  "#include \"c.h\"\n"
  "#include \n"
  "#include \n"
- "\nint x;";
+ "int x;";
   tooling::Replacements Replaces = {createInsertion("#include \"a.h\""),
 createInsertion("#include \"c.h\""),
 createInsertion("#include \"b.h\""),
@@ -483,13 +483,13 @@
 
 TEST_F(CleanUpReplacementsTest, InsertMultipleNewHeadersAndSortGoogle) {
   std::string Code = "\nint x;";
-  std::string Expected = "#include \"fix.h\"\n"
+  std::string Expected = "\n#include \"fix.h\"\n"
  "#include \n"
  "#include \n"
  "#include \"a.h\"\n"
  "#include \"b.h\"\n"
  "#include \"c.h\"\n"
- "\nint x;";
+ "int x;";
   tooling::Replacements Replaces = {createInsertion("#include \"a.h\""),
 createInsertion("#include \"c.h\""),
 createInsertion("#include \"b.h\""),
@@ -502,21 +502,22 @@
 
 TEST_F(CleanUpReplacementsTest, FormatCorrectLineWhenHeadersAreInserted) {
   std::string Code = "\n"
+ "int x;\n"
  "inta;\n"
  "inta;\n"
  "inta;";
 
-  std::string Expected = "#include \"x.h\"\n"
+  std::string Expected = "\n#include \"x.h\"\n"
  "#include \"y.h\"\n"
  "#include \"clang/x/x.h\"\n"
  "#include \n"
  "#include \n"
- "\n"
+ "int x;\n"
  "inta;\n"
  "int b;\n"
  "inta;";
   tooling::Replacements Replaces = {
-  createReplacement(getOffset(Code, 3, 8), 1, "b"),
+  createReplacement(getOffset(Code, 4, 8), 1, "b"),
   createInsertion("#include "),
   createInsertion("#include "),
   createInsertion("#include \"clang/x/x.h\""),
@@ -537,6 +538,76 @@
   EXPECT_EQ(Expected, formatAndApply(Code, Replaces));
 }
 
+TEST_F(CleanUpReplacementsTest, SkippedTopComment) {
+  std::string Code = "// comment\n"
+ "\n"
+ "   // comment\n";
+  std::string Expected = "// comment\n"
+ "\n"
+ "   // comment\n"
+ "#include \n";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, SkippedMixedComments) {
+  std::string Code = "// comment\n"
+ "// comment \\\n"
+ " comment continued\n"
+ "/*\n"
+ "* comment\n"
+ "*/\n";
+  std::string Expected = "// comment\n"
+ "// comment \\\n"
+ " comment continued\n"
+ "/*\n"
+ "* comment\n"
+ "*/\n"
+ "#include \n";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, MultipleBlockCommentsInOneLine) {
+  std::string Code = "/*\n"
+ "* comment\n"
+ "*/ /* comment\n"
+ "*/\n"
+ "\n\n"
+ "/* c1 */ /*c2 */\n";
+  std::string Expected = "/*\n"
+ "* comment\n"
+ "*/ /* comment\n"
+ "*/\n"
+ "\n\n"
+ "/* c1 */ /*c2 */\n"
+ "#include \n";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+T

Re: [PATCH] D20858: [clang-format] make header guard identification stricter in header insertion.

2016-06-03 Thread Eric Liu via cfe-commits
ioeric abandoned this revision.
ioeric added a comment.

Abandon this patch in favor of http://reviews.llvm.org/D20959


http://reviews.llvm.org/D20858



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


Re: [PATCH] D20933: Preallocate ExplodedNode hash table

2016-06-03 Thread Ben Craig via cfe-commits
bcraig added a comment.

In http://reviews.llvm.org/D20933#447608, @zaks.anna wrote:

> Does FoldingSet already have reserve? (I do not see it.)


The reserve call would be new.  I'm attempting to add it in this llvm review: 
http://reviews.llvm.org/D20930

> My understanding is that you propose to allocate all the nodes that would be 
> required to store the maximum number of nodes we allow, lowering the malloc 
> traffic. The current implementation just doubles the size. Is this correct?

> 

> Maybe we should just set a higher initial size, instead of going all the way 
> to the max?


The implementation of FoldingSet has a vector of bucket pointers.  Reserve 
preallocates that vector of bucket pointers to the correct size to avoid 
rehashing.  The allocation of the nodes themselves hasn't changed.  With a 
value of 150,000 steps (the default?), reserve will preallocate 131072 bucket 
pointers (this gives a node capacity of double that).  On a 64-bit system, 
that's a 1 MB allocation.

Note that the biggest savings are in avoiding the last rehashing.  If we shrink 
the initial size, but still rehash frequently, we'll lose a lot of the benefits.


http://reviews.llvm.org/D20933



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


[PATCH] D20959: [clang-format] make header guard identification stricter (with Lexer).

2016-06-03 Thread Eric Liu via cfe-commits
ioeric created this revision.
ioeric added a reviewer: djasper.
ioeric added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

make header guard identification stricter with Lexer.

http://reviews.llvm.org/D20959

Files:
  lib/Format/Format.cpp
  unittests/Format/CleanupTest.cpp

Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -608,6 +608,70 @@
   EXPECT_EQ(Expected, apply(Code, Replaces));
 }
 
+TEST_F(CleanUpReplacementsTest, FakeHeaderGuardIfDef) {
+  std::string Code = "// comment \n"
+ "#ifdef X\n"
+ "#define X\n";
+  std::string Expected = "// comment \n"
+ "#include \n"
+ "#ifdef X\n"
+ "#define X\n";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, RealHeaderGuardAfterComments) {
+  std::string Code = "// comment \n"
+ "#ifndef X\n"
+ "#define X\n"
+ "int x;\n"
+ "#define Y 1\n";
+  std::string Expected = "// comment \n"
+ "#ifndef X\n"
+ "#define X\n"
+ "#include \n"
+ "int x;\n"
+ "#define Y 1\n";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, IfNDefWithNoDefine) {
+  std::string Code = "// comment \n"
+ "#ifndef X\n"
+ "int x;\n"
+ "#define Y 1\n";
+  std::string Expected = "// comment \n"
+ "#include \n"
+ "#ifndef X\n"
+ "int x;\n"
+ "#define Y 1\n";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, HeaderGuardWithComment) {
+  std::string Code = "// comment \n"
+ "#ifndef X // comment\n"
+ "// comment\n"
+ "/* comment\n"
+ "*/\n"
+ "/* comment */ #define X\n"
+ "int x;\n"
+ "#define Y 1\n";
+  std::string Expected = "// comment \n"
+ "#ifndef X // comment\n"
+ "// comment\n"
+ "/* comment\n"
+ "*/\n"
+ "/* comment */ #define X\n"
+ "#include \n"
+ "int x;\n"
+ "#define Y 1\n";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1436,6 +1436,24 @@
  llvm::Regex(IncludeRegexPattern).match(Replace.getReplacementText());
 }
 
+// Skip the current token and all comments following the current token.
+void skipComments(Lexer &Lex, Token &Tok) {
+  while (!Lex.LexFromRawLexer(Tok))
+if (Tok.isNot(tok::comment))
+  return;
+}
+
+// Check if a preprocessor directive is like "# ".
+// \post If the preprocessor directive matches the given pattern, \p Tok will be
+// the raw_identifier in the directive; otherwise, it can be any tokens after
+// the hash token.
+bool isDirectiveWithName(Lexer &Lex, StringRef Name, Token &Tok) {
+  assert(Tok.is(tok::hash) && "If-directive must start with hash!");
+  return !Lex.LexFromRawLexer(Tok) && Tok.is(tok::raw_identifier) &&
+ Tok.getRawIdentifier() == Name && !Lex.LexFromRawLexer(Tok) &&
+ Tok.is(tok::raw_identifier);
+}
+
 // FIXME: do not insert headers into conditional #include blocks, e.g. #includes
 // surrounded by compile condition "#if...".
 // FIXME: do not insert existing headers.
@@ -1474,24 +1492,34 @@
   const SourceManager &SourceMgr = Env->getSourceManager();
   Lexer Lex(Env->getFileID(), SourceMgr.getBuffer(Env->getFileID()), SourceMgr,
 getFormattingLangOpts(Style));
-  Token Tok;
   // All new headers should be inserted after this offset.
   int MinInsertOffset = Code.size();
-  while (!Lex.LexFromRawLexer(Tok)) {
-if (Tok.isNot(tok::comment)) {
-  MinInsertOffset = SourceMgr.getFileOffset(Tok.getLocation());
-  break;
+  Token Tok;
+  skipComments(Lex, Tok);
+  Token TokAfterComments = Tok;
+  bool HeaderGuardFound = false;
+  if (Tok.is(tok::hash) && isDirectiveWithName(Lex, "ifndef", Tok) &&
+  !Lex.LexFromRawLexer(Tok)) {
+if (Tok.is(tok::comment))
+   

Re: [PATCH] D20959: [clang-format] make header guard identification stricter (with Lexer).

2016-06-03 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: lib/Format/Format.cpp:1441
@@ +1440,3 @@
+void skipComments(Lexer &Lex, Token &Tok) {
+  while (!Lex.LexFromRawLexer(Tok))
+if (Tok.isNot(tok::comment))

I'd modify this to:

  while (Tok.is(comment))
if (Lex.LexFromRawLexer(Tok))
  return;

So it skips tokens until it finds a non-comment token.


Comment at: lib/Format/Format.cpp:1452
@@ +1451,3 @@
+  assert(Tok.is(tok::hash) && "If-directive must start with hash!");
+  return !Lex.LexFromRawLexer(Tok) && Tok.is(tok::raw_identifier) &&
+ Tok.getRawIdentifier() == Name && !Lex.LexFromRawLexer(Tok) &&

Store this value in a bool and call another Lex.LexFromRawLexer afterwards. 
Both calls do this next.


Comment at: lib/Format/Format.cpp:1501
@@ +1500,3 @@
+  bool HeaderGuardFound = false;
+  if (Tok.is(tok::hash) && isDirectiveWithName(Lex, "ifndef", Tok) &&
+  !Lex.LexFromRawLexer(Tok)) {

Move the Tok.is(hash) check into isDirectiveWithName and replace the assert 
there.


http://reviews.llvm.org/D20959



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


[PATCH] D20960: [include-fixer] Be smarter about inserting symbols for a prefix.

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

If prefix search finds something where nothing can be nested under (e.g.
a variable or macro) don't add it to the result.

This is for cases like:
header.h:
  extern int a;

file.cc:
namespace a {
  SOME_MACRO
}

We will look up a::SOME_MACRO, which doesn't have any results. Then we
look up 'a' and find something before we ever look up just 'SOME_MACRO'.
With some basic filtering we can avoid this case.

http://reviews.llvm.org/D20960

Files:
  include-fixer/SymbolIndexManager.cpp
  test/include-fixer/Inputs/fake_yaml_db.yaml
  test/include-fixer/prefix_variable.cpp

Index: test/include-fixer/prefix_variable.cpp
===
--- /dev/null
+++ test/include-fixer/prefix_variable.cpp
@@ -0,0 +1,11 @@
+// REQUIRES: shell
+// RUN: sed -e 's#//.*$##' %s > %t.cpp
+// RUN: clang-include-fixer -db=yaml -input=%p/Inputs/fake_yaml_db.yaml %t.cpp 
--
+// RUN: FileCheck %s -input-file=%t.cpp
+
+// CHECK-NOT: #include
+// CHECK: doesnotexist f;
+
+namespace b {
+doesnotexist f;
+}
Index: test/include-fixer/Inputs/fake_yaml_db.yaml
===
--- test/include-fixer/Inputs/fake_yaml_db.yaml
+++ test/include-fixer/Inputs/fake_yaml_db.yaml
@@ -43,3 +43,11 @@
 LineNumber:  1
 Type:Class
 NumOccurrences:  3
+---
+Name:   b
+Contexts:
+FilePath:var.h
+LineNumber:  1
+Type:Variable
+NumOccurrences:  1
+...
Index: include-fixer/SymbolIndexManager.cpp
===
--- include-fixer/SymbolIndexManager.cpp
+++ include-fixer/SymbolIndexManager.cpp
@@ -66,6 +66,7 @@
   // 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
   // either) and can report that result.
+  bool TookPrefix = false;
   std::vector Results;
   while (Results.empty() && !Names.empty()) {
 std::vector Symbols;
@@ -109,6 +110,16 @@
 // 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()) {
+  // If we're in a situation where we took a prefix but the thing we
+  // found couldn't possibly have a nested member ignore it.
+  if (TookPrefix &&
+  (Symbol.getSymbolKind() == SymbolInfo::SymbolKind::Function ||
+   Symbol.getSymbolKind() == SymbolInfo::SymbolKind::Variable ||
+   Symbol.getSymbolKind() ==
+   SymbolInfo::SymbolKind::EnumConstantDecl ||
+   Symbol.getSymbolKind() == SymbolInfo::SymbolKind::Macro))
+continue;
+
   // FIXME: file path should never be in the form of <...> or "...", 
but
   // the unit test with fixed database use <...> file path, which might
   // need to be changed.
@@ -122,6 +133,7 @@
   }
 }
 Names.pop_back();
+TookPrefix = true;
   }
 
   return Results;


Index: test/include-fixer/prefix_variable.cpp
===
--- /dev/null
+++ test/include-fixer/prefix_variable.cpp
@@ -0,0 +1,11 @@
+// REQUIRES: shell
+// RUN: sed -e 's#//.*$##' %s > %t.cpp
+// RUN: clang-include-fixer -db=yaml -input=%p/Inputs/fake_yaml_db.yaml %t.cpp --
+// RUN: FileCheck %s -input-file=%t.cpp
+
+// CHECK-NOT: #include
+// CHECK: doesnotexist f;
+
+namespace b {
+doesnotexist f;
+}
Index: test/include-fixer/Inputs/fake_yaml_db.yaml
===
--- test/include-fixer/Inputs/fake_yaml_db.yaml
+++ test/include-fixer/Inputs/fake_yaml_db.yaml
@@ -43,3 +43,11 @@
 LineNumber:  1
 Type:Class
 NumOccurrences:  3
+---
+Name:   b
+Contexts:
+FilePath:var.h
+LineNumber:  1
+Type:Variable
+NumOccurrences:  1
+...
Index: include-fixer/SymbolIndexManager.cpp
===
--- include-fixer/SymbolIndexManager.cpp
+++ include-fixer/SymbolIndexManager.cpp
@@ -66,6 +66,7 @@
   // 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
   // either) and can report that result.
+  bool TookPrefix = false;
   std::vector Results;
   while (Results.empty() && !Names.empty()) {
 std::vector Symbols;
@@ -109,6 +110,16 @@
 // 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()) {
+  // If we're in a situation where we took a prefix but the thing we
+  // found couldn't possibly have a nested membe

Re: [PATCH] D20382: Add postorder support to RecursiveASTVisitor

2016-06-03 Thread Raphael Isemann via cfe-commits
teemperor added a comment.

Size changes to clang's binary (build with clang):

Release:  63367728 Byte -> 6326141 Byte (0.2% less, -106kB)
Debug: 1239669408 Byte -> 1264216256 Byte (2% increase, +24.5 MB)


http://reviews.llvm.org/D20382



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


Re: [PATCH] D20959: [clang-format] make header guard identification stricter (with Lexer).

2016-06-03 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 59549.
ioeric marked 3 inline comments as done.
ioeric added a comment.

- Addressed reviewer's comments.


http://reviews.llvm.org/D20959

Files:
  lib/Format/Format.cpp
  unittests/Format/CleanupTest.cpp

Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -608,6 +608,70 @@
   EXPECT_EQ(Expected, apply(Code, Replaces));
 }
 
+TEST_F(CleanUpReplacementsTest, FakeHeaderGuardIfDef) {
+  std::string Code = "// comment \n"
+ "#ifdef X\n"
+ "#define X\n";
+  std::string Expected = "// comment \n"
+ "#include \n"
+ "#ifdef X\n"
+ "#define X\n";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, RealHeaderGuardAfterComments) {
+  std::string Code = "// comment \n"
+ "#ifndef X\n"
+ "#define X\n"
+ "int x;\n"
+ "#define Y 1\n";
+  std::string Expected = "// comment \n"
+ "#ifndef X\n"
+ "#define X\n"
+ "#include \n"
+ "int x;\n"
+ "#define Y 1\n";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, IfNDefWithNoDefine) {
+  std::string Code = "// comment \n"
+ "#ifndef X\n"
+ "int x;\n"
+ "#define Y 1\n";
+  std::string Expected = "// comment \n"
+ "#include \n"
+ "#ifndef X\n"
+ "int x;\n"
+ "#define Y 1\n";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, HeaderGuardWithComment) {
+  std::string Code = "// comment \n"
+ "#ifndef X // comment\n"
+ "// comment\n"
+ "/* comment\n"
+ "*/\n"
+ "/* comment */ #define X\n"
+ "int x;\n"
+ "#define Y 1\n";
+  std::string Expected = "// comment \n"
+ "#ifndef X // comment\n"
+ "// comment\n"
+ "/* comment\n"
+ "*/\n"
+ "/* comment */ #define X\n"
+ "#include \n"
+ "int x;\n"
+ "#define Y 1\n";
+  tooling::Replacements Replaces = {createInsertion("#include ")};
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1436,6 +1436,25 @@
  llvm::Regex(IncludeRegexPattern).match(Replace.getReplacementText());
 }
 
+void skipComments(Lexer &Lex, Token &Tok) {
+  while (Tok.is(tok::comment))
+if (Lex.LexFromRawLexer(Tok))
+  return;
+}
+
+// Check if a sequence of tokens is like "# ". If it is,
+// \p Tok will be the token after this directive; otherwise, it can be any token
+// after the given \p Tok (including \p Tok).
+bool checkAndConsumeDirectiveWithName(Lexer &Lex, StringRef Name, Token &Tok) {
+  bool Matched = Tok.is(tok::hash) && !Lex.LexFromRawLexer(Tok) &&
+ Tok.is(tok::raw_identifier) &&
+ Tok.getRawIdentifier() == Name && !Lex.LexFromRawLexer(Tok) &&
+ Tok.is(tok::raw_identifier);
+  if (Matched)
+Lex.LexFromRawLexer(Tok);
+  return Matched;
+}
+
 // FIXME: do not insert headers into conditional #include blocks, e.g. #includes
 // surrounded by compile condition "#if...".
 // FIXME: do not insert existing headers.
@@ -1474,24 +1493,31 @@
   const SourceManager &SourceMgr = Env->getSourceManager();
   Lexer Lex(Env->getFileID(), SourceMgr.getBuffer(Env->getFileID()), SourceMgr,
 getFormattingLangOpts(Style));
-  Token Tok;
   // All new headers should be inserted after this offset.
   int MinInsertOffset = Code.size();
-  while (!Lex.LexFromRawLexer(Tok)) {
-if (Tok.isNot(tok::comment)) {
-  MinInsertOffset = SourceMgr.getFileOffset(Tok.getLocation());
-  break;
-}
+  Token Tok;
+  // Get the first token.
+  Lex.LexFromRawLexer(Tok);
+  skipComments(Lex, Tok);
+  Token TokAfterComments = Tok;
+  bool HeaderGuardFound = false;
+  if (checkAndConsumeDirectiveWithName(Lex, "ifndef", Tok)) {
+skipComments(Lex, Tok);
+if (checkAndConsumeDirectiveWithName(Lex, "define", Tok))
+  HeaderGuardFound =

Re: [PATCH] D20960: [include-fixer] Be smarter about inserting symbols for a prefix.

2016-06-03 Thread Eric Liu via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

LG.


http://reviews.llvm.org/D20960



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


Re: [PATCH] D20960: [include-fixer] Be smarter about inserting symbols for a prefix.

2016-06-03 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271671: [include-fixer] Be smarter about inserting symbols 
for a prefix. (authored by d0k).

Changed prior to commit:
  http://reviews.llvm.org/D20960?vs=59545&id=59550#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20960

Files:
  clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
  clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml
  clang-tools-extra/trunk/test/include-fixer/prefix_variable.cpp

Index: clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml
===
--- clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml
+++ clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml
@@ -43,3 +43,11 @@
 LineNumber:  1
 Type:Class
 NumOccurrences:  3
+---
+Name:   b
+Contexts:
+FilePath:var.h
+LineNumber:  1
+Type:Variable
+NumOccurrences:  1
+...
Index: clang-tools-extra/trunk/test/include-fixer/prefix_variable.cpp
===
--- clang-tools-extra/trunk/test/include-fixer/prefix_variable.cpp
+++ clang-tools-extra/trunk/test/include-fixer/prefix_variable.cpp
@@ -0,0 +1,11 @@
+// REQUIRES: shell
+// RUN: sed -e 's#//.*$##' %s > %t.cpp
+// RUN: clang-include-fixer -db=yaml -input=%p/Inputs/fake_yaml_db.yaml %t.cpp 
--
+// RUN: FileCheck %s -input-file=%t.cpp
+
+// CHECK-NOT: #include
+// CHECK: doesnotexist f;
+
+namespace b {
+doesnotexist f;
+}
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
@@ -66,6 +66,7 @@
   // 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
   // either) and can report that result.
+  bool TookPrefix = false;
   std::vector Results;
   while (Results.empty() && !Names.empty()) {
 std::vector Symbols;
@@ -109,6 +110,16 @@
 // 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()) {
+  // If we're in a situation where we took a prefix but the thing we
+  // found couldn't possibly have a nested member ignore it.
+  if (TookPrefix &&
+  (Symbol.getSymbolKind() == SymbolInfo::SymbolKind::Function ||
+   Symbol.getSymbolKind() == SymbolInfo::SymbolKind::Variable ||
+   Symbol.getSymbolKind() ==
+   SymbolInfo::SymbolKind::EnumConstantDecl ||
+   Symbol.getSymbolKind() == SymbolInfo::SymbolKind::Macro))
+continue;
+
   // FIXME: file path should never be in the form of <...> or "...", 
but
   // the unit test with fixed database use <...> file path, which might
   // need to be changed.
@@ -122,6 +133,7 @@
   }
 }
 Names.pop_back();
+TookPrefix = true;
   }
 
   return Results;


Index: clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml
===
--- clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml
+++ clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml
@@ -43,3 +43,11 @@
 LineNumber:  1
 Type:Class
 NumOccurrences:  3
+---
+Name:   b
+Contexts:
+FilePath:var.h
+LineNumber:  1
+Type:Variable
+NumOccurrences:  1
+...
Index: clang-tools-extra/trunk/test/include-fixer/prefix_variable.cpp
===
--- clang-tools-extra/trunk/test/include-fixer/prefix_variable.cpp
+++ clang-tools-extra/trunk/test/include-fixer/prefix_variable.cpp
@@ -0,0 +1,11 @@
+// REQUIRES: shell
+// RUN: sed -e 's#//.*$##' %s > %t.cpp
+// RUN: clang-include-fixer -db=yaml -input=%p/Inputs/fake_yaml_db.yaml %t.cpp --
+// RUN: FileCheck %s -input-file=%t.cpp
+
+// CHECK-NOT: #include
+// CHECK: doesnotexist f;
+
+namespace b {
+doesnotexist f;
+}
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
@@ -66,6 +66,7 @@
   // 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
   // either) and can report that result.
+  bool TookPrefix = false;
   std::vector Results;
   while (Results.empty() && !Names.empty()) {
 std::vector Symbols;
@@ -109,6 +110,16 @@
 // FIXME: 

[clang-tools-extra] r271671 - [include-fixer] Be smarter about inserting symbols for a prefix.

2016-06-03 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Jun  3 09:07:38 2016
New Revision: 271671

URL: http://llvm.org/viewvc/llvm-project?rev=271671&view=rev
Log:
[include-fixer] Be smarter about inserting symbols for a prefix.

If prefix search finds something where nothing can be nested under (e.g.
a variable or macro) don't add it to the result.

This is for cases like:
header.h:
  extern int a;

file.cc:
namespace a {
  SOME_MACRO
}

We will look up a::SOME_MACRO, which doesn't have any results. Then we
look up 'a' and find something before we ever look up just 'SOME_MACRO'.
With some basic filtering we can avoid this case.

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

Added:
clang-tools-extra/trunk/test/include-fixer/prefix_variable.cpp
Modified:
clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml

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=271671&r1=271670&r2=271671&view=diff
==
--- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp Fri Jun  3 
09:07:38 2016
@@ -66,6 +66,7 @@ SymbolIndexManager::search(llvm::StringR
   // 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
   // either) and can report that result.
+  bool TookPrefix = false;
   std::vector Results;
   while (Results.empty() && !Names.empty()) {
 std::vector Symbols;
@@ -109,6 +110,16 @@ SymbolIndexManager::search(llvm::StringR
 // 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()) {
+  // If we're in a situation where we took a prefix but the thing we
+  // found couldn't possibly have a nested member ignore it.
+  if (TookPrefix &&
+  (Symbol.getSymbolKind() == SymbolInfo::SymbolKind::Function ||
+   Symbol.getSymbolKind() == SymbolInfo::SymbolKind::Variable ||
+   Symbol.getSymbolKind() ==
+   SymbolInfo::SymbolKind::EnumConstantDecl ||
+   Symbol.getSymbolKind() == SymbolInfo::SymbolKind::Macro))
+continue;
+
   // FIXME: file path should never be in the form of <...> or "...", 
but
   // the unit test with fixed database use <...> file path, which might
   // need to be changed.
@@ -122,6 +133,7 @@ SymbolIndexManager::search(llvm::StringR
   }
 }
 Names.pop_back();
+TookPrefix = true;
   }
 
   return Results;

Modified: clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml?rev=271671&r1=271670&r2=271671&view=diff
==
--- clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml 
(original)
+++ clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml Fri Jun 
 3 09:07:38 2016
@@ -43,3 +43,11 @@ FilePath:../include/zbar.h
 LineNumber:  1
 Type:Class
 NumOccurrences:  3
+---
+Name:   b
+Contexts:
+FilePath:var.h
+LineNumber:  1
+Type:Variable
+NumOccurrences:  1
+...

Added: clang-tools-extra/trunk/test/include-fixer/prefix_variable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/include-fixer/prefix_variable.cpp?rev=271671&view=auto
==
--- clang-tools-extra/trunk/test/include-fixer/prefix_variable.cpp (added)
+++ clang-tools-extra/trunk/test/include-fixer/prefix_variable.cpp Fri Jun  3 
09:07:38 2016
@@ -0,0 +1,11 @@
+// REQUIRES: shell
+// RUN: sed -e 's#//.*$##' %s > %t.cpp
+// RUN: clang-include-fixer -db=yaml -input=%p/Inputs/fake_yaml_db.yaml %t.cpp 
--
+// RUN: FileCheck %s -input-file=%t.cpp
+
+// CHECK-NOT: #include
+// CHECK: doesnotexist f;
+
+namespace b {
+doesnotexist f;
+}


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


r271672 - RAS extensions are part of ARMv8.2.

2016-06-03 Thread Sjoerd Meijer via cfe-commits
Author: sjoerdmeijer
Date: Fri Jun  3 09:08:20 2016
New Revision: 271672

URL: http://llvm.org/viewvc/llvm-project?rev=271672&view=rev
Log:
RAS extensions are part of ARMv8.2.

This patch enables +ras +noras to AArch64 in clang.

Patch by: Roger Ferrer Ibanez and Oliver Stannard

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

Added:
cfe/trunk/test/Driver/aarch64-ras.c
cfe/trunk/test/Driver/arm-ras.c
Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=271672&r1=271671&r2=271672&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Jun  3 09:08:20 2016
@@ -2282,12 +2282,14 @@ static bool DecodeAArch64Features(const
  .Case("crypto", "+crypto")
  .Case("fp16", "+fullfp16")
  .Case("profile", "+spe")
+ .Case("ras", "+ras")
  .Case("nofp", "-fp-armv8")
  .Case("nosimd", "-neon")
  .Case("nocrc", "-crc")
  .Case("nocrypto", "-crypto")
  .Case("nofp16", "-fullfp16")
  .Case("noprofile", "-spe")
+ .Case("noras", "-ras")
  .Default(nullptr);
 if (result)
   Features.push_back(result);

Added: cfe/trunk/test/Driver/aarch64-ras.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/aarch64-ras.c?rev=271672&view=auto
==
--- cfe/trunk/test/Driver/aarch64-ras.c (added)
+++ cfe/trunk/test/Driver/aarch64-ras.c Fri Jun  3 09:08:20 2016
@@ -0,0 +1,7 @@
+// RUN: %clang -target aarch64-none-none-eabi -march=armv8a+ras -### -c %s 
2>&1 | FileCheck --check-prefix=CHECK-RAS %s
+// RUN: %clang -target aarch64-none-none-eabi -mcpu=generic+ras -### -c %s 
2>&1 | FileCheck --check-prefix=CHECK-RAS %s
+// CHECK-RAS: "-target-feature" "+ras"
+
+// RUN: %clang -target aarch64-none-none-eabi -march=armv8a+noras -### -c %s 
2>&1 | FileCheck --check-prefix=CHECK-NORAS %s
+// RUN: %clang -target aarch64-none-none-eabi -mcpu=generic+noras -### -c %s 
2>&1 | FileCheck --check-prefix=CHECK-NORAS %s
+// CHECK-NORAS: "-target-feature" "-ras"

Added: cfe/trunk/test/Driver/arm-ras.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-ras.c?rev=271672&view=auto
==
--- cfe/trunk/test/Driver/arm-ras.c (added)
+++ cfe/trunk/test/Driver/arm-ras.c Fri Jun  3 09:08:20 2016
@@ -0,0 +1,7 @@
+// RUN: %clang -target arm-none-none-eabi -march=armv8a+ras -### -c %s 2>&1 | 
FileCheck --check-prefix=CHECK-RAS %s
+// RUN: %clang -target arm-none-none-eabi -mcpu=generic+ras -### -c %s 2>&1 | 
FileCheck --check-prefix=CHECK-RAS %s
+// CHECK-RAS: "-target-feature" "+ras"
+
+// RUN: %clang -target arm-none-none-eabi -march=armv8a+noras -### -c %s 2>&1 
| FileCheck --check-prefix=CHECK-NORAS %s
+// RUN: %clang -target arm-none-none-eabi -mcpu=generic+noras -### -c %s 2>&1 
| FileCheck --check-prefix=CHECK-NORAS %s
+// CHECK-NORAS: "-target-feature" "-ras"


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


Re: [PATCH] D20283: Add ras/noras flag to enable/disable RAS in clang

2016-06-03 Thread Sjoerd Meijer via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271672: RAS extensions are part of ARMv8.2. (authored by 
SjoerdMeijer).

Changed prior to commit:
  http://reviews.llvm.org/D20283?vs=57451&id=59551#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20283

Files:
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/aarch64-ras.c
  cfe/trunk/test/Driver/arm-ras.c

Index: cfe/trunk/test/Driver/arm-ras.c
===
--- cfe/trunk/test/Driver/arm-ras.c
+++ cfe/trunk/test/Driver/arm-ras.c
@@ -0,0 +1,7 @@
+// RUN: %clang -target arm-none-none-eabi -march=armv8a+ras -### -c %s 2>&1 | 
FileCheck --check-prefix=CHECK-RAS %s
+// RUN: %clang -target arm-none-none-eabi -mcpu=generic+ras -### -c %s 2>&1 | 
FileCheck --check-prefix=CHECK-RAS %s
+// CHECK-RAS: "-target-feature" "+ras"
+
+// RUN: %clang -target arm-none-none-eabi -march=armv8a+noras -### -c %s 2>&1 
| FileCheck --check-prefix=CHECK-NORAS %s
+// RUN: %clang -target arm-none-none-eabi -mcpu=generic+noras -### -c %s 2>&1 
| FileCheck --check-prefix=CHECK-NORAS %s
+// CHECK-NORAS: "-target-feature" "-ras"
Index: cfe/trunk/test/Driver/aarch64-ras.c
===
--- cfe/trunk/test/Driver/aarch64-ras.c
+++ cfe/trunk/test/Driver/aarch64-ras.c
@@ -0,0 +1,7 @@
+// RUN: %clang -target aarch64-none-none-eabi -march=armv8a+ras -### -c %s 
2>&1 | FileCheck --check-prefix=CHECK-RAS %s
+// RUN: %clang -target aarch64-none-none-eabi -mcpu=generic+ras -### -c %s 
2>&1 | FileCheck --check-prefix=CHECK-RAS %s
+// CHECK-RAS: "-target-feature" "+ras"
+
+// RUN: %clang -target aarch64-none-none-eabi -march=armv8a+noras -### -c %s 
2>&1 | FileCheck --check-prefix=CHECK-NORAS %s
+// RUN: %clang -target aarch64-none-none-eabi -mcpu=generic+noras -### -c %s 
2>&1 | FileCheck --check-prefix=CHECK-NORAS %s
+// CHECK-NORAS: "-target-feature" "-ras"
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -2282,12 +2282,14 @@
  .Case("crypto", "+crypto")
  .Case("fp16", "+fullfp16")
  .Case("profile", "+spe")
+ .Case("ras", "+ras")
  .Case("nofp", "-fp-armv8")
  .Case("nosimd", "-neon")
  .Case("nocrc", "-crc")
  .Case("nocrypto", "-crypto")
  .Case("nofp16", "-fullfp16")
  .Case("noprofile", "-spe")
+ .Case("noras", "-ras")
  .Default(nullptr);
 if (result)
   Features.push_back(result);


Index: cfe/trunk/test/Driver/arm-ras.c
===
--- cfe/trunk/test/Driver/arm-ras.c
+++ cfe/trunk/test/Driver/arm-ras.c
@@ -0,0 +1,7 @@
+// RUN: %clang -target arm-none-none-eabi -march=armv8a+ras -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-RAS %s
+// RUN: %clang -target arm-none-none-eabi -mcpu=generic+ras -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-RAS %s
+// CHECK-RAS: "-target-feature" "+ras"
+
+// RUN: %clang -target arm-none-none-eabi -march=armv8a+noras -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-NORAS %s
+// RUN: %clang -target arm-none-none-eabi -mcpu=generic+noras -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-NORAS %s
+// CHECK-NORAS: "-target-feature" "-ras"
Index: cfe/trunk/test/Driver/aarch64-ras.c
===
--- cfe/trunk/test/Driver/aarch64-ras.c
+++ cfe/trunk/test/Driver/aarch64-ras.c
@@ -0,0 +1,7 @@
+// RUN: %clang -target aarch64-none-none-eabi -march=armv8a+ras -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-RAS %s
+// RUN: %clang -target aarch64-none-none-eabi -mcpu=generic+ras -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-RAS %s
+// CHECK-RAS: "-target-feature" "+ras"
+
+// RUN: %clang -target aarch64-none-none-eabi -march=armv8a+noras -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-NORAS %s
+// RUN: %clang -target aarch64-none-none-eabi -mcpu=generic+noras -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-NORAS %s
+// CHECK-NORAS: "-target-feature" "-ras"
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -2282,12 +2282,14 @@
  .Case("crypto", "+crypto")
  .Case("fp16", "+fullfp16")
  .Case("profile", "+spe")
+ .Case("ras", "+ras")
  .Case("nofp", "-fp-armv8")
  .Case("nosimd", "-neon")
  .Case("nocrc", "-crc"

[PATCH] D20961: [mips] Replace almost all Arch checks in MipsTargetInfo with ABI checks. NFC.

2016-06-03 Thread Daniel Sanders via cfe-commits
dsanders created this revision.
dsanders added a reviewer: atanasyan.
dsanders added a subscriber: cfe-commits.

setABI() is still tied to the Arch component of the Triple to preserve existing
behaviour.

http://reviews.llvm.org/D20961

Files:
  lib/Basic/Targets.cpp

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -7047,38 +7047,19 @@
 
 public:
   MipsTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
-  : TargetInfo(Triple), CPU((getTriple().getArch() == llvm::Triple::mips ||
- getTriple().getArch() == llvm::Triple::mipsel)
-? "mips32r2"
-: "mips64r2"),
-IsMips16(false), IsMicromips(false), IsNan2008(false),
-IsSingleFloat(false), FloatABI(HardFloat), DspRev(NoDSP), HasMSA(false),
-HasFP64(false), ABI((getTriple().getArch() == llvm::Triple::mips ||
- getTriple().getArch() == llvm::Triple::mipsel)
-? "o32"
-: "n64") {
+  : TargetInfo(Triple), IsMips16(false), IsMicromips(false),
+IsNan2008(false), IsSingleFloat(false), FloatABI(HardFloat),
+DspRev(NoDSP), HasMSA(false), HasFP64(false) {
 TheCXXABI.set(TargetCXXABI::GenericMIPS);
 BigEndian = getTriple().getArch() == llvm::Triple::mips ||
 getTriple().getArch() == llvm::Triple::mips64;
 
-if (getTriple().getArch() == llvm::Triple::mips ||
-getTriple().getArch() == llvm::Triple::mipsel) {
-  SizeType = UnsignedInt;
-  PtrDiffType = SignedInt;
-  Int64Type = SignedLongLong;
-  IntMaxType = Int64Type;
-  MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
-} else {
-  LongDoubleWidth = LongDoubleAlign = 128;
-  LongDoubleFormat = &llvm::APFloat::IEEEquad;
-  if (getTriple().getOS() == llvm::Triple::FreeBSD) {
-LongDoubleWidth = LongDoubleAlign = 64;
-LongDoubleFormat = &llvm::APFloat::IEEEdouble;
-  }
-  setN64ABITypes();
-  SuitableAlign = 128;
-  MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
-}
+setABI((getTriple().getArch() == llvm::Triple::mips ||
+getTriple().getArch() == llvm::Triple::mipsel)
+   ? "o32"
+   : "n64");
+
+CPU = ABI == "o32" ? "mips32r2" : "mips64r2";
   }
 
   bool isNaN2008Default() const {
@@ -7095,9 +7076,16 @@
 
   StringRef getABI() const override { return ABI; }
   bool setABI(const std::string &Name) override {
+// FIXME: The Arch component on the triple actually has no bearing on
+//whether the ABI is valid or not. It's features of the CPU that
+//matters and the size of the GPR's in particular.
+//However, we can't allow O32 on 64-bit processors just yet because
+//the backend still checks the Arch component instead of the ABI in
+//a few places.
 if (getTriple().getArch() == llvm::Triple::mips ||
 getTriple().getArch() == llvm::Triple::mipsel) {
   if (Name == "o32") {
+setO32ABITypes();
 ABI = Name;
 return true;
   }
@@ -7118,39 +7106,64 @@
 return false;
   }
 
+  void setO32ABITypes() {
+Int64Type = SignedLongLong;
+IntMaxType = Int64Type;
+LongDoubleFormat = &llvm::APFloat::IEEEdouble;
+LongDoubleWidth = LongDoubleAlign = 64;
+LongWidth = LongAlign = 32;
+MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
+PointerWidth = PointerAlign = 32;
+PtrDiffType = SignedInt;
+SizeType = UnsignedInt;
+SuitableAlign = 64;
+  }
+
+  void setN32N64ABITypes() {
+LongDoubleWidth = LongDoubleAlign = 128;
+LongDoubleFormat = &llvm::APFloat::IEEEquad;
+if (getTriple().getOS() == llvm::Triple::FreeBSD) {
+  LongDoubleWidth = LongDoubleAlign = 64;
+  LongDoubleFormat = &llvm::APFloat::IEEEdouble;
+}
+MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
+SuitableAlign = 128;
+  }
+
   void setN64ABITypes() {
+setN32N64ABITypes();
+Int64Type = SignedLong;
+IntMaxType = Int64Type;
 LongWidth = LongAlign = 64;
 PointerWidth = PointerAlign = 64;
-SizeType = UnsignedLong;
 PtrDiffType = SignedLong;
-Int64Type = SignedLong;
-IntMaxType = Int64Type;
+SizeType = UnsignedLong;
   }
 
   void setN32ABITypes() {
+setN32N64ABITypes();
+Int64Type = SignedLongLong;
+IntMaxType = Int64Type;
 LongWidth = LongAlign = 32;
 PointerWidth = PointerAlign = 32;
-SizeType = UnsignedInt;
 PtrDiffType = SignedInt;
-Int64Type = SignedLongLong;
-IntMaxType = Int64Type;
+SizeType = UnsignedInt;
   }
 
   bool setCPU(const std::string &Name) override {
-bool IsMips32 = getTriple().getArch() == llvm::Triple::mips ||
-getTriple().getArch() == llvm::Triple::mipsel;
+bool GPR64Required =

[PATCH] D20963: [mips] The P5600 does not support N32/N64 since it's a 32-bit CPU.

2016-06-03 Thread Daniel Sanders via cfe-commits
dsanders created this revision.
dsanders added a reviewer: atanasyan.
dsanders added a subscriber: cfe-commits.
dsanders added a dependency: D20961: [mips] Replace almost all Arch checks in 
MipsTargetInfo with ABI checks. NFC..
Herald added a subscriber: sdardis.

Depends on D20961

http://reviews.llvm.org/D20963

Files:
  lib/Basic/Targets.cpp
  test/Driver/mips-abi.c

Index: test/Driver/mips-abi.c
===
--- test/Driver/mips-abi.c
+++ test/Driver/mips-abi.c
@@ -98,6 +98,11 @@
 // MIPS-ARCH-P5600: "-target-cpu" "p5600"
 // MIPS-ARCH-P5600: "-target-abi" "o32"
 //
+// RUN: not %clang -target mips-linux-gnu -c %s \
+// RUN:-march=p5600 -mabi=64 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-ARCH-P5600-N64 %s
+// MIPS-ARCH-P5600-N64: error: unknown target ABI 'n64'
+//
 // RUN: %clang -target mips-linux-gnu -### -c %s \
 // RUN:-march=mips64 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ARCH-3264 %s
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -7170,7 +7170,7 @@
 .Case("mips64r5", true)
 .Case("mips64r6", true)
 .Case("octeon", true)
-.Case("p5600", true)
+.Case("p5600", !GPR64Required)
 .Default(false);
   }
   const std::string& getCPU() const { return CPU; }


Index: test/Driver/mips-abi.c
===
--- test/Driver/mips-abi.c
+++ test/Driver/mips-abi.c
@@ -98,6 +98,11 @@
 // MIPS-ARCH-P5600: "-target-cpu" "p5600"
 // MIPS-ARCH-P5600: "-target-abi" "o32"
 //
+// RUN: not %clang -target mips-linux-gnu -c %s \
+// RUN:-march=p5600 -mabi=64 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-ARCH-P5600-N64 %s
+// MIPS-ARCH-P5600-N64: error: unknown target ABI 'n64'
+//
 // RUN: %clang -target mips-linux-gnu -### -c %s \
 // RUN:-march=mips64 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ARCH-3264 %s
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -7170,7 +7170,7 @@
 .Case("mips64r5", true)
 .Case("mips64r6", true)
 .Case("octeon", true)
-.Case("p5600", true)
+.Case("p5600", !GPR64Required)
 .Default(false);
   }
   const std::string& getCPU() const { return CPU; }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Piotr Padlewski via cfe-commits
Prazek updated this revision to Diff 59558.
Prazek added a comment.

- Fix


http://reviews.llvm.org/D20964

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tidy/modernize/UseEmplaceCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-emplace.rst
  test/clang-tidy/modernize-use-emplace.cpp

Index: test/clang-tidy/modernize-use-emplace.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-emplace.cpp
@@ -0,0 +1,157 @@
+// RUN: %check_clang_tidy %s modernize-use-emplace %t
+
+namespace std {
+template 
+class vector {
+public:
+  void push_back(const T &) {}
+  void push_back(T &&) {}
+
+  template 
+  void emplace_back(Args &&... args);
+};
+template 
+class pair {
+public:
+  pair() = default;
+  pair(const pair &) = default;
+  pair(pair &&) = default;
+
+  pair(const T1 &, const T2 &) {}
+  pair(T1 &&, T2 &&) {}
+
+  template 
+  pair(const pair &p){};
+  template 
+  pair(pair &&p){};
+};
+
+template 
+pair make_pair(T1, T2) {
+  return pair();
+};
+
+template 
+class unique_ptr {
+public:
+  unique_ptr(T *) {}
+};
+} // namespace std
+
+void testInts() {
+  std::vector v;
+  v.push_back(42);
+  v.push_back(int(42));
+  v.push_back(int{42});
+  int z;
+  v.push_back(z);
+}
+
+struct S {
+  S(int a, int b = 41) {}
+  S() {}
+  void push_back(S);
+};
+
+struct Convertable {
+  operator S() { return S{}; }
+};
+struct Zoz {
+  Zoz(S s) {}
+};
+
+Zoz getZoz(S s) { return Zoz(s); }
+
+void test_S() {
+  std::vector v;
+
+  v.push_back(S(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back instead of push_back [modernize-use-emplace]
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  v.push_back(S{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  v.push_back(S());
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back();
+
+  v.push_back(S{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back();
+
+  v.push_back(42);
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(42);
+
+  S temporary(42, 42);
+  temporary.push_back(temporary);
+  v.push_back(temporary);
+
+  v.push_back(Convertable());
+  v.push_back(Convertable{});
+  Convertable s;
+  v.push_back(s);
+}
+
+void test2() {
+  std::vector v;
+  v.push_back(Zoz(S(21, 37)));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(S(21, 37));
+
+  v.push_back(getZoz(S(1, 2)));
+}
+
+void testPair() {
+  std::vector> v;
+  v.push_back(std::pair(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  std::vector> v2;
+  v2.push_back(std::pair(S(42, 42), Zoz(S(21, 37;
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v2.emplace_back(S(42, 42), Zoz(S(21, 37)));
+}
+
+void testSpaces() {
+  std::vector v;
+
+  // clang-format off
+  v.push_back(S   (1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+  v.push_back(S   {1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  v.push_back(  S {});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back();
+
+  // clang-format on
+}
+
+void testPointers() {
+  std::vector v;
+  v.push_back(new int(5));
+
+  std::vector> v2;
+  v2.push_back(new int(42));
+  // This call can't be replaced with emplace_back.
+  // If emplacement will fail (not enough memory to add to vector)
+  // we will have leak of int because unique_ptr won't be constructed
+  // (and destructed) as in push_back case.
+
+  auto *ptr = new int;
+  v2.push_back(ptr);
+  // Same here
+}
+
+void testMakePair() {
+  std::vector> v;
+  // FIXME: add functionality to change calls of std::make_pair
+  v.push_back(std::make_pair(1, 2));
+}
Index: docs/clang-tidy/checks/modernize-use-emplace.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/modernize-use-emplace.rst
@@ -0,0 +1,61 @@
+.. title:: clang-tidy - modernize-use-emplace
+
+modernize-use-emplace
+=
+
+This check would look for cases when inserting new element into an STL
+container, but the element is constructed temporarily or is constructed just
+to be moved. It would also work with std::pair.
+
+Before:
+
+.. code:: c++
+
+	std::vector v;
+	v.push_back(MyClass(21, 37));
+
+	std::vector > w;
+	w.push_back(std::make_pair(21, 37));
+
+After:
+
+.. code:: c++
+
+	std::vector v;
+	v.emplace_back(21, 37);
+
+

Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Stanisław Barzowski via cfe-commits
sbarzowski added inline comments.


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:57
@@ +56,3 @@
+
+  auto functionNameSourceRange = CharSourceRange::getCharRange(
+  PushBackExpr->getExprLoc(), Call->getArg(0)->getExprLoc());

capital letter?


Comment at: docs/ReleaseNotes.rst:212
@@ +211,3 @@
+
+  Finds calls that could be change to emplace.
+

typo: change -> changed


Comment at: docs/clang-tidy/checks/modernize-use-emplace.rst:6
@@ +5,3 @@
+
+This check would look for cases when inserting new element into an STL
+container, but the element is constructed temporarily or is constructed just

Why "would"? Did you copy the description from the proposal? :-)


Comment at: docs/clang-tidy/checks/modernize-use-emplace.rst:8
@@ +7,3 @@
+container, but the element is constructed temporarily or is constructed just
+to be moved. It would also work with std::pair.
+

Same here, and it is not obvious to me what is so special about std::pair here.


http://reviews.llvm.org/D20964



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


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Stanisław Barzowski via cfe-commits
sbarzowski added inline comments.


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:28
@@ +27,3 @@
+
+  auto callPushBack =
+  cxxMemberCallExpr(hasDeclaration(functionDecl(hasName(PushBackName))),

Shouldn't it start with an uppercase letter?


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:37
@@ +36,3 @@
+  // (and destructed) as in push_back case.
+  auto isCtorOfSmartPtr = hasDeclaration(cxxConstructorDecl(
+  ofClass(hasAnyName("std::shared_ptr", "std::unique_ptr", "std::auto_ptr",

Same


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:41
@@ +40,3 @@
+
+  auto hasConstructExpr = has(ignoringParenImpCasts(
+  cxxConstructExpr(unless(isCtorOfSmartPtr)).bind("ctor")));

Same


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:44
@@ +43,3 @@
+
+  auto ctorAsArgument = materializeTemporaryExpr(
+  anyOf(hasConstructExpr, has(cxxFunctionalCastExpr(hasConstructExpr;

same


http://reviews.llvm.org/D20964



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


[PATCH] D20966: [include-fixer] Add the missing header to the file where the unidentified symbol comes from.

2016-06-03 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added reviewers: bkramer, ioeric.
hokein added a subscriber: cfe-commits.

http://reviews.llvm.org/D20966

Files:
  include-fixer/IncludeFixer.cpp
  include-fixer/IncludeFixerContext.h
  include-fixer/tool/ClangIncludeFixer.cpp
  include-fixer/tool/clang-include-fixer.py
  test/include-fixer/commandline_options.cpp
  test/include-fixer/insert_header_in_header.cpp
  unittests/include-fixer/IncludeFixerTest.cpp

Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -44,8 +44,6 @@
   llvm::MemoryBuffer::getMemBuffer("\n"));
   InMemoryFileSystem->addFile("dir/otherdir/qux.h", 0,
   llvm::MemoryBuffer::getMemBuffer("\n"));
-  InMemoryFileSystem->addFile("header.h", 0,
-  llvm::MemoryBuffer::getMemBuffer("bar b;"));
   return Invocation.run();
 }
 
@@ -188,11 +186,6 @@
 runIncludeFixer("int test = a::b::Green;\n"));
 }
 
-TEST(IncludeFixer, IgnoreSymbolFromHeader) {
-  std::string Code = "#include \"header.h\"";
-  EXPECT_EQ(Code, runIncludeFixer(Code));
-}
-
 // FIXME: add test cases for inserting and sorting multiple headers when
 // include-fixer supports multiple headers insertion.
 TEST(IncludeFixer, InsertAndSortSingleHeader) {
Index: test/include-fixer/insert_header_in_header.cpp
===
--- /dev/null
+++ test/include-fixer/insert_header_in_header.cpp
@@ -0,0 +1,10 @@
+// REQUIRES: shell
+// RUN: echo 'foo f;' > %T/main.h
+// RUN: sed -e 's#//.*$##' %s > %t.cpp
+// RUN: clang-include-fixer -db=yaml -input=%p/Inputs/fake_yaml_db.yaml %t.cpp --
+// RUN: FileCheck %s -input-file=%T/main.h
+
+// CHECK: #include "foo.h"
+// CHECK: foo f;
+
+#include "main.h"
Index: test/include-fixer/commandline_options.cpp
===
--- test/include-fixer/commandline_options.cpp
+++ test/include-fixer/commandline_options.cpp
@@ -1,7 +1,7 @@
 // REQUIRES: shell
 // RUN: sed -e 's#//.*$##' %s > %t.cpp
 // RUN: clang-include-fixer -db=fixed -input='foo= "foo.h","bar.h"' -output-headers %t.cpp -- | FileCheck %s -check-prefix=CHECK-HEADERS
-// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='{SymbolIdentifier: foo, Headers: ["\"foo.h\""]}' %t.cpp | FileCheck %s -check-prefix=CHECK
+// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='{SymbolIdentifier: foo, FilePath: %t.cpp, Headers: ["\"foo.h\""]}' %t.cpp | FileCheck %s -check-prefix=CHECK
 //
 // CHECK-HEADERS: "Headers": [ "\"foo.h\"", "\"bar.h\"" ]
 //
Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -49,11 +49,19 @@
   return p.communicate(input=text)
 
 
-def InsertHeaderToVimBuffer(header, text):
+def InsertHeaderToVimBuffer(header, code):
   command = [binary, "-stdin", "-insert-header="+json.dumps(header),
  vim.current.buffer.name]
-  stdout, stderr = execute(command, text)
+  stdout, stderr = execute(command, code)
+
   if stdout:
+# If the file being inserted is not the current one in vim buffer, just
+# overwrite it in filesystem.
+if header["FilePath"] != vim.current.buffer.name:
+  with open(header["FilePath"], "w") as f:
+f.write(stdout)
+  return
+
 lines = stdout.splitlines()
 sequence = difflib.SequenceMatcher(None, vim.current.buffer, lines)
 for op in reversed(sequence.get_opcodes()):
@@ -72,19 +80,24 @@
 
   # Get the current text.
   buf = vim.current.buffer
-  text = '\n'.join(buf)
+  code = '\n'.join(buf)
 
   # Run command to get all headers.
   command = [binary, "-stdin", "-output-headers", "-db="+args.db,
  "-input="+args.input, vim.current.buffer.name]
-  stdout, stderr = execute(command, text)
+  stdout, stderr = execute(command, code)
   if stderr:
 print >> sys.stderr, "Error while running clang-include-fixer: " + stderr
 return
 
   include_fixer_context = json.loads(stdout)
   symbol = include_fixer_context["SymbolIdentifier"]
   headers = include_fixer_context["Headers"]
+  file_path = include_fixer_context["FilePath"]
+
+  if file_path != vim.current.buffer.name:
+with open(file_path, "r") as f:
+  code = f.read();
 
   if not symbol:
 print "The file is fine, no need to add a header.\n"
@@ -98,8 +111,11 @@
   # If there is only one suggested header, insert it directly.
   if len(headers) == 1 or maximum_suggested_headers == 1:
 InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
- "Headers":[headers[0]]}, text)
-print "Added #include {0} for {1}.\n".format(headers[0], symbol)
+ "Headers": [headers[0]],
+

Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Piotr Padlewski via cfe-commits
Prazek marked 4 inline comments as done.


Comment at: docs/clang-tidy/checks/modernize-use-emplace.rst:6
@@ +5,3 @@
+
+This check would look for cases when inserting new element into an STL
+container, but the element is constructed temporarily or is constructed just

sbarzowski wrote:
> Why "would"? Did you copy the description from the proposal? :-)
yep :D


http://reviews.llvm.org/D20964



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


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Piotr Padlewski via cfe-commits
Prazek updated this revision to Diff 59561.
Prazek marked an inline comment as done.
Prazek added a comment.

Fixed stuff


http://reviews.llvm.org/D20964

Files:
  clang-tidy/modernize/UseEmplaceCheck.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/modernize-use-emplace.rst

Index: docs/clang-tidy/checks/modernize-use-emplace.rst
===
--- docs/clang-tidy/checks/modernize-use-emplace.rst
+++ docs/clang-tidy/checks/modernize-use-emplace.rst
@@ -3,9 +3,8 @@
 modernize-use-emplace
 =
 
-This check would look for cases when inserting new element into an STL
-container, but the element is constructed temporarily or is constructed just
-to be moved. It would also work with std::pair.
+This check look for cases when inserting new element into an STL
+container, but the element is constructed temporarily.
 
 Before:
 
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -209,7 +209,7 @@
 - New `modernize-use-emplace
   `_ 
check
 
-  Finds calls that could be change to emplace.
+  Finds calls that could be changed to emplace.
 
 - New `performance-faster-string-find
   
`_
 check
Index: clang-tidy/modernize/UseEmplaceCheck.cpp
===
--- clang-tidy/modernize/UseEmplaceCheck.cpp
+++ clang-tidy/modernize/UseEmplaceCheck.cpp
@@ -54,16 +54,16 @@
   const auto *PushBackExpr = Result.Nodes.getNodeAs("push_back");
   const auto *InnerCtorCall = Result.Nodes.getNodeAs("ctor");
 
-  auto functionNameSourceRange = CharSourceRange::getCharRange(
+  auto FunctionNameSourceRange = CharSourceRange::getCharRange(
   PushBackExpr->getExprLoc(), Call->getArg(0)->getExprLoc());
 
   auto Diag =
   diag(PushBackExpr->getExprLoc(), "use emplace_back instead of 
push_back");
 
-  if (functionNameSourceRange.getBegin().isMacroID())
+  if (FunctionNameSourceRange.getBegin().isMacroID())
 return;
 
-  Diag << FixItHint::CreateReplacement(functionNameSourceRange,
+  Diag << FixItHint::CreateReplacement(FunctionNameSourceRange,
"emplace_back(");
 
   auto CallParensRange = InnerCtorCall->getParenOrBraceRange();


Index: docs/clang-tidy/checks/modernize-use-emplace.rst
===
--- docs/clang-tidy/checks/modernize-use-emplace.rst
+++ docs/clang-tidy/checks/modernize-use-emplace.rst
@@ -3,9 +3,8 @@
 modernize-use-emplace
 =
 
-This check would look for cases when inserting new element into an STL
-container, but the element is constructed temporarily or is constructed just
-to be moved. It would also work with std::pair.
+This check look for cases when inserting new element into an STL
+container, but the element is constructed temporarily.
 
 Before:
 
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -209,7 +209,7 @@
 - New `modernize-use-emplace
   `_ check
 
-  Finds calls that could be change to emplace.
+  Finds calls that could be changed to emplace.
 
 - New `performance-faster-string-find
   `_ check
Index: clang-tidy/modernize/UseEmplaceCheck.cpp
===
--- clang-tidy/modernize/UseEmplaceCheck.cpp
+++ clang-tidy/modernize/UseEmplaceCheck.cpp
@@ -54,16 +54,16 @@
   const auto *PushBackExpr = Result.Nodes.getNodeAs("push_back");
   const auto *InnerCtorCall = Result.Nodes.getNodeAs("ctor");
 
-  auto functionNameSourceRange = CharSourceRange::getCharRange(
+  auto FunctionNameSourceRange = CharSourceRange::getCharRange(
   PushBackExpr->getExprLoc(), Call->getArg(0)->getExprLoc());
 
   auto Diag =
   diag(PushBackExpr->getExprLoc(), "use emplace_back instead of push_back");
 
-  if (functionNameSourceRange.getBegin().isMacroID())
+  if (FunctionNameSourceRange.getBegin().isMacroID())
 return;
 
-  Diag << FixItHint::CreateReplacement(functionNameSourceRange,
+  Diag << FixItHint::CreateReplacement(FunctionNameSourceRange,
"emplace_back(");
 
   auto CallParensRange = InnerCtorCall->getParenOrBraceRange();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Piotr Padlewski via cfe-commits
Prazek updated this revision to Diff 59562.
Prazek added a comment.

Learning how to use arc


http://reviews.llvm.org/D20964

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tidy/modernize/UseEmplaceCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-emplace.rst
  test/clang-tidy/modernize-use-emplace.cpp

Index: test/clang-tidy/modernize-use-emplace.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-emplace.cpp
@@ -0,0 +1,157 @@
+// RUN: %check_clang_tidy %s modernize-use-emplace %t
+
+namespace std {
+template 
+class vector {
+public:
+  void push_back(const T &) {}
+  void push_back(T &&) {}
+
+  template 
+  void emplace_back(Args &&... args);
+};
+template 
+class pair {
+public:
+  pair() = default;
+  pair(const pair &) = default;
+  pair(pair &&) = default;
+
+  pair(const T1 &, const T2 &) {}
+  pair(T1 &&, T2 &&) {}
+
+  template 
+  pair(const pair &p){};
+  template 
+  pair(pair &&p){};
+};
+
+template 
+pair make_pair(T1, T2) {
+  return pair();
+};
+
+template 
+class unique_ptr {
+public:
+  unique_ptr(T *) {}
+};
+} // namespace std
+
+void testInts() {
+  std::vector v;
+  v.push_back(42);
+  v.push_back(int(42));
+  v.push_back(int{42});
+  int z;
+  v.push_back(z);
+}
+
+struct S {
+  S(int a, int b = 41) {}
+  S() {}
+  void push_back(S);
+};
+
+struct Convertable {
+  operator S() { return S{}; }
+};
+struct Zoz {
+  Zoz(S s) {}
+};
+
+Zoz getZoz(S s) { return Zoz(s); }
+
+void test_S() {
+  std::vector v;
+
+  v.push_back(S(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back instead of push_back [modernize-use-emplace]
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  v.push_back(S{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  v.push_back(S());
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back();
+
+  v.push_back(S{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back();
+
+  v.push_back(42);
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(42);
+
+  S temporary(42, 42);
+  temporary.push_back(temporary);
+  v.push_back(temporary);
+
+  v.push_back(Convertable());
+  v.push_back(Convertable{});
+  Convertable s;
+  v.push_back(s);
+}
+
+void test2() {
+  std::vector v;
+  v.push_back(Zoz(S(21, 37)));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(S(21, 37));
+
+  v.push_back(getZoz(S(1, 2)));
+}
+
+void testPair() {
+  std::vector> v;
+  v.push_back(std::pair(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  std::vector> v2;
+  v2.push_back(std::pair(S(42, 42), Zoz(S(21, 37;
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v2.emplace_back(S(42, 42), Zoz(S(21, 37)));
+}
+
+void testSpaces() {
+  std::vector v;
+
+  // clang-format off
+  v.push_back(S   (1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+  v.push_back(S   {1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  v.push_back(  S {});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back();
+
+  // clang-format on
+}
+
+void testPointers() {
+  std::vector v;
+  v.push_back(new int(5));
+
+  std::vector> v2;
+  v2.push_back(new int(42));
+  // This call can't be replaced with emplace_back.
+  // If emplacement will fail (not enough memory to add to vector)
+  // we will have leak of int because unique_ptr won't be constructed
+  // (and destructed) as in push_back case.
+
+  auto *ptr = new int;
+  v2.push_back(ptr);
+  // Same here
+}
+
+void testMakePair() {
+  std::vector> v;
+  // FIXME: add functionality to change calls of std::make_pair
+  v.push_back(std::make_pair(1, 2));
+}
Index: docs/clang-tidy/checks/modernize-use-emplace.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/modernize-use-emplace.rst
@@ -0,0 +1,60 @@
+.. title:: clang-tidy - modernize-use-emplace
+
+modernize-use-emplace
+=
+
+This check look for cases when inserting new element into an STL
+container, but the element is constructed temporarily.
+
+Before:
+
+.. code:: c++
+
+	std::vector v;
+	v.push_back(MyClass(21, 37));
+
+	std::vector > w;
+	w.push_back(std::make_pair(21, 37));
+
+After:
+
+.. code:: c++
+
+	std::vector v;
+	v.emplace_back(21, 37);
+
+	std::vector > w;
+	v.emplace_back(21, 37);
+
+The other si

Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Piotr Padlewski via cfe-commits
Prazek marked 4 inline comments as done.


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:29
@@ +28,3 @@
+  auto callPushBack =
+  cxxMemberCallExpr(hasDeclaration(functionDecl(hasName(PushBackName))),
+on(hasType(cxxRecordDecl(hasName(VectorName)

I don't think so. In all checks people use lowerCamelCase, because it looks 
like a real matchers


http://reviews.llvm.org/D20964



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


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Piotr Padlewski via cfe-commits
Prazek marked 2 inline comments as done.
Prazek added a comment.

http://reviews.llvm.org/D20964



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


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread David Blaikie via cfe-commits
dblaikie added a subscriber: dblaikie.
dblaikie added a comment.

Could you describe in more detail (ideally in the original patch review 
summary/description) what this transformation does? Under what conditions does 
it suggest emplace, etc.


http://reviews.llvm.org/D20964



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


Re: [PATCH] D20961: [mips] Replace almost all Arch checks in MipsTargetInfo with ABI checks. NFC.

2016-06-03 Thread Simon Atanasyan via cfe-commits
atanasyan accepted this revision.
atanasyan added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D20961



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


Re: [PATCH] D20963: [mips] The P5600 does not support N32/N64 since it's a 32-bit CPU.

2016-06-03 Thread Simon Atanasyan via cfe-commits
atanasyan accepted this revision.
atanasyan added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D20963



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


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Stanisław Barzowski via cfe-commits
sbarzowski added inline comments.


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:30
@@ +29,3 @@
+  cxxMemberCallExpr(hasDeclaration(functionDecl(hasName(PushBackName))),
+on(hasType(cxxRecordDecl(hasName(VectorName)
+  .bind("call");

Maybe it can work with some more types, with minimal changes... Like maybe 
std::list.


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:38
@@ +37,3 @@
+  auto isCtorOfSmartPtr = hasDeclaration(cxxConstructorDecl(
+  ofClass(hasAnyName("std::shared_ptr", "std::unique_ptr", "std::auto_ptr",
+ "std::weak_ptr";

This argument really holds for _any_ class taking ownership of the created 
object.

Maybe it would be better to check if we pass a non-const pointer as an argument 
to the constructor, as a pretty good indicator of taking ownership.

Or maybe just look for `new` operator in the expression.


http://reviews.llvm.org/D20964



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


Re: [PATCH] D20053: [clang-tidy] Add misc-unnecessary-mutable check.

2016-06-03 Thread Etienne Bergeron via cfe-commits
etienneb added inline comments.


Comment at: clang-tidy/misc/UnnecessaryMutableCheck.cpp:23
@@ +22,3 @@
+
+// Matcher checking if the declaration is non-macro existent mutable which is
+// not dependent on context.

add an anonymous namespace around this declaration.


Comment at: clang-tidy/misc/UnnecessaryMutableCheck.cpp:26
@@ +25,3 @@
+AST_MATCHER(FieldDecl, isSubstantialMutable) {
+  return Node.getDeclName() && Node.isMutable() &&
+ !Node.getLocation().isMacroID() &&

why getDeclName ?


Comment at: clang-tidy/misc/UnnecessaryMutableCheck.cpp:42
@@ +41,3 @@
+
+class FieldUseVisitor : public RecursiveASTVisitor {
+public:

Please add a comment to describe the purpose of this class.
The code is the doc, and it will help readers.


Comment at: clang-tidy/misc/UnnecessaryMutableCheck.cpp:56
@@ +55,3 @@
+  bool VisitExpr(Expr *GenericExpr) {
+MemberExpr *Expression = dyn_cast(GenericExpr);
+if (!Expression || Expression->getMemberDecl() != SoughtField)

MemberExpr *Expression  -> const auto*


Comment at: clang-tidy/misc/UnnecessaryMutableCheck.cpp:60
@@ +59,3 @@
+
+// Check if expr is a member of const thing.
+bool IsConstObj = false;

thing -> object


Comment at: clang-tidy/misc/UnnecessaryMutableCheck.cpp:62
@@ +61,3 @@
+bool IsConstObj = false;
+for (const auto *ChildStmt : Expression->children()) {
+  const Expr *ChildExpr = dyn_cast(ChildStmt);

I think the child-expressions of MemberExpr can only be "member->getBase()" ?
In this case, no loop is needed.

```
child_range children() { return child_range(&Base, &Base+1); }
```

```
 Expr *getBase() const { return cast(Base); }
```


Comment at: clang-tidy/misc/UnnecessaryMutableCheck.cpp:134
@@ +133,3 @@
+// All decls need their definitions in main file.
+if (!Declaration->hasBody() ||
+!SM.isInMainFile(Declaration->getBody()->getLocStart())) {

Watch out, Declaration->hasBody() is tricky with code when compile on windows 
(clang-cl).
hasBody() may return true, but the getBody() may be NULL.

This is why these tests exist:
```
cppcoreguidelines-pro-type-member-init-delayed.cpp
modernize-redundant-void-arg-delayed.cpp
modernize-use-default-delayed.cpp
performance-unnecessary-value-param-delayed.cpp
```
So this code may crash with delayed-template-parsing.



Comment at: clang-tidy/misc/UnnecessaryMutableCheck.cpp:213
@@ +212,3 @@
+  diag(FD->getLocation(), "'mutable' modifier is unnecessary for field %0")
+  << FD->getDeclName();
+

no need for ->getDeclName()
There is an overloaded operator for namedDecl.


Comment at: clang-tidy/misc/UnnecessaryMutableCheck.cpp:217
@@ +216,3 @@
+
+  if (CheckRemoval(SM, FD->getLocStart(), FD->getLocEnd(), Context,
+   RemovalRange)) {

You can change CheckRemoval to return the SourceRange.
If it's failing, you can call 'fixithint <<' and it won't be an issue.

This way, you do not need to declare Diag, and you can directly add the 
sourceRange to the expression to line 213.

```
 diag(FD->getLocation(), "'mutable' modifier is unnecessary for field %0")
  << FD
  << getSourceRangeOfMutableToken(FD);
```

WDYT?


http://reviews.llvm.org/D20053



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


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Piotr Padlewski via cfe-commits
Prazek added inline comments.


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:31
@@ +30,3 @@
+on(hasType(cxxRecordDecl(hasName(VectorName)
+  .bind("call");
+

ok, std::list works for me. I just don't want to spend much time on it right 
now, and I want to be sure it works.


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:39
@@ +38,3 @@
+  ofClass(hasAnyName("std::shared_ptr", "std::unique_ptr", "std::auto_ptr",
+ "std::weak_ptr";
+

Look at tests - the same thing happens when

std::vector> v;

const auto *p = new int;
v.push_back(p);

Not many custom classes take pointer in constructor. 
If I will look for const pointers, then I will not be able to pass "abc" into 
vector.

So I guess this solution seems to be the best idea. 


http://reviews.llvm.org/D20964



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


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Piotr Padlewski via cfe-commits
Prazek updated this revision to Diff 59568.
Prazek added a comment.

- Post review fix


http://reviews.llvm.org/D20964

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tidy/modernize/UseEmplaceCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-emplace.rst
  test/clang-tidy/modernize-use-emplace.cpp

Index: test/clang-tidy/modernize-use-emplace.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-emplace.cpp
@@ -0,0 +1,189 @@
+// RUN: %check_clang_tidy %s modernize-use-emplace %t
+
+namespace std {
+template 
+class vector {
+public:
+  void push_back(const T &) {}
+  void push_back(T &&) {}
+
+  template 
+  void emplace_back(Args &&... args);
+};
+template 
+class list {
+public:
+  void push_back(const T &) {}
+  void push_back(T &&) {}
+
+  template 
+  void emplace_back(Args &&... args);
+};
+
+template 
+class deque {
+public:
+  void push_back(const T &) {}
+  void push_back(T &&) {}
+
+  template 
+  void emplace_back(Args &&... args);
+};
+
+template 
+class pair {
+public:
+  pair() = default;
+  pair(const pair &) = default;
+  pair(pair &&) = default;
+
+  pair(const T1 &, const T2 &) {}
+  pair(T1 &&, T2 &&) {}
+
+  template 
+  pair(const pair &p){};
+  template 
+  pair(pair &&p){};
+};
+
+template 
+pair make_pair(T1, T2) {
+  return pair();
+};
+
+template 
+class unique_ptr {
+public:
+  unique_ptr(T *) {}
+};
+} // namespace std
+
+void testInts() {
+  std::vector v;
+  v.push_back(42);
+  v.push_back(int(42));
+  v.push_back(int{42});
+  int z;
+  v.push_back(z);
+}
+
+struct S {
+  S(int a, int b = 41) {}
+  S() {}
+  void push_back(S);
+};
+
+struct Convertable {
+  operator S() { return S{}; }
+};
+struct Zoz {
+  Zoz(S s) {}
+};
+
+Zoz getZoz(S s) { return Zoz(s); }
+
+void test_S() {
+  std::vector v;
+
+  v.push_back(S(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back instead of push_back [modernize-use-emplace]
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  v.push_back(S{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  v.push_back(S());
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back();
+
+  v.push_back(S{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back();
+
+  v.push_back(42);
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(42);
+
+  S temporary(42, 42);
+  temporary.push_back(temporary);
+  v.push_back(temporary);
+
+  v.push_back(Convertable());
+  v.push_back(Convertable{});
+  Convertable s;
+  v.push_back(s);
+}
+
+void test2() {
+  std::vector v;
+  v.push_back(Zoz(S(21, 37)));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(S(21, 37));
+
+  v.push_back(getZoz(S(1, 2)));
+}
+
+void testPair() {
+  std::vector> v;
+  v.push_back(std::pair(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  std::vector> v2;
+  v2.push_back(std::pair(S(42, 42), Zoz(S(21, 37;
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v2.emplace_back(S(42, 42), Zoz(S(21, 37)));
+}
+
+void testSpaces() {
+  std::vector v;
+
+  // clang-format off
+  v.push_back(S   (1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+  v.push_back(S   {1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  v.push_back(  S {});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back();
+
+  // clang-format on
+}
+
+void testPointers() {
+  std::vector v;
+  v.push_back(new int(5));
+
+  std::vector> v2;
+  v2.push_back(new int(42));
+  // This call can't be replaced with emplace_back.
+  // If emplacement will fail (not enough memory to add to vector)
+  // we will have leak of int because unique_ptr won't be constructed
+  // (and destructed) as in push_back case.
+
+  auto *ptr = new int;
+  v2.push_back(ptr);
+  // Same here
+}
+
+void testMakePair() {
+  std::vector> v;
+  // FIXME: add functionality to change calls of std::make_pair
+  v.push_back(std::make_pair(1, 2));
+}
+
+void testOtherCointainers() {
+  std::list l;
+  l.push_back(S(42, 41));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: l.emplace_back(42, 41);
+
+  std::deque d;
+  d.push_back(S(42));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: d.emplace_back(42);
+}
Index: docs/clang-tidy/checks/modernize-use-emplace.rs

Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Stanisław Barzowski via cfe-commits
sbarzowski added inline comments.


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:40
@@ +39,3 @@
+  // passed pointer because smart pointer won't be constructed
+  // (and destructed) as in push_back case.
+  auto isCtorOfSmartPtr = hasDeclaration(cxxConstructorDecl(

> Look at tests - the same thing happens when

Yeah. I meant looking for `new` in addition to blacklist.

> Not many custom classes take pointer in constructor. 

Obviously depends on codebase, but IMO it's quite common. However usually this 
classes aren't copy-constructible (or at least shouldn't be) anyway, making it 
impossible to use push_back, so maybe it's not such a big deal.

> If I will look for const pointers, then I will not be able to pass "abc" into 
> vector.

I wrote explicitly about only **non**-const pointers.


http://reviews.llvm.org/D20964



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


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

2016-06-03 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7347
@@ -7346,3 +7346,3 @@
 def err_blocks_disable : Error<"blocks support disabled - compile with 
-fblocks"
-  " or pick a deployment target that supports them">;
+  " or %select{pick a deployment target that supports them|as OpenCL 2.0 or 
above}0">;
 def err_block_returning_array_function : Error<

-> for OpenCL version 2.0 or above


Comment at: test/Headers/opencl-c-header.cl:50
@@ +49,3 @@
+// RUN: %clang_cc1 -cc1 -triple spir-unknown-unknown -emit-llvm -o - 
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -fdisable-module-hash %s | FileCheck %s
+// RUN: diff %t/1_0.pcm %t/opencl_c.pcm
+// RUN: rm %t/opencl_c.pcm

Sam, what was the aim of this test?

I was just wondering if we should instead check that the file is exactly the 
same i.e. hasn't been overwritten with exactly the same content?


Comment at: test/Headers/opencl-c-header.cl:53-54
@@ +52,4 @@
+
+// ===
+// Compile for OpenCL 2.0 for the first time. The module should change.
+// RUN: %clang_cc1 -cc1 -triple spir-unknown-unknown -emit-llvm -o - 
-cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -fdisable-module-hash %s | FileCheck 
--check-prefix=CHECK20 %s

Indeed PCH size is an issue. I don't quite get why it expands from the original 
source code size by a factor or 2. Something to look at!


Comment at: test/Headers/opencl-c-header.cl:70
@@ +69,3 @@
+// RUN: %clang_cc1 -cc1 -triple amdgcn--amdhsa -emit-llvm -o - -cl-std=CL2.0  
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t %s | FileCheck --check-prefix=CHECK20 %s
+// RUN: %clang_cc1 -cc1 -triple spir-unknown-unknown -emit-llvm -o - 
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t %s | FileCheck %s
+// RUN: %clang_cc1 -cc1 -triple spir-unknown-unknown -emit-llvm -o - 
-cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t %s | FileCheck --check-prefix=CHECK20 %s

This line seems exactly the same as line 67.


http://reviews.llvm.org/D20444



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


Re: [PATCH] D20090: [OPENCL] Fix wrongly vla error for OpenCL array.

2016-06-03 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.

LGTM! Thanks!


http://reviews.llvm.org/D20090



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


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Piotr Padlewski via cfe-commits
Prazek marked 2 inline comments as done.


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:40
@@ +39,3 @@
+  // passed pointer because smart pointer won't be constructed
+  // (and destructed) as in push_back case.
+  auto isCtorOfSmartPtr = hasDeclaration(cxxConstructorDecl(

sbarzowski wrote:
> > Look at tests - the same thing happens when
> 
> Yeah. I meant looking for `new` in addition to blacklist.
> 
> > Not many custom classes take pointer in constructor. 
> 
> Obviously depends on codebase, but IMO it's quite common. However usually 
> this classes aren't copy-constructible (or at least shouldn't be) anyway, 
> making it impossible to use push_back, so maybe it's not such a big deal.
> 
> > If I will look for const pointers, then I will not be able to pass "abc" 
> > into vector.
> 
> I wrote explicitly about only **non**-const pointers.
It doesn't matter if it is const or not. Disabling any of them would disable 
some cases where it would be good.
I have to run it on llvm code base and see what happens


http://reviews.llvm.org/D20964



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


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Stanisław Barzowski via cfe-commits
sbarzowski added inline comments.


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:40
@@ +39,3 @@
+  // passed pointer because smart pointer won't be constructed
+  // (and destructed) as in push_back case.
+  auto isCtorOfSmartPtr = hasDeclaration(cxxConstructorDecl(

Prazek wrote:
> sbarzowski wrote:
> > > Look at tests - the same thing happens when
> > 
> > Yeah. I meant looking for `new` in addition to blacklist.
> > 
> > > Not many custom classes take pointer in constructor. 
> > 
> > Obviously depends on codebase, but IMO it's quite common. However usually 
> > this classes aren't copy-constructible (or at least shouldn't be) anyway, 
> > making it impossible to use push_back, so maybe it's not such a big deal.
> > 
> > > If I will look for const pointers, then I will not be able to pass "abc" 
> > > into vector.
> > 
> > I wrote explicitly about only **non**-const pointers.
> It doesn't matter if it is const or not. Disabling any of them would disable 
> some cases where it would be good.
> I have to run it on llvm code base and see what happens
Of course there would be some false negatives. It's close to impossible to know 
for sure if it's safe, so we need some sort of heuristic. My concern is that 
the current "blacklist smart pointers" solution may lead to a lot of false 
positives. And false positives here are quite nasty - very subtle bugs, that 
are unlikely to be caught by the tests or quick code review. So I'm more 
comfortable with false negatives.


http://reviews.llvm.org/D20964



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


r271688 - Obj-C: Fix assert-on-invalid (PR27822)

2016-06-03 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Fri Jun  3 11:59:13 2016
New Revision: 271688

URL: http://llvm.org/viewvc/llvm-project?rev=271688&view=rev
Log:
Obj-C: Fix assert-on-invalid (PR27822)

Clang would assert when isObjCInstancetype() was called on a
tok::annot_cxxscope token.

Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/test/SemaObjCXX/instancetype.mm

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=271688&r1=271687&r2=271688&view=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Fri Jun  3 11:59:13 2016
@@ -647,6 +647,8 @@ private:
   /// Should only be used in Objective-C language modes.
   bool isObjCInstancetype() {
 assert(getLangOpts().ObjC1);
+if (Tok.isAnnotation())
+  return false;
 if (!Ident_instancetype)
   Ident_instancetype = PP.getIdentifierInfo("instancetype");
 return Tok.getIdentifierInfo() == Ident_instancetype;

Modified: cfe/trunk/test/SemaObjCXX/instancetype.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/instancetype.mm?rev=271688&r1=271687&r2=271688&view=diff
==
--- cfe/trunk/test/SemaObjCXX/instancetype.mm (original)
+++ cfe/trunk/test/SemaObjCXX/instancetype.mm Fri Jun  3 11:59:13 2016
@@ -214,3 +214,10 @@ void test_instancetype_inherited() {
   return 0;
 }
 @end
+
+// PR27822
+@class NSString;
+namespace pr27822 { }
+@interface AXPlatformNodeCocoa
++ (NSString*)nativeRoleFromAXRole:(pr27822::UndeclaredIdentifier)role; // 
expected-error {{expected a type}}
+@end


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


Re: [PATCH] D20681: Add target-specific pre-linking passes to Clang

2016-06-03 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Do you think we could add any test for this change?



Comment at: lib/CodeGen/BackendUtil.cpp:657
@@ -627,2 +656,3 @@
 
+
 bool EmitAssemblyHelper::AddEmitPasses(BackendAction Action,

Remove the empty line please


Comment at: lib/CodeGen/CodeGenAction.cpp:169
@@ +168,3 @@
+  std::function
+LinkCallBack = [=](llvm::Module *M)->bool {
+// Link LinkModule into this module if present, preserving its 
validity.

Is there any reason for having this as a callback now?

Could we just add a call to prelink passes here above instead without modifying 
much the original flow?


http://reviews.llvm.org/D20681



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


r271689 - Fix test for LLVM_LIBDIR_SUFFIX=64 case.

2016-06-03 Thread Ismail Donmez via cfe-commits
Author: ismail
Date: Fri Jun  3 12:06:52 2016
New Revision: 271689

URL: http://llvm.org/viewvc/llvm-project?rev=271689&view=rev
Log:
Fix test for LLVM_LIBDIR_SUFFIX=64 case.


Modified:
cfe/trunk/test/Driver/android-ndk-standalone.cpp

Modified: cfe/trunk/test/Driver/android-ndk-standalone.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/android-ndk-standalone.cpp?rev=271689&r1=271688&r2=271689&view=diff
==
--- cfe/trunk/test/Driver/android-ndk-standalone.cpp (original)
+++ cfe/trunk/test/Driver/android-ndk-standalone.cpp Fri Jun  3 12:06:52 2016
@@ -17,7 +17,7 @@
 // CHECK-NOT: "-internal-isystem" 
"{{.*}}/include/c++/4.9/arm-linux-androideabi/thumb"
 // CHECK: "-internal-isystem" "{{.*}}/include/c++/4.9/backward"
 // CHECK: "-internal-isystem" "{{.*}}/sysroot/usr/local/include"
-// CHECK: "-internal-isystem" 
"{{.*(/|)}}lib{{(/|)}}clang{{(/|)[^"]+(/|)}}include"
+// CHECK: "-internal-isystem" 
"{{.*(/|)}}lib{{(64)?(/|)}}clang{{(/|)[^"]+(/|)}}include"
 // CHECK: "-internal-externc-isystem" "{{.*}}/sysroot/include"
 // CHECK: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include"
 // CHECK: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
@@ -53,7 +53,7 @@
 // CHECK-ARMV7-NOT: "-internal-isystem" 
"{{.*}}/include/c++/4.9/arm-linux-androideabi"
 // CHECK-ARMV7: "-internal-isystem" "{{.*}}/include/c++/4.9/backward"
 // CHECK-ARMV7: "-internal-isystem" "{{.*}}/sysroot/usr/local/include"
-// CHECK-ARMV7: "-internal-isystem" 
"{{.*(/|)}}lib{{(/|)}}clang{{(/|)[^"]+(/|)}}include"
+// CHECK-ARMV7: "-internal-isystem" 
"{{.*(/|)}}lib{{(64)?(/|)}}clang{{(/|)[^"]+(/|)}}include"
 // CHECK-ARMV7: "-internal-externc-isystem" "{{.*}}/sysroot/include"
 // CHECK-ARMV7: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include"
 // CHECK-ARMV7: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
@@ -111,7 +111,7 @@
 // CHECK-THUMB-NOT: "-internal-isystem" 
"{{.*}}/include/c++/4.9/arm-linux-androideabi"
 // CHECK-THUMB: "-internal-isystem" "{{.*}}/include/c++/4.9/backward"
 // CHECK-THUMB: "-internal-isystem" "{{.*}}/sysroot/usr/local/include"
-// CHECK-THUMB: "-internal-isystem" 
"{{.*(/|)}}lib{{(/|)}}clang{{(/|)[^"]+(/|)}}include"
+// CHECK-THUMB: "-internal-isystem" 
"{{.*(/|)}}lib{{(64)?(/|)}}clang{{(/|)[^"]+(/|)}}include"
 // CHECK-THUMB: "-internal-externc-isystem" "{{.*}}/sysroot/include"
 // CHECK-THUMB: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include"
 // CHECK-THUMB: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
@@ -149,7 +149,7 @@
 // CHECK-ARMV7THUMB-NOT: "-internal-isystem" 
"{{.*}}/include/c++/4.9/arm-linux-androideabi"
 // CHECK-ARMV7THUMB: "-internal-isystem" "{{.*}}/include/c++/4.9/backward"
 // CHECK-ARMV7THUMB: "-internal-isystem" "{{.*}}/sysroot/usr/local/include"
-// CHECK-ARMV7THUMB: "-internal-isystem" 
"{{.*(/|)}}lib{{(/|)}}clang{{(/|)[^"]+(/|)}}include"
+// CHECK-ARMV7THUMB: "-internal-isystem" 
"{{.*(/|)}}lib{{(64)?(/|)}}clang{{(/|)[^"]+(/|)}}include"
 // CHECK-ARMV7THUMB: "-internal-externc-isystem" "{{.*}}/sysroot/include"
 // CHECK-ARMV7THUMB: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include"
 // CHECK-ARMV7THUMB: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"


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


Re: r271427 - [driver][arm] add armv7 and thumb include and lib paths

2016-06-03 Thread Ismail Donmez via cfe-commits
Fixed in r271689.

On Fri, Jun 3, 2016 at 9:55 AM, Ismail Donmez  wrote:
> This is due to lib vs lib64. Will fix. Sorry for the wrong diagnosis :)
>
> On Thu, Jun 2, 2016 at 8:24 PM, Chih-hung Hsieh  wrote:
>> Ismail,
>> I saw that android-ndk-standalone.cpp has already -stdlib=libstdc++.
>> Could you tell me or just go ahead and make the necessary change?
>> Thanks.
>>
>>
>> On Thu, Jun 2, 2016 at 9:52 AM, Ismail Donmez  wrote:
>>>
>>> Hi,
>>>
>>> On Wed, Jun 1, 2016 at 11:48 PM, Chih-Hung Hsieh via cfe-commits
>>>  wrote:
>>> > Author: chh
>>> > Date: Wed Jun  1 15:48:46 2016
>>> > New Revision: 271427
>>> >
>>> > URL: http://llvm.org/viewvc/llvm-project?rev=271427&view=rev
>>> > Log:
>>> > [driver][arm] add armv7 and thumb include and lib paths
>>> >
>>> > Add a new test android-ndk-standalone.cpp
>>> > with new Android NDK release tree structure.
>>> > Detect armv7 sub architecture and thumb mode,
>>> > to add system include and link search paths.
>>> >
>>> > Differential Revision: http://reviews.llvm.org/D20600
>>> >
>>>
>>> android-ndk-standalone.cpp needs -stdlib=libstdc++ to fix test on
>>> libc++ default systems.
>>>
>>> ismail
>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: r271413 - Fixup list of available extensions

2016-06-03 Thread Anastasia Stulova via cfe-commits
Hi Jan,

In the future could you please keep "[OpenCL]" prefix for all commit messages 
related to OpenCL. :)

Thanks,
Anastasia
 
-Original Message-
From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of Jan 
Vesely via cfe-commits
Sent: 01 June 2016 19:05
To: cfe-commits@lists.llvm.org
Subject: r271413 - Fixup list of available extensions

Author: jvesely
Date: Wed Jun  1 13:04:50 2016
New Revision: 271413

URL: http://llvm.org/viewvc/llvm-project?rev=271413&view=rev
Log:
Fixup list of available extensions

Reviewers: Anastasia

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

Added:
cfe/trunk/test/SemaOpenCL/extension-version.cl
Modified:
cfe/trunk/include/clang/Basic/OpenCLExtensions.def

Modified: cfe/trunk/include/clang/Basic/OpenCLExtensions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenCLExtensions.def?rev=271413&r1=271412&r2=271413&view=diff
==
--- cfe/trunk/include/clang/Basic/OpenCLExtensions.def (original)
+++ cfe/trunk/include/clang/Basic/OpenCLExtensions.def Wed Jun  1 
+++ 13:04:50 2016
@@ -34,35 +34,39 @@
 #endif // OPENCLEXT_INTERNAL
 
 // OpenCL 1.0.
-OPENCLEXT_INTERNAL(cl_khr_3d_image_writes, 100, 120)
+OPENCLEXT_INTERNAL(cl_khr_3d_image_writes, 100, 200) // fprounding mode 
+is special since it is not mentioned beyond 1.0 
+OPENCLEXT_INTERNAL(cl_khr_select_fprounding_mode, 100, 110)
 OPENCLEXT_INTERNAL(cl_khr_byte_addressable_store, 100, 110)  
OPENCLEXT_INTERNAL(cl_khr_fp16, 100, ~0U)  OPENCLEXT_INTERNAL(cl_khr_fp64, 100, 
120)  OPENCLEXT_INTERNAL(cl_khr_global_int32_base_atomics, 100, 110)  
OPENCLEXT_INTERNAL(cl_khr_global_int32_extended_atomics, 100, 110) 
-OPENCLEXT_INTERNAL(cl_khr_gl_sharing, 100, ~0U) 
-OPENCLEXT_INTERNAL(cl_khr_icd, 100, ~0U)  
OPENCLEXT_INTERNAL(cl_khr_local_int32_base_atomics, 100, 110)  
OPENCLEXT_INTERNAL(cl_khr_local_int32_extended_atomics, 100, 110)
+OPENCLEXT_INTERNAL(cl_khr_int64_base_atomics, 100, ~0U) 
+OPENCLEXT_INTERNAL(cl_khr_int64_extended_atomics, 100, ~0U) 
+OPENCLEXT_INTERNAL(cl_khr_gl_sharing, 100, ~0U) 
+OPENCLEXT_INTERNAL(cl_khr_icd, 100, ~0U)
 
 // OpenCL 1.1.
-OPENCLEXT_INTERNAL(cl_khr_d3d10_sharing, 110, ~0U)  
OPENCLEXT_INTERNAL(cl_khr_gl_event, 110, ~0U) 
-OPENCLEXT_INTERNAL(cl_khr_int64_base_atomics, 110, ~0U) 
-OPENCLEXT_INTERNAL(cl_khr_int64_extended_atomics, 110, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_d3d10_sharing, 110, ~0U)
 
 // OpenCL 1.2.
+OPENCLEXT_INTERNAL(cl_khr_context_abort, 120, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_d3d11_sharing, 120, ~0U)  
OPENCLEXT_INTERNAL(cl_khr_depth_images, 120, ~0U)  
OPENCLEXT_INTERNAL(cl_khr_dx9_media_sharing, 120, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_image2d_from_buffer, 120, ~0U) 
+OPENCLEXT_INTERNAL(cl_khr_initialize_memory, 120, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_gl_depth_images, 120, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_gl_msaa_sharing, 120, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_spir, 120, ~0U)
 
 // OpenCL 2.0.
 OPENCLEXT_INTERNAL(cl_khr_egl_event, 200, ~0U)  
OPENCLEXT_INTERNAL(cl_khr_egl_image, 200, ~0U) 
-OPENCLEXT_INTERNAL(cl_khr_gl_msaa_sharing, 200, ~0U) 
-OPENCLEXT_INTERNAL(cl_khr_initialize_memory, 200, ~0U)  
OPENCLEXT_INTERNAL(cl_khr_srgb_image_writes, 200, ~0U)  
OPENCLEXT_INTERNAL(cl_khr_subgroups, 200, ~0U)  
OPENCLEXT_INTERNAL(cl_khr_terminate_context, 200, ~0U)

Added: cfe/trunk/test/SemaOpenCL/extension-version.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/extension-version.cl?rev=271413&view=auto
==
--- cfe/trunk/test/SemaOpenCL/extension-version.cl (added)
+++ cfe/trunk/test/SemaOpenCL/extension-version.cl Wed Jun  1 13:04:50 
+++ 2016
@@ -0,0 +1,225 @@
+// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple 
+spir-unknown-unknown // RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify 
+-triple spir-unknown-unknown // RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s 
+-verify -triple spir-unknown-unknown // RUN: %clang_cc1 -x cl 
+-cl-std=CL2.0 %s -verify -triple spir-unknown-unknown
+
+#if __OPENCL_C_VERSION__ >= 200
+// expected-no-diagnostics
+#endif
+
+// Extensions in all versions
+#ifndef cl_clang_storage_class_specifiers #error "Missing 
+cl_clang_storage_class_specifiers define"
+#endif
+#pragma OPENCL EXTENSION cl_clang_storage_class_specifiers: enable
+
+#ifndef cl_khr_fp16
+#error "Missing cl_khr_fp16 define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_fp16: enable
+
+#ifndef cl_khr_int64_base_atomics
+#error "Missing cl_khr_int64_base_atomics define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_int64_base_atomics: enable
+
+#ifndef cl_khr_int64_extended_atomics
+#error "Missing cl_khr_int64_extended_atomics define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_int64_extended_atomics: enable
+
+#ifndef cl_khr_gl_sharing
+#error "Missing cl_khr_gl_sharing define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_gl_sharing: enable
+
+#ifndef cl_khr_icd
+#error "Missing cl_khr_icd 

Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added a comment.

I think will be good idea to try this check with LLVM STL too.



Comment at: docs/clang-tidy/checks/modernize-use-emplace.rst:47
@@ +46,3 @@
+
+In this case the calls of push_back won't be replaced.
+

Please highlight push_back with ``.


Comment at: docs/clang-tidy/checks/modernize-use-emplace.rst:55
@@ +54,3 @@
+
+This is because replacing it with emplace_back could cause a leak of this
+this pointer, if emplace_back would throw exception before emplacement

Please highlight emplace_back with ``. Same below.


Comment at: test/clang-tidy/modernize-use-emplace.cpp:12
@@ +11,3 @@
+  void emplace_back(Args &&... args);
+};
+template 

Please insert new line.


Comment at: test/clang-tidy/modernize-use-emplace.cpp:78
@@ +77,3 @@
+  operator S() { return S{}; }
+};
+struct Zoz {

Please insert new line.


http://reviews.llvm.org/D20964



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


Re: Don't pass --build-id by default.

2016-06-03 Thread Ed Maste via cfe-commits
On 2 June 2016 at 21:19, Hal Finkel via cfe-commits
 wrote:
> - Original Message -
>> From: "Rafael Espíndola" 
>> To: "Hal Finkel" 
>> Cc: "cfe-commits cfe" 
>> Sent: Thursday, June 2, 2016 7:06:26 PM
>> Subject: Re: Don't pass --build-id by default.
>>
>> > This is going to break a lot of my local rpm packaging scripts, and
>> > I suspect the same is true for others. This is not a huge deal,
>> > but I wonder if we should emulate GCC is this regard and provide
>> > some CMake option to keep the current behavior?
>>
>> Yes, a cmake option is probably best.
>>
>> What do you think of the attached patch (still building).
>
> Seems reasonable to me.

This sounds like the right approach to me too.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20338: [PCH] Fixed overridden files always invalidating preamble even when unchanged

2016-06-03 Thread Cameron via cfe-commits
cameron314 updated the summary for this revision.
cameron314 removed rL LLVM as the repository for this revision.
cameron314 updated this revision to Diff 59577.
cameron314 added a comment.

It took some modifications to the ASTUnit to support a virtual file system with 
a PCH parse/reparse (preliminary VFS support had already been added in 
http://reviews.llvm.org/rL249410 but it did not support initial parses using 
PCHs, nor reparses), but I was finally able to write a test that checks that 
the reparse actually uses the PCH with my fix, and rejects the PCH (rereading 
everything and failing the test) without it.


http://reviews.llvm.org/D20338

Files:
  include/clang/Basic/FileManager.h
  include/clang/Frontend/ASTUnit.h
  lib/Basic/FileManager.cpp
  lib/Frontend/ASTUnit.cpp
  unittests/Frontend/CMakeLists.txt
  unittests/Frontend/PchPreambleTest.cpp

Index: unittests/Frontend/PchPreambleTest.cpp
===
--- /dev/null
+++ unittests/Frontend/PchPreambleTest.cpp
@@ -0,0 +1,155 @@
+//-- unittests/Frontend/PchPreambleTest.cpp - FrontendAction tests ---//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Frontend/ASTUnit.h"
+#include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Frontend/FrontendOptions.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/FileManager.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace llvm;
+using namespace clang;
+
+namespace {
+
+class ReadCountingInMemoryFileSystem : public vfs::InMemoryFileSystem
+{
+  std::map ReadCounts;
+
+public:
+  ErrorOr> openFileForRead(const Twine &Path) override
+  {
+SmallVector PathVec;
+Path.toVector(PathVec);
+llvm::sys::path::remove_dots(PathVec, true);
+++ReadCounts[std::string(PathVec.begin(), PathVec.end())];
+return InMemoryFileSystem::openFileForRead(Path);
+  }
+
+  unsigned GetReadCount(const Twine &Path) const
+  {
+auto it = ReadCounts.find(Path.str());
+return it == ReadCounts.end() ? 0 : it->second;
+  }
+};
+
+class PchPreambleTest : public ::testing::Test {
+  IntrusiveRefCntPtr VFS;
+  StringMap RemappedFiles;
+  std::shared_ptr PCHContainerOpts;
+  FileSystemOptions FSOpts;
+
+public:
+  void SetUp() override {
+VFS = new ReadCountingInMemoryFileSystem();
+// We need the working directory to be set to something absolute,
+// otherwise it ends up being inadvertently set to the current
+// working directory in the real file system due to a series of
+// unfortunate conditions interacting badly.
+// What's more, this path *must* be absolute on all (real)
+// filesystems, so just '/' won't work (e.g. on Win32).
+VFS->setCurrentWorkingDirectory("//./");
+  }
+
+  void TearDown() override {
+  }
+
+  void AddFile(const std::string &Filename, const std::string &Contents) {
+::time_t now;
+::time(&now);
+VFS->addFile(Filename, now, MemoryBuffer::getMemBufferCopy(Contents, Filename));
+  }
+
+  void RemapFile(const std::string &Filename, const std::string &Contents) {
+RemappedFiles[Filename] = Contents;
+  }
+
+  std::unique_ptr ParseAST(const std::string &EntryFile) {
+PCHContainerOpts = std::make_shared();
+CompilerInvocation *CI = new CompilerInvocation;
+CI->getFrontendOpts().Inputs.push_back(
+  FrontendInputFile(EntryFile, FrontendOptions::getInputKindForExtension(
+llvm::sys::path::extension(EntryFile).substr(1;
+
+CI->getTargetOpts().Triple = "i386-unknown-linux-gnu";
+
+CI->getPreprocessorOpts().RemappedFileBuffers = GetRemappedFiles();
+
+PreprocessorOptions &PPOpts = CI->getPreprocessorOpts();
+PPOpts.RemappedFilesKeepOriginalName = true;
+
+IntrusiveRefCntPtr
+  Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions));
+
+FileManager *FileMgr = new FileManager(FSOpts, VFS);
+
+std::unique_ptr AST = ASTUnit::LoadFromCompilerInvocation(
+  CI, PCHContainerOpts, Diags, FileMgr, false, false,
+  /*PrecompilePreambleAfterNParses=*/1);
+return AST;
+  }
+
+  bool ReparseAST(const std::unique_ptr &AST) {
+FileManager *FileMgr = new FileManager(FSOpts, VFS);
+bool reparseFailed = AST->Reparse(PCHContainerOpts, GetRemappedFiles(), FileMgr);
+return reparseFailed;
+  }
+
+  unsigned GetFileReadCount(const std::string &Filename) const {
+return VFS->GetReadCount(Filename);
+  }
+
+private:
+  std::vector>
+  GetRemappedFiles() const {
+std::vector> Remapped;
+for (const auto &RemappedFile : RemappedFiles) {
+  std::unique_ptr buf = MemoryBuffer::getMemBufferC

r271692 - Don't pass --build-id to ld by default.

2016-06-03 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Fri Jun  3 12:26:16 2016
New Revision: 271692

URL: http://llvm.org/viewvc/llvm-project?rev=271692&view=rev
Log:
Don't pass --build-id to ld by default.

We now have a cmake option to change the default: ENABLE_LINKER_BUILD_ID.

The reason is that build-id is fairly expensive, so we shouldn't impose
it in the regular edit/build cycle.

This is similar to gcc, that has an off by default --enable-linker-build-id
option.

Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/include/clang/Config/config.h.cmake
cfe/trunk/lib/Driver/ToolChains.cpp

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=271692&r1=271691&r2=271692&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Fri Jun  3 12:26:16 2016
@@ -197,6 +197,8 @@ set(GCC_INSTALL_PREFIX "" CACHE PATH "Di
 set(DEFAULT_SYSROOT "" CACHE PATH
   "Default  to all compiler invocations for --sysroot=." )
 
+set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld")
+
 set(CLANG_DEFAULT_CXX_STDLIB "" CACHE STRING
   "Default C++ stdlib to use (empty for architecture default, \"libstdc++\" or 
\"libc++\"")
 if (NOT(CLANG_DEFAULT_CXX_STDLIB STREQUAL "" OR

Modified: cfe/trunk/include/clang/Config/config.h.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Config/config.h.cmake?rev=271692&r1=271691&r2=271692&view=diff
==
--- cfe/trunk/include/clang/Config/config.h.cmake (original)
+++ cfe/trunk/include/clang/Config/config.h.cmake Fri Jun  3 12:26:16 2016
@@ -38,4 +38,7 @@
 /* Linker version detected at compile time. */
 #cmakedefine HOST_LINK_VERSION "${HOST_LINK_VERSION}"
 
+/* pass --build-id to ld */
+#cmakedefine ENABLE_LINKER_BUILD_ID
+
 #endif

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=271692&r1=271691&r2=271692&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Jun  3 12:26:16 2016
@@ -3978,10 +3978,9 @@ Linux::Linux(const Driver &D, const llvm
   if (IsRedhat(Distro) && Distro != RHEL5 && Distro != RHEL6)
 ExtraOpts.push_back("--no-add-needed");
 
-  if ((IsDebian(Distro) && Distro >= DebianSqueeze) || IsOpenSUSE(Distro) ||
-  (IsRedhat(Distro) && Distro != RHEL5) ||
-  (IsUbuntu(Distro) && Distro >= UbuntuKarmic))
-ExtraOpts.push_back("--build-id");
+#ifdef ENABLE_LINKER_BUILD_ID
+  ExtraOpts.push_back("--build-id");
+#endif
 
   if (IsOpenSUSE(Distro))
 ExtraOpts.push_back("--enable-new-dtags");


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


Re: Don't pass --build-id by default.

2016-06-03 Thread Rafael Espíndola via cfe-commits
r271692, thanks.

Cheers,
Rafael


On 3 June 2016 at 10:19, Ed Maste  wrote:
> On 2 June 2016 at 21:19, Hal Finkel via cfe-commits
>  wrote:
>> - Original Message -
>>> From: "Rafael Espíndola" 
>>> To: "Hal Finkel" 
>>> Cc: "cfe-commits cfe" 
>>> Sent: Thursday, June 2, 2016 7:06:26 PM
>>> Subject: Re: Don't pass --build-id by default.
>>>
>>> > This is going to break a lot of my local rpm packaging scripts, and
>>> > I suspect the same is true for others. This is not a huge deal,
>>> > but I wonder if we should emulate GCC is this regard and provide
>>> > some CMake option to keep the current behavior?
>>>
>>> Yes, a cmake option is probably best.
>>>
>>> What do you think of the attached patch (still building).
>>
>> Seems reasonable to me.
>
> This sounds like the right approach to me too.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: r269670 - [OpenCL] Add supported OpenCL extensions to target info.

2016-06-03 Thread Anastasia Stulova via cfe-commits
Hi Jeroen,

I am not quite sure what your question is about in (a).

Regarding (b) please see example in test/SemaOpenCL/extensions.cl from the 
commit r269670.

Please note that SPIR target supports all extensions but disables them by 
default (see commit r269670). The latter logic hasn't been modified from 
earlier revisions of Clang.
Each targets can set the supported extensions as required, if you look at the 
latest commits: http://reviews.llvm.org/D20389

Perhaps, you can give us some code examples of what you believe isn't compiled 
correctly in Clang now. 

Thanks,
Anastasia

-Original Message-
From: Jeroen Ketema [mailto:j.ket...@imperial.ac.uk] 
Sent: 31 May 2016 23:07
To: Liu, Yaxun (Sam)
Cc: Anastasia Stulova; Clang Commits; nd
Subject: Re: r269670 - [OpenCL] Add supported OpenCL extensions to target info.

Hi Sam,

> This commit does not change the initial state of the extensions. An extension 
> is supported is not the same as enabled. At the beginning all extensions are 
> disabled.

I do not see this reflected in the code at all. Could you please:

a. Point me to the location where this distinction is made.

b. Convince me that I cannot enable an extension for a target if that target 
does not support the extension?

Jeroen

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


Re: r271413 - Fixup list of available extensions

2016-06-03 Thread Jan Vesely via cfe-commits
of course. sorry about that. I didn't realize the patches had different
title from phabricator.

Jan

On Fri, 2016-06-03 at 17:14 +, Anastasia Stulova wrote:
> Hi Jan,
> 
> In the future could you please keep "[OpenCL]" prefix for all commit
> messages related to OpenCL. :)
> 
> Thanks,
> Anastasia
>  
> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On
> Behalf Of Jan Vesely via cfe-commits
> Sent: 01 June 2016 19:05
> To: cfe-commits@lists.llvm.org
> Subject: r271413 - Fixup list of available extensions
> 
> Author: jvesely
> Date: Wed Jun  1 13:04:50 2016
> New Revision: 271413
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=271413&view=rev
> Log:
> Fixup list of available extensions
> 
> Reviewers: Anastasia
> 
> Differential Revision: http://reviews.llvm.org/D20447
> 
> Added:
> cfe/trunk/test/SemaOpenCL/extension-version.cl
> Modified:
> cfe/trunk/include/clang/Basic/OpenCLExtensions.def
> 
> Modified: cfe/trunk/include/clang/Basic/OpenCLExtensions.def
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basi
> c/OpenCLExtensions.def?rev=271413&r1=271412&r2=271413&view=diff
> =
> =
> --- cfe/trunk/include/clang/Basic/OpenCLExtensions.def (original)
> +++ cfe/trunk/include/clang/Basic/OpenCLExtensions.def Wed Jun  1 
> +++ 13:04:50 2016
> @@ -34,35 +34,39 @@
>  #endif // OPENCLEXT_INTERNAL
>  
>  // OpenCL 1.0.
> -OPENCLEXT_INTERNAL(cl_khr_3d_image_writes, 100, 120)
> +OPENCLEXT_INTERNAL(cl_khr_3d_image_writes, 100, 200) // fprounding
> mode 
> +is special since it is not mentioned beyond 1.0 
> +OPENCLEXT_INTERNAL(cl_khr_select_fprounding_mode, 100, 110)
>  OPENCLEXT_INTERNAL(cl_khr_byte_addressable_store, 100,
> 110)  OPENCLEXT_INTERNAL(cl_khr_fp16, 100,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_fp64, 100,
> 120)  OPENCLEXT_INTERNAL(cl_khr_global_int32_base_atomics, 100,
> 110)  OPENCLEXT_INTERNAL(cl_khr_global_int32_extended_atomics, 100,
> 110) -OPENCLEXT_INTERNAL(cl_khr_gl_sharing, 100, ~0U)
> -OPENCLEXT_INTERNAL(cl_khr_icd, 100,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_local_int32_base_atomics, 100,
> 110)  OPENCLEXT_INTERNAL(cl_khr_local_int32_extended_atomics, 100,
> 110)
> +OPENCLEXT_INTERNAL(cl_khr_int64_base_atomics, 100, ~0U) 
> +OPENCLEXT_INTERNAL(cl_khr_int64_extended_atomics, 100, ~0U) 
> +OPENCLEXT_INTERNAL(cl_khr_gl_sharing, 100, ~0U) 
> +OPENCLEXT_INTERNAL(cl_khr_icd, 100, ~0U)
>  
>  // OpenCL 1.1.
> -OPENCLEXT_INTERNAL(cl_khr_d3d10_sharing, 110,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_gl_event, 110, ~0U)
> -OPENCLEXT_INTERNAL(cl_khr_int64_base_atomics, 110, ~0U)
> -OPENCLEXT_INTERNAL(cl_khr_int64_extended_atomics, 110, ~0U)
> +OPENCLEXT_INTERNAL(cl_khr_d3d10_sharing, 110, ~0U)
>  
>  // OpenCL 1.2.
> +OPENCLEXT_INTERNAL(cl_khr_context_abort, 120, ~0U)
>  OPENCLEXT_INTERNAL(cl_khr_d3d11_sharing, 120,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_depth_images, 120,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_dx9_media_sharing, 120, ~0U)
> +OPENCLEXT_INTERNAL(cl_khr_image2d_from_buffer, 120, ~0U) 
> +OPENCLEXT_INTERNAL(cl_khr_initialize_memory, 120, ~0U)
>  OPENCLEXT_INTERNAL(cl_khr_gl_depth_images, 120, ~0U)
> +OPENCLEXT_INTERNAL(cl_khr_gl_msaa_sharing, 120, ~0U)
>  OPENCLEXT_INTERNAL(cl_khr_spir, 120, ~0U)
>  
>  // OpenCL 2.0.
>  OPENCLEXT_INTERNAL(cl_khr_egl_event, 200,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_egl_image, 200, ~0U)
> -OPENCLEXT_INTERNAL(cl_khr_gl_msaa_sharing, 200, ~0U)
> -OPENCLEXT_INTERNAL(cl_khr_initialize_memory, 200,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_srgb_image_writes, 200,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_subgroups, 200,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_terminate_context, 200, ~0U)
> 
> Added: cfe/trunk/test/SemaOpenCL/extension-version.cl
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/ex
> tension-version.cl?rev=271413&view=auto
> =
> =
> --- cfe/trunk/test/SemaOpenCL/extension-version.cl (added)
> +++ cfe/trunk/test/SemaOpenCL/extension-version.cl Wed Jun  1
> 13:04:50 
> +++ 2016
> @@ -0,0 +1,225 @@
> +// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple 
> +spir-unknown-unknown // RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s
> -verify 
> +-triple spir-unknown-unknown // RUN: %clang_cc1 -x cl -cl-std=CL1.2
> %s 
> +-verify -triple spir-unknown-unknown // RUN: %clang_cc1 -x cl 
> +-cl-std=CL2.0 %s -verify -triple spir-unknown-unknown
> +
> +#if __OPENCL_C_VERSION__ >= 200
> +// expected-no-diagnostics
> +#endif
> +
> +// Extensions in all versions
> +#ifndef cl_clang_storage_class_specifiers #error "Missing 
> +cl_clang_storage_class_specifiers define"
> +#endif
> +#pragma OPENCL EXTENSION cl_clang_storage_class_specifiers: enable
> +
> +#ifndef cl_khr_fp16
> +#error "Missing cl_khr_fp16 define"
> +#endif
> +#pragma OPENCL EXTENSION cl_khr_fp16: enable
> +
> +#ifndef cl_khr_int64_base_atomics
> +#error "Missing cl_khr_int64_base_atomics define"
> +#endif
> +#pragma O

RE: r271413 - Fixup list of available extensions

2016-06-03 Thread Anastasia Stulova via cfe-commits
No worries! Thanks!

Anastasia

-Original Message-
From: Jan Vesely [mailto:jv...@scarletmail.rutgers.edu] On Behalf Of Jan Vesely
Sent: 03 June 2016 18:35
To: Anastasia Stulova; cfe-commits@lists.llvm.org
Cc: nd
Subject: Re: r271413 - Fixup list of available extensions

of course. sorry about that. I didn't realize the patches had different title 
from phabricator.

Jan

On Fri, 2016-06-03 at 17:14 +, Anastasia Stulova wrote:
> Hi Jan,
> 
> In the future could you please keep "[OpenCL]" prefix for all commit 
> messages related to OpenCL. :)
> 
> Thanks,
> Anastasia
>  
> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On 
> Behalf Of Jan Vesely via cfe-commits
> Sent: 01 June 2016 19:05
> To: cfe-commits@lists.llvm.org
> Subject: r271413 - Fixup list of available extensions
> 
> Author: jvesely
> Date: Wed Jun  1 13:04:50 2016
> New Revision: 271413
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=271413&view=rev
> Log:
> Fixup list of available extensions
> 
> Reviewers: Anastasia
> 
> Differential Revision: http://reviews.llvm.org/D20447
> 
> Added:
> cfe/trunk/test/SemaOpenCL/extension-version.cl
> Modified:
> cfe/trunk/include/clang/Basic/OpenCLExtensions.def
> 
> Modified: cfe/trunk/include/clang/Basic/OpenCLExtensions.def
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basi
> c/OpenCLExtensions.def?rev=271413&r1=271412&r2=271413&view=diff
> =
> =
> --- cfe/trunk/include/clang/Basic/OpenCLExtensions.def (original)
> +++ cfe/trunk/include/clang/Basic/OpenCLExtensions.def Wed Jun  1
> +++ 13:04:50 2016
> @@ -34,35 +34,39 @@
>  #endif // OPENCLEXT_INTERNAL
>  
>  // OpenCL 1.0.
> -OPENCLEXT_INTERNAL(cl_khr_3d_image_writes, 100, 120)
> +OPENCLEXT_INTERNAL(cl_khr_3d_image_writes, 100, 200) // fprounding
> mode
> +is special since it is not mentioned beyond 1.0 
> +OPENCLEXT_INTERNAL(cl_khr_select_fprounding_mode, 100, 110)
>  OPENCLEXT_INTERNAL(cl_khr_byte_addressable_store, 100,
> 110)  OPENCLEXT_INTERNAL(cl_khr_fp16, 100,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_fp64, 100,
> 120)  OPENCLEXT_INTERNAL(cl_khr_global_int32_base_atomics, 100,
> 110)  OPENCLEXT_INTERNAL(cl_khr_global_int32_extended_atomics, 100,
> 110) -OPENCLEXT_INTERNAL(cl_khr_gl_sharing, 100, ~0U) 
> -OPENCLEXT_INTERNAL(cl_khr_icd, 100,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_local_int32_base_atomics, 100,
> 110)  OPENCLEXT_INTERNAL(cl_khr_local_int32_extended_atomics, 100,
> 110)
> +OPENCLEXT_INTERNAL(cl_khr_int64_base_atomics, 100, ~0U) 
> +OPENCLEXT_INTERNAL(cl_khr_int64_extended_atomics, 100, ~0U) 
> +OPENCLEXT_INTERNAL(cl_khr_gl_sharing, 100, ~0U) 
> +OPENCLEXT_INTERNAL(cl_khr_icd, 100, ~0U)
>  
>  // OpenCL 1.1.
> -OPENCLEXT_INTERNAL(cl_khr_d3d10_sharing, 110,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_gl_event, 110, ~0U) 
> -OPENCLEXT_INTERNAL(cl_khr_int64_base_atomics, 110, ~0U) 
> -OPENCLEXT_INTERNAL(cl_khr_int64_extended_atomics, 110, ~0U)
> +OPENCLEXT_INTERNAL(cl_khr_d3d10_sharing, 110, ~0U)
>  
>  // OpenCL 1.2.
> +OPENCLEXT_INTERNAL(cl_khr_context_abort, 120, ~0U)
>  OPENCLEXT_INTERNAL(cl_khr_d3d11_sharing, 120,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_depth_images, 120,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_dx9_media_sharing, 120, ~0U)
> +OPENCLEXT_INTERNAL(cl_khr_image2d_from_buffer, 120, ~0U) 
> +OPENCLEXT_INTERNAL(cl_khr_initialize_memory, 120, ~0U)
>  OPENCLEXT_INTERNAL(cl_khr_gl_depth_images, 120, ~0U)
> +OPENCLEXT_INTERNAL(cl_khr_gl_msaa_sharing, 120, ~0U)
>  OPENCLEXT_INTERNAL(cl_khr_spir, 120, ~0U)
>  
>  // OpenCL 2.0.
>  OPENCLEXT_INTERNAL(cl_khr_egl_event, 200,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_egl_image, 200, ~0U) 
> -OPENCLEXT_INTERNAL(cl_khr_gl_msaa_sharing, 200, ~0U) 
> -OPENCLEXT_INTERNAL(cl_khr_initialize_memory, 200,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_srgb_image_writes, 200,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_subgroups, 200,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_terminate_context, 200, ~0U)
> 
> Added: cfe/trunk/test/SemaOpenCL/extension-version.cl
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/ex
> tension-version.cl?rev=271413&view=auto
> =
> =
> --- cfe/trunk/test/SemaOpenCL/extension-version.cl (added)
> +++ cfe/trunk/test/SemaOpenCL/extension-version.cl Wed Jun  1
> 13:04:50
> +++ 2016
> @@ -0,0 +1,225 @@
> +// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple 
> +spir-unknown-unknown // RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s
> -verify
> +-triple spir-unknown-unknown // RUN: %clang_cc1 -x cl -cl-std=CL1.2
> %s
> +-verify -triple spir-unknown-unknown // RUN: %clang_cc1 -x cl
> +-cl-std=CL2.0 %s -verify -triple spir-unknown-unknown
> +
> +#if __OPENCL_C_VERSION__ >= 200
> +// expected-no-diagnostics
> +#endif
> +
> +// Extensions in all versions
> +#ifndef cl_clang_storage_class_specifiers #error "Missing 
> +cl_clang_storage_class_specifiers define"
> +#endif
> +#pragma OPENCL EXTENSION 

Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Piotr Padlewski via cfe-commits
Prazek updated this revision to Diff 59580.
Prazek marked 4 inline comments as done.
Prazek added a comment.

- Review fixes


http://reviews.llvm.org/D20964

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tidy/modernize/UseEmplaceCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-emplace.rst
  test/clang-tidy/modernize-use-emplace.cpp

Index: test/clang-tidy/modernize-use-emplace.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-emplace.cpp
@@ -0,0 +1,191 @@
+// RUN: %check_clang_tidy %s modernize-use-emplace %t
+
+namespace std {
+template 
+class vector {
+public:
+  void push_back(const T &) {}
+  void push_back(T &&) {}
+
+  template 
+  void emplace_back(Args &&... args) {};
+};
+
+template 
+class list {
+public:
+  void push_back(const T &) {}
+  void push_back(T &&) {}
+
+  template 
+  void emplace_back(Args &&... args) {};
+};
+
+template 
+class deque {
+public:
+  void push_back(const T &) {}
+  void push_back(T &&) {}
+
+  template 
+  void emplace_back(Args &&... args) {};
+};
+
+template 
+class pair {
+public:
+  pair() = default;
+  pair(const pair &) = default;
+  pair(pair &&) = default;
+
+  pair(const T1 &, const T2 &) {}
+  pair(T1 &&, T2 &&) {}
+
+  template 
+  pair(const pair &p) {};
+  template 
+  pair(pair &&p) {};
+};
+
+template 
+pair make_pair(T1, T2) {
+  return pair();
+};
+
+template 
+class unique_ptr {
+public:
+  unique_ptr(T *) {}
+};
+} // namespace std
+
+void testInts() {
+  std::vector v;
+  v.push_back(42);
+  v.push_back(int(42));
+  v.push_back(int{42});
+  int z;
+  v.push_back(z);
+}
+
+struct S {
+  S(int a, int b = 41) {}
+  S() {}
+  void push_back(S);
+};
+
+struct Convertable {
+  operator S() { return S{}; }
+};
+
+struct Zoz {
+  Zoz(S s) {}
+};
+
+Zoz getZoz(S s) { return Zoz(s); }
+
+void test_S() {
+  std::vector v;
+
+  v.push_back(S(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back instead of push_back [modernize-use-emplace]
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  v.push_back(S{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  v.push_back(S());
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back();
+
+  v.push_back(S{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back();
+
+  v.push_back(42);
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(42);
+
+  S temporary(42, 42);
+  temporary.push_back(temporary);
+  v.push_back(temporary);
+
+  v.push_back(Convertable());
+  v.push_back(Convertable{});
+  Convertable s;
+  v.push_back(s);
+}
+
+void test2() {
+  std::vector v;
+  v.push_back(Zoz(S(21, 37)));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(S(21, 37));
+
+  v.push_back(getZoz(S(1, 2)));
+}
+
+void testPair() {
+  std::vector> v;
+  v.push_back(std::pair(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  std::vector> v2;
+  v2.push_back(std::pair(S(42, 42), Zoz(S(21, 37;
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v2.emplace_back(S(42, 42), Zoz(S(21, 37)));
+}
+
+void testSpaces() {
+  std::vector v;
+
+  // clang-format off
+  v.push_back(S   (1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+  v.push_back(S   {1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  v.push_back(  S {});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back();
+
+  // clang-format on
+}
+
+void testPointers() {
+  std::vector v;
+  v.push_back(new int(5));
+
+  std::vector> v2;
+  v2.push_back(new int(42));
+  // This call can't be replaced with emplace_back.
+  // If emplacement will fail (not enough memory to add to vector)
+  // we will have leak of int because unique_ptr won't be constructed
+  // (and destructed) as in push_back case.
+
+  auto *ptr = new int;
+  v2.push_back(ptr);
+  // Same here
+}
+
+void testMakePair() {
+  std::vector> v;
+  // FIXME: add functionality to change calls of std::make_pair
+  v.push_back(std::make_pair(1, 2));
+}
+
+void testOtherCointainers() {
+  std::list l;
+  l.push_back(S(42, 41));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: l.emplace_back(42, 41);
+
+  std::deque d;
+  d.push_back(S(42));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: d.emplace_back(42);
+}
I

Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

In http://reviews.llvm.org/D20964#448455, @Eugene.Zelenko wrote:

> I think will be good idea to try this check with LLVM STL too.


You mean llvm::SmallVector stuff?


http://reviews.llvm.org/D20964



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


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a comment.

In http://reviews.llvm.org/D20964#448525, @Prazek wrote:

> In http://reviews.llvm.org/D20964#448455, @Eugene.Zelenko wrote:
>
> > I think will be good idea to try this check with LLVM STL too.
>
>
> You mean llvm::SmallVector stuff?


No, I meant to build example with -stdlib=libc++, -lc++, -lc++abi. Just to make 
sure, that hasName() is proper matcher.


http://reviews.llvm.org/D20964



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


Re: [PATCH] D20602: Add .rgba syntax extension to ext_vector_type types

2016-06-03 Thread Pirama Arumuga Nainar via cfe-commits
pirama added a comment.

Friendly ping...


http://reviews.llvm.org/D20602



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


r271701 - Test commit

2016-06-03 Thread Taewook Oh via cfe-commits
Author: twoh
Date: Fri Jun  3 13:27:39 2016
New Revision: 271701

URL: http://llvm.org/viewvc/llvm-project?rev=271701&view=rev
Log:
Test commit 


Modified:
cfe/trunk/include/clang/Basic/Builtins.def

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=271701&r1=271700&r2=271701&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Fri Jun  3 13:27:39 2016
@@ -790,6 +790,7 @@ LIBBUILTIN(isxdigit, "ii", "fnU", "ctype
 LIBBUILTIN(tolower, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
 LIBBUILTIN(toupper, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
 
+
 // C99
 // In some systems setjmp is a macro that expands to _setjmp. We undefine
 // it here to avoid having two identical LIBBUILTIN entries.


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


[RFC] Embedded bitcode and related upstream (Part II)

2016-06-03 Thread Steven Wu via cfe-commits
Hi everyone

I am still in the process of upstreaming some improvements to the embed bitcode 
option. If you want more background, you can read the previous RFC 
(http://lists.llvm.org/pipermail/llvm-dev/2016-February/094851.html 
). This is 
part II of the discussion. 

Current Status:
A basic version of -fembed-bitcode option is upstreamed and functioning.
You can use -fembed-bitcode={off, all, bitcode, marker} option to control what 
gets embedded in the final object file output:
off: default, nothing gets embedded.
all: optimized bitcode and command line options gets embedded in the object 
file.
bitcode: only optimized bitcode is embedded
marker: only put a marker in the object file

What needs to be improved:
1. Whitelist for command line options that can be used with bitcode:
Current trunk implementation embeds all the cc1 command line options (that 
includes header include paths, warning flags and other front-end options) in 
the command line section. That is lot of redundant information. To re-create 
the object file from the embedded optimized bitcode, most of these options are 
useless. On the other hand, they can leak information of the source code. One 
solution will be keeping a list of all the options that can affect code 
generation but not encoded in the bitcode. I have internally prototyped with 
disallowing these options explicitly and allowed only the reminder of the  
options to be embedded (http://reviews.llvm.org/D17394 
). A better solution might be encoding that 
information in "Options.td" as specific group.

2. Assembly input handling:
This is a workaround to allow source code written in assembly to work with 
"-fembed-bitcode" options. When compiling assembly source code with 
"-fembed-bitcode", clang-as creates an empty section "__LLVM, __asm" in the 
object file. That is just a way to distinguish object files compiled from 
assembly source from those compiled from higher level source code but forgot to 
use "-fembed-bitcode" options. Linker can use this section to diagnose if 
"-fembed-bitcode" is consistently used on all the object files participated in 
the linking.

3. Bitcode symbol hiding:
There was some concerns for leaking source code information when using bitcode 
feature. One approach to avoid the leak is to add a pass which renames all the 
globals and metadata strings. The also keeps a reverse map in case the original 
name needs to be recovered. The final bitcode should contain no more symbols or 
debug info than a stripped binary. To make sure modified bitcode can still be 
linked correctly, the renaming need to be consistent across all bitcode 
participated in the linking and everything that is external of the linkage unit 
need to be preserved. This means the pass can only be run during the linking 
and requires some LTO api.

4. Debug info strip to line-tables pass:
As the name suggested, this pass strip down the full debug info to line-tables 
only. This is also one of the steps we took to prevent the leak of source code 
information in bitcode.

Please let me know what do you think about the pieces above or if you have any 
concerns about the methodology. I will put up patches for review soon.

Thanks

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


r271702 - [Title] Revert test commit

2016-06-03 Thread Taewook Oh via cfe-commits
Author: twoh
Date: Fri Jun  3 13:30:12 2016
New Revision: 271702

URL: http://llvm.org/viewvc/llvm-project?rev=271702&view=rev
Log:
[Title] Revert test commit

Summary: Revert test commit

Trac Bug: #

Blame Rev:

Reviewed By:

Test Plan:

Revert Plan:

Database Impact:

Memcache Impact:

Other Notes:

EImportant:

- begin *PUBLIC* platform impact section -
Bugzilla: #
- end platform impact -


Modified:
cfe/trunk/include/clang/Basic/Builtins.def

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=271702&r1=271701&r2=271702&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Fri Jun  3 13:30:12 2016
@@ -790,7 +790,6 @@ LIBBUILTIN(isxdigit, "ii", "fnU", "ctype
 LIBBUILTIN(tolower, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
 LIBBUILTIN(toupper, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
 
-
 // C99
 // In some systems setjmp is a macro that expands to _setjmp. We undefine
 // it here to avoid having two identical LIBBUILTIN entries.


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


[PATCH] D20979: [OpenCL] Use function attribute/metadata to represent kernel attributes

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

This patch attempts to use target-dependent function attribute to represent 
reqd_work_group_size, work_group_size_hint and vector_type_hint kernel 
attributes and use function metadata to represent kernel argument info.

This is to elicit further discussion about a better way to represent kernel 
attributes.

The cfe-dev discussion is at 
http://lists.llvm.org/pipermail/cfe-dev/2016-June/049223.html

http://reviews.llvm.org/D20979

Files:
  lib/CodeGen/CodeGenFunction.cpp
  test/CodeGenOpenCL/kernel-arg-info.cl
  test/CodeGenOpenCL/kernel-attributes.cl
  test/CodeGenOpenCL/kernel-metadata.cl

Index: test/CodeGenOpenCL/kernel-metadata.cl
===
--- test/CodeGenOpenCL/kernel-metadata.cl
+++ test/CodeGenOpenCL/kernel-metadata.cl
@@ -6,10 +6,5 @@
 __kernel void kernel_function() {
 }
 
-// CHECK: !opencl.kernels = !{!0}
-// CHECK: !0 = !{void ()* @kernel_function, !1, !2, !3, !4, !5}
-// CHECK: !1 = !{!"kernel_arg_addr_space"}
-// CHECK: !2 = !{!"kernel_arg_access_qual"}
-// CHECK: !3 = !{!"kernel_arg_type"}
-// CHECK: !4 = !{!"kernel_arg_base_type"}
-// CHECK: !5 = !{!"kernel_arg_type_qual"}
+// CHECK: define void @kernel_function() #{{[0-9]+}} !kernel_arg_addr_space ![[MD:[0-9]+]] !kernel_arg_access_qual ![[MD]] !kernel_arg_type ![[MD]] !kernel_arg_base_type ![[MD]] !kernel_arg_type_qual ![[MD]] {
+// CHECK: ![[MD]] = !{}
Index: test/CodeGenOpenCL/kernel-attributes.cl
===
--- test/CodeGenOpenCL/kernel-attributes.cl
+++ test/CodeGenOpenCL/kernel-attributes.cl
@@ -3,14 +3,14 @@
 typedef unsigned int uint4 __attribute__((ext_vector_type(4)));
 
 kernel  __attribute__((vec_type_hint(int))) __attribute__((reqd_work_group_size(1,2,4))) void kernel1(int a) {}
+// CHECK: define void @kernel1(i32 %a) #[[AT1:[0-9]+]]
 
 kernel __attribute__((vec_type_hint(uint4))) __attribute__((work_group_size_hint(8,16,32))) void kernel2(int a) {}
+// CHECK: define void @kernel2(i32 %a) #[[AT2:[0-9]+]]
 
-// CHECK: opencl.kernels = !{[[MDNODE0:![0-9]+]], [[MDNODE3:![0-9]+]]}
-
-// CHECK: [[MDNODE0]] = !{void (i32)* @kernel1, {{.*}} [[MDNODE1:![0-9]+]], [[MDNODE2:![0-9]+]]}
-// CHECK: [[MDNODE1]] = !{!"vec_type_hint", i32 undef, i32 1}
-// CHECK: [[MDNODE2]] = !{!"reqd_work_group_size", i32 1, i32 2, i32 4}
-// CHECK: [[MDNODE3]] = !{void (i32)* @kernel2, {{.*}} [[MDNODE4:![0-9]+]], [[MDNODE5:![0-9]+]]}
-// CHECK: [[MDNODE4]] = !{!"vec_type_hint", <4 x i32> undef, i32 0}
-// CHECK: [[MDNODE5]] = !{!"work_group_size_hint", i32 8, i32 16, i32 32}
+// CHECK: attributes #[[AT1]] = { 
+// CHECK-DAG: "reqd_work_group_size"="1 2 4"
+// CHECK-DAG: "vec_type_hint"="int"
+// CHECK: attributes #[[AT2]] = {
+// CHECK-DAG: "vec_type_hint"="uint4"
+// CHECK-DAG: "work_group_size_hint"="8 16 32"
Index: test/CodeGenOpenCL/kernel-arg-info.cl
===
--- test/CodeGenOpenCL/kernel-arg-info.cl
+++ test/CodeGenOpenCL/kernel-arg-info.cl
@@ -1,55 +1,88 @@
-// RUN: %clang_cc1 %s -cl-kernel-arg-info -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s -check-prefix ARGINFO
-// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s -check-prefix NO-ARGINFO
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown -cl-kernel-arg-info | FileCheck %s -check-prefix ARGINFO
 
 kernel void foo(__global int * restrict X, const int Y, 
 volatile int anotherArg, __constant float * restrict Z) {
   *X = Y + anotherArg;
 }
-
-// CHECK:  !{!"kernel_arg_addr_space", i32 1, i32 0, i32 0, i32 2}
-// CHECK:  !{!"kernel_arg_access_qual", !"none", !"none", !"none", !"none"}
-// CHECK:  !{!"kernel_arg_type", !"int*", !"int", !"int", !"float*"}
-// CHECK:  !{!"kernel_arg_base_type", !"int*", !"int", !"int", !"float*"}
-// CHECK:  !{!"kernel_arg_type_qual", !"restrict", !"const", !"volatile", !"restrict const"}
-// ARGINFO: !{!"kernel_arg_name", !"X", !"Y", !"anotherArg", !"Z"}
-// NO-ARGINFO-NOT: !{!"kernel_arg_name", !"X", !"Y", !"anotherArg", !"Z"}
+// CHECK: define spir_kernel void @foo{{[^!]+}}
+// CHECK: !kernel_arg_addr_space ![[MD11:[0-9]+]]
+// CHECK: !kernel_arg_access_qual ![[MD12:[0-9]+]]
+// CHECK: !kernel_arg_type ![[MD13:[0-9]+]]
+// CHECK: !kernel_arg_base_type ![[MD13]]
+// CHECK: !kernel_arg_type_qual ![[MD14:[0-9]+]]
+// CHECK-NOT: !kernel_arg_name
+// ARGINFO: !kernel_arg_name ![[MD15:[0-9]+]]
 
 kernel void foo2(read_only image1d_t img1, image2d_t img2, write_only image2d_array_t img3) {
 }
-// CHECK:  !{!"kernel_arg_addr_space", i32 1, i32 1, i32 1}
-// CHECK:  !{!"kernel_arg_access_qual", !"read_only", !"read_only", !"write_only"}
-// CHECK:  !{!"kernel_arg_type", !"image1d_t", !"image2d_t", !"image2d_arra

r271708 - Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.

2016-06-03 Thread Taewook Oh via cfe-commits
Author: twoh
Date: Fri Jun  3 13:52:51 2016
New Revision: 271708

URL: http://llvm.org/viewvc/llvm-project?rev=271708&view=rev
Log:
Use the name of the file on disk to issue a new diagnostic about non-portable 
#include and #import paths.

Differential Revision: http://reviews.llvm.org/D19843
Corresponding LLVM change: http://reviews.llvm.org/D19842

Patch by Eric Niebler


Added:
cfe/trunk/test/Lexer/Inputs/case-insensitive-include.h
cfe/trunk/test/Lexer/case-insensitive-include-ms.c
cfe/trunk/test/Lexer/case-insensitive-include.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/include/clang/Basic/FileManager.h
cfe/trunk/include/clang/Basic/VirtualFileSystem.h
cfe/trunk/include/clang/Lex/DirectoryLookup.h
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/lib/Basic/FileManager.cpp
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/test/PCH/case-insensitive-include.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=271708&r1=271707&r2=271708&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Jun  3 13:52:51 2016
@@ -390,6 +390,7 @@ def : DiagGroup<"sequence-point", [Unseq
 def AmbiguousMacro : DiagGroup<"ambiguous-macro">;
 def KeywordAsMacro : DiagGroup<"keyword-macro">;
 def ReservedIdAsMacro : DiagGroup<"reserved-id-macro">;
+def NonportableIncludePath : DiagGroup<"nonportable-include-path">;
 
 // Just silence warnings about -Wstrict-aliasing for now.
 def : DiagGroup<"strict-aliasing=0">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=271708&r1=271707&r2=271708&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Fri Jun  3 13:52:51 2016
@@ -274,6 +274,10 @@ def ext_missing_whitespace_after_macro_n
   "whitespace required after macro name">;
 def warn_missing_whitespace_after_macro_name : Warning<
   "whitespace recommended after macro name">;
+def pp_nonportable_path : Warning<
+  "non-portable path to file '%0'; specified path differs in case from file"
+  " name on disk">,
+  InGroup;
   
 def pp_pragma_once_in_main_file : Warning<"#pragma once in main file">,
   InGroup>;

Modified: cfe/trunk/include/clang/Basic/FileManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=271708&r1=271707&r2=271708&view=diff
==
--- cfe/trunk/include/clang/Basic/FileManager.h (original)
+++ cfe/trunk/include/clang/Basic/FileManager.h Fri Jun  3 13:52:51 2016
@@ -52,6 +52,7 @@ public:
 /// descriptor for the file.
 class FileEntry {
   const char *Name;   // Name of the file.
+  std::string RealPathName;   // Real path to the file; could be empty.
   off_t Size; // File size in bytes.
   time_t ModTime; // Modification time of file.
   const DirectoryEntry *Dir;  // Directory file lives in.
@@ -82,6 +83,7 @@ public:
   }
 
   const char *getName() const { return Name; }
+  StringRef tryGetRealPathName() const { return RealPathName; }
   bool isValid() const { return IsValid; }
   off_t getSize() const { return Size; }
   unsigned getUID() const { return UID; }

Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=271708&r1=271707&r2=271708&view=diff
==
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Fri Jun  3 13:52:51 2016
@@ -91,6 +91,13 @@ public:
   virtual ~File();
   /// \brief Get the status of the file.
   virtual llvm::ErrorOr status() = 0;
+  /// \brief Get the name of the file
+  virtual llvm::ErrorOr getName() {
+if (auto Status = status())
+  return Status->getName();
+else
+  return Status.getError();
+  }
   /// \brief Get the contents of the file as a \p MemoryBuffer.
   virtual llvm::ErrorOr>
   getBuffer(const Twine &Name, int64_t FileSize = -1,

Modified: cfe/trunk/include/clang/Lex/DirectoryLookup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/DirectoryLookup.h?rev=271708&r1=271707&r2=271708&view=diff
==
--- cfe/trunk/include/clang/Lex/DirectoryLookup.h 

Re: [PATCH] D19843: Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.

2016-06-03 Thread Taewook Oh via cfe-commits
twoh added a subscriber: twoh.
twoh closed this revision.
twoh added a comment.

I have commit in r271708: http://reviews.llvm.org/rL271708


http://reviews.llvm.org/D19843



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


Re: [PATCH] D20917: [clang-tidy] modernize-use-auto: don't remove stars by default

2016-06-03 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D20917#447046, @sbenza wrote:

> Is it a typo in the description when it says that when RemoveStar is on we 
> will write 'auto*' instead if 'auto'?


Yep, the whole patch description is a typo, fixed ;)


http://reviews.llvm.org/D20917



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


Re: [PATCH] D20917: [clang-tidy] modernize-use-auto: don't remove stars by default

2016-06-03 Thread Alexander Kornienko via cfe-commits
alexfh updated this revision to Diff 59599.
alexfh marked an inline comment as done.
alexfh added a comment.

- Updated formatting in the doc.


http://reviews.llvm.org/D20917

Files:
  clang-tidy/modernize/UseAutoCheck.cpp
  clang-tidy/modernize/UseAutoCheck.h
  docs/clang-tidy/checks/modernize-use-auto.rst
  test/clang-tidy/modernize-use-auto-new-remove-stars.cpp
  test/clang-tidy/modernize-use-auto-new.cpp

Index: test/clang-tidy/modernize-use-auto-new.cpp
===
--- test/clang-tidy/modernize-use-auto-new.cpp
+++ test/clang-tidy/modernize-use-auto-new.cpp
@@ -9,11 +9,11 @@
 void auto_new() {
   MyType *a_new = new MyType();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
-  // CHECK-FIXES: auto a_new = new MyType();
+  // CHECK-FIXES: auto *a_new = new MyType();
 
   static MyType *a_static = new MyType();
   // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use auto when initializing with new
-  // CHECK-FIXES: static auto a_static = new MyType();
+  // CHECK-FIXES: static auto *a_static = new MyType();
 
   MyType *derived = new MyDerivedType();
 
@@ -27,42 +27,42 @@
   // not "MyType * const".
   static MyType * const d_static = new MyType();
   // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use auto when initializing with new
-  // CHECK-FIXES: static auto  const d_static = new MyType();
+  // CHECK-FIXES: static auto * const d_static = new MyType();
 
   MyType * const a_const = new MyType();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
-  // CHECK-FIXES: auto  const a_const = new MyType();
+  // CHECK-FIXES: auto * const a_const = new MyType();
 
   MyType * volatile vol = new MyType();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
-  // CHECK-FIXES: auto  volatile vol = new MyType();
+  // CHECK-FIXES: auto * volatile vol = new MyType();
 
   struct SType {} *stype = new SType;
 
   int (**func)(int, int) = new (int(*[5])(int,int));
 
   int *array = new int[5];
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
-  // CHECK-FIXES: auto array = new int[5];
+  // CHECK-FIXES: auto *array = new int[5];
 
   MyType *ptr(new MyType);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
-  // CHECK-FIXES: auto ptr(new MyType);
+  // CHECK-FIXES: auto *ptr(new MyType);
 
   MyType *ptr2{new MyType};
 
   {
 // Test for declaration lists.
 MyType *a = new MyType(), *b = new MyType(), *c = new MyType();
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
-// CHECK-FIXES: auto a = new MyType(), b = new MyType(), c = new MyType();
+// CHECK-FIXES: auto *a = new MyType(), *b = new MyType(), *c = new MyType();
 
 // Non-initialized declaration should not be transformed.
 MyType *d = new MyType(), *e;
 
 MyType **f = new MyType*(), **g = new MyType*();
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
-// CHECK-FIXES: auto f = new MyType*(), g = new MyType*();
+// CHECK-FIXES: auto **f = new MyType*(), **g = new MyType*();
 
 // Mismatching types in declaration lists should not be transformed.
 MyType *h = new MyType(), **i = new MyType*();
@@ -75,25 +75,26 @@
   {
 // Test for typedefs.
 typedef int * int_p;
+// CHECK-FIXES: typedef int * int_p;
 
 int_p a = new int;
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
-// CHECK-FIXES: auto  a = new int;
+// CHECK-FIXES: auto a = new int;
 int_p *b = new int*;
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
-// CHECK-FIXES: auto b = new int*;
+// CHECK-FIXES: auto *b = new int*;
 
 // Test for typedefs in declarations lists.
 int_p c = new int, d = new int;
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
-// CHECK-FIXES: auto  c = new int, d = new int;
+// CHECK-FIXES: auto c = new int, d = new int;
 
 // Different types should not be transformed.
 int_p e = new int, *f = new int_p;
 
 int_p *g = new int*, *h = new int_p;
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
-// CHECK-FIXES: auto g = new int*, h = new int_p;
+// CHECK-FIXES: auto *g = new int*, *h = new int_p;
   }
 
   // Don't warn when 'auto' is already being used.
Index: test/clang-tidy/modernize-use-auto-new-remove-stars.cpp
===
--- test/clang-tidy/modernize-use-auto-new-remove-stars.cpp
+++ test/clang-tidy/modernize-use-auto-new-remove-stars.cpp
@@ -1,4 +1,6 @@
-// RUN: %check_clang_tidy %s modernize-use-auto %t
+// RUN: %check_clang_tidy %s modernize-use-auto %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-auto.RemoveStars, value: '1'}]}" \
+// RUN:   -- -std=c++11
 
 cl

Re: [PATCH] D20917: [clang-tidy] modernize-use-auto: don't remove stars by default

2016-06-03 Thread Piotr Padlewski via cfe-commits
Prazek added a subscriber: Prazek.
Prazek added a comment.

besides it lgtm



Comment at: clang-tidy/modernize/UseAutoCheck.cpp:338
@@ -329,8 +337,3 @@
 
-// Remove explicitly written '*' from declarations where there's more than
-// one declaration in the declaration list.
-if (Dec == *D->decl_begin())
-  continue;
-
 // All subsequent declarations should match the same non-decorated type.
 if (FirstDeclType != V->getType().getCanonicalType())

Can you change this comment to make it more clear, or tell me what it do? I 
don't quite understand it right now


http://reviews.llvm.org/D20917



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


Re: r271692 - Don't pass --build-id to ld by default.

2016-06-03 Thread Nico Weber via cfe-commits
Can you add this to the release notes? It'll for example break chromium's
crash server (we can fix this on our end by explicitly passing
-Wl,--build-id for release builds, but we only saw this commit fly by by
chance.)

On Fri, Jun 3, 2016 at 1:26 PM, Rafael Espindola via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rafael
> Date: Fri Jun  3 12:26:16 2016
> New Revision: 271692
>
> URL: http://llvm.org/viewvc/llvm-project?rev=271692&view=rev
> Log:
> Don't pass --build-id to ld by default.
>
> We now have a cmake option to change the default: ENABLE_LINKER_BUILD_ID.
>
> The reason is that build-id is fairly expensive, so we shouldn't impose
> it in the regular edit/build cycle.
>
> This is similar to gcc, that has an off by default --enable-linker-build-id
> option.
>
> Modified:
> cfe/trunk/CMakeLists.txt
> cfe/trunk/include/clang/Config/config.h.cmake
> cfe/trunk/lib/Driver/ToolChains.cpp
>
> Modified: cfe/trunk/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=271692&r1=271691&r2=271692&view=diff
>
> ==
> --- cfe/trunk/CMakeLists.txt (original)
> +++ cfe/trunk/CMakeLists.txt Fri Jun  3 12:26:16 2016
> @@ -197,6 +197,8 @@ set(GCC_INSTALL_PREFIX "" CACHE PATH "Di
>  set(DEFAULT_SYSROOT "" CACHE PATH
>"Default  to all compiler invocations for --sysroot=." )
>
> +set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld")
> +
>  set(CLANG_DEFAULT_CXX_STDLIB "" CACHE STRING
>"Default C++ stdlib to use (empty for architecture default,
> \"libstdc++\" or \"libc++\"")
>  if (NOT(CLANG_DEFAULT_CXX_STDLIB STREQUAL "" OR
>
> Modified: cfe/trunk/include/clang/Config/config.h.cmake
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Config/config.h.cmake?rev=271692&r1=271691&r2=271692&view=diff
>
> ==
> --- cfe/trunk/include/clang/Config/config.h.cmake (original)
> +++ cfe/trunk/include/clang/Config/config.h.cmake Fri Jun  3 12:26:16 2016
> @@ -38,4 +38,7 @@
>  /* Linker version detected at compile time. */
>  #cmakedefine HOST_LINK_VERSION "${HOST_LINK_VERSION}"
>
> +/* pass --build-id to ld */
> +#cmakedefine ENABLE_LINKER_BUILD_ID
> +
>  #endif
>
> Modified: cfe/trunk/lib/Driver/ToolChains.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=271692&r1=271691&r2=271692&view=diff
>
> ==
> --- cfe/trunk/lib/Driver/ToolChains.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Jun  3 12:26:16 2016
> @@ -3978,10 +3978,9 @@ Linux::Linux(const Driver &D, const llvm
>if (IsRedhat(Distro) && Distro != RHEL5 && Distro != RHEL6)
>  ExtraOpts.push_back("--no-add-needed");
>
> -  if ((IsDebian(Distro) && Distro >= DebianSqueeze) || IsOpenSUSE(Distro)
> ||
> -  (IsRedhat(Distro) && Distro != RHEL5) ||
> -  (IsUbuntu(Distro) && Distro >= UbuntuKarmic))
> -ExtraOpts.push_back("--build-id");
> +#ifdef ENABLE_LINKER_BUILD_ID
> +  ExtraOpts.push_back("--build-id");
> +#endif
>
>if (IsOpenSUSE(Distro))
>  ExtraOpts.push_back("--enable-new-dtags");
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >