r290661 - [CodeGen] Unique constant CompoundLiterals.

2016-12-27 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Wed Dec 28 01:27:40 2016
New Revision: 290661

URL: http://llvm.org/viewvc/llvm-project?rev=290661=rev
Log:
[CodeGen] Unique constant CompoundLiterals.

Our newly aggressive constant folding logic makes it possible for
CGExprConstant to see the same CompoundLiteralExpr more than once. So,
emitting a new GlobalVariable every time we see a CompoundLiteral is no
longer correct.

We had a similar issue with BlockExprs that was caught while testing
said aggressive folding, so I applied the same style of fix (see D26410)
here. If we find yet another case where this needs to happen, we should
probably refactor this so we don't have a third DenseMap+getter+setter.

As a design note: getAddrOfConstantCompoundLiteralIfEmitted is really
only intended to be called by ConstExprEmitter::EmitLValue. So,
returning a GlobalVariable* instead of a ConstantAddress costs us
effectively nothing, and saves us either a few bytes per entry in our
map or a bit of code duplication.

Modified:
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/test/CodeGen/compound-literal.c

Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=290661=290660=290661=diff
==
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Wed Dec 28 01:27:40 2016
@@ -1023,16 +1023,17 @@ public:
 switch (E->getStmtClass()) {
 default: break;
 case Expr::CompoundLiteralExprClass: {
-  // Note that due to the nature of compound literals, this is guaranteed
-  // to be the only use of the variable, so we just generate it here.
   CompoundLiteralExpr *CLE = cast(E);
+  CharUnits Align = CGM.getContext().getTypeAlignInChars(E->getType());
+  if (llvm::GlobalVariable *Addr =
+  CGM.getAddrOfConstantCompoundLiteralIfEmitted(CLE))
+return ConstantAddress(Addr, Align);
+
   llvm::Constant* C = CGM.EmitConstantExpr(CLE->getInitializer(),
CLE->getType(), CGF);
   // FIXME: "Leaked" on failure.
   if (!C) return ConstantAddress::invalid();
 
-  CharUnits Align = CGM.getContext().getTypeAlignInChars(E->getType());
-
   auto GV = new llvm::GlobalVariable(CGM.getModule(), C->getType(),
  E->getType().isConstant(CGM.getContext()),
  llvm::GlobalValue::InternalLinkage,
@@ -1040,6 +1041,7 @@ public:
  llvm::GlobalVariable::NotThreadLocal,
   
CGM.getContext().getTargetAddressSpace(E->getType()));
   GV->setAlignment(Align.getQuantity());
+  CGM.setAddrOfConstantCompoundLiteral(CLE, GV);
   return ConstantAddress(GV, Align);
 }
 case Expr::StringLiteralClass:
@@ -1492,6 +1494,18 @@ CodeGenModule::EmitConstantValueForMemor
   return C;
 }
 
+llvm::GlobalVariable *CodeGenModule::getAddrOfConstantCompoundLiteralIfEmitted(
+const CompoundLiteralExpr *E) {
+  return EmittedCompoundLiterals.lookup(E);
+}
+
+void CodeGenModule::setAddrOfConstantCompoundLiteral(
+const CompoundLiteralExpr *CLE, llvm::GlobalVariable *GV) {
+  bool Ok = EmittedCompoundLiterals.insert(std::make_pair(CLE, GV)).second;
+  (void)Ok;
+  assert(Ok && "CLE has already been emitted!");
+}
+
 ConstantAddress
 CodeGenModule::GetAddrOfConstantCompoundLiteral(const CompoundLiteralExpr *E) {
   assert(E->isFileScope() && "not a file-scope compound literal expr");

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=290661=290660=290661=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Wed Dec 28 01:27:40 2016
@@ -455,6 +455,10 @@ private:
   bool isTriviallyRecursive(const FunctionDecl *F);
   bool shouldEmitFunction(GlobalDecl GD);
 
+  /// Map used to be sure we don't emit the same CompoundLiteral twice.
+  llvm::DenseMap
+  EmittedCompoundLiterals;
+
   /// Map of the global blocks we've emitted, so that we don't have to re-emit
   /// them if the constexpr evaluator gets aggressive.
   llvm::DenseMap EmittedGlobalBlocks;
@@ -824,6 +828,16 @@ public:
   /// compound literal expression.
   ConstantAddress GetAddrOfConstantCompoundLiteral(const 
CompoundLiteralExpr*E);
 
+  /// If it's been emitted already, returns the GlobalVariable corresponding to
+  /// a compound literal. Otherwise, returns null.
+  llvm::GlobalVariable *
+  getAddrOfConstantCompoundLiteralIfEmitted(const CompoundLiteralExpr *E);
+
+  /// Notes that CLE's GlobalVariable is GV. Asserts that CLE isn't already
+  /// emitted.
+  void setAddrOfConstantCompoundLiteral(const CompoundLiteralExpr 

[PATCH] D24599: Add 'inline' but not _LIBCPP_INLINE_VISIBILITY to basic_string's destructor

2016-12-27 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF abandoned this revision.
EricWF added a comment.

Another version of this has already been committed.


https://reviews.llvm.org/D24599



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


[PATCH] D23495: Remove std::tuple's reduced-arity-extension on implicit constructors.

2016-12-27 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF abandoned this revision.
EricWF added a comment.

Another version of this has already been committed.


https://reviews.llvm.org/D23495



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


[PATCH] D20800: Make placeholders constexpr in C++17

2016-12-27 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF abandoned this revision.
EricWF added a comment.

Already committed.


https://reviews.llvm.org/D20800



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


[PATCH] D13796: [libcxx] Use "-stdlib=libc++" when possible instead of '-nodefaultlibs' in the test suite.

2016-12-27 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF abandoned this revision.
EricWF added a comment.

This is long dead.


https://reviews.llvm.org/D13796



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


[PATCH] D13332: [libcxx] Remove uses of std::unique_ptr<T[N]> from test to prevent warning.

2016-12-27 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF abandoned this revision.
EricWF added a comment.

This was already committed.


https://reviews.llvm.org/D13332



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


r290660 - Mark 'auto' as dependent when instantiating the type of a non-type template

2016-12-27 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Dec 28 00:27:18 2016
New Revision: 290660

URL: http://llvm.org/viewvc/llvm-project?rev=290660=rev
Log:
Mark 'auto' as dependent when instantiating the type of a non-type template
parameter. Fixes failed deduction for 'auto' non-type template parameters
nested within templates.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=290660=290659=290660=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Dec 28 00:27:18 2016
@@ -5790,7 +5790,10 @@ public:
SourceLocation EqualLoc,
ParsedType DefaultArg);
 
+  QualType CheckNonTypeTemplateParameterType(TypeSourceInfo *,
+ SourceLocation Loc);
   QualType CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc);
