r286796 - Add explicit (void) cast to result of unique_ptr::release()

2016-11-13 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Nov 14 01:03:50 2016
New Revision: 286796

URL: http://llvm.org/viewvc/llvm-project?rev=286796=rev
Log:
Add explicit (void) cast to result of unique_ptr::release()

Modified:
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=286796=286795=286796=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Mon Nov 14 01:03:50 2016
@@ -7761,7 +7761,7 @@ CXTUResourceUsage clang_getCXTUResourceU
   CXTUResourceUsage usage = { (void*) entries.get(),
 (unsigned) entries->size(),
 !entries->empty() ? &(*entries)[0] : nullptr };
-  entries.release();
+  (void)entries.release();
   return usage;
 }
 


___
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-13 Thread Eric Fiselier via cfe-commits
EricWF updated this revision to Diff 77769.
EricWF added a comment.

- Add `[[no_discard]]` to various smart pointer observers including `get()` and 
`operator*()`.


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
 {
-lk.try_lock();
+(void)lk.try_lock();
 assert(false);
 }
 catch (std::system_error& e)
@@ -59,7 +59,7 @@
 #ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
-lk.try_lock();
+(void)lk.try_lock();
 assert(false);
 }
 catch (std::system_error& e)
Index: 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.shared/thread.lock.shared.locking/try_lock_until.pass.cpp
+++ test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp
@@ -49,7 +49,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)
@@ -65,7 +65,7 @@
 #ifndef TEST_HAS_NO_EXCEPTIONS
 try
  

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

2016-11-13 Thread Faisal Vali via cfe-commits
faisalv removed rL LLVM as the repository for this revision.
faisalv updated this revision to Diff 77767.
faisalv marked 4 inline comments as done.
faisalv added a comment.

Addressed Aaron's requests regarding improving formatting and assert messages.

Thanks!


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 = 
 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((std::distance(ClosureClass->captures_begin(),
+  ClosureClass->captures_end()) == 0) &&
+   "Number of captures shall be zero if we are able to convert to "
+   "pointer to function");
+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);
 

[libcxxabi] r286793 - __cxa_demangle: allow demangling invocation blocks

2016-11-13 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Sun Nov 13 21:07:47 2016
New Revision: 286793

URL: http://llvm.org/viewvc/llvm-project?rev=286793=rev
Log:
__cxa_demangle: allow demangling invocation blocks

The block invocation function uses an extension where the prefix is ___Z
as opposed to _Z.  This should make the tests pass again.

Disable a negative test which was testing a crasher.  The symbol being
demangled is not a valid mangled symbol and will return a nullptr.

Adjust the type info decoding test to be a valid symbol name.

Modified:
libcxxabi/trunk/src/cxa_demangle.cpp
libcxxabi/trunk/test/test_demangle.pass.cpp

Modified: libcxxabi/trunk/src/cxa_demangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=286793=286792=286793=diff
==
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Sun Nov 13 21:07:47 2016
@@ -4980,11 +4980,14 @@ __cxa_demangle(const char *mangled_name,
 }
 
 size_t len = std::strlen(mangled_name);
-if (len < 2 || mangled_name[0] != '_' || mangled_name[1] != 'Z')
+if (len < 2 || strncmp(mangled_name, "_Z", 2))
 {
-if (status)
-*status = invalid_mangled_name;
-return nullptr;
+if (len < 4 || strncmp(mangled_name, "___Z", 4))
+{
+if (status)
+*status = invalid_mangled_name;
+return nullptr;
+}
 }
 
 size_t internal_size = buf != nullptr ? *n : 0;

Modified: libcxxabi/trunk/test/test_demangle.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_demangle.pass.cpp?rev=286793=286792=286793=diff
==
--- libcxxabi/trunk/test/test_demangle.pass.cpp (original)
+++ libcxxabi/trunk/test/test_demangle.pass.cpp Sun Nov 13 21:07:47 2016
@@ -29478,7 +29478,6 @@ const char* cases[][2] =
 
{"_Z1f1XS13_S12_S11_S10_SZ_SY_SX_SW_SV_SU_ST_SS_SR_SQ_SP_SO_SN_SM_SL_SK_SJ_SI_SH_SG_SF_SE_SD_SC_SB_SA_S9_S8_S7_S6_S5_S4_S3_S2_S1_S0_S_",
 "f(X, 
X, 
X***, 
X**, 
X*, X, 
X***, X**, 
X*, X, 
X***, X**, 
X*, X, 
X***, X**, 
X*, X, 
X***, X**, X*, 
X, X***, X**, 
X*, X*
 ***, X***, X**, X*, X, 
X***, X**, X*, X, X***, X**, X*, 
X, X***, X**, X*, X)"},
 {"_ZZN1J1KEvENK1C1FEv", "J::K()::C::F() const"},
 {"_ZZNVK1J1KEvENK1C1FEv", "J::K() const volatile::C::F() const"},
-{"U4_farrVKPi", "int* const volatile restrict _far"},
 {"_Z1fM1AKFvvE", "f(void (A::*)() const)"},
 {"_ZNR1X1fEv", "X::f() &"},
 {"_ZNKO1X1hEv", "X::h() const &&"},
