[libcxx] r292097 - Added a workaround for a `-fdelayed-template-parsing` bug.

2017-01-16 Thread Michael Park via cfe-commits
Author: mpark
Date: Mon Jan 16 02:14:25 2017
New Revision: 292097

URL: http://llvm.org/viewvc/llvm-project?rev=292097&view=rev
Log:
Added a workaround for a `-fdelayed-template-parsing` bug.

Summary:
There seems to be an additional bug in `-fdelayed-template-parsing`
similar to
http://llvm.org/viewvc/llvm-project?view=revision&revision=236063.

This is a workaround for it for  to compile with `clang-cl` on Windows.

Reviewers: EricWF

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

Modified:
libcxx/trunk/include/variant
libcxx/trunk/test/std/utilities/variant/variant.visit/visit.pass.cpp

Modified: libcxx/trunk/include/variant
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/variant?rev=292097&r1=292096&r2=292097&view=diff
==
--- libcxx/trunk/include/variant (original)
+++ libcxx/trunk/include/variant Mon Jan 16 02:14:25 2017
@@ -466,17 +466,22 @@ private:
 return __result{{_VSTD::forward<_Fs>(__fs)...}};
   }
 
-  template 
-  inline _LIBCPP_INLINE_VISIBILITY
-  static constexpr auto __make_dispatch(index_sequence<_Is...>) {
-struct __dispatcher {
-  static constexpr decltype(auto) __dispatch(_Fp __f, _Vs... __vs) {
+  template 
+  struct __dispatcher {
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+static constexpr decltype(auto) __dispatch(_Fp __f, _Vs... __vs) {
 return __invoke_constexpr(
 static_cast<_Fp>(__f),
 __access::__base::__get_alt<_Is>(static_cast<_Vs>(__vs))...);
-  }
-};
-return _VSTD::addressof(__dispatcher::__dispatch);
+}
+  };
+
+  template 
+  inline _LIBCPP_INLINE_VISIBILITY
+  static constexpr auto __make_dispatch(index_sequence<_Is...>) {
+return _VSTD::addressof(
+__dispatcher<_Is...>::template __dispatch<_Fp, _Vs...>);
   }
 
   template 

Modified: libcxx/trunk/test/std/utilities/variant/variant.visit/visit.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/variant/variant.visit/visit.pass.cpp?rev=292097&r1=292096&r2=292097&view=diff
==
--- libcxx/trunk/test/std/utilities/variant/variant.visit/visit.pass.cpp 
(original)
+++ libcxx/trunk/test/std/utilities/variant/variant.visit/visit.pass.cpp Mon 
Jan 16 02:14:25 2017
@@ -10,9 +10,6 @@
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 
-// FIXME: This test hangs for an unknown reason on Windows. See 
llvm.org/PR31642
-// UNSUPPORTED: windows
-
 // 
 // template 
 // constexpr see below visit(Visitor&& vis, Variants&&... vars);


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


[PATCH] D28753: [OpenMP] Codegen support for 'target parallel' on the host.

2017-01-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: include/clang/Sema/Sema.h:8328-8330
+  /// Return the number of captured regions created for an OpenMP directive.
+  static int getOpenMPCaptureLevels(OpenMPDirectiveKind Kind);
+

I think it would be good to have a member function that returns the captured 
statement for the provided OpenMP region kind, like `CapturedStmt 
*getCapturedStmt(OpenMPDirectiveKind Kind)`. In this case you don't need to add 
an additional parameter for the codegen functions



Comment at: lib/Sema/SemaOpenMP.cpp:1914
+};
+}
+

} // namespace



Comment at: lib/Sema/SemaOpenMP.cpp:2001-2003
+  while (--ThisCaptureLevel >= 0) {
+SR = ActOnCapturedRegionEnd(SR.get());
+  }

No braces here



Comment at: lib/Sema/TreeTransform.h:7243-7245
+  while (--ThisCaptureLevel >= 0) {
+CS = cast(CS)->getCapturedStmt();
+  }

No braces


https://reviews.llvm.org/D28753



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


[PATCH] D28755: [OpenMP] Codegen for the 'target parallel' directive on the NVPTX device.

2017-01-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D28755



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


[PATCH] D28293: [clang-move] Dump enum and type alias declarations.

2017-01-16 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

Lg


https://reviews.llvm.org/D28293



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


[clang-tools-extra] r292098 - [clang-move] Dump enum and type alias declarations.

2017-01-16 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Mon Jan 16 03:34:07 2017
New Revision: 292098

URL: http://llvm.org/viewvc/llvm-project?rev=292098&view=rev
Log:
[clang-move] Dump enum and type alias declarations.

Reviewers: ioeric

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-move/ClangMove.cpp
clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp

Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=292098&r1=292097&r2=292098&view=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Mon Jan 16 03:34:07 2017
@@ -841,6 +841,12 @@ void ClangMoveTool::onEndOfTranslationUn
   else if (Kind == Decl::Kind::ClassTemplate ||
Kind == Decl::Kind::CXXRecord)
 Reporter->reportDeclaration(QualifiedName, "Class");
+  else if (Kind == Decl::Kind::Enum)
+Reporter->reportDeclaration(QualifiedName, "Enum");
+  else if (Kind == Decl::Kind::Typedef ||
+   Kind == Decl::Kind::TypeAlias ||
+   Kind == Decl::Kind::TypeAliasTemplate)
+Reporter->reportDeclaration(QualifiedName, "TypeAlias");
 }
 return;
   }

Modified: clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp?rev=292098&r1=292097&r2=292098&view=diff
==
--- clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp Mon Jan 16 
03:34:07 2017
@@ -535,6 +535,10 @@ TEST(ClangMove, DumpDecls) {
 "namespace b {\n"
 "class Move1 { public : void f(); };\n"
 "void f() {}\n"
+"enum E1 { Green };\n"
+"enum class E2 { Red };\n"
+"typedef int Int2;\n"
+"using Int = int;\n"
 "} // namespace b\n"
 "} // namespace a\n";
   const char TestCode[] = "#include \"foo.h\"\n";
@@ -545,22 +549,16 @@ TEST(ClangMove, DumpDecls) {
   Spec.NewHeader = "new_foo.h";
   Spec.NewCC = "new_foo.cc";
   DeclarationReporter Reporter;
-  std::vector ExpectedDeclarations = {
+  std::set ExpectedDeclarations = {
   {"A", "Class"}, {"B", "Class"},{"a::Move1", "Class"},
   {"a::f1", "Function"},  {"a::f2", "Function"}, {"a::b::Move1", "Class"},
-  {"a::b::f", "Function"}};
+  {"a::b::f", "Function"}, {"a::b::E1", "Enum"}, {"a::b::E2", "Enum"},
+  {"a::b::Int2", "TypeAlias"}, {"a::b::Int", "TypeAlias"} };
   runClangMoveOnCode(Spec, TestHeader, TestCode, &Reporter);
-  const auto& Results = Reporter.getDeclarationList();
-  auto ActualDeclIter = Results.begin();
-  auto ExpectedDeclIter = ExpectedDeclarations.begin();
-  while (ActualDeclIter != Results.end() &&
- ExpectedDeclIter != ExpectedDeclarations.end()) {
-EXPECT_EQ(*ActualDeclIter, *ExpectedDeclIter);
-++ActualDeclIter;
-++ExpectedDeclIter;
-  }
-  ASSERT_TRUE(ActualDeclIter == Results.end());
-  ASSERT_TRUE(ExpectedDeclIter == ExpectedDeclarations.end());
+  std::set Results;
+  for (const auto& DelPair : Reporter.getDeclarationList())
+Results.insert(DelPair);
+  EXPECT_EQ(ExpectedDeclarations, Results);
 }
 
 } // namespace


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


[PATCH] D28293: [clang-move] Dump enum and type alias declarations.

2017-01-16 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292098: [clang-move] Dump enum and type alias declarations. 
(authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D28293?vs=83054&id=84525#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28293

Files:
  clang-tools-extra/trunk/clang-move/ClangMove.cpp
  clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp


Index: clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
===
--- clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
+++ clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
@@ -535,6 +535,10 @@
 "namespace b {\n"
 "class Move1 { public : void f(); };\n"
 "void f() {}\n"
+"enum E1 { Green };\n"
+"enum class E2 { Red };\n"
+"typedef int Int2;\n"
+"using Int = int;\n"
 "} // namespace b\n"
 "} // namespace a\n";
   const char TestCode[] = "#include \"foo.h\"\n";
@@ -545,22 +549,16 @@
   Spec.NewHeader = "new_foo.h";
   Spec.NewCC = "new_foo.cc";
   DeclarationReporter Reporter;
-  std::vector ExpectedDeclarations = {
+  std::set ExpectedDeclarations = {
   {"A", "Class"}, {"B", "Class"},{"a::Move1", "Class"},
   {"a::f1", "Function"},  {"a::f2", "Function"}, {"a::b::Move1", "Class"},
-  {"a::b::f", "Function"}};
+  {"a::b::f", "Function"}, {"a::b::E1", "Enum"}, {"a::b::E2", "Enum"},
+  {"a::b::Int2", "TypeAlias"}, {"a::b::Int", "TypeAlias"} };
   runClangMoveOnCode(Spec, TestHeader, TestCode, &Reporter);
-  const auto& Results = Reporter.getDeclarationList();
-  auto ActualDeclIter = Results.begin();
-  auto ExpectedDeclIter = ExpectedDeclarations.begin();
-  while (ActualDeclIter != Results.end() &&
- ExpectedDeclIter != ExpectedDeclarations.end()) {
-EXPECT_EQ(*ActualDeclIter, *ExpectedDeclIter);
-++ActualDeclIter;
-++ExpectedDeclIter;
-  }
-  ASSERT_TRUE(ActualDeclIter == Results.end());
-  ASSERT_TRUE(ExpectedDeclIter == ExpectedDeclarations.end());
+  std::set Results;
+  for (const auto& DelPair : Reporter.getDeclarationList())
+Results.insert(DelPair);
+  EXPECT_EQ(ExpectedDeclarations, Results);
 }
 
 } // namespace
Index: clang-tools-extra/trunk/clang-move/ClangMove.cpp
===
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp
@@ -841,6 +841,12 @@
   else if (Kind == Decl::Kind::ClassTemplate ||
Kind == Decl::Kind::CXXRecord)
 Reporter->reportDeclaration(QualifiedName, "Class");
+  else if (Kind == Decl::Kind::Enum)
+Reporter->reportDeclaration(QualifiedName, "Enum");
+  else if (Kind == Decl::Kind::Typedef ||
+   Kind == Decl::Kind::TypeAlias ||
+   Kind == Decl::Kind::TypeAliasTemplate)
+Reporter->reportDeclaration(QualifiedName, "TypeAlias");
 }
 return;
   }


Index: clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
===
--- clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
+++ clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
@@ -535,6 +535,10 @@
 "namespace b {\n"
 "class Move1 { public : void f(); };\n"
 "void f() {}\n"
+"enum E1 { Green };\n"
+"enum class E2 { Red };\n"
+"typedef int Int2;\n"
+"using Int = int;\n"
 "} // namespace b\n"
 "} // namespace a\n";
   const char TestCode[] = "#include \"foo.h\"\n";
@@ -545,22 +549,16 @@
   Spec.NewHeader = "new_foo.h";
   Spec.NewCC = "new_foo.cc";
   DeclarationReporter Reporter;
-  std::vector ExpectedDeclarations = {
+  std::set ExpectedDeclarations = {
   {"A", "Class"}, {"B", "Class"},{"a::Move1", "Class"},
   {"a::f1", "Function"},  {"a::f2", "Function"}, {"a::b::Move1", "Class"},
-  {"a::b::f", "Function"}};
+  {"a::b::f", "Function"}, {"a::b::E1", "Enum"}, {"a::b::E2", "Enum"},
+  {"a::b::Int2", "TypeAlias"}, {"a::b::Int", "TypeAlias"} };
   runClangMoveOnCode(Spec, TestHeader, TestCode, &Reporter);
-  const auto& Results = Reporter.getDeclarationList();
-  auto ActualDeclIter = Results.begin();
-  auto ExpectedDeclIter = ExpectedDeclarations.begin();
-  while (ActualDeclIter != Results.end() &&
- ExpectedDeclIter != ExpectedDeclarations.end()) {
-EXPECT_EQ(*ActualDeclIter, *ExpectedDeclIter);
-++ActualDec

[PATCH] D28763: clang-format: [JS] revert over-eager ASI check.

2017-01-16 Thread Martin Probst via Phabricator via cfe-commits
mprobst created this revision.
mprobst added a reviewer: djasper.
mprobst added subscribers: cfe-commits, sammccall.
Herald added a subscriber: klimek.

Change r291428 introduced ASI detection after closing curly braces. That would 
generally be correct, however this breaks indentation for structural 
statements. What happens is that CompoundStatementIndenter increases 
indentation for the current line, then after reading ASI creates a new line 
(with the increased line level), and only after the structural parser sees e.g. 
the if/then/else branch closed, line level is reduced. That leads to the new 
line started by ASI having a level too high.


https://reviews.llvm.org/D28763

Files:
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTestJS.cpp


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -858,26 +858,44 @@
"return 1",
"a = null\n"
"  return   1");
+  // Below "class Y {}" should ideally be on its own line.
   verifyFormat(
   "x = {\n"
   "  a: 1\n"
-  "}\n"
-  "class Y {}",
+  "} class Y {}",
   "  x  =  {a  : 1}\n"
   "   class  Y {  }");
+  verifyFormat(
+  "if (x) {\n"
+  "}\n"
+  "return 1",
+  "if (x) {}\n"
+  " return   1");
+  verifyFormat(
+  "if (x) {\n"
+  "}\n"
+  "class X {}",
+  "if (x) {}\n"
+  " class X {}");
 }
 
 TEST_F(FormatTestJS, ImportExportASI) {
   verifyFormat(
   "import {x} from 'y'\n"
   "export function z() {}",
   "import   {x} from 'y'\n"
   "  export function z() {}");
+  // Below "class Y {}" should ideally be on its own line.
   verifyFormat(
-  "export {x}\n"
-  "class Y {}",
+  "export {x} class Y {}",
   "  export {x}\n"
   "  class  Y {\n}");
+  verifyFormat(
+  "if (x) {\n"
+  "}\n"
+  "export class Y {}",
+  "if ( x ) { }\n"
+  " export class Y {}");
 }
 
 TEST_F(FormatTestJS, ClosureStyleCasts) {
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -746,8 +746,7 @@
Previous->isOneOf(tok::r_square, tok::r_paren, tok::plusplus,
  tok::minusminus)))
 return addUnwrappedLine();
-  if ((PreviousMustBeValue || Previous->is(tok::r_brace)) &&
-  isJSDeclOrStmt(Keywords, Next))
+  if (PreviousMustBeValue && isJSDeclOrStmt(Keywords, Next))
 return addUnwrappedLine();
 }
 


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -858,26 +858,44 @@
"return 1",
"a = null\n"
"  return   1");
+  // Below "class Y {}" should ideally be on its own line.
   verifyFormat(
   "x = {\n"
   "  a: 1\n"
-  "}\n"
-  "class Y {}",
+  "} class Y {}",
   "  x  =  {a  : 1}\n"
   "   class  Y {  }");
+  verifyFormat(
+  "if (x) {\n"
+  "}\n"
+  "return 1",
+  "if (x) {}\n"
+  " return   1");
+  verifyFormat(
+  "if (x) {\n"
+  "}\n"
+  "class X {}",
+  "if (x) {}\n"
+  " class X {}");
 }
 
 TEST_F(FormatTestJS, ImportExportASI) {
   verifyFormat(
   "import {x} from 'y'\n"
   "export function z() {}",
   "import   {x} from 'y'\n"
   "  export function z() {}");
+  // Below "class Y {}" should ideally be on its own line.
   verifyFormat(
-  "export {x}\n"
-  "class Y {}",
+  "export {x} class Y {}",
   "  export {x}\n"
   "  class  Y {\n}");
+  verifyFormat(
+  "if (x) {\n"
+  "}\n"
+  "export class Y {}",
+  "if ( x ) { }\n"
+  " export class Y {}");
 }
 
 TEST_F(FormatTestJS, ClosureStyleCasts) {
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -746,8 +746,7 @@
Previous->isOneOf(tok::r_square, tok::r_paren, tok::plusplus,
  tok::minusminus)))
 return addUnwrappedLine();
-  if ((PreviousMustBeValue || Previous->is(tok::r_brace)) &&
-  isJSDeclOrStmt(Keywords, Next))
+  if (PreviousMustBeValue && isJSDeclOrStmt(Keywords, Next))
 return addUnwrappedLine();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28763: clang-format: [JS] revert over-eager ASI check.

2017-01-16 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292099: clang-format: [JS] revert over-eager ASI check. 
(authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D28763?vs=84527&id=84528#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28763

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


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -746,8 +746,7 @@
Previous->isOneOf(tok::r_square, tok::r_paren, tok::plusplus,
  tok::minusminus)))
 return addUnwrappedLine();
-  if ((PreviousMustBeValue || Previous->is(tok::r_brace)) &&
-  isJSDeclOrStmt(Keywords, Next))
+  if (PreviousMustBeValue && isJSDeclOrStmt(Keywords, Next))
 return addUnwrappedLine();
 }
 
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -858,26 +858,44 @@
"return 1",
"a = null\n"
"  return   1");
+  // Below "class Y {}" should ideally be on its own line.
   verifyFormat(
   "x = {\n"
   "  a: 1\n"
-  "}\n"
-  "class Y {}",
+  "} class Y {}",
   "  x  =  {a  : 1}\n"
   "   class  Y {  }");
+  verifyFormat(
+  "if (x) {\n"
+  "}\n"
+  "return 1",
+  "if (x) {}\n"
+  " return   1");
+  verifyFormat(
+  "if (x) {\n"
+  "}\n"
+  "class X {}",
+  "if (x) {}\n"
+  " class X {}");
 }
 
 TEST_F(FormatTestJS, ImportExportASI) {
   verifyFormat(
   "import {x} from 'y'\n"
   "export function z() {}",
   "import   {x} from 'y'\n"
   "  export function z() {}");
+  // Below "class Y {}" should ideally be on its own line.
   verifyFormat(
-  "export {x}\n"
-  "class Y {}",
+  "export {x} class Y {}",
   "  export {x}\n"
   "  class  Y {\n}");
+  verifyFormat(
+  "if (x) {\n"
+  "}\n"
+  "export class Y {}",
+  "if ( x ) { }\n"
+  " export class Y {}");
 }
 
 TEST_F(FormatTestJS, ClosureStyleCasts) {


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -746,8 +746,7 @@
Previous->isOneOf(tok::r_square, tok::r_paren, tok::plusplus,
  tok::minusminus)))
 return addUnwrappedLine();
-  if ((PreviousMustBeValue || Previous->is(tok::r_brace)) &&
-  isJSDeclOrStmt(Keywords, Next))
+  if (PreviousMustBeValue && isJSDeclOrStmt(Keywords, Next))
 return addUnwrappedLine();
 }
 
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -858,26 +858,44 @@
"return 1",
"a = null\n"
"  return   1");
+  // Below "class Y {}" should ideally be on its own line.
   verifyFormat(
   "x = {\n"
   "  a: 1\n"
-  "}\n"
-  "class Y {}",
+  "} class Y {}",
   "  x  =  {a  : 1}\n"
   "   class  Y {  }");
+  verifyFormat(
+  "if (x) {\n"
+  "}\n"
+  "return 1",
+  "if (x) {}\n"
+  " return   1");
+  verifyFormat(
+  "if (x) {\n"
+  "}\n"
+  "class X {}",
+  "if (x) {}\n"
+  " class X {}");
 }
 
 TEST_F(FormatTestJS, ImportExportASI) {
   verifyFormat(
   "import {x} from 'y'\n"
   "export function z() {}",
   "import   {x} from 'y'\n"
   "  export function z() {}");
+  // Below "class Y {}" should ideally be on its own line.
   verifyFormat(
-  "export {x}\n"
-  "class Y {}",
+  "export {x} class Y {}",
   "  export {x}\n"
   "  class  Y {\n}");
+  verifyFormat(
+  "if (x) {\n"
+  "}\n"
+  "export class Y {}",
+  "if ( x ) { }\n"
+  " export class Y {}");
 }
 
 TEST_F(FormatTestJS, ClosureStyleCasts) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r292099 - clang-format: [JS] revert over-eager ASI check.

2017-01-16 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Mon Jan 16 03:52:40 2017
New Revision: 292099

URL: http://llvm.org/viewvc/llvm-project?rev=292099&view=rev
Log:
clang-format: [JS] revert over-eager ASI check.

Summary: Change r291428 introduced ASI detection after closing curly braces. 
That would generally be correct, however this breaks indentation for structural 
statements. What happens is that CompoundStatementIndenter increases 
indentation for the current line, then after reading ASI creates a new line 
(with the increased line level), and only after the structural parser sees e.g. 
the if/then/else branch closed, line level is reduced. That leads to the new 
line started by ASI having a level too high.

Reviewers: djasper

Subscribers: sammccall, cfe-commits, klimek

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

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

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=292099&r1=292098&r2=292099&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Mon Jan 16 03:52:40 2017
@@ -746,8 +746,7 @@ void UnwrappedLineParser::readTokenWithJ
Previous->isOneOf(tok::r_square, tok::r_paren, tok::plusplus,
  tok::minusminus)))
 return addUnwrappedLine();
-  if ((PreviousMustBeValue || Previous->is(tok::r_brace)) &&
-  isJSDeclOrStmt(Keywords, Next))
+  if (PreviousMustBeValue && isJSDeclOrStmt(Keywords, Next))
 return addUnwrappedLine();
 }
 

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=292099&r1=292098&r2=292099&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Mon Jan 16 03:52:40 2017
@@ -858,13 +858,25 @@ TEST_F(FormatTestJS, AutomaticSemicolonI
"return 1",
"a = null\n"
"  return   1");
+  // Below "class Y {}" should ideally be on its own line.
   verifyFormat(
   "x = {\n"
   "  a: 1\n"
-  "}\n"
-  "class Y {}",
+  "} class Y {}",
   "  x  =  {a  : 1}\n"
   "   class  Y {  }");
+  verifyFormat(
+  "if (x) {\n"
+  "}\n"
+  "return 1",
+  "if (x) {}\n"
+  " return   1");
+  verifyFormat(
+  "if (x) {\n"
+  "}\n"
+  "class X {}",
+  "if (x) {}\n"
+  " class X {}");
 }
 
 TEST_F(FormatTestJS, ImportExportASI) {
@@ -873,11 +885,17 @@ TEST_F(FormatTestJS, ImportExportASI) {
   "export function z() {}",
   "import   {x} from 'y'\n"
   "  export function z() {}");
+  // Below "class Y {}" should ideally be on its own line.
   verifyFormat(
-  "export {x}\n"
-  "class Y {}",
+  "export {x} class Y {}",
   "  export {x}\n"
   "  class  Y {\n}");
+  verifyFormat(
+  "if (x) {\n"
+  "}\n"
+  "export class Y {}",
+  "if ( x ) { }\n"
+  " export class Y {}");
 }
 
 TEST_F(FormatTestJS, ClosureStyleCasts) {


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


[PATCH] D28315: Update tools to use new getStyle API

2017-01-16 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

Let me know when broken tests are fixed and this patch (and the corresponding 
patch) is ready again for review. Also let me know if you need any help.




Comment at: change-namespace/ChangeNamespace.cpp:892
+  llvm::errs() << llvm::toString(Style.takeError()) << "\n";
+  continue;
+}

amaiorano wrote:
> amaiorano wrote:
> > amaiorano wrote:
> > > ioeric wrote:
> > > > I'd still like to apply replacements that are not cleaned up. Could you 
> > > > add the following line before continue, thanks! :)
> > > > ```
> > > > FileToReplacements[FilePath] = Replaces;
> > > > ```
> > > Will do.
> > Ah darn, just realized that I forgot to make this change you asked for 
> > @ioeric. Let me know if everything else is okay, and I'll be sure to add 
> > this in before submitting. 
> @ioeric Was looking at this code, and I'm wondering about the change you 
> wanted me to make here. You said that you'd still like to apply replacements 
> that are not cleaned up, so shouldn't that also be the case for when 
> format::cleanupAroundReplacements fails (just below)? In other words, 
> shouldn't it be:
> 
> ```
> // Clean up old namespaces if there is nothing in it after moving.
> auto CleanReplacements =
> format::cleanupAroundReplacements(Code, Replaces, *Style);
> if (!CleanReplacements) {
>   llvm::errs() << llvm::toString(CleanReplacements.takeError()) << "\n";
>   FileToReplacements[FilePath] = Replaces;
>   continue;
> }
> FileToReplacements[FilePath] = *CleanReplacements;
>   }
> ```
> 
> If so, I propose instead that we add 
> ```
> FileToReplacements[FilePath] = Replaces;
> ``` 
> before the call to format::getStyle so that if either of the format-related 
> calls below it (getStyle or cleanupAroundReplacements) fail, we get the 
> unclean replacements.
After taking a closer look, I realize that we don't actually need this change 
since `Replaces` is a reference to `FileToReplacements[FilePath]`.


https://reviews.llvm.org/D28315



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


[PATCH] D28764: [clang-format] Implement comment reflowing (v3)

2017-01-16 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
krasimir added a reviewer: klimek.
krasimir added subscribers: ioeric, cfe-commits, mgorny, klimek, djasper.

This presents a version of the comment reflowing with less mutable state inside
the comment breakable token subclasses. The state has been pushed into the
driving breakProtrudingToken method. For this, the API of BreakableToken is 
enriched 
by the methods getSplitBefore and getLineLengthAfterSplitBefore.


https://reviews.llvm.org/D28764

Files:
  lib/Format/BreakableToken.cpp
  lib/Format/BreakableToken.h
  lib/Format/CMakeLists.txt
  lib/Format/Comments.cpp
  lib/Format/Comments.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/TokenAnnotator.cpp
  lib/Format/UnwrappedLineParser.cpp
  lib/Format/WhitespaceManager.cpp
  unittests/Format/FormatTest.cpp
  unittests/Format/FormatTestSelective.cpp

Index: unittests/Format/FormatTestSelective.cpp
===
--- unittests/Format/FormatTestSelective.cpp
+++ unittests/Format/FormatTestSelective.cpp
@@ -111,13 +111,19 @@
 format("int   a; // comment\n"
"intb; // comment",
0, 0));
-  EXPECT_EQ("int   a; // comment\n"
-" // line 2\n"
+  EXPECT_EQ("int a; // comment\n"
+"   // line 2\n"
 "int b;",
 format("int   a; // comment\n"
"// line 2\n"
"int b;",
28, 0));
+  EXPECT_EQ("int   a; // comment\n"
+"// comment 2\n"
+"int b;",
+format("int   a; // comment\n"
+   "// comment 2\n"
+   "int b;", 28, 0));
   EXPECT_EQ("int aa; // comment\n"
 "int b;\n"
 "int c; // unrelated comment",
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -1783,6 +1783,455 @@
"0x00, 0x00, 0x00, 0x00};// comment\n");
 }
 