+
   Decl *ActOnNonTypeTemplateParameter(Scope *S, Declarator ,
   unsigned Depth,
   unsigned Position,

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=290660=290659=290660=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed Dec 28 00:27:18 2016
@@ -729,8 +729,22 @@ Decl *Sema::ActOnTypeParameter(Scope *S,
 ///
 /// \returns the (possibly-promoted) parameter type if valid;
 /// otherwise, produces a diagnostic and returns a NULL type.
-QualType
-Sema::CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc) {
+QualType Sema::CheckNonTypeTemplateParameterType(TypeSourceInfo *,
+ SourceLocation Loc) {
+  if (TSI->getType()->isUndeducedType()) {
+// C++1z [temp.dep.expr]p3:
+//   An id-expression is type-dependent if it contains
+//- an identifier associated by name lookup with a non-type
+//  template-parameter declared with a type that contains a
+//  placeholder type (7.1.7.4),
+TSI = SubstAutoTypeSourceInfo(TSI, Context.DependentTy);
+  }
+
+  return CheckNonTypeTemplateParameterType(TSI->getType(), Loc);
+}
+
+QualType Sema::CheckNonTypeTemplateParameterType(QualType T,
+ SourceLocation Loc) {
   // We don't allow variably-modified types as the type of non-type template
   // parameters.
   if (T->isVariablyModifiedType()) {
@@ -759,10 +773,6 @@ Sema::CheckNonTypeTemplateParameterType(
   T->isDependentType() ||
   // Allow use of auto in template parameter declarations.
   T->isUndeducedType()) {
-if (T->isUndeducedType()) {
-  Diag(Loc, diag::warn_cxx14_compat_template_nontype_parm_auto_type)
-  << QualType(T->getContainedAutoType(), 0);
-}
 // C++ [temp.param]p5: The top-level cv-qualifiers on the 
template-parameter
 // are ignored when determining its type.
 return T.getUnqualifiedType();
@@ -788,13 +798,18 @@ Decl *Sema::ActOnNonTypeTemplateParamete
   SourceLocation EqualLoc,
   Expr *Default) {
   TypeSourceInfo *TInfo = GetTypeForDeclarator(D, S);
-  QualType T = TInfo->getType();
+
+  if (TInfo->getType()->isUndeducedType()) {
+Diag(D.getIdentifierLoc(),
+ diag::warn_cxx14_compat_template_nontype_parm_auto_type)
+  << QualType(TInfo->getType()->getContainedAutoType(), 0);
+  }
 
   assert(S->isTemplateParamScope() &&
  "Non-type template parameter not in template parameter scope!");
   bool Invalid = false;
 
-  T = CheckNonTypeTemplateParameterType(T, D.getIdentifierLoc());
+  QualType T = CheckNonTypeTemplateParameterType(TInfo, D.getIdentifierLoc());
   if (T.isNull()) {
 T = Context.IntTy; // Recover with an 'int' type.
 Invalid = true;

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=290660=290659=290660=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Wed Dec 28 00:27:18 2016
@@ -2085,18 +2085,18 @@ Decl *TemplateDeclInstantiator::VisitNon
 ExpandedParameterPackTypes.reserve(D->getNumExpansionTypes());
 ExpandedParameterPackTypesAsWritten.reserve(D->getNumExpansionTypes());
 for (unsigned I = 0, N = D->getNumExpansionTypes(); I 

[libcxx] r290659 - Remove dead debug_mode doc link

2016-12-27 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Dec 28 00:21:09 2016
New Revision: 290659

URL: http://llvm.org/viewvc/llvm-project?rev=290659=rev
Log:
Remove dead debug_mode doc link

Modified:
libcxx/trunk/docs/index.rst

Modified: libcxx/trunk/docs/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/index.rst?rev=290659=290658=290659=diff
==
--- libcxx/trunk/docs/index.rst (original)
+++ libcxx/trunk/docs/index.rst Wed Dec 28 00:21:09 2016
@@ -135,7 +135,6 @@ Design Documents
 
 * ` design `_
 * ` design `_
-* `Status of debug mode `_
 * `Notes by Marshall Clow`__
 
 .. __: 
https://cplusplusmusings.wordpress.com/2012/07/05/clang-and-standard-libraries-on-mac-os-x/


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


[libcxx] r290658 - Ensure <__debug> gets the nullptr definition in C++03

2016-12-27 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Dec 28 00:15:01 2016
New Revision: 290658

URL: http://llvm.org/viewvc/llvm-project?rev=290658=rev
Log:
Ensure <__debug> gets the nullptr definition in C++03

Modified:
libcxx/trunk/include/__debug

Modified: libcxx/trunk/include/__debug
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__debug?rev=290658=290657=290658=diff
==
--- libcxx/trunk/include/__debug (original)
+++ libcxx/trunk/include/__debug Wed Dec 28 00:15:01 2016
@@ -17,6 +17,10 @@
 #pragma GCC system_header
 #endif
 
+#if defined(_LIBCPP_HAS_NO_NULLPTR)
+# include 
+#endif
+
 #if _LIBCPP_DEBUG_LEVEL >= 1 || defined(_LIBCPP_BUILDING_LIBRARY)
 #   include 
 #   include 


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


[libcxx] r290657 - Fix debug mode for vector/list and cleanup tests

2016-12-27 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Dec 28 00:06:09 2016
New Revision: 290657

URL: http://llvm.org/viewvc/llvm-project?rev=290657=rev
Log:
Fix debug mode for vector/list and cleanup tests

Added:

libcxx/trunk/test/libcxx/debug/containers/db_associative_container_tests.pass.cpp

libcxx/trunk/test/libcxx/debug/containers/db_sequence_container_iterators.pass.cpp
Removed:
libcxx/trunk/test/libcxx/containers/sequences/list/db_back.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/list/db_cback.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/list/db_cfront.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/list/db_front.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/list/db_iterators_6.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/list/db_iterators_7.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/list/db_iterators_8.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/list/db_iterators_9.pass.cpp

libcxx/trunk/test/libcxx/containers/sequences/list/list.special/db_swap_1.pass.cpp

libcxx/trunk/test/libcxx/containers/sequences/list/list.special/db_swap_2.pass.cpp

libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp

libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp

libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp

libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp

libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp

libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp

libcxx/trunk/test/std/containers/sequences/vector/vector.special/db_swap_1.pass.cpp
Modified:
libcxx/trunk/include/list
libcxx/trunk/include/vector

libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp

libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp

libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp

libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp

libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp

libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp

libcxx/trunk/test/std/containers/sequences/vector/vector.special/swap.pass.cpp

Modified: libcxx/trunk/include/list
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/list?rev=290657=290656=290657=diff
==
--- libcxx/trunk/include/list (original)
+++ libcxx/trunk/include/list Wed Dec 28 00:06:09 2016
@@ -626,9 +626,9 @@ protected:
 
 void swap(__list_imp& __c)
 #if _LIBCPP_STD_VER >= 14
-_NOEXCEPT;
+_NOEXCEPT_DEBUG;
 #else
-_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || 
+_NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value ||
 __is_nothrow_swappable::value);
 #endif
 
@@ -669,6 +669,13 @@ private:
 void __move_assign_alloc(__list_imp&, false_type)
 _NOEXCEPT
 {}
+
+_LIBCPP_INLINE_VISIBILITY
+void __invalidate_all_iterators() {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+  __get_db()->__invalidate_all(this);
+#endif
+}
 };
 
 // Unlink nodes [__f, __l]
@@ -724,21 +731,7 @@ __list_imp<_Tp, _Alloc>::clear() _NOEXCE
 __node_alloc_traits::destroy(__na, 
_VSTD::addressof(__np->__value_));
 __node_alloc_traits::deallocate(__na, __np, 1);
 }
-#if _LIBCPP_DEBUG_LEVEL >= 2
-__c_node* __c = __get_db()->__find_c_and_lock(this);
-for (__i_node** __p = __c->end_; __p != __c->beg_; )
-{
---__p;
-const_iterator* __i = static_cast((*__p)->__i_);
-if (__i->__ptr_ != __l)
-{
-(*__p)->__c_ = nullptr;
-if (--__c->end_ != __p)
-memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
-}
-}
-__get_db()->unlock();
-#endif
+__invalidate_all_iterators();
 }
 }
 
@@ -746,9 +739,9 @@ template 
 void
 __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
 #if _LIBCPP_STD_VER >= 14
-_NOEXCEPT
+_NOEXCEPT_DEBUG
 #else
-_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || 
+_NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value ||
 __is_nothrow_swappable::value)
 #endif
 {
@@ -1002,9 +995,9 @@ public:
 _LIBCPP_INLINE_VISIBILITY
 void swap(list& __c)
 #if _LIBCPP_STD_VER >= 14
-_NOEXCEPT
+_NOEXCEPT_DEBUG
 #else
-

[libcxx] r290656 - Fix stupid build error caused by a stupid person

2016-12-27 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Dec 27 23:56:16 2016
New Revision: 290656

URL: http://llvm.org/viewvc/llvm-project?rev=290656=rev
Log:
Fix stupid build error caused by a stupid person

Modified:
libcxx/trunk/include/__debug

Modified: libcxx/trunk/include/__debug
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__debug?rev=290656=290655=290656=diff
==
--- libcxx/trunk/include/__debug (original)
+++ libcxx/trunk/include/__debug Tue Dec 27 23:56:16 2016
@@ -54,6 +54,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 struct _LIBCPP_TYPE_VIS_ONLY __libcpp_debug_info {
   _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+  __libcpp_debug_info()
+  : __file_(nullptr), __line_(-1), __pred_(nullptr), __msg_(nullptr) {}
+  _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
   __libcpp_debug_info(const char* __f, int __l, const char* __p, const char* 
__m)
 : __file_(__f), __line_(__l), __pred_(__p), __msg_(__m) {}
   const char* __file_;


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


[libcxx] r290655 - Add tests for unordered container tests and std::string

2016-12-27 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Dec 27 23:53:01 2016
New Revision: 290655

URL: http://llvm.org/viewvc/llvm-project?rev=290655=rev
Log:
Add tests for unordered container tests and std::string

Added:
libcxx/trunk/test/libcxx/debug/containers/
libcxx/trunk/test/libcxx/debug/containers/db_string.pass.cpp
libcxx/trunk/test/libcxx/debug/containers/db_unord_container_tests.pass.cpp
libcxx/trunk/test/support/debug_mode_helper.h
Modified:
libcxx/trunk/include/__hash_table
libcxx/trunk/include/string
libcxx/trunk/include/unordered_map
libcxx/trunk/test/libcxx/test/config.py

Modified: libcxx/trunk/include/__hash_table
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__hash_table?rev=290655=290654=290655=diff
==
--- libcxx/trunk/include/__hash_table (original)
+++ libcxx/trunk/include/__hash_table Tue Dec 27 23:53:01 2016
@@ -1181,7 +1181,7 @@ public:
 
 void swap(__hash_table& __u)
 #if _LIBCPP_STD_VER <= 11
-_NOEXCEPT_(
+_NOEXCEPT_DEBUG_(
 __is_nothrow_swappable::value && 
__is_nothrow_swappable::value
 && 
(!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value
   || __is_nothrow_swappable<__pointer_allocator>::value)
@@ -1189,7 +1189,7 @@ public:
   || __is_nothrow_swappable<__node_allocator>::value)
 );
 #else
- _NOEXCEPT_(__is_nothrow_swappable::value && 
__is_nothrow_swappable::value);
+ _NOEXCEPT_DEBUG_(__is_nothrow_swappable::value && 
__is_nothrow_swappable::value);
 #endif
 
 _LIBCPP_INLINE_VISIBILITY
@@ -2408,15 +2408,15 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 --size();
 #if _LIBCPP_DEBUG_LEVEL >= 2
 __c_node* __c = __get_db()->__find_c_and_lock(this);
-for (__i_node** __p = __c->end_; __p != __c->beg_; )
+for (__i_node** __dp = __c->end_; __dp != __c->beg_; )
 {
---__p;
-iterator* __i = static_cast((*__p)->__i_);
+--__dp;
+iterator* __i = static_cast((*__dp)->__i_);
 if (__i->__node_ == __cn)
 {
-(*__p)->__c_ = nullptr;
-if (--__c->end_ != __p)
-memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
+(*__dp)->__c_ = nullptr;
+if (--__c->end_ != __dp)
+memmove(__dp, __dp+1, (__c->end_ - __dp)*sizeof(__i_node*));
 }
 }
 __get_db()->unlock();
@@ -2524,7 +2524,7 @@ template ::swap(__hash_table& __u)
 #if _LIBCPP_STD_VER <= 11
-_NOEXCEPT_(
+_NOEXCEPT_DEBUG_(
 __is_nothrow_swappable::value && 
__is_nothrow_swappable::value
 && 
(!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value
   || __is_nothrow_swappable<__pointer_allocator>::value)
@@ -2532,9 +2532,13 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
   || __is_nothrow_swappable<__node_allocator>::value)
 )
 #else
-  _NOEXCEPT_(__is_nothrow_swappable::value && 
__is_nothrow_swappable::value)
+  _NOEXCEPT_DEBUG_(__is_nothrow_swappable::value && 
__is_nothrow_swappable::value)
 #endif
 {
+_LIBCPP_ASSERT(__node_traits::propagate_on_container_swap::value ||
+   this->__node_alloc() == __u.__node_alloc(),
+   "list::swap: Either propagate_on_container_swap must be 
true"
+   " or the allocators must compare equal");
 {
 __node_pointer_pointer __npp = __bucket_list_.release();
 __bucket_list_.reset(__u.__bucket_list_.release());

Modified: libcxx/trunk/include/string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=290655=290654=290655=diff
==
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Tue Dec 27 23:53:01 2016
@@ -1105,9 +1105,9 @@ public:
 _LIBCPP_INLINE_VISIBILITY
 void swap(basic_string& __str)
 #if _LIBCPP_STD_VER >= 14
-_NOEXCEPT;
+_NOEXCEPT_DEBUG;
 #else
-_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || 
+_NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value ||
 __is_nothrow_swappable::value);
 #endif
 
@@ -2996,9 +2996,9 @@ inline _LIBCPP_INLINE_VISIBILITY
 void
 basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str)
 #if _LIBCPP_STD_VER >= 14
-_NOEXCEPT
+_NOEXCEPT_DEBUG
 #else
-_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || 
+_NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value ||
 __is_nothrow_swappable::value)
 #endif
 {
@@ -3009,6 +3009,10 @@ basic_string<_CharT, _Traits, _Allocator
 __get_db()->__invalidate_all(&__str);
 __get_db()->swap(this, &__str);
 #endif
+_LIBCPP_ASSERT(
+__alloc_traits::propagate_on_container_swap::value ||
+

[libcxx] r290654 - Fix __wrap_iter in debug mode and apply _NOEXCEPT_DEBUG to it

2016-12-27 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Dec 27 23:35:32 2016
New Revision: 290654

URL: http://llvm.org/viewvc/llvm-project?rev=290654=rev
Log:
Fix __wrap_iter in debug mode and apply _NOEXCEPT_DEBUG to it

Modified:
libcxx/trunk/include/algorithm
libcxx/trunk/include/iterator

Modified: libcxx/trunk/include/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=290654=290653=290654=diff
==
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Tue Dec 27 23:35:32 2016
@@ -1681,6 +1681,20 @@ __unwrap_iter(__wrap_iter<_Tp*> __i)
 return __i.base();
 }
 
+#else
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+is_trivially_copy_assignable<_Tp>::value,
+__wrap_iter<_Tp*>
+>::type
+__unwrap_iter(__wrap_iter<_Tp*> __i)
+{
+return __i;
+}
+
 #endif  // _LIBCPP_DEBUG_LEVEL < 2
 
 template 

Modified: libcxx/trunk/include/iterator
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/iterator?rev=290654=290653=290654=diff
==
--- libcxx/trunk/include/iterator (original)
+++ libcxx/trunk/include/iterator Tue Dec 27 23:35:32 2016
@@ -1180,56 +1180,58 @@ template  class __wrap_iter
 template 
 _LIBCPP_INLINE_VISIBILITY
 bool
-operator==(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
+operator==(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) 
_NOEXCEPT_DEBUG;
 
 template 
 _LIBCPP_INLINE_VISIBILITY
 bool
-operator<(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
+operator<(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) 
_NOEXCEPT_DEBUG;
 
 template 
 _LIBCPP_INLINE_VISIBILITY
 bool
-operator!=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
+operator!=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) 
_NOEXCEPT_DEBUG;
 
 template 
 _LIBCPP_INLINE_VISIBILITY
 bool
-operator>(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
+operator>(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) 
_NOEXCEPT_DEBUG;
 
 template 
 _LIBCPP_INLINE_VISIBILITY
 bool
-operator>=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
+operator>=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) 
_NOEXCEPT_DEBUG;
 
 template 
 _LIBCPP_INLINE_VISIBILITY
 bool
-operator<=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
+operator<=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) 
_NOEXCEPT_DEBUG;
 
 #ifndef _LIBCPP_CXX03_LANG
 template 
 _LIBCPP_INLINE_VISIBILITY
 auto
-operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) 
_NOEXCEPT
+operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) 
_NOEXCEPT_DEBUG
 -> decltype(__x.base() - __y.base());
 #else
 template 
 _LIBCPP_INLINE_VISIBILITY
 typename __wrap_iter<_Iter1>::difference_type
-operator-(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
+operator-(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) 
_NOEXCEPT_DEBUG;
 #endif
 
 template 
 _LIBCPP_INLINE_VISIBILITY
 __wrap_iter<_Iter>
-operator+(typename __wrap_iter<_Iter>::difference_type, __wrap_iter<_Iter>) 
_NOEXCEPT;
+operator+(typename __wrap_iter<_Iter>::difference_type, __wrap_iter<_Iter>) 
_NOEXCEPT_DEBUG;
 
 template  _Op _LIBCPP_INLINE_VISIBILITY copy(_Ip, _Ip, 
_Op);
 template  _B2 _LIBCPP_INLINE_VISIBILITY 
copy_backward(_B1, _B1, _B2);
 template  _Op _LIBCPP_INLINE_VISIBILITY move(_Ip, _Ip, 
_Op);
 template  _B2 _LIBCPP_INLINE_VISIBILITY 
move_backward(_B1, _B1, _B2);
 
+#if _LIBCPP_DEBUG_LEVEL < 2
+
 template 
 _LIBCPP_INLINE_VISIBILITY
 typename enable_if
@@ -1239,6 +1241,19 @@ typename enable_if
 >::type
 __unwrap_iter(__wrap_iter<_Tp*>);
 
+#else
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+is_trivially_copy_assignable<_Tp>::value,
+__wrap_iter<_Tp*>
+>::type
+__unwrap_iter(__wrap_iter<_Tp*> __i);
+
+#endif
+
 template 
 class __wrap_iter
 {
@@ -1252,7 +1267,7 @@ public:
 private:
 iterator_type __i;
 public:
-_LIBCPP_INLINE_VISIBILITY __wrap_iter() _NOEXCEPT
+_LIBCPP_INLINE_VISIBILITY __wrap_iter() _NOEXCEPT_DEBUG
 #if _LIBCPP_STD_VER > 11
 : __i{}
 #endif
@@ -1262,7 +1277,7 @@ public:
 #endif
 }
 template  _LIBCPP_INLINE_VISIBILITY __wrap_iter(const 
__wrap_iter<_Up>& __u,
-typename enable_if::value>::type* = 
0) _NOEXCEPT
+typename enable_if::value>::type* = 
0) _NOEXCEPT_DEBUG
 : __i(__u.base())
 {
 #if _LIBCPP_DEBUG_LEVEL >= 2
@@ -1292,7 +1307,7 @@ public:
 __get_db()->__erase_i(this);
 }
 #endif
-_LIBCPP_INLINE_VISIBILITY reference operator*() const _NOEXCEPT
+_LIBCPP_INLINE_VISIBILITY reference operator*() const _NOEXCEPT_DEBUG
 {
 #if _LIBCPP_DEBUG_LEVEL >= 2
 

[libcxx] r290653 - Fix build errors in C++03 caused by recent debug changes

2016-12-27 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Dec 27 23:26:56 2016
New Revision: 290653

URL: http://llvm.org/viewvc/llvm-project?rev=290653=rev
Log:
Fix build errors in C++03 caused by recent debug changes

Modified:
libcxx/trunk/include/__debug
libcxx/trunk/test/libcxx/debug/debug_throw.pass.cpp

Modified: libcxx/trunk/include/__debug
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__debug?rev=290653=290652=290653=diff
==
--- libcxx/trunk/include/__debug (original)
+++ libcxx/trunk/include/__debug Tue Dec 27 23:26:56 2016
@@ -26,7 +26,7 @@
 
 #if _LIBCPP_DEBUG_LEVEL >= 1 && !defined(_LIBCPP_ASSERT)
 # define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : \
-  _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info{__FILE__, 
__LINE__, #x, m}))
+  _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, 
__LINE__, #x, m)))
 #endif
 
 #if _LIBCPP_DEBUG_LEVEL >= 2
@@ -53,6 +53,9 @@ class _LIBCPP_EXCEPTION_ABI __libcpp_deb
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 struct _LIBCPP_TYPE_VIS_ONLY __libcpp_debug_info {
+  _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+  __libcpp_debug_info(const char* __f, int __l, const char* __p, const char* 
__m)
+: __file_(__f), __line_(__l), __pred_(__p), __msg_(__m) {}
   const char* __file_;
   int __line_;
   const char* __pred_;

Modified: libcxx/trunk/test/libcxx/debug/debug_throw.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/debug/debug_throw.pass.cpp?rev=290653=290652=290653=diff
==
--- libcxx/trunk/test/libcxx/debug/debug_throw.pass.cpp (original)
+++ libcxx/trunk/test/libcxx/debug/debug_throw.pass.cpp Tue Dec 27 23:26:56 2016
@@ -29,8 +29,8 @@ int main()
   }
   {
 // test that the libc++ exception type derives from std::exception
-static_assert(std::is_base_of::value, "must be an exception");
+  >::value), "must be an exception");
   }
 }


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


[libcxx] r290652 - Fix debug mode build w/o exceptions

2016-12-27 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Dec 27 23:20:27 2016
New Revision: 290652

URL: http://llvm.org/viewvc/llvm-project?rev=290652=rev
Log:
Fix debug mode build w/o exceptions

Modified:
libcxx/trunk/include/__debug
libcxx/trunk/lib/abi/CHANGELOG.TXT
libcxx/trunk/src/debug.cpp