@@ -29591,7 +29590,10 @@ const char* cases[][2] =
 {"_ZZ4testvEN1g3fooE5Point", "test()::g::foo(Point)"},
 {"_ZThn12_NSt9strstreamD0Ev",   "non-virtual thunk to 
std::strstream::~strstream()"},
 {"_ZTv0_n12_NSt9strstreamD0Ev", "virtual thunk to 
std::strstream::~strstream()"},
-{"\x6D", "unsigned long"}, // This use to crash with ASAN
+
+// NOTE: disable this test since it is a negative test case, you cannot 
demangle a non-mangled symbol
+// {"\x6D", nullptr},  // This use to crash with ASAN
+{"_ZTIU4_farrVKPi", "typeinfo for int* const volatile restrict _far"},
 };
 
 const unsigned N = sizeof(cases) / sizeof(cases[0]);


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


[libcxx] r286792 - Fix ABI configuration detection on OS X

2016-11-13 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Nov 13 21:03:13 2016
New Revision: 286792

URL: http://llvm.org/viewvc/llvm-project?rev=286792=rev
Log:
Fix ABI configuration detection on OS X

Modified:
libcxx/trunk/lib/abi/CMakeLists.txt

Modified: libcxx/trunk/lib/abi/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/abi/CMakeLists.txt?rev=286792=286791=286792=diff
==
--- libcxx/trunk/lib/abi/CMakeLists.txt (original)
+++ libcxx/trunk/lib/abi/CMakeLists.txt Sun Nov 13 21:03:13 2016
@@ -4,13 +4,15 @@
 if (DEFINED TARGET_TRIPLE
 AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/${TARGET_TRIPLE}.abilist"
 AND TARGET cxx_shared
-AND "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi"
+AND ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi" OR
+ (APPLE AND "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "none"))
 AND NOT LIBCXX_ABI_UNSTABLE
 AND LIBCXX_ABI_VERSION EQUAL "1")
 set(LIBCXX_HAS_ABILIST_CONFIGURATION 1 CACHE INTERNAL "")
 else()
 if (NOT DEFINED LIBCXX_HAS_ABILIST_CONFIGURATION)
-message(STATUS "libc++ configuration differs from the abilist 
configuration. check-cxx-abilist target is not supported")
+message(STATUS "libc++ configuration differs from the abilist 
configuration. "
+"check-cxx-abilist target is not supported")
 endif()
 set(LIBCXX_HAS_ABILIST_CONFIGURATION 0 CACHE INTERNAL "")
 endif()


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


[libcxx] r286791 - Fix CMake set syntax

2016-11-13 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Nov 13 20:51:30 2016
New Revision: 286791

URL: http://llvm.org/viewvc/llvm-project?rev=286791=rev
Log:
Fix CMake set syntax

Modified:
libcxx/trunk/lib/abi/CMakeLists.txt

Modified: libcxx/trunk/lib/abi/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/abi/CMakeLists.txt?rev=286791=286790=286791=diff
==
--- libcxx/trunk/lib/abi/CMakeLists.txt (original)
+++ libcxx/trunk/lib/abi/CMakeLists.txt Sun Nov 13 20:51:30 2016
@@ -7,12 +7,12 @@ if (DEFINED TARGET_TRIPLE
 AND "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi"
 AND NOT LIBCXX_ABI_UNSTABLE
 AND LIBCXX_ABI_VERSION EQUAL "1")
-set(LIBCXX_HAS_ABILIST_CONFIGURATION 1 CACHE "")
+set(LIBCXX_HAS_ABILIST_CONFIGURATION 1 CACHE INTERNAL "")
 else()
 if (NOT DEFINED LIBCXX_HAS_ABILIST_CONFIGURATION)
 message(STATUS "libc++ configuration differs from the abilist 
configuration. check-cxx-abilist target is not supported")
 endif()
-set(LIBCXX_HAS_ABILIST_CONFIGURATION 0 CACHE "")
+set(LIBCXX_HAS_ABILIST_CONFIGURATION 0 CACHE INTERNAL "")
 endif()
 
 


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


[PATCH] D26544: [PPC] support for arithmetic builtins in the FE

2016-11-13 Thread Nemanja Ivanovic via cfe-commits
nemanjai added inline comments.



Comment at: lib/Headers/altivec.h:314
+  vector signed int __carry = __c & __mask;
+  return vec_add(vec_add(__a, __b), __mask);
+}

I don't understand why we're adding `__mask` to the sum of `__a` and `__b`. 
Shouldn't that be `__carry`?



Comment at: lib/Headers/altivec.h:322
+  vector unsigned int __carry = __c & __mask;
+  return vec_add(vec_add(__a, __b), __mask);
+}

Same comment as above.



Comment at: lib/Headers/altivec.h:349
+unsigned int __tempc = (unsigned int) __c[i];
+__tempc = __tempc & 0x0001;
+unsigned long long __longa = (unsigned long long) __tempa;

Is it not a little cleaner and more readable to just mask out the `__c` 
parameter before the loop (similarly to the masking you've done with `__mask` 
above)?



Comment at: lib/Headers/altivec.h:350
+__tempc = __tempc & 0x0001;
+unsigned long long __longa = (unsigned long long) __tempa;
+unsigned long long __longb = (unsigned long long) __tempb;

I think it's a little more clear and obvious what is happening if you actually 
have just a single cast and mask - i.e.
``` unsigned long long __longa = ((unsigned long long) __a[i]) & 0x;```


https://reviews.llvm.org/D26544



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


[libcxxabi] r286788 - __cxa_demangle: ensure that we have a mangled symbol

2016-11-13 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Sun Nov 13 19:55:54 2016
New Revision: 286788

URL: http://llvm.org/viewvc/llvm-project?rev=286788=rev
Log:
__cxa_demangle: ensure that we have a mangled symbol

Ensure that we have a mangled symbol before attempting to demangle it.  We would
previously treat any input as a mangled symbol rather than checking that the
symbol has the initial C++ Itanium v3 mangling prefix of `_Z`.  This changes the
behaviour from the previous case which would undecorate `f` to `float` rather
than nullptr as it should.

Unfortunately, we do not have any negative testing for the demangler.

Modified:
libcxxabi/trunk/src/cxa_demangle.cpp

Modified: libcxxabi/trunk/src/cxa_demangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=286788=286787=286788=diff
==
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Sun Nov 13 19:55:54 2016
@@ -4978,6 +4978,15 @@ __cxa_demangle(const char *mangled_name,
 *status = invalid_args;
 return nullptr;
 }
+
+size_t len = std::strlen(mangled_name);
+if (len < 2 || mangled_name[0] != '_' || mangled_name[1] != 'Z')
+{
+if (status)
+*status = invalid_mangled_name;
+return nullptr;
+}
+
 size_t internal_size = buf != nullptr ? *n : 0;
 arena a;
 Db db(a);
@@ -4990,7 +4999,6 @@ __cxa_demangle(const char *mangled_name,
 db.fix_forward_references = false;
 db.try_to_parse_template_args = true;
 int internal_status = success;
-size_t len = std::strlen(mangled_name);
 demangle(mangled_name, mangled_name + len, db,
  internal_status);
 if (internal_status == success && db.fix_forward_references &&


___
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-13 Thread Nemanja Ivanovic via cfe-commits
nemanjai 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

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.


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] D26596: [RFC] Add _LIBCPP_NO_DISCARD and apply it to `Container::empty()`, `unique_ptr::release()`, and `Lockable::try_lock()`

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

- Fix tests containing discarded values.
- Fix two more instances of discarded `unique_ptr::release()` in the headers.


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/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.fail.cpp
  
test/libcxx/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/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
 {
-lk.try_lock();
+(void)lk.try_lock();
 assert(false);
 }
 catch (std::system_error& e)
@@ -59,7 +59,7 @@
 #ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
-lk.try_lock();
+(void)lk.try_lock();
 assert(false);
 }
 catch (std::system_error& e)
Index: 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.shared/thread.lock.shared.locking/try_lock_until.pass.cpp
+++ test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp
@@ -49,7 +49,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)
@@ -65,7 +65,7 @@
 #ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
-lk.try_lock_until(Clock::now());
+

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

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

- Fix even more instances of `unique_ptr::release()` with a discarded value. 
Hopefully this is the last of them.


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/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/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.fail.cpp
  
test/libcxx/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.fail.cpp

Index: test/libcxx/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.fail.cpp
===
--- /dev/null
+++ test/libcxx/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.fail.cpp
@@ -0,0 +1,25 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// unique_ptr
+
+// test release
+
+#include 
+#include 
+
+int main()
+{
+std::unique_ptr p(new int(3));
+int* i = p.get();
+p.release(); // expected-warning {{ignoring return value of function declared with 'warn_unused_result' attribute}}
+delete i;
+}
Index: test/libcxx/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.fail.cpp
===
--- /dev/null
+++ test/libcxx/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.fail.cpp
@@ -0,0 +1,25 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// unique_ptr
+
+// test release
+
+#include 
+#include 
+
+int main()
+{
+std::unique_ptr p(new int[3]);
+int* i = p.get();
+p.release(); // expected-warning {{ignoring return value of function declared with 'warn_unused_result' attribute}}
+delete [] i;
+}
Index: test/libcxx/thread/thread.mutex/try_lock_no_discard_disabled.fail.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/try_lock_no_discard_disabled.fail.cpp
@@ -0,0 +1,105 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: libcpp-has-no-threads
+// REQUIRES: verify-diagnostics
+
+// test the generated [[no_discard]] warnings
+
+#define _LIBCPP_DISABLE_NO_DISCARD_TRY_LOCK
+#include 
+#include 
+
+#include "test_macros.h"
+
+int main() {
+  // expected-no-diagnostics
+  {
+std::mutex m;
+m.try_lock();
+m.unlock();
+  }
+  {
+std::recursive_mutex m;
+m.try_lock();
+m.unlock();
+  }
+  {
+std::timed_mutex m;
+m.try_lock();
+m.unlock();
+m.try_lock_for(std::chrono::seconds(1));
+m.unlock();
+m.try_lock_until(std::chrono::steady_clock::now() + std::chrono::seconds(1));
+m.unlock();
+  }
+  {
+std::recursive_timed_mutex m;
+m.try_lock();
+m.unlock();
+m.try_lock_for(std::chrono::seconds(1));
+m.unlock();
+m.try_lock_until(std::chrono::steady_clock::now() + std::chrono::seconds(1));
+m.unlock();
+  }
+  {
+std::mutex m;
+std::unique_lock lk(m);
+lk.unlock();
+lk.try_lock();
+  }
+  {
+std::timed_mutex m;
+std::unique_lock lk(m);
+lk.unlock();
+lk.try_lock();
+lk.unlock();
+lk.try_lock_for(std::chrono::seconds(1));
+lk.unlock();
+lk.try_lock_until(std::chrono::steady_clock::now() + std::chrono::seconds(1));
+lk.unlock();
+  }
+#if TEST_STD_VER > 11
+  {
+std::shared_timed_mutex m;
+

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

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

- Apply no-discard to `string_view::empty()` and friends.
- Fix discarded use of `unique_ptr::release()` within libc++.


https://reviews.llvm.org/D26596

Files:
  docs/UsingLibcxx.rst
  include/__config
  include/__hash_table
  include/__mutex_base
  include/deque
  include/forward_list
  include/list
  include/locale
  include/map
  include/memory
  include/mutex
  include/set
  include/shared_mutex
  include/string
  include/string_view
  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/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.fail.cpp
  
test/libcxx/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.fail.cpp

Index: test/libcxx/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.fail.cpp
===
--- /dev/null
+++ test/libcxx/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.fail.cpp
@@ -0,0 +1,25 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// unique_ptr
+
+// test release
+
+#include 
+#include 
+
+int main()
+{
+std::unique_ptr p(new int(3));
+int* i = p.get();
+p.release(); // expected-warning {{ignoring return value of function declared with 'warn_unused_result' attribute}}
+delete i;
+}
Index: test/libcxx/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.fail.cpp
===
--- /dev/null
+++ test/libcxx/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.fail.cpp
@@ -0,0 +1,25 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// unique_ptr
+
+// test release
+
+#include 
+#include 
+
+int main()
+{
+std::unique_ptr p(new int[3]);
+int* i = p.get();
+p.release(); // expected-warning {{ignoring return value of function declared with 'warn_unused_result' attribute}}
+delete [] i;
+}
Index: test/libcxx/thread/thread.mutex/try_lock_no_discard_disabled.fail.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/try_lock_no_discard_disabled.fail.cpp
@@ -0,0 +1,105 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: libcpp-has-no-threads
+// REQUIRES: verify-diagnostics
+
+// test the generated [[no_discard]] warnings
+
+#define _LIBCPP_DISABLE_NO_DISCARD_TRY_LOCK
+#include 
+#include 
+
+#include "test_macros.h"
+
+int main() {
+  // expected-no-diagnostics
+  {
+std::mutex m;
+m.try_lock();
+m.unlock();
+  }
+  {
+std::recursive_mutex m;
+m.try_lock();
+m.unlock();
+  }
+  {
+std::timed_mutex m;
+m.try_lock();
+m.unlock();
+m.try_lock_for(std::chrono::seconds(1));
+m.unlock();
+m.try_lock_until(std::chrono::steady_clock::now() + std::chrono::seconds(1));
+m.unlock();
+  }
+  {
+std::recursive_timed_mutex m;
+m.try_lock();
+m.unlock();
+m.try_lock_for(std::chrono::seconds(1));
+m.unlock();
+m.try_lock_until(std::chrono::steady_clock::now() + std::chrono::seconds(1));
+m.unlock();
+  }
+  {
+std::mutex m;
+std::unique_lock lk(m);
+lk.unlock();
+lk.try_lock();
+  }
+  {
+std::timed_mutex m;
+std::unique_lock lk(m);
+lk.unlock();
+lk.try_lock();
+lk.unlock();
+lk.try_lock_for(std::chrono::seconds(1));
+lk.unlock();
+lk.try_lock_until(std::chrono::steady_clock::now() + std::chrono::seconds(1));
+lk.unlock();
+  }
+#if TEST_STD_VER > 11
+  {
+std::shared_timed_mutex m;
+m.try_lock();
+m.unlock();
+

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

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

- Add missing newlines in added tests.


https://reviews.llvm.org/D26596

Files:
  docs/UsingLibcxx.rst
  include/__config
  include/__mutex_base
  include/forward_list
  include/list
  include/map
  include/memory
  include/mutex
  include/set
  include/shared_mutex
  include/string
  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/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.fail.cpp
  
test/libcxx/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.fail.cpp

Index: test/libcxx/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.fail.cpp
===
--- /dev/null
+++ test/libcxx/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.fail.cpp
@@ -0,0 +1,25 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// unique_ptr
+
+// test release
+
+#include 
+#include 
+
+int main()
+{
+std::unique_ptr p(new int(3));
+int* i = p.get();
+p.release(); // expected-warning {{ignoring return value of function declared with 'warn_unused_result' attribute}}
+delete i;
+}
Index: test/libcxx/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.fail.cpp
===
--- /dev/null
+++ test/libcxx/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.fail.cpp
@@ -0,0 +1,25 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// unique_ptr
+
+// test release
+
+#include 
+#include 
+
+int main()
+{
+std::unique_ptr p(new int[3]);
+int* i = p.get();
+p.release(); // expected-warning {{ignoring return value of function declared with 'warn_unused_result' attribute}}
+delete [] i;
+}
Index: test/libcxx/thread/thread.mutex/try_lock_no_discard_disabled.fail.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/try_lock_no_discard_disabled.fail.cpp
@@ -0,0 +1,105 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: libcpp-has-no-threads
+// REQUIRES: verify-diagnostics
+
+// test the generated [[no_discard]] warnings
+
+#define _LIBCPP_DISABLE_NO_DISCARD_TRY_LOCK
+#include 
+#include 
+
+#include "test_macros.h"
+
+int main() {
+  // expected-no-diagnostics
+  {
+std::mutex m;
+m.try_lock();
+m.unlock();
+  }
+  {
+std::recursive_mutex m;
+m.try_lock();
+m.unlock();
+  }
+  {
+std::timed_mutex m;
+m.try_lock();
+m.unlock();
+m.try_lock_for(std::chrono::seconds(1));
+m.unlock();
+m.try_lock_until(std::chrono::steady_clock::now() + std::chrono::seconds(1));
+m.unlock();
+  }
+  {
+std::recursive_timed_mutex m;
+m.try_lock();
+m.unlock();
+m.try_lock_for(std::chrono::seconds(1));
+m.unlock();
+m.try_lock_until(std::chrono::steady_clock::now() + std::chrono::seconds(1));
+m.unlock();
+  }
+  {
+std::mutex m;
+std::unique_lock lk(m);
+lk.unlock();
+lk.try_lock();
+  }
+  {
+std::timed_mutex m;
+std::unique_lock lk(m);
+lk.unlock();
+lk.try_lock();
+lk.unlock();
+lk.try_lock_for(std::chrono::seconds(1));
+lk.unlock();
+lk.try_lock_until(std::chrono::steady_clock::now() + std::chrono::seconds(1));
+lk.unlock();
+  }
+#if TEST_STD_VER > 11
+  {
+std::shared_timed_mutex m;
+m.try_lock();
+m.unlock();
+m.try_lock_for(std::chrono::seconds(1));
+m.unlock();
+m.try_lock_until(std::chrono::steady_clock::now() + std::chrono::seconds(1));
+m.unlock();
+

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

2016-11-13 Thread Eric Fiselier via cfe-commits
EricWF retitled this revision from "[RFC] Add _LIBCPP_NO_DISCARD and apply it 
to unique_ptr::release()" to "[RFC] Add _LIBCPP_NO_DISCARD and apply it to 
`Container::empty()`, `unique_ptr::release()`,  and `Lockable::try_lock()` ".
EricWF updated the summary for this revision.
EricWF updated this revision to Diff 77760.
EricWF added a comment.

- Allow groups of no-discard checks to be enabled/disabled using group specific 
macros. (As requested by @chandlerc)
- Add documentation for `_LIBCPP_NO_DISCARD` and friends.
- Apply no-discard checks in more places to show new feature macro example.

@chandlerc Would this approach be sufficient?


https://reviews.llvm.org/D26596

Files:
  docs/UsingLibcxx.rst
  include/__config
  include/__mutex_base
  include/forward_list
  include/list
  include/map
  include/memory
  include/mutex
  include/set
  include/shared_mutex
  include/string
  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/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.fail.cpp
  
test/libcxx/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.fail.cpp

Index: test/libcxx/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.fail.cpp
===
--- /dev/null
+++ test/libcxx/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.fail.cpp
@@ -0,0 +1,25 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// unique_ptr
+
+// test release
+
+#include 
+#include 
+
+int main()
+{
+std::unique_ptr p(new int(3));
+int* i = p.get();
+p.release(); // expected-warning {{ignoring return value of function declared with 'warn_unused_result' attribute}}
+delete i;
+}
Index: test/libcxx/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.fail.cpp
===
--- /dev/null
+++ test/libcxx/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.fail.cpp
@@ -0,0 +1,25 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// unique_ptr
+
+// test release
+
+#include 
+#include 
+
+int main()
+{
+std::unique_ptr p(new int[3]);
+int* i = p.get();
+p.release(); // expected-warning {{ignoring return value of function declared with 'warn_unused_result' attribute}}
+delete [] i;
+}
Index: test/libcxx/thread/thread.mutex/try_lock_no_discard_disabled.fail.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/try_lock_no_discard_disabled.fail.cpp
@@ -0,0 +1,105 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: libcpp-has-no-threads
+// REQUIRES: verify-diagnostics
+
+// test the generated [[no_discard]] warnings
+
+#define _LIBCPP_DISABLE_NO_DISCARD_TRY_LOCK
+#include 
+#include 
+
+#include "test_macros.h"
+
+int main() {
+  // expected-no-diagnostics
+  {
+std::mutex m;
+m.try_lock();
+m.unlock();
+  }
+  {
+std::recursive_mutex m;
+m.try_lock();
+m.unlock();
+  }
+  {
+std::timed_mutex m;
+m.try_lock();
+m.unlock();
+m.try_lock_for(std::chrono::seconds(1));
+m.unlock();
+m.try_lock_until(std::chrono::steady_clock::now() + std::chrono::seconds(1));
+m.unlock();
+  }
+  {
+std::recursive_timed_mutex m;
+m.try_lock();
+m.unlock();
+m.try_lock_for(std::chrono::seconds(1));
+m.unlock();
+m.try_lock_until(std::chrono::steady_clock::now() + std::chrono::seconds(1));
+m.unlock();
+  }
+  {
+std::mutex m;
+std::unique_lock lk(m);
+lk.unlock();
+lk.try_lock();
+  }
+  {
+std::timed_mutex m;

[PATCH] D26596: [RFC] Add _LIBCPP_NO_DISCARD and apply it to unique_ptr::release()

2016-11-13 Thread Marshall Clow via cfe-commits
mclow.lists added a comment.

Note: I'm not unsympathetic to the situation that Chandler describes; I just 
don't want to manage a potentially unbounded (but probably more than 20) set of 
macros.


https://reviews.llvm.org/D26596



___
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 unique_ptr::release()

2016-11-13 Thread Marshall Clow via cfe-commits
mclow.lists added a comment.

In https://reviews.llvm.org/D26596#593948, @chandlerc wrote:

> I think we want dedicated macros to disable each added [[nodiscard]].


My concern here is that I expect that there will be a lot of these.
Off the top of my head, I can name:

- Every smart pointer's `get()` and `release()`
- Every container's `empty()`
- A bunch of algorithms (`find()`, `find_if()`, `search()`, and 
`lower/upper_bound()` leap to mind, but that's not an exhaustive list)


https://reviews.llvm.org/D26596



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


[PATCH] D23418: [analyzer] Added a reusable constraint system to the CloneDetector

2016-11-13 Thread Raphael Isemann via cfe-commits
teemperor updated the summary for this revision.
teemperor updated this revision to Diff 77759.
teemperor added a comment.

- Rebased patch to the current trunk state.
- Replaced runtime polymorphism with templates.
- Constraint interface now only has one method signature.


https://reviews.llvm.org/D23418

Files:
  include/clang/Analysis/CloneDetection.h
  lib/Analysis/CloneDetection.cpp
  lib/StaticAnalyzer/Checkers/CloneChecker.cpp

Index: lib/StaticAnalyzer/Checkers/CloneChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/CloneChecker.cpp
+++ lib/StaticAnalyzer/Checkers/CloneChecker.cpp
@@ -40,12 +40,13 @@
 
   /// \brief Reports all clones to the user.
   void reportClones(BugReporter , AnalysisManager ,
-int MinComplexity) const;
+std::vector ) const;
 
   /// \brief Reports only suspicious clones to the user along with informaton
   ///that explain why they are suspicious.
-  void reportSuspiciousClones(BugReporter , AnalysisManager ,
-  int MinComplexity) const;
+  void reportSuspiciousClones(
+  BugReporter , AnalysisManager ,
+  std::vector ) const;
 };
 } // end anonymous namespace
 
@@ -72,11 +73,29 @@
   bool ReportNormalClones = Mgr.getAnalyzerOptions().getBooleanOption(
   "ReportNormalClones", true, this);
 
+  // Let the CloneDetector create a list of clones from all the analyzed
+  // statements. We don't filter for matching variable patterns at this point
+  // because reportSuspiciousClones() wants to search them for errors.
+  std::vector AllCloneGroups;
+
+  Detector.findClones(AllCloneGroups, RecursiveCloneTypeIIConstraint(),
+  MinComplexityConstraint(MinComplexity),
+  MinGroupSizeConstraint(2), OnlyLargestCloneConstraint());
+
   if (ReportSuspiciousClones)
-reportSuspiciousClones(BR, Mgr, MinComplexity);
+reportSuspiciousClones(BR, Mgr, AllCloneGroups);
+
+  // We are done for this translation unit unless we also need to report normal
+  // clones.
+  if (!ReportNormalClones)
+return;
 
-  if (ReportNormalClones)
-reportClones(BR, Mgr, MinComplexity);
+  // Now that the suspicious clone detector has checked for pattern errors,
+  // we also filter all clones who don't have matching patterns
+  Detector.constrainClones(AllCloneGroups, MatchingVariablePatternConstraint(),
+   MinGroupSizeConstraint(2));
+
+  reportClones(BR, Mgr, AllCloneGroups);
 }
 
 static PathDiagnosticLocation makeLocation(const StmtSequence ,
@@ -87,37 +106,55 @@
   Mgr.getAnalysisDeclContext(ACtx.getTranslationUnitDecl()));
 }
 
-void CloneChecker::reportClones(BugReporter , AnalysisManager ,
-int MinComplexity) const {
-
-  std::vector CloneGroups;
-  Detector.findClones(CloneGroups, MinComplexity);
+void CloneChecker::reportClones(
+BugReporter , AnalysisManager ,
+std::vector ) const {
 
   if (!BT_Exact)
 BT_Exact.reset(new BugType(this, "Exact code clone", "Code clone"));
 
-  for (CloneDetector::CloneGroup  : CloneGroups) {
+  for (const CloneDetector::CloneGroup  : CloneGroups) {
 // We group the clones by printing the first as a warning and all others
 // as a note.
-auto R = llvm::make_unique(
-*BT_Exact, "Duplicate code detected",
-makeLocation(Group.Sequences.front(), Mgr));
-R->addRange(Group.Sequences.front().getSourceRange());
-
-for (unsigned i = 1; i < Group.Sequences.size(); ++i)
-  R->addNote("Similar code here",
-  makeLocation(Group.Sequences[i], Mgr),
-  Group.Sequences[i].getSourceRange());
+auto R = llvm::make_unique(*BT_Exact, "Duplicate code detected",
+  makeLocation(Group.front(), Mgr));
+R->addRange(Group.front().getSourceRange());
+
+for (unsigned i = 1; i < Group.size(); ++i)
+  R->addNote("Similar code here", makeLocation(Group[i], Mgr),
+ Group[i].getSourceRange());
 BR.emitReport(std::move(R));
   }
 }
 
-void CloneChecker::reportSuspiciousClones(BugReporter ,
-  AnalysisManager ,
-  int MinComplexity) const {
-
-  std::vector Clones;
-  Detector.findSuspiciousClones(Clones, MinComplexity);
+void CloneChecker::reportSuspiciousClones(
+BugReporter , AnalysisManager ,
+std::vector ) const {
+  std::vector Pairs;
+
+  for (const CloneDetector::CloneGroup  : CloneGroups) {
+for (unsigned i = 0; i < Group.size(); ++i) {
+  VariablePattern PatternA(Group[i]);
+
+  for (unsigned j = i + 1; j < Group.size(); ++j) {
+VariablePattern PatternB(Group[j]);
+
+VariablePattern::SuspiciousClonePair ClonePair;
+// For now, we only report clones which break the variable pattern just
+// once because multiple differences in a pattern are an 

[PATCH] D23418: [analyzer] Added a reusable constraint system to the CloneDetector

2016-11-13 Thread Raphael Isemann via cfe-commits
teemperor planned changes to this revision.
teemperor added a comment.

- I ran all real-world tests (sqlite, etc.) before rebasing to trunk. I'm not 
100% confident that I correctly merged everything, so I'll rerun them just in 
case. The normal clang test-suite passes, so it looks good.


https://reviews.llvm.org/D23418



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


Re: [PATCH] Warning for main returning a bool.

2016-11-13 Thread Joshua Hurwitz via cfe-commits
Friendly ping. Any further thoughts on this suggested warning?

On Sat, Nov 5, 2016 at 1:48 PM Manuel Klimek  wrote:

> +richard
>
> On Fri, Oct 14, 2016 at 10:18 AM Joshua Hurwitz via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> See attached.
>
> Returning a bool from main is a special case of return type mismatch. The
> common convention when returning a bool is that 'true' (== 1) indicates
> success and 'false' (== 0) failure. But since main expects a return value
> of 0 on success, returning a bool is usually unintended.
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r286784 - Add docs for use-configurable libc++ features

2016-11-13 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Nov 13 17:00:30 2016
New Revision: 286784

URL: http://llvm.org/viewvc/llvm-project?rev=286784=rev
Log:
Add docs for use-configurable libc++ features

Modified:
libcxx/trunk/docs/UsingLibcxx.rst

Modified: libcxx/trunk/docs/UsingLibcxx.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/UsingLibcxx.rst?rev=286784=286783=286784=diff
==
--- libcxx/trunk/docs/UsingLibcxx.rst (original)
+++ libcxx/trunk/docs/UsingLibcxx.rst Sun Nov 13 17:00:30 2016
@@ -123,3 +123,29 @@ supported by libc++ they may be useful t
 Known 3rd Party Implementations Include:
 
 * `Koutheir's libc++ pretty-printers 
`_.
+
+
+Libc++ Configuration Macros
+===
+
+Libc++ provides a number of configuration macros which can be used to enable
+or disable extended libc++ behavior, including enabling "debug mode" or
+thread safety annotations.
+
+**_LIBCPP_DEBUG**:
+  This macro is used to enable assertions and other debugging checks within
+  libc++. All debugging checks are disabled by default.
+
+  **Values**: ``0``, ``1``
+
+  Defining ``_LIBCPP_DEBUG`` to ``0`` or greater enables most of libc++'s
+  assertions. Defining ``_LIBCPP_DEBUG`` to ``1`` enables "iterator debugging"
+  which provides additional assertions about the validity of iterators used by
+  the program.
+
+  Note that this option has no effect on libc++'s ABI
+
+**_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS**:
+  This macro is used to enable -Wthread-safety annotations on libc++'s
+  ``std::mutex`` and ``std::lock_guard``. By default these annotations are
+  disabled and must be manually enabled by the user.


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


[libcxx] r286783 - Fix GCC libc++abi build

2016-11-13 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Nov 13 16:27:00 2016
New Revision: 286783

URL: http://llvm.org/viewvc/llvm-project?rev=286783=rev
Log:
Fix GCC libc++abi build

Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/test/libcxx/compiler.py
libcxx/trunk/test/libcxx/test/config.py
libcxx/trunk/test/lit.site.cfg.in

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=286783=286782=286783=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Sun Nov 13 16:27:00 2016
@@ -312,6 +312,9 @@ add_target_flags_if(LIBCXX_BUILD_32_BITS
 add_target_flags_if(LIBCXX_TARGET_TRIPLE "-target ${LIBCXX_TARGET_TRIPLE}")
 add_target_flags_if(LIBCXX_SYSROOT "--sysroot=${LIBCXX_SYSROOT}")
 add_target_flags_if(LIBCXX_GCC_TOOLCHAIN "-gcc-toolchain 
${LIBCXX_GCC_TOOLCHAIN}")
+if (LIBCXX_TARGET_TRIPLE)
+  set(TARGET_TRIPLE "${LIBCXX_TARGET_TRIPLE}")
+endif()
 
 # Configure compiler.
 include(config-ix)

Modified: libcxx/trunk/test/libcxx/compiler.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/compiler.py?rev=286783=286782=286783=diff
==
--- libcxx/trunk/test/libcxx/compiler.py (original)
+++ libcxx/trunk/test/libcxx/compiler.py Sun Nov 13 16:27:00 2016
@@ -193,6 +193,17 @@ class CXXCompiler(object):
  flags=flags)
 return rc == 0
 
+def addFlagIfSupported(self, flag):
+if isinstance(flag, list):
+flags = list(flag)
+else:
+flags = [flag]
+if self.hasCompileFlag(flags):
+self.flags += flags
+return True
+else:
+return False
+
 def addCompileFlagIfSupported(self, flag):
 if isinstance(flag, list):
 flags = list(flag)

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=286783=286782=286783=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Sun Nov 13 16:27:00 2016
@@ -83,6 +83,10 @@ class Configuration(object):
 conf = self.get_lit_conf(name)
 if conf is None:
 return default
+if isinstance(conf, bool):
+return conf
+if not isinstance(conf, str):
+raise TypeError('expected bool or string')
 if conf.lower() in ('1', 'true'):
 return True
 if conf.lower() in ('', '0', 'false'):
@@ -375,7 +379,10 @@ class Configuration(object):
 if gcc_toolchain:
 self.cxx.flags += ['-gcc-toolchain', gcc_toolchain]
 if self.use_target:
-self.cxx.flags += ['-target', self.config.target_triple]
+if not self.cxx.addFlagIfSupported(
+['-target', self.config.target_triple]):
+self.lit_config.warning('use_target is true but -target is '\
+'not supported by the compiler')
 
 def configure_compile_flags_header_includes(self):
 support_path = os.path.join(self.libcxx_src_root, 'test/support')
@@ -756,10 +763,12 @@ class Configuration(object):
 def configure_triple(self):
 # Get or infer the target triple.
 self.config.target_triple = self.get_lit_conf('target_triple')
-self.use_target = bool(self.config.target_triple)
+self.use_target = self.get_lit_bool('use_target', False)
+if self.use_target and self.config.target_triple:
+self.lit_config.warning('use_target is true but no triple is 
specified')
 # If no target triple was given, try to infer it from the compiler
 # under test.
-if not self.use_target:
+if not self.config.target_triple:
 target_triple = self.cxx.getTriple()
 # Drop sub-major version components from the triple, because the
 # current XFAIL handling expects exact matches for feature checks.

Modified: libcxx/trunk/test/lit.site.cfg.in
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/lit.site.cfg.in?rev=286783=286782=286783=diff
==
--- libcxx/trunk/test/lit.site.cfg.in (original)
+++ libcxx/trunk/test/lit.site.cfg.in Sun Nov 13 16:27:00 2016
@@ -15,7 +15,9 @@ config.use_sanitizer= "@LLVM
 config.sanitizer_library= "@LIBCXX_SANITIZER_LIBRARY@"
 config.abi_library_path = "@LIBCXX_CXX_ABI_LIBRARY_PATH@"
 config.configuration_variant= "@LIBCXX_LIT_VARIANT@"
-config.target_triple= "@LIBCXX_TARGET_TRIPLE@"
+config.host_triple  = "@LLVM_HOST_TRIPLE@"
+config.target_triple= "@TARGET_TRIPLE@"
+config.use_target   = 

[libcxxabi] r286783 - Fix GCC libc++abi build

2016-11-13 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Nov 13 16:27:00 2016
New Revision: 286783

URL: http://llvm.org/viewvc/llvm-project?rev=286783=rev
Log:
Fix GCC libc++abi build

Modified:
libcxxabi/trunk/CMakeLists.txt
libcxxabi/trunk/test/lit.site.cfg.in

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=286783=286782=286783=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Sun Nov 13 16:27:00 2016
@@ -249,6 +249,10 @@ add_target_flags_if(LIBCXXABI_GCC_TOOLCH
 add_target_flags_if(LIBCXXABI_SYSROOT
   "--sysroot=${LIBCXXABI_SYSROOT}")
 
+if (LIBCXXABI_TARGET_TRIPLE)
+  set(TARGET_TRIPLE "${LIBCXXABI_TARGET_TRIPLE}")
+endif()
+
 # Configure compiler. Must happen after setting the target flags.
 include(config-ix)
 

Modified: libcxxabi/trunk/test/lit.site.cfg.in
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/lit.site.cfg.in?rev=286783=286782=286783=diff
==
--- libcxxabi/trunk/test/lit.site.cfg.in (original)
+++ libcxxabi/trunk/test/lit.site.cfg.in Sun Nov 13 16:27:00 2016
@@ -18,6 +18,7 @@ config.enable_shared= "@LIBC
 config.enable_exceptions= "@LIBCXXABI_ENABLE_EXCEPTIONS@"
 config.host_triple  = "@LLVM_HOST_TRIPLE@"
 config.target_triple= "@TARGET_TRIPLE@"
+config.use_target   = len("@LIBCXXABI_TARGET_TRIPLE@") > 0
 
 # Let the main config do the real work.
 lit_config.load_config(config, "@LIBCXXABI_SOURCE_DIR@/test/lit.cfg")


___
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 unique_ptr::release()

2016-11-13 Thread Eric Fiselier via cfe-commits
EricWF created this revision.
EricWF added reviewers: mclow.lists, chandlerc.
EricWF added a subscriber: cfe-commits.

The title says it all.

I just want to check that we agree on the general direction of this patch. 
Specifically that libc++ should be free to apply `no_discard` where we feel 
appropriate. If we agree then some other candidates are:

- Containers `empty()` and `size()` methods.
- `try_lock()` functions.
- other `release()` functions.

Additional suggestions welcome!

This patch fixes PR30898 (https://llvm.org/bugs/show_bug.cgi?id=30898)


https://reviews.llvm.org/D26596

Files:
  include/__config
  include/memory
  
test/libcxx/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.fail.cpp
  
test/libcxx/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.fail.cpp

Index: test/libcxx/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.fail.cpp
===
--- /dev/null
+++ test/libcxx/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.fail.cpp
@@ -0,0 +1,25 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// unique_ptr
+
+// test release
+
+#include 
+#include 
+
+int main()
+{
+std::unique_ptr p(new int(3));
+int* i = p.get();
+p.release(); // expected-warning {{ignoring return value of function declared with 'warn_unused_result' attribute}}
+delete i;
+}
Index: test/libcxx/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.fail.cpp
===
--- /dev/null
+++ test/libcxx/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.fail.cpp
@@ -0,0 +1,25 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// unique_ptr
+
+// test release
+
+#include 
+#include 
+
+int main()
+{
+std::unique_ptr p(new int[3]);
+int* i = p.get();
+p.release(); // expected-warning {{ignoring return value of function declared with 'warn_unused_result' attribute}}
+delete [] i;
+}
Index: include/memory
===
--- include/memory
+++ include/memory
@@ -2768,7 +2768,7 @@
 _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT
 {return __ptr_.first() != nullptr;}
 
-_LIBCPP_INLINE_VISIBILITY pointer release() _NOEXCEPT
+_LIBCPP_NO_DISCARD _LIBCPP_INLINE_VISIBILITY pointer release() _NOEXCEPT
 {
 pointer __t = __ptr_.first();
 __ptr_.first() = pointer();
@@ -2959,7 +2959,7 @@
 _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT
 {return __ptr_.first() != nullptr;}
 
-_LIBCPP_INLINE_VISIBILITY pointer release() _NOEXCEPT
+_LIBCPP_NO_DISCARD _LIBCPP_INLINE_VISIBILITY pointer release() _NOEXCEPT
 {
 pointer __t = __ptr_.first();
 __ptr_.first() = pointer();
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -900,6 +900,14 @@
 #define _LIBCPP_SAFE_STATIC
 #endif
 
+#ifndef _LIBCPP_NO_DISCARD
+# if __has_attribute(warn_unused_result) || _GNUC_VER > 408
+#   define _LIBCPP_NO_DISCARD __attribute__((__warn_unused_result__))
+# else
+#   define _LIBCPP_NO_DISCARD
+# endif
+#endif // !defined(_LIBCPP_NO_DISCARD)
+
 #if !__has_builtin(__builtin_addressof) && _GNUC_VER < 700
 #define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r286779 - Implement LWG 2770 - Make tuple_size defined for all T

2016-11-13 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Nov 13 14:43:50 2016
New Revision: 286779

URL: http://llvm.org/viewvc/llvm-project?rev=286779=rev
Log:
Implement LWG 2770 - Make tuple_size defined for all T

Modified:
libcxx/trunk/include/__tuple
libcxx/trunk/include/tuple

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.fail.cpp

Modified: libcxx/trunk/include/__tuple
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__tuple?rev=286779=286778=286779=diff
==
--- libcxx/trunk/include/__tuple (original)
+++ libcxx/trunk/include/__tuple Sun Nov 13 14:43:50 2016
@@ -22,7 +22,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-template  class _LIBCPP_TYPE_VIS_ONLY tuple_size;
+template  class _LIBCPP_TYPE_VIS_ONLY tuple_size {};
 
 template 
 class _LIBCPP_TYPE_VIS_ONLY tuple_size

Modified: libcxx/trunk/include/tuple
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/tuple?rev=286779=286778=286779=diff
==
--- libcxx/trunk/include/tuple (original)
+++ libcxx/trunk/include/tuple Sun Nov 13 14:43:50 2016
@@ -84,7 +84,7 @@ template 
   constexpr T make_from_tuple(Tuple&& t); // C++17
 
 // 20.4.1.4, tuple helper classes:
-template  class tuple_size; // undefined
+template  class tuple_size;
 template  class tuple_size;
 template 
  constexpr size_t tuple_size_v = tuple_size::value; // C++17

Modified: 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp?rev=286779=286778=286779=diff
==
--- 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp
 Sun Nov 13 14:43:50 2016
@@ -21,7 +21,7 @@
 
 int main()
 {
-(void)std::tuple_size &>::value; // expected-error {{implicit 
instantiation of undefined template}}
-(void)std::tuple_size::value; // expected-error {{implicit 
instantiation of undefined template}}
-(void)std::tuple_size*>::value; // expected-error {{implicit 
instantiation of undefined template}}
+(void)std::tuple_size &>::value; // expected-error {{no 
member named 'value'}}
+(void)std::tuple_size::value; // expected-error {{no member named 
'value'}}
+(void)std::tuple_size*>::value; // expected-error {{no member 
named 'value'}}
 }

Modified: 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp?rev=286779=286778=286779=diff
==
--- 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp
 Sun Nov 13 14:43:50 2016
@@ -18,19 +18,36 @@
 // UNSUPPORTED: c++98, c++03
 
 #include 
+#include 
+#include 
 #include 
 
+template ::value)>
+constexpr bool has_value(int) { return true; }
+template  constexpr bool has_value(long) { return false; }
+template  constexpr bool has_value() { return has_value(0); }
+
+
 template 
 void test()
 {
+static_assert(has_value(), "");
 static_assert((std::is_base_of,
std::tuple_size >::value), "");
+static_assert(has_value(), "");
 static_assert((std::is_base_of,
std::tuple_size >::value), "");
+static_assert(has_value(), "");
 static_assert((std::is_base_of,
std::tuple_size >::value), "");
+
+static_assert(has_value(), "");
 static_assert((std::is_base_of,
std::tuple_size 
>::value), "");
+{
+static_assert(!has_value(), "");
+static_assert(!has_value(), "");
+}
 }
 
 int main()
@@ -39,4 +56,13 @@ int main()
 test();
 test, 2>();
 test, 3>();
+test, 2>();
+test, 42>();
+{
+static_assert(!has_value(), "");
+static_assert(!has_value(), "");
+static_assert(!has_value(), "");
+static_assert(!has_value*>(), "");
+   

[libcxx] r286774 - Fix PR30979 - tuple is constructible from move_only const

2016-11-13 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Nov 13 13:54:31 2016
New Revision: 286774

URL: http://llvm.org/viewvc/llvm-project?rev=286774=rev
Log:
Fix PR30979 - tuple is constructible from move_only const&

Modified:
libcxx/trunk/include/tuple
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move.pass.cpp

Modified: libcxx/trunk/include/tuple
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/tuple?rev=286774=286773=286774=diff
==
--- libcxx/trunk/include/tuple (original)
+++ libcxx/trunk/include/tuple Sun Nov 13 13:54:31 2016
@@ -632,7 +632,7 @@ public:
   <
  _CheckArgsConstructor<
 _Dummy
- >::template __enable_implicit<_Tp...>(),
+ >::template __enable_implicit<_Tp const&...>(),
  bool
   >::type = false
 >
@@ -650,7 +650,7 @@ public:
   <
  _CheckArgsConstructor<
 _Dummy
- >::template __enable_explicit<_Tp...>(),
+ >::template __enable_explicit<_Tp const&...>(),
  bool
   >::type = false
 >
@@ -668,7 +668,7 @@ public:
   <
  _CheckArgsConstructor<
 _Dummy
- >::template __enable_implicit<_Tp...>(),
+ >::template __enable_implicit<_Tp const&...>(),
  bool
   >::type = false
 >
@@ -687,7 +687,7 @@ public:
   <
  _CheckArgsConstructor<
 _Dummy
- >::template __enable_explicit<_Tp...>(),
+ >::template __enable_explicit<_Tp const&...>(),
  bool
   >::type = false
 >

Modified: 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move.pass.cpp?rev=286774=286773=286774=diff
==
--- libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move.pass.cpp 
(original)
+++ libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move.pass.cpp 
Sun Nov 13 13:54:31 2016
@@ -35,6 +35,52 @@ struct ConstructsWithTupleLeaf
 }
 };
 
+// move_only type which triggers the empty base optimization
+struct move_only_ebo {
+  move_only_ebo() = default;
+  move_only_ebo(move_only_ebo&&) = default;
+};
+
+// a move_only type which does not trigger the empty base optimization
+struct move_only_large final {
+  move_only_large() : value(42) {}
+  move_only_large(move_only_large&&) = default;
+  int value;
+};
+
+template 
+void test_sfinae() {
+using Tup = std::tuple;
+using Alloc = std::allocator;
+using Tag = std::allocator_arg_t;
+// special members
+{
+static_assert(std::is_default_constructible::value, "");
+static_assert(std::is_move_constructible::value, "");
+static_assert(!std::is_copy_constructible::value, "");
+static_assert(!std::is_constructible::value, "");
+}
+// args constructors
+{
+static_assert(std::is_constructible::value, "");
+static_assert(!std::is_constructible::value, "");
+static_assert(!std::is_constructible::value, "");
+}
+// uses-allocator special member constructors
+{
+static_assert(std::is_constructible::value, "");
+static_assert(std::is_constructible::value, 
"");
+static_assert(!std::is_constructible::value, "");
+static_assert(!std::is_constructible::value, 
"");
+}
+// uses-allocator args constructors
+{
+static_assert(std::is_constructible::value, 
"");
+static_assert(!std::is_constructible::value, "");
+static_assert(!std::is_constructible::value, 
"");
+}
+}
+
 int main()
 {
 {
@@ -72,4 +118,8 @@ int main()
 d_t d((ConstructsWithTupleLeaf()));
 d_t d2(static_cast(d));
 }
+{
+test_sfinae();
+test_sfinae();
+}
 }


___
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-13 Thread Krzysztof Wiśniewski via cfe-commits
k-wisniewski created this revision.
k-wisniewski added reviewers: zaks.anna, dcoughlin, dergachev.a.
k-wisniewski added a subscriber: cfe-commits.
Herald added a subscriber: mgorny.

This is the very first version of a checker that aims to find cases of infinite 
recursion.  It relies on Add LocationContext to members of check::RegionChanges 
.

What it does:

- it registers on check::PreCall and check::RegionChanges events
- in checkPreCall digs through the call stack searching for invocation of 
currently encountered function/method with exactly the same arguments (meaning 
same SVals of them)
- in checkRegionChanges makes all the frames on the call stack invalid by 
adding them to the set of dirty frames
- if the frame encountered by the search in checkPreCall is in the set of dirty 
frames  the search stops

Obviously this has lots of both false negatives and false positives, but I plan 
to improve it by decreasing the number of frame invalidations and only taking 
into account changes that affect whether the recursive call happens or not. The 
 support for Obj-C method calls is also on the way.

I welcome any ideas on how to make it better!

PS. This is one of my first patches submitted here - sorry if it doesn't comply 
with some conventions you might have here!


https://reviews.llvm.org/D26589

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/RecursionChecker.cpp
  test/Analysis/misc-ps-region-store.cpp
  test/Analysis/recursion.cpp

Index: test/Analysis/recursion.cpp
===
--- /dev/null
+++ test/Analysis/recursion.cpp
@@ -0,0 +1,210 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.core.RecursionChecker -verify %s
+
+namespace obvious {
+
+void f() {
+f(); // expected-warning {{Infinite recursion detected}}
+}
+
+void h();
+
+// Mutual recursion - simplest case
+void g() {
+h(); // expected-warning {{Infinite recursion detected}}
+}
+
+void h() {
+g();
+}
+
+}
+
+namespace region_changes {
+
+// some global variable
+int SampleGlobalVariable = 0;
+
+void f2();
+void f3();
+void f1();
+
+void f1() {
+f2();
+}
+
+// we spoil the frame here by touching global variable - no warnings
+void f2() {
+SampleGlobalVariable = 1;
+f3();
+}
+
+// no warning because frame of f1 has been spoiled in f2!
+void f3() {
+f1();
+}
+
+void f() {
+f1();
+}
+
+void f5();
+void f6();
+void f7();
+void f4();
+
+void f5() {
+f6();
+}
+
+void f6() {
+f7();
+}
+
+void f7() {
+   f5(); // expected-warning {{Infinite recursion detected}}
+}
+
+// only the first frame is spoiled, the two over it are fine
+void f4() {
+SampleGlobalVariable = 1;
+f5();
+}
+
+}
+
+namespace obvious_with_arguments {
+
+void f(int a) {
+  f(a); // expected-warning {{Infinite recursion detected}}
+}
+
+void h(int a, int b);
+
+void g(int a, int b) {
+  h(b, a); // expected-warning {{Infinite recursion detected}}
+}
+
+void h(int a, int b) {
+  g(b, a);
+}
+
+void f2(int a);
+
+void f1(int a, int b) {
+  f2(a); // expected-warning {{Infinite recursion detected}}
+}
+
+void f2(int a) {
+  f1(a, 3);
+}
+
+}
+
+namespace object_oriented {
+
+struct A {
+  void f() {
+f(); // expected-warning {{Infinite recursion detected}}
+  }
+
+  // Mutual recursion - simplest case
+  void g() {
+  h();
+  }
+
+  void h() {
+  g(); // expected-warning {{Infinite recursion detected}}
+  }
+  void f(int a) {
+f(a); // expected-warning {{Infinite recursion detected}}
+  }
+
+  void g1(int a, int b) {
+h1(b, a);
+  }
+
+  void h1(int a, int b) {
+g1(b, a); // expected-warning {{Infinite recursion detected}}
+  }
+
+  void f1(int a, int b) {
+f2(a);
+  }
+
+  void f2(int a) {
+f1(a, 3); // expected-warning {{Infinite recursion detected}}
+  }
+
+};
+
+void start1() {
+  A a;
+  a.f();
+}
+
+void start2() {
+  A a;
+  a.g();
+}
+
+void start3() {
+  A a;
+  a.g1(1, 2);
+}
+
+void start4() {
+  A a;
+  a.f1(1, 3);
+}
+
+class B {
+public:
+
+  int f(A& a) {
+return f(a); // expected-warning {{Infinite recursion detected}}
+  }
+
+  A g(A& a, int b) {
+return h(b, a);
+  }
+
+  A h(int a, A& b) {
+return g(b, a); // expected-warning {{Infinite recursion detected}}
+  }
+
+  int f1(const B& b) const {
+return b.f1(*this); // expected-warning {{Infinite recursion detected}}
+  }
+
+  void g1(const B& b) const {
+b.h1(*this);
+  }
+
+  void h1(const B& b) const {
+b.g1(*this); // expected-warning {{Infinite recursion detected}}
+  }
+
+};
+
+void start5() {
+  B b;
+  A a;
+  b.f(a);
+}
+
+void start6() {
+  B b;
+  A a;
+  b.g(a, 3);
+}
+
+void start7() {
+  B b1, b2;
+  b1.f1(b2);
+}
+
+void start8() {
+  B b1, b2;
+  b1.g1(b2);
+}
+}
Index: test/Analysis/misc-ps-region-store.cpp
===
--- test/Analysis/misc-ps-region-store.cpp
+++ 

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

2016-11-13 Thread Krzysztof Wiśniewski via cfe-commits
k-wisniewski created this revision.
k-wisniewski added reviewers: dergachev.a, dcoughlin, zaks.anna.
k-wisniewski added a subscriber: cfe-commits.

Hi,

I've been working on a checker that uses RegionChanges interface and needed to 
access to LocationContext.  Another change is an easy way to obtain arguments' 
SVals from StackFrameCtx, with which the function/method has been called. In my 
opinion having that might prove useful for creating future checkers so I 
publish it here for review and discussion. Obvoiusly, this needs some 
improvement, but I'll be more than happy to hear community's opinion about the 
current version, as I wasn't sure if my changes fit into architecture etc.

Also: this is my first public contribution to clang. so if there are any 
annoying aspects of it (like the list of subscribers being to broad, bad forma, 
wrong metadata etc.) - sorry!


https://reviews.llvm.org/D26588

Files:
  include/clang/StaticAnalyzer/Core/Checker.h
  include/clang/StaticAnalyzer/Core/CheckerManager.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
  lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp
  lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  lib/StaticAnalyzer/Core/CheckerManager.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
  lib/StaticAnalyzer/Core/ProgramState.cpp

Index: lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- lib/StaticAnalyzer/Core/ProgramState.cpp
+++ lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -111,24 +111,29 @@
   return ConstraintMgr->removeDeadBindings(Result, SymReaper);
 }
 
-ProgramStateRef ProgramState::bindLoc(Loc LV, SVal V, bool notifyChanges) const {
+ProgramStateRef ProgramState::bindLoc(Loc LV,
+  SVal V,
+  const LocationContext *LCtx,
+  bool notifyChanges) const {
   ProgramStateManager  = getStateManager();
   ProgramStateRef newState = makeWithStore(Mgr.StoreMgr->Bind(getStore(),
  LV, V));
   const MemRegion *MR = LV.getAsRegion();
   if (MR && Mgr.getOwningEngine() && notifyChanges)
-return Mgr.getOwningEngine()->processRegionChange(newState, MR);
+return Mgr.getOwningEngine()->processRegionChange(newState, MR, LCtx);
 
   return newState;
 }
 
-ProgramStateRef ProgramState::bindDefault(SVal loc, SVal V) const {
+ProgramStateRef ProgramState::bindDefault(SVal loc,
+  SVal V,
+  const LocationContext *LCtx) const {
   ProgramStateManager  = getStateManager();
   const MemRegion *R = loc.castAs().getRegion();
   const StoreRef  = Mgr.StoreMgr->BindDefault(getStore(), R, V);
   ProgramStateRef new_state = makeWithStore(newStore);
   return Mgr.getOwningEngine() ?
-   Mgr.getOwningEngine()->processRegionChange(new_state, R) :
+   Mgr.getOwningEngine()->processRegionChange(new_state, R, LCtx) :
new_state;
 }
 
@@ -202,7 +207,7 @@
 }
 
 return Eng->processRegionChanges(newState, IS, TopLevelInvalidated,
- Invalidated, Call);
+ Invalidated, Call, LCtx);
   }
 
   const StoreRef  =
Index: lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
@@ -115,11 +115,11 @@
 SymbolRef Sym = SymMgr.conjureSymbol(elem, LCtx, T,
  currBldrCtx->blockCount());
 SVal V = svalBuilder.makeLoc(Sym);
-hasElems = hasElems->bindLoc(elementV, V);
+hasElems = hasElems->bindLoc(elementV, V, LCtx);
 
 // Bind the location to 'nil' on the false branch.
 SVal nilV = svalBuilder.makeIntVal(0, T);
-noElems = noElems->bindLoc(elementV, nilV);
+noElems = noElems->bindLoc(elementV, nilV, LCtx);
   }
 
 // Create the new nodes.
Index: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -317,7 +317,7 @@
 // actually make things worse. Placement new makes this tricky as well,
 // since it's then possible to be initializing one part of a multi-
 // dimensional array.
-State = State->bindDefault(loc::MemRegionVal(Target), ZeroVal);
+State = 

[PATCH] D24085: arm: Fix ttype encoding assertion failure.

2016-11-13 Thread Logan Chien via cfe-commits
logan closed this revision.
logan added a comment.

Thanks for reviewing.  Committed as https://reviews.llvm.org/rL286760.


https://reviews.llvm.org/D24085



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


[libcxxabi] r286760 - arm: Fix ttype encoding assertion failure.

2016-11-13 Thread Logan Chien via cfe-commits
Author: logan
Date: Sun Nov 13 08:44:41 2016
New Revision: 286760

URL: http://llvm.org/viewvc/llvm-project?rev=286760=rev
Log:
arm: Fix ttype encoding assertion failure.

GCC 4.7 or newer emits 0x90 (indirect | pcrel) as the ttype encoding.
This would hit an assertion in cxa_personality.cpp.  This commit fixes
the problem by relaxing the assertion.

Added:
libcxxabi/trunk/test/native/
libcxxabi/trunk/test/native/arm-linux-eabi/
libcxxabi/trunk/test/native/arm-linux-eabi/lit.local.cfg
libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-00.pass.sh.s
libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-90.pass.sh.s
Modified:
libcxxabi/trunk/src/cxa_personality.cpp
libcxxabi/trunk/test/lit.cfg
libcxxabi/trunk/test/lit.site.cfg.in

Modified: libcxxabi/trunk/src/cxa_personality.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_personality.cpp?rev=286760=286759=286760=diff
==
--- libcxxabi/trunk/src/cxa_personality.cpp (original)
+++ libcxxabi/trunk/src/cxa_personality.cpp Sun Nov 13 08:44:41 2016
@@ -348,7 +348,10 @@ get_shim_type_info(uint64_t ttypeIndex,
 call_terminate(native_exception, unwind_exception);
 }
 
-assert(ttypeEncoding == DW_EH_PE_absptr && "Unexpected TTypeEncoding");
+assert(((ttypeEncoding == DW_EH_PE_absptr) ||  // LLVM or GCC 4.6
+(ttypeEncoding == DW_EH_PE_pcrel) ||  // GCC 4.7 baremetal
+(ttypeEncoding == (DW_EH_PE_pcrel | DW_EH_PE_indirect))) &&  // 
GCC 4.7 linux
+   "Unexpected TTypeEncoding");
 (void)ttypeEncoding;
 
 const uint8_t* ttypePtr = classInfo - ttypeIndex * sizeof(uintptr_t);
@@ -415,7 +418,10 @@ exception_spec_can_catch(int64_t specInd
 call_terminate(false, unwind_exception);
 }
 
-assert(ttypeEncoding == DW_EH_PE_absptr && "Unexpected TTypeEncoding");
+assert(((ttypeEncoding == DW_EH_PE_absptr) ||  // LLVM or GCC 4.6
+(ttypeEncoding == DW_EH_PE_pcrel) ||  // GCC 4.7 baremetal
+(ttypeEncoding == (DW_EH_PE_pcrel | DW_EH_PE_indirect))) &&  // 
GCC 4.7 linux
+   "Unexpected TTypeEncoding");
 (void)ttypeEncoding;
 
 // specIndex is negative of 1-based byte offset into classInfo;

Modified: libcxxabi/trunk/test/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/lit.cfg?rev=286760=286759=286760=diff
==
--- libcxxabi/trunk/test/lit.cfg (original)
+++ libcxxabi/trunk/test/lit.cfg Sun Nov 13 08:44:41 2016
@@ -18,7 +18,7 @@ if 'PYLINT_IMPORT' in os.environ:
 config.name = 'libc++abi'
 
 # suffixes: A list of file extensions to treat as test files.
-config.suffixes = ['.cpp']
+config.suffixes = ['.cpp', '.s']
 
 # test_source_root: The root path where tests are located.
 config.test_source_root = os.path.dirname(__file__)

Modified: libcxxabi/trunk/test/lit.site.cfg.in
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/lit.site.cfg.in?rev=286760=286759=286760=diff
==
--- libcxxabi/trunk/test/lit.site.cfg.in (original)
+++ libcxxabi/trunk/test/lit.site.cfg.in Sun Nov 13 08:44:41 2016
@@ -16,6 +16,8 @@ config.executor = "@LIBC
 config.libcxxabi_shared = "@LIBCXXABI_ENABLE_SHARED@"
 config.enable_shared= "@LIBCXX_ENABLE_SHARED@"
 config.enable_exceptions= "@LIBCXXABI_ENABLE_EXCEPTIONS@"
+config.host_triple  = "@LLVM_HOST_TRIPLE@"
+config.target_triple= "@TARGET_TRIPLE@"
 
 # Let the main config do the real work.
 lit_config.load_config(config, "@LIBCXXABI_SOURCE_DIR@/test/lit.cfg")

Added: libcxxabi/trunk/test/native/arm-linux-eabi/lit.local.cfg
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/native/arm-linux-eabi/lit.local.cfg?rev=286760=auto
==
--- libcxxabi/trunk/test/native/arm-linux-eabi/lit.local.cfg (added)
+++ libcxxabi/trunk/test/native/arm-linux-eabi/lit.local.cfg Sun Nov 13 
08:44:41 2016
@@ -0,0 +1,6 @@
+def is_arm_linux_eabi(triple):
+return ('arm' in triple) and ('linux' in triple) and ('eabi' in triple)
+
+is_native = config.root.host_triple == config.root.target_triple
+if not is_native or not is_arm_linux_eabi(config.root.host_triple):
+config.unsupported = True

Added: libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-00.pass.sh.s
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-00.pass.sh.s?rev=286760=auto
==
--- libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-00.pass.sh.s 
(added)
+++ libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-00.pass.sh.s Sun 
Nov 13 08:44:41 2016
@@ -0,0 +1,97 @@
+@ RUN: %cxx %flags 

[PATCH] D24082: [CMake] Fix libc++abi arm build w/o libunwind.

2016-11-13 Thread Logan Chien via cfe-commits
logan closed this revision.
logan added a comment.

Thanks.  Committed as https://reviews.llvm.org/rL286759.


https://reviews.llvm.org/D24082



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


[libcxxabi] r286759 - [CMake] Fix libc++abi arm build w/o libunwind.

2016-11-13 Thread Logan Chien via cfe-commits
Author: logan
Date: Sun Nov 13 08:42:15 2016
New Revision: 286759

URL: http://llvm.org/viewvc/llvm-project?rev=286759=rev
Log:
[CMake] Fix libc++abi arm build w/o libunwind.

This commit fixes libc++abi build when LLVM unwinder (libunwind_llvm) is
not enabled.

This commit fixes the problem by removing "LLVM_NATIVE_ARCH MATCHES ARM"
from CMakeLists.txt so that LIBCXXABI_USE_LLVM_UNWINDER will only be
defined when LLVM unwinder is enabled.

We need LIBCXXABI_USE_LLVM_UNWINDER becase there is a subtle difference
between the unwinder from libgcc and the one from libunwind_llvm.  For
the unwinder from libgcc, we have to initialize register r12 with the
address of _Unwind_Control_Block; otherwise,
_Unwind_GetLanguageSpecificData() and _Unwind_GetRegionStart() won't
work properly.  Consequently, there is an extra _Unwind_SetGR() when
LLVM unwinder is disabled.  Check cxa_personality.cpp for details.

Modified:
libcxxabi/trunk/CMakeLists.txt

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=286759=286758=286759=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Sun Nov 13 08:42:15 2016
@@ -362,7 +362,7 @@ if (MSVC)
 endif()
 
 # Define LIBCXXABI_USE_LLVM_UNWINDER for conditional compilation.
-if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_NATIVE_ARCH MATCHES ARM)
+if (LIBCXXABI_USE_LLVM_UNWINDER)
   add_definitions(-DLIBCXXABI_USE_LLVM_UNWINDER=1)
 endif()
 


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


[PATCH] D26587: [X86][AVX512][InlineASM][MS][clang] (I|G)CC Memory adjustments compatibility

2016-11-13 Thread coby via cfe-commits
coby created this revision.
coby added reviewers: m_zuckerman, rnk, myatsina.
coby added a subscriber: cfe-commits.
coby set the repository for this revision to rL LLVM.

(I|G)CC will adjust a missing size qualifier on an indirect memory reference 
according to a certain logic, which is presented on the suggested patch.
This patch implements a narrow view of those said adjustments - only upon 
AVX512 platforms, and only if the adjusted operand is missing a size qualifier 
& is of SIMD type (or a broadcast)
Summery of adjustment logic:

Unqualified indirect memory reference (i.e. - via 'brackets')
AVX512 platform
Operand is of SIMD type
llvm part can be viewed here: https://reviews.llvm.org/D26586


Repository:
  rL LLVM

https://reviews.llvm.org/D26587

Files:
  test/CodeGen/ms-inline-asm-avx512-relaxations.c


Index: test/CodeGen/ms-inline-asm-avx512-relaxations.c
===
--- test/CodeGen/ms-inline-asm-avx512-relaxations.c
+++ test/CodeGen/ms-inline-asm-avx512-relaxations.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu 
skylake-avx512 -fasm-blocks -o - | FileCheck %s
+
+// Minimal reproducer
+// Case1: Check integrity of inspected patch upon broadcasting
+// Case2: Check integrity of inspected patch upon SIMD mem ref
+// Case3: Check we don't mess up with non-SIMD mem ref
+// Case4: Check non-AVX512 insts aren't affected
+
+void F() {
+  char a;
+  // CHECK: vaddps xmm1, xmm2, dword ptr $0{1to4}
+  // CHECK: vaddps xmm1, xmm2, xmmword ptr $1
+  // CHECK: vcomiss xmm1, byte ptr $2
+  // CHECK: mov rax, byte ptr $3
+  __asm vaddps xmm1, xmm2, [a]{1to4}
+  __asm vaddps xmm1, xmm2, [a]
+  __asm vcomiss xmm1, [a]
+  __asm mov rax, [a]
+}


