[PATCH] D28279: [clang-move] Support moving type alias declarations.

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

https://reviews.llvm.org/D28279

Files:
  clang-move/ClangMove.cpp
  test/clang-move/Inputs/type_alias.h
  test/clang-move/move-type-alias.cpp
  unittests/clang-move/ClangMoveTests.cpp

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -365,25 +365,6 @@
   }
 }
 
-TEST(ClangMove, IgnoreUnsupportedKindsAndMoveAll) {
-  const char Code[] = "#include \"foo.h\"\nint A::f() { return 0; }";
-  std::vector TestHeaders = {
-  "typedef int Int;\nclass A {\npublic:\n  int f();\n};\n",
-  "using Int = int;\nclass A {\npublic:\n  int f();\n};\n",
-  };
-  move::MoveDefinitionSpec Spec;
-  Spec.Names.push_back("A");
-  Spec.OldHeader = "foo.h";
-  Spec.OldCC = "foo.cc";
-  Spec.NewHeader = "new_foo.h";
-  Spec.NewCC = "new_foo.cc";
-  for (const auto &Header : TestHeaders) {
-auto Results = runClangMoveOnCode(Spec, Header.c_str(), Code);
-EXPECT_EQ(Header, Results[Spec.NewHeader]);
-EXPECT_EQ("", Results[Spec.OldHeader]);
-  }
-}
-
 TEST(ClangMove, MacroInFunction) {
   const char TestHeader[] = "#define INT int\n"
 "class A {\npublic:\n  int f();\n};\n"
Index: test/clang-move/move-type-alias.cpp
===
--- /dev/null
+++ test/clang-move/move-type-alias.cpp
@@ -0,0 +1,52 @@
+// RUN: mkdir -p %T/move-type-alias
+// RUN: cp %S/Inputs/type_alias.h  %T/move-type-alias/type_alias.h
+// RUN: echo '#include "type_alias.h"' > %T/move-type-alias/type_alias.cpp
+// RUN: cd %T/move-type-alias
+//
+// -
+// Test moving typedef declarations.
+// -
+// RUN: clang-move -names="Int1" -new_cc=%T/move-type-alias/new_test.cpp -new_header=%T/move-type-alias/new_test.h -old_cc=%T/move-type-alias/type_alias.cpp -old_header=%T/move-type-alias/type_alias.h %T/move-type-alias/type_alias.cpp -- -std=c++11
+// RUN: FileCheck -input-file=%T/move-type-alias/new_test.h -check-prefix=CHECK-NEW-TEST-H-CASE1 %s
+// RUN: FileCheck -input-file=%T/move-type-alias/type_alias.h -check-prefix=CHECK-OLD-TEST-H-CASE1 %s
+
+// CHECK-NEW-TEST-H-CASE1: typedef int Int1;
+
+// CHECK-OLD-TEST-H-CASE1-NOT: typedef int Int1;
+
+
+// -
+// Test moving type alias declarations.
+// -
+// RUN: cp %S/Inputs/type_alias.h  %T/move-type-alias/type_alias.h
+// RUN: echo '#include "type_alias.h"' > %T/move-type-alias/type_alias.cpp
+// RUN: clang-move -names="Int2" -new_cc=%T/move-type-alias/new_test.cpp -new_header=%T/move-type-alias/new_test.h -old_cc=%T/move-type-alias/type_alias.cpp -old_header=%T/move-type-alias/type_alias.h %T/move-type-alias/type_alias.cpp -- -std=c++11
+// RUN: FileCheck -input-file=%T/move-type-alias/new_test.h -check-prefix=CHECK-NEW-TEST-H-CASE2 %s
+// RUN: FileCheck -input-file=%T/move-type-alias/type_alias.h -check-prefix=CHECK-OLD-TEST-H-CASE2 %s
+
+// CHECK-NEW-TEST-H-CASE2: using Int2 = int;
+
+// CHECK-OLD-TEST-H-CASE2-NOT: using Int2 = int;
+
+
+// -
+// Test moving template type alias declarations.
+// -
+// RUN: cp %S/Inputs/type_alias.h  %T/move-type-alias/type_alias.h
+// RUN: echo '#include "type_alias.h"' > %T/move-type-alias/type_alias.cpp
+// RUN: clang-move -names="B" -new_cc=%T/move-type-alias/new_test.cpp -new_header=%T/move-type-alias/new_test.h -old_cc=%T/move-type-alias/type_alias.cpp -old_header=%T/move-type-alias/type_alias.h %T/move-type-alias/type_alias.cpp -- -std=c++11
+// RUN: FileCheck -input-file=%T/move-type-alias/new_test.h -check-prefix=CHECK-OLD-TEST-H-CASE3 %s
+
+// CHECK-NEW-TEST-H-CASE3: template using B = A;
+// CHECK-OLD-TEST-H-CASE3-NOT: template using B = A;
+
+
+// -
+// Test not moving class-insided typedef declarations.
+// -
+// RUN: cp %S/Inputs/type_alias.h  %T/move-type-alias/type_alias.h
+// RUN: echo '#include "type_alias.h"' > %T/move-type-alias/type_alias.cpp
+// RUN: clang-move -names="C::Int3" -new_cc=%T/move-type-alias/new_test.cpp -new_header=%T/move-type-alias/new_test.h -old_cc=%T/move-type-alias/type_alias.cpp -old_header=%T/move-type-alias/type_alias.h %T/move-type-alias/type_alias.cpp -- -std=c++11
+// RUN: FileCheck -input-file=%T/move-type-alias/new_test.h -allow-empty -check-prefix=CHECK-EMPTY %s
+
+// CHECK-EMPTY: {{^}}{{$}}
In

[PATCH] D28222: [libcxx] Re-implement LWG 2770 again: Fix tuple_size to work with structured bindings

2017-01-04 Thread Michael Park via Phabricator via cfe-commits
mpark accepted this revision.
mpark added a reviewer: mpark.
mpark added a comment.

That was fun =D


https://reviews.llvm.org/D28222



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


[PATCH] D28220: provide Win32 native threading

2017-01-04 Thread Andrey Khalyavin via Phabricator via cfe-commits
halyavin added inline comments.



Comment at: include/__threading_support:458
+   __libcpp_mutex_reference&& __m,
+   timespec* __ts)
+{

In posix, pthread_cond_timedwait uses absolute time but we use relative time 
here.



Comment at: include/__threading_support:460
+{
+  using namespace _VSTD::chrono;
+  auto timeout = seconds(__ts->tv_sec) + nanoseconds(__ts->tv_nsec);

We need to include  to use types and functions from this namespace.



Comment at: include/__threading_support:464
+
+  _LIBCPP_ASSERT(timeout_ms.count() < _VSTD::numeric_limits::max(),
+ "timeout duration overflows");

You have done it accidentally right. I realized there is a second problem here 
- if timeout equals to INFINITE, the thread will wait forever. INFINITE equals 
to (DWORD)-1, so the strict sign in the assert is required. But for sanity sake 
_VSTD::numeric_limits::max() should be replaced with INFINITE.  



Comment at: include/__threading_support:486
+static inline _LIBCPP_ALWAYS_INLINE BOOL CALLBACK
+__libcpp_init_once_trampoline(PINIT_ONCE InitOnce, PVOID Parameter,
+  PVOID *Context)

We need underscores for parameters and init_routine.



Comment at: include/__threading_support:497
+
+int __libcpp_execute_once(__libcpp_exec_once_flag* flag,
+  void (*init_routine)(void))

Underscores for parameters are missing.



Comment at: include/__threading_support:527
+static inline _LIBCPP_ALWAYS_INLINE unsigned int WINAPI
+__libcpp_thread_trampoline(void *__data)
+{

Trampolines will never be inlined. Should we put them in support *.cpp instead? 
The downside is new public symbols which can't be changed without breaking 
backward compatibility. The upside is that we will have only one copy of each 
trampoline. What do you think?



Comment at: include/__threading_support:531
+  *(__libcpp_thread_trampoline_data*)__data;
+  _VSTD::free(__data);
+  return reinterpret_cast(data.__func(data.__arg));

Do we need #include  for free() and malloc() now? Can we use 
new/delete instead?

BTW, What is the purpose of _VSTD? I think it is used to prevent 
argument-dependent lookup and so is not needed for free and malloc.



Comment at: include/__threading_support:532
+  _VSTD::free(__data);
+  return reinterpret_cast(data.__func(data.__arg));
+}

Should we even try to pass thread exit code, given that sizeof(unsigned int) < 
sizeof(void*) on 64-bit system? std::thread doesn't support thread exit code 
anyway.


Repository:
  rL LLVM

https://reviews.llvm.org/D28220



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


[PATCH] D28279: [clang-move] Support moving type alias declarations.

2017-01-04 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/D28279



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


[PATCH] D28282: [change-namespace] get whitespaces right when moving old namespaces.

2017-01-04 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added a reviewer: hokein.
ioeric added a subscriber: cfe-commits.

https://reviews.llvm.org/D28282

Files:
  change-namespace/ChangeNamespace.cpp
  unittests/change-namespace/ChangeNamespaceTests.cpp

Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -110,12 +110,52 @@
  "namespace nc {\n"
  "class A {};\n"
  "} // namespace nc\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
+TEST_F(ChangeNamespaceTest, NewNsNestedInOldNsWithSurroundingNewLines) {
+  NewNamespace = "na::nb::nc";
+  std::string Code = "namespace na {\n"
+ "namespace nb {\n"
+ "\n"
+ "class A {};\n"
+ "\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "namespace na {\n"
+ "namespace nb {\n"
+ "namespace nc {\n"
+ "\n"
+ "class A {};\n"
  "\n"
+ "} // namespace nc\n"
  "} // namespace nb\n"
  "} // namespace na\n";
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, MoveOldNsWithSurroundingNewLines) {
+  NewNamespace = "nx::ny";
+  std::string Code = "namespace na {\n"
+ "namespace nb {\n"
+ "\n"
+ "class A {};\n"
+ "\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "\n\n"
+ "namespace nx {\n"
+ "namespace ny {\n"
+ "\n"
+ "class A {};\n"
+ "\n"
+ "} // namespace ny\n"
+ "} // namespace nx\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 TEST_F(ChangeNamespaceTest, NewNsNestedInOldNsWithRefs) {
   NewNamespace = "na::nb::nc";
   std::string Code = "namespace na {\n"
@@ -134,7 +174,6 @@
  "class C {};\n"
  "void f() { A a; B b; }\n"
  "} // namespace nc\n"
- "\n"
  "} // namespace nb\n"
  "} // namespace na\n";
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
@@ -1497,7 +1536,7 @@
  "void f() {\n"
  "  GG g;\n"
  "}\n"
- "} // namespace nc\n\n"
+ "} // namespace nc\n"
  "} // namespace nb\n"
  "} // namespace na\n";
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
@@ -1554,7 +1593,7 @@
  "  struct Derived::Nested nested;\n"
  "  const struct Derived::Nested *nested_ptr;\n"
  "}\n"
- "} // namespace nc\n\n"
+ "} // namespace nc\n"
  "} // namespace nb\n"
  "} // namespace na\n";
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -559,13 +559,15 @@
   SourceLocation Start = getLocAfterNamespaceLBrace(
   NsDecl, *Result.SourceManager, Result.Context->getLangOpts());
   assert(Start.isValid() && "Can't find l_brace for namespace.");
-  SourceLocation End = NsDecl->getRBraceLoc().getLocWithOffset(-1);
-  // Create a replacement that deletes the code in the old namespace merely for
-  // retrieving offset and length from it.
-  const auto R = createReplacement(Start, End, "", *Result.SourceManager);
+  // Create a replacement merely for retrieving file path and start offset.
+  const auto R = createReplacement(Start, Start, "", *Result.SourceManager);
   MoveNamespace MoveNs;
   MoveNs.Offset = R.getOffset();
-  MoveNs.Length = R.getLength();
+  // The replacement contains token range, but we need to be more accurate and
+  // calculate offsets directly. Note that the range is from the location just
+  // past the left brace to the location right before the right brace.
+  MoveNs.Length = Result.SourceManager->getFileOffset(NsDecl->getRBraceLoc()) -
+  Result.SourceManager->getFileOffset(Start)

[PATCH] D28282: [change-namespace] get whitespaces right when moving old namespaces.

2017-01-04 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added inline comments.



Comment at: change-namespace/ChangeNamespace.cpp:563
+  // Create a replacement merely for retrieving file path and start offset.
+  const auto R = createReplacement(Start, Start, "", *Result.SourceManager);
   MoveNamespace MoveNs;

maybe i am missing smth, to be honest i somehow think this code is "hacky" / 
looks like a "workaround", so don't like the idea of creating a replacement 
only for extracting the  offset / filepath.
I would prefer to refactor this (+ SourceManager ?) to get rid of these hacks 
(they create extra "tech debt" plus decrease the readability) 


https://reviews.llvm.org/D28282



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


[PATCH] D28282: [change-namespace] get whitespaces right when moving old namespaces.

2017-01-04 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 83024.
ioeric marked an inline comment as done.
ioeric added a comment.

- Get rid of hacky replacement.


https://reviews.llvm.org/D28282

Files:
  change-namespace/ChangeNamespace.cpp
  unittests/change-namespace/ChangeNamespaceTests.cpp

Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -110,12 +110,52 @@
  "namespace nc {\n"
  "class A {};\n"
  "} // namespace nc\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
+TEST_F(ChangeNamespaceTest, NewNsNestedInOldNsWithSurroundingNewLines) {
+  NewNamespace = "na::nb::nc";
+  std::string Code = "namespace na {\n"
+ "namespace nb {\n"
+ "\n"
+ "class A {};\n"
+ "\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "namespace na {\n"
+ "namespace nb {\n"
+ "namespace nc {\n"
+ "\n"
+ "class A {};\n"
  "\n"
+ "} // namespace nc\n"
  "} // namespace nb\n"
  "} // namespace na\n";
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, MoveOldNsWithSurroundingNewLines) {
+  NewNamespace = "nx::ny";
+  std::string Code = "namespace na {\n"
+ "namespace nb {\n"
+ "\n"
+ "class A {};\n"
+ "\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "\n\n"
+ "namespace nx {\n"
+ "namespace ny {\n"
+ "\n"
+ "class A {};\n"
+ "\n"
+ "} // namespace ny\n"
+ "} // namespace nx\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 TEST_F(ChangeNamespaceTest, NewNsNestedInOldNsWithRefs) {
   NewNamespace = "na::nb::nc";
   std::string Code = "namespace na {\n"
@@ -134,7 +174,6 @@
  "class C {};\n"
  "void f() { A a; B b; }\n"
  "} // namespace nc\n"
- "\n"
  "} // namespace nb\n"
  "} // namespace na\n";
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
@@ -1497,7 +1536,7 @@
  "void f() {\n"
  "  GG g;\n"
  "}\n"
- "} // namespace nc\n\n"
+ "} // namespace nc\n"
  "} // namespace nb\n"
  "} // namespace na\n";
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
@@ -1554,7 +1593,7 @@
  "  struct Derived::Nested nested;\n"
  "  const struct Derived::Nested *nested_ptr;\n"
  "}\n"
- "} // namespace nc\n\n"
+ "} // namespace nc\n"
  "} // namespace nb\n"
  "} // namespace na\n";
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -555,17 +555,17 @@
   if (Decl::castToDeclContext(NsDecl)->decls_empty())
 return;
 
+  const SourceManager &SM = *Result.SourceManager;
   // Get the range of the code in the old namespace.
-  SourceLocation Start = getLocAfterNamespaceLBrace(
-  NsDecl, *Result.SourceManager, Result.Context->getLangOpts());
+  SourceLocation Start =
+  getLocAfterNamespaceLBrace(NsDecl, SM, Result.Context->getLangOpts());
   assert(Start.isValid() && "Can't find l_brace for namespace.");
-  SourceLocation End = NsDecl->getRBraceLoc().getLocWithOffset(-1);
-  // Create a replacement that deletes the code in the old namespace merely for
-  // retrieving offset and length from it.
-  const auto R = createReplacement(Start, End, "", *Result.SourceManager);
   MoveNamespace MoveNs;
-  MoveNs.Offset = R.getOffset();
-  MoveNs.Length = R.getLength();
+  MoveNs.Offset = SM.getFileOffset(Start);
+  // The range of the moved namespace is from the location just past the left
+  // brace to the location right before the right brace.
+  MoveNs.Length =
+  SM

[PATCH] D28282: [change-namespace] get whitespaces right when moving old namespaces.

2017-01-04 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: change-namespace/ChangeNamespace.cpp:563
+  // Create a replacement merely for retrieving file path and start offset.
+  const auto R = createReplacement(Start, Start, "", *Result.SourceManager);
   MoveNamespace MoveNs;

alexshap wrote:
> maybe i am missing smth, to be honest i somehow think this code is "hacky" / 
> looks like a "workaround", so don't like the idea of creating a replacement 
> only for extracting the  offset / filepath.
> I would prefer to refactor this (+ SourceManager ?) to get rid of these hacks 
> (they create extra "tech debt" plus decrease the readability) 
You are right; I was being lazy... remove the hack ;-)


https://reviews.llvm.org/D28282



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


[PATCH] D28246: clang-format: [JS] avoid indent after ambient function declarations.

2017-01-04 Thread Martin Probst via Phabricator via cfe-commits
mprobst updated this revision to Diff 83028.
mprobst added a comment.

- Handle type declarations.


https://reviews.llvm.org/D28246

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


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -377,6 +377,14 @@
   "declare function\n"
   "x();",  // TODO(martinprobst): should ideally be indented.
   NineCols);
+  verifyFormat("declare function foo();\n"
+   "let x = 1;\n");
+  verifyFormat("declare function foo(): string;\n"
+   "let x = 1;\n");
+  verifyFormat("declare class X {}\n"
+   "let x = 1;\n");
+  verifyFormat("declare interface Y {}\n"
+   "let x = 1;\n");
   verifyFormat(
   "declare enum X {\n"
   "}",
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -1255,10 +1255,13 @@
 if (FormatTok->is(tok::l_brace))
   tryToParseBracedList();
 else
-  while (FormatTok->isNot(tok::l_brace) && !eof())
+  while (!FormatTok->isOneOf(tok::l_brace, tok::semi) && !eof())
 nextToken();
   }
 
+  if (FormatTok->is(tok::semi))
+return;
+
   parseChildBlock();
 }
 


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -377,6 +377,14 @@
   "declare function\n"
   "x();",  // TODO(martinprobst): should ideally be indented.
   NineCols);
+  verifyFormat("declare function foo();\n"
+   "let x = 1;\n");
+  verifyFormat("declare function foo(): string;\n"
+   "let x = 1;\n");
+  verifyFormat("declare class X {}\n"
+   "let x = 1;\n");
+  verifyFormat("declare interface Y {}\n"
+   "let x = 1;\n");
   verifyFormat(
   "declare enum X {\n"
   "}",
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -1255,10 +1255,13 @@
 if (FormatTok->is(tok::l_brace))
   tryToParseBracedList();
 else
-  while (FormatTok->isNot(tok::l_brace) && !eof())
+  while (!FormatTok->isOneOf(tok::l_brace, tok::semi) && !eof())
 nextToken();
   }
 
+  if (FormatTok->is(tok::semi))
+return;
+
   parseChildBlock();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28286: [CodeCompletion] Code complete the missing C++11 keywords

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

This patch adds context sensitive code completion support for the C++11 
keywords that currently don't have completion results.

The following keywords are supported by this patch:

- alignas
- constexpr
- static_assert
- noexcept (as a function/method qualifier, not the expression which was 
already supported)
- thread_local

The following special identifiers are also supported:

- final (as a method qualifier or class qualifier)
- override


Repository:
  rL LLVM

https://reviews.llvm.org/D28286

Files:
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Sema/SemaCodeComplete.cpp
  test/CodeCompletion/keywords.cpp
  test/CodeCompletion/ordinary-name-cxx11.cpp

Index: test/CodeCompletion/ordinary-name-cxx11.cpp
===
--- test/CodeCompletion/ordinary-name-cxx11.cpp
+++ test/CodeCompletion/ordinary-name-cxx11.cpp
@@ -39,10 +39,12 @@
   // CHECK-CC1-NEXT: COMPLETION: Pattern : [#size_t#]sizeof(<#expression-or-type#>)
   // CHECK-CC1-NEXT: COMPLETION: Pattern : [#size_t#]sizeof...(<#parameter-pack#>)
   // CHECK-CC1-NEXT: COMPLETION: static
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : static_assert(<#expression#>, <#message#>)
   // CHECK-CC1-NEXT: COMPLETION: Pattern : static_cast<<#type#>>(<#expression#>)
   // CHECK-CC1-NEXT: COMPLETION: struct
   // CHECK-CC1-NEXT: COMPLETION: Pattern : switch(<#condition#>){
   // CHECK-CC1: COMPLETION: t : t
+  // CHECK-CC1-NEXT: COMPLETION: thread_local
   // CHECK-CC1-NEXT: COMPLETION: Pattern : [#void#]throw <#expression#>
   // CHECK-CC1-NEXT: COMPLETION: Pattern : [#bool#]true
   // CHECK-CC1-NEXT: COMPLETION: Pattern : try{<#statements#>
@@ -72,6 +74,7 @@
   // CHECK-CC2-NEXT: COMPLETION: char32
   // CHECK-CC2-NEXT: COMPLETION: class
   // CHECK-CC2-NEXT: COMPLETION: const
+  // CHECK-CC2-NEXT: COMPLETION: constexpr
   // CHECK-CC2-NEXT: COMPLETION: Pattern : decltype(<#expression#>)
   // CHECK-CC2-NEXT: COMPLETION: double
   // CHECK-CC2-NEXT: COMPLETION: enum
@@ -86,10 +89,12 @@
   // CHECK-CC2-NEXT: COMPLETION: short
   // CHECK-CC2-NEXT: COMPLETION: signed
   // CHECK-CC2-NEXT: COMPLETION: static
+  // CHECK-CC2-NEXT: COMPLETION: Pattern : static_assert(<#expression#>, <#message#>)
   // CHECK-CC2-NEXT: COMPLETION: struct
   // CHECK-CC2-NEXT: COMPLETION: t : t
   // CHECK-CC2-NEXT: COMPLETION: Pattern : template <#declaration#>
   // CHECK-CC2-NEXT: COMPLETION: Pattern : template<<#parameters#>>
+  // CHECK-CC2-NEXT: COMPLETION: thread_local
   // CHECK-CC2-NEXT: COMPLETION: TYPEDEF : TYPEDEF
   // CHECK-CC2-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>
   // CHECK-CC2-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
@@ -111,6 +116,7 @@
   // CHECK-CC3-NEXT: COMPLETION: char32_t
   // CHECK-CC3-NEXT: COMPLETION: class
   // CHECK-CC3-NEXT: COMPLETION: const
+  // CHECK-CC3-NEXT: COMPLETION: constexpr
   // CHECK-CC3-NEXT: COMPLETION: Pattern : decltype(<#expression#>)
   // CHECK-CC3-NEXT: COMPLETION: double
   // CHECK-CC3-NEXT: COMPLETION: enum
@@ -129,8 +135,10 @@
   // CHECK-CC3-NEXT: COMPLETION: short
   // CHECK-CC3-NEXT: COMPLETION: signed
   // CHECK-CC3-NEXT: COMPLETION: static
+  // CHECK-CC3-NEXT: COMPLETION: Pattern : static_assert(<#expression#>, <#message#>)
   // CHECK-CC3-NEXT: COMPLETION: struct
   // CHECK-CC3-NEXT: COMPLETION: Pattern : template<<#parameters#>>
+  // CHECK-CC3-NEXT: COMPLETION: thread_local
   // CHECK-CC3-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>
   // CHECK-CC3-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
   // CHECK-CC3-NEXT: COMPLETION: Pattern : typeof <#expression#>
@@ -227,6 +235,7 @@
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : [#size_t#]sizeof(<#expression-or-type#>)
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : [#size_t#]sizeof...(<#parameter-pack#>)
   // CHECK-NO-RTTI-NEXT: COMPLETION: static
+  // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : static_assert(<#expression#>, <#message#>)
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : static_cast<<#type#>>(<#expression#>)
   // CHECK-NO-RTTI-NEXT: COMPLETION: struct
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : switch(<#condition#>){
Index: test/CodeCompletion/keywords.cpp
===
--- /dev/null
+++ test/CodeCompletion/keywords.cpp
@@ -0,0 +1,79 @@
+int function(int x) {
+  return x + 1;
+}
+
+int variable = 0;
+
+class Class {
+public:
+  Class() { }
+
+  int method(int x) {
+return x + 1;
+  }
+
+  virtual void virtualMethod() {
+  }
+
+  static void staticMethod() {
+  }
+
+  static int staticVar;
+};
+
+class SubClass : public Class {
+  void virtualMethod() override final {
+  }
+};
+
+struct Struct {
+};
+
+// RUN: %clang_cc1 -std=c++11 -code

[PATCH] D28231: -Wunreachable-code: Avoid multiple diagnostics that are triggered by the same source range and fix the unary operator fixit source range

2017-01-04 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 83032.
arphaman added a comment.

You're right, the fixit for `if (!s->p || 1)` is wrong, but that was another 
existing bug. The updated patch fixes this issue.


Repository:
  rL LLVM

https://reviews.llvm.org/D28231

Files:
  lib/Analysis/ReachableCode.cpp
  lib/Sema/AnalysisBasedWarnings.cpp
  test/Sema/warn-unreachable.c

Index: test/Sema/warn-unreachable.c
===
--- test/Sema/warn-unreachable.c
+++ test/Sema/warn-unreachable.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks -Wunreachable-code-aggressive -Wno-unused-value -Wno-covered-switch-default -I %S/Inputs
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wunreachable-code-aggressive -Wno-unused-value -Wno-covered-switch-default -fdiagnostics-parseable-fixits -I %S/Inputs %s 2>&1 | FileCheck %s
 
 #include "warn-unreachable.h"
 
@@ -396,3 +397,44 @@
   else
 calledFun();
 }
+
+// rdar://24570531
+
+struct StructWithPointer {
+  void *p;
+};
+
+void emitJustOneWarningForOr(struct StructWithPointer *s) {
+  if (1 || !s->p) // expected-note {{silence by adding parentheses to mark code as explicitly dead}}
+return; // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:7-[[@LINE-1]]:7}:"/* DISABLES CODE */ ("
+// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:8-[[@LINE-2]]:8}:")"
+  emitJustOneWarningForOr(s); // expected-warning {{code will never be executed}}
+}
+
+void emitJustOneWarningForOrSilenced(struct StructWithPointer *s) {
+  if ((1) || !s->p)
+return;
+
+  emitJustOneWarningForOrSilenced(s); // no warning
+}
+
+void emitJustOneWarningForOr2(struct StructWithPointer *s) {
+  if (1 || !s->p) // expected-warning {{code will never be executed}}
+return; // expected-note@-1 {{silence by adding parentheses to mark code as explicitly dead}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:7-[[@LINE-2]]:7}:"/* DISABLES CODE */ ("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:8-[[@LINE-3]]:8}:")"
+}
+
+void wrapOneInFixit(struct StructWithPointer *s) {
+  if (!s->p || 1) // expected-note {{silence by adding parentheses to mark code as explicitly dead}}
+return; // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:16-[[@LINE-1]]:16}:"/* DISABLES CODE */ ("
+// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:17-[[@LINE-2]]:17}:")"
+  wrapOneInFixit(s); // expected-warning {{code will never be executed}}
+}
+
+void unaryOpFixit() {
+  if (- 1)  // expected-note {{silence by adding parentheses to mark code as explicitly dead}}
+return; // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:7-[[@LINE-1]]:7}:"/* DISABLES CODE */ ("
+// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:10-[[@LINE-2]]:10}:")"
+  unaryOpFixit(); // expected-warning {{code will never be executed}}
+}
Index: lib/Sema/AnalysisBasedWarnings.cpp
===
--- lib/Sema/AnalysisBasedWarnings.cpp
+++ lib/Sema/AnalysisBasedWarnings.cpp
@@ -56,14 +56,24 @@
 namespace {
   class UnreachableCodeHandler : public reachable_code::Callback {
 Sema &S;
+SourceRange PreviousSilenceableCondVal;
+
   public:
 UnreachableCodeHandler(Sema &s) : S(s) {}
 
 void HandleUnreachable(reachable_code::UnreachableKind UK,
SourceLocation L,
SourceRange SilenceableCondVal,
SourceRange R1,
SourceRange R2) override {
+  // Avoid reporting multiple unreachable code diagnostics that are
+  // triggered by the same conditional value.
+  if (PreviousSilenceableCondVal.isValid() &&
+  SilenceableCondVal.isValid() &&
+  PreviousSilenceableCondVal == SilenceableCondVal)
+return;
+  PreviousSilenceableCondVal = SilenceableCondVal;
+
   unsigned diag = diag::warn_unreachable;
   switch (UK) {
 case reachable_code::UK_Break:
Index: lib/Analysis/ReachableCode.cpp
===
--- lib/Analysis/ReachableCode.cpp
+++ lib/Analysis/ReachableCode.cpp
@@ -218,11 +218,16 @@
 }
 case Stmt::UnaryOperatorClass: {
   const UnaryOperator *UO = cast(S);
-  if (SilenceableCondVal) 
-*SilenceableCondVal = UO->getSourceRange();  
-  return UO->getOpcode() == UO_LNot &&
- isConfigurationValue(UO->getSubExpr(), PP, SilenceableCondVal,
-  IncludeIntegers, WrappedInParens);
+  bool SilenceableCondValNotSet =
+  SilenceableCondVal && SilenceableCondVal->getBegin().isInvalid();
+  bool IsSubExprConfigValue =
+  isConfigurationValue(UO->getSubExpr(), PP, SilenceableCondVal,
+   IncludeIntegers, WrappedInParens);
+  // Update the silenceable condition value source range only if the range
+  // was set in the child expression.
+  if (SilenceableCondValNotSet && SilenceableCondVal->getBegin().isValid())
+*SilenceableCondVal =

[PATCH] D17981: [clang-tidy] Fix clang-tidy to support parsing of assembly statements.

2017-01-04 Thread Jacob Kooijman via Phabricator via cfe-commits
jckooijman added a comment.

Hi, this is my first time posting here so excuse me if i am giving you not 
enough information.

I found this bugreport from: 
https://blog.yuo.be/2016/05/11/columns-ui-can-now-be-compiled-using-clang/

I am getting the exact same issue using clang-tidy e.g.

  C:\Program Files (x86)\Windows Kits\8.0\include\um\winnt.h:833:5: error: 
MS-styl
  e inline assembly is not available: Unable to find target for this triple (no 
ta
  rgets are registered) [clang-diagnostic-error]
  __asm{
  ^

I am trying to use clang-tidy on a windows 32bit source. As you stated 
clang-tidy seems to simply ignore the error and move on, but i think it should 
be fixed regardless (my error log gets spammed by this)


https://reviews.llvm.org/D17981



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


[PATCH] D28289: Fix tests with CLANG_DEFAULT_LINKER

2017-01-04 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld created this revision.
Hahnfeld added reviewers: phosek, mgorny.
Hahnfeld added a subscriber: cfe-commits.
Herald added subscribers: srhines, danalbert.

I originally requested this to be tested in https://reviews.llvm.org/D25263 but 
in the end forgot to make sure that it was done.


https://reviews.llvm.org/D28289

Files:
  test/Driver/B-opt.c
  test/Driver/coverage-ld.c
  test/Driver/cross-linux.c
  test/Driver/fuchsia.c
  test/Driver/fuchsia.cpp
  test/Driver/fuse-ld.c
  test/Driver/instrprof-ld.c
  test/Driver/mips-mti-linux.c
  test/Driver/nostdlib.c
  test/Driver/prefixed-tools.c
  test/Driver/sanitizer-ld.c
  test/Driver/windows-cross.c

Index: test/Driver/windows-cross.c
===
--- test/Driver/windows-cross.c
+++ test/Driver/windows-cross.c
@@ -1,34 +1,34 @@
-// RUN: %clang -### -target armv7-windows-itanium --sysroot %S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -stdlib=libstdc++ -rtlib=platform -o /dev/null %s 2>&1 \
+// RUN: %clang -### -target armv7-windows-itanium --sysroot %S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -fuse-ld=ld -stdlib=libstdc++ -rtlib=platform -o /dev/null %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix CHECK-BASIC
 
 // CHECK-BASIC: armv7-windows-itanium-ld" "--sysroot={{.*}}/Inputs/Windows/ARM/8.1" "-m" "thumb2pe" "-Bdynamic" "--entry" "mainCRTStartup" "--allow-multiple-definition" "-o" "{{[^"]*}}" "{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/crtbegin.obj" "-L{{.*}}/Inputs/Windows/ARM/8.1/usr/lib" "-L{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/gcc" "{{.*}}.o" "-lmsvcrt" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
 
-// RUN: %clang -### -target armv7-windows-itanium --sysroot %s/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -rtlib=compiler-rt -stdlib=libstdc++ -o /dev/null %s 2>&1 \
+// RUN: %clang -### -target armv7-windows-itanium --sysroot %s/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -fuse-ld=ld -rtlib=compiler-rt -stdlib=libstdc++ -o /dev/null %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix CHECK-RTLIB
 
 // CHECK-RTLIB: armv7-windows-itanium-ld" "--sysroot={{.*}}/Inputs/Windows/ARM/8.1" "-m" "thumb2pe" "-Bdynamic" "--entry" "mainCRTStartup" "--allow-multiple-definition" "-o" "{{[^"]*}}" "{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/crtbegin.obj" "-L{{.*}}/Inputs/Windows/ARM/8.1/usr/lib" "-L{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/gcc" "{{.*}}.o" "-lmsvcrt" "{{.*[\\/]}}clang_rt.builtins-arm.lib"
 
-// RUN: %clang -### -target armv7-windows-itanium --sysroot %S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -rtlib=compiler-rt -stdlib=libc++ -o /dev/null %s 2>&1 \
+// RUN: %clang -### -target armv7-windows-itanium --sysroot %S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -fuse-ld=ld -rtlib=compiler-rt -stdlib=libc++ -o /dev/null %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix CHECK-C-LIBCXX
 
 // CHECK-C-LIBCXX: armv7-windows-itanium-ld" "--sysroot={{.*}}/Inputs/Windows/ARM/8.1" "-m" "thumb2pe" "-Bdynamic" "--entry" "mainCRTStartup" "--allow-multiple-definition" "-o" "{{[^"]*}}" "{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/crtbegin.obj" "{{.*}}.o" "-lmsvcrt" "{{.*[\\/]}}clang_rt.builtins-arm.lib"
 
-// RUN: %clangxx -### -target armv7-windows-itanium --sysroot %S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -rtlib=compiler-rt -stdlib=libc++ -o /dev/null %s 2>&1 \
+// RUN: %clangxx -### -target armv7-windows-itanium --sysroot %S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -fuse-ld=ld -rtlib=compiler-rt -stdlib=libc++ -o /dev/null %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix CHECK-LIBCXX
 
 // CHECK-LIBCXX: armv7-windows-itanium-ld" "--sysroot={{.*}}/Inputs/Windows/ARM/8.1" "-m" "thumb2pe" "-Bdynamic" "--entry" "mainCRTStartup" "--allow-multiple-definition" "-o" "{{[^"]*}}" "{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/crtbegin.obj" "{{.*}}.o" "-lc++" "-lmsvcrt" "{{.*[\\/]}}clang_rt.builtins-arm.lib"
 
-// RUN: %clang -### -target armv7-windows-itanium --sysroot %S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -shared -rtlib=compiler-rt -stdlib=libc++ -o shared.dll %s 2>&1 \
+// RUN: %clang -### -target armv7-windows-itanium --sysroot %S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -fuse-ld=ld -shared -rtlib=compiler-rt -stdlib=libc++ -o shared.dll %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix CHECK-SHARED
 
 // CHECK-SHARED: armv7-windows-itanium-ld" "--sysroot={{.*}}/Inputs/Windows/ARM/8.1" "-m" "thumb2pe" "-shared" "-Bdynamic" "--enable-auto-image-base" "--entry" "_DllMainCRTStartup" "--allow-multiple-definition" "-o" "shared.dll" "--out-implib" "shared.lib" "{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/crtbeginS.obj" "{{.*}}.o" "-lmsvcrt" "{{.*[\\/]}}clang_rt.builtins-arm.lib"
 
-// RUN: %clang -### -target armv7-windows-itanium --sysroot %s/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -shared -rtlib=compiler-rt -stdlib=libc++ -nostartfiles -o share

[PATCH] D28282: [change-namespace] get whitespaces right when moving old namespaces.

2017-01-04 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added a comment.

thx, LGTM


https://reviews.llvm.org/D28282



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


[PATCH] D28246: clang-format: [JS] avoid indent after ambient function declarations.

2017-01-04 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a reviewer: sammccall.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: unittests/Format/FormatTestJS.cpp:382
+   "let x = 1;\n");
+  verifyFormat("declare function foo(): string;\n"
+   "let x = 1;\n");

Maybe include an inline object return type for completeness?


https://reviews.llvm.org/D28246



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


[PATCH] D28246: clang-format: [JS] avoid indent after ambient function declarations.

2017-01-04 Thread Martin Probst via Phabricator via cfe-commits
mprobst updated this revision to Diff 83038.
mprobst added a comment.

- Handle type declarations.
- test for object literal return types


https://reviews.llvm.org/D28246

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


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -377,6 +377,16 @@
   "declare function\n"
   "x();",  // TODO(martinprobst): should ideally be indented.
   NineCols);
+  verifyFormat("declare function foo();\n"
+   "let x = 1;\n");
+  verifyFormat("declare function foo(): string;\n"
+   "let x = 1;\n");
+  verifyFormat("declare function foo(): {x: number};\n"
+   "let x = 1;\n");
+  verifyFormat("declare class X {}\n"
+   "let x = 1;\n");
+  verifyFormat("declare interface Y {}\n"
+   "let x = 1;\n");
   verifyFormat(
   "declare enum X {\n"
   "}",
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -1255,10 +1255,13 @@
 if (FormatTok->is(tok::l_brace))
   tryToParseBracedList();
 else
-  while (FormatTok->isNot(tok::l_brace) && !eof())
+  while (!FormatTok->isOneOf(tok::l_brace, tok::semi) && !eof())
 nextToken();
   }
 
+  if (FormatTok->is(tok::semi))
+return;
+
   parseChildBlock();
 }
 


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -377,6 +377,16 @@
   "declare function\n"
   "x();",  // TODO(martinprobst): should ideally be indented.
   NineCols);
+  verifyFormat("declare function foo();\n"
+   "let x = 1;\n");
+  verifyFormat("declare function foo(): string;\n"
+   "let x = 1;\n");
+  verifyFormat("declare function foo(): {x: number};\n"
+   "let x = 1;\n");
+  verifyFormat("declare class X {}\n"
+   "let x = 1;\n");
+  verifyFormat("declare interface Y {}\n"
+   "let x = 1;\n");
   verifyFormat(
   "declare enum X {\n"
   "}",
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -1255,10 +1255,13 @@
 if (FormatTok->is(tok::l_brace))
   tryToParseBracedList();
 else
-  while (FormatTok->isNot(tok::l_brace) && !eof())
+  while (!FormatTok->isOneOf(tok::l_brace, tok::semi) && !eof())
 nextToken();
   }
 
+  if (FormatTok->is(tok::semi))
+return;
+
   parseChildBlock();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r290959 - clang-format: [JS] avoid indent after ambient function declarations.

2017-01-04 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Wed Jan  4 07:36:43 2017
New Revision: 290959

URL: http://llvm.org/viewvc/llvm-project?rev=290959&view=rev
Log:
clang-format: [JS] avoid indent after ambient function declarations.

Summary:
Before:
  declare function foo();
let x = 1;

After:
  declare function foo();
  let x = 1;

The problem was that clang-format would unconditionally try to parse a child 
block, even though ambient function declarations do not have a body (similar to 
forward declarations).

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

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=290959&r1=290958&r2=290959&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Wed Jan  4 07:36:43 2017
@@ -1255,10 +1255,13 @@ void UnwrappedLineParser::tryToParseJSFu
 if (FormatTok->is(tok::l_brace))
   tryToParseBracedList();
 else
-  while (FormatTok->isNot(tok::l_brace) && !eof())
+  while (!FormatTok->isOneOf(tok::l_brace, tok::semi) && !eof())
 nextToken();
   }
 
+  if (FormatTok->is(tok::semi))
+return;
+
   parseChildBlock();
 }
 

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=290959&r1=290958&r2=290959&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Wed Jan  4 07:36:43 2017
@@ -377,6 +377,16 @@ TEST_F(FormatTestJS, AmbientDeclarations
   "declare function\n"
   "x();",  // TODO(martinprobst): should ideally be indented.
   NineCols);
+  verifyFormat("declare function foo();\n"
+   "let x = 1;\n");
+  verifyFormat("declare function foo(): string;\n"
+   "let x = 1;\n");
+  verifyFormat("declare function foo(): {x: number};\n"
+   "let x = 1;\n");
+  verifyFormat("declare class X {}\n"
+   "let x = 1;\n");
+  verifyFormat("declare interface Y {}\n"
+   "let x = 1;\n");
   verifyFormat(
   "declare enum X {\n"
   "}",


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


[PATCH] D28246: clang-format: [JS] avoid indent after ambient function declarations.

2017-01-04 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290959: clang-format: [JS] avoid indent after ambient 
function declarations. (authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D28246?vs=83038&id=83039#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28246

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
@@ -1255,10 +1255,13 @@
 if (FormatTok->is(tok::l_brace))
   tryToParseBracedList();
 else
-  while (FormatTok->isNot(tok::l_brace) && !eof())
+  while (!FormatTok->isOneOf(tok::l_brace, tok::semi) && !eof())
 nextToken();
   }
 
+  if (FormatTok->is(tok::semi))
+return;
+
   parseChildBlock();
 }
 
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -377,6 +377,16 @@
   "declare function\n"
   "x();",  // TODO(martinprobst): should ideally be indented.
   NineCols);
+  verifyFormat("declare function foo();\n"
+   "let x = 1;\n");
+  verifyFormat("declare function foo(): string;\n"
+   "let x = 1;\n");
+  verifyFormat("declare function foo(): {x: number};\n"
+   "let x = 1;\n");
+  verifyFormat("declare class X {}\n"
+   "let x = 1;\n");
+  verifyFormat("declare interface Y {}\n"
+   "let x = 1;\n");
   verifyFormat(
   "declare enum X {\n"
   "}",


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -1255,10 +1255,13 @@
 if (FormatTok->is(tok::l_brace))
   tryToParseBracedList();
 else
-  while (FormatTok->isNot(tok::l_brace) && !eof())
+  while (!FormatTok->isOneOf(tok::l_brace, tok::semi) && !eof())
 nextToken();
   }
 
+  if (FormatTok->is(tok::semi))
+return;
+
   parseChildBlock();
 }
 
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -377,6 +377,16 @@
   "declare function\n"
   "x();",  // TODO(martinprobst): should ideally be indented.
   NineCols);
+  verifyFormat("declare function foo();\n"
+   "let x = 1;\n");
+  verifyFormat("declare function foo(): string;\n"
+   "let x = 1;\n");
+  verifyFormat("declare function foo(): {x: number};\n"
+   "let x = 1;\n");
+  verifyFormat("declare class X {}\n"
+   "let x = 1;\n");
+  verifyFormat("declare interface Y {}\n"
+   "let x = 1;\n");
   verifyFormat(
   "declare enum X {\n"
   "}",
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28246: clang-format: [JS] avoid indent after ambient function declarations.

2017-01-04 Thread Martin Probst via Phabricator via cfe-commits
mprobst marked an inline comment as done.
mprobst added inline comments.



Comment at: unittests/Format/FormatTestJS.cpp:382
+   "let x = 1;\n");
+  verifyFormat("declare function foo(): string;\n"
+   "let x = 1;\n");

sammccall wrote:
> Maybe include an inline object return type for completeness?
Done. There are still a lot of corner cases (e.g. union type with curlies in a 
latter type). We'd need to parse more or less the entire type grammar for that 
though :-/


Repository:
  rL LLVM

https://reviews.llvm.org/D28246



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


[PATCH] D27163: Introduce -f[no-]strict-return flag that controls code generation for C++'s undefined behaviour return optimisation

2017-01-04 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
arphaman marked 5 inline comments as done.
Closed by commit rL290960: Add -f[no-]strict-return flag that can be used to 
avoid undefined behaviour (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D27163?vs=81584&id=83041#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27163

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/include/clang/Frontend/CodeGenOptions.def
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGenCXX/return.cpp
  cfe/trunk/test/CodeGenObjCXX/return.mm
  cfe/trunk/test/Driver/clang_f_opts.c

Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
===
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def
@@ -251,6 +251,10 @@
 /// Whether copy relocations support is available when building as PIE.
 CODEGENOPT(PIECopyRelocations, 1, 0)
 
+/// Whether we should use the undefined behaviour optimization for control flow
+/// paths that reach the end of a function without executing a required return.
+CODEGENOPT(StrictReturn, 1, 1)
+
 #undef CODEGENOPT
 #undef ENUM_CODEGENOPT
 #undef VALUE_CODEGENOPT
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1331,6 +1331,12 @@
 def fno_unique_section_names : Flag <["-"], "fno-unique-section-names">,
   Group, Flags<[CC1Option]>;
 
+def fstrict_return : Flag<["-"], "fstrict-return">, Group,
+  Flags<[CC1Option]>,
+  HelpText<"Always treat control flow paths that fall off the end of a non-void"
+   "function as unreachable">;
+def fno_strict_return : Flag<["-"], "fno-strict-return">, Group,
+  Flags<[CC1Option]>;
 
 def fdebug_types_section: Flag <["-"], "fdebug-types-section">, Group,
   Flags<[CC1Option]>, HelpText<"Place debug types in their own section (ELF Only)">;
Index: cfe/trunk/test/CodeGenCXX/return.cpp
===
--- cfe/trunk/test/CodeGenCXX/return.cpp
+++ cfe/trunk/test/CodeGenCXX/return.cpp
@@ -1,12 +1,105 @@
-// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -o - %s | FileCheck %s
-// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -O -o - %s | FileCheck %s --check-prefix=CHECK-OPT
+// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -std=c++11 -o - %s | FileCheck --check-prefixes=CHECK,CHECK-COMMON %s
+// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -std=c++11 -O -o - %s | FileCheck %s --check-prefixes=CHECK-OPT,CHECK-COMMON
+// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -std=c++11 -fno-strict-return -o - %s | FileCheck %s --check-prefixes=CHECK-NOSTRICT,CHECK-COMMON
+// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -std=c++11 -fno-strict-return -Wno-return-type -o - %s | FileCheck %s --check-prefixes=CHECK-NOSTRICT,CHECK-COMMON
+// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -std=c++11 -fno-strict-return -O -o - %s | FileCheck %s --check-prefixes=CHECK-NOSTRICT-OPT,CHECK-COMMON
 
-// CHECK: @_Z9no_return
-// CHECK-OPT: @_Z9no_return
+// CHECK-COMMON-LABEL: @_Z9no_return
 int no_return() {
   // CHECK:  call void @llvm.trap
   // CHECK-NEXT: unreachable
 
   // CHECK-OPT-NOT: call void @llvm.trap
   // CHECK-OPT: unreachable
+
+  // -fno-strict-return should not emit trap + unreachable but it should return
+  // an undefined value instead.
+
+  // CHECK-NOSTRICT: entry:
+  // CHECK-NOSTRICT-NEXT: alloca
+  // CHECK-NOSTRICT-NEXT: load
+  // CHECK-NOSTRICT-NEXT: ret i32
+  // CHECK-NOSTRICT-NEXT: }
+
+  // CHECK-NOSTRICT-OPT: entry:
+  // CHECK-NOSTRICT-OPT: ret i32 undef
+}
+
+enum Enum {
+  A, B
+};
+
+// CHECK-COMMON-LABEL: @_Z27returnNotViableDontOptimize4Enum
+int returnNotViableDontOptimize(Enum e) {
+  switch (e) {
+  case A: return 1;
+  case B: return 2;
+  }
+  // Undefined behaviour optimization shouldn't be used when -fno-strict-return
+  // is turned on, even if all the enum cases are covered in this function.
+
+  // CHECK-NOSTRICT-NOT: call void @llvm.trap
+  // CHECK-NOSTRICT-NOT: unreachable
+}
+
+struct Trivial {
+  int x;
+};
+
+// CHECK-NOSTRICT-LABEL: @_Z7trivialv
+Trivial trivial() {
+  // This function returns a trivial record so -fno-strict-return should avoid
+  // the undefined behaviour optimization.
+
+  // CHECK-NOSTRICT-NOT: call void @llvm.trap
+  // CHECK-NOSTRICT-NOT: unreachable
+}
+
+struct NonTrivialCopy {
+  NonTrivialCopy(const NonTrivialCopy &);
+};
+
+// CHECK-NOSTRICT-LABEL: @_Z14nonTrivialCopyv
+NonTrivialCopy nonTrivialCopy() {
+  // CHECK-NOSTRICT-NOT: call void @llvm.trap
+  // CHECK-NOSTRICT-NOT: unreachable
+}
+
+struct NonTrivialDefaultConstructor {
+  int x;

r290960 - Add -f[no-]strict-return flag that can be used to avoid undefined behaviour

2017-01-04 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Jan  4 07:40:34 2017
New Revision: 290960

URL: http://llvm.org/viewvc/llvm-project?rev=290960&view=rev
Log:
Add -f[no-]strict-return flag that can be used to avoid undefined behaviour
in non-void functions that fall off at the end without returning a value when
compiling C++.

Clang uses the new compiler flag to determine when it should treat control flow
paths that fall off the end of a non-void function as unreachable. If
-fno-strict-return is on, the code generator emits the ureachable and trap
IR only when the function returns either a record type with a non-trivial
destructor or another non-trivially copyable type.

The primary goal of this flag is to avoid treating falling off the end of a
non-void function as undefined behaviour. The burden of undefined behaviour
is placed on the caller instead: if the caller ignores the returned value then
the undefined behaviour is avoided. This kind of behaviour is useful in
several cases, e.g. when compiling C code in C++ mode.

rdar://13102603

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

Added:
cfe/trunk/test/CodeGenObjCXX/return.mm
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGenCXX/return.cpp
cfe/trunk/test/Driver/clang_f_opts.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=290960&r1=290959&r2=290960&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Jan  4 07:40:34 2017
@@ -1331,6 +1331,12 @@ def funique_section_names : Flag <["-"],
 def fno_unique_section_names : Flag <["-"], "fno-unique-section-names">,
   Group, Flags<[CC1Option]>;
 
+def fstrict_return : Flag<["-"], "fstrict-return">, Group,
+  Flags<[CC1Option]>,
+  HelpText<"Always treat control flow paths that fall off the end of a 
non-void"
+   "function as unreachable">;
+def fno_strict_return : Flag<["-"], "fno-strict-return">, Group,
+  Flags<[CC1Option]>;
 
 def fdebug_types_section: Flag <["-"], "fdebug-types-section">, Group,
   Flags<[CC1Option]>, HelpText<"Place debug types in their own section (ELF 
Only)">;

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=290960&r1=290959&r2=290960&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Wed Jan  4 07:40:34 2017
@@ -251,6 +251,10 @@ CODEGENOPT(DiagnosticsWithHotness, 1, 0)
 /// Whether copy relocations support is available when building as PIE.
 CODEGENOPT(PIECopyRelocations, 1, 0)
 
+/// Whether we should use the undefined behaviour optimization for control flow
+/// paths that reach the end of a function without executing a required return.
+CODEGENOPT(StrictReturn, 1, 1)
+
 #undef CODEGENOPT
 #undef ENUM_CODEGENOPT
 #undef VALUE_CODEGENOPT

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=290960&r1=290959&r2=290960&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Wed Jan  4 07:40:34 2017
@@ -1049,6 +1049,19 @@ QualType CodeGenFunction::BuildFunctionA
   return ResTy;
 }
 
+static bool
+shouldUseUndefinedBehaviorReturnOptimization(const FunctionDecl *FD,
+ const ASTContext &Context) {
+  QualType T = FD->getReturnType();
+  // Avoid the optimization for functions that return a record type with a
+  // trivial destructor or another trivially copyable type.
+  if (const RecordType *RT = T.getCanonicalType()->getAs()) {
+if (const auto *ClassDecl = dyn_cast(RT->getDecl()))
+  return !ClassDecl->hasTrivialDestructor();
+  }
+  return !T.isTriviallyCopyableType(Context);
+}
+
 void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn,
const CGFunctionInfo &FnInfo) {
   const FunctionDecl *FD = cast(GD.getDecl());
@@ -1127,17 +1140,23 @@ void CodeGenFunction::GenerateCode(Globa
   //   function call is used by the caller, the behavior is undefined.
   if (getLangOpts().CPlusPlus && !FD->hasImplicitReturnZero() && !SawAsmBlock 
&&
   !FD->getReturnType()->isVoidType() && Builder.GetInsertBlock()) {
+bool ShouldEmitUnreachable =
+CGM.getCodeGenOpts().StrictReturn ||
+shouldUseUndefinedBehaviorReturnOptimization(FD, getContext(

[PATCH] D28229: [libcxx] Fix testing of the externally-threaded library build after r290850

2017-01-04 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath added a comment.

In https://reviews.llvm.org/D28229#634278, @compnerd wrote:

> I dont think that making Win32 threading an external one makes much sense 
> unless we also do the same for pthreads.  Its just as valid a threading model 
> as pthreads, so why give preferential treatment to that?  (Sure, there are 
> more buildbots using it, but thats not a strong technical justification).


If the Win32 threading is support is going to be upstreamed, yes, it makes 
sense to give it the same treatment as pthreads (keep it inside 
`__threading_support`). libcxx has been tied to pthreads for a while, would be 
good to see something else supported as well. This will also allow us to iron 
out pthread-isms from the sources into the threading API. I have a couple of 
patches in that area (which I discovered while implementing the libcxx 
threading API with a different thread implementation), will put them up for 
review soon.




Comment at: include/__threading_support:30-50
 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) && \
+!__libcpp_has_include(<__external_threading>)
+// If the <__external_threading> header is absent, build libc++ against a
+// pthread-oriented thread api but leave out its implementation. This setup
+// allows building+testing of an externally-threaded library variant (on any
+// platform that supports pthreads). Here, an 'externally-threaded' library
+// variant is one where the implementation of the libc++ thread api is provided

compnerd wrote:
> Can you break this down into this which IMO is far more readable:
> 
> #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
> #if __libcpp_has_include()
> #include <__external_threading>
> #else
> // Why pthread?
> #define _LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD
> #endif
> #endif
> 
> #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) ||
> defined(_LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD)
> #include 
> #include 
> #endif
The reason I kept it in the current form is, when `__external_threading` is 
present, everything else in this header needs to be silenced. This is enforced 
by the current form because everything else in this header lives inside the 
`#else` side of the `__external_threading` inclusion.

Sure, the header will be a bit more readable if we arrange it the way you 
suggested, but then it's easy to add something to the header in a way that does 
not get removed when `__external_threading` is present.


https://reviews.llvm.org/D28229



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


[PATCH] D27478: Make ASTContext::getDeclAlign return the correct alignment for FunctionDecls

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

Thanks. LGTM, I think the patch makes sense.


https://reviews.llvm.org/D27478



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


Re: [PATCH] D27123: Add AVR target and toolchain to Clang

2017-01-04 Thread Jonathan Roelofs via cfe-commits



On 1/4/17 2:52 AM, Dylan McKay wrote:

I've just raised a bug here

https://llvm.org/bugs/show_bug.cgi?id=31530

> What's necessary for sign-off? Should I ping the reviewer (Richard 
Smith) again?


I think so long as Richard or someone else who actively works on Clang 
signs off. Perhaps somebody else is keen to review?


On the other hand, I can review it and then ask if there aren't any 
objections to it being in-tree within a few days, I can commit it.


LGTM


Jon



On Wed, Jan 4, 2017 at 7:20 PM, Senthil Kumar Selvaraj 
> wrote:



Dylan McKay writes:

> Did you get the BugZilla account sorted Senthil?

Nope, direct email also didn't help. Can you please file a bug with

Title:

UINT16_TYPE and INT16_TYPE are defined as short instead of int for AVR

Description:

   UINT16_TYPE and INT16_TYPE are implicitly defined by the
preprocessor
   to the short type, rather than int. While shorts and ints are both
   16 bits wide on the avr, gcc picks ints to represent 16 bits
wherever
   possible, and picking short can cause issues with C++ name mangling
   (see https://reviews.llvm.org/D27123#615854
). Therefore, clang should
   define the two types to short.

   Clang's
lib/Frontend/InitPreprocessor.cpp::DefineExactWidthIntType does not
   use TargetInfo::getIntTypeByWidth. Instead,
   InitializePredefinedMacros calls
   the function with the specific type
(SignedShort/UnsignedShort), because
   getShortWidth() > getCharWidth(), but getIntWidth() ==
   getShortWidth().


What's necessary for sign-off? Should I ping the reviewer (Richard
Smith) again?

Regards
Senthil




--
Jon Roelofs
jonat...@codesourcery.com
CodeSourcery / Mentor Embedded

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


[PATCH] D28282: [change-namespace] get whitespaces right when moving old namespaces.

2017-01-04 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM with some nits.

Would be clearer to elaborate more descriptions in the commit message. Looks 
like the patch actually resolves newline character "\n" rather than 
whitespace...




Comment at: change-namespace/ChangeNamespace.cpp:568
+  MoveNs.Length =
+  SM.getFileOffset(NsDecl->getRBraceLoc()) - SM.getFileOffset(Start);
 

Maybe use `MoveNs.Offset` instead of recalling `SM.getFileOffset(Start);`


https://reviews.llvm.org/D28282



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


[PATCH] D28282: [change-namespace] get whitespaces right when moving old namespaces.

2017-01-04 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 83051.
ioeric marked an inline comment as done.
ioeric added a comment.

- fix a nit.


https://reviews.llvm.org/D28282

Files:
  change-namespace/ChangeNamespace.cpp
  unittests/change-namespace/ChangeNamespaceTests.cpp

Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -110,12 +110,52 @@
  "namespace nc {\n"
  "class A {};\n"
  "} // namespace nc\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
+TEST_F(ChangeNamespaceTest, NewNsNestedInOldNsWithSurroundingNewLines) {
+  NewNamespace = "na::nb::nc";
+  std::string Code = "namespace na {\n"
+ "namespace nb {\n"
+ "\n"
+ "class A {};\n"
+ "\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "namespace na {\n"
+ "namespace nb {\n"
+ "namespace nc {\n"
+ "\n"
+ "class A {};\n"
  "\n"
+ "} // namespace nc\n"
  "} // namespace nb\n"
  "} // namespace na\n";
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, MoveOldNsWithSurroundingNewLines) {
+  NewNamespace = "nx::ny";
+  std::string Code = "namespace na {\n"
+ "namespace nb {\n"
+ "\n"
+ "class A {};\n"
+ "\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "\n\n"
+ "namespace nx {\n"
+ "namespace ny {\n"
+ "\n"
+ "class A {};\n"
+ "\n"
+ "} // namespace ny\n"
+ "} // namespace nx\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 TEST_F(ChangeNamespaceTest, NewNsNestedInOldNsWithRefs) {
   NewNamespace = "na::nb::nc";
   std::string Code = "namespace na {\n"
@@ -134,7 +174,6 @@
  "class C {};\n"
  "void f() { A a; B b; }\n"
  "} // namespace nc\n"
- "\n"
  "} // namespace nb\n"
  "} // namespace na\n";
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
@@ -1497,7 +1536,7 @@
  "void f() {\n"
  "  GG g;\n"
  "}\n"
- "} // namespace nc\n\n"
+ "} // namespace nc\n"
  "} // namespace nb\n"
  "} // namespace na\n";
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
@@ -1554,7 +1593,7 @@
  "  struct Derived::Nested nested;\n"
  "  const struct Derived::Nested *nested_ptr;\n"
  "}\n"
- "} // namespace nc\n\n"
+ "} // namespace nc\n"
  "} // namespace nb\n"
  "} // namespace na\n";
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -555,17 +555,16 @@
   if (Decl::castToDeclContext(NsDecl)->decls_empty())
 return;
 
+  const SourceManager &SM = *Result.SourceManager;
   // Get the range of the code in the old namespace.
-  SourceLocation Start = getLocAfterNamespaceLBrace(
-  NsDecl, *Result.SourceManager, Result.Context->getLangOpts());
+  SourceLocation Start =
+  getLocAfterNamespaceLBrace(NsDecl, SM, Result.Context->getLangOpts());
   assert(Start.isValid() && "Can't find l_brace for namespace.");
-  SourceLocation End = NsDecl->getRBraceLoc().getLocWithOffset(-1);
-  // Create a replacement that deletes the code in the old namespace merely for
-  // retrieving offset and length from it.
-  const auto R = createReplacement(Start, End, "", *Result.SourceManager);
   MoveNamespace MoveNs;
-  MoveNs.Offset = R.getOffset();
-  MoveNs.Length = R.getLength();
+  MoveNs.Offset = SM.getFileOffset(Start);
+  // The range of the moved namespace is from the location just past the left
+  // brace to the location right before the right brace.
+  MoveNs.Length = SM.getFileOffset(NsDecl->get

[clang-tools-extra] r290966 - [change-namespace] get newlines around moved namespace right.

2017-01-04 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed Jan  4 08:49:08 2017
New Revision: 290966

URL: http://llvm.org/viewvc/llvm-project?rev=290966&view=rev
Log:
[change-namespace] get newlines around moved namespace right.

Summary: Previously, a `\n` might be left in the old namespace and thus not 
copied to the new namespace, which is bad.

Reviewers: hokein

Subscribers: alexshap, cfe-commits

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

Modified:
clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.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=290966&r1=290965&r2=290966&view=diff
==
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp (original)
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Wed Jan  4 
08:49:08 2017
@@ -555,17 +555,16 @@ void ChangeNamespaceTool::moveOldNamespa
   if (Decl::castToDeclContext(NsDecl)->decls_empty())
 return;
 
+  const SourceManager &SM = *Result.SourceManager;
   // Get the range of the code in the old namespace.
-  SourceLocation Start = getLocAfterNamespaceLBrace(
-  NsDecl, *Result.SourceManager, Result.Context->getLangOpts());
+  SourceLocation Start =
+  getLocAfterNamespaceLBrace(NsDecl, SM, Result.Context->getLangOpts());
   assert(Start.isValid() && "Can't find l_brace for namespace.");
-  SourceLocation End = NsDecl->getRBraceLoc().getLocWithOffset(-1);
-  // Create a replacement that deletes the code in the old namespace merely for
-  // retrieving offset and length from it.
-  const auto R = createReplacement(Start, End, "", *Result.SourceManager);
   MoveNamespace MoveNs;
-  MoveNs.Offset = R.getOffset();
-  MoveNs.Length = R.getLength();
+  MoveNs.Offset = SM.getFileOffset(Start);
+  // The range of the moved namespace is from the location just past the left
+  // brace to the location right before the right brace.
+  MoveNs.Length = SM.getFileOffset(NsDecl->getRBraceLoc()) - MoveNs.Offset;
 
   // Insert the new namespace after `DiffOldNamespace`. For example, if
   // `OldNamespace` is "a::b::c" and `NewNamespace` is `a::x::y`, then
@@ -577,18 +576,16 @@ void ChangeNamespaceTool::moveOldNamespa
   const NamespaceDecl *OuterNs = getOuterNamespace(NsDecl, DiffOldNamespace);
   SourceLocation InsertionLoc = Start;
   if (OuterNs) {
-SourceLocation LocAfterNs =
-getStartOfNextLine(OuterNs->getRBraceLoc(), *Result.SourceManager,
-   Result.Context->getLangOpts());
+SourceLocation LocAfterNs = getStartOfNextLine(
+OuterNs->getRBraceLoc(), SM, Result.Context->getLangOpts());
 assert(LocAfterNs.isValid() &&
"Failed to get location after DiffOldNamespace");
 InsertionLoc = LocAfterNs;
   }
-  MoveNs.InsertionOffset = Result.SourceManager->getFileOffset(
-  Result.SourceManager->getSpellingLoc(InsertionLoc));
-  MoveNs.FID = Result.SourceManager->getFileID(Start);
+  MoveNs.InsertionOffset = SM.getFileOffset(SM.getSpellingLoc(InsertionLoc));
+  MoveNs.FID = SM.getFileID(Start);
   MoveNs.SourceMgr = Result.SourceManager;
-  MoveNamespaces[R.getFilePath()].push_back(MoveNs);
+  MoveNamespaces[SM.getFilename(Start)].push_back(MoveNs);
 }
 
 // Removes a class forward declaration from the code in the moved namespace and

Modified: 
clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp?rev=290966&r1=290965&r2=290966&view=diff
==
--- clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp 
Wed Jan  4 08:49:08 2017
@@ -110,12 +110,52 @@ TEST_F(ChangeNamespaceTest, NewNsNestedI
  "namespace nc {\n"
  "class A {};\n"
  "} // namespace nc\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
+TEST_F(ChangeNamespaceTest, NewNsNestedInOldNsWithSurroundingNewLines) {
+  NewNamespace = "na::nb::nc";
+  std::string Code = "namespace na {\n"
+ "namespace nb {\n"
+ "\n"
+ "class A {};\n"
+ "\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "namespace na {\n"
+ "namespace nb {\n"
+ "namespace nc {\n"
+ "\n"
+ "class A {};\n"
  

[PATCH] D28282: [change-namespace] get newlines around moved namespace right.

2017-01-04 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290966: [change-namespace] get newlines around moved 
namespace right. (authored by ioeric).

Changed prior to commit:
  https://reviews.llvm.org/D28282?vs=83051&id=83052#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28282

Files:
  clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
  clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp

Index: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
===
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
@@ -555,17 +555,16 @@
   if (Decl::castToDeclContext(NsDecl)->decls_empty())
 return;
 
+  const SourceManager &SM = *Result.SourceManager;
   // Get the range of the code in the old namespace.
-  SourceLocation Start = getLocAfterNamespaceLBrace(
-  NsDecl, *Result.SourceManager, Result.Context->getLangOpts());
+  SourceLocation Start =
+  getLocAfterNamespaceLBrace(NsDecl, SM, Result.Context->getLangOpts());
   assert(Start.isValid() && "Can't find l_brace for namespace.");
-  SourceLocation End = NsDecl->getRBraceLoc().getLocWithOffset(-1);
-  // Create a replacement that deletes the code in the old namespace merely for
-  // retrieving offset and length from it.
-  const auto R = createReplacement(Start, End, "", *Result.SourceManager);
   MoveNamespace MoveNs;
-  MoveNs.Offset = R.getOffset();
-  MoveNs.Length = R.getLength();
+  MoveNs.Offset = SM.getFileOffset(Start);
+  // The range of the moved namespace is from the location just past the left
+  // brace to the location right before the right brace.
+  MoveNs.Length = SM.getFileOffset(NsDecl->getRBraceLoc()) - MoveNs.Offset;
 
   // Insert the new namespace after `DiffOldNamespace`. For example, if
   // `OldNamespace` is "a::b::c" and `NewNamespace` is `a::x::y`, then
@@ -577,18 +576,16 @@
   const NamespaceDecl *OuterNs = getOuterNamespace(NsDecl, DiffOldNamespace);
   SourceLocation InsertionLoc = Start;
   if (OuterNs) {
-SourceLocation LocAfterNs =
-getStartOfNextLine(OuterNs->getRBraceLoc(), *Result.SourceManager,
-   Result.Context->getLangOpts());
+SourceLocation LocAfterNs = getStartOfNextLine(
+OuterNs->getRBraceLoc(), SM, Result.Context->getLangOpts());
 assert(LocAfterNs.isValid() &&
"Failed to get location after DiffOldNamespace");
 InsertionLoc = LocAfterNs;
   }
-  MoveNs.InsertionOffset = Result.SourceManager->getFileOffset(
-  Result.SourceManager->getSpellingLoc(InsertionLoc));
-  MoveNs.FID = Result.SourceManager->getFileID(Start);
+  MoveNs.InsertionOffset = SM.getFileOffset(SM.getSpellingLoc(InsertionLoc));
+  MoveNs.FID = SM.getFileID(Start);
   MoveNs.SourceMgr = Result.SourceManager;
-  MoveNamespaces[R.getFilePath()].push_back(MoveNs);
+  MoveNamespaces[SM.getFilename(Start)].push_back(MoveNs);
 }
 
 // Removes a class forward declaration from the code in the moved namespace and
Index: clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
+++ clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -110,12 +110,52 @@
  "namespace nc {\n"
  "class A {};\n"
  "} // namespace nc\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
+TEST_F(ChangeNamespaceTest, NewNsNestedInOldNsWithSurroundingNewLines) {
+  NewNamespace = "na::nb::nc";
+  std::string Code = "namespace na {\n"
+ "namespace nb {\n"
+ "\n"
+ "class A {};\n"
+ "\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "namespace na {\n"
+ "namespace nb {\n"
+ "namespace nc {\n"
+ "\n"
+ "class A {};\n"
  "\n"
+ "} // namespace nc\n"
  "} // namespace nb\n"
  "} // namespace na\n";
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, MoveOldNsWithSurroundingNewLines) {
+  NewNamespace = "nx::ny";
+  std::string Code = "namespace na {\n"
+ "namespace nb {\n"
+ "\n"
+ "class A {};\n"
+ "\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "\n\n"
+ 

[PATCH] D28279: [clang-move] Support moving type alias declarations.

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

Changed prior to commit:
  https://reviews.llvm.org/D28279?vs=83016&id=83053#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28279

Files:
  clang-tools-extra/trunk/clang-move/ClangMove.cpp
  clang-tools-extra/trunk/test/clang-move/Inputs/type_alias.h
  clang-tools-extra/trunk/test/clang-move/move-type-alias.cpp
  clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp

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
@@ -166,6 +166,27 @@
   ClangMoveTool *MoveTool;
 };
 
+class TypeAliasMatch : public MatchFinder::MatchCallback {
+public:
+  explicit TypeAliasMatch(ClangMoveTool *MoveTool)
+  : MoveTool(MoveTool) {}
+
+  void run(const MatchFinder::MatchResult &Result) override {
+if (const auto *TD = Result.Nodes.getNodeAs("typedef"))
+  MoveDeclFromOldFileToNewFile(MoveTool, TD);
+else if (const auto *TAD =
+ Result.Nodes.getNodeAs("type_alias")) {
+  const NamedDecl * D = TAD;
+  if (const auto * TD = TAD->getDescribedAliasTemplate())
+D = TD;
+  MoveDeclFromOldFileToNewFile(MoveTool, D);
+}
+  }
+
+private:
+  ClangMoveTool *MoveTool;
+};
+
 class EnumDeclarationMatch : public MatchFinder::MatchCallback {
 public:
   explicit EnumDeclarationMatch(ClangMoveTool *MoveTool)
@@ -587,13 +608,22 @@
  .bind("function"),
  MatchCallbacks.back().get());
 
-  // Match enum definition in old.h. Enum helpers (which are definied in old.cc)
+  // Match enum definition in old.h. Enum helpers (which are defined in old.cc)
   // will not be moved for now no matter whether they are used or not.
   MatchCallbacks.push_back(llvm::make_unique(this));
   Finder->addMatcher(
   enumDecl(InOldHeader, *HasAnySymbolNames, isDefinition(), TopLevelDecl)
   .bind("enum"),
   MatchCallbacks.back().get());
+
+  // Match type alias in old.h, this includes "typedef" and "using" type alias
+  // declarations. Type alias helpers (which are defined in old.cc) will not be
+  // moved for now no matter whether they are used or not.
+  MatchCallbacks.push_back(llvm::make_unique(this));
+  Finder->addMatcher(namedDecl(anyOf(typedefDecl().bind("typedef"),
+ typeAliasDecl().bind("type_alias")),
+   InOldHeader, *HasAnySymbolNames, TopLevelDecl),
+ MatchCallbacks.back().get());
 }
 
 void ClangMoveTool::run(const ast_matchers::MatchFinder::MatchResult &Result) {
@@ -828,6 +858,9 @@
 case Decl::Kind::ClassTemplate:
 case Decl::Kind::CXXRecord:
 case Decl::Kind::Enum:
+case Decl::Kind::Typedef:
+case Decl::Kind::TypeAlias:
+case Decl::Kind::TypeAliasTemplate:
   return true;
 default:
   return false;
Index: clang-tools-extra/trunk/test/clang-move/Inputs/type_alias.h
===
--- clang-tools-extra/trunk/test/clang-move/Inputs/type_alias.h
+++ clang-tools-extra/trunk/test/clang-move/Inputs/type_alias.h
@@ -0,0 +1,11 @@
+typedef int Int1;
+using Int2 = int;
+
+template
+struct A {};
+
+template  using B = A;
+
+class C {
+  typedef int Int3;
+};
Index: clang-tools-extra/trunk/test/clang-move/move-type-alias.cpp
===
--- clang-tools-extra/trunk/test/clang-move/move-type-alias.cpp
+++ clang-tools-extra/trunk/test/clang-move/move-type-alias.cpp
@@ -0,0 +1,52 @@
+// RUN: mkdir -p %T/move-type-alias
+// RUN: cp %S/Inputs/type_alias.h  %T/move-type-alias/type_alias.h
+// RUN: echo '#include "type_alias.h"' > %T/move-type-alias/type_alias.cpp
+// RUN: cd %T/move-type-alias
+//
+// -
+// Test moving typedef declarations.
+// -
+// RUN: clang-move -names="Int1" -new_cc=%T/move-type-alias/new_test.cpp -new_header=%T/move-type-alias/new_test.h -old_cc=%T/move-type-alias/type_alias.cpp -old_header=%T/move-type-alias/type_alias.h %T/move-type-alias/type_alias.cpp -- -std=c++11
+// RUN: FileCheck -input-file=%T/move-type-alias/new_test.h -check-prefix=CHECK-NEW-TEST-H-CASE1 %s
+// RUN: FileCheck -input-file=%T/move-type-alias/type_alias.h -check-prefix=CHECK-OLD-TEST-H-CASE1 %s
+
+// CHECK-NEW-TEST-H-CASE1: typedef int Int1;
+
+// CHECK-OLD-TEST-H-CASE1-NOT: typedef int Int1;
+
+
+// -
+// Test moving type alias declarations.
+// -
+// RUN: cp %S

[clang-tools-extra] r290967 - [clang-move] Support moving type alias declarations.

2017-01-04 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed Jan  4 08:50:49 2017
New Revision: 290967

URL: http://llvm.org/viewvc/llvm-project?rev=290967&view=rev
Log:
[clang-move] Support moving type alias declarations.

Reviewers: ioeric

Subscribers: cfe-commits

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

Added:
clang-tools-extra/trunk/test/clang-move/Inputs/type_alias.h
clang-tools-extra/trunk/test/clang-move/move-type-alias.cpp
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=290967&r1=290966&r2=290967&view=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Wed Jan  4 08:50:49 2017
@@ -166,6 +166,27 @@ private:
   ClangMoveTool *MoveTool;
 };
 
+class TypeAliasMatch : public MatchFinder::MatchCallback {
+public:
+  explicit TypeAliasMatch(ClangMoveTool *MoveTool)
+  : MoveTool(MoveTool) {}
+
+  void run(const MatchFinder::MatchResult &Result) override {
+if (const auto *TD = Result.Nodes.getNodeAs("typedef"))
+  MoveDeclFromOldFileToNewFile(MoveTool, TD);
+else if (const auto *TAD =
+ Result.Nodes.getNodeAs("type_alias")) {
+  const NamedDecl * D = TAD;
+  if (const auto * TD = TAD->getDescribedAliasTemplate())
+D = TD;
+  MoveDeclFromOldFileToNewFile(MoveTool, D);
+}
+  }
+
+private:
+  ClangMoveTool *MoveTool;
+};
+
 class EnumDeclarationMatch : public MatchFinder::MatchCallback {
 public:
   explicit EnumDeclarationMatch(ClangMoveTool *MoveTool)
@@ -587,13 +608,22 @@ void ClangMoveTool::registerMatchers(ast
  .bind("function"),
  MatchCallbacks.back().get());
 
-  // Match enum definition in old.h. Enum helpers (which are definied in 
old.cc)
+  // Match enum definition in old.h. Enum helpers (which are defined in old.cc)
   // will not be moved for now no matter whether they are used or not.
   MatchCallbacks.push_back(llvm::make_unique(this));
   Finder->addMatcher(
   enumDecl(InOldHeader, *HasAnySymbolNames, isDefinition(), TopLevelDecl)
   .bind("enum"),
   MatchCallbacks.back().get());
+
+  // Match type alias in old.h, this includes "typedef" and "using" type alias
+  // declarations. Type alias helpers (which are defined in old.cc) will not be
+  // moved for now no matter whether they are used or not.
+  MatchCallbacks.push_back(llvm::make_unique(this));
+  Finder->addMatcher(namedDecl(anyOf(typedefDecl().bind("typedef"),
+ typeAliasDecl().bind("type_alias")),
+   InOldHeader, *HasAnySymbolNames, TopLevelDecl),
+ MatchCallbacks.back().get());
 }
 
 void ClangMoveTool::run(const ast_matchers::MatchFinder::MatchResult &Result) {
@@ -828,6 +858,9 @@ void ClangMoveTool::onEndOfTranslationUn
 case Decl::Kind::ClassTemplate:
 case Decl::Kind::CXXRecord:
 case Decl::Kind::Enum:
+case Decl::Kind::Typedef:
+case Decl::Kind::TypeAlias:
+case Decl::Kind::TypeAliasTemplate:
   return true;
 default:
   return false;

Added: clang-tools-extra/trunk/test/clang-move/Inputs/type_alias.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/Inputs/type_alias.h?rev=290967&view=auto
==
--- clang-tools-extra/trunk/test/clang-move/Inputs/type_alias.h (added)
+++ clang-tools-extra/trunk/test/clang-move/Inputs/type_alias.h Wed Jan  4 
08:50:49 2017
@@ -0,0 +1,11 @@
+typedef int Int1;
+using Int2 = int;
+
+template
+struct A {};
+
+template  using B = A;
+
+class C {
+  typedef int Int3;
+};

Added: clang-tools-extra/trunk/test/clang-move/move-type-alias.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/move-type-alias.cpp?rev=290967&view=auto
==
--- clang-tools-extra/trunk/test/clang-move/move-type-alias.cpp (added)
+++ clang-tools-extra/trunk/test/clang-move/move-type-alias.cpp Wed Jan  4 
08:50:49 2017
@@ -0,0 +1,52 @@
+// RUN: mkdir -p %T/move-type-alias
+// RUN: cp %S/Inputs/type_alias.h  %T/move-type-alias/type_alias.h
+// RUN: echo '#include "type_alias.h"' > %T/move-type-alias/type_alias.cpp
+// RUN: cd %T/move-type-alias
+//
+// 
-
+// Test moving typedef declarations.
+// 
-
+// RUN: clang-move -names="Int1" -new_cc=%T/move-type-alias/new_test.cpp 
-new_header=%T/move-type-alias/new_test.h 
-old_cc=%T/move-type-alias/type_alias.cpp 
-old_header

[PATCH] D28257: [OpenCL] Re-enable supported core extensions based on opencl version when disabling all extensions using pragma

2017-01-04 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: test/SemaOpenCL/extensions.cl:47
 
+#ifndef _OPENCL_H_
 int isnan(float x) {

Why do you need this?


https://reviews.llvm.org/D28257



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


Re: [PATCH] D27123: Add AVR target and toolchain to Clang

2017-01-04 Thread Dylan McKay via cfe-commits
Did you get the BugZilla account sorted Senthil?

On Thu, Dec 22, 2016 at 10:47 AM, Nico Weber  wrote:

> On Wed, Dec 21, 2016 at 6:42 AM, Senthil Kumar Selvaraj via Phabricator
> via cfe-commits  wrote:
>
>> saaadhu added a comment.
>>
>> Would someone with a llvm bugzilla account please file the PR for me? New
>> user registration is disabled, and I've been waiting for
>> llvm-ad...@lists.llvm.org to respond for nearly a week now.
>>
>
> Email to...@nondot.org directly, see http://lists.llvm.org/
> pipermail/cfe-dev/2016-December/051921.html
>
>
>>
>> And how should I proceed after that? Would one of the reviewers commit
>> the patch for me?
>>
>>
>> https://reviews.llvm.org/D27123
>>
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D27123: Add AVR target and toolchain to Clang

2017-01-04 Thread Dylan McKay via cfe-commits
I've just raised a bug here

https://llvm.org/bugs/show_bug.cgi?id=31530

> What's necessary for sign-off? Should I ping the reviewer (Richard Smith)
again?

I think so long as Richard or someone else who actively works on Clang
signs off. Perhaps somebody else is keen to review?

On the other hand, I can review it and then ask if there aren't any
objections to it being in-tree within a few days, I can commit it.

On Wed, Jan 4, 2017 at 7:20 PM, Senthil Kumar Selvaraj <
senthilkumar.selva...@microchip.com> wrote:

>
> Dylan McKay writes:
>
> > Did you get the BugZilla account sorted Senthil?
>
> Nope, direct email also didn't help. Can you please file a bug with
>
> Title:
>
> UINT16_TYPE and INT16_TYPE are defined as short instead of int for AVR
>
> Description:
>
>UINT16_TYPE and INT16_TYPE are implicitly defined by the preprocessor
>to the short type, rather than int. While shorts and ints are both
>16 bits wide on the avr, gcc picks ints to represent 16 bits wherever
>possible, and picking short can cause issues with C++ name mangling
>(see https://reviews.llvm.org/D27123#615854). Therefore, clang should
>define the two types to short.
>
>Clang's lib/Frontend/InitPreprocessor.cpp::DefineExactWidthIntType
> does not
>use TargetInfo::getIntTypeByWidth. Instead,
>InitializePredefinedMacros calls
>the function with the specific type (SignedShort/UnsignedShort), because
>getShortWidth() > getCharWidth(), but getIntWidth() ==
>getShortWidth().
>
>
> What's necessary for sign-off? Should I ping the reviewer (Richard Smith)
> again?
>
> Regards
> Senthil
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28287: [clang-tidy] Ignore default arguments in modernize-default-member-init

2017-01-04 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Btw, when creating a patch, it's helpful to the reviewers (especially ones who 
are only casually interested) to put some of the context from the bug report 
into the patch summary rather than only list the PR.




Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:161
 cxxBoolLiteral(), cxxNullPtrLiteralExpr(), implicitValueInitExpr(),
-declRefExpr());
+declRefExpr(unless(to(varDecl();
 

Any `varDecl`? Or do we want to limit it to only `parmVarDecl` instead?
```
int i = 12;
struct S {
  int j;
  S() : j(i) {}
};
```
It seems reasonable to suggest the member initialization be "fixed" to: `int j 
= i;`


https://reviews.llvm.org/D28287



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


r290968 - Fix a buildbot failure introduced by r290960.

2017-01-04 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Jan  4 09:07:13 2017
New Revision: 290968

URL: http://llvm.org/viewvc/llvm-project?rev=290968&view=rev
Log:
Fix a buildbot failure introduced by r290960.

The commit r290960 checked the the basic block label name which isn't there
when clang is compiled in release mode.

Modified:
cfe/trunk/test/CodeGenCXX/return.cpp

Modified: cfe/trunk/test/CodeGenCXX/return.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/return.cpp?rev=290968&r1=290967&r2=290968&view=diff
==
--- cfe/trunk/test/CodeGenCXX/return.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/return.cpp Wed Jan  4 09:07:13 2017
@@ -15,13 +15,11 @@ int no_return() {
   // -fno-strict-return should not emit trap + unreachable but it should return
   // an undefined value instead.
 
-  // CHECK-NOSTRICT: entry:
-  // CHECK-NOSTRICT-NEXT: alloca
+  // CHECK-NOSTRICT: alloca
   // CHECK-NOSTRICT-NEXT: load
   // CHECK-NOSTRICT-NEXT: ret i32
   // CHECK-NOSTRICT-NEXT: }
 
-  // CHECK-NOSTRICT-OPT: entry:
   // CHECK-NOSTRICT-OPT: ret i32 undef
 }
 


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


[PATCH] D28287: [clang-tidy] Ignore default arguments in modernize-default-member-init

2017-01-04 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added inline comments.



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:161
 cxxBoolLiteral(), cxxNullPtrLiteralExpr(), implicitValueInitExpr(),
-declRefExpr());
+declRefExpr(unless(to(varDecl();
 

aaron.ballman wrote:
> Any `varDecl`? Or do we want to limit it to only `parmVarDecl` instead?
> ```
> int i = 12;
> struct S {
>   int j;
>   S() : j(i) {}
> };
> ```
> It seems reasonable to suggest the member initialization be "fixed" to: `int 
> j = i;`
I would find a default member initializer that is not a constant to be 
surprising.
Maybe I want to limit it to `enumConstantDecl`.


https://reviews.llvm.org/D28287



___
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-04 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: ioeric.
hokein added a subscriber: cfe-commits.

https://reviews.llvm.org/D28293

Files:
  clang-move/ClangMove.cpp
  unittests/clang-move/ClangMoveTests.cpp


Index: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ 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-move/ClangMove.cpp
===
--- clang-move/ClangMove.cpp
+++ 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: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ 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-move/ClangMove.cpp
===
--- clang-move

[PATCH] D28287: [clang-tidy] Ignore default arguments in modernize-default-member-init

2017-01-04 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons updated this revision to Diff 83056.
malcolm.parsons added a comment.

Only match DeclRefExprs to EnumConstantDecls.


https://reviews.llvm.org/D28287

Files:
  clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
  test/clang-tidy/modernize-use-default-member-init.cpp


Index: test/clang-tidy/modernize-use-default-member-init.cpp
===
--- test/clang-tidy/modernize-use-default-member-init.cpp
+++ test/clang-tidy/modernize-use-default-member-init.cpp
@@ -221,6 +221,12 @@
   int i;
 };
 
+struct NegativeDefaultArg
+{
+  NegativeDefaultArg(int i = 4) : i(i) {}
+  int i;
+};
+
 struct ExistingChar {
   ExistingChar(short) : e1(), e2(), e3(), e4() {}
   // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: member initializer for 'e1' is 
redundant [modernize-use-default-member-init]
Index: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -158,7 +158,7 @@
 unaryOperator(anyOf(hasOperatorName("+"), hasOperatorName("-")),
   hasUnaryOperand(floatLiteral())),
 cxxBoolLiteral(), cxxNullPtrLiteralExpr(), implicitValueInitExpr(),
-declRefExpr());
+declRefExpr(to(enumConstantDecl(;
 
   Finder->addMatcher(
   cxxConstructorDecl(


Index: test/clang-tidy/modernize-use-default-member-init.cpp
===
--- test/clang-tidy/modernize-use-default-member-init.cpp
+++ test/clang-tidy/modernize-use-default-member-init.cpp
@@ -221,6 +221,12 @@
   int i;
 };
 
+struct NegativeDefaultArg
+{
+  NegativeDefaultArg(int i = 4) : i(i) {}
+  int i;
+};
+
 struct ExistingChar {
   ExistingChar(short) : e1(), e2(), e3(), e4() {}
   // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: member initializer for 'e1' is redundant [modernize-use-default-member-init]
Index: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -158,7 +158,7 @@
 unaryOperator(anyOf(hasOperatorName("+"), hasOperatorName("-")),
   hasUnaryOperand(floatLiteral())),
 cxxBoolLiteral(), cxxNullPtrLiteralExpr(), implicitValueInitExpr(),
-declRefExpr());
+declRefExpr(to(enumConstantDecl(;
 
   Finder->addMatcher(
   cxxConstructorDecl(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28287: [clang-tidy] Ignore default arguments in modernize-default-member-init

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



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:161
 cxxBoolLiteral(), cxxNullPtrLiteralExpr(), implicitValueInitExpr(),
-declRefExpr());
+declRefExpr(unless(to(varDecl();
 

malcolm.parsons wrote:
> aaron.ballman wrote:
> > Any `varDecl`? Or do we want to limit it to only `parmVarDecl` instead?
> > ```
> > int i = 12;
> > struct S {
> >   int j;
> >   S() : j(i) {}
> > };
> > ```
> > It seems reasonable to suggest the member initialization be "fixed" to: 
> > `int j = i;`
> I would find a default member initializer that is not a constant to be 
> surprising.
> Maybe I want to limit it to `enumConstantDecl`.
I wouldn't; consider a global synchronization object, like a mutex (this is a 
relatively common thing).


https://reviews.llvm.org/D28287



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


[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

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



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:34
+  // a tag declaration (e.g. struct, class etc.):
+  // class A { } Object1, Object2;  <-- won't be matched
+  Finder->addMatcher(

firolino wrote:
> aaron.ballman wrote:
> > firolino wrote:
> > > aaron.ballman wrote:
> > > > firolino wrote:
> > > > > firolino wrote:
> > > > > > firolino wrote:
> > > > > > > firolino wrote:
> > > > > > > > aaron.ballman wrote:
> > > > > > > > > firolino wrote:
> > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > Why do we not want to match this?
> > > > > > > > > > If we decide, whether we transform 
> > > > > > > > > > ```
> > > > > > > > > > class A { 
> > > > > > > > > > } Object1, Object2;
> > > > > > > > > > ``` 
> > > > > > > > > > to
> > > > > > > > > > ```
> > > > > > > > > > class A { 
> > > > > > > > > > } Object1, 
> > > > > > > > > > Object2;
> > > > > > > > > > ``` 
> > > > > > > > > > or
> > > > > > > > > > ```
> > > > > > > > > > class A { 
> > > > > > > > > > } 
> > > > > > > > > > Object1, 
> > > > > > > > > > Object2;
> > > > > > > > > > ``` 
> > > > > > > > > > I might consider adding support for it. Moreover, this kind 
> > > > > > > > > > of definition is usually seen globally and I don't know how 
> > > > > > > > > > to handle globals yet. See 
> > > > > > > > > > http://lists.llvm.org/pipermail/cfe-dev/2015-November/046262.html
> > > > > > > > > I think this should be handled. It can be handled in either 
> > > > > > > > > of the forms you show, or by saying:
> > > > > > > > > ```
> > > > > > > > > A Object1;
> > > > > > > > > A Object2;
> > > > > > > > > ```
> > > > > > > > > If all of these turn out to be a problem, we can still 
> > > > > > > > > diagnose without providing a fixit.
> > > > > > > > > 
> > > > > > > > > As for globals in general, they can be handled in a separate 
> > > > > > > > > patch once we figure out the declaration grouping.
> > > > > > > > OK. I will try to split the object definition from the class 
> > > > > > > > definition, as you have suggested. Thus, I can kick out the 
> > > > > > > > tagDecl-matcher as well. If there is no easy way to do this, it 
> > > > > > > > will be reported anyway but without a fixit.
> > > > > > > > 
> > > > > > > > Note for me: Update documentation!
> > > > > > > What about
> > > > > > > ```
> > > > > > > struct S {
> > > > > > > } S1;
> > > > > > > ```
> > > > > > > I would like to report this too, since two names are being 
> > > > > > > declared here. `S` and `S1`. What do you think?
> > > > > > ```
> > > > > > struct {
> > > > > > } nn1, nn2;
> > > > > > ```
> > > > > > Shall we ignore anonymous definitions?
> > > > > To be more precise: Warn and provide a fixit for `struct S {} S1`. 
> > > > > Only warn for `struct {} nn1, nn2`.
> > > > > What about
> > > > > 
> > > > > ```
> > > > > struct S {
> > > > > } S1;
> > > > > ```
> > > > > I would like to report this too, since two names are being declared 
> > > > > here. S and S1. What do you think?
> > > > 
> > > > I don't think that this should be diagnosed. For one, this is a 
> > > > relatively common pattern (arguably more common than `struct S { } S1, 
> > > > S2;`), but also, it names two very distinct entities (a type and a 
> > > > variable).
> > > > 
> > > > > ```
> > > > > struct {
> > > > > } nn1, nn2;
> > > > >```
> > > > > Shall we ignore anonymous definitions?
> > > > 
> > > > Yes, we basically have to.
> > > > 
> > > Transforming
> > > ```
> > > typedef struct X { int t; } X, Y;
> > > ```
> > > to
> > > ```
> > > typedef struct X { int t; };
> > > typedef X X;
> > > typedef X Y;
> > > ```
> > > will be valid, but looks odd.
> > I am on the fence about this transformation -- it does not declare new 
> > objects, but instead declares new types. A very common pattern in some 
> > libraries (such as the Win32 SDK) is to declare:
> > ```
> > typedef struct Blah {
> > 
> > } Blah, *PBlah, **PPBlah;
> > ```
> > Because of that pattern, diagnosing the above typedef is likely to be very 
> > chatty in some projects, and I don't know that the fixit provides much real 
> > benefit for types.
> > 
> > At least for the CERT DCL04-C version of this rule, that code should not be 
> > flagged. Do you think any of the variations of this check should flag it?
> Maybe we should reconsider where to split and where not. The original idea 
> was to minimize confusion on code like
> ```
> int* a,b;
> ```
> whereas 
> ```
> struct S {} *s1, s2;
> ```
> seems not so confusing as above. However, 
> ```
> struct S {}* s1, s2;
> ```
> looks dangerous again.
> 
> Even following code looks unfamiliar to me.
> ```
> typedef struct Blah {} Blah, *PBlah;
> ```
> 
> It really depends on the beholder. So, how about letting this check split 
> **everything** and provide options for maximum flexibility? So specific 
> rulesets or the user may configure it as they wish. We could add for example 
> split-after-tag-

[PATCH] D28295: [libunwind] [cmake] Support overriding LLVM_CMAKE_PATH

2017-01-04 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: mclow.lists, beanz, phosek, EricWF.
mgorny added a subscriber: cfe-commits.

Make LLVM_CMAKE_PATH a cache variable in order to support user
overrides. This is useful when building multiple multilib variants of
libunwind using CMake files from a single-ABI install of LLVM, e.g. when
LLVM_LIBDIR_SUFFIX == "32" but CMake files are to be found in
/usr/lib64/cmake/llvm. Since libunwind is not using any of the LLVM
build configuration variables (just generic macros), it is fine to use
CMake files from a different ABI.


https://reviews.llvm.org/D28295

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -43,7 +43,8 @@
 set(LLVM_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include")
 set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
 set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source 
tree")
-set(LLVM_CMAKE_PATH 
"${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+set(LLVM_CMAKE_PATH 
"${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm"
+CACHE PATH "Path to LLVM CMake modules")
 set(LLVM_LIT_PATH "${LLVM_PATH}/utils/lit/lit.py")
   else()
 message(FATAL_ERROR "llvm-config not found and LLVM_MAIN_SRC_DIR not 
defined. "


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -43,7 +43,8 @@
 set(LLVM_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include")
 set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
 set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
-set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm"
+CACHE PATH "Path to LLVM CMake modules")
 set(LLVM_LIT_PATH "${LLVM_PATH}/utils/lit/lit.py")
   else()
 message(FATAL_ERROR "llvm-config not found and LLVM_MAIN_SRC_DIR not defined. "
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28271: [Sema] Get rid of unused default argument to Sema::CheckCallingConvAttr.

2017-01-04 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I think you've discovered this bug:

  struct F { void __attribute__((pcs("aapcs"))) f(); };
  void __attribute__((pcs("aapcs"))) F::f() {}

Clang ignores the pcs convention on 32-bit x86, and because we don't have an FD 
here, we choose the wrong default calling convention (not thiscall) for F::f.


https://reviews.llvm.org/D28271



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


[PATCH] D28001: [X86] Teach Clang about -mfentry flag

2017-01-04 Thread Chad Rosier via Phabricator via cfe-commits
mcrosier added inline comments.



Comment at: include/clang/Driver/Options.td:1731
 def mno_pie_copy_relocations : Flag<["-"], "mno-pie-copy-relocations">, 
Group;
+def mfentry : Flag<["-"], "mfentry">, HelpText<"insert calls to fentry at 
function entry">, Flags<[CC1Option]>, Group;
 def mx87 : Flag<["-"], "mx87">, Group;

Should this not be in the m_x86_Features_Group since this is an x86 specific 
flag?



Comment at: test/CodeGen/fentry.c:1
+// RUN: %clang_cc1 -pg -mfentry -triple i386-unknown-unknown -emit-llvm -o - 
%s | FileCheck -check-prefix=HAS %s
+// RUN: %clang_cc1 -pg -mfentry -triple x86_64-unknown-linux-gnu -emit-llvm -o 
- %s | FileCheck -check-prefix=HAS %s

I want to say this test should be in test/Frontend directory since you're 
testing a new CC1 option.



Comment at: test/CodeGen/fentry.c:11
+
+//HAS: attributes #{{[0-9]+}} = { {{.*}}"fentry-call"="true"{{.*}} }
+//NOHAS-NOT: attributes #{{[0-9]+}} = { {{.*}}"fentry-call"{{.*}} }

I'd prefer we stick with the default CHECK and CHECK-NOT prefixes.


https://reviews.llvm.org/D28001



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


[PATCH] D28274: [MS] Instantiate default args during instantiation of exported default ctors

2017-01-04 Thread Reid Kleckner via Phabricator via cfe-commits
rnk updated this revision to Diff 83059.
rnk added a comment.

simplify


https://reviews.llvm.org/D28274

Files:
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/CodeGenCXX/dllexport.cpp
  test/SemaCXX/default-arg-closures.cpp
  test/SemaCXX/dllexport.cpp

Index: test/SemaCXX/dllexport.cpp
===
--- test/SemaCXX/dllexport.cpp
+++ test/SemaCXX/dllexport.cpp
@@ -741,6 +741,27 @@
   ClassWithMultipleDefaultCtors(int = 40) {} // expected-error{{'__declspec(dllexport)' cannot be applied to more than one default constructor}}
   ClassWithMultipleDefaultCtors(int = 30, ...) {} // expected-note{{declared here}}
 };
+template 
+struct ClassTemplateWithMultipleDefaultCtors {
+  __declspec(dllexport) ClassTemplateWithMultipleDefaultCtors(int = 40) {}  // expected-error{{'__declspec(dllexport)' cannot be applied to more than one default constructor}}
+  __declspec(dllexport) ClassTemplateWithMultipleDefaultCtors(int = 30, ...) {} // expected-note{{declared here}}
+};
+
+template  struct HasDefaults {
+  HasDefaults(int x = sizeof(T)) {} // expected-error {{invalid application of 'sizeof'}}
+};
+template struct __declspec(dllexport) HasDefaults;
+
+template struct
+__declspec(dllexport) // expected-note {{in instantiation of default function argument expression for 'HasDefaults' required here}}
+HasDefaults; // expected-note {{in instantiation of member function 'HasDefaults::HasDefaults' requested here}}
+
+template  struct HasDefaults2 {
+  __declspec(dllexport) // expected-note {{in instantiation of default function argument expression for 'HasDefaults2' required here}}
+  HasDefaults2(int x = sizeof(T)) {} // expected-error {{invalid application of 'sizeof'}}
+};
+template struct HasDefaults2; // expected-note {{in instantiation of member function 'HasDefaults2::HasDefaults2' requested here}}
+
 #endif
 
 //===--===//
Index: test/SemaCXX/default-arg-closures.cpp
===
--- test/SemaCXX/default-arg-closures.cpp
+++ test/SemaCXX/default-arg-closures.cpp
@@ -4,16 +4,15 @@
 // instantiating and checking the semantics of default arguments. Make sure we
 // do that right.
 
-// FIXME: Don't diagnose this issue twice.
 template 
-struct DependentDefaultCtorArg { // expected-note {{in instantiation of default function argument}}
-  // expected-error@+1 2 {{type 'int' cannot be used prior to '::' because it has no members}}
+struct DependentDefaultCtorArg {
+  // expected-error@+1 {{type 'int' cannot be used prior to '::' because it has no members}}
   DependentDefaultCtorArg(int n = T::error);
 };
 struct
 __declspec(dllexport) // expected-note {{due to 'ExportDefaultCtorClosure' being dllexported}}
-ExportDefaultCtorClosure // expected-note {{implicit default constructor for 'ExportDefaultCtorClosure' first required here}}
-: DependentDefaultCtorArg // expected-note {{in instantiation of template class}}
+ExportDefaultCtorClosure // expected-note {{in instantiation of default function argument expression for 'DependentDefaultCtorArg' required here}} expected-note {{implicit default constructor for 'ExportDefaultCtorClosure' first required here}}
+: DependentDefaultCtorArg
 {};
 
 template 
Index: test/CodeGenCXX/dllexport.cpp
===
--- test/CodeGenCXX/dllexport.cpp
+++ test/CodeGenCXX/dllexport.cpp
@@ -515,6 +515,18 @@
 // M32-DAG:   ret void
 };
 
+template  struct TemplateWithClosure {
+  TemplateWithClosure(int x = sizeof(T)) {}
+};
+extern template struct TemplateWithClosure;
+template struct __declspec(dllexport) TemplateWithClosure;
+extern template struct TemplateWithClosure;
+template struct __declspec(dllexport) TemplateWithClosure;
+// M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01??_F?$TemplateWithClosure@D@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
+// M32-DAG:   call {{.*}} @"\01??0?$TemplateWithClosure@D@@QAE@H@Z"({{.*}}, i32 1)
+// M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01??_F?$TemplateWithClosure@H@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
+// M32-DAG:   call {{.*}} @"\01??0?$TemplateWithClosure@H@@QAE@H@Z"({{.*}}, i32 4)
+
 struct __declspec(dllexport) NestedOuter {
   DELETE_IMPLICIT_MEMBERS(NestedOuter);
   NestedOuter(void *p = 0) {}
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3616,6 +3616,27 @@
   return false;
 }
 
+/// In the MS ABI, we need to instantiate default arguments of dllexported
+/// default constructors along with the constructor definition. This allows IR
+/// gen to emit a constructor closure which calls the default constructor with
+/// its default arguments.
+static void InstantiateDefaultCtorDefaultArgs(Sema &S,
+   

[PATCH] D28001: [X86] Teach Clang about -mfentry flag

2017-01-04 Thread Chad Rosier via Phabricator via cfe-commits
mcrosier added inline comments.



Comment at: test/CodeGen/fentry.c:11
+
+//HAS: attributes #{{[0-9]+}} = { {{.*}}"fentry-call"="true"{{.*}} }
+//NOHAS-NOT: attributes #{{[0-9]+}} = { {{.*}}"fentry-call"{{.*}} }

mcrosier wrote:
> I'd prefer we stick with the default CHECK and CHECK-NOT prefixes.
Specifically, for the first two RUN commands please use CHECK and for the 
latter two use something like NOPG-NOT.


https://reviews.llvm.org/D28001



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


[PATCH] D28166: Properly merge K&R functions that have attributes

2017-01-04 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:11958-11962
+// The type location may be attributed; strip the attributes to get to
+// the function type location.
+while (auto ATL = TL.getAs()) {
+  TL = ATL.getModifiedLoc();
+}

rsmith wrote:
> Again, I don't like having this knowledge about what kinds of type sugar can 
> appear in a function declaration hardcoded here. Please put this somewhere 
> more central.
> 
> A quick look finds that `FunctionDecl::getReturnTypeSourceRange()` gets this 
> wrong in the opposite direction: it skips parens but not attributes. Maybe we 
> should have a `TypeLoc::getAsAdjusted` or similar, that walks over type 
> sugar nodes that represent some kind of type adjustment from a type that was 
> written as a T to another type that is still canonically a T (`ParenType`, 
> `AttributedType`, `ElaboratedType`).
What about AdjustedType? You would see that in this case:
  template  struct A {
T A::*method; // adjusted to __thiscall on i686-windows
  };
  template struct A;
Do you want to look through the __thiscall adjustment?


https://reviews.llvm.org/D28166



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


[PATCH] D28296: [ObjC] The declarator for a block literal should be a definition

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

This avoids the -Wstrict-prototypes warning for block literals with an empty or 
without argument lists.


Repository:
  rL LLVM

https://reviews.llvm.org/D28296

Files:
  lib/Parse/ParseExpr.cpp
  test/Sema/warn-strict-prototypes.m


Index: test/Sema/warn-strict-prototypes.m
===
--- test/Sema/warn-strict-prototypes.m
+++ test/Sema/warn-strict-prototypes.m
@@ -14,7 +14,8 @@
   void (^block)() = // expected-warning {{this function declaration is not a 
prototype}}
 ^void(int arg) { // no warning
   };
-  void (^block2)(void) = // no warning
- ^void() { // expected-warning {{this function 
declaration is not a prototype}}
+  void (^block2)(void) = ^void() { // no warning
+  };
+  void (^block3)(void) = ^ { // no warning
   };
 }
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -2751,6 +2751,7 @@
 
   // Parse the block-declarator.
   Declarator DeclaratorInfo(DS, Declarator::BlockLiteralContext);
+  DeclaratorInfo.setFunctionDefinitionKind(FDK_Definition);
   ParseDeclarator(DeclaratorInfo);
 
   MaybeParseGNUAttributes(DeclaratorInfo);
@@ -2789,6 +2790,7 @@
   // Parse the return type if present.
   DeclSpec DS(AttrFactory);
   Declarator ParamInfo(DS, Declarator::BlockLiteralContext);
+  ParamInfo.setFunctionDefinitionKind(FDK_Definition);
   // FIXME: Since the return type isn't actually parsed, it can't be used to
   // fill ParamInfo with an initial valid range, so do it manually.
   ParamInfo.SetSourceRange(SourceRange(Tok.getLocation(), Tok.getLocation()));


Index: test/Sema/warn-strict-prototypes.m
===
--- test/Sema/warn-strict-prototypes.m
+++ test/Sema/warn-strict-prototypes.m
@@ -14,7 +14,8 @@
   void (^block)() = // expected-warning {{this function declaration is not a prototype}}
 ^void(int arg) { // no warning
   };
-  void (^block2)(void) = // no warning
- ^void() { // expected-warning {{this function declaration is not a prototype}}
+  void (^block2)(void) = ^void() { // no warning
+  };
+  void (^block3)(void) = ^ { // no warning
   };
 }
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -2751,6 +2751,7 @@
 
   // Parse the block-declarator.
   Declarator DeclaratorInfo(DS, Declarator::BlockLiteralContext);
+  DeclaratorInfo.setFunctionDefinitionKind(FDK_Definition);
   ParseDeclarator(DeclaratorInfo);
 
   MaybeParseGNUAttributes(DeclaratorInfo);
@@ -2789,6 +2790,7 @@
   // Parse the return type if present.
   DeclSpec DS(AttrFactory);
   Declarator ParamInfo(DS, Declarator::BlockLiteralContext);
+  ParamInfo.setFunctionDefinitionKind(FDK_Definition);
   // FIXME: Since the return type isn't actually parsed, it can't be used to
   // fill ParamInfo with an initial valid range, so do it manually.
   ParamInfo.SetSourceRange(SourceRange(Tok.getLocation(), Tok.getLocation()));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28297: [StaticAnalyzer] Fix crash in CastToStructChecker

2017-01-04 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki created this revision.
danielmarjamaki added a reviewer: NoQ.
danielmarjamaki added a subscriber: cfe-commits.
danielmarjamaki set the repository for this revision to rL LLVM.

This fix the crash reported in https://llvm.org/bugs/show_bug.cgi?id=31173


Repository:
  rL LLVM

https://reviews.llvm.org/D28297

Files:
  lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
  test/Analysis/cast-to-struct.cpp


Index: test/Analysis/cast-to-struct.cpp
===
--- test/Analysis/cast-to-struct.cpp
+++ test/Analysis/cast-to-struct.cpp
@@ -65,3 +65,8 @@
   void *VP = P;
   Abc = (struct ABC *)VP;
 }
+
+// https://llvm.org/bugs/show_bug.cgi?id=31173
+void dontCrash(struct AB X) {
+  struct UndefS *S = (struct UndefS *)&X;
+}
Index: lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
+++ lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
@@ -55,6 +55,12 @@
   if (!ToPointeeTy->isStructureOrClassType())
 return true;
 
+  if (const RecordType *RD = dyn_cast(ToPointeeTy.getTypePtr())) {
+if (!RD->getDecl()->getDefinition()) {
+  return true;
+}
+  }
+
   // We allow cast from void*.
   if (OrigPointeeTy->isVoidType())
 return true;


Index: test/Analysis/cast-to-struct.cpp
===
--- test/Analysis/cast-to-struct.cpp
+++ test/Analysis/cast-to-struct.cpp
@@ -65,3 +65,8 @@
   void *VP = P;
   Abc = (struct ABC *)VP;
 }
+
+// https://llvm.org/bugs/show_bug.cgi?id=31173
+void dontCrash(struct AB X) {
+  struct UndefS *S = (struct UndefS *)&X;
+}
Index: lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
+++ lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
@@ -55,6 +55,12 @@
   if (!ToPointeeTy->isStructureOrClassType())
 return true;
 
+  if (const RecordType *RD = dyn_cast(ToPointeeTy.getTypePtr())) {
+if (!RD->getDecl()->getDefinition()) {
+  return true;
+}
+  }
+
   // We allow cast from void*.
   if (OrigPointeeTy->isVoidType())
 return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28166: Properly merge K&R functions that have attributes

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



Comment at: lib/Sema/SemaDecl.cpp:11958-11962
+// The type location may be attributed; strip the attributes to get to
+// the function type location.
+while (auto ATL = TL.getAs()) {
+  TL = ATL.getModifiedLoc();
+}

rnk wrote:
> rsmith wrote:
> > Again, I don't like having this knowledge about what kinds of type sugar 
> > can appear in a function declaration hardcoded here. Please put this 
> > somewhere more central.
> > 
> > A quick look finds that `FunctionDecl::getReturnTypeSourceRange()` gets 
> > this wrong in the opposite direction: it skips parens but not attributes. 
> > Maybe we should have a `TypeLoc::getAsAdjusted` or similar, that walks 
> > over type sugar nodes that represent some kind of type adjustment from a 
> > type that was written as a T to another type that is still canonically a T 
> > (`ParenType`, `AttributedType`, `ElaboratedType`).
> What about AdjustedType? You would see that in this case:
>   template  struct A {
> T A::*method; // adjusted to __thiscall on i686-windows
>   };
>   template struct A;
> Do you want to look through the __thiscall adjustment?
Can you get an `AdjustedType` in C? Both of my uses are gated by if 
!LangOpts.CPlusPlus, so I'm not certain whether `AdjustedType` makes sense or 
not (but I'm also a bit unfamiliar with `AdjustedType`). From the description, 
it sounds like it might be reasonable to add.


https://reviews.llvm.org/D28166



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


[PATCH] D28220: provide Win32 native threading

2017-01-04 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: include/__threading_support:44
+#define WIN32_LEAN_AND_MEAN
+#define VC_EXTRA_LEAN
+#include 

kimgr wrote:
> EricWF wrote:
> > compnerd wrote:
> > > EricWF wrote:
> > > > Do these definitions have any affect when `` has already 
> > > > been included?
> > > > Also are these definitions required before including the header, or 
> > > > merely beneficial? If they are required this will make the 
> > > > `` header a pain to use with modules.
> > > > 
> > > > 
> > > No, they dont effect it once it has been included.  They are beneficial 
> > > since they reduce the amount of stuff that gets included (including 
> > > things which, at least when I last checked, can cause clang to choke).
> > And can users re-include `` afterwards in the same TU and get 
> > all of the symbols?
> I don't think so.
> 
> We've recently switched to defining these two symbols in our build system, 
> and I think that's basically the only way to make this work in a project 
> composed of headers from various authors. I think you're right that libc++ 
> should not define them.
I don't think libc++ should not include windows.h in a public header. I'd 
rather write our own __threading_support_win.h that re-prototypes everything we 
need from windows.h, and then we can have some test in libc++ that validates 
that there are no mismatches when including windows.h before libc++ . If 
we do this, we should sink as much win32 API usage as possible out of headers 
to reduce our duplication.

It's worth pointing out VS 2015's thread implementation also hides its win32 
API usage.



Comment at: include/__threading_support:527
+static inline _LIBCPP_ALWAYS_INLINE unsigned int WINAPI
+__libcpp_thread_trampoline(void *__data)
+{

halyavin wrote:
> Trampolines will never be inlined. Should we put them in support *.cpp 
> instead? The downside is new public symbols which can't be changed without 
> breaking backward compatibility. The upside is that we will have only one 
> copy of each trampoline. What do you think?
Considering that libc++ already has a __thread_proxy trampoline, let's just 
give it the right CC and get rid of this trampoline.



Comment at: include/__threading_support:593
+{
+  // TODO(compnerd) provide a wrapper for CC adjustment
+  *__key = FlsAlloc(reinterpret_cast(__at_exit));

Yeah, we need to fix that. We should find a way to make 
`__thread_specific_ptr::__at_thread_exit(void*)` have the right convention out 
of the box, rather than thunking. Something like:
  #define __LIBCPP_TLS_CALLBACK_CC WINAPI
  .. // else
  #define __LIBCPP_TLS_CALLBACK_CC
  ... // 
  static void __LIBCPP_TLS_CALLBACK_CC __at_thread_exit(void*);



Repository:
  rL LLVM

https://reviews.llvm.org/D28220



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


[PATCH] D28287: [clang-tidy] Ignore default arguments in modernize-default-member-init

2017-01-04 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added inline comments.



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:161
 cxxBoolLiteral(), cxxNullPtrLiteralExpr(), implicitValueInitExpr(),
-declRefExpr());
+declRefExpr(unless(to(varDecl();
 

aaron.ballman wrote:
> malcolm.parsons wrote:
> > aaron.ballman wrote:
> > > Any `varDecl`? Or do we want to limit it to only `parmVarDecl` instead?
> > > ```
> > > int i = 12;
> > > struct S {
> > >   int j;
> > >   S() : j(i) {}
> > > };
> > > ```
> > > It seems reasonable to suggest the member initialization be "fixed" to: 
> > > `int j = i;`
> > I would find a default member initializer that is not a constant to be 
> > surprising.
> > Maybe I want to limit it to `enumConstantDecl`.
> I wouldn't; consider a global synchronization object, like a mutex (this is a 
> relatively common thing).
Note that this check doesn't consider initializations of members that are 
classes, e.g. `std::lock_guard`.
I have no plans to make it consider them.


https://reviews.llvm.org/D28287



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


[PATCH] D28287: [clang-tidy] Ignore default arguments in modernize-default-member-init

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



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:161
 cxxBoolLiteral(), cxxNullPtrLiteralExpr(), implicitValueInitExpr(),
-declRefExpr());
+declRefExpr(unless(to(varDecl();
 

malcolm.parsons wrote:
> aaron.ballman wrote:
> > malcolm.parsons wrote:
> > > aaron.ballman wrote:
> > > > Any `varDecl`? Or do we want to limit it to only `parmVarDecl` instead?
> > > > ```
> > > > int i = 12;
> > > > struct S {
> > > >   int j;
> > > >   S() : j(i) {}
> > > > };
> > > > ```
> > > > It seems reasonable to suggest the member initialization be "fixed" to: 
> > > > `int j = i;`
> > > I would find a default member initializer that is not a constant to be 
> > > surprising.
> > > Maybe I want to limit it to `enumConstantDecl`.
> > I wouldn't; consider a global synchronization object, like a mutex (this is 
> > a relatively common thing).
> Note that this check doesn't consider initializations of members that are 
> classes, e.g. `std::lock_guard`.
> I have no plans to make it consider them.
Ah, okay, then it's less pressing, though the pattern is still not unheard of 
for non-class types. I don't have a strong opinion any longer, though.



Comment at: test/clang-tidy/modernize-use-default-member-init.cpp:224
 
+struct NegativeDefaultArg
+{

Can we also have a positive test with an enumerator?


https://reviews.llvm.org/D28287



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


[PATCH] D28287: [clang-tidy] Ignore default arguments in modernize-default-member-init

2017-01-04 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added inline comments.



Comment at: test/clang-tidy/modernize-use-default-member-init.cpp:224
 
+struct NegativeDefaultArg
+{

aaron.ballman wrote:
> Can we also have a positive test with an enumerator?
See lines 159-166.


https://reviews.llvm.org/D28287



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


[PATCH] D28287: [clang-tidy] Ignore default arguments in modernize-default-member-init

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

LGTM!




Comment at: test/clang-tidy/modernize-use-default-member-init.cpp:224
 
+struct NegativeDefaultArg
+{

malcolm.parsons wrote:
> aaron.ballman wrote:
> > Can we also have a positive test with an enumerator?
> See lines 159-166.
Ah, thanks, my eyes missed that. :-)


https://reviews.llvm.org/D28287



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


[PATCH] D27486: Correct class-template deprecation behavior

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



Comment at: include/clang/Basic/Attr.td:301
   bit DuplicatesAllowedWhileMerging = 0;
+  // Set to true if this attribute should apply to template declaration,
+  // remains false if this should only be applied on definition.

template declaration -> template declarations



Comment at: include/clang/Basic/Attr.td:302
+  // Set to true if this attribute should apply to template declaration,
+  // remains false if this should only be applied on definition.
+  bit AppliesToTemplateDeclaration = 0;

on definition -> to the definition



Comment at: include/clang/Sema/Sema.h:7388-7391
+  void InstantiateAttrsForDecl(const MultiLevelTemplateArgumentList 
&TemplateArgs,
+const Decl *Pattern, Decl *Inst,
+LateInstantiatedAttrVec *LateAttrs = nullptr,
+LocalInstantiationScope *OuterMostScope = nullptr);

Did clang-format produce this formatting?



Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:320
+CXXRecordDecl *ThisContext =
+dyn_cast_or_null(ND->getDeclContext());
+CXXThisScopeRAII ThisScope(*this, ThisContext, /*TypeQuals*/ 0,

Are you sure `ND` is always non-null? If so, then you should use `cast<>` above 
instead of `dyn_cast<>`.



Comment at: utils/TableGen/ClangAttrEmitter.cpp:2456
+void EmitClangAttrTemplateInstantiateHelper(const std::vector &Attrs,
+raw_ostream &OS, bool DeclTime) {
+ OS << "  switch (At->getKind()) {\n";

What does "time" mean in `DeclTime`?



Comment at: utils/TableGen/ClangAttrEmitter.cpp:2507
+}
+// Emits code to instantiate dependent attributes on templates.
+void EmitClangAttrTemplateInstantiate(RecordKeeper &Records, raw_ostream &OS) {

Add a newline above this comment to separate it from the previous function body.


https://reviews.llvm.org/D27486



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


[clang-tools-extra] r290972 - [clang-tidy] Ignore default arguments in modernize-default-member-init

2017-01-04 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Wed Jan  4 11:33:55 2017
New Revision: 290972

URL: http://llvm.org/viewvc/llvm-project?rev=290972&view=rev
Log:
[clang-tidy] Ignore default arguments in modernize-default-member-init

Summary:
Default member initializers cannot refer to constructor parameters, but 
modernize-default-member-init was trying to when the default constructor had 
default arguments.

Change the check to ignore default arguments to the default constructor.

Fixes PR31524.

Reviewers: alexfh, aaron.ballman

Subscribers: cfe-commits, JDevlieghere, Eugene.Zelenko

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp?rev=290972&r1=290971&r2=290972&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
Wed Jan  4 11:33:55 2017
@@ -158,7 +158,7 @@ void UseDefaultMemberInitCheck::register
 unaryOperator(anyOf(hasOperatorName("+"), hasOperatorName("-")),
   hasUnaryOperand(floatLiteral())),
 cxxBoolLiteral(), cxxNullPtrLiteralExpr(), implicitValueInitExpr(),
-declRefExpr());
+declRefExpr(to(enumConstantDecl(;
 
   Finder->addMatcher(
   cxxConstructorDecl(

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp?rev=290972&r1=290971&r2=290972&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp 
Wed Jan  4 11:33:55 2017
@@ -221,6 +221,12 @@ struct NegativeNotDefaultInt
   int i;
 };
 
+struct NegativeDefaultArg
+{
+  NegativeDefaultArg(int i = 4) : i(i) {}
+  int i;
+};
+
 struct ExistingChar {
   ExistingChar(short) : e1(), e2(), e3(), e4() {}
   // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: member initializer for 'e1' is 
redundant [modernize-use-default-member-init]


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


[PATCH] D28287: [clang-tidy] Ignore default arguments in modernize-default-member-init

2017-01-04 Thread Malcolm Parsons via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290972: [clang-tidy] Ignore default arguments in 
modernize-default-member-init (authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D28287?vs=83056&id=83066#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28287

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp


Index: 
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -158,7 +158,7 @@
 unaryOperator(anyOf(hasOperatorName("+"), hasOperatorName("-")),
   hasUnaryOperand(floatLiteral())),
 cxxBoolLiteral(), cxxNullPtrLiteralExpr(), implicitValueInitExpr(),
-declRefExpr());
+declRefExpr(to(enumConstantDecl(;
 
   Finder->addMatcher(
   cxxConstructorDecl(
Index: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp
@@ -221,6 +221,12 @@
   int i;
 };
 
+struct NegativeDefaultArg
+{
+  NegativeDefaultArg(int i = 4) : i(i) {}
+  int i;
+};
+
 struct ExistingChar {
   ExistingChar(short) : e1(), e2(), e3(), e4() {}
   // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: member initializer for 'e1' is 
redundant [modernize-use-default-member-init]


Index: clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -158,7 +158,7 @@
 unaryOperator(anyOf(hasOperatorName("+"), hasOperatorName("-")),
   hasUnaryOperand(floatLiteral())),
 cxxBoolLiteral(), cxxNullPtrLiteralExpr(), implicitValueInitExpr(),
-declRefExpr());
+declRefExpr(to(enumConstantDecl(;
 
   Finder->addMatcher(
   cxxConstructorDecl(
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp
@@ -221,6 +221,12 @@
   int i;
 };
 
+struct NegativeDefaultArg
+{
+  NegativeDefaultArg(int i = 4) : i(i) {}
+  int i;
+};
+
 struct ExistingChar {
   ExistingChar(short) : e1(), e2(), e3(), e4() {}
   // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: member initializer for 'e1' is redundant [modernize-use-default-member-init]
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28287: [clang-tidy] Ignore default arguments in modernize-default-member-init

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

In https://reviews.llvm.org/D28287#635442, @aaron.ballman wrote:

> LGTM!


Thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D28287



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


[PATCH] D27689: Module: hash the pcm content and use it as SIGNATURE for implicit modules.

2017-01-04 Thread Manman Ren via Phabricator via cfe-commits
manmanren updated this revision to Diff 83068.
manmanren added a comment.

Addressing review comments!

I still need to measure the performance impact of calculating the hash then 
decide how to enable this.


https://reviews.llvm.org/D27689

Files:
  include/clang/AST/ExternalASTSource.h
  include/clang/Basic/Module.h
  include/clang/Frontend/PCHContainerOperations.h
  include/clang/Serialization/ASTBitCodes.h
  include/clang/Serialization/ASTReader.h
  include/clang/Serialization/ASTWriter.h
  include/clang/Serialization/Module.h
  lib/Basic/Module.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  lib/Frontend/ASTUnit.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/GeneratePCH.cpp
  lib/Serialization/GlobalModuleIndex.cpp
  lib/Serialization/Module.cpp
  lib/Serialization/ModuleManager.cpp
  test/Modules/diagnostic-options-out-of-date.m
  test/Modules/explicit-build.cpp
  test/Modules/module_file_info.m
  test/Modules/rebuild.m

Index: test/Modules/rebuild.m
===
--- test/Modules/rebuild.m
+++ test/Modules/rebuild.m
@@ -19,11 +19,10 @@
 // RUN: diff %t/Module.size %t/Module.size.saved
 // RUN: cp %t/Module.pcm %t/Module.pcm.saved.2
 
-// But the signature at least is expected to change, so we rebuild DependsOnModule.
-// NOTE: if we change how the signature is created, this test may need updating.
+// The signature is the hash of the PCM content, we will not rebuild rebuild DependsOnModule.
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs %s
 // RUN: diff %t/Module.pcm %t/Module.pcm.saved.2
-// RUN: not diff %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved
+// RUN: diff %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved
 
 // Rebuild Module, reset its timestamp, and verify its size hasn't changed
 // RUN: rm %t/Module.pcm
@@ -34,10 +33,9 @@
 // RUN: cp %t/Module.pcm %t/Module.pcm.saved.2
 
 // Verify again with Module pre-imported.
-// NOTE: if we change how the signature is created, this test may need updating.
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs %s
 // RUN: diff %t/Module.pcm %t/Module.pcm.saved.2
-// RUN: not diff %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved
+// RUN: diff %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved
 
 #ifdef PREIMPORT
 @import Module;
Index: test/Modules/module_file_info.m
===
--- test/Modules/module_file_info.m
+++ test/Modules/module_file_info.m
@@ -29,11 +29,6 @@
 // CHECK: CPU:
 // CHECK: ABI:
 
-// CHECK: Diagnostic options:
-// CHECK:   IgnoreWarnings: Yes
-// CHECK:   Diagnostic flags:
-// CHECK: -Wunused
-
 // CHECK: Header search options:
 // CHECK:   System root [-isysroot=]: '/'
 // CHECK:   Use builtin include directories [-nobuiltininc]: Yes
@@ -47,3 +42,8 @@
 // CHECK:   Predefined macros:
 // CHECK: -DBLARG
 // CHECK: -DWIBBLE=WOBBLE
+
+// CHECK: Diagnostic options:
+// CHECK:   IgnoreWarnings: Yes
+// CHECK:   Diagnostic flags:
+// CHECK: -Wunused
Index: test/Modules/explicit-build.cpp
===
--- test/Modules/explicit-build.cpp
+++ test/Modules/explicit-build.cpp
@@ -199,6 +199,6 @@
 // RUN:-fmodule-file=%t/c.pcm \
 // RUN:%s -DHAVE_A -DHAVE_B -DHAVE_C 2>&1 | FileCheck --check-prefix=CHECK-MISMATCHED-B %s
 //
-// CHECK-MISMATCHED-B:  fatal error: module file '{{.*}}b.pcm' is out of date and needs to be rebuilt: module file out of date
+// CHECK-MISMATCHED-B:  fatal error: module file '{{.*}}b.pcm' is out of date and needs to be rebuilt: signature mismatch
 // CHECK-MISMATCHED-B-NEXT: note: imported by module 'c'
 // CHECK-MISMATCHED-B-NOT:  note:
Index: test/Modules/diagnostic-options-out-of-date.m
===
--- test/Modules/diagnostic-options-out-of-date.m
+++ test/Modules/diagnostic-options-out-of-date.m
@@ -7,6 +7,16 @@
 // RUN: %clang_cc1 -Werror -Wconversion -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs %s -fmodules-disable-diagnostic-validation
 // Make sure we don't error out when using the pch
 // RUN: %clang_cc1 -Werror -Wno-conversion -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -fsyntax-only -I %S/Inputs -include-pch %t.pch %s -verify -fmodules-disable-diagnostic-validation
+
+// Build A.pcm
+// RUN: %clang_cc1 -Werror -Wno-conversion -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs %s
+// Build pch that imports A.pcm
+// RUN: %clang_cc1 -Werror -Wno-conversion -emit-pch -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -o %t.pch -I %S/Inputs -x objective-c-header %S/Inputs/pch-import-module-out-of-date.pch
+// We will rebuild A.pcm and 

[PATCH] D28212: typeinfo: provide a partial implementation for Win32

2017-01-04 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: include/typeinfo:75
+#elif defined(_WIN32)
+#define _LIBCPP_HAS_WINDOWS_TYPEINFO
+#else

Is _WIN32 the right condition? It seems like this is intended to match the MS 
ABI RTTI structure, not the Itanium one. _MSC_VER maybe?



Comment at: src/typeinfo.cpp:28-32
+  static constexpr const size_t fnv_offset_basis = 14695981039346656037;
+  static constexpr const size_t fnv_prime = 10995116282110;
+#else
+  static constexpr const size_t fnv_offset_basis = 2166136261;
+  static constexpr const size_t fnv_prime = 16777619;

compnerd wrote:
> majnemer wrote:
> > majnemer wrote:
> > > Why make these static? Seems strange to use that storage duration.
> > These literals are ill-formed, I think you need a ULL suffix here.
> Oh, just to ensure that they are handled as literal constants.  I can drop 
> the static if you like, since the compiler should do the right thing anyways.
Isn't `constexpr const` redundant?


https://reviews.llvm.org/D28212



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


[PATCH] D28299: Module: use PCMCache to manage memory buffers for pcm files.

2017-01-04 Thread Manman Ren via Phabricator via cfe-commits
manmanren created this revision.
manmanren added reviewers: rsmith, benlangmuir, dexonsmith.
manmanren added subscribers: cfe-commits, bruno.

We create a PCMCache class to manage memory buffers associated with pcm files. 
With implicit modules, we currently use lock files to make
sure we are making progress when a single clang invocation builds a module file 
and then loads the module file immediately after. This
implementation requires lock file for correctness and causes all kinds of 
locking issues.

This patch tries to use PCMCache to share the content between writes and reads 
within a single clang invocation, so we can remove the
correctness-side of the lock file, and only use lock file for performance i.e 
to reduce chance of building the same pcm file from multiple
clang invocations.

We also add ThreadContext in PCMCache to diagnose cases where an ancestor 
validates a module and later on, a child thread tries
to invalidate it. Without the patch, this scenario will cause use-after-free of 
the FileEntry held by the ancestor.


https://reviews.llvm.org/D28299

Files:
  include/clang/Basic/DiagnosticSerializationKinds.td
  include/clang/Basic/FileManager.h
  include/clang/Serialization/ASTReader.h
  include/clang/Serialization/ASTWriter.h
  include/clang/Serialization/Module.h
  include/clang/Serialization/ModuleManager.h
  lib/Basic/FileManager.cpp
  lib/Frontend/ASTUnit.cpp
  lib/Frontend/ChainedIncludesSource.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Frontend/FrontendActions.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/GeneratePCH.cpp
  lib/Serialization/ModuleManager.cpp

Index: lib/Serialization/ModuleManager.cpp
===
--- lib/Serialization/ModuleManager.cpp
+++ lib/Serialization/ModuleManager.cpp
@@ -108,7 +108,11 @@
 // Load the contents of the module
 if (std::unique_ptr Buffer = lookupBuffer(FileName)) {
   // The buffer was already provided for us.
-  ModuleEntry->Buffer = std::move(Buffer);
+  ModuleEntry->Buffer = Buffer.get();
+  FileMgr.getPCMCache()->addConsistentBuffer(FileName, std::move(Buffer));
+} else if(llvm::MemoryBuffer *ConsistentB =
+  FileMgr.getPCMCache()->lookupConsistentBuffer(FileName)) {
+  ModuleEntry->Buffer = ConsistentB;
 } else {
   // Open the AST file.
   llvm::ErrorOr> Buf(
@@ -131,7 +135,8 @@
 return Missing;
   }
 
-  ModuleEntry->Buffer = std::move(*Buf);
+  ModuleEntry->Buffer = (*Buf).get();
+  FileMgr.getPCMCache()->addConsistentBuffer(FileName, std::move(*Buf));
 }
 
 // Initialize the stream.
@@ -148,8 +153,11 @@
   ErrorStr = ModuleEntry->Signature != ASTFileSignature({{0}}) ?
  "signature mismatch" : "could not read module signature";
 
-  if (NewModule)
+  if (NewModule) {
+FileMgr.getPCMCache()->removeFromConsistentBuffer(
+ModuleEntry->FileName);
 delete ModuleEntry;
+  }
   return OutOfDate;
 }
   }
@@ -184,7 +192,8 @@
 void ModuleManager::removeModules(
 ModuleIterator first, ModuleIterator last,
 llvm::SmallPtrSetImpl &LoadedSuccessfully,
-ModuleMap *modMap) {
+ModuleMap *modMap,
+llvm::SmallVectorImpl &ValidationConflicts) {
   if (first == last)
 return;
 
@@ -227,16 +236,76 @@
 // Files that didn't make it through ReadASTCore successfully will be
 // rebuilt (or there was an error). Invalidate them so that we can load the
 // new files that will be renamed over the old ones.
-if (LoadedSuccessfully.count(*victim) == 0)
-  FileMgr.invalidateCache((*victim)->File);
-
+if (LoadedSuccessfully.count(*victim) == 0) {
+  // Before removing the module file, check if it was validated in an
+  // ancestor thread, if yes, throw a hard error instead of causing
+  // use-after-free in the ancestor thread.
+  bool IsSystem;
+  if (FileMgr.getPCMCache()->isValidatedByAncestor((*victim)->FileName,
+   IsSystem))
+ValidationConflicts.push_back((*victim)->FileName);
+  else
+FileMgr.invalidateCache((*victim)->File);
+  FileMgr.getPCMCache()->removeFromConsistentBuffer((*victim)->FileName);
+}
 delete *victim;
   }
 
   // Remove the modules from the chain.
   Chain.erase(first, last);
 }
 
+llvm::MemoryBuffer*
+PCMCache::lookupConsistentBuffer(std::string Name) {
+  if (!ConsistentBuffers.count(Name))
+return nullptr;
+  return ConsistentBuffers[Name].first.get();
+}
+
+void
+PCMCache::addConsistentBuffer(std::string FileName,
+  std::unique_ptr Buffer) {
+  assert(!ConsistentBuffers.count(FileName) && "already has a buffer");
+  ConsistentBuffers[FileName] = std::make_pair(std::move(Buffer),
+   /*IsSystem*/false);
+}
+
+void PCMCache::removeFromConsistentBuffer(std::st

[PATCH] D28301: [CUDA] Pre-include sm_60 and sm_61 headers.

2017-01-04 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
tra added a reviewer: jlebar.
tra added a subscriber: cfe-commits.

CUDA-8.0 comes with new headers which nvcc pre-includes via cuda_runtime.h
Clang now makes them available as well.


https://reviews.llvm.org/D28301

Files:
  lib/Headers/__clang_cuda_runtime_wrapper.h


Index: lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- lib/Headers/__clang_cuda_runtime_wrapper.h
+++ lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -232,6 +232,11 @@
 // hardware, seems to generate faster machine code because ptxas can more 
easily
 // reason about our code.
 
+#if CUDA_VERSION >= 8000
+#include "sm_60_atomic_functions.hpp"
+#include "sm_61_intrinsics.hpp"
+#endif
+
 #undef __MATH_FUNCTIONS_HPP__
 
 // math_functions.hpp defines ::signbit as a __host__ __device__ function.  
This


Index: lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- lib/Headers/__clang_cuda_runtime_wrapper.h
+++ lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -232,6 +232,11 @@
 // hardware, seems to generate faster machine code because ptxas can more easily
 // reason about our code.
 
+#if CUDA_VERSION >= 8000
+#include "sm_60_atomic_functions.hpp"
+#include "sm_61_intrinsics.hpp"
+#endif
+
 #undef __MATH_FUNCTIONS_HPP__
 
 // math_functions.hpp defines ::signbit as a __host__ __device__ function.  This
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27486: Correct class-template deprecation behavior

2017-01-04 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked 6 inline comments as done.
erichkeane added a comment.

All Aaron's comments addressed in a patch that is on its way!




Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:320
+CXXRecordDecl *ThisContext =
+dyn_cast_or_null(ND->getDeclContext());
+CXXThisScopeRAII ThisScope(*this, ThisContext, /*TypeQuals*/ 0,

aaron.ballman wrote:
> Are you sure `ND` is always non-null? If so, then you should use `cast<>` 
> above instead of `dyn_cast<>`.
I hadn't thought much about it actually, this is from a section in 
InstantiateAttrs (see 410 in this file).  Also reinspecting, it seems that ND 
can be moved above the for-loop as well, so I'm going to do that, so that we 
can perhaps save the attributes in that case.



Comment at: utils/TableGen/ClangAttrEmitter.cpp:2456
+void EmitClangAttrTemplateInstantiateHelper(const std::vector &Attrs,
+raw_ostream &OS, bool DeclTime) {
+ OS << "  switch (At->getKind()) {\n";

aaron.ballman wrote:
> What does "time" mean in `DeclTime`?
Right, good point.  I'll choose a better name in the next patch.


https://reviews.llvm.org/D27486



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


[PATCH] D27486: Correct class-template deprecation behavior

2017-01-04 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 83072.
erichkeane marked 2 inline comments as done.
erichkeane added a comment.

Updated based on Aarons comments.


https://reviews.llvm.org/D27486

Files:
  include/clang/Basic/Attr.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -1882,6 +1882,8 @@
   namespace sema {
 Attr *instantiateTemplateAttribute(const Attr *At, ASTContext &C, Sema &S,
 const MultiLevelTemplateArgumentList &TemplateArgs);
+Attr *instantiateTemplateAttributeForDecl(const Attr *At, ASTContext &C, Sema &S,
+const MultiLevelTemplateArgumentList &TemplateArgs);
   }
 }
 
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -2401,6 +2401,10 @@
 ClassTemplate->getLocation(),
  ClassTemplate,
  Converted, nullptr);
+  MultiLevelTemplateArgumentList TemplateArgLists;
+  TemplateArgLists.addOuterTemplateArguments(Converted);
+  InstantiateAttrsForDecl(TemplateArgLists,
+  ClassTemplate->getTemplatedDecl(), Decl);
   ClassTemplate->AddSpecialization(Decl, InsertPos);
   if (ClassTemplate->isOutOfLine())
 Decl->setLexicalDeclContext(ClassTemplate->getLexicalDeclContext());
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -308,6 +308,27 @@
   Attr.getRange());
 }
 
+void Sema::InstantiateAttrsForDecl(
+const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Tmpl,
+Decl *New, LateInstantiatedAttrVec *LateAttrs,
+LocalInstantiationScope *OuterMostScope) {
+  if (NamedDecl *ND = dyn_cast(New)) {
+for (const auto *TmplAttr : Tmpl->attrs()) {
+  // FIXME: If any of the special case versions from InstantiateAttrs become
+  // applicable to template declaration, we'll need to add them here.
+  CXXRecordDecl *ThisContext =
+  dyn_cast_or_null(ND->getDeclContext());
+  CXXThisScopeRAII ThisScope(*this, ThisContext, /*TypeQuals*/ 0,
+ ND && ND->isCXXInstanceMember());
+
+  Attr *NewAttr = sema::instantiateTemplateAttributeForDecl(
+  TmplAttr, Context, *this, TemplateArgs);
+  if (NewAttr)
+New->addAttr(NewAttr);
+}
+  }
+}
+
 void Sema::InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
 const Decl *Tmpl, Decl *New,
 LateInstantiatedAttrVec *LateAttrs,
@@ -945,6 +966,7 @@
 }
   }
 
+  SemaRef.InstantiateAttrsForDecl(TemplateArgs, D, Enum);
   SemaRef.InstantiateAttrs(TemplateArgs, D, Enum);
 
   Enum->setInstantiationOfMemberEnum(D, TSK_ImplicitInstantiation);
@@ -1033,6 +1055,7 @@
 }
 
 if (EnumConst) {
+  SemaRef.InstantiateAttrsForDecl(TemplateArgs, EC, EnumConst);
   SemaRef.InstantiateAttrs(TemplateArgs, EC, EnumConst);
 
   EnumConst->setAccess(Enum->getAccess());
Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -2452,26 +2452,21 @@
   OS << "#endif  // ATTR_VISITOR_DECLS_ONLY\n";
 }
 
-// Emits code to instantiate dependent attributes on templates.
-void EmitClangAttrTemplateInstantiate(RecordKeeper &Records, raw_ostream &OS) {
-  emitSourceFileHeader("Template instantiation code for attributes", OS);
-
-  std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
-
-  OS << "namespace clang {\n"
- << "namespace sema {\n\n"
- << "Attr *instantiateTemplateAttribute(const Attr *At, ASTContext &C, "
- << "Sema &S,\n"
- << "const MultiLevelTemplateArgumentList &TemplateArgs) {\n"
- << "  switch (At->getKind()) {\n";
+void EmitClangAttrTemplateInstantiateHelper(const std::vector &Attrs,
+raw_ostream &OS,
+bool AppliesToDecl) {
+  OS << "  switch (At->getKind()) {\n";
 
   for (const auto *Attr : Attrs) {
 const Record &R = *Attr;
 if (!R.getValueAsBit("ASTNode"))
   continue;
 
 OS << "case attr::" << R.getName() << ": {\n";
-bool ShouldClone = R.getValueAsBit("Clone");
+
+bool ShouldClone =
+R.getVal

[libcxx] r290976 - Implement the last bit of P0031: 'A Proposal to Add Constexpr Modifiers to reverse_iterator, move_iterator, array and Range Access' for C++17

2017-01-04 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Jan  4 11:58:17 2017
New Revision: 290976

URL: http://llvm.org/viewvc/llvm-project?rev=290976&view=rev
Log:
Implement the last bit of P0031: 'A Proposal to Add Constexpr Modifiers to 
reverse_iterator, move_iterator, array and Range Access' for C++17

Modified:
libcxx/trunk/include/array
libcxx/trunk/include/iterator

libcxx/trunk/test/std/containers/sequences/array/array.data/data_const.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/iterators.pass.cpp
libcxx/trunk/test/std/iterators/iterator.range/begin-end.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/array
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/array?rev=290976&r1=290975&r2=290976&view=diff
==
--- libcxx/trunk/include/array (original)
+++ libcxx/trunk/include/array Wed Jan  4 11:58:17 2017
@@ -149,31 +149,31 @@ struct _LIBCPP_TYPE_VIS_ONLY array
 { _VSTD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);}
 
 // iterators:
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 iterator begin() _NOEXCEPT {return iterator(__elems_);}
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 const_iterator begin() const _NOEXCEPT {return const_iterator(__elems_);}
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 iterator end() _NOEXCEPT {return iterator(__elems_ + _Size);}
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 const_iterator end() const _NOEXCEPT {return const_iterator(__elems_ + 
_Size);}
 
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 const_reverse_iterator rbegin() const _NOEXCEPT {return 
const_reverse_iterator(end());}
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 const_reverse_iterator rend() const _NOEXCEPT {return 
const_reverse_iterator(begin());}
 
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 const_iterator cbegin() const _NOEXCEPT {return begin();}
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 const_iterator cend() const _NOEXCEPT {return end();}
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 const_reverse_iterator crend() const _NOEXCEPT {return rend();}
 
 // capacity:
@@ -195,9 +195,9 @@ struct _LIBCPP_TYPE_VIS_ONLY array
 _LIBCPP_INLINE_VISIBILITY reference back()  {return 
__elems_[_Size > 0 ? _Size-1 : 0];}
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference 
back() const  {return __elems_[_Size > 0 ? _Size-1 : 0];}
 
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 value_type* data() _NOEXCEPT {return __elems_;}
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 const value_type* data() const _NOEXCEPT {return __elems_;}
 };
 

Modified: libcxx/trunk/include/iterator
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/iterator?rev=290976&r1=290975&r2=290976&view=diff
==
--- libcxx/trunk/include/iterator (original)
+++ libcxx/trunk/include/iterator Wed Jan  4 11:58:17 2017
@@ -378,25 +378,25 @@ public:
 bool failed() const noexcept;
 };
 
-template  auto begin(C& c) -> decltype(c.begin());
-template  auto begin(const C& c) -> decltype(c.begin());
-template  auto end(C& c) -> decltype(c.end());
-template  auto end(const C& c) -> decltype(c.end());
-template  T* begin(T (&array)[N]);
-template  T* end(T (&array)[N]);
-
-template  auto cbegin(const C& c) -> decltype(std::begin(c));
// C++14
-template  auto cend(const C& c) -> decltype(std::end(c));
// C++14
-template  auto rbegin(C& c) -> decltype(c.rbegin()); 
// C++14
-template  auto rbegin(const C& c) -> decltype(c.rbegin());   
// C++14
-template  auto rend(C& c) -> decltype(c.rend()); 
// C++14
-template  auto rend(const C& c) -> decltype(c.rend());   
// C++14
-template  reverse_iterator rbegin(initializer_list il); 
// C++14
-template  reverse_iterator rend

[PATCH] D28212: typeinfo: provide a partial implementation for Win32

2017-01-04 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: include/typeinfo:75
+#elif defined(_WIN32)
+#define _LIBCPP_HAS_WINDOWS_TYPEINFO
+#else

rnk wrote:
> Is _WIN32 the right condition? It seems like this is intended to match the MS 
> ABI RTTI structure, not the Itanium one. _MSC_VER maybe?
Yeah, this is meant to match the MS ABI RTTI.  Yeah, _MSC_VER seems more 
appropriate than _WIN32.



Comment at: src/typeinfo.cpp:28-32
+  static constexpr const size_t fnv_offset_basis = 14695981039346656037;
+  static constexpr const size_t fnv_prime = 10995116282110;
+#else
+  static constexpr const size_t fnv_offset_basis = 2166136261;
+  static constexpr const size_t fnv_prime = 16777619;

rnk wrote:
> compnerd wrote:
> > majnemer wrote:
> > > majnemer wrote:
> > > > Why make these static? Seems strange to use that storage duration.
> > > These literals are ill-formed, I think you need a ULL suffix here.
> > Oh, just to ensure that they are handled as literal constants.  I can drop 
> > the static if you like, since the compiler should do the right thing 
> > anyways.
> Isn't `constexpr const` redundant?
Yeah, intentional.  I should be using `_LIBCPP_CONSTEXPR` just incase the 
compiler doesn't support constexpr.


https://reviews.llvm.org/D28212



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


[PATCH] D26034: [CodeCompletion] Block property setters: Use dynamic priority heuristic

2017-01-04 Thread Manman Ren via Phabricator via cfe-commits
manmanren accepted this revision.
manmanren added a comment.
This revision is now accepted and ready to land.

LGTM.

Manman


Repository:
  rL LLVM

https://reviews.llvm.org/D26034



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


[PATCH] D28257: [OpenCL] Re-enable supported core extensions based on opencl version when disabling all extensions using pragma

2017-01-04 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl added inline comments.



Comment at: test/SemaOpenCL/extensions.cl:47
 
+#ifndef _OPENCL_H_
 int isnan(float x) {

Anastasia wrote:
> Why do you need this?
`isnan` and `isfinite` are declared in opencl-c.h, so without guards I am 
getting redeclation diagnostics. Alternatively we can add overloadable 
attribute to `isnan` and `isfinite` in the test to avoid those diagnostic 
messages?


https://reviews.llvm.org/D28257



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


[PATCH] D27486: Correct class-template deprecation behavior

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



Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:322
+  CXXThisScopeRAII ThisScope(*this, ThisContext, /*TypeQuals*/ 0,
+ ND && ND->isCXXInstanceMember());
+

No need to check for `ND` here; already done above. You might also want to 
remove `ThisContext` and just sink the initialization.



Comment at: utils/TableGen/ClangAttrEmitter.cpp:2520
+ << "const MultiLevelTemplateArgumentList &TemplateArgs) {\n";
+  EmitClangAttrTemplateInstantiateHelper(Attrs, OS, /*DeclTime=*/false);
+  OS << "}\n\n"

DeclTime -> AppliesToDecl



Comment at: utils/TableGen/ClangAttrEmitter.cpp:2525
+ << "const MultiLevelTemplateArgumentList &TemplateArgs) {\n";
+  EmitClangAttrTemplateInstantiateHelper(Attrs, OS, /*DeclTime=*/true);
+

DeclTime -> AppliesToDecl


https://reviews.llvm.org/D27486



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


r290979 - Accept and ignore -Wa, -mbig-obj on COFF targets for gas compatibility

2017-01-04 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Wed Jan  4 12:16:32 2017
New Revision: 290979

URL: http://llvm.org/viewvc/llvm-project?rev=290979&view=rev
Log:
Accept and ignore -Wa,-mbig-obj on COFF targets for gas compatibility

LLVM's integrated assembler will automatically switch to big objects
when there are more than 2**16 sections.

Patch by Kyra!

Added:
cfe/trunk/test/Driver/mbig-obj.c
Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=290979&r1=290978&r2=290979&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Jan  4 12:16:32 2017
@@ -3067,6 +3067,10 @@ static void CollectArgsForIntegratedAsse
 continue;
   }
 
+  if (C.getDefaultToolChain().getTriple().isOSBinFormatCOFF() &&
+  Value == "-mbig-obj")
+continue; // LLVM handles bigobj automatically
+
   switch (C.getDefaultToolChain().getArch()) {
   default:
 break;

Added: cfe/trunk/test/Driver/mbig-obj.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mbig-obj.c?rev=290979&view=auto
==
--- cfe/trunk/test/Driver/mbig-obj.c (added)
+++ cfe/trunk/test/Driver/mbig-obj.c Wed Jan  4 12:16:32 2017
@@ -0,0 +1,9 @@
+// RUN: %clang --target=x86_64-windows -c -Wa,-mbig-obj %s 2>&1 | FileCheck %s 
--check-prefix=WINDOWS
+// RUN: %clang --target=x86_64-windows -c -Xassembler -mbig-obj %s 2>&1 | 
FileCheck %s --check-prefix=WINDOWS
+// RUN: not %clang --target=x86_64-linux -c -Wa,-mbig-obj %s 2>&1 | FileCheck 
%s --check-prefix=LINUX
+// RUN: not %clang --target=x86_64-linux -c -Xassembler -mbig-obj %s 2>&1 | 
FileCheck %s --check-prefix=LINUX
+// WINDOWS-NOT: argument unused during compilation
+// LINUX: unsupported argument '-mbig-obj' to option '{{(Wa,|Xassembler)}}'
+#ifdef _WIN32
+#warning "produce non-empty output for FileCheck"
+#endif


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


[PATCH] D27486: Correct class-template deprecation behavior

2017-01-04 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 83081.
erichkeane marked 3 inline comments as done.
erichkeane added a comment.

Aaron's new comments


https://reviews.llvm.org/D27486

Files:
  include/clang/Basic/Attr.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -1882,6 +1882,8 @@
   namespace sema {
 Attr *instantiateTemplateAttribute(const Attr *At, ASTContext &C, Sema &S,
 const MultiLevelTemplateArgumentList &TemplateArgs);
+Attr *instantiateTemplateAttributeForDecl(const Attr *At, ASTContext &C, Sema &S,
+const MultiLevelTemplateArgumentList &TemplateArgs);
   }
 }
 
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -2401,6 +2401,10 @@
 ClassTemplate->getLocation(),
  ClassTemplate,
  Converted, nullptr);
+  MultiLevelTemplateArgumentList TemplateArgLists;
+  TemplateArgLists.addOuterTemplateArguments(Converted);
+  InstantiateAttrsForDecl(TemplateArgLists,
+  ClassTemplate->getTemplatedDecl(), Decl);
   ClassTemplate->AddSpecialization(Decl, InsertPos);
   if (ClassTemplate->isOutOfLine())
 Decl->setLexicalDeclContext(ClassTemplate->getLexicalDeclContext());
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -308,6 +308,26 @@
   Attr.getRange());
 }
 
+void Sema::InstantiateAttrsForDecl(
+const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Tmpl,
+Decl *New, LateInstantiatedAttrVec *LateAttrs,
+LocalInstantiationScope *OuterMostScope) {
+  if (NamedDecl *ND = dyn_cast(New)) {
+for (const auto *TmplAttr : Tmpl->attrs()) {
+  // FIXME: If any of the special case versions from InstantiateAttrs become
+  // applicable to template declaration, we'll need to add them here.
+  CXXThisScopeRAII ThisScope(
+  *this, dyn_cast_or_null(ND->getDeclContext()),
+  /*TypeQuals*/ 0, ND->isCXXInstanceMember());
+
+  Attr *NewAttr = sema::instantiateTemplateAttributeForDecl(
+  TmplAttr, Context, *this, TemplateArgs);
+  if (NewAttr)
+New->addAttr(NewAttr);
+}
+  }
+}
+
 void Sema::InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
 const Decl *Tmpl, Decl *New,
 LateInstantiatedAttrVec *LateAttrs,
@@ -945,6 +965,7 @@
 }
   }
 
+  SemaRef.InstantiateAttrsForDecl(TemplateArgs, D, Enum);
   SemaRef.InstantiateAttrs(TemplateArgs, D, Enum);
 
   Enum->setInstantiationOfMemberEnum(D, TSK_ImplicitInstantiation);
@@ -1033,6 +1054,7 @@
 }
 
 if (EnumConst) {
+  SemaRef.InstantiateAttrsForDecl(TemplateArgs, EC, EnumConst);
   SemaRef.InstantiateAttrs(TemplateArgs, EC, EnumConst);
 
   EnumConst->setAccess(Enum->getAccess());
Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -2452,26 +2452,21 @@
   OS << "#endif  // ATTR_VISITOR_DECLS_ONLY\n";
 }
 
-// Emits code to instantiate dependent attributes on templates.
-void EmitClangAttrTemplateInstantiate(RecordKeeper &Records, raw_ostream &OS) {
-  emitSourceFileHeader("Template instantiation code for attributes", OS);
-
-  std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
-
-  OS << "namespace clang {\n"
- << "namespace sema {\n\n"
- << "Attr *instantiateTemplateAttribute(const Attr *At, ASTContext &C, "
- << "Sema &S,\n"
- << "const MultiLevelTemplateArgumentList &TemplateArgs) {\n"
- << "  switch (At->getKind()) {\n";
+void EmitClangAttrTemplateInstantiateHelper(const std::vector &Attrs,
+raw_ostream &OS,
+bool AppliesToDecl) {
+  OS << "  switch (At->getKind()) {\n";
 
   for (const auto *Attr : Attrs) {
 const Record &R = *Attr;
 if (!R.getValueAsBit("ASTNode"))
   continue;
 
 OS << "case attr::" << R.getName() << ": {\n";
-bool ShouldClone = R.getValueAsBit("Clone");
+
+bool ShouldClone =
+R.getValueAsBit("Clone") &&
+R.getValueAsBit("AppliesToTemplateDeclaration") == AppliesToD

[PATCH] D28271: [Sema] Get rid of unused default argument to Sema::CheckCallingConvAttr.

2017-01-04 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

Thanks for the review, Reid.


https://reviews.llvm.org/D28271



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


[PATCH] D28271: [Sema] Get rid of unused default argument to Sema::CheckCallingConvAttr.

2017-01-04 Thread Justin Lebar via Phabricator via cfe-commits
jlebar abandoned this revision.
jlebar added a comment.

> I think you've discovered this bug:

Hm, I guess this is a step in the wrong direction, then.

(I spun this patch after writing some code in this function that assumed I'd 
get a FunctionDecl where appropriate, which of course doesn't work.)


https://reviews.llvm.org/D28271



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


[PATCH] D27486: Correct class-template deprecation behavior

2017-01-04 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Marking Aaron's comments done.


https://reviews.llvm.org/D27486



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


[PATCH] D28304: [compiler-rt] [cmake] Disable appending -msse* flags implicitly

2017-01-04 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: cryptoad, kcc, samsonov.
mgorny added a subscriber: cfe-commits.
Herald added subscribers: dberris, kubabrecka.

Disable the code appending -msse3 and -msse4.2 flags implicitly when
the compiler supports them. The compiler support for those flags do not
indicate that the underlying CPU will support them, and passing those
flags to the compiler may result in SSE3/SSE4.2 code being emitted
*implicitly*.

If the target platform supports SSE3/SSE4.2 appropriately, the relevant
bits should be already enabled via -march= or equivalent. In this case
passing -msse* is redundant.

If a runtime detection is desired (which seems to be a case with SCUDO),
then (as gcc manpage points out) the specific SSE4.2 needs to be
isolated into a separate file, the -msse4.2 flag can be forced only
for that file and the function defined in that file can only be called
when the CPU is determined to support SSE4.2.

This fixes SIGILL on SCUDO when it is compiled using gcc-5.4.


https://reviews.llvm.org/D28304

Files:
  cmake/config-ix.cmake
  lib/scudo/CMakeLists.txt
  lib/tsan/CMakeLists.txt


Index: lib/tsan/CMakeLists.txt
===
--- lib/tsan/CMakeLists.txt
+++ lib/tsan/CMakeLists.txt
@@ -16,7 +16,6 @@
 endif()
 
 set(TSAN_RTL_CFLAGS ${TSAN_CFLAGS})
-append_list_if(COMPILER_RT_HAS_MSSE3_FLAG -msse3 TSAN_RTL_CFLAGS)
 append_list_if(SANITIZER_LIMIT_FRAME_SIZE -Wframe-larger-than=530
TSAN_RTL_CFLAGS)
 append_list_if(COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG -Wglobal-constructors
Index: lib/scudo/CMakeLists.txt
===
--- lib/scudo/CMakeLists.txt
+++ lib/scudo/CMakeLists.txt
@@ -4,7 +4,6 @@
 
 set(SCUDO_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 append_rtti_flag(OFF SCUDO_CFLAGS)
-append_list_if(COMPILER_RT_HAS_MSSE4_2_FLAG -msse4.2 SCUDO_CFLAGS)
 
 set(SCUDO_SOURCES
   scudo_allocator.cpp
Index: cmake/config-ix.cmake
===
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -28,8 +28,6 @@
 check_cxx_compiler_flag(-std=c++11   COMPILER_RT_HAS_STD_CXX11_FLAG)
 check_cxx_compiler_flag(-ftls-model=initial-exec 
COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC)
 check_cxx_compiler_flag(-fno-lto COMPILER_RT_HAS_FNO_LTO_FLAG)
-check_cxx_compiler_flag("-Werror -msse3" COMPILER_RT_HAS_MSSE3_FLAG)
-check_cxx_compiler_flag("-Werror -msse4.2"   COMPILER_RT_HAS_MSSE4_2_FLAG)
 check_cxx_compiler_flag(--sysroot=.  COMPILER_RT_HAS_SYSROOT_FLAG)
 
 if(NOT WIN32 AND NOT CYGWIN)


Index: lib/tsan/CMakeLists.txt
===
--- lib/tsan/CMakeLists.txt
+++ lib/tsan/CMakeLists.txt
@@ -16,7 +16,6 @@
 endif()
 
 set(TSAN_RTL_CFLAGS ${TSAN_CFLAGS})
-append_list_if(COMPILER_RT_HAS_MSSE3_FLAG -msse3 TSAN_RTL_CFLAGS)
 append_list_if(SANITIZER_LIMIT_FRAME_SIZE -Wframe-larger-than=530
TSAN_RTL_CFLAGS)
 append_list_if(COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG -Wglobal-constructors
Index: lib/scudo/CMakeLists.txt
===
--- lib/scudo/CMakeLists.txt
+++ lib/scudo/CMakeLists.txt
@@ -4,7 +4,6 @@
 
 set(SCUDO_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 append_rtti_flag(OFF SCUDO_CFLAGS)
-append_list_if(COMPILER_RT_HAS_MSSE4_2_FLAG -msse4.2 SCUDO_CFLAGS)
 
 set(SCUDO_SOURCES
   scudo_allocator.cpp
Index: cmake/config-ix.cmake
===
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -28,8 +28,6 @@
 check_cxx_compiler_flag(-std=c++11   COMPILER_RT_HAS_STD_CXX11_FLAG)
 check_cxx_compiler_flag(-ftls-model=initial-exec COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC)
 check_cxx_compiler_flag(-fno-lto COMPILER_RT_HAS_FNO_LTO_FLAG)
-check_cxx_compiler_flag("-Werror -msse3" COMPILER_RT_HAS_MSSE3_FLAG)
-check_cxx_compiler_flag("-Werror -msse4.2"   COMPILER_RT_HAS_MSSE4_2_FLAG)
 check_cxx_compiler_flag(--sysroot=.  COMPILER_RT_HAS_SYSROOT_FLAG)
 
 if(NOT WIN32 AND NOT CYGWIN)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27486: Correct class-template deprecation behavior

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

This LGTM, but you should wait for @rsmith to sign off as well.


https://reviews.llvm.org/D27486



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


[PATCH] D27486: Correct class-template deprecation behavior

2017-01-04 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Thanks for your help here Aaron.

I agree about waiting for @rsmith, thanks!


https://reviews.llvm.org/D27486



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


[PATCH] D28301: [CUDA] Pre-include sm_60 and sm_61 headers.

2017-01-04 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290982: [CUDA] Pre-include sm_60 and sm_61 headers. 
(authored by tra).

Changed prior to commit:
  https://reviews.llvm.org/D28301?vs=83071&id=83083#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28301

Files:
  cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h


Index: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -232,6 +232,11 @@
 // hardware, seems to generate faster machine code because ptxas can more 
easily
 // reason about our code.
 
+#if CUDA_VERSION >= 8000
+#include "sm_60_atomic_functions.hpp"
+#include "sm_61_intrinsics.hpp"
+#endif
+
 #undef __MATH_FUNCTIONS_HPP__
 
 // math_functions.hpp defines ::signbit as a __host__ __device__ function.  
This


Index: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -232,6 +232,11 @@
 // hardware, seems to generate faster machine code because ptxas can more easily
 // reason about our code.
 
+#if CUDA_VERSION >= 8000
+#include "sm_60_atomic_functions.hpp"
+#include "sm_61_intrinsics.hpp"
+#endif
+
 #undef __MATH_FUNCTIONS_HPP__
 
 // math_functions.hpp defines ::signbit as a __host__ __device__ function.  This
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r290982 - [CUDA] Pre-include sm_60 and sm_61 headers.

2017-01-04 Thread Artem Belevich via cfe-commits
Author: tra
Date: Wed Jan  4 12:39:29 2017
New Revision: 290982

URL: http://llvm.org/viewvc/llvm-project?rev=290982&view=rev
Log:
[CUDA] Pre-include sm_60 and sm_61 headers.

CUDA-8.0 comes with new headers which nvcc pre-includes via cuda_runtime.h
Clang now makes them available as well.

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

Modified:
cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h

Modified: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h?rev=290982&r1=290981&r2=290982&view=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h Wed Jan  4 12:39:29 
2017
@@ -232,6 +232,11 @@ static inline __device__ void __brkpt(in
 // hardware, seems to generate faster machine code because ptxas can more 
easily
 // reason about our code.
 
+#if CUDA_VERSION >= 8000
+#include "sm_60_atomic_functions.hpp"
+#include "sm_61_intrinsics.hpp"
+#endif
+
 #undef __MATH_FUNCTIONS_HPP__
 
 // math_functions.hpp defines ::signbit as a __host__ __device__ function.  
This


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


[PATCH] D28304: [compiler-rt] [cmake] Disable appending -msse* flags implicitly

2017-01-04 Thread Kostya Kortchinsky via Phabricator via cfe-commits
cryptoad added a comment.

Hey Michal,
If I understand correctly, my next move is to move the CRC32 code into it's own 
file an only enable SSE 4.2 for this file?
Shouldn't COMPILER_RT_HAS_MSSE4_2_FLAG be kept for that purpose or is there an 
alternative way to do it?
Thanks


https://reviews.llvm.org/D28304



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


r290983 - [OpenMP] Update target codegen for NVPTX device.

2017-01-04 Thread Arpith Chacko Jacob via cfe-commits
Author: arpith
Date: Wed Jan  4 12:44:50 2017
New Revision: 290983

URL: http://llvm.org/viewvc/llvm-project?rev=290983&view=rev
Log:
[OpenMP] Update target codegen for NVPTX device.

This patch includes updates for codegen of the target region for the NVPTX
device. It moves initializers from the compiler to the runtime and updates
the worker loop to assume parallel work is retrieved from the runtime. A
subsequent patch will update the codegen to retrieve the parallel work using
calls to the runtime. It includes the removal of the inline attribute
for the worker loop and disabling debug info in it.

This allows codegen for a target directive and serial execution on the
NVPTX device.

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


Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=290983&r1=290982&r2=290983&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Wed Jan  4 12:44:50 2017
@@ -22,14 +22,10 @@ using namespace CodeGen;
 
 namespace {
 enum OpenMPRTLFunctionNVPTX {
-  /// \brief Call to void __kmpc_kernel_init(kmp_int32 omp_handle,
-  /// kmp_int32 thread_limit);
+  /// \brief Call to void __kmpc_kernel_init(kmp_int32 thread_limit);
   OMPRTL_NVPTX__kmpc_kernel_init,
-};
-
-// NVPTX Address space
-enum AddressSpace {
-  AddressSpaceShared = 3,
+  /// \brief Call to void __kmpc_kernel_deinit();
+  OMPRTL_NVPTX__kmpc_kernel_deinit,
 };
 } // namespace
 
@@ -70,6 +66,15 @@ static void getNVPTXCTABarrier(CodeGenFu
 /// Synchronize all GPU threads in a block.
 static void syncCTAThreads(CodeGenFunction &CGF) { getNVPTXCTABarrier(CGF); }
 
+/// Get the value of the thread_limit clause in the teams directive.
+/// The runtime encodes thread_limit in the launch parameter, always starting
+/// thread_limit+warpSize threads per team.
+static llvm::Value *getThreadLimit(CodeGenFunction &CGF) {
+  CGBuilderTy &Bld = CGF.Builder;
+  return Bld.CreateSub(getNVPTXNumThreads(CGF), getNVPTXWarpSize(CGF),
+   "thread_limit");
+}
+
 /// Get the thread id of the OMP master thread.
 /// The master thread id is the first thread (lane) of the last warp in the
 /// GPU block.  Warp size is assumed to be some power of 2.
@@ -103,35 +108,105 @@ void CGOpenMPRuntimeNVPTX::WorkerFunctio
   CGM.getTypes().GetFunctionType(*CGFI), 
llvm::GlobalValue::InternalLinkage,
   /* placeholder */ "_worker", &CGM.getModule());
   CGM.SetInternalFunctionAttributes(/*D=*/nullptr, WorkerFn, *CGFI);
-  WorkerFn->setLinkage(llvm::GlobalValue::InternalLinkage);
-  WorkerFn->addFnAttr(llvm::Attribute::NoInline);
 }
 
-void CGOpenMPRuntimeNVPTX::initializeEnvironment() {
-  //
-  // Initialize master-worker control state in shared memory.
-  //
+void CGOpenMPRuntimeNVPTX::emitGenericKernel(const OMPExecutableDirective &D,
+ StringRef ParentName,
+ llvm::Function *&OutlinedFn,
+ llvm::Constant *&OutlinedFnID,
+ bool IsOffloadEntry,
+ const RegionCodeGenTy &CodeGen) {
+  EntryFunctionState EST;
+  WorkerFunctionState WST(CGM);
+
+  // Emit target region as a standalone region.
+  class NVPTXPrePostActionTy : public PrePostActionTy {
+CGOpenMPRuntimeNVPTX &RT;
+CGOpenMPRuntimeNVPTX::EntryFunctionState &EST;
+CGOpenMPRuntimeNVPTX::WorkerFunctionState &WST;
+
+  public:
+NVPTXPrePostActionTy(CGOpenMPRuntimeNVPTX &RT,
+ CGOpenMPRuntimeNVPTX::EntryFunctionState &EST,
+ CGOpenMPRuntimeNVPTX::WorkerFunctionState &WST)
+: RT(RT), EST(EST), WST(WST) {}
+void Enter(CodeGenFunction &CGF) override {
+  RT.emitGenericEntryHeader(CGF, EST, WST);
+}
+void Exit(CodeGenFunction &CGF) override {
+  RT.emitGenericEntryFooter(CGF, EST);
+}
+  } Action(*this, EST, WST);
+  CodeGen.setAction(Action);
+  emitTargetOutlinedFunctionHelper(D, ParentName, OutlinedFn, OutlinedFnID,
+   IsOffloadEntry, CodeGen);
+
+  // Create the worker function
+  emitWorkerFunction(WST);
+
+  // Now change the name of the worker function to correspond to this target
+  // region's entry function.
+  WST.WorkerFn->setName(OutlinedFn->getName() + "_worker");
+}
+
+// Setup NVPTX threads for master-worker OpenMP scheme.
+void CGOpenMPRuntimeNVPTX::emitGenericEntryHeader(CodeGenFunction &CGF,
+  EntryFunctionState &EST,
+

[PATCH] D28125: [OpenMP] Update target codegen for NVPTX device.

2017-01-04 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290983: [OpenMP] Update target codegen for NVPTX device. 
(authored by arpith).

Changed prior to commit:
  https://reviews.llvm.org/D28125?vs=82621&id=83085#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28125

Files:
  cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp

Index: cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp
===
--- cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp
+++ cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp
@@ -8,9 +8,6 @@
 #ifndef HEADER
 #define HEADER
 
-// CHECK-DAG: [[OMP_NT:@.+]] = common addrspace(3) global i32 0
-// CHECK-DAG: [[OMP_WID:@.+]] = common addrspace(3) global i64 0
-
 template
 struct TT{
   tx X;
@@ -26,19 +23,22 @@
   double cn[5][n];
   TT d;
 
-  // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+foo.+l87}}_worker()
+  // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+foo.+l93}}_worker()
+  // CHECK-DAG: [[OMP_EXEC_STATUS:%.+]] = alloca i8,
+  // CHECK-DAG: [[OMP_WORK_FN:%.+]] = alloca i8*,
+  // CHECK: store i8* null, i8** [[OMP_WORK_FN]],
+  // CHECK: store i8 0, i8* [[OMP_EXEC_STATUS]],
   // CHECK: br label {{%?}}[[AWAIT_WORK:.+]]
   //
   // CHECK: [[AWAIT_WORK]]
   // CHECK: call void @llvm.nvvm.barrier0()
-  // CHECK: [[WORK:%.+]] = load i64, i64 addrspace(3)* [[OMP_WID]],
-  // CHECK: [[SHOULD_EXIT:%.+]] = icmp eq i64 [[WORK]], 0
+  // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
+  // CHECK: [[SHOULD_EXIT:%.+]] = icmp eq i8* [[WORK]], null
   // CHECK: br i1 [[SHOULD_EXIT]], label {{%?}}[[EXIT:.+]], label {{%?}}[[SEL_WORKERS:.+]]
   //
   // CHECK: [[SEL_WORKERS]]
-  // CHECK: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
-  // CHECK: [[NT:%.+]] = load i32, i32 addrspace(3)* [[OMP_NT]]
-  // CHECK: [[IS_ACTIVE:%.+]] = icmp slt i32 [[TID]], [[NT]]
+  // CHECK: [[ST:%.+]] = load i8, i8* [[OMP_EXEC_STATUS]],
+  // CHECK: [[IS_ACTIVE:%.+]] = icmp ne i8 [[ST]], 0
   // CHECK: br i1 [[IS_ACTIVE]], label {{%?}}[[EXEC_PARALLEL:.+]], label {{%?}}[[BAR_PARALLEL:.+]]
   //
   // CHECK: [[EXEC_PARALLEL]]
@@ -54,31 +54,37 @@
   // CHECK: [[EXIT]]
   // CHECK: ret void
 
-  // CHECK: define {{.*}}void [[T1:@__omp_offloading_.+foo.+l87]]()
-  // CHECK: [[NTID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
-  // CHECK: [[WS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
-  // CHECK: [[A:%.+]] = sub i32 [[WS]], 1
-  // CHECK: [[B:%.+]] = sub i32 [[NTID]], 1
-  // CHECK: [[MID:%.+]] = and i32 [[B]],
-  // CHECK: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
-  // CHECK: [[EXCESS:%.+]] = icmp ugt i32 [[TID]], [[MID]]
-  // CHECK: br i1 [[EXCESS]], label {{%?}}[[EXIT:.+]], label {{%?}}[[CHECK_WORKER:.+]]
-  //
-  // CHECK: [[CHECK_WORKER]]
-  // CHECK: [[IS_WORKER:%.+]] = icmp ult i32 [[TID]], [[MID]]
-  // CHECK: br i1 [[IS_WORKER]], label {{%?}}[[WORKER:.+]], label {{%?}}[[MASTER:.+]]
+  // CHECK: define {{.*}}void [[T1:@__omp_offloading_.+foo.+l93]]()
+  // CHECK-DAG: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  // CHECK-DAG: [[NTH:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
+  // CHECK-DAG: [[WS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
+  // CHECK-DAG: [[TH_LIMIT:%.+]] = sub i32 [[NTH]], [[WS]]
+  // CHECK: [[IS_WORKER:%.+]] = icmp ult i32 [[TID]], [[TH_LIMIT]]
+  // CHECK: br i1 [[IS_WORKER]], label {{%?}}[[WORKER:.+]], label {{%?}}[[CHECK_MASTER:.+]]
   //
   // CHECK: [[WORKER]]
   // CHECK: {{call|invoke}} void [[T1]]_worker()
-  // CHECK: br label {{%?}}[[EXIT]]
+  // CHECK: br label {{%?}}[[EXIT:.+]]
+  //
+  // CHECK: [[CHECK_MASTER]]
+  // CHECK-DAG: [[CMTID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  // CHECK-DAG: [[CMNTH:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
+  // CHECK-DAG: [[CMWS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
+  // CHECK: [[CMTMP1:%.+]] = sub i32 [[CMWS]], 1
+  // CHECK: [[CMTMP2:%.+]] = sub i32 [[CMNTH]], 1
+  // CHECK: [[MID:%.+]] = and i32 [[CMTMP2]],
+  // CHECK: [[IS_MASTER:%.+]] = icmp eq i32 [[CMTID]], [[MID]]
+  // CHECK: br i1 [[IS_MASTER]], label {{%?}}[[MASTER:.+]], label {{%?}}[[EXIT]]
   //
   // CHECK: [[MASTER]]
-  // CHECK: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
-  // CHECK: call void @__kmpc_kernel_init(i32 0, i32 [[TID]])
-  // CHECK: br label {{%?}}[[TERM:.+]]
+  // CHECK-DAG: [[MNTH:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
+  // CHECK-DAG: [[MWS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
+  // CHECK: [[MTMP1:%.+]] = sub i32 [[MNTH]], [[MWS]]
+  // CHECK: call void @__kmpc_kernel_init(i32 [[MTMP1]]
+  // CHECK: br label {{%?}}[[TERMINATE:.+]]
   //
-  // CHECK: [[TERM]]
-  // CHECK: store i64 0, i64 addrspace(3)* [[OMP_WID]],
+  // CHECK: [[TERMINATE]]
+  // CHECK: call void @__kmpc_kernel_deinit()
   // CHECK: call void @ll

[PATCH] D27529: Correct Vectorcall Register passing and HVA Behavior

2017-01-04 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: include/clang/CodeGen/CGFunctionInfo.h:136
   }
+  static ABIArgInfo getDirectHva(llvm::Type *T = nullptr) {
+auto AI = getDirect(T);

Marking HVAs with inreg is an x86-specific convention. Let's move this down to 
TargetInfo.cpp and call it something like `getDirectX86HVA` or something.



Comment at: include/clang/CodeGen/CGFunctionInfo.h:139
+AI.setInReg(true);
+AI.setCanBeFlattened(false);
+return AI;

In the long run, I think ABIArgInfo::Direct is too overloaded and needs to be 
split. The implementation of a single direct argument in EmitFunctionPrologue 
is *174* lines. It would be much cleaner to make some new ABIArgInfo types 
instead of having these "can be flattened" flags and things.



Comment at: lib/CodeGen/TargetInfo.cpp:1507
-   State.CC == llvm::CallingConv::X86_RegCall) &&
-  isHomogeneousAggregate(Ty, Base, NumElts)) {
-if (State.FreeSSERegs >= NumElts) {

You don't seem to do anything in this if block if !IsHva, so maybe fold it back 
into the initial check like it was, and then break out the case for regcall and 
vectorcall separately.



Comment at: lib/CodeGen/TargetInfo.cpp:1678-1679
+// HVAs must be done as a second priority for registers, so the deferred
+// items
+// are dealt with by going through the pattern a second time.
+for (auto &I : FI.arguments()) {

Rewrap this. clang-format breaks comments without re-flowing, since it doesn't 
know what should flow together.


https://reviews.llvm.org/D27529



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


[PATCH] D28306: Remove fixme, use ASTContext::getCanonicalTemplateSpecializationType

2017-01-04 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev created this revision.
v.g.vassilev added a reviewer: rsmith.
v.g.vassilev added a subscriber: cfe-commits.
v.g.vassilev set the repository for this revision to rL LLVM.

Repository:
  rL LLVM

https://reviews.llvm.org/D28306

Files:
  lib/Sema/SemaTemplate.cpp


Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -2292,15 +2292,7 @@
 // A have identical types when A is declared as:
 //
 //   template struct A;
-TemplateName CanonName = Context.getCanonicalTemplateName(Name);
-CanonType = Context.getTemplateSpecializationType(CanonName,
-  Converted);
-
-// FIXME: CanonType is not actually the canonical type, and unfortunately
-// it is a TemplateSpecializationType that we will never use again.
-// In the future, we need to teach getTemplateSpecializationType to only
-// build the canonical type and return that to us.
-CanonType = Context.getCanonicalType(CanonType);
+CanonType = Context.getCanonicalTemplateSpecializationType(Name, 
Converted);
 
 // This might work out to be a current instantiation, in which
 // case the canonical type needs to be the InjectedClassNameType.
@@ -3353,7 +3345,7 @@
  SourceLocation TemplateLoc,
  SourceLocation RAngleLoc,
  TemplateTypeParmDecl *Param,
- SmallVectorImpl &Converted) {
+ SmallVectorImpl &Converted) {
   TypeSourceInfo *ArgType = Param->getDefaultArgumentInfo();
 
   // If the argument type is dependent, instantiate it now based


Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -2292,15 +2292,7 @@
 // A have identical types when A is declared as:
 //
 //   template struct A;
-TemplateName CanonName = Context.getCanonicalTemplateName(Name);
-CanonType = Context.getTemplateSpecializationType(CanonName,
-  Converted);
-
-// FIXME: CanonType is not actually the canonical type, and unfortunately
-// it is a TemplateSpecializationType that we will never use again.
-// In the future, we need to teach getTemplateSpecializationType to only
-// build the canonical type and return that to us.
-CanonType = Context.getCanonicalType(CanonType);
+CanonType = Context.getCanonicalTemplateSpecializationType(Name, Converted);
 
 // This might work out to be a current instantiation, in which
 // case the canonical type needs to be the InjectedClassNameType.
@@ -3353,7 +3345,7 @@
  SourceLocation TemplateLoc,
  SourceLocation RAngleLoc,
  TemplateTypeParmDecl *Param,
- SmallVectorImpl &Converted) {
+ SmallVectorImpl &Converted) {
   TypeSourceInfo *ArgType = Param->getDefaultArgumentInfo();
 
   // If the argument type is dependent, instantiate it now based
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r290984 - Use -### so the mbig-obj.c test passes when there is no registered x86 target

2017-01-04 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Wed Jan  4 12:50:51 2017
New Revision: 290984

URL: http://llvm.org/viewvc/llvm-project?rev=290984&view=rev
Log:
Use -### so the mbig-obj.c test passes when there is no registered x86 target

Modified:
cfe/trunk/test/Driver/mbig-obj.c

Modified: cfe/trunk/test/Driver/mbig-obj.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mbig-obj.c?rev=290984&r1=290983&r2=290984&view=diff
==
--- cfe/trunk/test/Driver/mbig-obj.c (original)
+++ cfe/trunk/test/Driver/mbig-obj.c Wed Jan  4 12:50:51 2017
@@ -1,9 +1,6 @@
-// RUN: %clang --target=x86_64-windows -c -Wa,-mbig-obj %s 2>&1 | FileCheck %s 
--check-prefix=WINDOWS
-// RUN: %clang --target=x86_64-windows -c -Xassembler -mbig-obj %s 2>&1 | 
FileCheck %s --check-prefix=WINDOWS
-// RUN: not %clang --target=x86_64-linux -c -Wa,-mbig-obj %s 2>&1 | FileCheck 
%s --check-prefix=LINUX
-// RUN: not %clang --target=x86_64-linux -c -Xassembler -mbig-obj %s 2>&1 | 
FileCheck %s --check-prefix=LINUX
+// RUN: %clang --target=x86_64-windows -c -Wa,-mbig-obj %s -### 2>&1 | 
FileCheck %s --check-prefix=WINDOWS
+// RUN: %clang --target=x86_64-windows -c -Xassembler -mbig-obj %s -### 2>&1 | 
FileCheck %s --check-prefix=WINDOWS
+// RUN: %clang --target=x86_64-linux -c -Wa,-mbig-obj %s -### 2>&1 | FileCheck 
%s --check-prefix=LINUX
+// RUN: %clang --target=x86_64-linux -c -Xassembler -mbig-obj %s -### 2>&1 | 
FileCheck %s --check-prefix=LINUX
 // WINDOWS-NOT: argument unused during compilation
 // LINUX: unsupported argument '-mbig-obj' to option '{{(Wa,|Xassembler)}}'
-#ifdef _WIN32
-#warning "produce non-empty output for FileCheck"
-#endif


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


[PATCH] D28271: [Sema] Get rid of unused default argument to Sema::CheckCallingConvAttr.

2017-01-04 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In general we can't get an FD here because we might be in the middle of parsing 
the declarator. The calls from SemaType.cpp in particular can't actually 
provide one. They would have to thread through the IsVariadic and IsCXXMethod 
bools based on syntactic cues (the ellipsis, member pointer declarator chunks, 
being the appropriate declarator chunk in a record context, i.e. what 
getCCForDeclaratorChunk does).


https://reviews.llvm.org/D28271



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


[PATCH] D22275: Support -fno-delayed-template-parsing in clang-cl.exe

2017-01-04 Thread Reid Kleckner via Phabricator via cfe-commits
rnk commandeered this revision.
rnk edited reviewers, added: DaveBartolomeo; removed: rnk.
rnk added a comment.

Looks good, let me grab this and add a test. I think this just got lost in the 
shuffle over the summer.


https://reviews.llvm.org/D22275



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


r290989 - Reverting commit r290983 while debugging test failure on windows.

2017-01-04 Thread Arpith Chacko Jacob via cfe-commits
Author: arpith
Date: Wed Jan  4 13:14:43 2017
New Revision: 290989

URL: http://llvm.org/viewvc/llvm-project?rev=290989&view=rev
Log:
Reverting commit r290983 while debugging test failure on windows.


Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=290989&r1=290988&r2=290989&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Wed Jan  4 13:14:43 2017
@@ -22,10 +22,14 @@ using namespace CodeGen;
 
 namespace {
 enum OpenMPRTLFunctionNVPTX {
-  /// \brief Call to void __kmpc_kernel_init(kmp_int32 thread_limit);
+  /// \brief Call to void __kmpc_kernel_init(kmp_int32 omp_handle,
+  /// kmp_int32 thread_limit);
   OMPRTL_NVPTX__kmpc_kernel_init,
-  /// \brief Call to void __kmpc_kernel_deinit();
-  OMPRTL_NVPTX__kmpc_kernel_deinit,
+};
+
+// NVPTX Address space
+enum AddressSpace {
+  AddressSpaceShared = 3,
 };
 } // namespace
 
@@ -66,15 +70,6 @@ static void getNVPTXCTABarrier(CodeGenFu
 /// Synchronize all GPU threads in a block.
 static void syncCTAThreads(CodeGenFunction &CGF) { getNVPTXCTABarrier(CGF); }
 
-/// Get the value of the thread_limit clause in the teams directive.
-/// The runtime encodes thread_limit in the launch parameter, always starting
-/// thread_limit+warpSize threads per team.
-static llvm::Value *getThreadLimit(CodeGenFunction &CGF) {
-  CGBuilderTy &Bld = CGF.Builder;
-  return Bld.CreateSub(getNVPTXNumThreads(CGF), getNVPTXWarpSize(CGF),
-   "thread_limit");
-}
-
 /// Get the thread id of the OMP master thread.
 /// The master thread id is the first thread (lane) of the last warp in the
 /// GPU block.  Warp size is assumed to be some power of 2.
@@ -108,105 +103,35 @@ void CGOpenMPRuntimeNVPTX::WorkerFunctio
   CGM.getTypes().GetFunctionType(*CGFI), 
llvm::GlobalValue::InternalLinkage,
   /* placeholder */ "_worker", &CGM.getModule());
   CGM.SetInternalFunctionAttributes(/*D=*/nullptr, WorkerFn, *CGFI);
+  WorkerFn->setLinkage(llvm::GlobalValue::InternalLinkage);
+  WorkerFn->addFnAttr(llvm::Attribute::NoInline);
 }
 
-void CGOpenMPRuntimeNVPTX::emitGenericKernel(const OMPExecutableDirective &D,
- StringRef ParentName,
- llvm::Function *&OutlinedFn,
- llvm::Constant *&OutlinedFnID,
- bool IsOffloadEntry,
- const RegionCodeGenTy &CodeGen) {
-  EntryFunctionState EST;
-  WorkerFunctionState WST(CGM);
-
-  // Emit target region as a standalone region.
-  class NVPTXPrePostActionTy : public PrePostActionTy {
-CGOpenMPRuntimeNVPTX &RT;
-CGOpenMPRuntimeNVPTX::EntryFunctionState &EST;
-CGOpenMPRuntimeNVPTX::WorkerFunctionState &WST;
-
-  public:
-NVPTXPrePostActionTy(CGOpenMPRuntimeNVPTX &RT,
- CGOpenMPRuntimeNVPTX::EntryFunctionState &EST,
- CGOpenMPRuntimeNVPTX::WorkerFunctionState &WST)
-: RT(RT), EST(EST), WST(WST) {}
-void Enter(CodeGenFunction &CGF) override {
-  RT.emitGenericEntryHeader(CGF, EST, WST);
-}
-void Exit(CodeGenFunction &CGF) override {
-  RT.emitGenericEntryFooter(CGF, EST);
-}
-  } Action(*this, EST, WST);
-  CodeGen.setAction(Action);
-  emitTargetOutlinedFunctionHelper(D, ParentName, OutlinedFn, OutlinedFnID,
-   IsOffloadEntry, CodeGen);
-
-  // Create the worker function
-  emitWorkerFunction(WST);
-
-  // Now change the name of the worker function to correspond to this target
-  // region's entry function.
-  WST.WorkerFn->setName(OutlinedFn->getName() + "_worker");
-}
-
-// Setup NVPTX threads for master-worker OpenMP scheme.
-void CGOpenMPRuntimeNVPTX::emitGenericEntryHeader(CodeGenFunction &CGF,
-  EntryFunctionState &EST,
-  WorkerFunctionState &WST) {
-  CGBuilderTy &Bld = CGF.Builder;
-
-  llvm::BasicBlock *WorkerBB = CGF.createBasicBlock(".worker");
-  llvm::BasicBlock *MasterCheckBB = CGF.createBasicBlock(".mastercheck");
-  llvm::BasicBlock *MasterBB = CGF.createBasicBlock(".master");
-  EST.ExitBB = CGF.createBasicBlock(".exit");
-
-  auto *IsWorker =
-  Bld.CreateICmpULT(getNVPTXThreadID(CGF), getThreadLimit(CGF));
-  Bld.CreateCondBr(IsWorker, WorkerBB, MasterCheckBB);
-
-  CGF.EmitBlock(WorkerBB);
-  CGF.EmitCallOrInvoke(WST.WorkerFn, llvm::None);
-  CGF.EmitBranch(EST.ExitBB);
-
-  CGF.EmitBlock(MasterCheckBB);
-  auto *IsMaster =
-  Bld.CreateICmpEQ(getNVPTXThreadID(C

r290990 - Support -fno-delayed-template-parsing in clang-cl.exe

2017-01-04 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Wed Jan  4 13:15:53 2017
New Revision: 290990

URL: http://llvm.org/viewvc/llvm-project?rev=290990&view=rev
Log:
Support -fno-delayed-template-parsing in clang-cl.exe

Summary:
This change adds support for the -fno-delayed-template-parsing option in
clang-cl.exe. This allows developers using clang-cl.exe to opt out of
emulation of MSVC's non-conformant template instantiation implementation
while continuing to use clang-cl.exe for its emulation of cl.exe
command-line options. The default behavior of clang-cl.exe
(-fdelayed-template-parsing) is unchanged.

The MSVC Standard Library implementation uses clang-cl.exe with this
switch in its tests to ensure that the library headers work on compilers
with the conformant two-phase-lookup behavior.

Reviewers: majnemer, cfe-commits, DaveBartolomeo

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

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

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=290990&r1=290989&r2=290990&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Jan  4 13:15:53 2017
@@ -882,7 +882,7 @@ def fms_compatibility_version
"(default))">;
 def fdelayed_template_parsing : Flag<["-"], "fdelayed-template-parsing">, 
Group,
   HelpText<"Parse templated function definitions at the end of the "
-   "translation unit">,  Flags<[CC1Option]>;
+   "translation unit">,  Flags<[CC1Option, CoreOption]>;
 def fms_memptr_rep_EQ : Joined<["-"], "fms-memptr-rep=">, Group, 
Flags<[CC1Option]>;
 def fmodules_cache_path : Joined<["-"], "fmodules-cache-path=">, 
Group,
   Flags<[DriverOption, CC1Option]>, MetaVarName<"">,
@@ -1031,7 +1031,8 @@ def fno_ms_extensions : Flag<["-"], "fno
   Flags<[CoreOption]>;
 def fno_ms_compatibility : Flag<["-"], "fno-ms-compatibility">, Group,
   Flags<[CoreOption]>;
-def fno_delayed_template_parsing : Flag<["-"], 
"fno-delayed-template-parsing">, Group;
+def fno_delayed_template_parsing : Flag<["-"], 
"fno-delayed-template-parsing">, Group,
+  Flags<[DriverOption, CoreOption]>;
 def fno_objc_exceptions: Flag<["-"], "fno-objc-exceptions">, Group;
 def fno_objc_legacy_dispatch : Flag<["-"], "fno-objc-legacy-dispatch">, 
Group;
 def fno_objc_weak : Flag<["-"], "fno-objc-weak">, Group, 
Flags<[CC1Option]>;

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=290990&r1=290989&r2=290990&view=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Wed Jan  4 13:15:53 2017
@@ -295,6 +295,14 @@
 // RUN: %clang_cl -c -fno-strict-aliasing -### -- %s 2>&1 | FileCheck 
-check-prefix=NOSTRICT %s
 // NOSTRICT: "-relaxed-aliasing"
 
+// We recognize -f[no-]delayed-template-parsing.
+// RUN: %clang_cl -c -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDDEFAULT 
%s
+// DELAYEDDEFAULT: "-fdelayed-template-parsing"
+// RUN: %clang_cl -c -fdelayed-template-parsing -### -- %s 2>&1 | FileCheck 
-check-prefix=DELAYEDON %s
+// DELAYEDON: "-fdelayed-template-parsing"
+// RUN: %clang_cl -c -fno-delayed-template-parsing -### -- %s 2>&1 | FileCheck 
-check-prefix=DELAYEDOFF %s
+// DELAYEDOFF-NOT: "-fdelayed-template-parsing"
+
 // For some warning ids, we can map from MSVC warning to Clang warning.
 // RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -### -- %s 2>&1 | FileCheck 
-check-prefix=Wno %s
 // Wno: "-cc1"


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


[PATCH] D22275: Support -fno-delayed-template-parsing in clang-cl.exe

2017-01-04 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290990: Support -fno-delayed-template-parsing in 
clang-cl.exe (authored by rnk).

Changed prior to commit:
  https://reviews.llvm.org/D22275?vs=63713&id=83091#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22275

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/test/Driver/cl-options.c


Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -882,7 +882,7 @@
"(default))">;
 def fdelayed_template_parsing : Flag<["-"], "fdelayed-template-parsing">, 
Group,
   HelpText<"Parse templated function definitions at the end of the "
-   "translation unit">,  Flags<[CC1Option]>;
+   "translation unit">,  Flags<[CC1Option, CoreOption]>;
 def fms_memptr_rep_EQ : Joined<["-"], "fms-memptr-rep=">, Group, 
Flags<[CC1Option]>;
 def fmodules_cache_path : Joined<["-"], "fmodules-cache-path=">, 
Group,
   Flags<[DriverOption, CC1Option]>, MetaVarName<"">,
@@ -1031,7 +1031,8 @@
   Flags<[CoreOption]>;
 def fno_ms_compatibility : Flag<["-"], "fno-ms-compatibility">, Group,
   Flags<[CoreOption]>;
-def fno_delayed_template_parsing : Flag<["-"], 
"fno-delayed-template-parsing">, Group;
+def fno_delayed_template_parsing : Flag<["-"], 
"fno-delayed-template-parsing">, Group,
+  Flags<[DriverOption, CoreOption]>;
 def fno_objc_exceptions: Flag<["-"], "fno-objc-exceptions">, Group;
 def fno_objc_legacy_dispatch : Flag<["-"], "fno-objc-legacy-dispatch">, 
Group;
 def fno_objc_weak : Flag<["-"], "fno-objc-weak">, Group, 
Flags<[CC1Option]>;
Index: cfe/trunk/test/Driver/cl-options.c
===
--- cfe/trunk/test/Driver/cl-options.c
+++ cfe/trunk/test/Driver/cl-options.c
@@ -295,6 +295,14 @@
 // RUN: %clang_cl -c -fno-strict-aliasing -### -- %s 2>&1 | FileCheck 
-check-prefix=NOSTRICT %s
 // NOSTRICT: "-relaxed-aliasing"
 
+// We recognize -f[no-]delayed-template-parsing.
+// RUN: %clang_cl -c -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDDEFAULT 
%s
+// DELAYEDDEFAULT: "-fdelayed-template-parsing"
+// RUN: %clang_cl -c -fdelayed-template-parsing -### -- %s 2>&1 | FileCheck 
-check-prefix=DELAYEDON %s
+// DELAYEDON: "-fdelayed-template-parsing"
+// RUN: %clang_cl -c -fno-delayed-template-parsing -### -- %s 2>&1 | FileCheck 
-check-prefix=DELAYEDOFF %s
+// DELAYEDOFF-NOT: "-fdelayed-template-parsing"
+
 // For some warning ids, we can map from MSVC warning to Clang warning.
 // RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -### -- %s 2>&1 | FileCheck 
-check-prefix=Wno %s
 // Wno: "-cc1"


Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -882,7 +882,7 @@
"(default))">;
 def fdelayed_template_parsing : Flag<["-"], "fdelayed-template-parsing">, Group,
   HelpText<"Parse templated function definitions at the end of the "
-   "translation unit">,  Flags<[CC1Option]>;
+   "translation unit">,  Flags<[CC1Option, CoreOption]>;
 def fms_memptr_rep_EQ : Joined<["-"], "fms-memptr-rep=">, Group, Flags<[CC1Option]>;
 def fmodules_cache_path : Joined<["-"], "fmodules-cache-path=">, Group,
   Flags<[DriverOption, CC1Option]>, MetaVarName<"">,
@@ -1031,7 +1031,8 @@
   Flags<[CoreOption]>;
 def fno_ms_compatibility : Flag<["-"], "fno-ms-compatibility">, Group,
   Flags<[CoreOption]>;
-def fno_delayed_template_parsing : Flag<["-"], "fno-delayed-template-parsing">, Group;
+def fno_delayed_template_parsing : Flag<["-"], "fno-delayed-template-parsing">, Group,
+  Flags<[DriverOption, CoreOption]>;
 def fno_objc_exceptions: Flag<["-"], "fno-objc-exceptions">, Group;
 def fno_objc_legacy_dispatch : Flag<["-"], "fno-objc-legacy-dispatch">, Group;
 def fno_objc_weak : Flag<["-"], "fno-objc-weak">, Group, Flags<[CC1Option]>;
Index: cfe/trunk/test/Driver/cl-options.c
===
--- cfe/trunk/test/Driver/cl-options.c
+++ cfe/trunk/test/Driver/cl-options.c
@@ -295,6 +295,14 @@
 // RUN: %clang_cl -c -fno-strict-aliasing -### -- %s 2>&1 | FileCheck -check-prefix=NOSTRICT %s
 // NOSTRICT: "-relaxed-aliasing"
 
+// We recognize -f[no-]delayed-template-parsing.
+// RUN: %clang_cl -c -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDDEFAULT %s
+// DELAYEDDEFAULT: "-fdelayed-template-parsing"
+// RUN: %clang_cl -c -fdelayed-template-parsing -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDON %s
+// DELAYEDON: "-fdelayed-template-parsing"
+// RUN: %clang_cl -c -fno-delayed-template-parsing -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDOFF %s
+// DELAYEDOFF-NOT: "-fdelayed-template-parsing"
+
 // For some warning ids, we can map from MSVC warning to Clang warning.
 //

r290991 - [Sema] Replace remove_if+erase with erase_if. NFC.

2017-01-04 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Wed Jan  4 13:16:29 2017
New Revision: 290991

URL: http://llvm.org/viewvc/llvm-project?rev=290991&view=rev
Log:
[Sema] Replace remove_if+erase with erase_if. NFC.

Modified:
cfe/trunk/lib/Sema/SemaCUDA.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/SemaCUDA.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCUDA.cpp?rev=290991&r1=290990&r2=290991&view=diff
==
--- cfe/trunk/lib/Sema/SemaCUDA.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCUDA.cpp Wed Jan  4 13:16:29 2017
@@ -228,10 +228,8 @@ void Sema::EraseUnwantedCUDAMatches(
   [&](const Pair &M1, const Pair &M2) { return GetCFP(M1) < GetCFP(M2); 
}));
 
   // Erase all functions with lower priority.
-  Matches.erase(
-  llvm::remove_if(
-  Matches, [&](const Pair &Match) { return GetCFP(Match) < BestCFP; }),
-  Matches.end());
+  llvm::erase_if(Matches,
+ [&](const Pair &Match) { return GetCFP(Match) < BestCFP; });
 }
 
 /// When an implicitly-declared special member has to invoke more than one

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=290991&r1=290990&r2=290991&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Jan  4 13:16:29 2017
@@ -8958,9 +8958,7 @@ OverloadCandidateSet::BestViableFunction
S.IdentifyCUDAPreference(Caller, Cand->Function) ==
Sema::CFP_WrongSide;
   };
-  Candidates.erase(std::remove_if(Candidates.begin(), Candidates.end(),
-  IsWrongSideCandidate),
-   Candidates.end());
+  llvm::erase_if(Candidates, IsWrongSideCandidate);
 }
   }
 


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


[PATCH] D27529: Correct Vectorcall Register passing and HVA Behavior

2017-01-04 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked 3 inline comments as done.
erichkeane added a comment.

patch incoming




Comment at: include/clang/CodeGen/CGFunctionInfo.h:139
+AI.setInReg(true);
+AI.setCanBeFlattened(false);
+return AI;

rnk wrote:
> In the long run, I think ABIArgInfo::Direct is too overloaded and needs to be 
> split. The implementation of a single direct argument in EmitFunctionPrologue 
> is *174* lines. It would be much cleaner to make some new ABIArgInfo types 
> instead of having these "can be flattened" flags and things.
I think you're right, this was my first run-in with what "direct" means and it 
took a lot to figure out what it even MEANS.  I definitely think that it is 
worth a refactoring in the future.  I notice that a lot of the ABIArgInfo 
/ABIInfo related things could strongly benefit from a refactoring as well.



Comment at: lib/CodeGen/TargetInfo.cpp:1507
-   State.CC == llvm::CallingConv::X86_RegCall) &&
-  isHomogeneousAggregate(Ty, Base, NumElts)) {
-if (State.FreeSSERegs >= NumElts) {

rnk wrote:
> You don't seem to do anything in this if block if !IsHva, so maybe fold it 
> back into the initial check like it was, and then break out the case for 
> regcall and vectorcall separately.
I did this same thing in 2 places, so I suspect I had SOME /*good*/ reason for 
splitting it out like this, but I cannot for the life of me remember it.  
Changed.


https://reviews.llvm.org/D27529



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


[PATCH] D27529: Correct Vectorcall Register passing and HVA Behavior

2017-01-04 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 83092.
erichkeane marked an inline comment as done.
erichkeane added a comment.

Reid's comments


https://reviews.llvm.org/D27529

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/vectorcall.c
  test/CodeGenCXX/homogeneous-aggregates.cpp

Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -857,6 +857,14 @@
   return NumMembers <= 4;
 }
 
+/// Returns a Homogeneous Vector Aggregate ABIArgInfo, used in X86.
+static ABIArgInfo getDirectX86Hva(llvm::Type* T = nullptr) {
+  auto AI = ABIArgInfo::getDirect(T);
+  AI.setInReg(true);
+  AI.setCanBeFlattened(false);
+  return AI;
+}
+
 //===--===//
 // X86-32 ABI Implementation
 //===--===//
@@ -870,6 +878,11 @@
   unsigned FreeSSERegs;
 };
 
+enum {
+  // Vectorcall only allows the first 6 parameters to be passed in registers.
+  VectorcallMaxParamNumAsReg = 6
+};
+
 /// X86_32ABIInfo - The X86-32 ABI information.
 class X86_32ABIInfo : public SwiftABIInfo {
   enum Class {
@@ -915,6 +928,8 @@
   Class classify(QualType Ty) const;
   ABIArgInfo classifyReturnType(QualType RetTy, CCState &State) const;
   ABIArgInfo classifyArgumentType(QualType RetTy, CCState &State) const;
+  ABIArgInfo reclassifyHvaArgType(QualType RetTy, CCState &State, 
+  const ABIArgInfo& current) const;
   /// \brief Updates the number of available free registers, returns 
   /// true if any registers were allocated.
   bool updateFreeRegs(QualType Ty, CCState &State) const;
@@ -1480,6 +1495,27 @@
   return true;
 }
 
+ABIArgInfo
+X86_32ABIInfo::reclassifyHvaArgType(QualType Ty, CCState &State,
+const ABIArgInfo ¤t) const {
+  // Assumes vectorCall calling convention.
+  const Type *Base = nullptr;
+  uint64_t NumElts = 0;
+
+  if (!Ty->isBuiltinType() && !Ty->isVectorType() &&
+  isHomogeneousAggregate(Ty, Base, NumElts)) {
+if (State.FreeSSERegs >= NumElts) {
+  // HVA types get passed directly in registers if there is room.
+  State.FreeSSERegs -= NumElts;
+  return getDirectX86Hva();
+}
+// If there's no room, the HVA gets passed as normal indirect
+// structure.
+return getIndirectResult(Ty, /*ByVal=*/false, State);
+  } 
+  return current;
+}
+
 ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty,
CCState &State) const {
   // FIXME: Set alignment on indirect arguments.
@@ -1499,19 +1535,34 @@
   }
 
   // vectorcall adds the concept of a homogenous vector aggregate, similar
-  // to other targets.
+  // to other targets, regcall uses some of the HVA rules.
   const Type *Base = nullptr;
   uint64_t NumElts = 0;
   if ((State.CC == llvm::CallingConv::X86_VectorCall ||
State.CC == llvm::CallingConv::X86_RegCall) &&
   isHomogeneousAggregate(Ty, Base, NumElts)) {
-if (State.FreeSSERegs >= NumElts) {
-  State.FreeSSERegs -= NumElts;
-  if (Ty->isBuiltinType() || Ty->isVectorType())
+
+if (State.CC == llvm::CallingConv::X86_RegCall) {
+  if (State.FreeSSERegs >= NumElts) {
+State.FreeSSERegs -= NumElts;
+if (Ty->isBuiltinType() || Ty->isVectorType())
+  return ABIArgInfo::getDirect();
+return ABIArgInfo::getExpand();
+
+  }
+  return getIndirectResult(Ty, /*ByVal=*/false, State);
+} else if (State.CC == llvm::CallingConv::X86_VectorCall) {
+  if (State.FreeSSERegs >= NumElts && (Ty->isBuiltinType() || Ty->isVectorType())) {
+// Actual floating-point types get registers first time through if
+// there is registers available
+State.FreeSSERegs -= NumElts;
 return ABIArgInfo::getDirect();
-  return ABIArgInfo::getExpand();
+  }  else if (!Ty->isBuiltinType() && !Ty->isVectorType()) {
+// HVA Types only get registers after everything else has been
+// set, so it gets set as indirect for now.
+return ABIArgInfo::getIndirect(getContext().getTypeAlignInChars(Ty));
+  }
 }
-return getIndirectResult(Ty, /*ByVal=*/false, State);
   }
 
   if (isAggregateTypeForABI(Ty)) {
@@ -1624,9 +1675,39 @@
 ++State.FreeRegs;
 
   bool UsedInAlloca = false;
-  for (auto &I : FI.arguments()) {
-I.info = classifyArgumentType(I.type, State);
-UsedInAlloca |= (I.info.getKind() == ABIArgInfo::InAlloca);
+  if (State.CC == llvm::CallingConv::X86_VectorCall) {
+// Vectorcall only allows the first 6 parameters to be passed in registers,
+// and homogeneous vector aggregates are only put into registers as a second
+// priority.
+unsigned Count = 0;
+CCState ZeroState = State;
+ZeroState.FreeRegs = ZeroState.FreeSSERegs = 0;
+// HVAs must be done as a second priority for registers, s

[PATCH] D27529: Correct Vectorcall Register passing and HVA Behavior

2017-01-04 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Last thing, I promise.




Comment at: lib/CodeGen/TargetInfo.cpp:1678
   bool UsedInAlloca = false;
-  for (auto &I : FI.arguments()) {
-I.info = classifyArgumentType(I.type, State);
-UsedInAlloca |= (I.info.getKind() == ABIArgInfo::InAlloca);
+  if (State.CC == llvm::CallingConv::X86_VectorCall) {
+// Vectorcall only allows the first 6 parameters to be passed in registers,

Can we out the body of this if into a separate helper? The much more common 
case is to do one pass over the arguments, and this two-pass block obscures 
that.



Comment at: lib/CodeGen/TargetInfo.cpp:3882
+  if (IsVectorCall) {
+unsigned Count = 0;
+for (auto &I : FI.arguments()) {

Ditto, can we extract the two-pass code into a helper?


https://reviews.llvm.org/D27529



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


[PATCH] D27529: Correct Vectorcall Register passing and HVA Behavior

2017-01-04 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked 2 inline comments as done.
erichkeane added a comment.

Good idea, building now!


https://reviews.llvm.org/D27529



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


[PATCH] D28226: threading_support: introduce __libcpp_recursive_mutex_t

2017-01-04 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

Im not tied to this approach.  I really want to get @mclow.lists or @EricWF to 
weigh in as to which approach they prefer (new interfaces or the wrapper, or 
even a new approach).


Repository:
  rL LLVM

https://reviews.llvm.org/D28226



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


r290996 - Factor out duplicated code and simplify.

2017-01-04 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Jan  4 13:47:19 2017
New Revision: 290996

URL: http://llvm.org/viewvc/llvm-project?rev=290996&view=rev
Log:
Factor out duplicated code and simplify.

No functionality change intended.

Modified:
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=290996&r1=290995&r2=290996&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Wed Jan  4 13:47:19 2017
@@ -3203,67 +3203,59 @@ static Sema::TemplateDeductionResult Ded
 
 /// \brief Attempt template argument deduction from an initializer list
 ///deemed to be an argument in a function call.
-static bool
+static Sema::TemplateDeductionResult
 DeduceFromInitializerList(Sema &S, TemplateParameterList *TemplateParams,
   QualType AdjustedParamType, InitListExpr *ILE,
   TemplateDeductionInfo &Info,
   SmallVectorImpl &Deduced,
-  unsigned TDF, Sema::TemplateDeductionResult &Result) 
{
-
-  // [temp.deduct.call] p1 (post CWG-1591)
-  // If removing references and cv-qualifiers from P gives
-  // std::initializer_list or P0[N] for some P0 and N and the argument is a
-  // non-empty initializer list (8.5.4), then deduction is performed instead 
for
-  // each element of the initializer list, taking P0 as a function template
-  // parameter type and the initializer element as its argument, and in the
-  // P0[N] case, if N is a non-type template parameter, N is deduced from the
-  // length of the initializer list. Otherwise, an initializer list argument
-  // causes the parameter to be considered a non-deduced context
-
-  const bool IsConstSizedArray = AdjustedParamType->isConstantArrayType();
-
-  const bool IsDependentSizedArray =
-  !IsConstSizedArray && AdjustedParamType->isDependentSizedArrayType();
-
-  QualType ElTy;  // The element type of the std::initializer_list or the 
array.
-
-  const bool IsSTDList = !IsConstSizedArray && !IsDependentSizedArray &&
- S.isStdInitializerList(AdjustedParamType, &ElTy);
-
-  if (!IsConstSizedArray && !IsDependentSizedArray && !IsSTDList)
-return false;
-
-  Result = Sema::TDK_Success;
-  // If we are not deducing against the 'T' in a std::initializer_list then
-  // deduce against the 'T' in T[N].
-  if (ElTy.isNull()) {
-assert(!IsSTDList);
-ElTy = S.Context.getAsArrayType(AdjustedParamType)->getElementType();
+  unsigned TDF) {
+  // C++ [temp.deduct.call]p1: (CWG 1591)
+  //   If removing references and cv-qualifiers from P gives
+  //   std::initializer_list or P0[N] for some P0 and N and the argument is
+  //   a non-empty initializer list, then deduction is performed instead for
+  //   each element of the initializer list, taking P0 as a function template
+  //   parameter type and the initializer element as its argument
+  //
+  // FIXME: Remove references and cv-qualifiers here? Consider
+  //  std::initializer_list&&>
+  QualType ElTy;
+  auto *ArrTy = S.Context.getAsArrayType(AdjustedParamType);
+  if (ArrTy)
+ElTy = ArrTy->getElementType();
+  else if (!S.isStdInitializerList(AdjustedParamType, &ElTy)) {
+//   Otherwise, an initializer list argument causes the parameter to be
+//   considered a non-deduced context
+return Sema::TDK_Success;
   }
+
   // Deduction only needs to be done for dependent types.
   if (ElTy->isDependentType()) {
 for (Expr *E : ILE->inits()) {
-  if ((Result = DeduceTemplateArgumentByListElement(S, TemplateParams, 
ElTy,
-E, Info, Deduced, 
TDF)))
-return true;
+  if (auto Result = DeduceTemplateArgumentByListElement(
+  S, TemplateParams, ElTy, E, Info, Deduced, TDF))
+return Result;
 }
   }
-  if (IsDependentSizedArray) {
-const DependentSizedArrayType *ArrTy =
-S.Context.getAsDependentSizedArrayType(AdjustedParamType);
+
+  //   in the P0[N] case, if N is a non-type template parameter, N is deduced
+  //   from the length of the initializer list.
+  // FIXME: We're not supposed to get here if N would be deduced as 0.
+  if (auto *DependentArrTy = dyn_cast_or_null(ArrTy)) 
{
 // Determine the array bound is something we can deduce.
 if (NonTypeTemplateParmDecl *NTTP =
-getDeducedParameterFromExpr(Info, ArrTy->getSizeExpr())) {
+getDeducedParameterFromExpr(Info, DependentArrTy->getSizeExpr())) {
   // We can perform template argument deduction for the given non-type
   // template parameter.
   llvm::APInt Size(S.Context.getIntWidth(NTTP->getType()),
  

r290997 - Revert accidentally-committed file.

2017-01-04 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Jan  4 13:48:07 2017
New Revision: 290997

URL: http://llvm.org/viewvc/llvm-project?rev=290997&view=rev
Log:
Revert accidentally-committed file.

Modified:
cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp

Modified: cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp?rev=290997&r1=290996&r2=290997&view=diff
==
--- cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp Wed Jan  4 
13:48:07 2017
@@ -104,7 +104,7 @@ template 
 T deduce_ref(const std::initializer_list&); // expected-note {{conflicting 
types for parameter 'T' ('int' vs. 'double')}}
 
 template struct pair { pair(...); };
-template void deduce_pairs(std::initializer_list>); // expected-note {{something}}
+template void deduce_pairs(std::initializer_list>);
 struct WithIntType { typedef int type; };
 
 template void deduce_after_init_list_in_pack(void (*)(T...), 
T...); // expected-note {{ vs. <(no value), double>}}
@@ -123,7 +123,7 @@ void argument_deduction() {
   pair pi;
   pair pf;
   deduce_pairs({pi, pi, pi}); // ok
-  deduce_pairs({pi, pf, pi}); // expected-error {{no matching function}}
+  deduce_pairs({pi, pf, pi}); // FIXME: This should be rejected, as we fail to 
produce a type that exactly matches the argument type.
 
   deduce_after_init_list_in_pack((void(*)(int,int))0, {}, 0);
   deduce_after_init_list_in_pack((void(*)(int,int))0, {}, 0.0); // 
expected-error {{no matching function}}


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


[PATCH] D28304: [compiler-rt] [cmake] Disable appending -msse* flags implicitly

2017-01-04 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D28304#635620, @cryptoad wrote:

> Hey Michal,
>  If I understand correctly, my next move is to move the CRC32 code into it's 
> own file an only enable SSE 4.2 for this file?


Yes, like that. Have a SSE4.2 CRC32 function in a separate file, and call it 
only when SSE4.2 is determined to be supported. Note that for this you'd need 
to refactor things a bit since it seems that the hw CRC32 code is used commonly 
be SSE4.2 and ARM.

Furthermore, you might want to do the runtime check only when SSE4.2 was not 
enabled at build time, i.e. skip it if user specified -msse4.2 or -march= 
option enabling it explicitly. I guess you could use the `#ifdef` for that (on 
a file where -msse4.2 is not forced).

> Shouldn't COMPILER_RT_HAS_MSSE4_2_FLAG be kept for that purpose or is there 
> an alternative way to do it?

I don't really see a point in keeping it if you can equally easily re-add it in 
a later patch.


https://reviews.llvm.org/D28304



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


[PATCH] D27251: [PPC] some bugs mainly about sign problem fixed in altivec.h

2017-01-04 Thread Kit Barton via Phabricator via cfe-commits
kbarton added a comment.

Sorry, I don't have time to go through the entire patch in detail right now. 
But I did notice several places where the lines are too long, which need to get 
fixed.




Comment at: lib/Headers/altivec.h:14206
   vector signed long long __b) {
-  return __builtin_altivec_vcmpgtud_p(__CR6_LT, (vector unsigned long long)__a,
-  (vector unsigned long long)__b);
+  return __builtin_altivec_vcmpgtsd_p(__CR6_LT, (vector signed long long)__a, 
__b);
 }

line too long



Comment at: lib/Headers/altivec.h:14381
   vector signed long long __b) {
-  return __builtin_altivec_vcmpgtud_p(__CR6_EQ, (vector unsigned long long)__a,
-  (vector unsigned long long)__b);
+  return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, (vector signed long long)__a, 
__b);
 }

line too long



Comment at: lib/Headers/altivec.h:14549
   vector signed long long __b) {
-  return __builtin_altivec_vcmpgtud_p(__CR6_LT, (vector unsigned long long)__b,
-  (vector unsigned long long)__a);
+  return __builtin_altivec_vcmpgtsd_p(__CR6_LT, __b, (vector signed long 
long)__a);
 }

line too long


https://reviews.llvm.org/D27251



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


  1   2   3   >