Modified: libcxx/trunk/include/__debug
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__debug?rev=290652=290651=290652=diff
==
--- libcxx/trunk/include/__debug (original)
+++ libcxx/trunk/include/__debug Tue Dec 27 23:20:27 2016
@@ -82,6 +82,9 @@ bool __libcpp_set_debug_function(__libcp
 
 // Setup the throwing debug handler during dynamic initialization.
 #if _LIBCPP_DEBUG_LEVEL >= 1 && defined(_LIBCPP_DEBUG_USE_EXCEPTIONS)
+# if defined(_LIBCPP_NO_EXCEPTIONS)
+#   error _LIBCPP_DEBUG_USE_EXCEPTIONS cannot be used when exceptions are 
disabled.
+# endif
 static bool __init_dummy = 
__libcpp_set_debug_function(__libcpp_throw_debug_function);
 #endif
 

Modified: libcxx/trunk/lib/abi/CHANGELOG.TXT
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/abi/CHANGELOG.TXT?rev=290652=290651=290652=diff
==
--- libcxx/trunk/lib/abi/CHANGELOG.TXT (original)
+++ libcxx/trunk/lib/abi/CHANGELOG.TXT Tue Dec 27 23:20:27 2016
@@ -16,7 +16,7 @@ New entries should be added directly bel
 Version 4.0
 ---
 
-* rTBD - Add _LIBCPP_ASSERT debug handling functions
+* r290651 - Add _LIBCPP_ASSERT debug handling functions
 
   All Platforms
   -

Modified: libcxx/trunk/src/debug.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/debug.cpp?rev=290652=290651=290652=diff
==
--- libcxx/trunk/src/debug.cpp (original)
+++ libcxx/trunk/src/debug.cpp Tue Dec 27 23:20:27 2016
@@ -41,7 +41,11 @@ _LIBCPP_NORETURN void __libcpp_abort_deb
 }
 
 _LIBCPP_NORETURN void __libcpp_throw_debug_function(__libcpp_debug_info const& 
info) {
+#ifndef _LIBCPP_NO_EXCEPTIONS
   throw __libcpp_debug_exception(info);
+#else
+  __libcpp_abort_debug_function(info);
+#endif
 }
 
 struct __libcpp_debug_exception::__libcpp_debug_exception_imp {


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


[libcxx] r290651 - Implement a throwing version of _LIBCPP_ASSERT.

2016-12-27 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Dec 27 22:58:52 2016
New Revision: 290651

URL: http://llvm.org/viewvc/llvm-project?rev=290651=rev
Log:
Implement a throwing version of _LIBCPP_ASSERT.

This patch implements changes to allow _LIBCPP_ASSERT to throw on failure
instead of aborting. The main changes needed to do this are:

1. Change _LIBCPP_ASSERT to call a handler via a replacable function pointer
   instead of calling abort directly. Additionally this patch implements two
   handler functions, one which aborts and another that throws an exception.

2. Add _NOEXCEPT_DEBUG macro for disabling noexcept spec on function which
   contain _LIBCPP_ASSERT. This is required in order to prevent assertion
   failures throwing through a noexcept function. This macro has no effect
   unless _LIBCPP_DEBUG_USE_EXCEPTIONS is defined.

Having a non-aborting _LIBCPP_ASSERT is very important to allow sane testing of
debug mode. Currently we can only have one test case per file, since the test
case will cause the program to abort. Testing debug mode this way would require
thousands of test files, most of which would be 95% boiler plate. I don't think
this is a feasible strategy. Fortunately using a throwing debug handler solves
these issues.

Additionally this patch rewrites the documentation for debug mode.

Added:
libcxx/trunk/docs/DesignDocs/DebugMode.rst
libcxx/trunk/test/libcxx/debug/
libcxx/trunk/test/libcxx/debug/debug_abort.pass.cpp
libcxx/trunk/test/libcxx/debug/debug_throw.pass.cpp
libcxx/trunk/test/libcxx/debug/debug_throw_register.pass.cpp
Removed:
libcxx/trunk/www/debug_mode.html
Modified:
libcxx/trunk/docs/UsingLibcxx.rst
libcxx/trunk/docs/index.rst
libcxx/trunk/include/__config
libcxx/trunk/include/__debug
libcxx/trunk/lib/abi/CHANGELOG.TXT
libcxx/trunk/lib/abi/x86_64-apple-darwin16.0.0.abilist
libcxx/trunk/lib/abi/x86_64-unknown-linux-gnu.abilist
libcxx/trunk/src/debug.cpp
libcxx/trunk/www/index.html

Added: libcxx/trunk/docs/DesignDocs/DebugMode.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/DesignDocs/DebugMode.rst?rev=290651=auto
==
--- libcxx/trunk/docs/DesignDocs/DebugMode.rst (added)
+++ libcxx/trunk/docs/DesignDocs/DebugMode.rst Tue Dec 27 22:58:52 2016
@@ -0,0 +1,100 @@
+==
+Debug Mode
+==
+
+.. contents::
+   :local
+
+.. _using-debug-mode:
+
+Using Debug Mode
+
+
+Libc++ provides a debug mode that enables assertions meant to detect incorrect
+usage of the standard library. By default these assertions are disabled but
+they can be enabled using the ``_LIBCPP_DEBUG`` macro.
+
+**_LIBCPP_DEBUG** Macro
+---
+
+**_LIBCPP_DEBUG**:
+  This macro is used to enable assertions and iterator debugging checks within
+  libc++. By default it is undefined.
+
+  **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_DEBUG_USE_EXCEPTIONS**:
+  When this macro is defined ``_LIBCPP_ASSERT`` failures throw
+  ``__libcpp_debug_exception`` instead of aborting. Additionally this macro
+  disables exception specifications on functions containing ``_LIBCPP_ASSERT``
+  checks. This allows assertion failures to correctly throw through these
+  functions.
+
+Handling Assertion Failures
+---
+
+When a debug assertion fails the assertion handler is called via the
+``std::__libcpp_debug_function`` function pointer. It is possible to override
+this function pointer using a different handler function. Libc++ provides two
+different assertion handlers, the default handler
+``std::__libcpp_abort_debug_handler`` which aborts the program, and
+``std::__libcpp_throw_debug_handler`` which throws an instance of
+``std::__libcpp_debug_exception``. Libc++ can be changed to use the throwing
+assertion handler as follows:
+
+.. code-block:: cpp
+
+  #define _LIBCPP_DEBUG 1
+  #include 
+  int main() {
+std::__libcpp_debug_function = std::__libcpp_throw_debug_function;
+try {
+  std::string::iterator bad_it;
+  std::string str("hello world");
+  str.insert(bad_it, '!'); // causes debug assertion
+} catch (std::__libcpp_debug_exception const&) {
+  return EXIT_SUCCESS;
+}
+return EXIT_FAILURE;
+  }
+
+Debug Mode Checks
+=
+
+Libc++'s debug mode offers two levels of checking. The first enables various
+precondition checks throughout libc++. The second additionally enables
+"iterator debugging" which checks the validity of iterators used by the 
program.
+
+Basic Checks
+
+
+These checks are enabled when ``_LIBCPP_DEBUG`` is defined to either 0 or 1.
+
+The following checks are 

[libcxxabi] r290650 - add cxa_demangle_fuzzer

2016-12-27 Thread Kostya Serebryany via cfe-commits
Author: kcc
Date: Tue Dec 27 21:28:29 2016
New Revision: 290650

URL: http://llvm.org/viewvc/llvm-project?rev=290650=rev
Log:
add cxa_demangle_fuzzer

Summary:
All easy-to-find bugs in cxa_demangle where fixed now
(https://bugs.chromium.org/p/chromium/issues/detail?id=606626)
except for one (https://llvm.org/bugs/show_bug.cgi?id=31031).
Now I'd like to properly integrate this fuzzer with the source tree
and then run the fuzzer continuously on https://github.com/google/oss-fuzz

Reviewers: compnerd, mclow.lists, mehdi_amini

Subscribers: cfe-commits, mgorny

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

Added:
libcxxabi/trunk/fuzz/
libcxxabi/trunk/fuzz/CMakeLists.txt
libcxxabi/trunk/fuzz/cxa_demangle_fuzzer.cpp
Modified:
libcxxabi/trunk/CMakeLists.txt

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=290650=290649=290650=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Tue Dec 27 21:28:29 2016
@@ -432,4 +432,5 @@ if (LIBCXXABI_STANDALONE_BUILD AND NOT L
   "available!")
 else()
   add_subdirectory(test)
+  add_subdirectory(fuzz)
 endif()

Added: libcxxabi/trunk/fuzz/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/fuzz/CMakeLists.txt?rev=290650=auto
==
--- libcxxabi/trunk/fuzz/CMakeLists.txt (added)
+++ libcxxabi/trunk/fuzz/CMakeLists.txt Tue Dec 27 21:28:29 2016
@@ -0,0 +1,11 @@
+# See http://llvm.org/docs/LibFuzzer.html
+if( LLVM_USE_SANITIZE_COVERAGE )
+  add_executable(cxa_demangle_fuzzer
+cxa_demangle_fuzzer.cpp
+../src/cxa_demangle.cpp
+)
+
+  target_link_libraries(cxa_demangle_fuzzer
+LLVMFuzzer
+)
+endif()

Added: libcxxabi/trunk/fuzz/cxa_demangle_fuzzer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/fuzz/cxa_demangle_fuzzer.cpp?rev=290650=auto
==
--- libcxxabi/trunk/fuzz/cxa_demangle_fuzzer.cpp (added)
+++ libcxxabi/trunk/fuzz/cxa_demangle_fuzzer.cpp Tue Dec 27 21:28:29 2016
@@ -0,0 +1,15 @@
+#include 
+#include 
+#include 
+#include 
+extern "C" char *
+__cxa_demangle(const char *mangled_name, char *buf, size_t *n, int *status);
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+  char *str = new char[size+1];
+  memcpy(str, data, size);
+  str[size] = 0;
+  free(__cxa_demangle(str, 0, 0, 0));
+  delete [] str;
+  return 0;
+}


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


[PATCH] D28133: add cxa_demangle_fuzzer

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

LGTM.

(I can't test because LLVM_USE_SANITIZE_COVERAGE seems broken on Darwin)


https://reviews.llvm.org/D28133



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


[PATCH] D28133: add cxa_demangle_fuzzer

2016-12-27 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc updated this revision to Diff 82571.
kcc added a comment.

remove unneeded  set(LLVM_LINK_COMPONENTS support)


https://reviews.llvm.org/D28133

Files:
  CMakeLists.txt
  fuzz/
  fuzz/CMakeLists.txt
  fuzz/cxa_demangle_fuzzer.cpp


Index: fuzz/cxa_demangle_fuzzer.cpp
===
--- /dev/null
+++ fuzz/cxa_demangle_fuzzer.cpp
@@ -0,0 +1,15 @@
+#include 
+#include 
+#include 
+#include 
+extern "C" char *
+__cxa_demangle(const char *mangled_name, char *buf, size_t *n, int *status);
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+  char *str = new char[size+1];
+  memcpy(str, data, size);
+  str[size] = 0;
+  free(__cxa_demangle(str, 0, 0, 0));
+  delete [] str;
+  return 0;
+}
Index: fuzz/CMakeLists.txt
===
--- /dev/null
+++ fuzz/CMakeLists.txt
@@ -0,0 +1,11 @@
+# See http://llvm.org/docs/LibFuzzer.html
+if( LLVM_USE_SANITIZE_COVERAGE )
+  add_executable(cxa_demangle_fuzzer
+cxa_demangle_fuzzer.cpp
+../src/cxa_demangle.cpp
+)
+
+  target_link_libraries(cxa_demangle_fuzzer
+LLVMFuzzer
+)
+endif()
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -432,4 +432,5 @@
   "available!")
 else()
   add_subdirectory(test)
+  add_subdirectory(fuzz)
 endif()


Index: fuzz/cxa_demangle_fuzzer.cpp
===
--- /dev/null
+++ fuzz/cxa_demangle_fuzzer.cpp
@@ -0,0 +1,15 @@
+#include 
+#include 
+#include 
+#include 
+extern "C" char *
+__cxa_demangle(const char *mangled_name, char *buf, size_t *n, int *status);
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+  char *str = new char[size+1];
+  memcpy(str, data, size);
+  str[size] = 0;
+  free(__cxa_demangle(str, 0, 0, 0));
+  delete [] str;
+  return 0;
+}
Index: fuzz/CMakeLists.txt
===
--- /dev/null
+++ fuzz/CMakeLists.txt
@@ -0,0 +1,11 @@
+# See http://llvm.org/docs/LibFuzzer.html
+if( LLVM_USE_SANITIZE_COVERAGE )
+  add_executable(cxa_demangle_fuzzer
+cxa_demangle_fuzzer.cpp
+../src/cxa_demangle.cpp
+)
+
+  target_link_libraries(cxa_demangle_fuzzer
+LLVMFuzzer
+)
+endif()
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -432,4 +432,5 @@
   "available!")
 else()
   add_subdirectory(test)
+  add_subdirectory(fuzz)
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28133: add cxa_demangle_fuzzer

2016-12-27 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc marked an inline comment as done.
kcc added a comment.

yes, removed.


https://reviews.llvm.org/D28133



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


r290647 - DR1315: a non-type template argument in a partial specialization is permitted

2016-12-27 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Dec 27 20:37:25 2016
New Revision: 290647

URL: http://llvm.org/viewvc/llvm-project?rev=290647=rev
Log:
DR1315: a non-type template argument in a partial specialization is permitted
to make reference to template parameters. This is only a partial
implementation; we retain the restriction that the argument must not be
type-dependent, since it's unclear how that would work given the existence of
other language rules requiring an exact type match in this context, even for
type-dependent cases (a question has been raised on the core reflector).

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/CXX/drs/dr13xx.cpp
cfe/trunk/test/CXX/temp/temp.decls/temp.class.spec/p8-0x.cpp
cfe/trunk/test/CXX/temp/temp.decls/temp.class.spec/p8-1y.cpp
cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p9-0x.cpp
cfe/trunk/test/SemaTemplate/class-template-spec.cpp
cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp
cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx11.cpp
cfe/trunk/test/SemaTemplate/temp_class_spec_neg.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
cfe/trunk/www/cxx_dr_status.html

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=290647=290646=290647=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Dec 27 20:37:25 
2016
@@ -4032,8 +4032,8 @@ def err_specialize_member_of_template :
 def err_default_arg_in_partial_spec : Error<
 "default template argument in a class template partial specialization">;
 def err_dependent_non_type_arg_in_partial_spec : Error<
-"non-type template argument depends on a template parameter of the "
-"partial specialization">;
+"type of specialized non-type template argument depends on a template "
+"parameter of the partial specialization">;
 def note_dependent_non_type_default_arg_in_partial_spec : Note<
 "template parameter is used in default argument declared here">;
 def err_dependent_typed_non_type_arg_in_partial_spec : Error<
@@ -4048,11 +4048,11 @@ def ext_partial_spec_not_more_specialize
 "more specialized than the primary template">, DefaultError,
 InGroup>;
 def note_partial_spec_not_more_specialized_than_primary : Note<"%0">;
-def warn_partial_specs_not_deducible : Warning<
+def ext_partial_specs_not_deducible : ExtWarn<
 "%select{class|variable}0 template partial specialization contains "
 "%select{a template parameter|template parameters}1 that cannot be "
 "deduced; this partial specialization will never be used">,
-InGroup>;
+DefaultError, InGroup>;
 def note_partial_spec_unused_parameter : Note<
 "non-deducible template parameter %0">;
 def err_partial_spec_ordering_ambiguous : Error<

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=290647=290646=290647=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Dec 27 20:37:25 2016
@@ -5927,6 +5927,15 @@ public:
  MultiTemplateParamsArg TemplateParameterLists,
SkipBodyInfo *SkipBody = nullptr);
 
+  bool CheckTemplatePartialSpecializationArgs(SourceLocation Loc,
+  TemplateDecl *PrimaryTemplate,
+  unsigned NumExplicitArgs,
+  ArrayRef Args);
+  void CheckTemplatePartialSpecialization(
+  ClassTemplatePartialSpecializationDecl *Partial);
+  void CheckTemplatePartialSpecialization(
+  VarTemplatePartialSpecializationDecl *Partial);
+
   Decl *ActOnTemplateDeclarator(Scope *S,
 MultiTemplateParamsArg TemplateParameterLists,
 Declarator );

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=290647=290646=290647=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Tue Dec 27 20:37:25 2016
@@ -1638,12 +1638,22 @@ struct DependencyChecker : RecursiveASTV
   typedef RecursiveASTVisitor super;
 
   unsigned Depth;
+
+  // Whether we're looking for a use of a 

[PATCH] D28133: add cxa_demangle_fuzzer

2016-12-27 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added inline comments.



Comment at: fuzz/CMakeLists.txt:3
+if( LLVM_USE_SANITIZE_COVERAGE )
+  set(LLVM_LINK_COMPONENTS support)
+

This is a dependency on libLLVMSupport right? Why is this needed?


https://reviews.llvm.org/D28133



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


[PATCH] D28133: add cxa_demangle_fuzzer

2016-12-27 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc created this revision.
kcc added reviewers: compnerd, mehdi_amini, mclow.lists.
kcc added a subscriber: cfe-commits.
Herald added a subscriber: mgorny.

All easy-to-find bugs in cxa_demangle where fixed now
(https://bugs.chromium.org/p/chromium/issues/detail?id=606626)
except for one (https://llvm.org/bugs/show_bug.cgi?id=31031).
Now I'd like to properly integrate this fuzzer with the source tree
and then run the fuzzer continuously on https://github.com/google/oss-fuzz


https://reviews.llvm.org/D28133

Files:
  CMakeLists.txt
  fuzz/
  fuzz/CMakeLists.txt
  fuzz/cxa_demangle_fuzzer.cpp


Index: fuzz/cxa_demangle_fuzzer.cpp
===
--- /dev/null
+++ fuzz/cxa_demangle_fuzzer.cpp
@@ -0,0 +1,15 @@
+#include 
+#include 
+#include 
+#include 
+extern "C" char *
+__cxa_demangle(const char *mangled_name, char *buf, size_t *n, int *status);
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+  char *str = new char[size+1];
+  memcpy(str, data, size);
+  str[size] = 0;
+  free(__cxa_demangle(str, 0, 0, 0));
+  delete [] str;
+  return 0;
+}
Index: fuzz/CMakeLists.txt
===
--- /dev/null
+++ fuzz/CMakeLists.txt
@@ -0,0 +1,13 @@
+# See http://llvm.org/docs/LibFuzzer.html
+if( LLVM_USE_SANITIZE_COVERAGE )
+  set(LLVM_LINK_COMPONENTS support)
+
+  add_executable(cxa_demangle_fuzzer
+cxa_demangle_fuzzer.cpp
+../src/cxa_demangle.cpp
+)
+
+  target_link_libraries(cxa_demangle_fuzzer
+LLVMFuzzer
+)
+endif()
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -432,4 +432,5 @@
   "available!")
 else()
   add_subdirectory(test)
+  add_subdirectory(fuzz)
 endif()


Index: fuzz/cxa_demangle_fuzzer.cpp
===
--- /dev/null
+++ fuzz/cxa_demangle_fuzzer.cpp
@@ -0,0 +1,15 @@
+#include 
+#include 
+#include 
+#include 
+extern "C" char *
+__cxa_demangle(const char *mangled_name, char *buf, size_t *n, int *status);
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+  char *str = new char[size+1];
+  memcpy(str, data, size);
+  str[size] = 0;
+  free(__cxa_demangle(str, 0, 0, 0));
+  delete [] str;
+  return 0;
+}
Index: fuzz/CMakeLists.txt
===
--- /dev/null
+++ fuzz/CMakeLists.txt
@@ -0,0 +1,13 @@
+# See http://llvm.org/docs/LibFuzzer.html
+if( LLVM_USE_SANITIZE_COVERAGE )
+  set(LLVM_LINK_COMPONENTS support)
+
+  add_executable(cxa_demangle_fuzzer
+cxa_demangle_fuzzer.cpp
+../src/cxa_demangle.cpp
+)
+
+  target_link_libraries(cxa_demangle_fuzzer
+LLVMFuzzer
+)
+endif()
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -432,4 +432,5 @@
   "available!")
 else()
   add_subdirectory(test)
+  add_subdirectory(fuzz)
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r290642 - Update test that relies on the optimizer to match new output.

2016-12-27 Thread Michael Kuperstein via cfe-commits
Author: mkuper
Date: Tue Dec 27 18:30:43 2016
New Revision: 290642

URL: http://llvm.org/viewvc/llvm-project?rev=290642=rev
Log:
Update test that relies on the optimizer to match new output.

Modified:
cfe/trunk/test/CodeGen/avx-shuffle-builtins.c

Modified: cfe/trunk/test/CodeGen/avx-shuffle-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx-shuffle-builtins.c?rev=290642=290641=290642=diff
==
--- cfe/trunk/test/CodeGen/avx-shuffle-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx-shuffle-builtins.c Tue Dec 27 18:30:43 2016
@@ -67,9 +67,7 @@ __m128
 test_mm_broadcast_ss(float const *__a) {
   // CHECK-LABEL: @test_mm_broadcast_ss
   // CHECK: insertelement <4 x float> {{.*}}, i32 0
-  // CHECK: insertelement <4 x float> {{.*}}, i32 1
-  // CHECK: insertelement <4 x float> {{.*}}, i32 2
-  // CHECK: insertelement <4 x float> {{.*}}, i32 3
+  // CHECK: shufflevector <4 x float> {{.*}}, <4 x float> undef, <4 x i32> 
zeroinitializer
   return _mm_broadcast_ss(__a);
 }
 
@@ -77,9 +75,7 @@ __m256d
 test_mm256_broadcast_sd(double const *__a) {
   // CHECK-LABEL: @test_mm256_broadcast_sd
   // CHECK: insertelement <4 x double> {{.*}}, i32 0
-  // CHECK: insertelement <4 x double> {{.*}}, i32 1
-  // CHECK: insertelement <4 x double> {{.*}}, i32 2
-  // CHECK: insertelement <4 x double> {{.*}}, i32 3
+  // CHECK: shufflevector <4 x double> {{.*}}, <4 x double> undef, <4 x i32> 
zeroinitializer
   return _mm256_broadcast_sd(__a);
 }
 
@@ -87,13 +83,7 @@ __m256
 test_mm256_broadcast_ss(float const *__a) {
   // CHECK-LABEL: @test_mm256_broadcast_ss
   // CHECK: insertelement <8 x float> {{.*}}, i32 0
-  // CHECK: insertelement <8 x float> {{.*}}, i32 1
-  // CHECK: insertelement <8 x float> {{.*}}, i32 2
-  // CHECK: insertelement <8 x float> {{.*}}, i32 3
-  // CHECK: insertelement <8 x float> {{.*}}, i32 4
-  // CHECK: insertelement <8 x float> {{.*}}, i32 5
-  // CHECK: insertelement <8 x float> {{.*}}, i32 6
-  // CHECK: insertelement <8 x float> {{.*}}, i32 7
+  // CHECK: shufflevector <8 x float> {{.*}}, <8 x float> undef, <8 x i32> 
zeroinitializer
   return _mm256_broadcast_ss(__a);
 }
 


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


