[PATCH] D31022: Implement P0298R3: `std::byte`

2017-03-23 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists closed this revision.
mclow.lists added a comment.

Committed as revision 298689


https://reviews.llvm.org/D31022



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


[libcxx] r298689 - Implement P0298R3: 'std::byte'. Reviewed as https://reviews.llvm.org/D31022

2017-03-23 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Fri Mar 24 00:45:39 2017
New Revision: 298689

URL: http://llvm.org/viewvc/llvm-project?rev=298689=rev
Log:
Implement P0298R3: 'std::byte'. Reviewed as https://reviews.llvm.org/D31022

Added:
libcxx/trunk/test/std/language.support/support.types/byte.pass.cpp
libcxx/trunk/test/std/language.support/support.types/byteops/

libcxx/trunk/test/std/language.support/support.types/byteops/and.assign.pass.cpp
libcxx/trunk/test/std/language.support/support.types/byteops/and.pass.cpp

libcxx/trunk/test/std/language.support/support.types/byteops/lshift.assign.fail.cpp

libcxx/trunk/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp
libcxx/trunk/test/std/language.support/support.types/byteops/lshift.fail.cpp
libcxx/trunk/test/std/language.support/support.types/byteops/lshift.pass.cpp
libcxx/trunk/test/std/language.support/support.types/byteops/not.pass.cpp

libcxx/trunk/test/std/language.support/support.types/byteops/or.assign.pass.cpp
libcxx/trunk/test/std/language.support/support.types/byteops/or.pass.cpp

libcxx/trunk/test/std/language.support/support.types/byteops/rshift.assign.fail.cpp

libcxx/trunk/test/std/language.support/support.types/byteops/rshift.assign.pass.cpp
libcxx/trunk/test/std/language.support/support.types/byteops/rshift.fail.cpp
libcxx/trunk/test/std/language.support/support.types/byteops/rshift.pass.cpp

libcxx/trunk/test/std/language.support/support.types/byteops/to_integer.fail.cpp

libcxx/trunk/test/std/language.support/support.types/byteops/to_integer.pass.cpp

libcxx/trunk/test/std/language.support/support.types/byteops/xor.assign.pass.cpp
libcxx/trunk/test/std/language.support/support.types/byteops/xor.pass.cpp
Modified:
libcxx/trunk/include/cstddef
libcxx/trunk/include/type_traits
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/cstddef
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstddef?rev=298689=298688=298689=diff
==
--- libcxx/trunk/include/cstddef (original)
+++ libcxx/trunk/include/cstddef Fri Mar 24 00:45:39 2017
@@ -28,6 +28,7 @@ Types:
 size_t
 max_align_t
 nullptr_t
+byte // C++17
 
 }  // std
 
@@ -58,4 +59,32 @@ typedef long double max_align_t;
 
 _LIBCPP_END_NAMESPACE_STD
 
+#if _LIBCPP_STD_VER > 14
+namespace std  // purposefully not versioned
+{
+enum class byte : unsigned char {};
+
+constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept
+{ return __lhs = byte(static_cast(__lhs) | static_cast(__rhs)); }
+constexpr byte  operator| (byte  __lhs, byte __rhs) noexcept
+{ return byte(static_cast(__lhs) | static_cast(__rhs)); }
+
+constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept
+{ return __lhs = byte(static_cast(__lhs) & static_cast(__rhs)); }
+constexpr byte  operator& (byte  __lhs, byte __rhs) noexcept
+{ return byte(static_cast(__lhs) & static_cast(__rhs)); }
+
+constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept 
+{ return __lhs = byte(static_cast(__lhs) ^ static_cast(__rhs)); }
+constexpr byte  operator^ (byte  __lhs, byte __rhs) noexcept
+{ return byte(static_cast(__lhs) ^ static_cast(__rhs)); }
+
+constexpr byte  operator~ (byte __b) noexcept
+{ return  byte(~static_cast(__b)); }
+
+}
+
+#include   // rest of byte
+#endif
+
 #endif  // _LIBCPP_CSTDDEF

Modified: libcxx/trunk/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=298689=298688=298689=diff
==
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Fri Mar 24 00:45:39 2017
@@ -4714,4 +4714,35 @@ struct __can_extract_map_key<_ValTy, _Ke
 
 _LIBCPP_END_NAMESPACE_STD
 
+#if _LIBCPP_STD_VER > 14
+// std::byte
+namespace std  // purposefully not versioned
+{
+template 
+  constexpr typename enable_if, byte>::type &
+  operator<<=(byte& __lhs, _Integer __shift) noexcept
+  { return __lhs = byte(static_cast(__lhs) << __shift); }
+  
+template 
+  constexpr typename enable_if, byte>::type
+  operator<< (byte  __lhs, _Integer __shift) noexcept
+  { return byte(static_cast(__lhs) << __shift); }
+
+template 
+  constexpr typename enable_if, byte>::type &
+  operator>>=(byte& __lhs, _Integer __shift) noexcept
+  { return __lhs = byte(static_cast(__lhs) >> __shift); }
+
+template 
+  constexpr typename enable_if, byte>::type
+  operator>> (byte  __lhs, _Integer __shift) noexcept
+  { return byte(static_cast(__lhs) >> __shift); }
+  
+template 
+  constexpr typename enable_if, _Integer>::type
+  to_integer(byte __b) noexcept { return _Integer(__b); }
+
+}
+#endif
+
 #endif  // _LIBCPP_TYPE_TRAITS

Added: 

[PATCH] D31183: [OpenCL] Added parsing for OpenCL vector types.

2017-03-23 Thread Egor Churaev via Phabricator via cfe-commits
echuraev added a comment.

In https://reviews.llvm.org/D31183#708833, @yaxunl wrote:

> I think this is a good feature for the convenience of user. I've seen usage 
> like this.


I agree. I don't see any reasons why this case doesn't have the right to exist. 
I don't think that using extra parenthesis is a good solution for solving this 
problem.


https://reviews.llvm.org/D31183



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


[PATCH] D31166: Encapsulate FPOptions and use it consistently

2017-03-23 Thread Adam Nemet via Phabricator via cfe-commits
anemet updated this revision to Diff 92898.
anemet added a comment.

Address Aaron's comments.


https://reviews.llvm.org/D31166

Files:
  include/clang/AST/Expr.h
  include/clang/AST/ExprCXX.h
  include/clang/Basic/LangOptions.h
  include/clang/Sema/Sema.h
  lib/AST/ASTImporter.cpp
  lib/Analysis/BodyFarm.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/Frontend/Rewrite/RewriteModernObjC.cpp
  lib/Frontend/Rewrite/RewriteObjC.cpp
  lib/Sema/SemaAttr.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaPseudoObject.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/ASTWriterStmt.cpp

Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -650,7 +650,7 @@
   Record.AddStmt(E->getRHS());
   Record.push_back(E->getOpcode()); // FIXME: stable encoding
   Record.AddSourceLocation(E->getOperatorLoc());
-  Record.push_back(E->isFPContractable());
+  Record.push_back(E->getFPFeatures().getInt());
   Code = serialization::EXPR_BINARY_OPERATOR;
 }
 
@@ -1218,7 +1218,7 @@
   VisitCallExpr(E);
   Record.push_back(E->getOperator());
   Record.AddSourceRange(E->Range);
-  Record.push_back(E->isFPContractable());
+  Record.push_back(E->getFPFeatures().getInt());
   Code = serialization::EXPR_CXX_OPERATOR_CALL;
 }
 
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -4013,7 +4013,7 @@
 
 /// \brief Write an FP_PRAGMA_OPTIONS block for the given FPOptions.
 void ASTWriter::WriteFPPragmaOptions(const FPOptions ) {
-  RecordData::value_type Record[] = {Opts.fp_contract};
+  RecordData::value_type Record[] = {Opts.getInt()};
   Stream.EmitRecord(FP_PRAGMA_OPTIONS, Record);
 }
 
Index: lib/Serialization/ASTReaderStmt.cpp
===
--- lib/Serialization/ASTReaderStmt.cpp
+++ lib/Serialization/ASTReaderStmt.cpp
@@ -670,7 +670,7 @@
   E->setRHS(Record.readSubExpr());
   E->setOpcode((BinaryOperator::Opcode)Record.readInt());
   E->setOperatorLoc(ReadSourceLocation());
-  E->setFPContractable((bool)Record.readInt());
+  E->setFPFeatures(FPOptions(Record.readInt()));
 }
 
 void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
@@ -1225,7 +1225,7 @@
   VisitCallExpr(E);
   E->Operator = (OverloadedOperatorKind)Record.readInt();
   E->Range = Record.readSourceRange();
-  E->setFPContractable((bool)Record.readInt());
+  E->setFPFeatures(FPOptions(Record.readInt()));
 }
 
 void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -7367,7 +7367,7 @@
   // FIXME: What happens if these are changed by a module import?
   if (!FPPragmaOptions.empty()) {
 assert(FPPragmaOptions.size() == 1 && "Wrong number of FP_PRAGMA_OPTIONS");
-SemaObj->FPFeatures.fp_contract = FPPragmaOptions[0];
+SemaObj->FPFeatures = FPOptions(FPPragmaOptions[0]);
   }
 
   SemaObj->OpenCLFeatures.copy(OpenCLExtensions);
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -9146,7 +9146,7 @@
 return E;
 
   Sema::FPContractStateRAII FPContractState(getSema());
-  getSema().FPFeatures.fp_contract = E->isFPContractable();
+  getSema().FPFeatures = E->getFPFeatures();
 
   return getDerived().RebuildBinaryOperator(E->getOperatorLoc(), E->getOpcode(),
 LHS.get(), RHS.get());
@@ -9626,7 +9626,7 @@
 return SemaRef.MaybeBindToTemporary(E);
 
   Sema::FPContractStateRAII FPContractState(getSema());
-  getSema().FPFeatures.fp_contract = E->isFPContractable();
+  getSema().FPFeatures = E->getFPFeatures();
 
   return getDerived().RebuildCXXOperatorCallExpr(E->getOperator(),
  E->getOperatorLoc(),
Index: lib/Sema/SemaPseudoObject.cpp
===
--- lib/Sema/SemaPseudoObject.cpp
+++ lib/Sema/SemaPseudoObject.cpp
@@ -447,7 +447,8 @@
 syntactic = new (S.Context) BinaryOperator(syntacticLHS, capturedRHS,
opcode, capturedRHS->getType(),
capturedRHS->getValueKind(),
-   OK_Ordinary, opcLoc, false);
+   OK_Ordinary, opcLoc,
+   

[libcxx] r298686 - Move the scoped_lock inside the '#ifndef NO_THREADS' block to fix the no-threading build

2017-03-23 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Fri Mar 24 00:19:15 2017
New Revision: 298686

URL: http://llvm.org/viewvc/llvm-project?rev=298686=rev
Log:
Move the scoped_lock inside the '#ifndef NO_THREADS' block to fix the 
no-threading build

Modified:
libcxx/trunk/include/mutex

Modified: libcxx/trunk/include/mutex
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/mutex?rev=298686=298685=298686=diff
==
--- libcxx/trunk/include/mutex (original)
+++ libcxx/trunk/include/mutex Fri Mar 24 00:19:15 2017
@@ -468,6 +468,84 @@ void __unlock(_L0& __l0, _L1& __l1, _L2&
 
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 
+#if _LIBCPP_STD_VER > 14
+template 
+class _LIBCPP_TEMPLATE_VIS scoped_lock;
+
+template <>
+class _LIBCPP_TEMPLATE_VIS scoped_lock<> {
+public:
+explicit scoped_lock() {}
+~scoped_lock() = default;
+
+_LIBCPP_INLINE_VISIBILITY
+explicit scoped_lock(adopt_lock_t) {}
+
+scoped_lock(scoped_lock const&) = delete;
+scoped_lock& operator=(scoped_lock const&) = delete;
+};
+
+template 
+class _LIBCPP_TEMPLATE_VIS scoped_lock<_Mutex> {
+public:
+typedef _Mutex  mutex_type;
+private:
+mutex_type& __m_;
+public:
+explicit scoped_lock(mutex_type & __m) 
_LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m))
+: __m_(__m) {__m_.lock();}
+
+~scoped_lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) 
{__m_.unlock();}
+
+_LIBCPP_INLINE_VISIBILITY
+explicit scoped_lock(mutex_type& __m, adopt_lock_t) 
_LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m))
+: __m_(__m) {}
+
+
+scoped_lock(scoped_lock const&) = delete;
+scoped_lock& operator=(scoped_lock const&) = delete;
+};
+
+template 
+class _LIBCPP_TEMPLATE_VIS scoped_lock
+{
+static_assert(sizeof...(_MArgs) > 1, "At least 2 lock types required");
+typedef tuple<_MArgs&...> _MutexTuple;
+
+public:
+_LIBCPP_INLINE_VISIBILITY
+explicit scoped_lock(_MArgs&... __margs)
+  : __t_(__margs...)
+{
+_VSTD::lock(__margs...);
+}
+
+_LIBCPP_INLINE_VISIBILITY
+scoped_lock(_MArgs&... __margs, adopt_lock_t)
+: __t_(__margs...)
+{
+}
+
+_LIBCPP_INLINE_VISIBILITY
+~scoped_lock() {
+typedef typename __make_tuple_indices::type 
_Indices;
+__unlock_unpack(_Indices{}, __t_);
+}
+
+scoped_lock(scoped_lock const&) = delete;
+scoped_lock& operator=(scoped_lock const&) = delete;
+
+private:
+template 
+_LIBCPP_INLINE_VISIBILITY
+static void __unlock_unpack(__tuple_indices<_Indx...>, _MutexTuple& __mt) {
+_VSTD::__unlock(_VSTD::get<_Indx>(__mt)...);
+}
+
+_MutexTuple __t_;
+};
+
+#endif // _LIBCPP_STD_VER > 14
 #endif // !_LIBCPP_HAS_NO_THREADS
 
 struct _LIBCPP_TEMPLATE_VIS once_flag;
@@ -616,85 +694,6 @@ call_once(once_flag& __flag, const _Call
 
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 
-#if _LIBCPP_STD_VER > 14
-template 
-class _LIBCPP_TEMPLATE_VIS scoped_lock;
-
-template <>
-class _LIBCPP_TEMPLATE_VIS scoped_lock<> {
-public:
-explicit scoped_lock() {}
-~scoped_lock() = default;
-
-_LIBCPP_INLINE_VISIBILITY
-explicit scoped_lock(adopt_lock_t) {}
-
-scoped_lock(scoped_lock const&) = delete;
-scoped_lock& operator=(scoped_lock const&) = delete;
-};
-
-template 
-class _LIBCPP_TEMPLATE_VIS scoped_lock<_Mutex> {
-public:
-typedef _Mutex  mutex_type;
-private:
-mutex_type& __m_;
-public:
-explicit scoped_lock(mutex_type & __m) 
_LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m))
-: __m_(__m) {__m_.lock();}
-
-~scoped_lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) 
{__m_.unlock();}
-
-_LIBCPP_INLINE_VISIBILITY
-explicit scoped_lock(mutex_type& __m, adopt_lock_t) 
_LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m))
-: __m_(__m) {}
-
-
-scoped_lock(scoped_lock const&) = delete;
-scoped_lock& operator=(scoped_lock const&) = delete;
-};
-
-template 
-class _LIBCPP_TEMPLATE_VIS scoped_lock
-{
-static_assert(sizeof...(_MArgs) > 1, "At least 2 lock types required");
-typedef tuple<_MArgs&...> _MutexTuple;
-
-public:
-_LIBCPP_INLINE_VISIBILITY
-explicit scoped_lock(_MArgs&... __margs)
-  : __t_(__margs...)
-{
-_VSTD::lock(__margs...);
-}
-
-_LIBCPP_INLINE_VISIBILITY
-scoped_lock(_MArgs&... __margs, adopt_lock_t)
-: __t_(__margs...)
-{
-}
-
-_LIBCPP_INLINE_VISIBILITY
-~scoped_lock() {
-typedef typename __make_tuple_indices::type 
_Indices;
-__unlock_unpack(_Indices{}, __t_);
-}
-
-scoped_lock(scoped_lock const&) = delete;
-scoped_lock& operator=(scoped_lock const&) = delete;
-
-private:
-template 
-_LIBCPP_INLINE_VISIBILITY
-static void __unlock_unpack(__tuple_indices<_Indx...>, _MutexTuple& __mt) {
-_VSTD::__unlock(_VSTD::get<_Indx>(__mt)...);
-}
-
-_MutexTuple 

[PATCH] D31166: Encapsulate FPOptions and use it consistently

2017-03-23 Thread Adam Nemet via Phabricator via cfe-commits
anemet marked 3 inline comments as done.
anemet added inline comments.



Comment at: lib/CodeGen/CGExprScalar.cpp:1712
   BinOp.Opcode = IsInc ? BO_Add : BO_Sub;
-  BinOp.FPContractable = false;
+  // FIXME: once UnaryOperator carries FPFeatures, copy it here.
   BinOp.E = E;

aaron.ballman wrote:
> Why not make UnaryOperator carry this information now, since it's needed?
The trouble is that currently it's not needed.  I'd rather wait for a fast-math 
flag that actually needs it so that we can write tests.


https://reviews.llvm.org/D31166



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


[PATCH] D31022: Implement P0298R3: `std::byte`

2017-03-23 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: 
test/std/language.support/support.types/byteops/xor.assign.pass.cpp:13
+
+// XFAIL: c++98, c++03, c++11, c++14
+

Nit. These should be `// UNSUPPORTED`. `XFAIL` is for bugs we need to fix.


https://reviews.llvm.org/D31022



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


[libcxx] r298681 - Implement Pp0156r2: 'Variadic Lock Guard, version 5' Reviewed as https://reviews.llvm.org/D31163.

2017-03-23 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Mar 23 22:40:36 2017
New Revision: 298681

URL: http://llvm.org/viewvc/llvm-project?rev=298681=rev
Log:
Implement Pp0156r2: 'Variadic Lock Guard, version 5'  Reviewed as 
https://reviews.llvm.org/D31163.

Added:
libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/adopt_lock.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/assign.fail.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/copy.fail.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/mutex.fail.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/mutex.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/types.pass.cpp
Removed:

libcxx/trunk/test/libcxx/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex_mangling.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_adopt_lock.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_assign.fail.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_copy.fail.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.fail.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex_cxx03.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_types.pass.cpp
Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/__mutex_base
libcxx/trunk/include/mutex
libcxx/trunk/include/shared_mutex

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=298681=298680=298681=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Thu Mar 23 22:40:36 2017
@@ -49,7 +49,6 @@
 #define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
 #define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
 #define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
-#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD
 // Don't use a nullptr_t simulation type in C++03 instead using C++11 nullptr
 // provided under the alternate keyword __nullptr, which changes the mangling
 // of nullptr_t. This option is ABI incompatible with GCC in C++03 mode.
@@ -1076,6 +1075,10 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 # define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
 #endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
 
+#if !defined(__cpp_deduction_guides) || __cpp_deduction_guides < 201611
+# define _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+#endif
+
 #endif // __cplusplus
 
 #endif // _LIBCPP_CONFIG

Modified: libcxx/trunk/include/__mutex_base
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__mutex_base?rev=298681=298680=298681=diff
==
--- libcxx/trunk/include/__mutex_base (original)
+++ libcxx/trunk/include/__mutex_base Thu Mar 23 22:40:36 2017
@@ -80,21 +80,9 @@ constexpr adopt_lock_t  adopt_lock  = ad
 
 #endif
 
-
-// Forward declare lock_guard as a variadic template even in C++03 to keep
-// the mangling consistent between dialects.
-#if defined(_LIBCPP_ABI_VARIADIC_LOCK_GUARD)
-template 
-class _LIBCPP_TEMPLATE_VIS lock_guard;
-#endif
-
 template 
 class _LIBCPP_TEMPLATE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(scoped_lockable)
-#if !defined(_LIBCPP_ABI_VARIADIC_LOCK_GUARD)
 lock_guard
-#else
-lock_guard<_Mutex>
-#endif
 {
 public:
 typedef _Mutex mutex_type;

Modified: libcxx/trunk/include/mutex
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/mutex?rev=298681=298680=298681=diff
==
--- libcxx/trunk/include/mutex (original)
+++ libcxx/trunk/include/mutex Thu Mar 23 22:40:36 2017
@@ -109,15 +109,17 @@ public:
 lock_guard& operator=(lock_guard const&) = delete;
 };
 
-template  // Variadic lock_guard only provided in ABI V2.
-class lock_guard
+template 
+class scoped_lock // C++17
 {
 public:
-explicit lock_guard(MutexTypes&... m);
-lock_guard(MutexTypes&... m, adopt_lock_t);
-~lock_guard();
-lock_guard(lock_guard const&) = delete;
-lock_guard& operator=(lock_guard const&) = delete;
+using 

[PATCH] D31022: Implement P0298R3: `std::byte`

2017-03-23 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.

I still think we can come up with a better include structure, but we have 
plenty of time to figure that out before the next release.
I see no reason to hold this up.

@mclow.lists is there a feature test macro we should be implementing?


https://reviews.llvm.org/D31022



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


[PATCH] D31163: Implement Pp0156r2 "Variadic Lock Guard, version 5"

2017-03-23 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.

LGTM. I'll send something to the reflectors about the explicit deduction guides 
over the weekend.


https://reviews.llvm.org/D31163



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


[PATCH] D31163: Implement Pp0156r2 "Variadic Lock Guard, version 5"

2017-03-23 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists marked 8 inline comments as done.
mclow.lists added inline comments.



Comment at: include/mutex:176
 
+template unique_lock(unique_lock)
+-> unique_lock; // C++17

mclow.lists wrote:
> EricWF wrote:
> > This should be guarded behind a feature test macro. I would suggest adding 
> > this to `__config`.
> > 
> > ```
> > #if !defined(__cpp_deduction_guides) || __cpp_deduction_guides < 201611
> > # define _LIBCPP_HAS_NO_DEDUCTION_GUIDES
> > #endif
> > ```
> That sounds right to me.
Actually, this is in the synopsis; so no guard needed.


https://reviews.llvm.org/D31163



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


[PATCH] D31163: Implement Pp0156r2 "Variadic Lock Guard, version 5"

2017-03-23 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists updated this revision to Diff 92896.
mclow.lists added a comment.

Removed the deduction guides. Guarded the tests for the deduction guides with 
#ifdefs.


https://reviews.llvm.org/D31163

Files:
  include/__config
  include/__mutex_base
  include/mutex
  include/shared_mutex
  
test/libcxx/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex_mangling.pass.cpp
  test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_adopt_lock.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_assign.fail.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_copy.fail.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.fail.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex_cxx03.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_types.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/adopt_lock.pass.cpp
  test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/assign.fail.cpp
  test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/copy.fail.cpp
  test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/mutex.fail.cpp
  test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/mutex.pass.cpp
  test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/types.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp

Index: test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp
===
--- test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp
+++ test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp
@@ -15,11 +15,16 @@
 
 // explicit unique_lock(mutex_type& m);
 
+// template unique_lock(unique_lock<_Mutex>)
+// -> unique_lock<_Mutex>;  // C++17
+
 #include 
 #include 
 #include 
 #include 
 
+#include "test_macros.h"
+
 std::mutex m;
 
 typedef std::chrono::system_clock Clock;
@@ -47,4 +52,9 @@
 std::this_thread::sleep_for(ms(250));
 m.unlock();
 t.join();
+
+#ifdef __cpp_deduction_guides
+	std::unique_lock ul(m);
+static_assert((std::is_same>::value), "" );
+#endif
 }
Index: test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp
===
--- test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp
+++ test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp
@@ -18,6 +18,9 @@
 
 // explicit shared_lock(mutex_type& m);
 
+// template shared_lock(shared_lock<_Mutex>)
+// -> shared_lock<_Mutex>;  // C++17
+
 #include 
 #include 
 #include 
@@ -92,4 +95,9 @@
 t.join();
 q.join();
 }
+
+#ifdef __cpp_deduction_guides
+std::shared_lock sl(m);
+static_assert((std::is_same>::value), "" );
+#endif
 }
Index: test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/types.pass.cpp
===
--- test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/types.pass.cpp
+++ test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/types.pass.cpp
@@ -0,0 +1,78 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// 
+
+// template 
+// class scoped_lock
+// {
+// public:
+// typedef Mutex mutex_type;  // only if sizeof...(Mutex) == 1
+// ...
+// };
+
+#include 
+#include 
+#include "test_macros.h"
+
+struct NAT {};
+
+template 
+auto test_typedef(int) -> typename LG::mutex_type;
+
+template 
+auto test_typedef(...) -> NAT;
+
+template 
+constexpr bool has_mutex_type() {
+return !std::is_same::value;
+}
+
+int main()
+{
+{
+using T = std::scoped_lock<>;
+static_assert(!has_mutex_type(), "");
+}
+{
+using M1 = std::mutex;
+using T = std::scoped_lock;
+static_assert(std::is_same::value, "");
+}
+{
+using M1 = 

[PATCH] D30760: Record command lines in objects built by clang, Clang part

2017-03-23 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

Needs more testing. Might want to make sure that you actually are recording 
some useful command line options and that you're looking at the cc1 command 
line.

This should also be a Driver test and not CodeGen. You can then use -### to 
inspect the command lines as passed around.

-eric


https://reviews.llvm.org/D30760



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


[PATCH] D30760: Record command lines in objects built by clang, Clang part

2017-03-23 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:4328
+  if (getToolChain().UseDwarfDebugFlags() ||
+  Args.hasArg(options::OPT_grecord_gcc_switches)) {
 ArgStringList OriginalArgs;

looks like we have to consider `-gno-record-gcc-switches` (which already exists 
in Options.td), too. `hasFlag` should let you test them both easily.

please also add a test checking that we respect `-gno-record-gcc-switches`.



Comment at: test/CodeGen/debug-info-grecord-gcc-switches.c:6
+
+// CHECK: -g -grecord-gcc-switches -S -emit-llvm

nit: since `RenderAsInput` args (`-Xlinker`, `-o`, ...) have cases where 
they're printed without their arg, can we check that `-o -` is printed sanely 
here, as well?


https://reviews.llvm.org/D30760



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


r298676 - Fix handling of initialization from parenthesized initializer list.

2017-03-23 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Mar 23 20:14:25 2017
New Revision: 298676

URL: http://llvm.org/viewvc/llvm-project?rev=298676=rev
Log:
Fix handling of initialization from parenthesized initializer list.

This change fixes a crash on initialization of a reference from ({}) during
template instantiation and incidentally improves diagnostics.

This reverts a prior attempt to handle this in r286721. Instead, we teach the
initialization code that initialization cannot be performed if a source type
is required and the initializer is an initializer list (which is not an
expression and does not have a type), and likewise for function-style cast
expressions.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Initialization.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/SemaCXX/cxx0x-initializer-constructor.cpp
cfe/trunk/test/SemaCXX/cxx0x-initializer-references.cpp
cfe/trunk/test/SemaCXX/cxx0x-initializer-scalars.cpp
cfe/trunk/test/SemaCXX/type-convert-construct.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=298676=298675=298676=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Mar 23 20:14:25 
2017
@@ -1814,8 +1814,9 @@ def note_uninit_fixit_remove_cond : Note
   "remove the %select{'%1' if its condition|condition if it}0 "
   "is always %select{false|true}2">;
 def err_init_incomplete_type : Error<"initialization of incomplete type %0">;
-def err_list_init_in_parens : Error<"list-initializer for non-class type %0 "
-  "must not be parenthesized">;
+def err_list_init_in_parens : Error<
+  "cannot initialize %select{non-class|reference}0 type %1 with a "
+  "parenthesized initializer list">;
 
 def warn_unsequenced_mod_mod : Warning<
   "multiple unsequenced modifications to %0">, InGroup;
@@ -5865,8 +5866,8 @@ def err_builtin_func_cast_more_than_one_
   "function-style cast to a builtin type can only take one argument">;
 def err_value_init_for_array_type : Error<
   "array types cannot be value-initialized">;
-def err_value_init_for_function_type : Error<
-  "function types cannot be value-initialized">;
+def err_init_for_function_type : Error<
+  "cannot create object of function type %0">;
 def warn_format_nonliteral_noargs : Warning<
   "format string is not a string literal (potentially insecure)">,
   InGroup;

Modified: cfe/trunk/include/clang/Sema/Initialization.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Initialization.h?rev=298676=298675=298676=diff
==
--- cfe/trunk/include/clang/Sema/Initialization.h (original)
+++ cfe/trunk/include/clang/Sema/Initialization.h Thu Mar 23 20:14:25 2017
@@ -822,6 +822,8 @@ public:
   enum FailureKind {
 /// \brief Too many initializers provided for a reference.
 FK_TooManyInitsForReference,
+/// \brief Reference initialized from a parenthesized initializer list.
+FK_ParenthesizedListInitForReference,
 /// \brief Array must be initialized with an initializer list.
 FK_ArrayNeedsInitList,
 /// \brief Array must be initialized with an initializer list or a 
@@ -866,6 +868,8 @@ public:
 FK_ConversionFromPropertyFailed,
 /// \brief Too many initializers for scalar
 FK_TooManyInitsForScalar,
+/// \brief Scalar initialized from a parenthesized initializer list.
+FK_ParenthesizedListInitForScalar,
 /// \brief Reference initialization from an initializer list
 FK_ReferenceBindingToInitList,
 /// \brief Initialization of some unused destination type with an
@@ -892,7 +896,7 @@ public:
 /// having its address taken.
 FK_AddressOfUnaddressableFunction,
 /// \brief List-copy-initialization chose an explicit constructor.
-FK_ExplicitConstructor
+FK_ExplicitConstructor,
   };
   
 private:

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=298676=298675=298676=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Mar 23 20:14:25 2017
@@ -1822,7 +1822,6 @@ public:
   void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit);
   void ActOnUninitializedDecl(Decl *dcl);
   void ActOnInitializerError(Decl *Dcl);
-  bool canInitializeWithParenthesizedList(QualType TargetType);
 
   void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc);
   void ActOnCXXForRangeDecl(Decl *D);

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 

[PATCH] D31007: [Objective-C] Miscellaneous -fobjc-weak Fixes

2017-03-23 Thread Brian T. Kelley via Phabricator via cfe-commits
bkelley added inline comments.



Comment at: lib/AST/Type.cpp:3773
+/// lifetime semantics.
+bool Type::isNonTrivialObjCLifetimeType() const {
+  return CanonicalType.hasNonTrivialObjCLifetime();

rjmccall wrote:
> Is this method not identical in behavior to hasNonTrivialObjCLifetime()?
Yes, but I didn't see how to extract that information, which is on the internal 
QualType. But after examining the usage of this function in SemaInit.cpp:6681, 
I think we need something similar to the isObjCLifetimeType() implementation 
above.


https://reviews.llvm.org/D31007



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


[PATCH] D31007: [Objective-C] Miscellaneous -fobjc-weak Fixes

2017-03-23 Thread Brian T. Kelley via Phabricator via cfe-commits
bkelley updated this revision to Diff 92892.

https://reviews.llvm.org/D31007

Files:
  include/clang/AST/Type.h
  lib/AST/Type.cpp
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaInit.cpp
  test/SemaObjCXX/objc-weak.mm

Index: test/SemaObjCXX/objc-weak.mm
===
--- /dev/null
+++ test/SemaObjCXX/objc-weak.mm
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-weak -fblocks -Wno-objc-root-class -std=c++98 -Wno-c++0x-extensions -verify %s
+
+@interface AnObject
+@property(weak) id value;
+@end
+
+__attribute__((objc_arc_weak_reference_unavailable))
+@interface NOWEAK : AnObject // expected-note 2 {{class is declared here}}
+@end
+
+struct S {
+  __weak id a; // expected-note {{because type 'S' has a member with __weak ownership}}
+};
+
+union U {
+  __weak id a; // expected-error {{ARC forbids Objective-C objects in union}}
+  S b; // expected-error {{union member 'b' has a non-trivial copy constructor}}
+};
+
+void testCast(AnObject *o) {
+  __weak id a = reinterpret_cast<__weak NOWEAK *>(o); // expected-error {{class is incompatible with __weak references}} \
+  // expected-error {{explicit ownership qualifier on cast result has no effect}} \
+  // expected-error {{assignment of a weak-unavailable object to a __weak object}}
+
+  __weak id b = static_cast<__weak NOWEAK *>(o); // expected-error {{class is incompatible with __weak references}} \
+ // expected-error {{explicit ownership qualifier on cast result has no effect}} \
+ // expected-error {{assignment of a weak-unavailable object to a __weak object}}
+}
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -6678,8 +6678,7 @@
   // need cleanups. Likewise if we're extending this temporary to automatic
   // storage duration -- we need to register its cleanup during the
   // full-expression's cleanups.
-  if ((S.getLangOpts().ObjCAutoRefCount &&
-   MTE->getType()->isObjCLifetimeType()) ||
+  if (MTE->getType()->isNonTrivialObjCLifetimeType() ||
   (MTE->getStorageDuration() == SD_Automatic &&
MTE->getType().isDestructedType()))
 S.Cleanup.setExprNeedsCleanups(true);
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -7145,8 +7145,7 @@
 //   [...] nontrivally ownership-qualified types are [...] not trivially
 //   default constructible, copy constructible, move constructible, copy
 //   assignable, move assignable, or destructible [...]
-if (S.getLangOpts().ObjCAutoRefCount &&
-FieldType.hasNonTrivialObjCLifetime()) {
+if (FieldType.hasNonTrivialObjCLifetime()) {
   if (Diagnose)
 S.Diag(FI->getLocation(), diag::note_nontrivial_objc_ownership)
   << RD << FieldType.getObjCLifetime();
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -14492,7 +14492,7 @@
   // Verify that all the fields are okay.
   SmallVector RecFields;
 
-  bool ARCErrReported = false;
+  bool ObjCFieldLifetimeErrReported = false;
   for (ArrayRef::iterator i = Fields.begin(), end = Fields.end();
i != end; ++i) {
 FieldDecl *FD = cast(*i);
@@ -14627,16 +14627,16 @@
 << FixItHint::CreateInsertion(FD->getLocation(), "*");
   QualType T = Context.getObjCObjectPointerType(FD->getType());
   FD->setType(T);
-} else if (getLangOpts().ObjCAutoRefCount && Record && !ARCErrReported &&
+} else if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
+   Record && !ObjCFieldLifetimeErrReported &&
(!getLangOpts().CPlusPlus || Record->isUnion())) {
-  // It's an error in ARC if a field has lifetime.
+  // It's an error in ARC or Weak if a field has lifetime.
   // We don't want to report this in a system header, though,
   // so we just make the field unavailable.
   // FIXME: that's really not sufficient; we need to make the type
   // itself invalid to, say, initialize or copy.
   QualType T = FD->getType();
-  Qualifiers::ObjCLifetime lifetime = T.getObjCLifetime();
-  if (lifetime && lifetime != Qualifiers::OCL_ExplicitNone) {
+  if (T.hasNonTrivialObjCLifetime()) {
 SourceLocation loc = FD->getLocation();
 if (getSourceManager().isInSystemHeader(loc)) {
   if (!FD->hasAttr()) {
@@ -14647,7 +14647,7 @@
   Diag(FD->getLocation(), diag::err_arc_objc_object_in_tag)
 << 

[PATCH] D31004: [Objective-C] Fix __weak type traits with -fobjc-weak

2017-03-23 Thread Brian T. Kelley via Phabricator via cfe-commits
bkelley updated this revision to Diff 92890.
bkelley marked an inline comment as done.
bkelley added a comment.

Removed redundant conditions, per feedback from @rjmccall


https://reviews.llvm.org/D31004

Files:
  lib/AST/Type.cpp
  lib/Sema/SemaExprCXX.cpp
  test/SemaObjCXX/objc-weak-type-traits.mm

Index: test/SemaObjCXX/objc-weak-type-traits.mm
===
--- /dev/null
+++ test/SemaObjCXX/objc-weak-type-traits.mm
@@ -0,0 +1,210 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-weak -fobjc-runtime-has-weak -verify -std=c++11 %s
+// expected-no-diagnostics
+
+// Check the results of the various type-trait query functions on
+// lifetime-qualified types in ObjC Weak.
+
+#define TRAIT_IS_TRUE(Trait, Type) static_assert(Trait(Type), "")
+#define TRAIT_IS_FALSE(Trait, Type) static_assert(!Trait(Type), "")
+#define TRAIT_IS_TRUE_2(Trait, Type1, Type2) static_assert(Trait(Type1, Type2), "")
+#define TRAIT_IS_FALSE_2(Trait, Type1, Type2) static_assert(!Trait(Type1, Type2), "")
+  
+struct HasStrong { id obj; };
+struct HasWeak { __weak id obj; };
+struct HasUnsafeUnretained { __unsafe_unretained id obj; };
+
+// __has_nothrow_assign
+TRAIT_IS_TRUE(__has_nothrow_assign, __strong id);
+TRAIT_IS_TRUE(__has_nothrow_assign, __weak id);
+TRAIT_IS_TRUE(__has_nothrow_assign, __autoreleasing id);
+TRAIT_IS_TRUE(__has_nothrow_assign, __unsafe_unretained id);
+TRAIT_IS_TRUE(__has_nothrow_assign, HasStrong);
+TRAIT_IS_TRUE(__has_nothrow_assign, HasWeak);
+TRAIT_IS_TRUE(__has_nothrow_assign, HasUnsafeUnretained);
+
+// __has_nothrow_copy
+TRAIT_IS_TRUE(__has_nothrow_copy, __strong id);
+TRAIT_IS_TRUE(__has_nothrow_copy, __weak id);
+TRAIT_IS_TRUE(__has_nothrow_copy, __autoreleasing id);
+TRAIT_IS_TRUE(__has_nothrow_copy, __unsafe_unretained id);
+TRAIT_IS_TRUE(__has_nothrow_copy, HasStrong);
+TRAIT_IS_TRUE(__has_nothrow_copy, HasWeak);
+TRAIT_IS_TRUE(__has_nothrow_copy, HasUnsafeUnretained);
+
+// __has_nothrow_constructor
+TRAIT_IS_TRUE(__has_nothrow_constructor, __strong id);
+TRAIT_IS_TRUE(__has_nothrow_constructor, __weak id);
+TRAIT_IS_TRUE(__has_nothrow_constructor, __autoreleasing id);
+TRAIT_IS_TRUE(__has_nothrow_constructor, __unsafe_unretained id);
+TRAIT_IS_TRUE(__has_nothrow_constructor, HasStrong);
+TRAIT_IS_TRUE(__has_nothrow_constructor, HasWeak);
+TRAIT_IS_TRUE(__has_nothrow_constructor, HasUnsafeUnretained);
+
+// __has_trivial_assign
+TRAIT_IS_TRUE(__has_trivial_assign, __strong id);
+TRAIT_IS_FALSE(__has_trivial_assign, __weak id);
+TRAIT_IS_TRUE(__has_trivial_assign, __autoreleasing id);
+TRAIT_IS_TRUE(__has_trivial_assign, __unsafe_unretained id);
+TRAIT_IS_TRUE(__has_trivial_assign, HasStrong);
+TRAIT_IS_FALSE(__has_trivial_assign, HasWeak);
+TRAIT_IS_TRUE(__has_trivial_assign, HasUnsafeUnretained);
+
+// __has_trivial_copy
+TRAIT_IS_TRUE(__has_trivial_copy, __strong id);
+TRAIT_IS_FALSE(__has_trivial_copy, __weak id);
+TRAIT_IS_TRUE(__has_trivial_copy, __autoreleasing id);
+TRAIT_IS_TRUE(__has_trivial_copy, __unsafe_unretained id);
+TRAIT_IS_TRUE(__has_trivial_copy, HasStrong);
+TRAIT_IS_FALSE(__has_trivial_copy, HasWeak);
+TRAIT_IS_TRUE(__has_trivial_copy, HasUnsafeUnretained);
+
+// __has_trivial_constructor
+TRAIT_IS_TRUE(__has_trivial_constructor, __strong id);
+TRAIT_IS_FALSE(__has_trivial_constructor, __weak id);
+TRAIT_IS_TRUE(__has_trivial_constructor, __autoreleasing id);
+TRAIT_IS_TRUE(__has_trivial_constructor, __unsafe_unretained id);
+TRAIT_IS_TRUE(__has_trivial_constructor, HasStrong);
+TRAIT_IS_FALSE(__has_trivial_constructor, HasWeak);
+TRAIT_IS_TRUE(__has_trivial_constructor, HasUnsafeUnretained);
+
+// __has_trivial_destructor
+TRAIT_IS_TRUE(__has_trivial_destructor, __strong id);
+TRAIT_IS_FALSE(__has_trivial_destructor, __weak id);
+TRAIT_IS_TRUE(__has_trivial_destructor, __autoreleasing id);
+TRAIT_IS_TRUE(__has_trivial_destructor, __unsafe_unretained id);
+TRAIT_IS_TRUE(__has_trivial_destructor, HasStrong);
+TRAIT_IS_FALSE(__has_trivial_destructor, HasWeak);
+TRAIT_IS_TRUE(__has_trivial_destructor, HasUnsafeUnretained);
+
+// __is_literal
+TRAIT_IS_TRUE(__is_literal, __strong id);
+TRAIT_IS_TRUE(__is_literal, __weak id);
+TRAIT_IS_TRUE(__is_literal, __autoreleasing id);
+TRAIT_IS_TRUE(__is_literal, __unsafe_unretained id);
+
+// __is_literal_type
+TRAIT_IS_TRUE(__is_literal_type, __strong id);
+TRAIT_IS_TRUE(__is_literal_type, __weak id);
+TRAIT_IS_TRUE(__is_literal_type, __autoreleasing id);
+TRAIT_IS_TRUE(__is_literal_type, __unsafe_unretained id);
+
+// __is_pod
+TRAIT_IS_TRUE(__is_pod, __strong id);
+TRAIT_IS_FALSE(__is_pod, __weak id);
+TRAIT_IS_TRUE(__is_pod, __autoreleasing id);
+TRAIT_IS_TRUE(__is_pod, __unsafe_unretained id);
+TRAIT_IS_TRUE(__is_pod, HasStrong);
+TRAIT_IS_FALSE(__is_pod, HasWeak);
+TRAIT_IS_TRUE(__is_pod, HasUnsafeUnretained);
+
+// __is_trivial
+TRAIT_IS_TRUE(__is_trivial, __strong id);
+TRAIT_IS_FALSE(__is_trivial, __weak id);
+TRAIT_IS_TRUE(__is_trivial, __autoreleasing id);

[PATCH] D31004: [Objective-C] Fix __weak type traits with -fobjc-weak

2017-03-23 Thread Brian T. Kelley via Phabricator via cfe-commits
bkelley added a comment.

Thanks for the feedback! Apologies for the slow turn around; I was out sick :(




Comment at: lib/AST/Type.cpp:2026
 
-  if (Context.getLangOpts().ObjCAutoRefCount) {
-switch (getObjCLifetime()) {
-case Qualifiers::OCL_ExplicitNone:
-  return true;
-  
-case Qualifiers::OCL_Strong:
-case Qualifiers::OCL_Weak:
-case Qualifiers::OCL_Autoreleasing:
-  return false;
-
-case Qualifiers::OCL_None:
-  break;
-}
-  }
+  if (getQualifiers().hasObjCLifetime() && hasNonTrivialObjCLifetime())
+return false;

rjmccall wrote:
> Is the first condition not implied by the second?
It definitely is. Thanks!


https://reviews.llvm.org/D31004



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


[PATCH] D31308: [clang-tidy] new check readability-no-alternative-tokens

2017-03-23 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

I think will be good idea to make this check working in both ways (standard or 
alternative operator representations), depending on option.

Probably readability-operators-representation will be better name for check.

See also PR25195.


https://reviews.llvm.org/D31308



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


[PATCH] D30760: Record command lines in objects built by clang, Clang part

2017-03-23 Thread Zhizhou Yang via Phabricator via cfe-commits
zhizhouy updated this revision to Diff 92885.
zhizhouy retitled this revision from "Record command lines in objects built by 
clang" to "Record command lines in objects built by clang, Clang part".
zhizhouy edited the summary of this revision.
zhizhouy added a reviewer: aprantl.
zhizhouy added a comment.

I am reusing the DwarfDebugFlags to try to solve this bug now.

DwarfDebugFlags only records the command line options for Apple Darwin and will 
generate DW_AT_APPLE_flags into debug info.
I decide not to touch those parts for now.

When -grecord-gcc-switches is set, I record command line options into 
DwarfDebugFlags no matter what ToolChain currently is.

This patch also modified LLVM side, which can be referred to: name 



https://reviews.llvm.org/D30760

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/CodeGen/debug-info-grecord-gcc-switches.c


Index: test/CodeGen/debug-info-grecord-gcc-switches.c
===
--- /dev/null
+++ test/CodeGen/debug-info-grecord-gcc-switches.c
@@ -0,0 +1,6 @@
+// RUN: %clang -g -grecord-gcc-switches -S -emit-llvm -o - %s | FileCheck %s
+int main (void) {
+  return 0;
+}
+
+// CHECK: -g -grecord-gcc-switches -S -emit-llvm
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -2728,7 +2728,8 @@
 DwarfVersion = getToolChain().GetDefaultDwarfVersion();
   }
 
-  // We ignore flags -gstrict-dwarf and -grecord-gcc-switches for now.
+  // We ignore flag -gstrict-dwarf for now.
+  // And we handle flag -grecord-gcc-switches later with DwarfDebugFlags.
   Args.ClaimAllArgs(options::OPT_g_flags_Group);
 
   // Column info is included by default for everything except PS4 and CodeView.
@@ -4321,7 +4322,10 @@
 
   // Optionally embed the -cc1 level arguments into the debug info, for build
   // analysis.
-  if (getToolChain().UseDwarfDebugFlags()) {
+  // Also record command line arguments into the debug info if
+  // -grecord-gcc-switches options is set on.
+  if (getToolChain().UseDwarfDebugFlags() ||
+  Args.hasArg(options::OPT_grecord_gcc_switches)) {
 ArgStringList OriginalArgs;
 for (const auto  : Args)
   Arg->render(Args, OriginalArgs);


Index: test/CodeGen/debug-info-grecord-gcc-switches.c
===
--- /dev/null
+++ test/CodeGen/debug-info-grecord-gcc-switches.c
@@ -0,0 +1,6 @@
+// RUN: %clang -g -grecord-gcc-switches -S -emit-llvm -o - %s | FileCheck %s
+int main (void) {
+  return 0;
+}
+
+// CHECK: -g -grecord-gcc-switches -S -emit-llvm
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -2728,7 +2728,8 @@
 DwarfVersion = getToolChain().GetDefaultDwarfVersion();
   }
 
-  // We ignore flags -gstrict-dwarf and -grecord-gcc-switches for now.
+  // We ignore flag -gstrict-dwarf for now.
+  // And we handle flag -grecord-gcc-switches later with DwarfDebugFlags.
   Args.ClaimAllArgs(options::OPT_g_flags_Group);
 
   // Column info is included by default for everything except PS4 and CodeView.
@@ -4321,7 +4322,10 @@
 
   // Optionally embed the -cc1 level arguments into the debug info, for build
   // analysis.
-  if (getToolChain().UseDwarfDebugFlags()) {
+  // Also record command line arguments into the debug info if
+  // -grecord-gcc-switches options is set on.
+  if (getToolChain().UseDwarfDebugFlags() ||
+  Args.hasArg(options::OPT_grecord_gcc_switches)) {
 ArgStringList OriginalArgs;
 for (const auto  : Args)
   Arg->render(Args, OriginalArgs);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r298670 - [XRay] Do not depend on C++ stdlib for XRay builds

2017-03-23 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Thu Mar 23 19:20:05 2017
New Revision: 298670

URL: http://llvm.org/viewvc/llvm-project?rev=298670=rev
Log:
[XRay] Do not depend on C++ stdlib for XRay builds

Summary:
Now that XRay doesn't require a runtime dependency on a C++ standard
library, we remove that dependency from the clang linker flags.

Reviewers: saugustine, pelikan

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=298670=298669=298670=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Thu Mar 23 19:20:05 2017
@@ -348,8 +348,6 @@ static void linkXRayRuntimeDeps(const To
   CmdArgs.push_back("-lm");
   CmdArgs.push_back("-latomic");
 
-  TC.AddCXXStdlibLibArgs(Args, CmdArgs);
-
   if (TC.getTriple().getOS() != llvm::Triple::FreeBSD)
 CmdArgs.push_back("-ldl");
 }


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


[PATCH] D31313: [XRay] Do not depend on C++ stdlib for XRay builds

2017-03-23 Thread Dean Michael Berris via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL298670: [XRay] Do not depend on C++ stdlib for XRay builds 
(authored by dberris).

Changed prior to commit:
  https://reviews.llvm.org/D31313?vs=92884=92886#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31313

Files:
  cfe/trunk/lib/Driver/ToolChains/Gnu.cpp


Index: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
@@ -348,8 +348,6 @@
   CmdArgs.push_back("-lm");
   CmdArgs.push_back("-latomic");
 
-  TC.AddCXXStdlibLibArgs(Args, CmdArgs);
-
   if (TC.getTriple().getOS() != llvm::Triple::FreeBSD)
 CmdArgs.push_back("-ldl");
 }


Index: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
@@ -348,8 +348,6 @@
   CmdArgs.push_back("-lm");
   CmdArgs.push_back("-latomic");
 
-  TC.AddCXXStdlibLibArgs(Args, CmdArgs);
-
   if (TC.getTriple().getOS() != llvm::Triple::FreeBSD)
 CmdArgs.push_back("-ldl");
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31313: [XRay] Do not depend on C++ stdlib for XRay builds

2017-03-23 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris created this revision.

Now that XRay doesn't require a runtime dependency on a C++ standard
library, we remove that dependency from the clang linker flags.


https://reviews.llvm.org/D31313

Files:
  lib/Driver/ToolChains/Gnu.cpp


Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -348,8 +348,6 @@
   CmdArgs.push_back("-lm");
   CmdArgs.push_back("-latomic");
 
-  TC.AddCXXStdlibLibArgs(Args, CmdArgs);
-
   if (TC.getTriple().getOS() != llvm::Triple::FreeBSD)
 CmdArgs.push_back("-ldl");
 }


Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -348,8 +348,6 @@
   CmdArgs.push_back("-lm");
   CmdArgs.push_back("-latomic");
 
-  TC.AddCXXStdlibLibArgs(Args, CmdArgs);
-
   if (TC.getTriple().getOS() != llvm::Triple::FreeBSD)
 CmdArgs.push_back("-ldl");
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r298663 - Remove uses of std::binary_function, removed in C++17.

2017-03-23 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Mar 23 18:32:03 2017
New Revision: 298663

URL: http://llvm.org/viewvc/llvm-project?rev=298663=rev
Log:
Remove uses of std::binary_function, removed in C++17.

Modified:
cfe/trunk/include/clang/AST/TypeOrdering.h
cfe/trunk/include/clang/Basic/SourceLocation.h

Modified: cfe/trunk/include/clang/AST/TypeOrdering.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TypeOrdering.h?rev=298663=298662=298663=diff
==
--- cfe/trunk/include/clang/AST/TypeOrdering.h (original)
+++ cfe/trunk/include/clang/AST/TypeOrdering.h Thu Mar 23 18:32:03 2017
@@ -26,7 +26,7 @@
 namespace clang {
 
 /// \brief Function object that provides a total ordering on QualType values.
-struct QualTypeOrdering : std::binary_function {
+struct QualTypeOrdering {
   bool operator()(QualType T1, QualType T2) const {
 return std::less()(T1.getAsOpaquePtr(), T2.getAsOpaquePtr());
   }

Modified: cfe/trunk/include/clang/Basic/SourceLocation.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceLocation.h?rev=298663=298662=298663=diff
==
--- cfe/trunk/include/clang/Basic/SourceLocation.h (original)
+++ cfe/trunk/include/clang/Basic/SourceLocation.h Thu Mar 23 18:32:03 2017
@@ -321,8 +321,7 @@ public:
   }
 
   /// \brief Comparison function class, useful for sorting FullSourceLocs.
-  struct BeforeThanCompare : public std::binary_function {
+  struct BeforeThanCompare {
 bool operator()(const FullSourceLoc& lhs, const FullSourceLoc& rhs) const {
   return lhs.isBeforeInTranslationUnitThan(rhs);
 }


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


r298657 - Remove all uses of std::mem_fun and std::bind1st removed in C++17.

2017-03-23 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Mar 23 18:17:58 2017
New Revision: 298657

URL: http://llvm.org/viewvc/llvm-project?rev=298657=rev
Log:
Remove all uses of std::mem_fun and std::bind1st removed in C++17.

Modified:
cfe/trunk/include/clang/AST/DeclContextInternals.h
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/Sema/Sema.cpp

Modified: cfe/trunk/include/clang/AST/DeclContextInternals.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclContextInternals.h?rev=298657=298656=298657=diff
==
--- cfe/trunk/include/clang/AST/DeclContextInternals.h (original)
+++ cfe/trunk/include/clang/AST/DeclContextInternals.h Thu Mar 23 18:17:58 2017
@@ -131,7 +131,7 @@ public:
 } else {
   DeclsTy  = *getAsVector();
   Vec.erase(std::remove_if(Vec.begin(), Vec.end(),
-   std::mem_fun(::isFromASTFile)),
+   [](Decl *D) { return D->isFromASTFile(); }),
 Vec.end());
   // Don't have any external decls any more.
   Data = DeclsAndHasExternalTy(, false);

Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=298657=298656=298657=diff
==
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Thu Mar 23 18:17:58 2017
@@ -381,15 +381,17 @@ public:
ArrayRef SelLocs = llvm::None);
 
   // Iterator access to parameter types.
-  typedef std::const_mem_fun_t deref_fun;
-  typedef llvm::mapped_iterator
-  param_type_iterator;
+  struct GetTypeFn {
+QualType operator()(const ParmVarDecl *PD) const { return PD->getType(); }
+  };
+  typedef llvm::mapped_iterator
+  param_type_iterator;
 
   param_type_iterator param_type_begin() const {
-return llvm::map_iterator(param_begin(), deref_fun(::getType));
+return llvm::map_iterator(param_begin(), GetTypeFn());
   }
   param_type_iterator param_type_end() const {
-return llvm::map_iterator(param_end(), deref_fun(::getType));
+return llvm::map_iterator(param_end(), GetTypeFn());
   }
 
   /// createImplicitParams - Used to lazily create the self and cmd

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h?rev=298657=298656=298657=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h Thu 
Mar 23 18:17:58 2017
@@ -383,7 +383,9 @@ public:
 
   // Iterator access to formal parameters and their types.
 private:
-  typedef std::const_mem_fun_t get_type_fun;
+  struct GetTypeFn {
+QualType operator()(ParmVarDecl *PD) const { return PD->getType(); }
+  };
 
 public:
   /// Return call's formal parameters.
@@ -393,7 +395,7 @@ public:
   /// correspond with the argument value returned by \c getArgSVal(0).
   virtual ArrayRef parameters() const = 0;
 
-  typedef llvm::mapped_iterator::iterator, get_type_fun>
+  typedef llvm::mapped_iterator::iterator, GetTypeFn>
 param_type_iterator;
 
   /// Returns an iterator over the types of the call's formal parameters.
@@ -402,13 +404,11 @@ public:
   /// definition because it represents a public interface, and probably has
   /// more annotations.
   param_type_iterator param_type_begin() const {
-return llvm::map_iterator(parameters().begin(),
-  get_type_fun(::getType));
+return llvm::map_iterator(parameters().begin(), GetTypeFn());
   }
   /// \sa param_type_begin()
   param_type_iterator param_type_end() const {
-return llvm::map_iterator(parameters().end(),
-  get_type_fun(::getType));
+return llvm::map_iterator(parameters().end(), GetTypeFn());
   }
 
   // For debugging purposes only

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=298657=298656=298657=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Mar 23 18:17:58 2017
@@ -719,7 +719,7 @@ CodeGenTypes::arrangeLLVMFunctionInfo(Ca
  ArrayRef paramInfos,
   RequiredArgs required) {
   assert(std::all_of(argTypes.begin(), argTypes.end(),
-   

[PATCH] D30810: Preserve vec3 type.

2017-03-23 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

> I would like to see this patch committed. I see clear evidence of it 
> improving existing GPU targets in the master repo as well as outside of the 
> main tree implementations. Bruno, do you have any more concerns?

I believe the argument lacks numbers (or at least you have them but didn't 
mention). I didn't hear about performance results, or validation that this was 
actually tested for correctness. Small test cases prove a point, but can't be 
considered general.

OTOH, it seems like this is exactly why you want the flag, to hide any 
potential issues and play with it. I'm not opposed to adding the flag if 
there's a commitment to actually get the result and change the default to 
whatever seems to be better, does that seems reasonable?


https://reviews.llvm.org/D30810



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


[PATCH] D29262: Fixes to modernize-use-using

2017-03-23 Thread Krystyna via Phabricator via cfe-commits
krystyna added a comment.

I have plan to finish this patch next week, when I finish academic year at my 
school. If I will have any issues with submitting, Prazek offered to help me.


https://reviews.llvm.org/D29262



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


[PATCH] D31210: [AMDGPU] Add new address space mapping

2017-03-23 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

Ping! Any further issues? We need this in to move on with Clang codegen for the 
new address space mapping.

Thanks.


https://reviews.llvm.org/D31210



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


r298647 - Update the SamplePGO test to verify that unroll/icp is not invoked in thinlto compile phase.

2017-03-23 Thread Dehao Chen via cfe-commits
Author: dehao
Date: Thu Mar 23 16:20:17 2017
New Revision: 298647

URL: http://llvm.org/viewvc/llvm-project?rev=298647=rev
Log:
Update the SamplePGO test to verify that unroll/icp is not invoked in thinlto 
compile phase.

Summary: This is the test added for https://reviews.llvm.org/D31217

Reviewers: tejohnson, mehdi_amini

Reviewed By: tejohnson

Subscribers: cfe-commits, Prazek

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

Modified:
cfe/trunk/test/CodeGen/Inputs/pgo-sample-thinlto-summary.prof
cfe/trunk/test/CodeGen/pgo-sample-thinlto-summary.c

Modified: cfe/trunk/test/CodeGen/Inputs/pgo-sample-thinlto-summary.prof
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/Inputs/pgo-sample-thinlto-summary.prof?rev=298647=298646=298647=diff
==
--- cfe/trunk/test/CodeGen/Inputs/pgo-sample-thinlto-summary.prof (original)
+++ cfe/trunk/test/CodeGen/Inputs/pgo-sample-thinlto-summary.prof Thu Mar 23 
16:20:17 2017
@@ -1,2 +1,4 @@
 bar:100:100
  2: 2000 foo:2000
+icp:100:100
+ 1: 1000 unroll:1000

Modified: cfe/trunk/test/CodeGen/pgo-sample-thinlto-summary.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pgo-sample-thinlto-summary.c?rev=298647=298646=298647=diff
==
--- cfe/trunk/test/CodeGen/pgo-sample-thinlto-summary.c (original)
+++ cfe/trunk/test/CodeGen/pgo-sample-thinlto-summary.c Thu Mar 23 16:20:17 2017
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=INLINE
-// RUN: %clang_cc1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=NOINLINE
+// RUN: %clang_cc1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=O2
+// RUN: %clang_cc1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
 // Checks if hot call is inlined by normal compile, but not inlined by
 // thinlto compile.
 
@@ -11,9 +11,32 @@ void foo(int n) {
 g += baz(i);
 }
 
-// INLINE-NOT: call{{.*}}foo
-// NOINLINE: call{{.*}}foo
+// O2-LABEL: define void @bar
+// THINLTO-LABEL: define void @bar
+// O2-NOT: call{{.*}}foo
+// THINLTO: call{{.*}}foo
 void bar(int n) {
   for (int i = 0; i < n; i++)
 foo(i);
 }
+
+// Checks if loop unroll is invoked by normal compile, but not thinlto compile.
+// O2-LABEL: define void @unroll
+// THINLTO-LABEL: define void @unroll
+// O2: call{{.*}}baz
+// O2: call{{.*}}baz
+// THINLTO: call{{.*}}baz
+// THINLTO-NOT: call{{.*}}baz
+void unroll() {
+  for (int i = 0; i < 2; i++)
+baz(i);
+}
+
+// Checks if icp is invoked by normal compile, but not thinlto compile.
+// O2-LABEL: define void @icp
+// THINLTO-LABEL: define void @icp
+// O2: if.true.direct_targ
+// ThinLTO-NOT: if.true.direct_targ
+void icp(void (*p)()) {
+  p();
+}


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


[PATCH] D31219: Update the SamplePGO test to verify that unroll/icp is not invoked in thinlto compile phase.

2017-03-23 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson accepted this revision.
tejohnson added a comment.
This revision is now accepted and ready to land.

LGTM but please add comments about what we're testing.


https://reviews.llvm.org/D31219



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


[PATCH] D31308: [clang-tidy] new check readability-no-alternative-tokens

2017-03-23 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre created this revision.
Herald added a subscriber: mgorny.

Flags (and replaces) the alternative tokens for binary and unary
operators, such as ``not`` (for ``!``), ``bitand`` (for ``&``), ``or`` (for 
``||``)
or ``not_eq`` (for ``!=``).


https://reviews.llvm.org/D31308

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/NoAlternativeTokensCheck.cpp
  clang-tidy/readability/NoAlternativeTokensCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-no-alternative-tokens.rst
  test/clang-tidy/readability-no-alternative-tokens.cpp

Index: test/clang-tidy/readability-no-alternative-tokens.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-no-alternative-tokens.cpp
@@ -0,0 +1,54 @@
+// RUN: %check_clang_tidy %s readability-no-alternative-tokens %t
+
+void f() {
+  bool a, b, c;
+
+  c = a and b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: operator uses alternative spelling [readability-no-alternative-tokens]
+  // CHECK-FIXES: c = a && b;
+  c and_eq a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: operator
+  // CHECK-FIXES: c &= a;
+  c = a bitand b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: operator
+  // CHECK-FIXES: c = a & b;
+  c = a bitor b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: operator
+  // CHECK-FIXES: c = a | b;
+  c = compl a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: operator
+  // CHECK-FIXES: c = ~ a;
+  c = not a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: operator
+  // CHECK-FIXES: c = ! a;
+  c = a not_eq b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: operator
+  // CHECK-FIXES: c = a != b;
+  c = a or b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: operator
+  // CHECK-FIXES: c = a || b;
+  c or_eq a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: operator
+  // CHECK-FIXES: c |= a;
+  c = a xor b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: operator
+  // CHECK-FIXES: c = a ^ b;
+  c xor_eq a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: operator
+  // CHECK-FIXES: c ^= a;
+
+#define M a xor
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: operator
+  // CHECK-FIXES: #define M a ^
+  c = M b;
+
+  int arr[2];
+  for (int i : arr) // OK (Here is an implicit != operator.)
+;
+
+  auto ptr =  // OK
+  auto i = -1;   // OK
+  c = a && b;// OK
+  c &= a;// OK
+  c = !a;// OK
+}
Index: docs/clang-tidy/checks/readability-no-alternative-tokens.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-no-alternative-tokens.rst
@@ -0,0 +1,8 @@
+.. title:: clang-tidy - readability-no-alternative-tokens
+
+readability-no-alternative-tokens
+=
+
+Flags (and replaces) the alternative tokens for binary and unary operators,
+such as ``not`` (for ``!``), ``bitand`` (for ``&``), ``or`` (for ``||``) or ``not_eq``
+(for ``!=``).
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -144,6 +144,7 @@
readability-misleading-indentation
readability-misplaced-array-index
readability-named-parameter
+   readability-no-alternative-tokens
readability-non-const-parameter
readability-redundant-control-flow
readability-redundant-declaration
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -72,6 +72,12 @@
 
   Finds misleading indentation where braces should be introduced or the code should be reformatted.
 
+- New `readability-no-alternative-tokens
+  `_ check
+
+  Flags (and replaces) the alternative tokens for binary and unary operators,
+  such as ``not`` (for ``!``) and ``or`` (for ``||``).
+
 - Added `ParameterThreshold` to `readability-function-size`.
 
   Finds functions that have more then `ParameterThreshold` parameters and emits a warning.
Index: clang-tidy/readability/ReadabilityTidyModule.cpp
===
--- clang-tidy/readability/ReadabilityTidyModule.cpp
+++ clang-tidy/readability/ReadabilityTidyModule.cpp
@@ -23,6 +23,7 @@
 #include "MisleadingIndentationCheck.h"
 #include "MisplacedArrayIndexCheck.h"
 #include "NamedParameterCheck.h"
+#include "NoAlternativeTokensCheck.h"
 #include "NonConstParameterCheck.h"
 #include "RedundantControlFlowCheck.h"
 #include "RedundantDeclarationCheck.h"
@@ -66,6 +67,8 @@
 "readability-misleading-indentation");
 CheckFactories.registerCheck(
 "readability-misplaced-array-index");
+CheckFactories.registerCheck(
+"readability-no-alternative-tokens");
 CheckFactories.registerCheck(
 

[PATCH] D31121: [clangd] Add support for vscode extension configuration

2017-03-23 Thread Stanislav Ionascu via Phabricator via cfe-commits
stanionascu added a comment.

Thanks for review!
Would be great if somebody would commit it, as I cannot do it myself.


https://reviews.llvm.org/D31121



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


[PATCH] D31050: [ThinLTO] Clang support for emitting minimized bitcode for thin link

2017-03-23 Thread Teresa Johnson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL298639: [ThinLTO] Clang support for emitting minimized 
bitcode for thin link (authored by tejohnson).

Changed prior to commit:
  https://reviews.llvm.org/D31050?vs=92647=92849#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31050

Files:
  cfe/trunk/include/clang/Driver/CC1Options.td
  cfe/trunk/include/clang/Frontend/CodeGenOptions.h
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGen/thin_link_bitcode.c


Index: cfe/trunk/test/CodeGen/thin_link_bitcode.c
===
--- cfe/trunk/test/CodeGen/thin_link_bitcode.c
+++ cfe/trunk/test/CodeGen/thin_link_bitcode.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -o %t -flto=thin -fthin-link-bitcode=%t.nodebug -triple 
x86_64-unknown-linux-gnu -emit-llvm-bc -debug-info-kind=limited %s
+// RUN: llvm-bcanalyzer -dump %t | FileCheck %s
+// RUN: llvm-bcanalyzer -dump %t.nodebug | FileCheck %s --check-prefix=NO_DEBUG
+int main (void) {
+  return 0;
+}
+
+// CHECK: COMPILE_UNIT
+// NO_DEBUG-NOT: COMPILE_UNIT
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -641,6 +641,7 @@
   << A->getAsString(Args) << "-x ir";
 Opts.ThinLTOIndexFile = Args.getLastArgValue(OPT_fthinlto_index_EQ);
   }
+  Opts.ThinLinkBitcodeFile = Args.getLastArgValue(OPT_fthin_link_bitcode_EQ);
 
   Opts.MSVolatile = Args.hasArg(OPT_fms_volatile);
 
Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -686,13 +686,28 @@
   CodeGenPasses.add(
   createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
 
+  std::unique_ptr ThinLinkOS;
+
   switch (Action) {
   case Backend_EmitNothing:
 break;
 
   case Backend_EmitBC:
-if (CodeGenOpts.EmitSummaryIndex)
-  PerModulePasses.add(createWriteThinLTOBitcodePass(*OS));
+if (CodeGenOpts.EmitSummaryIndex) {
+  if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
+std::error_code EC;
+ThinLinkOS.reset(new llvm::raw_fd_ostream(
+CodeGenOpts.ThinLinkBitcodeFile, EC,
+llvm::sys::fs::F_None));
+if (EC) {
+  Diags.Report(diag::err_fe_unable_to_open_output) << 
CodeGenOpts.ThinLinkBitcodeFile
+   << EC.message();
+  return;
+}
+  }
+  PerModulePasses.add(
+  createWriteThinLTOBitcodePass(*OS, ThinLinkOS.get()));
+}
 else
   PerModulePasses.add(
   createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists));
Index: cfe/trunk/include/clang/Driver/CC1Options.td
===
--- cfe/trunk/include/clang/Driver/CC1Options.td
+++ cfe/trunk/include/clang/Driver/CC1Options.td
@@ -312,6 +312,8 @@
 def flto_unit: Flag<["-"], "flto-unit">,
 HelpText<"Emit IR to support LTO unit features (CFI, whole program vtable 
opt)">;
 def fno_lto_unit: Flag<["-"], "fno-lto-unit">;
+def fthin_link_bitcode_EQ : Joined<["-"], "fthin-link-bitcode=">,
+HelpText<"Write minimized bitcode to  for the ThinLTO thin link 
only">;
 
 
//===--===//
 // Dependency Output Options
Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.h
===
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.h
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.h
@@ -188,6 +188,11 @@
   /// importing.
   std::string ThinLTOIndexFile;
 
+  /// Name of a file that can optionally be written with minimized bitcode
+  /// to be used as input for the ThinLTO thin link step, which only needs
+  /// the summary and module symbol table (and not, e.g. any debug metadata).
+  std::string ThinLinkBitcodeFile;
+
   /// A list of file names passed with -fcuda-include-gpubinary options to
   /// forward to CUDA runtime back-end for incorporating them into host-side
   /// object file.


Index: cfe/trunk/test/CodeGen/thin_link_bitcode.c
===
--- cfe/trunk/test/CodeGen/thin_link_bitcode.c
+++ cfe/trunk/test/CodeGen/thin_link_bitcode.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -o %t -flto=thin -fthin-link-bitcode=%t.nodebug -triple x86_64-unknown-linux-gnu -emit-llvm-bc -debug-info-kind=limited %s
+// RUN: llvm-bcanalyzer -dump %t | FileCheck %s
+// RUN: llvm-bcanalyzer -dump %t.nodebug | FileCheck %s --check-prefix=NO_DEBUG
+int main (void) {
+  return 0;
+}
+
+// CHECK: COMPILE_UNIT
+// NO_DEBUG-NOT: COMPILE_UNIT
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp

r298639 - [ThinLTO] Clang support for emitting minimized bitcode for thin link

2017-03-23 Thread Teresa Johnson via cfe-commits
Author: tejohnson
Date: Thu Mar 23 14:47:49 2017
New Revision: 298639

URL: http://llvm.org/viewvc/llvm-project?rev=298639=rev
Log:
[ThinLTO] Clang support for emitting minimized bitcode for thin link

Summary:
Clang companion patch to LLVM patch D31027, which adds support
for emitting minimized bitcode file for use in the thin link step.
Add a cc1 option -fthin-link-bitcode= to trigger this behavior.

Depends on D31027.

Reviewers: mehdi_amini, pcc

Subscribers: cfe-commits, Prazek

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

Added:
cfe/trunk/test/CodeGen/thin_link_bitcode.c
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=298639=298638=298639=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Thu Mar 23 14:47:49 2017
@@ -312,6 +312,8 @@ def flto_visibility_public_std:
 def flto_unit: Flag<["-"], "flto-unit">,
 HelpText<"Emit IR to support LTO unit features (CFI, whole program vtable 
opt)">;
 def fno_lto_unit: Flag<["-"], "fno-lto-unit">;
+def fthin_link_bitcode_EQ : Joined<["-"], "fthin-link-bitcode=">,
+HelpText<"Write minimized bitcode to  for the ThinLTO thin link 
only">;
 
 
//===--===//
 // Dependency Output Options

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.h?rev=298639=298638=298639=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.h Thu Mar 23 14:47:49 2017
@@ -188,6 +188,11 @@ public:
   /// importing.
   std::string ThinLTOIndexFile;
 
+  /// Name of a file that can optionally be written with minimized bitcode
+  /// to be used as input for the ThinLTO thin link step, which only needs
+  /// the summary and module symbol table (and not, e.g. any debug metadata).
+  std::string ThinLinkBitcodeFile;
+
   /// A list of file names passed with -fcuda-include-gpubinary options to
   /// forward to CUDA runtime back-end for incorporating them into host-side
   /// object file.

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=298639=298638=298639=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Mar 23 14:47:49 2017
@@ -686,13 +686,28 @@ void EmitAssemblyHelper::EmitAssembly(Ba
   CodeGenPasses.add(
   createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
 
+  std::unique_ptr ThinLinkOS;
+
   switch (Action) {
   case Backend_EmitNothing:
 break;
 
   case Backend_EmitBC:
-if (CodeGenOpts.EmitSummaryIndex)
-  PerModulePasses.add(createWriteThinLTOBitcodePass(*OS));
+if (CodeGenOpts.EmitSummaryIndex) {
+  if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
+std::error_code EC;
+ThinLinkOS.reset(new llvm::raw_fd_ostream(
+CodeGenOpts.ThinLinkBitcodeFile, EC,
+llvm::sys::fs::F_None));
+if (EC) {
+  Diags.Report(diag::err_fe_unable_to_open_output) << 
CodeGenOpts.ThinLinkBitcodeFile
+   << EC.message();
+  return;
+}
+  }
+  PerModulePasses.add(
+  createWriteThinLTOBitcodePass(*OS, ThinLinkOS.get()));
+}
 else
   PerModulePasses.add(
   createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists));

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=298639=298638=298639=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Mar 23 14:47:49 2017
@@ -641,6 +641,7 @@ static bool ParseCodeGenArgs(CodeGenOpti
   << A->getAsString(Args) << "-x ir";
 Opts.ThinLTOIndexFile = Args.getLastArgValue(OPT_fthinlto_index_EQ);
   }
+  Opts.ThinLinkBitcodeFile = Args.getLastArgValue(OPT_fthin_link_bitcode_EQ);
 
   Opts.MSVolatile = Args.hasArg(OPT_fms_volatile);
 

Added: cfe/trunk/test/CodeGen/thin_link_bitcode.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thin_link_bitcode.c?rev=298639=auto
==

[PATCH] D31276: Add #pragma clang fast_math

2017-03-23 Thread Adam Nemet via Phabricator via cfe-commits
anemet added a comment.

In https://reviews.llvm.org/D31276#708999, @hfinkel wrote:

> They're definitely on my list. I might not get to them until the weekend or 
> next week, however.


Thank you.  The schedule is getting tight but that should still work ;).

Actually most of the individual patches are pretty small both in clang and 
llvm.  This one was the one that I felt the least confident about :).


https://reviews.llvm.org/D31276



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


[PATCH] D31276: Add #pragma clang fast_math

2017-03-23 Thread Adam Nemet via Phabricator via cfe-commits
anemet added a comment.

In https://reviews.llvm.org/D31276#708992, @hfinkel wrote:

> High-level comment ;)
>
>   #pragma clang fast_math contract_fast(on)
>   
>
> This seems a bit unfortunate because 'fast' appears twice? How are we 
> planning on naming the other fast-math flags? Maybe we should just name it:


This is just pure laziness on my part, I was hoping that all these flags can be 
implemented with on/off but if you find it confusing that's a good indicator.

> 
> 
>   #pragma clang math constract_fast(on)
>
> 
> or
> 
>   #pragma clang math contract(fast) // we could also accept off/on here for 
> consistency and compatibility with the standard pragma
>
> 
> or maybe fp_math or floating_point_math or floating_point or fp instead of 
> math.
> 
> I think that I prefer this last form (because it does not repeat 'fast' and 
> also makes our extension a pure superset of the standard pragma).
> 
> What do you want to name the other flags? I'd prefer if they're grammatically 
> consistent. Maybe we should stick closely to the command-line options, and 
> have:
> 
>   fp_contract(on/off/fast)
>   unsafe_optimizations(on/off)
>   finite_only(on/off)
>
> 
> What do you think?

I really like #pragma clang fp or fp_math because contraction feels different 
from the other fast-math flags.  That said then we don't want to repeat fp in 
fp_contract.

We should probably have the full list to make sure it works though with all the 
FMFs.  Here is a straw-man proposal:

  UnsafeAlgebra  #pragma clang fp unsafe_optimizations(on/off)
  NoNaNs #pragma clang fp no_nans(on/off)
  NoInfs#pragma clang fp finite_only(on/off)
  NoSignedZeros #pragma clang fp no_signed_zeros(on/off)
  AllowReciprocal#pragma clang fp reciprocal_math
  AllowContract   #pragma clang fp contract(on/off/fast)

The negative ones feel a bit strange...   What do you think?


https://reviews.llvm.org/D31276



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


r298634 - Correct class-template deprecation behavior-REDUX

2017-03-23 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Mar 23 13:51:54 2017
New Revision: 298634

URL: http://llvm.org/viewvc/llvm-project?rev=298634=rev
Log:
Correct class-template deprecation behavior-REDUX

Correct class-template deprecation behavior

Based on the comment in the test, and my reading of the standard, a deprecated 
warning should be issued in the following case:
template [[deprecated]] class Foo{}; Foo f;

This was not the case, because the ClassTemplateSpecializationDecl creation did 
not also copy the deprecated attribute.

Note: I did NOT audit the complete set of attributes to see WHICH ones should 
be copied, so instead I simply copy ONLY the deprecated attribute.

Previous DiffRev: https://reviews.llvm.org/D27486, was reverted.
This patch fixes the issues brought up here by the reverter: 
https://reviews.llvm.org/rL298410

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

Added:
cfe/trunk/test/SemaCXX/template-multiple-attr-propagation.cpp   (with props)
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
cfe/trunk/test/Sema/attr-deprecated.c
cfe/trunk/test/SemaCXX/attr-deprecated.cpp
cfe/trunk/test/SemaObjC/attr-deprecated.m
cfe/trunk/test/SemaObjC/special-dep-unavail-warning.m
cfe/trunk/test/SemaObjC/warn-deprecated-implementations.m
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=298634=298633=298634=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Thu Mar 23 13:51:54 2017
@@ -302,6 +302,9 @@ class Attr {
   // Set to true if this attribute can be duplicated on a subject when merging
   // attributes. By default, attributes are not merged.
   bit DuplicatesAllowedWhileMerging = 0;
+  // Set to true if this attribute meaningful when applied to or inherited 
+  // in a class template definition.
+  bit MeaningfulToClassTemplateDefinition = 0;
   // Lists language options, one of which is required to be true for the
   // attribute to be applicable. If empty, no language options are required.
   list LangOpts = [];
@@ -373,6 +376,7 @@ def AbiTag : Attr {
   let Args = [VariadicStringArgument<"Tags">];
   let Subjects = SubjectList<[Struct, Var, Function, Namespace], ErrorDiag,
   "ExpectedStructClassVariableFunctionOrInlineNamespace">;
+  let MeaningfulToClassTemplateDefinition = 1;
   let Documentation = [AbiTagsDocs];
 }
 
@@ -805,6 +809,7 @@ def Deprecated : InheritableAttr {
   // An optional string argument that enables us to provide a
   // Fix-It.
   StringArgument<"Replacement", 1>];
+  let MeaningfulToClassTemplateDefinition = 1;
   let Documentation = [DeprecatedDocs];
 }
 
@@ -1723,6 +1728,7 @@ def Visibility : InheritableAttr {
   let Args = [EnumArgument<"Visibility", "VisibilityType",
["default", "hidden", "internal", "protected"],
["Default", "Hidden", "Hidden", "Protected"]>];
+  let MeaningfulToClassTemplateDefinition = 1;
   let Documentation = [Undocumented];
 }
 

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=298634=298633=298634=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Mar 23 13:51:54 2017
@@ -7505,6 +7505,12 @@ public:
 LateInstantiatedAttrVec *LateAttrs = nullptr,
 LocalInstantiationScope *OuterMostScope = nullptr);
 
+  void
+  InstantiateAttrsForDecl(const MultiLevelTemplateArgumentList ,
+  const Decl *Pattern, Decl *Inst,
+  LateInstantiatedAttrVec *LateAttrs = nullptr,
+  LocalInstantiationScope *OuterMostScope = nullptr);
+
   bool
   InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation,
ClassTemplateSpecializationDecl *ClassTemplateSpec,

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=298634=298633=298634=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Mar 23 13:51:54 2017
@@ -6723,6 +6723,7 @@ static void DoEmitAvailabilityWarning(Se
   // Diagnostics for deprecated or unavailable.
   unsigned diag, diag_message, 

[PATCH] D30837: [libcxx] Support for shared_ptr<T()>

2017-03-23 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

Ping!


https://reviews.llvm.org/D30837



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


RE: D30739: [OpenMP] "declare simd" for AArch64 Advanced SIMD.

2017-03-23 Thread Tian, Xinmin via cfe-commits
What is the error in the spec? 

Thanks,
Xinmin

-Original Message-
From: Francesco Petrogalli via Phabricator [mailto:revi...@reviews.llvm.org] 
Sent: Thursday, March 23, 2017 10:29 AM
To: francesco.petroga...@arm.com; cber...@us.ibm.com; acja...@us.ibm.com; 
hahnf...@itc.rwth-aachen.de; a.bat...@hotmail.com
Cc: Tian, Xinmin ; florian.h...@arm.com; 
roger.ferreriba...@arm.com; amara.emer...@arm.com; renato.go...@linaro.org; 
cfe-commits@lists.llvm.org
Subject: [PATCH] D30739: [OpenMP] "declare simd" for AArch64 Advanced SIMD.

fpetrogalli planned changes to this revision.
fpetrogalli added a comment.

Dear all,

thank you for reviewing this patch. We found out an error in the spec and would 
like to fix it before things are used.

I will soon update this patch.

Thanks,

Francesco


https://reviews.llvm.org/D30739



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


[PATCH] D31276: Add #pragma clang fast_math

2017-03-23 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D31276#708993, @anemet wrote:

> In https://reviews.llvm.org/D31276#708976, @aaron.ballman wrote:
>
> > In https://reviews.llvm.org/D31276#708968, @anemet wrote:
> >
> > > Thanks very much, Aaron!  It would be great if you could also look at the 
> > > three patches that add support for the generation of the new FMF 
> > > 'contract' for -ffp-contract=fast.  I've added them in the dependencies 
> > > of this revision.  (https://reviews.llvm.org/D31168 is not really a 
> > > prerequisite but I am planning to commit the patches in this order.)
> >
> >
> > I'll take a look, but feel less qualified to give a LGTM to those.
>
>
> NP, thanks for your help on this one.  Hopefully @hfinkel or @mehdi_amini can 
> take a look.


They're definitely on my list. I might not get to them until the weekend or 
next week, however.


https://reviews.llvm.org/D31276



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


[PATCH] D31166: Encapsulate FPOptions and use it consistently

2017-03-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/AST/ExprCXX.h:58
+  // Only meaningful for floating point types. For other types this value can 
be
   // set to false.
+  FPOptions FPFeatures;

Setting a class to false sounds a bit strange. May want to reword.



Comment at: include/clang/Basic/LangOptions.h:180
 
-  FPOptions(const LangOptions ) :
-fp_contract(LangOpts.DefaultFPContract) {}
+  explicit FPOptions(uint64_t I) : fp_contract(I) {}
+

Why a `uint64_t` rather than `unsigned`? Same for the accessor.



Comment at: include/clang/Basic/LangOptions.h:182
+
+  FPOptions(const LangOptions )
+  : fp_contract(LangOpts.DefaultFPContract) {}

Might as well make this one explicit as well.



Comment at: lib/CodeGen/CGExprScalar.cpp:1712
   BinOp.Opcode = IsInc ? BO_Add : BO_Sub;
-  BinOp.FPContractable = false;
+  // FIXME: once UnaryOperator carries FPFeatures, copy it here.
   BinOp.E = E;

Why not make UnaryOperator carry this information now, since it's needed?


https://reviews.llvm.org/D31166



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


[PATCH] D31276: Add #pragma clang fast_math

2017-03-23 Thread Adam Nemet via Phabricator via cfe-commits
anemet added a comment.

In https://reviews.llvm.org/D31276#708976, @aaron.ballman wrote:

> In https://reviews.llvm.org/D31276#708968, @anemet wrote:
>
> > Thanks very much, Aaron!  It would be great if you could also look at the 
> > three patches that add support for the generation of the new FMF 'contract' 
> > for -ffp-contract=fast.  I've added them in the dependencies of this 
> > revision.  (https://reviews.llvm.org/D31168 is not really a prerequisite 
> > but I am planning to commit the patches in this order.)
>
>
> I'll take a look, but feel less qualified to give a LGTM to those.


NP, thanks for your help on this one.  Hopefully @hfinkel or @mehdi_amini can 
take a look.


https://reviews.llvm.org/D31276



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


[PATCH] D31276: Add #pragma clang fast_math

2017-03-23 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

High-level comment ;)

  #pragma clang fast_math contract_fast(on)

This seems a bit unfortunate because 'fast' appears twice? How are we planning 
on naming the other fast-math flags? Maybe we should just name it:

  #pragma clang math constract_fast(on)

or

  #pragma clang math contract(fast) // we could also accept off/on here for 
consistency and compatibility with the standard pragma

or maybe fp_math or floating_point_math or floating_point or fp instead of math.

I think that I prefer this last form (because it does not repeat 'fast' and 
also makes our extension a pure superset of the standard pragma).

What do you want to name the other flags? I'd prefer if they're grammatically 
consistent. Maybe we should stick closely to the command-line options, and have:

  fp_contract(on/off/fast)
  unsafe_optimizations(on/off)
  finite_only(on/off)

What do you think?


https://reviews.llvm.org/D31276



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


[PATCH] D30739: [OpenMP] "declare simd" for AArch64 Advanced SIMD.

2017-03-23 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli planned changes to this revision.
fpetrogalli added a comment.

Dear all,

thank you for reviewing this patch. We found out an error in the spec and would 
like to fix it before things are used.

I will soon update this patch.

Thanks,

Francesco


https://reviews.llvm.org/D30739



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


[PATCH] D31276: Add #pragma clang fast_math

2017-03-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D31276#708968, @anemet wrote:

> Thanks very much, Aaron!  It would be great if you could also look at the 
> three patches that add support for the generation of the new FMF 'contract' 
> for -ffp-contract=fast.  I've added them in the dependencies of this 
> revision.  (https://reviews.llvm.org/D31168 is not really a prerequisite but 
> I am planning to commit the patches in this order.)


I'll take a look, but feel less qualified to give a LGTM to those.


https://reviews.llvm.org/D31276



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


[PATCH] D28213: [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin

2017-03-23 Thread Michał Górny via Phabricator via cfe-commits
mgorny reopened this revision.
mgorny added a comment.
This revision is now accepted and ready to land.

Reopening since it has been reverted.


Repository:
  rL LLVM

https://reviews.llvm.org/D28213



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


[PATCH] D31289: [analyzer] Fix symbolication for unknown unary increment/decrement results.

2017-03-23 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

Looks good to me.


https://reviews.llvm.org/D31289



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


[PATCH] D31276: Add #pragma clang fast_math

2017-03-23 Thread Adam Nemet via Phabricator via cfe-commits
anemet added a comment.

Thanks very much, Aaron!  It would be great if you could also look at the three 
patches that add support for the generation of the new FMF 'contract' for 
-ffp-contract=fast.  I've added them in the dependencies of this revision.  
(https://reviews.llvm.org/D31168 is not really a prerequisite but I am planning 
to commit the patches in this order.)


https://reviews.llvm.org/D31276



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


[PATCH] D31276: Add #pragma clang fast_math

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

LGTM!


https://reviews.llvm.org/D31276



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


[PATCH] D30810: Preserve vec3 type.

2017-03-23 Thread JinGu Kang via Phabricator via cfe-commits
jaykang10 updated this revision to Diff 92829.
jaykang10 added a comment.

Preserved vec3 type on __builtin_astype.


https://reviews.llvm.org/D30810

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenOpenCL/preserve_vec3.cl

Index: test/CodeGenOpenCL/preserve_vec3.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/preserve_vec3.cl
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown -fpreserve-vec3-type  | FileCheck %s
+
+typedef float float3 __attribute__((ext_vector_type(3)));
+typedef float float4 __attribute__((ext_vector_type(4)));
+
+void kernel foo(global float3 *a, global float3 *b) {
+  // CHECK: %[[LOAD_A:.*]] = load <3 x float>, <3 x float> addrspace(1)* %a
+  // CHECK: store <3 x float> %[[LOAD_A]], <3 x float> addrspace(1)* %b
+  *b = *a;
+}
+
+void kernel float4_to_float3(global float3 *a, global float4 *b) {
+  // CHECK: %[[LOAD_A:.*]] = load <4 x float>, <4 x float> addrspace(1)* %b, align 16
+  // CHECK: %[[ASTYPE:.*]] = shufflevector <4 x float> %[[LOAD_A]], <4 x float> undef, <3 x i32> 
+  // CHECK: store <3 x float> %[[ASTYPE:.*]], <3 x float> addrspace(1)* %a, align 16
+  *a = __builtin_astype(*b, float3);
+}
+
+void kernel float3_to_float4(global float3 *a, global float4 *b) {
+  // CHECK: %[[LOAD_A:.*]] = load <3 x float>, <3 x float> addrspace(1)* %a, align 16
+  // CHECK: %[[ASTYPE:.*]] = shufflevector <3 x float> %[[LOAD_A]], <3 x float> undef, <4 x i32> 
+  // CHECK: store <4 x float> %[[ASTYPE:.*]], <4 x float> addrspace(1)* %b, align 16
+  *b = __builtin_astype(*a, float4);
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -713,6 +713,7 @@
 }
   }
 
+  Opts.PreserveVec3Type = Args.hasArg(OPT_fpreserve_vec3_type);
   Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
   Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument);
   Opts.XRayInstructionThreshold =
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -3589,19 +3589,26 @@
   // vector to get a vec4, then a bitcast if the target type is different.
   if (NumElementsSrc == 3 && NumElementsDst != 3) {
 Src = ConvertVec3AndVec4(Builder, CGF, Src, 4);
-Src = createCastsForTypeOfSameSize(Builder, CGF.CGM.getDataLayout(), Src,
-   DstTy);
+
+if (!CGF.CGM.getCodeGenOpts().PreserveVec3Type) {
+  Src = createCastsForTypeOfSameSize(Builder, CGF.CGM.getDataLayout(), Src,
+ DstTy);
+}
+
 Src->setName("astype");
 return Src;
   }
 
   // Going from non-vec3 to vec3 is a special case and requires a bitcast
   // to vec4 if the original type is not vec4, then a shuffle vector to
   // get a vec3.
   if (NumElementsSrc != 3 && NumElementsDst == 3) {
-auto Vec4Ty = llvm::VectorType::get(DstTy->getVectorElementType(), 4);
-Src = createCastsForTypeOfSameSize(Builder, CGF.CGM.getDataLayout(), Src,
-   Vec4Ty);
+if (!CGF.CGM.getCodeGenOpts().PreserveVec3Type) {
+  auto Vec4Ty = llvm::VectorType::get(DstTy->getVectorElementType(), 4);
+  Src = createCastsForTypeOfSameSize(Builder, CGF.CGM.getDataLayout(), Src,
+ Vec4Ty);
+}
+
 Src = ConvertVec3AndVec4(Builder, CGF, Src, 3);
 Src->setName("astype");
 return Src;
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -1369,26 +1369,28 @@
QualType TBAABaseType,
uint64_t TBAAOffset,
bool isNontemporal) {
-  // For better performance, handle vector loads differently.
-  if (Ty->isVectorType()) {
-const llvm::Type *EltTy = Addr.getElementType();
-
-const auto *VTy = cast(EltTy);
-
-// Handle vectors of size 3 like size 4 for better performance.
-if (VTy->getNumElements() == 3) {
-
-  // Bitcast to vec4 type.
-  llvm::VectorType *vec4Ty = llvm::VectorType::get(VTy->getElementType(),
- 4);
-  Address Cast = Builder.CreateElementBitCast(Addr, vec4Ty, "castToVec4");
-  // Now load value.
-  llvm::Value *V = Builder.CreateLoad(Cast, Volatile, "loadVec4");
-
-  // Shuffle vector to get vec3.
-  V = Builder.CreateShuffleVector(V, llvm::UndefValue::get(vec4Ty),
-  {0, 1, 2}, "extractVec");
-  

[PATCH] D31276: Add #pragma clang fast_math

2017-03-23 Thread Adam Nemet via Phabricator via cfe-commits
anemet added inline comments.



Comment at: docs/LanguageExtensions.rst:2321
+specified for a section of the source code.  This pragma can only appear at
+file scope or at the start of a compound statement.  When using within a
+compound statement, the pragma is active within the scope of the compound

aaron.ballman wrote:
> By "start of a compound statement", does that include or exclude things like 
> comments? e.g., is this valid?
> ```
> {
>   // Disable clang's fast-math
>   #pragma clang fast_math contract_fast(off)
> }
> ```
Excluding comments.  Added the words.

FTR, there is also test coverage for this already in the patch.


https://reviews.llvm.org/D31276



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


r298622 - [index] When indexing system headers make sure to report important reference relations

2017-03-23 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Thu Mar 23 11:34:47 2017
New Revision: 298622

URL: http://llvm.org/viewvc/llvm-project?rev=298622=rev
Log:
[index] When indexing system headers make sure to report important reference 
relations

Even if we exclude plain reference occurrences, we should include 
relation-based references, like the 'base' one.

rdar://31010737

Added:
cfe/trunk/test/Index/Core/Inputs/sys/
cfe/trunk/test/Index/Core/Inputs/sys/system-head.h
cfe/trunk/test/Index/Core/index-system.mm
Modified:
cfe/trunk/include/clang/Index/IndexSymbol.h
cfe/trunk/lib/Index/IndexSymbol.cpp
cfe/trunk/lib/Index/IndexingContext.cpp

Modified: cfe/trunk/include/clang/Index/IndexSymbol.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/IndexSymbol.h?rev=298622=298621=298622=diff
==
--- cfe/trunk/include/clang/Index/IndexSymbol.h (original)
+++ cfe/trunk/include/clang/Index/IndexSymbol.h Thu Mar 23 11:34:47 2017
@@ -132,6 +132,8 @@ bool isFunctionLocalSymbol(const Decl *D
 
 void applyForEachSymbolRole(SymbolRoleSet Roles,
 llvm::function_ref Fn);
+bool applyForEachSymbolRoleInterruptible(SymbolRoleSet Roles,
+llvm::function_ref Fn);
 void printSymbolRoles(SymbolRoleSet Roles, raw_ostream );
 
 /// \returns true if no name was printed, false otherwise.

Modified: cfe/trunk/lib/Index/IndexSymbol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=298622=298621=298622=diff
==
--- cfe/trunk/lib/Index/IndexSymbol.cpp (original)
+++ cfe/trunk/lib/Index/IndexSymbol.cpp Thu Mar 23 11:34:47 2017
@@ -321,11 +321,12 @@ SymbolInfo index::getSymbolInfo(const De
   return Info;
 }
 
-void index::applyForEachSymbolRole(SymbolRoleSet Roles,
-   llvm::function_ref Fn) {
+bool index::applyForEachSymbolRoleInterruptible(SymbolRoleSet Roles,
+   llvm::function_ref Fn) {
 #define APPLY_FOR_ROLE(Role) \
   if (Roles & (unsigned)SymbolRole::Role) \
-Fn(SymbolRole::Role)
+if (!Fn(SymbolRole::Role)) \
+  return false;
 
   APPLY_FOR_ROLE(Declaration);
   APPLY_FOR_ROLE(Definition);
@@ -347,6 +348,16 @@ void index::applyForEachSymbolRole(Symbo
   APPLY_FOR_ROLE(RelationIBTypeOf);
 
 #undef APPLY_FOR_ROLE
+
+  return true;
+}
+
+void index::applyForEachSymbolRole(SymbolRoleSet Roles,
+   llvm::function_ref Fn) {
+  applyForEachSymbolRoleInterruptible(Roles, [&](SymbolRole r) -> bool {
+Fn(r);
+return true;
+  });
 }
 
 void index::printSymbolRoles(SymbolRoleSet Roles, raw_ostream ) {

Modified: cfe/trunk/lib/Index/IndexingContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexingContext.cpp?rev=298622=298621=298622=diff
==
--- cfe/trunk/lib/Index/IndexingContext.cpp (original)
+++ cfe/trunk/lib/Index/IndexingContext.cpp Thu Mar 23 11:34:47 2017
@@ -204,6 +204,49 @@ static const Decl *getCanonicalDecl(cons
   return D;
 }
 
+static bool shouldReportOccurrenceForSystemDeclOnlyMode(
+bool IsRef, SymbolRoleSet Roles, ArrayRef Relations) {
+  if (!IsRef)
+return true;
+
+  auto acceptForRelation = [](SymbolRoleSet roles) -> bool {
+bool accept = false;
+applyForEachSymbolRoleInterruptible(roles, [](SymbolRole r) -> bool 
{
+  switch (r) {
+  case SymbolRole::RelationChildOf:
+  case SymbolRole::RelationBaseOf:
+  case SymbolRole::RelationOverrideOf:
+  case SymbolRole::RelationExtendedBy:
+  case SymbolRole::RelationAccessorOf:
+  case SymbolRole::RelationIBTypeOf:
+accept = true;
+return false;
+  case SymbolRole::Declaration:
+  case SymbolRole::Definition:
+  case SymbolRole::Reference:
+  case SymbolRole::Read:
+  case SymbolRole::Write:
+  case SymbolRole::Call:
+  case SymbolRole::Dynamic:
+  case SymbolRole::AddressOf:
+  case SymbolRole::Implicit:
+  case SymbolRole::RelationReceivedBy:
+  case SymbolRole::RelationCalledBy:
+  case SymbolRole::RelationContainedBy:
+return true;
+  }
+});
+return accept;
+  };
+
+  for (auto  : Relations) {
+if (acceptForRelation(Rel.Roles))
+  return true;
+  }
+
+  return false;
+}
+
 bool IndexingContext::handleDeclOccurrence(const Decl *D, SourceLocation Loc,
bool IsRef, const Decl *Parent,
SymbolRoleSet Roles,
@@ -239,7 +282,7 @@ bool IndexingContext::handleDeclOccurren
 case IndexingOptions::SystemSymbolFilterKind::None:
   return true;
 case 

[PATCH] D31276: Add #pragma clang fast_math

2017-03-23 Thread Adam Nemet via Phabricator via cfe-commits
anemet updated this revision to Diff 92825.
anemet marked 4 inline comments as done.
anemet added a comment.

Address Aaron's comments.  Also add a code example to the documentation.


https://reviews.llvm.org/D31276

Files:
  docs/LanguageExtensions.rst
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/TokenKinds.def
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  lib/Parse/ParsePragma.cpp
  lib/Parse/ParseStmt.cpp
  lib/Parse/Parser.cpp
  lib/Sema/SemaAttr.cpp
  test/CodeGen/fp-contract-fast-pragma.cpp
  test/Parser/cxx11-stmt-attributes.cpp
  test/Parser/pragma-fast-math.cpp

Index: test/Parser/pragma-fast-math.cpp
===
--- /dev/null
+++ test/Parser/pragma-fast-math.cpp
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+void test_0(int *List, int Length) {
+/* expected-error@+1 {{missing option; expected contract_fast}} */
+#pragma clang fast_math
+  for (int i = 0; i < Length; i++) {
+List[i] = i;
+  }
+}
+void test_1(int *List, int Length) {
+/* expected-error@+1 {{invalid option 'blah'; expected contract_fast}} */
+#pragma clang fast_math blah
+  for (int i = 0; i < Length; i++) {
+List[i] = i;
+  }
+}
+
+void test_3(int *List, int Length) {
+/* expected-error@+1 {{expected '('}} */
+#pragma clang fast_math contract_fast on
+  for (int i = 0; i < Length; i++) {
+List[i] = i;
+  }
+}
+
+void test_4(int *List, int Length) {
+/* expected-error@+1 {{unexpected argument 'while' to '#pragma clang fast_math contract_fast'; expected 'on' or 'off'}} */
+#pragma clang fast_math contract_fast(while)
+  for (int i = 0; i < Length; i++) {
+List[i] = i;
+  }
+}
+
+void test_5(int *List, int Length) {
+/* expected-error@+1 {{unexpected argument 'maybe' to '#pragma clang fast_math contract_fast'; expected 'on' or 'off'}} */
+#pragma clang fast_math contract_fast(maybe)
+  for (int i = 0; i < Length; i++) {
+List[i] = i;
+  }
+}
+
+void test_6(int *List, int Length) {
+/* expected-error@+1 {{expected ')'}} */
+#pragma clang fast_math contract_fast(on
+  for (int i = 0; i < Length; i++) {
+List[i] = i;
+  }
+}
+
+void test_7(int *List, int Length) {
+/* expected-warning@+1 {{extra tokens at end of '#pragma clang fast_math' - ignored}} */
+#pragma clang fast_math contract_fast(on) *
+  for (int i = 0; i < Length; i++) {
+List[i] = i;
+  }
+}
+
+void test_8(int *List, int Length) {
+  for (int i = 0; i < Length; i++) {
+List[i] = i;
+/* expected-error@+1 {{'#pragma clang fast_math' can only appear at file scope or at the start of a compound statement}} */
+#pragma clang fast_math contract_fast(on)
+  }
+}
Index: test/Parser/cxx11-stmt-attributes.cpp
===
--- test/Parser/cxx11-stmt-attributes.cpp
+++ test/Parser/cxx11-stmt-attributes.cpp
@@ -80,5 +80,6 @@
   {
 [[ ]] // expected-error {{an attribute list cannot appear here}}
 #pragma STDC FP_CONTRACT ON // expected-error {{can only appear at file scope or at the start of a compound statement}}
+#pragma clang fast_math contract_fast(on) // expected-error {{can only appear at file scope or at the start of a compound statement}}
   }
 }
Index: test/CodeGen/fp-contract-fast-pragma.cpp
===
--- /dev/null
+++ test/CodeGen/fp-contract-fast-pragma.cpp
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -O3 -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s
+
+// Is FP_CONTRACT honored in a simple case?
+float fp_contract_1(float a, float b, float c) {
+// CHECK: _Z13fp_contract_1fff
+// CHECK: %[[M:.+]] = fmul contract float %a, %b
+// CHECK-NEXT: fadd contract float %[[M]], %c
+#pragma clang fast_math contract_fast(on)
+  return a * b + c;
+}
+
+// Is FP_CONTRACT state cleared on exiting compound statements?
+float fp_contract_2(float a, float b, float c) {
+  // CHECK: _Z13fp_contract_2fff
+  // CHECK: %[[M:.+]] = fmul float %a, %b
+  // CHECK-NEXT: fadd float %[[M]], %c
+  {
+#pragma clang fast_math contract_fast(on)
+  }
+  return a * b + c;
+}
+
+// Does FP_CONTRACT survive template instantiation?
+class Foo {};
+Foo operator+(Foo, Foo);
+
+template 
+T template_muladd(T a, T b, T c) {
+#pragma clang fast_math contract_fast(on)
+  return a * b + c;
+}
+
+float fp_contract_3(float a, float b, float c) {
+  // CHECK: _Z13fp_contract_3fff
+  // CHECK: %[[M:.+]] = fmul contract float %a, %b
+  // CHECK-NEXT: fadd contract float %[[M]], %c
+  return template_muladd(a, b, c);
+}
+
+template 
+class fp_contract_4 {
+  float method(float a, float b, float c) {
+#pragma clang fast_math contract_fast(on)
+return a * b + c;
+  }
+};
+
+template class fp_contract_4;
+// CHECK: _ZN13fp_contract_4IiE6methodEfff
+// CHECK: %[[M:.+]] = fmul contract float %a, %b
+// CHECK-NEXT: fadd contract float %[[M]], %c
+
+// Check file-scoped FP_CONTRACT
+#pragma clang fast_math contract_fast(on)
+float fp_contract_5(float a, float b, 

[clang-tools-extra] r298621 - [clang-tidy] Fix treating non-space whitespaces in checks list.

2017-03-23 Thread Marek Kurdej via cfe-commits
Author: mkurdej
Date: Thu Mar 23 11:32:06 2017
New Revision: 298621

URL: http://llvm.org/viewvc/llvm-project?rev=298621=rev
Log:
[clang-tidy] Fix treating non-space whitespaces in checks list.

Summary:
This furtherly improves r295303: [clang-tidy] Ignore spaces between globs in 
the Checks option.
Trims all whitespaces and not only spaces and correctly computes the offset of 
the checks list (taking the size before trimming).

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: cfe-commits, JDevlieghere

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

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp

clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=298621=298620=298621=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Thu Mar 
23 11:32:06 2017
@@ -1,618 +1,619 @@
-//===--- tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp --=== 
//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-///
-///  \file This file implements ClangTidyDiagnosticConsumer, ClangTidyContext
-///  and ClangTidyError classes.
-///
-///  This tool uses the Clang Tooling infrastructure, see
-///http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html
-///  for details on setting it up with LLVM source tree.
-///
-//===--===//
-
-#include "ClangTidyDiagnosticConsumer.h"
-#include "ClangTidyOptions.h"
-#include "clang/AST/ASTDiagnostic.h"
-#include "clang/Basic/DiagnosticOptions.h"
-#include "clang/Frontend/DiagnosticRenderer.h"
-#include "llvm/ADT/SmallString.h"
-#include 
-#include 
-using namespace clang;
-using namespace tidy;
-
-namespace {
-class ClangTidyDiagnosticRenderer : public DiagnosticRenderer {
-public:
-  ClangTidyDiagnosticRenderer(const LangOptions ,
-  DiagnosticOptions *DiagOpts,
-  ClangTidyError )
-  : DiagnosticRenderer(LangOpts, DiagOpts), Error(Error) {}
-
-protected:
-  void emitDiagnosticMessage(SourceLocation Loc, PresumedLoc PLoc,
- DiagnosticsEngine::Level Level, StringRef Message,
- ArrayRef Ranges,
- const SourceManager *SM,
- DiagOrStoredDiag Info) override {
-// Remove check name from the message.
-// FIXME: Remove this once there's a better way to pass check names than
-// appending the check name to the message in ClangTidyContext::diag and
-// using getCustomDiagID.
-std::string CheckNameInMessage = " [" + Error.DiagnosticName + "]";
-if (Message.endswith(CheckNameInMessage))
-  Message = Message.substr(0, Message.size() - CheckNameInMessage.size());
-
-auto TidyMessage = Loc.isValid()
-   ? tooling::DiagnosticMessage(Message, *SM, Loc)
-   : tooling::DiagnosticMessage(Message);
-if (Level == DiagnosticsEngine::Note) {
-  Error.Notes.push_back(TidyMessage);
-  return;
-}
-assert(Error.Message.Message.empty() && "Overwriting a diagnostic 
message");
-Error.Message = TidyMessage;
-  }
-
-  void emitDiagnosticLoc(SourceLocation Loc, PresumedLoc PLoc,
- DiagnosticsEngine::Level Level,
- ArrayRef Ranges,
- const SourceManager ) override {}
-
-  void emitCodeContext(SourceLocation Loc, DiagnosticsEngine::Level Level,
-   SmallVectorImpl ,
-   ArrayRef Hints,
-   const SourceManager ) override {
-assert(Loc.isValid());
-for (const auto  : Hints) {
-  CharSourceRange Range = FixIt.RemoveRange;
-  assert(Range.getBegin().isValid() && Range.getEnd().isValid() &&
- "Invalid range in the fix-it hint.");
-  assert(Range.getBegin().isFileID() && Range.getEnd().isFileID() &&
- "Only file locations supported in fix-it hints.");
-
-  tooling::Replacement Replacement(SM, Range, FixIt.CodeToInsert);
-  llvm::Error Err = Error.Fix[Replacement.getFilePath()].add(Replacement);
-  // FIXME: better error handling (at least, don't let other replacements 
be
-  // applied).
-  if (Err) {
-llvm::errs() << "Fix conflicts with existing fix! "
- << llvm::toString(std::move(Err)) << "\n";
-

[clang-tools-extra] r298619 - [clang-tidy] Don't use groups in the big regexy filter

2017-03-23 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Mar 23 11:29:39 2017
New Revision: 298619

URL: http://llvm.org/viewvc/llvm-project?rev=298619=rev
Log:
[clang-tidy] Don't use groups in the big regexy filter

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

Modified:
clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py

Modified: clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py?rev=298619=298618=298619=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py Thu Mar 23 
11:29:39 2017
@@ -182,7 +182,7 @@ def main():
 tmpdir = tempfile.mkdtemp()
 
   # Build up a big regexy filter from all command line arguments.
-  file_name_re = re.compile('(' + ')|('.join(args.files) + ')')
+  file_name_re = re.compile('|'.join(args.files))
 
   try:
 # Spin up a bunch of tidy-launching threads.


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


[PATCH] D30567: [clang-tidy] Fix treating non-space whitespaces in checks list.

2017-03-23 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

In https://reviews.llvm.org/D30567#708797, @alexfh wrote:

> Do you have commit rights?


Yes, I will commit this ASAP.


https://reviews.llvm.org/D30567



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


[libcxx] r298618 - Update the algorithm tests to not use the (deprecated) function binders. No functional change.

2017-03-23 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Mar 23 11:13:50 2017
New Revision: 298618

URL: http://llvm.org/viewvc/llvm-project?rev=298618=rev
Log:
Update the algorithm tests to not use the (deprecated) function binders. No 
functional change.

Modified:

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp

libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp
libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp

libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp

Modified: 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp?rev=298618=298617=298618=diff
==
--- 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp
 Thu Mar 23 11:13:50 2017
@@ -21,6 +21,8 @@
 
 #include "test_iterators.h"
 
+bool equalToTwo(int v) { return v == 2; }
+
 template 
 void
 test()
@@ -28,8 +30,8 @@ test()
 int ia[] = {0, 1, 2, 3, 4, 2, 3, 4, 2};
 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
 int ib[sa];
-OutIter r = std::remove_copy_if(InIter(ia), InIter(ia+sa), OutIter(ib),
-std::bind2nd(std::equal_to(), 2));
+OutIter r = std::remove_copy_if(InIter(ia), InIter(ia+sa), 
+OutIter(ib), equalToTwo);
 assert(base(r) == ib + sa-3);
 assert(ib[0] == 0);
 assert(ib[1] == 1);

Modified: 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp?rev=298618=298617=298618=diff
==
--- 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp
 Thu Mar 23 11:13:50 2017
@@ -23,6 +23,8 @@
 
 #include "test_iterators.h"
 
+bool equalToTwo(int v) { return v == 2; }
+
 template 
 void
 test()
@@ -30,8 +32,8 @@ test()
 int ia[] = {0, 1, 2, 3, 4};
 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
 int ib[sa] = {0};
-OutIter r = std::replace_copy_if(InIter(ia), InIter(ia+sa), OutIter(ib),
- std::bind2nd(std::equal_to(), 2), 5);
+OutIter r = std::replace_copy_if(InIter(ia), InIter(ia+sa),
+ OutIter(ib), equalToTwo, 5);
 assert(base(r) == ib + sa);
 assert(ib[0] == 0);
 assert(ib[1] == 1);

Modified: 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp?rev=298618=298617=298618=diff
==
--- 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp
 Thu Mar 23 11:13:50 2017
@@ -22,13 +22,15 @@
 
 #include "test_iterators.h"
 
+bool equalToTwo(int v) { return v == 2; }
+
 template 
 void
 test()
 {
 int ia[] = {0, 1, 2, 3, 4};
 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
-std::replace_if(Iter(ia), Iter(ia+sa), std::bind2nd(std::equal_to(), 
2), 5);
+std::replace_if(Iter(ia), Iter(ia+sa), equalToTwo, 5);
 assert(ia[0] == 0);
 assert(ia[1] == 1);
 assert(ia[2] == 5);

Modified: 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp?rev=298618=298617=298618=diff
==
--- 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp
 Thu Mar 23 11:13:50 2017
@@ -21,6 +21,8 @@
 
 #include "test_iterators.h"
 
+int plusOne(int v) { return v + 1; }
+
 template 
 

[PATCH] D31288: [libclang] Bury dead TemporaryFiles

2017-03-23 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

kill it with fire


https://reviews.llvm.org/D31288



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


[PATCH] D31276: Add #pragma clang fast_math

2017-03-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: docs/LanguageExtensions.rst:2319
+
+The ``#pragma clang fast_math`` allows floating-point fast-math options to be
+specified for a section of the source code.  This pragma can only appear at

Missing "pragma" in front of "allows".



Comment at: docs/LanguageExtensions.rst:2320
+The ``#pragma clang fast_math`` allows floating-point fast-math options to be
+specified for a section of the source code.  This pragma can only appear at
+file scope or at the start of a compound statement.  When using within a

Remove double spaces (applies elsewhere).



Comment at: docs/LanguageExtensions.rst:2321
+specified for a section of the source code.  This pragma can only appear at
+file scope or at the start of a compound statement.  When using within a
+compound statement, the pragma is active within the scope of the compound

By "start of a compound statement", does that include or exclude things like 
comments? e.g., is this valid?
```
{
  // Disable clang's fast-math
  #pragma clang fast_math contract_fast(off)
}
```



Comment at: docs/LanguageExtensions.rst:2325
+
+Currently only FP contraction can be controlled with the pragma. ``#pragma
+clang fast_math contract_fast(on)`` enables contraction of a mulitply and an

Comma after Currently.


https://reviews.llvm.org/D31276



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


[PATCH] D31289: [analyzer] Fix symbolication for unknown unary increment/decrement results.

2017-03-23 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.

If result of an unary increment or decrement is unknown, conjure a symbol to 
represent it based on the operator expression, not on the sub-expression.

In this particular test case, result of a LocAsInteger increment is unknown, 
and it gets symbolicated to an `int *`-type symbol, because sub-expression is 
an lvalue. This causes a crash later when we're trying to compare a Loc and a 
NonLoc.


https://reviews.llvm.org/D31289

Files:
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/Analysis/casts.c


Index: test/Analysis/casts.c
===
--- test/Analysis/casts.c
+++ test/Analysis/casts.c
@@ -118,3 +118,8 @@
   extern float globalFloat;
   clang_analyzer_eval(globalFloat); // expected-warning{{UNKNOWN}}
 }
+
+void locAsIntegerCasts(void *p) {
+  int x = (int) p;
+  clang_analyzer_eval(++x < 10); // no-crash // expected-warning{{UNKNOWN}}
+}
Index: lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -1054,7 +1054,7 @@
 // Conjure a new symbol if necessary to recover precision.
 if (Result.isUnknown()){
   DefinedOrUnknownSVal SymVal =
-svalBuilder.conjureSymbolVal(nullptr, Ex, LCtx,
+svalBuilder.conjureSymbolVal(nullptr, U, LCtx,
  currBldrCtx->blockCount());
   Result = SymVal;
 


Index: test/Analysis/casts.c
===
--- test/Analysis/casts.c
+++ test/Analysis/casts.c
@@ -118,3 +118,8 @@
   extern float globalFloat;
   clang_analyzer_eval(globalFloat); // expected-warning{{UNKNOWN}}
 }
+
+void locAsIntegerCasts(void *p) {
+  int x = (int) p;
+  clang_analyzer_eval(++x < 10); // no-crash // expected-warning{{UNKNOWN}}
+}
Index: lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -1054,7 +1054,7 @@
 // Conjure a new symbol if necessary to recover precision.
 if (Result.isUnknown()){
   DefinedOrUnknownSVal SymVal =
-svalBuilder.conjureSymbolVal(nullptr, Ex, LCtx,
+svalBuilder.conjureSymbolVal(nullptr, U, LCtx,
  currBldrCtx->blockCount());
   Result = SymVal;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29599: Clang Changes for alloc_align

2017-03-23 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 92814.
erichkeane added a comment.

Update test based on the corresponding LLVM change.


https://reviews.llvm.org/D29599

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Sema/Sema.h
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/CodeGen/alloc-align-attr.c
  test/Sema/alloc-align-attr.c
  test/SemaCXX/alloc-align-attr.cpp

Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -4370,7 +4370,11 @@
   llvm::ConstantInt *AlignmentCI = cast(Alignment);
   EmitAlignmentAssumption(Ret.getScalarVal(), AlignmentCI->getZExtValue(),
   OffsetValue);
+} else if (const auto *AA = TargetDecl->getAttr()) {
+  llvm::Value *ParamVal = IRCallArgs[AA->getParamIndex() - 1];
+  EmitAlignmentAssumption(Ret.getScalarVal(), ParamVal);
 }
+
   }
 
   return Ret;
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -2465,6 +2465,12 @@
   PeepholeProtection protectFromPeepholes(RValue rvalue);
   void unprotectFromPeepholes(PeepholeProtection protection);
 
+  void EmitAlignmentAssumption(llvm::Value *PtrValue, llvm::Value *Alignment,
+   llvm::Value *OffsetValue = nullptr) {
+Builder.CreateAlignmentAssumption(CGM.getDataLayout(), PtrValue, Alignment,
+  OffsetValue);
+  }
+
   //======//
   // Statement Emission
   //======//
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -168,6 +168,16 @@
 Aligned->getSpellingListIndex());
 }
 
+static void instantiateDependentAllocAlignAttr(
+Sema , const MultiLevelTemplateArgumentList ,
+const AllocAlignAttr *Align, Decl *New) {
+  Expr *Param = IntegerLiteral::Create(
+  S.getASTContext(), llvm::APInt(64, Align->getParamIndex()),
+  S.getASTContext().UnsignedLongLongTy, Align->getLocation());
+  S.AddAllocAlignAttr(Align->getLocation(), New, Param,
+  Align->getSpellingListIndex());
+}
+
 static Expr *instantiateDependentFunctionAttrCondition(
 Sema , const MultiLevelTemplateArgumentList ,
 const Attr *A, Expr *OldCond, const Decl *Tmpl, FunctionDecl *New) {
@@ -352,6 +362,12 @@
   continue;
 }
 
+if (const auto *AllocAlign = dyn_cast(TmplAttr)) {
+  instantiateDependentAllocAlignAttr(*this, TemplateArgs, AllocAlign, New);
+  continue;
+}
+
+
 if (const auto *EnableIf = dyn_cast(TmplAttr)) {
   instantiateDependentEnableIfAttr(*this, TemplateArgs, EnableIf, Tmpl,
cast(New));
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -218,21 +218,42 @@
std::greater());
 }
 
+/// \brief A helper function to provide Attribute Location for the Attr types
+/// AND the AttributeList
+template  static typename
+std::enable_if::value, SourceLocation>::type
+getAttrLoc(const AttrInfo& Attr) {
+  return Attr.getLocation();
+}
+static SourceLocation getAttrLoc(const clang::AttributeList& Attr) {
+  return Attr.getLoc();
+}
+/// \brief A helper function to provide Attribute Name for the Attr types
+/// AND the AttributeList
+template  static typename
+std::enable_if::value, const AttrInfo*>::type
+getAttrName(const AttrInfo& Attr) {
+  return 
+}
+const IdentifierInfo* getAttrName(const clang::AttributeList ) {
+  return Attr.getName();
+}
+
 /// \brief If Expr is a valid integer constant, get the value of the integer
 /// expression and return success or failure. May output an error.
-static bool checkUInt32Argument(Sema , const AttributeList ,
-const Expr *Expr, uint32_t ,
-unsigned Idx = UINT_MAX) {
+template
+static bool checkUInt32Argument(Sema , const AttrInfo& Attr, const Expr *Expr,
+uint32_t , unsigned Idx = UINT_MAX) {
   llvm::APSInt I(32);
   if (Expr->isTypeDependent() || Expr->isValueDependent() ||
   !Expr->isIntegerConstantExpr(I, S.Context)) {
 if (Idx != UINT_MAX)
-  S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_type)
-<< Attr.getName() << Idx << AANT_ArgumentIntegerConstant
+  

[PATCH] D31029: [analyzer] Fix logical not for pointers with different bit width

2017-03-23 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki marked an inline comment as done.
danielmarjamaki added a comment.

In https://reviews.llvm.org/D31029#708567, @danielmarjamaki wrote:

> In https://reviews.llvm.org/D31029#703428, @zaks.anna wrote:
>
> > Are there other cases where makeNull would need to be replaced?
>
>
> There might be. As I understand it, this is the only known case at the moment.


To clarify. The static analyser runs fine on plenty of code. I ran CSA using 
this target on a 1000's of C-files project. I think it works well.. but I can't 
guarantee there won't be any more issues.


Repository:
  rL LLVM

https://reviews.llvm.org/D31029



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


[PATCH] D31183: [OpenCL] Added parsing for OpenCL vector types.

2017-03-23 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

I think this is a good feature for the convenience of user. I've seen usage 
like this.


https://reviews.llvm.org/D31183



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


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

2017-03-23 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki updated this revision to Diff 92810.
danielmarjamaki added a comment.

Updated the patch so all the loss of precision are detected also


Repository:
  rL LLVM

https://reviews.llvm.org/D25596

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

Index: test/Analysis/conversion.c
===
--- test/Analysis/conversion.c
+++ test/Analysis/conversion.c
@@ -14,6 +14,64 @@
 S8 = U;
 }
 
+void addAssign() {
+  unsigned long L = 1000;
+  int I = -100;
+  U8 += L; // expected-warning {{Loss of precision in implicit conversion}}
+  L += I;
+}
+
+void subAssign() {
+  unsigned long L = 1000;
+  int I = -100;
+  U8 -= L; // expected-warning {{Loss of precision in implicit conversion}}
+  L -= I;
+}
+
+void mulAssign() {
+  unsigned long L = 1000;
+  int I = -1;
+  U8 *= L; // expected-warning {{Loss of precision in implicit conversion}}
+  L *= I;  // expected-warning {{Loss of sign in implicit conversion}}
+  I = 10;
+  L *= I;
+}
+
+void divAssign() {
+  unsigned long L = 1000;
+  int I = -1;
+  U8 /= L;
+  L /= I; // expected-warning {{Loss of sign in implicit conversion}}
+}
+
+void remAssign() {
+  unsigned long L = 1000;
+  int I = -1;
+  U8 %= L;
+  L %= I; // expected-warning {{Loss of sign in implicit conversion}}
+}
+
+void andAssign() {
+  unsigned long L = 1000;
+  int I = -1;
+  U8 &= L;
+  L &= I; // expected-warning {{Loss of sign in implicit conversion}}
+}
+
+void orAssign() {
+  unsigned long L = 1000;
+  int I = -1;
+  U8 |= L; // expected-warning {{Loss of precision in implicit conversion}}
+  L |= I;  // expected-warning {{Loss of sign in implicit conversion}}
+}
+
+void xorAssign() {
+  unsigned long L = 1000;
+  int I = -1;
+  U8 ^= L; // expected-warning {{Loss of precision in implicit conversion}}
+  L ^= I;  // expected-warning {{Loss of sign in implicit conversion}}
+}
+
 void init1() {
   long long A = 1LL << 60;
   short X = A; // expected-warning {{Loss of precision in implicit conversion}}
Index: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
+++ lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
@@ -41,7 +41,8 @@
   mutable std::unique_ptr BT;
 
   // Is there loss of precision
-  bool isLossOfPrecision(const ImplicitCastExpr *Cast, CheckerContext ) const;
+  bool isLossOfPrecision(const ImplicitCastExpr *Cast, QualType DestType,
+ CheckerContext ) const;
 
   // Is there loss of sign
   bool isLossOfSign(const ImplicitCastExpr *Cast, CheckerContext ) const;
@@ -73,16 +74,30 @@
   // Loss of sign/precision in binary operation.
   if (const auto *B = dyn_cast(Parent)) {
 BinaryOperator::Opcode Opc = B->getOpcode();
-if (Opc == BO_Assign || Opc == BO_AddAssign || Opc == BO_SubAssign ||
-Opc == BO_MulAssign) {
+if (Opc == BO_Assign) {
   LossOfSign = isLossOfSign(Cast, C);
-  LossOfPrecision = isLossOfPrecision(Cast, C);
+  LossOfPrecision = isLossOfPrecision(Cast, Cast->getType(), C);
+} else if (Opc == BO_AddAssign || Opc == BO_SubAssign) {
+  // No loss of sign.
+  LossOfPrecision = isLossOfPrecision(Cast, B->getLHS()->getType(), C);
+} else if (Opc == BO_MulAssign) {
+  LossOfSign = isLossOfSign(Cast, C);
+  LossOfPrecision = isLossOfPrecision(Cast, B->getLHS()->getType(), C);
+} else if (Opc == BO_DivAssign || Opc == BO_RemAssign) {
+  LossOfSign = isLossOfSign(Cast, C);
+  // No loss of precision.
+} else if (Opc == BO_AndAssign) {
+  LossOfSign = isLossOfSign(Cast, C);
+  // No loss of precision.
+} else if (Opc == BO_OrAssign || Opc == BO_XorAssign) {
+  LossOfSign = isLossOfSign(Cast, C);
+  LossOfPrecision = isLossOfPrecision(Cast, B->getLHS()->getType(), C);
 } else if (B->isRelationalOp() || B->isMultiplicativeOp()) {
   LossOfSign = isLossOfSign(Cast, C);
 }
   } else if (isa(Parent)) {
 LossOfSign = isLossOfSign(Cast, C);
-LossOfPrecision = isLossOfPrecision(Cast, C);
+LossOfPrecision = isLossOfPrecision(Cast, Cast->getType(), C);
   }
 
   if (LossOfSign || LossOfPrecision) {
@@ -113,6 +128,13 @@
unsigned long long Val) {
   ProgramStateRef State = C.getState();
   SVal EVal = C.getSVal(E);
+  if (EVal.isUnknownOrUndef())
+return false;
+  if (!EVal.getAs() && EVal.getAs()) {
+ProgramStateManager  = C.getStateManager();
+EVal =
+Mgr.getStoreManager().getBinding(State->getStore(), EVal.castAs());
+  }
   if (EVal.isUnknownOrUndef() || !EVal.getAs())
 return false;
 
@@ -153,22 +175,22 @@
 }
 
 bool ConversionChecker::isLossOfPrecision(const ImplicitCastExpr *Cast,
-CheckerContext ) const {
+  QualType DestType,
+  CheckerContext ) 

[PATCH] D29262: Fixes to modernize-use-using

2017-03-23 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Krystyna, do you need help committing the patch after you address the 
outstanding comments?


https://reviews.llvm.org/D29262



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


[PATCH] D30592: [clang-tidy] Fix diag message for catch-by-value

2017-03-23 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL298608: [clang-tidy] Fix diag message for catch-by-value 
(authored by alexfh).

Changed prior to commit:
  https://reviews.llvm.org/D30592?vs=90572=92805#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30592

Files:
  clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
  
clang-tools-extra/trunk/test/clang-tidy/misc-throw-by-value-catch-by-reference.cpp


Index: 
clang-tools-extra/trunk/test/clang-tidy/misc-throw-by-value-catch-by-reference.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/misc-throw-by-value-catch-by-reference.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/misc-throw-by-value-catch-by-reference.cpp
@@ -62,7 +62,7 @@
   try {
 testThrowFunc();
   } catch (logic_error e) {
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: catch handler catches a 
pointer value; should throw a non-pointer value and catch by reference instead 
[misc-throw-by-value-catch-by-reference]
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: catch handler catches by 
value; should catch by reference instead 
[misc-throw-by-value-catch-by-reference]
   }
 }
 
Index: 
clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
===
--- 
clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
+++ 
clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
@@ -131,22 +131,24 @@
 
 void ThrowByValueCatchByReferenceCheck::diagnoseCatchLocations(
 const CXXCatchStmt *catchStmt, ASTContext ) {
-  const char *diagMsgCatchReference = "catch handler catches a pointer value; "
-  "should throw a non-pointer value and "
-  "catch by reference instead";
   if (!catchStmt)
 return;
   auto caughtType = catchStmt->getCaughtType();
   if (caughtType.isNull())
 return;
   auto *varDecl = catchStmt->getExceptionDecl();
   if (const auto *PT = caughtType.getCanonicalType()->getAs()) {
+const char *diagMsgCatchReference = "catch handler catches a pointer 
value; "
+"should throw a non-pointer value and "
+"catch by reference instead";
 // We do not diagnose when catching pointer to strings since we also allow
 // throwing string literals.
 if (!PT->getPointeeType()->isAnyCharacterType())
   diag(varDecl->getLocStart(), diagMsgCatchReference);
   } else if (!caughtType->isReferenceType()) {
-// If it's not a pointer and not a reference then it must be thrown "by
+const char *diagMsgCatchReference = "catch handler catches by value; "
+"should catch by reference instead";
+// If it's not a pointer and not a reference then it must be caught "by
 // value". In this case we should emit a diagnosis message unless the type
 // is trivial.
 if (!caughtType.isTrivialType(context))


Index: clang-tools-extra/trunk/test/clang-tidy/misc-throw-by-value-catch-by-reference.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-throw-by-value-catch-by-reference.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-throw-by-value-catch-by-reference.cpp
@@ -62,7 +62,7 @@
   try {
 testThrowFunc();
   } catch (logic_error e) {
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: catch handler catches a pointer value; should throw a non-pointer value and catch by reference instead [misc-throw-by-value-catch-by-reference]
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: catch handler catches by value; should catch by reference instead [misc-throw-by-value-catch-by-reference]
   }
 }
 
Index: clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
@@ -131,22 +131,24 @@
 
 void ThrowByValueCatchByReferenceCheck::diagnoseCatchLocations(
 const CXXCatchStmt *catchStmt, ASTContext ) {
-  const char *diagMsgCatchReference = "catch handler catches a pointer value; "
-  "should throw a non-pointer value and "
-  "catch by reference instead";
   if (!catchStmt)
 return;
   auto caughtType = catchStmt->getCaughtType();
   if (caughtType.isNull())
 return;
   auto *varDecl = catchStmt->getExceptionDecl();
   if (const auto *PT = caughtType.getCanonicalType()->getAs()) {
+const char *diagMsgCatchReference = "catch handler catches a pointer value; "
+"should throw a 

[clang-tools-extra] r298608 - [clang-tidy] Fix diag message for catch-by-value

2017-03-23 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Mar 23 10:17:44 2017
New Revision: 298608

URL: http://llvm.org/viewvc/llvm-project?rev=298608=rev
Log:
[clang-tidy] Fix diag message for catch-by-value

Summary:
```
catch (std::exception ex)
{
}
```

Was flagged with "catch handler catches a pointer value".

Reviewers: alexfh, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: cfe-commits, JDevlieghere

Patch by Florian Gross!

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

Modified:

clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/misc-throw-by-value-catch-by-reference.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp?rev=298608=298607=298608=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp 
Thu Mar 23 10:17:44 2017
@@ -131,9 +131,6 @@ void ThrowByValueCatchByReferenceCheck::
 
 void ThrowByValueCatchByReferenceCheck::diagnoseCatchLocations(
 const CXXCatchStmt *catchStmt, ASTContext ) {
-  const char *diagMsgCatchReference = "catch handler catches a pointer value; "
-  "should throw a non-pointer value and "
-  "catch by reference instead";
   if (!catchStmt)
 return;
   auto caughtType = catchStmt->getCaughtType();
@@ -141,12 +138,17 @@ void ThrowByValueCatchByReferenceCheck::
 return;
   auto *varDecl = catchStmt->getExceptionDecl();
   if (const auto *PT = caughtType.getCanonicalType()->getAs()) {
+const char *diagMsgCatchReference = "catch handler catches a pointer 
value; "
+"should throw a non-pointer value and "
+"catch by reference instead";
 // We do not diagnose when catching pointer to strings since we also allow
 // throwing string literals.
 if (!PT->getPointeeType()->isAnyCharacterType())
   diag(varDecl->getLocStart(), diagMsgCatchReference);
   } else if (!caughtType->isReferenceType()) {
-// If it's not a pointer and not a reference then it must be thrown "by
+const char *diagMsgCatchReference = "catch handler catches by value; "
+"should catch by reference instead";
+// If it's not a pointer and not a reference then it must be caught "by
 // value". In this case we should emit a diagnosis message unless the type
 // is trivial.
 if (!caughtType.isTrivialType(context))

Modified: 
clang-tools-extra/trunk/test/clang-tidy/misc-throw-by-value-catch-by-reference.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-throw-by-value-catch-by-reference.cpp?rev=298608=298607=298608=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/misc-throw-by-value-catch-by-reference.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/misc-throw-by-value-catch-by-reference.cpp
 Thu Mar 23 10:17:44 2017
@@ -62,7 +62,7 @@ void catchByValue() {
   try {
 testThrowFunc();
   } catch (logic_error e) {
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: catch handler catches a 
pointer value; should throw a non-pointer value and catch by reference instead 
[misc-throw-by-value-catch-by-reference]
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: catch handler catches by 
value; should catch by reference instead 
[misc-throw-by-value-catch-by-reference]
   }
 }
 


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


[PATCH] D29858: [clang-tidy] Catch trivially true statements like a != 1 || a != 3

2017-03-23 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D29858#707897, @watsond wrote:

> Following up. Was this checked in? Do I need to do anything further?


Committed the patch now. Thanks for the reminder!


Repository:
  rL LLVM

https://reviews.llvm.org/D29858



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


[clang-tools-extra] r298607 - [clang-tidy] Catch trivially true statements like a != 1 || a != 3

2017-03-23 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Mar 23 10:13:54 2017
New Revision: 298607

URL: http://llvm.org/viewvc/llvm-project?rev=298607=rev
Log:
[clang-tidy] Catch trivially true statements like a != 1 || a != 3

Catch trivially true statements of the form a != 1 || a != 3. Statements like
these are likely errors. They are particularly easy to miss when handling enums:

enum State {
RUNNING,
STOPPED,
STARTING,
ENDING
}

...
if (state != RUNNING || state != STARTING)
...

Patch by Blaise Watson!

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

Modified:
clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp?rev=298607=298606=298607=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp Thu 
Mar 23 10:13:54 2017
@@ -239,6 +239,11 @@ static bool rangesFullyCoverDomain(Binar
   (OpcodeRHS == BO_LT || OpcodeRHS == BO_LE))
 return true;
 
+  // Handle cases where constants are different but both ops are !=, like:
+  // x != 5 || x != 10
+  if (OpcodeLHS == BO_NE && OpcodeRHS == BO_NE)
+return true;
+
   return false;
 }
 

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp?rev=298607=298606=298607=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp Thu 
Mar 23 10:13:54 2017
@@ -321,6 +321,8 @@ int TestRelational(int X, int Y) {
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always 
true
   if (X <= 10 || X >= 11) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always 
true
+  if (X != 7 || X != 14) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: logical expression is always 
true
 
   if (X < 7 && X < 6) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
@@ -422,6 +424,8 @@ int TestRelatiopnalWithEnum(enum Color C
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always 
false
   if (C == Red && C != Red) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always 
false
+  if (C != Red || C != Yellow) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always 
true
 
   // Should not match.
   if (C == Red || C == Yellow) return 1;


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


[PATCH] D29858: [clang-tidy] Catch trivially true statements like a != 1 || a != 3

2017-03-23 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL298607: [clang-tidy] Catch trivially true statements like a 
!= 1 || a != 3 (authored by alexfh).

Changed prior to commit:
  https://reviews.llvm.org/D29858?vs=90087=92802#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29858

Files:
  clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp


Index: clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -239,6 +239,11 @@
   (OpcodeRHS == BO_LT || OpcodeRHS == BO_LE))
 return true;
 
+  // Handle cases where constants are different but both ops are !=, like:
+  // x != 5 || x != 10
+  if (OpcodeLHS == BO_NE && OpcodeRHS == BO_NE)
+return true;
+
   return false;
 }
 
Index: clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp
@@ -321,6 +321,8 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always 
true
   if (X <= 10 || X >= 11) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always 
true
+  if (X != 7 || X != 14) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: logical expression is always 
true
 
   if (X < 7 && X < 6) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
@@ -422,6 +424,8 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always 
false
   if (C == Red && C != Red) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always 
false
+  if (C != Red || C != Yellow) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always 
true
 
   // Should not match.
   if (C == Red || C == Yellow) return 1;


Index: clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -239,6 +239,11 @@
   (OpcodeRHS == BO_LT || OpcodeRHS == BO_LE))
 return true;
 
+  // Handle cases where constants are different but both ops are !=, like:
+  // x != 5 || x != 10
+  if (OpcodeLHS == BO_NE && OpcodeRHS == BO_NE)
+return true;
+
   return false;
 }
 
Index: clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp
@@ -321,6 +321,8 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always true
   if (X <= 10 || X >= 11) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always true
+  if (X != 7 || X != 14) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: logical expression is always true
 
   if (X < 7 && X < 6) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
@@ -422,6 +424,8 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always false
   if (C == Red && C != Red) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always false
+  if (C != Red || C != Yellow) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always true
 
   // Should not match.
   if (C == Red || C == Yellow) return 1;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30567: [clang-tidy] Fix treating non-space whitespaces in checks list.

2017-03-23 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG. Thanks!

Do you have commit rights?


https://reviews.llvm.org/D30567



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


[PATCH] D31190: Publish RAIIObjectsForParser.h for external usage

2017-03-23 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev closed this revision.
v.g.vassilev added a comment.

Landed in r298606.


Repository:
  rL LLVM

https://reviews.llvm.org/D31190



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


r298606 - Publish RAIIObjectsForParser.h for external usage.

2017-03-23 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Thu Mar 23 10:11:07 2017
New Revision: 298606

URL: http://llvm.org/viewvc/llvm-project?rev=298606=rev
Log:
Publish RAIIObjectsForParser.h for external usage.

Some clients (eg the cling interpreter) need to recover their parser from
errors.

Patch by Axel Naumann (D31190)!

Added:
cfe/trunk/include/clang/Parse/RAIIObjectsForParser.h
  - copied unchanged from r298605, 
cfe/trunk/lib/Parse/RAIIObjectsForParser.h
Removed:
cfe/trunk/lib/Parse/RAIIObjectsForParser.h
Modified:
cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Parse/ParseInit.cpp
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Parse/ParsePragma.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Parse/ParseStmtAsm.cpp
cfe/trunk/lib/Parse/ParseTemplate.cpp
cfe/trunk/lib/Parse/Parser.cpp

Modified: cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp?rev=298606=298605=298606=diff
==
--- cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp (original)
+++ cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp Thu Mar 23 10:11:07 2017
@@ -12,9 +12,9 @@
 
//===--===//
 
 #include "clang/Parse/Parser.h"
-#include "RAIIObjectsForParser.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Parse/ParseDiagnostic.h"
+#include "clang/Parse/RAIIObjectsForParser.h"
 #include "clang/Sema/DeclSpec.h"
 #include "clang/Sema/Scope.h"
 using namespace clang;

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=298606=298605=298606=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Thu Mar 23 10:11:07 2017
@@ -12,7 +12,7 @@
 
//===--===//
 
 #include "clang/Parse/Parser.h"
-#include "RAIIObjectsForParser.h"
+#include "clang/Parse/RAIIObjectsForParser.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/AddressSpaces.h"

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=298606=298605=298606=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Thu Mar 23 10:11:07 2017
@@ -12,7 +12,6 @@
 
//===--===//
 
 #include "clang/Parse/Parser.h"
-#include "RAIIObjectsForParser.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/Attributes.h"
@@ -20,6 +19,7 @@
 #include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Parse/ParseDiagnostic.h"
+#include "clang/Parse/RAIIObjectsForParser.h"
 #include "clang/Sema/DeclSpec.h"
 #include "clang/Sema/ParsedTemplate.h"
 #include "clang/Sema/PrettyDeclStackTrace.h"

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=298606=298605=298606=diff
==
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Thu Mar 23 10:11:07 2017
@@ -21,10 +21,10 @@
 ///
 
//===--===//
 
-#include "RAIIObjectsForParser.h"
+#include "clang/Parse/Parser.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/Basic/PrettyStackTrace.h"
-#include "clang/Parse/Parser.h"
+#include "clang/Parse/RAIIObjectsForParser.h"
 #include "clang/Sema/DeclSpec.h"
 #include "clang/Sema/ParsedTemplate.h"
 #include "clang/Sema/Scope.h"

Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=298606=298605=298606=diff
==
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Thu Mar 23 10:11:07 2017
@@ -10,13 +10,13 @@
 // This file implements the Expression parsing implementation for C++.
 //
 
//===--===//
+#include "clang/Parse/Parser.h"
 #include "clang/AST/ASTContext.h"
-#include "RAIIObjectsForParser.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/PrettyStackTrace.h"
 #include "clang/Lex/LiteralSupport.h"
 #include "clang/Parse/ParseDiagnostic.h"

[PATCH] D31121: [clangd] Add support for vscode extension configuration

2017-03-23 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added a comment.
This revision is now accepted and ready to land.

Looks good! Sorry for the delay.


https://reviews.llvm.org/D31121



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


[PATCH] D31176: [clang-rename] Support renaming qualified symbol

2017-03-23 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clang-rename/USRFinder.cpp:200
 
+  // Also find all USRs of nested declarations.
+  NestedNameSpecifierLocFinder Finder(const_cast(Context));

ioeric wrote:
> It is unclear to me what `nested declarations` are.
But what is the nested name?  Is it the nested name specifier? Of what?



Comment at: clang-rename/USRLocFinder.cpp:195
+// Find all locations identified by the given USRs. Traverse the AST and find
+// every AST node whose USR is in the given USRs' set.
+class RenameLocFinder

I think this also does some renaming?



Comment at: clang-rename/USRLocFinder.cpp:217
+
+  // FIXME: For renaming declarations/definitions, prefix qualifiers should be
+  // filtered out.

Could you be more specific in this FIXME? I don't quite get it. Maybe an 
example?



Comment at: clang-rename/USRLocFinder.cpp:359
+
+  // Returns a list of using declarations which are needed to update.
+  const std::vector () const {

I think these are using shadows only?



Comment at: clang-rename/USRLocFinder.h:36
+/// \return Replacement for renaming.
+std::vector
+createRenameReplacement(llvm::ArrayRef USRs,

Why use `std::vector` instead of `tooling::Replacements`?


https://reviews.llvm.org/D31176



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


[PATCH] D25241: [libcxx] Improve code generation for vector::clear().

2017-03-23 Thread Bruce Mitchener via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL298601: [libcxx] Improve code generation for 
vector::clear(). (authored by brucem).

Changed prior to commit:
  https://reviews.llvm.org/D25241?vs=73790=92796#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25241

Files:
  libcxx/trunk/include/vector
  
libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp


Index: libcxx/trunk/include/vector
===
--- libcxx/trunk/include/vector
+++ libcxx/trunk/include/vector
@@ -413,8 +413,10 @@
 void
 __vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT
 {
-while (__new_last != __end_)
-__alloc_traits::destroy(__alloc(), _VSTD::__to_raw_pointer(--__end_));
+pointer __soon_to_be_end = __end_;
+while (__new_last != __soon_to_be_end)
+__alloc_traits::destroy(__alloc(), 
_VSTD::__to_raw_pointer(--__soon_to_be_end));
+__end_ = __new_last;
 }
 
 template 
Index: 
libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp
===
--- 
libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp
+++ 
libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp
@@ -0,0 +1,40 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// void clear();
+
+#include 
+#include 
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+{
+int a[] = {1, 2, 3};
+std::vector c(a, a+3);
+c.clear();
+assert(c.empty());
+LIBCPP_ASSERT(c.__invariants());
+LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
+}
+#if TEST_STD_VER >= 11
+{
+int a[] = {1, 2, 3};
+std::vector c(a, a+3);
+c.clear();
+assert(c.empty());
+LIBCPP_ASSERT(c.__invariants());
+LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
+}
+#endif
+}


Index: libcxx/trunk/include/vector
===
--- libcxx/trunk/include/vector
+++ libcxx/trunk/include/vector
@@ -413,8 +413,10 @@
 void
 __vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT
 {
-while (__new_last != __end_)
-__alloc_traits::destroy(__alloc(), _VSTD::__to_raw_pointer(--__end_));
+pointer __soon_to_be_end = __end_;
+while (__new_last != __soon_to_be_end)
+__alloc_traits::destroy(__alloc(), _VSTD::__to_raw_pointer(--__soon_to_be_end));
+__end_ = __new_last;
 }
 
 template 
Index: libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp
===
--- libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp
@@ -0,0 +1,40 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// void clear();
+
+#include 
+#include 
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+{
+int a[] = {1, 2, 3};
+std::vector c(a, a+3);
+c.clear();
+assert(c.empty());
+LIBCPP_ASSERT(c.__invariants());
+LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
+}
+#if TEST_STD_VER >= 11
+{
+int a[] = {1, 2, 3};
+std::vector c(a, a+3);
+c.clear();
+assert(c.empty());
+LIBCPP_ASSERT(c.__invariants());
+LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
+}
+#endif
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r298601 - [libcxx] Improve code generation for vector::clear().

2017-03-23 Thread Bruce Mitchener via cfe-commits
Author: brucem
Date: Thu Mar 23 09:39:23 2017
New Revision: 298601

URL: http://llvm.org/viewvc/llvm-project?rev=298601=rev
Log:
[libcxx] Improve code generation for vector::clear().

Summary:
By manipulating a local variable in the loop, when the loop can
be optimized away (due to no non-trivial destructors), this lets
it be fully optimized away and we modify the __end_ separately.

This results in a substantial improvement in the generated code.

Prior to this change, this would be generated (on x86_64):

movq(%rdi), %rdx
movq8(%rdi), %rcx
cmpq%rdx, %rcx
jeLBB2_2
leaq-12(%rcx), %rax
subq%rdx, %rax
movabsq$-6148914691236517205, %rdx ## imm = 0xAAAB
mulq%rdx
shrq$3, %rdx
notq%rdx
leaq(%rdx,%rdx,2), %rax
leaq(%rcx,%rax,4), %rax
movq%rax, 8(%rdi)

And after:

movq(%rdi), %rax
movq%rax, 8(%rdi)

This brings this in line with what other implementations do.

Subscribers: cfe-commits

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

Added:

libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp
Modified:
libcxx/trunk/include/vector

Modified: libcxx/trunk/include/vector
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/vector?rev=298601=298600=298601=diff
==
--- libcxx/trunk/include/vector (original)
+++ libcxx/trunk/include/vector Thu Mar 23 09:39:23 2017
@@ -413,8 +413,10 @@ inline _LIBCPP_INLINE_VISIBILITY
 void
 __vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT
 {
-while (__new_last != __end_)
-__alloc_traits::destroy(__alloc(), _VSTD::__to_raw_pointer(--__end_));
+pointer __soon_to_be_end = __end_;
+while (__new_last != __soon_to_be_end)
+__alloc_traits::destroy(__alloc(), 
_VSTD::__to_raw_pointer(--__soon_to_be_end));
+__end_ = __new_last;
 }
 
 template 

Added: 
libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp?rev=298601=auto
==
--- 
libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp
 (added)
+++ 
libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp
 Thu Mar 23 09:39:23 2017
@@ -0,0 +1,40 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// void clear();
+
+#include 
+#include 
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+{
+int a[] = {1, 2, 3};
+std::vector c(a, a+3);
+c.clear();
+assert(c.empty());
+LIBCPP_ASSERT(c.__invariants());
+LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
+}
+#if TEST_STD_VER >= 11
+{
+int a[] = {1, 2, 3};
+std::vector c(a, a+3);
+c.clear();
+assert(c.empty());
+LIBCPP_ASSERT(c.__invariants());
+LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
+}
+#endif
+}


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


[PATCH] D31177: [ARC][ObjC++] Use ObjC semantic rules for comparisons between a pointer and objective-c object pointer

2017-03-23 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak accepted this revision.
ahatanak added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM.


Repository:
  rL LLVM

https://reviews.llvm.org/D31177



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


[libcxx] r298600 - Use 'REQUIRES: c++98 || c++03 || c++11 || c++14' instead of the deprecated 'REQUIRES-ANY: c++98, c++03, c++11, c++14'

2017-03-23 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Mar 23 09:20:43 2017
New Revision: 298600

URL: http://llvm.org/viewvc/llvm-project?rev=298600=rev
Log:
Use 'REQUIRES: c++98 || c++03 || c++11 || c++14' instead of the deprecated 
'REQUIRES-ANY: c++98, c++03, c++11, c++14'

Modified:

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp

Modified: 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp?rev=298600=298599=298600=diff
==
--- 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
 Thu Mar 23 09:20:43 2017
@@ -8,7 +8,7 @@
 
//===--===//
 
 // 
-// REQUIRES-ANY: c++98, c++03, c++11, c++14
+// REQUIRES: c++98 || c++03 || c++11 || c++14
 
 // template
 //   requires ShuffleIterator

Modified: 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp?rev=298600=298599=298600=diff
==
--- 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
 Thu Mar 23 09:20:43 2017
@@ -8,7 +8,7 @@
 
//===--===//
 
 // 
-// REQUIRES-ANY: c++98, c++03, c++11, c++14
+// REQUIRES: c++98 || c++03 || c++11 || c++14
 
 // template 
Rand>
 //   requires ShuffleIterator


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


[PATCH] D31252: [clang-tidy] add readability-compound-statement-size check.

2017-03-23 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

Hi Roman,

Welcome to the community! As others noted, adding a separate check so similar 
functionally and implementation-wise to the existing one is not the best way to 
go here. A single check for all similar complexity limits would be a better 
solution. However, first I'd like to understand the specific use case you have 
for this check. Is there a recommendation of a certain style document to impose 
a complexity limit per-compound statement instead of a function? Should both 
limits be used? What would be the specific numbers and how should they interact 
with regard to nesting (e.g. should the warning be issued only on the innermost 
compound statement violating the rule or should it be issued on all levels)?


https://reviews.llvm.org/D31252



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


[PATCH] D25241: [libcxx] Improve code generation for vector::clear().

2017-03-23 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.

Still LGTM




Comment at: 
test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp:18
+#include "min_allocator.h"
+
+int main()

LIBCPP_ASSERT requires including test_macros.h


https://reviews.llvm.org/D25241



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


[libcxx] r298598 - One more file for the random_shuffle removal

2017-03-23 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Mar 23 08:44:06 2017
New Revision: 298598

URL: http://llvm.org/viewvc/llvm-project?rev=298598=rev
Log:
One more file for the random_shuffle removal

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=298598=298597=298598=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Thu Mar 23 08:44:06 2017
@@ -1073,6 +1073,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 #if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
 # define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
 # define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
+# define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
 #endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
 
 #endif // __cplusplus


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


[libcxx] r298597 - Remove random_shuffle in C++17. Please use shuffle instead. If you have to, you cant get it back by defining _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE before including any libc++

2017-03-23 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Mar 23 08:43:37 2017
New Revision: 298597

URL: http://llvm.org/viewvc/llvm-project?rev=298597=rev
Log:
Remove random_shuffle in C++17.  Please use shuffle instead. If you have to, 
you cant get it back by defining _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE 
before including any libc++ headers.

Added:
libcxx/trunk/test/libcxx/algorithms/alg.modifying.operations/

libcxx/trunk/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/

libcxx/trunk/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp
Modified:
libcxx/trunk/include/algorithm

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp

Modified: libcxx/trunk/include/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=298597=298596=298597=diff
==
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Thu Mar 23 08:43:37 2017
@@ -281,12 +281,12 @@ template 
 void
-random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // 
deprecated in C++14
+random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // 
deprecated in C++14, removed in C++17
 
 template 
 void
 random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
-   RandomNumberGenerator& rand);  // deprecated in C++14
+   RandomNumberGenerator& rand);  // deprecated in C++14, 
removed in C++17
 
 template
@@ -3026,6 +3026,7 @@ uniform_int_distribution<_IntType>::oper
 return static_cast(__u + __p.a());
 }
 
+#if _LIBCPP_STD_VER <= 14 || 
defined(_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE)
 class _LIBCPP_TYPE_VIS __rs_default;
 
 _LIBCPP_FUNC_VIS __rs_default __rs_get();
@@ -3095,6 +3096,7 @@ random_shuffle(_RandomAccessIterator __f
 }
 }
 }
+#endif
 
 template 

Added: 
libcxx/trunk/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp?rev=298597=auto
==
--- 
libcxx/trunk/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp
 (added)
+++ 
libcxx/trunk/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp
 Thu Mar 23 08:43:37 2017
@@ -0,0 +1,46 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template 
+// void
+// random_shuffle(RandomAccessIterator first, RandomAccessIterator last);
+// 
+// template 
+// void
+// random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
+//RandomNumberGenerator& rand);
+
+//
+//  In C++17, random_shuffle has been removed.
+//  However, for backwards compatibility, if 
_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
+//  is defined before including , then random_shuffle will be 
restored.
+
+#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
+
+#include 
+#include 
+
+struct gen
+{
+std::ptrdiff_t operator()(std::ptrdiff_t n)
+{
+return n-1;
+}
+};
+
+
+int main()
+{
+std::vector v;
+std::random_shuffle(v.begin(), v.end());
+gen r;
+std::random_shuffle(v.begin(), v.end(), r);
+}

Modified: 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp?rev=298597=298596=298597=diff
==
--- 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
 Thu Mar 23 08:43:37 2017
@@ -8,6 +8,7 @@
 
//===--===//
 
 // 
+// REQUIRES-ANY: c++98, c++03, c++11, c++14
 
 // template
 //   requires ShuffleIterator

Modified: 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
URL: 

[PATCH] D25241: [libcxx] Improve code generation for vector::clear().

2017-03-23 Thread Bruce Mitchener via Phabricator via cfe-commits
brucem added a comment.

This was accepted long ago, and then I got sidetracked for a while. Is this 
still okay to land?


https://reviews.llvm.org/D25241



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


[PATCH] D30547: [clang-tidy] Forwarding reference overload in constructors

2017-03-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/misc/ForwardingReferenceOverloadCheck.cpp:125-126
+}
+diag(Ctor->getLocation(), "function %0 can hide copy and move 
constructors")
+<< Ctor;
+  }

leanil wrote:
> aaron.ballman wrote:
> > xazax.hun wrote:
> > > aaron.ballman wrote:
> > > > xazax.hun wrote:
> > > > > aaron.ballman wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > leanil wrote:
> > > > > > > > aaron.ballman wrote:
> > > > > > > > > I think a better diagnostic might be: "constructor accepting 
> > > > > > > > > a universal reference hides the %select{copy|move|both the 
> > > > > > > > > copy and move}0 %select{constructor{|s}1"
> > > > > > > > > 
> > > > > > > > > And then provide a note ("%select{copy|move}0 constructor 
> > > > > > > > > declared here") that points to the offending copy and/or move 
> > > > > > > > > constructor.
> > > > > > > > Without checking actual constructor calls, I would have to make 
> > > > > > > > notes on every (non disabled) copy / move constructor, any time 
> > > > > > > > I produce a warning. And as the warning already states where 
> > > > > > > > the problem lies, the notes would only help people find the 
> > > > > > > > copy and move constructors. Do you think that's necessary? 
> > > > > > > The warning states where the forwarding reference constructor is, 
> > > > > > > but it doesn't state where the conflicting constructors are. When 
> > > > > > > we issue diagnostics like that, we generally use notes so that 
> > > > > > > the user can see all of the locations involved -- the user may 
> > > > > > > want to get rid of the other constructors, or they may want to 
> > > > > > > get rid of the forwarding reference constructor. Also, saying 
> > > > > > > "can hide" implies that it isn't hiding anything at all, just 
> > > > > > > that it's possible to do so. Tightening up the wording and 
> > > > > > > showing all of the locations involved solves both problems.
> > > > > > This isn't quite complete. It's still an ambiguous statement to say 
> > > > > > "it can hide"; it does hide these constructors, and we even know 
> > > > > > which ones. Emit the notes before you emit the main diagnostic and 
> > > > > > you can use the `%select` suggested originally to be specific in 
> > > > > > the diagnostic.
> > > > > We can not say for sure without looking at a concrete call whether a 
> > > > > constructor is "hidden" or not. It is always determined during the 
> > > > > overload resolution.
> > > > > 
> > > > > This check does not consider the calls, because that way it would 
> > > > > always miss the possible misuses if libraries. 
> > > > I can see the logic in that. I guess I'm thinking of it the same way we 
> > > > use the phrase "hidden" when describing code like:
> > > > ```
> > > > struct Base {
> > > >   virtual void f(int);
> > > > };
> > > > 
> > > > struct Derived : Base {
> > > >   void f(double);
> > > > };
> > > > 
> > > > ```
> > > > We claim Derived::f() hides Base::f() without considering the callers.
> > > I see. In that case maybe we should come up with a less confusing term 
> > > like hijacking overload? The constructors are still part of the overload 
> > > set, so no hiding as in the standard's nomenclature happens here, but the 
> > > overload resolution is not doing what the user would expect in these 
> > > cases. 
> > I'm also fine going back to being somewhat more wishy-washy in our phrasing 
> > (can hide).
> > 
> > What do you think about using the %select to specify what can be hidden, 
> > rather than always talking about copy and move constructors (one of which 
> > may not even be present in the user's source)?
> I think the (assumed) use of a compiler generated copy or move is similarly 
> problematic as in the case of a user defined one, so I would keep mentioning 
> both.
That would be handled automatically anyway (the select I suggested has an 
option for both). Also, you should have a test for the case involving the 
implicitly declared constructors.



Comment at: clang-tidy/misc/ForwardingReferenceOverloadCheck.cpp:127
+  << Ctor;
+  for (auto OtherCtor : Ctor->getParent()->ctors()) {
+if (OtherCtor->isCopyConstructor() || OtherCtor->isMoveConstructor()) {

Should be `const auto *` rather than just `auto`.



Comment at: clang-tidy/misc/ForwardingReferenceOverloadCheck.cpp:131
+   "%select{copy|move}0 constructor declared here", 
DiagnosticIDs::Note)
+  << OtherCtor->isMoveConstructor() << OtherCtor;
+}

This passes in too many arguments to the diagnostic, I think `OtherCtor` should 
be removed.


Repository:
  rL LLVM

https://reviews.llvm.org/D30547



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


[PATCH] D31177: [ARC][ObjC++] Use ObjC semantic rules for comparisons between a pointer and objective-c object pointer

2017-03-23 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 92783.
arphaman marked an inline comment as done.
arphaman added a comment.

The condition in the if is now more clear.


Repository:
  rL LLVM

https://reviews.llvm.org/D31177

Files:
  lib/Sema/SemaExpr.cpp
  test/SemaObjCXX/arc-ptr-comparison.mm


Index: test/SemaObjCXX/arc-ptr-comparison.mm
===
--- /dev/null
+++ test/SemaObjCXX/arc-ptr-comparison.mm
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only 
-fobjc-arc -verify %s
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only 
-verify -DNOARC %s
+#ifdef NOARC
+// expected-no-diagnostics
+#endif
+
+int testObjCComparisonRules(void *v, id x, id y) {
+  return v == x;
+#ifndef NOARC
+// expected-error@-2 {{implicit conversion of Objective-C pointer type 'id' to 
C pointer type 'void *' requires a bridged cast}}
+// expected-note@-3 {{use __bridge to convert directly (no change in 
ownership)}}
+// expected-note@-4 {{use __bridge_retained to make an ARC object available as 
a +1 'void *'}}
+#endif
+  return v >= x;
+#ifndef NOARC
+// expected-error@-2 {{implicit conversion of Objective-C pointer type 'id' to 
C pointer type 'void *' requires a bridged cast}}
+// expected-note@-3 {{use __bridge to convert directly (no change in 
ownership)}}
+// expected-note@-4 {{use __bridge_retained to make an ARC object available as 
a +1 'void *'}}
+#endif
+  return v == (id)(void *)0; // OK
+  return v == nullptr; // OK
+  return v == (void *)0;
+  return x == y;
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -9424,7 +9424,10 @@
 //   If both operands are pointers, [...] bring them to their composite
 //   pointer type.
 if ((int)LHSType->isPointerType() + (int)RHSType->isPointerType() >=
-(IsRelational ? 2 : 1)) {
+(IsRelational ? 2 : 1) &&
+(!LangOpts.ObjCAutoRefCount ||
+ !(LHSType->isObjCObjectPointerType() ||
+   RHSType->isObjCObjectPointerType( {
   if (convertPointersToCompositeType(*this, Loc, LHS, RHS))
 return QualType();
   else


Index: test/SemaObjCXX/arc-ptr-comparison.mm
===
--- /dev/null
+++ test/SemaObjCXX/arc-ptr-comparison.mm
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only -verify -DNOARC %s
+#ifdef NOARC
+// expected-no-diagnostics
+#endif
+
+int testObjCComparisonRules(void *v, id x, id y) {
+  return v == x;
+#ifndef NOARC
+// expected-error@-2 {{implicit conversion of Objective-C pointer type 'id' to C pointer type 'void *' requires a bridged cast}}
+// expected-note@-3 {{use __bridge to convert directly (no change in ownership)}}
+// expected-note@-4 {{use __bridge_retained to make an ARC object available as a +1 'void *'}}
+#endif
+  return v >= x;
+#ifndef NOARC
+// expected-error@-2 {{implicit conversion of Objective-C pointer type 'id' to C pointer type 'void *' requires a bridged cast}}
+// expected-note@-3 {{use __bridge to convert directly (no change in ownership)}}
+// expected-note@-4 {{use __bridge_retained to make an ARC object available as a +1 'void *'}}
+#endif
+  return v == (id)(void *)0; // OK
+  return v == nullptr; // OK
+  return v == (void *)0;
+  return x == y;
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -9424,7 +9424,10 @@
 //   If both operands are pointers, [...] bring them to their composite
 //   pointer type.
 if ((int)LHSType->isPointerType() + (int)RHSType->isPointerType() >=
-(IsRelational ? 2 : 1)) {
+(IsRelational ? 2 : 1) &&
+(!LangOpts.ObjCAutoRefCount ||
+ !(LHSType->isObjCObjectPointerType() ||
+   RHSType->isObjCObjectPointerType( {
   if (convertPointersToCompositeType(*this, Loc, LHS, RHS))
 return QualType();
   else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31177: [ARC][ObjC++] Use ObjC semantic rules for comparisons between a pointer and objective-c object pointer

2017-03-23 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/Sema/SemaExpr.cpp:9431
+ ? 2
+ : 1)) {
   if (convertPointersToCompositeType(*this, Loc, LHS, RHS))

ahatanak wrote:
> It wasn't clear to me why the code has to be added to the right hand side of 
> the >= operator.
> 
> Is it equivalent to adding the following code, which I think is easier to 
> understand? I'm assuming you are trying to avoid executing the statement when 
> ObjCAutoRefCount is true and either LHSType or RHSType is an objc pointer 
> type.
> 
> ```
> && (!LangOpts.ObjCAutoRefCount || (!LHSType->isObjCObjectPointerType() && 
> !RHSType->isObjCObjectPointerType()))
> ```
Yes, that's correct. I think a more clear condition would be better here, I 
agree.


Repository:
  rL LLVM

https://reviews.llvm.org/D31177



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


[PATCH] D31179: Objective-C categories should support attributes

2017-03-23 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL298589: Support attributes for Objective-C categories 
(authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D31179?vs=92454=92782#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31179

Files:
  cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Parse/ParseObjc.cpp
  cfe/trunk/lib/Sema/SemaDeclObjC.cpp
  cfe/trunk/test/SemaObjC/attr-deprecated.m
  cfe/trunk/test/SemaObjC/category-attribute.m
  cfe/trunk/test/SemaObjC/default-synthesize-3.m
  cfe/trunk/test/SemaObjC/warn-deprecated-implementations.m

Index: cfe/trunk/lib/Parse/ParseObjc.cpp
===
--- cfe/trunk/lib/Parse/ParseObjc.cpp
+++ cfe/trunk/lib/Parse/ParseObjc.cpp
@@ -278,11 +278,6 @@
 T.consumeClose();
 if (T.getCloseLocation().isInvalid())
   return nullptr;
-
-if (!attrs.empty()) { // categories don't support attributes.
-  Diag(nameLoc, diag::err_objc_no_attributes_on_category);
-  attrs.clear();
-}
 
 // Next, we need to check for any protocol references.
 assert(LAngleLoc.isInvalid() && "Cannot have already parsed protocols");
@@ -294,16 +289,11 @@
 /*consumeLastToken=*/true))
   return nullptr;
 
-Decl *CategoryType =
-Actions.ActOnStartCategoryInterface(AtLoc,
-nameId, nameLoc,
-typeParameterList,
-categoryId, categoryLoc,
-ProtocolRefs.data(),
-ProtocolRefs.size(),
-ProtocolLocs.data(),
-EndProtoLoc);
-
+Decl *CategoryType = Actions.ActOnStartCategoryInterface(
+AtLoc, nameId, nameLoc, typeParameterList, categoryId, categoryLoc,
+ProtocolRefs.data(), ProtocolRefs.size(), ProtocolLocs.data(),
+EndProtoLoc, attrs.getList());
+
 if (Tok.is(tok::l_brace))
   ParseObjCClassInstanceVariables(CategoryType, tok::objc_private, AtLoc);
   
Index: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp
@@ -258,7 +258,8 @@
   S.Diag(ND->getLocation(), diag::note_method_declared_at)
 << ND->getDeclName();
 else
-  S.Diag(ND->getLocation(), diag::note_previous_decl) << "class";
+  S.Diag(ND->getLocation(), diag::note_previous_decl)
+  << (isa(ND) ? "category" : "class");
   }
 }
 
@@ -1724,7 +1725,8 @@
 Decl * const *ProtoRefs,
 unsigned NumProtoRefs,
 const SourceLocation *ProtoLocs,
-SourceLocation EndProtoLoc) {
+SourceLocation EndProtoLoc,
+AttributeList *AttrList) {
   ObjCCategoryDecl *CDecl;
   ObjCInterfaceDecl *IDecl = getObjCInterfaceDecl(ClassName, ClassLoc, true);
 
@@ -1801,6 +1803,9 @@
 NumProtoRefs, Context); 
   }
 
+  if (AttrList)
+ProcessDeclAttributeList(TUScope, CDecl, AttrList);
+
   CheckObjCDeclScope(CDecl);
   return ActOnObjCContainerStartDefinition(CDecl);
 }
@@ -1865,9 +1870,10 @@
   CatIDecl->setImplementation(CDecl);
   // Warn on implementating category of deprecated class under 
   // -Wdeprecated-implementations flag.
-  DiagnoseObjCImplementedDeprecations(*this, 
-  dyn_cast(IDecl), 
-  CDecl->getLocation(), 2);
+  DiagnoseObjCImplementedDeprecations(
+  *this,
+  CatIDecl->isDeprecated() ? CatIDecl : dyn_cast(IDecl),
+  CDecl->getLocation(), 2);
 }
   }
 
Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -7666,7 +7666,8 @@
 Decl * const *ProtoRefs,
 unsigned NumProtoRefs,
 const SourceLocation *ProtoLocs,
-SourceLocation EndProtoLoc);
+SourceLocation EndProtoLoc,
+AttributeList *AttrList);
 
   Decl *ActOnStartClassImplementation(
 SourceLocation AtClassImplLoc,
Index: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
@@ -364,8 

r298589 - Support attributes for Objective-C categories

2017-03-23 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Mar 23 06:44:25 2017
New Revision: 298589

URL: http://llvm.org/viewvc/llvm-project?rev=298589=rev
Log:
Support attributes for Objective-C categories

rdar://31095315

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

Added:
cfe/trunk/test/SemaObjC/category-attribute.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/test/SemaObjC/attr-deprecated.m
cfe/trunk/test/SemaObjC/default-synthesize-3.m
cfe/trunk/test/SemaObjC/warn-deprecated-implementations.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=298589=298588=298589=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Thu Mar 23 06:44:25 
2017
@@ -364,8 +364,6 @@ def ext_decomp_decl_empty : ExtWarn<
 /// Objective-C parser diagnostics
 def err_expected_minus_or_plus : Error<
   "method type specifier must start with '-' or '+'">;
-def err_objc_no_attributes_on_category : Error<
-  "attributes may not be specified on a category">;
 def err_objc_missing_end : Error<"missing '@end'">;
 def note_objc_container_start : Note<
   "%select{class|protocol|category|class extension|implementation"

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=298589=298588=298589=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Mar 23 06:44:25 2017
@@ -7666,7 +7666,8 @@ public:
 Decl * const *ProtoRefs,
 unsigned NumProtoRefs,
 const SourceLocation *ProtoLocs,
-SourceLocation EndProtoLoc);
+SourceLocation EndProtoLoc,
+AttributeList *AttrList);
 
   Decl *ActOnStartClassImplementation(
 SourceLocation AtClassImplLoc,

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=298589=298588=298589=diff
==
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Thu Mar 23 06:44:25 2017
@@ -278,11 +278,6 @@ Decl *Parser::ParseObjCAtInterfaceDeclar
 T.consumeClose();
 if (T.getCloseLocation().isInvalid())
   return nullptr;
-
-if (!attrs.empty()) { // categories don't support attributes.
-  Diag(nameLoc, diag::err_objc_no_attributes_on_category);
-  attrs.clear();
-}
 
 // Next, we need to check for any protocol references.
 assert(LAngleLoc.isInvalid() && "Cannot have already parsed protocols");
@@ -294,16 +289,11 @@ Decl *Parser::ParseObjCAtInterfaceDeclar
 /*consumeLastToken=*/true))
   return nullptr;
 
-Decl *CategoryType =
-Actions.ActOnStartCategoryInterface(AtLoc,
-nameId, nameLoc,
-typeParameterList,
-categoryId, categoryLoc,
-ProtocolRefs.data(),
-ProtocolRefs.size(),
-ProtocolLocs.data(),
-EndProtoLoc);
-
+Decl *CategoryType = Actions.ActOnStartCategoryInterface(
+AtLoc, nameId, nameLoc, typeParameterList, categoryId, categoryLoc,
+ProtocolRefs.data(), ProtocolRefs.size(), ProtocolLocs.data(),
+EndProtoLoc, attrs.getList());
+
 if (Tok.is(tok::l_brace))
   ParseObjCClassInstanceVariables(CategoryType, tok::objc_private, AtLoc);
   

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=298589=298588=298589=diff
==
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Mar 23 06:44:25 2017
@@ -258,7 +258,8 @@ static void DiagnoseObjCImplementedDepre
   S.Diag(ND->getLocation(), diag::note_method_declared_at)
 << ND->getDeclName();
 else
-  S.Diag(ND->getLocation(), diag::note_previous_decl) << "class";
+  S.Diag(ND->getLocation(), diag::note_previous_decl)
+  << (isa(ND) ? "category" : "class");
   }
 }
 
@@ -1724,7 +1725,8 @@ ActOnStartCategoryInterface(SourceLocati
   

r298588 - [CodeGen] Emit a CoreFoundation link guard when @available is used

2017-03-23 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Mar 23 06:14:27 2017
New Revision: 298588

URL: http://llvm.org/viewvc/llvm-project?rev=298588=rev
Log:
[CodeGen] Emit a CoreFoundation link guard when @available is used

After r297760, __isOSVersionAtLeast in compiler-rt loads the CoreFoundation
symbols at runtime. This means that `@available` will always fail when used in a
binary without a linked CoreFoundation.

This commit forces Clang to emit a reference to a CoreFoundation symbol when
`@available` is used to ensure that linking will fail when CoreFoundation isn't
linked with the build product.

rdar://31039592

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

Added:
cfe/trunk/test/CodeGenObjC/availability-cf-link-guard.m
Modified:
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=298588=298587=298588=diff
==
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Thu Mar 23 06:14:27 2017
@@ -3416,4 +3416,37 @@ CodeGenFunction::EmitBuiltinAvailable(Ar
   return Builder.CreateICmpNE(CallRes, llvm::Constant::getNullValue(Int32Ty));
 }
 
+void CodeGenModule::emitAtAvailableLinkGuard() {
+  if (!IsOSVersionAtLeastFn)
+return;
+  // @available requires CoreFoundation only on Darwin.
+  if (!Target.getTriple().isOSDarwin())
+return;
+  // Add -framework CoreFoundation to the linker commands. We still want to
+  // emit the core foundation reference down below because otherwise if
+  // CoreFoundation is not used in the code, the linker won't link the
+  // framework.
+  auto  = getLLVMContext();
+  llvm::Metadata *Args[2] = {llvm::MDString::get(Context, "-framework"),
+ llvm::MDString::get(Context, "CoreFoundation")};
+  LinkerOptionsMetadata.push_back(llvm::MDNode::get(Context, Args));
+  // Emit a reference to a symbol from CoreFoundation to ensure that
+  // CoreFoundation is linked into the final binary.
+  llvm::FunctionType *FTy =
+  llvm::FunctionType::get(Int32Ty, {VoidPtrTy}, false);
+  llvm::Constant *CFFunc =
+  CreateRuntimeFunction(FTy, "CFBundleGetVersionNumber");
+
+  llvm::FunctionType *CheckFTy = llvm::FunctionType::get(VoidTy, {}, false);
+  llvm::Function *CFLinkCheckFunc = cast(CreateBuiltinFunction(
+  CheckFTy, "__clang_at_available_requires_core_foundation_framework"));
+  CFLinkCheckFunc->setLinkage(llvm::GlobalValue::LinkOnceAnyLinkage);
+  CFLinkCheckFunc->setVisibility(llvm::GlobalValue::HiddenVisibility);
+  CodeGenFunction CGF(*this);
+  CGF.Builder.SetInsertPoint(CGF.createBasicBlock("", CFLinkCheckFunc));
+  CGF.EmitNounwindRuntimeCall(CFFunc, llvm::Constant::getNullValue(VoidPtrTy));
+  CGF.Builder.CreateUnreachable();
+  addCompilerUsedGlobal(CFLinkCheckFunc);
+}
+
 CGObjCRuntime::~CGObjCRuntime() {}

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=298588=298587=298588=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Mar 23 06:14:27 2017
@@ -414,6 +414,7 @@ void CodeGenModule::Release() {
 CoverageMapping->emit();
   if (CodeGenOpts.SanitizeCfiCrossDso)
 CodeGenFunction(*this).EmitCfiCheckFail();
+  emitAtAvailableLinkGuard();
   emitLLVMUsed();
   if (SanStats)
 SanStats->finish();

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=298588=298587=298588=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Thu Mar 23 06:14:27 2017
@@ -1286,6 +1286,10 @@ private:
   /// Emit any vtables which we deferred and still have a use for.
   void EmitDeferredVTables();
 
+  /// Emit a dummy function that reference a CoreFoundation symbol when
+  /// @available is used on Darwin.
+  void emitAtAvailableLinkGuard();
+
   /// Emit the llvm.used and llvm.compiler.used metadata.
   void emitLLVMUsed();
 

Added: cfe/trunk/test/CodeGenObjC/availability-cf-link-guard.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/availability-cf-link-guard.m?rev=298588=auto
==
--- cfe/trunk/test/CodeGenObjC/availability-cf-link-guard.m (added)
+++ cfe/trunk/test/CodeGenObjC/availability-cf-link-guard.m Thu Mar 23 06:14:27 
2017
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11 -emit-llvm -o - %s | 
FileCheck --check-prefixes=CHECK,CHECK_LINK_OPT %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11 -emit-llvm -o - -D 

[PATCH] D30977: [CodeGen] Emit a CoreFoundation link guard when @available is used

2017-03-23 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL298588: [CodeGen] Emit a CoreFoundation link guard when 
@available is used (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D30977?vs=92028=92780#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30977

Files:
  cfe/trunk/lib/CodeGen/CGObjC.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.h
  cfe/trunk/test/CodeGenObjC/availability-cf-link-guard.m

Index: cfe/trunk/test/CodeGenObjC/availability-cf-link-guard.m
===
--- cfe/trunk/test/CodeGenObjC/availability-cf-link-guard.m
+++ cfe/trunk/test/CodeGenObjC/availability-cf-link-guard.m
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11 -emit-llvm -o - %s | FileCheck --check-prefixes=CHECK,CHECK_LINK_OPT %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11 -emit-llvm -o - -D USE_BUILTIN %s | FileCheck --check-prefixes=CHECK,CHECK_LINK_OPT %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11 -emit-llvm -o - -D DEF_CF %s | FileCheck --check-prefixes=CHECK_CF,CHECK_LINK_OPT %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.12 -emit-llvm -o - %s | FileCheck --check-prefix=CHECK_NO_GUARD %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -emit-llvm -o - %s | FileCheck --check-prefix=CHECK_NO_GUARD %s
+
+#ifdef DEF_CF
+struct CFBundle;
+typedef struct CFBundle *CFBundleRef;
+unsigned CFBundleGetVersionNumber(CFBundleRef bundle);
+// CHECK_CF: declare i32 @CFBundleGetVersionNumber(%struct.CFBundle*)
+// CHECK_CF: @__clang_at_available_requires_core_foundation_framework
+// CHECK_CF-NEXT: call {{.*}}@CFBundleGetVersionNumber
+#endif
+
+void use_at_available() {
+#ifdef DEF_CF
+  CFBundleGetVersionNumber(0);
+#endif
+#ifdef USE_BUILTIN
+  if (__builtin_available(macos 10.12, *))
+;
+#else
+  if (@available(macos 10.12, *))
+;
+#endif
+}
+
+// CHECK: @llvm.compiler.used{{.*}}@__clang_at_available_requires_core_foundation_framework
+
+// CHECK: declare i32 @CFBundleGetVersionNumber(i8*)
+
+// CHECK-LABEL: linkonce hidden void @__clang_at_available_requires_core_foundation_framework
+// CHECK: call i32 @CFBundleGetVersionNumber(i8* null)
+// CHECK-NEXT: unreachable
+
+// CHECK_NO_GUARD-NOT: __clang_at_available_requires_core_foundation_framework
+// CHECK_NO_GUARD-NOT: CFBundleGetVersionNumber
+
+// CHECK_LINK_OPT: !"Linker Options", ![[OPTS:[0-9]+]]
+// CHECK_LINK_OPT: ![[OPTS]] = !{![[FRAMEWORK:[0-9]+]]
+// CHECK_LINK_OPT: ![[FRAMEWORK]] = !{!"-framework", !"CoreFoundation"}
+
+// CHECK_NO_GUARD-NOT: "Linker Options"
+// CHECK_NO_GUARD-NOT: CoreFoundation
Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -414,6 +414,7 @@
 CoverageMapping->emit();
   if (CodeGenOpts.SanitizeCfiCrossDso)
 CodeGenFunction(*this).EmitCfiCheckFail();
+  emitAtAvailableLinkGuard();
   emitLLVMUsed();
   if (SanStats)
 SanStats->finish();
Index: cfe/trunk/lib/CodeGen/CodeGenModule.h
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.h
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h
@@ -1286,6 +1286,10 @@
   /// Emit any vtables which we deferred and still have a use for.
   void EmitDeferredVTables();
 
+  /// Emit a dummy function that reference a CoreFoundation symbol when
+  /// @available is used on Darwin.
+  void emitAtAvailableLinkGuard();
+
   /// Emit the llvm.used and llvm.compiler.used metadata.
   void emitLLVMUsed();
 
Index: cfe/trunk/lib/CodeGen/CGObjC.cpp
===
--- cfe/trunk/lib/CodeGen/CGObjC.cpp
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp
@@ -3416,4 +3416,37 @@
   return Builder.CreateICmpNE(CallRes, llvm::Constant::getNullValue(Int32Ty));
 }
 
+void CodeGenModule::emitAtAvailableLinkGuard() {
+  if (!IsOSVersionAtLeastFn)
+return;
+  // @available requires CoreFoundation only on Darwin.
+  if (!Target.getTriple().isOSDarwin())
+return;
+  // Add -framework CoreFoundation to the linker commands. We still want to
+  // emit the core foundation reference down below because otherwise if
+  // CoreFoundation is not used in the code, the linker won't link the
+  // framework.
+  auto  = getLLVMContext();
+  llvm::Metadata *Args[2] = {llvm::MDString::get(Context, "-framework"),
+ llvm::MDString::get(Context, "CoreFoundation")};
+  LinkerOptionsMetadata.push_back(llvm::MDNode::get(Context, Args));
+  // Emit a reference to a symbol from CoreFoundation to ensure that
+  // CoreFoundation is linked into the final binary.
+  llvm::FunctionType *FTy =
+  llvm::FunctionType::get(Int32Ty, {VoidPtrTy}, false);
+  llvm::Constant *CFFunc =
+  CreateRuntimeFunction(FTy, "CFBundleGetVersionNumber");
+
+  llvm::FunctionType 

[PATCH] D31235: Enhance -Wshadow to warn when shadowing typedefs or type aliases

2017-03-23 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:5547
 
+  if (ShadowedDecl && !Redeclaration) {
+CheckShadow(NewTD, ShadowedDecl, Previous);

You don't need to use `{}` braces here.



Comment at: lib/Sema/SemaDecl.cpp:6753
 // the constructor initializes the field with the parameter.
-if (isa(NewDC) && isa(D)) {
-  // Remember that this was shadowed so we can either warn about its
-  // modification or its existence depending on warning settings.
-  D = D->getCanonicalDecl();
-  ShadowingDecls.insert({D, FD});
-  return;
-}
+if (isa(NewDC))
+  if (ParmVarDecl* PVD = dyn_cast(D)) {

ahmedasadi wrote:
> arphaman wrote:
> > Why is the change to this `if` necessary? It doesn't seem that related to 
> > the main change.
> VarDecl overrides getCanonicalDecl() to return a VarDecl*. As the type of D 
> was changed from VarDecl* to NamedDecl*,  getCanonicalDecl() now returns a 
> NamedDecl*. 
> 
> I created a new ParmVarDecl variable so getCanonicalDecl() returns a VarDecl* 
> which can be inserted into ShadowingDecls.
> 
> Perhaps it might be better to just cast D->getCanonicalDecl() to a VarDecl 
> when inserting it into ShadowingDecls?
I see, thanks for the explanation. The change is fine then.



Comment at: lib/Sema/SemaDecl.cpp:6754
+if (isa(NewDC))
+  if (ParmVarDecl* PVD = dyn_cast(D)) {
+// Remember that this was shadowed so we can either warn about its

You can use `const auto` here.



Comment at: test/SemaCXX/warn-shadow.cpp:65
 char *data; // expected-warning {{declaration shadows a static data member 
of 'A'}}
+char *a1; // expected-warning {{declaration shadows a typedef in 'A'}}
+char *a2; // expected-warning {{declaration shadows a type alias in 'A'}}

It looks like previously this wouldn't have been a warning. Should we really 
warn about local variables that shadow typedef names?


https://reviews.llvm.org/D31235



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


r298587 - [ObjC][ARC] Avoid -Warc-performSelector-leaks for performSelector variations

2017-03-23 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Mar 23 05:46:05 2017
New Revision: 298587

URL: http://llvm.org/viewvc/llvm-project?rev=298587=rev
Log:
[ObjC][ARC] Avoid -Warc-performSelector-leaks for performSelector variations
that became supported after r297019

The commit r297019 expanded the performSelector ObjC method family heuristic
to ensure that -Wobjc-unsafe-perform-selector covers all performSelector
variations. However, this made the -Warc-performSelector-leaks too noisy, as
that warning produces mostly false positives since the selector is unknown.
This commit reverts the ObjC method family heuristics introduced in r297019.
This ensures that -Warc-performSelector-leaks isn't too noisy. The commit still
preserves the coverage of -Wobjc-unsafe-perform-selector.

rdar://31124629

Modified:
cfe/trunk/lib/AST/DeclObjC.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/test/SemaObjC/arc-peformselector.m

Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=298587=298586=298587=diff
==
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Thu Mar 23 05:46:05 2017
@@ -979,12 +979,11 @@ ObjCMethodFamily ObjCMethodDecl::getMeth
 break;
   
   case OMF_performSelector:
-if (!isInstanceMethod() ||
-!(getReturnType()->isObjCIdType() || getReturnType()->isVoidType()))
+if (!isInstanceMethod() || !getReturnType()->isObjCIdType())
   family = OMF_None;
 else {
   unsigned noParams = param_size();
-  if (noParams < 1 || noParams > 5)
+  if (noParams < 1 || noParams > 3)
 family = OMF_None;
   else {
 ObjCMethodDecl::param_type_iterator it = param_type_begin();
@@ -993,11 +992,10 @@ ObjCMethodFamily ObjCMethodDecl::getMeth
   family = OMF_None;
   break;
 }
-// The first type should generally always be 'id' or 'Thread *', the
-// other types can vary.
-if (noParams > 1) {
-  ArgT = *(it + 1);
-  if (!ArgT->isObjCObjectPointerType()) {
+while (--noParams) {
+  it++;
+  ArgT = (*it);
+  if (!ArgT->isObjCIdType()) {
 family = OMF_None;
 break;
   }

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=298587=298586=298587=diff
==
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Thu Mar 23 05:46:05 2017
@@ -2272,7 +2272,8 @@ static void checkFoundationAPI(Sema ,
bool IsClassObjectCall) {
   // Check if this is a performSelector method that uses a selector that 
returns
   // a record or a vector type.
-  if (Method->getMethodFamily() != OMF_performSelector || Args.empty())
+  if (Method->getSelector().getMethodFamily() != OMF_performSelector ||
+  Args.empty())
 return;
   const auto *SE = dyn_cast(Args[0]->IgnoreParens());
   if (!SE)

Modified: cfe/trunk/test/SemaObjC/arc-peformselector.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-peformselector.m?rev=298587=298586=298587=diff
==
--- cfe/trunk/test/SemaObjC/arc-peformselector.m (original)
+++ cfe/trunk/test/SemaObjC/arc-peformselector.m Thu Mar 23 05:46:05 2017
@@ -18,6 +18,9 @@
 - (id)performSelector:(SEL)aSelector;
 - (id)performSelector:(SEL)aSelector withObject:(id)object;
 - (id)performSelector:(SEL)aSelector withObject:(id)object1 
withObject:(id)object2;
+
+- (void)performSelector:(SEL)aSelector withObject:(id)anArgument 
afterDelay:(double)delay inModes:(I *)modes;
+
 @end
 
 @implementation I
@@ -33,10 +36,15 @@
   return [self performSelector : @selector(PlusZero)];
   return [self performSelector : @selector(PlusOne)]; // expected-error 
{{performSelector names a selector which retains the object}}
 
+  // Avoid the unkown selector warning for more complicated performSelector
+  // variations because it produces too many false positives.
+  [self performSelector: sel1 withObject:0 afterDelay:0 inModes:0];
+
   return [self performSelector: @selector(self)]; // No error, -self is not +1!
 }
 
 - (id)performSelector:(SEL)aSelector { return 0; }
 - (id)performSelector:(SEL)aSelector withObject:(id)object { return 0; }
 - (id)performSelector:(SEL)aSelector withObject:(id)object1 
withObject:(id)object2 { return 0; }
+- (void)performSelector:(SEL)aSelector withObject:(id)anArgument 
afterDelay:(double)delay inModes:(I *)modes { }
 @end


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


[PATCH] D31252: [clang-tidy] add readability-compound-statement-size check.

2017-03-23 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D31252#708209, @Eugene.Zelenko wrote:

> Please mention this check in docs/ReleaseNotes.rst (in alphabetical order).


Done

> Will be good idea to run Clang-tidy modernize and readability checks over new 
> code.

I did run them (`-checks=*`) over `CompoundStatementSizeCheck.cpp`, there is no 
`modernize` notes, and no meaningful `readability` notes.


https://reviews.llvm.org/D31252



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


[PATCH] D31252: [clang-tidy] add readability-compound-statement-size check.

2017-03-23 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 92775.
lebedev.ri marked 2 inline comments as done.
lebedev.ri added a comment.

No changes compared to v2, just correctly rebased the master branch now.


https://reviews.llvm.org/D31252

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/CompoundStatementSizeCheck.cpp
  clang-tidy/readability/CompoundStatementSizeCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-compound-statement-size.rst
  test/clang-tidy/readability-compound-statement-size.cpp

Index: test/clang-tidy/readability-compound-statement-size.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-compound-statement-size.cpp
@@ -0,0 +1,88 @@
+// RUN: %check_clang_tidy %s readability-compound-statement-size %t -- -config='{CheckOptions: [{key: readability-compound-statement-size.LineThreshold, value: 0}, {key: readability-compound-statement-size.StatementThreshold, value: 0}, {key: readability-compound-statement-size.BranchThreshold, value: 0}]}' -- -std=c++11
+
+// Bad formatting is intentional, don't run clang-format over the whole file!
+
+// the function's base compound statement is NOT being checked.
+
+void foo1() {
+}
+
+void foo2() {;}
+
+void bar2() {{;}}
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: compound statement exceeds recommended size/complexity thresholds [readability-compound-statement-size]
+// CHECK-MESSAGES: :[[@LINE-2]]:14: note: 1 statements (threshold 0)
+
+void foo3() {
+;
+
+}
+
+void bar3() {
+  {
+;
+
+  }
+}
+// CHECK-MESSAGES: :[[@LINE-5]]:3: warning: compound statement exceeds recommended size/complexity thresholds [readability-compound-statement-size]
+// CHECK-MESSAGES: :[[@LINE-6]]:3: note: 3 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-7]]:3: note: 1 statements (threshold 0)
+
+void foo4(int i) { if (i) {} else; {}
+}
+
+void bar4(int i) { { if (i) {} else; {}
+}
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:20: warning: compound statement exceeds recommended size/complexity thresholds [readability-compound-statement-size]
+// CHECK-MESSAGES: :[[@LINE-4]]:20: note: 1 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-5]]:20: note: 3 statements (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-6]]:20: note: 1 branches (threshold 0)
+
+void foo5(int i) {for(;i;)while(i)
+do;while(i);
+}
+
+void bar5(int i) {{for(;i;)while(i)
+do;while(i);
+}
+}
+// CHECK-MESSAGES: :[[@LINE-4]]:19: warning: compound statement exceeds recommended size/complexity thresholds [readability-compound-statement-size]
+// CHECK-MESSAGES: :[[@LINE-5]]:19: note: 2 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-6]]:19: note: 7 statements (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-7]]:19: note: 3 branches (threshold 0)
+
+template  T foo6(T i) {return i;
+}
+int x = foo6(0);
+
+template  T bar6(T i) {{return i;
+}
+}
+int y = bar6(0);
+// CHECK-MESSAGES: :[[@LINE-4]]:36: warning: compound statement exceeds recommended size/complexity thresholds [readability-compound-statement-size]
+// CHECK-MESSAGES: :[[@LINE-5]]:36: note: 1 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-6]]:36: note: 1 statements (threshold 0)
+
+void foo7(int p1, int p2, int p3, int p4, int p5, int p6) {;}
+
+void bar8() { [](){;;;  if(1){}
+
+
+}();
+
+
+}
+// CHECK-MESSAGES: :[[@LINE-7]]:19: warning: compound statement exceeds recommended size/complexity thresholds [readability-compound-statement-size]
+// CHECK-MESSAGES: :[[@LINE-8]]:19: note: 3 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-9]]:19: note: 13 statements (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-10]]:19: note: 1 branches (threshold 0)
+
+void foo9() { class A { void foox() {;;} }; }
+
+void bar9() { { class A { void barx() {{;;}} }; } }
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: compound statement exceeds recommended size/complexity thresholds [readability-compound-statement-size]
+// CHECK-MESSAGES: :[[@LINE-2]]:15: note: 3 statements (threshold 0)
+//
+// CHECK-MESSAGES: :[[@LINE-4]]:40: warning: compound statement exceeds recommended size/complexity thresholds [readability-compound-statement-size]
+// CHECK-MESSAGES: :[[@LINE-5]]:40: note: 2 statements (threshold 0)
Index: docs/clang-tidy/checks/readability-compound-statement-size.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-compound-statement-size.rst
@@ -0,0 +1,29 @@
+.. title:: clang-tidy - readability-compound-statement-size
+
+readability-compound-statement-size
+===
+
+Checks for compound statements based on various metrics.
+
+Similar to the `readability-function-size` check. It works for each compound
+statement, excluding the ones 

[PATCH] D31252: [clang-tidy] add readability-compound-statement-size check.

2017-03-23 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 92774.
lebedev.ri added a comment.

Addressing review notes.


https://reviews.llvm.org/D31252

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/CompoundStatementSizeCheck.cpp
  clang-tidy/readability/CompoundStatementSizeCheck.h
  clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tidy/readability/IdentifierNamingCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-compound-statement-size.rst
  test/clang-tidy/check_clang_tidy.py
  test/clang-tidy/readability-compound-statement-size.cpp

Index: test/clang-tidy/readability-compound-statement-size.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-compound-statement-size.cpp
@@ -0,0 +1,88 @@
+// RUN: %check_clang_tidy %s readability-compound-statement-size %t -- -config='{CheckOptions: [{key: readability-compound-statement-size.LineThreshold, value: 0}, {key: readability-compound-statement-size.StatementThreshold, value: 0}, {key: readability-compound-statement-size.BranchThreshold, value: 0}]}' -- -std=c++11
+
+// Bad formatting is intentional, don't run clang-format over the whole file!
+
+// the function's base compound statement is NOT being checked.
+
+void foo1() {
+}
+
+void foo2() {;}
+
+void bar2() {{;}}
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: compound statement exceeds recommended size/complexity thresholds [readability-compound-statement-size]
+// CHECK-MESSAGES: :[[@LINE-2]]:14: note: 1 statements (threshold 0)
+
+void foo3() {
+;
+
+}
+
+void bar3() {
+  {
+;
+
+  }
+}
+// CHECK-MESSAGES: :[[@LINE-5]]:3: warning: compound statement exceeds recommended size/complexity thresholds [readability-compound-statement-size]
+// CHECK-MESSAGES: :[[@LINE-6]]:3: note: 3 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-7]]:3: note: 1 statements (threshold 0)
+
+void foo4(int i) { if (i) {} else; {}
+}
+
+void bar4(int i) { { if (i) {} else; {}
+}
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:20: warning: compound statement exceeds recommended size/complexity thresholds [readability-compound-statement-size]
+// CHECK-MESSAGES: :[[@LINE-4]]:20: note: 1 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-5]]:20: note: 3 statements (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-6]]:20: note: 1 branches (threshold 0)
+
+void foo5(int i) {for(;i;)while(i)
+do;while(i);
+}
+
+void bar5(int i) {{for(;i;)while(i)
+do;while(i);
+}
+}
+// CHECK-MESSAGES: :[[@LINE-4]]:19: warning: compound statement exceeds recommended size/complexity thresholds [readability-compound-statement-size]
+// CHECK-MESSAGES: :[[@LINE-5]]:19: note: 2 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-6]]:19: note: 7 statements (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-7]]:19: note: 3 branches (threshold 0)
+
+template  T foo6(T i) {return i;
+}
+int x = foo6(0);
+
+template  T bar6(T i) {{return i;
+}
+}
+int y = bar6(0);
+// CHECK-MESSAGES: :[[@LINE-4]]:36: warning: compound statement exceeds recommended size/complexity thresholds [readability-compound-statement-size]
+// CHECK-MESSAGES: :[[@LINE-5]]:36: note: 1 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-6]]:36: note: 1 statements (threshold 0)
+
+void foo7(int p1, int p2, int p3, int p4, int p5, int p6) {;}
+
+void bar8() { [](){;;;  if(1){}
+
+
+}();
+
+
+}
+// CHECK-MESSAGES: :[[@LINE-7]]:19: warning: compound statement exceeds recommended size/complexity thresholds [readability-compound-statement-size]
+// CHECK-MESSAGES: :[[@LINE-8]]:19: note: 3 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-9]]:19: note: 13 statements (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-10]]:19: note: 1 branches (threshold 0)
+
+void foo9() { class A { void foox() {;;} }; }
+
+void bar9() { { class A { void barx() {{;;}} }; } }
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: compound statement exceeds recommended size/complexity thresholds [readability-compound-statement-size]
+// CHECK-MESSAGES: :[[@LINE-2]]:15: note: 3 statements (threshold 0)
+//
+// CHECK-MESSAGES: :[[@LINE-4]]:40: warning: compound statement exceeds recommended size/complexity thresholds [readability-compound-statement-size]
+// CHECK-MESSAGES: :[[@LINE-5]]:40: note: 2 statements (threshold 0)
Index: test/clang-tidy/check_clang_tidy.py
===
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -60,11 +60,6 @@
   if len(clang_tidy_extra_args) == 0:
 clang_tidy_extra_args = ['--', '--std=c++11'] if extension == '.cpp' \
else ['--']
-
-  # Tests should not rely on STL being available, and instead provide mock
-  # implementations of relevant APIs.
-  

[PATCH] D31029: [analyzer] Fix logical not for pointers with different bit width

2017-03-23 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added a comment.

In https://reviews.llvm.org/D31029#703428, @zaks.anna wrote:

> Are there other cases where makeNull would need to be replaced?


There might be. As I understand it, this is the only known case at the moment.


Repository:
  rL LLVM

https://reviews.llvm.org/D31029



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


[PATCH] D31029: [analyzer] Fix logical not for pointers with different bit width

2017-03-23 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki updated this revision to Diff 92773.
danielmarjamaki added a comment.

Added a testcase that will crash without the fix. Used the amdgcn target as 
that happens to use different pointer bit widths for different address spaces.

Updated the comment. I am not good at english so I hope the grammar is ok.


Repository:
  rL LLVM

https://reviews.llvm.org/D31029

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/Analysis/ptr.cl


Index: test/Analysis/ptr.cl
===
--- test/Analysis/ptr.cl
+++ test/Analysis/ptr.cl
@@ -0,0 +1,10 @@
+// RUN: %clang_analyze_cc1 -triple amdgcn-unknown-unknown -target-cpu verde 
-analyze -analyzer-checker=core %s
+
+#define __cm __attribute__((address_space(256)))
+
+// Don't crash when pointer bit-widths are different for different address 
spaces
+void dontCrash(void) {
+  __cm void *cm_p = 0;
+  if (!cm_p)
+(void)cm_p;
+}
Index: lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -980,10 +980,9 @@
   //transfer functions as "0 == E".
   SVal Result;
   if (Optional LV = V.getAs()) {
-Loc X = svalBuilder.makeNull();
+Loc X = svalBuilder.makeNullWithType(Ex->getType());
 Result = evalBinOp(state, BO_EQ, *LV, X, U->getType());
-  }
-  else if (Ex->getType()->isFloatingType()) {
+  } else if (Ex->getType()->isFloatingType()) {
 // FIXME: handle floating point types.
 Result = UnknownVal();
   } else {
Index: include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
@@ -310,10 +310,15 @@
 return nonloc::ConcreteInt(BasicVals.getTruthValue(b));
   }
 
-  Loc makeNull() {
-return loc::ConcreteInt(BasicVals.getZeroWithPtrWidth());
+  /// Create NULL pointer, with proper pointer bit-width for given address
+  /// space.
+  /// \param type pointer type.
+  Loc makeNullWithType(QualType type) {
+return loc::ConcreteInt(BasicVals.getZeroWithTypeSize(type));
   }
 
+  Loc makeNull() { return loc::ConcreteInt(BasicVals.getZeroWithPtrWidth()); }
+
   Loc makeLoc(SymbolRef sym) {
 return loc::MemRegionVal(MemMgr.getSymbolicRegion(sym));
   }
Index: include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
@@ -176,7 +176,12 @@
 return getValue(X);
   }
 
-  inline const llvm::APSInt& getZeroWithPtrWidth(bool isUnsigned = true) {
+  inline const llvm::APSInt (QualType T,
+ bool isUnsigned = true) {
+return getValue(0, Ctx.getTypeSize(T), isUnsigned);
+  }
+
+  inline const llvm::APSInt (bool isUnsigned = true) {
 return getValue(0, Ctx.getTypeSize(Ctx.VoidPtrTy), isUnsigned);
   }
 


Index: test/Analysis/ptr.cl
===
--- test/Analysis/ptr.cl
+++ test/Analysis/ptr.cl
@@ -0,0 +1,10 @@
+// RUN: %clang_analyze_cc1 -triple amdgcn-unknown-unknown -target-cpu verde -analyze -analyzer-checker=core %s
+
+#define __cm __attribute__((address_space(256)))
+
+// Don't crash when pointer bit-widths are different for different address spaces
+void dontCrash(void) {
+  __cm void *cm_p = 0;
+  if (!cm_p)
+(void)cm_p;
+}
Index: lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -980,10 +980,9 @@
   //transfer functions as "0 == E".
   SVal Result;
   if (Optional LV = V.getAs()) {
-Loc X = svalBuilder.makeNull();
+Loc X = svalBuilder.makeNullWithType(Ex->getType());
 Result = evalBinOp(state, BO_EQ, *LV, X, U->getType());
-  }
-  else if (Ex->getType()->isFloatingType()) {
+  } else if (Ex->getType()->isFloatingType()) {
 // FIXME: handle floating point types.
 Result = UnknownVal();
   } else {
Index: include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
@@ -310,10 +310,15 @@
 return 

[PATCH] D30567: [clang-tidy] Fix treating non-space whitespaces in checks list.

2017-03-23 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius updated this revision to Diff 92772.
curdeius added a comment.

Trim spaces only everywhere. Fix test.


https://reviews.llvm.org/D30567

Files:
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp

Index: unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
===
--- unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
+++ unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
@@ -1,87 +1,94 @@
-#include "ClangTidy.h"
-#include "ClangTidyTest.h"
-#include "gtest/gtest.h"
-
-namespace clang {
-namespace tidy {
-namespace test {
-
-class TestCheck : public ClangTidyCheck {
-public:
-  TestCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
-  void registerMatchers(ast_matchers::MatchFinder *Finder) override {
-Finder->addMatcher(ast_matchers::varDecl().bind("var"), this);
-  }
-  void check(const ast_matchers::MatchFinder::MatchResult ) override {
-const auto *Var = Result.Nodes.getNodeAs("var");
-// Add diagnostics in the wrong order.
-diag(Var->getLocation(), "variable");
-diag(Var->getTypeSpecStartLoc(), "type specifier");
-  }
-};
-
-TEST(ClangTidyDiagnosticConsumer, SortsErrors) {
-  std::vector Errors;
-  runCheckOnCode("int a;", );
-  EXPECT_EQ(2ul, Errors.size());
-  EXPECT_EQ("type specifier", Errors[0].Message.Message);
-  EXPECT_EQ("variable", Errors[1].Message.Message);
-}
-
-TEST(GlobList, Empty) {
-  GlobList Filter("");
-
-  EXPECT_TRUE(Filter.contains(""));
-  EXPECT_FALSE(Filter.contains("aaa"));
-}
-
-TEST(GlobList, Nothing) {
-  GlobList Filter("-*");
-
-  EXPECT_FALSE(Filter.contains(""));
-  EXPECT_FALSE(Filter.contains("a"));
-  EXPECT_FALSE(Filter.contains("-*"));
-  EXPECT_FALSE(Filter.contains("-"));
-  EXPECT_FALSE(Filter.contains("*"));
-}
-
-TEST(GlobList, Everything) {
-  GlobList Filter("*");
-
-  EXPECT_TRUE(Filter.contains(""));
-  EXPECT_TRUE(Filter.contains(""));
-  EXPECT_TRUE(Filter.contains("-*"));
-  EXPECT_TRUE(Filter.contains("-"));
-  EXPECT_TRUE(Filter.contains("*"));
-}
-
-TEST(GlobList, Simple) {
-  GlobList Filter("aaa");
-
-  EXPECT_TRUE(Filter.contains("aaa"));
-  EXPECT_FALSE(Filter.contains(""));
-  EXPECT_FALSE(Filter.contains("aa"));
-  EXPECT_FALSE(Filter.contains(""));
-  EXPECT_FALSE(Filter.contains("bbb"));
-}
-
-TEST(GlobList, Complex) {
-  GlobList Filter("*,-a.*, -b.*,   a.1.* ,-a.1.A.*,-..,-...,-..+,-*$, -*qwe* ");
-
-  EXPECT_TRUE(Filter.contains("aaa"));
-  EXPECT_TRUE(Filter.contains("qqq"));
-  EXPECT_FALSE(Filter.contains("a."));
-  EXPECT_FALSE(Filter.contains("a.b"));
-  EXPECT_FALSE(Filter.contains("b."));
-  EXPECT_FALSE(Filter.contains("b.b"));
-  EXPECT_TRUE(Filter.contains("a.1.b"));
-  EXPECT_FALSE(Filter.contains("a.1.A.a"));
-  EXPECT_FALSE(Filter.contains("qwe"));
-  EXPECT_FALSE(Filter.contains("asdfqweasdf"));
-  EXPECT_TRUE(Filter.contains("asdfqwEasdf"));
-}
-
-} // namespace test
-} // namespace tidy
-} // namespace clang
+#include "ClangTidy.h"
+#include "ClangTidyTest.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace tidy {
+namespace test {
+
+class TestCheck : public ClangTidyCheck {
+public:
+  TestCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override {
+Finder->addMatcher(ast_matchers::varDecl().bind("var"), this);
+  }
+  void check(const ast_matchers::MatchFinder::MatchResult ) override {
+const auto *Var = Result.Nodes.getNodeAs("var");
+// Add diagnostics in the wrong order.
+diag(Var->getLocation(), "variable");
+diag(Var->getTypeSpecStartLoc(), "type specifier");
+  }
+};
+
+TEST(ClangTidyDiagnosticConsumer, SortsErrors) {
+  std::vector Errors;
+  runCheckOnCode("int a;", );
+  EXPECT_EQ(2ul, Errors.size());
+  EXPECT_EQ("type specifier", Errors[0].Message.Message);
+  EXPECT_EQ("variable", Errors[1].Message.Message);
+}
+
+TEST(GlobList, Empty) {
+  GlobList Filter("");
+
+  EXPECT_TRUE(Filter.contains(""));
+  EXPECT_FALSE(Filter.contains("aaa"));
+}
+
+TEST(GlobList, Nothing) {
+  GlobList Filter("-*");
+
+  EXPECT_FALSE(Filter.contains(""));
+  EXPECT_FALSE(Filter.contains("a"));
+  EXPECT_FALSE(Filter.contains("-*"));
+  EXPECT_FALSE(Filter.contains("-"));
+  EXPECT_FALSE(Filter.contains("*"));
+}
+
+TEST(GlobList, Everything) {
+  GlobList Filter("*");
+
+  EXPECT_TRUE(Filter.contains(""));
+  EXPECT_TRUE(Filter.contains(""));
+  EXPECT_TRUE(Filter.contains("-*"));
+  EXPECT_TRUE(Filter.contains("-"));
+  EXPECT_TRUE(Filter.contains("*"));
+}
+
+TEST(GlobList, Simple) {
+  GlobList Filter("aaa");
+
+  EXPECT_TRUE(Filter.contains("aaa"));
+  EXPECT_FALSE(Filter.contains(""));
+  EXPECT_FALSE(Filter.contains("aa"));
+  EXPECT_FALSE(Filter.contains(""));
+  EXPECT_FALSE(Filter.contains("bbb"));
+}
+
+TEST(GlobList, WhitespacesAtBegin) {
+  GlobList Filter("-*,   a.b.*");
+
+ 

  1   2   >