+TEST_F(FormatTest, ReflowsComments) {
+  // Break a long line and reflow with the full next line.
+  EXPECT_EQ("// long long long\n"
+"// long long",
+format("// long long long long\n"
+   "// long",
+   getLLVMStyleWithColumns(20)));
+
+  // Keep the trailing newline while reflowing.
+  EXPECT_EQ("// long long long\n"
+"// long long\n",
+format("// long long long long\n"
+   "// long\n",
+   getLLVMStyleWithColumns(20)));
+
+  // Break a long line and reflow with a part of the next line.
+  EXPECT_EQ("// long long long\n"
+"// long long\n"
+"// long_long",
+format("// long long long long\n"
+   "// long long_long",
+   getLLVMStyleWithColumns(20)));
+
+  // Break but do not reflow if the first word from the next line is too long.
+  EXPECT_EQ("// long long long\n"
+"// long\n"
+"// long_long_long\n",
+format("// long long long long\n"
+   "// long_long_long\n",
+   getLLVMStyleWithColumns(20)));
+
+  // Don't break or reflow short lines.
+  verifyFormat("// long\n"
+   "// long long long lo\n"
+   "// long long long lo\n"
+   "// long",
+   getLLVMStyleWithColumns(20));
+
+  // Keep prefixes and decorations while reflowing.
+  EXPECT_EQ("/// long long long\n"
+"/// long long\n",
+format("/// long long long long\n"
+   "/// long\n",
+   getLLVMStyleWithColumns(20)));
+  EXPECT_EQ("//! long long long\n"
+"//! long long\n",
+format("//! long long long long\n"
+   "//! long\n",
+   getLLVMStyleWithColumns(20)));
+  EXPECT_EQ("/* long long long\n"
+" * long long */",
+format("/* long long long long\n"
+   " * long */",
+   getLLVMStyleWithColumns(20)));
+
+  // Don't bring leading whitespace up while reflowing.
+  EXPECT_EQ("/*  long long long\n"
+" * long long long\n"
+" */",
+format("/*  long long long long\n"
+   " *  long long\n"
+   " */",
+   getLLVMStyleWithColumns(20)));
+
+  // Reflow the last line of a block comment with its trailing '*/'.
+  EXPECT_EQ("/* long long long\n"
+"   long long */",
+format("/* long long long long\n"
+   "   long */",
+   getLLVMStyleWithColumns(20)));
+
+  // Reflow two short lines; keep the postfix of the last one.
+  EXPECT_EQ("/* long long long\n"
+" * long long long */",
+format("/* long long long long\n"
+   " * long\n"
+   " * long */",
+ 

[PATCH] D25817: [Sema] Improve the error diagnostic for dot destructor calls on pointer objects

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

Are there any other comments for this patch? I would like to commit it in the 
next couple of days, as it was accepted and I believe I addressed Richard's 
concerns.

Thanks


Repository:
  rL LLVM

https://reviews.llvm.org/D25817



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


[PATCH] D28765: CStringChecker can crash when uninitialized checks are disabled

2017-01-16 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich created this revision.
vlad.tsyrklevich added reviewers: cfe-commits, zaks.anna, dcoughlin, NoQ.

CStringChecker assumes that SVals are not undefined at two points with comments 
stating that other checkers will check for that condition first; however, it 
can crash if a user chooses a particular configuration. I hit such an unlucky 
configuration while eliminating false positive heavy checks analyzing the Linux 
kernel and tracked down the crashes to this assumption.

Add UndefinedVal checks where appropriate.


https://reviews.llvm.org/D28765

Files:
  lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  test/Analysis/cstring-regressions.c


Index: test/Analysis/cstring-regressions.c
===
--- /dev/null
+++ test/Analysis/cstring-regressions.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,unix.cstring,debug.ExprInspection 
-analyzer-disable-checker=core.UndefinedBinaryOperatorResult,core.CallAndMessage,core.NullDereference,core.uninitialized
 -analyzer-store=region -verify %s
+//
+// CStringChecker crashes found running analyzer over the Linux kernel source
+// with a very particular set of enabled/disabled checks.
+
+int strcmp(const char * s1, const char * s2);
+int memcmp(const void *s1, const void *s2, unsigned long n);
+void clang_analyzer_eval(int);
+
+void test1(void *ptr) {
+ int uninit;
+ clang_analyzer_eval(strcmp(ptr + uninit, "mcp_trace_meta") == 0); // 
expected-warning{{UNKNOWN}}
+}
+
+void test2(char *foo, void *ptr) {
+ int uninit;
+ clang_analyzer_eval(memcmp(foo, ptr + uninit, 48) == 0); // 
expected-warning{{UNKNOWN}}
+}
Index: lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -1179,15 +1179,17 @@
   if (stateNonZeroSize) {
 state = stateNonZeroSize;
 // If we know the two buffers are the same, we know the result is 0.
-// First, get the two buffers' addresses. Another checker will have already
-// made sure they're not undefined.
-DefinedOrUnknownSVal LV =
-state->getSVal(Left, LCtx).castAs();
-DefinedOrUnknownSVal RV =
-state->getSVal(Right, LCtx).castAs();
+// First, get the two buffers' addresses.
+Optional LV =
+state->getSVal(Left, LCtx).getAs();
+Optional RV =
+state->getSVal(Right, LCtx).getAs();
+
+if (!LV || !RV)
+  return;
 
 // See if they are the same.
-DefinedOrUnknownSVal SameBuf = svalBuilder.evalEQ(state, LV, RV);
+DefinedOrUnknownSVal SameBuf = svalBuilder.evalEQ(state, *LV, *RV);
 ProgramStateRef StSameBuf, StNotSameBuf;
 std::tie(StSameBuf, StNotSameBuf) = state->assume(SameBuf);
 
@@ -1781,13 +1783,19 @@
   // Check that the first string is non-null
   const Expr *s1 = CE->getArg(0);
   SVal s1Val = state->getSVal(s1, LCtx);
+  if (s1Val.isUndef())
+return;
+
   state = checkNonNull(C, state, s1, s1Val);
   if (!state)
 return;
 
   // Check that the second string is non-null.
   const Expr *s2 = CE->getArg(1);
   SVal s2Val = state->getSVal(s2, LCtx);
+  if (s2Val.isUndef())
+return;
+
   state = checkNonNull(C, state, s2, s2Val);
   if (!state)
 return;
@@ -1803,8 +1811,7 @@
 return;
 
   // If we know the two buffers are the same, we know the result is 0.
-  // First, get the two buffers' addresses. Another checker will have already
-  // made sure they're not undefined.
+  // First, get the two buffers' addresses.
   DefinedOrUnknownSVal LV = s1Val.castAs();
   DefinedOrUnknownSVal RV = s2Val.castAs();
 


Index: test/Analysis/cstring-regressions.c
===
--- /dev/null
+++ test/Analysis/cstring-regressions.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,debug.ExprInspection -analyzer-disable-checker=core.UndefinedBinaryOperatorResult,core.CallAndMessage,core.NullDereference,core.uninitialized -analyzer-store=region -verify %s
+//
+// CStringChecker crashes found running analyzer over the Linux kernel source
+// with a very particular set of enabled/disabled checks.
+
+int strcmp(const char * s1, const char * s2);
+int memcmp(const void *s1, const void *s2, unsigned long n);
+void clang_analyzer_eval(int);
+
+void test1(void *ptr) {
+ int uninit;
+ clang_analyzer_eval(strcmp(ptr + uninit, "mcp_trace_meta") == 0); // expected-warning{{UNKNOWN}}
+}
+
+void test2(char *foo, void *ptr) {
+ int uninit;
+ clang_analyzer_eval(memcmp(foo, ptr + uninit, 48) == 0); // expected-warning{{UNKNOWN}}
+}
Index: lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -1179,15 +1179,17 @@
   if (stateNonZeroSize) {
 state = stateNonZeroSize;
 

[PATCH] D28081: Make GetStyle return Expected instead of FormatStyle

2017-01-16 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano updated this revision to Diff 84538.
amaiorano added a comment.

Rebased changes on latest, no functional change in this diff.


https://reviews.llvm.org/D28081

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Tooling/Refactoring.cpp
  test/Format/style-on-command-line.cpp
  tools/clang-format/ClangFormat.cpp
  unittests/Format/FormatTest.cpp
  unittests/Format/FormatTestObjC.cpp

Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -68,17 +68,21 @@
   FormatStyle Style;
 };
 
-TEST_F(FormatTestObjC, DetectsObjCInHeaders) {
-  Style = getStyle("LLVM", "a.h", "none", "@interface\n"
-  "- (id)init;");
-  EXPECT_EQ(FormatStyle::LK_ObjC, Style.Language);
+TEST(FormatTestObjCStyle, DetectsObjCInHeaders) {
+  auto Style = getStyle("LLVM", "a.h", "none", "@interface\n"
+   "- (id)init;");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
   Style = getStyle("LLVM", "a.h", "none", "@interface\n"
   "+ (id)init;");
-  EXPECT_EQ(FormatStyle::LK_ObjC, Style.Language);
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 
   // No recognizable ObjC.
   Style = getStyle("LLVM", "a.h", "none", "void f() {}");
-  EXPECT_EQ(FormatStyle::LK_Cpp, Style.Language);
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
 }
 
 TEST_F(FormatTestObjC, FormatObjCTryCatch) {
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -10967,22 +10967,51 @@
   ASSERT_TRUE(
   FS.addFile("/a/test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int i;")));
   auto Style1 = getStyle("file", "/a/.clang-format", "Google", "", &FS);
-  ASSERT_EQ(Style1, getLLVMStyle());
+  ASSERT_TRUE((bool)Style1);
+  ASSERT_EQ(*Style1, getLLVMStyle());
 
   // Test 2: fallback to default.
   ASSERT_TRUE(
   FS.addFile("/b/test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int i;")));
   auto Style2 = getStyle("file", "/b/test.cpp", "Mozilla", "", &FS);
-  ASSERT_EQ(Style2, getMozillaStyle());
+  ASSERT_TRUE((bool)Style2);
+  ASSERT_EQ(*Style2, getMozillaStyle());
 
   // Test 3: format file in parent directory.
   ASSERT_TRUE(
   FS.addFile("/c/.clang-format", 0,
  llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
   ASSERT_TRUE(FS.addFile("/c/sub/sub/sub/test.cpp", 0,
  llvm::MemoryBuffer::getMemBuffer("int i;")));
   auto Style3 = getStyle("file", "/c/sub/sub/sub/test.cpp", "LLVM", "", &FS);
-  ASSERT_EQ(Style3, getGoogleStyle());
+  ASSERT_TRUE((bool)Style3);
+  ASSERT_EQ(*Style3, getGoogleStyle());
+
+  // Test 4: error on invalid fallback style
+  auto Style4 = getStyle("file", "a.h", "KungFu", "", &FS);
+  ASSERT_FALSE((bool)Style4);
+  llvm::consumeError(Style4.takeError());
+
+  // Test 5: error on invalid yaml on command line
+  auto Style5 = getStyle("{invalid_key=invalid_value}", "a.h", "LLVM", "", &FS);
+  ASSERT_FALSE((bool)Style5);
+  llvm::consumeError(Style5.takeError());
+
+  // Test 6: error on invalid style
+  auto Style6 = getStyle("KungFu", "a.h", "LLVM", "", &FS);
+  ASSERT_FALSE((bool)Style6);
+  llvm::consumeError(Style6.takeError());
+
+  // Test 7: found config file, error on parsing it
+  ASSERT_TRUE(
+  FS.addFile("/d/.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: LLVM\n"
+  "InvalidKey: InvalidValue")));
+  ASSERT_TRUE(
+  FS.addFile("/d/test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int i;")));
+  auto Style7 = getStyle("file", "/d/.clang-format", "LLVM", "", &FS);
+  ASSERT_FALSE((bool)Style7);
+  llvm::consumeError(Style7.takeError());
 }
 
 TEST_F(ReplacementTest, FormatCodeAfterReplacements) {
Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -249,12 +249,17 @@
   if (fillRanges(Code.get(), Ranges))
 return true;
   StringRef AssumedFileName = (FileName == "-") ? AssumeFileName : FileName;
-  FormatStyle FormatStyle =
+
+  llvm::Expected FormatStyle =
   getStyle(Style, AssumedFileName, FallbackStyle, Code->getBuffer());
+  if (!FormatStyle) {
+llvm::errs() << llvm::toString(FormatStyle.takeError()) << "\n";
+return true;
+  }
   if (SortIncludes.getNumOccurrences() != 0)
-FormatStyle.SortIncludes = SortIncludes;
+FormatStyle->SortIncludes = SortIncludes;
   unsigned CursorPosition = Cursor;
-  Replacements Replaces = sortIncludes(FormatStyle, Code->getBuffer(), Ranges,
+  Replacements Replaces = sortIncludes(*For

[PATCH] D28315: Update tools to use new getStyle API

2017-01-16 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano updated this revision to Diff 84539.
amaiorano added a comment.

Rebased changes on latest. No functional changes in this diff since last.

All tests pass (on Windows).


https://reviews.llvm.org/D28315

Files:
  change-namespace/ChangeNamespace.cpp
  clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
  clang-move/ClangMove.cpp
  clang-tidy/ClangTidy.cpp
  include-fixer/tool/ClangIncludeFixer.cpp

Index: include-fixer/tool/ClangIncludeFixer.cpp
===
--- include-fixer/tool/ClangIncludeFixer.cpp
+++ include-fixer/tool/ClangIncludeFixer.cpp
@@ -303,10 +303,13 @@
const IncludeFixerContext::HeaderInfo &RHS) {
   return LHS.QualifiedName == RHS.QualifiedName;
 });
-format::FormatStyle InsertStyle =
-format::getStyle("file", Context.getFilePath(), Style);
+auto InsertStyle = format::getStyle("file", Context.getFilePath(), Style);
+if (!InsertStyle) {
+  llvm::errs() << llvm::toString(InsertStyle.takeError()) << "\n";
+  return 1;
+}
 auto Replacements = clang::include_fixer::createIncludeFixerReplacements(
-Code->getBuffer(), Context, InsertStyle,
+Code->getBuffer(), Context, *InsertStyle,
 /*AddQualifiers=*/IsUniqueQualifiedName);
 if (!Replacements) {
   errs() << "Failed to create replacements: "
@@ -378,16 +381,20 @@
   std::vector FixerReplacements;
   for (const auto &Context : Contexts) {
 StringRef FilePath = Context.getFilePath();
-format::FormatStyle InsertStyle = format::getStyle("file", FilePath, Style);
+auto InsertStyle = format::getStyle("file", FilePath, Style);
+if (!InsertStyle) {
+  llvm::errs() << llvm::toString(InsertStyle.takeError()) << "\n";
+  return 1;
+}
 auto Buffer = llvm::MemoryBuffer::getFile(FilePath);
 if (!Buffer) {
   errs() << "Couldn't open file: " + FilePath.str() + ": "
  << Buffer.getError().message() + "\n";
   return 1;
 }
 
 auto Replacements = clang::include_fixer::createIncludeFixerReplacements(
-Buffer.get()->getBuffer(), Context, InsertStyle);
+Buffer.get()->getBuffer(), Context, *InsertStyle);
 if (!Replacements) {
   errs() << "Failed to create replacement: "
  << llvm::toString(Replacements.takeError()) << "\n";
Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -197,10 +197,14 @@
   continue;
 }
 StringRef Code = Buffer.get()->getBuffer();
-format::FormatStyle Style = format::getStyle("file", File, FormatStyle);
+auto Style = format::getStyle("file", File, FormatStyle);
+if (!Style) {
+  llvm::errs() << llvm::toString(Style.takeError()) << "\n";
+  continue;
+}
 llvm::Expected CleanReplacements =
 format::cleanupAroundReplacements(Code, FileAndReplacements.second,
-  Style);
+  *Style);
 if (!CleanReplacements) {
   llvm::errs() << llvm::toString(CleanReplacements.takeError()) << "\n";
   continue;
Index: clang-move/ClangMove.cpp
===
--- clang-move/ClangMove.cpp
+++ clang-move/ClangMove.cpp
@@ -742,10 +742,13 @@
 // Ignore replacements for new.h/cc.
 if (SI == FilePathToFileID.end()) continue;
 llvm::StringRef Code = SM.getBufferData(SI->second);
-format::FormatStyle Style =
-format::getStyle("file", FilePath, Context->FallbackStyle);
+auto Style = format::getStyle("file", FilePath, Context->FallbackStyle);
+if (!Style) {
+  llvm::errs() << llvm::toString(Style.takeError()) << "\n";
+  continue;
+}
 auto CleanReplacements = format::cleanupAroundReplacements(
-Code, Context->FileToReplacements[FilePath], Style);
+Code, Context->FileToReplacements[FilePath], *Style);
 
 if (!CleanReplacements) {
   llvm::errs() << llvm::toString(CleanReplacements.takeError()) << "\n";
Index: clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
===
--- clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
+++ clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
@@ -208,8 +208,15 @@
 
   // Determine a formatting style from options.
   format::FormatStyle FormatStyle;
-  if (DoFormat)
-FormatStyle = format::getStyle(FormatStyleOpt, FormatStyleConfig, "LLVM");
+  if (DoFormat) {
+auto FormatStyleOrError =
+format::getStyle(FormatStyleOpt, FormatStyleConfig, "LLVM");
+if (!FormatStyleOrError) {
+  llvm::errs() << llvm::toString(FormatStyleOrError.takeError()) << "\n";
+  return 1;
+}
+FormatStyle = *FormatStyleOrError;
+  }
 
   TUReplacements TURs;

[PATCH] D28315: Update tools to use new getStyle API

2017-01-16 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano added a comment.

In https://reviews.llvm.org/D28315#647103, @ioeric wrote:

> Let me know when broken tests are fixed and this patch (and the corresponding 
> patch) is ready again for review. Also let me know if you need any help.


I updated the two patches after rebasing on latest (no conflicts). These should 
be ready to go. If you don't mind testing the two again on Linux, that would be 
greatly appreciated. Otherwise, on Windows the tests pass.


https://reviews.llvm.org/D28315



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


[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'

2017-01-16 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: hokein, Prazek, aaron.ballman, alexfh.
JDevlieghere added a subscriber: cfe-commits.
JDevlieghere set the repository for this revision to rL LLVM.
JDevlieghere added a project: clang-tools-extra.
Herald added a subscriber: mgorny.

Replaces explicit calls to the constructor in a return with a braced
initializer list. This way the return type is not needlessly duplicated in the
return type and the return statement.

  Foo bar() {
Baz baz;
return Foo(baz);
  }
  
  // transforms to:
  
  Foo bar() {
Baz baz;
return {baz};
  }


Repository:
  rL LLVM

https://reviews.llvm.org/D28768

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/ReturnBracedInitListCheck.cpp
  clang-tidy/modernize/ReturnBracedInitListCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-return-braced-init-list.rst
  test/clang-tidy/modernize-return-braced-init-list.cpp

Index: test/clang-tidy/modernize-return-braced-init-list.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-return-braced-init-list.cpp
@@ -0,0 +1,33 @@
+// RUN: %check_clang_tidy %s modernize-return-braced-init-list %t
+
+class Bar {};
+
+class Foo {
+public:
+  Foo(Bar bar) : bar(bar){};
+
+private:
+  Bar bar;
+};
+
+class Baz {
+public:
+  Foo m() {
+Bar b;
+return Foo(b);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use braced initializer list for constructing return types [modernize-return-braced-init-list]
+// CHECK-FIXES: return {b};
+  }
+};
+
+Foo f() {
+  Bar b;
+  return Foo(b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use braced initializer list for constructing return types [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {b};
+}
+
+Foo f2() {
+  Bar b;
+  return {b};
+}
Index: docs/clang-tidy/checks/modernize-return-braced-init-list.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/modernize-return-braced-init-list.rst
@@ -0,0 +1,22 @@
+.. title:: clang-tidy - modernize-return-braced-init-list
+
+modernize-return-braced-init-list
+=
+
+Replaces explicit calls to the constructor in a return with a braced
+initializer list. This way the return type is not needlessly duplicated in the
+return type and the return statement.
+
+.. code:: c++
+
+  Foo bar() {
+Baz baz;
+return Foo(baz);
+  }
+
+  // transforms to:
+
+  Foo bar() {
+Baz baz;
+return {baz};
+  }
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -109,6 +109,7 @@
modernize-raw-string-literal
modernize-redundant-void-arg
modernize-replace-auto-ptr
+   modernize-return-braced-init-list
modernize-shrink-to-fit
modernize-use-auto
modernize-use-bool-literals
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,7 +57,11 @@
 Improvements to clang-tidy
 --
 
-The improvements are...
+- New `modernize-return-braced-init-list
+`_ check
+
+  Replaces explicit calls to the constructor in a return statement by a braced
+  initializer list so that the return type is not needlessly repeated.
 
 Improvements to include-fixer
 -
Index: clang-tidy/modernize/ReturnBracedInitListCheck.h
===
--- /dev/null
+++ clang-tidy/modernize/ReturnBracedInitListCheck.h
@@ -0,0 +1,36 @@
+//===--- ReturnBracedInitListCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_RETURN_BRACED_INIT_LIST_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_RETURN_BRACED_INIT_LIST_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+/// Use a braced init list for return statements rather than unnecessary
+/// repeating the return type name.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/modernize-return-braced-init-list.html
+class ReturnBracedInitListCheck : public ClangTidyCheck {
+public:
+  ReturnBracedInitListCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void ch

[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'

2017-01-16 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

What happens if the function has `auto` as the return type?




Comment at: clang-tidy/modernize/ReturnBracedInitListCheck.cpp:23
+void ReturnBracedInitListCheck::registerMatchers(MatchFinder *Finder) {
+  // Only register the matchers for C++.
+  if (!getLangOpts().CPlusPlus)

C++11?



Comment at: clang-tidy/modernize/ReturnBracedInitListCheck.cpp:37
+  functionDecl(isDefinition(), // Declarations don't have return 
statements.
+   returns(recordType()), // We onnly care about record types.
+   hasDescendant(returnStmt(hasDescendant(ctorAsArgument

typo - only.


Repository:
  rL LLVM

https://reviews.llvm.org/D28768



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


[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'

2017-01-16 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere updated this revision to Diff 84543.
JDevlieghere added a comment.

- Fixed comments from @malcolm.parsons

In https://reviews.llvm.org/D28768#647177, @malcolm.parsons wrote:

> What happens if the function has `auto` as the return type?


Nothing, the constructor is left untouched.


Repository:
  rL LLVM

https://reviews.llvm.org/D28768

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/ReturnBracedInitListCheck.cpp
  clang-tidy/modernize/ReturnBracedInitListCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-return-braced-init-list.rst
  test/clang-tidy/modernize-return-braced-init-list.cpp

Index: test/clang-tidy/modernize-return-braced-init-list.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-return-braced-init-list.cpp
@@ -0,0 +1,33 @@
+// RUN: %check_clang_tidy %s modernize-return-braced-init-list %t
+
+class Bar {};
+
+class Foo {
+public:
+  Foo(Bar bar) : bar(bar){};
+
+private:
+  Bar bar;
+};
+
+class Baz {
+public:
+  Foo m() {
+Bar b;
+return Foo(b);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use braced initializer list for constructing return types [modernize-return-braced-init-list]
+// CHECK-FIXES: return {b};
+  }
+};
+
+Foo f() {
+  Bar b;
+  return Foo(b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use braced initializer list for constructing return types [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {b};
+}
+
+Foo f2() {
+  Bar b;
+  return {b};
+}
Index: docs/clang-tidy/checks/modernize-return-braced-init-list.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/modernize-return-braced-init-list.rst
@@ -0,0 +1,22 @@
+.. title:: clang-tidy - modernize-return-braced-init-list
+
+modernize-return-braced-init-list
+=
+
+Replaces explicit calls to the constructor in a return with a braced
+initializer list. This way the return type is not needlessly duplicated in the
+return type and the return statement.
+
+.. code:: c++
+
+  Foo bar() {
+Baz baz;
+return Foo(baz);
+  }
+
+  // transforms to:
+
+  Foo bar() {
+Baz baz;
+return {baz};
+  }
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -109,6 +109,7 @@
modernize-raw-string-literal
modernize-redundant-void-arg
modernize-replace-auto-ptr
+   modernize-return-braced-init-list
modernize-shrink-to-fit
modernize-use-auto
modernize-use-bool-literals
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,7 +57,11 @@
 Improvements to clang-tidy
 --
 
-The improvements are...
+- New `modernize-return-braced-init-list
+`_ check
+
+  Replaces explicit calls to the constructor in a return statement by a braced
+  initializer list so that the return type is not needlessly repeated.
 
 Improvements to include-fixer
 -
Index: clang-tidy/modernize/ReturnBracedInitListCheck.h
===
--- /dev/null
+++ clang-tidy/modernize/ReturnBracedInitListCheck.h
@@ -0,0 +1,36 @@
+//===--- ReturnBracedInitListCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_RETURN_BRACED_INIT_LIST_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_RETURN_BRACED_INIT_LIST_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+/// Use a braced init list for return statements rather than unnecessary
+/// repeating the return type name.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/modernize-return-braced-init-list.html
+class ReturnBracedInitListCheck : public ClangTidyCheck {
+public:
+  ReturnBracedInitListCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace modernize
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_RETURN_BRACED_INIT_LIST_H
Index: clang-tidy/modernize/ReturnBracedInitListCheck.cpp
===

[libcxx] r292107 - [libcxx] Don't assume __libcpp_thread_t is an integral type

2017-01-16 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Mon Jan 16 06:19:54 2017
New Revision: 292107

URL: http://llvm.org/viewvc/llvm-project?rev=292107&view=rev
Log:
[libcxx] Don't assume __libcpp_thread_t is an integral type

We have already refactored the underlying platform thread type into
__libcpp_thread_t, but there are few places in the source where we
still assume it is an integral type.

This patch refactores those points back into the threading API.

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

Reviewers: EricWF

Modified:
libcxx/trunk/include/__threading_support
libcxx/trunk/include/thread

Modified: libcxx/trunk/include/__threading_support
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=292107&r1=292106&r2=292107&view=diff
==
--- libcxx/trunk/include/__threading_support (original)
+++ libcxx/trunk/include/__threading_support Mon Jan 16 06:19:54 2017
@@ -61,6 +61,8 @@ typedef pthread_once_t __libcpp_exec_onc
 typedef pthread_t __libcpp_thread_id;
 
 // Thread
+#define _LIBCPP_NULL_THREAD 0U
+
 typedef pthread_t __libcpp_thread_t;
 
 // Thrad Local Storage
@@ -86,6 +88,8 @@ typedef INIT_ONCE __libcpp_exec_once_fla
 typedef DWORD __libcpp_thread_id;
 
 // Thread
+#define _LIBCPP_NULL_THREAD 0U
+
 typedef HANDLE __libcpp_thread_t;
 
 // Thread Local Storage
@@ -158,6 +162,9 @@ bool __libcpp_thread_id_less(__libcpp_th
 
 // Thread
 _LIBCPP_THREAD_ABI_VISIBILITY
+bool __libcpp_thread_isnull(const __libcpp_thread_t *__t);
+
+_LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
void *__arg);
 
@@ -309,6 +316,10 @@ bool __libcpp_thread_id_less(__libcpp_th
 }
 
 // Thread
+bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
+  return *__t == 0;
+}
+
 int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
void *__arg)
 {
@@ -506,6 +517,10 @@ __libcpp_beginthreadex_thunk(void *__raw
   return static_cast(reinterpret_cast(__func(__arg)));
 }
 
+bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
+  return *__t == 0;
+}
+
 int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
void *__arg)
 {

Modified: libcxx/trunk/include/thread
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/thread?rev=292107&r1=292106&r2=292107&view=diff
==
--- libcxx/trunk/include/thread (original)
+++ libcxx/trunk/include/thread Mon Jan 16 06:19:54 2017
@@ -290,7 +290,7 @@ public:
 typedef __libcpp_thread_t native_handle_type;
 
 _LIBCPP_INLINE_VISIBILITY
-thread() _NOEXCEPT : __t_(0) {}
+thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {}
 #ifndef _LIBCPP_HAS_NO_VARIADICS
 template http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28608: [libcxx] Don't assume __libcpp_thread_t is an integral type.

2017-01-16 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292107: [libcxx] Don't assume __libcpp_thread_t is an 
integral type (authored by asiri).

Changed prior to commit:
  https://reviews.llvm.org/D28608?vs=84114&id=84544#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28608

Files:
  libcxx/trunk/include/__threading_support
  libcxx/trunk/include/thread


Index: libcxx/trunk/include/thread
===
--- libcxx/trunk/include/thread
+++ libcxx/trunk/include/thread
@@ -290,7 +290,7 @@
 typedef __libcpp_thread_t native_handle_type;
 
 _LIBCPP_INLINE_VISIBILITY
-thread() _NOEXCEPT : __t_(0) {}
+thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {}
 #ifndef _LIBCPP_HAS_NO_VARIADICS
 template (reinterpret_cast(__func(__arg)));
 }
 
+bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
+  return *__t == 0;
+}
+
 int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
void *__arg)
 {


Index: libcxx/trunk/include/thread
===
--- libcxx/trunk/include/thread
+++ libcxx/trunk/include/thread
@@ -290,7 +290,7 @@
 typedef __libcpp_thread_t native_handle_type;
 
 _LIBCPP_INLINE_VISIBILITY
-thread() _NOEXCEPT : __t_(0) {}
+thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {}
 #ifndef _LIBCPP_HAS_NO_VARIADICS
 template (reinterpret_cast(__func(__arg)));
 }
 
+bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
+  return *__t == 0;
+}
+
 int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
void *__arg)
 {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'

2017-01-16 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D28768#647198, @JDevlieghere wrote:

> In https://reviews.llvm.org/D28768#647177, @malcolm.parsons wrote:
>
> > What happens if the function has `auto` as the return type?
>
>
> Nothing, the constructor is left untouched.


Please add a test.


Repository:
  rL LLVM

https://reviews.llvm.org/D28768



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


[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'

2017-01-16 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere marked 2 inline comments as done.
JDevlieghere added a comment.

In https://reviews.llvm.org/D28768#647203, @malcolm.parsons wrote:

> In https://reviews.llvm.org/D28768#647198, @JDevlieghere wrote:
>
> > In https://reviews.llvm.org/D28768#647177, @malcolm.parsons wrote:
> >
> > > What happens if the function has `auto` as the return type?
> >
> >
> > Nothing, the constructor is left untouched.
>
>
> Please add a test.


I wanted to do that but it seems that the test script hard codes it to C++11, 
and the `auto` return type is a C++14 feature. Maybe I'm mistaken though, but I 
didn't manage to get it working, even when appending `-- -std=c++14` to the RUN 
command. Am I missing something?


Repository:
  rL LLVM

https://reviews.llvm.org/D28768



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


[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'

2017-01-16 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D28768#647204, @JDevlieghere wrote:

> I wanted to do that but it seems that the test script hard codes it to C++11, 
> and the `auto` return type is a C++14 feature. Maybe I'm mistaken though, but 
> I didn't manage to get it working, even when appending `-- -std=c++14` to the 
> RUN command. Am I missing something?


You need one `--` for check_clang_tidy and one for clang-tidy:
`-- -- -std=c++14`


Repository:
  rL LLVM

https://reviews.llvm.org/D28768



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


[PATCH] D28315: Update tools to use new getStyle API

2017-01-16 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

In https://reviews.llvm.org/D28315#647154, @amaiorano wrote:

> In https://reviews.llvm.org/D28315#647103, @ioeric wrote:
>
> > Let me know when broken tests are fixed and this patch (and the 
> > corresponding patch) is ready again for review. Also let me know if you 
> > need any help.
>
>
> I updated the two patches after rebasing on latest (no conflicts). These 
> should be ready to go. If you don't mind testing the two again on Linux, that 
> would be greatly appreciated. Otherwise, on Windows the tests pass.


All tests passed on Linux. Are these patches still depending on 
https://reviews.llvm.org/D28419? Or the previous issue has been somehow 
resolved on Windows?


https://reviews.llvm.org/D28315



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


[PATCH] D28610: [libcxx] Improve design documentation for the external-thread-library configuration

2017-01-16 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292108: [libcxx] Improve design documentation for the 
external-thread-library (authored by asiri).

Changed prior to commit:
  https://reviews.llvm.org/D28610?vs=84129&id=84548#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28610

Files:
  libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst


Index: libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst
===
--- libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst
+++ libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst
@@ -33,13 +33,22 @@
 External Threading Library
 ==
 
-Normally ``<__threading_support>`` provides inline definitions to each internal
-threading API function it declares. However libc++ also supports using an
-external library to provide the definitions.
-
-When ``_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL`` libc++ does not provide inline
-definitions for the internal API, instead assuming the definitions will be
-provided by an external library.
+libc++ can be compiled with its internal threading API delegating to an 
external
+library. Such a configuration is useful for library vendors who wish to
+distribute a thread-agnostic libc++ library, where the users of the library are
+expected to provide the implementation of the libc++ internal threading API.
+
+On a production setting, this would be achieved through a custom
+``<__external_threading>`` header, which declares the libc++ internal threading
+API but leaves out the implementation.
+
+The ``-DLIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY`` option allows building libc++ in
+such a configuration while allowing it to be tested on a platform that supports
+any of the threading systems (e.g. pthread) supported in 
``__threading_support``
+header. Therefore, the main purpose of this option is to allow testing of this
+particular configuration of the library without being tied to a vendor-specific
+threading system. This option is only meant to be used by libc++ library
+developers.
 
 Threading Configuration Macros
 ==


Index: libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst
===
--- libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst
+++ libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst
@@ -33,13 +33,22 @@
 External Threading Library
 ==
 
-Normally ``<__threading_support>`` provides inline definitions to each internal
-threading API function it declares. However libc++ also supports using an
-external library to provide the definitions.
-
-When ``_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL`` libc++ does not provide inline
-definitions for the internal API, instead assuming the definitions will be
-provided by an external library.
+libc++ can be compiled with its internal threading API delegating to an external
+library. Such a configuration is useful for library vendors who wish to
+distribute a thread-agnostic libc++ library, where the users of the library are
+expected to provide the implementation of the libc++ internal threading API.
+
+On a production setting, this would be achieved through a custom
+``<__external_threading>`` header, which declares the libc++ internal threading
+API but leaves out the implementation.
+
+The ``-DLIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY`` option allows building libc++ in
+such a configuration while allowing it to be tested on a platform that supports
+any of the threading systems (e.g. pthread) supported in ``__threading_support``
+header. Therefore, the main purpose of this option is to allow testing of this
+particular configuration of the library without being tied to a vendor-specific
+threading system. This option is only meant to be used by libc++ library
+developers.
 
 Threading Configuration Macros
 ==
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r292108 - [libcxx] Improve design documentation for the external-thread-library

2017-01-16 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Mon Jan 16 06:44:08 2017
New Revision: 292108

URL: http://llvm.org/viewvc/llvm-project?rev=292108&view=rev
Log:
[libcxx] Improve design documentation for the external-thread-library
  configuration

NFC.

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

Reviewers: EricWF

Modified:
libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst

Modified: libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst?rev=292108&r1=292107&r2=292108&view=diff
==
--- libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst (original)
+++ libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst Mon Jan 16 06:44:08 
2017
@@ -33,13 +33,22 @@ interface normally provided by ``<__thre
 External Threading Library
 ==
 
-Normally ``<__threading_support>`` provides inline definitions to each internal
-threading API function it declares. However libc++ also supports using an
-external library to provide the definitions.
+libc++ can be compiled with its internal threading API delegating to an 
external
+library. Such a configuration is useful for library vendors who wish to
+distribute a thread-agnostic libc++ library, where the users of the library are
+expected to provide the implementation of the libc++ internal threading API.
 
-When ``_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL`` libc++ does not provide inline
-definitions for the internal API, instead assuming the definitions will be
-provided by an external library.
+On a production setting, this would be achieved through a custom
+``<__external_threading>`` header, which declares the libc++ internal threading
+API but leaves out the implementation.
+
+The ``-DLIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY`` option allows building libc++ in
+such a configuration while allowing it to be tested on a platform that supports
+any of the threading systems (e.g. pthread) supported in 
``__threading_support``
+header. Therefore, the main purpose of this option is to allow testing of this
+particular configuration of the library without being tied to a vendor-specific
+threading system. This option is only meant to be used by libc++ library
+developers.
 
 Threading Configuration Macros
 ==


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


[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'

2017-01-16 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

In https://reviews.llvm.org/D28768#647206, @malcolm.parsons wrote:

> In https://reviews.llvm.org/D28768#647204, @JDevlieghere wrote:
>
> > I wanted to do that but it seems that the test script hard codes it to 
> > C++11, and the `auto` return type is a C++14 feature. Maybe I'm mistaken 
> > though, but I didn't manage to get it working, even when appending `-- 
> > -std=c++14` to the RUN command. Am I missing something?
>
>
> You need one `--` for check_clang_tidy and one for clang-tidy:
>  `-- -- -std=c++14`


Thanks, I forgot about the extra `--`! :-)


Repository:
  rL LLVM

https://reviews.llvm.org/D28768



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


[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'

2017-01-16 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere updated this revision to Diff 84549.
JDevlieghere added a comment.

Add test for auto return type.


Repository:
  rL LLVM

https://reviews.llvm.org/D28768

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/ReturnBracedInitListCheck.cpp
  clang-tidy/modernize/ReturnBracedInitListCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-return-braced-init-list.rst
  test/clang-tidy/modernize-return-braced-init-list.cpp

Index: test/clang-tidy/modernize-return-braced-init-list.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-return-braced-init-list.cpp
@@ -0,0 +1,38 @@
+// RUN: %check_clang_tidy %s modernize-return-braced-init-list %t -- -- -std=c++14
+
+class Bar {};
+
+class Foo {
+public:
+  Foo(Bar bar) : bar(bar){};
+
+private:
+  Bar bar;
+};
+
+class Baz {
+public:
+  Foo m() {
+Bar b;
+return Foo(b);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use braced initializer list for constructing return types [modernize-return-braced-init-list]
+// CHECK-FIXES: return {b};
+  }
+};
+
+Foo f() {
+  Bar b;
+  return Foo(b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use braced initializer list for constructing return types [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {b};
+}
+
+Foo f2() {
+  Bar b;
+  return {b};
+}
+
+auto f3() {
+  Bar b;
+  return Foo(b);
+}
Index: docs/clang-tidy/checks/modernize-return-braced-init-list.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/modernize-return-braced-init-list.rst
@@ -0,0 +1,22 @@
+.. title:: clang-tidy - modernize-return-braced-init-list
+
+modernize-return-braced-init-list
+=
+
+Replaces explicit calls to the constructor in a return with a braced
+initializer list. This way the return type is not needlessly duplicated in the
+return type and the return statement.
+
+.. code:: c++
+
+  Foo bar() {
+Baz baz;
+return Foo(baz);
+  }
+
+  // transforms to:
+
+  Foo bar() {
+Baz baz;
+return {baz};
+  }
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -109,6 +109,7 @@
modernize-raw-string-literal
modernize-redundant-void-arg
modernize-replace-auto-ptr
+   modernize-return-braced-init-list
modernize-shrink-to-fit
modernize-use-auto
modernize-use-bool-literals
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,7 +57,11 @@
 Improvements to clang-tidy
 --
 
-The improvements are...
+- New `modernize-return-braced-init-list
+`_ check
+
+  Replaces explicit calls to the constructor in a return statement by a braced
+  initializer list so that the return type is not needlessly repeated.
 
 Improvements to include-fixer
 -
Index: clang-tidy/modernize/ReturnBracedInitListCheck.h
===
--- /dev/null
+++ clang-tidy/modernize/ReturnBracedInitListCheck.h
@@ -0,0 +1,36 @@
+//===--- ReturnBracedInitListCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_RETURN_BRACED_INIT_LIST_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_RETURN_BRACED_INIT_LIST_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+/// Use a braced init list for return statements rather than unnecessary
+/// repeating the return type name.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/modernize-return-braced-init-list.html
+class ReturnBracedInitListCheck : public ClangTidyCheck {
+public:
+  ReturnBracedInitListCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace modernize
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_RETURN_BRACED_INIT_LIST_H
Index: clang-tidy/modernize/ReturnBracedInitListCheck.cpp
===
--- /dev/null
+++ clang-tidy/modernize/ReturnBracedInitListCheck.cpp
@@ -0,0 +1,81 @@

[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'

2017-01-16 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

`{}` doesn't allow narrowing; can you check for that?




Comment at: clang-tidy/modernize/ReturnBracedInitListCheck.cpp:50
+  SourceLocation Loc = MatchedConstructExpr->getExprLoc();
+  if (Loc.isMacroID())
+return;

Test?



Comment at: clang-tidy/modernize/ReturnBracedInitListCheck.cpp:56
+  const QualType constructType = MatchedConstructExpr->getType();
+  if (returnType != constructType)
+return;

Test?



Comment at: clang-tidy/modernize/ReturnBracedInitListCheck.cpp:65
+  // Return if there is no explicit constructor call.
+  if (CallParensRange.isInvalid())
+return;

Test?



Comment at: clang-tidy/modernize/ReturnBracedInitListCheck.cpp:68
+
+  Diag << FixItHint::CreateRemoval(MatchedConstructExpr->getLocStart());
+  Diag << FixItHint::CreateReplacement(

What happens for multi-token types like `vector`?


Repository:
  rL LLVM

https://reviews.llvm.org/D28768



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


[PATCH] D28315: Update tools to use new getStyle API

2017-01-16 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano added a comment.

In https://reviews.llvm.org/D28315#647212, @ioeric wrote:

> In https://reviews.llvm.org/D28315#647154, @amaiorano wrote:
>
> > In https://reviews.llvm.org/D28315#647103, @ioeric wrote:
> >
> > > Let me know when broken tests are fixed and this patch (and the 
> > > corresponding patch) is ready again for review. Also let me know if you 
> > > need any help.
> >
> >
> > I updated the two patches after rebasing on latest (no conflicts). These 
> > should be ready to go. If you don't mind testing the two again on Linux, 
> > that would be greatly appreciated. Otherwise, on Windows the tests pass.
>
>
> All tests passed on Linux. Are these patches still depending on 
> https://reviews.llvm.org/D28419? Or the previous issue has been somehow 
> resolved on Windows?


Thank you for testing it on Linux. No, there is no dependency on 
https://reviews.llvm.org/D28419 insofar as getting these 2 patches in. 
https://reviews.llvm.org/D28419 is about making sure tests work on Windows if 
you use Git and set core.autocrlf; however, I suspect the Windows build 
machines are using svn.


https://reviews.llvm.org/D28315



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


[PATCH] D28081: Make GetStyle return Expected instead of FormatStyle

2017-01-16 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

Lgtm. Thanks!


https://reviews.llvm.org/D28081



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


[PATCH] D28315: Update tools to use new getStyle API

2017-01-16 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

Lgtm. Thanks!


https://reviews.llvm.org/D28315



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


[libcxx] r292109 - [libcxx] Follow-up to r292107

2017-01-16 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Mon Jan 16 07:13:01 2017
New Revision: 292109

URL: http://llvm.org/viewvc/llvm-project?rev=292109&view=rev
Log:
[libcxx] Follow-up to r292107

I've missed a couple of updates. NFC.

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=292109&r1=292108&r2=292109&view=diff
==
--- libcxx/trunk/src/thread.cpp (original)
+++ libcxx/trunk/src/thread.cpp Mon Jan 16 07:13:01 2017
@@ -40,7 +40,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 thread::~thread()
 {
-if (__t_ != 0)
+if (!__libcpp_thread_isnull(&__t_))
 terminate();
 }
 
@@ -48,11 +48,11 @@ void
 thread::join()
 {
 int ec = EINVAL;
-if (__t_ != 0)
+if (!__libcpp_thread_isnull(&__t_))
 {
 ec = __libcpp_thread_join(&__t_);
 if (ec == 0)
-__t_ = 0;
+__t_ = _LIBCPP_NULL_THREAD;
 }
 
 if (ec)
@@ -63,11 +63,11 @@ void
 thread::detach()
 {
 int ec = EINVAL;
-if (__t_ != 0)
+if (!__libcpp_thread_isnull(&__t_))
 {
 ec = __libcpp_thread_detach(&__t_);
 if (ec == 0)
-__t_ = 0;
+__t_ = _LIBCPP_NULL_THREAD;
 }
 
 if (ec)


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


r292110 - clang-format: Always wrap before multi-line parameters/operands.

2017-01-16 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Jan 16 07:13:15 2017
New Revision: 292110

URL: http://llvm.org/viewvc/llvm-project?rev=292110&view=rev
Log:
clang-format: Always wrap before multi-line parameters/operands.

Before:
  aa(, aaa::
   ,
 a);

After:
  aa(,
 aaa::
 ,
 a);

No new test cases, as the existing ones cover this fairly well.

Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/lib/Format/ContinuationIndenter.h
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=292110&r1=292109&r2=292110&view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Mon Jan 16 07:13:15 2017
@@ -135,6 +135,12 @@ bool ContinuationIndenter::canBreak(cons
   return false;
   }
 
+  // If binary operators are moved to the next line (including commas for some
+  // styles of constructor initializers), that's always ok.
+  if (!Current.isOneOf(TT_BinaryOperator, tok::comma) &&
+  State.Stack.back().NoLineBreakInOperand)
+return false;
+
   return !State.Stack.back().NoLineBreak;
 }
 
@@ -395,6 +401,27 @@ void ContinuationIndenter::addTokenOnCur
 State.Stack.back().NoLineBreak = true;
   }
 
+  // Don't allow the RHS of an operator to be split over multiple lines unless
+  // there is a line-break right after the operator.
+  // Exclude relational operators, as there, it is always more desirable to
+  // have the LHS 'left' of the RHS.
+  const FormatToken *P = Current.getPreviousNonComment();
+  if (!Current.is(tok::comment) && P &&
+  (P->isOneOf(TT_BinaryOperator, tok::comma) ||
+   (P->is(TT_ConditionalExpr) && P->is(tok::colon))) &&
+  !P->isOneOf(TT_OverloadedOperator, TT_CtorInitializerComma) &&
+  P->getPrecedence() != prec::Assignment &&
+  P->getPrecedence() != prec::Relational) {
+bool BreakBeforeOperator =
+P->is(tok::lessless) ||
+(P->is(TT_BinaryOperator) &&
+ Style.BreakBeforeBinaryOperators != FormatStyle::BOS_None) ||
+(P->is(TT_ConditionalExpr) && Style.BreakBeforeTernaryOperators);
+if (!BreakBeforeOperator ||
+(!State.Stack.back().LastOperatorWrapped && BreakBeforeOperator))
+  State.Stack.back().NoLineBreakInOperand = true;
+  }
+
   State.Column += Spaces;
   if (Current.isNot(tok::comment) && Previous.is(tok::l_paren) &&
   Previous.Previous &&
@@ -716,6 +743,8 @@ unsigned ContinuationIndenter::moveState
   assert(State.Stack.size());
   const FormatToken &Current = *State.NextToken;
 
+  if (Current.isOneOf(tok::comma, TT_BinaryOperator))
+State.Stack.back().NoLineBreakInOperand = false;
   if (Current.is(TT_InheritanceColon))
 State.Stack.back().AvoidBinPacking = true;
   if (Current.is(tok::lessless) && Current.isNot(TT_OverloadedOperator)) {
@@ -724,8 +753,10 @@ unsigned ContinuationIndenter::moveState
 else
   State.Stack.back().LastOperatorWrapped = Newline;
   }
-  if ((Current.is(TT_BinaryOperator) && Current.isNot(tok::lessless)) ||
-  Current.is(TT_ConditionalExpr))
+  if (Current.is(TT_BinaryOperator) && Current.isNot(tok::lessless))
+State.Stack.back().LastOperatorWrapped = Newline;
+  if (Current.is(TT_ConditionalExpr) && Current.Previous &&
+  !Current.Previous->is(TT_ConditionalExpr))
 State.Stack.back().LastOperatorWrapped = Newline;
   if (Current.is(TT_ArraySubscriptLSquare) &&
   State.Stack.back().StartOfArraySubscripts == 0)
@@ -848,6 +879,8 @@ void ContinuationIndenter::moveStatePast
I != E; ++I) {
 ParenState NewParenState = State.Stack.back();
 NewParenState.ContainsLineBreak = false;
+NewParenState.NoLineBreak =
+NewParenState.NoLineBreak || State.Stack.back().NoLineBreakInOperand;
 
 // Indent from 'LastSpace' unless these are fake parentheses encapsulating
 // a builder type call after 'return' or, if the alignment after opening
@@ -862,24 +895,6 @@ void ContinuationIndenter::moveStatePast
   std::max(std::max(State.Column, NewParenState.Indent),
State.Stack.back().LastSpace);
 
-// Don't allow the RHS of an operator to be split over multiple lines 
unless
-// there is a line-break right after the operator.
-// Exclude relational operators, as there, it is always more desirable to
-// have the LHS 'left' of the RHS.
-if (Previous && Previous->getPrecedence() != prec::Assignment &&
-Previous->isOneOf(TT_BinaryOperator, TT_Conditi

[PATCH] D28729: [clang-tidy] Add -enable-alpha-checks command

2017-01-16 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek updated this revision to Diff 84550.
Prazek marked an inline comment as done.
Prazek added a comment.

-enable-alpha-checks is now not visible for users, but it make 
my life as clang-tidy developer much easier.


https://reviews.llvm.org/D28729

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidyOptions.cpp
  clang-tidy/ClangTidyOptions.h
  clang-tidy/tool/ClangTidyMain.cpp
  test/clang-tidy/enable-alpha-checks.cpp

Index: test/clang-tidy/enable-alpha-checks.cpp
===
--- /dev/null
+++ test/clang-tidy/enable-alpha-checks.cpp
@@ -0,0 +1,6 @@
+// Check if '-enable-alpha-checks' is visible for users
+// RUN: clang-tidy -help | not grep 'enable-alpha-checks'
+
+// Check if '-enable-alpha-checks' enables alpha checks.
+// RUN: clang-tidy -checks=* -list-checks | not grep 'clang-analyzer-alpha'
+// RUN: clang-tidy -checks=* -list-checks -enable-alpha-checks | grep 'clang-analyzer-alpha'
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -180,6 +180,13 @@
cl::init(false),
cl::cat(ClangTidyCategory));
 
+/// This option Enables alpha checkers from the static analyzer, that are
+/// experimental. This option is set to false and not visible in help, because
+/// it is highly not recommended for users.
+static cl::opt EnableAlphaChecks("enable-alpha-checks",
+   cl::init(false), cl::Hidden,
+   cl::cat(ClangTidyCategory));
+
 static cl::opt ExportFixes("export-fixes", cl::desc(R"(
 YAML file to store suggested fixes in. The
 stored fixes can be applied to the input source
@@ -272,6 +279,7 @@
   DefaultOptions.HeaderFilterRegex = HeaderFilter;
   DefaultOptions.SystemHeaders = SystemHeaders;
   DefaultOptions.AnalyzeTemporaryDtors = AnalyzeTemporaryDtors;
+  DefaultOptions.EnableAlphaChecks = EnableAlphaChecks;
   DefaultOptions.User = llvm::sys::Process::GetEnv("USER");
   // USERNAME is used on Windows.
   if (!DefaultOptions.User)
Index: clang-tidy/ClangTidyOptions.h
===
--- clang-tidy/ClangTidyOptions.h
+++ clang-tidy/ClangTidyOptions.h
@@ -75,6 +75,9 @@
   /// \brief Turns on temporary destructor-based analysis.
   llvm::Optional AnalyzeTemporaryDtors;
 
+  /// \brief Turns on experimental alpha checkers from the static analyzer.
+  llvm::Optional EnableAlphaChecks;
+
   /// \brief Specifies the name or e-mail of the user running clang-tidy.
   ///
   /// This option is used, for example, to place the correct user name in TODO()
Index: clang-tidy/ClangTidyOptions.cpp
===
--- clang-tidy/ClangTidyOptions.cpp
+++ clang-tidy/ClangTidyOptions.cpp
@@ -89,6 +89,7 @@
 IO.mapOptional("WarningsAsErrors", Options.WarningsAsErrors);
 IO.mapOptional("HeaderFilterRegex", Options.HeaderFilterRegex);
 IO.mapOptional("AnalyzeTemporaryDtors", Options.AnalyzeTemporaryDtors);
+IO.mapOptional("EnableAlphaChecks", Options.EnableAlphaChecks);
 IO.mapOptional("User", Options.User);
 IO.mapOptional("CheckOptions", NOpts->Options);
 IO.mapOptional("ExtraArgs", Options.ExtraArgs);
@@ -109,6 +110,7 @@
   Options.HeaderFilterRegex = "";
   Options.SystemHeaders = false;
   Options.AnalyzeTemporaryDtors = false;
+  Options.EnableAlphaChecks = false;
   Options.User = llvm::None;
   for (ClangTidyModuleRegistry::iterator I = ClangTidyModuleRegistry::begin(),
  E = ClangTidyModuleRegistry::end();
@@ -148,6 +150,7 @@
   overrideValue(Result.HeaderFilterRegex, Other.HeaderFilterRegex);
   overrideValue(Result.SystemHeaders, Other.SystemHeaders);
   overrideValue(Result.AnalyzeTemporaryDtors, Other.AnalyzeTemporaryDtors);
+  overrideValue(Result.EnableAlphaChecks, Other.EnableAlphaChecks);
   overrideValue(Result.User, Other.User);
   mergeVectors(Result.ExtraArgs, Other.ExtraArgs);
   mergeVectors(Result.ExtraArgsBefore, Other.ExtraArgsBefore);
Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -289,11 +289,12 @@
 
 typedef std::vector> CheckersList;
 
-static CheckersList getCheckersControlList(GlobList &Filter) {
+static CheckersList getCheckersControlList(GlobList &Filter,
+   bool IncludeExperimental) {
   CheckersList List;
 
   const auto &RegisteredCheckers =
-  AnalyzerOptions::getRegisteredCheckers(/*IncludeExperimental=*/false);
+  AnalyzerOptions::getRegisteredCheckers(IncludeExperimental);
   bool AnalyzerChecksEnabled = false;
   for (StringRef CheckName : RegisteredCheckers) {
 std::string ClangTidyCheckName((Analyze

[PATCH] D28729: [clang-tidy] Add -enable-alpha-checks command

2017-01-16 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added a comment.

Does solution like this works for you? We don't officially support alpha 
checkers, but it is much easier to check if something is already implemented in 
static analyzer easily


https://reviews.llvm.org/D28729



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


[PATCH] D28606: Mention devirtualization in release notes

2017-01-16 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek closed this revision.
Prazek added a comment.

Pushed on branch


https://reviews.llvm.org/D28606



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


[PATCH] D28746: Mention ThinLTO with PGO in ReleaseNotes 4.0

2017-01-16 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek closed this revision.
Prazek added a comment.

Pushed on branch. 
Please check if everything looks good when RC will be released.


https://reviews.llvm.org/D28746



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


r292112 - Add -fstrict-vtable-pointers to UsersManual

2017-01-16 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Mon Jan 16 07:20:08 2017
New Revision: 292112

URL: http://llvm.org/viewvc/llvm-project?rev=292112&view=rev
Log:
Add -fstrict-vtable-pointers to UsersManual

Summary: Add missing flag to UsersManual
It would be good to merge it to 4.0 branch.

Reviewers: hans

Subscribers: cfe-commits

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

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=292112&r1=292111&r2=292112&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Mon Jan 16 07:20:08 2017
@@ -1097,6 +1097,13 @@ are listed below.
the behavior of sanitizers in the ``cfi`` group to allow checking
of cross-DSO virtual and indirect calls.
 
+
+.. option:: -fstrict-vtable-pointers
+   Enable optimizations based on the strict rules for overwriting polymorphic
+   C++ objects, i.e. the vptr is invariant during an object's lifetime.
+   This enables better devirtualization. Turned off by default, because it is
+   still experimental.
+
 .. option:: -ffast-math
 
Enable fast-math mode. This defines the ``__FAST_MATH__`` preprocessor


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


[PATCH] D28727: Add -fstrict-vtable-pointers to UserManual

2017-01-16 Thread Piotr Padlewski via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Prazek marked an inline comment as done.
Closed by commit rL292112: Add -fstrict-vtable-pointers to UsersManual 
(authored by Prazek).

Changed prior to commit:
  https://reviews.llvm.org/D28727?vs=84492&id=84551#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28727

Files:
  cfe/trunk/docs/UsersManual.rst


Index: cfe/trunk/docs/UsersManual.rst
===
--- cfe/trunk/docs/UsersManual.rst
+++ cfe/trunk/docs/UsersManual.rst
@@ -1097,6 +1097,13 @@
the behavior of sanitizers in the ``cfi`` group to allow checking
of cross-DSO virtual and indirect calls.
 
+
+.. option:: -fstrict-vtable-pointers
+   Enable optimizations based on the strict rules for overwriting polymorphic
+   C++ objects, i.e. the vptr is invariant during an object's lifetime.
+   This enables better devirtualization. Turned off by default, because it is
+   still experimental.
+
 .. option:: -ffast-math
 
Enable fast-math mode. This defines the ``__FAST_MATH__`` preprocessor


Index: cfe/trunk/docs/UsersManual.rst
===
--- cfe/trunk/docs/UsersManual.rst
+++ cfe/trunk/docs/UsersManual.rst
@@ -1097,6 +1097,13 @@
the behavior of sanitizers in the ``cfi`` group to allow checking
of cross-DSO virtual and indirect calls.
 
+
+.. option:: -fstrict-vtable-pointers
+   Enable optimizations based on the strict rules for overwriting polymorphic
+   C++ objects, i.e. the vptr is invariant during an object's lifetime.
+   This enables better devirtualization. Turned off by default, because it is
+   still experimental.
+
 .. option:: -ffast-math
 
Enable fast-math mode. This defines the ``__FAST_MATH__`` preprocessor
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28727: Add -fstrict-vtable-pointers to UserManual

2017-01-16 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added a comment.

I also have sent it on the branch


Repository:
  rL LLVM

https://reviews.llvm.org/D28727



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


[PATCH] D28771: [Analyzer] Various fixes for the IteratorPastEnd checker

2017-01-16 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision.
baloghadamsoftware added reviewers: zaks.anna, NoQ.
baloghadamsoftware added subscribers: xazax.hun, o.gyorgy, cfe-commits.

This patch fixes some issues for the IteratorPastEnd checkers. There are 
basically two main issues this patch targets: one is the handling of 
assignments between iterators, the other one is correct handling of the +, +=, 
- and -= operators of random-access iterators. The handling of these operators 
also checks the sign of the argument, e.g. a negative number for + or += is 
handled as decrementation.


https://reviews.llvm.org/D28771

Files:
  lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp
  test/Analysis/Inputs/system-header-simulator-cxx.h
  test/Analysis/diagnostics/explicit-suppression.cpp
  test/Analysis/iterator-past-end.cpp

Index: test/Analysis/iterator-past-end.cpp
===
--- test/Analysis/iterator-past-end.cpp
+++ test/Analysis/iterator-past-end.cpp
@@ -203,3 +203,49 @@
 start = ++item; // no-warning
   }
 }
+
+void good_overwrite(std::vector &vec) {
+  auto i = vec.end();
+  i = vec.begin();
+  *i; // no-warning
+}
+
+void good_overwrite_find(std::vector &vec, int e) {
+  auto i = std::find(vec.begin(), vec.end(), e);
+  if(i == vec.end()) {
+i = vec.begin();
+  }
+  *i; // no-warning
+}
+
+void bad_overwrite(std::vector &vec) {
+  auto i = vec.begin();
+  i = vec.end();
+  *i; // expected-warning{{Iterator accessed past its end}}
+}
+
+void bad_overwrite_find(std::vector &vec, int e) {
+  auto i = std::find(vec.begin(), vec.end(), e);
+  if(i != vec.end()) {
+i = vec.begin();
+  }
+  *i; // expected-warning{{Iterator accessed past its end}}
+}
+
+void good_advance(std::vector &vec) {
+  auto i = vec.end();
+  std::advance(i, -1);
+  *i; // no-warning
+}
+
+void good_prev(std::vector &vec) {
+  auto i = std::prev(vec.end());
+  *i; // no-warning
+}
+
+struct init_value_prev {
+  init_value_prev(std::list l) : Back(std::prev(l.end())), Item(*Back) {} // no-warning
+private:
+  std::list::iterator Back;
+  int Item;
+};
Index: test/Analysis/diagnostics/explicit-suppression.cpp
===
--- test/Analysis/diagnostics/explicit-suppression.cpp
+++ test/Analysis/diagnostics/explicit-suppression.cpp
@@ -18,6 +18,6 @@
 void testCopyNull(C *I, C *E) {
   std::copy(I, E, (C *)0);
 #ifndef SUPPRESSED
-  // expected-warning@../Inputs/system-header-simulator-cxx.h:191 {{Called C++ object pointer is null}}
+  // expected-warning@../Inputs/system-header-simulator-cxx.h:293 {{Called C++ object pointer is null}}
 #endif
 }
Index: test/Analysis/Inputs/system-header-simulator-cxx.h
===
--- test/Analysis/Inputs/system-header-simulator-cxx.h
+++ test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -8,18 +8,60 @@
 typedef unsigned char uint8_t;
 
 typedef __typeof__(sizeof(int)) size_t;
+typedef __typeof__((char*)0-(char*)0) ptrdiff_t;
 void *memmove(void *s1, const void *s2, size_t n);
 
-template  struct __iterator {
-  typedef __iterator iterator;
-  typedef __iterator const_iterator;
+namespace std {
+  struct input_iterator_tag { };
+  struct output_iterator_tag { };
+  struct forward_iterator_tag : public input_iterator_tag { };
+  struct bidirectional_iterator_tag : public forward_iterator_tag { };
+  struct random_access_iterator_tag : public bidirectional_iterator_tag { };
+
+  template  struct iterator_traits {
+typedef typename Iterator::difference_type difference_type;
+typedef typename Iterator::value_type value_type;
+typedef typename Iterator::pointer pointer;
+typedef typename Iterator::reference reference;
+typedef typename Iterator::iterator_category iterator_category;
+  };
+}
 
-  __iterator(const Ptr p) : ptr(p) {}
+template  struct __vector_iterator {
+  typedef __vector_iterator iterator;
+  typedef __vector_iterator const_iterator;
+
+  typedef ptrdiff_t difference_type;
+  typedef T value_type;
+  typedef Ptr pointer;
+  typedef Ref reference;
+  typedef std::random_access_iterator_tag iterator_category;
+
+  __vector_iterator(const Ptr p) : ptr(p) {}
+  __vector_iterator operator++() { ++ ptr; return *this; }
+  __vector_iterator operator++(int) {
+auto tmp = *this;
+++ ptr;
+return tmp;
+  }
+  __vector_iterator operator--() { -- ptr; return *this; }
+  __vector_iterator operator--(int) {
+auto tmp = *this; -- ptr;
+return tmp;
+  }
+  __vector_iterator operator+(difference_type n) {
+return ptr + n;
+  }
+  __vector_iterator operator-(difference_type n) {
+return ptr - n;
+  }
+  __vector_iterator operator+=(difference_type n) {
+return ptr += n;
+  }
+  __vector_iterator operator-=(difference_type n) {
+return ptr -= n;
+  }
 
-  __iterator operator++() { return *this; }
-  __iterator operator++(int) { return *this; }
-  __iterator operator--() { return *this; }
-  

r292115 - Replace non-ASCII ellipsis with "..." to silence Sphinx warnings.

2017-01-16 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Jan 16 07:42:21 2017
New Revision: 292115

URL: http://llvm.org/viewvc/llvm-project?rev=292115&view=rev
Log:
Replace non-ASCII ellipsis with "..." to silence Sphinx warnings.

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=292115&r1=292114&r2=292115&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Mon Jan 16 07:42:21 2017
@@ -2235,7 +2235,7 @@ An example is the subgroup operations su
 
  // Define custom my_sub_group_shuffle(data, c)
  // that makes use of intel_sub_group_shuffle
- r1 = … 
+ r1 = ... 
  if (r0) r1 = computeA();
  // Shuffle data from r1 into r3
  // of threads id r2.
@@ -2246,7 +2246,7 @@ with non-SPMD semantics this is optimize
 
.. code-block:: c
 
- r1 = …
+ r1 = ...
  if (!r0)
// Incorrect functionality! The data in r1
// have not been computed by all threads yet.


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


r292116 - Fix test failures after recent clang-format format change.

2017-01-16 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Jan 16 07:43:46 2017
New Revision: 292116

URL: http://llvm.org/viewvc/llvm-project?rev=292116&view=rev
Log:
Fix test failures after recent clang-format format change.

Modified:
cfe/trunk/test/Index/overriding-ftemplate-comments.cpp

Modified: cfe/trunk/test/Index/overriding-ftemplate-comments.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/overriding-ftemplate-comments.cpp?rev=292116&r1=292115&r2=292116&view=diff
==
--- cfe/trunk/test/Index/overriding-ftemplate-comments.cpp (original)
+++ cfe/trunk/test/Index/overriding-ftemplate-comments.cpp Mon Jan 16 07:43:46 
2017
@@ -77,10 +77,10 @@ void comment_to_html_conversion_21();
 template  class 
BBB > class AAA>
 void comment_to_html_conversion_22();
 
-// CHECK: FullCommentAsXML=[comment_to_html_conversion_22c:@FT@>2#T#t>2#T#t>2#T#Tcomment_to_html_conversion_22#v#template
  class 
BBB>\n  class AAA>\nvoid 
comment_to_html_conversion_22()C10
 Ccc 1 
AAA1
 Zzz 
C2 
Ccc 2 
C3 
Ccc 3 
C4 
Ccc 4 
BBB 
Bbb]
+// CHECK: FullCommentAsXML=[comment_to_html_conversion_22c:@FT@>2#T#t>2#T#t>2#T#Tcomment_to_html_conversion_22#v#template
  
class BBB>\n  class AAA>\nvoid 
comment_to_html_conversion_22()C10
 Ccc 1 
AAA1
 Zzz 
C2 
Ccc 2 
C3 
Ccc 3 
C4 
Ccc 4 
BBB 
Bbb]
 
 template 
class QQQ> class PPP>
 void comment_to_html_conversion_22();
 
-// CHECK: FullCommentAsXML=[comment_to_html_conversion_22c:@FT@>2#T#t>2#T#t>2#T#Tcomment_to_html_conversion_22#v#template
 \nclass QQQ> class PPP>\nvoid 
comment_to_html_conversion_22()CCC10
 Ccc 1 
PPP1
 Zzz 
CCC2 
Ccc 2 
CCC3 
Ccc 3 
CCC4 
Ccc 4 
QQQ 
Bbb]
+// CHECK: FullCommentAsXML=[comment_to_html_conversion_22c:@FT@>2#T#t>2#T#t>2#T#Tcomment_to_html_conversion_22#v#template
  class QQQ>\n class PPP>\nvoid 
comment_to_html_conversion_22()CCC10
 Ccc 1 
PPP1
 Zzz 
CCC2 
Ccc 2 
CCC3 
Ccc 3 
CCC4 
Ccc 4 
QQQ 
Bbb]
 


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


[PATCH] D27202: [analyzer] Do not conjure a symbol for return value of a conservatively evaluated function

2017-01-16 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

Any progress regarding this patch? Is https://reviews.llvm.org/D26837 
necessarily a dependency, or we just need isCompoundType() function? This 
function could be moved to a separate patch so the dependency could be removed.


https://reviews.llvm.org/D27202



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


r292119 - Ensure that clang -pthread creates the right macro. -D_POSIX_THREADS

2017-01-16 Thread Joerg Sonnenberger via cfe-commits
Author: joerg
Date: Mon Jan 16 08:07:24 2017
New Revision: 292119

URL: http://llvm.org/viewvc/llvm-project?rev=292119&view=rev
Log:
Ensure that clang -pthread creates the right macro. -D_POSIX_THREADS
seems to have been a C&P error from old GCC specs for OpenBSD.

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Driver/netbsd.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=292119&r1=292118&r2=292119&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Jan 16 08:07:24 2017
@@ -512,7 +512,7 @@ protected:
 Builder.defineMacro("__unix__");
 Builder.defineMacro("__ELF__");
 if (Opts.POSIXThreads)
-  Builder.defineMacro("_POSIX_THREADS");
+  Builder.defineMacro("_REENTRANT");
 
 switch (Triple.getArch()) {
 default:

Modified: cfe/trunk/test/Driver/netbsd.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/netbsd.c?rev=292119&r1=292118&r2=292119&view=diff
==
--- cfe/trunk/test/Driver/netbsd.c (original)
+++ cfe/trunk/test/Driver/netbsd.c Mon Jan 16 08:07:24 2017
@@ -126,6 +126,8 @@
 // RUN: %clang -no-canonical-prefixes -target powerpc64--netbsd -static \
 // RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=S-POWERPC64 %s
+// RUN: %clang -target x86_64--netbsd -pthread -dM -E %s \
+// RUN: | FileCheck -check-prefix=PTHREAD %s
 
 // STATIC: ld{{.*}}" "--eh-frame-hdr"
 // STATIC-NOT: "-pie"
@@ -427,3 +429,7 @@
 // S-POWERPC64: "{{.*}}/usr/lib{{/|}}crti.o"
 // S-POWERPC64: "{{.*}}/usr/lib{{/|}}crtbegin.o" "{{.*}}.o" "-lc"
 // S-POWERPC64: "{{.*}}/usr/lib{{/|}}crtend.o" 
"{{.*}}/usr/lib{{/|}}crtn.o"
+
+// PTHREAD-NOT: _POSIX_THREADS
+// PTHREAD: _REENTRANT
+// PTHREAD-NOT: _POSIX_THREADS


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


[PATCH] D28462: clang-format: Add new style option AlignConsecutiveMacros

2017-01-16 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added inline comments.



Comment at: Format/FormatToken.h:148
 
+  /// \brief Whether the token is the final token in the identifier of a PP
+  // macro. This will be either 1) the identifier token following the 'define'

This adds a lot of code, runtime and memory even if you disable the alignment 
of macros and I am slightly hesitant about that. Two reasons:
- It would be nicer if all of this logic was completely encapsulated in the 
whitespace manager.
- We don't want to spent the computing resources if this is disabled.

Can we remove all of what's in FormatToken.h and TokenAnnotator.cpp and instead 
have a function in the whitespace manager, that identifies this location in the 
code?



Comment at: Format/TokenAnnotator.cpp:1652
+return false;
+  if (!tok.is(tok::identifier) || !tok.TokenText.equals("define"))
+return false;

Use:

  tok.is(tok::pp_define)



Comment at: Format/TokenAnnotator.cpp:1661
+static bool endsMacroIdentifier(const FormatToken &Current) {
+  const FormatToken *keyword = Current.Previous;
+

Upper-case "Keyword"



Comment at: Format/WhitespaceManager.cpp:33
 StringRef CurrentLinePrefix, tok::TokenKind Kind, bool 
ContinuesPPDirective,
-bool IsStartOfDeclName, bool IsInsideToken)
+bool IsStartOfDeclName, bool IsInsideToken, bool EndsPPIdentifier)
 : CreateReplacement(CreateReplacement),

We have to stop adding more stuff here. I think it is better to store reference 
to the actual FormatToken by now. I'll take a stab at that later this week.


Repository:
  rL LLVM

https://reviews.llvm.org/D28462



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


[PATCH] D28772: [Preprocessor] Fix incorrect token caching that occurs when lexing _Pragma in macro argument pre-expansion mode when skipping a function body

2017-01-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added reviewers: bruno, rsmith, akyrtzi.
arphaman added a subscriber: cfe-commits.
arphaman set the repository for this revision to rL LLVM.
Herald added a subscriber: nemanjai.

This patch fixes a token caching problem that currently occurs when clang is 
skipping a function body (e.g. when looking for a code completion token) and at 
the same time caching the tokens for _Pragma when lexing it in macro argument 
pre-expansion mode.

When _Pragma is being lexed in macro argument pre-expansion mode, it caches the 
tokens so that it can avoid interpreting the pragma immediately (as the macro 
argument may not be used in the macro body), and then either backtracks over or 
commits these tokens. The problem is that, when we're backtracking/committing 
in such a scenario, there's already a previous backtracking position stored in 
`BacktrackPositions` (as we're skipping the function body), and this leads to a 
situation where the cached tokens from the pragma (like '(' 'string_literal' 
and ')') will remain in the cached tokens array incorrectly even after they're 
consumed (in the case of backtracking) or just ignored (in the case when 
they're committed). Furthermore, what makes it even worse, is that because of a 
previous backtracking position, the logic that deals with when should we call 
`ExitCachingLexMode` in `CachingLex` no longer works for us in this situation, 
and more tokens in the macro argument get cached, to the point where the EOF 
token that corresponds to the macro argument EOF is cached. This problem leads 
to all sorts of issues in code completion mode, where incorrect errors get 
presented and code completion completely fails to produce completion results.

Thanks for taking a look


Repository:
  rL LLVM

https://reviews.llvm.org/D28772

Files:
  include/clang/Lex/Preprocessor.h
  lib/Lex/PPCaching.cpp
  test/CodeCompletion/pragma-macro-token-caching.c

Index: test/CodeCompletion/pragma-macro-token-caching.c
===
--- /dev/null
+++ test/CodeCompletion/pragma-macro-token-caching.c
@@ -0,0 +1,18 @@
+
+#define Outer(action) action
+
+void completeParam(int param) {
+;
+Outer(__extension__({ _Pragma("clang diagnostic push") }));
+param;
+}
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:7:1 %s | FileCheck %s
+// CHECK: param : [#int#]param
+
+void completeParamPragmaError(int param) {
+Outer(__extension__({ _Pragma(2) })); // expected-error {{_Pragma takes a parenthesized string literal}}
+param;
+}
+
+// RUN: %clang_cc1 -fsyntax-only -verify -code-completion-at=%s:16:1 %s | FileCheck %s
Index: lib/Lex/PPCaching.cpp
===
--- lib/Lex/PPCaching.cpp
+++ lib/Lex/PPCaching.cpp
@@ -32,25 +32,58 @@
 void Preprocessor::CommitBacktrackedTokens() {
   assert(!BacktrackPositions.empty()
  && "EnableBacktrackAtThisPos was not called!");
+  auto PrevCachedLexPos = BacktrackPositions.back();
   BacktrackPositions.pop_back();
+  // When committing in a macro argument pre-expansion when tokens are still
+  // being cached, we want to ensure that the tokens which were just committed
+  // won't remain in the cache and that the caching stops.
+  // Otherwise the caching will interfere with the way macro expansion works,
+  // because we will continue to cache tokens after consuming the backtracked
+  // tokens, which shouldn't happen when we're dealing with macro argument
+  // pre-expansion.
+  if (InMacroArgPreExpansion && !BacktrackPositions.empty()) {
+CachedTokens.erase(CachedTokens.begin() + PrevCachedLexPos,
+   CachedTokens.begin() + CachedLexPos);
+ExitCachingLexMode();
+  }
 }
 
 // Make Preprocessor re-lex the tokens that were lexed since
 // EnableBacktrackAtThisPos() was previously called.
 void Preprocessor::Backtrack() {
   assert(!BacktrackPositions.empty()
  && "EnableBacktrackAtThisPos was not called!");
+  auto CurrentCachedLexPos = CachedLexPos;
   CachedLexPos = BacktrackPositions.back();
   BacktrackPositions.pop_back();
   recomputeCurLexerKind();
+  // When backtracking in a macro argument pre-expansion when tokens are still
+  // being cached, we want to ensure that the tokens over which we just
+  // backtracked won't remain in the cache after they're consumed and and that
+  // the caching will stop after consuming them.
+  // Otherwise they will interfere with the way macro expansion works, because
+  // we will continue to cache tokens after consuming the backtracked tokens,
+  // which shouldn't happen when we're dealing with macro argument
+  // pre-expansion.
+  if (InMacroArgPreExpansion && !BacktrackPositions.empty())
+ErasedBacktrackRange = CachedTokensRange{CachedLexPos, CurrentCachedLexPos};
 }
 
 void Preprocessor::CachingLex(Token &Result) {
   if (!InCachingLexMode())
 return;
 
   if (CachedLexPos < CachedTokens.size()) {
  

[PATCH] D28752: [OpenMP] Refactor code that calls codegen for target regions on the device.

2017-01-16 Thread Arpith Jacob via Phabricator via cfe-commits
arpith-jacob added a comment.

Thanks Alexey.

> Is this an NFC patch? If so add 'NFC' to this patch.

Do you mean NVPTX?  No, this is a patch to support target directives for any 
accelerator.


https://reviews.llvm.org/D28752



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


r292134 - [OpenMP] Refactor code that calls codegen for target regions on the device.

2017-01-16 Thread Arpith Chacko Jacob via cfe-commits
Author: arpith
Date: Mon Jan 16 09:26:02 2017
New Revision: 292134

URL: http://llvm.org/viewvc/llvm-project?rev=292134&view=rev
Log:
[OpenMP] Refactor code that calls codegen for target regions on the device.

This patch refactors code that calls codegen for target regions.  Currently
the codebase only supports the 'target' directive.  The patch pulls out
common target processing code into a static function that can be called
by codegen for any target directive.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D28752

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=292134&r1=292133&r2=292134&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Mon Jan 16 09:26:02 2017
@@ -6099,17 +6099,18 @@ void CGOpenMPRuntime::scanForTargetRegio
   if (!S)
 return;
 
-  // If we find a OMP target directive, codegen the outline function and
-  // register the result.
-  // FIXME: Add other directives with target when they become supported.
-  bool isTargetDirective = isa(S);
+  // Codegen OMP target directives that offload compute to the device.
+  bool requiresDeviceCodegen =
+  isa(S) &&
+  isOpenMPTargetExecutionDirective(
+  cast(S)->getDirectiveKind());
 
-  if (isTargetDirective) {
-auto *E = cast(S);
+  if (requiresDeviceCodegen) {
+auto &E = *cast(S);
 unsigned DeviceID;
 unsigned FileID;
 unsigned Line;
-getTargetEntryUniqueInfo(CGM.getContext(), E->getLocStart(), DeviceID,
+getTargetEntryUniqueInfo(CGM.getContext(), E.getLocStart(), DeviceID,
  FileID, Line);
 
 // Is this a target region that should not be emitted as an entry point? If
@@ -6118,13 +6119,14 @@ void CGOpenMPRuntime::scanForTargetRegio
 ParentName, Line))
   return;
 
-llvm::Function *Fn;
-llvm::Constant *Addr;
-std::tie(Fn, Addr) =
-CodeGenFunction::EmitOMPTargetDirectiveOutlinedFunction(
-CGM, cast(*E), ParentName,
-/*isOffloadEntry=*/true);
-assert(Fn && Addr && "Target region emission failed.");
+switch (S->getStmtClass()) {
+case Stmt::OMPTargetDirectiveClass:
+  CodeGenFunction::EmitOMPTargetDeviceFunction(
+  CGM, ParentName, cast(*S));
+  break;
+default:
+  llvm_unreachable("Unknown target directive for OpenMP device codegen.");
+}
 return;
   }
 

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=292134&r1=292133&r2=292134&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Mon Jan 16 09:26:02 2017
@@ -3403,32 +3403,15 @@ void CodeGenFunction::EmitOMPAtomicDirec
   CGM.getOpenMPRuntime().emitInlinedDirective(*this, OMPD_atomic, CodeGen);
 }
 
-std::pair
-CodeGenFunction::EmitOMPTargetDirectiveOutlinedFunction(
-CodeGenModule &CGM, const OMPTargetDirective &S, StringRef ParentName,
-bool IsOffloadEntry) {
-  llvm::Function *OutlinedFn = nullptr;
-  llvm::Constant *OutlinedFnID = nullptr;
-  auto &&CodeGen = [&S](CodeGenFunction &CGF, PrePostActionTy &Action) {
-OMPPrivateScope PrivateScope(CGF);
-(void)CGF.EmitOMPFirstprivateClause(S, PrivateScope);
-CGF.EmitOMPPrivateClause(S, PrivateScope);
-(void)PrivateScope.Privatize();
-
-Action.Enter(CGF);
-CGF.EmitStmt(cast(S.getAssociatedStmt())->getCapturedStmt());
-  };
-  // Emit target region as a standalone region.
-  CGM.getOpenMPRuntime().emitTargetOutlinedFunction(
-  S, ParentName, OutlinedFn, OutlinedFnID, IsOffloadEntry, CodeGen);
-  return std::make_pair(OutlinedFn, OutlinedFnID);
-}
-
-void CodeGenFunction::EmitOMPTargetDirective(const OMPTargetDirective &S) {
+static void emitCommonOMPTargetDirective(CodeGenFunction &CGF,
+ const OMPExecutableDirective &S,
+ const RegionCodeGenTy &CodeGen) {
+  assert(isOpenMPTargetExecutionDirective(S.getDirectiveKind()));
+  CodeGenModule &CGM = CGF.CGM;
   const CapturedStmt &CS = *cast(S.getAssociatedStmt());
 
   llvm::SmallVector CapturedVars;
-  GenerateOpenMPCapturedVars(CS, CapturedVars);
+  CGF.GenerateOpenMPCapturedVars(CS, CapturedVars);
 
   llvm::Function *Fn = nullptr;
   llvm::Constant *FnID = nullptr;
@@ -3452,31 +3435,64 @@ void CodeGenFunction::EmitOMPTargetDirec
   bool IsOffloadEntry = true;
   if (IfCond) {
 bool Val;
-if (ConstantFoldsToSimpleInteger(IfCond, Val) && !Val)
+  

[PATCH] D28752: [OpenMP] Refactor code that calls codegen for target regions on the device.

2017-01-16 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292134: [OpenMP] Refactor code that calls codegen for target 
regions on the device. (authored by arpith).

Changed prior to commit:
  https://reviews.llvm.org/D28752?vs=84509&id=84563#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28752

Files:
  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
  cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h

Index: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
===
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
@@ -3403,32 +3403,15 @@
   CGM.getOpenMPRuntime().emitInlinedDirective(*this, OMPD_atomic, CodeGen);
 }
 
-std::pair
-CodeGenFunction::EmitOMPTargetDirectiveOutlinedFunction(
-CodeGenModule &CGM, const OMPTargetDirective &S, StringRef ParentName,
-bool IsOffloadEntry) {
-  llvm::Function *OutlinedFn = nullptr;
-  llvm::Constant *OutlinedFnID = nullptr;
-  auto &&CodeGen = [&S](CodeGenFunction &CGF, PrePostActionTy &Action) {
-OMPPrivateScope PrivateScope(CGF);
-(void)CGF.EmitOMPFirstprivateClause(S, PrivateScope);
-CGF.EmitOMPPrivateClause(S, PrivateScope);
-(void)PrivateScope.Privatize();
-
-Action.Enter(CGF);
-CGF.EmitStmt(cast(S.getAssociatedStmt())->getCapturedStmt());
-  };
-  // Emit target region as a standalone region.
-  CGM.getOpenMPRuntime().emitTargetOutlinedFunction(
-  S, ParentName, OutlinedFn, OutlinedFnID, IsOffloadEntry, CodeGen);
-  return std::make_pair(OutlinedFn, OutlinedFnID);
-}
-
-void CodeGenFunction::EmitOMPTargetDirective(const OMPTargetDirective &S) {
+static void emitCommonOMPTargetDirective(CodeGenFunction &CGF,
+ const OMPExecutableDirective &S,
+ const RegionCodeGenTy &CodeGen) {
+  assert(isOpenMPTargetExecutionDirective(S.getDirectiveKind()));
+  CodeGenModule &CGM = CGF.CGM;
   const CapturedStmt &CS = *cast(S.getAssociatedStmt());
 
   llvm::SmallVector CapturedVars;
-  GenerateOpenMPCapturedVars(CS, CapturedVars);
+  CGF.GenerateOpenMPCapturedVars(CS, CapturedVars);
 
   llvm::Function *Fn = nullptr;
   llvm::Constant *FnID = nullptr;
@@ -3452,31 +3435,64 @@
   bool IsOffloadEntry = true;
   if (IfCond) {
 bool Val;
-if (ConstantFoldsToSimpleInteger(IfCond, Val) && !Val)
+if (CGF.ConstantFoldsToSimpleInteger(IfCond, Val) && !Val)
   IsOffloadEntry = false;
   }
   if (CGM.getLangOpts().OMPTargetTriples.empty())
 IsOffloadEntry = false;
 
-  assert(CurFuncDecl && "No parent declaration for target region!");
+  assert(CGF.CurFuncDecl && "No parent declaration for target region!");
   StringRef ParentName;
   // In case we have Ctors/Dtors we use the complete type variant to produce
   // the mangling of the device outlined kernel.
-  if (auto *D = dyn_cast(CurFuncDecl))
+  if (auto *D = dyn_cast(CGF.CurFuncDecl))
 ParentName = CGM.getMangledName(GlobalDecl(D, Ctor_Complete));
-  else if (auto *D = dyn_cast(CurFuncDecl))
+  else if (auto *D = dyn_cast(CGF.CurFuncDecl))
 ParentName = CGM.getMangledName(GlobalDecl(D, Dtor_Complete));
   else
 ParentName =
-CGM.getMangledName(GlobalDecl(cast(CurFuncDecl)));
+CGM.getMangledName(GlobalDecl(cast(CGF.CurFuncDecl)));
 
-  std::tie(Fn, FnID) = EmitOMPTargetDirectiveOutlinedFunction(
-  CGM, S, ParentName, IsOffloadEntry);
-  OMPLexicalScope Scope(*this, S);
-  CGM.getOpenMPRuntime().emitTargetCall(*this, S, Fn, FnID, IfCond, Device,
+  // Emit target region as a standalone region.
+  CGM.getOpenMPRuntime().emitTargetOutlinedFunction(S, ParentName, Fn, FnID,
+IsOffloadEntry, CodeGen);
+  OMPLexicalScope Scope(CGF, S);
+  CGM.getOpenMPRuntime().emitTargetCall(CGF, S, Fn, FnID, IfCond, Device,
 CapturedVars);
 }
 
+static void emitTargetRegion(CodeGenFunction &CGF, const OMPTargetDirective &S,
+ PrePostActionTy &Action) {
+  CodeGenFunction::OMPPrivateScope PrivateScope(CGF);
+  (void)CGF.EmitOMPFirstprivateClause(S, PrivateScope);
+  CGF.EmitOMPPrivateClause(S, PrivateScope);
+  (void)PrivateScope.Privatize();
+
+  Action.Enter(CGF);
+  CGF.EmitStmt(cast(S.getAssociatedStmt())->getCapturedStmt());
+}
+
+void CodeGenFunction::EmitOMPTargetDeviceFunction(CodeGenModule &CGM,
+  StringRef ParentName,
+  const OMPTargetDirective &S) {
+  auto &&CodeGen = [&S](CodeGenFunction &CGF, PrePostActionTy &Action) {
+emitTargetRegion(CGF, S, Action);
+  };
+  llvm::Function *Fn;
+  llvm::Constant *Addr;
+  // Emit target region as a standalone region.
+  CGM.getOpenMPRuntime().emitTargetOutlinedFunction(
+  S, ParentName, Fn, Addr, /*IsOffloadEntry=*/true, CodeGen);
+  assert(Fn && Addr && "Target dev

[libcxxabi] r292135 - Mark the dynamic-exception tests as unsupported under C++17, since it has no dynamic-exception specs. Also, remove a FIXME workaround from the config that allowed these tests to

2017-01-16 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Jan 16 09:28:03 2017
New Revision: 292135

URL: http://llvm.org/viewvc/llvm-project?rev=292135&view=rev
Log:
Mark the dynamic-exception tests as unsupported under C++17, since it has no 
dynamic-exception specs. Also, remove a FIXME workaround from the config that 
allowed these tests to work under C++17. This addresses PR#31621.

Modified:
libcxxabi/trunk/test/libcxxabi/test/config.py
libcxxabi/trunk/test/unwind_02.pass.cpp
libcxxabi/trunk/test/unwind_03.pass.cpp
libcxxabi/trunk/test/unwind_04.pass.cpp
libcxxabi/trunk/test/unwind_05.pass.cpp

Modified: libcxxabi/trunk/test/libcxxabi/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/libcxxabi/test/config.py?rev=292135&r1=292134&r2=292135&view=diff
==
--- libcxxabi/trunk/test/libcxxabi/test/config.py (original)
+++ libcxxabi/trunk/test/libcxxabi/test/config.py Mon Jan 16 09:28:03 2017
@@ -55,10 +55,6 @@ class Configuration(LibcxxConfiguration)
 if not self.get_lit_bool('enable_threads', True):
 self.cxx.compile_flags += ['-D_LIBCXXABI_HAS_NO_THREADS']
 self.config.available_features.add('libcxxabi-no-threads')
-# FIXME: Fix the unwind_* tests that test dynamic exception
-# specifications so they work in C++17 (or always test in C++14).
-# Suppressing this warning is a temporary workaround.
-self.cxx.addWarningFlagIfSupported('-Wno-dynamic-exception-spec')
 super(Configuration, self).configure_compile_flags()
 
 def configure_compile_flags_header_includes(self):

Modified: libcxxabi/trunk/test/unwind_02.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/unwind_02.pass.cpp?rev=292135&r1=292134&r2=292135&view=diff
==
--- libcxxabi/trunk/test/unwind_02.pass.cpp (original)
+++ libcxxabi/trunk/test/unwind_02.pass.cpp Mon Jan 16 09:28:03 2017
@@ -8,6 +8,7 @@
 
//===--===//
 
 // UNSUPPORTED: libcxxabi-no-exceptions
+// REQUIRES-ANY: c++98, c++03, c++11, c++14
 
 #include 
 

Modified: libcxxabi/trunk/test/unwind_03.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/unwind_03.pass.cpp?rev=292135&r1=292134&r2=292135&view=diff
==
--- libcxxabi/trunk/test/unwind_03.pass.cpp (original)
+++ libcxxabi/trunk/test/unwind_03.pass.cpp Mon Jan 16 09:28:03 2017
@@ -8,6 +8,7 @@
 
//===--===//
 
 // UNSUPPORTED: libcxxabi-no-exceptions
+// REQUIRES-ANY: c++98, c++03, c++11, c++14
 
 #include 
 #include 

Modified: libcxxabi/trunk/test/unwind_04.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/unwind_04.pass.cpp?rev=292135&r1=292134&r2=292135&view=diff
==
--- libcxxabi/trunk/test/unwind_04.pass.cpp (original)
+++ libcxxabi/trunk/test/unwind_04.pass.cpp Mon Jan 16 09:28:03 2017
@@ -8,6 +8,7 @@
 
//===--===//
 
 // UNSUPPORTED: libcxxabi-no-exceptions
+// REQUIRES-ANY: c++98, c++03, c++11, c++14
 
 #include 
 #include 

Modified: libcxxabi/trunk/test/unwind_05.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/unwind_05.pass.cpp?rev=292135&r1=292134&r2=292135&view=diff
==
--- libcxxabi/trunk/test/unwind_05.pass.cpp (original)
+++ libcxxabi/trunk/test/unwind_05.pass.cpp Mon Jan 16 09:28:03 2017
@@ -8,6 +8,7 @@
 
//===--===//
 
 // UNSUPPORTED: libcxxabi-no-exceptions
+// REQUIRES-ANY: c++98, c++03, c++11, c++14
 
 #include 
 #include 


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


r292141 - [StaticAnalyzer] Fix android build

2017-01-16 Thread Pavel Labath via cfe-commits
Author: labath
Date: Mon Jan 16 09:57:07 2017
New Revision: 292141

URL: http://llvm.org/viewvc/llvm-project?rev=292141&view=rev
Log:
[StaticAnalyzer] Fix android build

std::to_string is not available in the android NDK. Use llvm::to_string instead.

Committing as obvious.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp?rev=292141&r1=292140&r2=292141&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp Mon Jan 16 
09:57:07 2017
@@ -13,6 +13,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Checkers/SValExplainer.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/ScopedPrinter.h"
 
 using namespace clang;
 using namespace ento;
@@ -269,7 +270,7 @@ void ExprInspectionChecker::checkEndAnal
 unsigned NumTimesReached = Item.second.NumTimesReached;
 ExplodedNode *N = Item.second.ExampleNode;
 
-reportBug(std::to_string(NumTimesReached), BR, N);
+reportBug(llvm::to_string(NumTimesReached), BR, N);
   }
 }
 


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


[PATCH] D28670: [ObjC] Disallow vector parameters and return values in Objective-C methods on older X86 targets

2017-01-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/Sema/SemaDeclObjC.cpp:4337
+  VersionTuple MethodVersion = Method->getVersionIntroduced();
+  if (SemaRef.getASTContext().getTargetInfo().getPlatformMinVersion() >=
+  AcceptedInVersion &&

erik.pilkington wrote:
> I wonder if this is the right place to check this. If we're compiling using a 
> new SDK, but deploying back before vector types were supported we will 
> diagnose a method declared in a header even if it is never called. We should 
> probably hook this into DiagnoseAvailabilityOfDecl (in SemaExpr.cpp), which 
> is called whenever a method is actually used, and diagnose it then.
I'm not sure I get your argument.. We don't diagnose on method declarations, 
just method definitions, so I don't see how the header stuff is relevant here. 
We definitely don't want to diagnose on method uses either.


Repository:
  rL LLVM

https://reviews.llvm.org/D28670



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


[PATCH] D28670: [ObjC] Disallow vector parameters and return values in Objective-C methods on older X86 targets

2017-01-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 84564.
arphaman marked an inline comment as done.
arphaman added a comment.

Use better diagnostic message as suggested by Erik


Repository:
  rL LLVM

https://reviews.llvm.org/D28670

Files:
  include/clang/AST/DeclBase.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/DeclBase.cpp
  lib/Sema/SemaDeclObjC.cpp
  test/SemaObjC/x86-method-vector-values.m

Index: test/SemaObjC/x86-method-vector-values.m
===
--- /dev/null
+++ test/SemaObjC/x86-method-vector-values.m
@@ -0,0 +1,93 @@
+// RUN: %clang_cc1 -verify -DMAC -triple=i686-apple-macosx10.10 -Wno-objc-root-class %s
+// RUN: %clang_cc1 -verify -DMAC -triple=i686-apple-macosx10.4 -Wno-objc-root-class %s
+// RUN: %clang_cc1 -verify -DMAC -triple=i686-apple-darwin14 -Wno-objc-root-class %s
+// RUN: %clang_cc1 -verify -triple=i686-apple-ios8 -Wno-objc-root-class %s
+
+// RUN: %clang_cc1 -verify -DALLOW -DMAC -triple=i686-apple-macosx10.11 -Wno-objc-root-class %s
+// RUN: %clang_cc1 -verify -DALLOW -DMAC -triple=i686-apple-darwin15 -Wno-objc-root-class %s
+// RUN: %clang_cc1 -verify -DALLOW -DIOS -triple=i686-apple-ios9 -Wno-objc-root-class %s
+// RUN: %clang_cc1 -verify -DALLOW -DOTHER -triple=i686-apple-watchos -Wno-objc-root-class %s
+// RUN: %clang_cc1 -verify -DALLOW -DOTHER -triple=i686-apple-tvos -Wno-objc-root-class %s
+
+// RUN: %clang_cc1 -verify -DALLOW -DOTHER -triple=x86_64-apple-macosx10.10 -Wno-objc-root-class %s
+
+// rdar://21662309
+
+typedef __attribute__((__ext_vector_type__(3))) float float3;
+
+#define AVAILABLE_MACOS_10_10 __attribute__((availability(macos, introduced = 10.10)))
+#define AVAILABLE_MACOS_10_11 __attribute__((availability(macos, introduced = 10.11)))
+
+#define AVAILABLE_IOS_8 __attribute__((availability(ios, introduced = 8.0)))
+#define AVAILABLE_IOS_9 __attribute__((availability(ios, introduced = 9.0)))
+
+@interface VectorMethods
+
+-(void)takeVector:(float3)v; // there should be no diagnostic at declaration
+
+@end
+
+@implementation VectorMethods
+
+#ifndef ALLOW
+
+-(void)takeVector:(float3)v {
+#ifdef MAC
+  // expected-error@-2 {{'float3' (vector of 3 'float' values) parameter type is unsupported; support for vector types for this target is introduced in macOS 10.11}}
+#else
+  // expected-error@-4 {{'float3' (vector of 3 'float' values) parameter type is unsupported; support for vector types for this target is introduced in iOS 9}}
+#endif
+}
+
+-(float3)retVector { // expected-error {{'float3' (vector of 3 'float' values) return type is unsupported}}
+}
+
+-(void)takeVector2:(float3)v AVAILABLE_MACOS_10_10 { // expected-error {{'float3' (vector of 3 'float' values) parameter type is unsupported}}
+}
+
+-(void)takeVector3:(float3)v AVAILABLE_MACOS_10_11 { // expected-error {{'float3' (vector of 3 'float' values) parameter type is unsupported}}
+}
+
+-(void)takeVector4:(float3)v AVAILABLE_IOS_8 { // expected-error {{'float3' (vector of 3 'float' values) parameter type is unsupported}}
+}
+
+-(void)takeVector5:(float3)v AVAILABLE_IOS_9 { // expected-error {{'float3' (vector of 3 'float' values) parameter type is unsupported}}
+}
+
+#else
+
+-(void)takeVector:(float3)v {
+}
+
+-(float3)retVector {
+  return 0;
+}
+
+-(void)takeVector2:(float3)v AVAILABLE_MACOS_10_10 {
+#ifdef MAC
+// expected-error@-2 {{'float3' (vector of 3 'float' values) parameter type is unsupported}}
+#endif
+}
+
+-(void)takeVector3:(float3)v AVAILABLE_MACOS_10_11 { // no error
+}
+
+-(void)takeVector4:(float3)v AVAILABLE_IOS_8 {
+#ifdef IOS
+  // expected-error@-2 {{'float3' (vector of 3 'float' values) parameter type is unsupported}}
+#endif
+}
+
+-(void)takeVector5:(float3)v AVAILABLE_IOS_9 { // no error
+}
+
+#ifdef OTHER
+// expected-no-diagnostics
+#endif
+
+#endif
+
+-(void)doStuff:(int)m { // no error
+}
+
+@end
Index: lib/Sema/SemaDeclObjC.cpp
===
--- lib/Sema/SemaDeclObjC.cpp
+++ lib/Sema/SemaDeclObjC.cpp
@@ -4302,6 +4302,48 @@
   }
 }
 
+/// Verify that the method parameters/return value have types that are supported
+/// by the x86 target.
+static void checkObjCMethodX86VectorTypes(Sema &SemaRef,
+  const ObjCMethodDecl *Method) {
+  SourceLocation Loc;
+  QualType T;
+  for (const ParmVarDecl *P : Method->parameters()) {
+if (P->getType()->isVectorType()) {
+  Loc = P->getLocStart();
+  T = P->getType();
+  break;
+}
+  }
+  if (Loc.isInvalid()) {
+if (Method->getReturnType()->isVectorType()) {
+  Loc = Method->getReturnTypeSourceRange().getBegin();
+  T = Method->getReturnType();
+} else
+  return;
+  }
+
+  // Vector parameters/return values are not supported by objc_msgSend on x86 in
+  // iOS < 9 and macOS < 10.11.
+  const auto &Triple = SemaRef.getASTContext().getTargetInfo().getTriple();
+  VersionTuple AcceptedInVersion;
+  if (Triple.getOS() == llvm::Triple::IOS)
+Accept

[PATCH] D24991: Inline hot functions in libcxx shared_ptr implementation.

2017-01-16 Thread Kevin Hu via Phabricator via cfe-commits
hxy9243 updated this revision to Diff 84565.
hxy9243 added a comment.

Addresses comments from @EricWF.

Thanks for reviewing, I know it takes a lot of energy. It helped me learn a lot.


Repository:
  rL LLVM

https://reviews.llvm.org/D24991

Files:
  libcxx/include/memory
  libcxx/src/memory.cpp

Index: libcxx/src/memory.cpp
===
--- libcxx/src/memory.cpp
+++ libcxx/src/memory.cpp
@@ -17,28 +17,6 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-namespace
-{
-
-// NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively)
-// should be sufficient for thread safety.
-// See https://llvm.org/bugs/show_bug.cgi?id=22803
-template 
-inline T
-increment(T& t) _NOEXCEPT
-{
-return __libcpp_atomic_add(&t, 1, _AO_Relaxed);
-}
-
-template 
-inline T
-decrement(T& t) _NOEXCEPT
-{
-return __libcpp_atomic_add(&t, -1, _AO_Acq_Rel);
-}
-
-}  // namespace
-
 const allocator_arg_t allocator_arg = allocator_arg_t();
 
 bad_weak_ptr::~bad_weak_ptr() _NOEXCEPT {}
@@ -53,27 +31,27 @@
 {
 }
 
+__shared_weak_count::~__shared_weak_count()
+{
+}
+
 void
 __shared_count::__add_shared() _NOEXCEPT
 {
-increment(__shared_owners_);
+__libcpp_atomic_refcount_increment(__shared_owners_);
 }
 
 bool
 __shared_count::__release_shared() _NOEXCEPT
 {
-if (decrement(__shared_owners_) == -1)
+if (__libcpp_atomic_refcount_decrement(__shared_owners_) == -1)
 {
 __on_zero_shared();
 return true;
 }
 return false;
 }
 
-__shared_weak_count::~__shared_weak_count()
-{
-}
-
 void
 __shared_weak_count::__add_shared() _NOEXCEPT
 {
@@ -83,7 +61,7 @@
 void
 __shared_weak_count::__add_weak() _NOEXCEPT
 {
-increment(__shared_weak_owners_);
+__libcpp_atomic_refcount_increment(__shared_weak_owners_);
 }
 
 void
@@ -124,7 +102,7 @@
 //__libcpp_atomic_store(&__shared_weak_owners_, -1, _AO_Release);
 __on_zero_shared_weak();
 }
-else if (decrement(__shared_weak_owners_) == -1)
+else if (__libcpp_atomic_refcount_decrement(__shared_weak_owners_) == -1)
 __on_zero_shared_weak();
 }
 
Index: libcxx/include/memory
===
--- libcxx/include/memory
+++ libcxx/include/memory
@@ -3681,6 +3681,44 @@
 
 #endif // _LIBCPP_STD_VER > 14
 
+// NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively)
+// should be sufficient for thread safety.
+// See https://llvm.org/bugs/show_bug.cgi?id=22803
+#if defined(__clang__) && __has_builtin(__atomic_load_n) \
+   && __has_builtin(__atomic_store_n)\
+   && __has_builtin(__atomic_add_fetch)  \
+   && __has_builtin(__atomic_compare_exchange_n) \
+   && defined(__ATOMIC_RELAXED)  \
+   && defined(__ATOMIC_CONSUME)  \
+   && defined(__ATOMIC_ACQUIRE)  \
+   && defined(__ATOMIC_RELEASE)  \
+   && defined(__ATOMIC_ACQ_REL)  \
+   && defined(__ATOMIC_SEQ_CST)
+#   define _LIBCPP_HAS_ATOMIC_BUILTINS
+#endif
+
+template 
+inline T
+__libcpp_atomic_refcount_increment(T& t) _NOEXCEPT
+{
+#if defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS)
+return __atomic_add_fetch(&t, 1, __ATOMIC_RELAXED);
+#else
+return t += 1;
+#endif
+}
+
+template 
+inline T
+__libcpp_atomic_refcount_decrement(T& t) _NOEXCEPT
+{
+#if defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS)
+return __atomic_add_fetch(&t, -1, __ATOMIC_ACQ_REL);
+#else
+return t -= 1;
+#endif
+}
+
 class _LIBCPP_EXCEPTION_ABI bad_weak_ptr
 : public std::exception
 {
@@ -3717,8 +3755,23 @@
 explicit __shared_count(long __refs = 0) _NOEXCEPT
 : __shared_owners_(__refs) {}
 
-void __add_shared() _NOEXCEPT;
-bool __release_shared() _NOEXCEPT;
+#ifdef _LIBCPP_BUILDING_MEMORY
+void _LIBCPP_FUNC_VIS __add_shared() _NOEXCEPT;
+bool _LIBCPP_FUNC_VIS __release_shared() _NOEXCEPT;
+#else
+_LIBCPP_INLINE_VISIBILITY
+void __add_shared() _NOEXCEPT {
+  __libcpp_atomic_refcount_increment(__shared_owners_);
+}
+_LIBCPP_INLINE_VISIBILITY
+bool __release_shared() _NOEXCEPT {
+  if (__libcpp_atomic_refcount_decrement(__shared_owners_) == -1) {
+__on_zero_shared();
+return true;
+  }
+  return false;
+}
+#endif
 _LIBCPP_INLINE_VISIBILITY
 long use_count() const _NOEXCEPT {
 return __libcpp_relaxed_load(&__shared_owners_) + 1;
@@ -3739,9 +3792,25 @@
 virtual ~__shared_weak_count();
 
 public:
-void __add_shared() _NOEXCEPT;
-void __add_weak() _NOEXCEPT;
-void __release_shared() _NOEXCEPT;
+#ifdef _LIBCPP_BUILDING_MEMORY
+void _LIBCPP_FUNC_VIS __add_shared() _NOEXCEPT;
+void _LIBCPP_FUNC_VIS __add_weak()

[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'

2017-01-16 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added a comment.

Thanks for the check. Have you run it on llvm?




Comment at: clang-tidy/modernize/ReturnBracedInitListCheck.cpp:27-32
+  auto soughtConstructExpr =
+  cxxConstructExpr(unless(isListInitialization())).bind("ctor");
+
+  auto hasConstructExpr = has(ignoringImplicit(soughtConstructExpr));
+
+  auto ctorAsArgument = materializeTemporaryExpr(

Uppercase



Comment at: clang-tidy/modernize/ReturnBracedInitListCheck.cpp:38
+   returns(recordType()), // We only care about record types.
+   hasDescendant(returnStmt(hasDescendant(ctorAsArgument
+  .bind("fn"),

Wouldn't 
returnStmt(has(ctorAsArgument))

be sufficient?
or maybe

returnStmt(has(ignoringImplici(ctorAsArgument)))

hasDescendant is slow, and besides it probably match for cases like:

return fun(A(a, b, c));

where fun is call, and ctorAsArgument will match to A()


Repository:
  rL LLVM

https://reviews.llvm.org/D28768



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


[PATCH] D24991: Inline hot functions in libcxx shared_ptr implementation.

2017-01-16 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: libcxx/include/memory:3700
+
+template 
+inline T

`template `, please.

Otherwise when some client code does `#define T true` (yes, I've seen that!) 
this breaks.  `_Tp` is a reserved identifier, and if they use that, we can 
point at them and laugh.




Comment at: libcxx/include/memory:3702
+inline T
+__libcpp_atomic_refcount_increment(T& t) _NOEXCEPT
+{

The parameter name needs to be reserved as well. `__t`, please.



Comment at: libcxx/include/memory:3711
+
+template 
+inline T

Same comment as L3700



Comment at: libcxx/include/memory:3713
+inline T
+__libcpp_atomic_refcount_decrement(T& t) _NOEXCEPT
+{

Same comment as L3702


Repository:
  rL LLVM

https://reviews.llvm.org/D24991



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


[PATCH] D28729: [clang-tidy] Add -enable-alpha-checks command

2017-01-16 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D28729#647250, @Prazek wrote:

> Does solution like this works for you? We don't officially support alpha 
> checkers, but it is much easier to check if something is already implemented 
> in static analyzer easily


Is it the only problem you're trying to solve by this patch? If so, it might be 
better to add an alias/script to run `clang --analyze -Xclang 
-analyzer-checker=alpha` or even use gcc.godbolt.org (e.g. 
https://godbolt.org/g/msQigz).

My concern is that if there's a user-visible option (undocumented, unlisted, 
named `--no-no-no-please-dont-use-this-option` or otherwise discouraged), 
people will use it (sometimes unintentionally, because, well, they changed 
their config once to give it a try and then forgot about it for a year), rely 
on it, complain about the tool, etc. If clang-tidy is used in some sort of a 
server-side manner (e.g. integrated with code review), misbehaving checkers may 
cause crashes, and this is problematic, when maintainers have no intention to 
fix the bugs and well, they explicitly asked not to expose experimental 
checkers (see http://llvm.org/PR26855, for example).


https://reviews.llvm.org/D28729



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


[PATCH] D24991: Inline hot functions in libcxx shared_ptr implementation.

2017-01-16 Thread Kevin Hu via Phabricator via cfe-commits
hxy9243 updated this revision to Diff 84569.
hxy9243 added a comment.

Addresses comments from @mclow.lists.


Repository:
  rL LLVM

https://reviews.llvm.org/D24991

Files:
  libcxx/include/memory
  libcxx/src/memory.cpp

Index: libcxx/src/memory.cpp
===
--- libcxx/src/memory.cpp
+++ libcxx/src/memory.cpp
@@ -17,28 +17,6 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-namespace
-{
-
-// NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively)
-// should be sufficient for thread safety.
-// See https://llvm.org/bugs/show_bug.cgi?id=22803
-template 
-inline T
-increment(T& t) _NOEXCEPT
-{
-return __libcpp_atomic_add(&t, 1, _AO_Relaxed);
-}
-
-template 
-inline T
-decrement(T& t) _NOEXCEPT
-{
-return __libcpp_atomic_add(&t, -1, _AO_Acq_Rel);
-}
-
-}  // namespace
-
 const allocator_arg_t allocator_arg = allocator_arg_t();
 
 bad_weak_ptr::~bad_weak_ptr() _NOEXCEPT {}
@@ -53,27 +31,27 @@
 {
 }
 
+__shared_weak_count::~__shared_weak_count()
+{
+}
+
 void
 __shared_count::__add_shared() _NOEXCEPT
 {
-increment(__shared_owners_);
+__libcpp_atomic_refcount_increment(__shared_owners_);
 }
 
 bool
 __shared_count::__release_shared() _NOEXCEPT
 {
-if (decrement(__shared_owners_) == -1)
+if (__libcpp_atomic_refcount_decrement(__shared_owners_) == -1)
 {
 __on_zero_shared();
 return true;
 }
 return false;
 }
 
-__shared_weak_count::~__shared_weak_count()
-{
-}
-
 void
 __shared_weak_count::__add_shared() _NOEXCEPT
 {
@@ -83,7 +61,7 @@
 void
 __shared_weak_count::__add_weak() _NOEXCEPT
 {
-increment(__shared_weak_owners_);
+__libcpp_atomic_refcount_increment(__shared_weak_owners_);
 }
 
 void
@@ -124,7 +102,7 @@
 //__libcpp_atomic_store(&__shared_weak_owners_, -1, _AO_Release);
 __on_zero_shared_weak();
 }
-else if (decrement(__shared_weak_owners_) == -1)
+else if (__libcpp_atomic_refcount_decrement(__shared_weak_owners_) == -1)
 __on_zero_shared_weak();
 }
 
Index: libcxx/include/memory
===
--- libcxx/include/memory
+++ libcxx/include/memory
@@ -3681,6 +3681,39 @@
 
 #endif // _LIBCPP_STD_VER > 14
 
+// NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively)
+// should be sufficient for thread safety.
+// See https://llvm.org/bugs/show_bug.cgi?id=22803
+#if defined(__clang__) && __has_builtin(__atomic_add_fetch)  \
+   && defined(__ATOMIC_RELAXED)  \
+   && defined(__ATOMIC_ACQ_REL)
+#   define _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT
+#elif !defined(__clang__) && defined(_GNUC_VER) && _GNUC_VER >= 407
+#   define _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT
+#endif
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY _Tp
+__libcpp_atomic_refcount_increment(_Tp& __t) _NOEXCEPT
+{
+#if defined(_LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT) && !defined(_LIBCPP_HAS_NO_THREADS)
+return __atomic_add_fetch(&__t, 1, __ATOMIC_RELAXED);
+#else
+return __t += 1;
+#endif
+}
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY _Tp
+__libcpp_atomic_refcount_decrement(_Tp& __t) _NOEXCEPT
+{
+#if defined(_LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT) && !defined(_LIBCPP_HAS_NO_THREADS)
+return __atomic_add_fetch(&__t, -1, __ATOMIC_ACQ_REL);
+#else
+return __t -= 1;
+#endif
+}
+
 class _LIBCPP_EXCEPTION_ABI bad_weak_ptr
 : public std::exception
 {
@@ -3717,8 +3750,23 @@
 explicit __shared_count(long __refs = 0) _NOEXCEPT
 : __shared_owners_(__refs) {}
 
-void __add_shared() _NOEXCEPT;
-bool __release_shared() _NOEXCEPT;
+#ifdef _LIBCPP_BUILDING_MEMORY
+_LIBCPP_FUNC_VIS void __add_shared() _NOEXCEPT;
+_LIBCPP_FUNC_VIS bool __release_shared() _NOEXCEPT;
+#else
+_LIBCPP_INLINE_VISIBILITY
+void __add_shared() _NOEXCEPT {
+  __libcpp_atomic_refcount_increment(__shared_owners_);
+}
+_LIBCPP_INLINE_VISIBILITY
+bool __release_shared() _NOEXCEPT {
+  if (__libcpp_atomic_refcount_decrement(__shared_owners_) == -1) {
+__on_zero_shared();
+return true;
+  }
+  return false;
+}
+#endif
 _LIBCPP_INLINE_VISIBILITY
 long use_count() const _NOEXCEPT {
 return __libcpp_relaxed_load(&__shared_owners_) + 1;
@@ -3739,9 +3787,25 @@
 virtual ~__shared_weak_count();
 
 public:
-void __add_shared() _NOEXCEPT;
-void __add_weak() _NOEXCEPT;
-void __release_shared() _NOEXCEPT;
+#ifdef _LIBCPP_BUILDING_MEMORY
+_LIBCPP_FUNC_VIS void __add_shared() _NOEXCEPT;
+_LIBCPP_FUNC_VIS void __add_weak() _NOEXCEPT;
+_LIBCPP_FUNC_VIS void __release_shared() _NOEXCEPT;
+#else
+_LIBCPP_INLINE_VISIBILITY
+void __add_shared() _NOEXCEPT {
+  __shared_count::__add_shared();
+}
+_LIBCPP_INLINE_VISIBILITY
+void __add_weak() _NOEXCEPT {
+  __libcpp_atomic_refcount_increment(__shared_weak_owners_);
+}
+_LIBCPP_INLINE_VISIBILITY
+void __

[PATCH] D28774: [clang-move] Ignore using decls which are defined in macros.

2017-01-16 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: ioeric.
hokein added a subscriber: cfe-commits.

Also ignore helpers which are defined in macro. Currently clang-move doesn't
handle macro well enough, especiall for complex macros. This patch will ignore
declarations in macros to make the behavior of clang-move more correct.


https://reviews.llvm.org/D28774

Files:
  clang-move/ClangMove.cpp
  test/clang-move/Inputs/macro_helper_test.cpp
  test/clang-move/Inputs/macro_helper_test.h
  test/clang-move/no-move-macro-helpers.cpp


Index: test/clang-move/no-move-macro-helpers.cpp
===
--- /dev/null
+++ test/clang-move/no-move-macro-helpers.cpp
@@ -0,0 +1,19 @@
+// RUN: mkdir -p %T/no-move-macro-helper
+// RUN: cp %S/Inputs/macro_helper_test.h  
%T/no-move-macro-helper/macro_helper_test.h
+// RUN: cp %S/Inputs/macro_helper_test.cpp 
%T/no-move-macro-helper/macro_helper_test.cpp
+// RUN: cd %T/no-move-macro-helper
+//
+// 
-
+// Test no moving helpers in macro.
+// 
-
+// RUN: clang-move -names="A" -new_cc=%T/no-move-macro-helper/new_test.cpp 
-new_header=%T/no-move-macro-helper/new_test.h 
-old_cc=%T/no-move-macro-helper/macro_helper_test.cpp 
-old_header=%T/no-move-macro-helper/macro_helper_test.h 
%T/no-move-macro-helper/macro_helper_test.cpp -- -std=c++11
+// RUN: FileCheck -input-file=%T/no-move-macro-helper/new_test.h 
-check-prefix=CHECK-NEW-TEST-H %s
+// RUN: FileCheck -input-file=%T/no-move-macro-helper/macro_helper_test.h 
-check-prefix=CHECK-OLD-TEST-H %s
+// RUN: FileCheck -input-file=%T/no-move-macro-helper/new_test.cpp 
-check-prefix=CHECK-NEW-TEST-CPP %s
+
+
+// CHECK-NEW-TEST-H: class A {};
+
+// CHECK-OLD-TEST-H-NOT: class A {};
+
+// CHECK-NEW-TEST-CPP-NOT: DEFINE(test)
Index: test/clang-move/Inputs/macro_helper_test.h
===
--- /dev/null
+++ test/clang-move/Inputs/macro_helper_test.h
@@ -0,0 +1,2 @@
+class A {};
+void f1();
Index: test/clang-move/Inputs/macro_helper_test.cpp
===
--- /dev/null
+++ test/clang-move/Inputs/macro_helper_test.cpp
@@ -0,0 +1,13 @@
+#include "macro_helper_test.h"
+
+#define DEFINE(name) \
+  namespace ns { \
+  static const bool t1 = false; \
+  bool t2_##name = t1; \
+  bool t3_##name = t1; \
+  } \
+  using ns::t2_##name;
+
+DEFINE(test)
+
+void f1() {}
Index: clang-move/ClangMove.cpp
===
--- clang-move/ClangMove.cpp
+++ clang-move/ClangMove.cpp
@@ -31,6 +31,8 @@
 // FIXME: Move to ASTMatchers.
 AST_MATCHER(VarDecl, isStaticDataMember) { return Node.isStaticDataMember(); }
 
+AST_MATCHER(NamedDecl, notInMacro) { return !Node.getLocation().isMacroID(); }
+
 AST_MATCHER_P(Decl, hasOutermostEnclosingClass,
   ast_matchers::internal::Matcher, InnerMatcher) {
   const auto *Context = Node.getDeclContext();
@@ -525,12 +527,12 @@
   // Matching using decls/type alias decls which are in named/anonymous/global
   // namespace, these decls are always copied to new.h/cc. Those in classes,
   // functions are covered in other matchers.
-  Finder->addMatcher(
-  namedDecl(anyOf(usingDecl(IsOldCCTopLevelDecl),
-  usingDirectiveDecl(IsOldCCTopLevelDecl),
-  typeAliasDecl(IsOldCCTopLevelDecl)))
-  .bind("using_decl"),
-  this);
+  Finder->addMatcher(namedDecl(anyOf(usingDecl(IsOldCCTopLevelDecl),
+ usingDirectiveDecl(IsOldCCTopLevelDecl),
+ typeAliasDecl(IsOldCCTopLevelDecl)),
+   notInMacro())
+ .bind("using_decl"),
+ this);
 
   // Match static functions/variable definitions which are defined in named
   // namespaces.
@@ -556,9 +558,11 @@
   allOf(DefinitionInOldCC, anyOf(isStaticStorageClass(), InAnonymousNS));
   // Match helper classes separately with helper functions/variables since we
   // want to reuse these matchers in finding helpers usage below.
-  auto HelperFuncOrVar = namedDecl(anyOf(functionDecl(IsOldCCHelperDefinition),
- varDecl(IsOldCCHelperDefinition)));
-  auto HelperClasses = cxxRecordDecl(DefinitionInOldCC, InAnonymousNS);
+  auto HelperFuncOrVar =
+  namedDecl(notInMacro(), anyOf(functionDecl(IsOldCCHelperDefinition),
+varDecl(IsOldCCHelperDefinition)));
+  auto HelperClasses =
+  cxxRecordDecl(notInMacro(), DefinitionInOldCC, InAnonymousNS);
   // Save all helper declarations in old.cc.
   Finder->addMatcher(
   namedDecl(anyOf(HelperFuncOrVar, HelperClasses)).bind("helper_decls"),


Index: test/clang-move/no-move-macro-helpers.cpp

[PATCH] D28774: [clang-move] Ignore using decls which are defined in macros.

2017-01-16 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

Lg.




Comment at: test/clang-move/no-move-macro-helpers.cpp:1
+// RUN: mkdir -p %T/no-move-macro-helper
+// RUN: cp %S/Inputs/macro_helper_test.h  
%T/no-move-macro-helper/macro_helper_test.h

Would be nice to add a test case where both `A` and `f1` are moved.



Comment at: test/clang-move/no-move-macro-helpers.cpp:19
+
+// CHECK-NEW-TEST-CPP-NOT: DEFINE(test)

Check that this is not deleted in old cc.


https://reviews.llvm.org/D28774



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


Re: [PATCH] D28548: Improve include fixer's ranking by taking the paths into account.

2017-01-16 Thread David Blaikie via cfe-commits
Looks like Ben signed off on this on Phab - but the email didn't go to the
list (making this look like code was sent for review, then committed,
without review/approval happening)

Ben: I think Phab doesn't send mail for an approval with no text, so at
least as a workaround you can write something in the comments section when
approving (people often write "LGTM" or similar) to ensure the approval is
reflected on the mailing list.

On Wed, Jan 11, 2017 at 1:59 AM Manuel Klimek via Phabricator via
cfe-commits  wrote:

> klimek created this revision.
> klimek added a reviewer: bkramer.
> klimek added a subscriber: cfe-commits.
>
> Instead of just using popularity, we also take into account how similar the
> path of the current file is to the path of the header.
> Our first approach is to get popularity into a reasonably small scale by
> taking
> log2 (which is roughly intuitive to how humans would bucket popularity),
> and
> multiply that with the number of matching prefix path fragments of the
> included
> header with the current file.
> Note that currently we do not take special care for unclean paths
> containing
> "../" or "./".
>
>
> https://reviews.llvm.org/D28548
>
> Files:
>   include-fixer/IncludeFixer.cpp
>   include-fixer/SymbolIndexManager.cpp
>   include-fixer/SymbolIndexManager.h
>   include-fixer/tool/ClangIncludeFixer.cpp
>   test/include-fixer/Inputs/fake_yaml_db.yaml
>   test/include-fixer/ranking.cpp
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28462: clang-format: Add new style option AlignConsecutiveMacros

2017-01-16 Thread Erik Nyquist via Phabricator via cfe-commits
enyquist added inline comments.



Comment at: Format/FormatToken.h:148
 
+  /// \brief Whether the token is the final token in the identifier of a PP
+  // macro. This will be either 1) the identifier token following the 'define'

djasper wrote:
> This adds a lot of code, runtime and memory even if you disable the alignment 
> of macros and I am slightly hesitant about that. Two reasons:
> - It would be nicer if all of this logic was completely encapsulated in the 
> whitespace manager.
> - We don't want to spent the computing resources if this is disabled.
> 
> Can we remove all of what's in FormatToken.h and TokenAnnotator.cpp and 
> instead have a function in the whitespace manager, that identifies this 
> location in the code?
My first attempt was changes in WhitespaceManager.cpp only, however I couldn't 
figure out a way to make this work without access to the full FormatToken in 
WhitespaceManager.

Sounds like you're going to try it this week, so I'll watch for that change, 
and try to implement this style option in WhitespaceManager.cpp only, when I 
see it.



Comment at: Format/WhitespaceManager.cpp:33
 StringRef CurrentLinePrefix, tok::TokenKind Kind, bool 
ContinuesPPDirective,
-bool IsStartOfDeclName, bool IsInsideToken)
+bool IsStartOfDeclName, bool IsInsideToken, bool EndsPPIdentifier)
 : CreateReplacement(CreateReplacement),

djasper wrote:
> We have to stop adding more stuff here. I think it is better to store 
> reference to the actual FormatToken by now. I'll take a stab at that later 
> this week.
Sounds good-- this style option should be do-able in WhitespaceManager only, if 
we have access to the full FormatToken.


Repository:
  rL LLVM

https://reviews.llvm.org/D28462



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


[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'

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



Comment at: clang-tidy/modernize/ReturnBracedInitListCheck.cpp:60
+  auto Diag =
+  diag(Loc, "use braced initializer list for constructing return types");
+

This diagnostic doesn't really tell the user what's wrong with the code. Why is 
a braced init list better than another kind of initialization expression? 
Perhaps: "to avoid repeating the return type from the declaration, use a braced 
initializer list instead" or something along those lines?



Comment at: clang-tidy/modernize/ReturnBracedInitListCheck.cpp:62
+
+  auto CallParensRange = MatchedConstructExpr->getParenOrBraceRange();
+

Please do not use `auto` here, the type is not explicitly spelled out in the 
initialization.



Comment at: test/clang-tidy/modernize-return-braced-init-list.cpp:38
+  return Foo(b);
+}

We should probably have a test that ensures this code
```
[]() { return std::vector({1, 2}); }();   
```
does not get converted into this code
```
[]() { return {1, 2}; }();   
```


Repository:
  rL LLVM

https://reviews.llvm.org/D28768



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


[PATCH] D19201: [clang-tidy] misc-throw-with-noexcept

2017-01-16 Thread Stanisław Barzowski via Phabricator via cfe-commits
sbarzowski removed rL LLVM as the repository for this revision.
sbarzowski updated this revision to Diff 84577.
sbarzowski added a comment.
Herald added subscribers: JDevlieghere, mgorny.

I took advantage of new getExceptionSpecSourceRange (it wasn't available 
before) instead of getting exception specification manually with the lexer.


https://reviews.llvm.org/D19201

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/ThrowWithNoexceptCheck.cpp
  clang-tidy/misc/ThrowWithNoexceptCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-throw-with-noexcept.rst
  test/clang-tidy/misc-throw-with-noexcept.cpp

Index: test/clang-tidy/misc-throw-with-noexcept.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-throw-with-noexcept.cpp
@@ -0,0 +1,88 @@
+// RUN: %check_clang_tidy %s misc-throw-with-noexcept %t
+
+void f_throw_with_ne() noexcept(true) {
+  {
+throw 5;
+  }
+}
+// CHECK-MESSAGES: :[[@LINE-5]]:24: warning: In function declared no-throw here: [misc-throw-with-noexcept]
+// CHECK-MESSAGES: :[[@LINE-4]]:5: warning: 'throw' expression in a function declared with a non-throwing exception specification [misc-throw-with-noexcept]
+// CHECK-FIXES: void f_throw_with_ne() {
+
+void f_noexcept_false() noexcept(false) {
+  throw 5;
+}
+
+void f_decl_only() noexcept;
+
+// Controversial example
+void throw_and_catch() noexcept(true) {
+  try {
+throw 5;
+  } catch (...) {
+  }
+}
+// CHECK-MESSAGES: :[[@LINE-6]]:24: warning: In function declared no-throw here: [misc-throw-with-noexcept]
+// CHECK-MESSAGES: :[[@LINE-5]]:5: warning: 'throw' expression in a function declared with a non-throwing exception specification [misc-throw-with-noexcept]
+// CHECK-FIXES: void throw_and_catch() {
+
+void with_parens() noexcept((true)) {
+	throw 42;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:20: warning: In function declared no-throw here: [misc-throw-with-noexcept]
+// CHECK-MESSAGES: :[[@LINE-3]]:2: warning: 'throw' expression in a function declared with a non-throwing exception specification [misc-throw-with-noexcept]
+// CHECK-FIXES: void with_parens() {
+
+
+void with_parens_and_spaces() noexcept(  (true)  ) {
+	throw 42;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:31: warning: In function declared no-throw here: [misc-throw-with-noexcept]
+// CHECK-MESSAGES: :[[@LINE-3]]:2: warning: 'throw' expression in a function declared with a non-throwing exception specification [misc-throw-with-noexcept]
+// CHECK-FIXES: void with_parens_and_spaces() {
+
+class Class {
+  void InClass() const noexcept(true) {
+throw 42;
+  }
+};
+// CHECK-MESSAGES: :[[@LINE-4]]:24: warning: In function declared no-throw here: [misc-throw-with-noexcept]
+// CHECK-MESSAGES: :[[@LINE-4]]:5: warning: 'throw' expression in a function declared with a non-throwing exception specification [misc-throw-with-noexcept]
+// CHECK-FIXES: void InClass() const {
+
+
+void forward_declared() noexcept;
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: In function declared no-throw here: [misc-throw-with-noexcept]
+// CHECK-FIXES: void forward_declared() ;
+
+void forward_declared() noexcept {
+	throw 42;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:25: warning: In function declared no-throw here: [misc-throw-with-noexcept]
+// CHECK-MESSAGES: :[[@LINE-3]]:2: warning: 'throw' expression in a function declared with a non-throwing exception specification [misc-throw-with-noexcept]
+// CHECK-FIXES: void forward_declared() {
+
+void getFunction() noexcept {
+  struct X {
+static void inner()
+{
+throw 42;
+}
+  };
+}
+
+void dynamic_exception_spec() throw() {
+  throw 42;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:31: warning: In function declared no-throw here: [misc-throw-with-noexcept]
+// CHECK-MESSAGES: :[[@LINE-3]]:3: warning: 'throw' expression in a function declared with a non-throwing exception specification [misc-throw-with-noexcept]
+// CHECK-FIXES: void dynamic_exception_spec() {
+
+#define NOEXCEPT noexcept
+
+void with_macro() NOEXCEPT {
+  throw 42;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:19: warning: In function declared no-throw here: [misc-throw-with-noexcept]
+// CHECK-MESSAGES: :[[@LINE-3]]:3: warning: 'throw' expression in a function declared with a non-throwing exception specification [misc-throw-with-noexcept]
+// CHECK-FIXES: void with_macro() {
Index: docs/clang-tidy/checks/misc-throw-with-noexcept.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-throw-with-noexcept.rst
@@ -0,0 +1,22 @@
+.. title:: clang-tidy - misc-throw-with-noexcept
+
+mist-throw-with-noexcept
+
+
+This check finds cases of using ``throw`` in a function declared as noexcept.
+Please note that the warning is issued even if the exception is caught within
+the same function, as that would be probably a bad style anyway.
+
+It removes the noexcept speci

[PATCH] D28705: [Sema] Fix bug in handling of designated initializer

2017-01-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D28705



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


LLVM buildmaster will be updated and restarted tonight

2017-01-16 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be updated and restarted after 5 PM Pacific time
today.

Thanks

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


[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'

2017-01-16 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere updated this revision to Diff 84581.
JDevlieghere marked 8 inline comments as done.
JDevlieghere added a comment.

- Added more tests
- Improved matchers
- Addressed code review comments from @malcolm.parsons, @Prazek and 
@aaron.ballman


Repository:
  rL LLVM

https://reviews.llvm.org/D28768

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/ReturnBracedInitListCheck.cpp
  clang-tidy/modernize/ReturnBracedInitListCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-return-braced-init-list.rst
  test/clang-tidy/modernize-return-braced-init-list.cpp

Index: test/clang-tidy/modernize-return-braced-init-list.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-return-braced-init-list.cpp
@@ -0,0 +1,104 @@
+// RUN: %check_clang_tidy %s modernize-return-braced-init-list %t -- --
+// -std=c++14
+
+namespace std {
+  typedef decltype(sizeof(int)) size_t;
+
+  // libc++'s implementation
+  template 
+  class initializer_list
+  {
+const _E* __begin_;
+size_t__size_;
+
+initializer_list(const _E* __b, size_t __s)
+  : __begin_(__b),
+__size_(__s)
+{}
+
+  public:
+typedef _Evalue_type;
+typedef const _E& reference;
+typedef const _E& const_reference;
+typedef size_tsize_type;
+
+typedef const _E* iterator;
+typedef const _E* const_iterator;
+
+initializer_list() : __begin_(nullptr), __size_(0) {}
+
+size_tsize()  const {return __size_;}
+const _E* begin() const {return __begin_;}
+const _E* end()   const {return __begin_ + __size_;}
+  };
+}
+
+class Bar {};
+
+class Foo {
+public:
+  Foo(Bar bar) : bar(bar){};
+
+private:
+  Bar bar;
+};
+
+class Baz {
+public:
+  Foo m() {
+Bar b;
+return Foo(b);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+// CHECK-FIXES: return {b};
+  }
+};
+
+template  class vector {
+public:
+  vector(T){};
+  vector(std::initializer_list) {}
+};
+
+class Quux : public Foo {
+public:
+  Quux(Bar bar) : Foo(bar){};
+};
+
+Foo f() {
+  Bar b;
+  return Foo(b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {b};
+}
+
+Foo f2() {
+  Bar b;
+  return {b};
+}
+
+auto f3() {
+  Bar b;
+  return Foo(b);
+}
+
+#define A(b) Foo(b)
+
+Foo f4() {
+  Bar b;
+  return A(b);
+}
+
+Foo f5() {
+  Bar b;
+  return Quux(b);
+}
+
+vector f6() {
+  int i = 1;
+  return vector(i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {i};
+}
+
+auto v1 = []() { return vector({1, 2}); }();
+auto v2 = []() -> vector { return vector({1, 2}); }();
Index: docs/clang-tidy/checks/modernize-return-braced-init-list.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/modernize-return-braced-init-list.rst
@@ -0,0 +1,22 @@
+.. title:: clang-tidy - modernize-return-braced-init-list
+
+modernize-return-braced-init-list
+=
+
+Replaces explicit calls to the constructor in a return with a braced
+initializer list. This way the return type is not needlessly duplicated in the
+return type and the return statement.
+
+.. code:: c++
+
+  Foo bar() {
+Baz baz;
+return Foo(baz);
+  }
+
+  // transforms to:
+
+  Foo bar() {
+Baz baz;
+return {baz};
+  }
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -109,6 +109,7 @@
modernize-raw-string-literal
modernize-redundant-void-arg
modernize-replace-auto-ptr
+   modernize-return-braced-init-list
modernize-shrink-to-fit
modernize-use-auto
modernize-use-bool-literals
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,7 +57,11 @@
 Improvements to clang-tidy
 --
 
-The improvements are...
+- New `modernize-return-braced-init-list
+`_ check
+
+  Replaces explicit calls to the constructor in a return statement by a braced
+  initializer list so that the return type is not needlessly repeated.
 
 Improvements to include-fixer
 -
Index: clang-tidy/modernize/ReturnBracedInitListCheck.h
===
--- /dev/null
+++ clang-t

[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'

2017-01-16 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

In https://reviews.llvm.org/D28768#647333, @Prazek wrote:

> Thanks for the check. Have you run it on llvm?


Not yet, there was an issue with templated types and I wanted to fix that 
first. It's running now.


Repository:
  rL LLVM

https://reviews.llvm.org/D28768



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


[libcxx] r292152 - Make sym_check python 3 compatible

2017-01-16 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jan 16 13:52:58 2017
New Revision: 292152

URL: http://llvm.org/viewvc/llvm-project?rev=292152&view=rev
Log:
Make sym_check python 3 compatible

Modified:
libcxx/trunk/utils/sym_check/sym_check/util.py

Modified: libcxx/trunk/utils/sym_check/sym_check/util.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/sym_check/sym_check/util.py?rev=292152&r1=292151&r2=292152&view=diff
==
--- libcxx/trunk/utils/sym_check/sym_check/util.py (original)
+++ libcxx/trunk/utils/sym_check/sym_check/util.py Mon Jan 16 13:52:58 2017
@@ -14,6 +14,25 @@ import subprocess
 import sys
 import re
 
+def to_bytes(str):
+# Encode to UTF-8 to get binary data.
+if isinstance(str, bytes):
+return str
+return str.encode('utf-8')
+
+def to_string(bytes):
+if isinstance(bytes, str):
+return bytes
+return to_bytes(bytes)
+
+def convert_string(bytes):
+try:
+return to_string(bytes.decode('utf-8'))
+except AttributeError: # 'str' object has no attribute 'decode'.
+return str(bytes)
+except UnicodeError:
+return str(bytes)
+
 def execute_command(cmd, input_str=None):
 """
 Execute a command, capture and return its output.
@@ -28,6 +47,8 @@ def execute_command(cmd, input_str=None)
 exitCode = p.wait()
 if exitCode == -signal.SIGINT:
 raise KeyboardInterrupt
+out = convert_string(out)
+err = convert_string(err)
 return out, err, exitCode
 
 
@@ -105,13 +126,13 @@ def demangle_symbol(symbol):
 
 
 def is_elf(filename):
-with open(filename, 'r') as f:
+with open(filename, 'rb') as f:
 magic_bytes = f.read(4)
-return magic_bytes == '\x7fELF'
+return magic_bytes == b'\x7fELF'
 
 
 def is_mach_o(filename):
-with open(filename, 'r') as f:
+with open(filename, 'rb') as f:
 magic_bytes = f.read(4)
 return magic_bytes in [
 '\xfe\xed\xfa\xce',  # MH_MAGIC


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


[PATCH] D24991: Inline hot functions in libcxx shared_ptr implementation.

2017-01-16 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rL LLVM

https://reviews.llvm.org/D24991



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


Phabricator will be down for upgrading

2017-01-16 Thread Eric Liu via cfe-commits
Hi all,

Sorry about the short notice, but I am about to push an upgrade for
Phabricator. The upgrade might take a while (<30 mins hopefully).

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


[libcxx] r292157 - Improve CMake and LIT support for Windows

2017-01-16 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jan 16 14:47:35 2017
New Revision: 292157

URL: http://llvm.org/viewvc/llvm-project?rev=292157&view=rev
Log:
Improve CMake and LIT support for Windows

This patch contains multiple cleanups and fixes to better support building on
Windows.

* [Test] Fix handling of library runtime search paths by correctly adding them
  to the PATH variable when running the tests.

* [Test] Don't explicitly force "--target=i686-pc-windows" when running the
  test suite. Clang++ seems to deduce the correct target.

* [Test] Fix `.sh.cpp` tests on Windows by properly escaping flags used in
  shell commands. Specifically windows style paths which included spaces
  were causing these tests to fail.

* [CMake] Add "vcruntime" to the list of supported C++ ABI libraries in CMake, 
and
  teach the test suite how to handle it. For now libc++ defaults to using
  "vcruntime" on Windows except when libc++abi is in tree; That is probably
  a bug and should be changed to always use vcruntime, at least for now.

* [Misc] Move the "c++-build" include directory to the libc++ binary dir
  instead of the top level project dir and rename it "c++build". This is just
  misc cleanup. Libc++ shouldn't be creating internal build files and 
directories
  at the top-level projects root.

* [Misc] Build type_info's destructor when building for MSVC. This is a 
temporary
  work around to prevent link errors until we have a proper type_info
  implementation.

Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake
libcxx/trunk/src/typeinfo.cpp
libcxx/trunk/test/libcxx/test/config.py
libcxx/trunk/test/libcxx/test/format.py

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=292157&r1=292156&r2=292157&view=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Mon Jan 16 14:47:35 2017
@@ -104,7 +104,7 @@ endif()
 # ABI Library options -
 set(LIBCXX_CXX_ABI "default" CACHE STRING
 "Specify C++ ABI library to use.")
-set(CXXABIS none default libcxxabi libcxxrt libstdc++ libsupc++)
+set(CXXABIS none default libcxxabi libcxxrt libstdc++ libsupc++ vcruntime)
 set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS})
 
 # FIXME: This is a temporary hack to force LLVM buildbots to store
@@ -131,9 +131,9 @@ if (LIBCXX_CXX_ABI STREQUAL "default")
 set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}")
 set(LIBCXX_CXX_ABI_INTREE 1)
   else()
-if (WIN32 AND NOT MINGW)
+if (LIBCXX_TARGETING_MSVC)
   # FIXME: Figure out how to configure the ABI library on Windows.
-  set(LIBCXX_CXX_ABI_LIBNAME "none")
+  set(LIBCXX_CXX_ABI_LIBNAME "vcruntime")
 else()
   set(LIBCXX_CXX_ABI_LIBNAME "default")
 endif()
@@ -331,7 +331,9 @@ endif()
 set(LIBCXX_COMPILER${CMAKE_CXX_COMPILER})
 set(LIBCXX_SOURCE_DIR  ${CMAKE_CURRENT_SOURCE_DIR})
 set(LIBCXX_BINARY_DIR  ${CMAKE_CURRENT_BINARY_DIR})
+set(LIBCXX_BINARY_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++build")
 set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
+file(MAKE_DIRECTORY "${LIBCXX_BINARY_INCLUDE_DIR}")
 
 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR})
 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR})

Modified: libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake?rev=292157&r1=292156&r2=292157&view=diff
==
--- libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake (original)
+++ libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake Mon Jan 16 14:47:35 2017
@@ -18,6 +18,7 @@
 #   abidirs   : A list of relative paths to create under an include directory
 #   in the libc++ build directory.
 #
+
 macro(setup_abi_lib abidefines abilib abifiles abidirs)
   list(APPEND LIBCXX_COMPILE_FLAGS ${abidefines})
   set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_CXX_ABI_INCLUDE_PATHS}"
@@ -32,11 +33,10 @@ macro(setup_abi_lib abidefines abilib ab
   set(LIBCXX_ABILIB_FILES ${abifiles})
 
   # The place in the build tree where we store out-of-source headers.
-  set(LIBCXX_BUILD_HEADERS_ROOT "${CMAKE_BINARY_DIR}/include/c++-build")
   file(MAKE_DIRECTORY "${LIBCXX_BUILD_HEADERS_ROOT}")
   file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include/c++/v1")
   foreach(_d ${abidirs})
-file(MAKE_DIRECTORY "${LIBCXX_BUILD_HEADERS_ROOT}/${_d}")
+file(MAKE_DIRECTORY "${LIBCXX_BINARY_INCLUDE_DIR}/${_d}")
 file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include/c++/v1/${_d}")
   endforeach()
 
@@ -48,19 +48,19 @@ macro(setup_abi_lib abidefines abilib ab
 get_filename_component(dstdir ${fpath} PATH)
 get_filename_component(ifile ${fpath} NAME)
 file(COPY "${incpath}/${fpath

[PATCH] D28728: [libc++] Introduce _LIBCPP_EXTERN_VIS to fix __libcpp_debug_function link errors

2017-01-16 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D28728#646489, @smeenai wrote:

> This will need to be exported on other platforms too when hidden visibility 
> happens :)


Are you sure?I don't think "extern" variables are subject to visibility rules 
in GCC or Clang. At least I haven't
been able to generate a test case or even different assembly.

> Is it okay for these to be exported unconditionally, or should their 
> exporting be determined by `_LIBCPP_DEBUG`? This LGTM if it's the former.

Unconditionally. The declaration should already be `#ifdef`'ed out when 
libc++'s debug mode is not enabled.

I'm going to commit this as-is, and will address visibility issues on other 
platforms if needed.


https://reviews.llvm.org/D28728



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


[libcxx] r292158 - [libc++] Introduce _LIBCPP_EXTERN_VIS to fix __libcpp_debug_function link errors

2017-01-16 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jan 16 15:01:00 2017
New Revision: 292158

URL: http://llvm.org/viewvc/llvm-project?rev=292158&view=rev
Log:
[libc++] Introduce _LIBCPP_EXTERN_VIS to fix __libcpp_debug_function link errors

Summary: On Windows tests that use `_LIBCPP_ASSERT` fail to link because the 
assertion handler function isn't correctly exported from the libc++ dylib. This 
patch fixes the dll import/export issues by introducing a new visibility macro 
`_LIBCPP_EXTERN_VIS` for use on external variables.

Reviewers: compnerd, smeenai, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits

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

Modified:
libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst
libcxx/trunk/include/__config
libcxx/trunk/include/__debug

Modified: libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst?rev=292158&r1=292157&r2=292158&view=diff
==
--- libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst (original)
+++ libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst Mon Jan 16 15:01:00 2017
@@ -22,6 +22,12 @@ Visibility Macros
   Mark a symbol as being exported by the libc++ library. This attribute must
   be applied to the declaration of all functions exported by the libc++ dylib.
 
+**_LIBCPP_EXTERN_VIS**
+  Mark a symbol as being exported by the libc++ library. This attribute may
+  only be applied to objects defined in the libc++ library. On Windows this
+  macro applies `dllimport`/`dllexport` to the symbol. On all other platforms
+  this macro has no effect.
+
 **_LIBCPP_OVERRIDABLE_FUNC_VIS**
   Mark a symbol as being exported by the libc++ library, but allow it to be
   overridden locally. On non-Windows, this is equivalent to `_LIBCPP_FUNC_VIS`.

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=292158&r1=292157&r2=292158&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Mon Jan 16 15:01:00 2017
@@ -583,6 +583,7 @@ namespace std {
 
 #define _LIBCPP_TYPE_VIS_LIBCPP_DLL_VIS
 #define _LIBCPP_FUNC_VIS_LIBCPP_DLL_VIS
+#define _LIBCPP_EXTERN_VIS  _LIBCPP_DLL_VIS
 #define _LIBCPP_EXCEPTION_ABI   _LIBCPP_DLL_VIS
 #define _LIBCPP_HIDDEN
 #define _LIBCPP_TEMPLATE_VIS
@@ -636,6 +637,10 @@ namespace std {
 # define _LIBCPP_FUNC_VIS_ONLY _LIBCPP_FUNC_VIS
 #endif
 
+#ifndef _LIBCPP_EXTERN_VIS
+# define _LIBCPP_EXTERN_VIS
+#endif
+
 #ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
 # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS
 #endif

Modified: libcxx/trunk/include/__debug
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__debug?rev=292158&r1=292157&r2=292158&view=diff
==
--- libcxx/trunk/include/__debug (original)
+++ libcxx/trunk/include/__debug Mon Jan 16 15:01:00 2017
@@ -74,7 +74,7 @@ typedef void(*__libcpp_debug_function_ty
 
 /// __libcpp_debug_function - The handler function called when a _LIBCPP_ASSERT
 ///fails.
-extern __libcpp_debug_function_type __libcpp_debug_function;
+extern _LIBCPP_EXTERN_VIS __libcpp_debug_function_type __libcpp_debug_function;
 
 /// __libcpp_abort_debug_function - A debug handler that aborts when called.
 _LIBCPP_NORETURN _LIBCPP_FUNC_VIS


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


Re: Phabricator will be down for upgrading

2017-01-16 Thread Eric Liu via cfe-commits
Upgrade done. Phab is up again.

On Mon, Jan 16, 2017 at 9:36 PM Eric Liu  wrote:

> Hi all,
>
> Sorry about the short notice, but I am about to push an upgrade for
> Phabricator. The upgrade might take a while (<30 mins hopefully).
>
> Thanks,
> Eric
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D19201: [clang-tidy] misc-throw-with-noexcept

2017-01-16 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added inline comments.



Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.cpp:52-53
+  for (const auto &NoExceptRange : NoExceptRanges) {
+// FIXME use DiagnosticIDs::Level::Note
+diag(NoExceptRange.getBegin(), "In function declared no-throw here:")
+<< FixItHint::CreateRemoval(NoExceptRange);

just add DiagnosticIDs::Note as third argument
This might also change the order of diagnostics as we discussed ofline


https://reviews.llvm.org/D19201



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


[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'

2017-01-16 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added inline comments.



Comment at: test/clang-tidy/modernize-return-braced-init-list.cpp:95
+}
+
+vector f6() {

please also add test that contains 
for function
Type foo():

return call(Type());


return OtherType(Type()); // implicit conversion

It would also good to have test that already contain braces :)

return {};


Repository:
  rL LLVM

https://reviews.llvm.org/D28768



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


[libcxx] r292159 - Fix std::tuples EBO when targeting the MSVC ABI.

2017-01-16 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jan 16 15:15:08 2017
New Revision: 292159

URL: http://llvm.org/viewvc/llvm-project?rev=292159&view=rev
Log:
Fix std::tuples EBO when targeting the MSVC ABI.

MSVC/clang-cl doesn't do a full EBO unless __declspec(empty_bases)
is applied to the derived type. This causes certain tuple tests
to fail.

This patch adds the empty_bases attribute to __tuple_impl in order
for tuple to fully provide the EBO.

Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/tuple

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=292159&r1=292158&r2=292159&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Mon Jan 16 15:15:08 2017
@@ -100,6 +100,9 @@
 #ifndef __is_identifier
 #define __is_identifier(__x) 1
 #endif
+#ifndef __has_declspec_attribute
+#define __has_declspec_attribute(__x) 0
+#endif
 
 #define __has_keyword(__x) !(__is_identifier(__x))
 
@@ -1023,6 +1026,13 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 # define _LIBCPP_DIAGNOSE_ERROR(...)
 #endif
 
+#if defined(_LIBCPP_ABI_MICROSOFT) && \
+   (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases))
+# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
+#else
+# define _LIBCPP_DECLSPEC_EMPTY_BASES
+#endif
+
 #endif // __cplusplus
 
 #endif // _LIBCPP_CONFIG

Modified: libcxx/trunk/include/tuple
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/tuple?rev=292159&r1=292158&r2=292159&view=diff
==
--- libcxx/trunk/include/tuple (original)
+++ libcxx/trunk/include/tuple Mon Jan 16 15:15:08 2017
@@ -366,7 +366,7 @@ struct __all_default_constructible<__tup
 template struct __tuple_impl;
 
 template
-struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
+struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, 
_Tp...>
 : public __tuple_leaf<_Indx, _Tp>...
 {
 _LIBCPP_INLINE_VISIBILITY


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


[PATCH] D20660: Remove `auto_ptr` in C++17.

2017-01-16 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

> there's probably a better way to state `_LIBCPP_STD_VER <= 14 || 
> defined(_LIBCPP_NO_REMOVE_AUTO_PTR)`.

There probably is; but remember, we want to make it so someone can 
`-D_LIBCPP_NO_REMOVE_AUTO_PTR` on the command-line and get this back.

> I would love to have a semi-consistent naming scheme for macros which 
> re-enable removed C++17 features. Maybe `_LIBCPP_ENABLE_REMOVED_CXX17_FOO`

I like this: I'm using `_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR` now.




Comment at: test/libcxx/depr/depr.auto.ptr/auto.ptr/auto_ptr.cxx1z.pass.cpp:26
+{
+std::shared_ptr p;
+}

D'oh!  `auto_ptr`


https://reviews.llvm.org/D20660



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


[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'

2017-01-16 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere updated this revision to Diff 84589.
JDevlieghere added a comment.

- Don't replace explicit constructors
- Add @Prazek's suggested tests


Repository:
  rL LLVM

https://reviews.llvm.org/D28768

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/ReturnBracedInitListCheck.cpp
  clang-tidy/modernize/ReturnBracedInitListCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-return-braced-init-list.rst
  test/clang-tidy/modernize-return-braced-init-list.cpp

Index: test/clang-tidy/modernize-return-braced-init-list.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-return-braced-init-list.cpp
@@ -0,0 +1,132 @@
+// RUN: %check_clang_tidy %s modernize-return-braced-init-list %t -- --
+// -std=c++14
+
+namespace std {
+typedef decltype(sizeof(int)) size_t;
+
+// libc++'s implementation
+template 
+class initializer_list {
+  const _E *__begin_;
+  size_t __size_;
+
+  initializer_list(const _E *__b, size_t __s)
+  : __begin_(__b),
+__size_(__s) {}
+
+public:
+  typedef _E value_type;
+  typedef const _E &reference;
+  typedef const _E &const_reference;
+  typedef size_t size_type;
+
+  typedef const _E *iterator;
+  typedef const _E *const_iterator;
+
+  initializer_list() : __begin_(nullptr), __size_(0) {}
+
+  size_t size() const { return __size_; }
+  const _E *begin() const { return __begin_; }
+  const _E *end() const { return __begin_ + __size_; }
+};
+}
+
+class Bar {};
+
+class Foo {
+public:
+  Foo(Bar);
+  explicit Foo(Bar, int);
+};
+
+class Baz {
+public:
+  Foo m() {
+Bar b;
+return Foo(b);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+// CHECK-FIXES: return {b};
+  }
+};
+
+template 
+class vector {
+public:
+  vector(T){};
+  vector(std::initializer_list) {}
+};
+
+class Quux : public Foo {
+public:
+  Quux(Bar bar) : Foo(bar){};
+};
+
+Foo f() {
+  Bar b;
+  return Foo(b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {b};
+}
+
+Foo f2() {
+  Bar b;
+  return {b};
+}
+
+auto f3() {
+  Bar b;
+  return Foo(b);
+}
+
+#define A(b) Foo(b)
+
+Foo f4() {
+  Bar b;
+  return A(b);
+}
+
+Foo f5() {
+  Bar b;
+  return Quux(b);
+}
+
+Foo f6() {
+  Bar b;
+  return Foo(b, 1);
+}
+
+vector f7() {
+  int i = 1;
+  return vector(i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {i};
+}
+
+Bar f8 () {
+  return {};
+}
+
+Bar f9 () {
+  return Bar();
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {};
+}
+
+Foo f9 (Bar b) {
+  return Foo(b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {b};
+}
+
+Foo f10() {
+  return f9(Bar());
+}
+
+Foo f11() {
+  return Foo(Bar());
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {Bar()};
+}
+
+auto v1 = []() { return vector({1, 2}); }();
+auto v2 = []() -> vector { return vector({1, 2}); }();
Index: docs/clang-tidy/checks/modernize-return-braced-init-list.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/modernize-return-braced-init-list.rst
@@ -0,0 +1,22 @@
+.. title:: clang-tidy - modernize-return-braced-init-list
+
+modernize-return-braced-init-list
+=
+
+Replaces explicit calls to the constructor in a return with a braced
+initializer list. This way the return type is not needlessly duplicated in the
+return type and the return statement.
+
+.. code:: c++
+
+  Foo bar() {
+Baz baz;
+return Foo(baz);
+  }
+
+  // transforms to:
+
+  Foo bar() {
+Baz baz;
+return {baz};
+  }
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -109,6 +109,7 @@
modernize-raw-string-literal
modernize-redundant-void-arg
modernize-replace-auto-ptr
+   modernize-return-braced-init-list
modernize-shrink-to-fit
modernize-use-auto
modernize-use-bool-literals
Index: docs/ReleaseNotes.rst
===

[PATCH] D20660: Remove `auto_ptr` in C++17.

2017-01-16 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists updated this revision to Diff 84593.
mclow.lists added a comment.

Updated the macro name.
Use REQUIRES-ALL
Found a couple more tests that needed to be updated.
Fixed the libcxx/test bit.


https://reviews.llvm.org/D20660

Files:
  include/memory
  test/libcxx/depr/depr.auto.ptr/auto.ptr/auto_ptr.cxx1z.pass.cpp
  test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp
  test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp
  test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp
  test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp
  test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp
  
test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp
  
test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp
  
test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp
  
test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp
  test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp
  test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp
  test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp
  test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp
  test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp
  
test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp
  
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp
  
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp

Index: test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp
===
--- test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp
+++ test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp
@@ -10,6 +10,7 @@
 // 
 
 // template explicit shared_ptr(auto_ptr&& r);
+// REQUIRES-ANY: c++98, c++03 c++11, c++14
 
 
 #include 
Index: test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp
===
--- test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp
+++ test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp
@@ -10,6 +10,7 @@
 // 
 
 // shared_ptr
+// REQUIRES-ANY: c++98, c++03 c++11, c++14
 
 // template shared_ptr& operator=(auto_ptr&& r);
 
Index: test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp
===
--- test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp
+++ test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp
@@ -9,7 +9,7 @@
 
 // libc++ cannot safely provide the auto_ptr constructor without rvalue
 // references.
-// XFAIL: c++98, c++03
+// REQUIRES-ANY: c++11, c++14
 
 // 
 
Index: test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp
===
--- test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp
+++ test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp
@@ -17,6 +17,8 @@
 //   ...
 // };
 
+// REQUIRES-ANY: c++98, c++03, c++11, c++14
+
 #include 
 #include 
 
Index: test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp
===
--- test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp
+++ test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp
@@ -16,6 +16,8 @@
 #include 
 #include 
 
+// REQUIRES-ANY: c++98, c++03, c++11, c++14
+
 #include "../A.h"
 
 void
Index: test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp
===
--- test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp
+++ test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp
@@ -16,6 +16,8 @@
 #include 
 #include 
 
+// REQUIRES-ANY: c++98, c++03, c++11, c++14
+
 #include "../A.h"
 
 void
Index: test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp
===
--- test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp
+++ test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp
@@ -13,6 +13,8 @@
 
 // X& operator*() const throw();
 
+// REQUIRES-ANY: c++98, c++03, c++11, c++14
+
 #include 
 #include 
 
Index: test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.mem

[PATCH] D28779: [ASTReader] Add a DeserializationListener callback for IMPORTED_MODULES

2017-01-16 Thread Graydon Hoare via Phabricator via cfe-commits
graydon created this revision.

Add a callback from ASTReader to DeserializationListener when the former
reads an IMPORTED_MODULES block. This supports Swift in using PCH for
bridging headers.


https://reviews.llvm.org/D28779

Files:
  include/clang/Serialization/ASTDeserializationListener.h
  lib/Serialization/ASTReader.cpp


Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -3245,8 +3245,11 @@
 for (unsigned I = 0, N = Record.size(); I != N; /**/) {
   unsigned GlobalID = getGlobalSubmoduleID(F, Record[I++]);
   SourceLocation Loc = ReadSourceLocation(F, Record, I);
-  if (GlobalID)
+  if (GlobalID) {
 ImportedModules.push_back(ImportedSubmodule(GlobalID, Loc));
+if (DeserializationListener)
+  DeserializationListener->ModuleImportRead(GlobalID, Loc);
+  }
 }
   }
   break;
Index: include/clang/Serialization/ASTDeserializationListener.h
===
--- include/clang/Serialization/ASTDeserializationListener.h
+++ include/clang/Serialization/ASTDeserializationListener.h
@@ -26,6 +26,7 @@
 class MacroDefinitionRecord;
 class MacroInfo;
 class Module;
+class SourceLocation;
 
 class ASTDeserializationListener {
 public:
@@ -52,6 +53,9 @@
MacroDefinitionRecord *MD) {}
   /// \brief A module definition was read from the AST file.
   virtual void ModuleRead(serialization::SubmoduleID ID, Module *Mod) {}
+  /// \brief A module import was read from the AST file.
+  virtual void ModuleImportRead(serialization::SubmoduleID ID,
+SourceLocation ImportLoc) {}
 };
 }
 


Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -3245,8 +3245,11 @@
 for (unsigned I = 0, N = Record.size(); I != N; /**/) {
   unsigned GlobalID = getGlobalSubmoduleID(F, Record[I++]);
   SourceLocation Loc = ReadSourceLocation(F, Record, I);
-  if (GlobalID)
+  if (GlobalID) {
 ImportedModules.push_back(ImportedSubmodule(GlobalID, Loc));
+if (DeserializationListener)
+  DeserializationListener->ModuleImportRead(GlobalID, Loc);
+  }
 }
   }
   break;
Index: include/clang/Serialization/ASTDeserializationListener.h
===
--- include/clang/Serialization/ASTDeserializationListener.h
+++ include/clang/Serialization/ASTDeserializationListener.h
@@ -26,6 +26,7 @@
 class MacroDefinitionRecord;
 class MacroInfo;
 class Module;
+class SourceLocation;
 
 class ASTDeserializationListener {
 public:
@@ -52,6 +53,9 @@
MacroDefinitionRecord *MD) {}
   /// \brief A module definition was read from the AST file.
   virtual void ModuleRead(serialization::SubmoduleID ID, Module *Mod) {}
+  /// \brief A module import was read from the AST file.
+  virtual void ModuleImportRead(serialization::SubmoduleID ID,
+SourceLocation ImportLoc) {}
 };
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D28548: Improve include fixer's ranking by taking the paths into account.

2017-01-16 Thread Benjamin Kramer via cfe-commits
I got an email where it says that I accepted the revision. Looks like
phab didn't add cfe-commits to the list of recipients though :(

On Mon, Jan 16, 2017 at 6:43 PM, David Blaikie  wrote:
> Looks like Ben signed off on this on Phab - but the email didn't go to the
> list (making this look like code was sent for review, then committed,
> without review/approval happening)
>
> Ben: I think Phab doesn't send mail for an approval with no text, so at
> least as a workaround you can write something in the comments section when
> approving (people often write "LGTM" or similar) to ensure the approval is
> reflected on the mailing list.
>
> On Wed, Jan 11, 2017 at 1:59 AM Manuel Klimek via Phabricator via
> cfe-commits  wrote:
>>
>> klimek created this revision.
>> klimek added a reviewer: bkramer.
>> klimek added a subscriber: cfe-commits.
>>
>> Instead of just using popularity, we also take into account how similar
>> the
>> path of the current file is to the path of the header.
>> Our first approach is to get popularity into a reasonably small scale by
>> taking
>> log2 (which is roughly intuitive to how humans would bucket popularity),
>> and
>> multiply that with the number of matching prefix path fragments of the
>> included
>> header with the current file.
>> Note that currently we do not take special care for unclean paths
>> containing
>> "../" or "./".
>>
>>
>> https://reviews.llvm.org/D28548
>>
>> Files:
>>   include-fixer/IncludeFixer.cpp
>>   include-fixer/SymbolIndexManager.cpp
>>   include-fixer/SymbolIndexManager.h
>>   include-fixer/tool/ClangIncludeFixer.cpp
>>   test/include-fixer/Inputs/fake_yaml_db.yaml
>>   test/include-fixer/ranking.cpp
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28781: [OpenMP] Support for the if-clause on the combined directive 'target parallel'.

2017-01-16 Thread Arpith Jacob via Phabricator via cfe-commits
arpith-jacob created this revision.

The if-clause on the combined directive potentially applies to both the
'target' and the 'parallel' regions. Codegen'ing the if-clause on the
combined directive requires additional support because the expression in
the clause must be captured by the 'target' capture statement but not
the 'parallel' capture statement. Note that this situation arises for
other clauses such as num_threads.

The OMPIfClause class inherits OMPClauseWithPreInit to support capturing
of expressions in the clause. A member CaptureRegion is added to
OMPClauseWithPreInit to indicate the innermost captured statement (in this
case 'target' but not 'parallel') that captures these expressions.

To ensure correct codegen of captured expressions in the presence of
'parallel' combined with 'target', OMPParallelScope was added to 'parallel'
codegen.


https://reviews.llvm.org/D28781

Files:
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RecursiveASTVisitor.h
  lib/AST/OpenMPClause.cpp
  lib/AST/StmtProfile.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/target_parallel_if_codegen.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -2104,6 +2104,7 @@
 }
 
 void OMPClauseEnqueue::VisitOMPIfClause(const OMPIfClause *C) {
+  VisitOMPClauseWithPreInit(C);
   Visitor->AddStmt(C->getCondition());
 }
 
Index: test/OpenMP/target_parallel_if_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/target_parallel_if_codegen.cpp
@@ -0,0 +1,413 @@
+// Test host codegen.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-32
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix TCH

[PATCH] D28667: [clang-tidy] Don't modernize-raw-string-literal if replacement is longer.

2017-01-16 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: test/clang-tidy/modernize-raw-string-literal.cpp:94
 
+char const *const Concatenated("\"foo\""
+   "\"bar\"");

leanil wrote:
> alexfh wrote:
> > Does this test fail without the patch? Also, should there be a test 
> > covering the case where no replacement is made (and the current code issues 
> > a warning)?
> No, it doesn't. This is to check that MeasureTokenLength works as I expect. 
> It wouldn't warn if it measured the two parts separately.
> And I left the check here for those who may have the same concerns, although 
> it's indeed not the core functionality I test here. Should I remove it?
The test is fine, but it's better to add it as a separate patch. This patch 
needs proper tests of the new functionality.


https://reviews.llvm.org/D28667



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


[PATCH] D28785: Split exception.cpp implementation into different files for different runtimes

2017-01-16 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.

`exception.cpp` is a bloody mess. It's full of confusing `#ifdef` branches for 
each different ABI library we support, and it's getting unmaintainable.

This patch breaks down `exception.cpp` into multiple different header files, 
roughly one per implementation.


https://reviews.llvm.org/D28785

Files:
  src/exception.cpp
  src/support/runtime/exception_fallback.ipp
  src/support/runtime/exception_glibcxx.ipp
  src/support/runtime/exception_libcxxabi.ipp
  src/support/runtime/exception_libcxxrt.ipp
  src/support/runtime/exception_msvc.ipp
  src/support/runtime/exception_pointer_cxxabi.ipp
  src/support/runtime/exception_pointer_glibcxx.ipp
  src/support/runtime/exception_pointer_unimplemented.ipp

Index: src/support/runtime/exception_pointer_unimplemented.ipp
===
--- /dev/null
+++ src/support/runtime/exception_pointer_unimplemented.ipp
@@ -0,0 +1,80 @@
+// -*- C++ -*-
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+#include 
+#include 
+
+namespace std {
+
+exception_ptr::~exception_ptr() _NOEXCEPT
+{
+#  warning exception_ptr not yet implemented
+  fprintf(stderr, "exception_ptr not yet implemented\n");
+  ::abort();
+}
+
+exception_ptr::exception_ptr(const exception_ptr& other) _NOEXCEPT
+: __ptr_(other.__ptr_)
+{
+#  warning exception_ptr not yet implemented
+  fprintf(stderr, "exception_ptr not yet implemented\n");
+  ::abort();
+}
+
+exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT
+{
+#  warning exception_ptr not yet implemented
+  fprintf(stderr, "exception_ptr not yet implemented\n");
+  ::abort();
+}
+
+nested_exception::nested_exception() _NOEXCEPT
+: __ptr_(current_exception())
+{
+}
+
+#if !defined(__GLIBCXX__)
+
+nested_exception::~nested_exception() _NOEXCEPT
+{
+}
+
+#endif
+
+_LIBCPP_NORETURN
+void
+nested_exception::rethrow_nested() const
+{
+#  warning exception_ptr not yet implemented
+  fprintf(stderr, "exception_ptr not yet implemented\n");
+  ::abort();
+#if 0
+  if (__ptr_ == nullptr)
+  terminate();
+  rethrow_exception(__ptr_);
+#endif // FIXME
+}
+
+exception_ptr current_exception() _NOEXCEPT
+{
+#  warning exception_ptr not yet implemented
+  fprintf(stderr, "exception_ptr not yet implemented\n");
+  ::abort();
+}
+
+_LIBCPP_NORETURN
+void rethrow_exception(exception_ptr p)
+{
+#  warning exception_ptr not yet implemented
+  fprintf(stderr, "exception_ptr not yet implemented\n");
+  ::abort();
+}
+
+} // namespace std
Index: src/support/runtime/exception_pointer_glibcxx.ipp
===
--- /dev/null
+++ src/support/runtime/exception_pointer_glibcxx.ipp
@@ -0,0 +1,74 @@
+// -*- C++ -*-
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// libsupc++ does not implement the dependent EH ABI and the functionality
+// it uses to implement std::exception_ptr (which it declares as an alias of
+// std::__exception_ptr::exception_ptr) is not directly exported to clients. So
+// we have little choice but to hijack std::__exception_ptr::exception_ptr's
+// (which fortunately has the same layout as our std::exception_ptr) copy
+// constructor, assignment operator and destructor (which are part of its
+// stable ABI), and its rethrow_exception(std::__exception_ptr::exception_ptr)
+// function.
+
+namespace __exception_ptr
+{
+
+struct exception_ptr
+{
+void* __ptr_;
+
+exception_ptr(const exception_ptr&) _NOEXCEPT;
+exception_ptr& operator=(const exception_ptr&) _NOEXCEPT;
+~exception_ptr() _NOEXCEPT;
+};
+
+}
+
+_LIBCPP_NORETURN void rethrow_exception(__exception_ptr::exception_ptr);
+
+exception_ptr::~exception_ptr() _NOEXCEPT
+{
+reinterpret_cast<__exception_ptr::exception_ptr*>(this)->~exception_ptr();
+}
+
+exception_ptr::exception_ptr(const exception_ptr& other) _NOEXCEPT
+: __ptr_(other.__ptr_)
+{
+new (reinterpret_cast(this)) __exception_ptr::exception_ptr(
+reinterpret_cast(other));
+}
+
+exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT
+{
+*reinterpret_cast<__exception_ptr::exception_ptr*>(this) =
+reinterpret_cast(other);
+return *this;
+}
+
+nested_exception::nested_exception() _NOEXCEPT
+: __ptr_(current_exception())
+{
+}
+
+
+_LIBCPP_NORETURN
+void
+nested_exception::rethrow_nested()

[PATCH] D28788: [AST] AttributedType should derive type properties from the EquivalentType

2017-01-16 Thread David Majnemer via Phabricator via cfe-commits
majnemer created this revision.

Using the canonical type instead of the equivalent type can result in
insufficient template instantiations.

This fixes PR31656.


https://reviews.llvm.org/D28788

Files:
  include/clang/AST/Type.h
  test/CodeGenCXX/microsoft-abi-default-cc.cpp


Index: test/CodeGenCXX/microsoft-abi-default-cc.cpp
===
--- test/CodeGenCXX/microsoft-abi-default-cc.cpp
+++ test/CodeGenCXX/microsoft-abi-default-cc.cpp
@@ -45,3 +45,12 @@
 void static_qux() {}
 // GCABI-LABEL: define void @_Z10static_quxv
 // MSABI: define void @"\01?static_qux@@YAXXZ"
+
+namespace PR31656 {
+template 
+void __cdecl callee(int args[I]);
+// GCABI-LABEL: declare void @_ZN7PR316566calleeILi1EEEvPi(
+// MSABI: declare void @"\01??$callee@$00@PR31656@@YAXQAH@Z"(
+
+void caller() { callee<1>(0); }
+}
Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -3827,13 +3827,13 @@
 
   friend class ASTContext; // creates these
 
-  AttributedType(QualType canon, Kind attrKind,
- QualType modified, QualType equivalent)
-: Type(Attributed, canon, canon->isDependentType(),
-   canon->isInstantiationDependentType(),
-   canon->isVariablyModifiedType(),
-   canon->containsUnexpandedParameterPack()),
-  ModifiedType(modified), EquivalentType(equivalent) {
+  AttributedType(QualType canon, Kind attrKind, QualType modified,
+ QualType equivalent)
+  : Type(Attributed, canon, equivalent->isDependentType(),
+ equivalent->isInstantiationDependentType(),
+ equivalent->isVariablyModifiedType(),
+ equivalent->containsUnexpandedParameterPack()),
+ModifiedType(modified), EquivalentType(equivalent) {
 AttributedTypeBits.AttrKind = attrKind;
   }
 


Index: test/CodeGenCXX/microsoft-abi-default-cc.cpp
===
--- test/CodeGenCXX/microsoft-abi-default-cc.cpp
+++ test/CodeGenCXX/microsoft-abi-default-cc.cpp
@@ -45,3 +45,12 @@
 void static_qux() {}
 // GCABI-LABEL: define void @_Z10static_quxv
 // MSABI: define void @"\01?static_qux@@YAXXZ"
+
+namespace PR31656 {
+template 
+void __cdecl callee(int args[I]);
+// GCABI-LABEL: declare void @_ZN7PR316566calleeILi1EEEvPi(
+// MSABI: declare void @"\01??$callee@$00@PR31656@@YAXQAH@Z"(
+
+void caller() { callee<1>(0); }
+}
Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -3827,13 +3827,13 @@
 
   friend class ASTContext; // creates these
 
-  AttributedType(QualType canon, Kind attrKind,
- QualType modified, QualType equivalent)
-: Type(Attributed, canon, canon->isDependentType(),
-   canon->isInstantiationDependentType(),
-   canon->isVariablyModifiedType(),
-   canon->containsUnexpandedParameterPack()),
-  ModifiedType(modified), EquivalentType(equivalent) {
+  AttributedType(QualType canon, Kind attrKind, QualType modified,
+ QualType equivalent)
+  : Type(Attributed, canon, equivalent->isDependentType(),
+ equivalent->isInstantiationDependentType(),
+ equivalent->isVariablyModifiedType(),
+ equivalent->containsUnexpandedParameterPack()),
+ModifiedType(modified), EquivalentType(equivalent) {
 AttributedTypeBits.AttrKind = attrKind;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r292174 - clang-format: Make GetStyle return Expected instead of FormatStyle

2017-01-16 Thread Antonio Maiorano via cfe-commits
Author: amaiorano
Date: Mon Jan 16 18:12:27 2017
New Revision: 292174

URL: http://llvm.org/viewvc/llvm-project?rev=292174&view=rev
Log:
clang-format: Make GetStyle return Expected instead of FormatStyle

Change the contract of GetStyle so that it returns an error when an error occurs
(i.e. when it writes to stderr), and only returns the fallback style when it
can't find a configuration file.

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

Modified:
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Tooling/Refactoring.cpp
cfe/trunk/test/Format/style-on-command-line.cpp
cfe/trunk/tools/clang-format/ClangFormat.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
cfe/trunk/unittests/Format/FormatTestObjC.cpp

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=292174&r1=292173&r2=292174&view=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Mon Jan 16 18:12:27 2017
@@ -853,17 +853,19 @@ extern const char *StyleOptionHelpDescri
 /// \param[in] FileName Path to start search for .clang-format if ``StyleName``
 /// == "file".
 /// \param[in] FallbackStyle The name of a predefined style used to fallback to
-/// in case the style can't be determined from \p StyleName.
+/// in case \p StyleName is "file" and no file can be found.
 /// \param[in] Code The actual code to be formatted. Used to determine the
 /// language if the filename isn't sufficient.
 /// \param[in] FS The underlying file system, in which the file resides. By
 /// default, the file system is the real file system.
 ///
-/// \returns FormatStyle as specified by ``StyleName``. If no style could be
-/// determined, the default is LLVM Style (see ``getLLVMStyle()``).
-FormatStyle getStyle(StringRef StyleName, StringRef FileName,
- StringRef FallbackStyle, StringRef Code = "",
- vfs::FileSystem *FS = nullptr);
+/// \returns FormatStyle as specified by ``StyleName``. If ``StyleName`` is
+/// "file" and no file is found, returns ``FallbackStyle``. If no style could 
be
+/// determined, returns an Error.
+llvm::Expected getStyle(StringRef StyleName, StringRef FileName,
+ StringRef FallbackStyle,
+ StringRef Code = "",
+ vfs::FileSystem *FS = nullptr);
 
 // \brief Returns a string representation of ``Language``.
 inline StringRef getLanguageName(FormatStyle::LanguageKind Language) {

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=292174&r1=292173&r2=292174&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Mon Jan 16 18:12:27 2017
@@ -421,6 +421,11 @@ std::error_code make_error_code(ParseErr
   return std::error_code(static_cast(e), getParseCategory());
 }
 
+inline llvm::Error make_string_error(const llvm::Twine &Message) {
+  return llvm::make_error(Message,
+ llvm::inconvertibleErrorCode());
+}
+
 const char *ParseErrorCategory::name() const noexcept {
   return "clang-format.parse_error";
 }
@@ -1882,9 +1887,9 @@ static FormatStyle::LanguageKind getLang
   return FormatStyle::LK_Cpp;
 }
 
-FormatStyle getStyle(StringRef StyleName, StringRef FileName,
- StringRef FallbackStyle, StringRef Code,
- vfs::FileSystem *FS) {
+llvm::Expected getStyle(StringRef StyleName, StringRef FileName,
+ StringRef FallbackStyle, StringRef Code,
+ vfs::FileSystem *FS) {
   if (!FS) {
 FS = vfs::getRealFileSystem().get();
   }
@@ -1898,35 +1903,28 @@ FormatStyle getStyle(StringRef StyleName
   (Code.contains("\n- (") || Code.contains("\n+ (")))
 Style.Language = FormatStyle::LK_ObjC;
 
-  if (!getPredefinedStyle(FallbackStyle, Style.Language, &Style)) {
-llvm::errs() << "Invalid fallback style \"" << FallbackStyle
- << "\" using LLVM style\n";
-return Style;
-  }
+  // FIXME: If FallbackStyle is explicitly "none", format is disabled.
+  if (!getPredefinedStyle(FallbackStyle, Style.Language, &Style))
+return make_string_error("Invalid fallback style \"" + 
FallbackStyle.str());
 
   if (StyleName.startswith("{")) {
 // Parse YAML/JSON style from the command line.
-if (std::error_code ec = parseConfiguration(StyleName, &Style)) {
-  llvm::errs() << "Error parsing -style: " << ec.message() << ", using "
-   << FallbackStyle << " style\n";
-}
+if (std::error_code ec = parseConfiguration(StyleName, &Style))
+  return make_string_error(

[PATCH] D28081: Make GetStyle return Expected instead of FormatStyle

2017-01-16 Thread Antonio Maiorano via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292174: clang-format: Make GetStyle return 
Expected instead of FormatStyle (authored by amaiorano).

Changed prior to commit:
  https://reviews.llvm.org/D28081?vs=84538&id=84610#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28081

Files:
  cfe/trunk/include/clang/Format/Format.h
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/lib/Tooling/Refactoring.cpp
  cfe/trunk/test/Format/style-on-command-line.cpp
  cfe/trunk/tools/clang-format/ClangFormat.cpp
  cfe/trunk/unittests/Format/FormatTest.cpp
  cfe/trunk/unittests/Format/FormatTestObjC.cpp

Index: cfe/trunk/include/clang/Format/Format.h
===
--- cfe/trunk/include/clang/Format/Format.h
+++ cfe/trunk/include/clang/Format/Format.h
@@ -853,17 +853,19 @@
 /// \param[in] FileName Path to start search for .clang-format if ``StyleName``
 /// == "file".
 /// \param[in] FallbackStyle The name of a predefined style used to fallback to
-/// in case the style can't be determined from \p StyleName.
+/// in case \p StyleName is "file" and no file can be found.
 /// \param[in] Code The actual code to be formatted. Used to determine the
 /// language if the filename isn't sufficient.
 /// \param[in] FS The underlying file system, in which the file resides. By
 /// default, the file system is the real file system.
 ///
-/// \returns FormatStyle as specified by ``StyleName``. If no style could be
-/// determined, the default is LLVM Style (see ``getLLVMStyle()``).
-FormatStyle getStyle(StringRef StyleName, StringRef FileName,
- StringRef FallbackStyle, StringRef Code = "",
- vfs::FileSystem *FS = nullptr);
+/// \returns FormatStyle as specified by ``StyleName``. If ``StyleName`` is
+/// "file" and no file is found, returns ``FallbackStyle``. If no style could be
+/// determined, returns an Error.
+llvm::Expected getStyle(StringRef StyleName, StringRef FileName,
+ StringRef FallbackStyle,
+ StringRef Code = "",
+ vfs::FileSystem *FS = nullptr);
 
 // \brief Returns a string representation of ``Language``.
 inline StringRef getLanguageName(FormatStyle::LanguageKind Language) {
Index: cfe/trunk/test/Format/style-on-command-line.cpp
===
--- cfe/trunk/test/Format/style-on-command-line.cpp
+++ cfe/trunk/test/Format/style-on-command-line.cpp
@@ -1,11 +1,11 @@
 // RUN: clang-format -style="{BasedOnStyle: Google, IndentWidth: 8}" %s | FileCheck -strict-whitespace -check-prefix=CHECK1 %s
 // RUN: clang-format -style="{BasedOnStyle: LLVM, IndentWidth: 7}" %s | FileCheck -strict-whitespace -check-prefix=CHECK2 %s
-// RUN: clang-format -style="{BasedOnStyle: invalid, IndentWidth: 7}" -fallback-style=LLVM %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK3 %s
-// RUN: clang-format -style="{lsjd}" %s -fallback-style=LLVM 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK4 %s
+// RUN: not clang-format -style="{BasedOnStyle: invalid, IndentWidth: 7}" -fallback-style=LLVM %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK3 %s
+// RUN: not clang-format -style="{lsjd}" %s -fallback-style=LLVM 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK4 %s
 // RUN: printf "BasedOnStyle: google\nIndentWidth: 5\n" > %T/.clang-format
 // RUN: clang-format -style=file -assume-filename=%T/foo.cpp < %s | FileCheck -strict-whitespace -check-prefix=CHECK5 %s
 // RUN: printf "\n" > %T/.clang-format
-// RUN: clang-format -style=file -fallback-style=webkit -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK6 %s
+// RUN: not clang-format -style=file -fallback-style=webkit -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK6 %s
 // RUN: rm %T/.clang-format
 // RUN: printf "BasedOnStyle: google\nIndentWidth: 6\n" > %T/_clang-format
 // RUN: clang-format -style=file -assume-filename=%T/foo.cpp < %s | FileCheck -strict-whitespace -check-prefix=CHECK7 %s
@@ -15,13 +15,10 @@
 // CHECK1: {{^int\* i;$}}
 // CHECK2: {{^   int \*i;$}}
 // CHECK3: Unknown value for BasedOnStyle: invalid
-// CHECK3: Error parsing -style: {{I|i}}nvalid argument, using LLVM style
-// CHECK3: {{^  int \*i;$}}
-// CHECK4: Error parsing -style: {{I|i}}nvalid argument, using LLVM style
-// CHECK4: {{^  int \*i;$}}
+// CHECK3: Error parsing -style: {{I|i}}nvalid argument
+// CHECK4: Error parsing -style: {{I|i}}nvalid argument
 // CHECK5: {{^ int\* i;$}}
 // CHECK6: {{^Error reading .*\.clang-format: (I|i)nvalid argument}}
-// CHECK6: {{^int\* i;$}}
 // CHECK7: {{^  int\* i;$}}
 // CHECK8: {{^  int\* i;$}}
 // CHECK9: {{^int \*i;$}}
Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/For

[clang-tools-extra] r292175 - Update tools to use new getStyle API

2017-01-16 Thread Antonio Maiorano via cfe-commits
Author: amaiorano
Date: Mon Jan 16 18:13:32 2017
New Revision: 292175

URL: http://llvm.org/viewvc/llvm-project?rev=292175&view=rev
Log:
Update tools to use new getStyle API

Depends on https://reviews.llvm.org/D28081

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

Modified:
clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp

clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
clang-tools-extra/trunk/clang-move/ClangMove.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp

Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp?rev=292175&r1=292174&r2=292175&view=diff
==
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp (original)
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Mon Jan 16 
18:13:32 2017
@@ -883,11 +883,14 @@ void ChangeNamespaceTool::onEndOfTransla
 // Add replacements referring to the changed code to existing replacements,
 // which refers to the original code.
 Replaces = Replaces.merge(NewReplacements);
-format::FormatStyle Style =
-format::getStyle("file", FilePath, FallbackStyle);
+auto Style = format::getStyle("file", FilePath, FallbackStyle);
+if (!Style) {
+  llvm::errs() << llvm::toString(Style.takeError()) << "\n";
+  continue;
+}
 // Clean up old namespaces if there is nothing in it after moving.
 auto CleanReplacements =
-format::cleanupAroundReplacements(Code, Replaces, Style);
+format::cleanupAroundReplacements(Code, Replaces, *Style);
 if (!CleanReplacements) {
   llvm::errs() << llvm::toString(CleanReplacements.takeError()) << "\n";
   continue;

Modified: 
clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp?rev=292175&r1=292174&r2=292175&view=diff
==
--- 
clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
 Mon Jan 16 18:13:32 2017
@@ -208,8 +208,15 @@ int main(int argc, char **argv) {
 
   // Determine a formatting style from options.
   format::FormatStyle FormatStyle;
-  if (DoFormat)
-FormatStyle = format::getStyle(FormatStyleOpt, FormatStyleConfig, "LLVM");
+  if (DoFormat) {
+auto FormatStyleOrError =
+format::getStyle(FormatStyleOpt, FormatStyleConfig, "LLVM");
+if (!FormatStyleOrError) {
+  llvm::errs() << llvm::toString(FormatStyleOrError.takeError()) << "\n";
+  return 1;
+}
+FormatStyle = *FormatStyleOrError;
+  }
 
   TUReplacements TURs;
   TUReplacementFiles TUFiles;

Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=292175&r1=292174&r2=292175&view=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Mon Jan 16 18:13:32 2017
@@ -742,10 +742,13 @@ void ClangMoveTool::removeDeclsInOldFile
 // Ignore replacements for new.h/cc.
 if (SI == FilePathToFileID.end()) continue;
 llvm::StringRef Code = SM.getBufferData(SI->second);
-format::FormatStyle Style =
-format::getStyle("file", FilePath, Context->FallbackStyle);
+auto Style = format::getStyle("file", FilePath, Context->FallbackStyle);
+if (!Style) {
+  llvm::errs() << llvm::toString(Style.takeError()) << "\n";
+  continue;
+}
 auto CleanReplacements = format::cleanupAroundReplacements(
-Code, Context->FileToReplacements[FilePath], Style);
+Code, Context->FileToReplacements[FilePath], *Style);
 
 if (!CleanReplacements) {
   llvm::errs() << llvm::toString(CleanReplacements.takeError()) << "\n";

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=292175&r1=292174&r2=292175&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Mon Jan 16 18:13:32 2017
@@ -197,10 +197,14 @@ public:
   continue;
 }
 StringRef Code = Buffer.get()->getBuffer();
-format::FormatStyle Style = format::getStyle("file", File, 
FormatStyle);
+auto Style = format::getStyle("file", File, FormatStyle);
+

[PATCH] D28315: Update tools to use new getStyle API

2017-01-16 Thread Antonio Maiorano via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292175: Update tools to use new getStyle API (authored by 
amaiorano).

Changed prior to commit:
  https://reviews.llvm.org/D28315?vs=84539&id=84611#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28315

Files:
  clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
  
clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
  clang-tools-extra/trunk/clang-move/ClangMove.cpp
  clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
  clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp

Index: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
===
--- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
+++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
@@ -303,10 +303,13 @@
const IncludeFixerContext::HeaderInfo &RHS) {
   return LHS.QualifiedName == RHS.QualifiedName;
 });
-format::FormatStyle InsertStyle =
-format::getStyle("file", Context.getFilePath(), Style);
+auto InsertStyle = format::getStyle("file", Context.getFilePath(), Style);
+if (!InsertStyle) {
+  llvm::errs() << llvm::toString(InsertStyle.takeError()) << "\n";
+  return 1;
+}
 auto Replacements = clang::include_fixer::createIncludeFixerReplacements(
-Code->getBuffer(), Context, InsertStyle,
+Code->getBuffer(), Context, *InsertStyle,
 /*AddQualifiers=*/IsUniqueQualifiedName);
 if (!Replacements) {
   errs() << "Failed to create replacements: "
@@ -378,16 +381,20 @@
   std::vector FixerReplacements;
   for (const auto &Context : Contexts) {
 StringRef FilePath = Context.getFilePath();
-format::FormatStyle InsertStyle = format::getStyle("file", FilePath, Style);
+auto InsertStyle = format::getStyle("file", FilePath, Style);
+if (!InsertStyle) {
+  llvm::errs() << llvm::toString(InsertStyle.takeError()) << "\n";
+  return 1;
+}
 auto Buffer = llvm::MemoryBuffer::getFile(FilePath);
 if (!Buffer) {
   errs() << "Couldn't open file: " + FilePath.str() + ": "
  << Buffer.getError().message() + "\n";
   return 1;
 }
 
 auto Replacements = clang::include_fixer::createIncludeFixerReplacements(
-Buffer.get()->getBuffer(), Context, InsertStyle);
+Buffer.get()->getBuffer(), Context, *InsertStyle);
 if (!Replacements) {
   errs() << "Failed to create replacement: "
  << llvm::toString(Replacements.takeError()) << "\n";
Index: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
===
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
@@ -197,10 +197,14 @@
   continue;
 }
 StringRef Code = Buffer.get()->getBuffer();
-format::FormatStyle Style = format::getStyle("file", File, FormatStyle);
+auto Style = format::getStyle("file", File, FormatStyle);
+if (!Style) {
+  llvm::errs() << llvm::toString(Style.takeError()) << "\n";
+  continue;
+}
 llvm::Expected CleanReplacements =
 format::cleanupAroundReplacements(Code, FileAndReplacements.second,
-  Style);
+  *Style);
 if (!CleanReplacements) {
   llvm::errs() << llvm::toString(CleanReplacements.takeError()) << "\n";
   continue;
Index: clang-tools-extra/trunk/clang-move/ClangMove.cpp
===
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp
@@ -742,10 +742,13 @@
 // Ignore replacements for new.h/cc.
 if (SI == FilePathToFileID.end()) continue;
 llvm::StringRef Code = SM.getBufferData(SI->second);
-format::FormatStyle Style =
-format::getStyle("file", FilePath, Context->FallbackStyle);
+auto Style = format::getStyle("file", FilePath, Context->FallbackStyle);
+if (!Style) {
+  llvm::errs() << llvm::toString(Style.takeError()) << "\n";
+  continue;
+}
 auto CleanReplacements = format::cleanupAroundReplacements(
-Code, Context->FileToReplacements[FilePath], Style);
+Code, Context->FileToReplacements[FilePath], *Style);
 
 if (!CleanReplacements) {
   llvm::errs() << llvm::toString(CleanReplacements.takeError()) << "\n";
Index: clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
===
--- clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
+++ clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
@@ -208,8 +208,15 @@
 
   // Dete

[libcxx] r292177 - Rename new_handler in tests to avoid conflicts with MSVC symbols.

2017-01-16 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jan 16 18:32:08 2017
New Revision: 292177

URL: http://llvm.org/viewvc/llvm-project?rev=292177&view=rev
Log:
Rename new_handler in tests to avoid conflicts with MSVC symbols.

On Windows the header new.h defines "new_handler" in the global
namespace.

Modified:

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp?rev=292177&r1=292176&r2=292177&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
 Mon Jan 16 18:32:08 2017
@@ -29,7 +29,7 @@ constexpr auto OverAligned = alignof(std
 
 int new_handler_called = 0;
 
-void new_handler()
+void my_new_handler()
 {
 ++new_handler_called;
 std::set_new_handler(0);
@@ -44,7 +44,7 @@ struct alignas(OverAligned) A
 };
 
 void test_max_alloc() {
-std::set_new_handler(new_handler);
+std::set_new_handler(my_new_handler);
 auto do_test = []() {
 void* vp = operator new [](std::numeric_limits::max(),
  std::align_val_t(OverAligned),

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp?rev=292177&r1=292176&r2=292177&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
 Mon Jan 16 18:32:08 2017
@@ -21,7 +21,7 @@
 
 int new_handler_called = 0;
 
-void new_handler()
+void my_new_handler()
 {
 ++new_handler_called;
 std::set_new_handler(0);
@@ -38,7 +38,7 @@ struct A
 int main()
 {
 #ifndef TEST_HAS_NO_EXCEPTIONS
-std::set_new_handler(new_handler);
+std::set_new_handler(my_new_handler);
 try
 {
 void* volatile vp = operator new[] 
(std::numeric_limits::max());

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp?rev=292177&r1=292176&r2=292177&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
 Mon Jan 16 18:32:08 2017
@@ -21,7 +21,7 @@
 
 int new_handler_called = 0;
 
-void new_handler()
+void my_new_handler()
 {
 ++new_handler_called;
 std::set_new_handler(0);
@@ -37,7 +37,7 @@ struct A
 
 int main()
 {
-std::set_new_handler(new_handler);
+std::set_new_handler(my_new_handler);
 #ifndef TEST_HAS_NO_EXCEPTIONS
 try
 #endif

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp?rev=292177&r1=292176&r2=292177&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
 Mon Jan 16 18:32:08 2017
@@ -21,7 +21,7 @@
 
 int new_handler_called = 0;
 
-void new_handler()
+void my_new_hand

[PATCH] D28785: Split exception.cpp and new.cpp implementation into different files for different runtimes

2017-01-16 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 84613.
EricWF retitled this revision from "Split exception.cpp implementation into 
different files for different runtimes" to "Split exception.cpp and new.cpp 
implementation into different files for different runtimes".
EricWF edited the summary of this revision.
EricWF added a comment.

- Cleanup `new.cpp` as well.

- Implement `typeinfo` on MSVC.


https://reviews.llvm.org/D28785

Files:
  include/exception
  include/new
  include/typeinfo
  src/exception.cpp
  src/new.cpp
  src/support/runtime/exception_fallback.ipp
  src/support/runtime/exception_glibcxx.ipp
  src/support/runtime/exception_libcxxabi.ipp
  src/support/runtime/exception_libcxxrt.ipp
  src/support/runtime/exception_msvc.ipp
  src/support/runtime/exception_pointer_cxxabi.ipp
  src/support/runtime/exception_pointer_glibcxx.ipp
  src/support/runtime/exception_pointer_unimplemented.ipp
  src/support/runtime/new_handler_fallback.ipp
  src/typeinfo.cpp

Index: src/typeinfo.cpp
===
--- src/typeinfo.cpp
+++ src/typeinfo.cpp
@@ -6,74 +6,11 @@
 // Source Licenses. See LICENSE.TXT for details.
 //
 //===--===//
-#include 
-
-#if !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) && \
-(defined(__APPLE__) || defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI))
-#include 
-#endif
 
 #include "typeinfo"
 
-#if defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) || \
-defined(_LIBCPP_ABI_MICROSOFT) // FIXME: This is a temporary workaround
+#if defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY)
 std::type_info::~type_info()
 {
 }
 #endif
-
-#if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION)
-
-std::bad_cast::bad_cast() _NOEXCEPT
-{
-}
-
-std::bad_typeid::bad_typeid() _NOEXCEPT
-{
-}
-
-#ifndef __GLIBCXX__
-
-std::bad_cast::~bad_cast() _NOEXCEPT
-{
-}
-
-const char*
-std::bad_cast::what() const _NOEXCEPT
-{
-  return "std::bad_cast";
-}
-
-std::bad_typeid::~bad_typeid() _NOEXCEPT
-{
-}
-
-const char*
-std::bad_typeid::what() const _NOEXCEPT
-{
-  return "std::bad_typeid";
-}
-
-#if defined(__APPLE__) && !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY)
-  // On Darwin, the cxa_bad_* functions cannot be in the lower level library
-  // because bad_cast and bad_typeid are defined in his higher level library
-  void __cxxabiv1::__cxa_bad_typeid()
-  {
-#ifndef _LIBCPP_NO_EXCEPTIONS
- throw std::bad_typeid();
-#else
- _VSTD::abort();
-#endif
-  }
-  void __cxxabiv1::__cxa_bad_cast()
-  {
-#ifndef _LIBCPP_NO_EXCEPTIONS
-  throw std::bad_cast();
-#else
-  _VSTD::abort();
-#endif
-  }
-#endif
-
-#endif  // !__GLIBCXX__
-#endif  // !LIBCXXRT && !_LIBCPPABI_VERSION
Index: src/support/runtime/new_handler_fallback.ipp
===
--- /dev/null
+++ src/support/runtime/new_handler_fallback.ipp
@@ -0,0 +1,27 @@
+// -*- C++ -*-
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+namespace std {
+
+_LIBCPP_SAFE_STATIC static std::new_handler __new_handler;
+
+new_handler
+set_new_handler(new_handler handler) _NOEXCEPT
+{
+return __sync_lock_test_and_set(&__new_handler, handler);
+}
+
+new_handler
+get_new_handler() _NOEXCEPT
+{
+return __sync_fetch_and_add(&__new_handler, nullptr);
+}
+
+} // namespace std
Index: src/support/runtime/exception_pointer_unimplemented.ipp
===
--- /dev/null
+++ src/support/runtime/exception_pointer_unimplemented.ipp
@@ -0,0 +1,80 @@
+// -*- C++ -*-
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+#include 
+#include 
+
+namespace std {
+
+exception_ptr::~exception_ptr() _NOEXCEPT
+{
+#  warning exception_ptr not yet implemented
+  fprintf(stderr, "exception_ptr not yet implemented\n");
+  ::abort();
+}
+
+exception_ptr::exception_ptr(const exception_ptr& other) _NOEXCEPT
+: __ptr_(other.__ptr_)
+{
+#  warning exception_ptr not yet implemented
+  fprintf(stderr, "exception_ptr not yet implemented\n");
+  ::abort();
+}
+
+exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT
+{
+#  warning exception_ptr not yet implemented
+  fprintf(stderr, "exception_ptr not yet implemented\n");
+  ::abort();
+}
+
+nested_exception::nested_exception() _NOEXCEPT
+: __ptr_(current_exception())
+{
+}
+
+#if

[libcxx] r292181 - Add warning messages to buildit/testit about their upcoming removal

2017-01-16 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Jan 16 19:16:44 2017
New Revision: 292181

URL: http://llvm.org/viewvc/llvm-project?rev=292181&view=rev
Log:
Add warning messages to buildit/testit about their upcoming removal

Modified:
libcxx/trunk/lib/buildit
libcxx/trunk/test/testit

Modified: libcxx/trunk/lib/buildit
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/buildit?rev=292181&r1=292180&r2=292181&view=diff
==
--- libcxx/trunk/lib/buildit (original)
+++ libcxx/trunk/lib/buildit Mon Jan 16 19:16:44 2017
@@ -6,6 +6,11 @@
 
 set -e
 
+echo "-- WARNING --"
+echo "buildit is no longer supported and will be removed in the next week!"
+echo "please contact the libc++ maintainers if you have any concerns"
+echo ""
+
 if [ `basename $(pwd)` != "lib" ]
 then
 echo "current directory must be lib"
@@ -177,3 +182,8 @@ if [ -z "$RC_XBS" ]
 then
 rm *.o
 fi
+
+echo "-- WARNING --"
+echo "buildit is no longer supported and will be removed in the next week!"
+echo "please contact the libc++ maintainers if you have any concerns"
+echo ""

Modified: libcxx/trunk/test/testit
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/testit?rev=292181&r1=292180&r2=292181&view=diff
==
--- libcxx/trunk/test/testit (original)
+++ libcxx/trunk/test/testit Mon Jan 16 19:16:44 2017
@@ -177,4 +177,7 @@ echo "   +   "
 echo "total number of tests: $(($FAIL+$PASS))"
 echo ""
 
+echo "-- WARNING --"
+echo "testit is no longer supported and will be removed in the future"
+
 exit $FAIL


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


[PATCH] D28790: [Modules] Correct test comment from obsolete earlier version of code. NFC

2017-01-16 Thread Graydon Hoare via Phabricator via cfe-commits
graydon created this revision.

Code committed in https://reviews.llvm.org/rL290219 went through a few 
iterations; test wound up with
stale comment.


https://reviews.llvm.org/D28790

Files:
  test/Modules/implicit-private-with-different-name.m


Index: test/Modules/implicit-private-with-different-name.m
===
--- test/Modules/implicit-private-with-different-name.m
+++ test/Modules/implicit-private-with-different-name.m
@@ -3,7 +3,7 @@
 // Build PCH using A, with adjacent private module APrivate, which winds up 
being implicitly referenced
 // RUN: %clang_cc1 -verify -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -F %S/Inputs/implicit-private-with-different-name 
-emit-pch -o %t-A.pch %s
 
-// Use the PCH with no explicit way to resolve PrivateA, still pick it up 
through MODULE_DIRECTORY reference in PCH control block
+// Use the PCH with no explicit way to resolve APrivate, still pick it up by 
automatic second-chance search for "A" with "Private" appended
 // RUN: %clang_cc1 -verify -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -F %S/Inputs/implicit-private-with-different-name 
-include-pch %t-A.pch %s -fsyntax-only
 
 // Check the fixit


Index: test/Modules/implicit-private-with-different-name.m
===
--- test/Modules/implicit-private-with-different-name.m
+++ test/Modules/implicit-private-with-different-name.m
@@ -3,7 +3,7 @@
 // Build PCH using A, with adjacent private module APrivate, which winds up being implicitly referenced
 // RUN: %clang_cc1 -verify -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -F %S/Inputs/implicit-private-with-different-name -emit-pch -o %t-A.pch %s
 
-// Use the PCH with no explicit way to resolve PrivateA, still pick it up through MODULE_DIRECTORY reference in PCH control block
+// Use the PCH with no explicit way to resolve APrivate, still pick it up by automatic second-chance search for "A" with "Private" appended
 // RUN: %clang_cc1 -verify -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -F %S/Inputs/implicit-private-with-different-name -include-pch %t-A.pch %s -fsyntax-only
 
 // Check the fixit
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25208: [libc++] Make _LIBCPP_TYPE_VIS export members

2017-01-16 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF requested changes to this revision.
EricWF added a comment.
This revision now requires changes to proceed.

Actually I probably shouldn't have approved this due to 
http://llvm.org/PR30642. I forgot about that when I last reviewed this.


https://reviews.llvm.org/D25208



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


r292183 - Partial revert of r290511.

2017-01-16 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Jan 16 20:14:37 2017
New Revision: 292183

URL: http://llvm.org/viewvc/llvm-project?rev=292183&view=rev
Log:
Partial revert of r290511.

The rules around typechecking deduced template arguments during partial
ordering are not clear, and while the prior behavior does not seem to be
correct (it doesn't follow the general model of partial ordering where each
template parameter is replaced by a non-dependent but unique value), the new
behavior is also not clearly right and breaks some existing idioms.

The new behavior is retained for dealing with non-type template parameters
with 'auto' types, as without it even the most basic uses of that feature
don't work. We can revisit this once CWG has come to an agreement on how
partial ordering with 'auto' non-type template parameters is supposed to
work.

Added:
cfe/trunk/test/SemaTemplate/partial-order.cpp
Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaTemplate/class-template-spec.cpp
cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp
cfe/trunk/test/SemaTemplate/temp_arg_template_cxx1z.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=292183&r1=292182&r2=292183&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Mon Jan 16 20:14:37 2017
@@ -5123,18 +5123,22 @@ ExprResult Sema::CheckTemplateArgument(N
   if (CTAK == CTAK_Deduced &&
   !Context.hasSameType(ParamType.getNonLValueExprType(Context),
Arg->getType())) {
-// C++ [temp.deduct.type]p17: (DR1770)
-//   If P has a form that contains , and if the type of i differs from
-//   the type of the corresponding template parameter of the template named
-//   by the enclosing simple-template-id, deduction fails.
-//
-// Note that CTAK will be CTAK_DeducedFromArrayBound if the form was [i]
-// rather than .
-//
-// FIXME: We interpret the 'i' here as referring to the expression
-// denoting the non-type template parameter rather than the parameter
-// itself, and so strip off references before comparing types. It's
-// not clear how this is supposed to work for references.
+// FIXME: If either type is dependent, we skip the check. This isn't
+// correct, since during deduction we're supposed to have replaced each
+// template parameter with some unique (non-dependent) placeholder.
+// FIXME: If the argument type contains 'auto', we carry on and fail the
+// type check in order to force specific types to be more specialized than
+// 'auto'. It's not clear how partial ordering with 'auto' is supposed to
+// work.
+if ((ParamType->isDependentType() || Arg->isTypeDependent()) &&
+!Arg->getType()->getContainedAutoType()) {
+  Converted = TemplateArgument(Arg);
+  return Arg;
+}
+// FIXME: This attempts to implement C++ [temp.deduct.type]p17. Per DR1770,
+// we should actually be checking the type of the template argument in P,
+// not the type of the template argument deduced from A, against the
+// template parameter type.
 Diag(StartLoc, diag::err_deduced_non_type_template_arg_type_mismatch)
   << Arg->getType()
   << ParamType.getUnqualifiedType();

Modified: cfe/trunk/test/SemaTemplate/class-template-spec.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/class-template-spec.cpp?rev=292183&r1=292182&r2=292183&view=diff
==
--- cfe/trunk/test/SemaTemplate/class-template-spec.cpp (original)
+++ cfe/trunk/test/SemaTemplate/class-template-spec.cpp Mon Jan 16 20:14:37 2017
@@ -207,19 +207,19 @@ namespace NTTPTypeVsPartialOrder {
   struct X { typedef int value_type; };
   template struct Y { typedef T value_type; };
 
-  template struct A; // expected-note 
{{template}}
+  template struct A;
   template struct A {};
-  template struct A, N> {}; // expected-error {{not more 
specialized}} expected-note {{'T' vs 'typename 
Y::value_type'}}
+  template struct A, N> {};
   A ax;
   A, 0> ay;
 
 
-  template struct B; // expected-note 
{{template}}
-  template struct B<0, T, N>; // 
expected-note {{matches}}
+  template struct B;
+  template struct B<0, T, N>;
   template struct B<0, X, N> {};
-  template struct B<0, Y, N> {}; // expected-error {{not 
more specialized}} expected-note {{'T' vs 'typename 
Y::value_type'}} expected-note {{matches}}
+  template struct B<0, Y, N> {};
   B<0, X, 0> bx;
-  B<0, Y, 0> by; // expected-error {{ambiguous}}
+  B<0, Y, 0> by;
 }
 
 namespace DefaultArgVsPartialSpec {

Added: cfe/trunk/test/SemaTemplate/partial-order.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/partial-order.cpp?rev=292183&view=auto
=

  1   2   >