Re: r290533 - Driver: warn on -fPIC/-fpic/-fPIE/-fpie on Windows

2016-12-27 Thread Joerg Sonnenberger via cfe-commits
On Tue, Dec 27, 2016 at 12:41:08PM -0800, Saleem Abdulrasool wrote:
> Id really rather not change the behavior.  We would generate ELF style PIC,
> which obviously doesn't work.

That's not what I mean. I simply say that we should ignore
-fPIC/-fpic/-fPIE/-fpie on Windows, silently. The relality is that the
majority of the code triggering the warning wants to created PIC, which
is the default. So creating a warning for that seems silly at best.

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


[PATCH] D28131: [libcxx] Fix PR31402: map::__find_equal_key has undefined behavior.

2016-12-27 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.
EricWF added reviewers: mclow.lists, vsk.
EricWF added a subscriber: cfe-commits.

This patch fixes llvm.org/PR31402 by replacing `map::__find_equal_key` with 
`__tree::__find_equal`, which has already addressed the same undefined behavior.

Unfortunately I haven't been able to write a test case which causes the UBSAN 
diagnostic mentioned in the bug report. I can write tests which exercise the UB 
but for some reason they do not cause UBSAN to fail. Any help writing a test 
case would be appreciated.


https://reviews.llvm.org/D28131

Files:
  include/__tree
  include/map

Index: include/map
===
--- include/map
+++ include/map
@@ -533,7 +533,7 @@
 using _VSTD::swap;
 swap(comp, __y.comp);
 }
-
+
 #if _LIBCPP_STD_VER > 11
 template 
 _LIBCPP_INLINE_VISIBILITY
@@ -730,7 +730,7 @@
 friend _LIBCPP_INLINE_VISIBILITY
 bool operator==(const __map_iterator& __x, const __map_iterator& __y)
 {return __x.__i_ == __y.__i_;}
-friend 
+friend
 _LIBCPP_INLINE_VISIBILITY
 bool operator!=(const __map_iterator& __x, const __map_iterator& __y)
 {return __x.__i_ != __y.__i_;}
@@ -895,7 +895,7 @@
 
 #if _LIBCPP_STD_VER > 11
 template 
-_LIBCPP_INLINE_VISIBILITY 
+_LIBCPP_INLINE_VISIBILITY
 map(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
 : map(__f, __l, key_compare(), __a) {}
 #endif
@@ -961,7 +961,7 @@
 }
 
 #if _LIBCPP_STD_VER > 11
-_LIBCPP_INLINE_VISIBILITY 
+_LIBCPP_INLINE_VISIBILITY
 map(initializer_list __il, const allocator_type& __a)
 : map(__il, key_compare(), __a) {}
 #endif
@@ -1297,72 +1297,17 @@
 typedef typename __base::__node_allocator  __node_allocator;
 typedef typename __base::__node_pointer__node_pointer;
 typedef typename __base::__node_base_pointer   __node_base_pointer;
+typedef typename __base::__parent_pointer  __parent_pointer;
 
 typedef __map_node_destructor<__node_allocator> _Dp;
 typedef unique_ptr<__node, _Dp> __node_holder;
 
 #ifdef _LIBCPP_CXX03_LANG
 __node_holder __construct_node_with_key(const key_type& __k);
 #endif
-
-__node_base_pointer const&
-__find_equal_key(__node_base_pointer& __parent, const key_type& __k) const;
-
-_LIBCPP_INLINE_VISIBILITY
-__node_base_pointer&
-__find_equal_key(__node_base_pointer& __parent, const key_type& __k) {
-map const* __const_this = this;
-return const_cast<__node_base_pointer&>(
-__const_this->__find_equal_key(__parent, __k));
-}
 };
 
 
-// Find __k
-// Set __parent to parent of null leaf and
-//return reference to null leaf iv __k does not exist.
-// If __k exists, set parent to node of __k and return reference to node of __k
-template 
-typename map<_Key, _Tp, _Compare, _Allocator>::__node_base_pointer const&
-map<_Key, _Tp, _Compare, _Allocator>::__find_equal_key(__node_base_pointer& __parent,
-   const key_type& __k) const
-{
-__node_pointer __nd = __tree_.__root();
-if (__nd != nullptr)
-{
-while (true)
-{
-if (__tree_.value_comp().key_comp()(__k, __nd->__value_.__cc.first))
-{
-if (__nd->__left_ != nullptr)
-__nd = static_cast<__node_pointer>(__nd->__left_);
-else
-{
-__parent = static_cast<__node_base_pointer>(__nd);
-return __parent->__left_;
-}
-}
-else if (__tree_.value_comp().key_comp()(__nd->__value_.__cc.first, __k))
-{
-if (__nd->__right_ != nullptr)
-__nd = static_cast<__node_pointer>(__nd->__right_);
-else
-{
-__parent = static_cast<__node_base_pointer>(__nd);
-return __parent->__right_;
-}
-}
-else
-{
-__parent = static_cast<__node_base_pointer>(__nd);
-return __parent;
-}
-}
-}
-__parent = static_cast<__node_base_pointer>(__tree_.__end_node());
-return __parent->__left_;
-}
-
 #ifndef _LIBCPP_CXX03_LANG
 
 template 
