[PATCH] D26592: [change-namespace] consider typedef/using alias decls in the moved namespace.

2016-11-14 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
ioeric marked an inline comment as done.
Closed by commit rL286873: [change-namespace] consider typedef/using alias 
decls in the moved namespace. (authored by ioeric).

Changed prior to commit:
  https://reviews.llvm.org/D26592?vs=77792&id=77852#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26592

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

Index: clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
+++ clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -822,22 +822,22 @@
 }
 
 TEST_F(ChangeNamespaceTest, UsingShadowDeclInClass) {
-  std::string Code = "namespace na { class C_A {};\n }\n"
+  std::string Code = "namespace na { class C_A {}; }\n"
  "namespace na {\n"
  "namespace nb {\n"
  "void f() {\n"
- "  using na::CA;\n"
- "  CA ca;\n"
+ "  using ::na::C_A;\n"
+ "  C_A ca;\n"
  "}\n"
  "} // namespace nb\n"
  "} // namespace na\n";
-  std::string Expected = "namespace na { class C_A {};\n }\n"
+  std::string Expected = "namespace na { class C_A {}; }\n"
  "\n"
  "namespace x {\n"
  "namespace y {\n"
  "void f() {\n"
- "  using na::CA;\n"
- "  CA ca;\n"
+ "  using ::na::C_A;\n"
+ "  C_A ca;\n"
  "}\n"
  "} // namespace y\n"
  "} // namespace x\n";
@@ -941,6 +941,70 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, UsingAliasDecl) {
+  std::string Code =
+  "namespace nx { namespace ny { class X {}; } }\n"
+  "namespace na {\n"
+  "namespace nb {\n"
+  "using Y = nx::ny::X;\n"
+  "void f() { Y y; }\n"
+  "} // namespace nb\n"
+  "} // namespace na\n";
+
+  std::string Expected = "namespace nx { namespace ny { class X {}; } }\n"
+ "\n"
+ "namespace x {\n"
+ "namespace y {\n"
+ "using Y = nx::ny::X;\n"
+ "void f() { Y y; }\n"
+ "} // namespace y\n"
+ "} // namespace x\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
+TEST_F(ChangeNamespaceTest, UsingAliasDeclInGlobal) {
+  std::string Code =
+  "namespace nx { namespace ny { class X {}; } }\n"
+  "using Y = nx::ny::X;\n"
+  "namespace na {\n"
+  "namespace nb {\n"
+  "void f() { Y y; }\n"
+  "} // namespace nb\n"
+  "} // namespace na\n";
+
+  std::string Expected = "namespace nx { namespace ny { class X {}; } }\n"
+ "using Y = nx::ny::X;\n"
+ "\n"
+ "namespace x {\n"
+ "namespace y {\n"
+ "void f() { Y y; }\n"
+ "} // namespace y\n"
+ "} // namespace x\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
+
+TEST_F(ChangeNamespaceTest, TypedefAliasDecl) {
+  std::string Code =
+  "namespace nx { namespace ny { class X {}; } }\n"
+  "namespace na {\n"
+  "namespace nb {\n"
+  "typedef nx::ny::X Y;\n"
+  "void f() { Y y; }\n"
+  "} // namespace nb\n"
+  "} // namespace na\n";
+
+  std::string Expected = "namespace nx { namespace ny { class X {}; } }\n"
+ "\n"
+ "namespace x {\n"
+ "namespace y {\n"
+ "typedef nx::ny::X Y;\n"
+ "void f() { Y y; }\n"
+ "} // namespace y\n"
+ "} // namespace x\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 } // anonymous namespace
 } // namespace change_namespace
 } // namespace clang
Index: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
===
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
@@ -621,8 +621,27 @@
   const auto *FromDecl = Result.Nodes.getNodeAs("from_decl");
   // `hasDeclaration` gives underlying declaration, but if the type is
   // a typedef type, we need to use the typedef type instead.
-  if (auto *Typedef = Type.getType()-

[PATCH] D26624: [libcxx] [test] Fix bucket_count() assumptions.

2016-11-14 Thread Stephan T. Lavavej via cfe-commits
STL_MSFT created this revision.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.

[libcxx] [test] Fix bucket_count() assumptions.

With a max_load_factor of 1.0, the only guarantee is that
bucket_count() >= size(). (Note: setting max_load_factor without
rehashing isn't supposed to affect this, because setting
max_load_factor is currently specified to be constant time.)


https://reviews.llvm.org/D26624

Files:
  test/std/containers/unord/unord.map/swap_member.pass.cpp
  test/std/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp
  test/std/containers/unord/unord.multimap/swap_member.pass.cpp
  
test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp
  test/std/containers/unord/unord.multiset/swap_member.pass.cpp
  
test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp
  test/std/containers/unord/unord.set/swap_member.pass.cpp
  test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp

Index: test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp
===
--- test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp
+++ test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp
@@ -77,7 +77,7 @@
 c2.max_load_factor(2);
 swap(c1, c2);
 
-assert(c1.bucket_count() >= 11);
+assert(c1.bucket_count() >= 8);
 assert(c1.size() == 8);
 assert(*c1.find(10) == 10);
 assert(*c1.find(20) == 20);
@@ -132,7 +132,7 @@
 assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
 assert(c1.max_load_factor() == 2);
 
-assert(c2.bucket_count() >= 5);
+assert(c2.bucket_count() >= 4);
 assert(c2.size() == 4);
 assert(c2.count(1) == 1);
 assert(c2.count(2) == 1);
@@ -176,7 +176,7 @@
 c2.max_load_factor(2);
 swap(c1, c2);
 
-assert(c1.bucket_count() >= 11);
+assert(c1.bucket_count() >= 8);
 assert(c1.size() == 8);
 assert(*c1.find(10) == 10);
 assert(*c1.find(20) == 20);
@@ -193,7 +193,7 @@
 assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
 assert(c1.max_load_factor() == 2);
 
-assert(c2.bucket_count() >= 5);
+assert(c2.bucket_count() >= 4);
 assert(c2.size() == 4);
 assert(c2.count(1) == 1);
 assert(c2.count(2) == 1);
@@ -258,7 +258,7 @@
 c2.max_load_factor(2);
 swap(c1, c2);
 
-assert(c1.bucket_count() >= 11);
+assert(c1.bucket_count() >= 8);
 assert(c1.size() == 8);
 assert(*c1.find(10) == 10);
 assert(*c1.find(20) == 20);
@@ -313,7 +313,7 @@
 assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
 assert(c1.max_load_factor() == 2);
 
-assert(c2.bucket_count() >= 5);
+assert(c2.bucket_count() >= 4);
 assert(c2.size() == 4);
 assert(c2.count(1) == 1);
 assert(c2.count(2) == 1);
@@ -357,7 +357,7 @@
 c2.max_load_factor(2);
 swap(c1, c2);
 
-assert(c1.bucket_count() >= 11);
+assert(c1.bucket_count() >= 8);
 assert(c1.size() == 8);
 assert(*c1.find(10) == 10);
 assert(*c1.find(20) == 20);
@@ -374,7 +374,7 @@
 assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
 assert(c1.max_load_factor() == 2);
 
-assert(c2.bucket_count() >= 5);
+assert(c2.bucket_count() >= 4);
 assert(c2.size() == 4);
 assert(c2.count(1) == 1);
 assert(c2.count(2) == 1);
@@ -439,7 +439,7 @@
 c2.max_load_factor(2);
 swap(c1, c2);
 
-assert(c1.bucket_count() >= 11);
+assert(c1.bucket_count() >= 8);
 assert(c1.size() == 8);
 assert(*c1.find(10) == 10);
 assert(*c1.find(20) == 20);
@@ -494,7 +494,7 @@
 assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
 assert(c1.max_load_factor() == 2);
 
-assert(c2.bucket_count() >= 5);
+assert(c2.bucket_count() >= 4);
 assert(c2.size() == 4);
 assert(c2.count(1) == 1);
 assert(c2.count(2) == 1);
@@ -538,7 +538,7 @@
 c2.max_load_factor(2);
 swap(c1, c2);
 
-assert(c1.bucket_count() >= 11);
+assert(c1.bucket_count() >= 8);
 assert(c1.size() == 8);
 assert(*c1.find(10) == 10);
 assert(*c1.find(20) == 20);
@@ -555,7 +555,7 @@
 assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
 assert(c1.max_load_factor() == 2);
 
-assert(c2.bucket_count() >= 5);
+assert(c2.bucket_count() >= 4);
 assert(c2.size() == 4);
 assert(c2.count(1) == 1);
 assert(c2.count(2) == 1);
Index: test/std/containers/unord/unord.set/swap_member.pass.cpp
===
-

[PATCH] D26625: [libcxx] [test] future_error::what() is implementation-defined.

2016-11-14 Thread Stephan T. Lavavej via cfe-commits
STL_MSFT created this revision.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.

[libcxx] [test] future_error::what() is implementation-defined.


https://reviews.llvm.org/D26625

Files:
  test/std/thread/futures/futures.future_error/what.pass.cpp


Index: test/std/thread/futures/futures.future_error/what.pass.cpp
===
--- test/std/thread/futures/futures.future_error/what.pass.cpp
+++ test/std/thread/futures/futures.future_error/what.pass.cpp
@@ -26,25 +26,27 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int main()
 {
 {
 std::future_error 
f(std::make_error_code(std::future_errc::broken_promise));
-assert(std::strcmp(f.what(), "The associated promise has been 
destructed prior "
+LIBCPP_ASSERT(std::strcmp(f.what(), "The associated promise has been 
destructed prior "
   "to the associated state becoming ready.") == 0);
 }
 {
 std::future_error 
f(std::make_error_code(std::future_errc::future_already_retrieved));
-assert(std::strcmp(f.what(), "The future has already been retrieved 
from "
+LIBCPP_ASSERT(std::strcmp(f.what(), "The future has already been 
retrieved from "
   "the promise or packaged_task.") == 0);
 }
 {
 std::future_error 
f(std::make_error_code(std::future_errc::promise_already_satisfied));
-assert(std::strcmp(f.what(), "The state of the promise has already 
been set.") == 0);
+LIBCPP_ASSERT(std::strcmp(f.what(), "The state of the promise has 
already been set.") == 0);
 }
 {
 std::future_error f(std::make_error_code(std::future_errc::no_state));
-assert(std::strcmp(f.what(), "Operation not permitted on an object 
without "
+LIBCPP_ASSERT(std::strcmp(f.what(), "Operation not permitted on an 
object without "
   "an associated state.") == 0);
 }
 }


Index: test/std/thread/futures/futures.future_error/what.pass.cpp
===
--- test/std/thread/futures/futures.future_error/what.pass.cpp
+++ test/std/thread/futures/futures.future_error/what.pass.cpp
@@ -26,25 +26,27 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int main()
 {
 {
 std::future_error f(std::make_error_code(std::future_errc::broken_promise));
-assert(std::strcmp(f.what(), "The associated promise has been destructed prior "
+LIBCPP_ASSERT(std::strcmp(f.what(), "The associated promise has been destructed prior "
   "to the associated state becoming ready.") == 0);
 }
 {
 std::future_error f(std::make_error_code(std::future_errc::future_already_retrieved));
-assert(std::strcmp(f.what(), "The future has already been retrieved from "
+LIBCPP_ASSERT(std::strcmp(f.what(), "The future has already been retrieved from "
   "the promise or packaged_task.") == 0);
 }
 {
 std::future_error f(std::make_error_code(std::future_errc::promise_already_satisfied));
-assert(std::strcmp(f.what(), "The state of the promise has already been set.") == 0);
+LIBCPP_ASSERT(std::strcmp(f.what(), "The state of the promise has already been set.") == 0);
 }
 {
 std::future_error f(std::make_error_code(std::future_errc::no_state));
-assert(std::strcmp(f.what(), "Operation not permitted on an object without "
+LIBCPP_ASSERT(std::strcmp(f.what(), "Operation not permitted on an object without "
   "an associated state.") == 0);
 }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26626: [libcxx] [test] Fix an improper assumption about Null Forward Iterators.

2016-11-14 Thread Stephan T. Lavavej via cfe-commits
STL_MSFT created this revision.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.

[libcxx] [test] Fix an improper assumption about Null Forward Iterators.

Value-initialized iterators still can't be compared to those with parents.


https://reviews.llvm.org/D26626

Files:
  test/std/containers/sequences/list/iterators.pass.cpp


Index: test/std/containers/sequences/list/iterators.pass.cpp
===
--- test/std/containers/sequences/list/iterators.pass.cpp
+++ test/std/containers/sequences/list/iterators.pass.cpp
@@ -138,7 +138,6 @@
 #endif
 #if TEST_STD_VER > 11
 {
-std::list c;
 std::list::iterator ii1{}, ii2{};
 std::list::iterator ii4 = ii1;
 std::list::const_iterator cii{};
@@ -151,9 +150,6 @@
 assert ( (cii == ii1 ));
 assert (!(ii1 != cii ));
 assert (!(cii != ii1 ));
-
-assert ( ii1 != c.cbegin());
-assert ( cii != c.begin());
 }
 #endif
 


Index: test/std/containers/sequences/list/iterators.pass.cpp
===
--- test/std/containers/sequences/list/iterators.pass.cpp
+++ test/std/containers/sequences/list/iterators.pass.cpp
@@ -138,7 +138,6 @@
 #endif
 #if TEST_STD_VER > 11
 {
-std::list c;
 std::list::iterator ii1{}, ii2{};
 std::list::iterator ii4 = ii1;
 std::list::const_iterator cii{};
@@ -151,9 +150,6 @@
 assert ( (cii == ii1 ));
 assert (!(ii1 != cii ));
 assert (!(cii != ii1 ));
-
-assert ( ii1 != c.cbegin());
-assert ( cii != c.begin());
 }
 #endif
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25916: Modules: emit an error instead of a random crash (or a misleading error) due to use-after-free.

2016-11-14 Thread Manman Ren via cfe-commits
manmanren added a comment.

@ Ben,

We are hitting this issue when building large projects, but the reproducibility 
is quite low.

This proposed patch is currently a little too complicated. I am thinking about 
just fixing the testing case for now, and adding the check later when we start 
to share some data structures between threads (the idea of keeping MemoryBuffer 
consistent for threads within a single clang invocation).

For this testing case, we ignore the diagnostic options when a module is 
imported by a system module (see the code snippet below):

  ModuleFile *TopImport = *ModuleMgr.rbegin();
  while (!TopImport->ImportedBy.empty())
TopImport = TopImport->ImportedBy[0];
  if (TopImport->Kind != MK_ImplicitModule)
return false;
  
  StringRef ModuleName = TopImport->ModuleName;
  assert(!ModuleName.empty() && "diagnostic options read before module name");
  
  Module *M = PP.getHeaderSearchInfo().lookupModule(ModuleName);
  assert(M && "missing module");
  
  // FIXME: if the diagnostics are incompatible, save a DiagnosticOptions that
  // contains the union of their flags.
  return checkDiagnosticMappings(*Diags, ExistingDiags, M->IsSystem, Complain);

And here

  // If we're reading the first module for this group, check its options
  // are compatible with ours. For modules it imports, no further checking
  // is required, because we checked them when we built it.
  if (Listener && !ImportedBy) {

Does it mean that a system module should only import system modules? If a 
system module is allowed to import non-system modules, for a non-system module, 
we will validate diagnostic options differently depending on whether a system 
module or a non-system module imports it. This will cause a non-system module 
that was validated earlier to be invalidated by a child thread.

Thanks,
Manman


https://reviews.llvm.org/D25916



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


[PATCH] D26623: [libcxx] [test] Swapping non-equal non-POCS allocators is UB.

2016-11-14 Thread Stephan T. Lavavej via cfe-commits
STL_MSFT created this revision.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.

[libcxx] [test] Swapping non-equal non-POCS allocators is UB.

test_allocator is a non-POCS allocator. Instead of swapping containers
with A(1) and A(2), which triggers undefined behavior,
swapping A(3) with A(3) is conformant.

test/std/containers/sequences/vector/vector.special/swap.pass.cpp
Remove "#ifndef _LIBCPP_DEBUG_LEVEL" and a comment about
the now-fixed undefined behavior.


https://reviews.llvm.org/D26623

Files:
  test/std/containers/associative/map/map.special/non_member_swap.pass.cpp
  
test/std/containers/associative/multimap/multimap.special/non_member_swap.pass.cpp
  
test/std/containers/associative/multiset/multiset.special/non_member_swap.pass.cpp
  test/std/containers/associative/set/set.special/non_member_swap.pass.cpp
  test/std/containers/sequences/deque/deque.special/swap.pass.cpp
  
test/std/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp
  
test/std/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp
  test/std/containers/sequences/vector.bool/swap.pass.cpp
  test/std/containers/sequences/vector/vector.special/swap.pass.cpp
  test/std/containers/unord/unord.map/swap_member.pass.cpp
  test/std/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp
  test/std/containers/unord/unord.multimap/swap_member.pass.cpp
  
test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp
  test/std/containers/unord/unord.multiset/swap_member.pass.cpp
  
test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp
  test/std/containers/unord/unord.set/swap_member.pass.cpp
  test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp

Index: test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp
===
--- test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp
+++ test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp
@@ -32,25 +32,25 @@
 typedef test_allocator Alloc;
 typedef std::unordered_set C;
 typedef int P;
-C c1(0, Hash(1), Compare(1), Alloc(1));
-C c2(0, Hash(2), Compare(2), Alloc(2));
+C c1(0, Hash(1), Compare(1), Alloc(3));
+C c2(0, Hash(2), Compare(2), Alloc(3));
 c2.max_load_factor(2);
 swap(c1, c2);
 
 LIBCPP_ASSERT(c1.bucket_count() == 0);
 assert(c1.size() == 0);
 assert(c1.hash_function() == Hash(2));
 assert(c1.key_eq() == Compare(2));
-assert(c1.get_allocator() == Alloc(1));
+assert(c1.get_allocator() == Alloc(3));
 assert(std::distance(c1.begin(), c1.end()) == c1.size());
 assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
 assert(c1.max_load_factor() == 2);
 
 LIBCPP_ASSERT(c2.bucket_count() == 0);
 assert(c2.size() == 0);
 assert(c2.hash_function() == Hash(1));
 assert(c2.key_eq() == Compare(1));
-assert(c2.get_allocator() == Alloc(2));
+assert(c2.get_allocator() == Alloc(3));
 assert(std::distance(c2.begin(), c2.end()) == c2.size());
 assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
 assert(c2.max_load_factor() == 1);
@@ -72,8 +72,8 @@
 P(70),
 P(80)
 };
-C c1(0, Hash(1), Compare(1), Alloc(1));
-C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+C c1(0, Hash(1), Compare(1), Alloc(3));
+C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(3));
 c2.max_load_factor(2);
 swap(c1, c2);
 
@@ -89,16 +89,16 @@
 assert(*c1.find(80) == 80);
 assert(c1.hash_function() == Hash(2));
 assert(c1.key_eq() == Compare(2));
-assert(c1.get_allocator() == Alloc(1));
+assert(c1.get_allocator() == Alloc(3));
 assert(std::distance(c1.begin(), c1.end()) == c1.size());
 assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
 assert(c1.max_load_factor() == 2);
 
 LIBCPP_ASSERT(c2.bucket_count() == 0);
 assert(c2.size() == 0);
 assert(c2.hash_function() == Hash(1));
 assert(c2.key_eq() == Compare(1));
-assert(c2.get_allocator() == Alloc(2));
+assert(c2.get_allocator() == Alloc(3));
 assert(std::distance(c2.begin(), c2.end()) == c2.size());
 assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
 assert(c2.max_load_factor() == 1);
@@ -118,16 +118,16 @@
 P(1),
 P(2)
 };
-C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
-C c2(0, Hash(2), Compare(2), Alloc(2));
+C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(3));
+C c2(0, Hash(2), Compare(2), Alloc(3));
 

[PATCH] D26627: [libcxx] [test] Fix ordering assumptions in unordered container tests.

2016-11-14 Thread Stephan T. Lavavej via cfe-commits
STL_MSFT created this revision.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.

[libcxx] [test] Fix ordering assumptions in unordered container tests.


https://reviews.llvm.org/D26627

Files:
  
test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp
  
test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp
  
test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp

Index: test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp
===
--- test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp
+++ test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp
@@ -146,18 +146,10 @@
 C c(std::move(c0), A());
 assert(c.bucket_count() >= 7);
 assert(c.size() == 6);
-C::const_iterator i = c.cbegin();
-assert(*i == 4);
-++i;
-assert(*i == 3);
-++i;
-assert(*i == 2);
-++i;
-assert(*i == 2);
-++i;
-assert(*i == 1);
-++i;
-assert(*i == 1);
+assert(c.count(1) == 2);
+assert(c.count(2) == 2);
+assert(c.count(3) == 1);
+assert(c.count(4) == 1);
 assert(c.hash_function() == test_hash >(8));
 assert(c.key_eq() == test_compare >(9));
 assert(c.get_allocator() == A());
Index: test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp
===
--- test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp
+++ test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp
@@ -204,18 +204,10 @@
 c = std::move(c0);
 LIBCPP_ASSERT(c.bucket_count() == 7);
 assert(c.size() == 6);
-C::const_iterator i = c.cbegin();
-assert(*i == 4);
-++i;
-assert(*i == 3);
-++i;
-assert(*i == 2);
-++i;
-assert(*i == 2);
-++i;
-assert(*i == 1);
-++i;
-assert(*i == 1);
+assert(c.count(1) == 2);
+assert(c.count(2) == 2);
+assert(c.count(3) == 1);
+assert(c.count(4) == 1);
 assert(c.hash_function() == test_hash >(8));
 assert(c.key_eq() == test_compare >(9));
 assert(c.get_allocator() == A());
Index: test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp
===
--- test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp
+++ test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp
@@ -25,6 +25,7 @@
 
 #include "../../../Emplaceable.h"
 #include "min_allocator.h"
+#include "test_macros.h"
 
 int main()
 {
@@ -44,20 +45,20 @@
 assert(c.size() == 2);
 assert(r->first == 3);
 assert(r->second == Emplaceable(5, 6));
-assert(r == next(c.begin()));
+LIBCPP_ASSERT(r == next(c.begin()));
 
 r = c.emplace_hint(r, std::piecewise_construct, std::forward_as_tuple(3),
 std::forward_as_tuple(6, 7));
 assert(c.size() == 3);
 assert(r->first == 3);
 assert(r->second == Emplaceable(6, 7));
-assert(r == next(c.begin()));
+LIBCPP_ASSERT(r == next(c.begin()));
 r = c.begin();
 assert(r->first == 3);
-assert(r->second == Emplaceable());
+LIBCPP_ASSERT(r->second == Emplaceable());
 r = next(r, 2);
 assert(r->first == 3);
-assert(r->second == Emplaceable(5, 6));
+LIBCPP_ASSERT(r->second == Emplaceable(5, 6));
 }
 #if TEST_STD_VER >= 11
 {
@@ -76,20 +77,20 @@
 assert(c.size() == 2);
 assert(r->first == 3);
 assert(r->second == Emplaceable(5, 6));
-assert(r == next(c.begin()));
+LIBCPP_ASSERT(r == next(c.begin()));
 
 r = c.emplace_hint(r, std::piecewise_construct, std::forward_as_tuple(3),
 std::forward_as_tuple(6, 7));
 assert(c.size() == 3);
 assert(r->first == 3);
 assert(r->second == Emplaceable(6, 7));
-assert(r == next(c.begin()));
+LIBCPP_ASSERT(r == next(c.begin()));
 r = c.begin();
 assert(r->first == 3);
-assert(r->second == Emplaceable());
+LIBCPP_ASSERT(r->second == Emplaceable());
 r = next(r, 2);
 assert(r->first == 3);
-assert(r->second == Emplaceable(5, 6));
+LIBCPP_ASSERT(r->second == Emplaceable(5, 6));
 }
 #endif
 #if _LIBCPP_DEBUG >= 1
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/c

[PATCH] D26559: Insert a type check before reading vtable.

2016-11-14 Thread Peter Collingbourne via cfe-commits
pcc added inline comments.



Comment at: lib/CodeGen/CGExprCXX.cpp:93
+
+  EmitTypeCheck(CodeGenFunction::TCK_MemberCall,
+CallLoc, This, C.getRecordType(DD->getParent()));

pcc wrote:
> Is it correct to emit a type check at this point? Looking at [0] it looks 
> like this function is only called from the Microsoft C++ ABI after we have 
> already resolved the virtual function pointer.
> 
> [0] 
> http://llvm-cs.pcc.me.uk/tools/clang/lib/CodeGen/CGExprCXX.cpp/rEmitCXXDestructorCall
What about this comment?


https://reviews.llvm.org/D26559



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


[libcxx] r286883 - Missed a test with exceptions disabled earlier. Oops.

2016-11-14 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Nov 14 14:38:43 2016
New Revision: 286883

URL: http://llvm.org/viewvc/llvm-project?rev=286883&view=rev
Log:
Missed a test with exceptions disabled earlier. Oops.

Modified:
libcxx/trunk/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp?rev=286883&r1=286882&r2=286883&view=diff
==
--- libcxx/trunk/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp 
(original)
+++ libcxx/trunk/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp 
Mon Nov 14 14:38:43 2016
@@ -31,7 +31,7 @@ test(SV sv, unsigned pos, unsigned n)
 {
 typedef typename S::traits_type T;
 typedef typename S::allocator_type A;
-try
+if (pos <= sv.size())
 {
 S s2(sv, pos, n);
 LIBCPP_ASSERT(s2.__invariants());
@@ -42,10 +42,20 @@ test(SV sv, unsigned pos, unsigned n)
 assert(s2.get_allocator() == A());
 assert(s2.capacity() >= s2.size());
 }
-catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+else
 {
-assert(pos > sv.size());
+try
+{
+S s2(sv, pos, n);
+assert(false);
+}
+catch (std::out_of_range&)
+{
+assert(pos > sv.size());
+}
 }
+#endif
 }
 
 template 
@@ -162,5 +172,5 @@ int main()
 
 S s7(s.data(), 2); // calls ctor(const char *, len)
 assert(s7 == "AB");
-   }
+}
 }


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


[PATCH] D26559: Insert a type check before reading vtable.

2016-11-14 Thread Ivan Krasin via cfe-commits
krasin updated this revision to Diff 77868.
krasin added a comment.

Add a regression test.


https://reviews.llvm.org/D26559

Files:
  lib/CodeGen/CGExprCXX.cpp
  test/CodeGenCXX/ubsan-null.cpp


Index: test/CodeGenCXX/ubsan-null.cpp
===
--- /dev/null
+++ test/CodeGenCXX/ubsan-null.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm 
-fsanitize=null %s -o - | FileCheck %s
+struct T {
+  virtual int v() { return 1; }
+};
+
+struct U : T {
+  virtual int v() { return 2; }
+};
+
+// CHECK: define i32 @_Z5get_vP1T
+int get_v(T* t) {
+  // CHECK: [[UBSAN_CMP_RES:%[0-9]+]] = icmp ne %struct.T* %{{[_a-z0-9]+}}, 
null
+  // CHECK-NEXT: br i1 [[UBSAN_CMP_RES]], label %cont, label 
%handler.type_mismatch
+  // CHECK: call void @__ubsan_handle_type_mismatch_abort
+  // CHECK: load i32 (%struct.T*)**, i32 (%struct.T*)***
+  return t->v();
+}
Index: lib/CodeGen/CGExprCXX.cpp
===
--- lib/CodeGen/CGExprCXX.cpp
+++ lib/CodeGen/CGExprCXX.cpp
@@ -35,17 +35,6 @@
  "Trying to emit a member or operator call expr on a static method!");
   ASTContext &C = CGF.getContext();
 
-  // C++11 [class.mfct.non-static]p2:
-  //   If a non-static member function of a class X is called for an object 
that
-  //   is not of type X, or of a type derived from X, the behavior is 
undefined.
-  SourceLocation CallLoc;
-  if (CE)
-CallLoc = CE->getExprLoc();
-  CGF.EmitTypeCheck(isa(MD)
-? CodeGenFunction::TCK_ConstructorCall
-: CodeGenFunction::TCK_MemberCall,
-CallLoc, This, C.getRecordType(MD->getParent()));
-
   // Push the this ptr.
   const CXXRecordDecl *RD =
   CGF.CGM.getCXXABI().getThisArgumentTypeForMethod(MD);
@@ -96,6 +85,14 @@
 const CXXDestructorDecl *DD, const CGCallee &Callee, llvm::Value *This,
 llvm::Value *ImplicitParam, QualType ImplicitParamTy, const CallExpr *CE,
 StructorType Type) {
+SourceLocation CallLoc;
+  ASTContext &C = getContext();
+  if (CE)
+CallLoc = CE->getExprLoc();
+
+  EmitTypeCheck(CodeGenFunction::TCK_MemberCall,
+CallLoc, This, C.getRecordType(DD->getParent()));
+
   CallArgList Args;
   commonEmitCXXMemberOrOperatorCall(*this, DD, This, ImplicitParam,
 ImplicitParamTy, CE, Args, nullptr);
@@ -293,6 +290,19 @@
 
   llvm::FunctionType *Ty = CGM.getTypes().GetFunctionType(*FInfo);
 
+  // C++11 [class.mfct.non-static]p2:
+  //   If a non-static member function of a class X is called for an object 
that
+  //   is not of type X, or of a type derived from X, the behavior is 
undefined.
+  SourceLocation CallLoc;
+  ASTContext &C = getContext();
+  if (CE)
+CallLoc = CE->getExprLoc();
+
+  EmitTypeCheck(isa(CalleeDecl)
+? CodeGenFunction::TCK_ConstructorCall
+: CodeGenFunction::TCK_MemberCall,
+CallLoc, This.getPointer(), 
C.getRecordType(CalleeDecl->getParent()));
+
   // FIXME: Uses of 'MD' past this point need to be audited. We may need to use
   // 'CalleeDecl' instead.
 


Index: test/CodeGenCXX/ubsan-null.cpp
===
--- /dev/null
+++ test/CodeGenCXX/ubsan-null.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm -fsanitize=null %s -o - | FileCheck %s
+struct T {
+  virtual int v() { return 1; }
+};
+
+struct U : T {
+  virtual int v() { return 2; }
+};
+
+// CHECK: define i32 @_Z5get_vP1T
+int get_v(T* t) {
+  // CHECK: [[UBSAN_CMP_RES:%[0-9]+]] = icmp ne %struct.T* %{{[_a-z0-9]+}}, null
+  // CHECK-NEXT: br i1 [[UBSAN_CMP_RES]], label %cont, label %handler.type_mismatch
+  // CHECK: call void @__ubsan_handle_type_mismatch_abort
+  // CHECK: load i32 (%struct.T*)**, i32 (%struct.T*)***
+  return t->v();
+}
Index: lib/CodeGen/CGExprCXX.cpp
===
--- lib/CodeGen/CGExprCXX.cpp
+++ lib/CodeGen/CGExprCXX.cpp
@@ -35,17 +35,6 @@
  "Trying to emit a member or operator call expr on a static method!");
   ASTContext &C = CGF.getContext();
 
-  // C++11 [class.mfct.non-static]p2:
-  //   If a non-static member function of a class X is called for an object that
-  //   is not of type X, or of a type derived from X, the behavior is undefined.
-  SourceLocation CallLoc;
-  if (CE)
-CallLoc = CE->getExprLoc();
-  CGF.EmitTypeCheck(isa(MD)
-? CodeGenFunction::TCK_ConstructorCall
-: CodeGenFunction::TCK_MemberCall,
-CallLoc, This, C.getRecordType(MD->getParent()));
-
   // Push the this ptr.
   const CXXRecordDecl *RD =
   CGF.CGM.getCXXABI().getThisArgumentTypeForMethod(MD);
@@ -96,6 +85,14 @@
 const CXXDestructorDecl *DD, const CGCallee &Callee, llvm::Value *This,
 llvm::Value *ImplicitParam, QualTyp

[libcxx] r286884 - P0503R0, adopted in Issaquah, rewords some requirements on nullptr_t and istream_iterator. No code changes were needed, but I updated a few tests. Also resolved P0509 and P0521, whi

2016-11-14 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Nov 14 14:41:17 2016
New Revision: 286884

URL: http://llvm.org/viewvc/llvm-project?rev=286884&view=rev
Log:
P0503R0, adopted in Issaquah, rewords some requirements on nullptr_t and 
istream_iterator. No code changes were needed, but I updated a few tests.  Also 
resolved P0509 and P0521, which required no changes to the library or tests.

Modified:

libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp

libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp

libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp?rev=286884&r1=286883&r2=286884&view=diff
==
--- 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp
 Mon Nov 14 14:41:17 2016
@@ -12,11 +12,15 @@
 // class istream_iterator
 
 // istream_iterator(const istream_iterator& x);
+//  C++17 says:  If is_trivially_copy_constructible_v is true, then
+// this constructor shall beis a trivial copy constructor.
 
 #include 
 #include 
 #include 
 
+#include "test_macros.h"
+
 int main()
 {
 {

Modified: 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp?rev=286884&r1=286883&r2=286884&view=diff
==
--- 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
 Mon Nov 14 14:41:17 2016
@@ -12,12 +12,32 @@
 // class istream_iterator
 
 // constexpr istream_iterator();
+// C++17 says: If is_trivially_default_constructible_v is true, then this 
+//constructor shall beis a constexpr constructor.
 
 #include 
 #include 
+#include 
 
 #include "test_macros.h"
 
+struct S { S(); }; // not constexpr
+
+#if TEST_STD_VER > 14
+template >
+struct test_trivial {
+void operator ()() const {
+constexpr std::istream_iterator it;
+}
+};
+
+template 
+struct test_trivial {
+void operator ()() const {}
+};
+#endif
+
+
 int main()
 {
 {
@@ -29,4 +49,11 @@ int main()
 #endif
 }
 
+#if TEST_STD_VER > 14
+test_trivial()();
+test_trivial()();
+test_trivial()();   
+test_trivial()();
+test_trivial()();
+#endif
 }

Modified: 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp?rev=286884&r1=286883&r2=286884&view=diff
==
--- 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp
 Mon Nov 14 14:41:17 2016
@@ -23,9 +23,18 @@
 // typedef basic_istream istream_type;
 // ...
 //
+// Before C++17, we have:
 //   If T is a literal type, then the default constructor shall be a constexpr 
constructor.
 //   If T is a literal type, then this constructor shall be a trivial copy 
constructor.
 //   If T is a literal type, then this destructor shall be a trivial 
destructor.
+// C++17 says:
+//   If is_trivially_default_constructible_v is true, then
+//   this constructor (the default ctor) shall beis a constexpr 
constructor.
+//   If is_trivially_copy_constructible_v is true, then
+//   this constructor (the copy ctor) shall beis a trivial copy 
constructor.
+//   If is_trivially_destructible_v is true, then this
+//   destructor shall beis a trivial destructor.
+//  Testing the C++17 ctors for this are in the ctor tests.
 
 #include 
 #include 
@@ -33,7 +42,7 @@
 
 int main()
 {
-typedef std::istream_iterator I1;
+typedef std::istream_iterator I1; // double is trivially 
destructible
 static_assert((std::is_convertible >::value), "");
@@ -43,7 +52,7 @@ int main()
 static_assert( std::is_trivially_copy_constructible::value, "");
 static_assert( std::is_trivially_destructible::value, "");
 
-typedef std::istream_iterator I2;
+typedef std::istream_iterator I2; // unsigned is 
trivially destructible
 static_assert((std::is_c

[PATCH] D22997: [cxx1z-constexpr-lambda] Make conversion function constexpr, and teach the expression-evaluator to evaluate the static-invoker.

2016-11-14 Thread Akira Hatanaka via cfe-commits
ahatanak added inline comments.



Comment at: lib/AST/ExprConstant.cpp:4427
+const CXXRecordDecl *ClosureClass = MD->getParent();
+assert((std::distance(ClosureClass->captures_begin(),
+  ClosureClass->captures_end()) == 0) &&

Can you just compare iterators here?

```
ClosureClass->captures_begin() == ClosureClass->captures_end()
```



https://reviews.llvm.org/D22997



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


[PATCH] D25206: [Parser] Correct typo after lambda capture initializer is parsed

2016-11-14 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

Are there any further comments?


https://reviews.llvm.org/D25206



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


[PATCH] D25916: Modules: emit an error instead of a random crash (or a misleading error) due to use-after-free.

2016-11-14 Thread Ben Langmuir via cfe-commits
benlangmuir added a comment.

> Does it mean that a system module should only import system modules? If a 
> system module is allowed to import non-system modules, for a non-system 
> module, we will validate diagnostic options differently depending on whether 
> a system module or a non-system module imports it. This will cause a 
> non-system module that was validated earlier to be invalidated by a child 
> thread.

It seems like we should validate the options the same way regardless of what 
the importer is, but I'm guessing this was done for a reason... What's the 
behaviour of a user-header imported by a system header (without modules)?  If 
the user header warnings show up even without -Wsystem-headers, then we should 
be okay validating, right?


https://reviews.llvm.org/D25916



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


[PATCH] D26115: [test] Correctly include build llvm_shlib_dir in stand-alone builds

2016-11-14 Thread Chris Bieneman via cfe-commits
beanz added inline comments.



Comment at: test/lit.cfg:109
+if not llvm_shlib_dir:
+lit_config.fatal('No LLVM shlib dir set!')
 llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)

Should this really be fatal? It seems to me in many cases you might not need 
this to be set.


https://reviews.llvm.org/D26115



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


Re: r286748 - Fix PR28366: Handle variables from enclosing local scopes more gracefully during constant expression evaluation.

2016-11-14 Thread Vedant Kumar via cfe-commits
Hi Faisal,

Our ASan bot started complaining after this commit.

I'm not 100% sure this caused it yet, though I'm running tests.

Could you take a look?

thanks,
vedant


FAIL: Clang :: SemaCXX/constant-expression-cxx11.cpp (9393 of 29261)

 TEST 'Clang :: SemaCXX/constant-expression-cxx11.cpp' 
FAILED 

Script:
--
ulimit -s 1 && 
/Users/buildslave/jenkins/workspace/clangsan-branch-R-nobootstrap-cmake/clang-build/./bin/clang
 -cc1 -internal-isystem 
/Users/buildslave/jenkins/workspace/clangsan-branch-R-nobootstrap-cmake/clang-build/bin/../lib/clang/4.0.0/include
 -nostdsysteminc -triple i686-linux -Wno-string-plus-int -Wno-pointer-arith 
-Wno-zero-length-array -fsyntax-only -fcxx-exceptions -verify -std=c++11 
-pedantic 
/Users/buildslave/jenkins/workspace/clangsan-branch-R-nobootstrap-cmake/clang/src/tools/clang/test/SemaCXX/constant-expression-cxx11.cpp
 -Wno-comment -Wno-tautological-pointer-compare -Wno-bool-conversion
--
Exit Code: 134

Command Output (stderr):
--
ASAN:DEADLYSIGNAL
=
==86262==ERROR: AddressSanitizer: stack-overflow on address 0x7fff50fda580 (pc 
0x0001165bcf2d bp 0x7fff50fdb1f0 sp 0x7fff50fda580 T0)
#0 0x1165bcf2c in Evaluate(clang::APValue&, (anonymous 
namespace)::EvalInfo&, clang::Expr const*) ExprConstant.cpp:9142

SUMMARY: AddressSanitizer: stack-overflow ExprConstant.cpp:9142 in 
Evaluate(clang::APValue&, (anonymous namespace)::EvalInfo&, clang::Expr const*)
==86262==ABORTING
Stack dump:
0.  Program arguments: 
/Users/buildslave/jenkins/workspace/clangsan-branch-R-nobootstrap-cmake/clang-build/./bin/clang
 -cc1 -internal-isystem 
/Users/buildslave/jenkins/workspace/clangsan-branch-R-nobootstrap-cmake/clang-build/bin/../lib/clang/4.0.0/include
 -nostdsysteminc -triple i686-linux -Wno-string-plus-int -Wno-pointer-arith 
-Wno-zero-length-array -fsyntax-only -fcxx-exceptions -verify -std=c++11 
-pedantic 
/Users/buildslave/jenkins/workspace/clangsan-branch-R-nobootstrap-cmake/clang/src/tools/clang/test/SemaCXX/constant-expression-cxx11.cpp
 -Wno-comment -Wno-tautological-pointer-compare -Wno-bool-conversion 
1.  
/Users/buildslave/jenkins/workspace/clangsan-branch-R-nobootstrap-cmake/clang/src/tools/clang/test/SemaCXX/constant-expression-cxx11.cpp:1457:1:
 current parser token '}'
2.  
/Users/buildslave/jenkins/workspace/clangsan-branch-R-nobootstrap-cmake/clang/src/tools/clang/test/SemaCXX/constant-expression-cxx11.cpp:1435:1:
 parsing namespace 'RecursiveOpaqueExpr'
/Users/buildslave/jenkins/workspace/clangsan-branch-R-nobootstrap-cmake/clang-build/tools/clang/test/SemaCXX/Output/constant-expression-cxx11.cpp.script:
 line 1: 86262 Abort trap: 6   
/Users/buildslave/jenkins/workspace/clangsan-branch-R-nobootstrap-cmake/clang-build/./bin/clang
 -cc1 -internal-isystem 
/Users/buildslave/jenkins/workspace/clangsan-branch-R-nobootstrap-cmake/clang-build/bin/../lib/clang/4.0.0/include
 -nostdsysteminc -triple i686-linux -Wno-string-plus-int -Wno-pointer-arith 
-Wno-zero-length-array -fsyntax-only -fcxx-exceptions -verify -std=c++11 
-pedantic 
/Users/buildslave/jenkins/workspace/clangsan-branch-R-nobootstrap-cmake/clang/src/tools/clang/test/SemaCXX/constant-expression-cxx11.cpp
 -Wno-comment -Wno-tautological-pointer-compare -Wno-bool-conversion



> On Nov 12, 2016, at 10:09 PM, Faisal Vali via cfe-commits 
>  wrote:
> 
> Author: faisalv
> Date: Sun Nov 13 00:09:16 2016
> New Revision: 286748
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=286748&view=rev
> Log:
> Fix PR28366: Handle variables from enclosing local scopes more gracefully 
> during constant expression evaluation.
> 
> Only look for a variable's value in the constant expression evaluation 
> activation frame, if the variable was indeed declared in that frame, 
> otherwise it might be a constant expression and be usable within a nested 
> local scope or emit an error.
> 
> 
> void f(char c) { 
>  struct X {
>static constexpr char f() { 
>  return c; // error gracefully here as opposed to crashing.
>}
>  };
>  int I = X::f();
> }
> 
> 
> Modified:
>cfe/trunk/lib/AST/ExprConstant.cpp
>cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
>cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp
>cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
> 
> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=286748&r1=286747&r2=286748&view=diff
> ==
> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> +++ cfe/trunk/lib/AST/ExprConstant.cpp Sun Nov 13 00:09:16 2016
> @@ -4803,10 +4803,21 @@ bool LValueExprEvaluator::VisitDeclRefEx
>   return Error(E);
> }
> 
> +
> bool LValueExprEvaluator::VisitVarDecl(const Expr *E, const VarDecl *VD) {
>   CallStackFrame *Frame = nullptr;
> -  if (VD->hasLocalStorage() && Info.CurrentCall->In

[PATCH] D26115: [test] Correctly include build llvm_shlib_dir in stand-alone builds

2016-11-14 Thread Michał Górny via cfe-commits
mgorny added inline comments.



Comment at: test/lit.cfg:109
+if not llvm_shlib_dir:
+lit_config.fatal('No LLVM shlib dir set!')
 llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)

beanz wrote:
> Should this really be fatal? It seems to me in many cases you might not need 
> this to be set.
I don't mind either way. I left it like this since I really don't see a case 
when it could be unset ;-).


https://reviews.llvm.org/D26115



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


[PATCH] D26559: Insert a type check before reading vtable.

2016-11-14 Thread Ivan Krasin via cfe-commits
krasin added inline comments.



Comment at: lib/CodeGen/CGExprCXX.cpp:93
+
+  EmitTypeCheck(CodeGenFunction::TCK_MemberCall,
+CallLoc, This, C.getRecordType(DD->getParent()));

pcc wrote:
> pcc wrote:
> > Is it correct to emit a type check at this point? Looking at [0] it looks 
> > like this function is only called from the Microsoft C++ ABI after we have 
> > already resolved the virtual function pointer.
> > 
> > [0] 
> > http://llvm-cs.pcc.me.uk/tools/clang/lib/CodeGen/CGExprCXX.cpp/rEmitCXXDestructorCall
> What about this comment?
Sorry, I have missed the comment. I have added this check here to preserve the 
existing behavior.

From what you describe, there could be a very similar issue related to the 
Microsoft C++ ABI to the one that I fix here. I am okay to file a bug or add a 
note about this, your choice.


https://reviews.llvm.org/D26559



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


[PATCH] D26559: Insert a type check before reading vtable.

2016-11-14 Thread Peter Collingbourne via cfe-commits
pcc added inline comments.



Comment at: lib/CodeGen/CGExprCXX.cpp:93
+
+  EmitTypeCheck(CodeGenFunction::TCK_MemberCall,
+CallLoc, This, C.getRecordType(DD->getParent()));

krasin wrote:
> pcc wrote:
> > pcc wrote:
> > > Is it correct to emit a type check at this point? Looking at [0] it looks 
> > > like this function is only called from the Microsoft C++ ABI after we 
> > > have already resolved the virtual function pointer.
> > > 
> > > [0] 
> > > http://llvm-cs.pcc.me.uk/tools/clang/lib/CodeGen/CGExprCXX.cpp/rEmitCXXDestructorCall
> > What about this comment?
> Sorry, I have missed the comment. I have added this check here to preserve 
> the existing behavior.
> 
> From what you describe, there could be a very similar issue related to the 
> Microsoft C++ ABI to the one that I fix here. I am okay to file a bug or add 
> a note about this, your choice.
Have you looked at how hard it would be to fix this?


https://reviews.llvm.org/D26559



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


Re: r286748 - Fix PR28366: Handle variables from enclosing local scopes more gracefully during constant expression evaluation.

2016-11-14 Thread Vedant Kumar via cfe-commits
Reverting this commit doesn't solve anything, sorry for the noise.

It seems to hit an infinite loop:

frame #17: 0x0001083d48ab clang`::Visit() [inlined] 
HandleConditionalOperator + 165 at 
ExprConstant.cpp:4212
frame #18: 0x0001083d4806 clang`::Visit() [inlined] 
VisitConditionalOperator at ExprConstant.cpp:4331
frame #19: 0x0001083d4806 clang`::Visit() + 33158 at StmtNodes.inc:129
frame #20: 0x00010835c43c clang`::Evaluate() + 1468 at 
ExprConstant.cpp:9155
frame #21: 0x0001083bad54 clang`::EvaluateStmt() + 15572 at 
ExprConstant.cpp:3663
frame #22: 0x0001083b9147 clang`::EvaluateStmt() + 8391 at 
ExprConstant.cpp:3673
frame #23: 0x000108360829 clang`::HandleFunctionCall() + 1657 at 
ExprConstant.cpp:3994
frame #24: 0x00010842f681 clang`::handleCallExpr() + 3697 at 
ExprConstant.cpp:4438
frame #25: 0x0001083ea4c5 clang`::VisitCallExpr() [inlined] 
VisitCallExpr + 54 at ExprConstant.cpp:4355
frame #26: 0x0001083ea48f clang`::VisitCallExpr() + 11407 at 
ExprConstant.cpp:6937
frame #27: 0x0001083ccdcd clang`::Visit() + 1869 at Expr.h:1705
frame #28: 0x00010835c43c clang`::Evaluate() + 1468 at 
ExprConstant.cpp:9155
frame #29: 0x0001083cf094 clang`::Visit() [inlined] 
VisitBinaryConditionalOperator + 145 at ExprConstant.cpp:4307
frame #30: 0x0001083cf003 clang`::Visit() + 10627 at StmtNodes.inc:123
frame #31: 0x0001083d1b7f clang`::Visit() + 21759 at ExprCXX.h:2998
frame #32: 0x0001083d48ab clang`::Visit() [inlined] 
HandleConditionalOperator + 165 at 
ExprConstant.cpp:4212

sudo ulimit -s 65000 && lldb  
/Users/buildslave/jenkins/workspace/clangsan-branch-R-nobootstrap-cmake/clang-build/./bin/clang
 -- -cc1 -internal-isystem 
/Users/buildslave/jenkins/workspace/clangsan-branch-R-nobootstrap-cmake/clang-build/bin/../lib/clang/4.0.0/include
 -nostdsysteminc -triple i686-linux -Wno-string-plus-int -Wno-pointer-arith 
-Wno-zero-length-array -fsyntax-only -fcxx-exceptions -verify -std=c++11 
-pedantic 
/Users/buildslave/jenkins/workspace/clangsan-branch-R-nobootstrap-cmake/clang/src/tools/clang/test/SemaCXX/constant-expression-cxx11.cpp
 -Wno-comment -Wno-tautological-pointer-compare -Wno-bool-conversion

vedant

> On Nov 14, 2016, at 1:56 PM, Vedant Kumar  wrote:
> 
> Hi Faisal,
> 
> Our ASan bot started complaining after this commit.
> 
> I'm not 100% sure this caused it yet, though I'm running tests.
> 
> Could you take a look?
> 
> thanks,
> vedant
> 
> 
> FAIL: Clang :: SemaCXX/constant-expression-cxx11.cpp (9393 of 29261)
> 
>  TEST 'Clang :: SemaCXX/constant-expression-cxx11.cpp' 
> FAILED 
> 
> Script:
> --
> ulimit -s 1 && 
> /Users/buildslave/jenkins/workspace/clangsan-branch-R-nobootstrap-cmake/clang-build/./bin/clang
>  -cc1 -internal-isystem 
> /Users/buildslave/jenkins/workspace/clangsan-branch-R-nobootstrap-cmake/clang-build/bin/../lib/clang/4.0.0/include
>  -nostdsysteminc -triple i686-linux -Wno-string-plus-int -Wno-pointer-arith 
> -Wno-zero-length-array -fsyntax-only -fcxx-exceptions -verify -std=c++11 
> -pedantic 
> /Users/buildslave/jenkins/workspace/clangsan-branch-R-nobootstrap-cmake/clang/src/tools/clang/test/SemaCXX/constant-expression-cxx11.cpp
>  -Wno-comment -Wno-tautological-pointer-compare -Wno-bool-conversion
> --
> Exit Code: 134
> 
> Command Output (stderr):
> --
> ASAN:DEADLYSIGNAL
> =
> ==86262==ERROR: AddressSanitizer: stack-overflow on address 0x7fff50fda580 
> (pc 0x0001165bcf2d bp 0x7fff50fdb1f0 sp 0x7fff50fda580 T0)
>#0 0x1165bcf2c in Evaluate(clang::APValue&, (anonymous 
> namespace)::EvalInfo&, clang::Expr const*) ExprConstant.cpp:9142
> 
> SUMMARY: AddressSanitizer: stack-overflow ExprConstant.cpp:9142 in 
> Evaluate(clang::APValue&, (anonymous namespace)::EvalInfo&, clang::Expr 
> const*)
> ==86262==ABORTING
> Stack dump:
> 0.Program arguments: 
> /Users/buildslave/jenkins/workspace/clangsan-branch-R-nobootstrap-cmake/clang-build/./bin/clang
>  -cc1 -internal-isystem 
> /Users/buildslave/jenkins/workspace/clangsan-branch-R-nobootstrap-cmake/clang-build/bin/../lib/clang/4.0.0/include
>  -nostdsysteminc -triple i686-linux -Wno-string-plus-int -Wno-pointer-arith 
> -Wno-zero-length-array -fsyntax-only -fcxx-exceptions -verify -std=c++11 
> -pedantic 
> /Users/buildslave/jenkins/workspace/clangsan-branch-R-nobootstrap-cmake/clang/src/tools/clang/test/SemaCXX/constant-expression-cxx11.cpp
>  -Wno-comment -Wno-tautological-pointer-compare -Wno-bool-conversion 
> 1.
> /Users/buildslave/jenkins/workspace/clangsan-branch-R-nobootstrap-cmake/clang/src/tools/clang/test/SemaCXX/constant-expression-cxx11.cpp:1457:1:
>  current parser token '}'
> 2.
> /Users/buildslave/jenkins/workspace/clangsan-branch-R-nobootstrap-cmake/clang/src/tools/clang/test/SemaCXX/constant-expression-cxx11.cpp:1435:1:
>  parsing namespace 'RecursiveOpaqueEx

r286898 - [sanitizer] Passthrough CMAKE_OSX_DEPLOYMENT_TARGET when building compiler-rt from clang/runtime/CMakeLists.txt

2016-11-14 Thread Kuba Brecka via cfe-commits
Author: kuba.brecka
Date: Mon Nov 14 16:38:57 2016
New Revision: 286898

URL: http://llvm.org/viewvc/llvm-project?rev=286898&view=rev
Log:
[sanitizer] Passthrough CMAKE_OSX_DEPLOYMENT_TARGET when building compiler-rt 
from clang/runtime/CMakeLists.txt

This breaks some Swift builds, because Swift's build scripts explicitly set 
CMAKE_OSX_DEPLOYMENT_TARGET. This however isn't propagated to the compiler-rt 
build, causing build errors.

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


Modified:
cfe/trunk/runtime/CMakeLists.txt

Modified: cfe/trunk/runtime/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/runtime/CMakeLists.txt?rev=286898&r1=286897&r2=286898&view=diff
==
--- cfe/trunk/runtime/CMakeLists.txt (original)
+++ cfe/trunk/runtime/CMakeLists.txt Mon Nov 14 16:38:57 2016
@@ -77,6 +77,7 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND E
-DCOMPILER_RT_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX}
+   -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
${COMPILER_RT_PASSTHROUGH_VARIABLES}
 INSTALL_COMMAND ""
 STEP_TARGETS configure build


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


r286901 - [analyzer] Fix crash in NullabilityChecker calling block with too few arguments

2016-11-14 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Mon Nov 14 16:46:02 2016
New Revision: 286901

URL: http://llvm.org/viewvc/llvm-project?rev=286901&view=rev
Log:
[analyzer] Fix crash in NullabilityChecker calling block with too few arguments

Fix a crash when checking parameter nullability on a block invocation
with fewer arguments than the block declaration requires.

rdar://problem/29237566

Added:
cfe/trunk/test/Analysis/nullability.c
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp?rev=286901&r1=286900&r2=286901&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp Mon Nov 14 
16:46:02 2016
@@ -679,9 +679,10 @@ void NullabilityChecker::checkPreCall(co
 if (Param->isParameterPack())
   break;
 
-const Expr *ArgExpr = nullptr;
-if (Idx < Call.getNumArgs())
-  ArgExpr = Call.getArgExpr(Idx);
+if (Idx >= Call.getNumArgs())
+  break;
+
+const Expr *ArgExpr = Call.getArgExpr(Idx);
 auto ArgSVal = Call.getArgSVal(Idx++).getAs();
 if (!ArgSVal)
   continue;

Added: cfe/trunk/test/Analysis/nullability.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/nullability.c?rev=286901&view=auto
==
--- cfe/trunk/test/Analysis/nullability.c (added)
+++ cfe/trunk/test/Analysis/nullability.c Mon Nov 14 16:46:02 2016
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fblocks -analyze -analyzer-checker=core,nullability 
-verify %s
+
+void it_takes_two(int a, int b);
+void function_pointer_arity_mismatch() {
+  void(*fptr)() = it_takes_two;
+  fptr(1); // no-crash expected-warning {{Function taking 2 arguments is 
called with less (1)}}
+}
+
+void block_arity_mismatch() {
+  void(^b)() = ^(int a, int b) { }; // no-crash
+  b(1);
+}


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


[PATCH] D26115: [test] Correctly include build llvm_shlib_dir in stand-alone builds

2016-11-14 Thread Chris Bieneman via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

LGTM!




Comment at: test/lit.cfg:109
+if not llvm_shlib_dir:
+lit_config.fatal('No LLVM shlib dir set!')
 llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)

mgorny wrote:
> beanz wrote:
> > Should this really be fatal? It seems to me in many cases you might not 
> > need this to be set.
> I don't mind either way. I left it like this since I really don't see a case 
> when it could be unset ;-).
Ah! You're right. I didn't see where it was getting set.


https://reviews.llvm.org/D26115



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


[PATCH] D26642: [analyzer] Minor optimizaiton: avoid setting state if unchanged

2016-11-14 Thread Dominic Chen via cfe-commits
ddcc created this revision.
ddcc added reviewers: zaks.anna, dcoughlin.
ddcc added a subscriber: cfe-commits.

Split out optimization from https://reviews.llvm.org/D26061


https://reviews.llvm.org/D26642

Files:
  lib/StaticAnalyzer/Core/RangeConstraintManager.cpp


Index: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -398,17 +398,19 @@
 ProgramStateRef
 RangeConstraintManager::removeDeadBindings(ProgramStateRef state,
SymbolReaper& SymReaper) {
-
+  bool Changed = false;
   ConstraintRangeTy CR = state->get();
-  ConstraintRangeTy::Factory& CRFactory = 
state->get_context();
+  ConstraintRangeTy::Factory &CRFactory = 
state->get_context();
 
   for (ConstraintRangeTy::iterator I = CR.begin(), E = CR.end(); I != E; ++I) {
 SymbolRef sym = I.getKey();
-if (SymReaper.maybeDead(sym))
+if (SymReaper.maybeDead(sym)) {
+  Changed = true;
   CR = CRFactory.remove(CR, sym);
+}
   }
 
-  return state->set(CR);
+  return Changed ? state->set(CR) : state;
 }
 
 RangeSet


Index: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -398,17 +398,19 @@
 ProgramStateRef
 RangeConstraintManager::removeDeadBindings(ProgramStateRef state,
SymbolReaper& SymReaper) {
-
+  bool Changed = false;
   ConstraintRangeTy CR = state->get();
-  ConstraintRangeTy::Factory& CRFactory = state->get_context();
+  ConstraintRangeTy::Factory &CRFactory = state->get_context();
 
   for (ConstraintRangeTy::iterator I = CR.begin(), E = CR.end(); I != E; ++I) {
 SymbolRef sym = I.getKey();
-if (SymReaper.maybeDead(sym))
+if (SymReaper.maybeDead(sym)) {
+  Changed = true;
   CR = CRFactory.remove(CR, sym);
+}
   }
 
-  return state->set(CR);
+  return Changed ? state->set(CR) : state;
 }
 
 RangeSet
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26644: [analyzer] Rename assumeWithinInclusiveRange*()

2016-11-14 Thread Dominic Chen via cfe-commits
ddcc created this revision.
ddcc added reviewers: zaks.anna, dcoughlin.
ddcc added a subscriber: cfe-commits.

The name is slightly confusing, since the constraint is not necessarily within 
the range unless `Assumption` is true. Split out renaming for 
ConstraintManager.h from https://reviews.llvm.org/D26061


https://reviews.llvm.org/D26644

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
  lib/StaticAnalyzer/Core/SimpleConstraintManager.h

Index: lib/StaticAnalyzer/Core/SimpleConstraintManager.h
===
--- lib/StaticAnalyzer/Core/SimpleConstraintManager.h
+++ lib/StaticAnalyzer/Core/SimpleConstraintManager.h
@@ -38,7 +38,7 @@
 
   ProgramStateRef assume(ProgramStateRef state, NonLoc Cond, bool Assumption);
 
-  ProgramStateRef assumeWithinInclusiveRange(ProgramStateRef State,
+  ProgramStateRef assumeInclusiveRange(ProgramStateRef State,
  NonLoc Value,
  const llvm::APSInt &From,
  const llvm::APSInt &To,
Index: lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
@@ -190,7 +190,7 @@
   } // end switch
 }
 
-ProgramStateRef SimpleConstraintManager::assumeWithinInclusiveRange(
+ProgramStateRef SimpleConstraintManager::assumeInclusiveRange(
 ProgramStateRef State, NonLoc Value, const llvm::APSInt &From,
 const llvm::APSInt &To, bool InRange) {
 
@@ -207,7 +207,7 @@
 
   switch (Value.getSubKind()) {
   default:
-llvm_unreachable("'assumeWithinInclusiveRange' is not implemented"
+llvm_unreachable("'assumeInclusiveRange' is not implemented"
  "for this NonLoc");
 
   case nonloc::LocAsIntegerKind:
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1836,7 +1836,7 @@
 ProgramStateRef StateCase;
 if (Optional NL = CondV.getAs())
   std::tie(StateCase, DefaultSt) =
-  DefaultSt->assumeWithinInclusiveRange(*NL, V1, V2);
+  DefaultSt->assumeInclusiveRange(*NL, V1, V2);
 else // UnknownVal
   StateCase = DefaultSt;
 
Index: lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -254,7 +254,7 @@
   const llvm::APSInt &Min = BVF.getValue(R[I].first, T);
   const llvm::APSInt &Max = BVF.getValue(R[I].second, T);
   assert(Min <= Max);
-  State = CM.assumeWithinInclusiveRange(State, *N, Min, Max, false);
+  State = CM.assumeInclusiveRange(State, *N, Min, Max, false);
   if (!State)
 break;
 }
@@ -288,24 +288,24 @@
 const llvm::APSInt &Left = BVF.getValue(R[0].first - 1ULL, T);
 if (Left != PlusInf) {
   assert(MinusInf <= Left);
-  State = CM.assumeWithinInclusiveRange(State, *N, MinusInf, Left, false);
+  State = CM.assumeInclusiveRange(State, *N, MinusInf, Left, false);
   if (!State)
 return nullptr;
 }
 
 const llvm::APSInt &Right = BVF.getValue(R[E - 1].second + 1ULL, T);
 if (Right != MinusInf) {
   assert(Right <= PlusInf);
-  State = CM.assumeWithinInclusiveRange(State, *N, Right, PlusInf, false);
+  State = CM.assumeInclusiveRange(State, *N, Right, PlusInf, false);
   if (!State)
 return nullptr;
 }
 
 for (size_t I = 1; I != E; ++I) {
   const llvm::APSInt &Min = BVF.getValue(R[I - 1].second + 1ULL, T);
   const llvm::APSInt &Max = BVF.getValue(R[I].first - 1ULL, T);
   assert(Min <= Max);
-  State = CM.assumeWithinInclusiveRange(State, *N, Min, Max, false);
+  State = CM.assumeInclusiveRange(State, *N, Min, Max, false);
   if (!State)
 return nullptr;
 }
Index: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -98,18 +98,18 @@
   /// This ctor is used when creating the first ProgramState object.
   ProgramState(ProgramStateManager *mgr, const Environment& env,
   StoreRef st, GenericDataMap gdm);
-
+
   /// Copy ctor - We must explicitly define this or else the "Next" ptr
   ///  in FoldingSetNode will also 

[PATCH] D26644: [analyzer] Rename assumeWithinInclusiveRange*()

2016-11-14 Thread Devin Coughlin via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

LGTM, other then some indentation issues for arguments and parameters after the 
rename. Please fix those and commit! And thanks for splitting this up.




Comment at: 
include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h:103
+  virtual ProgramStateRef assumeInclusiveRange(ProgramStateRef State,
  NonLoc Value,
  const llvm::APSInt &From,

Nit: The indentation here (and elsewhere) is off after the rename.


https://reviews.llvm.org/D26644



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


[PATCH] D26642: [analyzer] Minor optimization: avoid setting state if unchanged

2016-11-14 Thread Devin Coughlin via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

LGTM. Please commit!


https://reviews.llvm.org/D26642



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


[PATCH] D25916: Modules: emit an error instead of a random crash (or a misleading error) due to use-after-free.

2016-11-14 Thread Manman Ren via cfe-commits
manmanren added a comment.

In https://reviews.llvm.org/D25916#594844, @benlangmuir wrote:

> > Does it mean that a system module should only import system modules? If a 
> > system module is allowed to import non-system modules, for a non-system 
> > module, we will validate diagnostic options differently depending on 
> > whether a system module or a non-system module imports it. This will cause 
> > a non-system module that was validated earlier to be invalidated by a child 
> > thread.
>
> It seems like we should validate the options the same way regardless of what 
> the importer is, but I'm guessing this was done for a reason... What's the 
> behaviour of a user-header imported by a system header (without modules)?  If 
> the user header warnings show up even without -Wsystem-headers, then we 
> should be okay validating, right?


I tried a simple example:
cat test.mm 
#include "a.h"
cat Inputs/System/a.h 
#include "b.h"
cat Inputs/b.h 
void double_declarator1(int *_Nonnull *); // expected-warning{{pointer is 
missing a nullability type specifier (_Nonnull, _Nullable, or 
_Null_unspecified)}}

clang -cc1 -fsyntax-only -fblocks -I Inputs/ -isystem Inputs/System/ test.mm
--> has no warning
~/llvm_gmail/debug/bin/clang -cc1 -fsyntax-only -fblocks -I Inputs/ -isystem 
Inputs/System/ test.mm -Wsystem-headers
--> has one warning

Without modules, the user header warnings do not show up if it is included by a 
system header (without -Wsystem-headers). To exactly match this behavior, user 
modules need to be validated considering the importing context. We will need to 
change the code snippets I mentioned earlier to re-validate the options when 
the importing context changes.

Thanks,
Manman


https://reviews.llvm.org/D25916



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


[PATCH] D26649: [CMake] Support lld with LTO bootstrap

2016-11-14 Thread Petr Hosek via cfe-commits
phosek created this revision.
phosek added a reviewer: beanz.
phosek added subscribers: cfe-commits, ruiu.
phosek set the repository for this revision to rL LLVM.
Herald added subscribers: mehdi_amini, mgorny.

lld has LTO support, if requested we should add a dependency on lld rather than 
LLVMgold when doing LTO bootstrap build.


Repository:
  rL LLVM

https://reviews.llvm.org/D26649

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -511,7 +511,7 @@
   set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-stamps/)
   set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-bins/)
 
-  # If the next stage is LTO we need to depend on LTO and possibly LLVMgold
+  # If the next stage is LTO we need to depend on LTO and possibly lld or 
LLVMgold
   if(BOOTSTRAP_LLVM_ENABLE_LTO OR LLVM_ENABLE_LTO AND NOT 
LLVM_BUILD_INSTRUMENTED)
 add_dependencies(clang-bootstrap-deps LTO)
 if(APPLE)
@@ -526,7 +526,12 @@
   set(LTO_LIBRARY 
-DDARWIN_LTO_LIBRARY=${LLVM_SHLIB_OUTPUT_INTDIR}/libLTO.dylib
 -DDYLD_LIBRARY_PATH=${LLVM_LIBRARY_OUTPUT_INTDIR})
 elseif(NOT WIN32)
-  add_dependencies(clang-bootstrap-deps LLVMgold llvm-ar llvm-ranlib)
+  add_dependencies(clang-bootstrap-deps llvm-ar llvm-ranlib)
+  if(LLVM_ENABLE_LLD)
+add_dependencies(lld)
+  elseif(LLVM_BINUTILS_INCDIR)
+add_dependencies(LLVMgold)
+  endif()
   set(LTO_AR -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar)
   set(LTO_RANLIB -DCMAKE_RANLIB=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ranlib)
 endif()


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -511,7 +511,7 @@
   set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-stamps/)
   set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-bins/)
 
-  # If the next stage is LTO we need to depend on LTO and possibly LLVMgold
+  # If the next stage is LTO we need to depend on LTO and possibly lld or LLVMgold
   if(BOOTSTRAP_LLVM_ENABLE_LTO OR LLVM_ENABLE_LTO AND NOT LLVM_BUILD_INSTRUMENTED)
 add_dependencies(clang-bootstrap-deps LTO)
 if(APPLE)
@@ -526,7 +526,12 @@
   set(LTO_LIBRARY -DDARWIN_LTO_LIBRARY=${LLVM_SHLIB_OUTPUT_INTDIR}/libLTO.dylib
 -DDYLD_LIBRARY_PATH=${LLVM_LIBRARY_OUTPUT_INTDIR})
 elseif(NOT WIN32)
-  add_dependencies(clang-bootstrap-deps LLVMgold llvm-ar llvm-ranlib)
+  add_dependencies(clang-bootstrap-deps llvm-ar llvm-ranlib)
+  if(LLVM_ENABLE_LLD)
+add_dependencies(lld)
+  elseif(LLVM_BINUTILS_INCDIR)
+add_dependencies(LLVMgold)
+  endif()
   set(LTO_AR -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar)
   set(LTO_RANLIB -DCMAKE_RANLIB=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ranlib)
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26649: [CMake] Support lld with LTO bootstrap

2016-11-14 Thread Mehdi AMINI via cfe-commits
mehdi_amini added a comment.

Make sense to me, but I don't think it is enough: LLVM_ENABLE_LLD should be 
passed to stage-2, and it also should be set to the absolute path of the 
stage-1 lld build.


Repository:
  rL LLVM

https://reviews.llvm.org/D26649



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


[PATCH] D26649: [CMake] Support lld with LTO bootstrap

2016-11-14 Thread Mehdi AMINI via cfe-commits
mehdi_amini added inline comments.



Comment at: CMakeLists.txt:516
   if(BOOTSTRAP_LLVM_ENABLE_LTO OR LLVM_ENABLE_LTO AND NOT 
LLVM_BUILD_INSTRUMENTED)
 add_dependencies(clang-bootstrap-deps LTO)
 if(APPLE)

This dep does not make sense when using either lld or gold by the way.


Repository:
  rL LLVM

https://reviews.llvm.org/D26649



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


[PATCH] D26654: [CMake] Add Fuchsia toolchain CMake cache files

2016-11-14 Thread Petr Hosek via cfe-commits
phosek created this revision.
phosek added a reviewer: beanz.
phosek added a subscriber: cfe-commits.
phosek set the repository for this revision to rL LLVM.
Herald added a subscriber: mgorny.

These cache files can be used to build Fuchsia Clang toolchain. They also 
demonstrate the use of multi-target builtins build.


Repository:
  rL LLVM

https://reviews.llvm.org/D26654

Files:
  cmake/caches/Fuchsia-stage2.cmake
  cmake/caches/Fuchsia.cmake


Index: cmake/caches/Fuchsia.cmake
===
--- /dev/null
+++ cmake/caches/Fuchsia.cmake
@@ -0,0 +1,33 @@
+# This file sets up a CMakeCache for a Fuchsia toolchain build.
+
+set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
+
+set(CMAKE_BUILD_TYPE Release CACHE STRING "")
+
+set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
+
+set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
+
+set(CLANG_BOOTSTRAP_TARGETS
+  check-all
+  check-llvm
+  check-clang
+  llvm-config
+  test-suite
+  test-depends
+  llvm-test-depends
+  clang-test-depends
+  distribution
+  install-distribution
+  clang CACHE STRING "")
+
+if(FUCHSIA_SYSROOT)
+  set(EXTRA_ARGS -DFUCHSIA_SYSROOT=${FUCHSIA_SYSROOT})
+endif()
+
+# Setup the bootstrap build.
+set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
+set(CLANG_BOOTSTRAP_CMAKE_ARGS
+  ${EXTRA_ARGS}
+  -C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake
+  CACHE STRING "")
Index: cmake/caches/Fuchsia-stage2.cmake
===
--- /dev/null
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -0,0 +1,46 @@
+# This file sets up a CMakeCache for the second stage of a Fuchsia toolchain
+# build.
+
+set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64 CACHE STRING "")
+
+set(LLVM_ENABLE_LTO ON CACHE BOOL "")
+if(NOT APPLE)
+  set(LLVM_ENABLE_LLD ON CACHE BOOL "")
+endif()
+
+set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
+set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
+
+set(LLVM_BUILTIN_TARGETS "x86_64-fuchsia;aarch64-fuchsia" CACHE STRING "")
+set(BUILTINS_x86_64-fuchsia_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE STRING "")
+set(BUILTINS_x86_64-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+set(BUILTINS_aarch64-fuchsia_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE STRING "")
+set(BUILTINS_aarch64-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+
+# Setup toolchain.
+set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
+set(LLVM_TOOLCHAIN_TOOLS
+  llvm-ar
+  llvm-cov
+  llvm-cxxfilt
+  llvm-dwarfdump
+  llvm-dsymutil
+  llvm-lib
+  llvm-nm
+  llvm-objdump
+  llvm-profdata
+  llvm-ranlib
+  llvm-readobj
+  llvm-size
+  llvm-symbolizer
+  CACHE STRING "")
+
+set(LLVM_DISTRIBUTION_COMPONENTS
+  clang
+  LTO
+  clang-format
+  clang-headers
+  runtimes
+  ${LLVM_TOOLCHAIN_TOOLS}
+  CACHE STRING "")


Index: cmake/caches/Fuchsia.cmake
===
--- /dev/null
+++ cmake/caches/Fuchsia.cmake
@@ -0,0 +1,33 @@
+# This file sets up a CMakeCache for a Fuchsia toolchain build.
+
+set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
+
+set(CMAKE_BUILD_TYPE Release CACHE STRING "")
+
+set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
+
+set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
+
+set(CLANG_BOOTSTRAP_TARGETS
+  check-all
+  check-llvm
+  check-clang
+  llvm-config
+  test-suite
+  test-depends
+  llvm-test-depends
+  clang-test-depends
+  distribution
+  install-distribution
+  clang CACHE STRING "")
+
+if(FUCHSIA_SYSROOT)
+  set(EXTRA_ARGS -DFUCHSIA_SYSROOT=${FUCHSIA_SYSROOT})
+endif()
+
+# Setup the bootstrap build.
+set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
+set(CLANG_BOOTSTRAP_CMAKE_ARGS
+  ${EXTRA_ARGS}
+  -C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake
+  CACHE STRING "")
Index: cmake/caches/Fuchsia-stage2.cmake
===
--- /dev/null
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -0,0 +1,46 @@
+# This file sets up a CMakeCache for the second stage of a Fuchsia toolchain
+# build.
+
+set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64 CACHE STRING "")
+
+set(LLVM_ENABLE_LTO ON CACHE BOOL "")
+if(NOT APPLE)
+  set(LLVM_ENABLE_LLD ON CACHE BOOL "")
+endif()
+
+set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE STRING "")
+set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE STRING "")
+
+set(LLVM_BUILTIN_TARGETS "x86_64-fuchsia;aarch64-fuchsia" CACHE STRING "")
+set(BUILTINS_x86_64-fuchsia_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE STRING "")
+set(BUILTINS_x86_64-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+set(BUILTINS_aarch64-fuchsia_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE STRING "")
+set(BUILTINS_aarch64-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+
+# Setup toolchain.
+set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
+set(LLVM_TOOLCHAIN_TOOLS
+  llvm-ar

[PATCH] D26435: Use unique_ptr for cached tokens for default arguments in C++.

2016-11-14 Thread David Tarditi via cfe-commits
dtarditi added a comment.

I sync'ed to the head of the tree.  I tried to reproduce the failures that you 
saw and couldn't.I'm building on Windows 10 x64 using Visual Studio.  What 
platform/OS did you build on?  I built and test both Debug and RelWithDebugInfo.

Here's what I saw for RelWithDebugInfo

  Running the Clang regression tests
  -- Testing: 10026 tests, 24 threads --
  
  Testing Time: 604.17s
Expected Passes: 9922
Expected Failures  : 21
Unsupported Tests  : 83


https://reviews.llvm.org/D26435



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


[PATCH] D22997: [cxx1z-constexpr-lambda] Make conversion function constexpr, and teach the expression-evaluator to evaluate the static-invoker.

2016-11-14 Thread Faisal Vali via cfe-commits
faisalv updated this revision to Diff 77926.
faisalv marked an inline comment as done.
faisalv added a comment.

Simplify the check for zero captures in a lambda expression (within the assert) 
by comparing the begin and end pointers directly (as opposed to using distance) 
- thanks to Akira!


https://reviews.llvm.org/D22997

Files:
  lib/AST/ExprConstant.cpp
  lib/Sema/SemaLambda.cpp
  test/SemaCXX/cxx1z-constexpr-lambdas.cpp

Index: test/SemaCXX/cxx1z-constexpr-lambdas.cpp
===
--- test/SemaCXX/cxx1z-constexpr-lambdas.cpp
+++ test/SemaCXX/cxx1z-constexpr-lambdas.cpp
@@ -59,4 +59,30 @@
 }
 
 }
+
+namespace test_conversion_function_for_non_capturing_lambdas {
+
+namespace ns1 {
+auto L = [](int i) { return i; };
+constexpr int (*fpi)(int) = L;
+static_assert(fpi(3) == 3);
+auto GL = [](auto a) { return a; };
+
+constexpr char (*fp2)(char) = GL;
+constexpr double (*fp3)(double) = GL;
+constexpr const char* (*fp4)(const char*) = GL;
+static_assert(fp2('3') == '3');
+static_assert(fp3(3.14) == 3.14);
+constexpr const char *Str = "abc";
+static_assert(fp4(Str) == Str);
+
+auto NCL = [](int i) { static int j; return j; }; //expected-note{{declared here}}
+constexpr int (*fp5)(int) = NCL;
+constexpr int I = //expected-error{{must be initialized by a constant expression}}
+  fp5(5); //expected-note{{non-constexpr function}}
+
+} // end ns1
+
+} // end ns test_conversion_function_for_non_capturing_lambdas
+
 #endif // ndef CPP14_AND_EARLIER
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -1273,7 +1273,7 @@
 ConvTy, 
 ConvTSI,
 /*isInline=*/true, /*isExplicit=*/false,
-/*isConstexpr=*/false, 
+/*isConstexpr=*/S.getLangOpts().CPlusPlus1z, 
 CallOperator->getBody()->getLocEnd());
   Conversion->setAccess(AS_public);
   Conversion->setImplicit(true);
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -4399,6 +4399,10 @@
  Call.getLValueBase().dyn_cast());
   if (!FD)
 return Error(Callee);
+  
+  // Don't call function pointers which have been cast to some other type.
+  if (!Info.Ctx.hasSameType(CalleeType->getPointeeType(), FD->getType()))
+return Error(E);
 
   // Overloaded operator calls to member functions are represented as normal
   // calls with '*this' as the first argument.
@@ -4414,11 +4418,41 @@
   return false;
 This = &ThisVal;
 Args = Args.slice(1);
+  } else if (MD && MD->isLambdaStaticInvoker()) {   
+// Map the static invoker for the lambda back to the call operator.
+// Conveniently, we don't have to slice out the 'this' argument (as is
+// being done for the non-static case), since a static member function
+// doesn't have an implicit argument passed in.
+const CXXRecordDecl *ClosureClass = MD->getParent();
+assert(
+ClosureClass->captures_begin() == ClosureClass->captures_end() &&
+"Number of captures must be zero for conversion to function-ptr");
+
+const CXXMethodDecl *LambdaCallOp =
+ClosureClass->getLambdaCallOperator();
+
+// Set 'FD', the function that will be called below, to the call
+// operator.  If the closure object represents a generic lambda, find
+// the corresponding specialization of the call operator.
+
+if (ClosureClass->isGenericLambda()) {
+  assert(MD->isFunctionTemplateSpecialization() &&
+ "A generic lambda's static-invoker function must be a "
+ "template specialization");
+  const TemplateArgumentList *TAL = MD->getTemplateSpecializationArgs();
+  FunctionTemplateDecl *CallOpTemplate =
+  LambdaCallOp->getDescribedFunctionTemplate();
+  void *InsertPos = nullptr;
+  FunctionDecl *CorrespondingCallOpSpecialization =
+  CallOpTemplate->findSpecialization(TAL->asArray(), InsertPos);
+  assert(CorrespondingCallOpSpecialization &&
+ "We must always have a function call operator specialization "
+ "that corresponds to our static invoker specialization");
+  FD = cast(CorrespondingCallOpSpecialization);
+} else
+  FD = LambdaCallOp;
   }
-
-  // Don't call function pointers which have been cast to some other type.
-  if (!Info.Ctx.hasSameType(CalleeType->getPointeeType(), FD->getType()))
-return Error(E);
+  
 } else
   return Error(E);
 
___
cfe-c

[PATCH] D26649: [CMake] Support lld with LTO bootstrap

2016-11-14 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a comment.

In https://reviews.llvm.org/D26649#595213, @mehdi_amini wrote:

> Make sense to me, but I don't think it is enough: LLVM_ENABLE_LLD should be 
> passed to stage-2, and it also should be set to the absolute path of the 
> stage-1 lld build.


What is search directories order in Clang? It's reasonable it it tries to look 
into same directory first. In this case CMAKE_C_COMPILER/CMAKE_CXX_COMPILER 
should be enough for later stages.


Repository:
  rL LLVM

https://reviews.llvm.org/D26649



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


[PATCH] D26571: Clean up layout of ASTMerge tests

2016-11-14 Thread Sean Callanan via cfe-commits
spyffe added a reviewer: beanz.
spyffe updated this revision to Diff 77928.
spyffe added a comment.

Updated the locations so the structure is now

  a/test.c
  a/Inputs/a1.c
  a/Inputs/a2.c

The naming of "test.c" is no longer a requirement but only a convention.  Also 
`lit.site.cfg` is no longer required because we no longer do anything unusual 
from `lit`'s perspective.


Repository:
  rL LLVM

https://reviews.llvm.org/D26571

Files:
  Inputs/anonymous-fields1.cpp
  Inputs/anonymous-fields2.cpp
  Inputs/asm-function.cpp
  Inputs/body1.c
  Inputs/body2.c
  Inputs/category1.m
  Inputs/category2.m
  Inputs/class-template1.cpp
  Inputs/class-template2.cpp
  Inputs/class1.cpp
  Inputs/class2.cpp
  Inputs/class3.cpp
  Inputs/enum1.c
  Inputs/enum2.c
  Inputs/exprs1.c
  Inputs/exprs2.c
  Inputs/exprs3.cpp
  Inputs/function1.c
  Inputs/function2.c
  Inputs/inheritance-base.cpp
  Inputs/init-ctors-classes.cpp
  Inputs/interface1.m
  Inputs/interface2.m
  Inputs/macro.modulemap
  Inputs/macro1.h
  Inputs/macro1.m
  Inputs/macro2.m
  Inputs/namespace1.cpp
  Inputs/namespace2.cpp
  Inputs/property1.m
  Inputs/property2.m
  Inputs/struct1.c
  Inputs/struct2.c
  Inputs/typedef1.c
  Inputs/typedef2.c
  Inputs/var1.c
  Inputs/var1.h
  Inputs/var2.c
  anonymous-fields.cpp
  anonymous-fields/Inputs/anonymous-fields1.cpp
  anonymous-fields/Inputs/anonymous-fields2.cpp
  anonymous-fields/test.cpp
  asm.cpp
  asm/Inputs/asm-function.cpp
  asm/test.cpp
  category.m
  category/Inputs/category1.m
  category/Inputs/category2.m
  category/test.m
  class-template.cpp
  class-template/Inputs/class-template1.cpp
  class-template/Inputs/class-template2.cpp
  class-template/test.cpp
  class.cpp
  class/Inputs/class1.cpp
  class/Inputs/class2.cpp
  class/test.cpp
  class2.cpp
  class2/Inputs/class3.cpp
  class2/test.cpp
  codegen-body.c
  codegen-body/Inputs/body1.c
  codegen-body/Inputs/body2.c
  codegen-body/test.c
  codegen-exprs.c
  codegen-exprs/Inputs/exprs1.c
  codegen-exprs/Inputs/exprs2.c
  codegen-exprs/test.c
  enum.c
  enum/Inputs/enum1.c
  enum/Inputs/enum2.c
  enum/test.c
  exprs-cpp/Inputs/exprs3.cpp
  exprs-cpp/test.cpp
  exprs.c
  exprs.cpp
  exprs/Inputs/exprs1.c
  exprs/Inputs/exprs2.c
  exprs/test.c
  function.c
  function/Inputs/function1.c
  function/Inputs/function2.c
  function/test.c
  inheritance.cpp
  inheritance/Inputs/inheritance-base.cpp
  inheritance/test.cpp
  init-ctors.cpp
  init-ctors/Inputs/init-ctors-classes.cpp
  init-ctors/test.cpp
  interface.m
  interface/Inputs/interface1.m
  interface/Inputs/interface2.m
  interface/test.m
  macro.m
  macro/Inputs/macro.modulemap
  macro/Inputs/macro1.h
  macro/Inputs/macro1.m
  macro/Inputs/macro2.m
  macro/test.m
  namespace.cpp
  namespace/Inputs/namespace1.cpp
  namespace/Inputs/namespace2.cpp
  namespace/test.cpp
  property.m
  property/Inputs/property1.m
  property/Inputs/property2.m
  property/test.m
  struct.c
  struct/Inputs/struct1.c
  struct/Inputs/struct2.c
  struct/test.c
  typedef.c
  typedef/Inputs/typedef1.c
  typedef/Inputs/typedef2.c
  typedef/test.c
  var.c
  var/Inputs/var1.c
  var/Inputs/var1.h
  var/Inputs/var2.c
  var/test.c

Index: var.c
===
--- var.c
+++ var.c
@@ -1,12 +0,0 @@
-// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/var1.c
-// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/var2.c
-// RUN: not %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only -fdiagnostics-show-note-include-stack %s 2>&1 | FileCheck %s
-
-// CHECK: var2.c:2:9: error: external variable 'x1' declared with incompatible types in different translation units ('double *' vs. 'float **')
-// CHECK: var1.c:2:9: note: declared here with type 'float **'
-// CHECK: var2.c:3:5: error: external variable 'x2' declared with incompatible types in different translation units ('int' vs. 'double')
-// CHECK: In file included from{{.*}}var1.c:3:
-// CHECK: var1.h:1:8: note: declared here with type 'double'
-// CHECK: error: external variable 'xarray3' declared with incompatible types in different translation units ('int [17]' vs. 'int [18]')
-// CHECK: var1.c:7:5: note: declared here with type 'int [18]'
-// CHECK: 3 errors
Index: typedef.c
===
--- typedef.c
+++ typedef.c
@@ -1,7 +0,0 @@
-// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/typedef1.c
-// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/typedef2.c
-// RUN: not %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
-
-// CHECK: typedef2.c:4:10: error: external variable 'x2' declared with incompatible types in different translation units ('Typedef2' (aka 'double') vs. 'Typedef2' (aka 'int'))
-// CHECK: typedef1.c:4:10: note: declared here with type 'Typedef2' (aka 'int')
-// CHECK: 1 error
Index: struct.c
===
--- struct.c
+++ struct.c
@@ -1,42 +0,0 @@
-// RUN: %clang_cc1 -emit-p

[PATCH] D26649: [CMake] Support lld with LTO bootstrap

2016-11-14 Thread Petr Hosek via cfe-commits
phosek added a comment.

It's sufficient, I just tested it. I'm not actually sure if `LLVM_ENABLE_LLD` 
here is correct, `LLVM_ENABLE_LLD` forces the use of lld, but lld might not be 
available during first stage. We need `LLVM_ENABLE_LLD` to be set, but only for 
the second stage (which is something that can be done in the cache file), in 
the first stage we should probably just check whether lld source is available 
and we're building it, but I'm not sure what's the easiest/cleanest way to do 
that?


Repository:
  rL LLVM

https://reviews.llvm.org/D26649



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


[PATCH] D26649: [CMake] Support lld with LTO bootstrap

2016-11-14 Thread Mehdi AMINI via cfe-commits
mehdi_amini added a comment.

In https://reviews.llvm.org/D26649#595296, @phosek wrote:

> It's sufficient, I just tested it. I'm not actually sure if `LLVM_ENABLE_LLD` 
> here is correct, `LLVM_ENABLE_LLD` forces the use of lld, but lld might not 
> be available during first stage. We need `LLVM_ENABLE_LLD` to be set, but 
> only for the second stage (which is something that can be done in the cache 
> file), in the first stage we should probably just check whether lld source is 
> available and we're building it, but I'm not sure what's the easiest/cleanest 
> way to do that?


`-DBOOTSTRAP_ LLVM_ENABLE_LLD` is the right way to check for stage-2 options.

If you look just a few lines above your check you'll see an example of check 
for `BOOTSTRAP_LLVM_ENABLE_LTO`


Repository:
  rL LLVM

https://reviews.llvm.org/D26649



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


[PATCH] D26649: [CMake] Support lld with LTO bootstrap

2016-11-14 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a comment.

I think this should be handled in higher level script 
(utils/release/test-release.sh or similar), not in CMake. CMake compiler tests 
just need to fail when LLVM_ENABLE_LLD is used without actually having them.


Repository:
  rL LLVM

https://reviews.llvm.org/D26649



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


r286925 - [analyzer] Minor optimization: avoid setting state if unchanged

2016-11-14 Thread Dominic Chen via cfe-commits
Author: ddcc
Date: Mon Nov 14 19:40:58 2016
New Revision: 286925

URL: http://llvm.org/viewvc/llvm-project?rev=286925&view=rev
Log:
[analyzer] Minor optimization: avoid setting state if unchanged

Summary: Split out optimization from D26061

Reviewers: zaks.anna, dcoughlin

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp?rev=286925&r1=286924&r2=286925&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp Mon Nov 14 
19:40:58 2016
@@ -398,17 +398,19 @@ ConditionTruthVal RangeConstraintManager
 ProgramStateRef
 RangeConstraintManager::removeDeadBindings(ProgramStateRef state,
SymbolReaper& SymReaper) {
-
+  bool Changed = false;
   ConstraintRangeTy CR = state->get();
-  ConstraintRangeTy::Factory& CRFactory = 
state->get_context();
+  ConstraintRangeTy::Factory &CRFactory = 
state->get_context();
 
   for (ConstraintRangeTy::iterator I = CR.begin(), E = CR.end(); I != E; ++I) {
 SymbolRef sym = I.getKey();
-if (SymReaper.maybeDead(sym))
+if (SymReaper.maybeDead(sym)) {
+  Changed = true;
   CR = CRFactory.remove(CR, sym);
+}
   }
 
-  return state->set(CR);
+  return Changed ? state->set(CR) : state;
 }
 
 RangeSet


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


[PATCH] D26642: [analyzer] Minor optimization: avoid setting state if unchanged

2016-11-14 Thread Dominic Chen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286925: [analyzer] Minor optimization: avoid setting state 
if unchanged (authored by ddcc).

Changed prior to commit:
  https://reviews.llvm.org/D26642?vs=77897&id=77929#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26642

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp


Index: cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -398,17 +398,19 @@
 ProgramStateRef
 RangeConstraintManager::removeDeadBindings(ProgramStateRef state,
SymbolReaper& SymReaper) {
-
+  bool Changed = false;
   ConstraintRangeTy CR = state->get();
-  ConstraintRangeTy::Factory& CRFactory = 
state->get_context();
+  ConstraintRangeTy::Factory &CRFactory = 
state->get_context();
 
   for (ConstraintRangeTy::iterator I = CR.begin(), E = CR.end(); I != E; ++I) {
 SymbolRef sym = I.getKey();
-if (SymReaper.maybeDead(sym))
+if (SymReaper.maybeDead(sym)) {
+  Changed = true;
   CR = CRFactory.remove(CR, sym);
+}
   }
 
-  return state->set(CR);
+  return Changed ? state->set(CR) : state;
 }
 
 RangeSet


Index: cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -398,17 +398,19 @@
 ProgramStateRef
 RangeConstraintManager::removeDeadBindings(ProgramStateRef state,
SymbolReaper& SymReaper) {
-
+  bool Changed = false;
   ConstraintRangeTy CR = state->get();
-  ConstraintRangeTy::Factory& CRFactory = state->get_context();
+  ConstraintRangeTy::Factory &CRFactory = state->get_context();
 
   for (ConstraintRangeTy::iterator I = CR.begin(), E = CR.end(); I != E; ++I) {
 SymbolRef sym = I.getKey();
-if (SymReaper.maybeDead(sym))
+if (SymReaper.maybeDead(sym)) {
+  Changed = true;
   CR = CRFactory.remove(CR, sym);
+}
   }
 
-  return state->set(CR);
+  return Changed ? state->set(CR) : state;
 }
 
 RangeSet
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26644: [analyzer] Rename assumeWithinInclusiveRange*()

2016-11-14 Thread Dominic Chen via cfe-commits
ddcc updated this revision to Diff 77930.
ddcc added a comment.

Fix formatting


https://reviews.llvm.org/D26644

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
  lib/StaticAnalyzer/Core/SimpleConstraintManager.h

Index: lib/StaticAnalyzer/Core/SimpleConstraintManager.h
===
--- lib/StaticAnalyzer/Core/SimpleConstraintManager.h
+++ lib/StaticAnalyzer/Core/SimpleConstraintManager.h
@@ -38,7 +38,7 @@
 
   ProgramStateRef assume(ProgramStateRef state, NonLoc Cond, bool Assumption);
 
-  ProgramStateRef assumeWithinInclusiveRange(ProgramStateRef State,
+  ProgramStateRef assumeInclusiveRange(ProgramStateRef State,
  NonLoc Value,
  const llvm::APSInt &From,
  const llvm::APSInt &To,
Index: lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
@@ -190,7 +190,7 @@
   } // end switch
 }
 
-ProgramStateRef SimpleConstraintManager::assumeWithinInclusiveRange(
+ProgramStateRef SimpleConstraintManager::assumeInclusiveRange(
 ProgramStateRef State, NonLoc Value, const llvm::APSInt &From,
 const llvm::APSInt &To, bool InRange) {
 
@@ -207,7 +207,7 @@
 
   switch (Value.getSubKind()) {
   default:
-llvm_unreachable("'assumeWithinInclusiveRange' is not implemented"
+llvm_unreachable("'assumeInclusiveRange' is not implemented"
  "for this NonLoc");
 
   case nonloc::LocAsIntegerKind:
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1836,7 +1836,7 @@
 ProgramStateRef StateCase;
 if (Optional NL = CondV.getAs())
   std::tie(StateCase, DefaultSt) =
-  DefaultSt->assumeWithinInclusiveRange(*NL, V1, V2);
+  DefaultSt->assumeInclusiveRange(*NL, V1, V2);
 else // UnknownVal
   StateCase = DefaultSt;
 
Index: lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -254,7 +254,7 @@
   const llvm::APSInt &Min = BVF.getValue(R[I].first, T);
   const llvm::APSInt &Max = BVF.getValue(R[I].second, T);
   assert(Min <= Max);
-  State = CM.assumeWithinInclusiveRange(State, *N, Min, Max, false);
+  State = CM.assumeInclusiveRange(State, *N, Min, Max, false);
   if (!State)
 break;
 }
@@ -288,24 +288,24 @@
 const llvm::APSInt &Left = BVF.getValue(R[0].first - 1ULL, T);
 if (Left != PlusInf) {
   assert(MinusInf <= Left);
-  State = CM.assumeWithinInclusiveRange(State, *N, MinusInf, Left, false);
+  State = CM.assumeInclusiveRange(State, *N, MinusInf, Left, false);
   if (!State)
 return nullptr;
 }
 
 const llvm::APSInt &Right = BVF.getValue(R[E - 1].second + 1ULL, T);
 if (Right != MinusInf) {
   assert(Right <= PlusInf);
-  State = CM.assumeWithinInclusiveRange(State, *N, Right, PlusInf, false);
+  State = CM.assumeInclusiveRange(State, *N, Right, PlusInf, false);
   if (!State)
 return nullptr;
 }
 
 for (size_t I = 1; I != E; ++I) {
   const llvm::APSInt &Min = BVF.getValue(R[I - 1].second + 1ULL, T);
   const llvm::APSInt &Max = BVF.getValue(R[I].first - 1ULL, T);
   assert(Min <= Max);
-  State = CM.assumeWithinInclusiveRange(State, *N, Min, Max, false);
+  State = CM.assumeInclusiveRange(State, *N, Min, Max, false);
   if (!State)
 return nullptr;
 }
Index: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -98,18 +98,18 @@
   /// This ctor is used when creating the first ProgramState object.
   ProgramState(ProgramStateManager *mgr, const Environment& env,
   StoreRef st, GenericDataMap gdm);
-
+
   /// Copy ctor - We must explicitly define this or else the "Next" ptr
   ///  in FoldingSetNode will also get copied.
   ProgramState(const ProgramState &RHS);
-  
+
   ~ProgramState();
 
   /// Return the ProgramStateManager associated with this state.
   ProgramStateManager &getStateManager() const {
 return *stateMgr;
   }
-  
+

r286927 - [analyzer] Rename assumeWithinInclusiveRange*()

2016-11-14 Thread Dominic Chen via cfe-commits
Author: ddcc
Date: Mon Nov 14 19:54:41 2016
New Revision: 286927

URL: http://llvm.org/viewvc/llvm-project?rev=286927&view=rev
Log:
[analyzer] Rename assumeWithinInclusiveRange*()

Summary: The name is slightly confusing, since the constraint is not 
necessarily within the range unless `Assumption` is true. Split out renaming 
for ConstraintManager.h from D26061

Reviewers: zaks.anna, dcoughlin

Subscribers: cfe-commits

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

Modified:

cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.h

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h?rev=286927&r1=286926&r2=286927&view=diff
==
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h 
(original)
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h 
Mon Nov 14 19:54:41 2016
@@ -36,7 +36,7 @@ public:
 
   /// Construct a ConstraintVal indicating the constraint is underconstrained.
   ConditionTruthVal() {}
-  
+
   /// Return true if the constraint is perfectly constrained to 'true'.
   bool isConstrainedTrue() const {
 return Val.hasValue() && Val.getValue();
@@ -58,11 +58,11 @@ public:
 return !Val.hasValue();
   }
 };
-  
+
 class ConstraintManager {
 public:
   ConstraintManager() : NotifyAssumeClients(true) {}
-  
+
   virtual ~ConstraintManager();
   virtual ProgramStateRef assume(ProgramStateRef state,
  DefinedSVal Cond,
@@ -99,25 +99,26 @@ public:
 return ProgramStatePair(StTrue, StFalse);
   }
 
-  virtual ProgramStateRef assumeWithinInclusiveRange(ProgramStateRef State,
- NonLoc Value,
- const llvm::APSInt &From,
- const llvm::APSInt &To,
- bool InBound) = 0;
-
-  virtual ProgramStatePair assumeWithinInclusiveRangeDual(
-  ProgramStateRef State, NonLoc Value, const llvm::APSInt &From,
-  const llvm::APSInt &To) {
-ProgramStateRef StInRange = assumeWithinInclusiveRange(State, Value, From,
-   To, true);
+  virtual ProgramStateRef assumeInclusiveRange(ProgramStateRef State,
+   NonLoc Value,
+   const llvm::APSInt &From,
+   const llvm::APSInt &To,
+   bool InBound) = 0;
+
+  virtual ProgramStatePair assumeInclusiveRangeDual(ProgramStateRef State,
+NonLoc Value,
+const llvm::APSInt &From,
+const llvm::APSInt &To) {
+ProgramStateRef StInRange =
+assumeInclusiveRange(State, Value, From, To, true);
 
 // If StTrue is infeasible, asserting the falseness of Cond is unnecessary
 // because the existing constraints already establish this.
 if (!StInRange)
   return ProgramStatePair((ProgramStateRef)nullptr, State);
 
-ProgramStateRef StOutOfRange = assumeWithinInclusiveRange(State, Value,
-  From, To, false);
+ProgramStateRef StOutOfRange =
+assumeInclusiveRange(State, Value, From, To, false);
 if (!StOutOfRange) {
   // We are careful to return the original state, /not/ StTrue,
   // because we want to avoid having callers generate a new node
@@ -147,7 +148,7 @@ public:
  const char *sep) = 0;
 
   virtual void EndPath(ProgramStateRef state) {}
-  
+
   /// Convenience method to query the state to see if a symbol is null or
   /// not null, or if neither assumption can be made.
   ConditionTruthVal isNull(ProgramStateRef State, SymbolRef Sym) {
@@ -173,7 +174,7 @@ protected:
   virtual bool canReasonAbout(SVal X) const = 0;
 
   /// Returns whether or not a symbol is known to be null ("true"), known to be
-  /// non-null ("false"), or may be either ("underconstrained"). 
+  /// non-null ("false"), or may be either ("underconstrained").
   virtual ConditionTruthVal checkNull(ProgramStateRef State, SymbolRef Sym);
 };
 

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/P

[PATCH] D26644: [analyzer] Rename assumeWithinInclusiveRange*()

2016-11-14 Thread Dominic Chen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286927: [analyzer] Rename assumeWithinInclusiveRange*() 
(authored by ddcc).

Changed prior to commit:
  https://reviews.llvm.org/D26644?vs=77930&id=77933#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26644

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.h

Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1836,7 +1836,7 @@
 ProgramStateRef StateCase;
 if (Optional NL = CondV.getAs())
   std::tie(StateCase, DefaultSt) =
-  DefaultSt->assumeWithinInclusiveRange(*NL, V1, V2);
+  DefaultSt->assumeInclusiveRange(*NL, V1, V2);
 else // UnknownVal
   StateCase = DefaultSt;
 
Index: cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.h
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.h
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.h
@@ -38,7 +38,7 @@
 
   ProgramStateRef assume(ProgramStateRef state, NonLoc Cond, bool Assumption);
 
-  ProgramStateRef assumeWithinInclusiveRange(ProgramStateRef State,
+  ProgramStateRef assumeInclusiveRange(ProgramStateRef State,
  NonLoc Value,
  const llvm::APSInt &From,
  const llvm::APSInt &To,
Index: cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
@@ -190,7 +190,7 @@
   } // end switch
 }
 
-ProgramStateRef SimpleConstraintManager::assumeWithinInclusiveRange(
+ProgramStateRef SimpleConstraintManager::assumeInclusiveRange(
 ProgramStateRef State, NonLoc Value, const llvm::APSInt &From,
 const llvm::APSInt &To, bool InRange) {
 
@@ -207,7 +207,7 @@
 
   switch (Value.getSubKind()) {
   default:
-llvm_unreachable("'assumeWithinInclusiveRange' is not implemented"
+llvm_unreachable("'assumeInclusiveRange' is not implemented"
  "for this NonLoc");
 
   case nonloc::LocAsIntegerKind:
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -254,7 +254,7 @@
   const llvm::APSInt &Min = BVF.getValue(R[I].first, T);
   const llvm::APSInt &Max = BVF.getValue(R[I].second, T);
   assert(Min <= Max);
-  State = CM.assumeWithinInclusiveRange(State, *N, Min, Max, false);
+  State = CM.assumeInclusiveRange(State, *N, Min, Max, false);
   if (!State)
 break;
 }
@@ -288,24 +288,24 @@
 const llvm::APSInt &Left = BVF.getValue(R[0].first - 1ULL, T);
 if (Left != PlusInf) {
   assert(MinusInf <= Left);
-  State = CM.assumeWithinInclusiveRange(State, *N, MinusInf, Left, false);
+  State = CM.assumeInclusiveRange(State, *N, MinusInf, Left, false);
   if (!State)
 return nullptr;
 }
 
 const llvm::APSInt &Right = BVF.getValue(R[E - 1].second + 1ULL, T);
 if (Right != MinusInf) {
   assert(Right <= PlusInf);
-  State = CM.assumeWithinInclusiveRange(State, *N, Right, PlusInf, false);
+  State = CM.assumeInclusiveRange(State, *N, Right, PlusInf, false);
   if (!State)
 return nullptr;
 }
 
 for (size_t I = 1; I != E; ++I) {
   const llvm::APSInt &Min = BVF.getValue(R[I - 1].second + 1ULL, T);
   const llvm::APSInt &Max = BVF.getValue(R[I].first - 1ULL, T);
   assert(Min <= Max);
-  State = CM.assumeWithinInclusiveRange(State, *N, Min, Max, false);
+  State = CM.assumeInclusiveRange(State, *N, Min, Max, false);
   if (!State)
 return nullptr;
 }
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
@@ -36,7 +36,7 @@
 
   /// Construct a ConstraintVal indicating the constraint is underconstrained.
   ConditionTruthVal() {}
-  

[PATCH] D26649: [CMake] Support lld with LTO bootstrap

2016-11-14 Thread Mehdi AMINI via cfe-commits
mehdi_amini added a comment.

In https://reviews.llvm.org/D26649#595301, @Eugene.Zelenko wrote:

> I think this should be handled in higher level script 
> (utils/release/test-release.sh or similar), not in CMake. CMake compiler 
> tests just need to fail when LLVM_ENABLE_LLD is used without actually having 
> them.


I don't understand what you mean here, mind elaborating a bit?


Repository:
  rL LLVM

https://reviews.llvm.org/D26649



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


[PATCH] D26649: [CMake] Support lld with LTO bootstrap

2016-11-14 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a comment.

I meant that multi-stage build is processed by higher level script. So it 
should take care about consistency of source code srt versus later stages build 
options.


Repository:
  rL LLVM

https://reviews.llvm.org/D26649



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


[PATCH] D26649: [CMake] Support lld with LTO bootstrap

2016-11-14 Thread Mehdi AMINI via cfe-commits
mehdi_amini added a comment.

In https://reviews.llvm.org/D26649#595334, @Eugene.Zelenko wrote:

> I meant that multi-stage build is processed by higher level script. So it 
> should take care about consistency of source code srt versus later stages 
> build options.


We have a 2-stage build directly with a single CMake invocation, this is what 
this code path is about.
Are you referring to this situation or are you referring to 2-stage builds that 
are not "visible" from CMake itself and requires to first build stage-1 before 
configuring stage-2 with a second cmake invocation? (If I understand correctly 
I suspect you meant the latter)


Repository:
  rL LLVM

https://reviews.llvm.org/D26649



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


[PATCH] D26649: [CMake] Support lld with LTO bootstrap

2016-11-14 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a comment.

Yes, you are correct, I meant later.


Repository:
  rL LLVM

https://reviews.llvm.org/D26649



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


[PATCH] D26649: [CMake] Support lld with LTO bootstrap

2016-11-14 Thread Mehdi AMINI via cfe-commits
mehdi_amini added a comment.

In https://reviews.llvm.org/D26649#595296, @phosek wrote:

> It's sufficient, I just tested it.


How did you check it? I don't understand how LLVM_ENABLE_LLD is propagated to 
stage-2?




Comment at: CMakeLists.txt:534
+add_dependencies(LLVMgold)
+  endif()
   set(LTO_AR -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar)

What if not by the way? Should we error out here? What is the expected behavior?


Repository:
  rL LLVM

https://reviews.llvm.org/D26649



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


[PATCH] D26649: [CMake] Support lld with LTO bootstrap

2016-11-14 Thread Petr Hosek via cfe-commits
phosek added a comment.

In https://reviews.llvm.org/D26649#595356, @mehdi_amini wrote:

> In https://reviews.llvm.org/D26649#595296, @phosek wrote:
>
> > It's sufficient, I just tested it.
>
>
> How did you check it? I don't understand how LLVM_ENABLE_LLD is propagated to 
> stage-2?


Sufficient as in Clang looks for lld in the same directory where 
`clang`/`clang++` binary is first so we don't need to explicitly pass the path 
to lld to later stages.




Comment at: CMakeLists.txt:534
+add_dependencies(LLVMgold)
+  endif()
   set(LTO_AR -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar)

mehdi_amini wrote:
> What if not by the way? Should we error out here? What is the expected 
> behavior?
I assume that's platform dependent; if some platforms (other than Darwin) use 
linker other than gold or lld for LTO build, erroring out here might break 
them. I don't think there are any such platforms though because they'd be 
broken already as we currently always try to use LLVMgold which causes CMake 
error in case we're not building with Binutils (that's how I discovered this 
issue, since we're using lld rather than gold on our platform).


Repository:
  rL LLVM

https://reviews.llvm.org/D26649



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


[PATCH] D26649: [CMake] Support lld with LTO bootstrap

2016-11-14 Thread Mehdi AMINI via cfe-commits
mehdi_amini added a comment.

In https://reviews.llvm.org/D26649#595361, @phosek wrote:

> In https://reviews.llvm.org/D26649#595356, @mehdi_amini wrote:
>
> > In https://reviews.llvm.org/D26649#595296, @phosek wrote:
> >
> > > It's sufficient, I just tested it.
> >
> >
> > How did you check it? I don't understand how LLVM_ENABLE_LLD is propagated 
> > to stage-2?
>
>
> Sufficient as in Clang looks for lld in the same directory where 
> `clang`/`clang++` binary is first so we don't need to explicitly pass the 
> path to lld to later stages.


OK, but still, LLVM_ENABLE_LLD needs to be passed to stage-2, so it needs to be 
actually BOOTSTRAP_LLVM_ENABLE_LLD. 
I looked at all the CMake `_PASSTHROUGH` and didn't find it mentioned anywhere. 
We could make it auto-forwarded in this case maybe, @beanz is best to answer 
this.

Have you looked into turning `if(LLVM_ENABLE_LLD)` into 
`if(BOOTSTRAP_LLVM_ENABLE_LLD)`?
Technically we may want to have the stage-2 linked with lld even if lld is not 
on the system and not available during stage1.


Repository:
  rL LLVM

https://reviews.llvm.org/D26649



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


[PATCH] D26649: [CMake] Support lld with LTO bootstrap

2016-11-14 Thread Petr Hosek via cfe-commits
phosek added a comment.

In https://reviews.llvm.org/D26649#595367, @mehdi_amini wrote:

> OK, but still, LLVM_ENABLE_LLD needs to be passed to stage-2, so it needs to 
> be actually BOOTSTRAP_LLVM_ENABLE_LLD. 
>  I looked at all the CMake `_PASSTHROUGH` and didn't find it mentioned 
> anywhere. We could make it auto-forwarded in this case maybe, @beanz is best 
> to answer this.
>
> Have you looked into turning `if(LLVM_ENABLE_LLD)` into 
> `if(BOOTSTRAP_LLVM_ENABLE_LLD)`?
>  Technically we may want to have the stage-2 linked with lld even if lld is 
> not on the system and not available during stage1.


Yes, I just finished a test build and `BOOTSTRAP_LLVM_ENABLE_LLD` seems to 
work, see the updated diff.


Repository:
  rL LLVM

https://reviews.llvm.org/D26649



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


[PATCH] D26649: [CMake] Support lld with LTO bootstrap

2016-11-14 Thread Petr Hosek via cfe-commits
phosek updated this revision to Diff 77938.
phosek marked an inline comment as done.

Repository:
  rL LLVM

https://reviews.llvm.org/D26649

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -511,9 +511,8 @@
   set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-stamps/)
   set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-bins/)
 
-  # If the next stage is LTO we need to depend on LTO and possibly LLVMgold
+  # If the next stage is LTO we need to depend on LTO and possibly lld or 
LLVMgold
   if(BOOTSTRAP_LLVM_ENABLE_LTO OR LLVM_ENABLE_LTO AND NOT 
LLVM_BUILD_INSTRUMENTED)
-add_dependencies(clang-bootstrap-deps LTO)
 if(APPLE)
   # on Darwin we need to set DARWIN_LTO_LIBRARY so that -flto will work
   # using the just-built compiler, and we need to override 
DYLD_LIBRARY_PATH
@@ -526,7 +525,12 @@
   set(LTO_LIBRARY 
-DDARWIN_LTO_LIBRARY=${LLVM_SHLIB_OUTPUT_INTDIR}/libLTO.dylib
 -DDYLD_LIBRARY_PATH=${LLVM_LIBRARY_OUTPUT_INTDIR})
 elseif(NOT WIN32)
-  add_dependencies(clang-bootstrap-deps LLVMgold llvm-ar llvm-ranlib)
+  add_dependencies(clang-bootstrap-deps llvm-ar llvm-ranlib)
+  if(BOOTSTRAP_LLVM_ENABLE_LLD)
+add_dependencies(clang-bootstrap-deps lld)
+  elseif(LLVM_BINUTILS_INCDIR)
+add_dependencies(clang-bootstrap-deps LLVMgold)
+  endif()
   set(LTO_AR -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar)
   set(LTO_RANLIB -DCMAKE_RANLIB=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ranlib)
 endif()


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -511,9 +511,8 @@
   set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-stamps/)
   set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-bins/)
 
-  # If the next stage is LTO we need to depend on LTO and possibly LLVMgold
+  # If the next stage is LTO we need to depend on LTO and possibly lld or LLVMgold
   if(BOOTSTRAP_LLVM_ENABLE_LTO OR LLVM_ENABLE_LTO AND NOT LLVM_BUILD_INSTRUMENTED)
-add_dependencies(clang-bootstrap-deps LTO)
 if(APPLE)
   # on Darwin we need to set DARWIN_LTO_LIBRARY so that -flto will work
   # using the just-built compiler, and we need to override DYLD_LIBRARY_PATH
@@ -526,7 +525,12 @@
   set(LTO_LIBRARY -DDARWIN_LTO_LIBRARY=${LLVM_SHLIB_OUTPUT_INTDIR}/libLTO.dylib
 -DDYLD_LIBRARY_PATH=${LLVM_LIBRARY_OUTPUT_INTDIR})
 elseif(NOT WIN32)
-  add_dependencies(clang-bootstrap-deps LLVMgold llvm-ar llvm-ranlib)
+  add_dependencies(clang-bootstrap-deps llvm-ar llvm-ranlib)
+  if(BOOTSTRAP_LLVM_ENABLE_LLD)
+add_dependencies(clang-bootstrap-deps lld)
+  elseif(LLVM_BINUTILS_INCDIR)
+add_dependencies(clang-bootstrap-deps LLVMgold)
+  endif()
   set(LTO_AR -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar)
   set(LTO_RANLIB -DCMAKE_RANLIB=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ranlib)
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26546: [PPC] Add vec_insert4b/vec_extract4b to altivec.h

2016-11-14 Thread Sean Fertile via cfe-commits
sfertile added inline comments.



Comment at: lib/Headers/altivec.h:11908
+#define vec_extract4b(__a, __b)
\
+   vec_reve((vector unsigned long long)
\
+__builtin_vsx_xxextractuw((__a), (12 - (__b & 0xF

nemanjai wrote:
> I find it difficult to follow and understand this logic when it's in the 
> header.
> What I'd prefer to see here is that the macro simply expands into 
> `__builtin_vsx_xxextractuw` and then handle all this logic in the code that 
> emits an intrinsic call.
> Namely if the target is little endian, we adjust the parameter, emit the 
> intrinsic call and finally emit a shufflevector.
I think this is a good idea, looking at the code its not obvious what is going 
on.



Comment at: lib/Headers/altivec.h:12014
+#define vec_insert4b(__a, __b, __c) \
+  ((vector unsigned char)__builtin_vsx_xxinsertw((__a), (__b), (__c) & 0xF))
+#endif

kbarton wrote:
> nemanjai wrote:
> > As far as I can tell by looking at this patch and the corresponding back 
> > end patch, the `__a` argument will have a word inserted into it and it will 
> > be returned.
> > 
> > Is that the semantics that the ABI specifies (I can't seem to make sense of 
> > the description).
> > 
> > ```
> > vector unsigned int a = { 0x, 0xBB, 0xCC, 0xDD };
> > vector unsigned char b = (vector unsigned char) 0xFF;
> > vector unsigned char c = vec_insert4b(a, b, 4);
> > // Do we expect vector c to be:
> > // { 0xAA, 0xAA, 0xAA, 0xAA, 0xFF, 0xFF, 0xFF, 0xFF, 0xCC, 0xCC, 0xCC, 
> > 0xCC, 0xDD, 0xDD, 0xDD, 0xDD }
> > ```
> I think the current version of the ABI document has an error in it. The 
> description of the vec_insert4b is identical to the vec_extract4b, so I 
> expect it was copy/pasted in error. I think we need to open up an (internal) 
> bug against the ABI and wait for clarification to complete this. 
You have it correct Nemanja, word 1 will be extracted from b, and it will get 
inserted into a. The word will be inserted at the byte position starting at the 
3rd argument. (so in this case byte offsets 4 to 7)

I talked to Bill Schmidt earlier today and he already has a bug open. It hasn't 
been updated yet, but it should roughly correspond to the description for the 
xxinsertw instruction:

The contents of word element 1 of VSR[XB] are placed
into byte elements UIM:UIM+3 of VSR[XT]. The contents
of the remaining byte elements of VSR[XT] are not
modified.


Repository:
  rL LLVM

https://reviews.llvm.org/D26546



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


[PATCH] D26657: [Sema] Respect DLL attributes more faithfully

2016-11-14 Thread Shoaib Meenai via cfe-commits
smeenai created this revision.
smeenai added reviewers: compnerd, hans.
smeenai added a subscriber: cfe-commits.

On MSVC, if an implicit instantiation already exists and an explicit
instantiation definition with a DLL attribute is created, the DLL
attribute still takes effect. Make clang match this behavior.


https://reviews.llvm.org/D26657

Files:
  lib/Sema/SemaTemplate.cpp
  test/CodeGenCXX/dllexport.cpp
  test/CodeGenCXX/dllimport.cpp
  test/CodeGenCXX/windows-itanium-dllexport.cpp


Index: test/CodeGenCXX/windows-itanium-dllexport.cpp
===
--- test/CodeGenCXX/windows-itanium-dllexport.cpp
+++ test/CodeGenCXX/windows-itanium-dllexport.cpp
@@ -23,3 +23,8 @@
 // CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIcEaSERKS0_
 // CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIcE1fEv
 
+c g;
+template class __declspec(dllexport) c;
+
+// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIdEaSERKS0_
+// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIdE1fEv
Index: test/CodeGenCXX/dllimport.cpp
===
--- test/CodeGenCXX/dllimport.cpp
+++ test/CodeGenCXX/dllimport.cpp
@@ -814,6 +814,13 @@
 // M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc 
void @"\01?f@?$ExplicitInstantiationDeclExportedDefImportedTemplate@H@@QAEXXZ"
 // M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc 
%struct.ExplicitInstantiationDeclExportedDefImportedTemplate* 
@"\01??0?$ExplicitInstantiationDeclExportedDefImportedTemplate@H@@QAE@XZ"
 
+template  struct 
ImplicitInstantiationExplicitInstantiationDefImportedTemplate { void f() {} };
+ImplicitInstantiationExplicitInstantiationDefImportedTemplate 
ImplicitInstantiationExplicitInstantiationDefImportedTemplateInstance;
+template class __declspec(dllimport) 
ImplicitInstantiationExplicitInstantiationDefImportedTemplate;
+USEMEMFUNC(ImplicitInstantiationExplicitInstantiationDefImportedTemplate, 
f);
+// M32-DAG: declare dllimport x86_thiscallcc void 
@"\01?f@?$ImplicitInstantiationExplicitInstantiationDefImportedTemplate@H@@QAEXXZ"
+// G32-DAG: define weak_odr x86_thiscallcc void 
@_ZN61ImplicitInstantiationExplicitInstantiationDefImportedTemplateIiE1fEv
+
 template  struct PR23770BaseTemplate { void f() {} };
 template  struct PR23770DerivedTemplate : PR23770BaseTemplate 
{};
 extern template struct PR23770DerivedTemplate;
Index: test/CodeGenCXX/dllexport.cpp
===
--- test/CodeGenCXX/dllexport.cpp
+++ test/CodeGenCXX/dllexport.cpp
@@ -771,6 +771,13 @@
 // M32-DAG: define weak_odr dllexport x86_thiscallcc 
%struct.ExplicitInstantiationDeclExportedDefTemplate* 
@"\01??0?$ExplicitInstantiationDeclExportedDefTemplate@H@@QAE@XZ"
 // G32-DAG: define weak_odr x86_thiscallcc void 
@_ZN44ExplicitInstantiationDeclExportedDefTemplateIiE1fEv
 
+template  struct 
ImplicitInstantiationExplicitInstantiationDefExportedTemplate { void f() {} };
+ImplicitInstantiationExplicitInstantiationDefExportedTemplate 
ImplicitInstantiationExplicitInstantiationDefExportedTemplateInstance;
+template class __declspec(dllexport) 
ImplicitInstantiationExplicitInstantiationDefExportedTemplate;
+USEMEMFUNC(ImplicitInstantiationExplicitInstantiationDefExportedTemplate, 
f);
+// M32-DAG: define weak_odr dllexport x86_thiscallcc void 
@"\01?f@?$ImplicitInstantiationExplicitInstantiationDefExportedTemplate@H@@QAEXXZ"
+// G32-DAG: define weak_odr x86_thiscallcc void 
@_ZN61ImplicitInstantiationExplicitInstantiationDefExportedTemplateIiE1fEv
+
 namespace { struct InternalLinkageType {}; }
 struct __declspec(dllexport) PR23308 {
   void f(InternalLinkageType*);
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -7665,20 +7665,22 @@
Specialization->getDefinition());
   if (Def) {
 TemplateSpecializationKind Old_TSK = Def->getTemplateSpecializationKind();
-// Fix a TSK_ExplicitInstantiationDeclaration followed by a
-// TSK_ExplicitInstantiationDefinition
-if (Old_TSK == TSK_ExplicitInstantiationDeclaration &&
+// Fix a TSK_ExplicitInstantiationDeclaration or a 
TSK_ImplicitInstantiation
+// followed by a TSK_ExplicitInstantiationDefinition
+if ((Old_TSK == TSK_ExplicitInstantiationDeclaration ||
+ Old_TSK == TSK_ImplicitInstantiation) &&
 (TSK == TSK_ExplicitInstantiationDefinition ||
  DLLImportExplicitInstantiationDef)) {
   // FIXME: Need to notify the ASTMutationListener that we did this.
   Def->setTemplateSpecializationKind(TSK);
 
-  if (!getDLLAttr(Def) && getDLLAttr(Specialization) &&
+  if (getDLLAttr(Specialization) &&
+  (!getDLLAttr(Def) || Old_TSK == TSK_ImplicitInstantiation) &&
   (Context.getTargetInfo().getCXXABI().isMicrosoft() ||
Context.getTargetInfo().g

[PATCH] D26588: Add LocationContext to members of check::RegionChanges

2016-11-14 Thread Artem Dergachev via cfe-commits
NoQ added inline comments.



Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h:735
+  const FunctionDecl *FunctionDecl = SFC->getDecl()->getAsFunction();
+  unsigned NumArgs = FunctionDecl->getNumParams();
+  assert(ArgIdx < NumArgs && "Arg access out of range!");

a.sidorin wrote:
> Maybe we should put a check that requested StackFrame is our StackFrame or 
> our parent StackFrame here?
Hmm. We should probably add a similar check to `getSVal(Ex, LCtx)`!- and also 
check that `Ex` is an active expression.

Unfortunately, we do not know the current location context within any of these 
methods, not sure how to implement that.


https://reviews.llvm.org/D26588



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


[PATCH] D26559: Insert a type check before reading vtable.

2016-11-14 Thread Ivan Krasin via cfe-commits
krasin updated this revision to Diff 77941.
krasin added a comment.

Do better job with destructors.


https://reviews.llvm.org/D26559

Files:
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/ubsan-vtable-checks.cpp

Index: test/CodeGenCXX/ubsan-vtable-checks.cpp
===
--- /dev/null
+++ test/CodeGenCXX/ubsan-vtable-checks.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm -fsanitize=null %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NULL --check-prefix=ITANIUM
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-windows -emit-llvm -fsanitize=null %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NULL --check-prefix=MSABI
+// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm -fsanitize=vptr %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-VPTR --check-prefix=ITANIUM
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-windows -emit-llvm -fsanitize=vptr %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-VPTR --check-prefix=MSABI
+struct T {
+  virtual ~T() {}
+  virtual int v() { return 1; }
+};
+
+struct U : T {
+  ~U();
+  virtual int v() { return 2; }
+};
+
+U::~U() {}
+
+// ITANIUM: define i32 @_Z5get_vP1T
+// MSABI: define i32 @"\01?get_v
+int get_v(T* t) {
+  // First, we check that vtable is not loaded before a type check.
+  // CHECK-NULL-NOT: load {{.*}} (%struct.T*{{.*}})**, {{.*}} (%struct.T*{{.*}})***
+  // CHECK-NULL: [[UBSAN_CMP_RES:%[0-9]+]] = icmp ne %struct.T* %{{[_a-z0-9]+}}, null
+  // CHECK-NULL-NEXT: br i1 [[UBSAN_CMP_RES]], label %cont, label %handler.type_mismatch
+  // CHECK-NULL: call void @__ubsan_handle_type_mismatch_abort
+  // Second, we check that vtable is actually loaded once the type check is done.
+  // CHECK-NULL: load {{.*}} (%struct.T*{{.*}})**, {{.*}} (%struct.T*{{.*}})***
+  return t->v();
+}
+
+// ITANIUM: define void @_Z9delete_itP1T
+// MSABI: define void @"\01?delete_it
+void delete_it(T *t) {
+  // First, we check that vtable is not loaded before a type check.
+  // CHECK-VPTR-NOT: load {{.*}} (%struct.T*{{.*}})**, {{.*}} (%struct.T*{{.*}})***
+  // CHECK-VPTR: br i1 {{.*}} label %handler.dynamic_type_cache_miss
+  // CHECK-VPTR: call void @__ubsan_handle_dynamic_type_cache_miss_abort
+  // Second, we check that vtable is actually loaded once the type check is done.
+  // CHECK-VPTR: load {{.*}} (%struct.T*{{.*}})**, {{.*}} (%struct.T*{{.*}})***
+  delete t;
+}
Index: lib/CodeGen/MicrosoftCXXABI.cpp
===
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1817,16 +1817,21 @@
   assert(CE == nullptr || CE->arg_begin() == CE->arg_end());
   assert(DtorType == Dtor_Deleting || DtorType == Dtor_Complete);
 
+  ASTContext &Context = getContext();
+  SourceLocation CallLoc = CE ? CE->getLocStart() : SourceLocation();
+  CGF.EmitTypeCheck(CodeGenFunction::TCK_MemberCall,
+CallLoc, This.getPointer(),
+Context.getRecordType(Dtor->getParent()));
+
   // We have only one destructor in the vftable but can get both behaviors
   // by passing an implicit int parameter.
   GlobalDecl GD(Dtor, Dtor_Deleting);
   const CGFunctionInfo *FInfo = &CGM.getTypes().arrangeCXXStructorDeclaration(
   Dtor, StructorType::Deleting);
   llvm::Type *Ty = CGF.CGM.getTypes().GetFunctionType(*FInfo);
   CGCallee Callee = getVirtualFunctionPointer(
-  CGF, GD, This, Ty, CE ? CE->getLocStart() : SourceLocation());
+  CGF, GD, This, Ty, CallLoc);
 
-  ASTContext &Context = getContext();
   llvm::Value *ImplicitParam = llvm::ConstantInt::get(
   llvm::IntegerType::getInt32Ty(CGF.getLLVMContext()),
   DtorType == Dtor_Deleting);
Index: lib/CodeGen/CGExprCXX.cpp
===
--- lib/CodeGen/CGExprCXX.cpp
+++ lib/CodeGen/CGExprCXX.cpp
@@ -35,17 +35,6 @@
  "Trying to emit a member or operator call expr on a static method!");
   ASTContext &C = CGF.getContext();
 
-  // C++11 [class.mfct.non-static]p2:
-  //   If a non-static member function of a class X is called for an object that
-  //   is not of type X, or of a type derived from X, the behavior is undefined.
-  SourceLocation CallLoc;
-  if (CE)
-CallLoc = CE->getExprLoc();
-  CGF.EmitTypeCheck(isa(MD)
-? CodeGenFunction::TCK_ConstructorCall
-: CodeGenFunction::TCK_MemberCall,
-CallLoc, This, C.getRecordType(MD->getParent()));
-
   // Push the this ptr.
   const CXXRecordDecl *RD =
   CGF.CGM.getCXXABI().getThisArgumentTypeForMethod(MD);
@@ -293,6 +282,19 @@
 
   llvm::FunctionType *Ty = CGM.getTypes().GetFunctionType(*FInfo);
 
+  // C++11 [class.mfct.non-static]p2:
+  //   If a non-static member function of a class X is called for an object that
+  //   is not of type X, or

[PATCH] D26649: [CMake] Support lld with LTO bootstrap

2016-11-14 Thread Mehdi AMINI via cfe-commits
mehdi_amini accepted this revision.
mehdi_amini added a reviewer: mehdi_amini.
mehdi_amini added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rL LLVM

https://reviews.llvm.org/D26649



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


[PATCH] D26559: Insert a type check before reading vtable.

2016-11-14 Thread Ivan Krasin via cfe-commits
krasin added inline comments.



Comment at: lib/CodeGen/CGExprCXX.cpp:93
+
+  EmitTypeCheck(CodeGenFunction::TCK_MemberCall,
+CallLoc, This, C.getRecordType(DD->getParent()));

pcc wrote:
> krasin wrote:
> > pcc wrote:
> > > pcc wrote:
> > > > Is it correct to emit a type check at this point? Looking at [0] it 
> > > > looks like this function is only called from the Microsoft C++ ABI 
> > > > after we have already resolved the virtual function pointer.
> > > > 
> > > > [0] 
> > > > http://llvm-cs.pcc.me.uk/tools/clang/lib/CodeGen/CGExprCXX.cpp/rEmitCXXDestructorCall
> > > What about this comment?
> > Sorry, I have missed the comment. I have added this check here to preserve 
> > the existing behavior.
> > 
> > From what you describe, there could be a very similar issue related to the 
> > Microsoft C++ ABI to the one that I fix here. I am okay to file a bug or 
> > add a note about this, your choice.
> Have you looked at how hard it would be to fix this?
Done.

Note: since I don't have an ability to test on Windows, this CL is now 
high-risk. If it breaks any Windows-specific tests, when submitted, I will 
revert the CL and undo the MSABI change. After all, the previous state was to 
keep things working as they were before.


https://reviews.llvm.org/D26559



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


[PATCH] D26649: [CMake] Support lld with LTO bootstrap

2016-11-14 Thread Mehdi AMINI via cfe-commits
mehdi_amini requested changes to this revision.
mehdi_amini added inline comments.
This revision now requires changes to proceed.



Comment at: CMakeLists.txt:516
   if(BOOTSTRAP_LLVM_ENABLE_LTO OR LLVM_ENABLE_LTO AND NOT 
LLVM_BUILD_INSTRUMENTED)
-add_dependencies(clang-bootstrap-deps LTO)
 if(APPLE)

This is needed in the "if(APPLE)" case.
And conditonalized by "if(!BOOTSTRAP_LLVM_ENABLE_LLD))"



Comment at: CMakeLists.txt:530
+  if(BOOTSTRAP_LLVM_ENABLE_LLD)
+add_dependencies(clang-bootstrap-deps lld)
+  elseif(LLVM_BINUTILS_INCDIR)

Actually, not clear why this is behind `if(!APPLE)`


Repository:
  rL LLVM

https://reviews.llvm.org/D26649



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


[PATCH] D26649: [CMake] Support lld with LTO bootstrap

2016-11-14 Thread Mehdi AMINI via cfe-commits
mehdi_amini added a comment.

What about the following logic?

   if(BOOTSTRAP_LLVM_ENABLE_LLD)
add_dependencies(clang-bootstrap-deps lld)
   endif()
   if(APPLE)
  # on Darwin we need to set DARWIN_LTO_LIBRARY so that -flto will work
  # using the just-built compiler, and we need to override DYLD_LIBRARY_PATH
  # so that the host object file tools will use the just-built libLTO.
  # However if System Integrity Protection is enabled the DYLD variables
  # will be scrubbed from the environment of any base system commands. This
  # includes /bin/sh, which ninja uses when executing build commands. To
  # work around the envar being filtered away we pass it in as a CMake
  # variable, and have LLVM's CMake append the envar to the archiver calls.
  set(LTO_LIBRARY 
-DDARWIN_LTO_LIBRARY=${LLVM_SHLIB_OUTPUT_INTDIR}/libLTO.dylib
-DDYLD_LIBRARY_PATH=${LLVM_LIBRARY_OUTPUT_INTDIR})
elseif(NOT WIN32)
  add_dependencies(clang-bootstrap-deps llvm-ar llvm-ranlib)
  if(NOT LLVM_ENABLE_LLD AND LLVM_BINUTILS_INCDIR)
add_dependencies(clang-bootstrap-deps LLVMgold)
  endif()
  set(LTO_AR -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar)
  set(LTO_RANLIB -DCMAKE_RANLIB=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ranlib)
endif()
  endif()

I'm not even sure why we don't use `llvm-ar` and `llvm-ranlib` on OSX by the 
way, this makes the logic more complicated here, but there might be a good 
reason for that.


Repository:
  rL LLVM

https://reviews.llvm.org/D26649



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


[libcxx] r286932 - Missed one of the try blocks the first time :-(. Thanks to Renato for the heads up.

2016-11-14 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Nov 14 23:03:22 2016
New Revision: 286932

URL: http://llvm.org/viewvc/llvm-project?rev=286932&view=rev
Log:
Missed one of the try blocks the first time :-(. Thanks to Renato for the heads 
up.

Modified:
libcxx/trunk/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp?rev=286932&r1=286931&r2=286932&view=diff
==
--- libcxx/trunk/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp 
(original)
+++ libcxx/trunk/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp 
Mon Nov 14 23:03:22 2016
@@ -64,7 +64,7 @@ test(SV sv, unsigned pos, unsigned n, co
 {
 typedef typename S::traits_type T;
 typedef typename S::allocator_type A;
-try
+if (pos <= sv.size())
 {
 S s2(sv, pos, n, a);
 LIBCPP_ASSERT(s2.__invariants());
@@ -75,10 +75,20 @@ test(SV sv, unsigned pos, unsigned n, co
 assert(s2.get_allocator() == a);
 assert(s2.capacity() >= s2.size());
 }
-catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+else
 {
-assert(pos > sv.size());
+try
+{
+S s2(sv, pos, n, a);
+assert(false);
+}
+catch (std::out_of_range&)
+{
+assert(pos > sv.size());
+}
 }
+#endif
 }
 
 int main()


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


[PATCH] D21737: [PATCH] [CodeGen] Insert TargetLibraryInfoWrapperPass before anything else.

2016-11-14 Thread Mehdi AMINI via cfe-commits
mehdi_amini accepted this revision.
mehdi_amini added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!




Comment at: lib/CodeGen/BackendUtil.cpp:422
   // Set up the per-function pass manager.
+  FPM.add(new TargetLibraryInfoWrapperPass(*TLII));
   if (CodeGenOpts.VerifyModule)

koriakin wrote:
> mehdi_amini wrote:
> > This seems unnecessary?
> This ensures FPM passes get the right TLI as well - since I'm removing the 
> PMBuilder.LIbraryInfo assignment, they would otherwise get the 
> default-constructed ones.  Or should I keep the assignment instead, and only 
> special-case MPM?
Oh right, I was looking at the existing code and I missed that you were 
removing the LibraryInfo initialization.


Repository:
  rL LLVM

https://reviews.llvm.org/D21737



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


[PATCH] D26649: [CMake] Support lld with LTO bootstrap

2016-11-14 Thread Petr Hosek via cfe-commits
phosek added a comment.

AFAIK lld on Darwin doesn't support LTO (last I heard it cannot even self-host 
at the moment) so I'm not sure if it makes sense to enable it `if(APPLE)`.


Repository:
  rL LLVM

https://reviews.llvm.org/D26649



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


[PATCH] D26649: [CMake] Support lld with LTO bootstrap

2016-11-14 Thread Mehdi AMINI via cfe-commits
mehdi_amini added a comment.

In https://reviews.llvm.org/D26649#595429, @phosek wrote:

> AFAIK lld on Darwin doesn't support LTO (last I heard it cannot even 
> self-host at the moment) so I'm not sure if it makes sense to enable it 
> `if(APPLE)`.


OK, we could error instead of ignoring then.
But you still need to restore the dependency on libLTO, unless I'm missing 
something.


Repository:
  rL LLVM

https://reviews.llvm.org/D26649



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


[PATCH] D26649: [CMake] Support lld with LTO bootstrap

2016-11-14 Thread Petr Hosek via cfe-commits
phosek updated this revision to Diff 77950.

Repository:
  rL LLVM

https://reviews.llvm.org/D26649

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -511,10 +511,10 @@
   set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-stamps/)
   set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-bins/)
 
-  # If the next stage is LTO we need to depend on LTO and possibly LLVMgold
+  # If the next stage is LTO we need to depend on LTO and possibly lld or 
LLVMgold
   if(BOOTSTRAP_LLVM_ENABLE_LTO OR LLVM_ENABLE_LTO AND NOT 
LLVM_BUILD_INSTRUMENTED)
-add_dependencies(clang-bootstrap-deps LTO)
 if(APPLE)
+  add_dependencies(clang-bootstrap-deps LTO)
   # on Darwin we need to set DARWIN_LTO_LIBRARY so that -flto will work
   # using the just-built compiler, and we need to override 
DYLD_LIBRARY_PATH
   # so that the host object file tools will use the just-built libLTO.
@@ -526,7 +526,12 @@
   set(LTO_LIBRARY 
-DDARWIN_LTO_LIBRARY=${LLVM_SHLIB_OUTPUT_INTDIR}/libLTO.dylib
 -DDYLD_LIBRARY_PATH=${LLVM_LIBRARY_OUTPUT_INTDIR})
 elseif(NOT WIN32)
-  add_dependencies(clang-bootstrap-deps LLVMgold llvm-ar llvm-ranlib)
+  add_dependencies(clang-bootstrap-deps llvm-ar llvm-ranlib)
+  if(BOOTSTRAP_LLVM_ENABLE_LLD)
+add_dependencies(clang-bootstrap-deps lld)
+  elseif(LLVM_BINUTILS_INCDIR)
+add_dependencies(clang-bootstrap-deps LLVMgold)
+  endif()
   set(LTO_AR -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar)
   set(LTO_RANLIB -DCMAKE_RANLIB=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ranlib)
 endif()


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -511,10 +511,10 @@
   set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-stamps/)
   set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-bins/)
 
-  # If the next stage is LTO we need to depend on LTO and possibly LLVMgold
+  # If the next stage is LTO we need to depend on LTO and possibly lld or LLVMgold
   if(BOOTSTRAP_LLVM_ENABLE_LTO OR LLVM_ENABLE_LTO AND NOT LLVM_BUILD_INSTRUMENTED)
-add_dependencies(clang-bootstrap-deps LTO)
 if(APPLE)
+  add_dependencies(clang-bootstrap-deps LTO)
   # on Darwin we need to set DARWIN_LTO_LIBRARY so that -flto will work
   # using the just-built compiler, and we need to override DYLD_LIBRARY_PATH
   # so that the host object file tools will use the just-built libLTO.
@@ -526,7 +526,12 @@
   set(LTO_LIBRARY -DDARWIN_LTO_LIBRARY=${LLVM_SHLIB_OUTPUT_INTDIR}/libLTO.dylib
 -DDYLD_LIBRARY_PATH=${LLVM_LIBRARY_OUTPUT_INTDIR})
 elseif(NOT WIN32)
-  add_dependencies(clang-bootstrap-deps LLVMgold llvm-ar llvm-ranlib)
+  add_dependencies(clang-bootstrap-deps llvm-ar llvm-ranlib)
+  if(BOOTSTRAP_LLVM_ENABLE_LLD)
+add_dependencies(clang-bootstrap-deps lld)
+  elseif(LLVM_BINUTILS_INCDIR)
+add_dependencies(clang-bootstrap-deps LLVMgold)
+  endif()
   set(LTO_AR -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar)
   set(LTO_RANLIB -DCMAKE_RANLIB=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ranlib)
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26588: Add LocationContext to members of check::RegionChanges

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

Hi and welcome to the project!

This patch definitely looks quite complex for a first contribution, so great 
job at digging through the analyzer internals!

One higher level comment I have is that you should try and split patches 
whenever possible. For example, in the description, you mention that the patch 
contains 2 changes:

- extending RegionChanges interface with LocationContext
- adding an easy way to obtain arguments' SVals from StackFrameCtx

Since they are independent changes, please submit them as separate patches. 
This simplifies the job of the reviewers and anyone who will ever look at this 
patch in commit history or on phabricator. Also, this ensures that each change 
has sufficient test coverage. The LLVM Dev policy has a great explanation of 
the reasoning behind this: 
http://llvm.org/docs/DeveloperPolicy.html#incremental-development.

How do you plan on testing these changes? The main 2 methods are unit tests and 
checker regression tests. Since no checker uses these maybe we should only 
commit them once such checker is added...

I've only started looking at the first change and would like to understand the 
motivation behind it a bit more.




Comment at: include/clang/StaticAnalyzer/Core/Checker.h:325
+  const CallEvent *Call,
+  const LocationContext *LCtx) {
+return ((const CHECKER *) checker)->checkRegionChanges(state, invalidated,

LocationContext can be obtained by calling CallEvent::getLocationContext(). I 
do not think that adding another parameter here buys us much. Am I missing 
something?



Comment at: include/clang/StaticAnalyzer/Core/Checker.h:333
+   ProgramStateRef state,
+   const LocationContext *LCtx) {
+return ((const CHECKER *) checker)->wantsRegionChangeUpdate(state, LCtx);

What is the scenario in which you need the context here? The idea is that the 
checker would be interested in region changes if it is already tracking 
information in the state. For that check, the information in the state is 
sufficient. What is your scenario?

Also, For any checker API change, we need to update the 
CheckerDocumentation.cpp.


https://reviews.llvm.org/D26588



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


[PATCH] D26596: [RFC] Add _LIBCPP_NO_DISCARD and apply it to `Container::empty()`, `unique_ptr::release()`, and `Lockable::try_lock()`

2016-11-14 Thread Eric Fiselier via cfe-commits
EricWF updated this revision to Diff 2.
EricWF added a comment.

Add final touches. This patch is ready to go.

@chandlerc mentioned he would still like to see more per-function granularity 
for enabling/disabling the libc++ [[nodiscard]] macro in order to ease adoption 
in large code bases. However I'm concerned about the cost of maintaining 100+ 
user-visible configuration macros. This current patch attempts to find a happy 
medium by grouping similar functions  into a single macro; which can be 
sub-divided further if needed.

As a general rule functions where [[nodiscard]] may yield false positives (ie 
`unique_ptr::release()`) should always have their own group, since fixing the 
false-positives is a stylistic change. Functions where a discarded value is 
always a bug, either for correctness reasons (ie `try_lock()`) or  because the 
call has no side-effects (ie `string::empty`), may be grouped together as 
appropriate; Warnings generated by these groups should either be rare or high 
priority bugs. Dividing groups in this manner attempts to maximize adaptability 
while being reasonably maintainable.

@mclow.lists Any last words?


https://reviews.llvm.org/D26596

Files:
  docs/UsingLibcxx.rst
  include/__config
  include/__hash_table
  include/__mutex_base
  include/algorithm
  include/deque
  include/ext/hash_map
  include/forward_list
  include/list
  include/locale
  include/map
  include/memory
  include/mutex
  include/regex
  include/set
  include/shared_mutex
  include/string
  include/string_view
  include/thread
  include/unordered_map
  include/unordered_set
  include/vector
  test/libcxx/containers/no-discard-disable.fail.cpp
  test/libcxx/containers/no-discard.fail.cpp
  test/libcxx/test/config.py
  test/libcxx/thread/thread.mutex/try_lock_no_discard.fail.cpp
  test/libcxx/thread/thread.mutex/try_lock_no_discard_disabled.fail.cpp
  test/libcxx/utilities/memory/disable_no_discard_smart_ptr_observers.fail.cpp
  test/libcxx/utilities/memory/no_discard_smart_ptr_observers.fail.cpp
  test/libcxx/utilities/memory/unique.ptr/disable_no_discard_release.fail.cpp
  test/libcxx/utilities/memory/unique.ptr/no_discard_release.fail.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp

Index: test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp
===
--- test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp
+++ test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp
@@ -48,7 +48,7 @@
 #ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
-lk.try_lock_until(Clock::now());
+(void)lk.try_lock_until(Clock::now());
 assert(false);
 }
 catch (std::system_error& e)
@@ -64,7 +64,7 @@
 #ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
-lk.try_lock_until(Clock::now());
+(void)lk.try_lock_until(Clock::now());
 assert(false);
 }
 catch (std::system_error& e)
Index: test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp
===
--- test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp
+++ test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp
@@ -48,7 +48,7 @@
 #ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
-lk.try_lock_for(ms(5));
+(void)lk.try_lock_for(ms(5));
 assert(false);
 }
 catch (std::system_error& e)
@@ -64,7 +64,7 @@
 #ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
-lk.try_lock_for(ms(5));
+(void)lk.try_lock_for(ms(5));
 assert(false);
 }
 catch (std::system_error& e)
Index: test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp
===
--- test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp
+++ test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp
@@ -43,7 +43,7 @@
 #ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
-l

[PATCH] D26137: [clang-tidy] Add check name to YAML export

2016-11-14 Thread Alpha Abdoulaye via cfe-commits
Alpha added a comment.

Ping


Repository:
  rL LLVM

https://reviews.llvm.org/D26137



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


r286798 - Remove some false positives when taking the address of packed members

2016-11-14 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Mon Nov 14 02:53:27 2016
New Revision: 286798

URL: http://llvm.org/viewvc/llvm-project?rev=286798&view=rev
Log:
Remove some false positives when taking the address of packed members

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



Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/address-packed.c

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=286798&r1=286797&r2=286798&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Nov 14 02:53:27 2016
@@ -9998,7 +9998,7 @@ public:
   /// local diagnostics like in reference binding.
   void RefersToMemberWithReducedAlignment(
   Expr *E,
-  std::function 
Action);
+  std::function 
Action);
 };
 
 /// \brief RAII object that enters a new expression evaluation context.

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=286798&r1=286797&r2=286798&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Nov 14 02:53:27 2016
@@ -11696,7 +11696,8 @@ void Sema::DiagnoseMisalignedMembers() {
 }
 
 void Sema::DiscardMisalignedMemberAddress(const Type *T, Expr *E) {
-  if (!T->isPointerType())
+  E = E->IgnoreParens();
+  if (!T->isPointerType() && !T->isIntegerType())
 return;
   if (isa(E) &&
   cast(E)->getOpcode() == UO_AddrOf) {
@@ -11705,7 +11706,9 @@ void Sema::DiscardMisalignedMemberAddres
   auto MA = std::find(MisalignedMembers.begin(), MisalignedMembers.end(),
   MisalignedMember(Op));
   if (MA != MisalignedMembers.end() &&
-  Context.getTypeAlignInChars(T->getPointeeType()) <= MA->Alignment)
+  (T->isIntegerType() ||
+   (T->isPointerType() &&
+Context.getTypeAlignInChars(T->getPointeeType()) <= 
MA->Alignment)))
 MisalignedMembers.erase(MA);
 }
   }
@@ -11713,28 +11716,103 @@ void Sema::DiscardMisalignedMemberAddres
 
 void Sema::RefersToMemberWithReducedAlignment(
 Expr *E,
-std::function Action) {
+std::function Action) {
   const auto *ME = dyn_cast(E);
-  while (ME && isa(ME->getMemberDecl())) {
+  if (!ME)
+return;
+
+  // For a chain of MemberExpr like "a.b.c.d" this list
+  // will keep FieldDecl's like [d, c, b].
+  SmallVector ReverseMemberChain;
+  const MemberExpr *TopME = nullptr;
+  bool AnyIsPacked = false;
+  do {
 QualType BaseType = ME->getBase()->getType();
 if (ME->isArrow())
   BaseType = BaseType->getPointeeType();
 RecordDecl *RD = BaseType->getAs()->getDecl();
 
 ValueDecl *MD = ME->getMemberDecl();
-bool ByteAligned = Context.getTypeAlignInChars(MD->getType()).isOne();
-if (ByteAligned) // Attribute packed does not have any effect.
-  break;
-
-if (!ByteAligned &&
-(RD->hasAttr() || (MD->hasAttr( {
-  CharUnits Alignment = 
std::min(Context.getTypeAlignInChars(MD->getType()),
- Context.getTypeAlignInChars(BaseType));
-  // Notify that this expression designates a member with reduced alignment
-  Action(E, RD, MD, Alignment);
-  break;
+auto *FD = dyn_cast(MD);
+// We do not care about non-data members.
+if (!FD || FD->isInvalidDecl())
+  return;
+
+AnyIsPacked =
+AnyIsPacked || (RD->hasAttr() || 
MD->hasAttr());
+ReverseMemberChain.push_back(FD);
+
+TopME = ME;
+ME = dyn_cast(ME->getBase()->IgnoreParens());
+  } while (ME);
+  assert(TopME && "We did not compute a topmost MemberExpr!");
+
+  // Not the scope of this diagnostic.
+  if (!AnyIsPacked)
+return;
+
+  const Expr *TopBase = TopME->getBase()->IgnoreParenImpCasts();
+  const auto *DRE = dyn_cast(TopBase);
+  // TODO: The innermost base of the member expression may be too complicated.
+  // For now, just disregard these cases. This is left for future
+  // improvement.
+  if (!DRE && !isa(TopBase))
+  return;
+
+  // Alignment expected by the whole expression.
+  CharUnits ExpectedAlignment = Context.getTypeAlignInChars(E->getType());
+
+  // No need to do anything else with this case.
+  if (ExpectedAlignment.isOne())
+return;
+
+  // Synthesize offset of the whole access.
+  CharUnits Offset;
+  for (auto I = ReverseMemberChain.rbegin(); I != ReverseMemberChain.rend();
+   I++) {
+Offset += Context.toCharUnitsFromBits(Context.getFieldOffset(*I));
+  }
+
+  // Compute the CompleteObjectAlignment as the alignment of the whole chain.
+  CharUnits CompleteObjectAlignment = Context.getTypeAlignInChars(
+  ReverseMemberChain.back()->getParent()->getTypeForDecl());
+
+  // The base expression of the innerm

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

2016-11-14 Thread Roger Ferrer Ibanez via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286798: Remove some false positives when taking the address 
of packed members (authored by rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D23657?vs=77498&id=3#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23657

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

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -9998,7 +9998,7 @@
   /// local diagnostics like in reference binding.
   void RefersToMemberWithReducedAlignment(
   Expr *E,
-  std::function Action);
+  std::function Action);
 };
 
 /// \brief RAII object that enters a new expression evaluation context.
Index: cfe/trunk/test/Sema/address-packed.c
===
--- cfe/trunk/test/Sema/address-packed.c
+++ cfe/trunk/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
   }
 }
 
@@ -196,3 +202,130 @@
 int *anonymousInnerUnion(struct S6 *s) {
   return &s->x; // expected-warning {{packed member 'x' of class or structure 'S6::(anonymous)'}}
 }
+
+struct S6a {
+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 'S6a'}}
+}
+
+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 str

[PATCH] D26457: Protect smart-pointer tests under no exceptions

2016-11-14 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

Ping? :)


https://reviews.llvm.org/D26457



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


[PATCH] D26512: Protect std::ios tests under libcpp-no-exceptions

2016-11-14 Thread Eric Fiselier via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

LGTM modulo inline comments. There are a couple of tests which don't explicitly 
assert if they throw or not. Please address those tests before committing.




Comment at: 
test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp:44
 ios.exceptions(std::ios::badbit);
 }
 catch (...)

`assert(false);`

It's unrelated but it should be added.



Comment at: 
test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp:33
 {
 ios.exceptions(std::ios::badbit);
 }

`assert(false);`



Comment at: 
test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp:33
 {
 ios.exceptions(std::ios::badbit);
 }

`assert(false)`


https://reviews.llvm.org/D26512



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


[PATCH] D26458: Protect nested-exceptions tests under no-exceptions

2016-11-14 Thread Eric Fiselier via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D26458#590865, @rmaprath wrote:

> Not sure if either of these tests add much value to the no-exceptions 
> variant, using `std::nested_exception` with such a library seem pointless to 
> me. Perhaps marking these as `UNSUPPORTED` is a better fix?


There are cases where it is useful to be able to name `std::nested_exception` 
while exceptions are disabled. I agree with @rogfer01 on this patch.


https://reviews.llvm.org/D26458



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


[PATCH] D26139: Tests for strings conversions under libcpp-no-exceptions

2016-11-14 Thread Eric Fiselier via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

LGTM. The consensus is against adding `TEST_TRY` and `TEST_CATCH`.


https://reviews.llvm.org/D26139



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


[PATCH] D26589: Add static analyzer checker for finding infinite recursion

2016-11-14 Thread Aleksei Sidorin via cfe-commits
a.sidorin added a comment.

Wow, thank you for such a contribution! Did you evaluate this checker on some 
real code?

I have some minor inline comments below.




Comment at: lib/StaticAnalyzer/Checkers/CMakeLists.txt:41
   IdenticalExprChecker.cpp
+RecursionChecker.cpp
   IvarInvalidationChecker.cpp

Please fix indentation here



Comment at: lib/StaticAnalyzer/Checkers/RecursionChecker.cpp:12
+// This defines TestAfterDivZeroChecker, a builtin check that performs checks
+//  for division by zero where the division occurs before comparison with zero.
+//

This description is for other checker, could you update it?



Comment at: lib/StaticAnalyzer/Checkers/RecursionChecker.cpp:21
+
+REGISTER_SET_WITH_PROGRAMSTATE(DirtyStackFrames, const 
clang::StackFrameContext *)
+

The idea of "dirty stack frames" deserves some explanation. As I understand, it 
describes function calls where some values may change unexpectedly and we 
cannot consider this calls later. Am I understanding correctly?



Comment at: lib/StaticAnalyzer/Checkers/RecursionChecker.cpp:49
+  void checkPostCall(const CallEvent &Call,
+   CheckerContext &C) const;
+};

Incorrect indentation.



Comment at: lib/StaticAnalyzer/Checkers/RecursionChecker.cpp:68
+
+if (ParentLC->getKind() != LocationContext::StackFrame)
+  continue;

We may just use `getParent()->getCurrentStackFrame()` in the loop increment to 
make the code cleaner. What do you think?



Comment at: lib/StaticAnalyzer/Checkers/RecursionChecker.cpp:79
+const FunctionDecl *PrevFuncDecl =
+(const FunctionDecl *)PrevStackFrameCtx->getDecl();
+PrevFuncDecl = PrevFuncDecl->getCanonicalDecl();

We usually prefer LLVM `[dyn_]cast<>` where possible.



Comment at: lib/StaticAnalyzer/Checkers/RecursionChecker.cpp:89
+  SVal PrevArg = State->getArgSVal(PrevStackFrameCtx, i);
+  SameArgs = SameArgs && compareArgs(C, State, CurArg, PrevArg);
+}

Maybe we can use early return here?



Comment at: test/Analysis/recursion.cpp:27
+
+void f2();
+void f3();

I'd like to see some more informative function names: for me, it is hard to 
distinguish between f1-7 here :) It is also hard to determine the function 
where test starts.


https://reviews.llvm.org/D26589



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


[PATCH] D26457: Protect smart-pointer tests under no exceptions

2016-11-14 Thread Roger Ferrer Ibanez via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286809: Protect smart-pointer tests under no exceptions 
(authored by rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D26457?vs=77361&id=8#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26457

Files:
  
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
  
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp


Index: 
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
===
--- 
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
+++ 
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // shared_ptr
@@ -17,6 +16,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 struct B
 {
 static int count;
@@ -42,6 +43,7 @@
 
 int main()
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 std::weak_ptr wp;
 try
@@ -54,6 +56,7 @@
 }
 assert(A::count == 0);
 }
+#endif
 {
 std::shared_ptr sp0(new A);
 std::weak_ptr wp(sp0);
@@ -63,6 +66,7 @@
 assert(A::count == 1);
 }
 assert(A::count == 0);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 std::shared_ptr sp0(new A);
 std::weak_ptr wp(sp0);
@@ -77,4 +81,5 @@
 }
 }
 assert(A::count == 0);
+#endif
 }
Index: 
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
===
--- 
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
+++ 
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: sanitizer-new-delete
 
 // 
@@ -63,6 +62,7 @@
 assert(p.get() == raw_ptr);
 assert(ptr.get() == 0);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 assert(A::count == 0);
 {
 std::unique_ptr ptr(new A);
@@ -86,6 +86,7 @@
 #endif
 }
 }
+#endif
 assert(A::count == 0);
 { // LWG 2399
 fn(std::unique_ptr(new int));


Index: libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
===
--- libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
+++ libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // shared_ptr
@@ -17,6 +16,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 struct B
 {
 static int count;
@@ -42,6 +43,7 @@
 
 int main()
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 std::weak_ptr wp;
 try
@@ -54,6 +56,7 @@
 }
 assert(A::count == 0);
 }
+#endif
 {
 std::shared_ptr sp0(new A);
 std::weak_ptr wp(sp0);
@@ -63,6 +66,7 @@
 assert(A::count == 1);
 }
 assert(A::count == 0);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 std::shared_ptr sp0(new A);
 std::weak_ptr wp(sp0);
@@ -77,4 +81,5 @@
 }
 }
 assert(A::count == 0);
+#endif
 }
Index: libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
===
--- libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
+++ libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: sanitizer-new-delete
 
 // 
@@ -63,6 +62,7 @@
 assert(p.get() == raw_ptr);
 assert(ptr.get() == 0);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 assert(A::count == 0);
 {
 std::unique_ptr ptr(new A);
@@ -86,6 +86,7 @@
 #endif
 }
 }
+#endif
 assert(A::count == 0);
 { // LWG 2399
 fn(std::unique_ptr(new int));
_

[libcxx] r286809 - Protect smart-pointer tests under no exceptions

2016-11-14 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Mon Nov 14 04:27:56 2016
New Revision: 286809

URL: http://llvm.org/viewvc/llvm-project?rev=286809&view=rev
Log:
Protect smart-pointer tests under no exceptions

Skip tests that expect an exception be thrown under no-exceptions.

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


Modified:

libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp

libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp?rev=286809&r1=286808&r2=286809&view=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
 Mon Nov 14 04:27:56 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: sanitizer-new-delete
 
 // 
@@ -63,6 +62,7 @@ int main()
 assert(p.get() == raw_ptr);
 assert(ptr.get() == 0);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 assert(A::count == 0);
 {
 std::unique_ptr ptr(new A);
@@ -86,6 +86,7 @@ int main()
 #endif
 }
 }
+#endif
 assert(A::count == 0);
 { // LWG 2399
 fn(std::unique_ptr(new int));

Modified: 
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp?rev=286809&r1=286808&r2=286809&view=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
 Mon Nov 14 04:27:56 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // shared_ptr
@@ -17,6 +16,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 struct B
 {
 static int count;
@@ -42,6 +43,7 @@ int A::count = 0;
 
 int main()
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 std::weak_ptr wp;
 try
@@ -54,6 +56,7 @@ int main()
 }
 assert(A::count == 0);
 }
+#endif
 {
 std::shared_ptr sp0(new A);
 std::weak_ptr wp(sp0);
@@ -63,6 +66,7 @@ int main()
 assert(A::count == 1);
 }
 assert(A::count == 0);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 std::shared_ptr sp0(new A);
 std::weak_ptr wp(sp0);
@@ -77,4 +81,5 @@ int main()
 }
 }
 assert(A::count == 0);
+#endif
 }


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


[PATCH] D26589: Add static analyzer checker for finding infinite recursion

2016-11-14 Thread Krzysztof Wiśniewski via cfe-commits
k-wisniewski added a comment.

@a.sidorin 
Thank you for your review! I'll upload the new patch this evening that will 
include fixes for the things you pointed out. Can I also add you as a reviewer? 
Also: Can you have a look at my other patch that I have linked in the 
description? Thanks in advance!




Comment at: lib/StaticAnalyzer/Checkers/RecursionChecker.cpp:12
+// This defines TestAfterDivZeroChecker, a builtin check that performs checks
+//  for division by zero where the division occurs before comparison with zero.
+//

a.sidorin wrote:
> This description is for other checker, could you update it?
Sure, it was easier for me to use some other checker as a template and I forgot 
about it. Should I add you as a reviewer once I upload the updated patch?



Comment at: lib/StaticAnalyzer/Checkers/RecursionChecker.cpp:21
+
+REGISTER_SET_WITH_PROGRAMSTATE(DirtyStackFrames, const 
clang::StackFrameContext *)
+

a.sidorin wrote:
> The idea of "dirty stack frames" deserves some explanation. As I understand, 
> it describes function calls where some values may change unexpectedly and we 
> cannot consider this calls later. Am I understanding correctly?
Yes! Right now it considers frame as "dirty" when there was any kind of region 
change in this frame or in any function that was called from it. As you see 
below, it then stops the search down the stack once it encounter such a "dirty" 
frame, because it can no longer be sure that conditions upon which the 
recursive call depends on did not change in an unpredictable way. It's 
obviously too broad a definition and in the next iterations I'll try to narrow 
it down to variables that affect whether the recursive call happens or not. I 
also consider looking at //the way // it changes to determine if it's 
meaningful or not.



Comment at: test/Analysis/recursion.cpp:27
+
+void f2();
+void f3();

a.sidorin wrote:
> I'd like to see some more informative function names: for me, it is hard to 
> distinguish between f1-7 here :) It is also hard to determine the function 
> where test starts.
The convention I know is that the bottom-most one gets considered first, but I 
may add some explicitly marked entry points for the sake of consistency and to 
make it easier to reason about. 


https://reviews.llvm.org/D26589



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


[PATCH] D26139: Tests for strings conversions under libcpp-no-exceptions

2016-11-14 Thread Roger Ferrer Ibanez via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286812: Update tests for strings conversions under 
libcpp-no-exceptions (authored by rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D26139?vs=76373&id=9#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26139

Files:
  libcxx/trunk/test/std/strings/string.conversions/stod.pass.cpp
  libcxx/trunk/test/std/strings/string.conversions/stof.pass.cpp
  libcxx/trunk/test/std/strings/string.conversions/stoi.pass.cpp
  libcxx/trunk/test/std/strings/string.conversions/stol.pass.cpp
  libcxx/trunk/test/std/strings/string.conversions/stold.pass.cpp
  libcxx/trunk/test/std/strings/string.conversions/stoll.pass.cpp
  libcxx/trunk/test/std/strings/string.conversions/stoul.pass.cpp
  libcxx/trunk/test/std/strings/string.conversions/stoull.pass.cpp

Index: libcxx/trunk/test/std/strings/string.conversions/stoul.pass.cpp
===
--- libcxx/trunk/test/std/strings/string.conversions/stoul.pass.cpp
+++ libcxx/trunk/test/std/strings/string.conversions/stoul.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
 
@@ -19,6 +18,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int main()
 {
 assert(std::stoul("0") == 0);
@@ -33,6 +34,7 @@
 idx = 0;
 assert(std::stoul(L"10g", &idx, 16) == 16);
 assert(idx == 2);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 idx = 0;
 try
 {
@@ -107,4 +109,5 @@
 {
 assert(idx == 0);
 }
+#endif
 }
Index: libcxx/trunk/test/std/strings/string.conversions/stold.pass.cpp
===
--- libcxx/trunk/test/std/strings/string.conversions/stold.pass.cpp
+++ libcxx/trunk/test/std/strings/string.conversions/stold.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // long double stold(const string& str, size_t *idx = 0);
@@ -19,6 +18,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int main()
 {
 assert(std::stold("0") == 0);
@@ -35,25 +36,32 @@
 idx = 0;
 assert(std::stold(L"10g", &idx) == 10);
 assert(idx == 2);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
+#endif
 {
 assert(std::stold("1.e60", &idx) == 1.e60L);
 assert(idx == 5);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (const std::out_of_range&)
 {
 assert(false);
 }
 try
+#endif
 {
 assert(std::stold(L"1.e60", &idx) == 1.e60L);
 assert(idx == 5);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (const std::out_of_range&)
 {
 assert(false);
 }
+#endif
 idx = 0;
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 assert(std::stold("1.e6000", &idx) == INFINITY);
@@ -73,40 +81,54 @@
 assert(idx == 0);
 }
 try
+#endif
 {
 assert(std::stold("INF", &idx) == INFINITY);
 assert(idx == 3);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (const std::out_of_range&)
 {
 assert(false);
 }
+#endif
 idx = 0;
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
+#endif
 {
 assert(std::stold(L"INF", &idx) == INFINITY);
 assert(idx == 3);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (const std::out_of_range&)
 {
 assert(false);
 }
+#endif
 idx = 0;
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
+#endif
 {
 assert(std::isnan(std::stold("NAN", &idx)));
 assert(idx == 3);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (const std::out_of_range&)
 {
 assert(false);
 }
+#endif
 idx = 0;
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
+#endif
 {
 assert(std::isnan(std::stold(L"NAN", &idx)));
 assert(idx == 3);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (const std::out_of_range&)
 {
 assert(false);
@@ -166,4 +188,5 @@
 {
 assert(idx == 0);
 }
+#endif
 }
Index: libcxx/trunk/test/std/strings/string.conversions/stoull.pass.cpp
===
--- libcxx/trunk/test/std/strings/string.conversions/stoull.pass.cpp
+++ libcxx/trunk/test/std/strings/string.conversions/stoull.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
 
@@ -19,6 +18,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int main()
 {
 assert(std::stoull("0") == 0);
@@ -33,6 +34,7 @@
 idx = 0;
 assert(std::stoull(L"10g", &idx, 16) == 16);
 assert(idx == 2);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 idx = 0;

[libcxx] r286812 - Update tests for strings conversions under libcpp-no-exceptions

2016-11-14 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Mon Nov 14 04:44:26 2016
New Revision: 286812

URL: http://llvm.org/viewvc/llvm-project?rev=286812&view=rev
Log:
Update tests for strings conversions under libcpp-no-exceptions

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


Modified:
libcxx/trunk/test/std/strings/string.conversions/stod.pass.cpp
libcxx/trunk/test/std/strings/string.conversions/stof.pass.cpp
libcxx/trunk/test/std/strings/string.conversions/stoi.pass.cpp
libcxx/trunk/test/std/strings/string.conversions/stol.pass.cpp
libcxx/trunk/test/std/strings/string.conversions/stold.pass.cpp
libcxx/trunk/test/std/strings/string.conversions/stoll.pass.cpp
libcxx/trunk/test/std/strings/string.conversions/stoul.pass.cpp
libcxx/trunk/test/std/strings/string.conversions/stoull.pass.cpp

Modified: libcxx/trunk/test/std/strings/string.conversions/stod.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/string.conversions/stod.pass.cpp?rev=286812&r1=286811&r2=286812&view=diff
==
--- libcxx/trunk/test/std/strings/string.conversions/stod.pass.cpp (original)
+++ libcxx/trunk/test/std/strings/string.conversions/stod.pass.cpp Mon Nov 14 
04:44:26 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // double stod(const string& str, size_t *idx = 0);
@@ -17,6 +16,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int main()
 {
 assert(std::stod("0") == 0);
@@ -33,20 +34,25 @@ int main()
 idx = 0;
 assert(std::stod(L"10g", &idx) == 10);
 assert(idx == 2);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
+#endif
 {
 assert(std::stod("1.e60", &idx) == 1.e60);
 assert(idx == 5);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (const std::out_of_range&)
 {
 assert(false);
 }
 try
+#endif
 {
 assert(std::stod(L"1.e60", &idx) == 1.e60);
 assert(idx == 5);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (const std::out_of_range&)
 {
 assert(false);
@@ -71,40 +77,54 @@ int main()
 assert(idx == 0);
 }
 try
+#endif
 {
 assert(std::stod("INF", &idx) == INFINITY);
 assert(idx == 3);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (const std::out_of_range&)
 {
 assert(false);
 }
+#endif
 idx = 0;
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
+#endif
 {
 assert(std::stod(L"INF", &idx) == INFINITY);
 assert(idx == 3);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (const std::out_of_range&)
 {
 assert(false);
 }
+#endif
 idx = 0;
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
+#endif
 {
 assert(std::isnan(std::stod("NAN", &idx)));
 assert(idx == 3);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (const std::out_of_range&)
 {
 assert(false);
 }
+#endif
 idx = 0;
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
+#endif
 {
 assert(std::isnan(std::stod(L"NAN", &idx)));
 assert(idx == 3);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (const std::out_of_range&)
 {
 assert(false);
@@ -164,4 +184,5 @@ int main()
 {
 assert(idx == 0);
 }
+#endif
 }

Modified: libcxx/trunk/test/std/strings/string.conversions/stof.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/string.conversions/stof.pass.cpp?rev=286812&r1=286811&r2=286812&view=diff
==
--- libcxx/trunk/test/std/strings/string.conversions/stof.pass.cpp (original)
+++ libcxx/trunk/test/std/strings/string.conversions/stof.pass.cpp Mon Nov 14 
04:44:26 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
 
@@ -20,6 +19,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int main()
 {
 assert(std::stof("0") == 0);
@@ -36,6 +37,7 @@ int main()
 idx = 0;
 assert(std::stof(L"10g", &idx) == 10);
 assert(idx == 2);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 idx = 0;
 try
 {
@@ -75,40 +77,54 @@ int main()
 assert(idx == 0);
 }
 try
+#endif
 {
 assert(std::stof("INF", &idx) == INFINITY);
 assert(idx == 3);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (const std::out_of_range&)
 {
 assert(false);
 }
+#endif
 idx = 0;
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
+#endif
 {
 assert(std::stof(L"INF", &idx) == INFINITY);
 assert(idx == 3);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (const std::out_of_range&)
 {
 assert(false);
 }
+#endif
 idx = 0;
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
+#endif
 {
 

[PATCH] D26458: Protect nested-exceptions tests under no-exceptions

2016-11-14 Thread Roger Ferrer Ibanez via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286813: Protect nested-exceptions tests under no-exceptions 
(authored by rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D26458?vs=77363&id=77782#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26458

Files:
  
libcxx/trunk/test/std/language.support/support.exception/except.nested/assign.pass.cpp
  
libcxx/trunk/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp
  
libcxx/trunk/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp

Index: libcxx/trunk/test/std/language.support/support.exception/except.nested/assign.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.exception/except.nested/assign.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.exception/except.nested/assign.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // class nested_exception;
@@ -17,6 +16,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 class A
 {
 int data_;
@@ -34,6 +35,7 @@
 e = e0;
 assert(e.nested_ptr() == nullptr);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 try
 {
@@ -57,4 +59,5 @@
 }
 }
 }
+#endif
 }
Index: libcxx/trunk/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // class nested_exception;
@@ -17,6 +16,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 class A
 {
 int data_;
@@ -33,6 +34,7 @@
 std::nested_exception e = e0;
 assert(e.nested_ptr() == nullptr);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 try
 {
@@ -55,4 +57,5 @@
 }
 }
 }
+#endif
 }
Index: libcxx/trunk/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // class nested_exception;
@@ -17,6 +16,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 class A
 {
 int data_;
@@ -32,6 +33,7 @@
 std::nested_exception e;
 assert(e.nested_ptr() == nullptr);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 try
 {
@@ -53,4 +55,5 @@
 }
 }
 }
+#endif
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r286813 - Protect nested-exceptions tests under no-exceptions

2016-11-14 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Mon Nov 14 05:00:28 2016
New Revision: 286813

URL: http://llvm.org/viewvc/llvm-project?rev=286813&view=rev
Log:
Protect nested-exceptions tests under no-exceptions

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


Modified:

libcxx/trunk/test/std/language.support/support.exception/except.nested/assign.pass.cpp

libcxx/trunk/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp

libcxx/trunk/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp

Modified: 
libcxx/trunk/test/std/language.support/support.exception/except.nested/assign.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.exception/except.nested/assign.pass.cpp?rev=286813&r1=286812&r2=286813&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.exception/except.nested/assign.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.exception/except.nested/assign.pass.cpp
 Mon Nov 14 05:00:28 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // class nested_exception;
@@ -17,6 +16,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 class A
 {
 int data_;
@@ -34,6 +35,7 @@ int main()
 e = e0;
 assert(e.nested_ptr() == nullptr);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 try
 {
@@ -57,4 +59,5 @@ int main()
 }
 }
 }
+#endif
 }

Modified: 
libcxx/trunk/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp?rev=286813&r1=286812&r2=286813&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp
 Mon Nov 14 05:00:28 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // class nested_exception;
@@ -17,6 +16,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 class A
 {
 int data_;
@@ -33,6 +34,7 @@ int main()
 std::nested_exception e = e0;
 assert(e.nested_ptr() == nullptr);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 try
 {
@@ -55,4 +57,5 @@ int main()
 }
 }
 }
+#endif
 }

Modified: 
libcxx/trunk/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp?rev=286813&r1=286812&r2=286813&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp
 Mon Nov 14 05:00:28 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // class nested_exception;
@@ -17,6 +16,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 class A
 {
 int data_;
@@ -32,6 +33,7 @@ int main()
 std::nested_exception e;
 assert(e.nested_ptr() == nullptr);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 try
 {
@@ -53,4 +55,5 @@ int main()
 }
 }
 }
+#endif
 }


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


r286815 - Improve handling of floating point literals in OpenCL to only use double precision if the target supports fp64.

2016-11-14 Thread Neil Hickey via cfe-commits
Author: neil.hickey
Date: Mon Nov 14 05:15:51 2016
New Revision: 286815

URL: http://llvm.org/viewvc/llvm-project?rev=286815&view=rev
Log:
Improve handling of floating point literals in OpenCL to only use double 
precision if the target supports fp64.

This change makes sure single-precision floating point types are used if the 
cl_fp64 extension is not supported by the target.

Also removed the check to see whether the OpenCL version is >= 1.2, as this has
been incorporated into the extension setting code.

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


Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/CodeGenOpenCL/fpmath.cl
cfe/trunk/test/SemaOpenCL/extensions.cl

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=286815&r1=286814&r2=286815&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Nov 14 05:15:51 2016
@@ -705,9 +705,13 @@ ExprResult Sema::DefaultLvalueConversion
   if (getLangOpts().ObjCAutoRefCount &&
   E->getType().getObjCLifetime() == Qualifiers::OCL_Weak)
 Cleanup.setExprNeedsCleanups(true);
+  
+  ExprResult Res = E;
 
-  ExprResult Res = ImplicitCastExpr::Create(Context, T, CK_LValueToRValue, E,
-nullptr, VK_RValue);
+  if ( T != E->getType()) {
+Res = ImplicitCastExpr::Create(Context, T, CK_LValueToRValue, E,
+   nullptr, VK_RValue);
+  }
 
   // C11 6.3.2.1p2:
   //   ... if the lvalue has atomic type, the value has the non-atomic version 
@@ -817,8 +821,16 @@ ExprResult Sema::DefaultArgumentPromotio
   // double.
   const BuiltinType *BTy = Ty->getAs();
   if (BTy && (BTy->getKind() == BuiltinType::Half ||
-  BTy->getKind() == BuiltinType::Float))
-E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).get();
+  BTy->getKind() == BuiltinType::Float)) {
+if (getLangOpts().OpenCL &&
+!(getOpenCLOptions().cl_khr_fp64)) {
+if (BTy->getKind() == BuiltinType::Half) {
+E = ImpCastExprToType(E, Context.FloatTy, CK_FloatingCast).get();
+}
+} else {
+  E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).get();
+}
+  }
 
   // C++ performs lvalue-to-rvalue conversion as a default argument
   // promotion, even on class types, but note:
@@ -3397,10 +3409,13 @@ ExprResult Sema::ActOnNumericConstant(co
 
 if (Ty == Context.DoubleTy) {
   if (getLangOpts().SinglePrecisionConstants) {
-Res = ImpCastExprToType(Res, Context.FloatTy, CK_FloatingCast).get();
+const BuiltinType *BTy = Ty->getAs();
+if (BTy->getKind() != BuiltinType::Float) {
+  Res = ImpCastExprToType(Res, Context.FloatTy, CK_FloatingCast).get();
+}
   } else if (getLangOpts().OpenCL &&
- !((getLangOpts().OpenCLVersion >= 120) ||
-   getOpenCLOptions().cl_khr_fp64)) {
+ !(getOpenCLOptions().cl_khr_fp64)) {
+// Impose single-precision float type when cl_khr_fp64 is not enabled.
 Diag(Tok.getLocation(), diag::warn_double_const_requires_fp64);
 Res = ImpCastExprToType(Res, Context.FloatTy, CK_FloatingCast).get();
   }

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=286815&r1=286814&r2=286815&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Mon Nov 14 05:15:51 2016
@@ -1402,8 +1402,7 @@ static QualType ConvertDeclSpecToType(Ty
   Result = Context.DoubleTy;
 
 if (S.getLangOpts().OpenCL &&
-!((S.getLangOpts().OpenCLVersion >= 120) ||
-  S.getOpenCLOptions().cl_khr_fp64)) {
+!(S.getOpenCLOptions().cl_khr_fp64)) {
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_requires_extension)
   << Result << "cl_khr_fp64";
   declarator.setInvalidType(true);

Modified: cfe/trunk/test/CodeGenOpenCL/fpmath.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/fpmath.cl?rev=286815&r1=286814&r2=286815&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/fpmath.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/fpmath.cl Mon Nov 14 05:15:51 2016
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown | FileCheck 
--check-prefix=CHECK --check-prefix=NODIVOPT %s
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown 
-cl-fp32-correctly-rounded-divide-sqrt | FileCheck --check-prefix=CHECK 
--check-prefix=DIVOPT %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -DNOFP64 -cl-std=CL1.1 -triple 
r600-unknown-unknown -target-cpu r600 -pedantic | FileCheck

[PATCH] D24235: [OpenCL] Improve double literal handling

2016-11-14 Thread Neil Hickey via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286815: Improve handling of floating point literals in 
OpenCL to only use double… (authored by neil.hickey).

Changed prior to commit:
  https://reviews.llvm.org/D24235?vs=77600&id=77783#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24235

Files:
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/test/CodeGenOpenCL/fpmath.cl
  cfe/trunk/test/SemaOpenCL/extensions.cl

Index: cfe/trunk/test/SemaOpenCL/extensions.cl
===
--- cfe/trunk/test/SemaOpenCL/extensions.cl
+++ cfe/trunk/test/SemaOpenCL/extensions.cl
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.1
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.2 -DFP64
 
 // Test with a target not supporting fp64.
 // RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16
@@ -21,12 +22,16 @@
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -cl-ext=+cl_khr_fp64 -cl-ext=+cl_khr_fp16 -cl-ext=-cl_khr_fp64 -DNOFP64
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -cl-ext=+cl_khr_fp64,-cl_khr_fp64,+cl_khr_fp16 -DNOFP64
 
+#ifdef FP64
+// expected-no-diagnostics
+#endif
 
-
+#if __OPENCL_C_VERSION__ < 120
 void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 extension}}
   double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
   (void) 1.0; // expected-warning {{double precision constant requires cl_khr_fp64}}
 }
+#endif
 
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 #ifdef NOFP64
@@ -45,16 +50,19 @@
 #endif
 
   (void) 1.0;
+
 #ifdef NOFP64
-// expected-warning@-2{{double precision constant requires cl_khr_fp64, casting to single precision}}
+// expected-warning@-6{{double precision constant requires cl_khr_fp64, casting to single precision}}
 #endif
 }
 
 #pragma OPENCL EXTENSION cl_khr_fp64 : disable
 #ifdef NOFP64
 // expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp64' - ignoring}}
 #endif
 
+#if __OPENCL_C_VERSION__ < 120
 void f3(void) {
   double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
 }
+#endif
Index: cfe/trunk/test/CodeGenOpenCL/fpmath.cl
===
--- cfe/trunk/test/CodeGenOpenCL/fpmath.cl
+++ cfe/trunk/test/CodeGenOpenCL/fpmath.cl
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown | FileCheck --check-prefix=CHECK --check-prefix=NODIVOPT %s
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown -cl-fp32-correctly-rounded-divide-sqrt | FileCheck --check-prefix=CHECK --check-prefix=DIVOPT %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -DNOFP64 -cl-std=CL1.1 -triple r600-unknown-unknown -target-cpu r600 -pedantic | FileCheck --check-prefix=CHECK-DBL %s
 
 typedef __attribute__(( ext_vector_type(4) )) float float4;
 
@@ -21,14 +22,26 @@
   return a / b;
 }
 
+void printf(constant char* fmt, ...);
+
+#ifndef NOFP64
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
+#endif
+void testdbllit(long *val) {
+  // CHECK-DBL: float 2.00e+01
+  // CHECK: double 2.00e+01
+  printf("%f", 20.0);
+}
 
+#ifndef NOFP64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
 double dpscalardiv(double a, double b) {
   // CHECK: @dpscalardiv
   // CHECK: #[[ATTR]]
   // CHECK-NOT: !fpmath
   return a / b;
 }
+#endif
 
 // CHECK: attributes #[[ATTR]] = {
 // NODIVOPT: "correctly-rounded-divide-sqrt-fp-math"="false"
Index: cfe/trunk/lib/Sema/SemaType.cpp
===
--- cfe/trunk/lib/Sema/SemaType.cpp
+++ cfe/trunk/lib/Sema/SemaType.cpp
@@ -1402,8 +1402,7 @@
   Result = Context.DoubleTy;
 
 if (S.getLangOpts().OpenCL &&
-!((S.getLangOpts().OpenCLVersion >= 120) ||
-  S.getOpenCLOptions().cl_khr_fp64)) {
+!(S.getOpenCLOptions().cl_khr_fp64)) {
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_requires_extension)
   << Result << "cl_khr_fp64";
   declarator.setInvalidType(true);
Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -705,9 +705,13 @@
   if (getLangOpts().ObjCAutoRefCount &&
   E->getType().getObjCLifetime() == Qualifiers::OCL_Weak)
 Cleanup.setExprNeedsCleanups(true);
+  
+  ExprResult Res = E;
 
-  ExprResult Res = ImplicitCastExpr::Create(Context, T, CK_LValueToRValue, E,
-nullptr, VK_RValue);
+  if ( T != E->getType()) {
+Res = ImplicitCastExpr::Create(Context, T, CK_

[PATCH] D26509: [OpenCL] Fix integer parameters of enqueue_kernel

2016-11-14 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

I see. If I say something like:

- For the number of event argument allow to pass larger integers than 32 bits 
as soon as compiler can prove that the range fits in 32 bits. If not, the 
diagnostic will be given.

- Change type of the arguments specifying sizes of the corresponding block 
arguments to  be size_t.


https://reviews.llvm.org/D26509



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


[PATCH] D26515: [clang-move] Abstract a ClassMather for matching class declarations.

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



Comment at: clang-move/ClangMove.cpp:139
 
+class ClassDeclarationMatcher : public MatchFinder::MatchCallback {
+public:

ioeric wrote:
> Why is this called a Matcher?
Rename it to a better name "Match".


https://reviews.llvm.org/D26515



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


[PATCH] D26515: [clang-move] Abstract a ClassMather for matching class declarations.

2016-11-14 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 77788.
hokein marked 2 inline comments as done.
hokein added a comment.

Split to small functions.


https://reviews.llvm.org/D26515

Files:
  clang-move/ClangMove.cpp
  clang-move/ClangMove.h

Index: clang-move/ClangMove.h
===
--- clang-move/ClangMove.h
+++ clang-move/ClangMove.h
@@ -16,6 +16,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -80,6 +81,14 @@
clang::CharSourceRange IncludeFilenameRange,
const SourceManager &SM);
 
+  std::vector &getMovedDecls() { return MovedDecls; }
+
+  std::vector &getRemovedDecls() { return RemovedDecls; }
+
+  llvm::SmallPtrSet &getUnremovedDeclsInOldHeader() {
+return UnremovedDeclsInOldHeader;
+  }
+
 private:
   // Make the Path absolute using the OrignalRunningDirectory if the Path is not
   // an absolute path. An empty Path will result in an empty string.
@@ -90,6 +99,9 @@
   void moveAll(SourceManager& SM, StringRef OldFile, StringRef NewFile);
 
   MoveDefinitionSpec Spec;
+  // Stores all MatchCallbacks created by this tool.
+  std::vector>
+  MatchCallbacks;
   // The Key is file path, value is the replacements being applied to the file.
   std::map &FileToReplacements;
   // All declarations (the class decl being moved, forward decls) that need to
Index: clang-move/ClangMove.cpp
===
--- clang-move/ClangMove.cpp
+++ clang-move/ClangMove.cpp
@@ -136,6 +136,73 @@
   ClangMoveTool *const MoveTool;
 };
 
+class ClassDeclarationMatch : public MatchFinder::MatchCallback {
+public:
+  explicit ClassDeclarationMatch(ClangMoveTool *MoveTool)
+  : MoveTool(MoveTool) {}
+  void run(const MatchFinder::MatchResult &Result) override {
+if (MatchClassMethod(Result)) return;
+if (MatchClassStaticVariable(Result)) return;
+if (MatchClassDeclaration(Result)) return;
+  }
+
+private:
+  bool MatchClassMethod(const MatchFinder::MatchResult &Result) {
+if (const auto *CMD =
+Result.Nodes.getNodeAs("class_method")) {
+  // Skip inline class methods. isInline() ast matcher doesn't ignore this
+  // case.
+  if (!CMD->isInlined()) {
+MoveTool->getMovedDecls().emplace_back(
+CMD, &Result.Context->getSourceManager());
+MoveTool->getRemovedDecls().push_back(MoveTool->getMovedDecls().back());
+// Get template class method from its method declaration as
+// UnremovedDecls stores template class method.
+if (const auto *FTD = CMD->getDescribedFunctionTemplate()) {
+  MoveTool->getUnremovedDeclsInOldHeader().erase(FTD);
+} else {
+  MoveTool->getUnremovedDeclsInOldHeader().erase(CMD);
+}
+  }
+  return true;
+}
+return false;
+  }
+
+  bool MatchClassStaticVariable(const MatchFinder::MatchResult &Result) {
+   if (const auto *VD = Result.Nodes.getNodeAs(
+   "class_static_var_decl")) {
+  MoveTool->getMovedDecls().emplace_back(
+  VD, &Result.Context->getSourceManager());
+  MoveTool->getRemovedDecls().push_back(MoveTool->getMovedDecls().back());
+  MoveTool->getUnremovedDeclsInOldHeader().erase(VD);
+  return true;
+}
+return false;
+  }
+
+  bool MatchClassDeclaration(const MatchFinder::MatchResult &Result) {
+if (const auto *CD = Result.Nodes.getNodeAs(
+   "moved_class")) {
+  // Get class template from its class declaration as UnremovedDecls stores
+  // class template.
+  if (const auto *TC = CD->getDescribedClassTemplate()) {
+MoveTool->getMovedDecls().emplace_back(
+TC, &Result.Context->getSourceManager());
+  } else {
+MoveTool->getMovedDecls().emplace_back(
+CD, &Result.Context->getSourceManager());
+  }
+  MoveTool->getRemovedDecls().push_back(MoveTool->getMovedDecls().back());
+  MoveTool->getUnremovedDeclsInOldHeader().erase(
+  MoveTool->getMovedDecls().back().Decl);
+  return true;
+}
+return false;
+  }
+  ClangMoveTool *MoveTool;
+};
+
 // Expand to get the end location of the line where the EndLoc of the given
 // Decl.
 SourceLocation
@@ -352,23 +419,27 @@
   //
   // Matchers for old files, including old.h/old.cc
   //
+  // Create a MatchCallback for class declarations.
+  MatchCallbacks.push_back(llvm::make_unique(this));
   // Match moved class declarations.
-  auto MovedClass = cxxRecordDecl(
-  InOldFiles, *InMovedClassNames, isDefinition(),
-  hasDeclContext(anyOf(namespaceDecl(), translationUnitDecl(;
-  Finder->addMatcher(MovedClass.bind("moved_class"), this);
+  auto MovedClass =
+  cxxRecordDecl(
+  InOldFiles,

[PATCH] D26571: Clean up layout of ASTMerge tests

2016-11-14 Thread Aleksei Sidorin via cfe-commits
a.sidorin accepted this revision.
a.sidorin added a comment.
This revision is now accepted and ready to land.

Looks good, thank you!


Repository:
  rL LLVM

https://reviews.llvm.org/D26571



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


[PATCH] D26512: Protect std::ios tests under libcpp-no-exceptions

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

Add missing asserts as pointed out by @EricWF


https://reviews.llvm.org/D26512

Files:
  test/std/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp
  test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp
  test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp
  
test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp
  test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp

Index: test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp
===
--- test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp
+++ test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  class basic_ios
@@ -18,17 +17,21 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 struct testbuf : public std::streambuf {};
 
 int main()
 {
 {
 std::ios ios(0);
 ios.setstate(std::ios::goodbit);
 assert(ios.rdstate() == std::ios::badbit);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 ios.exceptions(std::ios::badbit);
+assert(false);
 }
 catch (...)
 {
@@ -51,6 +54,7 @@
 {
 assert(ios.rdstate() == (std::ios::eofbit | std::ios::badbit));
 }
+#endif
 }
 {
 testbuf sb;
Index: test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp
===
--- test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp
+++ test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  class basic_ios
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 struct testbuf : public std::streambuf {};
 
 int main()
@@ -27,6 +28,7 @@
 assert(ios.exceptions() == std::ios::goodbit);
 ios.exceptions(std::ios::eofbit);
 assert(ios.exceptions() == std::ios::eofbit);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 ios.exceptions(std::ios::badbit);
@@ -36,6 +38,7 @@
 {
 }
 assert(ios.exceptions() == std::ios::badbit);
+#endif
 }
 {
 testbuf sb;
Index: test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp
===
--- test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp
+++ test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  class basic_ios
@@ -18,17 +17,21 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 struct testbuf : public std::streambuf {};
 
 int main()
 {
 {
 std::ios ios(0);
 ios.clear();
 assert(ios.rdstate() == std::ios::badbit);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 ios.exceptions(std::ios::badbit);
+assert(false);
 }
 catch (...)
 {
@@ -51,6 +54,7 @@
 {
 assert(ios.rdstate() == (std::ios::eofbit | std::ios::badbit));
 }
+#endif
 }
 {
 testbuf sb;
Index: test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp
===
--- test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp
+++ test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  class basic_ios
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 struct testbuf
 : public std::streambuf
 {
@@ -35,24 +36,29 @@
 testbuf sb1;
 testbuf sb2;
 testios ios(&sb1);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 ios.setstate(std::ios::badbit);
 ios.exceptions(std::ios::badbit);
+assert(false);
 }
 catch (...)
 {
 }
+#endif
 ios.set_rdbuf(&sb2);
 assert(ios.rdbuf() == &sb2);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 ios.setstate(std::ios::badbit);
 ios.exceptions(std::ios::badbit);
 }
 catch (...)
 {
 }
+#endif
 ios.set_rdbuf(0);
 assert(ios.rdbuf() == 0);
 }
Index: test/std/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp
===

r286818 - Revert "Improve handling of floating point literals in OpenCL to only use double precision if the target supports fp64."

2016-11-14 Thread Renato Golin via cfe-commits
Author: rengolin
Date: Mon Nov 14 06:19:18 2016
New Revision: 286818

URL: http://llvm.org/viewvc/llvm-project?rev=286818&view=rev
Log:
Revert "Improve handling of floating point literals in OpenCL to only use 
double precision if the target supports fp64."

This reverts commit r286815, as it broke all ARM and AArch64 bots.

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/CodeGenOpenCL/fpmath.cl
cfe/trunk/test/SemaOpenCL/extensions.cl

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=286818&r1=286817&r2=286818&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Nov 14 06:19:18 2016
@@ -705,13 +705,9 @@ ExprResult Sema::DefaultLvalueConversion
   if (getLangOpts().ObjCAutoRefCount &&
   E->getType().getObjCLifetime() == Qualifiers::OCL_Weak)
 Cleanup.setExprNeedsCleanups(true);
-  
-  ExprResult Res = E;
 
-  if ( T != E->getType()) {
-Res = ImplicitCastExpr::Create(Context, T, CK_LValueToRValue, E,
-   nullptr, VK_RValue);
-  }
+  ExprResult Res = ImplicitCastExpr::Create(Context, T, CK_LValueToRValue, E,
+nullptr, VK_RValue);
 
   // C11 6.3.2.1p2:
   //   ... if the lvalue has atomic type, the value has the non-atomic version 
@@ -821,16 +817,8 @@ ExprResult Sema::DefaultArgumentPromotio
   // double.
   const BuiltinType *BTy = Ty->getAs();
   if (BTy && (BTy->getKind() == BuiltinType::Half ||
-  BTy->getKind() == BuiltinType::Float)) {
-if (getLangOpts().OpenCL &&
-!(getOpenCLOptions().cl_khr_fp64)) {
-if (BTy->getKind() == BuiltinType::Half) {
-E = ImpCastExprToType(E, Context.FloatTy, CK_FloatingCast).get();
-}
-} else {
-  E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).get();
-}
-  }
+  BTy->getKind() == BuiltinType::Float))
+E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).get();
 
   // C++ performs lvalue-to-rvalue conversion as a default argument
   // promotion, even on class types, but note:
@@ -3409,13 +3397,10 @@ ExprResult Sema::ActOnNumericConstant(co
 
 if (Ty == Context.DoubleTy) {
   if (getLangOpts().SinglePrecisionConstants) {
-const BuiltinType *BTy = Ty->getAs();
-if (BTy->getKind() != BuiltinType::Float) {
-  Res = ImpCastExprToType(Res, Context.FloatTy, CK_FloatingCast).get();
-}
+Res = ImpCastExprToType(Res, Context.FloatTy, CK_FloatingCast).get();
   } else if (getLangOpts().OpenCL &&
- !(getOpenCLOptions().cl_khr_fp64)) {
-// Impose single-precision float type when cl_khr_fp64 is not enabled.
+ !((getLangOpts().OpenCLVersion >= 120) ||
+   getOpenCLOptions().cl_khr_fp64)) {
 Diag(Tok.getLocation(), diag::warn_double_const_requires_fp64);
 Res = ImpCastExprToType(Res, Context.FloatTy, CK_FloatingCast).get();
   }

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=286818&r1=286817&r2=286818&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Mon Nov 14 06:19:18 2016
@@ -1402,7 +1402,8 @@ static QualType ConvertDeclSpecToType(Ty
   Result = Context.DoubleTy;
 
 if (S.getLangOpts().OpenCL &&
-!(S.getOpenCLOptions().cl_khr_fp64)) {
+!((S.getLangOpts().OpenCLVersion >= 120) ||
+  S.getOpenCLOptions().cl_khr_fp64)) {
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_requires_extension)
   << Result << "cl_khr_fp64";
   declarator.setInvalidType(true);

Modified: cfe/trunk/test/CodeGenOpenCL/fpmath.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/fpmath.cl?rev=286818&r1=286817&r2=286818&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/fpmath.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/fpmath.cl Mon Nov 14 06:19:18 2016
@@ -1,6 +1,5 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown | FileCheck 
--check-prefix=CHECK --check-prefix=NODIVOPT %s
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown 
-cl-fp32-correctly-rounded-divide-sqrt | FileCheck --check-prefix=CHECK 
--check-prefix=DIVOPT %s
-// RUN: %clang_cc1 %s -emit-llvm -o - -DNOFP64 -cl-std=CL1.1 -triple 
r600-unknown-unknown -target-cpu r600 -pedantic | FileCheck 
--check-prefix=CHECK-DBL %s
 
 typedef __attribute__(( ext_vector_type(4) )) float float4;
 
@@ -22,26 +21,14 @@ float4 spvectordiv(float4 a, float4 b) {
   return a / b;
 }
 
-void printf(constant char* fmt, ...);
-
-#ifndef NOFP64
 #pragma 

Re: r286815 - Improve handling of floating point literals in OpenCL to only use double precision if the target supports fp64.

2016-11-14 Thread Renato Golin via cfe-commits
On 14 November 2016 at 11:15, Neil Hickey via cfe-commits
 wrote:
> Author: neil.hickey
> Date: Mon Nov 14 05:15:51 2016
> New Revision: 286815
>
> URL: http://llvm.org/viewvc/llvm-project?rev=286815&view=rev
> Log:
> Improve handling of floating point literals in OpenCL to only use double 
> precision if the target supports fp64.

Major breakages on all ARM and AArch64 bots, with unreachable on Sema.cpp:

UNREACHABLE executed at
/home/buildslave/buildslave/clang-cmake-aarch64-quick/llvm/tools/clang/lib/Sema/Sema.cpp:375!

Examples:

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/473

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-39vma/builds/613

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/718

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-42vma/builds/871

etc...

Reverted in r286818.

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


[PATCH] D26522: Improve handling of __FUNCTION__ and other predefined expression for Objective-C Blocks

2016-11-14 Thread Alex Lorenz via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM, Thanks


https://reviews.llvm.org/D26522



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


[PATCH] D26515: [clang-move] Abstract a ClassMather for matching class declarations.

2016-11-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 with a few comments.

(There are two empty comments that can't be deleted due to a phabricator 
bugs...)




Comment at: clang-move/ClangMove.cpp:407
+  auto MovedClass =
+  cxxRecordDecl(
+  InOldFiles, *InMovedClassNames, isDefinition(),

.



Comment at: clang-move/ClangMove.cpp:455
 
 void ClangMoveTool::run(const ast_matchers::MatchFinder::MatchResult &Result) {
   if (const auto *D =

-



Comment at: clang-move/ClangMove.cpp:151
+  bool MatchClassMethod(const MatchFinder::MatchResult &Result) {
+if (const auto *CMD =
+Result.Nodes.getNodeAs("class_method")) {

Not sure why you don't do type check in `run(...)`. The following structure 
looks a bit weird.
```
if (...) {
  ...
  return true;
}
return false;
```



Comment at: clang-move/ClangMove.cpp:414
   hasParent(decl(anyOf(namespaceDecl(), translationUnitDecl();
   Finder->addMatcher(AllDeclsInHeader.bind("decls_in_header"), this);
   // Match forward declarations in old header.

Maybe put all `addMatcher`s that bind `this` before those that bind to 
`ClassDeclarationMatch`.


https://reviews.llvm.org/D26515



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


[PATCH] D26493: [clang-move] Make the output code look more pretty.

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

Add comments and update patch descriptions.


https://reviews.llvm.org/D26493

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

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -127,8 +127,10 @@
 
 const char ExpectedNewHeader[] = "#ifndef NEW_FOO_H\n"
  "#define NEW_FOO_H\n"
+ "\n"
  "namespace a {\n"
  "class C1; // test\n"
+ "\n"
  "template  class C2;\n"
  "namespace b {\n"
  "// This is a Foo class\n"
@@ -144,6 +146,7 @@
  "}; // abc\n"
  "} // namespace b\n"
  "} // namespace a\n"
+ "\n"
  "#endif // NEW_FOO_H\n";
 
 const char ExpectedNewCC[] = "namespace a {\n"
@@ -154,17 +157,21 @@
  "/// comment2.\n"
  "int kConstInt1 = 0;\n"
  "} // namespace\n"
+ "\n"
  "/* comment 3*/\n"
  "static int kConstInt2 = 1;\n"
+ "\n"
  "/** comment4\n"
  "*/\n"
  "static int help() {\n"
  "  int a = 0;\n"
  "  return a;\n"
  "}\n"
+ "\n"
  "// comment5\n"
  "// comment5\n"
  "void Foo::f() { f1(); }\n"
+ "\n"
  "/\n"
  "// comment //\n"
  "/\n"
@@ -312,15 +319,17 @@
 TEST(ClangMove, DontMoveAll) {
   const char ExpectedHeader[] = "#ifndef NEW_FOO_H\n"
 "#define NEW_FOO_H\n"
+"\n"
 "class A {\npublic:\n  int f();\n};\n"
+"\n"
 "#endif // NEW_FOO_H\n";
   const char Code[] = "#include \"foo.h\"\nint A::f() { return 0; }";
   std::vector TestHeaders = {
-"typedef int Int;\nclass A {\npublic:\n  int f();\n};",
-"using Int=int;\nclass A {\npublic:\n  int f();\n};",
-"class B {};\nclass A {\npublic:\n  int f();\n};",
-"void f() {};\nclass A {\npublic:\n  int f();\n};",
-"enum Color { RED };\nclass A {\npublic:\n  int f();\n};",
+"typedef int Int;\nclass A {\npublic:\n  int f();\n};\n",
+"using Int=int;\nclass A {\npublic:\n  int f();\n};\n",
+"class B {};\nclass A {\npublic:\n  int f();\n};\n",
+"void f() {};\nclass A {\npublic:\n  int f();\n};\n",
+"enum Color { RED };\nclass A {\npublic:\n  int f();\n};\n",
   };
   move::ClangMoveTool::MoveDefinitionSpec Spec;
   Spec.Names.push_back("A");
@@ -332,7 +341,7 @@
 auto Results = runClangMoveOnCode(Spec, Header.c_str(), Code);
 EXPECT_EQ(ExpectedHeader, Results[Spec.NewHeader]);
 // The expected old header should not contain class A definition.
-std::string ExpectedOldHeader = Header.substr(0, Header.size() - 31);
+std::string ExpectedOldHeader = Header.substr(0, Header.size() - 32);
 EXPECT_EQ(ExpectedOldHeader, Results[Spec.OldHeader]);
   }
 }
Index: clang-move/ClangMove.cpp
===
--- clang-move/ClangMove.cpp
+++ clang-move/ClangMove.cpp
@@ -237,7 +237,7 @@
 }
 GuardName = StringRef(GuardName).upper();
 NewCode += "#ifndef " + GuardName + "\n";
-NewCode += "#define " + GuardName + "\n";
+NewCode += "#define " + GuardName + "\n\n";
   }
 
   // Add #Includes.
@@ -249,40 +249,58 @@
 
   // Add moved class definition and its related declarations. All declarations
   // in same namespace are grouped together.
+  //
+  // Record namespaces where the current position is in.
   std::vector CurrentNamespaces;
   for (const auto &MovedDecl : Decls) {
+// The namespaces of the declaration being moved.
 std::vector DeclNamespaces = GetNamespaces(MovedDecl.Decl);
 auto CurrentIt = CurrentNamespaces.begin();
 auto DeclIt = DeclNamespaces.begin();
+// Skip the common prefix.
 while (CurrentIt != CurrentNamespaces.end() &&
DeclIt != DeclNamespaces.end()) {
   if (*CurrentIt != *DeclIt)
 break;
   ++CurrentIt;
   ++DeclIt;
 }
+// Calculate the new namespaces after add

[PATCH] D21298: [Clang-tidy] delete null check

2016-11-14 Thread Gergely Angeli via cfe-commits
SilverGeri updated this revision to Diff 77784.
SilverGeri added a comment.
Herald added a subscriber: modocache.

move checker to readability module
add missing description to header file


https://reviews.llvm.org/D21298

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/DeleteNullPointerCheck.cpp
  clang-tidy/readability/DeleteNullPointerCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-delete-null-pointer.rst
  test/clang-tidy/readability-delete-null-pointer.cpp

Index: test/clang-tidy/readability-delete-null-pointer.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-delete-null-pointer.cpp
@@ -0,0 +1,49 @@
+// RUN: %check_clang_tidy %s readability-delete-null-pointer %t
+
+#include 
+
+void f() {
+  int *p = 0;
+  if (p) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'if' statement is unnecessary; deleting null pointer has no effect [readability-delete-null-pointer]
+delete p;
+  }
+  // CHECK-FIXES: delete p;
+  int *p3 = new int[3];
+  if (p3)
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'if' statement is unnecessary; deleting null pointer has no effect [readability-delete-null-pointer]
+delete[] p3;
+  // CHECK-FIXES: delete[] p3;
+
+  if (NULL != p) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'if' statement is unnecessary; deleting null pointer has no effect [readability-delete-null-pointer]
+delete p;
+  }
+  // CHECK-FIXES: delete p;
+
+  if (p != nullptr) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'if' statement is unnecessary; deleting null pointer has no effect [readability-delete-null-pointer]
+delete p;
+  }
+  // CHECK-FIXES: delete p;
+
+  if (p != 0) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'if' statement is unnecessary; deleting null pointer has no effect [readability-delete-null-pointer]
+delete p;
+  }
+  // CHECK-FIXES: delete p;
+}
+
+void g() {
+  int *p, *p2;
+  if (p)
+delete p2;
+
+  if (p && p2)
+delete p;
+
+  if (p2) {
+int x = 5;
+delete p2;
+  }
+}
\ No newline at end of file
Index: docs/clang-tidy/checks/readability-delete-null-pointer.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-delete-null-pointer.rst
@@ -0,0 +1,12 @@
+.. title:: clang-tidy - readability-delete-null-pointer
+
+readability-delete-null-pointer
+===
+
+Checks the 'if' statements where a pointer's existence is checked and then deletes the pointer.
+The check is unnecessary as deleting a nullpointer has no effect.
+
+.. code:: c++
+  int *p;
+  if (p)
+delete p;
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -123,6 +123,7 @@
readability-avoid-const-params-in-decls
readability-braces-around-statements
readability-container-size-empty
+   readability-delete-null-pointer
readability-deleted-default
readability-else-after-return
readability-function-size
Index: clang-tidy/readability/ReadabilityTidyModule.cpp
===
--- clang-tidy/readability/ReadabilityTidyModule.cpp
+++ clang-tidy/readability/ReadabilityTidyModule.cpp
@@ -13,6 +13,7 @@
 #include "AvoidConstParamsInDecls.h"
 #include "BracesAroundStatementsCheck.h"
 #include "ContainerSizeEmptyCheck.h"
+#include "DeleteNullPointerCheck.h"
 #include "DeletedDefaultCheck.h"
 #include "ElseAfterReturnCheck.h"
 #include "FunctionSizeCheck.h"
@@ -44,6 +45,8 @@
 "readability-braces-around-statements");
 CheckFactories.registerCheck(
 "readability-container-size-empty");
+CheckFactories.registerCheck(
+"readability-delete-null-pointer");
 CheckFactories.registerCheck(
 "readability-deleted-default");
 CheckFactories.registerCheck(
Index: clang-tidy/readability/DeleteNullPointerCheck.h
===
--- /dev/null
+++ clang-tidy/readability/DeleteNullPointerCheck.h
@@ -0,0 +1,35 @@
+//===--- DeleteNullPointerCheck.h - clang-tidy---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_DELETE_NULL_POINTER_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_DELETE_NULL_POINTER_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+/// Check whether the 'if' statement is unnecessary before calling 'delete' on a pointer.
+///
+/// For the user-facing documentation see:
+///

[PATCH] D26157: [OpenCL] always use SPIR address spaces for kernel_arg_addr_space MD

2016-11-14 Thread Pekka Jääskeläinen via cfe-commits
pekka.jaaskelainen closed this revision.
pekka.jaaskelainen added a comment.

Committed in r286819.


Repository:
  rL LLVM

https://reviews.llvm.org/D26157



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


[PATCH] D26464: [ARM] Fix sema check of ARM special register names

2016-11-14 Thread Renato Golin via cfe-commits
rengolin added a comment.

Looks like an oversight. Aren't there any tests for this? Maybe there should be 
one.


Repository:
  rL LLVM

https://reviews.llvm.org/D26464



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


r286821 - Fix r286819 (accidentally patched multiple times.

2016-11-14 Thread Pekka Jaaskelainen via cfe-commits
Author: pjaaskel
Date: Mon Nov 14 07:14:38 2016
New Revision: 286821

URL: http://llvm.org/viewvc/llvm-project?rev=286821&view=rev
Log:
Fix r286819 (accidentally patched multiple times.

Modified:
cfe/trunk/test/CodeGenOpenCL/kernel-arg-info-single-as.cl

Modified: cfe/trunk/test/CodeGenOpenCL/kernel-arg-info-single-as.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/kernel-arg-info-single-as.cl?rev=286821&r1=286820&r2=286821&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/kernel-arg-info-single-as.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/kernel-arg-info-single-as.cl Mon Nov 14 
07:14:38 2016
@@ -7,21 +7,3 @@ kernel void foo(__global int * G, __cons
 }
 // CHECK: !kernel_arg_addr_space ![[MD123:[0-9]+]]
 // CHECK: ![[MD123]] = !{i32 1, i32 2, i32 3}
-// Test that the kernel argument info always refers to SPIR address spaces,
-// even if the target has only one address space like x86_64 does.
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -triple 
x86_64-unknown-unknown -cl-kernel-arg-info | FileCheck %s
-
-kernel void foo(__global int * G, __constant int *C, __local int *L) {
-  *G = *C + *L;
-}
-// CHECK: !kernel_arg_addr_space ![[MD123:[0-9]+]]
-// CHECK: ![[MD123]] = !{i32 1, i32 2, i32 3}
-// Test that the kernel argument info always refers to SPIR address spaces,
-// even if the target has only one address space like x86_64 does.
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -triple 
x86_64-unknown-unknown -cl-kernel-arg-info | FileCheck %s
-
-kernel void foo(__global int * G, __constant int *C, __local int *L) {
-  *G = *C + *L;
-}
-// CHECK: !kernel_arg_addr_space ![[MD123:[0-9]+]]
-// CHECK: ![[MD123]] = !{i32 1, i32 2, i32 3}


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


r286819 - [OpenCL] always use SPIR address spaces for kernel_arg_addr_space MD

2016-11-14 Thread Pekka Jaaskelainen via cfe-commits
Author: pjaaskel
Date: Mon Nov 14 07:08:30 2016
New Revision: 286819

URL: http://llvm.org/viewvc/llvm-project?rev=286819&view=rev
Log:
[OpenCL] always use SPIR address spaces for kernel_arg_addr_space MD

It doesn't make sense to use the target's address space ids in this context as
this is metadata that should be referring to the "logical" OpenCL address 
spaces.
For flat AS machines like all "CPUs" in general, the logical AS info gets lost 
as
there's only one address space (0).

This commit changes the logic such that we always use the SPIR address space
ids for the argument metadata. It thus allows implementing the 
clGetKernelArgInfo()
and the other detection needs.

https://reviews.llvm.org/D26157


Added:
cfe/trunk/test/CodeGenOpenCL/kernel-arg-info-single-as.cl
Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=286819&r1=286818&r2=286819&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Mon Nov 14 07:08:30 2016
@@ -466,6 +466,23 @@ static void removeImageAccessQualifier(s
   }
 }
 
+// Returns the address space id that should be produced to the
+// kernel_arg_addr_space metadata. This is always fixed to the ids
+// as specified in the SPIR 2.0 specification in order to differentiate
+// for example in clGetKernelArgInfo() implementation between the address
+// spaces with targets without unique mapping to the OpenCL address spaces
+// (basically all single AS CPUs).
+static unsigned ArgInfoAddressSpace(unsigned LangAS) {
+  switch (LangAS) {
+  case LangAS::opencl_global:   return 1;
+  case LangAS::opencl_constant: return 2;
+  case LangAS::opencl_local:return 3;
+  case LangAS::opencl_generic:  return 4; // Not in SPIR 2.0 specs.
+  default:
+return 0; // Assume private.
+  }
+}
+
 // OpenCL v1.2 s5.6.4.6 allows the compiler to store kernel argument
 // information in the program executable. The argument information stored
 // includes the argument name, its type, the address and access qualifiers 
used.
@@ -506,7 +523,7 @@ static void GenOpenCLArgMetadata(const F
 
   // Get address qualifier.
   addressQuals.push_back(llvm::ConstantAsMetadata::get(Builder.getInt32(
-  ASTCtx.getTargetAddressSpace(pointeeTy.getAddressSpace();
+ArgInfoAddressSpace(pointeeTy.getAddressSpace();
 
   // Get argument type name.
   std::string typeName =
@@ -543,8 +560,7 @@ static void GenOpenCLArgMetadata(const F
   uint32_t AddrSpc = 0;
   bool isPipe = ty->isPipeType();
   if (ty->isImageType() || isPipe)
-AddrSpc =
-  CGM.getContext().getTargetAddressSpace(LangAS::opencl_global);
+AddrSpc = ArgInfoAddressSpace(LangAS::opencl_global);
 
   addressQuals.push_back(
   llvm::ConstantAsMetadata::get(Builder.getInt32(AddrSpc)));

Added: cfe/trunk/test/CodeGenOpenCL/kernel-arg-info-single-as.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/kernel-arg-info-single-as.cl?rev=286819&view=auto
==
--- cfe/trunk/test/CodeGenOpenCL/kernel-arg-info-single-as.cl (added)
+++ cfe/trunk/test/CodeGenOpenCL/kernel-arg-info-single-as.cl Mon Nov 14 
07:08:30 2016
@@ -0,0 +1,27 @@
+// Test that the kernel argument info always refers to SPIR address spaces,
+// even if the target has only one address space like x86_64 does.
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -triple 
x86_64-unknown-unknown -cl-kernel-arg-info | FileCheck %s
+
+kernel void foo(__global int * G, __constant int *C, __local int *L) {
+  *G = *C + *L;
+}
+// CHECK: !kernel_arg_addr_space ![[MD123:[0-9]+]]
+// CHECK: ![[MD123]] = !{i32 1, i32 2, i32 3}
+// Test that the kernel argument info always refers to SPIR address spaces,
+// even if the target has only one address space like x86_64 does.
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -triple 
x86_64-unknown-unknown -cl-kernel-arg-info | FileCheck %s
+
+kernel void foo(__global int * G, __constant int *C, __local int *L) {
+  *G = *C + *L;
+}
+// CHECK: !kernel_arg_addr_space ![[MD123:[0-9]+]]
+// CHECK: ![[MD123]] = !{i32 1, i32 2, i32 3}
+// Test that the kernel argument info always refers to SPIR address spaces,
+// even if the target has only one address space like x86_64 does.
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -triple 
x86_64-unknown-unknown -cl-kernel-arg-info | FileCheck %s
+
+kernel void foo(__global int * G, __constant int *C, __local int *L) {
+  *G = *C + *L;
+}
+// CHECK: !kernel_arg_addr_space ![[MD123:[0-9]+]]
+// CHECK: ![[MD123]] = !{i32 1, i32 2, i32 3}


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

  1   2   >