Index: test/CodeGen/ms-inline-asm-avx512-relaxations.c
===
--- test/CodeGen/ms-inline-asm-avx512-relaxations.c
+++ test/CodeGen/ms-inline-asm-avx512-relaxations.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu skylake-avx512 -fasm-blocks -o - | FileCheck %s
+
+// Minimal reproducer
+// Case1: Check integrity of inspected patch upon broadcasting
+// Case2: Check integrity of inspected patch upon SIMD mem ref
+// Case3: Check we don't mess up with non-SIMD mem ref
+// Case4: Check non-AVX512 insts aren't affected
+
+void F() {
+  char a;
+  // CHECK: vaddps xmm1, xmm2, dword ptr $0{1to4}
+  // CHECK: vaddps xmm1, xmm2, xmmword ptr $1
+  // CHECK: vcomiss xmm1, byte ptr $2
+  // CHECK: mov rax, byte ptr $3
+  __asm vaddps xmm1, xmm2, [a]{1to4}
+  __asm vaddps xmm1, xmm2, [a]
+  __asm vcomiss xmm1, [a]
+  __asm mov rax, [a]
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26196: Add support for non-zero null pointer for C and OpenCL

2016-11-13 Thread John McCall via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D26196#593741, @yaxunl wrote:

> >> It seems the casting from a pointer to different address space is not 
> >> affected by this change. When a null pointer is casted to different 
> >> address space, it is casted the same way as an ordinary pointer, e.g. by 
> >> addrspacecast.
> > 
> > You mean, the code-generation for that knows about your special null 
> > pointer representation?  That is confusing.
>
> Do you mean if a null pointer in one address space is casted to another 
> address space, we should use the specific null pointer representation in the 
> new address space, instead of a simple addrspacecast?


That's the general user expectation, yes: a null pointer should be converted to 
a null pointer.  Technically, whether this required is up to the appropriate 
language standard.

The standard rules for address spaces are laid out by Embedded C (ISO/IEC TR 
18037), which has this to say in 5.1.3p4:

> A non-null pointer into an address space A can be cast to a pointer into 
> another address space B, but such a cast is undefined if the source pointer 
> does not point to a location in B. Note that if A is a subset of B, the cast 
> is always valid; however, if B is a subset of A, the cast is valid only if 
> the source pointer refers to a location in B. A null pointer into one address 
> space can be cast to a null pointer into any overlapping address space.

The wording could be better, but I think this is fairly clearly saying that you 
do need to map null to null.

Now, my understanding is that you're not actually implementing Embedded C, 
you're implementing Open CL.  The Open CL specification that I have on hand 
(v1.1) says that __global, __local, __constant, and __private are disjoint and 
that casts between address spaces are illegal.  So this might not actually 
matter to you.

But if you do need to support these conversions for some reason, the correct 
behavior is to ensure that null is mapped to null.


https://reviews.llvm.org/D26196



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