@@ -1400,8 +1345,8 @@
 _Tp&
 map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k)
 {
-__node_base_pointer __parent;
-__node_base_pointer& __child = __find_equal_key(__parent, __k);
+__parent_pointer __parent;
+__node_base_pointer& __child = __tree_.__find_equal(__parent, __k);
 __node_pointer __r = static_cast<__node_pointer>(__child);
 if (__child == nullptr)
 {
@@ -1440,8 +1385,8 @@
 _Tp&
 map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k)
 {
-__node_base_pointer __parent;
-__node_base_pointer& __child = 

[clang-tools-extra] r290633 - [clang-tidy] Make 2 checks register matchers for C++ only.

2016-12-27 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Tue Dec 27 16:14:40 2016
New Revision: 290633

URL: http://llvm.org/viewvc/llvm-project?rev=290633=rev
Log:
[clang-tidy] Make 2 checks register matchers for C++ only.

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp?rev=290633=290632=290633=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp Tue 
Dec 27 16:14:40 2016
@@ -22,6 +22,9 @@ static const char SpecialFunction[] = "S
 static const char DeletedNotPublic[] = "DeletedNotPublic";
 
 void UseEqualsDeleteCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;
+
   auto PrivateSpecialFn = cxxMethodDecl(
   isPrivate(),
   anyOf(cxxConstructorDecl(anyOf(isDefaultConstructor(),

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.cpp?rev=290633=290632=290633=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.cpp 
Tue Dec 27 16:14:40 2016
@@ -22,6 +22,9 @@ namespace tidy {
 namespace readability {
 
 void RedundantMemberInitCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;
+
   auto Construct =
   cxxConstructExpr(
   hasDeclaration(cxxConstructorDecl(hasParent(


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


r290631 - DebugInfo: Don't include size/alignment on class declarations

2016-12-27 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Tue Dec 27 16:05:35 2016
New Revision: 290631

URL: http://llvm.org/viewvc/llvm-project?rev=290631=rev
Log:
DebugInfo: Don't include size/alignment on class declarations

This seems like it must've been a leftover by accident - no tests were
backing it up & it doesn't make much sense to include size/alignment on
class declarations (it'd only be on those declarations for which the
definition was available - otherwise the size/alignment would not be
known).

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/CodeGenCXX/debug-info-class.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=290631=290630=290631=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Dec 27 16:05:35 2016
@@ -775,12 +775,6 @@ CGDebugInfo::getOrCreateRecordFwdDecl(co
   uint64_t Size = 0;
   uint32_t Align = 0;
 
-  const RecordDecl *D = RD->getDefinition();
-  if (D && D->isCompleteDefinition()) {
-Size = CGM.getContext().getTypeSize(Ty);
-Align = getDeclAlignIfRequired(D, CGM.getContext());
-  }
-
   // Create the type.
   SmallString<256> FullName = getUniqueTagTypeName(Ty, CGM, TheCU);
   llvm::DICompositeType *RetTy = DBuilder.createReplaceableCompositeType(

Modified: cfe/trunk/test/CodeGenCXX/debug-info-class.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-class.cpp?rev=290631=290630=290631=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-class.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-class.cpp Tue Dec 27 16:05:35 2016
@@ -122,6 +122,7 @@ int main(int argc, char **argv) {
 // CHECK: [[C_DTOR]] = !DISubprogram(name: "~C"
 
 // CHECK: [[D:![0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: 
"D"
+// CHECK-NOT:  size:
 // CHECK-SAME: DIFlagFwdDecl
 // CHECK-SAME: identifier: "_ZTS1D"
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "E"


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


[clang-tools-extra] r290630 - [clang-tidy] Replace dead link in modernize-pass-by-value doc

2016-12-27 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Tue Dec 27 16:01:37 2016
New Revision: 290630

URL: http://llvm.org/viewvc/llvm-project?rev=290630=rev
Log:
[clang-tidy] Replace dead link in modernize-pass-by-value doc

Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-pass-by-value.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-pass-by-value.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-pass-by-value.rst?rev=290630=290629=290630=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-pass-by-value.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-pass-by-value.rst 
Tue Dec 27 16:01:37 2016
@@ -150,7 +150,7 @@ Example:
 
   For more information about the pass-by-value idiom, read: `Want Speed? Pass 
by Value`_.
 
-  .. _Want Speed? Pass by Value: 
http://cpp-next.com/archive/2009/08/want-speed-pass-by-value/
+  .. _Want Speed? Pass by Value: 
https://web.archive.org/web/20140205194657/http://cpp-next.com/archive/2009/08/want-speed-pass-by-value/
 
 Options
 ---


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


[libcxx] r290627 - Implement P0435R1 - Resolving LWG issues for common_type

2016-12-27 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Dec 27 15:16:48 2016
New Revision: 290627

URL: http://llvm.org/viewvc/llvm-project?rev=290627=rev
Log:
Implement P0435R1 - Resolving LWG issues for common_type

Modified:
libcxx/trunk/include/type_traits

libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=290627=290626=290627=diff
==
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Tue Dec 27 15:16:48 2016
@@ -1996,10 +1996,10 @@ struct _LIBCPP_TYPE_VIS_ONLY common_type
 // bullet 3 - sizeof...(Tp) == 2
 
 template 
-struct __common_type2 {};
+struct __common_type2_imp {};
 
 template 
-struct __common_type2<_Tp, _Up,
+struct __common_type2_imp<_Tp, _Up,
 typename __void_t() : _VSTD::declval<_Up>()
 )>::type>
@@ -2009,6 +2009,16 @@ struct __common_type2<_Tp, _Up,
 )>::type type;
 };
 
+template ::type,
+  class _DUp = typename decay<_Up>::type>
+using __common_type2 =
+  typename conditional<
+is_same<_Tp, _DTp>::value && is_same<_Up, _DUp>::value,
+__common_type2_imp<_Tp, _Up>,
+common_type<_DTp, _DUp>
+  >::type;
+
 template 
 struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up>
 : __common_type2<_Tp, _Up> {};

Modified: 
libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp?rev=290627=290626=290627=diff
==
--- 
libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp
 Tue Dec 27 15:16:48 2016
@@ -12,6 +12,7 @@
 // common_type
 
 #include 
+#include 
 
 #include "test_macros.h"
 
@@ -30,6 +31,14 @@ namespace std
 {
 typedef S type;
 };
+
+template 
+struct common_type< ::S, T> {
+  typedef S type;
+};
+
+template <> struct common_type< ::S, long> {};
+template <> struct common_type {};
 }
 
 #if TEST_STD_VER >= 11
@@ -48,6 +57,172 @@ constexpr bool no_common_type_imp(long)
 template 
 using no_common_type = std::integral_constant;
 
+template 
+using Decay = typename std::decay::type;
+
+template 
+using CommonType = typename std::common_type::type;
+
+template 
+struct TernaryOpImp {
+  static_assert(std::is_same::value, "must be same");
+  static_assert(std::is_same::value, "must be same");
+  using type = typename std::decay<
+  decltype(false ? std::declval() : std::declval())
+>::type;
+};
+
+template 
+using TernaryOp = typename TernaryOpImp::type;
+
+// -- If sizeof...(T) is zero, there shall be no member type.
+void test_bullet_one() {
+  static_assert(no_common_type<>::value, "");
+}
+
+// If sizeof...(T) is one, let T0 denote the sole type constituting the pack T.
+// The member typedef-name type shall denote the same type as decay_t.
+void test_bullet_two() {
+  static_assert(std::is_same::value, "");
+  static_assert(std::is_same::value, "");
+  static_assert(std::is_same::value, "");
+  static_assert(std::is_same::value, "");
+  static_assert(std::is_same, void(*)()>::value, "");
+}
+
+template 
+void test_bullet_three_one_imp() {
+  using DT = Decay;
+  using DU = Decay;
+  static_assert(!std::is_same::value || !std::is_same::value, 
"");
+  static_assert(std::is_same, Expect>::value, "");
+  static_assert(std::is_same, Expect>::value, "");
+  static_assert(std::is_same, CommonType>::value, "");
+}
+
+// (3.3)
+// -- If sizeof...(T) is two, let the first and second types constituting T be
+//denoted by T1 and T2, respectively, and let D1 and D2 denote the same 
types
+//as decay_t and decay_t, respectively.
+// (3.3.1)
+//-- If is_same_v is false or is_same_v is false, let C
+//   denote the same type, if any, as common_type_t.
+void test_bullet_three_one() {
+  // Test that the user provided specialization of common_type is used after
+  // decaying T1.
+  {
+using T1 = S const;
+using T2 = int;
+test_bullet_three_one_imp();
+  }
+  // Test a user provided specialization that does not provide a typedef.
+  {
+using T1 = ::S const;
+using T2 = long;
+static_assert(no_common_type::value, "");
+static_assert(no_common_type::value, "");
+  }
+  // Test that the ternary operator is 

Re: r290533 - Driver: warn on -fPIC/-fpic/-fPIE/-fpie on Windows

2016-12-27 Thread Saleem Abdulrasool via cfe-commits
Id really rather not change the behavior.  We would generate ELF style PIC,
which obviously doesn't work.

On Tue, Dec 27, 2016 at 10:09 AM, Joerg Sonnenberger via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Mon, Dec 26, 2016 at 03:35:25AM -, Saleem Abdulrasool via
> cfe-commits wrote:
> > Driver: warn on -fPIC/-fpic/-fPIE/-fpie on Windows
>
> Can we please invert this behavior? Complain if the effective PIC mode
> is not level 2 and silently ignore it otherwise? I find the MinGW
> warnings to be highly annoying and verbose.
>
> Joerg
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>



-- 
Saleem Abdulrasool
compnerd (at) compnerd (dot) org
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2016-12-27 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano added a comment.

Thank you, @ioeric for your feedback!




Comment at: include/clang/Format/Format.h:862
 ///
 /// \returns FormatStyle as specified by ``StyleName``. If no style could be
 /// determined, the default is LLVM Style (see ``getLLVMStyle()``).

ioeric wrote:
> Is this still true?
No, it's not true, and I intend to update this comment. Thanks for pointing it 
out :)



Comment at: lib/Format/Format.cpp:424
 
+template  llvm::Error make_string_error(ArgTs &&... Args) {
+  return llvm::make_error(std::forward(Args)...,

ioeric wrote:
> Why do you need a template if you only use this function with one argument?
In the end, I didn't need it. But since make_error accepts variable args, I 
figured this was more flexible. I can simplify it in the end, I only pass a 
single param.



Comment at: lib/Format/Format.cpp:1890
   }
-  FormatStyle Style = getLLVMStyle();
-  Style.Language = getLanguageByFileName(FileName);
+  FormatStyle::LanguageKind Language = getLanguageByFileName(FileName);
 

ioeric wrote:
> amaiorano wrote:
> > Since we won't always return a FormatStyle, we no longer construct one 
> > here. Rather, instances are created in local scopes below when required.
> I'd probably keep the default style so that we don't need to set `Language` 
> repeatedly below.
The thing is, it made a lot of sense to have a default constructed FormatStyle 
before when we were sure to always return it. Since now we only return a Style 
under 2 specific conditions (found a config file, or did not return the 
FallbackStyle), otherwise return an error, I feel like it's more clear this 
way. But if you firmly disagree, I can go back.

To make returning the Style with current Language more clear, I could use a 
function that ties the two together and returns it (perhaps a local lambda), 
like StyleWithLanguage(Style, Language).



Comment at: lib/Format/Format.cpp:1900
+  FormatStyle FallbackStyle = getNoStyle();
+  if (!getPredefinedStyle(FallbackStyleName, Language, )) {
+return make_string_error("Invalid fallback style \"" +

ioeric wrote:
> Nit: prefer no curly brace around one liners. Same below.
Will do.



Comment at: lib/Format/Format.cpp:1901
+  if (!getPredefinedStyle(FallbackStyleName, Language, )) {
+return make_string_error("Invalid fallback style \"" +
+ FallbackStyleName.str());

ioeric wrote:
> amaiorano wrote:
> > I am unsure whether I should be returning these error strings at all. I say 
> > this because some of the functions called in this one will output to 
> > errs(), which means the caller doesn't get the full picture of what went 
> > wrong.
> > 
> > Maybe it's better to keep the original code that outputs to errs(), and 
> > just return an error code instead. Thoughts?
> I think returning an `Expected` is the right approach. I think we should 
> consider using customized format-relayed error codes (like that in the 
> `tooling::Replacements` library) to provide richer information. For example, 
> you could use customized error codes instead of 
> `llvm::inconvertibleErrorCode` when constructing a `StringError` to provide 
> additional information besides the error message. Other interfaces in the 
> format library can potentially benefit from codes as well (e.g. `ParseError` 
> can be merged). 
I agree with you, returning more specific error codes would be useful. However, 
I'm thinking we go at it incrementally. The point of this change is to have 
getStyle return when an error occurs so that we return non-zero from main, and 
more importantly, not use the fallback style when this happens. 

In that respect, what I'm wondering is whether I should just leave the errs() 
output in getStyle, and simply return an error code, or keep what I've done 
(returning StringError) as a stepping stone in the right direction - that is, 
eventually returning customized format-relayed error codes, as you say.




Comment at: lib/Tooling/Refactoring.cpp:86
 
-format::FormatStyle CurStyle = format::getStyle(Style, FilePath, "LLVM");
+   llvm::Expected FormatStyleOrError = 
format::getStyle(Style, FilePath, "LLVM");
+   if (!FormatStyleOrError) {

ioeric wrote:
> Is this indentation intended? 
No. I will definitely do a formatting pass. I'm using Visual Studio with the 
clang-format extension, which works alright, but Visual Studio fights against 
it with its own formatting. Indeed, the reason I even started contributing to 
clang-format was because I wanted to improve the VS extension. I've already 
pushed a few changes to it, and intend to do a little more to make the 
experience simpler. In any case, my next diff upload will have proper 
formatting everywhere.


https://reviews.llvm.org/D28081



___
cfe-commits 

[PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

2016-12-27 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons accepted this revision.
malcolm.parsons added a comment.

LGTM!


https://reviews.llvm.org/D27210



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


Re: r290593 - DR1495: A partial specialization is ill-formed if it is not (strictly) more

2016-12-27 Thread Richard Smith via cfe-commits
On 27 December 2016 at 10:41, Richard Smith  wrote:

> On 27 Dec 2016 1:42 am, "Chandler Carruth via cfe-commits" <
> cfe-commits@lists.llvm.org> wrote:
>
> I suspect that this commit is responsible for a regression parsing widely
> used open source packages like Eigen.
>
> See the code in Eigen here:
> https://bitbucket.org/eigen/eigen/src/e46c8246b284dea1690ac2
> 60dfe50851906138f0/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h?at=
> default=file-view-default#TensorStorage.h-38
>
> I'm not claiming this code is correct, but I'm worried about how much code
> out there looks like this... Thoughts? Could we at least temporarily put
> this DR fix behind a flag or make it a warning?
>
>
> Sure, I'll downgrade it to an ExtWarn. We should also let the Eigen folks
> know.
>

I added -Wno-invalid-partial-specialization to turn off the error in r290625.
I've left it as an error by default for now, but we can revisit that if
this shows up a lot. (We might want to split the diagnostic between the
more benign cases like that in Eigen and the cases where the partial
specialization can never be used if we do that.)


> On Tue, Dec 27, 2016 at 12:07 AM Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Tue Dec 27 01:56:27 2016
>> New Revision: 290593
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=290593=rev
>> Log:
>> DR1495: A partial specialization is ill-formed if it is not (strictly)
>> more
>> specialized than the primary template. (Put another way, if we imagine
>> there
>> were a partial specialization matching the primary template, we should
>> never
>> select it if some other partial specialization also matches.)
>>
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/include/clang/Sema/Sema.h
>> cfe/trunk/include/clang/Sema/TemplateDeduction.h
>> cfe/trunk/lib/Sema/SemaTemplate.cpp
>> cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
>> cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
>> cfe/trunk/test/CXX/drs/dr14xx.cpp
>> cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
>> cfe/trunk/test/SemaTemplate/class-template-spec.cpp
>> cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp
>> cfe/trunk/www/cxx_dr_status.html
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Basic/DiagnosticSemaKinds.td?rev=290593=290592=290593=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Dec 27
>> 01:56:27 2016
>> @@ -4043,6 +4043,10 @@ def err_partial_spec_args_match_primary_
>>  "%select{class|variable}0 template partial specialization does not "
>>  "specialize any template argument; to %select{declare|define}1 the "
>>  "primary template, remove the template argument list">;
>> +def err_partial_spec_not_more_specialized_than_primary : Error<
>> +"%select{class|variable}0 template partial specialization is not "
>> +"more specialized than the primary template">;
>> +def note_partial_spec_not_more_specialized_than_primary : Note<"%0">;
>>  def warn_partial_specs_not_deducible : Warning<
>>  "%select{class|variable}0 template partial specialization contains "
>>  "%select{a template parameter|template parameters}1 that cannot be "
>> @@ -4147,7 +4151,7 @@ def note_function_template_deduction_ins
>>"%1">;
>>  def note_deduced_template_arg_substitution_here : Note<
>>"during template argument deduction for %select{class|variable}0
>> template "
>> -  "partial specialization %1 %2">;
>> +  "%select{partial specialization |}1%2 %3">;
>>  def note_prior_template_arg_substitution : Note<
>>"while substituting prior template arguments into
>> %select{non-type|template}0"
>>" template parameter%1 %2">;
>>
>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Sema/Sema.h?rev=290593=290592=290593=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>> +++ cfe/trunk/include/clang/Sema/Sema.h Tue Dec 27 01:56:27 2016
>> @@ -6697,10 +6697,16 @@ public:
>>ClassTemplatePartialSpecializationDecl
>> *PS2,
>>SourceLocation Loc);
>>
>> +  bool isMoreSpecializedThanPrimary(ClassTemplatePartialSpecializationDecl
>> *T,
>> +sema::TemplateDeductionInfo );
>> +
>>VarTemplatePartialSpecializationDecl *getMoreSpecializedPartialSpec
>> ialization(
>>VarTemplatePartialSpecializationDecl *PS1,
>>VarTemplatePartialSpecializationDecl *PS2, SourceLocation Loc);
>>
>> +  bool 

r290625 - Add warning flag for "partial specialization is not more specialized than primary template" error (since Eigen hits it), and while I'm here also add a warning flag for "partial specializatio

2016-12-27 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Dec 27 14:03:09 2016
New Revision: 290625

URL: http://llvm.org/viewvc/llvm-project?rev=290625=rev
Log:
Add warning flag for "partial specialization is not more specialized than 
primary template" error (since Eigen hits it), and while I'm here also add a 
warning flag for "partial specialization is not usable because one or more of 
its parameters cannot be deduced" warning.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/Misc/warning-flags.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=290625=290624=290625=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Dec 27 14:03:09 
2016
@@ -4043,14 +4043,16 @@ def err_partial_spec_args_match_primary_
 "%select{class|variable}0 template partial specialization does not "
 "specialize any template argument; to %select{declare|define}1 the "
 "primary template, remove the template argument list">; 
-def err_partial_spec_not_more_specialized_than_primary : Error<
+def ext_partial_spec_not_more_specialized_than_primary : ExtWarn<
 "%select{class|variable}0 template partial specialization is not "
-"more specialized than the primary template">; 
+"more specialized than the primary template">, DefaultError,
+InGroup>;
 def note_partial_spec_not_more_specialized_than_primary : Note<"%0">;
 def warn_partial_specs_not_deducible : Warning<
 "%select{class|variable}0 template partial specialization contains "
 "%select{a template parameter|template parameters}1 that cannot be "
-"deduced; this partial specialization will never be used">;
+"deduced; this partial specialization will never be used">,
+InGroup>;
 def note_partial_spec_unused_parameter : Note<
 "non-deducible template parameter %0">;
 def err_partial_spec_ordering_ambiguous : Error<

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=290625=290624=290625=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Tue Dec 27 14:03:09 2016
@@ -2637,8 +2637,8 @@ static void checkMoreSpecializedThanPrim
 
   auto *Template = Partial->getSpecializedTemplate();
   S.Diag(Partial->getLocation(),
- diag::err_partial_spec_not_more_specialized_than_primary)
-  << /*variable template*/isa(Template);
+ diag::ext_partial_spec_not_more_specialized_than_primary)
+  << isa(Template);
 
   if (Info.hasSFINAEDiagnostic()) {
 PartialDiagnosticAt Diag = {SourceLocation(),

Modified: cfe/trunk/test/Misc/warning-flags.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/warning-flags.c?rev=290625=290624=290625=diff
==
--- cfe/trunk/test/Misc/warning-flags.c (original)
+++ cfe/trunk/test/Misc/warning-flags.c Tue Dec 27 14:03:09 2016
@@ -18,7 +18,7 @@ This test serves two purposes:
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (79):
+CHECK: Warnings without flags (78):
 CHECK-NEXT:   ext_excess_initializers
 CHECK-NEXT:   ext_excess_initializers_in_char_array_initializer
 CHECK-NEXT:   ext_expected_semi_decl_list
@@ -78,7 +78,6 @@ CHECK-NEXT:   warn_not_compound_assign
 CHECK-NEXT:   warn_objc_property_copy_missing_on_block
 CHECK-NEXT:   warn_objc_protocol_qualifier_missing_id
 CHECK-NEXT:   warn_on_superclass_use
-CHECK-NEXT:   warn_partial_specs_not_deducible
 CHECK-NEXT:   warn_pp_convert_to_positive
 CHECK-NEXT:   warn_pp_expr_overflow
 CHECK-NEXT:   warn_pp_line_decimal


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


Re: r290593 - DR1495: A partial specialization is ill-formed if it is not (strictly) more

2016-12-27 Thread Richard Smith via cfe-commits
Hi Eigen folks,

Clang (and GCC) recently implemented C++ DR 1495 (wg21.link/cwg1495), which
says that a class template partial specialization is ill-formed if it is
not more specialized than the primary template. (If we imagine the primary
template had a corresponding partial specialization, we require that the
partial specialization would always be chosen in any situation where both
match.)

This causes Clang to reject some code in Eigen:

https://bitbucket.org/eigen/eigen/src/e46c8246b284dea1690ac2
60dfe50851906138f0/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h?at=
default=file-view-default#TensorStorage.h-38

One way to fix this is:

-template
-class TensorStorage
+template
+class TensorStorage

That is, define the primary template instead of defining a partial
specialization that doesn't actually specialize anything.

On 27 December 2016 at 10:41, Richard Smith  wrote:

> On 27 Dec 2016 1:42 am, "Chandler Carruth via cfe-commits" <
> cfe-commits@lists.llvm.org> wrote:
>
> I suspect that this commit is responsible for a regression parsing widely
> used open source packages like Eigen.
>
> See the code in Eigen here:
> https://bitbucket.org/eigen/eigen/src/e46c8246b284dea1690ac2
> 60dfe50851906138f0/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h?at=
> default=file-view-default#TensorStorage.h-38
>
> I'm not claiming this code is correct, but I'm worried about how much code
> out there looks like this... Thoughts? Could we at least temporarily put
> this DR fix behind a flag or make it a warning?
>
>
> Sure, I'll downgrade it to an ExtWarn. We should also let the Eigen folks
> know.
>
> On Tue, Dec 27, 2016 at 12:07 AM Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Tue Dec 27 01:56:27 2016
>> New Revision: 290593
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=290593=rev
>> Log:
>> DR1495: A partial specialization is ill-formed if it is not (strictly)
>> more
>> specialized than the primary template. (Put another way, if we imagine
>> there
>> were a partial specialization matching the primary template, we should
>> never
>> select it if some other partial specialization also matches.)
>>
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/include/clang/Sema/Sema.h
>> cfe/trunk/include/clang/Sema/TemplateDeduction.h
>> cfe/trunk/lib/Sema/SemaTemplate.cpp
>> cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
>> cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
>> cfe/trunk/test/CXX/drs/dr14xx.cpp
>> cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
>> cfe/trunk/test/SemaTemplate/class-template-spec.cpp
>> cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp
>> cfe/trunk/www/cxx_dr_status.html
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Basic/DiagnosticSemaKinds.td?rev=290593=290592=290593=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Dec 27
>> 01:56:27 2016
>> @@ -4043,6 +4043,10 @@ def err_partial_spec_args_match_primary_
>>  "%select{class|variable}0 template partial specialization does not "
>>  "specialize any template argument; to %select{declare|define}1 the "
>>  "primary template, remove the template argument list">;
>> +def err_partial_spec_not_more_specialized_than_primary : Error<
>> +"%select{class|variable}0 template partial specialization is not "
>> +"more specialized than the primary template">;
>> +def note_partial_spec_not_more_specialized_than_primary : Note<"%0">;
>>  def warn_partial_specs_not_deducible : Warning<
>>  "%select{class|variable}0 template partial specialization contains "
>>  "%select{a template parameter|template parameters}1 that cannot be "
>> @@ -4147,7 +4151,7 @@ def note_function_template_deduction_ins
>>"%1">;
>>  def note_deduced_template_arg_substitution_here : Note<
>>"during template argument deduction for %select{class|variable}0
>> template "
>> -  "partial specialization %1 %2">;
>> +  "%select{partial specialization |}1%2 %3">;
>>  def note_prior_template_arg_substitution : Note<
>>"while substituting prior template arguments into
>> %select{non-type|template}0"
>>" template parameter%1 %2">;
>>
>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Sema/Sema.h?rev=290593=290592=290593=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>> +++ cfe/trunk/include/clang/Sema/Sema.h Tue Dec 27 01:56:27 2016
>> @@ -6697,10 +6697,16 @@ public:
>>

[libcxx] r290624 - Fix PR31481 - 3+ parameter common_type isn't SFINAE friendly

2016-12-27 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Dec 27 13:59:50 2016
New Revision: 290624

URL: http://llvm.org/viewvc/llvm-project?rev=290624=rev
Log:
Fix PR31481 - 3+ parameter common_type isn't SFINAE friendly

Modified:
libcxx/trunk/include/type_traits

libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp

Modified: libcxx/trunk/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=290624=290623=290624=diff
==
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Tue Dec 27 13:59:50 2016
@@ -2020,13 +2020,21 @@ template  struct __common_t
 template 
 struct __common_type_impl {};
 
+template 
+struct __common_type_impl<
+__common_types<_Tp, _Up>,
+typename __void_t::type>::type>
+{
+  typedef typename common_type<_Tp, _Up>::type type;
+};
+
 template 
 struct __common_type_impl<__common_types<_Tp, _Up, _Vp...>,
 typename __void_t::type>::type>
+  : __common_type_impl<
+  __common_types::type, _Vp...> >
 {
-typedef typename common_type<
-typename common_type<_Tp, _Up>::type, _Vp...
->::type type;
+
 };
 
 template 

Modified: 
libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp?rev=290624=290623=290624=diff
==
--- 
libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp
 Tue Dec 27 13:59:50 2016
@@ -33,12 +33,21 @@ namespace std
 }
 
 #if TEST_STD_VER >= 11
-template 
-struct no_common_type : std::true_type {};
+template 
+struct always_bool_imp { using type = bool; };
+template  using always_bool = typename always_bool_imp::type;
+
+template 
+constexpr auto no_common_type_imp(int)
+  -> always_bool::type>
+  { return false; }
+
+template 
+constexpr bool no_common_type_imp(long) { return true; }
+
+template 
+using no_common_type = std::integral_constant;
 
-template 
-struct no_common_type::type, void>::type> : std::false_type {};
 #endif // TEST_STD_VER >= 11
 
 int main()
@@ -93,6 +102,9 @@ int main()
 static_assert((no_common_type::value), "");
 static_assert((no_common_type::value), "");
 static_assert((no_common_type::value), "");
+static_assert((no_common_type::value), "");
+static_assert((no_common_type::value), "");
+static_assert((no_common_type::value), "");
 static_assert((no_common_type::value), "");
 #endif // TEST_STD_VER >= 11
 


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


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

2016-12-27 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: include/clang/Format/Format.h:862
 ///
 /// \returns FormatStyle as specified by ``StyleName``. If no style could be
 /// determined, the default is LLVM Style (see ``getLLVMStyle()``).

Is this still true?



Comment at: lib/Format/Format.cpp:424
 
+template  llvm::Error make_string_error(ArgTs &&... Args) {
+  return llvm::make_error(std::forward(Args)...,

Why do you need a template if you only use this function with one argument?



Comment at: lib/Format/Format.cpp:1890
   }
-  FormatStyle Style = getLLVMStyle();
-  Style.Language = getLanguageByFileName(FileName);
+  FormatStyle::LanguageKind Language = getLanguageByFileName(FileName);
 

amaiorano wrote:
> Since we won't always return a FormatStyle, we no longer construct one here. 
> Rather, instances are created in local scopes below when required.
I'd probably keep the default style so that we don't need to set `Language` 
repeatedly below.



Comment at: lib/Format/Format.cpp:1900
+  FormatStyle FallbackStyle = getNoStyle();
+  if (!getPredefinedStyle(FallbackStyleName, Language, )) {
+return make_string_error("Invalid fallback style \"" +

Nit: prefer no curly brace around one liners. Same below.



Comment at: lib/Format/Format.cpp:1901
+  if (!getPredefinedStyle(FallbackStyleName, Language, )) {
+return make_string_error("Invalid fallback style \"" +
+ FallbackStyleName.str());

amaiorano wrote:
> I am unsure whether I should be returning these error strings at all. I say 
> this because some of the functions called in this one will output to errs(), 
> which means the caller doesn't get the full picture of what went wrong.
> 
> Maybe it's better to keep the original code that outputs to errs(), and just 
> return an error code instead. Thoughts?
I think returning an `Expected` is the right approach. I think we should 
consider using customized format-relayed error codes (like that in the 
`tooling::Replacements` library) to provide richer information. For example, 
you could use customized error codes instead of `llvm::inconvertibleErrorCode` 
when constructing a `StringError` to provide additional information besides the 
error message. Other interfaces in the format library can potentially benefit 
from codes as well (e.g. `ParseError` can be merged). 



Comment at: lib/Tooling/Refactoring.cpp:86
 
-format::FormatStyle CurStyle = format::getStyle(Style, FilePath, "LLVM");
+   llvm::Expected FormatStyleOrError = 
format::getStyle(Style, FilePath, "LLVM");
+   if (!FormatStyleOrError) {

Is this indentation intended? 



Comment at: lib/Tooling/Refactoring.cpp:87
+   llvm::Expected FormatStyleOrError = 
format::getStyle(Style, FilePath, "LLVM");
+   if (!FormatStyleOrError) {
+   llvm::errs() << llvm::toString(FormatStyleOrError.takeError()) 
<< "\n";

amaiorano wrote:
> As I wrote above, by returning the string, the caller has the burden of 
> outputting the error. More importantly, getStyle may already have written 
> other errors to errs(), so I'm not sure this makes sense.
> 
> If we go with only returning error code, I suppose I'd use 
> llvm::ErrorOr as the return type.
I don't think `getStyle` should write to `errs()` if it returns an `Error`. 


https://reviews.llvm.org/D28081



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


[PATCH] D27850: [libcxx] add missing constexpr to optional::value_or

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

The changes to `` LGTM but not the ones to ``

Unfortunately libc++'s `` doesn't yet implement LFTS v2 
so all of the other non-const observers are also not constexpr in our 
implementation. I think updating `` to LFTS v2 should be 
done as a separate patch. Please back out the changes to 
`` before committing.




Comment at: 
test/std/experimental/optional/optional.object/optional.object.observe/value_or.pass.cpp:48
+if (!(std::move(opt).value_or(y) == 2)) std::abort();
+if (!(*opt == 0)) std::abort();
 }

This test doesn't compile since the non-const version of 
`std::experimental::optional::operator*()` isn't constexpr.




https://reviews.llvm.org/D27850



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


Re: [PATCH] D15075: No error for conflict between inputs\outputs and clobber list

2016-12-27 Thread Vitaly Buka via cfe-commits
Both work:

#define DECLARE_ASM_REP_MOVS(Type, Movs)
\
  template <> void asm_rep_movs(Type * dst, Type * src, size_t size)
{   \
__asm__("rep " Movs " \n\t"
   \
: "+D"(dst), "+S"(src), "+c"(size) \
: \
: "memory");  \
  }

#define DECLARE_ASM_REP_MOVS(Type, Movs)
\
  template <> void asm_rep_movs(Type * dst, Type * src, size_t size)
{   \
__asm__("rep " Movs " \n\t"
   \
: "=D"(dst), "=S"(src), "=c"(size) \
: "D"(dst), "S"(src), "c"(size) \
: "memory");  \
  }

On Tue, Dec 27, 2016 at 10:55 AM Akira Hatanaka via Phabricator <
revi...@reviews.llvm.org> wrote:

> ahatanak added a comment.
>
> I guess it doesn't build because output constraints need "=" (e.g., "=D")?
>
> Also, I think all registers ("D", "S", and "c") should be in both the
> output and input operands list. You can probably declare new variables and
> use them in the output operands  (e.g., "=D"(newDst)) or use input/output
> operands "+" (the former is simpler in this case, since you want to use the
> original values of dst and src).
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D15075
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27850: [libcxx] add missing constexpr to optional::value_or

2016-12-27 Thread S. B. Tam via Phabricator via cfe-commits
cpplearner updated this revision to Diff 82551.

https://reviews.llvm.org/D27850

Files:
  include/experimental/optional
  include/optional
  
test/std/experimental/optional/optional.object/optional.object.observe/value_or.pass.cpp
  
test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp

Index: test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp
===
--- test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp
+++ test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp
@@ -10,7 +10,7 @@
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // 
 
-// template  T optional::value_or(U&& v) &&;
+// template  constexpr T optional::value_or(U&& v) &&;
 
 #include 
 #include 
@@ -26,22 +26,22 @@
 {
 int i_;
 
-Y(int i) : i_(i) {}
+constexpr Y(int i) : i_(i) {}
 };
 
 struct X
 {
 int i_;
 
-X(int i) : i_(i) {}
-X(X&& x) : i_(x.i_) {x.i_ = 0;}
-X(const Y& y) : i_(y.i_) {}
-X(Y&& y) : i_(y.i_+1) {}
+constexpr X(int i) : i_(i) {}
+constexpr X(X&& x) : i_(x.i_) {x.i_ = 0;}
+constexpr X(const Y& y) : i_(y.i_) {}
+constexpr X(Y&& y) : i_(y.i_+1) {}
 friend constexpr bool operator==(const X& x, const X& y)
 {return x.i_ == y.i_;}
 };
 
-int main()
+constexpr int test()
 {
 {
 optional opt(in_place, 2);
@@ -65,4 +65,10 @@
 assert(std::move(opt).value_or(Y(3)) == 4);
 assert(!opt);
 }
+return 0;
+}
+
+int main()
+{
+static_assert(test() == 0);
 }
Index: test/std/experimental/optional/optional.object/optional.object.observe/value_or.pass.cpp
===
--- test/std/experimental/optional/optional.object/optional.object.observe/value_or.pass.cpp
+++ test/std/experimental/optional/optional.object/optional.object.observe/value_or.pass.cpp
@@ -10,7 +10,7 @@
 // UNSUPPORTED: c++98, c++03, c++11
 // 
 
-// template  T optional::value_or(U&& v) &&;
+// template  constexpr T optional::value_or(U&& v) &&;
 
 #include 
 #include 
@@ -24,43 +24,49 @@
 {
 int i_;
 
-Y(int i) : i_(i) {}
+constexpr Y(int i) : i_(i) {}
 };
 
 struct X
 {
 int i_;
 
-X(int i) : i_(i) {}
-X(X&& x) : i_(x.i_) {x.i_ = 0;}
-X(const Y& y) : i_(y.i_) {}
-X(Y&& y) : i_(y.i_+1) {}
+constexpr X(int i) : i_(i) {}
+constexpr X(X&& x) : i_(x.i_) {x.i_ = 0;}
+constexpr X(const Y& y) : i_(y.i_) {}
+constexpr X(Y&& y) : i_(y.i_+1) {}
 friend constexpr bool operator==(const X& x, const X& y)
 {return x.i_ == y.i_;}
 };
 
-int main()
+constexpr int test()
 {
 {
 optional opt(in_place, 2);
 Y y(3);
-assert(std::move(opt).value_or(y) == 2);
-assert(*opt == 0);
+if (!(std::move(opt).value_or(y) == 2)) std::abort();
+if (!(*opt == 0)) std::abort();
 }
 {
 optional opt(in_place, 2);
-assert(std::move(opt).value_or(Y(3)) == 2);
-assert(*opt == 0);
+if (!(std::move(opt).value_or(Y(3)) == 2)) std::abort();
+if (!(*opt == 0)) std::abort();
 }
 {
 optional opt;
 Y y(3);
-assert(std::move(opt).value_or(y) == 3);
-assert(!opt);
+if (!(std::move(opt).value_or(y) == 3)) std::abort();
+if (!(!opt)) std::abort();
 }
 {
 optional opt;
-assert(std::move(opt).value_or(Y(3)) == 4);
-assert(!opt);
+if (!(std::move(opt).value_or(Y(3)) == 4)) std::abort();
+if (!(!opt)) std::abort();
 }
+return 0;
+}
+
+int main()
+{
+static_assert(test() == 0, "");
 }
Index: include/optional
===
--- include/optional
+++ include/optional
@@ -893,7 +893,7 @@
 
 template 
 _LIBCPP_INLINE_VISIBILITY
-value_type value_or(_Up&& __v) &&
+constexpr value_type value_or(_Up&& __v) &&
 {
 static_assert(is_move_constructible_v,
   "optional::value_or: T must be move constructible");
Index: include/experimental/optional
===
--- include/experimental/optional
+++ include/experimental/optional
@@ -562,7 +562,7 @@
 
 template 
 _LIBCPP_INLINE_VISIBILITY
-value_type value_or(_Up&& __v) &&
+constexpr value_type value_or(_Up&& __v) &&
 {
 static_assert(is_move_constructible::value,
   "optional::value_or: T must be move constructible");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2016-12-27 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I think you uploaded the wrong patch on the last upload, the code looks like 
it's related to __attribute__((deprecated)) now?


https://reviews.llvm.org/D27529



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


r290619 - [DOXYGEN] Improved doxygen comments for xmmintrin.h intrinsics.

2016-12-27 Thread Ekaterina Romanova via cfe-commits
Author: kromanova
Date: Tue Dec 27 12:53:29 2016
New Revision: 290619

URL: http://llvm.org/viewvc/llvm-project?rev=290619=rev
Log:
[DOXYGEN] Improved doxygen comments for xmmintrin.h intrinsics.

Added \n commands to insert a line breaks where necessary, since one long line 
of documentation is nearly unreadable.
Formatted comments to fit into 80 chars.
In some cases added \a command in front of the parameter names to display them 
in italics.


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

Modified: cfe/trunk/lib/Headers/xmmintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/xmmintrin.h?rev=290619=290618=290619=diff
==
--- cfe/trunk/lib/Headers/xmmintrin.h (original)
+++ cfe/trunk/lib/Headers/xmmintrin.h Tue Dec 27 12:53:29 2016
@@ -341,8 +341,8 @@ _mm_min_ss(__m128 __a, __m128 __b)
   return __builtin_ia32_minss((__v4sf)__a, (__v4sf)__b);
 }
 
-/// \brief Compares two 128-bit vectors of [4 x float] and returns the
-///lesser of each pair of values.
+/// \brief Compares two 128-bit vectors of [4 x float] and returns the lesser
+///of each pair of values.
 ///
 /// \headerfile 
 ///
@@ -361,8 +361,8 @@ _mm_min_ps(__m128 __a, __m128 __b)
 }
 
 /// \brief Compares two 32-bit float values in the low-order bits of both
-///operands and returns the greater value in the low-order bits of
-///a vector [4 x float].
+///operands and returns the greater value in the low-order bits of a 
128-bit
+///vector of [4 x float].
 ///
 /// \headerfile 
 ///
@@ -699,7 +699,8 @@ _mm_cmpge_ps(__m128 __a, __m128 __b)
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VCMPNEQSS / CMPNEQSS  
instructions.
+/// This intrinsic corresponds to the  VCMPNEQSS / CMPNEQSS 
+///   instructions.
 ///
 /// \param __a
 ///A 128-bit vector of [4 x float] containing one of the operands. The 
lower
@@ -720,7 +721,8 @@ _mm_cmpneq_ss(__m128 __a, __m128 __b)
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VCMPNEQPS / CMPNEQPS  
instructions.
+/// This intrinsic corresponds to the  VCMPNEQPS / CMPNEQPS 
+///   instructions.
 ///
 /// \param __a
 ///A 128-bit vector of [4 x float].
@@ -740,7 +742,8 @@ _mm_cmpneq_ps(__m128 __a, __m128 __b)
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VCMPNLTSS / CMPNLTSS  
instructions.
+/// This intrinsic corresponds to the  VCMPNLTSS / CMPNLTSS 
+///   instructions.
 ///
 /// \param __a
 ///A 128-bit vector of [4 x float] containing one of the operands. The 
lower
@@ -762,7 +765,8 @@ _mm_cmpnlt_ss(__m128 __a, __m128 __b)
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VCMPNLTPS / CMPNLTPS  
instructions.
+/// This intrinsic corresponds to the  VCMPNLTPS / CMPNLTPS 
+///   instructions.
 ///
 /// \param __a
 ///A 128-bit vector of [4 x float].
@@ -783,7 +787,8 @@ _mm_cmpnlt_ps(__m128 __a, __m128 __b)
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VCMPNLESS / CMPNLESS  
instructions.
+/// This intrinsic corresponds to the  VCMPNLESS / CMPNLESS 
+///   instructions.
 ///
 /// \param __a
 ///A 128-bit vector of [4 x float] containing one of the operands. The 
lower
@@ -805,7 +810,8 @@ _mm_cmpnle_ss(__m128 __a, __m128 __b)
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VCMPNLEPS / CMPNLEPS  
instructions.
+/// This intrinsic corresponds to the  VCMPNLEPS / CMPNLEPS 
+///   instructions.
 ///
 /// \param __a
 ///A 128-bit vector of [4 x float].
@@ -826,7 +832,8 @@ _mm_cmpnle_ps(__m128 __a, __m128 __b)
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VCMPNLTSS / CMPNLTSS  
instructions.
+/// This intrinsic corresponds to the  VCMPNLTSS / CMPNLTSS 
+///   instructions.
 ///
 /// \param __a
 ///A 128-bit vector of [4 x float] containing one of the operands. The 
lower
@@ -850,7 +857,8 @@ _mm_cmpngt_ss(__m128 __a, __m128 __b)
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VCMPNLTPS / CMPNLTPS  
instructions.
+/// This intrinsic corresponds to the  VCMPNLTPS / CMPNLTPS 
+///   instructions.
 ///
 /// \param __a
 ///A 128-bit vector of [4 x float].
@@ -871,7 +879,8 @@ _mm_cmpngt_ps(__m128 __a, __m128 __b)
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VCMPNLESS / CMPNLESS  
instructions.
+/// This intrinsic corresponds to the  VCMPNLESS / CMPNLESS 
+///   instructions.
 ///
 /// \param __a
 ///A 128-bit vector of [4 x float] containing one of the operands. The 
lower
@@ -895,7 +904,8 @@ _mm_cmpnge_ss(__m128 __a, __m128 __b)
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VCMPNLEPS / CMPNLEPS  
instructions.
+/// This intrinsic corresponds to the  VCMPNLEPS / CMPNLEPS 
+///   instructions.
 ///
 /// \param __a
 ///A 128-bit vector of [4 x float].
@@ -916,7 +926,8 @@ _mm_cmpnge_ps(__m128 __a, __m128 __b)
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to 

[PATCH] D15075: No error for conflict between inputs\outputs and clobber list

2016-12-27 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

I guess it doesn't build because output constraints need "=" (e.g., "=D")?

Also, I think all registers ("D", "S", and "c") should be in both the output 
and input operands list. You can probably declare new variables and use them in 
the output operands  (e.g., "=D"(newDst)) or use input/output operands "+" (the 
former is simpler in this case, since you want to use the original values of 
dst and src).


Repository:
  rL LLVM

https://reviews.llvm.org/D15075



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


[PATCH] D27850: [libcxx] add missing constexpr to optional::value_or

2016-12-27 Thread S. B. Tam via Phabricator via cfe-commits
cpplearner updated this revision to Diff 82549.
cpplearner added a comment.

test updated


https://reviews.llvm.org/D27850

Files:
  
test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp


Index: 
test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp
===
--- 
test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp
+++ 
test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp
@@ -26,22 +26,22 @@
 {
 int i_;
 
-Y(int i) : i_(i) {}
+constexpr Y(int i) : i_(i) {}
 };
 
 struct X
 {
 int i_;
 
-X(int i) : i_(i) {}
-X(X&& x) : i_(x.i_) {x.i_ = 0;}
-X(const Y& y) : i_(y.i_) {}
-X(Y&& y) : i_(y.i_+1) {}
+constexpr X(int i) : i_(i) {}
+constexpr X(X&& x) : i_(x.i_) {x.i_ = 0;}
+constexpr X(const Y& y) : i_(y.i_) {}
+constexpr X(Y&& y) : i_(y.i_+1) {}
 friend constexpr bool operator==(const X& x, const X& y)
 {return x.i_ == y.i_;}
 };
 
-int main()
+constexpr int test()
 {
 {
 optional opt(in_place, 2);
@@ -65,4 +65,10 @@
 assert(std::move(opt).value_or(Y(3)) == 4);
 assert(!opt);
 }
+return 0;
+}
+
+int main()
+{
+static_assert(test() == 0);
 }


Index: test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp
===
--- test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp
+++ test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp
@@ -26,22 +26,22 @@
 {
 int i_;
 
-Y(int i) : i_(i) {}
+constexpr Y(int i) : i_(i) {}
 };
 
 struct X
 {
 int i_;
 
-X(int i) : i_(i) {}
-X(X&& x) : i_(x.i_) {x.i_ = 0;}
-X(const Y& y) : i_(y.i_) {}
-X(Y&& y) : i_(y.i_+1) {}
+constexpr X(int i) : i_(i) {}
+constexpr X(X&& x) : i_(x.i_) {x.i_ = 0;}
+constexpr X(const Y& y) : i_(y.i_) {}
+constexpr X(Y&& y) : i_(y.i_+1) {}
 friend constexpr bool operator==(const X& x, const X& y)
 {return x.i_ == y.i_;}
 };
 
-int main()
+constexpr int test()
 {
 {
 optional opt(in_place, 2);
@@ -65,4 +65,10 @@
 assert(std::move(opt).value_or(Y(3)) == 4);
 assert(!opt);
 }
+return 0;
+}
+
+int main()
+{
+static_assert(test() == 0);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r290593 - DR1495: A partial specialization is ill-formed if it is not (strictly) more

2016-12-27 Thread Richard Smith via cfe-commits
On 27 Dec 2016 1:42 am, "Chandler Carruth via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

I suspect that this commit is responsible for a regression parsing widely
used open source packages like Eigen.

See the code in Eigen here:
https://bitbucket.org/eigen/eigen/src/e46c8246b284dea1690ac260dfe508
51906138f0/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h?at=default&
fileviewer=file-view-default#TensorStorage.h-38

I'm not claiming this code is correct, but I'm worried about how much code
out there looks like this... Thoughts? Could we at least temporarily put
this DR fix behind a flag or make it a warning?


Sure, I'll downgrade it to an ExtWarn. We should also let the Eigen folks
know.

On Tue, Dec 27, 2016 at 12:07 AM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Tue Dec 27 01:56:27 2016
> New Revision: 290593
>
> URL: http://llvm.org/viewvc/llvm-project?rev=290593=rev
> Log:
> DR1495: A partial specialization is ill-formed if it is not (strictly) more
> specialized than the primary template. (Put another way, if we imagine
> there
> were a partial specialization matching the primary template, we should
> never
> select it if some other partial specialization also matches.)
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/include/clang/Sema/TemplateDeduction.h
> cfe/trunk/lib/Sema/SemaTemplate.cpp
> cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
> cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
> cfe/trunk/test/CXX/drs/dr14xx.cpp
> cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
> cfe/trunk/test/SemaTemplate/class-template-spec.cpp
> cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp
> cfe/trunk/www/cxx_dr_status.html
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/
> DiagnosticSemaKinds.td?rev=290593=290592=290593=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Dec 27
> 01:56:27 2016
> @@ -4043,6 +4043,10 @@ def err_partial_spec_args_match_primary_
>  "%select{class|variable}0 template partial specialization does not "
>  "specialize any template argument; to %select{declare|define}1 the "
>  "primary template, remove the template argument list">;
> +def err_partial_spec_not_more_specialized_than_primary : Error<
> +"%select{class|variable}0 template partial specialization is not "
> +"more specialized than the primary template">;
> +def note_partial_spec_not_more_specialized_than_primary : Note<"%0">;
>  def warn_partial_specs_not_deducible : Warning<
>  "%select{class|variable}0 template partial specialization contains "
>  "%select{a template parameter|template parameters}1 that cannot be "
> @@ -4147,7 +4151,7 @@ def note_function_template_deduction_ins
>"%1">;
>  def note_deduced_template_arg_substitution_here : Note<
>"during template argument deduction for %select{class|variable}0
> template "
> -  "partial specialization %1 %2">;
> +  "%select{partial specialization |}1%2 %3">;
>  def note_prior_template_arg_substitution : Note<
>"while substituting prior template arguments into
> %select{non-type|template}0"
>" template parameter%1 %2">;
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Sema/Sema.h?rev=290593=290592=290593=diff
> 
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Tue Dec 27 01:56:27 2016
> @@ -6697,10 +6697,16 @@ public:
>ClassTemplatePartialSpecializationDecl
> *PS2,
>SourceLocation Loc);
>
> +  bool isMoreSpecializedThanPrimary(ClassTemplatePartialSpecializationDecl
> *T,
> +sema::TemplateDeductionInfo );
> +
>VarTemplatePartialSpecializationDecl *getMoreSpecializedPartialSpeci
> alization(
>VarTemplatePartialSpecializationDecl *PS1,
>VarTemplatePartialSpecializationDecl *PS2, SourceLocation Loc);
>
> +  bool isMoreSpecializedThanPrimary(VarTemplatePartialSpecializationDecl
> *T,
> +sema::TemplateDeductionInfo );
> +
>void MarkUsedTemplateParameters(const TemplateArgumentList
> ,
>bool OnlyDeduced,
>unsigned Depth,
> @@ -6752,7 +6758,7 @@ public:
>/// template argument deduction for either a class template
>/// partial specialization or a function template. The
>/// Entity is either a {Class|Var}TemplatePartialSpecializationDecl
> or

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

2016-12-27 Thread Arpith Jacob via Phabricator via cfe-commits
arpith-jacob created this revision.
arpith-jacob added reviewers: ABataev, sfantao, carlo.bertolli, kkwli0, caomhin.
arpith-jacob added a subscriber: cfe-commits.
Herald added subscribers: aprantl, jholewinski.

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

This allows codegen for generic target directives and serial execution on
the device.


https://reviews.llvm.org/D28125

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

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

[PATCH] D15075: No error for conflict between inputs\outputs and clobber list

2016-12-27 Thread Marina Yatsina via Phabricator via cfe-commits
myatsina added a comment.

In https://reviews.llvm.org/D15075#631316, @ahatanak wrote:

> In https://reviews.llvm.org/D15075#631237, @myatsina wrote:
>
> > In https://reviews.llvm.org/D15075#631207, @vitalybuka wrote:
> >
> > > These patches break asan tests: 
> > > http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/528/steps/check-asan%20in%20gcc%20build/logs/stdio
> >
> >
> > Vitaly ,
> >
> > This patch is a gcc compatibility issue and it changes clang to output an 
> > error in case of illegal inline assembly syntax related to clobber list.
> >
> > Commit r290540 changed an asan test (asan_asm_test.cc) that used the 
> > illegal syntax and fixed it.
> >  The commit removed from the extended inline assembly clobber list 
> > registers that also appeared in the  input list.
> >  GCC fails as well on the original inline assembly that appeared in this 
> > test, so the fix is correct.
> >  I don't understand why this change has effect the logic of the test - can 
> > you help?
> >
> > Thanks,
> > Marina
>
>
> I believe asm_rep_movs needs something in the output operand list that tells 
> the compiler the inline-asm statement changes the contents of the registers 
> ("S", "D" and "c"). Otherwise, the compiler (register allocator) will not 
> save the old value of dst_good and src_good so that it can be used later in 
> the static_assert:
>
>   asm_rep_movs(dst_good, src_good, 4);
>   ASSERT_EQ(static_cast(0x0), dst_good[0]); // "D" register was 
> incremented 4 times.
>


You are right, the "S" and "D" constraint are wrong as well in both 
DECLARE_ASM_REP_MOVS macros, the right assembly should probably be something 
like:

__asm__("rep movsb \n\t"

  : "D"(dst), "S"(src)
  : "S"(src), "c"(size)
  : "memory");

The different movs instructions change both esi/rsi and edi/rdi (movs copies 
esi to edi and then also increments/decrements both registers), so esi/rdi is 
both input and output while edi/rdi is just output.

The problem is I am not able to build the AsanSanitizer unit test and check if 
this fixes the issue.


Repository:
  rL LLVM

https://reviews.llvm.org/D15075



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


Re: r290533 - Driver: warn on -fPIC/-fpic/-fPIE/-fpie on Windows

2016-12-27 Thread Joerg Sonnenberger via cfe-commits
On Mon, Dec 26, 2016 at 03:35:25AM -, Saleem Abdulrasool via cfe-commits 
wrote:
> Driver: warn on -fPIC/-fpic/-fPIE/-fpie on Windows

Can we please invert this behavior? Complain if the effective PIC mode
is not level 2 and silently ignore it otherwise? I find the MinGW
warnings to be highly annoying and verbose.

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


[PATCH] D15075: No error for conflict between inputs\outputs and clobber list

2016-12-27 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

In https://reviews.llvm.org/D15075#631237, @myatsina wrote:

> In https://reviews.llvm.org/D15075#631207, @vitalybuka wrote:
>
> > These patches break asan tests: 
> > http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/528/steps/check-asan%20in%20gcc%20build/logs/stdio
>
>
> Vitaly ,
>
> This patch is a gcc compatibility issue and it changes clang to output an 
> error in case of illegal inline assembly syntax related to clobber list.
>
> Commit r290540 changed an asan test (asan_asm_test.cc) that used the illegal 
> syntax and fixed it.
>  The commit removed from the extended inline assembly clobber list registers 
> that also appeared in the  input list.
>  GCC fails as well on the original inline assembly that appeared in this 
> test, so the fix is correct.
>  I don't understand why this change has effect the logic of the test - can 
> you help?
>
> Thanks,
> Marina


I believe asm_rep_movs needs something in the output operand list that tells 
the compiler the inline-asm statement changes the contents of the registers 
("S", "D" and "c"). Otherwise, the compiler (register allocator) will not save 
the old value of dst_good and src_good so that it can be used later in the 
static_assert:

  asm_rep_movs(dst_good, src_good, 4);
  ASSERT_EQ(static_cast(0x0), dst_good[0]); // "D" register was incremented 
4 times.


Repository:
  rL LLVM

https://reviews.llvm.org/D15075



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


[PATCH] D28124: [OpenMP] Code cleanup for NVPTX OpenMP codegen

2016-12-27 Thread Arpith Jacob via Phabricator via cfe-commits
arpith-jacob created this revision.
arpith-jacob added reviewers: ABataev, sfantao, carlo.bertolli, kkwli0, caomhin.
arpith-jacob added a subscriber: cfe-commits.
Herald added a subscriber: jholewinski.

This patch cleans up private methods for NVPTX OpenMP codegen.  It converts 
private members to static functions to follow the coding style of 
CGOpenMPRuntime.cpp and declutter the header file.


https://reviews.llvm.org/D28124

Files:
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h

Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.h
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.h
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.h
@@ -50,38 +50,6 @@
 
 private:
   //
-  // NVPTX calls.
-  //
-
-  /// \brief Get the GPU warp size.
-  llvm::Value *getNVPTXWarpSize(CodeGenFunction );
-
-  /// \brief Get the id of the current thread on the GPU.
-  llvm::Value *getNVPTXThreadID(CodeGenFunction );
-
-  // \brief Get the maximum number of threads in a block of the GPU.
-  llvm::Value *getNVPTXNumThreads(CodeGenFunction );
-
-  /// \brief Get barrier to synchronize all threads in a block.
-  void getNVPTXCTABarrier(CodeGenFunction );
-
-  // \brief Synchronize all GPU threads in a block.
-  void syncCTAThreads(CodeGenFunction );
-
-  //
-  // OMP calls.
-  //
-
-  /// \brief Get the thread id of the OMP master thread.
-  /// The master thread id is the first thread (lane) of the last warp in the
-  /// GPU block.  Warp size is assumed to be some power of 2.
-  /// Thread id is 0 indexed.
-  /// E.g: If NumThreads is 33, master id is 32.
-  ///  If NumThreads is 64, master id is 32.
-  ///  If NumThreads is 1024, master id is 992.
-  llvm::Value *getMasterThreadID(CodeGenFunction );
-
-  //
   // Private state and methods.
   //
 
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -20,76 +20,74 @@
 using namespace clang;
 using namespace CodeGen;
 
-/// \brief Get the GPU warp size.
-llvm::Value *CGOpenMPRuntimeNVPTX::getNVPTXWarpSize(CodeGenFunction ) {
+namespace {
+enum OpenMPRTLFunctionNVPTX {
+  /// \brief Call to void __kmpc_kernel_init(kmp_int32 omp_handle,
+  /// kmp_int32 thread_limit);
+  OMPRTL_NVPTX__kmpc_kernel_init,
+};
+
+// NVPTX Address space
+enum ADDRESS_SPACE {
+  ADDRESS_SPACE_SHARED = 3,
+};
+} // namespace
+
+/// Get the GPU warp size.
+static llvm::Value *GetNVPTXWarpSize(CodeGenFunction ) {
   CGBuilderTy  = CGF.Builder;
   return Bld.CreateCall(
   llvm::Intrinsic::getDeclaration(
-  (), llvm::Intrinsic::nvvm_read_ptx_sreg_warpsize),
+  (), llvm::Intrinsic::nvvm_read_ptx_sreg_warpsize),
   llvm::None, "nvptx_warp_size");
 }
 
-/// \brief Get the id of the current thread on the GPU.
-llvm::Value *CGOpenMPRuntimeNVPTX::getNVPTXThreadID(CodeGenFunction ) {
+/// Get the id of the current thread on the GPU.
+static llvm::Value *GetNVPTXThreadID(CodeGenFunction ) {
   CGBuilderTy  = CGF.Builder;
   return Bld.CreateCall(
   llvm::Intrinsic::getDeclaration(
-  (), llvm::Intrinsic::nvvm_read_ptx_sreg_tid_x),
+  (), llvm::Intrinsic::nvvm_read_ptx_sreg_tid_x),
   llvm::None, "nvptx_tid");
 }
 
-// \brief Get the maximum number of threads in a block of the GPU.
-llvm::Value *CGOpenMPRuntimeNVPTX::getNVPTXNumThreads(CodeGenFunction ) {
+/// Get the maximum number of threads in a block of the GPU.
+static llvm::Value *GetNVPTXNumThreads(CodeGenFunction ) {
   CGBuilderTy  = CGF.Builder;
   return Bld.CreateCall(
   llvm::Intrinsic::getDeclaration(
-  (), llvm::Intrinsic::nvvm_read_ptx_sreg_ntid_x),
+  (), llvm::Intrinsic::nvvm_read_ptx_sreg_ntid_x),
   llvm::None, "nvptx_num_threads");
 }
 
-/// \brief Get barrier to synchronize all threads in a block.
-void CGOpenMPRuntimeNVPTX::getNVPTXCTABarrier(CodeGenFunction ) {
+/// Get barrier to synchronize all threads in a block.
+static void GetNVPTXCTABarrier(CodeGenFunction ) {
   CGBuilderTy  = CGF.Builder;
   Bld.CreateCall(llvm::Intrinsic::getDeclaration(
-  (), llvm::Intrinsic::nvvm_barrier0));
+  (), llvm::Intrinsic::nvvm_barrier0));
 }
 
-// \brief Synchronize all GPU threads in a block.
-void CGOpenMPRuntimeNVPTX::syncCTAThreads(CodeGenFunction ) {
-  getNVPTXCTABarrier(CGF);
-}
+/// Synchronize all GPU threads in a block.
+static void SyncCTAThreads(CodeGenFunction ) { GetNVPTXCTABarrier(CGF); }
 
-/// \brief Get the thread id of the OMP master thread.
+/// Get the thread id of the OMP master thread.
 /// The master thread id is the first thread (lane) of the last warp in the
 /// GPU block.  Warp size is assumed to be some power of 2.
 /// Thread id is 0 indexed.
 /// E.g: If NumThreads is 33, master id is 32.
 ///  If NumThreads is 64, master id is 32.
 ///  If NumThreads is 1024, master id is 992.
-llvm::Value 

[clang-tools-extra] r290605 - Attempt to fix non-determinism in tests.

2016-12-27 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Tue Dec 27 05:56:54 2016
New Revision: 290605

URL: http://llvm.org/viewvc/llvm-project?rev=290605=rev
Log:
Attempt to fix non-determinism in tests.

Modified:

clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage-strict.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage-strict.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage-strict.cpp?rev=290605=290604=290605=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage-strict.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage-strict.cpp 
Tue Dec 27 05:56:54 2016
@@ -73,7 +73,7 @@ int trigger() {
   p |= pp;
   
   enum X x = Z;
-  p = x | ZZ;
+  p = x | Z;
   return 0;
 }
 


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


[PATCH] D26167: [Clang-tidy] check for malloc, realloc and free calls

2016-12-27 Thread Kim Gräsman via Phabricator via cfe-commits
kimgr added a comment.

Minor spelling nits inline




Comment at: clang-tidy/cppcoreguidelines/NoMallocCheck.cpp:30
+  callExpr(callee(functionDecl(hasAnyName("::malloc", "::calloc"
+  .bind("aquisition"),
+  this);

Spelling nit: acquisition

But I wonder if there's a simpler word you can use for this, e.g. "alloc"



Comment at: clang-tidy/cppcoreguidelines/NoMallocCheck.cpp:47
+
+  if ((Call = Result.Nodes.getNodeAs("aquisition")))
+Recommendation = "consider a container or a smart pointer";

"aquisition" as above


Repository:
  rL LLVM

https://reviews.llvm.org/D26167



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


[clang-tools-extra] r290600 - [clang-tidy] Add enum misuse check.

2016-12-27 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Tue Dec 27 04:07:39 2016
New Revision: 290600

URL: http://llvm.org/viewvc/llvm-project?rev=290600=rev
Log:
[clang-tidy] Add enum misuse check.

The checker detects various cases when an enum is probably misused
(as a bitmask).

Patch by: Peter Szecsi!

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

Added:
clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-suspicious-enum-usage.rst

clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage-strict.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=290600=290599=290600=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Tue Dec 27 04:07:39 
2016
@@ -31,6 +31,7 @@ add_clang_library(clangTidyMiscModule
   StringConstructorCheck.cpp
   StringIntegerAssignmentCheck.cpp
   StringLiteralWithEmbeddedNulCheck.cpp
+  SuspiciousEnumUsageCheck.cpp
   SuspiciousMissingCommaCheck.cpp
   SuspiciousSemicolonCheck.cpp
   SuspiciousStringCompareCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp?rev=290600=290599=290600=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp Tue Dec 27 
04:07:39 2016
@@ -38,6 +38,7 @@
 #include "StringConstructorCheck.h"
 #include "StringIntegerAssignmentCheck.h"
 #include "StringLiteralWithEmbeddedNulCheck.h"
+#include "SuspiciousEnumUsageCheck.h"
 #include "SuspiciousMissingCommaCheck.h"
 #include "SuspiciousSemicolonCheck.h"
 #include "SuspiciousStringCompareCheck.h"
@@ -111,6 +112,8 @@ public:
 "misc-string-integer-assignment");
 CheckFactories.registerCheck(
 "misc-string-literal-with-embedded-nul");
+CheckFactories.registerCheck(
+"misc-suspicious-enum-usage");
 CheckFactories.registerCheck(
 "misc-suspicious-missing-comma");
 CheckFactories.registerCheck(

Added: clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.cpp?rev=290600=auto
==
--- clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.cpp Tue 
Dec 27 04:07:39 2016
@@ -0,0 +1,216 @@
+//===--- SuspiciousEnumUsageCheck.cpp - 
clang-tidy-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "SuspiciousEnumUsageCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+static const char DifferentEnumErrorMessage[] =
+"enum values are from different enum types";
+
+static const char BitmaskErrorMessage[] =
+"enum type seems like a bitmask (contains mostly "
+"power-of-2 literals), but this literal is not a "
+"power-of-2";
+
+static const char BitmaskVarErrorMessage[] =
+"enum type seems like a bitmask (contains mostly "
+"power-of-2 literals) but %plural{1:a literal is|:some literals are}0 not "
+"power-of-2";
+
+static const char BitmaskNoteMessage[] = "used here as a bitmask";
+
+/// Stores a min and a max value which describe an interval.
+struct ValueRange {
+  llvm::APSInt MinVal;
+  llvm::APSInt MaxVal;
+
+  ValueRange(const EnumDecl *EnumDec) {
+const auto MinMaxVal = std::minmax_element(
+EnumDec->enumerator_begin(), EnumDec->enumerator_end(),
+[](const EnumConstantDecl *E1, const EnumConstantDecl *E2) {
+  return E1->getInitVal() < E2->getInitVal();
+});
+MinVal = MinMaxVal.first->getInitVal();
+MaxVal = MinMaxVal.second->getInitVal();
+  }
+};
+
+/// Return the number of EnumConstantDecls in an EnumDecl.
+static int enumLength(const EnumDecl *EnumDec) {
+  

[PATCH] D22507: Clang-tidy - Enum misuse check

2016-12-27 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290600: [clang-tidy] Add enum misuse check. (authored by 
xazax).

Changed prior to commit:
  https://reviews.llvm.org/D22507?vs=82488=82533#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22507

Files:
  clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.cpp
  clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.h
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/misc-suspicious-enum-usage.rst
  clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage-strict.cpp
  clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage.cpp
@@ -0,0 +1,90 @@
+// RUN: %check_clang_tidy %s misc-suspicious-enum-usage %t -- -config="{CheckOptions: [{key: misc-suspicious-enum-usage.StrictMode, value: 0}]}" --
+
+enum Empty {
+};
+
+enum A {
+  A = 1,
+  B = 2,
+  C = 4,
+  D = 8,
+  E = 16,
+  F = 32,
+  G = 63
+};
+
+enum X {
+  X = 8,
+  Y = 16,
+  Z = 4
+};
+
+enum {
+  P = 2,
+  Q = 3,
+  R = 4,
+  S = 8,
+  T = 16
+};
+
+enum {
+  H,
+  I,
+  J,
+  K,
+  L
+};
+
+enum Days {
+  Monday,
+  Tuesday,
+  Wednesday,
+  Thursday,
+  Friday,
+  Saturday,
+  Sunday
+};
+
+Days bestDay() {
+  return Friday;
+}
+
+int trigger() {
+  Empty EmptyVal;
+  int emptytest = EmptyVal | B;
+  if (bestDay() | A)
+return 1;
+  // CHECK-MESSAGES: :[[@LINE-2]]:17: warning: enum values are from different enum types 
+  if (I | Y)
+return 1;
+  // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: enum values are from different enum types
+}
+
+int dont_trigger() {
+  unsigned p;
+  p = Q | P;
+
+  if (A + G == E)
+return 1;
+  else if ((Q | R) == T)
+return 1;
+  else
+int k = T | Q;
+
+  Empty EmptyVal;
+  int emptytest = EmptyVal | B;
+
+  int a = 1, b = 5;
+  int c = a + b;
+  int d = c | H, e = b * a;
+  a = B | C;
+  b = X | Z;
+  
+  if (Tuesday != Monday + 1 ||
+  Friday - Thursday != 1 ||
+  Sunday + Wednesday == (Sunday | Wednesday))
+return 1;
+  if (H + I + L == 42)
+return 1;
+  return 42;
+}
Index: clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage-strict.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage-strict.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage-strict.cpp
@@ -0,0 +1,98 @@
+// RUN: %check_clang_tidy %s misc-suspicious-enum-usage %t -- -config="{CheckOptions: [{key: misc-suspicious-enum-usage.StrictMode, value: 1}]}" --
+
+enum A {
+  A = 1,
+  B = 2,
+  C = 4,
+  D = 8,
+  E = 16,
+  F = 32,
+  G = 63
+};
+
+// CHECK-MESSAGES: :[[@LINE+2]]:1: warning: enum type seems like a bitmask (contains mostly power-of-2 literals) but a literal is not power-of-2
+// CHECK-MESSAGES: :76:7: note: used here as a bitmask
+enum X {
+  X = 8,
+  Y = 16,
+  Z = 4,
+  ZZ = 3
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: enum type seems like a bitmask (contains mostly power-of-2 literals), but this literal is not a power-of-2 [misc-suspicious-enum-usage]
+// CHECK-MESSAGES: :70:13: note: used here as a bitmask
+};
+// CHECK-MESSAGES: :[[@LINE+2]]:1: warning: enum type seems like a bitmask (contains mostly power-of-2 literals) but some literals are not power-of-2
+// CHECK-MESSAGES: :73:8: note: used here as a bitmask
+enum PP {
+  P = 2,
+  Q = 3,
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: enum type seems like a bitmask (contains mostly power-of-2 literals), but this literal is not a power-of-2
+  // CHECK-MESSAGES: :65:11: note: used here as a bitmask
+  R = 4,
+  S = 8,
+  T = 16,
+  U = 31
+};
+
+enum {
+  H,
+  I,
+  J,
+  K,
+  L
+};
+
+enum Days {
+  Monday,
+  Tuesday,
+  Wednesday,
+  Thursday,
+  Friday,
+  Saturday,
+  Sunday
+};
+
+Days bestDay() {
+  return Friday;
+}
+
+int trigger() {
+  if (bestDay() | A)
+return 1;
+  // CHECK-MESSAGES: :[[@LINE-2]]:17: warning: enum values are from different enum types
+  if (I | Y)
+return 1;
+  // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: enum values are from different enum types
+  if (P + Q == R)
+return 1;
+  else if ((Q | R) == T)
+return 1;
+  else
+int k = ZZ | Z;
+  unsigned p = R;
+  PP pp = Q;
+  p |= pp;
+  
+  enum X x = Z;
+  p = x | ZZ;
+  return 0;
+}
+
+int dont_trigger() {
+  int a = 1, b = 5;
+  int c = a + b;
+  int d = c | H, e = b * a;
+  a = B | C;
+  b = X | Z;
+
+  unsigned bitflag;
+  enum A aa = B;
+  bitflag = aa | C;
+
+  if (Tuesday != Monday + 1 ||
+  Friday - Thursday 

Re: r290593 - DR1495: A partial specialization is ill-formed if it is not (strictly) more

2016-12-27 Thread Chandler Carruth via cfe-commits
I suspect that this commit is responsible for a regression parsing widely
used open source packages like Eigen.

See the code in Eigen here:
https://bitbucket.org/eigen/eigen/src/e46c8246b284dea1690ac260dfe50851906138f0/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h?at=default=file-view-default#TensorStorage.h-38

I'm not claiming this code is correct, but I'm worried about how much code
out there looks like this... Thoughts? Could we at least temporarily put
this DR fix behind a flag or make it a warning?

On Tue, Dec 27, 2016 at 12:07 AM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Tue Dec 27 01:56:27 2016
> New Revision: 290593
>
> URL: http://llvm.org/viewvc/llvm-project?rev=290593=rev
> Log:
> DR1495: A partial specialization is ill-formed if it is not (strictly) more
> specialized than the primary template. (Put another way, if we imagine
> there
> were a partial specialization matching the primary template, we should
> never
> select it if some other partial specialization also matches.)
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/include/clang/Sema/TemplateDeduction.h
> cfe/trunk/lib/Sema/SemaTemplate.cpp
> cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
> cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
> cfe/trunk/test/CXX/drs/dr14xx.cpp
> cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
> cfe/trunk/test/SemaTemplate/class-template-spec.cpp
> cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp
> cfe/trunk/www/cxx_dr_status.html
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=290593=290592=290593=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Dec 27
> 01:56:27 2016
> @@ -4043,6 +4043,10 @@ def err_partial_spec_args_match_primary_
>  "%select{class|variable}0 template partial specialization does not "
>  "specialize any template argument; to %select{declare|define}1 the "
>  "primary template, remove the template argument list">;
> +def err_partial_spec_not_more_specialized_than_primary : Error<
> +"%select{class|variable}0 template partial specialization is not "
> +"more specialized than the primary template">;
> +def note_partial_spec_not_more_specialized_than_primary : Note<"%0">;
>  def warn_partial_specs_not_deducible : Warning<
>  "%select{class|variable}0 template partial specialization contains "
>  "%select{a template parameter|template parameters}1 that cannot be "
> @@ -4147,7 +4151,7 @@ def note_function_template_deduction_ins
>"%1">;
>  def note_deduced_template_arg_substitution_here : Note<
>"during template argument deduction for %select{class|variable}0
> template "
> -  "partial specialization %1 %2">;
> +  "%select{partial specialization |}1%2 %3">;
>  def note_prior_template_arg_substitution : Note<
>"while substituting prior template arguments into
> %select{non-type|template}0"
>" template parameter%1 %2">;
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=290593=290592=290593=diff
>
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Tue Dec 27 01:56:27 2016
> @@ -6697,10 +6697,16 @@ public:
>ClassTemplatePartialSpecializationDecl
> *PS2,
>SourceLocation Loc);
>
> +  bool
> isMoreSpecializedThanPrimary(ClassTemplatePartialSpecializationDecl *T,
> +sema::TemplateDeductionInfo );
> +
>VarTemplatePartialSpecializationDecl
> *getMoreSpecializedPartialSpecialization(
>VarTemplatePartialSpecializationDecl *PS1,
>VarTemplatePartialSpecializationDecl *PS2, SourceLocation Loc);
>
> +  bool isMoreSpecializedThanPrimary(VarTemplatePartialSpecializationDecl
> *T,
> +sema::TemplateDeductionInfo );
> +
>void MarkUsedTemplateParameters(const TemplateArgumentList
> ,
>bool OnlyDeduced,
>unsigned Depth,
> @@ -6752,7 +6758,7 @@ public:
>/// template argument deduction for either a class template
>/// partial specialization or a function template. The
>/// Entity is either a {Class|Var}TemplatePartialSpecializationDecl
> or
> -  /// a FunctionTemplateDecl.
> +  /// a TemplateDecl.
>DeducedTemplateArgumentSubstitution,
>
>/// We are substituting prior template arguments into a new
> @@ -6973,6 

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

2016-12-27 Thread Alpha Abdoulaye via Phabricator 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


[PATCH] D15075: No error for conflict between inputs\outputs and clobber list

2016-12-27 Thread Marina Yatsina via Phabricator via cfe-commits
myatsina added a comment.

In https://reviews.llvm.org/D15075#631207, @vitalybuka wrote:

> These patches break asan tests: 
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/528/steps/check-asan%20in%20gcc%20build/logs/stdio


Vitaly ,

This patch is a gcc compatibility issue and it changes clang to output an error 
in case of illegal inline assembly syntax related to clobber list.

Commit r290540 changed an asan test (asan_asm_test.cc) that used the illegal 
syntax and fixed it.
The commit removed from the extended inline assembly clobber list registers 
that also appeared in the  input list.
GCC fails as well on the original inline assembly that appeared in this test, 
so the fix is correct.
I don't understand why this change has effect the logic of the test - can you 
help?

Thanks,
Marina


Repository:
  rL LLVM

https://reviews.llvm.org/D15075



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


Re: r290577 - Add a test for `const` folding introduced by r290297. NFC.

2016-12-27 Thread Richard Smith via cfe-commits
Great, thanks!

On 26 December 2016 at 21:44, George Burgess IV  wrote:

> r290584 :)
>
> On Mon, Dec 26, 2016 at 8:30 PM, George Burgess IV <
> george.burgess...@gmail.com> wrote:
>
>> SG; working on a follow-up now. Thanks!
>>
>> On Mon, Dec 26, 2016 at 8:26 PM, Richard Smith 
>> wrote:
>>
>>> On 26 December 2016 at 20:01, George Burgess IV via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: gbiv
 Date: Mon Dec 26 22:01:22 2016
 New Revision: 290577

 URL: http://llvm.org/viewvc/llvm-project?rev=290577=rev
 Log:
 Add a test for `const` folding introduced by r290297. NFC.

 AFAICT, we didn't add a test targeted at the new "const can sometimes
 act as constexpr" behavior introduced by r290297.

 Modified:
 cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp

 Modified: cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp
 URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/c
 onstant-expression-cxx1y.cpp?rev=290577=290576=290577=diff
 
 ==
 --- cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp (original)
 +++ cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp Mon Dec 26
 22:01:22 2016
 @@ -957,3 +957,20 @@ namespace PR27989 {
}
static_assert(f(0) == 1, "");
  }
 +
 +namespace const_char {
 +template 
 +constexpr int sum(const char ()[N]) {
 +  static_assert(N >= M, "");
 +  int S = 0;
 +  for (unsigned I = 0; I != M; ++I)
 +S += Arr[I];
 +  return S;
 +}
 +
 +// As an extension, we support evaluating some things that are `const`
 as though
 +// they were `constexpr`.
 +const char Cs[] = {'a', 'b', 'c'};
 +const int N = 2;
 +static_assert(sum(Cs) == 'a' + 'b', "");
 +}
>>>
>>>
>>> Hold on, this test should fail. It's OK to extend the set of things we
>>> can constant-fold, but formal constant expression checking still needs to
>>> be strict. (You should produce a CCEDiag from within the constant
>>> expression evaluator to mark things that are not core constant expressions
>>> but are permitted as an extension.)
>>>
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r290593 - DR1495: A partial specialization is ill-formed if it is not (strictly) more

2016-12-27 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Dec 27 01:56:27 2016
New Revision: 290593

URL: http://llvm.org/viewvc/llvm-project?rev=290593=rev
Log:
DR1495: A partial specialization is ill-formed if it is not (strictly) more
specialized than the primary template. (Put another way, if we imagine there
were a partial specialization matching the primary template, we should never
select it if some other partial specialization also matches.)

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Sema/TemplateDeduction.h
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/test/CXX/drs/dr14xx.cpp
cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
cfe/trunk/test/SemaTemplate/class-template-spec.cpp
cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp
cfe/trunk/www/cxx_dr_status.html

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=290593=290592=290593=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Dec 27 01:56:27 
2016
@@ -4043,6 +4043,10 @@ def err_partial_spec_args_match_primary_
 "%select{class|variable}0 template partial specialization does not "
 "specialize any template argument; to %select{declare|define}1 the "
 "primary template, remove the template argument list">; 
+def err_partial_spec_not_more_specialized_than_primary : Error<
+"%select{class|variable}0 template partial specialization is not "
+"more specialized than the primary template">; 
+def note_partial_spec_not_more_specialized_than_primary : Note<"%0">;
 def warn_partial_specs_not_deducible : Warning<
 "%select{class|variable}0 template partial specialization contains "
 "%select{a template parameter|template parameters}1 that cannot be "
@@ -4147,7 +4151,7 @@ def note_function_template_deduction_ins
   "%1">;
 def note_deduced_template_arg_substitution_here : Note<
   "during template argument deduction for %select{class|variable}0 template "
-  "partial specialization %1 %2">;
+  "%select{partial specialization |}1%2 %3">;
 def note_prior_template_arg_substitution : Note<
   "while substituting prior template arguments into 
%select{non-type|template}0"
   " template parameter%1 %2">;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=290593=290592=290593=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Dec 27 01:56:27 2016
@@ -6697,10 +6697,16 @@ public:
   ClassTemplatePartialSpecializationDecl *PS2,
   SourceLocation Loc);
 
+  bool isMoreSpecializedThanPrimary(ClassTemplatePartialSpecializationDecl *T,
+sema::TemplateDeductionInfo );
+
   VarTemplatePartialSpecializationDecl 
*getMoreSpecializedPartialSpecialization(
   VarTemplatePartialSpecializationDecl *PS1,
   VarTemplatePartialSpecializationDecl *PS2, SourceLocation Loc);
 
+  bool isMoreSpecializedThanPrimary(VarTemplatePartialSpecializationDecl *T,
+sema::TemplateDeductionInfo );
+
   void MarkUsedTemplateParameters(const TemplateArgumentList ,
   bool OnlyDeduced,
   unsigned Depth,
@@ -6752,7 +6758,7 @@ public:
   /// template argument deduction for either a class template
   /// partial specialization or a function template. The
   /// Entity is either a {Class|Var}TemplatePartialSpecializationDecl or
-  /// a FunctionTemplateDecl.
+  /// a TemplateDecl.
   DeducedTemplateArgumentSubstitution,
 
   /// We are substituting prior template arguments into a new
@@ -6973,6 +6979,14 @@ public:
   sema::TemplateDeductionInfo ,
   SourceRange InstantiationRange = SourceRange());
 
+/// \brief Note that we are instantiating as part of template
+/// argument deduction for a class template declaration.
+InstantiatingTemplate(Sema , SourceLocation PointOfInstantiation,
+  TemplateDecl *Template,
+  ArrayRef TemplateArgs,
+  sema::TemplateDeductionInfo ,
+  SourceRange InstantiationRange = SourceRange());
+
 /// \brief Note that we are instantiating as part of template
 /// argument deduction for a class template partial
 /// specialization.

Modified: