[PATCH] D25595: [libcxx] Support std::regex_constants::match_not_null

2016-10-14 Thread Tim Shen via cfe-commits
timshen created this revision.
timshen added reviewers: mclow.lists, EricWF.
timshen added a subscriber: cfe-commits.

Fixes PR21597.


https://reviews.llvm.org/D25595

Files:
  libcxx/include/regex
  libcxx/test/std/re/re.alg/re.alg.search/pr21597.pass.cpp


Index: libcxx/test/std/re/re.alg/re.alg.search/pr21597.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/re/re.alg/re.alg.search/pr21597.pass.cpp
@@ -0,0 +1,39 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template 
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+//  match_results& m,
+//  const basic_regex& e,
+//  regex_constants::match_flag_type flags = 
regex_constants::match_default);
+
+#include "test_macros.h"
+#include 
+#include 
+
+int main()
+{
+  // When match_not_null is on, the regex engine should reject empty matches 
and
+  // move on to try other solutions.
+  std::cmatch m;
+  assert(!std::regex_search("a", m, std::regex("b*"),
+std::regex_constants::match_not_null));
+  assert(std::regex_search("aa", m, std::regex("a*?"),
+   std::regex_constants::match_not_null));
+  assert(m[0].length() == 1);
+  assert(!std::regex_search("a", m, std::regex("b*", std::regex::extended),
+std::regex_constants::match_not_null));
+  assert(!std::regex_search(
+  "a", m,
+  std::regex("b*", std::regex::extended | std::regex_constants::nosubs),
+  std::regex_constants::match_not_null));
+}
Index: libcxx/include/regex
===
--- libcxx/include/regex
+++ libcxx/include/regex
@@ -,6 +,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 __m.__matches_[0].first = __first;
 __m.__matches_[0].second = _VSTD::next(__first, __s.__current_ 
- __first);
 __m.__matches_[0].matched = true;
@@ -5618,6 +5624,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
 __highest_j = __s.__current_ - __s.__first_;
 __matched = true;
@@ -5703,6 +5715,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
 {
 __highest_j = __s.__current_ - __s.__first_;


Index: libcxx/test/std/re/re.alg/re.alg.search/pr21597.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/re/re.alg/re.alg.search/pr21597.pass.cpp
@@ -0,0 +1,39 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template 
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+//  match_results& m,
+//  const basic_regex& e,
+//  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include "test_macros.h"
+#include 
+#include 
+
+int main()
+{
+  // When match_not_null is on, the regex engine should reject empty matches and
+  // move on to try other solutions.
+  std::cmatch m;
+  assert(!std::regex_search("a", m, std::regex("b*"),
+std::regex_constants::match_not_null));
+  assert(std::regex_search("aa", m, std::regex("a*?"),
+   std::regex_constants::match_not_null));
+  assert(m[0].length() == 1);
+  assert(!std::re

[libcxx] r284209 - Add void_t and invoke feature test macros

2016-10-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Oct 14 02:19:52 2016
New Revision: 284209

URL: http://llvm.org/viewvc/llvm-project?rev=284209&view=rev
Log:
Add void_t and invoke feature test macros

Added:

libcxx/trunk/test/std/utilities/function.objects/func.invoke/invoke_feature_test_macro.pass.cpp

libcxx/trunk/test/std/utilities/meta/meta.unary.prop.query/void_t_feature_test_macro.pass.cpp
Modified:
libcxx/trunk/include/functional
libcxx/trunk/include/type_traits

Modified: libcxx/trunk/include/functional
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/functional?rev=284209&r1=284208&r2=284209&view=diff
==
--- libcxx/trunk/include/functional (original)
+++ libcxx/trunk/include/functional Fri Oct 14 02:19:52 2016
@@ -2635,6 +2635,8 @@ struct _LIBCPP_TYPE_VIS_ONLY hash : publ
 
 #if _LIBCPP_STD_VER > 14
 
+#define __cpp_lib_invoke 201411
+
 template 
 result_of_t<_Fn&&(_Args&&...)>
 invoke(_Fn&& __f, _Args&&... __args)

Modified: libcxx/trunk/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=284209&r1=284208&r2=284209&view=diff
==
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Fri Oct 14 02:19:52 2016
@@ -4599,6 +4599,8 @@ struct __has_operator_addressof
 #endif  // _LIBCPP_CXX03_LANG
 
 #if _LIBCPP_STD_VER > 14
+
+#define __cpp_lib_void_t 201411
 template  using void_t = void;
 
 # ifndef _LIBCPP_HAS_NO_VARIADICS

Added: 
libcxx/trunk/test/std/utilities/function.objects/func.invoke/invoke_feature_test_macro.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.invoke/invoke_feature_test_macro.pass.cpp?rev=284209&view=auto
==
--- 
libcxx/trunk/test/std/utilities/function.objects/func.invoke/invoke_feature_test_macro.pass.cpp
 (added)
+++ 
libcxx/trunk/test/std/utilities/function.objects/func.invoke/invoke_feature_test_macro.pass.cpp
 Fri Oct 14 02:19:52 2016
@@ -0,0 +1,39 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template 
+// result_of_t invoke(F&&, Args&&...);
+
+#include 
+#include 
+
+#include "test_macros.h"
+
+#if TEST_STD_VER <= 14
+# ifdef __cpp_lib_invoke
+#   error Feature test macro should be defined
+# endif
+#else
+# ifndef __cpp_lib_invoke
+#   error Feature test macro not defined
+# endif
+# if __cpp_lib_invoke != 201411
+#   error __cpp_lib_invoke has the wrong value
+# endif
+#endif
+
+int foo(int) { return 42; }
+
+int main() {
+#if defined(__cpp_lib_invoke)
+  assert(std::invoke(foo, 101) == 42);
+#endif
+}
\ No newline at end of file

Added: 
libcxx/trunk/test/std/utilities/meta/meta.unary.prop.query/void_t_feature_test_macro.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary.prop.query/void_t_feature_test_macro.pass.cpp?rev=284209&view=auto
==
--- 
libcxx/trunk/test/std/utilities/meta/meta.unary.prop.query/void_t_feature_test_macro.pass.cpp
 (added)
+++ 
libcxx/trunk/test/std/utilities/meta/meta.unary.prop.query/void_t_feature_test_macro.pass.cpp
 Fri Oct 14 02:19:52 2016
@@ -0,0 +1,36 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// type_traits
+
+// void_t
+
+#include 
+
+#include "test_macros.h"
+
+#if TEST_STD_VER <= 14
+# ifdef __cpp_lib_void_t
+#   error Feature test macro should not be defined!
+# endif
+#else
+# ifndef __cpp_lib_void_t
+#   error Feature test macro is not defined
+# endif
+# if __cpp_lib_void_t != 201411
+#   error Feature test macro has the wrong value
+# endif
+#endif
+
+int main()
+{
+#if defined(__cpp_lib_void_t)
+  static_assert(std::is_same_v, void>, "");
+#endif
+}


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


[PATCH] D25576: Add 64-bit MS _Interlocked functions as builtins again

2016-10-14 Thread Martin Storsjö via cfe-commits
mstorsjo added a comment.

> (should they be also on AArch64? I had problems with testing it for AArch64, 
> so I left it)

Technically, I think they should be on AArch64 as well. But clang/LLVM probably 
doesn't support AArch64/Windows yet (I guess?), so testing it probably is 
impossible. When/if support later gets added for that, it's easy to complete 
these.

AArch64/Windows in general isn't available yet; the Windows 10 SDK contains 
some arm64 tools, and the Windows 10 SDK and MSVC 2015 headers have got ifdefs 
using _M_ARM64, but other than that, there's no public version of Visual Studio 
even having a compiler for it. So until then, and when someone tries to get 
clang/LLVM to support it, it's probably ok to just ignore it.


https://reviews.llvm.org/D25576



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


[libcxx] r284210 - XFAIL aligned allocation test failures with UBSAN

2016-10-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Oct 14 02:49:15 2016
New Revision: 284210

URL: http://llvm.org/viewvc/llvm-project?rev=284210&view=rev
Log:
XFAIL  aligned allocation test failures with UBSAN

Modified:

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

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

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

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

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp?rev=284210&r1=284209&r2=284210&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
 Fri Oct 14 02:49:15 2016
@@ -17,6 +17,9 @@
 // None of the current GCC compilers support this.
 // XFAIL: gcc-4, gcc-5, gcc-6
 
+// UBSAN replaces certain new/delete functions which makes this test fail
+// XFAIL: ubsan
+
 #include 
 #include 
 #include 
@@ -58,24 +61,24 @@ struct alignas(std::max_align_t) B {};
 int main()
 {
 {
-B *x = new B;
+B *x = new B[2];
 assert(0 == unsized_delete_called);
 assert(0 == unsized_delete_nothrow_called);
 assert(0 == aligned_delete_called);
 
-delete x;
+delete [] x;
 assert(1 == unsized_delete_called);
 assert(0 == unsized_delete_nothrow_called);
 assert(0 == aligned_delete_called);
 }
 reset();
 {
-A *x = new A;
+A *x = new A[2];
 assert(0 == unsized_delete_called);
 assert(0 == unsized_delete_nothrow_called);
 assert(0 == aligned_delete_called);
 
-delete x;
+delete [] x;
 assert(0 == unsized_delete_called);
 assert(0 == unsized_delete_nothrow_called);
 assert(1 == aligned_delete_called);

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp?rev=284210&r1=284209&r2=284210&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp
 Fri Oct 14 02:49:15 2016
@@ -13,9 +13,6 @@
 
 // UNSUPPORTED: sanitizer-new-delete
 
-// TODO Investigate why UBSAN prevents nothrow new from calling our 
replacement.
-// XFAIL: ubsan
-
 #include 
 #include 
 #include 

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp?rev=284210&r1=284209&r2=284210&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
 Fri Oct 14 02:49:15 2016
@@ -17,6 +17,9 @@
 // None of the current GCC compilers support this.
 // XFAIL: gcc-4, gcc-5, gcc-6
 
+// UBSAN replaces certain new/delete functions which makes this test fail
+// XFAIL: ubsan
+
 #include 
 #include 
 #include 

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp?rev=284210&r1=284209&r2=284210&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/ne

[PATCH] D25586: [clang-move] Use cl::list and cl::CommaSeparated for the list of names.

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

LGTM. Thanks.


Repository:
  rL LLVM

https://reviews.llvm.org/D25586



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


[clang-tools-extra] r284212 - [clang-tidy] Fix readability-braces-around-statements false positive

2016-10-14 Thread Marek Kurdej via cfe-commits
Author: mkurdej
Date: Fri Oct 14 03:10:08 2016
New Revision: 284212

URL: http://llvm.org/viewvc/llvm-project?rev=284212&view=rev
Log:
[clang-tidy] Fix readability-braces-around-statements false positive

Summary:
This fixes a false-positive e.g. when string literals are returned from if 
statement.

This patch includes as well a small fix to includes and renames of the test 
suite that collided with the name of the check.

Reviewers: alexfh, hokein

Subscribers: hokein

Tags: #clang-tools-extra

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

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

clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp
clang-tools-extra/trunk/unittests/clang-tidy/ReadabilityModuleTest.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp?rev=284212&r1=284211&r2=284212&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp Fri Oct 14 
03:10:08 2016
@@ -8,7 +8,8 @@
 
//===--===//
 
 #include "UseUsingCheck.h"
-#include "../utils/LexerUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
 

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp?rev=284212&r1=284211&r2=284212&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp 
Fri Oct 14 03:10:08 2016
@@ -61,7 +61,7 @@ SourceLocation findEndLocation(SourceLoc
   bool SkipEndWhitespaceAndComments = true;
   tok::TokenKind TokKind = getTokenKind(Loc, SM, Context);
   if (TokKind == tok::NUM_TOKENS || TokKind == tok::semi ||
-  TokKind == tok::r_brace) {
+  TokKind == tok::r_brace || isStringLiteral(TokKind)) {
 // If we are at ";" or "}", we found the last token. We could use as well
 // `if (isa(S))`, but it wouldn't work for nested statements.
 SkipEndWhitespaceAndComments = false;

Modified: clang-tools-extra/trunk/unittests/clang-tidy/ReadabilityModuleTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-tidy/ReadabilityModuleTest.cpp?rev=284212&r1=284211&r2=284212&view=diff
==
--- clang-tools-extra/trunk/unittests/clang-tidy/ReadabilityModuleTest.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/clang-tidy/ReadabilityModuleTest.cpp Fri 
Oct 14 03:10:08 2016
@@ -15,9 +15,9 @@ TEST(NamespaceCommentCheckTest, Basic) {
 runCheckOnCode("namespace i {\n}"));
   EXPECT_EQ("namespace {\n} // namespace",
 runCheckOnCode("namespace {\n}"));
-  EXPECT_EQ(
-  "namespace i { namespace j {\n} // namespace j\n } // namespace i",
-  runCheckOnCode("namespace i { namespace j {\n} 
}"));
+  EXPECT_EQ("namespace i { namespace j {\n} // namespace j\n } // namespace i",
+runCheckOnCode(
+"namespace i { namespace j {\n} }"));
 }
 
 TEST(NamespaceCommentCheckTest, SingleLineNamespaces) {
@@ -49,10 +49,11 @@ TEST(NamespaceCommentCheckTest, CheckExi
 "} // Anonymous namespace.",
 runCheckOnCode("namespace {\n"
   "} // Anonymous 
namespace."));
-  EXPECT_EQ("namespace q {\n"
-"} // namespace q",
-runCheckOnCode("namespace q {\n"
-  "} // anonymous namespace 
q"));
+  EXPECT_EQ(
+  "namespace q {\n"
+  "} // namespace q",
+  runCheckOnCode("namespace q {\n"
+"} // anonymous namespace q"));
   EXPECT_EQ(
   "namespace My_NameSpace123 {\n"
   "} // namespace My_NameSpace123",
@@ -97,7 +98,7 @@ TEST(NamespaceCommentCheckTest, FixWrong
   "} // random text"));
 }
 
-TEST(BracesAroundStatementsCheck, IfWithComments) {
+TEST(BracesAroundStatementsCheckTest, IfWithComments) {
   EXPECT_EQ("int main() {\n"
 "  if (false /*dummy token*/) {\n"
 "// comment\n"
@@ -134,7 +135,7 @@ TEST(BracesAroundStatementsCheck, IfWith
 "}"));
 }
 
-TEST(BracesAroundStatementsCheck, If) {
+TEST(BracesAroundStatementsCheckTest, If) {
   EXPECT_NO_CHANGES(BracesAroundStatementsCheck, "int main() {\n"
   

r284213 - [x86][ms-inline-asm] use of "jmp short" in asm is not supported

2016-10-14 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Fri Oct 14 03:13:27 2016
New Revision: 284213

URL: http://llvm.org/viewvc/llvm-project?rev=284213&view=rev
Log:
[x86][ms-inline-asm] use of "jmp short" in asm is not supported

Test linked to: https://reviews.llvm.org/D24957

Committing in the name of Ziv Izhar: After check-all and LGTM .

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


Modified:
cfe/trunk/test/CodeGen/ms-inline-asm.c

Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.c?rev=284213&r1=284212&r2=284213&view=diff
==
--- cfe/trunk/test/CodeGen/ms-inline-asm.c (original)
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c Fri Oct 14 03:13:27 2016
@@ -634,6 +634,15 @@ void label5() {
   // CHECK: call void asm sideeffect inteldialect "jmp 
{{.*}}__MSASMLABEL_.5__dollar_label$$\0A\09{{.*}}__MSASMLABEL_.5__dollar_label$$:",
 "~{dirflag},~{fpsr},~{flags}"()
 }
 
+void label6(){
+  __asm {
+  jmp short label
+label:
+  }
+  // CHECK-LABEL: define void @label6
+  // CHECK: call void asm sideeffect inteldialect "jmp 
{{.*}}__MSASMLABEL_.6__label\0A\09{{.*}}__MSASMLABEL_.6__label:", 
"~{dirflag},~{fpsr},~{flags}"()
+}
+
 typedef union _LARGE_INTEGER {
   struct {
 unsigned int LowPart;


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


[PATCH] D24958: Test linked to D24957

2016-10-14 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284213: [x86][ms-inline-asm] use of "jmp short" in asm is 
not supported (authored by mzuckerm).

Changed prior to commit:
  https://reviews.llvm.org/D24958?vs=72624&id=74626#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24958

Files:
  cfe/trunk/test/CodeGen/ms-inline-asm.c


Index: cfe/trunk/test/CodeGen/ms-inline-asm.c
===
--- cfe/trunk/test/CodeGen/ms-inline-asm.c
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c
@@ -634,6 +634,15 @@
   // CHECK: call void asm sideeffect inteldialect "jmp 
{{.*}}__MSASMLABEL_.5__dollar_label$$\0A\09{{.*}}__MSASMLABEL_.5__dollar_label$$:",
 "~{dirflag},~{fpsr},~{flags}"()
 }
 
+void label6(){
+  __asm {
+  jmp short label
+label:
+  }
+  // CHECK-LABEL: define void @label6
+  // CHECK: call void asm sideeffect inteldialect "jmp 
{{.*}}__MSASMLABEL_.6__label\0A\09{{.*}}__MSASMLABEL_.6__label:", 
"~{dirflag},~{fpsr},~{flags}"()
+}
+
 typedef union _LARGE_INTEGER {
   struct {
 unsigned int LowPart;


Index: cfe/trunk/test/CodeGen/ms-inline-asm.c
===
--- cfe/trunk/test/CodeGen/ms-inline-asm.c
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c
@@ -634,6 +634,15 @@
   // CHECK: call void asm sideeffect inteldialect "jmp {{.*}}__MSASMLABEL_.5__dollar_label$$\0A\09{{.*}}__MSASMLABEL_.5__dollar_label$$:", "~{dirflag},~{fpsr},~{flags}"()
 }
 
+void label6(){
+  __asm {
+  jmp short label
+label:
+  }
+  // CHECK-LABEL: define void @label6
+  // CHECK: call void asm sideeffect inteldialect "jmp {{.*}}__MSASMLABEL_.6__label\0A\09{{.*}}__MSASMLABEL_.6__label:", "~{dirflag},~{fpsr},~{flags}"()
+}
+
 typedef union _LARGE_INTEGER {
   struct {
 unsigned int LowPart;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25596: alpha.core.Conversion - Fix false positive for 'U32 += S16; ' expression, that is not unsafe

2016-10-14 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki created this revision.
danielmarjamaki added a reviewer: NoQ.
danielmarjamaki added subscribers: cfe-commits, xazax.hun, dcoughlin.
danielmarjamaki set the repository for this revision to rL LLVM.

This patch fix false positives for loss of sign in addition and subtraction 
assignment operators.


Repository:
  rL LLVM

https://reviews.llvm.org/D25596

Files:
  lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
  test/Analysis/conversion.c


Index: test/Analysis/conversion.c
===
--- test/Analysis/conversion.c
+++ test/Analysis/conversion.c
@@ -77,6 +77,10 @@
 void dontwarn5() {
   signed S = -32;
   U8 = S + 10;
+
+  unsigned  x = 100;
+  signed short delta = -1;
+  x += delta;
 }
 
 
Index: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
+++ lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
@@ -73,10 +73,13 @@
   // Loss of sign/precision in binary operation.
   if (const auto *B = dyn_cast(Parent)) {
 BinaryOperator::Opcode Opc = B->getOpcode();
-if (Opc == BO_Assign || Opc == BO_AddAssign || Opc == BO_SubAssign ||
-Opc == BO_MulAssign) {
-  LossOfSign = isLossOfSign(Cast, C);
-  LossOfPrecision = isLossOfPrecision(Cast, C);
+if (B->isAssignmentOp()) {
+  if (Opc == BO_Assign || Opc == BO_AddAssign || Opc == BO_SubAssign ||
+  Opc == BO_MulAssign || Opc == BO_OrAssign || Opc == BO_XorAssign)
+LossOfPrecision = isLossOfPrecision(Cast, C);
+  if (Opc == BO_Assign || Opc == BO_MulAssign || Opc == BO_DivAssign ||
+  Opc == BO_RemAssign)
+LossOfSign = isLossOfSign(Cast, C);
 } else if (B->isRelationalOp() || B->isMultiplicativeOp()) {
   LossOfSign = isLossOfSign(Cast, C);
 }
@@ -153,7 +156,7 @@
 }
 
 bool ConversionChecker::isLossOfPrecision(const ImplicitCastExpr *Cast,
-CheckerContext &C) const {
+  CheckerContext &C) const {
   // Don't warn about explicit loss of precision.
   if (Cast->isEvaluatable(C.getASTContext()))
 return false;
@@ -177,7 +180,7 @@
 }
 
 bool ConversionChecker::isLossOfSign(const ImplicitCastExpr *Cast,
-   CheckerContext &C) const {
+ CheckerContext &C) const {
   QualType CastType = Cast->getType();
   QualType SubType = Cast->IgnoreParenImpCasts()->getType();
 


Index: test/Analysis/conversion.c
===
--- test/Analysis/conversion.c
+++ test/Analysis/conversion.c
@@ -77,6 +77,10 @@
 void dontwarn5() {
   signed S = -32;
   U8 = S + 10;
+
+  unsigned  x = 100;
+  signed short delta = -1;
+  x += delta;
 }
 
 
Index: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
+++ lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
@@ -73,10 +73,13 @@
   // Loss of sign/precision in binary operation.
   if (const auto *B = dyn_cast(Parent)) {
 BinaryOperator::Opcode Opc = B->getOpcode();
-if (Opc == BO_Assign || Opc == BO_AddAssign || Opc == BO_SubAssign ||
-Opc == BO_MulAssign) {
-  LossOfSign = isLossOfSign(Cast, C);
-  LossOfPrecision = isLossOfPrecision(Cast, C);
+if (B->isAssignmentOp()) {
+  if (Opc == BO_Assign || Opc == BO_AddAssign || Opc == BO_SubAssign ||
+  Opc == BO_MulAssign || Opc == BO_OrAssign || Opc == BO_XorAssign)
+LossOfPrecision = isLossOfPrecision(Cast, C);
+  if (Opc == BO_Assign || Opc == BO_MulAssign || Opc == BO_DivAssign ||
+  Opc == BO_RemAssign)
+LossOfSign = isLossOfSign(Cast, C);
 } else if (B->isRelationalOp() || B->isMultiplicativeOp()) {
   LossOfSign = isLossOfSign(Cast, C);
 }
@@ -153,7 +156,7 @@
 }
 
 bool ConversionChecker::isLossOfPrecision(const ImplicitCastExpr *Cast,
-CheckerContext &C) const {
+  CheckerContext &C) const {
   // Don't warn about explicit loss of precision.
   if (Cast->isEvaluatable(C.getASTContext()))
 return false;
@@ -177,7 +180,7 @@
 }
 
 bool ConversionChecker::isLossOfSign(const ImplicitCastExpr *Cast,
-   CheckerContext &C) const {
+ CheckerContext &C) const {
   QualType CastType = Cast->getType();
   QualType SubType = Cast->IgnoreParenImpCasts()->getType();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r284214 - XFAIL aligned allocation tests for older Clang versions

2016-10-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Oct 14 03:47:09 2016
New Revision: 284214

URL: http://llvm.org/viewvc/llvm-project?rev=284214&view=rev
Log:
XFAIL aligned allocation tests for older Clang versions

Modified:
libcxx/trunk/test/libcxx/test/config.py

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

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

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

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

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

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

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

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

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=284214&r1=284213&r2=284214&view=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Fri Oct 14 03:47:09 2016
@@ -315,6 +315,10 @@ class Configuration(object):
 
 if self.cxx.hasCompileFlag('-faligned-allocation'):
 self.config.available_features.add('-faligned-allocation')
+else:
+# FIXME remove this once more than just clang-4.0 support
+# C++17 aligned allocation.
+self.config.available_features.add('no-aligned-allocation')
 
 if self.get_lit_bool('has_libatomic', False):
 self.config.available_features.add('libatomic')

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp?rev=284214&r1=284213&r2=284214&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp
 Fri Oct 14 03:47:09 2016
@@ -9,11 +9,13 @@
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 
-// test operator new
-
 // asan and msan will not call the new handler.
 // UNSUPPORTED: sanitizer-new-delete
 
+// XFAIL: no-aligned-allocation
+
+// test operator new
+
 #include 
 #include 
 #include 

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp?rev=284214&r1=284213&r2=284214&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
 Fri Oct 14 03:47:09 2016
@@ -9,11 +9,13 @@
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 
-// test operator new (nothrow)
-
 // asan and msan will not call the new handler.
 // UNSUPPORTED: sanitizer-new-delete
 
+// XFAIL: no-aligned-allocation
+
+// test operator new (nothrow)
+
 #include 
 #include 
 #include 

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp?rev=284214&r1=284213&r2=284214&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp
 Fri Oct 14 03:47:09 2016
@@ -8,10 +8,11 @@
 
//===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
+// UNSUPPORTED: sanitizer-new-delete
 
-// test operator new nothrow by replacing only operator new
+// XFAIL: no-aligned-allocation
 

[PATCH] D25597: Try to fix buildbot failure in VirtualFileSystem caused by r284129.

2016-10-14 Thread Eric Liu via cfe-commits
ioeric created this revision.
ioeric added a reviewer: bkramer.
ioeric added a subscriber: cfe-commits.

Since `remove_dots` does not delete leading "../" anymore, assertion test need
to be updated.


https://reviews.llvm.org/D25597

Files:
  lib/Basic/VirtualFileSystem.cpp


Index: lib/Basic/VirtualFileSystem.cpp
===
--- lib/Basic/VirtualFileSystem.cpp
+++ lib/Basic/VirtualFileSystem.cpp
@@ -1477,8 +1477,9 @@
 RedirectingFileSystem::lookupPath(sys::path::const_iterator Start,
   sys::path::const_iterator End, Entry *From) {
 #ifndef LLVM_ON_WIN32
-  assert(!isTraversalComponent(*Start) &&
- !isTraversalComponent(From->getName()) &&
+  // FIXME: `remove_dots` does not remove leading "../" anymore, might need
+  // better test here.
+  assert(!Start->equals(".") && !isTraversalComponent(From->getName()) &&
  "Paths should not contain traversal components");
 #else
   // FIXME: this is here to support windows, remove it once canonicalized


Index: lib/Basic/VirtualFileSystem.cpp
===
--- lib/Basic/VirtualFileSystem.cpp
+++ lib/Basic/VirtualFileSystem.cpp
@@ -1477,8 +1477,9 @@
 RedirectingFileSystem::lookupPath(sys::path::const_iterator Start,
   sys::path::const_iterator End, Entry *From) {
 #ifndef LLVM_ON_WIN32
-  assert(!isTraversalComponent(*Start) &&
- !isTraversalComponent(From->getName()) &&
+  // FIXME: `remove_dots` does not remove leading "../" anymore, might need
+  // better test here.
+  assert(!Start->equals(".") && !isTraversalComponent(From->getName()) &&
  "Paths should not contain traversal components");
 #else
   // FIXME: this is here to support windows, remove it once canonicalized
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24864: [libcxxabi] Refactor pthread usage into a separate API

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

Committed as r284128.


https://reviews.llvm.org/D24864



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


[PATCH] D25565: Deduplicate sets of replacements by file names.

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

I'd not rename the function. Otherwise looks good.


https://reviews.llvm.org/D25565



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


[libcxx] r284216 - Remove dead CMake target

2016-10-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Oct 14 04:06:38 2016
New Revision: 284216

URL: http://llvm.org/viewvc/llvm-project?rev=284216&view=rev
Log:
Remove dead CMake target

Modified:
libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake
libcxx/trunk/lib/CMakeLists.txt

Modified: libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake?rev=284216&r1=284215&r2=284216&view=diff
==
--- libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake (original)
+++ libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake Fri Oct 14 04:06:38 2016
@@ -58,9 +58,7 @@ macro(setup_abi_lib abidefines abilib ab
 endif()
   endforeach()
 
-  add_custom_target(LIBCXX_CXX_ABI_DEPS DEPENDS ${abilib_headers})
   include_directories("${CMAKE_BINARY_DIR}/include")
-
 endmacro()
 
 

Modified: libcxx/trunk/lib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=284216&r1=284215&r2=284216&view=diff
==
--- libcxx/trunk/lib/CMakeLists.txt (original)
+++ libcxx/trunk/lib/CMakeLists.txt Fri Oct 14 04:06:38 2016
@@ -198,10 +198,6 @@ endif()
 # Add a meta-target for both libraries.
 add_custom_target(cxx DEPENDS ${LIBCXX_TARGETS})
 
-if (DEFINED LIBCXX_CXX_ABI_DEPS)
-  add_dependencies(cxx LIBCXX_CXX_ABI_DEPS)
-endif()
-
 if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
   file(GLOB LIBCXX_EXPERIMENTAL_SOURCES ../src/experimental/*.cpp)
   if (LIBCXX_ENABLE_FILESYSTEM)


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


[PATCH] D25597: Try to fix buildbot failure in VirtualFileSystem caused by r284129.

2016-10-14 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 74631.
ioeric added a comment.

- Separate assertions to get more information.


https://reviews.llvm.org/D25597

Files:
  lib/Basic/VirtualFileSystem.cpp


Index: lib/Basic/VirtualFileSystem.cpp
===
--- lib/Basic/VirtualFileSystem.cpp
+++ lib/Basic/VirtualFileSystem.cpp
@@ -1477,9 +1477,12 @@
 RedirectingFileSystem::lookupPath(sys::path::const_iterator Start,
   sys::path::const_iterator End, Entry *From) {
 #ifndef LLVM_ON_WIN32
-  assert(!isTraversalComponent(*Start) &&
- !isTraversalComponent(From->getName()) &&
- "Paths should not contain traversal components");
+  // FIXME: `remove_dots` does not remove leading "../" anymore, might need
+  // better test here.
+  assert(!Start->equals(".") &&
+ "Start should not be \".\"");
+  assert(!isTraversalComponent(From->getName()) &&
+ "From->getName() should not contain traversal components");
 #else
   // FIXME: this is here to support windows, remove it once canonicalized
   // paths become globally default.


Index: lib/Basic/VirtualFileSystem.cpp
===
--- lib/Basic/VirtualFileSystem.cpp
+++ lib/Basic/VirtualFileSystem.cpp
@@ -1477,9 +1477,12 @@
 RedirectingFileSystem::lookupPath(sys::path::const_iterator Start,
   sys::path::const_iterator End, Entry *From) {
 #ifndef LLVM_ON_WIN32
-  assert(!isTraversalComponent(*Start) &&
- !isTraversalComponent(From->getName()) &&
- "Paths should not contain traversal components");
+  // FIXME: `remove_dots` does not remove leading "../" anymore, might need
+  // better test here.
+  assert(!Start->equals(".") &&
+ "Start should not be \".\"");
+  assert(!isTraversalComponent(From->getName()) &&
+ "From->getName() should not contain traversal components");
 #else
   // FIXME: this is here to support windows, remove it once canonicalized
   // paths become globally default.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25565: Deduplicate sets of replacements by file names.

2016-10-14 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 74632.
ioeric added a comment.

- Change name to groupReplacementsByFile


https://reviews.llvm.org/D25565

Files:
  include/clang/Tooling/Core/Replacement.h
  include/clang/Tooling/Refactoring.h
  lib/Tooling/Core/Replacement.cpp
  lib/Tooling/Refactoring.cpp
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -972,5 +972,23 @@
   toReplacements({{"", 0, 3, "cc"}, {"", 3, 3, "dd"}}));
 }
 
+TEST(DeduplicateByFileTest, LeaveLeadingDotDot) {
+  std::map FileToReplaces;
+  FileToReplaces["../../a/b/.././c.h"] = Replacements();
+  FileToReplaces["../../a/c.h"] = Replacements();
+  FileToReplaces = deduplicateReplacementsByFile(FileToReplaces);
+  EXPECT_EQ(1u, FileToReplaces.size());
+  EXPECT_EQ("../../a/c.h", FileToReplaces.begin()->first);
+}
+
+TEST(DeduplicateByFileTest, RemoveDotSlash) {
+  std::map FileToReplaces;
+  FileToReplaces["./a/b/.././c.h"] = Replacements();
+  FileToReplaces["a/c.h"] = Replacements();
+  FileToReplaces = deduplicateReplacementsByFile(FileToReplaces);
+  EXPECT_EQ(1u, FileToReplaces.size());
+  EXPECT_EQ("a/c.h", FileToReplaces.begin()->first);
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Tooling/Refactoring.cpp
===
--- lib/Tooling/Refactoring.cpp
+++ lib/Tooling/Refactoring.cpp
@@ -57,7 +57,7 @@
 
 bool RefactoringTool::applyAllReplacements(Rewriter &Rewrite) {
   bool Result = true;
-  for (const auto &Entry : FileToReplaces)
+  for (const auto &Entry : groupReplacementsByFile(FileToReplaces))
 Result = tooling::applyAllReplacements(Entry.second, Rewrite) && Result;
   return Result;
 }
@@ -73,7 +73,7 @@
   FileManager &Files = SM.getFileManager();
 
   bool Result = true;
-  for (const auto &FileAndReplaces : FileToReplaces) {
+  for (const auto &FileAndReplaces : groupReplacementsByFile(FileToReplaces)) {
 const std::string &FilePath = FileAndReplaces.first;
 auto &CurReplaces = FileAndReplaces.second;
 
Index: lib/Tooling/Core/Replacement.cpp
===
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -21,6 +21,7 @@
 #include "clang/Lex/Lexer.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/raw_os_ostream.h"
 
 namespace clang {
@@ -564,13 +565,15 @@
   return Result;
 }
 
-std::map
-groupReplacementsByFile(const Replacements &Replaces) {
-  std::map FileToReplaces;
-  for (const auto &Replace : Replaces)
-// We can ignore the Error here since \p Replaces is already conflict-free.
-FileToReplaces[Replace.getFilePath()].add(Replace);
-  return FileToReplaces;
+std::map groupReplacementsByFile(
+const std::map &FileToReplaces) {
+  std::map Result;
+  for (const auto &Entry : FileToReplaces) {
+llvm::SmallString<256> CleanPath(Entry.first.data());
+llvm::sys::path::remove_dots(CleanPath, /*remove_dot_dot=*/true);
+Result[CleanPath.str()] = std::move(Entry.second);
+  }
+  return Result;
 }
 
 } // end namespace tooling
Index: include/clang/Tooling/Refactoring.h
===
--- include/clang/Tooling/Refactoring.h
+++ include/clang/Tooling/Refactoring.h
@@ -55,6 +55,9 @@
 
   /// \brief Apply all stored replacements to the given Rewriter.
   ///
+  /// FileToReplaces will be deduplicated with `groupReplacementsByFile` before
+  /// application.
+  ///
   /// Replacement applications happen independently of the success of other
   /// applications.
   ///
@@ -75,6 +78,9 @@
 ///
 /// \pre Replacements must be conflict-free.
 ///
+/// FileToReplaces will be deduplicated with `groupReplacementsByFile` before
+/// application.
+///
 /// Replacement applications happen independently of the success of other
 /// applications.
 ///
Index: include/clang/Tooling/Core/Replacement.h
===
--- include/clang/Tooling/Core/Replacement.h
+++ include/clang/Tooling/Core/Replacement.h
@@ -230,8 +230,6 @@
   Replacements(const_iterator Begin, const_iterator End)
   : Replaces(Begin, End) {}
 
-  Replacements mergeReplacements(const ReplacementsImpl &Second) const;
-
   // Returns `R` with new range that refers to code after `Replaces` being
   // applied.
   Replacement getReplacementInChangedCode(const Replacement &R) const;
@@ -294,10 +292,11 @@
 calculateRangesAfterReplacements(const Replacements &Replaces,
  const std::vector &Ranges);
 
-/// \brief Groups a random set of replacements by file path. Replacements
-/// related to the same file entry are put into the same vector.
-std::map
-groupReplacementsByFile(const Repla

[libcxxabi] r284217 - Mark test as unsupported without threads

2016-10-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Oct 14 04:12:53 2016
New Revision: 284217

URL: http://llvm.org/viewvc/llvm-project?rev=284217&view=rev
Log:
Mark test as unsupported without threads

Modified:
libcxxabi/trunk/test/libcxxabi/test/config.py
libcxxabi/trunk/test/thread_local_destruction_order.pass.cpp

Modified: libcxxabi/trunk/test/libcxxabi/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/libcxxabi/test/config.py?rev=284217&r1=284216&r2=284217&view=diff
==
--- libcxxabi/trunk/test/libcxxabi/test/config.py (original)
+++ libcxxabi/trunk/test/libcxxabi/test/config.py Fri Oct 14 04:12:53 2016
@@ -46,6 +46,7 @@ class Configuration(LibcxxConfiguration)
 self.cxx.compile_flags += ['-fno-exceptions', 
'-DLIBCXXABI_HAS_NO_EXCEPTIONS']
 if not self.get_lit_bool('enable_threads', True):
 self.cxx.compile_flags += ['-D_LIBCXXABI_HAS_NO_THREADS']
+self.config.available_features.add('libcxxabi-no-threads')
 super(Configuration, self).configure_compile_flags()
 
 def configure_compile_flags_header_includes(self):

Modified: libcxxabi/trunk/test/thread_local_destruction_order.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/thread_local_destruction_order.pass.cpp?rev=284217&r1=284216&r2=284217&view=diff
==
--- libcxxabi/trunk/test/thread_local_destruction_order.pass.cpp (original)
+++ libcxxabi/trunk/test/thread_local_destruction_order.pass.cpp Fri Oct 14 
04:12:53 2016
@@ -8,6 +8,7 @@
 
//===--===//
 
 // UNSUPPORTED: c++98, c++03
+// UNSUPPORTED: libcxxabi-no-threads
 
 #include 
 #include 


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


[PATCH] D25598: [clang-move] Matching static class member more correctly.

2016-10-14 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: ioeric.
hokein added a subscriber: cfe-commits.

https://reviews.llvm.org/D25598

Files:
  clang-move/ClangMove.cpp
  test/clang-move/Inputs/test.cpp
  test/clang-move/Inputs/test.h
  test/clang-move/move-class.cpp


Index: test/clang-move/move-class.cpp
===
--- test/clang-move/move-class.cpp
+++ test/clang-move/move-class.cpp
@@ -25,13 +25,15 @@
 // CHECK-NEW-TEST-H: class Foo {
 // CHECK-NEW-TEST-H: public:
 // CHECK-NEW-TEST-H:   int f();
+// CHECK-NEW-TEST-H:   int f2(int a, int b);
 // CHECK-NEW-TEST-H: };
 // CHECK-NEW-TEST-H: } // namespace a
 //
 // CHECK-NEW-TEST-CPP: #include "{{.*}}new_test.h"
 // CHECK-NEW-TEST-CPP: #include "test2.h"
 // CHECK-NEW-TEST-CPP: namespace a {
 // CHECK-NEW-TEST-CPP: int Foo::f() { return 0; }
+// CHECK-NEW-TEST-CPP: int Foo::f2(int a, int b) { return a + b; }
 // CHECK-NEW-TEST-CPP: } // namespace a
 //
 // CHECK-OLD-TEST-CPP: #include "test.h"
Index: test/clang-move/Inputs/test.h
===
--- test/clang-move/Inputs/test.h
+++ test/clang-move/Inputs/test.h
@@ -2,5 +2,6 @@
 class Foo {
 public:
   int f();
+  int f2(int a, int b);
 };
 } // namespace a
Index: test/clang-move/Inputs/test.cpp
===
--- test/clang-move/Inputs/test.cpp
+++ test/clang-move/Inputs/test.cpp
@@ -5,4 +5,7 @@
 int Foo::f() {
   return 0;
 }
+int Foo::f2(int a, int b) {
+  return a + b;
+}
 } // namespace a
Index: clang-move/ClangMove.cpp
===
--- clang-move/ClangMove.cpp
+++ clang-move/ClangMove.cpp
@@ -24,6 +24,11 @@
 namespace move {
 namespace {
 
+// FIXME: Move to ASTMatchers.
+AST_MATCHER(VarDecl, isStaticDataMember) {
+  return Node.isStaticDataMember();
+}
+
 AST_MATCHER_P(Decl, hasOutermostEnclosingClass,
   ast_matchers::internal::Matcher, InnerMatcher) {
   const auto* Context = Node.getDeclContext();
@@ -365,7 +370,8 @@
   this);
 
   // Match static member variable definition of the moved class.
-  Finder->addMatcher(varDecl(InMovedClass, InOldCC, isDefinition())
+  Finder->addMatcher(varDecl(InMovedClass, InOldCC, isDefinition(),
+ isStaticDataMember())
  .bind("class_static_var_decl"),
  this);
 


Index: test/clang-move/move-class.cpp
===
--- test/clang-move/move-class.cpp
+++ test/clang-move/move-class.cpp
@@ -25,13 +25,15 @@
 // CHECK-NEW-TEST-H: class Foo {
 // CHECK-NEW-TEST-H: public:
 // CHECK-NEW-TEST-H:   int f();
+// CHECK-NEW-TEST-H:   int f2(int a, int b);
 // CHECK-NEW-TEST-H: };
 // CHECK-NEW-TEST-H: } // namespace a
 //
 // CHECK-NEW-TEST-CPP: #include "{{.*}}new_test.h"
 // CHECK-NEW-TEST-CPP: #include "test2.h"
 // CHECK-NEW-TEST-CPP: namespace a {
 // CHECK-NEW-TEST-CPP: int Foo::f() { return 0; }
+// CHECK-NEW-TEST-CPP: int Foo::f2(int a, int b) { return a + b; }
 // CHECK-NEW-TEST-CPP: } // namespace a
 //
 // CHECK-OLD-TEST-CPP: #include "test.h"
Index: test/clang-move/Inputs/test.h
===
--- test/clang-move/Inputs/test.h
+++ test/clang-move/Inputs/test.h
@@ -2,5 +2,6 @@
 class Foo {
 public:
   int f();
+  int f2(int a, int b);
 };
 } // namespace a
Index: test/clang-move/Inputs/test.cpp
===
--- test/clang-move/Inputs/test.cpp
+++ test/clang-move/Inputs/test.cpp
@@ -5,4 +5,7 @@
 int Foo::f() {
   return 0;
 }
+int Foo::f2(int a, int b) {
+  return a + b;
+}
 } // namespace a
Index: clang-move/ClangMove.cpp
===
--- clang-move/ClangMove.cpp
+++ clang-move/ClangMove.cpp
@@ -24,6 +24,11 @@
 namespace move {
 namespace {
 
+// FIXME: Move to ASTMatchers.
+AST_MATCHER(VarDecl, isStaticDataMember) {
+  return Node.isStaticDataMember();
+}
+
 AST_MATCHER_P(Decl, hasOutermostEnclosingClass,
   ast_matchers::internal::Matcher, InnerMatcher) {
   const auto* Context = Node.getDeclContext();
@@ -365,7 +370,8 @@
   this);
 
   // Match static member variable definition of the moved class.
-  Finder->addMatcher(varDecl(InMovedClass, InOldCC, isDefinition())
+  Finder->addMatcher(varDecl(InMovedClass, InOldCC, isDefinition(),
+ isStaticDataMember())
  .bind("class_static_var_decl"),
  this);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25565: Deduplicate sets of replacements by file names.

2016-10-14 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 74634.
ioeric added a comment.

- Merge branch 'master' of http://llvm.org/git/clang into arcpatch-D25565
- Forgot to update names in tests...


https://reviews.llvm.org/D25565

Files:
  include/clang/Tooling/Core/Replacement.h
  include/clang/Tooling/Refactoring.h
  lib/Tooling/Core/Replacement.cpp
  lib/Tooling/Refactoring.cpp
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -972,5 +972,23 @@
   toReplacements({{"", 0, 3, "cc"}, {"", 3, 3, "dd"}}));
 }
 
+TEST(DeduplicateByFileTest, LeaveLeadingDotDot) {
+  std::map FileToReplaces;
+  FileToReplaces["../../a/b/.././c.h"] = Replacements();
+  FileToReplaces["../../a/c.h"] = Replacements();
+  FileToReplaces = groupReplacementsByFile(FileToReplaces);
+  EXPECT_EQ(1u, FileToReplaces.size());
+  EXPECT_EQ("../../a/c.h", FileToReplaces.begin()->first);
+}
+
+TEST(DeduplicateByFileTest, RemoveDotSlash) {
+  std::map FileToReplaces;
+  FileToReplaces["./a/b/.././c.h"] = Replacements();
+  FileToReplaces["a/c.h"] = Replacements();
+  FileToReplaces = groupReplacementsByFile(FileToReplaces);
+  EXPECT_EQ(1u, FileToReplaces.size());
+  EXPECT_EQ("a/c.h", FileToReplaces.begin()->first);
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Tooling/Refactoring.cpp
===
--- lib/Tooling/Refactoring.cpp
+++ lib/Tooling/Refactoring.cpp
@@ -57,7 +57,7 @@
 
 bool RefactoringTool::applyAllReplacements(Rewriter &Rewrite) {
   bool Result = true;
-  for (const auto &Entry : FileToReplaces)
+  for (const auto &Entry : groupReplacementsByFile(FileToReplaces))
 Result = tooling::applyAllReplacements(Entry.second, Rewrite) && Result;
   return Result;
 }
@@ -73,7 +73,7 @@
   FileManager &Files = SM.getFileManager();
 
   bool Result = true;
-  for (const auto &FileAndReplaces : FileToReplaces) {
+  for (const auto &FileAndReplaces : groupReplacementsByFile(FileToReplaces)) {
 const std::string &FilePath = FileAndReplaces.first;
 auto &CurReplaces = FileAndReplaces.second;
 
Index: lib/Tooling/Core/Replacement.cpp
===
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -21,6 +21,7 @@
 #include "clang/Lex/Lexer.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/raw_os_ostream.h"
 
 namespace clang {
@@ -564,13 +565,15 @@
   return Result;
 }
 
-std::map
-groupReplacementsByFile(const Replacements &Replaces) {
-  std::map FileToReplaces;
-  for (const auto &Replace : Replaces)
-// We can ignore the Error here since \p Replaces is already conflict-free.
-FileToReplaces[Replace.getFilePath()].add(Replace);
-  return FileToReplaces;
+std::map groupReplacementsByFile(
+const std::map &FileToReplaces) {
+  std::map Result;
+  for (const auto &Entry : FileToReplaces) {
+llvm::SmallString<256> CleanPath(Entry.first.data());
+llvm::sys::path::remove_dots(CleanPath, /*remove_dot_dot=*/true);
+Result[CleanPath.str()] = std::move(Entry.second);
+  }
+  return Result;
 }
 
 } // end namespace tooling
Index: include/clang/Tooling/Refactoring.h
===
--- include/clang/Tooling/Refactoring.h
+++ include/clang/Tooling/Refactoring.h
@@ -55,6 +55,9 @@
 
   /// \brief Apply all stored replacements to the given Rewriter.
   ///
+  /// FileToReplaces will be deduplicated with `groupReplacementsByFile` before
+  /// application.
+  ///
   /// Replacement applications happen independently of the success of other
   /// applications.
   ///
@@ -75,6 +78,9 @@
 ///
 /// \pre Replacements must be conflict-free.
 ///
+/// FileToReplaces will be deduplicated with `groupReplacementsByFile` before
+/// application.
+///
 /// Replacement applications happen independently of the success of other
 /// applications.
 ///
Index: include/clang/Tooling/Core/Replacement.h
===
--- include/clang/Tooling/Core/Replacement.h
+++ include/clang/Tooling/Core/Replacement.h
@@ -230,8 +230,6 @@
   Replacements(const_iterator Begin, const_iterator End)
   : Replaces(Begin, End) {}
 
-  Replacements mergeReplacements(const ReplacementsImpl &Second) const;
-
   // Returns `R` with new range that refers to code after `Replaces` being
   // applied.
   Replacement getReplacementInChangedCode(const Replacement &R) const;
@@ -294,10 +292,11 @@
 calculateRangesAfterReplacements(const Replacements &Replaces,
  const std::vector &Ranges);
 
-/// \brief Groups a random set of replacements by file path. Replacements
-/// related to the same file entry are put into the s

[PATCH] D25565: Deduplicate sets of replacements by file names.

2016-10-14 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284219: Deduplicate sets of replacements by file names. 
(authored by ioeric).

Changed prior to commit:
  https://reviews.llvm.org/D25565?vs=74634&id=74636#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25565

Files:
  cfe/trunk/include/clang/Tooling/Core/Replacement.h
  cfe/trunk/include/clang/Tooling/Refactoring.h
  cfe/trunk/lib/Tooling/Core/Replacement.cpp
  cfe/trunk/lib/Tooling/Refactoring.cpp
  cfe/trunk/unittests/Tooling/RefactoringTest.cpp

Index: cfe/trunk/unittests/Tooling/RefactoringTest.cpp
===
--- cfe/trunk/unittests/Tooling/RefactoringTest.cpp
+++ cfe/trunk/unittests/Tooling/RefactoringTest.cpp
@@ -972,5 +972,23 @@
   toReplacements({{"", 0, 3, "cc"}, {"", 3, 3, "dd"}}));
 }
 
+TEST(DeduplicateByFileTest, LeaveLeadingDotDot) {
+  std::map FileToReplaces;
+  FileToReplaces["../../a/b/.././c.h"] = Replacements();
+  FileToReplaces["../../a/c.h"] = Replacements();
+  FileToReplaces = groupReplacementsByFile(FileToReplaces);
+  EXPECT_EQ(1u, FileToReplaces.size());
+  EXPECT_EQ("../../a/c.h", FileToReplaces.begin()->first);
+}
+
+TEST(DeduplicateByFileTest, RemoveDotSlash) {
+  std::map FileToReplaces;
+  FileToReplaces["./a/b/.././c.h"] = Replacements();
+  FileToReplaces["a/c.h"] = Replacements();
+  FileToReplaces = groupReplacementsByFile(FileToReplaces);
+  EXPECT_EQ(1u, FileToReplaces.size());
+  EXPECT_EQ("a/c.h", FileToReplaces.begin()->first);
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: cfe/trunk/include/clang/Tooling/Refactoring.h
===
--- cfe/trunk/include/clang/Tooling/Refactoring.h
+++ cfe/trunk/include/clang/Tooling/Refactoring.h
@@ -55,6 +55,9 @@
 
   /// \brief Apply all stored replacements to the given Rewriter.
   ///
+  /// FileToReplaces will be deduplicated with `groupReplacementsByFile` before
+  /// application.
+  ///
   /// Replacement applications happen independently of the success of other
   /// applications.
   ///
@@ -75,6 +78,9 @@
 ///
 /// \pre Replacements must be conflict-free.
 ///
+/// FileToReplaces will be deduplicated with `groupReplacementsByFile` before
+/// application.
+///
 /// Replacement applications happen independently of the success of other
 /// applications.
 ///
Index: cfe/trunk/include/clang/Tooling/Core/Replacement.h
===
--- cfe/trunk/include/clang/Tooling/Core/Replacement.h
+++ cfe/trunk/include/clang/Tooling/Core/Replacement.h
@@ -230,8 +230,6 @@
   Replacements(const_iterator Begin, const_iterator End)
   : Replaces(Begin, End) {}
 
-  Replacements mergeReplacements(const ReplacementsImpl &Second) const;
-
   // Returns `R` with new range that refers to code after `Replaces` being
   // applied.
   Replacement getReplacementInChangedCode(const Replacement &R) const;
@@ -294,10 +292,11 @@
 calculateRangesAfterReplacements(const Replacements &Replaces,
  const std::vector &Ranges);
 
-/// \brief Groups a random set of replacements by file path. Replacements
-/// related to the same file entry are put into the same vector.
-std::map
-groupReplacementsByFile(const Replacements &Replaces);
+/// \brief If there are multiple  pairs with the same file
+/// path after removing dots, we only keep one pair (with path after dots being
+/// removed) and discard the rest.
+std::map groupReplacementsByFile(
+const std::map &FileToReplaces);
 
 template 
 Replacement::Replacement(const SourceManager &Sources,
Index: cfe/trunk/lib/Tooling/Core/Replacement.cpp
===
--- cfe/trunk/lib/Tooling/Core/Replacement.cpp
+++ cfe/trunk/lib/Tooling/Core/Replacement.cpp
@@ -21,6 +21,7 @@
 #include "clang/Lex/Lexer.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/raw_os_ostream.h"
 
 namespace clang {
@@ -564,13 +565,15 @@
   return Result;
 }
 
-std::map
-groupReplacementsByFile(const Replacements &Replaces) {
-  std::map FileToReplaces;
-  for (const auto &Replace : Replaces)
-// We can ignore the Error here since \p Replaces is already conflict-free.
-FileToReplaces[Replace.getFilePath()].add(Replace);
-  return FileToReplaces;
+std::map groupReplacementsByFile(
+const std::map &FileToReplaces) {
+  std::map Result;
+  for (const auto &Entry : FileToReplaces) {
+llvm::SmallString<256> CleanPath(Entry.first.data());
+llvm::sys::path::remove_dots(CleanPath, /*remove_dot_dot=*/true);
+Result[CleanPath.str()] = std::move(Entry.second);
+  }
+  return Result;
 }
 
 } // end namespace tooling
Index: cfe/trunk/lib/Tooling/Refactoring.cpp
===
--- cfe/trunk/lib/Tooling/Refactoring.cpp
+++

r284219 - Deduplicate sets of replacements by file names.

2016-10-14 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Fri Oct 14 04:32:06 2016
New Revision: 284219

URL: http://llvm.org/viewvc/llvm-project?rev=284219&view=rev
Log:
Deduplicate sets of replacements by file names.

Summary:
If there are multiple  pairs with the same file
path after removing dots, we only keep one pair (with path after dots being
removed) and discard the rest.

Reviewers: djasper

Subscribers: klimek, hokein, bkramer, cfe-commits

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

Modified:
cfe/trunk/include/clang/Tooling/Core/Replacement.h
cfe/trunk/include/clang/Tooling/Refactoring.h
cfe/trunk/lib/Tooling/Core/Replacement.cpp
cfe/trunk/lib/Tooling/Refactoring.cpp
cfe/trunk/unittests/Tooling/RefactoringTest.cpp

Modified: cfe/trunk/include/clang/Tooling/Core/Replacement.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/Replacement.h?rev=284219&r1=284218&r2=284219&view=diff
==
--- cfe/trunk/include/clang/Tooling/Core/Replacement.h (original)
+++ cfe/trunk/include/clang/Tooling/Core/Replacement.h Fri Oct 14 04:32:06 2016
@@ -230,8 +230,6 @@ private:
   Replacements(const_iterator Begin, const_iterator End)
   : Replaces(Begin, End) {}
 
-  Replacements mergeReplacements(const ReplacementsImpl &Second) const;
-
   // Returns `R` with new range that refers to code after `Replaces` being
   // applied.
   Replacement getReplacementInChangedCode(const Replacement &R) const;
@@ -294,10 +292,11 @@ std::vector
 calculateRangesAfterReplacements(const Replacements &Replaces,
  const std::vector &Ranges);
 
-/// \brief Groups a random set of replacements by file path. Replacements
-/// related to the same file entry are put into the same vector.
-std::map
-groupReplacementsByFile(const Replacements &Replaces);
+/// \brief If there are multiple  pairs with the same file
+/// path after removing dots, we only keep one pair (with path after dots being
+/// removed) and discard the rest.
+std::map groupReplacementsByFile(
+const std::map &FileToReplaces);
 
 template 
 Replacement::Replacement(const SourceManager &Sources,

Modified: cfe/trunk/include/clang/Tooling/Refactoring.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring.h?rev=284219&r1=284218&r2=284219&view=diff
==
--- cfe/trunk/include/clang/Tooling/Refactoring.h (original)
+++ cfe/trunk/include/clang/Tooling/Refactoring.h Fri Oct 14 04:32:06 2016
@@ -55,6 +55,9 @@ public:
 
   /// \brief Apply all stored replacements to the given Rewriter.
   ///
+  /// FileToReplaces will be deduplicated with `groupReplacementsByFile` before
+  /// application.
+  ///
   /// Replacement applications happen independently of the success of other
   /// applications.
   ///
@@ -75,6 +78,9 @@ private:
 ///
 /// \pre Replacements must be conflict-free.
 ///
+/// FileToReplaces will be deduplicated with `groupReplacementsByFile` before
+/// application.
+///
 /// Replacement applications happen independently of the success of other
 /// applications.
 ///

Modified: cfe/trunk/lib/Tooling/Core/Replacement.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/Replacement.cpp?rev=284219&r1=284218&r2=284219&view=diff
==
--- cfe/trunk/lib/Tooling/Core/Replacement.cpp (original)
+++ cfe/trunk/lib/Tooling/Core/Replacement.cpp Fri Oct 14 04:32:06 2016
@@ -21,6 +21,7 @@
 #include "clang/Lex/Lexer.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/raw_os_ostream.h"
 
 namespace clang {
@@ -564,13 +565,15 @@ llvm::Expected applyAllRepl
   return Result;
 }
 
-std::map
-groupReplacementsByFile(const Replacements &Replaces) {
-  std::map FileToReplaces;
-  for (const auto &Replace : Replaces)
-// We can ignore the Error here since \p Replaces is already conflict-free.
-FileToReplaces[Replace.getFilePath()].add(Replace);
-  return FileToReplaces;
+std::map groupReplacementsByFile(
+const std::map &FileToReplaces) {
+  std::map Result;
+  for (const auto &Entry : FileToReplaces) {
+llvm::SmallString<256> CleanPath(Entry.first.data());
+llvm::sys::path::remove_dots(CleanPath, /*remove_dot_dot=*/true);
+Result[CleanPath.str()] = std::move(Entry.second);
+  }
+  return Result;
 }
 
 } // end namespace tooling

Modified: cfe/trunk/lib/Tooling/Refactoring.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring.cpp?rev=284219&r1=284218&r2=284219&view=diff
==
--- cfe/trunk/lib/Tooling/Refactoring.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring.cpp Fri Oct 14 04:32:06 2016
@@ -57,7 +57,7 @@ int RefactoringTool::runAndSave(Frontend
 
 bo

[PATCH] D25598: [clang-move] Matching static class member more correctly.

2016-10-14 Thread Eric Liu 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/D25598



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


[PATCH] D23657: Remove some false positives when taking the address of packed members

2016-10-14 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 updated this revision to Diff 74638.
rogfer01 added a comment.

Updated patch, now we check if the innermost base of a MemberExpr is a 
DeclRefExpr and check for its declaration in case it provides stronger 
alignment guarantees.


https://reviews.llvm.org/D23657

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaChecking.cpp
  test/Sema/address-packed.c

Index: test/Sema/address-packed.c
===
--- test/Sema/address-packed.c
+++ test/Sema/address-packed.c
@@ -26,6 +26,7 @@
 struct Arguable *get_arguable();
 
 void to_void(void *);
+void to_intptr(intptr_t);
 
 void g0(void) {
   {
@@ -41,43 +42,48 @@
 
 f1((int *)(void *)&arguable.x); // no-warning
 to_void(&arguable.x);   // no-warning
-void *p = &arguable.x;  // no-warning;
+void *p = &arguable.x;  // no-warning
 to_void(p);
+to_intptr((intptr_t)p); // no-warning
   }
   {
 union UnionArguable arguable;
 f2(&arguable.c); // no-warning
 f1(&arguable.x); // expected-warning {{packed member 'x' of class or structure 'UnionArguable'}}
 
-f1((int *)(void *)&arguable.x); // no-warning
-to_void(&arguable.x);   // no-warning
+f1((int *)(void *)&arguable.x);   // no-warning
+to_void(&arguable.x); // no-warning
+to_intptr((intptr_t)&arguable.x); // no-warning
   }
   {
 ArguableT arguable;
 f2(&arguable.c0); // no-warning
 f1(&arguable.x);  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&arguable.c1); // no-warning
 
-f1((int *)(void *)&arguable.x); // no-warning
-to_void(&arguable.x);   // no-warning
+f1((int *)(void *)&arguable.x);   // no-warning
+to_void(&arguable.x); // no-warning
+to_intptr((intptr_t)&arguable.x); // no-warning
   }
   {
 struct Arguable *arguable = get_arguable();
 f2(&arguable->c0); // no-warning
 f1(&arguable->x);  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&arguable->c1); // no-warning
 
-f1((int *)(void *)&arguable->x); // no-warning
-to_void(&arguable->c1);  // no-warning
+f1((int *)(void *)&arguable->x);// no-warning
+to_void(&arguable->c1); // no-warning
+to_intptr((intptr_t)&arguable->c1); // no-warning
   }
   {
 ArguableT *arguable = get_arguable();
 f2(&(arguable->c0)); // no-warning
 f1(&(arguable->x));  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&(arguable->c1)); // no-warning
 
-f1((int *)(void *)&(arguable->x)); // no-warning
-to_void(&(arguable->c1));  // no-warning
+f1((int *)(void *)&(arguable->x));  // no-warning
+to_void(&(arguable->c1));   // no-warning
+to_intptr((intptr_t)&(arguable->c1));   // no-warning
   }
 }
 
@@ -161,3 +167,120 @@
 {
 return (struct AlignedTo2Bis*)&s->x; // no-warning
 }
+
+struct S6 {
+int a;
+int _;
+int c;
+char __;
+int d;
+} __attribute__((packed, aligned(16))) s6;
+
+void g8()
+{ 
+f1(&s6.a); // no-warning
+f1(&s6.c); // no-warning
+f1(&s6.d); // expected-warning {{packed member 'd' of class or structure 'S6'}}
+}
+
+struct __attribute__((packed, aligned(1))) MisalignedContainee { double d; };
+struct __attribute__((aligned(8))) AlignedContainer { struct MisalignedContainee b; };
+
+struct AlignedContainer *p;
+double* g9() {
+  return &p->b.d; // no-warning
+}
+
+union OneUnion
+{
+uint32_t a;
+uint32_t b:1;
+};
+
+struct __attribute__((packed)) S7 {
+uint8_t length;
+uint8_t stuff;
+uint8_t padding[2];
+union OneUnion one_union;
+};
+
+union AnotherUnion {
+long data;
+struct S7 s;
+} *au;
+
+union OneUnion* get_OneUnion(void)
+{
+return &au->s.one_union; // no-warning
+}
+
+struct __attribute__((packed)) S8 {
+uint8_t data1;
+uint8_t data2;
+	uint16_t wider_data;
+};
+
+#define LE_READ_2(p)	\
+	((uint16_t)	\
+	 const uint8_t *)(p))[0]  ) |		\
+	  (((const uint8_t *)(p))[1] <<  8)))
+
+uint32_t get_wider_data(struct S8 *s)
+{
+return LE_READ_2(&s->wider_data); // no-warning
+}
+
+struct S9 {
+  uint32_t x;
+  uint8_t y[2];
+  uint16_t z;
+} __attribute__((__packed__));
+
+typedef struct S9 __attribute__((__aligned__(16))) aligned_S9;
+
+void g10() {
+  struct S9 x;
+  struct S9 __attribute__((__aligned__(8))) y;
+  aligned_S9 z;
+
+  uint32_t *p32;
+  p32 = &x.x; // expected-warning {{packed member 'x' of class or structure 'S9'}}
+  p32 = &y.x; // no-warning
+  p32 = &z.x; // no-warning
+}
+
+typedef struct {
+  uint32_t msgh_bits;
+  uint32_t msgh_size;
+  int32_t msgh_voucher_port;
+  int32_t msgh_id;
+} S10Header;
+
+typedef struct {
+  uint32_t t;
+  uint64_t m;
+  uint32_t p;
+  union {
+struct {
+  uint32_t a;
+  double z;
+} __attribute__((aligned(8), packed)) a;
+struct {
+  uint32_t b;
+  double z;
+  

[PATCH] D25600: [ASTMatcher] Add isStaticDataMember matcher for varDecl.

2016-10-14 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: klimek.
hokein added a subscriber: cfe-commits.

https://reviews.llvm.org/D25600

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp


Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -692,6 +692,15 @@
   EXPECT_TRUE(notMatches(T, varDecl(hasName("a"), 
hasThreadStorageDuration(;
 }
 
+TEST(Matcher, VarDecl_StaticDataMember) {
+  EXPECT_TRUE(matches(
+"class A {static int x; int y;};",
+varDecl(hasName("x"), isStaticDataMember(;
+  EXPECT_TRUE(notMatches(
+"class A {int x;};",
+varDecl(isStaticDataMember(;
+}
+
 TEST(Matcher, FindsVarDeclInFunctionParameter) {
   EXPECT_TRUE(matches(
 "void f(int i) {}",
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -2993,6 +2993,19 @@
   return Node.isExceptionVariable();
 }
 
+/// \brief Matches a variable declaration that is a static data member.
+///
+/// Example matches x (matcher = varDecl(isStaticDataMember())
+/// \code
+/// class A {
+///  static int x;
+///  int y;
+/// };
+/// \endcode
+AST_MATCHER(VarDecl, isStaticDataMember) {
+  return Node.isStaticDataMember();
+}
+
 /// \brief Checks that a call expression or a constructor call expression has
 /// a specific number of arguments (including absent default arguments).
 ///
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -3493,6 +3493,17 @@
 
 
 
+MatcherVarDecl>isStaticDataMember
+Matches a 
variable declaration that is a static data member.
+
+Example matches x (matcher = varDecl(isStaticDataMember())
+class A {
+ static int x;
+ int y;
+};
+
+
+
 MatcherVarDecl>isStaticStorageClass
 Matches 
variablefunction declarations that have "static" storage
 class specifier ("static" keyword) written in the source.


Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -692,6 +692,15 @@
   EXPECT_TRUE(notMatches(T, varDecl(hasName("a"), hasThreadStorageDuration(;
 }
 
+TEST(Matcher, VarDecl_StaticDataMember) {
+  EXPECT_TRUE(matches(
+"class A {static int x; int y;};",
+varDecl(hasName("x"), isStaticDataMember(;
+  EXPECT_TRUE(notMatches(
+"class A {int x;};",
+varDecl(isStaticDataMember(;
+}
+
 TEST(Matcher, FindsVarDeclInFunctionParameter) {
   EXPECT_TRUE(matches(
 "void f(int i) {}",
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -2993,6 +2993,19 @@
   return Node.isExceptionVariable();
 }
 
+/// \brief Matches a variable declaration that is a static data member.
+///
+/// Example matches x (matcher = varDecl(isStaticDataMember())
+/// \code
+/// class A {
+///  static int x;
+///  int y;
+/// };
+/// \endcode
+AST_MATCHER(VarDecl, isStaticDataMember) {
+  return Node.isStaticDataMember();
+}
+
 /// \brief Checks that a call expression or a constructor call expression has
 /// a specific number of arguments (including absent default arguments).
 ///
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -3493,6 +3493,17 @@
 
 
 
+MatcherVarDecl>isStaticDataMember
+Matches a variable declaration that is a static data member.
+
+Example matches x (matcher = varDecl(isStaticDataMember())
+class A {
+ static int x;
+ int y;
+};
+
+
+
 MatcherVarDecl>isStaticStorageClass
 Matches variablefunction declarations that have "static" storage
 class specifier ("static" keyword) written in the source.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25602: Do not reset TUScope when we are in incremental processing mode.

2016-10-14 Thread Vassil Vassilev via cfe-commits
v.g.vassilev created this revision.
v.g.vassilev added a reviewer: rsmith.
v.g.vassilev added a subscriber: cfe-commits.

We are using this in the context of cling, where we keep the compiler instance 
alive after EOF.

The incremental processing part in clang was done mostly by me and this patch 
LGTM, but I'd like to go under a formal review procedure.


https://reviews.llvm.org/D25602

Files:
  lib/Sema/Sema.cpp


Index: lib/Sema/Sema.cpp
===
--- lib/Sema/Sema.cpp
+++ lib/Sema/Sema.cpp
@@ -710,7 +710,8 @@
 
   if (TUKind == TU_Prefix) {
 // Translation unit prefixes don't need any of the checking below.
-TUScope = nullptr;
+if (!PP.isIncrementalProcessingEnabled())
+  TUScope = nullptr;
 return;
   }
 
@@ -909,7 +910,8 @@
   assert(ParsingInitForAutoVars.empty() &&
  "Didn't unmark var as having its initializer parsed");
 
-  TUScope = nullptr;
+  if (!PP.isIncrementalProcessingEnabled())
+TUScope = nullptr;
 }
 
 


Index: lib/Sema/Sema.cpp
===
--- lib/Sema/Sema.cpp
+++ lib/Sema/Sema.cpp
@@ -710,7 +710,8 @@
 
   if (TUKind == TU_Prefix) {
 // Translation unit prefixes don't need any of the checking below.
-TUScope = nullptr;
+if (!PP.isIncrementalProcessingEnabled())
+  TUScope = nullptr;
 return;
   }
 
@@ -909,7 +910,8 @@
   assert(ParsingInitForAutoVars.empty() &&
  "Didn't unmark var as having its initializer parsed");
 
-  TUScope = nullptr;
+  if (!PP.isIncrementalProcessingEnabled())
+TUScope = nullptr;
 }
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25597: Try to fix buildbot failure in VirtualFileSystem caused by r284129.

2016-10-14 Thread Benjamin Kramer via cfe-commits
bkramer added a comment.

I think the assertion is correct, there's something fishy with the inputs. The 
paths coming in should be absolute, and there should never be a .. at the start 
in a absolute path. This only fails on a single buildbot and doesn't reproduce 
anywhere else. @bruno any ideas?


https://reviews.llvm.org/D25597



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


[PATCH] D25603: [libc++] Fix modules build - Rework __refstring definition

2016-10-14 Thread Eric Fiselier via cfe-commits
EricWF created this revision.
EricWF added a reviewer: mclow.lists.
EricWF added a subscriber: cfe-commits.

`__libcpp_refstring` currently has two different definitions. First there is 
the complete definition in `<__refstring>` but there is also a second in  
``.  The historical reason for this split is because both libc++ and 
libc++abi need to see the inline definitions of __libcpp_refstrings methods, 
but the `` header doesn't.  However this is an ODR violation and 
breaks the modules build.

This patch fixes the issue by creating a single class definition in 
`` and changing `<__refstring>` to contain only the inline method 
definitions. This way both `libcxx/src/stdexcept.cpp` and 
`libcxxabi/src/stdexcept.cpp` see the same declaration in `` and 
definitions in `<__refstring>`


https://reviews.llvm.org/D25603

Files:
  include/__refstring
  include/stdexcept
  src/stdexcept.cpp

Index: src/stdexcept.cpp
===
--- src/stdexcept.cpp
+++ src/stdexcept.cpp
@@ -7,19 +7,20 @@
 //
 //===--===//
 
-#include "__refstring"
 #include "stdexcept"
 #include "new"
 #include "string"
 #include "system_error"
+#include "__refstring"
 
 /* For _LIBCPPABI_VERSION */
 #if defined(LIBCXX_BUILDING_LIBCXXABI) || defined(__APPLE__) || defined(LIBCXXRT)
 #include 
 #endif
 
 static_assert(sizeof(std::__libcpp_refstring) == sizeof(const char *), "");
 
+
 namespace std  // purposefully not using versioning namespace
 {
 
Index: include/stdexcept
===
--- include/stdexcept
+++ include/stdexcept
@@ -53,17 +53,23 @@
 #pragma GCC system_header
 #endif
 
-#ifndef _LIBCPP___REFSTRING
 _LIBCPP_BEGIN_NAMESPACE_STD
-class _LIBCPP_HIDDEN __libcpp_refstring {
-#ifdef __clang__
-const char *__imp_ __attribute__((__unused__)); // only clang emits a warning
-#else
-const char *__imp_;
-#endif
+
+class _LIBCPP_HIDDEN __libcpp_refstring
+{
+const char* __imp_;
+
+bool __uses_refcount() const;
+public:
+explicit __libcpp_refstring(const char* msg);
+__libcpp_refstring(const __libcpp_refstring& s) _NOEXCEPT;
+__libcpp_refstring& operator=(const __libcpp_refstring& s) _NOEXCEPT;
+~__libcpp_refstring();
+
+const char* c_str() const _NOEXCEPT {return __imp_;}
 };
+
 _LIBCPP_END_NAMESPACE_STD
-#endif
 
 namespace std  // purposefully not using versioning namespace
 {
Index: include/__refstring
===
--- include/__refstring
+++ include/__refstring
@@ -11,6 +11,7 @@
 #define _LIBCPP___REFSTRING
 
 #include <__config>
+#include 
 #include 
 #include 
 #ifdef __APPLE__
@@ -20,119 +21,106 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-class _LIBCPP_HIDDEN __libcpp_refstring
-{
-private:
-const char* str_;
+namespace __refstring_imp { namespace {
+typedef int count_t;
 
-typedef int count_t;
+struct _Rep_base {
+std::size_t len;
+std::size_t cap;
+count_t count;
+};
 
-struct _Rep_base
-{
-std::size_t len;
-std::size_t cap;
-count_t count;
-};
-
-static
-_Rep_base*
-rep_from_data(const char *data_) _NOEXCEPT
-{
-char *data = const_cast(data_);
-return reinterpret_cast<_Rep_base *>(data - sizeof(_Rep_base));
-}
-static
-char *
-data_from_rep(_Rep_base *rep) _NOEXCEPT
-{
-char *data = reinterpret_cast(rep);
-return data + sizeof(*rep);
-}
+inline _Rep_base* rep_from_data(const char *data_) noexcept {
+char *data = const_cast(data_);
+return reinterpret_cast<_Rep_base *>(data - sizeof(_Rep_base));
+}
 
-#ifdef __APPLE__
-static
-const char*
-compute_gcc_empty_string_storage() _NOEXCEPT
-{
-void* handle = dlopen("/usr/lib/libstdc++.6.dylib", RTLD_NOLOAD);
-if (handle == nullptr)
-return nullptr;
-void* sym = dlsym(handle, "_ZNSs4_Rep20_S_empty_rep_storageE");
-if (sym == nullptr)
-return nullptr;
-return data_from_rep(reinterpret_cast<_Rep_base *>(sym));
-}
-
-static
-const char*
-get_gcc_empty_string_storage() _NOEXCEPT
-{
-static const char* p = compute_gcc_empty_string_storage();
-return p;
-}
+inline char * data_from_rep(_Rep_base *rep) noexcept {
+char *data = reinterpret_cast(rep);
+return data + sizeof(*rep);
+}
 
-bool
-uses_refcount() const
-{
-return str_ != get_gcc_empty_string_storage();
-}
-#else
-bool
-uses_refcount() const
-{
-return true;
-}
+#if defined(__APPLE__)
+inline
+const char* compute_gcc_empty_string_storage() _NOEXCEPT
+{
+void* handle = dlopen("/usr/lib/libstdc++.6.dylib", RTLD_NOLOAD);
+if (handle == nullptr)
+return nullptr;
+void* sym = dlsym(handle, "_ZNSs4_Rep20_S_empty_rep_storageE");
+if (sym == nullptr)
+ 

[PATCH] D25604: Add support for Mageia Linux

2016-10-14 Thread Vassil Vassilev via cfe-commits
v.g.vassilev created this revision.
v.g.vassilev added reviewers: chandlerc, 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/D25604

Files:
  lib/Driver/ToolChains.cpp


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -1509,6 +1509,7 @@
   "x86_64-redhat-linux","x86_64-suse-linux",
   "x86_64-manbo-linux-gnu", "x86_64-linux-gnu",
   "x86_64-slackware-linux", "x86_64-linux-android",
+  "x86_64-mageia-linux-gnu",
   "x86_64-unknown-linux"};
   static const char *const X32LibDirs[] = {"/libx32"};
   static const char *const X86LibDirs[] = {"/lib32", "/lib"};
@@ -1517,6 +1518,7 @@
   "i386-linux-gnu",   "i386-redhat-linux6E",   "i686-redhat-linux",
   "i586-redhat-linux","i386-redhat-linux", "i586-suse-linux",
   "i486-slackware-linux", "i686-montavista-linux", "i686-linux-android",
+  "i586-mageia-linux-gnu",
   "i586-linux-gnu"};
 
   static const char *const MIPSLibDirs[] = {"/lib"};


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -1509,6 +1509,7 @@
   "x86_64-redhat-linux","x86_64-suse-linux",
   "x86_64-manbo-linux-gnu", "x86_64-linux-gnu",
   "x86_64-slackware-linux", "x86_64-linux-android",
+  "x86_64-mageia-linux-gnu",
   "x86_64-unknown-linux"};
   static const char *const X32LibDirs[] = {"/libx32"};
   static const char *const X86LibDirs[] = {"/lib32", "/lib"};
@@ -1517,6 +1518,7 @@
   "i386-linux-gnu",   "i386-redhat-linux6E",   "i686-redhat-linux",
   "i586-redhat-linux","i386-redhat-linux", "i586-suse-linux",
   "i486-slackware-linux", "i686-montavista-linux", "i686-linux-android",
+  "i586-mageia-linux-gnu",
   "i586-linux-gnu"};
 
   static const char *const MIPSLibDirs[] = {"/lib"};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25593: [libcxx] Build with -fvisibility-inlines-hidden -- Remove 20 inline definitions from the dylib

2016-10-14 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

I just spoke with Jonathan Wakely about this change, and he believes that it 
should be ABI safe.


https://reviews.llvm.org/D25593



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


[PATCH] D25598: [clang-move] Matching static class member more correctly.

2016-10-14 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284221: [clang-move] Matching static class member more 
correctly. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D25598?vs=74633&id=74650#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25598

Files:
  clang-tools-extra/trunk/clang-move/ClangMove.cpp
  clang-tools-extra/trunk/test/clang-move/Inputs/test.cpp
  clang-tools-extra/trunk/test/clang-move/Inputs/test.h
  clang-tools-extra/trunk/test/clang-move/move-class.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
@@ -24,6 +24,11 @@
 namespace move {
 namespace {
 
+// FIXME: Move to ASTMatchers.
+AST_MATCHER(VarDecl, isStaticDataMember) {
+  return Node.isStaticDataMember();
+}
+
 AST_MATCHER_P(Decl, hasOutermostEnclosingClass,
   ast_matchers::internal::Matcher, InnerMatcher) {
   const auto* Context = Node.getDeclContext();
@@ -365,7 +370,8 @@
   this);
 
   // Match static member variable definition of the moved class.
-  Finder->addMatcher(varDecl(InMovedClass, InOldCC, isDefinition())
+  Finder->addMatcher(varDecl(InMovedClass, InOldCC, isDefinition(),
+ isStaticDataMember())
  .bind("class_static_var_decl"),
  this);
 
Index: clang-tools-extra/trunk/test/clang-move/Inputs/test.h
===
--- clang-tools-extra/trunk/test/clang-move/Inputs/test.h
+++ clang-tools-extra/trunk/test/clang-move/Inputs/test.h
@@ -2,5 +2,6 @@
 class Foo {
 public:
   int f();
+  int f2(int a, int b);
 };
 } // namespace a
Index: clang-tools-extra/trunk/test/clang-move/Inputs/test.cpp
===
--- clang-tools-extra/trunk/test/clang-move/Inputs/test.cpp
+++ clang-tools-extra/trunk/test/clang-move/Inputs/test.cpp
@@ -5,4 +5,7 @@
 int Foo::f() {
   return 0;
 }
+int Foo::f2(int a, int b) {
+  return a + b;
+}
 } // namespace a
Index: clang-tools-extra/trunk/test/clang-move/move-class.cpp
===
--- clang-tools-extra/trunk/test/clang-move/move-class.cpp
+++ clang-tools-extra/trunk/test/clang-move/move-class.cpp
@@ -25,13 +25,15 @@
 // CHECK-NEW-TEST-H: class Foo {
 // CHECK-NEW-TEST-H: public:
 // CHECK-NEW-TEST-H:   int f();
+// CHECK-NEW-TEST-H:   int f2(int a, int b);
 // CHECK-NEW-TEST-H: };
 // CHECK-NEW-TEST-H: } // namespace a
 //
 // CHECK-NEW-TEST-CPP: #include "{{.*}}new_test.h"
 // CHECK-NEW-TEST-CPP: #include "test2.h"
 // CHECK-NEW-TEST-CPP: namespace a {
 // CHECK-NEW-TEST-CPP: int Foo::f() { return 0; }
+// CHECK-NEW-TEST-CPP: int Foo::f2(int a, int b) { return a + b; }
 // CHECK-NEW-TEST-CPP: } // namespace a
 //
 // CHECK-OLD-TEST-CPP: #include "test.h"


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
@@ -24,6 +24,11 @@
 namespace move {
 namespace {
 
+// FIXME: Move to ASTMatchers.
+AST_MATCHER(VarDecl, isStaticDataMember) {
+  return Node.isStaticDataMember();
+}
+
 AST_MATCHER_P(Decl, hasOutermostEnclosingClass,
   ast_matchers::internal::Matcher, InnerMatcher) {
   const auto* Context = Node.getDeclContext();
@@ -365,7 +370,8 @@
   this);
 
   // Match static member variable definition of the moved class.
-  Finder->addMatcher(varDecl(InMovedClass, InOldCC, isDefinition())
+  Finder->addMatcher(varDecl(InMovedClass, InOldCC, isDefinition(),
+ isStaticDataMember())
  .bind("class_static_var_decl"),
  this);
 
Index: clang-tools-extra/trunk/test/clang-move/Inputs/test.h
===
--- clang-tools-extra/trunk/test/clang-move/Inputs/test.h
+++ clang-tools-extra/trunk/test/clang-move/Inputs/test.h
@@ -2,5 +2,6 @@
 class Foo {
 public:
   int f();
+  int f2(int a, int b);
 };
 } // namespace a
Index: clang-tools-extra/trunk/test/clang-move/Inputs/test.cpp
===
--- clang-tools-extra/trunk/test/clang-move/Inputs/test.cpp
+++ clang-tools-extra/trunk/test/clang-move/Inputs/test.cpp
@@ -5,4 +5,7 @@
 int Foo::f() {
   return 0;
 }
+int Foo::f2(int a, int b) {
+  return a + b;
+}
 } // namespace a
Index: clang-tools-extra/trunk/test/clang-move/move-class.cpp
===
--- clang-tools-extra/trunk/test/clang-move/move-class.cpp
+++ clang-tools-extra/trunk/test/clang-move/move-class.cpp
@@ -25,13 +25,15 @@
 // CHECK-NEW-TEST-H: class Foo {
 // CHECK-NEW-TEST-H: pub

[clang-tools-extra] r284221 - [clang-move] Matching static class member more correctly.

2016-10-14 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Oct 14 05:07:58 2016
New Revision: 284221

URL: http://llvm.org/viewvc/llvm-project?rev=284221&view=rev
Log:
[clang-move] Matching static class member more correctly.

Reviewers: ioeric

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-move/ClangMove.cpp
clang-tools-extra/trunk/test/clang-move/Inputs/test.cpp
clang-tools-extra/trunk/test/clang-move/Inputs/test.h
clang-tools-extra/trunk/test/clang-move/move-class.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=284221&r1=284220&r2=284221&view=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Fri Oct 14 05:07:58 2016
@@ -24,6 +24,11 @@ namespace clang {
 namespace move {
 namespace {
 
+// FIXME: Move to ASTMatchers.
+AST_MATCHER(VarDecl, isStaticDataMember) {
+  return Node.isStaticDataMember();
+}
+
 AST_MATCHER_P(Decl, hasOutermostEnclosingClass,
   ast_matchers::internal::Matcher, InnerMatcher) {
   const auto* Context = Node.getDeclContext();
@@ -365,7 +370,8 @@ void ClangMoveTool::registerMatchers(ast
   this);
 
   // Match static member variable definition of the moved class.
-  Finder->addMatcher(varDecl(InMovedClass, InOldCC, isDefinition())
+  Finder->addMatcher(varDecl(InMovedClass, InOldCC, isDefinition(),
+ isStaticDataMember())
  .bind("class_static_var_decl"),
  this);
 

Modified: clang-tools-extra/trunk/test/clang-move/Inputs/test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/Inputs/test.cpp?rev=284221&r1=284220&r2=284221&view=diff
==
--- clang-tools-extra/trunk/test/clang-move/Inputs/test.cpp (original)
+++ clang-tools-extra/trunk/test/clang-move/Inputs/test.cpp Fri Oct 14 05:07:58 
2016
@@ -5,4 +5,7 @@ namespace a {
 int Foo::f() {
   return 0;
 }
+int Foo::f2(int a, int b) {
+  return a + b;
+}
 } // namespace a

Modified: clang-tools-extra/trunk/test/clang-move/Inputs/test.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/Inputs/test.h?rev=284221&r1=284220&r2=284221&view=diff
==
--- clang-tools-extra/trunk/test/clang-move/Inputs/test.h (original)
+++ clang-tools-extra/trunk/test/clang-move/Inputs/test.h Fri Oct 14 05:07:58 
2016
@@ -2,5 +2,6 @@ namespace a {
 class Foo {
 public:
   int f();
+  int f2(int a, int b);
 };
 } // namespace a

Modified: clang-tools-extra/trunk/test/clang-move/move-class.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/move-class.cpp?rev=284221&r1=284220&r2=284221&view=diff
==
--- clang-tools-extra/trunk/test/clang-move/move-class.cpp (original)
+++ clang-tools-extra/trunk/test/clang-move/move-class.cpp Fri Oct 14 05:07:58 
2016
@@ -25,6 +25,7 @@
 // CHECK-NEW-TEST-H: class Foo {
 // CHECK-NEW-TEST-H: public:
 // CHECK-NEW-TEST-H:   int f();
+// CHECK-NEW-TEST-H:   int f2(int a, int b);
 // CHECK-NEW-TEST-H: };
 // CHECK-NEW-TEST-H: } // namespace a
 //
@@ -32,6 +33,7 @@
 // CHECK-NEW-TEST-CPP: #include "test2.h"
 // CHECK-NEW-TEST-CPP: namespace a {
 // CHECK-NEW-TEST-CPP: int Foo::f() { return 0; }
+// CHECK-NEW-TEST-CPP: int Foo::f2(int a, int b) { return a + b; }
 // CHECK-NEW-TEST-CPP: } // namespace a
 //
 // CHECK-OLD-TEST-CPP: #include "test.h"


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


[PATCH] D25606: alpha.core.UnreachableCode - don't warn about unreachable code inside macro

2016-10-14 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki created this revision.
danielmarjamaki added reviewers: NoQ, dcoughlin.
danielmarjamaki added subscribers: cfe-commits, xazax.hun, zaks.anna, a.sidorin.
danielmarjamaki set the repository for this revision to rL LLVM.

This patch fixes false positives for such code:

  #define RETURN(X)  do { return; } while (0)
  
  void dostuff(void) {
RETURN(1); // no-warning
  }

The condition "0" in the macro is unreachable but that condition is there for a 
good reason.


Repository:
  rL LLVM

https://reviews.llvm.org/D25606

Files:
  lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
  test/Analysis/unreachable-code-path.c


Index: test/Analysis/unreachable-code-path.c
===
--- test/Analysis/unreachable-code-path.c
+++ test/Analysis/unreachable-code-path.c
@@ -206,3 +206,10 @@
   int x = inlineFunction(i);
   x && x < 10; // no-warning
 }
+
+// Don't warn in a macro
+#define RETURN(X)  do { return; } while (0)
+void macro(void) {
+  RETURN(1); // no-warning
+}
+
Index: lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
@@ -147,6 +147,8 @@
 PathDiagnosticLocation DL;
 SourceLocation SL;
 if (const Stmt *S = getUnreachableStmt(CB)) {
+  if (S->getLocStart().isMacroID())
+continue;
   SR = S->getSourceRange();
   DL = PathDiagnosticLocation::createBegin(S, B.getSourceManager(), LC);
   SL = DL.asLocation();


Index: test/Analysis/unreachable-code-path.c
===
--- test/Analysis/unreachable-code-path.c
+++ test/Analysis/unreachable-code-path.c
@@ -206,3 +206,10 @@
   int x = inlineFunction(i);
   x && x < 10; // no-warning
 }
+
+// Don't warn in a macro
+#define RETURN(X)  do { return; } while (0)
+void macro(void) {
+  RETURN(1); // no-warning
+}
+
Index: lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
@@ -147,6 +147,8 @@
 PathDiagnosticLocation DL;
 SourceLocation SL;
 if (const Stmt *S = getUnreachableStmt(CB)) {
+  if (S->getLocStart().isMacroID())
+continue;
   SR = S->getSourceRange();
   DL = PathDiagnosticLocation::createBegin(S, B.getSourceManager(), LC);
   SL = DL.asLocation();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r284222 - Try to fix windows bot file path style failure caused by r284219.

2016-10-14 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Fri Oct 14 05:10:26 2016
New Revision: 284222

URL: http://llvm.org/viewvc/llvm-project?rev=284222&view=rev
Log:
Try to fix windows bot file path style failure caused by r284219.

Modified:
cfe/trunk/unittests/Tooling/RefactoringTest.cpp

Modified: cfe/trunk/unittests/Tooling/RefactoringTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/RefactoringTest.cpp?rev=284222&r1=284221&r2=284222&view=diff
==
--- cfe/trunk/unittests/Tooling/RefactoringTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/RefactoringTest.cpp Fri Oct 14 05:10:26 2016
@@ -974,20 +974,38 @@ TEST_F(MergeReplacementsTest, Overlappin
 
 TEST(DeduplicateByFileTest, LeaveLeadingDotDot) {
   std::map FileToReplaces;
+#if !defined(LLVM_ON_WIN32)
   FileToReplaces["../../a/b/.././c.h"] = Replacements();
   FileToReplaces["../../a/c.h"] = Replacements();
+#else
+  FileToReplaces["..\\..\\a\\b\\..\\.\\c.h"] = Replacements();
+  FileToReplaces["..\\..\\a\\c.h"] = Replacements();
+#endif
   FileToReplaces = groupReplacementsByFile(FileToReplaces);
   EXPECT_EQ(1u, FileToReplaces.size());
+#if !defined(LLVM_ON_WIN32)
   EXPECT_EQ("../../a/c.h", FileToReplaces.begin()->first);
+#else
+  EXPECT_EQ("..\\..\\a\\c.h", FileToReplaces.begin()->first);
+#endif
 }
 
 TEST(DeduplicateByFileTest, RemoveDotSlash) {
   std::map FileToReplaces;
+#if !defined(LLVM_ON_WIN32)
   FileToReplaces["./a/b/.././c.h"] = Replacements();
   FileToReplaces["a/c.h"] = Replacements();
+#else
+  FileToReplaces[".\\a\\b\\..\\.\\c.h"] = Replacements();
+  FileToReplaces["a\\c.h"] = Replacements();
+#endif
   FileToReplaces = groupReplacementsByFile(FileToReplaces);
   EXPECT_EQ(1u, FileToReplaces.size());
+#if !defined(LLVM_ON_WIN32)
   EXPECT_EQ("a/c.h", FileToReplaces.begin()->first);
+#else
+  EXPECT_EQ("a\\c.h", FileToReplaces.begin()->first);
+#endif
 }
 
 } // end namespace tooling


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


[libcxx] r284225 - Work around Clang driver segfault when --coverage is used with -c and /dev/null

2016-10-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Oct 14 05:30:33 2016
New Revision: 284225

URL: http://llvm.org/viewvc/llvm-project?rev=284225&view=rev
Log:
Work around Clang driver segfault when --coverage is used with -c and /dev/null

Modified:
libcxx/trunk/test/libcxx/compiler.py

Modified: libcxx/trunk/test/libcxx/compiler.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/compiler.py?rev=284225&r1=284224&r2=284225&view=diff
==
--- libcxx/trunk/test/libcxx/compiler.py (original)
+++ libcxx/trunk/test/libcxx/compiler.py Fri Oct 14 05:30:33 2016
@@ -188,7 +188,7 @@ class CXXCompiler(object):
 # Add -Werror to ensure that an unrecognized flag causes a non-zero
 # exit code. -Werror is supported on all known compiler types.
 if self.type is not None:
-flags += ['-Werror']
+flags += ['-Werror', '-fsyntax-only']
 cmd, out, err, rc = self.compile(os.devnull, out=os.devnull,
  flags=flags)
 return rc == 0


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


[PATCH] D25568: [libcxx] [cmake] Use -print-libgcc-file-name option to find compiler runtime

2016-10-14 Thread Eric Fiselier via cfe-commits
EricWF requested changes to this revision.
EricWF added a comment.
This revision now requires changes to proceed.

This doesn't seem right seeing as `print-libgcc_file-name`  prints the 
`libgcc.a` path, and we were previously linking `libgcc_s`.


https://reviews.llvm.org/D25568



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


[PATCH] D25431: [libcxx] [CMake] Build Solaris compat as separate C lib, to avoid -std= issues

2016-10-14 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Why not just compile the sources files as C++ by changing their extensions? 
This change seems all kinds of wrong because we're throwing away *all* of our 
flags, including things like `-m32` or `-target `.


https://reviews.llvm.org/D25431



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


[PATCH] D25608: [libclang] Make tests for python bindings pass on Windows.

2016-10-14 Thread Igor Kudrin via cfe-commits
ikudrin created this revision.
ikudrin added reviewers: hansonw, compnerd, indygreg, eliben.
ikudrin added a subscriber: cfe-commits.

Please note that this patch fixes only Windows-related issues. 
https://reviews.llvm.org/D25470 is required to pass all the tests.


https://reviews.llvm.org/D25608

Files:
  bindings/python/tests/cindex/INPUTS/windows/compile_commands.json
  bindings/python/tests/cindex/test_cdb.py
  bindings/python/tests/cindex/test_cursor.py
  bindings/python/tests/cindex/test_translation_unit.py

Index: bindings/python/tests/cindex/test_translation_unit.py
===
--- bindings/python/tests/cindex/test_translation_unit.py
+++ bindings/python/tests/cindex/test_translation_unit.py
@@ -94,7 +94,9 @@
 
 Returns the filename it was saved to.
 """
-_, path = tempfile.mkstemp()
+fd, path = tempfile.mkstemp()
+# On Windows, if a file is open it cannot be replaced or deleted.
+os.close(fd)
 tu.save(path)
 
 return path
@@ -142,6 +144,7 @@
 
 # Just in case there is an open file descriptor somewhere.
 del tu2
+del foo
 
 os.unlink(path)
 
Index: bindings/python/tests/cindex/test_cursor.py
===
--- bindings/python/tests/cindex/test_cursor.py
+++ bindings/python/tests/cindex/test_cursor.py
@@ -295,7 +295,7 @@
 
 assert enum.kind == CursorKind.ENUM_DECL
 enum_type = enum.enum_type
-assert enum_type.kind == TypeKind.UINT
+assert enum_type.kind in (TypeKind.UINT, TypeKind.INT)
 
 def test_enum_type_cpp():
 tu = get_tu('enum TEST : long long { FOO=1, BAR=2 };', lang="cpp")
@@ -451,4 +451,4 @@
 # all valid manglings.
 # [c-index-test handles this by running the source through clang, emitting
 #  an AST file and running libclang on that AST file]
-assert foo.mangled_name in ('_Z3fooii', '__Z3fooii', '?foo@@YAHHH')
+assert foo.mangled_name in ('_Z3fooii', '__Z3fooii', '?foo@@YAHHH@Z')
Index: bindings/python/tests/cindex/test_cdb.py
===
--- bindings/python/tests/cindex/test_cdb.py
+++ bindings/python/tests/cindex/test_cdb.py
@@ -5,7 +5,20 @@
 import os
 import gc
 
-kInputsDir = os.path.join(os.path.dirname(__file__), 'INPUTS')
+if os.name == 'nt':
+kInputsDir = os.path.join(os.path.dirname(__file__), 'INPUTS', 'windows')
+kProjectFile = 'C:\\home\\john.doe\\MyProject\\project.cpp'
+kProject2File = 'C:\\home\\john.doe\\MyProject\\project2.cpp'
+kProjectDir = 'C:/home/john.doe/MyProject'
+kProjectADir = 'C:/home/john.doe/MyProjectA'
+kProjectBDir = 'C:/home/john.doe/MyProjectB'
+else:
+kInputsDir = os.path.join(os.path.dirname(__file__), 'INPUTS')
+kProjectFile = '/home/john.doe/MyProject/project.cpp'
+kProject2File = '/home/john.doe/MyProject/project2.cpp'
+kProjectDir = '/home/john.doe/MyProject'
+kProjectADir = '/home/john.doe/MyProjectA'
+kProjectBDir = '/home/john.doe/MyProjectB'
 
 def test_create_fail():
 """Check we fail loading a database with an assertion"""
@@ -29,27 +42,27 @@
 def test_lookup_succeed():
 """Check we get some results if the file exists in the db"""
 cdb = CompilationDatabase.fromDirectory(kInputsDir)
-cmds = cdb.getCompileCommands('/home/john.doe/MyProject/project.cpp')
+cmds = cdb.getCompileCommands(kProjectFile)
 assert len(cmds) != 0
 
 def test_all_compilecommand():
 """Check we get all results from the db"""
 cdb = CompilationDatabase.fromDirectory(kInputsDir)
 cmds = cdb.getAllCompileCommands()
 assert len(cmds) == 3
 expected = [
-{ 'wd': '/home/john.doe/MyProject',
-  'file': '/home/john.doe/MyProject/project.cpp',
+{ 'wd': kProjectDir,
+  'file': kProjectFile,
   'line': ['clang++', '-o', 'project.o', '-c',
-   '/home/john.doe/MyProject/project.cpp']},
-{ 'wd': '/home/john.doe/MyProjectA',
-  'file': '/home/john.doe/MyProject/project2.cpp',
+   kProjectFile]},
+{ 'wd': kProjectADir,
+  'file': kProject2File,
   'line': ['clang++', '-o', 'project2.o', '-c',
-   '/home/john.doe/MyProject/project2.cpp']},
-{ 'wd': '/home/john.doe/MyProjectB',
-  'file': '/home/john.doe/MyProject/project2.cpp',
+   kProject2File]},
+{ 'wd': kProjectBDir,
+  'file': kProject2File,
   'line': ['clang++', '-DFEATURE=1', '-o', 'project2-feature.o', '-c',
-   '/home/john.doe/MyProject/project2.cpp']},
+   kProject2File]},
 
 ]
 for i in range(len(cmds)):
@@ -61,28 +74,28 @@
 def test_1_compilecommand():
 """Check file with single compile command"""
 cdb = CompilationDatabase.fromDirectory(kInputsDir)
-file = '/home/john.doe/MyProject/project.cpp'
+file = kProjectFile
 cmds = cdb.getCompileComma

[PATCH] D23524: [libc++abi] Fix backtrace_test.pass.cpp failure seemingly caused by inlining differences.

2016-10-14 Thread Eric Fiselier via cfe-commits
EricWF abandoned this revision.
EricWF added a comment.

Another fix was committed.


https://reviews.llvm.org/D23524



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


r284228 - Removed duplicate header include

2016-10-14 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Fri Oct 14 06:48:10 2016
New Revision: 284228

URL: http://llvm.org/viewvc/llvm-project?rev=284228&view=rev
Log:
Removed duplicate header include

Reviewers: ioeric

Subscribers: klimek

Patch by Krasimir Georgiev!

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

Modified:
cfe/trunk/lib/Format/SortJavaScriptImports.cpp

Modified: cfe/trunk/lib/Format/SortJavaScriptImports.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/SortJavaScriptImports.cpp?rev=284228&r1=284227&r2=284228&view=diff
==
--- cfe/trunk/lib/Format/SortJavaScriptImports.cpp (original)
+++ cfe/trunk/lib/Format/SortJavaScriptImports.cpp Fri Oct 14 06:48:10 2016
@@ -1,4 +1,4 @@
-//===--- SortJavaScriptImports.h - Sort ES6 Imports -*- C++ 
-*-===//
+//===--- SortJavaScriptImports.cpp - Sort ES6 Imports ---*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -13,7 +13,6 @@
 
//===--===//
 
 #include "SortJavaScriptImports.h"
-#include "SortJavaScriptImports.h"
 #include "TokenAnalyzer.h"
 #include "TokenAnnotator.h"
 #include "clang/Basic/Diagnostic.h"


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


[PATCH] D25610: [clang-move] Add header guard for the new header.

2016-10-14 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: ioeric.
hokein added a subscriber: cfe-commits.

The header guard generated by clang-move isn't always a perfect
style, just avoid getting the header included multiple times during
compiling period.

Also, we can use llvm-Header-guard clang-tidy check to correct the guard
automatically.


https://reviews.llvm.org/D25610

Files:
  clang-move/ClangMove.cpp
  test/clang-move/move-class.cpp
  test/clang-move/move-multiple-classes.cpp
  unittests/clang-move/ClangMoveTests.cpp

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -123,7 +123,9 @@
   "} // namespace b\n"
   "} // namespace a\n";
 
-const char ExpectedNewHeader[] = "namespace a {\n"
+const char ExpectedNewHeader[] = "#ifndef NEW_FOO_H\n"
+ "#define NEW_FOO_H\n"
+ "namespace a {\n"
  "class C1; // test\n"
  "namespace b {\n"
  "// This is a Foo class\n"
@@ -138,7 +140,8 @@
  "  static int b;\n"
  "}; // abc\n"
  "} // namespace b\n"
- "} // namespace a\n";
+ "} // namespace a\n"
+ "#endif // NEW_FOO_H\n";
 
 const char ExpectedNewCC[] = "namespace a {\n"
  "namespace b {\n"
Index: test/clang-move/move-multiple-classes.cpp
===
--- test/clang-move/move-multiple-classes.cpp
+++ test/clang-move/move-multiple-classes.cpp
@@ -24,6 +24,8 @@
 // CHECK-OLD-TEST-CPP: }
 // CHECK-OLD-TEST-CPP: } // namespace c
 
+// CHECK-NEW-TEST-H: #ifndef {{.*}}NEW_MULTIPLE_CLASS_TEST_H
+// CHECK-NEW-TEST-H: #define {{.*}}NEW_MULTIPLE_CLASS_TEST_H
 // CHECK-NEW-TEST-H: namespace a {
 // CHECK-NEW-TEST-H: class Move1 {
 // CHECK-NEW-TEST-H: public:
@@ -54,6 +56,7 @@
 // CHECK-NEW-TEST-H:   static int a;
 // CHECK-NEW-TEST-H: };
 // CHECK-NEW-TEST-H: } // namespace c
+// CHECK-NEW-TEST-H: #endif // {{.*}}NEW_MULTIPLE_CLASS_TEST_H
 
 // CHECK-NEW-TEST-CPP: #include "{{.*}}new_multiple_class_test.h"
 // CHECK-NEW-TEST-CPP: namespace a {
Index: test/clang-move/move-class.cpp
===
--- test/clang-move/move-class.cpp
+++ test/clang-move/move-class.cpp
@@ -21,13 +21,17 @@
 // RUN: FileCheck -input-file=%T/clang-move/src/test.cpp -check-prefix=CHECK-OLD-TEST-CPP %s
 // RUN: FileCheck -input-file=%T/clang-move/include/test.h %s -implicit-check-not='{{namespace.*}}'
 //
+//
+// CHECK-NEW-TEST-H: #ifndef {{.*}}CLANG_MOVE_NEW_TEST_H
+// CHECK-NEW-TEST-H: #define {{.*}}CLANG_MOVE_NEW_TEST_H
 // CHECK-NEW-TEST-H: namespace a {
 // CHECK-NEW-TEST-H: class Foo {
 // CHECK-NEW-TEST-H: public:
 // CHECK-NEW-TEST-H:   int f();
 // CHECK-NEW-TEST-H:   int f2(int a, int b);
 // CHECK-NEW-TEST-H: };
 // CHECK-NEW-TEST-H: } // namespace a
+// CHECK-NEW-TEST-H: #endif // {{.*}}CLANG_MOVE_NEW_TEST_H
 //
 // CHECK-NEW-TEST-CPP: #include "{{.*}}new_test.h"
 // CHECK-NEW-TEST-CPP: #include "test2.h"
Index: clang-move/ClangMove.cpp
===
--- clang-move/ClangMove.cpp
+++ clang-move/ClangMove.cpp
@@ -249,8 +249,22 @@
 clang::tooling::Replacements
 createInsertedReplacements(const std::vector &Includes,
const std::vector &Decls,
-   llvm::StringRef FileName) {
+   llvm::StringRef FileName,
+   bool IsHeader = false) {
   clang::tooling::Replacements InsertedReplacements;
+  std::string GuardName(FileName);
+  if (IsHeader) {
+std::replace(GuardName.begin(), GuardName.end(), '/', '_');
+std::replace(GuardName.begin(), GuardName.end(), '.', '_');
+std::replace(GuardName.begin(), GuardName.end(), '-', '_');
+
+GuardName = StringRef(GuardName).upper();
+std::string HeaderGuard = "#ifndef " + GuardName + "\n";
+HeaderGuard += "#define " + GuardName + "\n";
+clang::tooling::Replacement HeaderGuardInclude(FileName, 0, 0,
+   HeaderGuard);
+addOrMergeReplacement(HeaderGuardInclude, &InsertedReplacements);
+  }
 
   // Add #Includes.
   std::string AllIncludesString;
@@ -308,6 +322,12 @@
 FileName, 0, 0, "} // namespace " + NS + "\n");
 addOrMergeReplacement(InsertedReplacement, &InsertedReplacements);
   }
+
+  if (IsHeader) {
+clang::tooling::Replacement HeaderGuardEnd(FileName, 0, 0,
+   "#endif // " + GuardName + "\n");
+addOrMergeReplacement(HeaderGuardE

[PATCH] D25568: [libcxx] [cmake] Use -print-libgcc-file-name option to find compiler runtime

2016-10-14 Thread Michał Górny via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D25568#570222, @EricWF wrote:

> This doesn't seem right seeing as `print-libgcc_file-name`  prints the 
> `libgcc.a` path, and we were previously linking `libgcc_s`.


Do you have any other solution in mind? There is no switch to print the shared 
library path. Should I modify it to detect whether the printed path matches 
`libgcc.a` and use `libgcc_s` in that case?

Just to be clear, since libgcc_s is the shared version of libgcc (+ libgcc_eh), 
this is mostly a matter of replacing dynamic linking with static. However, it 
doesn't matter much since in most of the cases no library function is actually 
used. From my experience, throughout 3.8.1 .. HEAD, no builtin functions were 
needed on amd64 and only one (__udiv3, if I recall correctly) was needed on 
32-bit x86. In this case, I dare say using the static library may actually be 
less problematic as it makes libc++ less dependent on compiler runtime.

Of course, on the other hand we have the unwinder library which still can be 
`gcc_s` and there is no easy way to solve this dependency.


https://reviews.llvm.org/D25568



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


[PATCH] D25431: [libcxx] [CMake] Build Solaris compat as separate C lib, to avoid -std= issues

2016-10-14 Thread Michał Górny via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D25431#570227, @EricWF wrote:

> Why not just compile the sources files as C++ by changing their extensions? 
> This change seems all kinds of wrong because we're throwing away *all* of our 
> flags, including things like `-m32` or `-target `.


That's another option. Having a lot of other problems on Solaris at the time, 
using a separate library was simpler to test. I will try this alternative today.


https://reviews.llvm.org/D25431



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


[PATCH] D25610: [clang-move] Add header guard for the new header.

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

Lg




Comment at: clang-move/ClangMove.cpp:264
+HeaderGuard += "#define " + GuardName + "\n";
+clang::tooling::Replacement HeaderGuardInclude(FileName, 0, 0,
+   HeaderGuard);

Might not quite related to this patch:

Considering how `tooling::Replacements::add(...)` is implemented now, it's 
quite inefficient to use `addOrMergeReplacement` in you case since almost all 
replacements will conflict, which would require expensive conflict-resolving 
merge. I think it would be cleaner and easier if you just concatenate all 
`Decl`s and create a single insertion replacement instead of keeping merging 
replacements at offset 0.


https://reviews.llvm.org/D25610



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


[PATCH] D25612: [clang-tidy] Add additional diagnostic to misc-use-after-move

2016-10-14 Thread Martin Böhme via cfe-commits
mboehme created this revision.
mboehme added a reviewer: hokein.
mboehme added a subscriber: cfe-commits.

This adds a diagnostic to the misc-use-after-move check that is output when the
use happens on a later loop iteration than the move, for example:

  A a;
  for (int i = 0; i < 10; ++i) {
a.foo();
std::move(a);
  }

This situation can be confusing to users because, in terms of source code
location, the use is above the move. This can make it look as if the warning
is a false positive, particularly if the loop is long but the use and move are
close together.

In cases like these, misc-use-after-move will now output an additional
diagnostic:

  a.cpp:393:7: note: the use happens in a later loop iteration than the move


https://reviews.llvm.org/D25612

Files:
  clang-tidy/misc/UseAfterMoveCheck.cpp
  test/clang-tidy/misc-use-after-move.cpp


Index: test/clang-tidy/misc-use-after-move.cpp
===
--- test/clang-tidy/misc-use-after-move.cpp
+++ test/clang-tidy/misc-use-after-move.cpp
@@ -133,6 +133,7 @@
   std::move(a);
   // CHECK-MESSAGES: [[@LINE-1]]:17: warning: 'a' used after it was moved
   // CHECK-MESSAGES: [[@LINE-2]]:7: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE-3]]:17: note: the use happens in a later loop
 }
   }
 }
@@ -391,7 +392,8 @@
 for (int i = 0; i < 10; ++i) {
   a.foo();
   // CHECK-MESSAGES: [[@LINE-1]]:7: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE+1]]:7: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE+2]]:7: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE-3]]:7: note: the use happens in a later loop
   std::move(a);
 }
   }
@@ -586,7 +588,7 @@
   }
 }
 
-// Passing the object to a function through a non-const pointer or refernce
+// Passing the object to a function through a non-const pointer or reference
 // counts as a re-initialization.
 void passByNonConstPointer(A *);
 void passByNonConstReference(A &);
Index: clang-tidy/misc/UseAfterMoveCheck.cpp
===
--- clang-tidy/misc/UseAfterMoveCheck.cpp
+++ clang-tidy/misc/UseAfterMoveCheck.cpp
@@ -562,18 +562,24 @@
 }
 
 static void emitDiagnostic(const Expr *MovingCall,
-   const ValueDecl *MovedVariable,
+   const DeclRefExpr *MoveArg,
const UseAfterMove &Use, ClangTidyCheck *Check,
ASTContext *Context) {
-  Check->diag(Use.DeclRef->getExprLoc(), "'%0' used after it was moved")
-  << MovedVariable->getName();
-  Check->diag(MovingCall->getExprLoc(), "move occurred here",
-  DiagnosticIDs::Note);
+  SourceLocation UseLoc = Use.DeclRef->getExprLoc();
+  SourceLocation MoveLoc = MovingCall->getExprLoc();
+
+  Check->diag(UseLoc, "'%0' used after it was moved")
+  << MoveArg->getDecl()->getName();
+  Check->diag(MoveLoc, "move occurred here", DiagnosticIDs::Note);
   if (Use.EvaluationOrderUndefined) {
-Check->diag(Use.DeclRef->getExprLoc(),
+Check->diag(UseLoc,
 "the use and move are unsequenced, i.e. there is no guarantee "
 "about the order in which they are evaluated",
 DiagnosticIDs::Note);
+  } else if(UseLoc < MoveLoc || Use.DeclRef == MoveArg) {
+Check->diag(UseLoc,
+"the use happens in a later loop iteration than the move",
+DiagnosticIDs::Note);
   }
 }
 
@@ -625,17 +631,15 @@
   else
 return;
 
-  const ValueDecl *MovedVariable = Arg->getDecl();
-
   // Ignore the std::move if the variable that was passed to it isn't a local
   // variable.
   if (!Arg->getDecl()->getDeclContext()->isFunctionOrMethod())
 return;
 
   UseAfterMoveFinder finder(Result.Context);
   UseAfterMove Use;
-  if (finder.find(FunctionBody, MovingCall, MovedVariable, &Use))
-emitDiagnostic(MovingCall, MovedVariable, Use, this, Result.Context);
+  if (finder.find(FunctionBody, MovingCall, Arg->getDecl(), &Use))
+emitDiagnostic(MovingCall, Arg, Use, this, Result.Context);
 }
 
 } // namespace misc


Index: test/clang-tidy/misc-use-after-move.cpp
===
--- test/clang-tidy/misc-use-after-move.cpp
+++ test/clang-tidy/misc-use-after-move.cpp
@@ -133,6 +133,7 @@
   std::move(a);
   // CHECK-MESSAGES: [[@LINE-1]]:17: warning: 'a' used after it was moved
   // CHECK-MESSAGES: [[@LINE-2]]:7: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE-3]]:17: note: the use happens in a later loop
 }
   }
 }
@@ -391,7 +392,8 @@
 for (int i = 0; i < 10; ++i) {
   a.foo();
   // CHECK-MESSAGES: [[@LINE-1]]:7: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE+1]]:7: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE+2]]:7: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE-3]]:7: note: the use

r284229 - Fix for PR30632: Name mangling issue.

2016-10-14 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Oct 14 07:43:59 2016
New Revision: 284229

URL: http://llvm.org/viewvc/llvm-project?rev=284229&view=rev
Log:
Fix for PR30632: Name mangling issue.

There was a bug in the implementation of captured statements. If it has
a lambda expression in it and the same lambda expression is used outside
the captured region, clang produced an error:
```
error: definition with same mangled name as another definition
```
Here is an example:
```
struct A {
 template 
 void g(const L&) { }
};

template
void f() {
  {
A().g([](){});
  }
  A().g([](){});
}

int main() {
  f();
}
```

Error report:
```
main.cpp:3:10: error: definition with same mangled name as another
definition
void g(const L&) { }
 ^
main.cpp:3:10: note: previous definition is here
```
Patch fixes this bug.

Modified:
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/test/CodeGenCXX/captured-statements.cpp
cfe/trunk/test/OpenMP/target_map_codegen.cpp

Modified: cfe/trunk/lib/Sema/SemaLambda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLambda.cpp?rev=284229&r1=284228&r2=284229&view=diff
==
--- cfe/trunk/lib/Sema/SemaLambda.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLambda.cpp Fri Oct 14 07:43:59 2016
@@ -311,18 +311,20 @@ Sema::getCurrentMangleNumberContext(cons
   bool IsInNonspecializedTemplate =
 !ActiveTemplateInstantiations.empty() || CurContext->isDependentContext();
   switch (Kind) {
-  case Normal:
+  case Normal: {
 //  -- the bodies of non-exported nonspecialized template functions
 //  -- the bodies of inline functions
+auto *CD = dyn_cast(CurContext);
 if ((IsInNonspecializedTemplate &&
  !(ManglingContextDecl && isa(ManglingContextDecl))) ||
-isInInlineFunction(CurContext)) {
+isInInlineFunction(CurContext) || CD) {
   ManglingContextDecl = nullptr;
-  return &Context.getManglingNumberContext(DC);
+  return &Context.getManglingNumberContext(CD ? CD->getParent() : DC);
 }
 
 ManglingContextDecl = nullptr;
 return nullptr;
+  }
 
   case StaticDataMember:
 //  -- the initializers of nonspecialized static members of template 
classes

Modified: cfe/trunk/test/CodeGenCXX/captured-statements.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/captured-statements.cpp?rev=284229&r1=284228&r2=284229&view=diff
==
--- cfe/trunk/test/CodeGenCXX/captured-statements.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/captured-statements.cpp Fri Oct 14 07:43:59 2016
@@ -78,6 +78,7 @@ void test3(int x) {
   {
 x = [=]() { return x + 1; } ();
   }
+  x = [=]() { return x + 1; }();
 
   // CHECK-3: %[[Capture:struct\.anon[\.0-9]*]] = type { i32* }
 

Modified: cfe/trunk/test/OpenMP/target_map_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_map_codegen.cpp?rev=284229&r1=284228&r2=284229&view=diff
==
--- cfe/trunk/test/OpenMP/target_map_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/target_map_codegen.cpp Fri Oct 14 07:43:59 2016
@@ -4104,7 +4104,9 @@ int explicit_maps_with_inner_lambda(int
 // CK25: [[VAL1:%.+]] = load i32*, i32** [[VALADDR]],
 // CK25: [[VALADDR1:%.+]] = getelementptr inbounds [[CA01]], [[CA01]]* 
[[CA:%[^,]+]], i32 0, i32 0
 // CK25: store i32* [[VAL1]], i32** [[VALADDR1]],
-// CK25: call void {{.*}}[[LAMBDA]]{{.*}}([[CA01]]* [[CA]])
+// CK25: call void {{.*}}[[LAMBDA2:@.+]]{{.*}}([[CA01]]* [[CA]])
+
+// CK25: define {{.+}}[[LAMBDA2]]
 #endif
 
///==///
 // RUN: %clang_cc1 -DCK26 -std=c++11 -verify -fopenmp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple 
powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix 
CK26 --check-prefix CK26-64


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


[PATCH] D25612: [clang-tidy] Add additional diagnostic to misc-use-after-move

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

The code looks good.




Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:579
 DiagnosticIDs::Note);
+  } else if(UseLoc < MoveLoc || Use.DeclRef == MoveArg) {
+Check->diag(UseLoc,

A space after `if`.


https://reviews.llvm.org/D25612



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


[PATCH] D25431: [libcxx] Convert Solaris support library to C++ to fix -std=c++11 build

2016-10-14 Thread Michał Górny via cfe-commits
mgorny retitled this revision from "[libcxx] [CMake] Build Solaris compat as 
separate C lib, to avoid -std= issues" to "[libcxx] Convert Solaris support 
library to C++ to fix -std=c++11 build
".
mgorny updated the summary for this revision.
mgorny updated this revision to Diff 74666.
mgorny added a comment.
Herald added a subscriber: modocache.

Ok, here's an updated patch that changes the code to C++. Since C++ is more 
strict than C, I also had to remove some conflicting declarations -- and while 
at it, I updated the header to avoid any collisions and redundancy on SunOS 
5.11 (OpenIndiana). I don't have access to any older system, and considering 
that the support for SunOS in clang is still incomplete, I don't think it 
important to support older systems.


https://reviews.llvm.org/D25431

Files:
  include/support/solaris/xlocale.h
  lib/CMakeLists.txt
  src/support/solaris/mbsnrtowcs.inc
  src/support/solaris/wcsnrtombs.inc
  src/support/solaris/xlocale.c
  src/support/solaris/xlocale.cpp

Index: src/support/solaris/xlocale.cpp
===
--- src/support/solaris/xlocale.cpp
+++ src/support/solaris/xlocale.cpp
@@ -12,20 +12,15 @@
 #include "support/solaris/xlocale.h"
 #include 
 #include 
+#include 
 #include 
 
 
-int isxdigit_l(int __c, locale_t __l) {
-return isxdigit(__c);
-}
-
-int iswxdigit_l(wchar_t __c, locale_t __l) {
-return isxdigit(__c);
-}
+extern "C" {
 
 // FIXME: This disregards the locale, which is Very Wrong
 #define vsnprintf_l(__s, __n, __l, __format, __va)  \
-vsnprintf(__s, __n, __format, __va) 
+vsnprintf(__s, __n, __format, __va)
 
 int snprintf_l(char *__s, size_t __n, locale_t __l, const char *__format, ...)
 {
@@ -54,13 +49,10 @@
   return __res;
 }
 
-size_t mbrtowc_l(wchar_t *__pwc, const char *__pmb,
- size_t __max, mbstate_t *__ps, locale_t __loc) {
-  return mbrtowc(__pwc, __pmb, __max, __ps);
-}
-
-struct lconv *localeconv_l(locale_t __l) {
+lconv *localeconv_l(locale_t __l) {
   return localeconv();
 }
 
+};
+
 #endif // __sun__
Index: src/support/solaris/wcsnrtombs.inc
===
--- src/support/solaris/wcsnrtombs.inc
+++ /dev/null
@@ -1,93 +0,0 @@
-/*-
- * Copyright (c) 2002-2004 Tim J. Robbins.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *notice, this list of conditions and the following disclaimer in the
- *documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-
-size_t
-wcsnrtombs_l(char * __restrict dst, const wchar_t ** __restrict src,
-size_t nwc, size_t len, mbstate_t * __restrict ps, locale_t loc)
-{
-  FIX_LOCALE(loc);
-  mbstate_t mbsbak;
-  char buf[MB_CUR_MAX_L(loc)];
-  const wchar_t *s;
-  size_t nbytes;
-  size_t nb;
-
-  s = *src;
-  nbytes = 0;
-
-  if (dst == NULL) {
-while (nwc-- > 0) {
-  if ((nb = wcrtomb_l(buf, *s, ps, loc)) == (size_t)-1)
-/* Invalid character - wcrtomb() sets errno. */
-return ((size_t)-1);
-  else if (*s == L'\0')
-return (nbytes + nb - 1);
-  s++;
-  nbytes += nb;
-}
-return (nbytes);
-  }
-
-  while (len > 0 && nwc-- > 0) {
-if (len > (size_t)MB_CUR_MAX_L(loc)) {
-  /* Enough space to translate in-place. */
-  if ((nb = wcrtomb_l(dst, *s, ps, loc)) == (size_t)-1) {
-*src = s;
-return ((size_t)-1);
-  }
-} else {
-  /*
-   * May not be enough space; use temp. buffer.
-   *
-   * We need to save a copy of the conversion state
-   * here so we can restore it if the multibyte
-   * character is too long for the buffer.
-   */
-  mbsbak = *ps;
-  if ((nb = wcrtomb_l(buf, *s, ps, loc)) == (size_t)-1) {
-*src = s;
-return ((size_t)-1);
-  }
-  if (nb > (int)len) {
-/* MB sequence for character won't fit. 

[libcxx] r284230 - Disable Modules when building the libc++ sources.

2016-10-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Oct 14 07:56:52 2016
New Revision: 284230

URL: http://llvm.org/viewvc/llvm-project?rev=284230&view=rev
Log:
Disable Modules when building the libc++ sources.

Libc++ will not build with modules enabled. In order to support an in-tree
libc++ when LLVM_ENABLE_MODULES is ON we need to explicitly disable the feature.

Unfortunately the libc++ sources are fundamentally non-modular. For example
iostream.cpp defines cout, cerr, wout, ... as char buffers instead of streams
in order to better control initialization/destruction. Not shockingly Clang
diagnoses this. Many other sources files define _LIBCPP_BUILDING_FOO macros to
provide definitions for normally inline symbols (See bind.cpp). Finally The
current module.map prohibits using  in C++11 so we can't build
strstream.cpp.

I think I can fix most of these issues but until then just disable modules.

Modified:
libcxx/trunk/CMakeLists.txt

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=284230&r1=284229&r2=284230&view=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Fri Oct 14 07:56:52 2016
@@ -411,6 +411,16 @@ endif()
 # Feature flags ===
 define_if(MSVC -D_CRT_SECURE_NO_WARNINGS)
 
+# Modules flags ===
+# FIXME The libc++ sources are fundamentally non-modular. They need special
+# versions of the headers in order to provide C++03 and legacy ABI definitions.
+# NOTE: The public headers can be used with modules in all other contexts.
+if (LLVM_ENABLE_MODULES)
+  # Ignore that the rest of the modules flags are now unused.
+  add_compile_flags_if_supported(-Wno-unused-command-line-argument)
+  add_compile_flags(-fno-modules)
+endif()
+
 # Sanitizer flags =
 
 # Configure for sanitizers. If LIBCXX_STANDALONE_BUILD then we have to do


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


[PATCH] D25610: [clang-move] Add header guard for the new header.

2016-10-14 Thread Haojian Wu via cfe-commits
hokein added inline comments.



Comment at: clang-move/ClangMove.cpp:264
+HeaderGuard += "#define " + GuardName + "\n";
+clang::tooling::Replacement HeaderGuardInclude(FileName, 0, 0,
+   HeaderGuard);

ioeric wrote:
> Might not quite related to this patch:
> 
> Considering how `tooling::Replacements::add(...)` is implemented now, it's 
> quite inefficient to use `addOrMergeReplacement` in you case since almost all 
> replacements will conflict, which would require expensive conflict-resolving 
> merge. I think it would be cleaner and easier if you just concatenate all 
> `Decl`s and create a single insertion replacement instead of keeping merging 
> replacements at offset 0.
Good point. Yeah, the function only inserts new code to the new file. Make 
sense to only construct a single Replacement of the concatenated string. Will 
do in a follow-up.


https://reviews.llvm.org/D25610



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


[libcxx] r284232 - [libcxx] Do not declare the thread api when __external_threading is present

2016-10-14 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Fri Oct 14 08:00:07 2016
New Revision: 284232

URL: http://llvm.org/viewvc/llvm-project?rev=284232&view=rev
Log:
[libcxx] Do not declare the thread api when __external_threading is present

This fixes a small omission where even when __external_threading is provided,
we attempt to declare a pthread based threading API. Instead, we should leave
out everything for the __external_threading header to take care of.

The __threading_support header provides a proof-of-concept externally threaded
libc++ variant when _LIBCPP_HAS_THREAD_API_EXTERNAL is defined. But if the
__external_threading header is present, we should exclude all of that POC stuff.

Reviewers: EricWF

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

Modified:
libcxx/trunk/include/__threading_support

Modified: libcxx/trunk/include/__threading_support
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=284232&r1=284231&r2=284232&view=diff
==
--- libcxx/trunk/include/__threading_support (original)
+++ libcxx/trunk/include/__threading_support Fri Oct 14 08:00:07 2016
@@ -25,17 +25,16 @@
 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 #if !defined(__clang__) && (_GNUC_VER < 500)
 #include <__external_threading>
-#define _LIBCPP_EXTERNAL_THREADING
+#define _LIBCPP_HAS_EXTERNAL_THREADING_HEADER
 #elif !defined(__has_include) || __has_include(<__external_threading>)
 #include <__external_threading>
-#define _LIBCPP_EXTERNAL_THREADING
+#define _LIBCPP_HAS_EXTERNAL_THREADING_HEADER
 #endif
 #endif
 
-#if !defined(_LIBCPP_EXTERNAL_THREADING)
+#if !defined(_LIBCPP_HAS_EXTERNAL_THREADING_HEADER)
 #include 
 #include 
-#endif
 
 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 #define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS
@@ -242,6 +241,8 @@ void __libcpp_tls_set(__libcpp_tls_key _
 
 _LIBCPP_END_NAMESPACE_STD
 
+#endif // !_LIBCPP_HAS_EXTERNAL_THREADING_HEADER
+
 #endif // _LIBCPP_HAS_NO_THREADS
 
 #endif // _LIBCPP_THREADING_SUPPORT


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


[PATCH] D25468: [libcxx] Do not declare the thread api when __external_threading is present

2016-10-14 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284232: [libcxx] Do not declare the thread api when 
__external_threading is present (authored by asiri).

Changed prior to commit:
  https://reviews.llvm.org/D25468?vs=74234&id=74668#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25468

Files:
  libcxx/trunk/include/__threading_support


Index: libcxx/trunk/include/__threading_support
===
--- libcxx/trunk/include/__threading_support
+++ libcxx/trunk/include/__threading_support
@@ -25,17 +25,16 @@
 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 #if !defined(__clang__) && (_GNUC_VER < 500)
 #include <__external_threading>
-#define _LIBCPP_EXTERNAL_THREADING
+#define _LIBCPP_HAS_EXTERNAL_THREADING_HEADER
 #elif !defined(__has_include) || __has_include(<__external_threading>)
 #include <__external_threading>
-#define _LIBCPP_EXTERNAL_THREADING
+#define _LIBCPP_HAS_EXTERNAL_THREADING_HEADER
 #endif
 #endif
 
-#if !defined(_LIBCPP_EXTERNAL_THREADING)
+#if !defined(_LIBCPP_HAS_EXTERNAL_THREADING_HEADER)
 #include 
 #include 
-#endif
 
 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 #define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS
@@ -242,6 +241,8 @@
 
 _LIBCPP_END_NAMESPACE_STD
 
+#endif // !_LIBCPP_HAS_EXTERNAL_THREADING_HEADER
+
 #endif // _LIBCPP_HAS_NO_THREADS
 
 #endif // _LIBCPP_THREADING_SUPPORT


Index: libcxx/trunk/include/__threading_support
===
--- libcxx/trunk/include/__threading_support
+++ libcxx/trunk/include/__threading_support
@@ -25,17 +25,16 @@
 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 #if !defined(__clang__) && (_GNUC_VER < 500)
 #include <__external_threading>
-#define _LIBCPP_EXTERNAL_THREADING
+#define _LIBCPP_HAS_EXTERNAL_THREADING_HEADER
 #elif !defined(__has_include) || __has_include(<__external_threading>)
 #include <__external_threading>
-#define _LIBCPP_EXTERNAL_THREADING
+#define _LIBCPP_HAS_EXTERNAL_THREADING_HEADER
 #endif
 #endif
 
-#if !defined(_LIBCPP_EXTERNAL_THREADING)
+#if !defined(_LIBCPP_HAS_EXTERNAL_THREADING_HEADER)
 #include 
 #include 
-#endif
 
 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 #define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS
@@ -242,6 +241,8 @@
 
 _LIBCPP_END_NAMESPACE_STD
 
+#endif // !_LIBCPP_HAS_EXTERNAL_THREADING_HEADER
+
 #endif // _LIBCPP_HAS_NO_THREADS
 
 #endif // _LIBCPP_THREADING_SUPPORT
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25600: [ASTMatcher] Add isStaticDataMember matcher for varDecl.

2016-10-14 Thread Aaron Ballman via cfe-commits
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added inline comments.



Comment at: include/clang/ASTMatchers/ASTMatchers.h:3005
+/// \endcode
+AST_MATCHER(VarDecl, isStaticDataMember) {
+  return Node.isStaticDataMember();

How does this differ from the existing matcher `hasStaticStorageDuration()` 
over a `fieldDecl()`?


https://reviews.llvm.org/D25600



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


[clang-tools-extra] r284233 - [clang-move] Add header guard for the new header.

2016-10-14 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Oct 14 08:01:36 2016
New Revision: 284233

URL: http://llvm.org/viewvc/llvm-project?rev=284233&view=rev
Log:
[clang-move] Add header guard for the new header.

Summary:
The header guard generated by clang-move isn't always a perfect
style, just avoid getting the header included multiple times during
compiling period.

Also, we can use llvm-Header-guard clang-tidy check to correct the guard
automatically.

Reviewers: ioeric

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-move/ClangMove.cpp
clang-tools-extra/trunk/test/clang-move/move-class.cpp
clang-tools-extra/trunk/test/clang-move/move-multiple-classes.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=284233&r1=284232&r2=284233&view=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Fri Oct 14 08:01:36 2016
@@ -249,8 +249,22 @@ std::vector GetNamespaces(c
 clang::tooling::Replacements
 createInsertedReplacements(const std::vector &Includes,
const std::vector &Decls,
-   llvm::StringRef FileName) {
+   llvm::StringRef FileName,
+   bool IsHeader = false) {
   clang::tooling::Replacements InsertedReplacements;
+  std::string GuardName(FileName);
+  if (IsHeader) {
+std::replace(GuardName.begin(), GuardName.end(), '/', '_');
+std::replace(GuardName.begin(), GuardName.end(), '.', '_');
+std::replace(GuardName.begin(), GuardName.end(), '-', '_');
+
+GuardName = StringRef(GuardName).upper();
+std::string HeaderGuard = "#ifndef " + GuardName + "\n";
+HeaderGuard += "#define " + GuardName + "\n";
+clang::tooling::Replacement HeaderGuardInclude(FileName, 0, 0,
+   HeaderGuard);
+addOrMergeReplacement(HeaderGuardInclude, &InsertedReplacements);
+  }
 
   // Add #Includes.
   std::string AllIncludesString;
@@ -308,6 +322,12 @@ createInsertedReplacements(const std::ve
 FileName, 0, 0, "} // namespace " + NS + "\n");
 addOrMergeReplacement(InsertedReplacement, &InsertedReplacements);
   }
+
+  if (IsHeader) {
+clang::tooling::Replacement HeaderGuardEnd(FileName, 0, 0,
+   "#endif // " + GuardName + 
"\n");
+addOrMergeReplacement(HeaderGuardEnd, &InsertedReplacements);
+  }
   return InsertedReplacements;
 }
 
@@ -500,7 +520,7 @@ void ClangMoveTool::moveClassDefinitionT
 
   if (!Spec.NewHeader.empty())
 FileToReplacements[Spec.NewHeader] = createInsertedReplacements(
-HeaderIncludes, NewHeaderDecls, Spec.NewHeader);
+HeaderIncludes, NewHeaderDecls, Spec.NewHeader, /*IsHeader=*/true);
   if (!Spec.NewCC.empty())
 FileToReplacements[Spec.NewCC] =
 createInsertedReplacements(CCIncludes, NewCCDecls, Spec.NewCC);

Modified: clang-tools-extra/trunk/test/clang-move/move-class.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/move-class.cpp?rev=284233&r1=284232&r2=284233&view=diff
==
--- clang-tools-extra/trunk/test/clang-move/move-class.cpp (original)
+++ clang-tools-extra/trunk/test/clang-move/move-class.cpp Fri Oct 14 08:01:36 
2016
@@ -21,6 +21,9 @@
 // RUN: FileCheck -input-file=%T/clang-move/src/test.cpp 
-check-prefix=CHECK-OLD-TEST-CPP %s
 // RUN: FileCheck -input-file=%T/clang-move/include/test.h %s 
-implicit-check-not='{{namespace.*}}'
 //
+//
+// CHECK-NEW-TEST-H: #ifndef {{.*}}CLANG_MOVE_NEW_TEST_H
+// CHECK-NEW-TEST-H: #define {{.*}}CLANG_MOVE_NEW_TEST_H
 // CHECK-NEW-TEST-H: namespace a {
 // CHECK-NEW-TEST-H: class Foo {
 // CHECK-NEW-TEST-H: public:
@@ -28,6 +31,7 @@
 // CHECK-NEW-TEST-H:   int f2(int a, int b);
 // CHECK-NEW-TEST-H: };
 // CHECK-NEW-TEST-H: } // namespace a
+// CHECK-NEW-TEST-H: #endif // {{.*}}CLANG_MOVE_NEW_TEST_H
 //
 // CHECK-NEW-TEST-CPP: #include "{{.*}}new_test.h"
 // CHECK-NEW-TEST-CPP: #include "test2.h"

Modified: clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp?rev=284233&r1=284232&r2=284233&view=diff
==
--- clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp (original)
+++ clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp Fri Oct 
14 08:01:36 2016
@@ -24,6 +24,8 @@
 // CHECK-OLD-TEST-CPP: }
 // CHECK-OLD-TEST-CPP: } // namespace c
 
+// CHECK-NEW-TEST-H: #ifndef {{.*}}NEW_MULTIPLE_CLASS_TEST_

[PATCH] D25612: [clang-tidy] Add additional diagnostic to misc-use-after-move

2016-10-14 Thread Martin Böhme via cfe-commits
mboehme updated this revision to Diff 74671.
mboehme added a comment.

- Responses to reviewer comments


https://reviews.llvm.org/D25612

Files:
  clang-tidy/misc/UseAfterMoveCheck.cpp
  test/clang-tidy/misc-use-after-move.cpp


Index: test/clang-tidy/misc-use-after-move.cpp
===
--- test/clang-tidy/misc-use-after-move.cpp
+++ test/clang-tidy/misc-use-after-move.cpp
@@ -133,6 +133,7 @@
   std::move(a);
   // CHECK-MESSAGES: [[@LINE-1]]:17: warning: 'a' used after it was moved
   // CHECK-MESSAGES: [[@LINE-2]]:7: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE-3]]:17: note: the use happens in a later loop
 }
   }
 }
@@ -391,7 +392,8 @@
 for (int i = 0; i < 10; ++i) {
   a.foo();
   // CHECK-MESSAGES: [[@LINE-1]]:7: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE+1]]:7: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE+2]]:7: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE-3]]:7: note: the use happens in a later loop
   std::move(a);
 }
   }
@@ -586,7 +588,7 @@
   }
 }
 
-// Passing the object to a function through a non-const pointer or refernce
+// Passing the object to a function through a non-const pointer or reference
 // counts as a re-initialization.
 void passByNonConstPointer(A *);
 void passByNonConstReference(A &);
Index: clang-tidy/misc/UseAfterMoveCheck.cpp
===
--- clang-tidy/misc/UseAfterMoveCheck.cpp
+++ clang-tidy/misc/UseAfterMoveCheck.cpp
@@ -562,18 +562,24 @@
 }
 
 static void emitDiagnostic(const Expr *MovingCall,
-   const ValueDecl *MovedVariable,
+   const DeclRefExpr *MoveArg,
const UseAfterMove &Use, ClangTidyCheck *Check,
ASTContext *Context) {
-  Check->diag(Use.DeclRef->getExprLoc(), "'%0' used after it was moved")
-  << MovedVariable->getName();
-  Check->diag(MovingCall->getExprLoc(), "move occurred here",
-  DiagnosticIDs::Note);
+  SourceLocation UseLoc = Use.DeclRef->getExprLoc();
+  SourceLocation MoveLoc = MovingCall->getExprLoc();
+
+  Check->diag(UseLoc, "'%0' used after it was moved")
+  << MoveArg->getDecl()->getName();
+  Check->diag(MoveLoc, "move occurred here", DiagnosticIDs::Note);
   if (Use.EvaluationOrderUndefined) {
-Check->diag(Use.DeclRef->getExprLoc(),
+Check->diag(UseLoc,
 "the use and move are unsequenced, i.e. there is no guarantee "
 "about the order in which they are evaluated",
 DiagnosticIDs::Note);
+  } else if (UseLoc < MoveLoc || Use.DeclRef == MoveArg) {
+Check->diag(UseLoc,
+"the use happens in a later loop iteration than the move",
+DiagnosticIDs::Note);
   }
 }
 
@@ -625,17 +631,15 @@
   else
 return;
 
-  const ValueDecl *MovedVariable = Arg->getDecl();
-
   // Ignore the std::move if the variable that was passed to it isn't a local
   // variable.
   if (!Arg->getDecl()->getDeclContext()->isFunctionOrMethod())
 return;
 
   UseAfterMoveFinder finder(Result.Context);
   UseAfterMove Use;
-  if (finder.find(FunctionBody, MovingCall, MovedVariable, &Use))
-emitDiagnostic(MovingCall, MovedVariable, Use, this, Result.Context);
+  if (finder.find(FunctionBody, MovingCall, Arg->getDecl(), &Use))
+emitDiagnostic(MovingCall, Arg, Use, this, Result.Context);
 }
 
 } // namespace misc


Index: test/clang-tidy/misc-use-after-move.cpp
===
--- test/clang-tidy/misc-use-after-move.cpp
+++ test/clang-tidy/misc-use-after-move.cpp
@@ -133,6 +133,7 @@
   std::move(a);
   // CHECK-MESSAGES: [[@LINE-1]]:17: warning: 'a' used after it was moved
   // CHECK-MESSAGES: [[@LINE-2]]:7: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE-3]]:17: note: the use happens in a later loop
 }
   }
 }
@@ -391,7 +392,8 @@
 for (int i = 0; i < 10; ++i) {
   a.foo();
   // CHECK-MESSAGES: [[@LINE-1]]:7: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE+1]]:7: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE+2]]:7: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE-3]]:7: note: the use happens in a later loop
   std::move(a);
 }
   }
@@ -586,7 +588,7 @@
   }
 }
 
-// Passing the object to a function through a non-const pointer or refernce
+// Passing the object to a function through a non-const pointer or reference
 // counts as a re-initialization.
 void passByNonConstPointer(A *);
 void passByNonConstReference(A &);
Index: clang-tidy/misc/UseAfterMoveCheck.cpp
===
--- clang-tidy/misc/UseAfterMoveCheck.cpp
+++ clang-tidy/misc/UseAfterMoveCheck.cpp
@@ -562,18 +562,24 @@
 }
 
 static void emitDiagnostic(const Expr *MovingCall,
-

[PATCH] D25610: [clang-move] Add header guard for the new header.

2016-10-14 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284233: [clang-move] Add header guard for the new header. 
(authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D25610?vs=74663&id=74669#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25610

Files:
  clang-tools-extra/trunk/clang-move/ClangMove.cpp
  clang-tools-extra/trunk/test/clang-move/move-class.cpp
  clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp
  clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp

Index: clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
===
--- clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
+++ clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
@@ -123,7 +123,9 @@
   "} // namespace b\n"
   "} // namespace a\n";
 
-const char ExpectedNewHeader[] = "namespace a {\n"
+const char ExpectedNewHeader[] = "#ifndef NEW_FOO_H\n"
+ "#define NEW_FOO_H\n"
+ "namespace a {\n"
  "class C1; // test\n"
  "namespace b {\n"
  "// This is a Foo class\n"
@@ -138,7 +140,8 @@
  "  static int b;\n"
  "}; // abc\n"
  "} // namespace b\n"
- "} // namespace a\n";
+ "} // namespace a\n"
+ "#endif // NEW_FOO_H\n";
 
 const char ExpectedNewCC[] = "namespace a {\n"
  "namespace b {\n"
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
@@ -249,8 +249,22 @@
 clang::tooling::Replacements
 createInsertedReplacements(const std::vector &Includes,
const std::vector &Decls,
-   llvm::StringRef FileName) {
+   llvm::StringRef FileName,
+   bool IsHeader = false) {
   clang::tooling::Replacements InsertedReplacements;
+  std::string GuardName(FileName);
+  if (IsHeader) {
+std::replace(GuardName.begin(), GuardName.end(), '/', '_');
+std::replace(GuardName.begin(), GuardName.end(), '.', '_');
+std::replace(GuardName.begin(), GuardName.end(), '-', '_');
+
+GuardName = StringRef(GuardName).upper();
+std::string HeaderGuard = "#ifndef " + GuardName + "\n";
+HeaderGuard += "#define " + GuardName + "\n";
+clang::tooling::Replacement HeaderGuardInclude(FileName, 0, 0,
+   HeaderGuard);
+addOrMergeReplacement(HeaderGuardInclude, &InsertedReplacements);
+  }
 
   // Add #Includes.
   std::string AllIncludesString;
@@ -308,6 +322,12 @@
 FileName, 0, 0, "} // namespace " + NS + "\n");
 addOrMergeReplacement(InsertedReplacement, &InsertedReplacements);
   }
+
+  if (IsHeader) {
+clang::tooling::Replacement HeaderGuardEnd(FileName, 0, 0,
+   "#endif // " + GuardName + "\n");
+addOrMergeReplacement(HeaderGuardEnd, &InsertedReplacements);
+  }
   return InsertedReplacements;
 }
 
@@ -500,7 +520,7 @@
 
   if (!Spec.NewHeader.empty())
 FileToReplacements[Spec.NewHeader] = createInsertedReplacements(
-HeaderIncludes, NewHeaderDecls, Spec.NewHeader);
+HeaderIncludes, NewHeaderDecls, Spec.NewHeader, /*IsHeader=*/true);
   if (!Spec.NewCC.empty())
 FileToReplacements[Spec.NewCC] =
 createInsertedReplacements(CCIncludes, NewCCDecls, Spec.NewCC);
Index: clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp
===
--- clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp
+++ clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp
@@ -24,6 +24,8 @@
 // CHECK-OLD-TEST-CPP: }
 // CHECK-OLD-TEST-CPP: } // namespace c
 
+// CHECK-NEW-TEST-H: #ifndef {{.*}}NEW_MULTIPLE_CLASS_TEST_H
+// CHECK-NEW-TEST-H: #define {{.*}}NEW_MULTIPLE_CLASS_TEST_H
 // CHECK-NEW-TEST-H: namespace a {
 // CHECK-NEW-TEST-H: class Move1 {
 // CHECK-NEW-TEST-H: public:
@@ -54,6 +56,7 @@
 // CHECK-NEW-TEST-H:   static int a;
 // CHECK-NEW-TEST-H: };
 // CHECK-NEW-TEST-H: } // namespace c
+// CHECK-NEW-TEST-H: #endif // {{.*}}NEW_MULTIPLE_CLASS_TEST_H
 
 // CHECK-NEW-TEST-CPP: #include "{{.*}}new_multiple_class_test.h"
 // CHECK-NEW-TEST-CPP: namespace a {
Index: clang-tools-extra/trunk/test/clang-move/move-class.cpp
===
--- clang-tools-extra/trunk/test/clang-move/move-class.cpp
+++ clang-too

[PATCH] D25613: [clang-move] Don't overuse Replacements::add.

2016-10-14 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: ioeric.
hokein added a subscriber: cfe-commits.

https://reviews.llvm.org/D25613

Files:
  clang-move/ClangMove.cpp


Index: clang-move/ClangMove.cpp
===
--- clang-move/ClangMove.cpp
+++ clang-move/ClangMove.cpp
@@ -251,32 +251,24 @@
const std::vector &Decls,
llvm::StringRef FileName,
bool IsHeader = false) {
-  clang::tooling::Replacements InsertedReplacements;
+  std::string NewCode;
   std::string GuardName(FileName);
   if (IsHeader) {
 std::replace(GuardName.begin(), GuardName.end(), '/', '_');
 std::replace(GuardName.begin(), GuardName.end(), '.', '_');
 std::replace(GuardName.begin(), GuardName.end(), '-', '_');
 
 GuardName = StringRef(GuardName).upper();
-std::string HeaderGuard = "#ifndef " + GuardName + "\n";
-HeaderGuard += "#define " + GuardName + "\n";
-clang::tooling::Replacement HeaderGuardInclude(FileName, 0, 0,
-   HeaderGuard);
-addOrMergeReplacement(HeaderGuardInclude, &InsertedReplacements);
+NewCode += "#ifndef " + GuardName + "\n";
+NewCode += "#define " + GuardName + "\n";
   }
 
   // Add #Includes.
-  std::string AllIncludesString;
-  // FIXME: Add header guard.
   for (const auto &Include : Includes)
-AllIncludesString += Include;
+NewCode += Include;
 
-  if (!AllIncludesString.empty()) {
-clang::tooling::Replacement InsertInclude(FileName, 0, 0,
-  AllIncludesString + "\n");
-addOrMergeReplacement(InsertInclude, &InsertedReplacements);
-  }
+  if (!Includes.empty())
+NewCode += "\n";
 
   // Add moved class definition and its related declarations. All declarations
   // in same namespace are grouped together.
@@ -299,36 +291,23 @@
 for (auto It = CurrentNamespaces.rbegin(); RemainingSize > 0;
  --RemainingSize, ++It) {
   assert(It < CurrentNamespaces.rend());
-  auto code = "} // namespace " + *It + "\n";
-  clang::tooling::Replacement InsertedReplacement(FileName, 0, 0, code);
-  addOrMergeReplacement(InsertedReplacement, &InsertedReplacements);
+  NewCode += "} // namespace " + *It + "\n";
 }
 while (DeclIt != DeclNamespaces.end()) {
-  clang::tooling::Replacement InsertedReplacement(
-  FileName, 0, 0, "namespace " + *DeclIt + " {\n");
-  addOrMergeReplacement(InsertedReplacement, &InsertedReplacements);
+  NewCode += "namespace " + *DeclIt + " {\n";
   ++DeclIt;
 }
-
-clang::tooling::Replacement InsertedReplacement(
-FileName, 0, 0, getDeclarationSourceText(MovedDecl.Decl, 
MovedDecl.SM));
-addOrMergeReplacement(InsertedReplacement, &InsertedReplacements);
-
+NewCode += getDeclarationSourceText(MovedDecl.Decl, MovedDecl.SM);
 CurrentNamespaces = std::move(NextNamespaces);
   }
   std::reverse(CurrentNamespaces.begin(), CurrentNamespaces.end());
-  for (const auto &NS : CurrentNamespaces) {
-clang::tooling::Replacement InsertedReplacement(
-FileName, 0, 0, "} // namespace " + NS + "\n");
-addOrMergeReplacement(InsertedReplacement, &InsertedReplacements);
-  }
+  for (const auto &NS : CurrentNamespaces)
+NewCode += "} // namespace " + NS + "\n";
 
-  if (IsHeader) {
-clang::tooling::Replacement HeaderGuardEnd(FileName, 0, 0,
-   "#endif // " + GuardName + 
"\n");
-addOrMergeReplacement(HeaderGuardEnd, &InsertedReplacements);
-  }
-  return InsertedReplacements;
+  if (IsHeader)
+NewCode += "#endif // " + GuardName + "\n";
+  return clang::tooling::Replacements(
+  clang::tooling::Replacement(FileName, 0, 0, NewCode));
 }
 
 } // namespace


Index: clang-move/ClangMove.cpp
===
--- clang-move/ClangMove.cpp
+++ clang-move/ClangMove.cpp
@@ -251,32 +251,24 @@
const std::vector &Decls,
llvm::StringRef FileName,
bool IsHeader = false) {
-  clang::tooling::Replacements InsertedReplacements;
+  std::string NewCode;
   std::string GuardName(FileName);
   if (IsHeader) {
 std::replace(GuardName.begin(), GuardName.end(), '/', '_');
 std::replace(GuardName.begin(), GuardName.end(), '.', '_');
 std::replace(GuardName.begin(), GuardName.end(), '-', '_');
 
 GuardName = StringRef(GuardName).upper();
-std::string HeaderGuard = "#ifndef " + GuardName + "\n";
-HeaderGuard += "#define " + GuardName + "\n";
-clang::tooling::Replacement HeaderGuardInclude(FileName, 0, 0,
-   HeaderGuard);
-addOrMergeReplacement(HeaderGuardInclude, &InsertedReplacements);
+NewCode += "#ifndef " + GuardName + "\n";
+NewCode += "#define " + GuardName + "\n";
   }
 
  

[clang-tools-extra] r284235 - [clang-tidy] Add additional diagnostic to misc-use-after-move

2016-10-14 Thread Martin Bohme via cfe-commits
Author: mboehme
Date: Fri Oct 14 08:23:39 2016
New Revision: 284235

URL: http://llvm.org/viewvc/llvm-project?rev=284235&view=rev
Log:
[clang-tidy] Add additional diagnostic to misc-use-after-move

Summary:
This adds a diagnostic to the misc-use-after-move check that is output when the
use happens on a later loop iteration than the move, for example:

A a;
for (int i = 0; i < 10; ++i) {
  a.foo();
  std::move(a);
}

This situation can be confusing to users because, in terms of source code
location, the use is above the move. This can make it look as if the warning
is a false positive, particularly if the loop is long but the use and move are
close together.

In cases like these, misc-use-after-move will now output an additional
diagnostic:

  a.cpp:393:7: note: the use happens in a later loop iteration than the move

Reviewers: hokein

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp?rev=284235&r1=284234&r2=284235&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp Fri Oct 14 
08:23:39 2016
@@ -562,18 +562,24 @@ void UseAfterMoveFinder::getReinits(
 }
 
 static void emitDiagnostic(const Expr *MovingCall,
-   const ValueDecl *MovedVariable,
+   const DeclRefExpr *MoveArg,
const UseAfterMove &Use, ClangTidyCheck *Check,
ASTContext *Context) {
-  Check->diag(Use.DeclRef->getExprLoc(), "'%0' used after it was moved")
-  << MovedVariable->getName();
-  Check->diag(MovingCall->getExprLoc(), "move occurred here",
-  DiagnosticIDs::Note);
+  SourceLocation UseLoc = Use.DeclRef->getExprLoc();
+  SourceLocation MoveLoc = MovingCall->getExprLoc();
+
+  Check->diag(UseLoc, "'%0' used after it was moved")
+  << MoveArg->getDecl()->getName();
+  Check->diag(MoveLoc, "move occurred here", DiagnosticIDs::Note);
   if (Use.EvaluationOrderUndefined) {
-Check->diag(Use.DeclRef->getExprLoc(),
+Check->diag(UseLoc,
 "the use and move are unsequenced, i.e. there is no guarantee "
 "about the order in which they are evaluated",
 DiagnosticIDs::Note);
+  } else if (UseLoc < MoveLoc || Use.DeclRef == MoveArg) {
+Check->diag(UseLoc,
+"the use happens in a later loop iteration than the move",
+DiagnosticIDs::Note);
   }
 }
 
@@ -625,8 +631,6 @@ void UseAfterMoveCheck::check(const Matc
   else
 return;
 
-  const ValueDecl *MovedVariable = Arg->getDecl();
-
   // Ignore the std::move if the variable that was passed to it isn't a local
   // variable.
   if (!Arg->getDecl()->getDeclContext()->isFunctionOrMethod())
@@ -634,8 +638,8 @@ void UseAfterMoveCheck::check(const Matc
 
   UseAfterMoveFinder finder(Result.Context);
   UseAfterMove Use;
-  if (finder.find(FunctionBody, MovingCall, MovedVariable, &Use))
-emitDiagnostic(MovingCall, MovedVariable, Use, this, Result.Context);
+  if (finder.find(FunctionBody, MovingCall, Arg->getDecl(), &Use))
+emitDiagnostic(MovingCall, Arg, Use, this, Result.Context);
 }
 
 } // namespace misc

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp?rev=284235&r1=284234&r2=284235&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp Fri Oct 14 
08:23:39 2016
@@ -133,6 +133,7 @@ void moveAfterMove() {
   std::move(a);
   // CHECK-MESSAGES: [[@LINE-1]]:17: warning: 'a' used after it was moved
   // CHECK-MESSAGES: [[@LINE-2]]:7: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE-3]]:17: note: the use happens in a later loop
 }
   }
 }
@@ -391,7 +392,8 @@ void useAndMoveInLoop() {
 for (int i = 0; i < 10; ++i) {
   a.foo();
   // CHECK-MESSAGES: [[@LINE-1]]:7: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE+1]]:7: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE+2]]:7: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE-3]]:7: note: the use happens in a later loop
   std::move(a);
 }
   }
@@ -586,7 +588,7 @@ void assignments(int i) {
   }
 }
 
-// Passing the object to a function through a non-const pointer or refernce
+// Passing the object to a functio

[PATCH] D25612: [clang-tidy] Add additional diagnostic to misc-use-after-move

2016-10-14 Thread Martin Böhme via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284235: [clang-tidy] Add additional diagnostic to 
misc-use-after-move (authored by mboehme).

Changed prior to commit:
  https://reviews.llvm.org/D25612?vs=74671&id=74673#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25612

Files:
  clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp


Index: clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp
@@ -562,18 +562,24 @@
 }
 
 static void emitDiagnostic(const Expr *MovingCall,
-   const ValueDecl *MovedVariable,
+   const DeclRefExpr *MoveArg,
const UseAfterMove &Use, ClangTidyCheck *Check,
ASTContext *Context) {
-  Check->diag(Use.DeclRef->getExprLoc(), "'%0' used after it was moved")
-  << MovedVariable->getName();
-  Check->diag(MovingCall->getExprLoc(), "move occurred here",
-  DiagnosticIDs::Note);
+  SourceLocation UseLoc = Use.DeclRef->getExprLoc();
+  SourceLocation MoveLoc = MovingCall->getExprLoc();
+
+  Check->diag(UseLoc, "'%0' used after it was moved")
+  << MoveArg->getDecl()->getName();
+  Check->diag(MoveLoc, "move occurred here", DiagnosticIDs::Note);
   if (Use.EvaluationOrderUndefined) {
-Check->diag(Use.DeclRef->getExprLoc(),
+Check->diag(UseLoc,
 "the use and move are unsequenced, i.e. there is no guarantee "
 "about the order in which they are evaluated",
 DiagnosticIDs::Note);
+  } else if (UseLoc < MoveLoc || Use.DeclRef == MoveArg) {
+Check->diag(UseLoc,
+"the use happens in a later loop iteration than the move",
+DiagnosticIDs::Note);
   }
 }
 
@@ -625,17 +631,15 @@
   else
 return;
 
-  const ValueDecl *MovedVariable = Arg->getDecl();
-
   // Ignore the std::move if the variable that was passed to it isn't a local
   // variable.
   if (!Arg->getDecl()->getDeclContext()->isFunctionOrMethod())
 return;
 
   UseAfterMoveFinder finder(Result.Context);
   UseAfterMove Use;
-  if (finder.find(FunctionBody, MovingCall, MovedVariable, &Use))
-emitDiagnostic(MovingCall, MovedVariable, Use, this, Result.Context);
+  if (finder.find(FunctionBody, MovingCall, Arg->getDecl(), &Use))
+emitDiagnostic(MovingCall, Arg, Use, this, Result.Context);
 }
 
 } // namespace misc
Index: clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp
@@ -133,6 +133,7 @@
   std::move(a);
   // CHECK-MESSAGES: [[@LINE-1]]:17: warning: 'a' used after it was moved
   // CHECK-MESSAGES: [[@LINE-2]]:7: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE-3]]:17: note: the use happens in a later loop
 }
   }
 }
@@ -391,7 +392,8 @@
 for (int i = 0; i < 10; ++i) {
   a.foo();
   // CHECK-MESSAGES: [[@LINE-1]]:7: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE+1]]:7: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE+2]]:7: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE-3]]:7: note: the use happens in a later loop
   std::move(a);
 }
   }
@@ -586,7 +588,7 @@
   }
 }
 
-// Passing the object to a function through a non-const pointer or refernce
+// Passing the object to a function through a non-const pointer or reference
 // counts as a re-initialization.
 void passByNonConstPointer(A *);
 void passByNonConstReference(A &);


Index: clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp
@@ -562,18 +562,24 @@
 }
 
 static void emitDiagnostic(const Expr *MovingCall,
-   const ValueDecl *MovedVariable,
+   const DeclRefExpr *MoveArg,
const UseAfterMove &Use, ClangTidyCheck *Check,
ASTContext *Context) {
-  Check->diag(Use.DeclRef->getExprLoc(), "'%0' used after it was moved")
-  << MovedVariable->getName();
-  Check->diag(MovingCall->getExprLoc(), "move occurred here",
-  DiagnosticIDs::Note);
+  SourceLocation UseLoc = Use.DeclRef->getExprLoc();
+  SourceLocation MoveLoc = MovingCall->getExprLoc();
+
+  Check->diag(UseLoc, "'%0' used after it was moved")
+  << MoveArg->getDecl()->getName();
+  Check->diag(MoveLoc, "move occurred here", DiagnosticIDs::Note);

[PATCH] D25613: [clang-move] Don't overuse Replacements::add.

2016-10-14 Thread Eric Liu via cfe-commits
ioeric added inline comments.



Comment at: clang-move/ClangMove.cpp:472
 std::string FilePath = RemoveReplacement.getFilePath().str();
 addOrMergeReplacement(RemoveReplacement, &FileToReplacements[FilePath]);
 

For deletions, you can simply use `add`, which now simply merges overlapping 
deletions. And I think it should be considered an error if `add` fails. With 
`add`, you can get rid of `addOrMergeReplacement`.


https://reviews.llvm.org/D25613



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


[PATCH] D25613: [clang-move] Don't overuse Replacements::add.

2016-10-14 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 74675.
hokein added a comment.

woohoo, delete more code!


https://reviews.llvm.org/D25613

Files:
  clang-move/ClangMove.cpp

Index: clang-move/ClangMove.cpp
===
--- clang-move/ClangMove.cpp
+++ clang-move/ClangMove.cpp
@@ -204,16 +204,6 @@
  Replacement.getReplacementText());
 }
 
-void addOrMergeReplacement(const clang::tooling::Replacement &Replacement,
-   clang::tooling::Replacements *Replacements) {
-  auto Err = Replacements->add(Replacement);
-  if (Err) {
-llvm::consumeError(std::move(Err));
-auto Replace = getReplacementInChangedCode(*Replacements, Replacement);
-*Replacements = Replacements->merge(clang::tooling::Replacements(Replace));
-  }
-}
-
 bool isInHeaderFile(const clang::SourceManager &SM, const clang::Decl *D,
 llvm::StringRef OriginalRunningDirectory,
 llvm::StringRef OldHeader) {
@@ -251,32 +241,24 @@
const std::vector &Decls,
llvm::StringRef FileName,
bool IsHeader = false) {
-  clang::tooling::Replacements InsertedReplacements;
+  std::string NewCode;
   std::string GuardName(FileName);
   if (IsHeader) {
 std::replace(GuardName.begin(), GuardName.end(), '/', '_');
 std::replace(GuardName.begin(), GuardName.end(), '.', '_');
 std::replace(GuardName.begin(), GuardName.end(), '-', '_');
 
 GuardName = StringRef(GuardName).upper();
-std::string HeaderGuard = "#ifndef " + GuardName + "\n";
-HeaderGuard += "#define " + GuardName + "\n";
-clang::tooling::Replacement HeaderGuardInclude(FileName, 0, 0,
-   HeaderGuard);
-addOrMergeReplacement(HeaderGuardInclude, &InsertedReplacements);
+NewCode += "#ifndef " + GuardName + "\n";
+NewCode += "#define " + GuardName + "\n";
   }
 
   // Add #Includes.
-  std::string AllIncludesString;
-  // FIXME: Add header guard.
   for (const auto &Include : Includes)
-AllIncludesString += Include;
+NewCode += Include;
 
-  if (!AllIncludesString.empty()) {
-clang::tooling::Replacement InsertInclude(FileName, 0, 0,
-  AllIncludesString + "\n");
-addOrMergeReplacement(InsertInclude, &InsertedReplacements);
-  }
+  if (!Includes.empty())
+NewCode += "\n";
 
   // Add moved class definition and its related declarations. All declarations
   // in same namespace are grouped together.
@@ -299,36 +281,23 @@
 for (auto It = CurrentNamespaces.rbegin(); RemainingSize > 0;
  --RemainingSize, ++It) {
   assert(It < CurrentNamespaces.rend());
-  auto code = "} // namespace " + *It + "\n";
-  clang::tooling::Replacement InsertedReplacement(FileName, 0, 0, code);
-  addOrMergeReplacement(InsertedReplacement, &InsertedReplacements);
+  NewCode += "} // namespace " + *It + "\n";
 }
 while (DeclIt != DeclNamespaces.end()) {
-  clang::tooling::Replacement InsertedReplacement(
-  FileName, 0, 0, "namespace " + *DeclIt + " {\n");
-  addOrMergeReplacement(InsertedReplacement, &InsertedReplacements);
+  NewCode += "namespace " + *DeclIt + " {\n";
   ++DeclIt;
 }
-
-clang::tooling::Replacement InsertedReplacement(
-FileName, 0, 0, getDeclarationSourceText(MovedDecl.Decl, MovedDecl.SM));
-addOrMergeReplacement(InsertedReplacement, &InsertedReplacements);
-
+NewCode += getDeclarationSourceText(MovedDecl.Decl, MovedDecl.SM);
 CurrentNamespaces = std::move(NextNamespaces);
   }
   std::reverse(CurrentNamespaces.begin(), CurrentNamespaces.end());
-  for (const auto &NS : CurrentNamespaces) {
-clang::tooling::Replacement InsertedReplacement(
-FileName, 0, 0, "} // namespace " + NS + "\n");
-addOrMergeReplacement(InsertedReplacement, &InsertedReplacements);
-  }
+  for (const auto &NS : CurrentNamespaces)
+NewCode += "} // namespace " + NS + "\n";
 
-  if (IsHeader) {
-clang::tooling::Replacement HeaderGuardEnd(FileName, 0, 0,
-   "#endif // " + GuardName + "\n");
-addOrMergeReplacement(HeaderGuardEnd, &InsertedReplacements);
-  }
-  return InsertedReplacements;
+  if (IsHeader)
+NewCode += "#endif // " + GuardName + "\n";
+  return clang::tooling::Replacements(
+  clang::tooling::Replacement(FileName, 0, 0, NewCode));
 }
 
 } // namespace
@@ -490,7 +459,11 @@
Range.getBegin(), Range.getEnd()),
 "");
 std::string FilePath = RemoveReplacement.getFilePath().str();
-addOrMergeReplacement(RemoveReplacement, &FileToReplacements[FilePath]);
+auto Err = FileToReplacements[FilePath].add(RemoveReplacement);
+if (Err) {
+  llvm::errs() << llvm::toString(std::move(Err)) << "\n";
+  continue;
+}
 
 llvm::StringRef Code =

[PATCH] D25613: [clang-move] Don't overuse Replacements::add.

2016-10-14 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 74677.
hokein added a comment.

Delete one more function.


https://reviews.llvm.org/D25613

Files:
  clang-move/ClangMove.cpp

Index: clang-move/ClangMove.cpp
===
--- clang-move/ClangMove.cpp
+++ clang-move/ClangMove.cpp
@@ -193,27 +193,6 @@
   return SourceText.str();
 }
 
-clang::tooling::Replacement
-getReplacementInChangedCode(const clang::tooling::Replacements &Replacements,
-const clang::tooling::Replacement &Replacement) {
-  unsigned Start = Replacements.getShiftedCodePosition(Replacement.getOffset());
-  unsigned End = Replacements.getShiftedCodePosition(Replacement.getOffset() +
- Replacement.getLength());
-  return clang::tooling::Replacement(Replacement.getFilePath(), Start,
- End - Start,
- Replacement.getReplacementText());
-}
-
-void addOrMergeReplacement(const clang::tooling::Replacement &Replacement,
-   clang::tooling::Replacements *Replacements) {
-  auto Err = Replacements->add(Replacement);
-  if (Err) {
-llvm::consumeError(std::move(Err));
-auto Replace = getReplacementInChangedCode(*Replacements, Replacement);
-*Replacements = Replacements->merge(clang::tooling::Replacements(Replace));
-  }
-}
-
 bool isInHeaderFile(const clang::SourceManager &SM, const clang::Decl *D,
 llvm::StringRef OriginalRunningDirectory,
 llvm::StringRef OldHeader) {
@@ -251,32 +230,24 @@
const std::vector &Decls,
llvm::StringRef FileName,
bool IsHeader = false) {
-  clang::tooling::Replacements InsertedReplacements;
+  std::string NewCode;
   std::string GuardName(FileName);
   if (IsHeader) {
 std::replace(GuardName.begin(), GuardName.end(), '/', '_');
 std::replace(GuardName.begin(), GuardName.end(), '.', '_');
 std::replace(GuardName.begin(), GuardName.end(), '-', '_');
 
 GuardName = StringRef(GuardName).upper();
-std::string HeaderGuard = "#ifndef " + GuardName + "\n";
-HeaderGuard += "#define " + GuardName + "\n";
-clang::tooling::Replacement HeaderGuardInclude(FileName, 0, 0,
-   HeaderGuard);
-addOrMergeReplacement(HeaderGuardInclude, &InsertedReplacements);
+NewCode += "#ifndef " + GuardName + "\n";
+NewCode += "#define " + GuardName + "\n";
   }
 
   // Add #Includes.
-  std::string AllIncludesString;
-  // FIXME: Add header guard.
   for (const auto &Include : Includes)
-AllIncludesString += Include;
+NewCode += Include;
 
-  if (!AllIncludesString.empty()) {
-clang::tooling::Replacement InsertInclude(FileName, 0, 0,
-  AllIncludesString + "\n");
-addOrMergeReplacement(InsertInclude, &InsertedReplacements);
-  }
+  if (!Includes.empty())
+NewCode += "\n";
 
   // Add moved class definition and its related declarations. All declarations
   // in same namespace are grouped together.
@@ -299,36 +270,23 @@
 for (auto It = CurrentNamespaces.rbegin(); RemainingSize > 0;
  --RemainingSize, ++It) {
   assert(It < CurrentNamespaces.rend());
-  auto code = "} // namespace " + *It + "\n";
-  clang::tooling::Replacement InsertedReplacement(FileName, 0, 0, code);
-  addOrMergeReplacement(InsertedReplacement, &InsertedReplacements);
+  NewCode += "} // namespace " + *It + "\n";
 }
 while (DeclIt != DeclNamespaces.end()) {
-  clang::tooling::Replacement InsertedReplacement(
-  FileName, 0, 0, "namespace " + *DeclIt + " {\n");
-  addOrMergeReplacement(InsertedReplacement, &InsertedReplacements);
+  NewCode += "namespace " + *DeclIt + " {\n";
   ++DeclIt;
 }
-
-clang::tooling::Replacement InsertedReplacement(
-FileName, 0, 0, getDeclarationSourceText(MovedDecl.Decl, MovedDecl.SM));
-addOrMergeReplacement(InsertedReplacement, &InsertedReplacements);
-
+NewCode += getDeclarationSourceText(MovedDecl.Decl, MovedDecl.SM);
 CurrentNamespaces = std::move(NextNamespaces);
   }
   std::reverse(CurrentNamespaces.begin(), CurrentNamespaces.end());
-  for (const auto &NS : CurrentNamespaces) {
-clang::tooling::Replacement InsertedReplacement(
-FileName, 0, 0, "} // namespace " + NS + "\n");
-addOrMergeReplacement(InsertedReplacement, &InsertedReplacements);
-  }
+  for (const auto &NS : CurrentNamespaces)
+NewCode += "} // namespace " + NS + "\n";
 
-  if (IsHeader) {
-clang::tooling::Replacement HeaderGuardEnd(FileName, 0, 0,
-   "#endif // " + GuardName + "\n");
-addOrMergeReplacement(HeaderGuardEnd, &InsertedReplacements);
-  }
-  return InsertedReplacements;
+  if (IsHeader)
+NewCode += "#endif // " + G

[PATCH] D25613: [clang-move] Don't overuse Replacements::add.

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

Awesome! Lg with one nit.




Comment at: clang-move/ClangMove.cpp:197
 clang::tooling::Replacement
 getReplacementInChangedCode(const clang::tooling::Replacements &Replacements,
 const clang::tooling::Replacement &Replacement) {

This is also dead I think :P


https://reviews.llvm.org/D25613



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


[clang-tools-extra] r284236 - [clang-move] Don't overuse Replacements::add.

2016-10-14 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Oct 14 08:43:49 2016
New Revision: 284236

URL: http://llvm.org/viewvc/llvm-project?rev=284236&view=rev
Log:
[clang-move] Don't overuse Replacements::add.

Reviewers: ioeric

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-move/ClangMove.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=284236&r1=284235&r2=284236&view=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Fri Oct 14 08:43:49 2016
@@ -193,27 +193,6 @@ std::string getDeclarationSourceText(con
   return SourceText.str();
 }
 
-clang::tooling::Replacement
-getReplacementInChangedCode(const clang::tooling::Replacements &Replacements,
-const clang::tooling::Replacement &Replacement) {
-  unsigned Start = 
Replacements.getShiftedCodePosition(Replacement.getOffset());
-  unsigned End = Replacements.getShiftedCodePosition(Replacement.getOffset() +
- Replacement.getLength());
-  return clang::tooling::Replacement(Replacement.getFilePath(), Start,
- End - Start,
- Replacement.getReplacementText());
-}
-
-void addOrMergeReplacement(const clang::tooling::Replacement &Replacement,
-   clang::tooling::Replacements *Replacements) {
-  auto Err = Replacements->add(Replacement);
-  if (Err) {
-llvm::consumeError(std::move(Err));
-auto Replace = getReplacementInChangedCode(*Replacements, Replacement);
-*Replacements = Replacements->merge(clang::tooling::Replacements(Replace));
-  }
-}
-
 bool isInHeaderFile(const clang::SourceManager &SM, const clang::Decl *D,
 llvm::StringRef OriginalRunningDirectory,
 llvm::StringRef OldHeader) {
@@ -251,7 +230,7 @@ createInsertedReplacements(const std::ve
const std::vector &Decls,
llvm::StringRef FileName,
bool IsHeader = false) {
-  clang::tooling::Replacements InsertedReplacements;
+  std::string NewCode;
   std::string GuardName(FileName);
   if (IsHeader) {
 std::replace(GuardName.begin(), GuardName.end(), '/', '_');
@@ -259,24 +238,16 @@ createInsertedReplacements(const std::ve
 std::replace(GuardName.begin(), GuardName.end(), '-', '_');
 
 GuardName = StringRef(GuardName).upper();
-std::string HeaderGuard = "#ifndef " + GuardName + "\n";
-HeaderGuard += "#define " + GuardName + "\n";
-clang::tooling::Replacement HeaderGuardInclude(FileName, 0, 0,
-   HeaderGuard);
-addOrMergeReplacement(HeaderGuardInclude, &InsertedReplacements);
+NewCode += "#ifndef " + GuardName + "\n";
+NewCode += "#define " + GuardName + "\n";
   }
 
   // Add #Includes.
-  std::string AllIncludesString;
-  // FIXME: Add header guard.
   for (const auto &Include : Includes)
-AllIncludesString += Include;
+NewCode += Include;
 
-  if (!AllIncludesString.empty()) {
-clang::tooling::Replacement InsertInclude(FileName, 0, 0,
-  AllIncludesString + "\n");
-addOrMergeReplacement(InsertInclude, &InsertedReplacements);
-  }
+  if (!Includes.empty())
+NewCode += "\n";
 
   // Add moved class definition and its related declarations. All declarations
   // in same namespace are grouped together.
@@ -299,36 +270,23 @@ createInsertedReplacements(const std::ve
 for (auto It = CurrentNamespaces.rbegin(); RemainingSize > 0;
  --RemainingSize, ++It) {
   assert(It < CurrentNamespaces.rend());
-  auto code = "} // namespace " + *It + "\n";
-  clang::tooling::Replacement InsertedReplacement(FileName, 0, 0, code);
-  addOrMergeReplacement(InsertedReplacement, &InsertedReplacements);
+  NewCode += "} // namespace " + *It + "\n";
 }
 while (DeclIt != DeclNamespaces.end()) {
-  clang::tooling::Replacement InsertedReplacement(
-  FileName, 0, 0, "namespace " + *DeclIt + " {\n");
-  addOrMergeReplacement(InsertedReplacement, &InsertedReplacements);
+  NewCode += "namespace " + *DeclIt + " {\n";
   ++DeclIt;
 }
-
-clang::tooling::Replacement InsertedReplacement(
-FileName, 0, 0, getDeclarationSourceText(MovedDecl.Decl, 
MovedDecl.SM));
-addOrMergeReplacement(InsertedReplacement, &InsertedReplacements);
-
+NewCode += getDeclarationSourceText(MovedDecl.Decl, MovedDecl.SM);
 CurrentNamespaces = std::move(NextNamespaces);
   }
   std::reverse(CurrentNamespaces.begin(), CurrentNamespaces.end());
-  for (const auto &NS : CurrentNamespaces) {
-clang::tooling::Replacement InsertedRe

[PATCH] D25613: [clang-move] Don't overuse Replacements::add.

2016-10-14 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.
Closed by commit rL284236: [clang-move] Don't overuse Replacements::add. 
(authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D25613?vs=74677&id=74679#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25613

Files:
  clang-tools-extra/trunk/clang-move/ClangMove.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
@@ -193,27 +193,6 @@
   return SourceText.str();
 }
 
-clang::tooling::Replacement
-getReplacementInChangedCode(const clang::tooling::Replacements &Replacements,
-const clang::tooling::Replacement &Replacement) {
-  unsigned Start = Replacements.getShiftedCodePosition(Replacement.getOffset());
-  unsigned End = Replacements.getShiftedCodePosition(Replacement.getOffset() +
- Replacement.getLength());
-  return clang::tooling::Replacement(Replacement.getFilePath(), Start,
- End - Start,
- Replacement.getReplacementText());
-}
-
-void addOrMergeReplacement(const clang::tooling::Replacement &Replacement,
-   clang::tooling::Replacements *Replacements) {
-  auto Err = Replacements->add(Replacement);
-  if (Err) {
-llvm::consumeError(std::move(Err));
-auto Replace = getReplacementInChangedCode(*Replacements, Replacement);
-*Replacements = Replacements->merge(clang::tooling::Replacements(Replace));
-  }
-}
-
 bool isInHeaderFile(const clang::SourceManager &SM, const clang::Decl *D,
 llvm::StringRef OriginalRunningDirectory,
 llvm::StringRef OldHeader) {
@@ -251,32 +230,24 @@
const std::vector &Decls,
llvm::StringRef FileName,
bool IsHeader = false) {
-  clang::tooling::Replacements InsertedReplacements;
+  std::string NewCode;
   std::string GuardName(FileName);
   if (IsHeader) {
 std::replace(GuardName.begin(), GuardName.end(), '/', '_');
 std::replace(GuardName.begin(), GuardName.end(), '.', '_');
 std::replace(GuardName.begin(), GuardName.end(), '-', '_');
 
 GuardName = StringRef(GuardName).upper();
-std::string HeaderGuard = "#ifndef " + GuardName + "\n";
-HeaderGuard += "#define " + GuardName + "\n";
-clang::tooling::Replacement HeaderGuardInclude(FileName, 0, 0,
-   HeaderGuard);
-addOrMergeReplacement(HeaderGuardInclude, &InsertedReplacements);
+NewCode += "#ifndef " + GuardName + "\n";
+NewCode += "#define " + GuardName + "\n";
   }
 
   // Add #Includes.
-  std::string AllIncludesString;
-  // FIXME: Add header guard.
   for (const auto &Include : Includes)
-AllIncludesString += Include;
+NewCode += Include;
 
-  if (!AllIncludesString.empty()) {
-clang::tooling::Replacement InsertInclude(FileName, 0, 0,
-  AllIncludesString + "\n");
-addOrMergeReplacement(InsertInclude, &InsertedReplacements);
-  }
+  if (!Includes.empty())
+NewCode += "\n";
 
   // Add moved class definition and its related declarations. All declarations
   // in same namespace are grouped together.
@@ -299,36 +270,23 @@
 for (auto It = CurrentNamespaces.rbegin(); RemainingSize > 0;
  --RemainingSize, ++It) {
   assert(It < CurrentNamespaces.rend());
-  auto code = "} // namespace " + *It + "\n";
-  clang::tooling::Replacement InsertedReplacement(FileName, 0, 0, code);
-  addOrMergeReplacement(InsertedReplacement, &InsertedReplacements);
+  NewCode += "} // namespace " + *It + "\n";
 }
 while (DeclIt != DeclNamespaces.end()) {
-  clang::tooling::Replacement InsertedReplacement(
-  FileName, 0, 0, "namespace " + *DeclIt + " {\n");
-  addOrMergeReplacement(InsertedReplacement, &InsertedReplacements);
+  NewCode += "namespace " + *DeclIt + " {\n";
   ++DeclIt;
 }
-
-clang::tooling::Replacement InsertedReplacement(
-FileName, 0, 0, getDeclarationSourceText(MovedDecl.Decl, MovedDecl.SM));
-addOrMergeReplacement(InsertedReplacement, &InsertedReplacements);
-
+NewCode += getDeclarationSourceText(MovedDecl.Decl, MovedDecl.SM);
 CurrentNamespaces = std::move(NextNamespaces);
   }
   std::reverse(CurrentNamespaces.begin(), CurrentNamespaces.end());
-  for (const auto &NS : CurrentNamespaces) {
-clang::tooling::Replacement InsertedReplacement(
-FileName, 0, 0, "} // namespace " + NS + "\n");
-addOrMergeReplacement(InsertedReplacement, &InsertedReplacements);
-  }
+  for (const auto &NS : CurrentNamespaces)
+NewCode += "} // namespace " + NS + "\n";
 
- 

[PATCH] D22955: [MSVC] Improved late parsing of template functions.

2016-10-14 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.



Comment at: lib/Sema/SemaLookup.cpp:1044-1070
+static bool isBaseClass(const CXXRecordDecl *Record, CXXRecordDecl *Base) {
+  SmallVector Queue;
+
+  while (true) {
+for (const auto &I : Record->bases()) {
+  const RecordType *Ty = I.getType()->getAs();
+  if (!Ty)

majnemer wrote:
> This looks a lot like forallBases, any chance it could be reused?
Yes, they are very similar, but forallBases() is a bit different. It checks 
that the provided callback returns true for all bases. In this case I need a 
single match, while other bases may not match. That's why I can't reuse 
forallBases().


https://reviews.llvm.org/D22955



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


[PATCH] D25593: [libcxx] Build with -fvisibility-inlines-hidden -- Remove 20 inline definitions from the dylib

2016-10-14 Thread Ed Maste via cfe-commits
emaste added inline comments.



Comment at: lib/abi/CHANGELOG.TXT:22
+  Although this change removes symbols, it should still be non-ABI breaking
+  since all of the definitions removed are inline functions.
+

Should we also include in this comment the further justification from your 
Phabricator description above (about having own definitions)?


https://reviews.llvm.org/D25593



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


[libcxx] r284237 - [libcxx] Improve the gcc workaround for the missing __has_include macro.

2016-10-14 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Fri Oct 14 08:56:58 2016
New Revision: 284237

URL: http://llvm.org/viewvc/llvm-project?rev=284237&view=rev
Log:
[libcxx] Improve the gcc workaround for the missing __has_include macro.

NFC.

Modified:
libcxx/trunk/include/__threading_support

Modified: libcxx/trunk/include/__threading_support
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=284237&r1=284236&r2=284237&view=diff
==
--- libcxx/trunk/include/__threading_support (original)
+++ libcxx/trunk/include/__threading_support Fri Oct 14 08:56:58 2016
@@ -19,20 +19,18 @@
 
 #ifndef _LIBCPP_HAS_NO_THREADS
 
-// These checks are carefully arranged so as not to trigger a gcc pre-processor
-// defect which causes it to fail to parse the __has_include check below, the
-// redundancy is intentional.
-#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
-#if !defined(__clang__) && (_GNUC_VER < 500)
-#include <__external_threading>
-#define _LIBCPP_HAS_EXTERNAL_THREADING_HEADER
-#elif !defined(__has_include) || __has_include(<__external_threading>)
-#include <__external_threading>
-#define _LIBCPP_HAS_EXTERNAL_THREADING_HEADER
-#endif
+#ifndef __libcpp_has_include
+  #ifndef __has_include
+#define __libcpp_has_include(x) 0
+  #else
+#define __libcpp_has_include(x) __has_include(x)
+  #endif
 #endif
 
-#if !defined(_LIBCPP_HAS_EXTERNAL_THREADING_HEADER)
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) && \
+__libcpp_has_include(<__external_threading>)
+#include <__external_threading>
+#else
 #include 
 #include 
 
@@ -241,7 +239,7 @@ void __libcpp_tls_set(__libcpp_tls_key _
 
 _LIBCPP_END_NAMESPACE_STD
 
-#endif // !_LIBCPP_HAS_EXTERNAL_THREADING_HEADER
+#endif // !_LIBCPP_HAS_THREAD_API_EXTERNAL || 
!__libcpp_has_include(<__external_threading>)
 
 #endif // _LIBCPP_HAS_NO_THREADS
 


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


[PATCH] D25539: [Coverage] Support for C++17 switch initializers

2016-10-14 Thread Igor Kudrin via cfe-commits
ikudrin accepted this revision.
ikudrin added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D25539



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


[PATCH] D25572: [Coverage] Support for C++17 if initializers

2016-10-14 Thread Igor Kudrin via cfe-commits
ikudrin accepted this revision.
ikudrin added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D25572



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


RE: r284174 - Disable swiftcall test on windows: More brutal way to appease windows bots

2016-10-14 Thread Robinson, Paul via cfe-commits
Is there a bug to track this problem so it doesn't get lost?
--paulr

From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of Reid 
Kleckner via cfe-commits
Sent: Thursday, October 13, 2016 4:02 PM
To: Arnold Schwaighofer
Cc: cfe-commits
Subject: Re: r284174 - Disable swiftcall test on windows: More brutal way to 
appease windows bots

These kinds of crashes typically happen when you have something like a 
use-after-destroy of a temporary, like a misuse of Twine or 
std::initializer_list.

On Thu, Oct 13, 2016 at 3:47 PM, Arnold Schwaighofer via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: arnolds
Date: Thu Oct 13 17:47:03 2016
New Revision: 284174

URL: http://llvm.org/viewvc/llvm-project?rev=284174&view=rev
Log:
Disable swiftcall test on windows: More brutal way to appease windows bots

The backtrace on the bot does not give me any indication what is wrong.
The test case interestingly passes in stage2 of the build.
I don't have a way of debugging this.

Disable the test on windows and hope if there is truly a bug in the code that
was causing we will eventually run into this on other platforms.

Modified:
cfe/trunk/test/CodeGen/64bit-swiftcall.c

Modified: cfe/trunk/test/CodeGen/64bit-swiftcall.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/64bit-swiftcall.c?rev=284174&r1=284173&r2=284174&view=diff
==
--- cfe/trunk/test/CodeGen/64bit-swiftcall.c (original)
+++ cfe/trunk/test/CodeGen/64bit-swiftcall.c Thu Oct 13 17:47:03 2016
@@ -3,6 +3,9 @@

 // REQUIRES: aarch64-registered-target,x86-registered-target

+// The union_het_vecint test case crashes on windows bot but only in stage1 
and not in stage2.
+// UNSUPPORTED: system-windows
+
 #define SWIFTCALL __attribute__((swiftcall))
 #define OUT __attribute__((swift_indirect_result))
 #define ERROR __attribute__((swift_error_result))


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

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


[PATCH] D25283: AvailabilityAttrs: Refactor context checking when diagnosing an availability violation

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

LGTM


https://reviews.llvm.org/D25283



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


[PATCH] D25600: [ASTMatcher] Add isStaticDataMember matcher for varDecl.

2016-10-14 Thread Haojian Wu via cfe-commits
hokein added inline comments.



Comment at: include/clang/ASTMatchers/ASTMatchers.h:3005
+/// \endcode
+AST_MATCHER(VarDecl, isStaticDataMember) {
+  return Node.isStaticDataMember();

aaron.ballman wrote:
> How does this differ from the existing matcher `hasStaticStorageDuration()` 
> over a `fieldDecl()`?
`fieldDecl` document says that fieldDecl is "an instance of this class is 
created by Sema::ActOnField to
represent a member of a struct/union/class.". So for static class members, they 
should not belong to `fieldDecl` as they are not bound to class instances.
 
Technically, we can't apply `hasStaticStorageDuration()` and 
`isStaticStorageClass` over a `fieldDecl`.
 


https://reviews.llvm.org/D25600



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


Re: r284174 - Disable swiftcall test on windows: More brutal way to appease windows bots

2016-10-14 Thread Arnold Schwaighofer via cfe-commits
https://llvm.org/bugs/show_bug.cgi?id=30699


> On Oct 14, 2016, at 7:11 AM, Robinson, Paul  wrote:
> 
> Is there a bug to track this problem so it doesn't get lost?
> --paulr
>  
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of 
> Reid Kleckner via cfe-commits
> Sent: Thursday, October 13, 2016 4:02 PM
> To: Arnold Schwaighofer
> Cc: cfe-commits
> Subject: Re: r284174 - Disable swiftcall test on windows: More brutal way to 
> appease windows bots
>  
> These kinds of crashes typically happen when you have something like a 
> use-after-destroy of a temporary, like a misuse of Twine or 
> std::initializer_list.
>  
> On Thu, Oct 13, 2016 at 3:47 PM, Arnold Schwaighofer via cfe-commits 
>  wrote:
> Author: arnolds
> Date: Thu Oct 13 17:47:03 2016
> New Revision: 284174
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=284174&view=rev
> Log:
> Disable swiftcall test on windows: More brutal way to appease windows bots
> 
> The backtrace on the bot does not give me any indication what is wrong.
> The test case interestingly passes in stage2 of the build.
> I don't have a way of debugging this.
> 
> Disable the test on windows and hope if there is truly a bug in the code that
> was causing we will eventually run into this on other platforms.
> 
> Modified:
> cfe/trunk/test/CodeGen/64bit-swiftcall.c
> 
> Modified: cfe/trunk/test/CodeGen/64bit-swiftcall.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/64bit-swiftcall.c?rev=284174&r1=284173&r2=284174&view=diff
> ==
> --- cfe/trunk/test/CodeGen/64bit-swiftcall.c (original)
> +++ cfe/trunk/test/CodeGen/64bit-swiftcall.c Thu Oct 13 17:47:03 2016
> @@ -3,6 +3,9 @@
> 
>  // REQUIRES: aarch64-registered-target,x86-registered-target
> 
> +// The union_het_vecint test case crashes on windows bot but only in stage1 
> and not in stage2.
> +// UNSUPPORTED: system-windows
> +
>  #define SWIFTCALL __attribute__((swiftcall))
>  #define OUT __attribute__((swift_indirect_result))
>  #define ERROR __attribute__((swift_error_result))
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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


[PATCH] D25621: DebugInfo: use DIAlignment type.

2016-10-14 Thread Victor Leschuk via cfe-commits
vleschuk created this revision.
vleschuk added reviewers: aprantl, mehdi_amini, dblaikie, echristo.
vleschuk added a subscriber: cfe-commits.

Use DIAlignment type introduced in https://reviews.llvm.org/D25620


https://reviews.llvm.org/D25621

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/DeclBase.h
  lib/AST/DeclBase.cpp
  lib/CodeGen/CGDebugInfo.cpp

Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -596,7 +596,7 @@
   }
   // Bit size, align and offset of the type.
   uint64_t Size = CGM.getContext().getTypeSize(BT);
-  uint64_t Align = CGM.getContext().getTypeAlign(BT);
+  llvm::DIAlignment Align = CGM.getContext().getTypeAlign(BT);
   return DBuilder.createBasicType(BTName, Size, Align, Encoding);
 }
 
@@ -607,7 +607,7 @@
 Encoding = llvm::dwarf::DW_ATE_lo_user;
 
   uint64_t Size = CGM.getContext().getTypeSize(Ty);
-  uint64_t Align = CGM.getContext().getTypeAlign(Ty);
+  llvm::DIAlignment Align = CGM.getContext().getTypeAlign(Ty);
   return DBuilder.createBasicType("complex", Size, Align, Encoding);
 }
 
@@ -721,7 +721,7 @@
   StringRef RDName = getClassName(RD);
 
   uint64_t Size = 0;
-  uint64_t Align = 0;
+  llvm::DIAlignment Align = 0;
 
   const RecordDecl *D = RD->getDefinition();
   if (D && D->isCompleteDefinition()) {
@@ -749,7 +749,7 @@
   // because that does not return the correct value for references.
   unsigned AS = CGM.getContext().getTargetAddressSpace(PointeeTy);
   uint64_t Size = CGM.getTarget().getPointerWidth(AS);
-  uint64_t Align = CGM.getContext().getTypeAlign(Ty);
+  llvm::DIAlignment Align = CGM.getContext().getTypeAlign(Ty);
 
   if (Tag == llvm::dwarf::DW_TAG_reference_type ||
   Tag == llvm::dwarf::DW_TAG_rvalue_reference_type)
@@ -1181,7 +1181,7 @@
 QualType PointeeTy = ThisPtrTy->getPointeeType();
 unsigned AS = CGM.getContext().getTargetAddressSpace(PointeeTy);
 uint64_t Size = CGM.getTarget().getPointerWidth(AS);
-uint64_t Align = CGM.getContext().getTypeAlign(ThisPtrTy);
+llvm::DIAlignment Align = CGM.getContext().getTypeAlign(ThisPtrTy);
 llvm::DIType *PointeeType = getOrCreateType(PointeeTy, Unit);
 llvm::DIType *ThisPtrType =
 DBuilder.createPointerType(PointeeType, Size, Align);
@@ -1968,12 +1968,12 @@
 
   // Bit size, align and offset of the type.
   uint64_t Size = CGM.getContext().getTypeSize(Ty);
-  uint64_t Align = CGM.getContext().getTypeAlign(Ty);
+  llvm::DIAlignment Align = CGM.getContext().getTypeAlign(Ty);
 
   llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
   if (ID->getImplementation())
 Flags |= llvm::DINode::FlagObjcClassComplete;
-
+ 
   llvm::DIScope *Mod = getParentModuleOrNull(ID);
   llvm::DICompositeType *RealDecl = DBuilder.createStructType(
   Mod ? Mod : Unit, ID->getName(), DefUnit, Line, Size, Align, Flags,
@@ -2134,14 +2134,14 @@
   llvm::DINodeArray SubscriptArray = DBuilder.getOrCreateArray(Subscript);
 
   uint64_t Size = CGM.getContext().getTypeSize(Ty);
-  uint64_t Align = CGM.getContext().getTypeAlign(Ty);
+  llvm::DIAlignment Align = CGM.getContext().getTypeAlign(Ty);
 
   return DBuilder.createVectorType(Size, Align, ElementTy, SubscriptArray);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const ArrayType *Ty, llvm::DIFile *Unit) {
   uint64_t Size;
-  uint64_t Align;
+  llvm::DIAlignment Align;
 
   // FIXME: make getTypeAlign() aware of VLAs and incomplete array types
   if (const auto *VAT = dyn_cast(Ty)) {
@@ -2264,7 +2264,7 @@
   const EnumDecl *ED = Ty->getDecl();
 
   uint64_t Size = 0;
-  uint64_t Align = 0;
+  llvm::DIAlignment Align = 0;
   if (!ED->getTypeForDecl()->isIncompleteType()) {
 Size = CGM.getContext().getTypeSize(ED->getTypeForDecl());
 Align = CGM.getContext().getTypeAlign(ED->getTypeForDecl());
@@ -2307,7 +2307,7 @@
 llvm::DIType *CGDebugInfo::CreateTypeDefinition(const EnumType *Ty) {
   const EnumDecl *ED = Ty->getDecl();
   uint64_t Size = 0;
-  uint64_t Align = 0;
+  llvm::DIAlignment Align = 0;
   if (!ED->getTypeForDecl()->isIncompleteType()) {
 Size = CGM.getContext().getTypeSize(ED->getTypeForDecl());
 Align = CGM.getContext().getTypeAlign(ED->getTypeForDecl());
@@ -2607,7 +2607,7 @@
 return getOrCreateRecordFwdDecl(Ty, RDContext);
 
   uint64_t Size = CGM.getContext().getTypeSize(Ty);
-  uint64_t Align = CGM.getContext().getTypeAlign(Ty);
+  llvm::DIAlignment Align = CGM.getContext().getTypeAlign(Ty);
 
   SmallString<256> FullName = getUniqueTagTypeName(Ty, CGM, TheCU);
 
Index: lib/AST/DeclBase.cpp
===
--- lib/AST/DeclBase.cpp
+++ lib/AST/DeclBase.cpp
@@ -327,11 +327,11 @@
   return getASTContext().getASTMutationListener();
 }
 
-unsigned Decl::getMaxAlignment() const {
+llvm::DIAlignment Decl::getMaxAlignment() const {
   if (!hasAttrs())
 return 0;
 
-  unsigned Align = 0;
+  llvm::DIAlignment Align = 0;
   const 

[PATCH] D25600: [ASTMatcher] Add isStaticDataMember matcher for varDecl.

2016-10-14 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/ASTMatchers/ASTMatchers.h:3005
+/// \endcode
+AST_MATCHER(VarDecl, isStaticDataMember) {
+  return Node.isStaticDataMember();

hokein wrote:
> aaron.ballman wrote:
> > How does this differ from the existing matcher `hasStaticStorageDuration()` 
> > over a `fieldDecl()`?
> `fieldDecl` document says that fieldDecl is "an instance of this class is 
> created by Sema::ActOnField to
> represent a member of a struct/union/class.". So for static class members, 
> they should not belong to `fieldDecl` as they are not bound to class 
> instances.
>  
> Technically, we can't apply `hasStaticStorageDuration()` and 
> `isStaticStorageClass` over a `fieldDecl`.
>  
That's a really good point, but the question still remains: since we have 
`hasStaticStorageDuration()` already, can we find a way to use that same 
matcher rather than introduce a new matcher under a new name that does the same 
thing?

This time I tested a matcher, and found that you get the correct behavior from 
`varDecl(hasStaticStorageDuration(), hasParent(recordDecl()))`.

I think this is especially important to try to do because we have 
`hasStaticStorageDuration()` and `isStaticStorageClass()`, so adding 
`isStaticDataMember()` adds a third option to possibly confuse users.


https://reviews.llvm.org/D25600



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


[PATCH] D24426: DebugInfo: Pass non-zero alignment to DIBuilder only if aligment was forced

2016-10-14 Thread Victor Leschuk via cfe-commits
vleschuk updated this revision to Diff 74686.
vleschuk added a comment.

Use DIAlignment type instead of uint64_t for alignment in DebugInfo.


https://reviews.llvm.org/D24426

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  test/CodeGen/debug-info-packed-struct.c
  test/CodeGen/debug-info-vector.c
  test/CodeGenCXX/debug-info-calling-conventions.cpp
  test/CodeGenCXX/debug-info-enum-class.cpp
  test/CodeGenCXX/debug-info-indirect-field-decl.cpp
  test/CodeGenCXX/debug-info-ms-bitfields.cpp
  test/CodeGenCXX/debug-info-ms-ptr-to-member.cpp
  test/CodeGenCXX/debug-info-rvalue-ref.cpp
  test/CodeGenCXX/debug-info-template-quals.cpp
  test/CodeGenCXX/debug-info-template.cpp
  test/CodeGenCXX/debug-info-union.cpp
  test/CodeGenCXX/debug-info-uuid.cpp
  test/CodeGenCXX/debug-info-vla.cpp
  test/CodeGenCXX/debug-info-zero-length-arrays.cpp
  test/CodeGenCXX/debug-info.cpp
  test/CodeGenCXX/debug-lambda-this.cpp
  test/CodeGenObjC/block-byref-debuginfo.m
  test/CodeGenObjC/debug-info-block-type.m
  test/CodeGenObjC/debug-info-ivars-extension.m
  test/CodeGenObjC/debug-info-ivars-private.m
  test/CodeGenObjC/debug-info-ivars.m
  test/CodeGenObjCXX/debug-info-cyclic.mm

Index: test/CodeGenObjCXX/debug-info-cyclic.mm
===
--- test/CodeGenObjCXX/debug-info-cyclic.mm
+++ test/CodeGenObjCXX/debug-info-cyclic.mm
@@ -3,7 +3,7 @@
 struct B {
 // CHECK: ![[B:[0-9]+]] ={{.*}}!DICompositeType(tag: DW_TAG_structure_type, name: "B"
 // CHECK-SAME: line: [[@LINE-2]],
-// CHECK-SAME: size: 8, align: 8,
+// CHECK-SAME: size: 8,
 // CHECK-NOT:  offset:
 // CHECK-NOT:  DIFlagFwdDecl
 // CHECK-SAME: elements: ![[BMEMBERS:[0-9]+]]
Index: test/CodeGenObjC/debug-info-ivars.m
===
--- test/CodeGenObjC/debug-info-ivars.m
+++ test/CodeGenObjC/debug-info-ivars.m
@@ -21,24 +21,24 @@
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "i"
 // CHECK-SAME:   line: 10
 // CHECK-SAME:   baseType: ![[INT:[0-9]+]]
-// CHECK-SAME:   size: 32, align: 32,
+// CHECK-SAME:   size: 32,
 // CHECK-NOT:offset:
 // CHECK-SAME:   flags: DIFlagProtected
 // CHECK: ![[INT]] = !DIBasicType(name: "int"
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "flag_1"
 // CHECK-SAME:   line: 11
 // CHECK-SAME:   baseType: ![[UNSIGNED:[0-9]+]]
-// CHECK-SAME:   size: 9, align: 32,
+// CHECK-SAME:   size: 9,
 // CHECK-NOT:offset:
 // CHECK-SAME:   flags: DIFlagProtected
 // CHECK: ![[UNSIGNED]] = !DIBasicType(name: "unsigned int"
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "flag_2"
 // CHECK-SAME:   line: 12
 // CHECK-SAME:   baseType: ![[UNSIGNED]]
-// CHECK-SAME:   size: 9, align: 32, offset: 1,
+// CHECK-SAME:   size: 9, offset: 1,
 // CHECK-SAME:   flags: DIFlagProtected
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "flag_3"
 // CHECK-SAME:   line: 14
 // CHECK-SAME:   baseType: ![[UNSIGNED]]
-// CHECK-SAME:   size: 9, align: 32, offset: 3,
+// CHECK-SAME:   size: 9, offset: 3,
 // CHECK-SAME:   flags: DIFlagProtected
Index: test/CodeGenObjC/debug-info-ivars-private.m
===
--- test/CodeGenObjC/debug-info-ivars-private.m
+++ test/CodeGenObjC/debug-info-ivars-private.m
@@ -35,13 +35,13 @@
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "foo"
 // CHECK-SAME:   line: 14
 // CHECK-SAME:   baseType: ![[INT:[0-9]+]]
-// CHECK-SAME:   size: 32, align: 32,
+// CHECK-SAME:   size: 32,
 // CHECK-NOT:offset:
 // CHECK-SAME:   flags: DIFlagProtected
 // CHECK: ![[INT]] = !DIBasicType(name: "int"
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "bar"
 // CHECK-SAME:   line: 27
 // CHECK-SAME:   baseType: ![[INT:[0-9]+]]
-// CHECK-SAME:   size: 32, align: 32,
+// CHECK-SAME:   size: 32,
 // CHECK-NOT:offset:
 // CHECK-SAME:   flags: DIFlagPrivate
Index: test/CodeGenObjC/debug-info-ivars-extension.m
===
--- test/CodeGenObjC/debug-info-ivars-extension.m
+++ test/CodeGenObjC/debug-info-ivars-extension.m
@@ -30,7 +30,7 @@
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "a"
 // CHECK-SAME:   line: 7
 // CHECK-SAME:   baseType: ![[INT:[0-9]+]]
-// CHECK-SAME:   size: 32, align: 32
+// CHECK-SAME:   size: 32
 // CHECK-NOT:offset:
 // CHECK-SAME:   flags: DIFlagPublic
 // CHECK: ![[INT]] = !DIBasicType(name: "int"
@@ -42,6 +42,6 @@
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "b"
 // CHECK-SA

[PATCH] D25305: [OpenCL] Setting constant address space for array initializers

2016-10-14 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

The test looks OK. However, the patch only contains the test now.


https://reviews.llvm.org/D25305



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


[PATCH] D25305: [OpenCL] Setting constant address space for array initializers

2016-10-14 Thread Alexey Sotkin via cfe-commits
AlexeySotkin updated this revision to Diff 74693.
AlexeySotkin added a comment.

Squashing commits


https://reviews.llvm.org/D25305

Files:
  lib/CodeGen/CGDecl.cpp
  test/CodeGenOpenCL/private-array-initialization.cl


Index: test/CodeGenOpenCL/private-array-initialization.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/private-array-initialization.cl
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -O0 -emit-llvm -o - | 
FileCheck %s
+
+// CHECK: @test.arr = private addrspace(2) constant [3 x i32] [i32 1, i32 2, 
i32 3], align 4
+
+void test() {
+  __private int arr[] = {1, 2, 3};
+// CHECK:  %[[arr_i8_ptr:[0-9]+]] = bitcast [3 x i32]* %arr to i8*
+// CHECK:  call void @llvm.memcpy.p0i8.p2i8.i32(i8* %[[arr_i8_ptr]], i8 
addrspace(2)* bitcast ([3 x i32] addrspace(2)* @test.arr to i8 addrspace(2)*), 
i32 12, i32 4, i1 false)
+}
\ No newline at end of file
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -1266,12 +1266,20 @@
 // Otherwise, create a temporary global with the initializer then
 // memcpy from the global to the alloca.
 std::string Name = getStaticDeclName(CGM, D);
+unsigned AS = 0;
+llvm::GlobalValue::UnnamedAddr UA = llvm::GlobalValue::UnnamedAddr::Global;
+if (getLangOpts().OpenCL) {
+  UA = llvm::GlobalValue::UnnamedAddr::None;
+  AS = CGM.getContext().getTargetAddressSpace(LangAS::opencl_constant);
+  BP = llvm::PointerType::getInt8PtrTy(getLLVMContext(), AS);
+}
 llvm::GlobalVariable *GV =
   new llvm::GlobalVariable(CGM.getModule(), constant->getType(), true,
llvm::GlobalValue::PrivateLinkage,
-   constant, Name);
+   constant, Name, nullptr,
+   llvm::GlobalValue::NotThreadLocal, AS);
 GV->setAlignment(Loc.getAlignment().getQuantity());
-GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
+GV->setUnnamedAddr(UA);
 
 Address SrcPtr = Address(GV, Loc.getAlignment());
 if (SrcPtr.getType() != BP)


Index: test/CodeGenOpenCL/private-array-initialization.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/private-array-initialization.cl
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -O0 -emit-llvm -o - | FileCheck %s
+
+// CHECK: @test.arr = private addrspace(2) constant [3 x i32] [i32 1, i32 2, i32 3], align 4
+
+void test() {
+  __private int arr[] = {1, 2, 3};
+// CHECK:  %[[arr_i8_ptr:[0-9]+]] = bitcast [3 x i32]* %arr to i8*
+// CHECK:  call void @llvm.memcpy.p0i8.p2i8.i32(i8* %[[arr_i8_ptr]], i8 addrspace(2)* bitcast ([3 x i32] addrspace(2)* @test.arr to i8 addrspace(2)*), i32 12, i32 4, i1 false)
+}
\ No newline at end of file
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -1266,12 +1266,20 @@
 // Otherwise, create a temporary global with the initializer then
 // memcpy from the global to the alloca.
 std::string Name = getStaticDeclName(CGM, D);
+unsigned AS = 0;
+llvm::GlobalValue::UnnamedAddr UA = llvm::GlobalValue::UnnamedAddr::Global;
+if (getLangOpts().OpenCL) {
+  UA = llvm::GlobalValue::UnnamedAddr::None;
+  AS = CGM.getContext().getTargetAddressSpace(LangAS::opencl_constant);
+  BP = llvm::PointerType::getInt8PtrTy(getLLVMContext(), AS);
+}
 llvm::GlobalVariable *GV =
   new llvm::GlobalVariable(CGM.getModule(), constant->getType(), true,
llvm::GlobalValue::PrivateLinkage,
-   constant, Name);
+   constant, Name, nullptr,
+   llvm::GlobalValue::NotThreadLocal, AS);
 GV->setAlignment(Loc.getAlignment().getQuantity());
-GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
+GV->setUnnamedAddr(UA);
 
 Address SrcPtr = Address(GV, Loc.getAlignment());
 if (SrcPtr.getType() != BP)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25305: [OpenCL] Setting constant address space for array initializers

2016-10-14 Thread Alexey Sotkin via cfe-commits
AlexeySotkin added a comment.

Now there should be both :)


https://reviews.llvm.org/D25305



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


[PATCH] D22221: Decide whether to enable plugin tests based on cmake variables

2016-10-14 Thread Ehsan Akhgari via cfe-commits
ehsan resigned from this revision.
ehsan removed a reviewer: ehsan.
ehsan added a comment.

I also don't know enough about the build system to review this, sorry!


Repository:
  rL LLVM

https://reviews.llvm.org/D1



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


[PATCH] D25326: [StaticAnalyser] Don't merge different returns in ExplodedGraph

2016-10-14 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

In https://reviews.llvm.org/D25326#569061, @danielmarjamaki wrote:

> > You could also try to add a canary with clang analyzer eval after the if 
> > statement to force the test to fail if we do add this symbolic reasoning.
>
> sounds good. sorry but I don't see how to do it.


The trick is to not first store the UnknownVal into a local (the analyzer will 
automatically create a symbol for that when read).

Instead you can do something like:

  if (table[i] != 0) { }
  clang_analyzer_eval((table[i] != 0)) // expected-warning {{UNKNOWN}}

This way if the analyzer ever starts generating symbols for a read from 
table[i] then the case split will change the eval to emit TRUE on one path and 
FALSE on the other.


Repository:
  rL LLVM

https://reviews.llvm.org/D25326



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


[PATCH] D25305: [OpenCL] Setting constant address space for array initializers

2016-10-14 Thread Yaxun Liu via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


https://reviews.llvm.org/D25305



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


[PATCH] D22494: [analyzer] Explain why analyzer report is not generated (fix for PR12421).

2016-10-14 Thread Anton Yartsev via cfe-commits
ayartsev closed this revision.
ayartsev added a comment.

Closed by r283499.


https://reviews.llvm.org/D22494



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


[PATCH] D25624: Added 'inline' attribute to basic_string's destructor

2016-10-14 Thread Aditya Kumar via cfe-commits
hiraditya created this revision.
hiraditya added reviewers: mclow.lists, EricWF.
hiraditya added subscribers: laxmansole, sebpop, cfe-commits.

Author: laxmansole

  

Original Differential Revision: https://reviews.llvm.org/D22834

  

Posting the patch again as the bug https://llvm.org/bugs/show_bug.cgi?id=30341 
is fixed.

  

Currently basic_string's destructor is not getting inlined. So adding 'inline' 
attribute to ~basic_string().
Worked in collaboration with Aditya Kumar.

  

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@280944 
91177308-0d34-0410-b5e6-96231b3b80d8


https://reviews.llvm.org/D25624

Files:
  include/string


Index: include/string
===
--- include/string
+++ include/string
@@ -1834,6 +1834,7 @@
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
 template 
+inline _LIBCPP_INLINE_VISIBILITY
 basic_string<_CharT, _Traits, _Allocator>::~basic_string()
 {
 #if _LIBCPP_DEBUG_LEVEL >= 2


Index: include/string
===
--- include/string
+++ include/string
@@ -1834,6 +1834,7 @@
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
 template 
+inline _LIBCPP_INLINE_VISIBILITY
 basic_string<_CharT, _Traits, _Allocator>::~basic_string()
 {
 #if _LIBCPP_DEBUG_LEVEL >= 2
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25621: DebugInfo: use DIAlignment type.

2016-10-14 Thread Adrian Prantl via cfe-commits
aprantl added inline comments.



Comment at: include/clang/AST/ASTContext.h:83
 uint64_t Width;
-unsigned Align;
+llvm::DIAlignment Align;
 bool AlignIsRequired : 1;

I'm not sure we want to use a debug info type inside the AST. I think we only 
want to use them in CGDebugInfo.cpp.


https://reviews.llvm.org/D25621



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


[PATCH] Warning for main returning a bool.

2016-10-14 Thread Joshua Hurwitz via cfe-commits
See attached.

Returning a bool from main is a special case of return type mismatch. The
common convention when returning a bool is that 'true' (== 1) indicates
success and 'false' (== 0) failure. But since main expects a return value
of 0 on success, returning a bool is usually unintended.
From 4b88e06e060fc70d6f82d17d92155377f939a96a Mon Sep 17 00:00:00 2001
From: Joshua Hurwitz 
Date: Fri, 14 Oct 2016 13:04:26 -0400
Subject: [PATCH] Warning for main returning a bool.

Returning a bool from main is a special case of return type mismatch.
The common convention when returning a bool is that 'true' (== 1)
indicates success and 'false' (== 0) failure. But since main expects a
return value of 0 on success, returning a bool is usually unintended.
---
 include/clang/Basic/DiagnosticSemaKinds.td |  2 ++
 lib/Sema/SemaStmt.cpp  |  5 +
 test/Sema/warn-main-returns-bool.cpp   | 17 +
 3 files changed, 24 insertions(+)
 create mode 100644 test/Sema/warn-main-returns-bool.cpp

diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index 872311f..9b9115d 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -634,6 +634,8 @@ def warn_main_one_arg : Warning<"only one parameter on 'main' declaration">,
 def err_main_arg_wrong : Error<"%select{first|second|third|fourth}0 "
 "parameter of 'main' (%select{argument count|argument array|environment|"
 "platform-specific data}0) must be of type %1">;
+def warn_main_returns_bool : Warning<"type of expression returned from 'main' "
+"(%0) should be 'int'">, InGroup;
 def err_main_global_variable :
 Error<"main cannot be declared as global variable">;
 def warn_main_redefined : Warning<"variable named 'main' with external linkage "
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index eba192d..dca81a2 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -3193,6 +3193,11 @@ StmtResult Sema::BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) {
 if (FD->isNoReturn())
   Diag(ReturnLoc, diag::warn_noreturn_function_has_return_expr)
 << FD->getDeclName();
+if (FD->isMain() && RetValExp)
+  if (Context.hasSameUnqualifiedType(RetValExp->getType(), Context.BoolTy))
+Diag(ReturnLoc, diag::warn_main_returns_bool)
+  << RetValExp->getType().getUnqualifiedType()
+  << RetValExp->getSourceRange();
   } else if (ObjCMethodDecl *MD = getCurMethodDecl()) {
 FnRetType = MD->getReturnType();
 isObjCMethod = true;
diff --git a/test/Sema/warn-main-returns-bool.cpp b/test/Sema/warn-main-returns-bool.cpp
new file mode 100644
index 000..8763335
--- /dev/null
+++ b/test/Sema/warn-main-returns-bool.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wmain -verify %s
+
+// expected-note@+1 {{previous definition is here}}
+int main() {
+  return 0;
+}  // no-warning
+
+// expected-error@+1 {{redefinition of 'main'}}
+int main() {
+  unsigned int u = 0;
+  return u;
+}  // no-warning
+
+int main() {
+  const bool b = true;
+  return b;  // expected-warning {{type of expression returned from 'main' ('bool') should be 'int'}}
+}
-- 
2.8.0.rc3.226.g39d4020

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


[PATCH] D25606: alpha.core.UnreachableCode - don't warn about unreachable code inside macro

2016-10-14 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

We should pattern match for this specific macro pattern (ex: do{...}while(0) ) 
instead of suppressing all warnings coming from macros. Maybe we could use the 
same heuristic as -Wunreachable-code-return compiler warning?


Repository:
  rL LLVM

https://reviews.llvm.org/D25606



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


[PATCH] D25334: Implement __stosb intrinsic as a volatile memset

2016-10-14 Thread David Majnemer via cfe-commits
majnemer accepted this revision.
majnemer added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D25334



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


r284253 - Implement __stosb intrinsic as a volatile memset

2016-10-14 Thread Albert Gutowski via cfe-commits
Author: agutowski
Date: Fri Oct 14 12:33:05 2016
New Revision: 284253

URL: http://llvm.org/viewvc/llvm-project?rev=284253&view=rev
Log:
Implement __stosb intrinsic as a volatile memset

Summary: We need `__stosb` to be an intrinsic, because SecureZeroMemory 
function uses it without including intrin.h. Implementing it as a volatile 
memset is not consistent with MSDN specification, but it gives us 
target-independent IR while keeping the most important properties of `__stosb`.

Reviewers: rnk, hans, thakis, majnemer

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/intrin.h
cfe/trunk/test/CodeGen/ms-intrinsics.c
cfe/trunk/test/Headers/ms-intrin.cpp

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=284253&r1=284252&r2=284253&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Fri Oct 14 12:33:05 2016
@@ -2041,6 +2041,8 @@ TARGET_HEADER_BUILTIN(__emulu, "ULLiUiUi
 
 TARGET_HEADER_BUILTIN(_AddressOfReturnAddress, "v*", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
 
+TARGET_HEADER_BUILTIN(__stosb, "vUc*Ucz", "nh", "intrin.h", ALL_MS_LANGUAGES, 
"")
+
 #undef BUILTIN
 #undef TARGET_BUILTIN
 #undef TARGET_HEADER_BUILTIN

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=284253&r1=284252&r2=284253&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Oct 14 12:33:05 2016
@@ -7770,6 +7770,11 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 Value *F = CGM.getIntrinsic(Intrinsic::addressofreturnaddress);
 return Builder.CreateCall(F);
   }
+  case X86::BI__stosb: {
+// We treat __stosb as a volatile memset - it may not generate "rep stosb"
+// instruction, but it will create a memset that won't be optimized away.
+return Builder.CreateMemSet(Ops[0], Ops[1], Ops[2], 1, true);
+  }
   }
 }
 

Modified: cfe/trunk/lib/Headers/intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/intrin.h?rev=284253&r1=284252&r2=284253&view=diff
==
--- cfe/trunk/lib/Headers/intrin.h (original)
+++ cfe/trunk/lib/Headers/intrin.h Fri Oct 14 12:33:05 2016
@@ -1024,11 +1024,6 @@ __movsw(unsigned short *__dst, unsigned
 : "%edi", "%esi", "%ecx");
 }
 static __inline__ void __DEFAULT_FN_ATTRS
-__stosb(unsigned char *__dst, unsigned char __x, size_t __n) {
-  __asm__("rep stosb" : : "D"(__dst), "a"(__x), "c"(__n)
-: "%edi", "%ecx");
-}
-static __inline__ void __DEFAULT_FN_ATTRS
 __stosd(unsigned long *__dst, unsigned long __x, size_t __n) {
   __asm__("rep stosl" : : "D"(__dst), "a"(__x), "c"(__n)
 : "%edi", "%ecx");

Modified: cfe/trunk/test/CodeGen/ms-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-intrinsics.c?rev=284253&r1=284252&r2=284253&view=diff
==
--- cfe/trunk/test/CodeGen/ms-intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/ms-intrinsics.c Fri Oct 14 12:33:05 2016
@@ -14,6 +14,22 @@ typedef __SIZE_TYPE__ size_t;
 
 #include 
 
+#if defined(__i386__) || defined(__x86_64__)
+void test__stosb(unsigned char *Dest, unsigned char Data, size_t Count) {
+  return __stosb(Dest, Data, Count);
+}
+
+// CHECK-I386: define{{.*}}void @test__stosb
+// CHECK-I386:   tail call void @llvm.memset.p0i8.i32(i8* %Dest, i8 %Data, i32 
%Count, i32 1, i1 true)
+// CHECK-I386:   ret void
+// CHECK-I386: }
+
+// CHECK-X64: define{{.*}}void @test__stosb
+// CHECK-X64:   tail call void @llvm.memset.p0i8.i64(i8* %Dest, i8 %Data, i64 
%Count, i32 1, i1 true)
+// CHECK-X64:   ret void
+// CHECK-X64: }
+#endif
+
 void *test_ReturnAddress() {
   return _ReturnAddress();
 }

Modified: cfe/trunk/test/Headers/ms-intrin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/ms-intrin.cpp?rev=284253&r1=284252&r2=284253&view=diff
==
--- cfe/trunk/test/Headers/ms-intrin.cpp (original)
+++ cfe/trunk/test/Headers/ms-intrin.cpp Fri Oct 14 12:33:05 2016
@@ -38,7 +38,6 @@ void f() {
   __movsd(0, 0, 0);
   __movsw(0, 0, 0);
 
-  __stosb(0, 0, 0);
   __stosd(0, 0, 0);
   __stosw(0, 0, 0);
 


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


[PATCH] D25593: [libcxx] Build with -fvisibility-inlines-hidden -- Remove 20 inline definitions from the dylib

2016-10-14 Thread Dimitry Andric via cfe-commits
dim accepted this revision.
dim added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D25593



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


Re: [libcxx] r284210 - XFAIL aligned allocation test failures with UBSAN

2016-10-14 Thread Richard Smith via cfe-commits
On Fri, Oct 14, 2016 at 12:49 AM, Eric Fiselier via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ericwf
> Date: Fri Oct 14 02:49:15 2016
> New Revision: 284210
>
> URL: http://llvm.org/viewvc/llvm-project?rev=284210&view=rev
> Log:
> XFAIL  aligned allocation test failures with UBSAN
>
> Modified:
> libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
> libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_
> replace.pass.cpp
> libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
> libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.single/new_align_val_t_
> nothrow_replace.pass.cpp
>
> Modified: libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/
> language.support/support.dynamic/new.delete/new.delete.
> array/delete_align_val_t_replace.pass.cpp?rev=284210&
> r1=284209&r2=284210&view=diff
> 
> ==
> --- libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
> (original)
> +++ libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
> Fri Oct 14 02:49:15 2016
> @@ -17,6 +17,9 @@
>  // None of the current GCC compilers support this.
>  // XFAIL: gcc-4, gcc-5, gcc-6
>
> +// UBSAN replaces certain new/delete functions which makes this test fail
>

I don't think that's the problem; the UBSan runtime doesn't replace any
functions. Instead...


> +// XFAIL: ubsan
> +
>  #include 
>  #include 
>  #include 
> @@ -58,24 +61,24 @@ struct alignas(std::max_align_t) B {};
>  int main()
>  {
>

I think you're missing a call to reset() here. It looks like the sanitizer
runtimes happen to call 'operator new' before entering main.


>  {
> -B *x = new B;
> +B *x = new B[2];
>  assert(0 == unsized_delete_called);
>  assert(0 == unsized_delete_nothrow_called);
>  assert(0 == aligned_delete_called);
>
> -delete x;
> +delete [] x;
>  assert(1 == unsized_delete_called);
>  assert(0 == unsized_delete_nothrow_called);
>  assert(0 == aligned_delete_called);
>  }
>  reset();
>  {
> -A *x = new A;
> +A *x = new A[2];
>  assert(0 == unsized_delete_called);
>  assert(0 == unsized_delete_nothrow_called);
>  assert(0 == aligned_delete_called);
>
> -delete x;
> +delete [] x;
>  assert(0 == unsized_delete_called);
>  assert(0 == unsized_delete_nothrow_called);
>  assert(1 == aligned_delete_called);
>
> Modified: libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_
> replace.pass.cpp
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/
> language.support/support.dynamic/new.delete/new.delete.
> array/new_align_val_t_nothrow_replace.pass.cpp?rev=284210&
> r1=284209&r2=284210&view=diff
> 
> ==
> --- libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp
> (original)
> +++ libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp
> Fri Oct 14 02:49:15 2016
> @@ -13,9 +13,6 @@
>
>  // UNSUPPORTED: sanitizer-new-delete
>
> -// TODO Investigate why UBSAN prevents nothrow new from calling our
> replacement.
> -// XFAIL: ubsan
> -
>  #include 
>  #include 
>  #include 
>
> Modified: libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/
> language.support/support.dynamic/new.delete/new.delete.
> single/delete_align_val_t_replace.pass.cpp?rev=284210&
> r1=284209&r2=284210&view=diff
> 
> ==
> --- libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
> (original)
> +++ libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
> Fri Oct 14 02:49:15 2016
> @@ -17,6 +17,9 @@
>  // None of the current GCC compilers support this.
>  // XFAIL: gcc-4, gcc-5, gcc-6
>
> +// UBSAN replaces certain new/delete functions which makes this test fail
> +// XFAIL: ubsan
> +
>  #include 
>  #include 
>  #include 
>
> Modified: libcxx/trunk/test/std/language.support/support.
> dynamic/new.d

r284256 - Link static PIE programs against rcrt0.o on OpenBSD

2016-10-14 Thread Ed Maste via cfe-commits
Author: emaste
Date: Fri Oct 14 12:59:53 2016
New Revision: 284256

URL: http://llvm.org/viewvc/llvm-project?rev=284256&view=rev
Log:
Link static PIE programs against rcrt0.o on OpenBSD

Patch by Stefan Kempf.

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

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/openbsd.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=284256&r1=284255&r2=284256&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Oct 14 12:59:53 2016
@@ -8519,6 +8519,10 @@ void openbsd::Linker::ConstructJob(Compi
   if (Args.hasArg(options::OPT_pg))
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("gcrt0.o")));
+  else if (Args.hasArg(options::OPT_static) &&
+   !Args.hasArg(options::OPT_nopie))
+CmdArgs.push_back(
+Args.MakeArgString(getToolChain().GetFilePath("rcrt0.o")));
   else
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("crt0.o")));

Modified: cfe/trunk/test/Driver/openbsd.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openbsd.c?rev=284256&r1=284255&r2=284256&view=diff
==
--- cfe/trunk/test/Driver/openbsd.c (original)
+++ cfe/trunk/test/Driver/openbsd.c Fri Oct 14 12:59:53 2016
@@ -67,3 +67,26 @@
 // CHECK-MIPS64-PIC: as{{.*}}" "-mabi" "64" "-EB" "-KPIC"
 // CHECK-MIPS64EL: as{{.*}}" "-mabi" "64" "-EL"
 // CHECK-MIPS64EL-PIC: as{{.*}}" "-mabi" "64" "-EL" "-KPIC"
+
+// Check linking against correct startup code when (not) using PIE
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-PIE %s
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -fno-pie %s 
-### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-PIE %s
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static %s -### 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-STATIC-PIE %s
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static -fno-pie 
%s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-STATIC-PIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -nopie %s -### 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -fno-pie -nopie %s 
-### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -static -nopie %s 
-### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -fno-pie -static 
-nopie %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// CHECK-PIE: "/usr/lib/crt0.o"
+// CHECK-PIE-NOT: "-nopie"
+// CHECK-STATIC-PIE: "/usr/lib/rcrt0.o"
+// CHECK-STATIC-PIE-NOT: "-nopie"
+// CHECK-NOPIE: "-nopie" {{.*}}"/usr/lib/crt0.o"


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


[PATCH] D22130: Link static PIE programs against rcrt0.o on OpenBSD

2016-10-14 Thread Ed Maste via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284256: Link static PIE programs against rcrt0.o on OpenBSD 
(authored by emaste).

Changed prior to commit:
  https://reviews.llvm.org/D22130?vs=68046&id=74718#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22130

Files:
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/openbsd.c


Index: cfe/trunk/test/Driver/openbsd.c
===
--- cfe/trunk/test/Driver/openbsd.c
+++ cfe/trunk/test/Driver/openbsd.c
@@ -67,3 +67,26 @@
 // CHECK-MIPS64-PIC: as{{.*}}" "-mabi" "64" "-EB" "-KPIC"
 // CHECK-MIPS64EL: as{{.*}}" "-mabi" "64" "-EL"
 // CHECK-MIPS64EL-PIC: as{{.*}}" "-mabi" "64" "-EL" "-KPIC"
+
+// Check linking against correct startup code when (not) using PIE
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-PIE %s
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -fno-pie %s 
-### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-PIE %s
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static %s -### 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-STATIC-PIE %s
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static -fno-pie 
%s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-STATIC-PIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -nopie %s -### 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -fno-pie -nopie %s 
-### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -static -nopie %s 
-### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -fno-pie -static 
-nopie %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// CHECK-PIE: "/usr/lib/crt0.o"
+// CHECK-PIE-NOT: "-nopie"
+// CHECK-STATIC-PIE: "/usr/lib/rcrt0.o"
+// CHECK-STATIC-PIE-NOT: "-nopie"
+// CHECK-NOPIE: "-nopie" {{.*}}"/usr/lib/crt0.o"
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -8519,6 +8519,10 @@
   if (Args.hasArg(options::OPT_pg))
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("gcrt0.o")));
+  else if (Args.hasArg(options::OPT_static) &&
+   !Args.hasArg(options::OPT_nopie))
+CmdArgs.push_back(
+Args.MakeArgString(getToolChain().GetFilePath("rcrt0.o")));
   else
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("crt0.o")));


Index: cfe/trunk/test/Driver/openbsd.c
===
--- cfe/trunk/test/Driver/openbsd.c
+++ cfe/trunk/test/Driver/openbsd.c
@@ -67,3 +67,26 @@
 // CHECK-MIPS64-PIC: as{{.*}}" "-mabi" "64" "-EB" "-KPIC"
 // CHECK-MIPS64EL: as{{.*}}" "-mabi" "64" "-EL"
 // CHECK-MIPS64EL-PIC: as{{.*}}" "-mabi" "64" "-EL" "-KPIC"
+
+// Check linking against correct startup code when (not) using PIE
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-PIE %s
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -fno-pie %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-PIE %s
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-STATIC-PIE %s
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static -fno-pie %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-STATIC-PIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -nopie %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -fno-pie -nopie %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -static -nopie %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -fno-pie -static -nopie %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// CHECK-PIE: "/usr/lib/crt0.o"
+// CHECK-PIE-NOT: "-nopie"
+// CHECK-STATIC-PIE: "/usr/lib/rcrt0.o"
+// CHECK-STATIC-PIE-NOT: "-nopie"
+// CHECK-NOPIE: "-nopie" {{.*}}"/usr/lib/crt0.o"
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -8519,6 +8519,10 @@
   if (Args.hasArg(options::OPT_pg))
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("gcrt0.o")));
+  else if (Args.hasArg(options::OPT_static) &&
+   !Args.hasArg

r284259 - Revert r284256 due to test failure

2016-10-14 Thread Ed Maste via cfe-commits
Author: emaste
Date: Fri Oct 14 13:20:12 2016
New Revision: 284259

URL: http://llvm.org/viewvc/llvm-project?rev=284259&view=rev
Log:
Revert r284256 due to test failure

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/openbsd.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=284259&r1=284258&r2=284259&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Oct 14 13:20:12 2016
@@ -8519,10 +8519,6 @@ void openbsd::Linker::ConstructJob(Compi
   if (Args.hasArg(options::OPT_pg))
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("gcrt0.o")));
-  else if (Args.hasArg(options::OPT_static) &&
-   !Args.hasArg(options::OPT_nopie))
-CmdArgs.push_back(
-Args.MakeArgString(getToolChain().GetFilePath("rcrt0.o")));
   else
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("crt0.o")));

Modified: cfe/trunk/test/Driver/openbsd.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openbsd.c?rev=284259&r1=284258&r2=284259&view=diff
==
--- cfe/trunk/test/Driver/openbsd.c (original)
+++ cfe/trunk/test/Driver/openbsd.c Fri Oct 14 13:20:12 2016
@@ -67,26 +67,3 @@
 // CHECK-MIPS64-PIC: as{{.*}}" "-mabi" "64" "-EB" "-KPIC"
 // CHECK-MIPS64EL: as{{.*}}" "-mabi" "64" "-EL"
 // CHECK-MIPS64EL-PIC: as{{.*}}" "-mabi" "64" "-EL" "-KPIC"
-
-// Check linking against correct startup code when (not) using PIE
-// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -### 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-PIE %s
-// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -fno-pie %s 
-### 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-PIE %s
-// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static %s -### 
2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-STATIC-PIE %s
-// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static -fno-pie 
%s -### 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-STATIC-PIE %s
-// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -nopie %s -### 
2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
-// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -fno-pie -nopie %s 
-### 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
-// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -static -nopie %s 
-### 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
-// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -fno-pie -static 
-nopie %s -### 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
-// CHECK-PIE: "/usr/lib/crt0.o"
-// CHECK-PIE-NOT: "-nopie"
-// CHECK-STATIC-PIE: "/usr/lib/rcrt0.o"
-// CHECK-STATIC-PIE-NOT: "-nopie"
-// CHECK-NOPIE: "-nopie" {{.*}}"/usr/lib/crt0.o"


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


Re: [libcxx] r249738 - Split out of .

2016-10-14 Thread Bruno Cardoso Lopes via cfe-commits
Hi Richard,

I have a patch on top of your suggested patch from a year ago, that
break the cyclic dependency we're seeing, with this (and a few changes
to the SDK) we can bootstrap clang with submodule local visibility on
darwin. I've attached the patch with a reduced, standalone testcase
that doesn't depend on the SDK. The issues that are not covered by
your patch, that I cover in mine, are related to built-in and textual
headers: they can be found in paths where they don't map to any
modules, triggering other cycles. I fix that by looking further to
find a matching module for the header in question, instead the first
found header in header search.

Can you take a look?

Thanks,


On Thu, Jul 28, 2016 at 3:55 PM, Adrian Prantl via cfe-commits
 wrote:
> +Bruno
>
> On Jul 27, 2016, at 11:58 PM, Nico Weber  wrote:
>
> I played with modules a bit today, and as far as I can tell this is still
> broken. If this proves difficult to fix, should this change be reverted for
> now? It breaks using modules on Darwin.
>
> On Sun, Mar 13, 2016 at 12:53 AM, Adrian Prantl via cfe-commits
>  wrote:
>>
>> > On Mar 11, 2016, at 4:11 PM, Duncan P. N. Exon Smith
>> >  wrote:
>> >
>> > Did anyone file a PR for this?
>> >
>>
>> I filed PR 26928 - Prune the include path for modules
>> https://llvm.org/bugs/show_bug.cgi?id=26928
>> as a starting point.
>>
>> -- adrian
>>
>> ___
>> 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
>



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc


0001-Add-NoUndeclaredIncludes-attribute-and-logic.patch
Description: Binary data


0002-Changes-on-top-of-Richard-s-patch.patch
Description: Binary data
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r284263 - Module: emit initializers in submodules when importing the parent module.

2016-10-14 Thread Manman Ren via cfe-commits
Author: mren
Date: Fri Oct 14 13:55:44 2016
New Revision: 284263

URL: http://llvm.org/viewvc/llvm-project?rev=284263&view=rev
Log:
Module: emit initializers in submodules when importing the parent module.

When importing the parent module, module initializers in submodules should
be emitted.

rdar://28740482

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/test/Modules/Inputs/objc-initializer/module.modulemap
cfe/trunk/test/Modules/objc-initializer.m

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=284263&r1=284262&r2=284263&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Oct 14 13:55:44 2016
@@ -3951,9 +3951,33 @@ void CodeGenModule::EmitTopLevelDecl(Dec
 DI->EmitImportDecl(*Import);
 }
 
-// Emit the module initializers.
-for (auto *D : Context.getModuleInitializers(Import->getImportedModule()))
-  EmitTopLevelDecl(D);
+// Find all of the submodules and emit the module initializers.
+llvm::SmallPtrSet Visited;
+SmallVector Stack;
+Visited.insert(Import->getImportedModule());
+Stack.push_back(Import->getImportedModule());
+
+while (!Stack.empty()) {
+  clang::Module *Mod = Stack.pop_back_val();
+  if (!EmittedModuleInitializers.insert(Mod).second)
+continue;
+
+  for (auto *D : Context.getModuleInitializers(Mod))
+EmitTopLevelDecl(D);
+
+  // Visit the submodules of this module.
+  for (clang::Module::submodule_iterator Sub = Mod->submodule_begin(),
+ SubEnd = Mod->submodule_end();
+   Sub != SubEnd; ++Sub) {
+// Skip explicit children; they need to be explicitly imported to emit
+// the initializers.
+if ((*Sub)->IsExplicit)
+  continue;
+
+if (Visited.insert(*Sub).second)
+  Stack.push_back(*Sub);
+  }
+}
 break;
   }
 

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=284263&r1=284262&r2=284263&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Fri Oct 14 13:55:44 2016
@@ -420,6 +420,10 @@ private:
   /// \brief The complete set of modules that has been imported.
   llvm::SetVector ImportedModules;
 
+  /// \brief The set of modules for which the module initializers
+  /// have been emitted.
+  llvm::SmallPtrSet EmittedModuleInitializers;
+
   /// \brief A vector of metadata strings.
   SmallVector LinkerOptionsMetadata;
 

Modified: cfe/trunk/test/Modules/Inputs/objc-initializer/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/objc-initializer/module.modulemap?rev=284263&r1=284262&r2=284263&view=diff
==
--- cfe/trunk/test/Modules/Inputs/objc-initializer/module.modulemap (original)
+++ cfe/trunk/test/Modules/Inputs/objc-initializer/module.modulemap Fri Oct 14 
13:55:44 2016
@@ -1,4 +1,7 @@
 module X {
-  header "X.h"
+  module T {
+header "X.h"
+export *
+  }
   export *
 }

Modified: cfe/trunk/test/Modules/objc-initializer.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/objc-initializer.m?rev=284263&r1=284262&r2=284263&view=diff
==
--- cfe/trunk/test/Modules/objc-initializer.m (original)
+++ cfe/trunk/test/Modules/objc-initializer.m Fri Oct 14 13:55:44 2016
@@ -1,8 +1,14 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I 
%S/Inputs/objc-initializer %s -emit-llvm -o - -fobjc-arc | FileCheck %s
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I 
%S/Inputs/objc-initializer %s -emit-llvm -o - -fobjc-arc -DIMPORT_TOP | 
FileCheck %s
 // CHECK: kSimDeviceIOGetInterface = internal constant {{.*}} bitcast
 
+#ifdef IMPORT_TOP
+@import X;
+#else
 #import 
+#endif
+
 void test2(const NSString*);
 void test() {
   test2(kSimDeviceIOGetInterface);


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


Re: r276159 - [modules] Don't emit initializers for VarDecls within a module eagerly whenever

2016-10-14 Thread Manman via cfe-commits
Hi Richard,

Another follow-up commit r284263.

When we import the top-level module with “@import X;”, all the initializers in 
the submodule should be emitted.

Let me know if you see any problem,
Manman

> On Oct 13, 2016, at 4:03 PM, Richard Smith  wrote:
> 
> On Thu, Oct 13, 2016 at 11:52 AM, Manman via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Hi Richard,
> 
> I committed a follow-up patch in r284142 to fix issues with C/ObjC.
> 
> Let me know if you see any problem.
> 
> Looks good, thank you!
>  
> Manman
> 
> > On Jul 20, 2016, at 12:10 PM, Richard Smith via cfe-commits 
> > mailto:cfe-commits@lists.llvm.org>> wrote:
> >
> > Author: rsmith
> > Date: Wed Jul 20 14:10:16 2016
> > New Revision: 276159
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=276159&view=rev 
> > 
> > Log:
> > [modules] Don't emit initializers for VarDecls within a module eagerly 
> > whenever
> > we first touch any part of that module. Instead, defer them until the first
> > time that module is (transitively) imported. The initializer step for a 
> > module
> > then recursively initializes modules that its own headers imported.
> >
> > For example, this avoids running the  global initializer in 
> > programs
> > that don't actually use iostreams, but do use other parts of the standard
> > library.
> >
> > Added:
> >cfe/trunk/test/Modules/Inputs/unused-global-init/
> >  - copied from r275623, 
> > cfe/trunk/test/Modules/Inputs/unused-global-init/
> >cfe/trunk/test/Modules/unused-global-init.cpp
> >  - copied, changed from r275623, 
> > cfe/trunk/test/Modules/unused-global-init.cpp
> > Modified:
> >cfe/trunk/include/clang/AST/ASTContext.h
> >cfe/trunk/include/clang/Sema/Sema.h
> >cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> >cfe/trunk/lib/AST/ASTContext.cpp
> >cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> >cfe/trunk/lib/Sema/SemaDecl.cpp
> >cfe/trunk/lib/Sema/SemaLookup.cpp
> >cfe/trunk/lib/Serialization/ASTReader.cpp
> >cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
> >cfe/trunk/lib/Serialization/ASTWriter.cpp
> >cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
> >cfe/trunk/test/Modules/Inputs/unused-global-init/used.h
> >cfe/trunk/test/Modules/odr.cpp
> >cfe/trunk/test/Modules/templates.mm 
> >
> > Modified: cfe/trunk/include/clang/AST/ASTContext.h
> > URL: 
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=276159&r1=276158&r2=276159&view=diff
> >  
> > 
> > ==
> > --- cfe/trunk/include/clang/AST/ASTContext.h (original)
> > +++ cfe/trunk/include/clang/AST/ASTContext.h Wed Jul 20 14:10:16 2016
> > @@ -312,6 +312,18 @@ class ASTContext : public RefCountedBase
> >   /// definitions of that entity.
> >   llvm::DenseMap> MergedDefModules;
> >
> > +  /// \brief Initializers for a module, in order. Each Decl will be either
> > +  /// something that has a semantic effect on startup (such as a variable 
> > with
> > +  /// a non-constant initializer), or an ImportDecl (which recursively 
> > triggers
> > +  /// initialization of another module).
> > +  struct PerModuleInitializers {
> > +llvm::SmallVector Initializers;
> > +llvm::SmallVector LazyInitializers;
> > +
> > +void resolve(ASTContext &Ctx);
> > +  };
> > +  llvm::DenseMap ModuleInitializers;
> > +
> > public:
> >   /// \brief A type synonym for the TemplateOrInstantiation mapping.
> >   typedef llvm::PointerUnion
> > @@ -883,6 +895,17 @@ public:
> > return MergedIt->second;
> >   }
> >
> > +  /// Add a declaration to the list of declarations that are initialized
> > +  /// for a module. This will typically be a global variable (with internal
> > +  /// linkage) that runs module initializers, such as the iostream 
> > initializer,
> > +  /// or an ImportDecl nominating another module that has initializers.
> > +  void addModuleInitializer(Module *M, Decl *Init);
> > +
> > +  void addLazyModuleInitializers(Module *M, ArrayRef IDs);
> > +
> > +  /// Get the initializations to perform when importing a module, if any.
> > +  ArrayRef getModuleInitializers(Module *M);
> > +
> >   TranslationUnitDecl *getTranslationUnitDecl() const { return TUDecl; }
> >
> >   ExternCContextDecl *getExternCContextDecl() const;
> >
> > Modified: cfe/trunk/include/clang/Sema/Sema.h
> > URL: 
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=276159&r1=276158&r2=276159&view=diff
> >  
> > 
> > ==
> > --- cfe/trunk/include/clang/Sema/Sema.h (original)
> > +++ cfe/trunk/include

[PATCH] D25283: AvailabilityAttrs: Refactor context checking when diagnosing an availability violation

2016-10-14 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284265: [Sema] Refactor context checking for availability 
diagnostics (authored by epilk).

Changed prior to commit:
  https://reviews.llvm.org/D25283?vs=74547&id=74729#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25283

Files:
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/test/SemaObjC/class-unavail-warning.m

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -9889,23 +9889,16 @@
 return OriginalLexicalContext ? OriginalLexicalContext : CurContext;
   }
 
-  AvailabilityResult getCurContextAvailability() const;
-
-  /// \brief Get the verison that this context implies.
-  /// For instance, a method in an interface that is annotated with an
-  /// availability attribuite effectively has the availability of the interface.
-  VersionTuple getVersionForDecl(const Decl *Ctx) const;
-
   /// \brief The diagnostic we should emit for \c D, or \c AR_Available.
   ///
   /// \param D The declaration to check. Note that this may be altered to point
   /// to another declaration that \c D gets it's availability from. i.e., we
   /// walk the list of typedefs to find an availability attribute.
   ///
-  /// \param ContextVersion The version to compare availability against.
-  AvailabilityResult
-  ShouldDiagnoseAvailabilityOfDecl(NamedDecl *&D, VersionTuple ContextVersion,
-   std::string *Message);
+  /// \param Message If non-null, this will be populated with the message from
+  /// the availability attribute that is selected.
+  AvailabilityResult ShouldDiagnoseAvailabilityOfDecl(NamedDecl *&D,
+  std::string *Message);
 
   const DeclContext *getCurObjCLexicalContext() const {
 const DeclContext *DC = getCurLexicalContext();
Index: cfe/trunk/test/SemaObjC/class-unavail-warning.m
===
--- cfe/trunk/test/SemaObjC/class-unavail-warning.m
+++ cfe/trunk/test/SemaObjC/class-unavail-warning.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -fsyntax-only  -triple x86_64-apple-darwin10 -verify %s
+// RUN: %clang_cc1  -fsyntax-only -fblocks -triple x86_64-apple-darwin10 -verify %s
 // rdar://9092208
 
 __attribute__((unavailable("not available")))
@@ -98,3 +98,19 @@
 @end
 @interface UnavailSub(cat) // no error
 @end
+
+int unavail_global UNAVAILABLE;
+
+UNAVAILABLE __attribute__((objc_root_class))
+@interface TestAttrContext
+-meth;
+@end
+
+@implementation TestAttrContext
+-meth {
+  unavail_global = 2; // no warn
+  (void) ^{
+unavail_global = 4; // no warn
+  };
+}
+@end
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -15615,29 +15615,3 @@
 Decl *Sema::getObjCDeclContext() const {
   return (dyn_cast_or_null(CurContext));
 }
-
-AvailabilityResult Sema::getCurContextAvailability() const {
-  const Decl *D = cast_or_null(getCurObjCLexicalContext());
-  if (!D)
-return AR_Available;
-
-  // If we are within an Objective-C method, we should consult
-  // both the availability of the method as well as the
-  // enclosing class.  If the class is (say) deprecated,
-  // the entire method is considered deprecated from the
-  // purpose of checking if the current context is deprecated.
-  if (const ObjCMethodDecl *MD = dyn_cast(D)) {
-AvailabilityResult R = MD->getAvailability();
-if (R != AR_Available)
-  return R;
-D = MD->getClassInterface();
-  }
-  // If we are within an Objective-c @implementation, it
-  // gets the same availability context as the @interface.
-  else if (const ObjCImplementationDecl *ID =
-dyn_cast(D)) {
-D = ID->getClassInterface();
-  }
-  // Recover from user error.
-  return D ? D->getAvailability() : AR_Available;
-}
Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -6317,30 +6317,6 @@
   diag.Triggered = true;
 }
 
-static bool isDeclDeprecated(Decl *D) {
-  do {
-if (D->isDeprecated())
-  return true;
-// A category implicitly has the availability of the interface.
-if (const ObjCCategoryDecl *CatD = dyn_cast(D))
-  if (const ObjCInterfaceDecl *Interface = CatD->getClassInterface())
-return Interface->isDeprecated();
-  } while ((D = cast_or_null(D->getDeclContext(;
-  return false;
-}
-
-static bool isDeclUnavailable(Decl *D) {
-  do {
-if (D->isUnavailable())
-  return true;
-// A category implicitly has the availability of the interface.
-if (co

r284265 - [Sema] Refactor context checking for availability diagnostics

2016-10-14 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Fri Oct 14 14:08:01 2016
New Revision: 284265

URL: http://llvm.org/viewvc/llvm-project?rev=284265&view=rev
Log:
[Sema] Refactor context checking for availability diagnostics

This commit combines a couple of redundant functions that do availability
attribute context checking into a more correct/simpler one.

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

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaObjC/class-unavail-warning.m

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=284265&r1=284264&r2=284265&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Oct 14 14:08:01 2016
@@ -9889,23 +9889,16 @@ public:
 return OriginalLexicalContext ? OriginalLexicalContext : CurContext;
   }
 
-  AvailabilityResult getCurContextAvailability() const;
-
-  /// \brief Get the verison that this context implies.
-  /// For instance, a method in an interface that is annotated with an
-  /// availability attribuite effectively has the availability of the 
interface.
-  VersionTuple getVersionForDecl(const Decl *Ctx) const;
-
   /// \brief The diagnostic we should emit for \c D, or \c AR_Available.
   ///
   /// \param D The declaration to check. Note that this may be altered to point
   /// to another declaration that \c D gets it's availability from. i.e., we
   /// walk the list of typedefs to find an availability attribute.
   ///
-  /// \param ContextVersion The version to compare availability against.
-  AvailabilityResult
-  ShouldDiagnoseAvailabilityOfDecl(NamedDecl *&D, VersionTuple ContextVersion,
-   std::string *Message);
+  /// \param Message If non-null, this will be populated with the message from
+  /// the availability attribute that is selected.
+  AvailabilityResult ShouldDiagnoseAvailabilityOfDecl(NamedDecl *&D,
+  std::string *Message);
 
   const DeclContext *getCurObjCLexicalContext() const {
 const DeclContext *DC = getCurLexicalContext();

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=284265&r1=284264&r2=284265&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Oct 14 14:08:01 2016
@@ -15615,29 +15615,3 @@ void Sema::ActOnPragmaWeakAlias(Identifi
 Decl *Sema::getObjCDeclContext() const {
   return (dyn_cast_or_null(CurContext));
 }
-
-AvailabilityResult Sema::getCurContextAvailability() const {
-  const Decl *D = cast_or_null(getCurObjCLexicalContext());
-  if (!D)
-return AR_Available;
-
-  // If we are within an Objective-C method, we should consult
-  // both the availability of the method as well as the
-  // enclosing class.  If the class is (say) deprecated,
-  // the entire method is considered deprecated from the
-  // purpose of checking if the current context is deprecated.
-  if (const ObjCMethodDecl *MD = dyn_cast(D)) {
-AvailabilityResult R = MD->getAvailability();
-if (R != AR_Available)
-  return R;
-D = MD->getClassInterface();
-  }
-  // If we are within an Objective-c @implementation, it
-  // gets the same availability context as the @interface.
-  else if (const ObjCImplementationDecl *ID =
-dyn_cast(D)) {
-D = ID->getClassInterface();
-  }
-  // Recover from user error.
-  return D ? D->getAvailability() : AR_Available;
-}

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=284265&r1=284264&r2=284265&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri Oct 14 14:08:01 2016
@@ -6317,30 +6317,6 @@ static void handleDelayedForbiddenType(S
   diag.Triggered = true;
 }
 
-static bool isDeclDeprecated(Decl *D) {
-  do {
-if (D->isDeprecated())
-  return true;
-// A category implicitly has the availability of the interface.
-if (const ObjCCategoryDecl *CatD = dyn_cast(D))
-  if (const ObjCInterfaceDecl *Interface = CatD->getClassInterface())
-return Interface->isDeprecated();
-  } while ((D = cast_or_null(D->getDeclContext(;
-  return false;
-}
-
-static bool isDeclUnavailable(Decl *D) {
-  do {
-if (D->isUnavailable())
-  return true;
-// A category implicitly has the availability of the interface.
-if (const ObjCCategoryDecl *CatD = dyn_cast(D))
-  if (const ObjCInterfaceDecl *Interface = CatD->getClassInterface())
-return Interf

Re: [libcxx] r284214 - XFAIL aligned allocation tests for older Clang versions

2016-10-14 Thread Nico Weber via cfe-commits
This is breaking tests for me:

Unexpected Passing Tests (4):
libc++ ::
std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp
libc++ ::
std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
libc++ ::
std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
libc++ ::
std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp

Am I holding something wrong, or are these XFAILs wrong?

On Fri, Oct 14, 2016 at 4:47 AM, Eric Fiselier via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ericwf
> Date: Fri Oct 14 03:47:09 2016
> New Revision: 284214
>
> URL: http://llvm.org/viewvc/llvm-project?rev=284214&view=rev
> Log:
> XFAIL aligned allocation tests for older Clang versions
>
> Modified:
> libcxx/trunk/test/libcxx/test/config.py
> libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp
> libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
> libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_
> replace.pass.cpp
> libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.array/new_align_val_t_replace.pass.cpp
> libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
> libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
> libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.single/new_align_val_t_
> nothrow_replace.pass.cpp
> libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp
>
> Modified: libcxx/trunk/test/libcxx/test/config.py
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/
> libcxx/test/config.py?rev=284214&r1=284213&r2=284214&view=diff
> 
> ==
> --- libcxx/trunk/test/libcxx/test/config.py (original)
> +++ libcxx/trunk/test/libcxx/test/config.py Fri Oct 14 03:47:09 2016
> @@ -315,6 +315,10 @@ class Configuration(object):
>
>  if self.cxx.hasCompileFlag('-faligned-allocation'):
>  self.config.available_features.add('-faligned-allocation')
> +else:
> +# FIXME remove this once more than just clang-4.0 support
> +# C++17 aligned allocation.
> +self.config.available_features.add('no-aligned-allocation')
>
>  if self.get_lit_bool('has_libatomic', False):
>  self.config.available_features.add('libatomic')
>
> Modified: libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/
> language.support/support.dynamic/new.delete/new.delete.
> array/new_align_val_t.pass.cpp?rev=284214&r1=284213&r2=284214&view=diff
> 
> ==
> --- libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp (original)
> +++ libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp Fri Oct 14
> 03:47:09 2016
> @@ -9,11 +9,13 @@
>
>  // UNSUPPORTED: c++98, c++03, c++11, c++14
>
> -// test operator new
> -
>  // asan and msan will not call the new handler.
>  // UNSUPPORTED: sanitizer-new-delete
>
> +// XFAIL: no-aligned-allocation
> +
> +// test operator new
> +
>  #include 
>  #include 
>  #include 
>
> Modified: libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/
> language.support/support.dynamic/new.delete/new.delete.
> array/new_align_val_t_nothrow.pass.cpp?rev=284214&r1=284213&
> r2=284214&view=diff
> 
> ==
> --- libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
> (original)
> +++ libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp Fri
> Oct 14 03:47:09 2016
> @@ -9,11 +9,13 @@
>
>  // UNSUPPORTED: c++98, c++03, c++11, c++14
>
> -// test operator new (nothrow)
> -
>  // asan and msan will not call the new handler.
>  // UNSUPPORTED: sanitizer-new-delete
>
> +// XFAIL: no-aligned-allocation
> +
> +// test operator new (nothrow)
> +
>  #include 
>  #include 
>  #include 
>
> Modified: libcxx/trunk/test/std/language.support/support.
> dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_
> replace.pass.cpp
> U

  1   2   >