Re: [libcxx] r286789 - Add check-cxx-abilist target when supported.

2016-12-14 Thread Eric Fiselier via cfe-commits
> Eric, this part of this change seems wrong to me. It causes the headers to
> be installed into the libcxx build directory instead of the LLVM one. If
> you build using the LLVM runtimes directory this puts the headers in the
> wrong place for clang to find them.
>
> Is there a reason you're copying them into the libcxx binary dir? I
> generally don't think the headers are needed there.
>
>
If it seems wrong for building in the LLVM runtimes directory then it
probably is. I don't think there is a good reason why we need to copy the
headers into the build directory, although we should double check
compiler-rt uses the headers from the source directory.

If you know how to fix this feel free to commit a patch. If not I'll look
into this more on Friday.

@Dan, @Jonathan: Do you guys use, or see a need for, this behavior?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r289783 - CodeGen: force builtins to be local

2016-12-14 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Dec 15 01:29:04 2016
New Revision: 289783

URL: http://llvm.org/viewvc/llvm-project?rev=289783=rev
Log:
CodeGen: force builtins to be local

Unfortunately _setjmp3 can be both import or local.  The ASAN tests try to
emulate the flags which makes this harder to detect.  Rely on the linker
creating or using thunks here instead.  Should repair the ASAN windows bots.

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=289783=289782=289783=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Dec 15 01:29:04 2016
@@ -2214,7 +2214,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 llvm::Attribute::ReturnsTwice);
   llvm::Constant *SetJmpEx = CGM.CreateRuntimeFunction(
   llvm::FunctionType::get(IntTy, ArgTypes, /*isVarArg=*/false),
-  "_setjmpex", ReturnsTwiceAttr);
+  "_setjmpex", ReturnsTwiceAttr, /*Local=*/true);
   llvm::Value *Buf = Builder.CreateBitOrPointerCast(
   EmitScalarExpr(E->getArg(0)), Int8PtrTy);
   llvm::Value *FrameAddr =
@@ -2239,7 +2239,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 llvm::Type *ArgTypes[] = {Int8PtrTy, IntTy};
 llvm::Constant *SetJmp3 = CGM.CreateRuntimeFunction(
 llvm::FunctionType::get(IntTy, ArgTypes, /*isVarArg=*/true),
-"_setjmp3", ReturnsTwiceAttr);
+"_setjmp3", ReturnsTwiceAttr, /*Local=*/true);
 llvm::Value *Count = ConstantInt::get(IntTy, 0);
 llvm::Value *Args[] = {Buf, Count};
 CS = EmitRuntimeCallOrInvoke(SetJmp3, Args);
@@ -2247,7 +2247,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 llvm::Type *ArgTypes[] = {Int8PtrTy, Int8PtrTy};
 llvm::Constant *SetJmp = CGM.CreateRuntimeFunction(
 llvm::FunctionType::get(IntTy, ArgTypes, /*isVarArg=*/false),
-"_setjmp", ReturnsTwiceAttr);
+"_setjmp", ReturnsTwiceAttr, /*Local=*/true);
 llvm::Value *FrameAddr =
 Builder.CreateCall(CGM.getIntrinsic(Intrinsic::frameaddress),
ConstantInt::get(Int32Ty, 0));


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


[libcxx] r289781 - Fix typo

2016-12-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Dec 15 01:23:44 2016
New Revision: 289781

URL: http://llvm.org/viewvc/llvm-project?rev=289781=rev
Log:
Fix typo

Modified:
libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/dtor.pass.cpp

Modified: libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/dtor.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/dtor.pass.cpp?rev=289781=289780=289781=diff
==
--- libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/dtor.pass.cpp 
(original)
+++ libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/dtor.pass.cpp Thu 
Dec 15 01:23:44 2016
@@ -31,5 +31,5 @@ int main()
   static_assert((std::is_trivially_destructible<
   std::pair >::value), "");
   static_assert((!std::is_trivially_destructible<
-  std::pair::value), "");
+  std::pair >::value), "");
 }


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


[libcxx] r289780 - Add tests for LWG 2796

2016-12-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Dec 15 01:15:39 2016
New Revision: 289780

URL: http://llvm.org/viewvc/llvm-project?rev=289780=rev
Log:
Add tests for LWG 2796

Added:
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/dtor.pass.cpp
libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/dtor.pass.cpp

Added: 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/dtor.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/dtor.pass.cpp?rev=289780=auto
==
--- libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/dtor.pass.cpp 
(added)
+++ libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/dtor.pass.cpp 
Thu Dec 15 01:15:39 2016
@@ -0,0 +1,38 @@
+//===--===//
+//
+// 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: c++98, c++03
+
+// Doesn't pass due to use of is_trivially_* trait.
+// XFAIL: gcc-4.9
+
+// 
+
+// template  class tuple;
+
+// ~tuple();
+
+#include 
+#include 
+#include 
+#include 
+
+int main()
+{
+  static_assert(std::is_trivially_destructible<
+  std::tuple<> >::value, "");
+  static_assert(std::is_trivially_destructible<
+  std::tuple >::value, "");
+  static_assert(std::is_trivially_destructible<
+  std::tuple >::value, "");
+  static_assert(!std::is_trivially_destructible<
+  std::tuple >::value, "");
+  static_assert(!std::is_trivially_destructible<
+  std::tuple >::value, "");
+}

Added: libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/dtor.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/dtor.pass.cpp?rev=289780=auto
==
--- libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/dtor.pass.cpp 
(added)
+++ libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/dtor.pass.cpp Thu 
Dec 15 01:15:39 2016
@@ -0,0 +1,35 @@
+//===--===//
+//
+// 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: c++98, c++03
+
+// Doesn't pass due to use of is_trivially_* trait.
+// XFAIL: gcc-4.9
+
+// 
+
+// template  struct pair
+
+// ~pair()
+
+
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+int main()
+{
+  static_assert((std::is_trivially_destructible<
+  std::pair >::value), "");
+  static_assert((!std::is_trivially_destructible<
+  std::pair::value), "");
+}


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


[libcxx] r289778 - Add more test cases for PR31384

2016-12-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Dec 15 01:05:19 2016
New Revision: 289778

URL: http://llvm.org/viewvc/llvm-project?rev=289778=rev
Log:
Add more test cases for PR31384

Modified:

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR31384.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR31384.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR31384.pass.cpp?rev=289778=289777=289778=diff
==
--- 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR31384.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR31384.pass.cpp 
Thu Dec 15 01:05:19 2016
@@ -15,24 +15,74 @@
 // template  tuple(TupleLike&&); // libc++ extension
 
 // See llvm.org/PR31384
-
 #include 
 #include 
 
-
 int count = 0;
 
+struct Explicit {
+  Explicit() = default;
+  explicit Explicit(int) {}
+};
+
+struct Implicit {
+  Implicit() = default;
+  Implicit(int) {}
+};
+
 template
-struct derived : std::tuple {
+struct Derived : std::tuple {
   using std::tuple::tuple;
   template
-  operator std::tuple() && {
-++count;
-return {};
-  }
+  operator std::tuple() && { ++count; return {}; }
+};
+
+
+template
+struct ExplicitDerived : std::tuple {
+  using std::tuple::tuple;
+  template
+  explicit operator std::tuple() && { ++count; return {}; }
 };
 
 int main() {
-  std::tuple foo = derived{42};
-  assert(count == 1);
+  {
+std::tuple foo = Derived{42};
+assert(count == 1);
+std::tuple bar(Derived{42});
+assert(count == 2);
+  }
+  count = 0;
+  {
+std::tuple foo = Derived{42};
+assert(count == 1);
+std::tuple bar(Derived{42});
+assert(count == 2);
+  }
+  count = 0;
+  {
+static_assert(!std::is_convertible<
+ExplicitDerived, std::tuple>::value, "");
+std::tuple bar(ExplicitDerived{42});
+assert(count == 1);
+  }
+  count = 0;
+  {
+// FIXME: Libc++ incorrectly rejects this code.
+#ifndef _LIBCPP_VERSION
+std::tuple foo = ExplicitDerived{42};
+static_assert(std::is_convertible<
+ExplicitDerived, std::tuple>::value,
+"correct STLs accept this");
+#else
+static_assert(!std::is_convertible<
+ExplicitDerived, std::tuple>::value,
+"libc++ incorrectly rejects this");
+#endif
+assert(count == 0);
+std::tuple bar(ExplicitDerived{42});
+assert(count == 1);
+  }
+  count = 0;
+
 }


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


r289776 - CodeGen: fix runtime function dll storage

2016-12-14 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Dec 15 00:59:05 2016
New Revision: 289776

URL: http://llvm.org/viewvc/llvm-project?rev=289776=rev
Log:
CodeGen: fix runtime function dll storage

Properly attribute DLL storage to runtime functions.  When generating the
runtime function, scan for an existing declaration which may provide an explicit
declaration (local storage) or a DLL import or export storage from the user.
Honour that if available.  Otherwise, if building with a local visibility of the
public or standard namespaces (-flto-visibility-public-std), give the symbols
local storage (it indicates a /MT[d] link, so static runtime).  Otherwise,
assume that the link is dynamic, and give the runtime function dllimport
storage.

This allows for implementations to get the correct storage as long as they are
properly declared, the user to override the import storage, and in case no
explicit storage is given, use of the import storage.

Added:
cfe/trunk/test/CodeGenCXX/runtime-dllstorage.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp

Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=289776=289775=289776=diff
==
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Thu Dec 15 00:59:05 2016
@@ -237,7 +237,8 @@ void CodeGenFunction::registerGlobalDtor
 llvm::FunctionType::get(IntTy, dtorStub->getType(), false);
 
   llvm::Constant *atexit =
-CGM.CreateRuntimeFunction(atexitTy, "atexit");
+  CGM.CreateRuntimeFunction(atexitTy, "atexit", llvm::AttributeSet(),
+/*Local=*/true);
   if (llvm::Function *atexitFn = dyn_cast(atexit))
 atexitFn->setDoesNotThrow();
 

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=289776=289775=289776=diff
==
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Thu Dec 15 00:59:05 2016
@@ -221,10 +221,9 @@ const EHPersonality ::get(
 
 static llvm::Constant *getPersonalityFn(CodeGenModule ,
 const EHPersonality ) {
-  llvm::Constant *Fn =
-CGM.CreateRuntimeFunction(llvm::FunctionType::get(CGM.Int32Ty, true),
-  Personality.PersonalityFn);
-  return Fn;
+  return CGM.CreateRuntimeFunction(llvm::FunctionType::get(CGM.Int32Ty, true),
+   Personality.PersonalityFn,
+   llvm::AttributeSet(), /*Local=*/true);
 }
 
 static llvm::Constant *getOpaquePersonalityFn(CodeGenModule ,

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=289776=289775=289776=diff
==
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Thu Dec 15 00:59:05 2016
@@ -1811,7 +1811,8 @@ static llvm::Constant *createARCRuntimeF
 // If the target runtime doesn't naturally support ARC, emit weak
 // references to the runtime support library.  We don't really
 // permit this to fail, but we need a particular relocation style.
-if (!CGM.getLangOpts().ObjCRuntime.hasNativeARC()) {
+if (!CGM.getLangOpts().ObjCRuntime.hasNativeARC() &&
+!CGM.getTriple().isOSBinFormatCOFF()) {
   f->setLinkage(llvm::Function::ExternalWeakLinkage);
 } else if (fnName == "objc_retain" || fnName  == "objc_release") {
   // If we have Native ARC, set nonlazybind attribute for these APIs for

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=289776=289775=289776=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Dec 15 00:59:05 2016
@@ -2038,18 +2038,70 @@ llvm::Constant *CodeGenModule::GetAddrOf
  IsForDefinition);
 }
 
+static const FunctionDecl *
+GetRuntimeFunctionDecl(ASTContext , StringRef Name) {
+  TranslationUnitDecl *TUDecl = C.getTranslationUnitDecl();
+  DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
+
+  IdentifierInfo  = C.Idents.get(Name);
+  for (const auto  : DC->lookup())
+if (const auto FD = dyn_cast(Result))
+  return FD;
+
+  if (!C.getLangOpts().CPlusPlus)
+return nullptr;
+
+  // Demangle the premangled name from 

[PATCH] D27786: [libcxx] [test] Strip trailing whitespace.

2016-12-14 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.

You can commit whitespace and formatting changes w/o review.


https://reviews.llvm.org/D27786



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


[libcxx] r289774 - Add test case for PR31384

2016-12-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Dec 15 00:38:07 2016
New Revision: 289774

URL: http://llvm.org/viewvc/llvm-project?rev=289774=rev
Log:
Add test case for PR31384

Added:

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR31384.pass.cpp

Added: 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR31384.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR31384.pass.cpp?rev=289774=auto
==
--- 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR31384.pass.cpp 
(added)
+++ 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR31384.pass.cpp 
Thu Dec 15 00:38:07 2016
@@ -0,0 +1,38 @@
+// -*- C++ -*-
+//===--===//
+//
+// 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: c++98, c++03
+
+// 
+
+// template  tuple(TupleLike&&); // libc++ extension
+
+// See llvm.org/PR31384
+
+#include 
+#include 
+
+
+int count = 0;
+
+template
+struct derived : std::tuple {
+  using std::tuple::tuple;
+  template
+  operator std::tuple() && {
+++count;
+return {};
+  }
+};
+
+int main() {
+  std::tuple foo = derived{42};
+  assert(count == 1);
+}


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


[libcxx] r289773 - Revert r289727 due to PR31384

2016-12-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Dec 15 00:34:54 2016
New Revision: 289773

URL: http://llvm.org/viewvc/llvm-project?rev=289773=rev
Log:
Revert r289727 due to PR31384

This patch reverts the changes to tuple which fixed construction from
types derived from tuple. It breaks the code mentioned in llvm.org/PR31384.
I'll follow this commit up with a test case.

Removed:

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/derived_from_tuple_like.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/derived_from_tuple_like.pass.cpp
libcxx/trunk/test/support/propagate_value_category.hpp
Modified:
libcxx/trunk/include/__tuple
libcxx/trunk/include/tuple
libcxx/trunk/include/type_traits

Modified: libcxx/trunk/include/__tuple
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__tuple?rev=289773=289772=289773=diff
==
--- libcxx/trunk/include/__tuple (original)
+++ libcxx/trunk/include/__tuple Thu Dec 15 00:34:54 2016
@@ -453,57 +453,19 @@ using tuple_element_t = typename tuple_e
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 
 #ifndef _LIBCPP_CXX03_LANG
+template 
+struct __tuple_like_with_size_imp : false_type {};
 
-template 
-struct __lookup_result {
-  using type = _Tp;
-  static constexpr bool _Success = _Good;
-  static constexpr size_t _Size = _TSize;
-};
-using __lookup_failure = __lookup_result;
-
-template 
-auto __deduce_tuple_type_ovl(tuple<_Args...>&)
--> __lookup_result, sizeof...(_Args)>;
-
-template 
-auto __deduce_tuple_type_ovl(pair<_T1, _T2>&)
--> __lookup_result, 2>;
-
-template 
-auto __deduce_tuple_type_ovl(array<_Tp, _Size>&)
-  -> __lookup_result, _Size>;
-
-template 
-auto __deduce_tuple_type_imp(int)
-  -> decltype(__deduce_tuple_type_ovl(_VSTD::declval<__uncvref_t<_Tp>&>()));
-template  __lookup_failure __deduce_tuple_type_imp(...);
-
-// __deduce_tuple_like - Given a type determine if it is, or is derived from,
-//   a tuple-like type. This trait is used to support constructing and 
assigning
-//   to std::tuple from user-types derived from a tuple-like type.
-template (0)),
-bool _Good = _Result::_Success>
-struct __deduce_tuple_like {
-  static_assert(_Good, "incorrect specialization choosen");
-  static constexpr bool _Success = true;
-  static constexpr size_t _Size = _Result::_Size;
-  using _RawType = typename _Result::type;
-  using _QualType =
-typename __propagate_value_category<_TupleLike>::template 
__apply<_RawType>;
-};
-
-template 
-struct __deduce_tuple_like<_TupleLike, _Result, /*_Good=*/false> {
-  static constexpr bool _Success = false;
-  static constexpr size_t _Size = (size_t)-1;
-};
-
-template >
-using __tuple_like_with_size = integral_constant;
+template 
+struct __tuple_like_with_size_imp
+: integral_constant {};
+
+template ::type>
+using __tuple_like_with_size = __tuple_like_with_size_imp<
+   __tuple_like<_RawTuple>::value,
+   tuple_size<_RawTuple>, _ExpectedSize
+  >;
 
 struct _LIBCPP_TYPE_VIS __check_tuple_constructor_fail {
 template 

Modified: libcxx/trunk/include/tuple
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/tuple?rev=289773=289772=289773=diff
==
--- libcxx/trunk/include/tuple (original)
+++ libcxx/trunk/include/tuple Thu Dec 15 00:34:54 2016
@@ -555,19 +555,13 @@ class _LIBCPP_TYPE_VIS_ONLY tuple
 {
 template 
 static constexpr bool __enable_implicit() {
-using _Deduced = __deduce_tuple_like<_Tuple>;
-using _QualType = typename _Deduced::_QualType;
-static_assert(__tuple_like::value, 
"");
-return __tuple_convertible<_QualType, tuple>::value;
+return __tuple_convertible<_Tuple, tuple>::value;
 }
 
 template 
 static constexpr bool __enable_explicit() {
-using _Deduced = __deduce_tuple_like<_Tuple>;
-using _QualType = typename _Deduced::_QualType;
-static_assert(__tuple_like::value, 
"");
-return __tuple_constructible<_QualType, tuple>::value
-   && !__tuple_convertible<_QualType, tuple>::value;
+return __tuple_constructible<_Tuple, tuple>::value
+   && !__tuple_convertible<_Tuple, tuple>::value;
 }
 };
 
@@ -820,74 +814,66 @@ public:
 _VSTD::forward<_Up>(__u)...) {}
 
 template ,
-  class _TupBase = typename _Deduced::_QualType,
   typename enable_if
   <
  _CheckTupleLikeConstructor<
-_Deduced::_Size 

[libcxx] r289767 - XFAIL test for more apple-clang versions

2016-12-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Dec 14 23:41:07 2016
New Revision: 289767

URL: http://llvm.org/viewvc/llvm-project?rev=289767=rev
Log:
XFAIL test for more apple-clang versions

Modified:

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

Modified: 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp?rev=289767=289766=289767=diff
==
--- 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
 Wed Dec 14 23:41:07 2016
@@ -9,7 +9,7 @@
 
 // Usage of is_trivially_constructible is broken with these compilers.
 // See https://llvm.org/bugs/show_bug.cgi?id=31016
-// XFAIL: clang-3.7, apple-clang-7.0
+// XFAIL: clang-3.7, apple-clang-7, apple-clang-7.0
 
 // 
 


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


[PATCH] D27796: Fix printf specifier handling: invalid specifier should not be marked as "consuming data arguments"

2016-12-14 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini created this revision.
mehdi_amini added reviewers: rsmith, bruno, dexonsmith.
mehdi_amini added a subscriber: cfe-commits.

https://reviews.llvm.org/D27796

Files:
  clang/include/clang/Analysis/Analyses/FormatString.h
  clang/test/CodeGen/builtins.c
  clang/test/Sema/format-strings.c
  clang/test/SemaObjC/format-strings-objc.m


Index: clang/test/SemaObjC/format-strings-objc.m
===
--- clang/test/SemaObjC/format-strings-objc.m
+++ clang/test/SemaObjC/format-strings-objc.m
@@ -47,7 +47,7 @@
 
 void check_nslog(unsigned k) {
   NSLog(@"%d%%", k); // no-warning
-  NSLog(@"%s%lb%d", "unix", 10,20); // expected-warning {{invalid conversion 
specifier 'b'}}
+  NSLog(@"%s%lb%d", "unix", 10, 20); // expected-warning {{invalid conversion 
specifier 'b'}} expected-warning {{data argument not used by format string}}
 }
 
 // Check type validation
Index: clang/test/Sema/format-strings.c
===
--- clang/test/Sema/format-strings.c
+++ clang/test/Sema/format-strings.c
@@ -156,10 +156,10 @@
 
 void check_invalid_specifier(FILE* fp, char *buf)
 {
-  printf("%s%lb%d","unix",10,20); // expected-warning {{invalid conversion 
specifier 'b'}}
+  printf("%s%lb%d","unix",10,20); // expected-warning {{invalid conversion 
specifier 'b'}} expected-warning {{data argument not used by format string}}
   fprintf(fp,"%%%l"); // expected-warning {{incomplete format specifier}}
   sprintf(buf,"%ld%d%d", 1, 2, 3); // expected-warning{{format specifies 
type 'long' but the argument has type 'int'}}
-  snprintf(buf, 2, "%ld%;%d", 1, 2, 3); // expected-warning{{format 
specifies type 'long' but the argument has type 'int'}} expected-warning 
{{invalid conversion specifier ';'}}
+  snprintf(buf, 2, "%ld%;%d", 1, 2, 3); // expected-warning{{format 
specifies type 'long' but the argument has type 'int'}} expected-warning 
{{invalid conversion specifier ';'}} expected-warning {{data argument not used 
by format string}}
 }
 
 void check_null_char_string(char* b)
@@ -251,7 +251,7 @@
   printf("%**\n"); // expected-warning{{invalid conversion specifier '*'}}
   printf("%d%d\n", x); // expected-warning{{more '%' conversions than data 
arguments}}
   printf("%d\n", x, x); // expected-warning{{data argument not used by format 
string}}
-  printf("%W%d\n", x, x); // expected-warning{{invalid conversion specifier 
'W'}}
+  printf("%W%d\n", x, x); // expected-warning{{invalid conversion specifier 
'W'}}  expected-warning {{data argument not used by format string}}
   printf("%"); // expected-warning{{incomplete format specifier}}
   printf("%.d", x); // no-warning
   printf("%.", x);  // expected-warning{{incomplete format specifier}}
@@ -270,7 +270,7 @@
   printf("%.0Lf", (long double) 1.0); // no-warning
   printf("%c\n", "x"); // expected-warning{{format specifies type 'int' but 
the argument has type 'char *'}}
   printf("%c\n", 1.23); // expected-warning{{format specifies type 'int' but 
the argument has type 'double'}}
-  printf("Format %d, is %! %f", 1, 2, 4.4); // expected-warning{{invalid 
conversion specifier '!'}}
+  printf("Format %d, is %! %f", 1, 4.4); // expected-warning{{invalid 
conversion specifier '!'}}
 }
 
 typedef unsigned char uint8_t;
Index: clang/test/CodeGen/builtins.c
===
--- clang/test/CodeGen/builtins.c
+++ clang/test/CodeGen/builtins.c
@@ -538,6 +538,34 @@
   __builtin_os_log_format(buf, "Hello %*.*s World", precision, width, data);
 }
 
+// CHECK-LABEL: define void @test_builtin_os_log_invalid
+// CHECK: (i8* [[BUF:%.*]], i32 [[DATA:%.*]])
+void test_builtin_os_log_invalid(void *buf, int data) {
+  volatile int len;
+  // CHECK: store i8* [[BUF]], i8** [[BUF_ADDR:%.*]], align 8
+  // CHECK: store i32 [[DATA]], i32* [[DATA_ADDR:%.*]]
+
+  // CHECK: store volatile i32 8,
+  len = __builtin_os_log_format_buffer_size("invalid specifier %: %d even a 
trailing one%", data);
+
+  // CHECK: [[BUF2:%.*]] = load i8*, i8** [[BUF_ADDR]]
+  // CHECK: [[SUMMARY:%.*]] = getelementptr i8, i8* [[BUF2]], i64 0
+  // CHECK: store i8 0, i8* [[SUMMARY]]
+  // CHECK: [[NUM_ARGS:%.*]] = getelementptr i8, i8* [[BUF2]], i64 1
+  // CHECK: store i8 1, i8* [[NUM_ARGS]]
+
+  // CHECK: [[ARG1_DESC:%.*]] = getelementptr i8, i8* [[BUF2]], i64 2
+  // CHECK: store i8 0, i8* [[ARG1_DESC]]
+  // CHECK: [[ARG1_SIZE:%.*]] = getelementptr i8, i8* [[BUF2]], i64 3
+  // CHECK: store i8 4, i8* [[ARG1_SIZE]]
+  // CHECK: [[ARG1:%.*]] = getelementptr i8, i8* [[BUF2]], i64 4
+  // CHECK: [[ARG1_INT:%.*]] = bitcast i8* [[ARG1]] to i32*
+  // CHECK: [[ARG1_VAL:%.*]] = load i32, i32* [[DATA_ADDR]]
+  // CHECK: store i32 [[ARG1_VAL]], i32* [[ARG1_INT]]
+
+  __builtin_os_log_format(buf, "invalid specifier %: %d even a trailing one%", 
data);
+}
+
 // CHECK-LABEL: define void @test_builtin_os_log_percent
 // CHECK: (i8* [[BUF:%.*]], i8* [[DATA1:%.*]], i8* 

r289763 - Revert "Fix printf specifier handling: invalid specifier should not be marked as "consuming data arguments""

2016-12-14 Thread Mehdi Amini via cfe-commits
Author: mehdi_amini
Date: Wed Dec 14 22:58:51 2016
New Revision: 289763

URL: http://llvm.org/viewvc/llvm-project?rev=289763=rev
Log:
Revert "Fix printf specifier handling: invalid specifier should not be marked 
as "consuming data arguments""

This reverts commit r289762, wasn't ready to be pushed, it broke the printf 
tests.

Modified:
cfe/trunk/include/clang/Analysis/Analyses/FormatString.h
cfe/trunk/test/CodeGen/builtins.c

Modified: cfe/trunk/include/clang/Analysis/Analyses/FormatString.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/FormatString.h?rev=289763=289762=289763=diff
==
--- cfe/trunk/include/clang/Analysis/Analyses/FormatString.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/FormatString.h Wed Dec 14 
22:58:51 2016
@@ -211,8 +211,6 @@ public:
 return false;
   case PercentArg:
 return false;
-  case InvalidSpecifier:
-return false;
   default:
 return true;
 }

Modified: cfe/trunk/test/CodeGen/builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins.c?rev=289763=289762=289763=diff
==
--- cfe/trunk/test/CodeGen/builtins.c (original)
+++ cfe/trunk/test/CodeGen/builtins.c Wed Dec 14 22:58:51 2016
@@ -538,34 +538,6 @@ void test_builtin_os_log_precision_width
   __builtin_os_log_format(buf, "Hello %*.*s World", precision, width, data);
 }
 
-// CHECK-LABEL: define void @test_builtin_os_log_invalid
-// CHECK: (i8* [[BUF:%.*]], i32 [[DATA:%.*]])
-void test_builtin_os_log_invalid(void *buf, int data) {
-  volatile int len;
-  // CHECK: store i8* [[BUF]], i8** [[BUF_ADDR:%.*]], align 8
-  // CHECK: store i32 [[DATA]], i32* [[DATA_ADDR:%.*]]
-
-  // CHECK: store volatile i32 8,
-  len = __builtin_os_log_format_buffer_size("invalid specifier %: %d even a 
trailing one%", data);
-
-  // CHECK: [[BUF2:%.*]] = load i8*, i8** [[BUF_ADDR]]
-  // CHECK: [[SUMMARY:%.*]] = getelementptr i8, i8* [[BUF2]], i64 0
-  // CHECK: store i8 0, i8* [[SUMMARY]]
-  // CHECK: [[NUM_ARGS:%.*]] = getelementptr i8, i8* [[BUF2]], i64 1
-  // CHECK: store i8 1, i8* [[NUM_ARGS]]
-
-  // CHECK: [[ARG1_DESC:%.*]] = getelementptr i8, i8* [[BUF2]], i64 2
-  // CHECK: store i8 0, i8* [[ARG1_DESC]]
-  // CHECK: [[ARG1_SIZE:%.*]] = getelementptr i8, i8* [[BUF2]], i64 3
-  // CHECK: store i8 4, i8* [[ARG1_SIZE]]
-  // CHECK: [[ARG1:%.*]] = getelementptr i8, i8* [[BUF2]], i64 4
-  // CHECK: [[ARG1_INT:%.*]] = bitcast i8* [[ARG1]] to i32*
-  // CHECK: [[ARG1_VAL:%.*]] = load i32, i32* [[DATA_ADDR]]
-  // CHECK: store i32 [[ARG1_VAL]], i32* [[ARG1_INT]]
-
-  __builtin_os_log_format(buf, "invalid specifier %: %d even a trailing one%", 
data);
-}
-
 // CHECK-LABEL: define void @test_builtin_os_log_percent
 // CHECK: (i8* [[BUF:%.*]], i8* [[DATA1:%.*]], i8* [[DATA2:%.*]])
 // Check that the %% which does not consume any argument is correctly handled


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


r289762 - Fix printf specifier handling: invalid specifier should not be marked as "consuming data arguments"

2016-12-14 Thread Mehdi Amini via cfe-commits
Author: mehdi_amini
Date: Wed Dec 14 22:51:22 2016
New Revision: 289762

URL: http://llvm.org/viewvc/llvm-project?rev=289762=rev
Log:
Fix printf specifier handling: invalid specifier should not be marked as 
"consuming data arguments"

Modified:
cfe/trunk/include/clang/Analysis/Analyses/FormatString.h
cfe/trunk/test/CodeGen/builtins.c

Modified: cfe/trunk/include/clang/Analysis/Analyses/FormatString.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/FormatString.h?rev=289762=289761=289762=diff
==
--- cfe/trunk/include/clang/Analysis/Analyses/FormatString.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/FormatString.h Wed Dec 14 
22:51:22 2016
@@ -211,6 +211,8 @@ public:
 return false;
   case PercentArg:
 return false;
+  case InvalidSpecifier:
+return false;
   default:
 return true;
 }

Modified: cfe/trunk/test/CodeGen/builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins.c?rev=289762=289761=289762=diff
==
--- cfe/trunk/test/CodeGen/builtins.c (original)
+++ cfe/trunk/test/CodeGen/builtins.c Wed Dec 14 22:51:22 2016
@@ -538,6 +538,34 @@ void test_builtin_os_log_precision_width
   __builtin_os_log_format(buf, "Hello %*.*s World", precision, width, data);
 }
 
+// CHECK-LABEL: define void @test_builtin_os_log_invalid
+// CHECK: (i8* [[BUF:%.*]], i32 [[DATA:%.*]])
+void test_builtin_os_log_invalid(void *buf, int data) {
+  volatile int len;
+  // CHECK: store i8* [[BUF]], i8** [[BUF_ADDR:%.*]], align 8
+  // CHECK: store i32 [[DATA]], i32* [[DATA_ADDR:%.*]]
+
+  // CHECK: store volatile i32 8,
+  len = __builtin_os_log_format_buffer_size("invalid specifier %: %d even a 
trailing one%", data);
+
+  // CHECK: [[BUF2:%.*]] = load i8*, i8** [[BUF_ADDR]]
+  // CHECK: [[SUMMARY:%.*]] = getelementptr i8, i8* [[BUF2]], i64 0
+  // CHECK: store i8 0, i8* [[SUMMARY]]
+  // CHECK: [[NUM_ARGS:%.*]] = getelementptr i8, i8* [[BUF2]], i64 1
+  // CHECK: store i8 1, i8* [[NUM_ARGS]]
+
+  // CHECK: [[ARG1_DESC:%.*]] = getelementptr i8, i8* [[BUF2]], i64 2
+  // CHECK: store i8 0, i8* [[ARG1_DESC]]
+  // CHECK: [[ARG1_SIZE:%.*]] = getelementptr i8, i8* [[BUF2]], i64 3
+  // CHECK: store i8 4, i8* [[ARG1_SIZE]]
+  // CHECK: [[ARG1:%.*]] = getelementptr i8, i8* [[BUF2]], i64 4
+  // CHECK: [[ARG1_INT:%.*]] = bitcast i8* [[ARG1]] to i32*
+  // CHECK: [[ARG1_VAL:%.*]] = load i32, i32* [[DATA_ADDR]]
+  // CHECK: store i32 [[ARG1_VAL]], i32* [[ARG1_INT]]
+
+  __builtin_os_log_format(buf, "invalid specifier %: %d even a trailing one%", 
data);
+}
+
 // CHECK-LABEL: define void @test_builtin_os_log_percent
 // CHECK: (i8* [[BUF:%.*]], i8* [[DATA1:%.*]], i8* [[DATA2:%.*]])
 // Check that the %% which does not consume any argument is correctly handled


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


r289761 - Fix os_log formating with arbitrary precision and field width

2016-12-14 Thread Mehdi Amini via cfe-commits
Author: mehdi_amini
Date: Wed Dec 14 22:02:31 2016
New Revision: 289761

URL: http://llvm.org/viewvc/llvm-project?rev=289761=rev
Log:
Fix os_log formating with arbitrary precision and field width

Modified:
cfe/trunk/lib/Analysis/OSLog.cpp
cfe/trunk/test/CodeGen/builtins.c

Modified: cfe/trunk/lib/Analysis/OSLog.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/OSLog.cpp?rev=289761=289760=289761=diff
==
--- cfe/trunk/lib/Analysis/OSLog.cpp (original)
+++ cfe/trunk/lib/Analysis/OSLog.cpp Wed Dec 14 22:02:31 2016
@@ -22,6 +22,9 @@ private:
 const Expr *E = nullptr;
 Optional Kind;
 Optional Size;
+Optional Count;
+Optional Precision;
+Optional FieldWidth;
 unsigned char Flags = 0;
   };
   SmallVector ArgsData;
@@ -84,7 +87,7 @@ public:
 ArgsData.back().Size = precision.getConstantAmount();
 break;
   case clang::analyze_format_string::OptionalAmount::Arg: // "%.*s"
-ArgsData.back().Kind = OSLogBufferItem::CountKind;
+ArgsData.back().Count = Args[precision.getArgIndex()];
 break;
   case clang::analyze_format_string::OptionalAmount::Invalid:
 return false;
@@ -100,7 +103,7 @@ public:
 ArgsData.back().Size = precision.getConstantAmount();
 break;
   case clang::analyze_format_string::OptionalAmount::Arg: // "%.*P"
-ArgsData.back().Kind = OSLogBufferItem::CountKind;
+ArgsData.back().Count = Args[precision.getArgIndex()];
 break;
   case clang::analyze_format_string::OptionalAmount::Invalid:
 return false;
@@ -108,8 +111,14 @@ public:
   break;
 }
 default:
+  if (FS.getPrecision().hasDataArgument()) {
+ArgsData.back().Precision = Args[FS.getPrecision().getArgIndex()];
+  }
   break;
 }
+if (FS.getFieldWidth().hasDataArgument()) {
+  ArgsData.back().FieldWidth = Args[FS.getFieldWidth().getArgIndex()];
+}
 
 if (FS.isPrivate()) {
   ArgsData.back().Flags |= OSLogBufferItem::IsPrivate;
@@ -123,6 +132,22 @@ public:
   void computeLayout(ASTContext , OSLogBufferLayout ) const {
 Layout.Items.clear();
 for (auto  : ArgsData) {
+  if (Data.FieldWidth) {
+CharUnits Size = Ctx.getTypeSizeInChars((*Data.FieldWidth)->getType());
+Layout.Items.emplace_back(OSLogBufferItem::ScalarKind, 
*Data.FieldWidth,
+  Size, 0);
+  }
+  if (Data.Precision) {
+CharUnits Size = Ctx.getTypeSizeInChars((*Data.Precision)->getType());
+Layout.Items.emplace_back(OSLogBufferItem::ScalarKind, *Data.Precision,
+  Size, 0);
+  }
+  if (Data.Count) {
+// "%.*P" has an extra "count" that we insert before the argument.
+CharUnits Size = Ctx.getTypeSizeInChars((*Data.Count)->getType());
+Layout.Items.emplace_back(OSLogBufferItem::CountKind, *Data.Count, 
Size,
+  0);
+  }
   if (Data.Size)
 Layout.Items.emplace_back(Ctx, CharUnits::fromQuantity(*Data.Size),
   Data.Flags);

Modified: cfe/trunk/test/CodeGen/builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins.c?rev=289761=289760=289761=diff
==
--- cfe/trunk/test/CodeGen/builtins.c (original)
+++ cfe/trunk/test/CodeGen/builtins.c Wed Dec 14 22:02:31 2016
@@ -489,6 +489,55 @@ void test_builtin_os_log_wide(void *buf,
   __builtin_os_log_format(buf, "%S", str);
 }
 
+// CHECK-LABEL: define void @test_builtin_os_log_precision_width
+// CHECK: (i8* [[BUF:%.*]], i8* [[DATA:%.*]], i32 [[PRECISION:%.*]], i32 
[[WIDTH:%.*]])
+void test_builtin_os_log_precision_width(void *buf, const char *data,
+ int precision, int width) {
+  volatile int len;
+  // CHECK: store i8* [[BUF]], i8** [[BUF_ADDR:%.*]], align 8
+  // CHECK: store i8* [[DATA]], i8** [[DATA_ADDR:%.*]], align 8
+  // CHECK: store i32 [[PRECISION]], i32* [[PRECISION_ADDR:%.*]], align 4
+  // CHECK: store i32 [[WIDTH]], i32* [[WIDTH_ADDR:%.*]], align 4
+
+  // CHECK: store volatile i32 24,
+  len = __builtin_os_log_format_buffer_size("Hello %*.*s World", precision, 
width, data);
+
+  // CHECK: [[BUF2:%.*]] = load i8*, i8** [[BUF_ADDR]]
+  // CHECK: [[SUMMARY:%.*]] = getelementptr i8, i8* [[BUF2]], i64 0
+  // CHECK: store i8 2, i8* [[SUMMARY]]
+  // CHECK: [[NUM_ARGS:%.*]] = getelementptr i8, i8* [[BUF2]], i64 1
+  // CHECK: store i8 3, i8* [[NUM_ARGS]]
+
+  // CHECK: [[ARG1_DESC:%.*]] = getelementptr i8, i8* [[BUF2]], i64 2
+  // CHECK: store i8 0, i8* [[ARG1_DESC]]
+  // CHECK: [[ARG1_SIZE:%.*]] = getelementptr i8, i8* [[BUF2]], i64 3
+  // CHECK: store i8 4, i8* [[ARG1_SIZE]]
+  // CHECK: [[ARG1:%.*]] = getelementptr i8, i8* [[BUF2]], i64 4
+  // CHECK: [[ARG1_INT:%.*]] = 

r289754 - [c++1z] Permit constant evaluation of a call through a function pointer whose

2016-12-14 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Dec 14 20:35:39 2016
New Revision: 289754

URL: http://llvm.org/viewvc/llvm-project?rev=289754=rev
Log:
[c++1z] Permit constant evaluation of a call through a function pointer whose
type differs from the type of the actual function due to having a different
exception specification.

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx1z.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=289754=289753=289754=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Wed Dec 14 20:35:39 2016
@@ -1109,6 +1109,10 @@ public:
   /// \brief Change the result type of a function type once it is deduced.
   void adjustDeducedFunctionResultType(FunctionDecl *FD, QualType ResultType);
 
+  /// \brief Determine whether two function types are the same, ignoring
+  /// exception specifications in cases where they're part of the type.
+  bool hasSameFunctionTypeIgnoringExceptionSpec(QualType T, QualType U);
+
   /// \brief Change the exception specification on a function once it is
   /// delay-parsed, instantiated, or computed.
   void adjustExceptionSpec(FunctionDecl *FD,

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=289754=289753=289754=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Dec 14 20:35:39 2016
@@ -2382,6 +2382,14 @@ static QualType getFunctionTypeWithExcep
   Proto->getExtProtoInfo().withExceptionSpec(ESI));
 }
 
+bool ASTContext::hasSameFunctionTypeIgnoringExceptionSpec(QualType T,
+  QualType U) {
+  return hasSameType(T, U) ||
+ (getLangOpts().CPlusPlus1z &&
+  hasSameType(getFunctionTypeWithExceptionSpec(*this, T, EST_None),
+  getFunctionTypeWithExceptionSpec(*this, U, EST_None)));
+}
+
 void ASTContext::adjustExceptionSpec(
 FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo ,
 bool AsWritten) {

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=289754=289753=289754=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Wed Dec 14 20:35:39 2016
@@ -4434,8 +4434,11 @@ public:
   }
 
   // Don't call function pointers which have been cast to some other type.
-  if (!Info.Ctx.hasSameType(CalleeType->getPointeeType(), FD->getType()))
+  // Per DR (no number yet), the caller and callee can differ in noexcept.
+  if (!Info.Ctx.hasSameFunctionTypeIgnoringExceptionSpec(
+  CalleeType->getPointeeType(), FD->getType())) {
 return Error(E);
+  }
 } else
   return Error(E);
 

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=289754=289753=289754=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Dec 14 20:35:39 2016
@@ -9076,27 +9076,16 @@ bool Sema::CheckFunctionDeclaration(Scop
   ASTContext::GetBuiltinTypeError Error;
   LookupPredefedObjCSuperType(*this, S, NewFD->getIdentifier());
   QualType T = Context.GetBuiltinType(BuiltinID, Error);
-  if (!T.isNull() && !Context.hasSameType(T, NewFD->getType())) {
-auto WithoutExceptionSpec = [&](QualType T) -> QualType {
-  auto *Proto = T->getAs();
-  if (!Proto)
-return T;
-  return Context.getFunctionType(
-  Proto->getReturnType(), Proto->getParamTypes(),
-  Proto->getExtProtoInfo().withExceptionSpec(EST_None));
-};
-
-// If the type of the builtin differs only in its exception
-// specification, that's OK.
-// FIXME: If the types do differ in this way, it would be better to
-// retain the 'noexcept' form of the type.
-if (!getLangOpts().CPlusPlus1z ||
-!Context.hasSameType(WithoutExceptionSpec(T),
- WithoutExceptionSpec(NewFD->getType(
-  // The type of this function differs from the type of the builtin,
-  // so forget about the builtin entirely.
-  Context.BuiltinInfo.forgetBuiltin(BuiltinID, Context.Idents);
-  }
+  // If the type of the builtin differs only in its exception
+  // specification, that's OK.
+   

r289753 - Move checks for creation of objects of abstract class type from the various

2016-12-14 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Dec 14 20:28:18 2016
New Revision: 289753

URL: http://llvm.org/viewvc/llvm-project?rev=289753=rev
Log:
Move checks for creation of objects of abstract class type from the various
constructs that can do so into the initialization code. This fixes a number
of different cases in which we used to fail to check for abstract types.

Thanks to Tim Shen for inspiring the weird code that uncovered this!

Added:
cfe/trunk/test/CXX/class.derived/class.abstract/p2.cpp
cfe/trunk/test/CXX/class.derived/class.abstract/p3.cpp
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaObjCProperty.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=289753=289752=289753=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Dec 14 20:28:18 2016
@@ -1291,10 +1291,6 @@ Sema::BuildCXXTypeConstructExpr(TypeSour
   diag::err_invalid_incomplete_type_use, FullRange))
 return ExprError();
 
-  if (RequireNonAbstractType(TyBeginLoc, Ty,
- diag::err_allocation_of_abstract_type))
-return ExprError();
-
   InitializedEntity Entity = InitializedEntity::InitializeTemporary(TInfo);
   InitializationKind Kind =
   Exprs.size() ? ListInitialization
@@ -5491,9 +5487,6 @@ QualType Sema::CXXCheckConditionalOperan
   if (Context.getCanonicalType(LTy) == Context.getCanonicalType(RTy)) {
 if (LTy->isRecordType()) {
   // The operands have class type. Make a temporary copy.
-  if (RequireNonAbstractType(QuestionLoc, LTy,
- diag::err_allocation_of_abstract_type))
-return QualType();
   InitializedEntity Entity = InitializedEntity::InitializeTemporary(LTy);
 
   ExprResult LHSCopy = PerformCopyInitialization(Entity,

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=289753=289752=289753=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Wed Dec 14 20:28:18 2016
@@ -4599,7 +4599,7 @@ static void TryValueInitialization(Sema
   MultiExprArg Args(, InitList ? 1 : 0);
   bool InitListSyntax = InitList;
 
-  // FIXME: Instead of creating a CXXConstructExpr of non-array type here,
+  // FIXME: Instead of creating a CXXConstructExpr of array type here,
   // wrap a class-typed CXXConstructExpr in an ArrayInitLoopExpr.
   return TryConstructorInitialization(
   S, Entity, Kind, Args, T, Entity.getType(), Sequence, 
InitListSyntax);
@@ -6366,6 +6366,8 @@ ExprResult Sema::TemporaryMaterializatio
 return E;
 
   // C++1z [conv.rval]/1: T shall be a complete type.
+  // FIXME: Does this ever matter (can we form a prvalue of incomplete type)?
+  // If so, we should check for a non-abstract class type here too.
   QualType T = E->getType();
   if (RequireCompleteType(E->getExprLoc(), T, diag::err_incomplete_type))
 return ExprError();
@@ -6541,6 +6543,17 @@ InitializationSequence::Perform(Sema ,
 break;
   }
 
+  // C++ [class.abstract]p2:
+  //   no objects of an abstract class can be created except as subobjects
+  //   of a class derived from it
+  auto checkAbstractType = [&](QualType T) -> bool {
+if (Entity.getKind() == InitializedEntity::EK_Base ||
+Entity.getKind() == InitializedEntity::EK_Delegating)
+  return false;
+return S.RequireNonAbstractType(Kind.getLocation(), T,
+diag::err_allocation_of_abstract_type);
+  };
+
   // Walk through the computed steps for the initialization sequence,
   // performing the specified conversions along the way.
   bool ConstructorInitRequiresZeroInit = false;
@@ -6647,6 +6660,9 @@ InitializationSequence::Perform(Sema ,
 }
 
 case SK_FinalCopy:
+  if (checkAbstractType(Step->Type))
+return ExprError();
+
   // If the overall initialization is initializing a temporary, we already
   // bound our argument if it was necessary to do so. If not (if we're
   // ultimately initializing a non-temporary), our argument needs to be
@@ -6731,6 +6747,9 @@ InitializationSequence::Perform(Sema ,
 CreatedObject = Conversion->getReturnType()->isRecordType();
   }
 
+  if (CreatedObject && checkAbstractType(CurInit.get()->getType()))
+return ExprError();
+
   CurInit = ImplicitCastExpr::Create(S.Context, CurInit.get()->getType(),
  CastKind, CurInit.get(), nullptr,
  CurInit.get()->getValueKind());
@@ -6813,6 +6832,9 @@ InitializationSequence::Perform(Sema ,
 }
 
 case SK_ListInitialization: {
+  if 

r289752 - Include SmallSet.h in BackendUtil.cpp

2016-12-14 Thread Hal Finkel via cfe-commits
Author: hfinkel
Date: Wed Dec 14 20:19:17 2016
New Revision: 289752

URL: http://llvm.org/viewvc/llvm-project?rev=289752=rev
Log:
Include SmallSet.h in BackendUtil.cpp

BackendUtil.cpp uses llvm::SmallSet but did not include the header. It was
included indirectly, but this will change once the AssumptionCache is removed.
NFC.

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=289752=289751=289752=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Dec 14 20:19:17 2016
@@ -14,6 +14,7 @@
 #include "clang/Frontend/CodeGenOptions.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
 #include "clang/Frontend/Utils.h"
+#include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Triple.h"


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


[PATCH] D26267: [Modules] Include builtins with #include instead of #import for ObjC

2016-12-14 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

Other options:

Do we need to perfectly preserve the functionality of `#pragma once` / 
`#import`? That is, would it be acceptable to you if we spuriously enter files 
that have been imported in that way, while building a module? If we view them 
as pure optimization, we can do something //substantially// simpler here, for 
instance by never importing "isImported" flags from modules and throwing away 
all our "isImported" flags whenever module visibility decreases.

Another possibility -- albeit slightly hacky -- would be to invent a 
controlling macro if the header in question turns out to not have one (say, 
form an identifier from the path by which the file was included and use that as 
the macro name) and is #imported / uses #pragma once. Or we could try simply 
rejecting textual headers that are #import'd / #pragma once'd and have no 
controlling macro in a modules build.




Comment at: include/clang/Lex/HeaderSearch.h:98-101
+  /// List of modules that import from this header. Since the number of modules
+  /// using the same FileEntry is usually small (2 or 3 at most, often related
+  /// to builtins) this should be enough. Choose a more appropriate data
+  /// structure in case the requirement changes.

I don't think this is true in general. For a textual header, there could be 
hundreds or thousands of loaded modules that use it. If all header files in a 
project start with

  #include "local_config.h"

... which is configured to be a textual header for whatever reason and contains 
a `#pragma once`, we would get into that situation for at least that one 
header. While a vector might be OK (as the number of entries should at least 
grow only linearly with the size of the entire codebase), quadratic-time 
algorithms over it probably won't be. Perhaps a sorted vector instead?



Comment at: lib/Lex/HeaderSearch.cpp:1116-1119
+//  - if there not associated module or the module already imports
+//from this header.
+//  - if any module associated with this header is visible.
+if (FileInfo.isImport) {

I think this would be clearer as:

> [...], ignore it, unless doing so will lead to us importing a module that 
> contains the file but didn't actually include it (because we're still 
> building the corresponding module), and we've not already made the file 
> visible by importing some other module.

... but I don't think that's actually right. If `M` is null (if the file is 
only ever included as a textual header), we still need to check whether some 
visible module has actually made it visible, and we should enter it if not.



Comment at: lib/Serialization/ASTReader.cpp:1691-1692
 HFI.isModuleHeader |= !(HeaderRole & ModuleMap::TextualHeader);
+if (HFI.isImport)
+  HFI.addModulesUsingHdr(Mod);
   }

Doing this here will do the wrong thing while building a module with local 
submodule visibility enabled -- we need to know whether the visible module set 
contains a module that entered the header, even for modules that we've never 
serialized.

Also, this will not populate the vector for the cases where the header was not 
listed in the module map, but was simply a non-moduler header that was 
textually entered while building a module.


https://reviews.llvm.org/D26267



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


[PATCH] D27794: Make some diagnostic tests C++11 clean

2016-12-14 Thread Paul Robinson via Phabricator via cfe-commits
probinson created this revision.
probinson added a reviewer: rsmith.
probinson added subscribers: cfe-commits, tigerleapgorge.

Another half-dozen test revisions in the ongoing campaign to make things ready 
for C++11 as Clangs's default dialect.

Most of these are straightforward, but I am not entirely sure about a couple of 
things:

- In fixit.cpp, the place that now gets 'expected unqualified-id' seems funny, 
but maybe that's just the nature of things
- In copy-assignment.cpp, I am bemused by the whole thing but especially 
'passing argument to parameter here'


https://reviews.llvm.org/D27794

Files:
  test/FixIt/fixit.cpp
  test/OpenMP/teams_distribute_collapse_messages.cpp
  test/OpenMP/teams_distribute_parallel_for_collapse_messages.cpp
  test/OpenMP/teams_distribute_parallel_for_simd_collapse_messages.cpp
  test/Parser/backtrack-off-by-one.cpp
  test/SemaCXX/copy-assignment.cpp

Index: test/SemaCXX/copy-assignment.cpp
===
--- test/SemaCXX/copy-assignment.cpp
+++ test/SemaCXX/copy-assignment.cpp
@@ -1,12 +1,22 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s 
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+#if __cplusplus >= 201103L
+// expected-note@+3 2 {{candidate constructor}}
+// expected-note@+2 {{passing argument to parameter here}}
+#endif
 struct A {
 };
 
 struct ConvertibleToA {
   operator A();
 };
 
 struct ConvertibleToConstA {
+#if __cplusplus >= 201103L
+// expected-note@+2 {{candidate function}}
+#endif
   operator const A();
 };
 
@@ -69,6 +79,9 @@
   na = a;
   na = constA;
   na = convertibleToA;
+#if __cplusplus >= 201103L
+// expected-error@+2 {{no viable conversion}}
+#endif
   na = convertibleToConstA;
   na += a; // expected-error{{no viable overloaded '+='}}
 
Index: test/Parser/backtrack-off-by-one.cpp
===
--- test/Parser/backtrack-off-by-one.cpp
+++ test/Parser/backtrack-off-by-one.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify %s -std=c++98
+// RUN: %clang_cc1 -verify %s -std=c++11
 
 // PR25946
 // We had an off-by-one error in an assertion when annotating A below.  Our
@@ -10,8 +12,10 @@
 
 // expected-error@+1 {{expected '{' after base class list}}
 template  class B : T // not ',' or '{'
-// expected-error@+3 {{C++ requires a type specifier for all declarations}}
-// expected-error@+2 {{expected ';' after top level declarator}}
+#if __cplusplus < 201103L
+// expected-error@+4 {{expected ';' after top level declarator}}
+#endif
+// expected-error@+2 {{C++ requires a type specifier for all declarations}}
 // expected-error@+1 {{expected ';' after class}}
 A {
 };
Index: test/OpenMP/teams_distribute_parallel_for_simd_collapse_messages.cpp
===
--- test/OpenMP/teams_distribute_parallel_for_simd_collapse_messages.cpp
+++ test/OpenMP/teams_distribute_parallel_for_simd_collapse_messages.cpp
@@ -1,8 +1,13 @@
 // RUN: %clang_cc1 -verify -fopenmp %s
+// RUN: %clang_cc1 -verify -fopenmp %s -std=c++98
+// RUN: %clang_cc1 -verify -fopenmp %s -std=c++11
 
 void foo() {
 }
 
+#if __cplusplus >= 201103L
+// expected-note@+2 4 {{declared here}}
+#endif
 bool foobool(int argc) {
   return argc;
 }
@@ -50,6 +55,9 @@
   for (int i = ST; i < N; i++)
 argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 for loops after '#pragma omp teams distribute parallel for simd', but found only 1}}
 
+#if __cplusplus >= 201103L
+// expected-note@+6 2 {{non-constexpr function 'foobool' cannot be used}}
+#endif
 // expected-error@+4 2 {{directive '#pragma omp teams distribute parallel for simd' cannot contain more than one 'collapse' clause}}
 // expected-error@+3 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
 // expected-error@+2 2 {{expression is not an integral constant expression}}
@@ -62,7 +70,11 @@
   for (int i = ST; i < N; i++)
 argv[0][i] = argv[0][i] - argv[0][i-ST];
 
-// expected-error@+2 2 {{expression is not an integral constant expression}}
+#if __cplusplus >= 201103L
+// expected-error@+5 2 {{integral constant expression must have integral or unscoped enumeration type}}
+#else
+// expected-error@+3 2 {{expression is not an integral constant expression}}
+#endif
 #pragma omp target
 #pragma omp teams distribute parallel for simd collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int i = ST; i < N; i++)
@@ -110,11 +122,17 @@
   for (int i = 4; i < 12; i++)
 argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp teams distribute parallel for simd', but found only 1}}
 
+#if __cplusplus >= 201103L
+// expected-note@+3 {{non-constexpr function 'foobool' cannot be used}}
+#endif
 #pragma omp target
 

[PATCH] D27788: [CUDA] Add --ptxas-path= flag.

2016-12-14 Thread Justin Lebar via Phabricator via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added a subscriber: cfe-commits.

This lets you build with one CUDA installation but use ptxas from
another install.

This is useful e.g. if you want to avoid bugs in an old ptxas without
actually upgrading wholesale to a newer CUDA version.


https://reviews.llvm.org/D27788

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Tools.cpp
  clang/test/Driver/cuda-ptxas-path.cu


Index: clang/test/Driver/cuda-ptxas-path.cu
===
--- /dev/null
+++ clang/test/Driver/cuda-ptxas-path.cu
@@ -0,0 +1,12 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang -### --target=i386-unknown-linux \
+// RUN:   --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
+// RUN:   --ptxas-path=/some/path/to/ptxas %s 2>&1 \
+// RUN: | FileCheck %s
+
+// CHECK-NOT: "ptxas"
+// CHECK: "/some/path/to/ptxas"
+// CHECK-SAME: "--gpu-name" "sm_20"
Index: clang/lib/Driver/Tools.cpp
===
--- clang/lib/Driver/Tools.cpp
+++ clang/lib/Driver/Tools.cpp
@@ -12075,7 +12075,11 @@
   for (const auto& A : Args.getAllArgValues(options::OPT_Xcuda_ptxas))
 CmdArgs.push_back(Args.MakeArgString(A));
 
-  const char *Exec = Args.MakeArgString(TC.GetProgramPath("ptxas"));
+  const char *Exec;
+  if (Arg *A = Args.getLastArg(options::OPT_ptxas_path_EQ))
+Exec = A->getValue();
+  else
+Exec = Args.MakeArgString(TC.GetProgramPath("ptxas"));
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -425,6 +425,8 @@
 def no_cuda_noopt_device_debug : Flag<["--"], "no-cuda-noopt-device-debug">;
 def cuda_path_EQ : Joined<["--"], "cuda-path=">, Group,
   HelpText<"CUDA installation path">;
+def ptxas_path_EQ : Joined<["--"], "ptxas-path=">, Group,
+  HelpText<"Path to ptxas (used for compiling CUDA code)">;
 def fcuda_flush_denormals_to_zero : Flag<["-"], 
"fcuda-flush-denormals-to-zero">,
   Flags<[CC1Option]>, HelpText<"Flush denormal floating point values to zero 
in CUDA device mode.">;
 def fno_cuda_flush_denormals_to_zero : Flag<["-"], 
"fno-cuda-flush-denormals-to-zero">;


Index: clang/test/Driver/cuda-ptxas-path.cu
===
--- /dev/null
+++ clang/test/Driver/cuda-ptxas-path.cu
@@ -0,0 +1,12 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang -### --target=i386-unknown-linux \
+// RUN:   --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
+// RUN:   --ptxas-path=/some/path/to/ptxas %s 2>&1 \
+// RUN: | FileCheck %s
+
+// CHECK-NOT: "ptxas"
+// CHECK: "/some/path/to/ptxas"
+// CHECK-SAME: "--gpu-name" "sm_20"
Index: clang/lib/Driver/Tools.cpp
===
--- clang/lib/Driver/Tools.cpp
+++ clang/lib/Driver/Tools.cpp
@@ -12075,7 +12075,11 @@
   for (const auto& A : Args.getAllArgValues(options::OPT_Xcuda_ptxas))
 CmdArgs.push_back(Args.MakeArgString(A));
 
-  const char *Exec = Args.MakeArgString(TC.GetProgramPath("ptxas"));
+  const char *Exec;
+  if (Arg *A = Args.getLastArg(options::OPT_ptxas_path_EQ))
+Exec = A->getValue();
+  else
+Exec = Args.MakeArgString(TC.GetProgramPath("ptxas"));
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -425,6 +425,8 @@
 def no_cuda_noopt_device_debug : Flag<["--"], "no-cuda-noopt-device-debug">;
 def cuda_path_EQ : Joined<["--"], "cuda-path=">, Group,
   HelpText<"CUDA installation path">;
+def ptxas_path_EQ : Joined<["--"], "ptxas-path=">, Group,
+  HelpText<"Path to ptxas (used for compiling CUDA code)">;
 def fcuda_flush_denormals_to_zero : Flag<["-"], "fcuda-flush-denormals-to-zero">,
   Flags<[CC1Option]>, HelpText<"Flush denormal floating point values to zero in CUDA device mode.">;
 def fno_cuda_flush_denormals_to_zero : Flag<["-"], "fno-cuda-flush-denormals-to-zero">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27786: [libcxx] [test] Strip trailing whitespace.

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

[libcxx] [test] Strip trailing whitespace.


https://reviews.llvm.org/D27786

Files:
  test/std/experimental/utilities/meta/meta.detect/detected_or.pass.cpp
  test/std/experimental/utilities/meta/meta.detect/detected_t.pass.cpp
  test/std/experimental/utilities/meta/meta.detect/is_detected.pass.cpp
  
test/std/experimental/utilities/meta/meta.detect/is_detected_convertible.pass.cpp
  test/std/experimental/utilities/meta/meta.detect/is_detected_exact.pass.cpp


Index: 
test/std/experimental/utilities/meta/meta.detect/is_detected_exact.pass.cpp
===
--- test/std/experimental/utilities/meta/meta.detect/is_detected_exact.pass.cpp
+++ test/std/experimental/utilities/meta/meta.detect/is_detected_exact.pass.cpp
@@ -19,7 +19,7 @@
 
 template 
   using callFoo = decltype(std::declval().Foo());
-  
+
 struct yesFoo {
 int Foo() { return 0; }
 };
Index: 
test/std/experimental/utilities/meta/meta.detect/is_detected_convertible.pass.cpp
===
--- 
test/std/experimental/utilities/meta/meta.detect/is_detected_convertible.pass.cpp
+++ 
test/std/experimental/utilities/meta/meta.detect/is_detected_convertible.pass.cpp
@@ -19,7 +19,7 @@
 
 template 
   using callFoo = decltype(std::declval().Foo());
-  
+
 struct yesFoo {
 int Foo() { return 0; }
 };
Index: test/std/experimental/utilities/meta/meta.detect/is_detected.pass.cpp
===
--- test/std/experimental/utilities/meta/meta.detect/is_detected.pass.cpp
+++ test/std/experimental/utilities/meta/meta.detect/is_detected.pass.cpp
@@ -19,7 +19,7 @@
 
 template 
   using copy_assign_t = decltype(std::declval() = std::declval());
-  
+
 struct not_assignable {
 not_assignable & operator=(const not_assignable&) = delete;
 };
Index: test/std/experimental/utilities/meta/meta.detect/detected_t.pass.cpp
===
--- test/std/experimental/utilities/meta/meta.detect/detected_t.pass.cpp
+++ test/std/experimental/utilities/meta/meta.detect/detected_t.pass.cpp
@@ -19,7 +19,7 @@
 
 template 
   using callFoo = decltype(std::declval().Foo());
-  
+
 struct yesFoo {
 int Foo() { return 0; }
 };
Index: test/std/experimental/utilities/meta/meta.detect/detected_or.pass.cpp
===
--- test/std/experimental/utilities/meta/meta.detect/detected_or.pass.cpp
+++ test/std/experimental/utilities/meta/meta.detect/detected_or.pass.cpp
@@ -19,7 +19,7 @@
 
 template 
   using hasFoo = typename T::Foo;
-  
+
 struct yesFoo {
 using Foo = int;
 };


Index: test/std/experimental/utilities/meta/meta.detect/is_detected_exact.pass.cpp
===
--- test/std/experimental/utilities/meta/meta.detect/is_detected_exact.pass.cpp
+++ test/std/experimental/utilities/meta/meta.detect/is_detected_exact.pass.cpp
@@ -19,7 +19,7 @@
 
 template 
   using callFoo = decltype(std::declval().Foo());
-  
+
 struct yesFoo {
 int Foo() { return 0; }
 };
Index: test/std/experimental/utilities/meta/meta.detect/is_detected_convertible.pass.cpp
===
--- test/std/experimental/utilities/meta/meta.detect/is_detected_convertible.pass.cpp
+++ test/std/experimental/utilities/meta/meta.detect/is_detected_convertible.pass.cpp
@@ -19,7 +19,7 @@
 
 template 
   using callFoo = decltype(std::declval().Foo());
-  
+
 struct yesFoo {
 int Foo() { return 0; }
 };
Index: test/std/experimental/utilities/meta/meta.detect/is_detected.pass.cpp
===
--- test/std/experimental/utilities/meta/meta.detect/is_detected.pass.cpp
+++ test/std/experimental/utilities/meta/meta.detect/is_detected.pass.cpp
@@ -19,7 +19,7 @@
 
 template 
   using copy_assign_t = decltype(std::declval() = std::declval());
-  
+
 struct not_assignable {
 not_assignable & operator=(const not_assignable&) = delete;
 };
Index: test/std/experimental/utilities/meta/meta.detect/detected_t.pass.cpp
===
--- test/std/experimental/utilities/meta/meta.detect/detected_t.pass.cpp
+++ test/std/experimental/utilities/meta/meta.detect/detected_t.pass.cpp
@@ -19,7 +19,7 @@
 
 template 
   using callFoo = decltype(std::declval().Foo());
-  
+
 struct yesFoo {
 int Foo() { return 0; }
 };
Index: test/std/experimental/utilities/meta/meta.detect/detected_or.pass.cpp
===
--- test/std/experimental/utilities/meta/meta.detect/detected_or.pass.cpp
+++ test/std/experimental/utilities/meta/meta.detect/detected_or.pass.cpp

[PATCH] D27785: [libcxx] [test] Fix recently introduced warnings emitted by MSVC.

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

[libcxx] [test] Fix recently introduced warnings emitted by MSVC.

test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_const_lvalue_pair.pass.cpp
test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_piecewise.pass.cpp
test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_rvalue.pass.cpp
test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_values.pass.cpp
These tests were using malloc()'s return value without checking for null,
which MSVC's /analyze rightly warns about. Asserting that the pointer is
non-null both expresses the test's intention and silences the warning.

test/support/controlled_allocators.hpp
Fix two unreferenced parameters by removing their names, and one unused 
variable by void-casting it.

test/support/uses_alloc_types.hpp
Fix an unreferenced function parameter pack by removing its name.


https://reviews.llvm.org/D27785

Files:
  
test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_const_lvalue_pair.pass.cpp
  
test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_piecewise.pass.cpp
  
test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_rvalue.pass.cpp
  
test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_values.pass.cpp
  test/support/controlled_allocators.hpp
  test/support/uses_alloc_types.hpp

Index: test/support/uses_alloc_types.hpp
===
--- test/support/uses_alloc_types.hpp
+++ test/support/uses_alloc_types.hpp
@@ -372,7 +372,7 @@
 : Base(()) {}
 // Non-Uses Allocator Ctor
 template  = false>
-NotUsesAllocator(Args&&... args) : Base(()) {}
+NotUsesAllocator(Args&&...) : Base(()) {}
 
 // Uses Allocator Arg Ctor
 template 
Index: test/support/controlled_allocators.hpp
===
--- test/support/controlled_allocators.hpp
+++ test/support/controlled_allocators.hpp
@@ -117,16 +117,16 @@
 }
 
 template 
-void countConstruct(Alloc const& a, Tp *p) {
+void countConstruct(Alloc const&, Tp *p) {
   ++construct_called;
   last_construct_pointer = p;
   last_construct_alloc = ();
   last_construct_type = ();
   last_construct_args = ();
 }
 
 template 
-void countDestroy(Alloc const& a, Tp *p) {
+void countDestroy(Alloc const&, Tp *p) {
   ++destroy_called;
   last_destroy_alloc = ();
   last_destroy_type = ();
@@ -264,6 +264,7 @@
 template 
 void construct(U *p, Args&&... args) {
   auto *c = ::new ((void*)p) U(std::forward(args)...);
+  ((void)c); // Prevent unused warning
   P->countConstruct(*this, p);
 }
 
Index: test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_values.pass.cpp
===
--- test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_values.pass.cpp
+++ test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_values.pass.cpp
@@ -41,6 +41,7 @@
 using SA = std::scoped_allocator_adaptor;
 static_assert(std::uses_allocator::value, "");
 Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
+assert(ptr != nullptr);
 Alloc CA(P);
 SA A(CA);
 A.construct(ptr, x, std::move(y));
@@ -65,6 +66,7 @@
 using SA = std::scoped_allocator_adaptor;
 static_assert(std::uses_allocator::value, "");
 Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
+assert(ptr != nullptr);
 Alloc CA(P);
 SA A(CA);
 A.construct(ptr, std::move(x), y);
@@ -99,6 +101,7 @@
 static_assert(!std::uses_allocator::value, "");
 static_assert(std::uses_allocator::value, "");
 Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
+assert(ptr != nullptr);
 Outer O(POuter);
 Inner I(PInner);
 SA A(O, I);
@@ -127,6 +130,7 @@
 static_assert(!std::uses_allocator::value, "");
 static_assert(std::uses_allocator::value, "");
 Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
+assert(ptr != nullptr);
 Outer O(POuter);
 Inner I(PInner);
 SA A(O, I);
Index: test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_rvalue.pass.cpp
===
--- test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_rvalue.pass.cpp
+++ test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_rvalue.pass.cpp
@@ -42,6 +42,7 @@
 

[PATCH] D26564: Use PIC relocation mode by default for PowerPC64 ELF

2016-12-14 Thread Joerg Sonnenberger via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289744: Use PIC relocation mode by default for PowerPC64 ELF 
(authored by joerg).

Changed prior to commit:
  https://reviews.llvm.org/D26564?vs=77670=81495#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26564

Files:
  cfe/trunk/lib/Driver/ToolChains.cpp
  cfe/trunk/test/Driver/ppc-abi.c


Index: cfe/trunk/test/Driver/ppc-abi.c
===
--- cfe/trunk/test/Driver/ppc-abi.c
+++ cfe/trunk/test/Driver/ppc-abi.c
@@ -24,7 +24,10 @@
 // RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 2>&1 \
 // RUN:   -mabi=altivec | FileCheck -check-prefix=CHECK-ELFv2 %s
 
+// CHECK-ELFv1: "-mrelocation-model" "pic" "-pic-level" "2"
 // CHECK-ELFv1: "-target-abi" "elfv1"
+// CHECK-ELFv1-QPX: "-mrelocation-model" "pic" "-pic-level" "2"
 // CHECK-ELFv1-QPX: "-target-abi" "elfv1-qpx"
+// CHECK-ELFv2: "-mrelocation-model" "pic" "-pic-level" "2"
 // CHECK-ELFv2: "-target-abi" "elfv2"
 
Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -2879,7 +2879,15 @@
 }
 
 bool Generic_GCC::isPICDefault() const {
-  return getArch() == llvm::Triple::x86_64 && getTriple().isOSWindows();
+  switch (getArch()) {
+  case llvm::Triple::x86_64:
+return getTriple().isOSWindows();
+  case llvm::Triple::ppc64:
+  case llvm::Triple::ppc64le:
+return !getTriple().isOSBinFormatMachO() && !getTriple().isMacOSX();
+  default:
+return false;
+  }
 }
 
 bool Generic_GCC::isPIEDefault() const { return false; }


Index: cfe/trunk/test/Driver/ppc-abi.c
===
--- cfe/trunk/test/Driver/ppc-abi.c
+++ cfe/trunk/test/Driver/ppc-abi.c
@@ -24,7 +24,10 @@
 // RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 2>&1 \
 // RUN:   -mabi=altivec | FileCheck -check-prefix=CHECK-ELFv2 %s
 
+// CHECK-ELFv1: "-mrelocation-model" "pic" "-pic-level" "2"
 // CHECK-ELFv1: "-target-abi" "elfv1"
+// CHECK-ELFv1-QPX: "-mrelocation-model" "pic" "-pic-level" "2"
 // CHECK-ELFv1-QPX: "-target-abi" "elfv1-qpx"
+// CHECK-ELFv2: "-mrelocation-model" "pic" "-pic-level" "2"
 // CHECK-ELFv2: "-target-abi" "elfv2"
 
Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -2879,7 +2879,15 @@
 }
 
 bool Generic_GCC::isPICDefault() const {
-  return getArch() == llvm::Triple::x86_64 && getTriple().isOSWindows();
+  switch (getArch()) {
+  case llvm::Triple::x86_64:
+return getTriple().isOSWindows();
+  case llvm::Triple::ppc64:
+  case llvm::Triple::ppc64le:
+return !getTriple().isOSBinFormatMachO() && !getTriple().isMacOSX();
+  default:
+return false;
+  }
 }
 
 bool Generic_GCC::isPIEDefault() const { return false; }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r289744 - Use PIC relocation mode by default for PowerPC64 ELF

2016-12-14 Thread Joerg Sonnenberger via cfe-commits
Author: joerg
Date: Wed Dec 14 18:02:57 2016
New Revision: 289744

URL: http://llvm.org/viewvc/llvm-project?rev=289744=rev
Log:
Use PIC relocation mode by default for PowerPC64 ELF

Most of the PowerPC64 code generation already creates PIC access. This
changes to a full PIC default, similar to what GCC is doing.

Overall, a monolithic clang binary shrinks by 600KB (about 1%). This can
be a slight regression for TLS access and will use the TOC more
aggressively instead of synthesizing immediates. It is expected to be
performance neutral.

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

Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/test/Driver/ppc-abi.c

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=289744=289743=289744=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Wed Dec 14 18:02:57 2016
@@ -2879,7 +2879,15 @@ bool Generic_GCC::IsUnwindTablesDefault(
 }
 
 bool Generic_GCC::isPICDefault() const {
-  return getArch() == llvm::Triple::x86_64 && getTriple().isOSWindows();
+  switch (getArch()) {
+  case llvm::Triple::x86_64:
+return getTriple().isOSWindows();
+  case llvm::Triple::ppc64:
+  case llvm::Triple::ppc64le:
+return !getTriple().isOSBinFormatMachO() && !getTriple().isMacOSX();
+  default:
+return false;
+  }
 }
 
 bool Generic_GCC::isPIEDefault() const { return false; }

Modified: cfe/trunk/test/Driver/ppc-abi.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ppc-abi.c?rev=289744=289743=289744=diff
==
--- cfe/trunk/test/Driver/ppc-abi.c (original)
+++ cfe/trunk/test/Driver/ppc-abi.c Wed Dec 14 18:02:57 2016
@@ -24,7 +24,10 @@
 // RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 2>&1 \
 // RUN:   -mabi=altivec | FileCheck -check-prefix=CHECK-ELFv2 %s
 
+// CHECK-ELFv1: "-mrelocation-model" "pic" "-pic-level" "2"
 // CHECK-ELFv1: "-target-abi" "elfv1"
+// CHECK-ELFv1-QPX: "-mrelocation-model" "pic" "-pic-level" "2"
 // CHECK-ELFv1-QPX: "-target-abi" "elfv1-qpx"
+// CHECK-ELFv2: "-mrelocation-model" "pic" "-pic-level" "2"
 // CHECK-ELFv2: "-target-abi" "elfv2"
 


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


[libcxx] r289741 - Work around bug in initialization of std::array base class with older clangs

2016-12-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Dec 14 17:24:12 2016
New Revision: 289741

URL: http://llvm.org/viewvc/llvm-project?rev=289741=rev
Log:
Work around bug in initialization of std::array base class with older clangs

Modified:

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/derived_from_tuple_like.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/derived_from_tuple_like.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/derived_from_tuple_like.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/derived_from_tuple_like.pass.cpp?rev=289741=289740=289741=diff
==
--- 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/derived_from_tuple_like.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/derived_from_tuple_like.pass.cpp
 Wed Dec 14 17:24:12 2016
@@ -95,7 +95,9 @@ void do_derived_assign_test() {
   }
   reset();
   {
-DerivedFromTup> d = {{{42, 101}}};
+DerivedFromTup> d;
+d[0] = 42;
+d[1] = 101;
 t = ValueCategoryCast(d);
 assert(std::get<0>(t) == 42);
 assert(std::get<1>(t).checkAssign(101, VC));

Modified: 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/derived_from_tuple_like.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/derived_from_tuple_like.pass.cpp?rev=289741=289740=289741=diff
==
--- 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/derived_from_tuple_like.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/derived_from_tuple_like.pass.cpp
 Wed Dec 14 17:24:12 2016
@@ -103,7 +103,9 @@ void do_derived_construct_test() {
 assert(std::get<1>(t).checkConstruct(101, VC));
   }
   {
-DerivedFromTup> d = {{{42, 101}}};
+DerivedFromTup> d;
+d[0] = 42;
+d[1] = 101;
 Tup1 t = ValueCategoryCast(d);
 assert(std::get<0>(t) == 42);
 assert(std::get<1>(t).checkConstruct(101, VC));
@@ -132,7 +134,9 @@ void do_derived_construct_test() {
 using D = DerivedFromTup>;
 static_assert(!std::is_convertible, 
Tup2>::value,
   "");
-D d = {{{42, 101}}};
+D d;
+d[0] = 42;
+d[1] = 101;
 Tup2 t(ValueCategoryCast(d));
 assert(std::get<0>(t) == 42);
 assert(std::get<1>(t).checkConstruct(101, VC));


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


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

2016-12-14 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added inline comments.



Comment at: clang-tidy/readability/DeleteNullPointerCheck.cpp:33
+  Finder->addMatcher(
+  ifStmt(allOf(hasCondition(
+   anyOf(PointerCondition, BinaryPointerCheckCondition)),

I think allOf matcher is redundant here because ifStmt takes variadic number of 
arguments and matches only if all of them matches.


https://reviews.llvm.org/D21298



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


[libcxx] r289735 - Fix PR31378 - std::list::remove should not require a default constructible allocator.

2016-12-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Dec 14 16:48:38 2016
New Revision: 289735

URL: http://llvm.org/viewvc/llvm-project?rev=289735=rev
Log:
Fix PR31378 - std::list::remove should not require a default constructible 
allocator.

In list::remove we collect the nodes we're removing in a seperate
list instance. However we construct this list using the default
constructor which default constructs the allocator. However allocators
are not required to be default constructible. This patch fixes the
construction of the second list.

Modified:
libcxx/trunk/include/list
libcxx/trunk/test/std/containers/sequences/list/list.ops/remove.pass.cpp
libcxx/trunk/test/support/controlled_allocators.hpp
libcxx/trunk/test/support/min_allocator.h

Modified: libcxx/trunk/include/list
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/list?rev=289735=289734=289735=diff
==
--- libcxx/trunk/include/list (original)
+++ libcxx/trunk/include/list Wed Dec 14 16:48:38 2016
@@ -2091,7 +2091,7 @@ template 
 void
 list<_Tp, _Alloc>::remove(const value_type& __x)
 {
-list<_Tp, _Alloc> __deleted_nodes; // collect the nodes we're removing
+list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes 
we're removing
 for (const_iterator __i = begin(), __e = end(); __i != __e;)
 {
 if (*__i == __x)

Modified: 
libcxx/trunk/test/std/containers/sequences/list/list.ops/remove.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/list.ops/remove.pass.cpp?rev=289735=289734=289735=diff
==
--- libcxx/trunk/test/std/containers/sequences/list/list.ops/remove.pass.cpp 
(original)
+++ libcxx/trunk/test/std/containers/sequences/list/list.ops/remove.pass.cpp 
Wed Dec 14 16:48:38 2016
@@ -14,56 +14,70 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "min_allocator.h"
 
 struct S {
-S(int i) : i_(new int(i)) {}
-S(const S ) : i_(new int(*rhs.i_)) {}
-S& operator = (const S ) { *i_ = *rhs.i_; return *this; }
-~S () { delete i_; i_ = NULL; }
-bool operator == (const S ) const { return *i_ == *rhs.i_; }
-int get () const { return *i_; }
-int *i_;
-};
+  S(int i) : i_(new int(i)) {}
+  S(const S ) : i_(new int(*rhs.i_)) {}
+  S =(const S ) {
+*i_ = *rhs.i_;
+return *this;
+  }
+  ~S() {
+delete i_;
+i_ = NULL;
+  }
+  bool operator==(const S ) const { return *i_ == *rhs.i_; }
+  int get() const { return *i_; }
+  int *i_;
+};
 
-
-int main()
-{
-{
+int main() {
+  {
 int a1[] = {1, 2, 3, 4};
 int a2[] = {1, 2, 4};
-std::list c(a1, a1+4);
+std::list c(a1, a1 + 4);
 c.remove(3);
-assert(c == std::list(a2, a2+3));
-}
-{  // LWG issue #526
+assert(c == std::list(a2, a2 + 3));
+  }
+  { // LWG issue #526
 int a1[] = {1, 2, 1, 3, 5, 8, 11};
-int a2[] = {   2,3, 5, 8, 11};
-std::list c(a1, a1+7);
+int a2[] = {2, 3, 5, 8, 11};
+std::list c(a1, a1 + 7);
 c.remove(c.front());
-assert(c == std::list(a2, a2+5));
-}
-{
+assert(c == std::list(a2, a2 + 5));
+  }
+  {
 int a1[] = {1, 2, 1, 3, 5, 8, 11, 1};
-int a2[] = {   2,3, 5, 8, 11   };
+int a2[] = {2, 3, 5, 8, 11};
 std::list c;
-for(int *ip = a1; ip < a1+8; ++ip)
-c.push_back(S(*ip));
+for (int *ip = a1; ip < a1 + 8; ++ip)
+  c.push_back(S(*ip));
 c.remove(c.front());
 std::list::const_iterator it = c.begin();
-for(int *ip = a2; ip < a2+5; ++ip, ++it) {
-assert ( it != c.end());
-assert ( *ip == it->get());
-}
-assert ( it == c.end ());
+for (int *ip = a2; ip < a2 + 5; ++ip, ++it) {
+  assert(it != c.end());
+  assert(*ip == it->get());
 }
+assert(it == c.end());
+  }
+  {
+typedef no_default_allocator Alloc;
+typedef std::list List;
+int a1[] = {1, 2, 3, 4};
+int a2[] = {1, 2, 4};
+List c(a1, a1 + 4, Alloc::create());
+c.remove(3);
+assert(c == List(a2, a2 + 3, Alloc::create()));
+  }
 #if TEST_STD_VER >= 11
-{
+  {
 int a1[] = {1, 2, 3, 4};
 int a2[] = {1, 2, 4};
-std::list c(a1, a1+4);
+std::list c(a1, a1 + 4);
 c.remove(3);
-assert((c == std::list(a2, a2+3)));
-}
+assert((c == std::list(a2, a2 + 3)));
+  }
 #endif
 }

Modified: libcxx/trunk/test/support/controlled_allocators.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/controlled_allocators.hpp?rev=289735=289734=289735=diff
==
--- libcxx/trunk/test/support/controlled_allocators.hpp (original)
+++ libcxx/trunk/test/support/controlled_allocators.hpp Wed Dec 14 16:48:38 2016
@@ -20,6 +20,10 @@
 #include "test_macros.h"
 #include 

[libcxx] r289734 - [libcxx] [test] Fix MSVC x64 truncation warnings with 32-bit allocator size_type/difference_type.

2016-12-14 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Wed Dec 14 16:46:46 2016
New Revision: 289734

URL: http://llvm.org/viewvc/llvm-project?rev=289734=rev
Log:
[libcxx] [test] Fix MSVC x64 truncation warnings with 32-bit allocator 
size_type/difference_type.

test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp
test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp
Iterate with C::size_type because that's what operator[] takes.

test/std/containers/sequences/vector/contiguous.pass.cpp
test/std/strings/basic.string/string.require/contiguous.pass.cpp
Add static_cast because that's what the iterator's 
operator+ takes.

Fixes D2.

Modified:

libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp
libcxx/trunk/test/std/containers/sequences/vector/contiguous.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.require/contiguous.pass.cpp

Modified: 
libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp?rev=289734=289733=289734=diff
==
--- 
libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp
 Wed Dec 14 16:46:46 2016
@@ -50,7 +50,7 @@ int main()
 test q(d, test_allocator(4));
 assert(q.get_allocator() == test_allocator(4));
 assert(q.size() == 5);
-for (std::size_t i = 0; i < d.size(); ++i)
+for (C::size_type i = 0; i < d.size(); ++i)
 {
 assert(q.front() == d[i]);
 q.pop();

Modified: 
libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp?rev=289734=289733=289734=diff
==
--- 
libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp
 Wed Dec 14 16:46:46 2016
@@ -50,7 +50,7 @@ int main()
 test q(d, test_allocator(4));
 assert(q.get_allocator() == test_allocator(4));
 assert(q.size() == 5);
-for (std::size_t i = 0; i < d.size(); ++i)
+for (C::size_type i = 0; i < d.size(); ++i)
 {
 assert(q.top() == d[d.size() - i - 1]);
 q.pop();

Modified: libcxx/trunk/test/std/containers/sequences/vector/contiguous.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/contiguous.pass.cpp?rev=289734=289733=289734=diff
==
--- libcxx/trunk/test/std/containers/sequences/vector/contiguous.pass.cpp 
(original)
+++ libcxx/trunk/test/std/containers/sequences/vector/contiguous.pass.cpp Wed 
Dec 14 16:46:46 2016
@@ -21,7 +21,7 @@ template 
 void test_contiguous ( const C  )
 {
 for ( size_t i = 0; i < c.size(); ++i )
-assert ( *(c.begin() + i) == *(std::addressof(*c.begin()) + i));
+assert ( *(c.begin() + static_cast(i)) == 
*(std::addressof(*c.begin()) + i));
 }
 
 int main()

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.require/contiguous.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.require/contiguous.pass.cpp?rev=289734=289733=289734=diff
==
--- 
libcxx/trunk/test/std/strings/basic.string/string.require/contiguous.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/strings/basic.string/string.require/contiguous.pass.cpp 
Wed Dec 14 16:46:46 2016
@@ -22,7 +22,7 @@ template 
 void test_contiguous ( const C  )
 {
 for ( size_t i = 0; i < c.size(); ++i )
-assert ( *(c.begin() + i) == *(std::addressof(*c.begin()) + i));
+assert ( *(c.begin() + static_cast(i)) == 
*(std::addressof(*c.begin()) + i));
 }
 
 int main()


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


[PATCH] D27740: [analyzer] Include type name in Retain Count Checker diagnostics

2016-12-14 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna updated this revision to Diff 81482.
zaks.anna added a comment.

Address Devin's comment regarding 'id'.


https://reviews.llvm.org/D27740

Files:
  lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  test/Analysis/edges-new.mm
  test/Analysis/inlining/path-notes.m
  test/Analysis/objc-arc.m
  test/Analysis/plist-output-alternate.m
  test/Analysis/retain-release-arc.m
  test/Analysis/retain-release-path-notes-gc.m
  test/Analysis/retain-release-path-notes.m

Index: test/Analysis/retain-release-path-notes.m
===
--- test/Analysis/retain-release-path-notes.m
+++ test/Analysis/retain-release-path-notes.m
@@ -44,12 +44,12 @@
 
 
 void creationViaAlloc () {
-  id leaked = [[NSObject alloc] init]; // expected-note{{Method returns an Objective-C object with a +1 retain count}}
+  id leaked = [[NSObject alloc] init]; // expected-note{{Method returns an instance of NSObject with a +1 retain count}}
   return; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}}
 }
 
 void creationViaCFCreate () {
-  CFTypeRef leaked = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count}}
+  CFTypeRef leaked = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count}}
   return; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}}
 }
 
@@ -68,25 +68,25 @@
 }
 
 void acquisitionViaCFFunction () {
-  CFTypeRef leaked = CFGetSomething(); // expected-note{{Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain count}}
+  CFTypeRef leaked = CFGetSomething(); // expected-note{{Call to function 'CFGetSomething' returns a Core Foundation object of type CFTypeRef with a +0 retain count}}
   CFRetain(leaked); // expected-note{{Reference count incremented. The object now has a +1 retain count}}
   return; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}}
 }
 
 void explicitDealloc () {
-  id object = [[NSObject alloc] init]; // expected-note{{Method returns an Objective-C object with a +1 retain count}}
+  id object = [[NSObject alloc] init]; // expected-note{{Method returns an instance of NSObject with a +1 retain count}}
   [object dealloc]; // expected-note{{Object released by directly sending the '-dealloc' message}}
   [object class]; // expected-warning{{Reference-counted object is used after it is released}} // expected-note{{Reference-counted object is used after it is released}}
 }
 
 void implicitDealloc () {
-  id object = [[NSObject alloc] init]; // expected-note{{Method returns an Objective-C object with a +1 retain count}}
+  id object = [[NSObject alloc] init]; // expected-note{{Method returns an instance of NSObject with a +1 retain count}}
   [object release]; // expected-note{{Object released}}
   [object class]; // expected-warning{{Reference-counted object is used after it is released}} // expected-note{{Reference-counted object is used after it is released}}
 }
 
 void overAutorelease () {
-  id object = [[NSObject alloc] init]; // expected-note{{Method returns an Objective-C object with a +1 retain count}}
+  id object = [[NSObject alloc] init]; // expected-note{{Method returns an instance of NSObject with a +1 retain count}}
   [object autorelease]; // expected-note{{Object autoreleased}}
   [object autorelease]; // expected-note{{Object autoreleased}} 
   return; // expected-warning{{Object autoreleased too many times}} expected-note{{Object was autoreleased 2 times but the object has a +1 retain count}} 
@@ -99,19 +99,19 @@
 }
 
 void makeCollectableIgnored () {
-  CFTypeRef leaked = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count}}
+  CFTypeRef leaked = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count}}
   CFMakeCollectable(leaked); // expected-note{{When GC is not enabled a call to 'CFMakeCollectable' has no effect on its argument}}
   NSMakeCollectable(leaked); // expected-note{{When GC is not enabled a call to 'NSMakeCollectable' has no effect on its argument}}
   return; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}}
 }
 
 CFTypeRef CFCopyRuleViolation () {
-  CFTypeRef object = CFGetSomething(); // expected-note{{Call to function 'CFGetSomething' returns a Core 

[PATCH] D27166: [clang-tidy] Enhance modernize-use-auto to templated function casts

2016-12-14 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek accepted this revision.
Prazek added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for all the fixes.
Can you leave FIXIT comment somewhere in the code near the FixitHint about the 
function pointers?


https://reviews.llvm.org/D27166



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


[PATCH] D25475: [analyzer] Add a new SVal to support pointer-to-member operations.

2016-12-14 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, other than some super tiny nits! Thanks for iterating on this 
-- it is awesome that the analyzer will be able to model this now!!




Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h:463
 
+class PointerToMember : public NonLoc {
+  friend class ento::SValBuilder;

I think this deserves a comment about why it is a NonLoc and why it needs to 
keep the PointerToMemberData with the list of CXXBaseSpecifiers.



Comment at: lib/StaticAnalyzer/Core/ExprEngineC.cpp:269
+StmtNodeBuilder , ExplodedNode* Pred) {
+  // Recover some path-sensitivty by conjuring a new value.
+  QualType resultType = CastE->getType();

While we're here we might as well correct the misspelling --> "path 
sensitivity".



Comment at: test/Analysis/pointer-to-member.cpp:74
 
-  // FIXME: Should emit a null dereference.
-  return obj.*member; // no-warning
+  return obj.*member; // expected-warning{{}}
+}

Can you include the warning text in the expected-warning directive? This will 
ensure we keep emitting the correct warning in the future.


https://reviews.llvm.org/D25475



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


[PATCH] D26267: [Modules] Include builtins with #include instead of #import for ObjC

2016-12-14 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno updated this revision to Diff 81478.
bruno added a comment.

Here is the Decl dump in the end of `ReadDeclRecord` for each Decl before it 
fails:

- ParmVarDecl 0x7ffe23053b20 

 col:12 in libc.math hidden 'int' -- FunctionDecl 0x7ffe23053a48 
 col:5 in libc.math hidden abs 'int (int)' `-ParmVarDecl 0x7ffe23053b20 
 col:12 in libc.math hidden 'int' -- TypedefDecl 0x7ffe23053f90 
 col:26 in libc.stddef hidden ptrdiff_t 'long' `-BuiltinType 
0x7ffe2300f9f0 'long' -- TypedefDecl 0x7ffe23054018 
 col:15 in libc.POSIX.sys.types hidden ptrdiff_t 'int *' `-PointerType 
0x7ffe23054070 'int *' imported `-BuiltinType 0x7ffe2300f9d0 'int' While 
building module 'libc++' imported from 
/Users/bruno/Dev/srcs/llvm/tools/clang/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stdio.h:4:
 In file included from :1: In file included from 
/Users/bruno/Dev/srcs/llvm/tools/clang/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/math.h:7:
 In file included from 
/Users/bruno/Dev/srcs/llvm/tools/clang/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/type_traits:4:
 
/Users/bruno/Dev/srcs/llvm/tools/clang/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/cstddef:7:9:
 error: unknown type name 'ptrdiff_t' typedef ptrdiff_t my_ptrdiff_t; ^

So, both `libc.stddef` and `libc++.stddef`, answer for the builtin 
`/Users/bruno/Dev/srcs/llvm/build/bin/../lib/clang/4.0.0/include/stddef.h`. 
`libc++.stddef` is being currently built, that's why the definition isn't there 
yet. Looks like the right thing is to indeed re-enter 
`/Users/bruno/Dev/srcs/llvm/build/bin/../lib/clang/4.0.0/include/stddef.h`, so 
it can be put in `libc++.stddef`.

I've updated the patch to do what you suggested in the first place: track 
modules per header. Can you comment on the general approach? One consideration 
though; it's expensive to have the additional SmallVector per each 
HeaderFileInfo, since most headers (except builtins and textuals) aren't 
actually expected to have more than one associated Module. Maybe a map from 
HFIs to associated modules, but I'm not sure where to store it, suggestions? 
The Decl's loaded from the AST now make more sense (output resuming from the 
previously failing point):

  TypedefDecl 0x7f81ed0f0840 
 col:23 in libc.stddef hidden size_t 'unsigned long'
  `-BuiltinType 0x7f81ed0ab890 'unsigned long'
  --
  TypedefDecl 0x7f81ed0f0938 
 col:23 in libc.stddef hidden rsize_t 'unsigned long'
  `-BuiltinType 0x7f81ed0ab890 'unsigned long'
  --
  TypedefDecl 0x7f81ed076778 
 col:26 in libc.stddef hidden ptrdiff_t 'long'
  `-BuiltinType 0x7f81ed03a9f0 'long'
  --
  TypedefDecl 0x7f81ed076800 
 col:15 in libc.POSIX.sys.types hidden ptrdiff_t 'int *'
  `-PointerType 0x7f81ed076850 'int *' imported
`-BuiltinType 0x7f81ed03a9d0 'int'
  --
  TypedefDecl 0x7f81ed0768b0 prev 0x7f81ed076778 
 col:26 in libc++.stddef hidden referenced ptrdiff_t 'long'
  `-BuiltinType 0x7f81ed03a9f0 'long'
  --
  TypedefDecl 0x7f81ed0769d0 
 col:19 in libc++.cstddef hidden my_ptrdiff_t 'ptrdiff_t':'long'
  `-TypedefType 0x7f81ed076920 'ptrdiff_t' sugar imported
|-Typedef 0x7f81ed0768b0 'ptrdiff_t'
`-BuiltinType 0x7f81ed03a9f0 'long'


https://reviews.llvm.org/D26267

Files:
  include/clang/Lex/HeaderSearch.h
  include/clang/Lex/Preprocessor.h
  lib/Lex/HeaderSearch.cpp
  lib/Serialization/ASTReader.cpp
  test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/cstddef
  test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/math.h
  test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/module.modulemap
  test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stddef.h
  test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/type_traits
  test/Modules/Inputs/libc-libcxx/sysroot/usr/include/module.modulemap
  test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stddef.h
  test/Modules/Inputs/libc-libcxx/sysroot/usr/include/sys/_types/_ptrdiff_t.h
  test/Modules/Inputs/libc-libcxx/sysroot/usr/include/sys/_types/_types.h
  test/Modules/builtin-import.mm

Index: test/Modules/builtin-import.mm
===
--- /dev/null
+++ test/Modules/builtin-import.mm
@@ -0,0 +1,12 @@
+// REQUIRES: system-darwin
+
+// RUN: rm -rf %t
+// RUN: %clang -cc1 -fsyntax-only -nostdinc++ -isysroot %S/Inputs/libc-libcxx/sysroot -isystem %S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ -fmodules-local-submodule-visibility %s
+
+#include 
+#include 
+#include 
+
+typedef ptrdiff_t try1_ptrdiff_t;
+typedef my_ptrdiff_t try2_ptrdiff_t;
+
Index: test/Modules/Inputs/libc-libcxx/sysroot/usr/include/sys/_types/_types.h
===
--- /dev/null
+++ test/Modules/Inputs/libc-libcxx/sysroot/usr/include/sys/_types/_types.h
@@ -0,0 +1,6 @@
+#ifndef _SYS_TYPES_UMBRELLA
+#define _SYS_TYPES_UMBRELLA
+
+#include "_ptrdiff_t.h"
+
+#endif
Index: 

[PATCH] D27606: [libcxx] Fix tuple construction/assignment from types derived from tuple/pair/array.

2016-12-14 Thread Eric Fiselier via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289727: [libcxx] Fix tuple construction/assignment from 
types derived from… (authored by EricWF).

Changed prior to commit:
  https://reviews.llvm.org/D27606?vs=81456=81476#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27606

Files:
  libcxx/trunk/include/__tuple
  libcxx/trunk/include/tuple
  libcxx/trunk/include/type_traits
  
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/derived_from_tuple_like.pass.cpp
  
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/derived_from_tuple_like.pass.cpp
  libcxx/trunk/test/support/propagate_value_category.hpp

Index: libcxx/trunk/include/tuple
===
--- libcxx/trunk/include/tuple
+++ libcxx/trunk/include/tuple
@@ -555,13 +555,19 @@
 {
 template 
 static constexpr bool __enable_implicit() {
-return __tuple_convertible<_Tuple, tuple>::value;
+using _Deduced = __deduce_tuple_like<_Tuple>;
+using _QualType = typename _Deduced::_QualType;
+static_assert(__tuple_like::value, "");
+return __tuple_convertible<_QualType, tuple>::value;
 }
 
 template 
 static constexpr bool __enable_explicit() {
-return __tuple_constructible<_Tuple, tuple>::value
-   && !__tuple_convertible<_Tuple, tuple>::value;
+using _Deduced = __deduce_tuple_like<_Tuple>;
+using _QualType = typename _Deduced::_QualType;
+static_assert(__tuple_like::value, "");
+return __tuple_constructible<_QualType, tuple>::value
+   && !__tuple_convertible<_QualType, tuple>::value;
 }
 };
 
@@ -814,66 +820,74 @@
 _VSTD::forward<_Up>(__u)...) {}
 
 template ,
+  class _TupBase = typename _Deduced::_QualType,
   typename enable_if
   <
  _CheckTupleLikeConstructor<
- __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
- && !_PackExpandsToThisTuple<_Tuple>::value
- >::template __enable_implicit<_Tuple>(),
+_Deduced::_Size == sizeof...(_Tp)
+ && !_PackExpandsToThisTuple<_TupBase>::value
+ >::template __enable_implicit<_TupBase>(),
  bool
   >::type = false
  >
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible::value))
-: base_(_VSTD::forward<_Tuple>(__t)) {}
+tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible::value))
+: base_(_VSTD::forward<_TupBase>(__t)) {}
 
 template ,
+  class _TupBase = typename _Deduced::_QualType,
   typename enable_if
   <
  _CheckTupleLikeConstructor<
- __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
- && !_PackExpandsToThisTuple<_Tuple>::value
- >::template __enable_explicit<_Tuple>(),
+  _Deduced::_Size == sizeof...(_Tp)
+ && !_PackExpandsToThisTuple<_TupBase>::value
+ >::template __enable_explicit<_TupBase>(),
  bool
   >::type = false
  >
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 explicit
-tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible::value))
-: base_(_VSTD::forward<_Tuple>(__t)) {}
+tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible::value))
+: base_(_VSTD::forward<_TupBase>(__t)) {}
 
 template ,
+  class _TupBase = typename _Deduced::_QualType,
   typename enable_if
   <
  _CheckTupleLikeConstructor<
- __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
- >::template __enable_implicit<_Tuple>(),
+ _Deduced::_Size == sizeof...(_Tp)
+ >::template __enable_implicit<_TupBase>(),
  bool
   >::type = false
  >
 _LIBCPP_INLINE_VISIBILITY
 tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
-: base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
+: base_(allocator_arg_t(), __a, _VSTD::forward<_TupBase>(__t)) {}
 
 template ,
+  class _TupBase = typename _Deduced::_QualType,
   typename enable_if
   <
  

[libcxx] r289727 - [libcxx] Fix tuple construction/assignment from types derived from tuple/pair/array.

2016-12-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Dec 14 16:22:38 2016
New Revision: 289727

URL: http://llvm.org/viewvc/llvm-project?rev=289727=rev
Log:
[libcxx] Fix tuple construction/assignment from types derived from 
tuple/pair/array.

Summary:
The standard requires tuple have the following constructors:
```
tuple(tuple const&);
tuple(tuple &&);
tuple(pair const&);
tuple(pair &&);
tuple(array const&);
tuple(array &&);
```
However libc++ implements these as a single constructor with the signature:
```
template ::value>>
tuple(TupleLike&&);
```

This causes the constructor to reject types derived from tuple-like types; 
Unlike if we had all of the concrete overloads, because they cause the 
derived->base conversion in the signature.

This patch fixes this issue by detecting derived types and the tuple-like base 
they are derived from. It does this by creating an overloaded function with 
signatures for each of tuple/pair/array and checking if the possibly derived 
type can convert to any of them.

This patch fixes [PR17550]( https://llvm.org/bugs/show_bug.cgi?id=17550)

This patch 

Reviewers: mclow.lists, K-ballo, mpark, EricWF

Subscribers: cfe-commits

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

Added:

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/derived_from_tuple_like.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/derived_from_tuple_like.pass.cpp
libcxx/trunk/test/support/propagate_value_category.hpp
Modified:
libcxx/trunk/include/__tuple
libcxx/trunk/include/tuple
libcxx/trunk/include/type_traits

Modified: libcxx/trunk/include/__tuple
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__tuple?rev=289727=289726=289727=diff
==
--- libcxx/trunk/include/__tuple (original)
+++ libcxx/trunk/include/__tuple Wed Dec 14 16:22:38 2016
@@ -453,19 +453,57 @@ using tuple_element_t = typename tuple_e
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 
 #ifndef _LIBCPP_CXX03_LANG
-template 
-struct __tuple_like_with_size_imp : false_type {};
 
-template 
-struct __tuple_like_with_size_imp
-: integral_constant {};
-
-template ::type>
-using __tuple_like_with_size = __tuple_like_with_size_imp<
-   __tuple_like<_RawTuple>::value,
-   tuple_size<_RawTuple>, _ExpectedSize
-  >;
+template 
+struct __lookup_result {
+  using type = _Tp;
+  static constexpr bool _Success = _Good;
+  static constexpr size_t _Size = _TSize;
+};
+using __lookup_failure = __lookup_result;
+
+template 
+auto __deduce_tuple_type_ovl(tuple<_Args...>&)
+-> __lookup_result, sizeof...(_Args)>;
+
+template 
+auto __deduce_tuple_type_ovl(pair<_T1, _T2>&)
+-> __lookup_result, 2>;
+
+template 
+auto __deduce_tuple_type_ovl(array<_Tp, _Size>&)
+  -> __lookup_result, _Size>;
+
+template 
+auto __deduce_tuple_type_imp(int)
+  -> decltype(__deduce_tuple_type_ovl(_VSTD::declval<__uncvref_t<_Tp>&>()));
+template  __lookup_failure __deduce_tuple_type_imp(...);
+
+// __deduce_tuple_like - Given a type determine if it is, or is derived from,
+//   a tuple-like type. This trait is used to support constructing and 
assigning
+//   to std::tuple from user-types derived from a tuple-like type.
+template (0)),
+bool _Good = _Result::_Success>
+struct __deduce_tuple_like {
+  static_assert(_Good, "incorrect specialization choosen");
+  static constexpr bool _Success = true;
+  static constexpr size_t _Size = _Result::_Size;
+  using _RawType = typename _Result::type;
+  using _QualType =
+typename __propagate_value_category<_TupleLike>::template 
__apply<_RawType>;
+};
+
+template 
+struct __deduce_tuple_like<_TupleLike, _Result, /*_Good=*/false> {
+  static constexpr bool _Success = false;
+  static constexpr size_t _Size = (size_t)-1;
+};
+
+template >
+using __tuple_like_with_size = integral_constant;
 
 struct _LIBCPP_TYPE_VIS __check_tuple_constructor_fail {
 template 

Modified: libcxx/trunk/include/tuple
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/tuple?rev=289727=289726=289727=diff
==
--- libcxx/trunk/include/tuple (original)
+++ libcxx/trunk/include/tuple Wed Dec 14 16:22:38 2016
@@ -555,13 +555,19 @@ class _LIBCPP_TYPE_VIS_ONLY tuple
 {
 template 
 static constexpr bool __enable_implicit() {
-return __tuple_convertible<_Tuple, tuple>::value;
+using _Deduced = __deduce_tuple_like<_Tuple>;
+using _QualType = typename _Deduced::_QualType;
+static_assert(__tuple_like::value, 
"");
+return 

[PATCH] D27606: [libcxx] Fix tuple construction/assignment from types derived from tuple/pair/array.

2016-12-14 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a reviewer: EricWF.
EricWF added a comment.

Accepting revision. @mpark mentioned that this was good to go offline.  Ignore 
the inline comment about `base.operator=`, phab won't let me delete it.




Comment at: include/tuple:884
 tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
 : base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
 

This should be fixed



Comment at: include/tuple:915
 tuple&
-operator=(_Tuple&& __t) _NOEXCEPT_((is_nothrow_assignable::value))
+operator=(_Tuple&& __t) _NOEXCEPT_((is_nothrow_assignable::value))
 {

mpark wrote:
> A general comment about using the `base` in noexcept condition. I remember 
> for `variant` we wanted to express it directly rather than delegating it to 
> the "base". Does that also apply here?
Yes. probably. but this is existing code. I'll fix that in another patch. Plus 
it's really hard to state this noexcept directly since you need to expand the 
input argument into its tuple-types.



Comment at: include/tuple:917
 {
-base_.operator=(_VSTD::forward<_Tuple>(__t));
+base_.operator=(_VSTD::forward<_QualTupleBase>(__t));
 return *this;

mpark wrote:
> Here and elsewhere, why do we bother with `base_.operator=(...);` as opposed 
> to just `base_ = ...;`?
I think the reason for not using `base_ = ...` is because that can select 
different conversion sequences IIRC.


https://reviews.llvm.org/D27606



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


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

2016-12-14 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D26167#621942, @JonasToth wrote:

> what do you think about configuration of the allocating functions? e.g. for 
> aligned memory you must use OS-specific allocation functions.
>  should the check catch custom allocation functions as well?


Sounds like a good idea to me.


Repository:
  rL LLVM

https://reviews.llvm.org/D26167



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


[PATCH] D21698: [OpenCL] Allow disabling types and declarations associated with extensions

2016-12-14 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 81471.
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

Added serialisation of types and declarations associated with extensions.
Brought the patch up to date.


https://reviews.llvm.org/D21698

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/OpenCLImageTypes.def
  include/clang/Basic/OpenCLOptions.h
  include/clang/Basic/TargetInfo.h
  include/clang/Sema/Overload.h
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  include/clang/Serialization/ASTReader.h
  include/clang/Serialization/ASTWriter.h
  lib/Basic/Targets.cpp
  lib/Frontend/InitPreprocessor.cpp
  lib/Headers/opencl-c.h
  lib/Parse/ParsePragma.cpp
  lib/Parse/Parser.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  test/CodeGenOpenCL/extension-begin.cl
  test/Parser/opencl-atomics-cl20.cl
  test/Parser/opencl-pragma.cl
  test/SemaOpenCL/extension-begin.cl
  test/SemaOpenCL/extensions.cl

Index: test/SemaOpenCL/extensions.cl
===
--- test/SemaOpenCL/extensions.cl
+++ test/SemaOpenCL/extensions.cl
@@ -22,8 +22,6 @@
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -cl-ext=+cl_khr_fp64 -cl-ext=+cl_khr_fp16 -cl-ext=-cl_khr_fp64 -DNOFP64
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -cl-ext=+cl_khr_fp64,-cl_khr_fp64,+cl_khr_fp16 -DNOFP64
 
-
-
 #ifdef FP64
 // expected-no-diagnostics
 #endif
Index: test/SemaOpenCL/extension-begin.cl
===
--- /dev/null
+++ test/SemaOpenCL/extension-begin.cl
@@ -0,0 +1,54 @@
+// Test this without pch.
+// RUN: %clang_cc1 %s -DHEADER -DHEADER_USER -triple spir-unknown-unknown -verify -pedantic -fsyntax-only
+
+// Test with pch.
+// RUN: %clang_cc1 %s -DHEADER -triple spir-unknown-unknown -emit-pch -DHEADER_ONLY -o %t -verify -pedantic
+// RUN: %clang_cc1 %s -DHEADER_USER -triple spir-unknown-unknown -include-pch %t -fsyntax-only -verify -pedantic
+
+#ifdef HEADER
+
+#pragma OPENCL EXTENSION all : begin // expected-warning {{expected 'disable' - ignoring}}
+#pragma OPENCL EXTENSION all : end // expected-warning {{expected 'disable' - ignoring}}
+
+#pragma OPENCL EXTENSION my_ext : begin 
+
+struct A {
+  int a;
+};
+
+typedef struct A TypedefOfA;
+typedef const TypedefOfA* PointerOfA;
+
+void f(void);
+
+__attribute__((overloadable)) void g(long x);
+
+#pragma OPENCL EXTENSION my_ext : end
+#pragma OPENCL EXTENSION my_ext : end // expected-warning {{OpenCL extension end directive mismatches begin directive - ignoring}}
+
+__attribute__((overloadable)) void g(void);
+
+#endif // HEADER
+
+#ifdef HEADER_USER
+
+#pragma OPENCL EXTENSION my_ext : enable
+void test_f1(void) {
+  struct A test_A1;
+  f();
+  g(0);
+}
+
+#pragma OPENCL EXTENSION my_ext : disable 
+void test_f2(void) {
+  struct A test_A2; // expected-error {{use of type 'struct A' requires my_ext extension to be enabled}}
+  const struct A test_A_local; // expected-error {{use of type 'struct A' requires my_ext extension to be enabled}}
+  TypedefOfA test_typedef_A; // expected-error {{use of type 'TypedefOfA' (aka 'struct A') requires my_ext extension to be enabled}}
+  PointerOfA test_A_pointer; // expected-error {{use of type 'PointerOfA' (aka 'const struct A *') requires my_ext extension to be enabled}}
+  f(); // expected-error {{use of declaration requires my_ext extension to be enabled}}
+  g(0); // expected-error {{no matching function for call to 'g'}}
+// expected-note@-26 {{candidate disabled due to OpenCL extension}}
+// expected-note@-22 {{candidate function not viable: requires 0 arguments, but 1 was provided}}
+}
+
+#endif // HEADER_USER
Index: test/Parser/opencl-pragma.cl
===
--- test/Parser/opencl-pragma.cl
+++ test/Parser/opencl-pragma.cl
@@ -5,9 +5,9 @@
 #pragma OPENCL EXTENSION cl_no_such_extension : disable /* expected-warning {{unknown OpenCL extension 'cl_no_such_extension' - ignoring}} */
 
 #pragma OPENCL EXTENSION all : disable
-#pragma OPENCL EXTENSION all : enable /* expected-warning {{unknown OpenCL extension 'all' - ignoring}} */
+#pragma OPENCL EXTENSION all : enable /* expected-warning {{expected 'disable' - ignoring}} */
 
-#pragma OPENCL EXTENSION cl_khr_fp64 : on /* expected-warning {{expected 'enable' or 'disable' - ignoring}} */
+#pragma OPENCL EXTENSION cl_khr_fp64 : on /* expected-warning {{expected 'enable', 'disable', 'begin' or 'end' - ignoring}} */
 
 #pragma OPENCL FP_CONTRACT ON
 #pragma OPENCL FP_CONTRACT OFF
Index: test/Parser/opencl-atomics-cl20.cl

[PATCH] D21698: [OpenCL] Allow disabling types and declarations associated with extensions

2016-12-14 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 6 inline comments as done.
yaxunl added inline comments.



Comment at: lib/Serialization/ASTReader.cpp:3167
 case OPENCL_EXTENSIONS:
-  // Later tables overwrite earlier ones.
-  OpenCLExtensions.swap(Record);

Anastasia wrote:
> Btw, OpenCLTypeExtMap and OpenCLTypeDeclMap don't have to be serialized?
Yes. I will add it.



Comment at: test/Parser/opencl-atomics-cl20.cl:51
 // expected-error@-28 {{use of type 'atomic_double' (aka '_Atomic(double)') 
requires cl_khr_int64_extended_atomics extension to be enabled}}
-// expected-error-re@-27 {{use of type 'atomic_intptr_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be enabled}}
-// expected-error-re@-28 {{use of type 'atomic_intptr_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension to be 
enabled}}
-// expected-error-re@-28 {{use of type 'atomic_uintptr_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be enabled}}
-// expected-error-re@-29 {{use of type 'atomic_uintptr_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension to be 
enabled}}
-// expected-error-re@-29 {{use of type 'atomic_size_t' (aka '_Atomic({{.+}})') 
requires cl_khr_int64_base_atomics extension to be enabled}}
-// expected-error-re@-30 {{use of type 'atomic_size_t' (aka '_Atomic({{.+}})') 
requires cl_khr_int64_extended_atomics extension to be enabled}}
-// expected-error-re@-30 {{use of type 'atomic_ptrdiff_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be enabled}}
-// expected-error-re@-31 {{use of type 'atomic_ptrdiff_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension to be 
enabled}}
+#if __LP64__
+// expected-error-re@-28 {{use of type 'atomic_intptr_t' (aka 
'_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be enabled}}

Anastasia wrote:
> yaxunl wrote:
> > Anastasia wrote:
> > > Why this change?
> > atomic_intptr_t etc. requires cl_khr_int64_extended_atomics only on 64 bit 
> > platforms.
> > 
> > This is a bug which was fixed by this patch.
> The spec says:
> "If the device address space is 64-bits, the data types atomic_intptr_t, 
> atomic_uintptr_t,
> atomic_size_t and atomic_ptrdiff_t are supported if the 
> cl_khr_int64_base_atomics and
> cl_khr_int64_extended_atomics extensions are supported."
> 
> This seems to be the same as long and double?
Yes. Use of long and double were correctly diagnosed if the corresponding 
extension was disabled but size_t/intptr_t/uintptr_t/ptrdiff_t was not. This 
patch fixes that.


https://reviews.llvm.org/D21698



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


[PATCH] D27777: [libcxx] [test] Fix MSVC x64 truncation warnings with 32-bit allocator size_type/difference_type.

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

[libcxx] [test] Fix MSVC x64 truncation warnings with 32-bit allocator 
size_type/difference_type.

test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp
test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp
Iterate with C::size_type because that's what operator[] takes.

test/std/containers/sequences/vector/contiguous.pass.cpp
test/std/strings/basic.string/string.require/contiguous.pass.cpp
Add static_cast because that's what the iterator's 
operator+ takes.


https://reviews.llvm.org/D2

Files:
  
test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp
  
test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp
  test/std/containers/sequences/vector/contiguous.pass.cpp
  test/std/strings/basic.string/string.require/contiguous.pass.cpp


Index: test/std/strings/basic.string/string.require/contiguous.pass.cpp
===
--- test/std/strings/basic.string/string.require/contiguous.pass.cpp
+++ test/std/strings/basic.string/string.require/contiguous.pass.cpp
@@ -22,7 +22,7 @@
 void test_contiguous ( const C  )
 {
 for ( size_t i = 0; i < c.size(); ++i )
-assert ( *(c.begin() + i) == *(std::addressof(*c.begin()) + i));
+assert ( *(c.begin() + static_cast(i)) == 
*(std::addressof(*c.begin()) + i));
 }
 
 int main()
Index: test/std/containers/sequences/vector/contiguous.pass.cpp
===
--- test/std/containers/sequences/vector/contiguous.pass.cpp
+++ test/std/containers/sequences/vector/contiguous.pass.cpp
@@ -21,7 +21,7 @@
 void test_contiguous ( const C  )
 {
 for ( size_t i = 0; i < c.size(); ++i )
-assert ( *(c.begin() + i) == *(std::addressof(*c.begin()) + i));
+assert ( *(c.begin() + static_cast(i)) == 
*(std::addressof(*c.begin()) + i));
 }
 
 int main()
Index: 
test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp
===
--- 
test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp
+++ 
test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp
@@ -50,7 +50,7 @@
 test q(d, test_allocator(4));
 assert(q.get_allocator() == test_allocator(4));
 assert(q.size() == 5);
-for (std::size_t i = 0; i < d.size(); ++i)
+for (C::size_type i = 0; i < d.size(); ++i)
 {
 assert(q.top() == d[d.size() - i - 1]);
 q.pop();
Index: 
test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp
===
--- 
test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp
+++ 
test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp
@@ -50,7 +50,7 @@
 test q(d, test_allocator(4));
 assert(q.get_allocator() == test_allocator(4));
 assert(q.size() == 5);
-for (std::size_t i = 0; i < d.size(); ++i)
+for (C::size_type i = 0; i < d.size(); ++i)
 {
 assert(q.front() == d[i]);
 q.pop();


Index: test/std/strings/basic.string/string.require/contiguous.pass.cpp
===
--- test/std/strings/basic.string/string.require/contiguous.pass.cpp
+++ test/std/strings/basic.string/string.require/contiguous.pass.cpp
@@ -22,7 +22,7 @@
 void test_contiguous ( const C  )
 {
 for ( size_t i = 0; i < c.size(); ++i )
-assert ( *(c.begin() + i) == *(std::addressof(*c.begin()) + i));
+assert ( *(c.begin() + static_cast(i)) == *(std::addressof(*c.begin()) + i));
 }
 
 int main()
Index: test/std/containers/sequences/vector/contiguous.pass.cpp
===
--- test/std/containers/sequences/vector/contiguous.pass.cpp
+++ test/std/containers/sequences/vector/contiguous.pass.cpp
@@ -21,7 +21,7 @@
 void test_contiguous ( const C  )
 {
 for ( size_t i = 0; i < c.size(); ++i )
-assert ( *(c.begin() + i) == *(std::addressof(*c.begin()) + i));
+assert ( *(c.begin() + static_cast(i)) == *(std::addressof(*c.begin()) + i));
 }
 
 int main()
Index: test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp
===
--- test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp
+++ test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp
@@ -50,7 +50,7 @@
 test q(d, test_allocator(4));
 assert(q.get_allocator() == test_allocator(4));
 

[PATCH] D27270: [libcxx] [test] Fix MSVC x64 warning C4267 "conversion from 'size_t' to 'int' [or 'unsigned int'], possible loss of data", part 4/4.

2016-12-14 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT abandoned this revision.
STL_MSFT added a comment.

Abandoning; I have changes in our STL to fix the bulk of these warnings, plus a 
small number of test changes that I'm about to send out.


https://reviews.llvm.org/D27270



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


[PATCH] D27740: [analyzer] Include type name in Retain Count Checker diagnostics

2016-12-14 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp:2000
+if (Sym->getType().isNull()) {
+  os << " returns an Objective-C object with a ";
+} else {

I think we should use this diagnostic text when type is not an 
ObjCObjectPointerType also. Where this matters, I think, is for id.

It seems weird to say "returns an instance of id"; I think it would be better 
in that case to say "returns an Objective-C object".


https://reviews.llvm.org/D27740



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


[PATCH] D27166: [clang-tidy] Enhance modernize-use-auto to templated function casts

2016-12-14 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons updated this revision to Diff 81465.
malcolm.parsons added a comment.

Add tests for implicit vars and pointers to pointers to auto.


https://reviews.llvm.org/D27166

Files:
  clang-tidy/modernize/UseAutoCheck.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/modernize-use-auto.rst
  test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp
  test/clang-tidy/modernize-use-auto-cast.cpp

Index: test/clang-tidy/modernize-use-auto-cast.cpp
===
--- test/clang-tidy/modernize-use-auto-cast.cpp
+++ test/clang-tidy/modernize-use-auto-cast.cpp
@@ -138,3 +138,95 @@
   B b;
   A a = A(b);
 }
+
+class StringRef
+{
+public:
+  StringRef(const char *);
+  const char *begin() const;
+  const char *end() const;
+};
+
+template 
+T template_value_cast(const U );
+
+template 
+T *template_pointer_cast(U *u);
+
+template 
+T _reference_cast(U );
+
+template 
+const T *template_const_pointer_cast(const U *u);
+
+template 
+const T _const_reference_cast(const U );
+
+template 
+T template_value_get(StringRef s);
+
+struct S {
+  template 
+  const T *template_member_get();
+};
+
+template 
+T max(T t1, T t2);
+
+void f_template_cast()
+{
+  double d = 0;
+  int i1 = template_value_cast(d);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
+  // CHECK-FIXES: auto i1 = template_value_cast(d);
+
+  A *a = new B();
+  B *b1 = template_value_cast(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *b1 = template_value_cast(a);
+  B  = template_value_cast(*a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
+  // CHECK-FIXES: auto  = template_value_cast(*a);
+  B *b3 = template_pointer_cast(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *b3 = template_pointer_cast(a);
+  B  = template_reference_cast(*a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
+  // CHECK-FIXES: auto  = template_reference_cast(*a);
+  const B *b5 = template_const_pointer_cast(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a template cast to avoid duplicating the type name
+  // CHECK-FIXES: const auto *b5 = template_const_pointer_cast(a);
+  const B  = template_const_reference_cast(*a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a template cast to avoid duplicating the type name
+  // CHECK-FIXES: const auto  = template_const_reference_cast(*a);
+  B *b7 = template_value_get("foo");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *b7 = template_value_get("foo");
+  B *b8 = template_value_get("foo"), *b9 = template_value_get("bar");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *b8 = template_value_get("foo"), *b9 = template_value_get("bar");
+
+  S s;
+  const B *b10 = s.template_member_get();
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a template cast to avoid duplicating the type name
+  // CHECK-FIXES: const auto *b10 = s.template_member_get();
+
+  // Don't warn when auto is already being used.
+  auto i2 = template_value_cast(d);
+  auto *i3 = template_value_cast(d);
+  auto **i4 = template_value_cast(d);
+  auto  = template_reference_cast(d);
+
+  // Don't warn for implicit template arguments.
+  int i6 = max(i1, i2);
+
+  // Don't warn for mismatched var and initializer types.
+  A *a1 = template_value_cast(a);
+
+  // Don't warn for mismatched var types.
+  B *b11 = template_value_get("foo"), b12 = template_value_get("bar");
+
+  // Don't warn for implicit variables.
+  for (auto  : template_reference_cast(*a)) {
+  }
+}
Index: test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp
===
--- test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp
+++ test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp
@@ -44,7 +44,7 @@
 
   const B *b3 = static_cast(a);
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a cast to avoid duplicating the type name
-  // CHECK-FIXES: auto b3 = static_cast(a);
+  // CHECK-FIXES: const auto b3 = static_cast(a);
 
   B  = static_cast(*a);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
@@ -58,6 +58,9 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid 

[PATCH] D27773: [analyzer] Add checker modeling gtest APIs.

2016-12-14 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin created this revision.
dcoughlin added reviewers: zaks.anna, NoQ.
dcoughlin added subscribers: cfe-commits, alexfh, sbenza.
Herald added a subscriber: mgorny.

gtest is a widely-used unit-testing API provides macros for unit test
assertions:

  ASSERT_TRUE(p != nullptr);

that expand into an if statement that constructs an object representing
the result of the assertion and returns when the assertion is false:

  if (AssertionResult gtest_ar_ = AssertionResult(p == nullptr))
  ;
  else
return ...;

Unfortunately, the analyzer does not model the effect of the constructor
precisely because (1) the copy constructor implementation is missing from the
the header (so it can't be inlined) and (2) the boolean-argument constructor
is constructed into a temporary (so the analyzer decides not to inline it since
it doesn't reliably call temporary destructors right now).

This results in false positives because the analyzer does not realize that the
the assertion must hold along the non-return path.

This patch addresses the false positives by explicitly modeling the effects
of the two un-inlined constructors on the AssertionResult state.

I've added a new package, "apiModeling", for these kinds of checkers that
model APIs but don't emit any diagnostics. I envision all the checkers in
this package always being on by default.

This addresses the false positives reported in PR30936.


https://reviews.llvm.org/D27773

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/Driver/Tools.cpp
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/GTestChecker.cpp
  test/Analysis/gtest.cpp
  test/Driver/analyzer-target-enabled-checkers.cpp

Index: test/Driver/analyzer-target-enabled-checkers.cpp
===
--- test/Driver/analyzer-target-enabled-checkers.cpp
+++ test/Driver/analyzer-target-enabled-checkers.cpp
@@ -4,6 +4,7 @@
 // RUN: %clang -### -target x86_64-apple-darwin10 --analyze %s 2>&1 | FileCheck --check-prefix=CHECK-DARWIN %s
 
 // CHECK-DARWIN: "-analyzer-checker=core"
+// CHECK-DARWIN-SAME: "-analyzer-checker=apiModeling"
 // CHECK-DARWIN-SAME: "-analyzer-checker=unix"
 // CHECK-DARWIN-SAME: "-analyzer-checker=osx"
 // CHECK-DARWIN-SAME: "-analyzer-checker=deadcode"
@@ -21,6 +22,7 @@
 // RUN: %clang -### -target x86_64-unknown-linux --analyze %s 2>&1 | FileCheck --check-prefix=CHECK-LINUX %s
 
 // CHECK-LINUX: "-analyzer-checker=core"
+// CHECK-LINUX-SAME: "-analyzer-checker=apiModeling"
 // CHECK-LINUX-SAME: "-analyzer-checker=unix"
 // CHECK-LINUX-NOT:  "-analyzer-checker=osx"
 // CHECK-LINUX-SAME: "-analyzer-checker=deadcode"
@@ -38,6 +40,7 @@
 // RUN: %clang -### -target x86_64-windows --analyze %s 2>&1 | FileCheck --check-prefix=CHECK-WINDOWS %s
 
 // CHECK-WINDOWS: "-analyzer-checker=core"
+// CHECK-WINDOWS-SAME: "-analyzer-checker=apiModeling"
 // CHECK-WINDOWS-SAME: "-analyzer-checker=unix.API"
 // CHECK-WINDOWS-SAME: "-analyzer-checker=unix.Malloc"
 // CHECK-WINDOWS-SAME: "-analyzer-checker=unix.MallocSizeof"
Index: test/Analysis/gtest.cpp
===
--- /dev/null
+++ test/Analysis/gtest.cpp
@@ -0,0 +1,142 @@
+//RUN: %clang_cc1 -cc1 -std=c++11 -analyze  -analyzer-checker=core,apiModeling.google.GTest -analyzer-eagerly-assume %s -verify
+//RUN: %clang_cc1 -cc1 -std=c++11 -analyze  -analyzer-checker=core,apiModeling.google.GTest -analyzer-eagerly-assume -DGTEST_VERSION_1_8_AND_LATER=1 %s -verify
+
+// expected-no-diagnostics
+
+namespace std {
+  class string {
+public:
+~string();
+const char *c_str();
+  };
+}
+
+namespace testing {
+
+class Message { };
+class TestPartResult {
+ public:
+  enum Type {
+kSuccess,
+kNonFatalFailure,
+kFatalFailure
+  };
+};
+
+namespace internal {
+
+class AssertHelper {
+ public:
+  AssertHelper(TestPartResult::Type type, const char* file, int line,
+   const char* message);
+  ~AssertHelper();
+  void operator=(const Message& message) const;
+};
+
+
+template 
+struct AddReference { typedef T& type; };
+template 
+struct AddReference { typedef T& type; };
+template 
+class ImplicitlyConvertible {
+ private:
+  static typename AddReference::type MakeFrom();
+  static char Helper(To);
+  static char ((...))[2];
+ public:
+  static const bool value =
+  sizeof(Helper(ImplicitlyConvertible::MakeFrom())) == 1;
+};
+template 
+const bool ImplicitlyConvertible::value;
+template struct EnableIf;
+template<> struct EnableIf { typedef void type; };
+
+} // end internal
+
+
+class AssertionResult {
+public:
+
+  // The implementation for the copy constructor is not exposed in the
+  // interface.
+  AssertionResult(const AssertionResult& other);
+
+#if defined(GTEST_VERSION_1_8_AND_LATER)
+  template 
+  explicit AssertionResult(
+  const T& success,
+  typename internal::EnableIf<
+  !internal::ImplicitlyConvertible::value>::type*
+  

[libcxx] r289716 - XFAIL test on apple-clang-7.0

2016-12-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Dec 14 15:44:08 2016
New Revision: 289716

URL: http://llvm.org/viewvc/llvm-project?rev=289716=rev
Log:
XFAIL test on apple-clang-7.0

Modified:

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

Modified: 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp?rev=289716=289715=289716=diff
==
--- 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
 Wed Dec 14 15:44:08 2016
@@ -9,7 +9,7 @@
 
 // Usage of is_trivially_constructible is broken with these compilers.
 // See https://llvm.org/bugs/show_bug.cgi?id=31016
-// XFAIL: clang-3.7
+// XFAIL: clang-3.7, apple-clang-7.0
 
 // 
 


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


r289715 - Create SampleProfileLoader pass in llvm instead of clang

2016-12-14 Thread Dehao Chen via cfe-commits
Author: dehao
Date: Wed Dec 14 15:41:04 2016
New Revision: 289715

URL: http://llvm.org/viewvc/llvm-project?rev=289715=rev
Log:
Create SampleProfileLoader pass in llvm instead of clang

Summary:
We used to create SampleProfileLoader pass in clang. This makes LTO/ThinLTO 
unable to add this pass in the linker plugin. This patch moves the 
SampleProfileLoader pass creation from
clang to llvm pass manager builder.

Reviewers: tejohnson, davidxl, dnovillo

Subscribers: mehdi_amini, cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=289715=289714=289715=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Dec 14 15:41:04 2016
@@ -464,10 +464,8 @@ void EmitAssemblyHelper::CreatePasses(le
   if (CodeGenOpts.hasProfileIRUse())
 PMBuilder.PGOInstrUse = CodeGenOpts.ProfileInstrumentUsePath;
 
-  if (!CodeGenOpts.SampleProfileFile.empty()) {
-MPM.add(createPruneEHPass());
-MPM.add(createSampleProfileLoaderPass(CodeGenOpts.SampleProfileFile));
-  }
+  if (!CodeGenOpts.SampleProfileFile.empty())
+PMBuilder.PGOSampleUse = CodeGenOpts.SampleProfileFile;
 
   PMBuilder.populateFunctionPassManager(FPM);
   PMBuilder.populateModulePassManager(MPM);


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


r289713 - Revert 289252 (and follow-up 289285), it caused PR31374

2016-12-14 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Dec 14 15:38:18 2016
New Revision: 289713

URL: http://llvm.org/viewvc/llvm-project?rev=289713=rev
Log:
Revert 289252 (and follow-up 289285), it caused PR31374

Removed:
cfe/trunk/test/CodeGenOpenCL/amdgpu-nullptr.cl
Modified:
cfe/trunk/include/clang/AST/APValue.h
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/AST/APValue.cpp
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.h
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/CodeGen/TargetInfo.h

Modified: cfe/trunk/include/clang/AST/APValue.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/APValue.h?rev=289713=289712=289713=diff
==
--- cfe/trunk/include/clang/AST/APValue.h (original)
+++ cfe/trunk/include/clang/AST/APValue.h Wed Dec 14 15:38:18 2016
@@ -135,15 +135,14 @@ public:
   }
   APValue(const APValue );
   APValue(APValue &) : Kind(Uninitialized) { swap(RHS); }
-  APValue(LValueBase B, const CharUnits , NoLValuePath N, unsigned CallIndex,
-  bool IsNullPtr = false)
+  APValue(LValueBase B, const CharUnits , NoLValuePath N, unsigned CallIndex)
   : Kind(Uninitialized) {
-MakeLValue(); setLValue(B, O, N, CallIndex, IsNullPtr);
+MakeLValue(); setLValue(B, O, N, CallIndex);
   }
   APValue(LValueBase B, const CharUnits , ArrayRef Path,
-  bool OnePastTheEnd, unsigned CallIndex, bool IsNullPtr = false)
+  bool OnePastTheEnd, unsigned CallIndex)
   : Kind(Uninitialized) {
-MakeLValue(); setLValue(B, O, Path, OnePastTheEnd, CallIndex, IsNullPtr);
+MakeLValue(); setLValue(B, O, Path, OnePastTheEnd, CallIndex);
   }
   APValue(UninitArray, unsigned InitElts, unsigned Size) : Kind(Uninitialized) 
{
 MakeArray(InitElts, Size);
@@ -255,7 +254,6 @@ public:
   bool hasLValuePath() const;
   ArrayRef getLValuePath() const;
   unsigned getLValueCallIndex() const;
-  bool isNullPointer() const;
 
   APValue (unsigned I) {
 assert(isVector() && "Invalid accessor");
@@ -376,10 +374,10 @@ public:
 ((ComplexAPFloat *)(char *)Data.buffer)->Imag = std::move(I);
   }
   void setLValue(LValueBase B, const CharUnits , NoLValuePath,
- unsigned CallIndex, bool IsNullPtr);
+ unsigned CallIndex);
   void setLValue(LValueBase B, const CharUnits ,
  ArrayRef Path, bool OnePastTheEnd,
- unsigned CallIndex, bool IsNullPtr);
+ unsigned CallIndex);
   void setUnion(const FieldDecl *Field, const APValue ) {
 assert(isUnion() && "Invalid accessor");
 ((UnionData*)(char*)Data.buffer)->Field = Field;

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=289713=289712=289713=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Wed Dec 14 15:38:18 2016
@@ -2295,10 +2295,6 @@ public:
   return (*AddrSpaceMap)[AS - LangAS::Offset];
   }
 
-  /// Get target-dependent integer value for null pointer which is used for
-  /// constant folding.
-  uint64_t getTargetNullPointerValue(QualType QT) const;
-
   bool addressSpaceMapManglingFor(unsigned AS) const {
 return AddrSpaceMapMangling || 
AS < LangAS::Offset || 

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=289713=289712=289713=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Wed Dec 14 15:38:18 2016
@@ -42,7 +42,6 @@ class DiagnosticsEngine;
 class LangOptions;
 class CodeGenOptions;
 class MacroBuilder;
-class QualType;
 class SourceLocation;
 class SourceManager;
 
@@ -301,12 +300,6 @@ public:
 return PointerWidth;
   }
 
-  /// \brief Get integer value for null pointer.
-  /// \param AddrSpace address space of pointee in source language.
-  virtual uint64_t getNullPointerValue(unsigned AddrSpace) const {
-return 0;
-  }
-
   /// \brief Return the size of '_Bool' and C++ 'bool' for this target, in 
bits.
   unsigned getBoolWidth() const { return BoolWidth; }
 

Modified: cfe/trunk/lib/AST/APValue.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/APValue.cpp?rev=289713=289712=289713=diff

r289712 - Update MSVC compat docs about debug info

2016-12-14 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Dec 14 15:34:19 2016
New Revision: 289712

URL: http://llvm.org/viewvc/llvm-project?rev=289712=rev
Log:
Update MSVC compat docs about debug info

https://reviews.llvm.org/D27769

Modified:
cfe/trunk/docs/MSVCCompatibility.rst

Modified: cfe/trunk/docs/MSVCCompatibility.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/MSVCCompatibility.rst?rev=289712=289711=289712=diff
==
--- cfe/trunk/docs/MSVCCompatibility.rst (original)
+++ cfe/trunk/docs/MSVCCompatibility.rst Wed Dec 14 15:34:19 2016
@@ -72,14 +72,11 @@ The status of major ABI-impacting C++ fe
 .. _/vm: http://msdn.microsoft.com/en-us/library/yad46a6z.aspx
 .. _pointer to a member of a virtual base class: http://llvm.org/PR15713
 
-* Debug info: :partial:`Minimal`.  Clang emits both CodeView line tables
-  (similar to what MSVC emits when given the ``/Z7`` flag) and DWARF debug
-  information into the object file.
-  Microsoft's link.exe will transform the CodeView line tables into a PDB,
-  enabling stack traces in all modern Windows debuggers.  Clang does not emit
-  any CodeView-compatible type info or description of variable layout.
-  Binaries linked with either binutils' ld or LLVM's lld should be usable with
-  GDB however sophisticated C++ expressions are likely to fail.
+* Debug info: :good:`Mostly complete`.  Clang emits relatively complete 
CodeView
+  debug information if ``/Z7`` or ``/Zi`` is passed. Microsoft's link.exe will
+  transform the CodeView debug information into a PDB that works in Windows
+  debuggers and other tools that consume PDB files like ETW. Work to teach lld
+  about CodeView and PDBs is ongoing.
 
 * RTTI: :good:`Complete`.  Generation of RTTI data structures has been
   finished, along with support for the ``/GR`` flag.


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


[libcxx] r289710 - [libcxx] Fix PR24075, PR23841 - Add scoped_allocator_adaptor::construct(pair<T, U>*, ...) overloads.

2016-12-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Dec 14 15:29:29 2016
New Revision: 289710

URL: http://llvm.org/viewvc/llvm-project?rev=289710=rev
Log:
[libcxx] Fix PR24075, PR23841 - Add scoped_allocator_adaptor::construct(pair*, ...) overloads.

Summary:
For more information see:

* https://llvm.org/bugs/show_bug.cgi?id=23841
* https://llvm.org/bugs/show_bug.cgi?id=24075

I hope you have as much fun reviewing as I did writing these insane tests!

Reviewers: mclow.lists, AlisdairM, EricWF

Subscribers: AlisdairM, Potatoswatter, cfe-commits

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

Added:

libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair.pass.cpp

libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_const_lvalue_pair.pass.cpp

libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_piecewise.pass.cpp

libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_rvalue.pass.cpp

libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_values.pass.cpp

libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_type.pass.cpp
Modified:
libcxx/trunk/include/__functional_base
libcxx/trunk/include/scoped_allocator

Modified: libcxx/trunk/include/__functional_base
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__functional_base?rev=289710=289709=289710=diff
==
--- libcxx/trunk/include/__functional_base (original)
+++ libcxx/trunk/include/__functional_base Wed Dec 14 15:29:29 2016
@@ -637,7 +637,8 @@ constexpr size_t uses_allocator_v = uses
 template 
 struct __uses_alloc_ctor_imp
 {
-static const bool __ua = uses_allocator<_Tp, _Alloc>::value;
+typedef typename __uncvref<_Alloc>::type _RawAlloc;
+static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value;
 static const bool __ic =
 is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;
 static const int value = __ua ? 2 - __ic : 0;
@@ -655,6 +656,7 @@ void __user_alloc_construct_impl (integr
 new (__storage) _Tp (_VSTD::forward<_Args>(__args)...);
 }
 
+// FIXME: This should have a version which takes a non-const alloc.
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 void __user_alloc_construct_impl (integral_constant, _Tp *__storage, 
const _Allocator &__a, _Args &&... __args )
@@ -662,6 +664,7 @@ void __user_alloc_construct_impl (integr
 new (__storage) _Tp (allocator_arg, __a, _VSTD::forward<_Args>(__args)...);
 }
 
+// FIXME: This should have a version which takes a non-const alloc.
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 void __user_alloc_construct_impl (integral_constant, _Tp *__storage, 
const _Allocator &__a, _Args &&... __args )
@@ -669,6 +672,7 @@ void __user_alloc_construct_impl (integr
 new (__storage) _Tp (_VSTD::forward<_Args>(__args)..., __a);
 }
 
+// FIXME: Theis should have a version which takes a non-const alloc.
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 void __user_alloc_construct (_Tp *__storage, const _Allocator &__a, _Args 
&&... __args)

Modified: libcxx/trunk/include/scoped_allocator
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/scoped_allocator?rev=289710=289709=289710=diff
==
--- libcxx/trunk/include/scoped_allocator (original)
+++ libcxx/trunk/include/scoped_allocator Wed Dec 14 15:29:29 2016
@@ -498,8 +498,58 @@ public:
 template 
 _LIBCPP_INLINE_VISIBILITY
 void construct(_Tp* __p, _Args&& ...__args)
-{__construct(__uses_alloc_ctor<_Tp, inner_allocator_type, 
_Args...>(),
+{__construct(__uses_alloc_ctor<_Tp, inner_allocator_type&, 
_Args...>(),
  __p, _VSTD::forward<_Args>(__args)...);}
+
+template 
+void construct(pair<_T1, _T2>* __p, piecewise_construct_t,
+   tuple<_Args1...> __x, tuple<_Args2...> __y)
+{
+typedef __outermost _OM;
+allocator_traits::construct(
+_OM()(outer_allocator()), __p, piecewise_construct
+  , __transform_tuple(
+  typename __uses_alloc_ctor<
+  _T1, inner_allocator_type&, _Args1...
+  >::type()
+, _VSTD::move(__x)
+, typename __make_tuple_indices::type{}
+  )
+  , __transform_tuple(
+  typename __uses_alloc_ctor<
+  _T2, inner_allocator_type&, _Args2...
+  >::type()
+, _VSTD::move(__y)
+, typename __make_tuple_indices::type{}
+  )
+);
+}
+
+template 
+void construct(pair<_T1, _T2>* __p)
+{ construct(__p, piecewise_construct, tuple<>{}, tuple<>{}); }
+
+template 
+

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

2016-12-14 Thread Gergely Angeli via Phabricator via cfe-commits
SilverGeri updated this revision to Diff 81458.

https://reviews.llvm.org/D21298

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

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

[PATCH] D27744: Create SampleProfileLoader pass in llvm instead of clang

2016-12-14 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh reopened this revision.
danielcdh added a comment.
This revision is now accepted and ready to land.

was reverted due to bot breaking


https://reviews.llvm.org/D27744



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


[PATCH] D27612: [libcxx] Fix PR24075, PR23841 - Add scoped_allocator_adaptor::construct(pair<T, U>*, ...) overloads.

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

Accepting for post-commit review.




Comment at: include/scoped_allocator:644
+{
+using _Tup = tuple<_Args&&..., inner_allocator_type&>;
+return _Tup(_VSTD::get<_Idx>(_VSTD::move(__t))..., inner_allocator());

FIXME: use initializer list construction in the return type.


https://reviews.llvm.org/D27612



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


[libcxx] r289708 - Recommit r286884: P0503R0, adopted in Issaquah, rewords some requirements on nullptr_t and istream_iterator.

2016-12-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Dec 14 15:22:48 2016
New Revision: 289708

URL: http://llvm.org/viewvc/llvm-project?rev=289708=rev
Log:
Recommit r286884: P0503R0, adopted in Issaquah, rewords some requirements on 
nullptr_t and istream_iterator.

No code changes were needed, but I updated a few tests.
Also resolved P0509 and P0521, which required no changes to the library or 
tests.

This patch was reverted due to llvm.org/PR31016. There is a bug in Clang 3.7
which causes default.pass.cpp to fails. That test is now marked as XFAIL for 
that
clang version.

This patch was originally authored by Marshall Clow.

Modified:

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

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

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

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

Modified: 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp?rev=289708=289707=289708=diff
==
--- 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
 Wed Dec 14 15:22:48 2016
@@ -7,17 +7,41 @@
 //
 
//===--===//
 
+// Usage of is_trivially_constructible is broken with these compilers.
+// See https://llvm.org/bugs/show_bug.cgi?id=31016
+// XFAIL: clang-3.7
+
 // 
 
 // class istream_iterator
 
 // constexpr istream_iterator();
+// C++17 says: If is_trivially_default_constructible_v is true, then this
+//constructor shall beis a constexpr constructor.
 
 #include 
 #include 
+#include 
 
 #include "test_macros.h"
 
+struct S { S(); }; // not constexpr
+
+#if TEST_STD_VER > 14
+template >
+struct test_trivial {
+void operator ()() const {
+constexpr std::istream_iterator it;
+}
+};
+
+template 
+struct test_trivial {
+void operator ()() const {}
+};
+#endif
+
+
 int main()
 {
 {
@@ -29,4 +53,11 @@ int main()
 #endif
 }
 
+#if TEST_STD_VER > 14
+test_trivial()();
+test_trivial()();
+test_trivial()();
+test_trivial()();
+test_trivial()();
+#endif
 }

Modified: 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp?rev=289708=289707=289708=diff
==
--- 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp
 Wed Dec 14 15:22:48 2016
@@ -23,9 +23,18 @@
 // typedef basic_istream istream_type;
 // ...
 //
+// Before C++17, we have:
 //   If T is a literal type, then the default constructor shall be a constexpr 
constructor.
 //   If T is a literal type, then this constructor shall be a trivial copy 
constructor.
 //   If T is a literal type, then this destructor shall be a trivial 
destructor.
+// C++17 says:
+//   If is_trivially_default_constructible_v is true, then
+//   this constructor (the default ctor) shall beis a constexpr 
constructor.
+//   If is_trivially_copy_constructible_v is true, then
+//   this constructor (the copy ctor) shall beis a trivial copy 
constructor.
+//   If is_trivially_destructible_v is true, then this
+//   destructor shall beis a trivial destructor.
+//  Testing the C++17 ctors for this are in the ctor tests.
 
 #include 
 #include 
@@ -33,7 +42,7 @@
 
 int main()
 {
-typedef 

[PATCH] D27606: [libcxx] Fix tuple construction/assignment from types derived from tuple/pair/array.

2016-12-14 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 81456.
EricWF marked 4 inline comments as done.
EricWF added a comment.

Address review comments.

@mpark any other concerns/comments?


https://reviews.llvm.org/D27606

Files:
  include/__tuple
  include/tuple
  include/type_traits
  
test/std/utilities/tuple/tuple.tuple/tuple.assign/derived_from_tuple_like.pass.cpp
  
test/std/utilities/tuple/tuple.tuple/tuple.cnstr/derived_from_tuple_like.pass.cpp
  test/support/propagate_value_category.hpp

Index: test/support/propagate_value_category.hpp
===
--- /dev/null
+++ test/support/propagate_value_category.hpp
@@ -0,0 +1,145 @@
+#ifndef TEST_SUPPORT_PROPAGATE_VALUE_CATEGORY
+#define TEST_SUPPORT_PROPAGATE_VALUE_CATEGORY
+
+#include "test_macros.h"
+#include 
+
+#if TEST_STD_VER < 11
+#error this header may only be used in C++11
+#endif
+
+using UnderlyingVCType = unsigned;
+enum ValueCategory : UnderlyingVCType {
+  VC_None = 0,
+  VC_LVal = 1 << 0,
+  VC_RVal = 1 << 1,
+  VC_Const = 1 << 2,
+  VC_Volatile = 1 << 3,
+  VC_ConstVolatile = VC_Const | VC_Volatile
+};
+
+inline constexpr ValueCategory operator&(ValueCategory LHS, ValueCategory RHS) {
+  return ValueCategory(LHS & (UnderlyingVCType)RHS);
+}
+
+inline constexpr ValueCategory operator|(ValueCategory LHS, ValueCategory RHS) {
+  return ValueCategory(LHS | (UnderlyingVCType)RHS);
+}
+
+inline constexpr ValueCategory operator^(ValueCategory LHS, ValueCategory RHS) {
+  return ValueCategory(LHS ^ (UnderlyingVCType)RHS);
+}
+
+inline constexpr bool isValidValueCategory(ValueCategory VC) {
+  return (VC & (VC_LVal | VC_RVal)) != (VC_LVal | VC_RVal);
+}
+
+inline constexpr bool hasValueCategory(ValueCategory Arg, ValueCategory Key) {
+  return Arg == Key || ((Arg & Key) == Key);
+}
+
+template 
+using UnCVRef =
+typename std::remove_cv::type>::type;
+
+template 
+constexpr ValueCategory getReferenceQuals() {
+  return std::is_lvalue_reference::value
+ ? VC_LVal
+ : (std::is_rvalue_reference::value ? VC_RVal : VC_None);
+}
+static_assert(getReferenceQuals() == VC_None, "");
+static_assert(getReferenceQuals() == VC_LVal, "");
+static_assert(getReferenceQuals() == VC_RVal, "");
+
+template 
+constexpr ValueCategory getCVQuals() {
+  using Vp = typename std::remove_reference::type;
+  return std::is_const::value && std::is_volatile::value
+ ? VC_ConstVolatile
+ : (std::is_const::value
+? VC_Const
+: (std::is_volatile::value ? VC_Volatile : VC_None));
+}
+static_assert(getCVQuals() == VC_None, "");
+static_assert(getCVQuals() == VC_Const, "");
+static_assert(getCVQuals() == VC_Volatile, "");
+static_assert(getCVQuals() == VC_ConstVolatile, "");
+static_assert(getCVQuals() == VC_None, "");
+static_assert(getCVQuals() == VC_Const, "");
+
+template 
+inline constexpr ValueCategory getValueCategory() {
+  return getReferenceQuals() | getCVQuals();
+}
+static_assert(getValueCategory() == VC_None, "");
+static_assert(getValueCategory() == (VC_LVal | VC_Const), "");
+static_assert(getValueCategory() ==
+  (VC_RVal | VC_ConstVolatile),
+  "");
+
+template 
+struct ApplyValueCategory {
+private:
+  static_assert(isValidValueCategory(VC), "");
+
+  template 
+  using CondT = typename std::conditional::type;
+
+public:
+  template >
+  using ApplyCVQuals = CondT<
+  hasValueCategory(VC, VC_ConstVolatile), typename std::add_cv::type,
+  CondT>>;
+
+  template ::type>
+  using ApplyReferenceQuals =
+  CondT>;
+
+  template 
+  using Apply = ApplyReferenceQuals>;
+
+  template ::type = true>
+  static Apply cast(Tp &) {
+using ToType = Apply;
+return static_cast(t);
+  }
+
+  template ::type = true>
+  static Apply cast(Tp &) {
+using ToType = Apply;
+return static_cast(std::move(t));
+  }
+
+  template <
+  class Tp, bool Dummy = true,
+  typename std::enable_if::type = true>
+  static Apply cast(Tp &) {
+return t;
+  }
+};
+
+template 
+using ApplyValueCategoryT = typename ApplyValueCategory::template Apply;
+
+template 
+using PropagateValueCategory = ApplyValueCategory;
+
+template 
+using PropagateValueCategoryT =
+typename ApplyValueCategory::template Apply;
+
+template 
+typename ApplyValueCategory::template Apply ValueCategoryCast(Tp &) {
+  return ApplyValueCategory::cast(std::forward(t));
+};
+
+#endif // TEST_SUPPORT_PROPAGATE_VALUE_CATEGORY
Index: 

Regression caused by r276159 - [modules] Don't emit initializers for VarDecls within a module eagerly whenever

2016-12-14 Thread Manman via cfe-commits

> On Jul 20, 2016, at 12:10 PM, Richard Smith via cfe-commits 
>  wrote:
> 
> Author: rsmith
> Date: Wed Jul 20 14:10:16 2016
> New Revision: 276159
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=276159=rev
> Log:
> [modules] Don't emit initializers for VarDecls within a module eagerly 
> whenever
> we first touch any part of that module. Instead, defer them until the first
> time that module is (transitively) imported. The initializer step for a module
> then recursively initializes modules that its own headers imported.
> 
> For example, this avoids running the  global initializer in programs
> that don't actually use iostreams, but do use other parts of the standard
> library.
> 
> Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=276159=276158=276159=diff
> ==
> --- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
> +++ cfe/trunk/lib/Serialization/ASTWriter.cpp Wed Jul 20 14:10:16 2016
> @@ -1017,6 +1017,7 @@ void ASTWriter::WriteBlockInfoBlock() {
>   RECORD(SUBMODULE_PRIVATE_HEADER);
>   RECORD(SUBMODULE_TEXTUAL_HEADER);
>   RECORD(SUBMODULE_PRIVATE_TEXTUAL_HEADER);
> +  RECORD(SUBMODULE_INITIALIZERS);
> 
>   // Comments Block.
>   BLOCK(COMMENTS_BLOCK);
> @@ -2417,7 +2418,9 @@ unsigned ASTWriter::getLocalOrImportedSu
>   if (Known != SubmoduleIDs.end())
> return Known->second;
> 
> -  if (Mod->getTopLevelModule() != WritingModule)
> +  auto *Top = Mod->getTopLevelModule();
> +  if (Top != WritingModule &&
> +  !Top->fullModuleNameIs(StringRef(getLangOpts().CurrentModule)))
> return 0;
> 
>   return SubmoduleIDs[Mod] = NextSubmoduleID++;
> @@ -2649,6 +2652,13 @@ void ASTWriter::WriteSubmodules(Module *
>   Stream.EmitRecordWithBlob(ConfigMacroAbbrev, Record, CM);
> }
> 
> +// Emit the initializers, if any.
> +RecordData Inits;
> +for (Decl *D : Context->getModuleInitializers(Mod))
> +  Inits.push_back(GetDeclRef(D));
> +if (!Inits.empty())
> +  Stream.EmitRecord(SUBMODULE_INITIALIZERS, Inits);
> +
> // Queue up the submodules of this module.
> for (auto *M : Mod->submodules())
>   Q.push(M);
> @@ -4514,6 +4524,17 @@ uint64_t ASTWriter::WriteASTCore(Sema 
>   // If we're emitting a module, write out the submodule information.  
>   if (WritingModule)
> WriteSubmodules(WritingModule);
> +  else if (!getLangOpts().CurrentModule.empty()) {
> +// If we're building a PCH in the implementation of a module, we may need
> +// the description of the current module.

Hi Richard,

Sorry to dig up this old commit. We are seeing a regression with the following 
simplified testing case.
cat test.h 
#include "A.h"
cat test.m 
#include "C.h"
cat run.sh 
rm -rf tmp
clang -cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=tmp -I Inputs 
-emit-pch -o tmp-A.pch test.h -fmodule-name=Contacts -x objective-c-header
clang -cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=tmp -I Inputs 
-include-pch tmp-A.pch test.m -fsyntax-only -fmodule-name=Contacts
test.m:1:2: fatal error: module 'Contacts' is defined in both 
'/Users/Ren/projects/module/screen/r29542516/tmp/2BSZ9VNPW89EZ/Contacts-389KKPMFZ1XO7.pcm'
 and 'tmp-A.pch'
#include "C.h"
 ^
test.m:1:2: note: imported by module 'CloudKit' in 
'/Users/Ren/projects/module/screen/r29542516/tmp/2BSZ9VNPW89EZ/CloudKit-389KKPMFZ1XO7.pcm'
1 error generated.

cat Inputs/module.modulemap 
module CloudKit {
  header "C.h"
  export *
}

module Contacts {
  header "D.h"
  export *
}
cat Inputs/A.h
// in pch
cat Inputs/C.h
#include "D.h"
cat Inputs/D.h
//empty

We used to have a different option "-fmodule-implementation-of" which was 
unified with "-fmodule-name”.

When building the pch, we pass in “-fmodule-implementation-of Contacts”, 
because of this part of the commit, we will say the pch defines module Contacts.
The TU also pulls in module CloudKit, which imports module Contacts. Thus we 
have this error:
module 'Contacts' is defined in both 
'/Users/Ren/projects/module/screen/r29542516/tmp/2BSZ9VNPW89EZ/Contacts-389KKPMFZ1XO7.pcm'
 and 'tmp-A.pch’

I wonder why we want to say that a pch defines a module. Is this related to 
lazily evaluating initializers?

Thanks,
Manman

> +//
> +// FIXME: We may need other modules that we did not load from an AST 
> file,
> +// such as if a module declares a 'conflicts' on a different module.
> +Module *M = PP.getHeaderSearchInfo().getModuleMap().findModule(
> +getLangOpts().CurrentModule);
> +if (M && !M->IsFromModuleFile)
> +  WriteSubmodules(M);
> +  }
> 
>   Stream.EmitRecord(SPECIAL_TYPES, SpecialTypes);
> 
> 

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


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

2016-12-14 Thread Gergely Angeli via Phabricator via cfe-commits
SilverGeri updated this revision to Diff 81452.
SilverGeri added a comment.

remove unused string
using early exit in condition
shorten check-message lines
add check-fisex to 'else' part


https://reviews.llvm.org/D21298

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

Index: test/clang-tidy/readability-delete-null-pointer.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-delete-null-pointer.cpp
@@ -0,0 +1,73 @@
+// RUN: %check_clang_tidy %s readability-delete-null-pointer %t
+
+#define NULL 0
+
+void f() {
+  int *p = 0;
+  // CHECK-FIXES: // comment that should not be deleted
+  if (p) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'if' statement is unnecessary; deleting null pointer has no effect [readability-delete-null-pointer]
+// comment that should not be deleted
+delete p;
+  }
+  // CHECK-FIXES-NOT: if (p) {
+  // CHECK-FIXES: delete p;
+
+
+  int *p2 = new int[3];
+  // CHECK-FIXES: // another comment to keep
+  if (p2)
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'if' statement is unnecessary;
+// another comment to keep
+delete[] p2;
+  // CHECK-FIXES-NOT: if (p2)
+  // CHECK-FIXES: delete[] p2;
+
+  int *p3 = 0;
+  if (NULL != p3) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'if' statement is unnecessary;
+delete p3;
+  }
+  // CHECK-FIXES-NOT: if (NULL != p3) {
+  // CHECK-FIXES: delete p3;
+
+  int *p4 = nullptr;
+  if (p4 != nullptr) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'if' statement is unnecessary;
+delete p4;
+  }
+  // CHECK-FIXES-NOT: if (p4 != nullptr) {
+  // CHECK-FIXES: delete p4;
+
+  char *c;
+  if (c != 0) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'if' statement is unnecessary;
+delete c;
+  }
+  // CHECK-FIXES-NOT: if (c != 0) {
+  // CHECK-FIXES: delete c;
+
+  char *c2;
+  if (c2) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'if' statement is unnecessary;
+// CHECK-FIXES: } else {
+// CHECK-FIXES: c2 = c;
+delete c2;
+  } else {
+c2 = c;
+  }
+}
+
+void g() {
+  int *p5, *p6;
+  if (p5)
+delete p6;
+
+  if (p5 && p6)
+delete p5;
+
+  if (p6) {
+int x = 5;
+delete p6;
+  }
+}
Index: docs/clang-tidy/checks/readability-delete-null-pointer.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-delete-null-pointer.rst
@@ -0,0 +1,12 @@
+.. title:: clang-tidy - readability-delete-null-pointer
+
+readability-delete-null-pointer
+===
+
+Checks the 'if' statements where a pointer's existence is checked and then deletes the pointer.
+The check is unnecessary as deleting a nullpointer has no effect.
+
+.. code:: c++
+  int *p;
+  if (p)
+delete p;
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -127,6 +127,7 @@
readability-avoid-const-params-in-decls
readability-braces-around-statements
readability-container-size-empty
+   readability-delete-null-pointer
readability-deleted-default
readability-else-after-return
readability-function-size
Index: clang-tidy/readability/ReadabilityTidyModule.cpp
===
--- clang-tidy/readability/ReadabilityTidyModule.cpp
+++ clang-tidy/readability/ReadabilityTidyModule.cpp
@@ -13,6 +13,7 @@
 #include "AvoidConstParamsInDecls.h"
 #include "BracesAroundStatementsCheck.h"
 #include "ContainerSizeEmptyCheck.h"
+#include "DeleteNullPointerCheck.h"
 #include "DeletedDefaultCheck.h"
 #include "ElseAfterReturnCheck.h"
 #include "FunctionSizeCheck.h"
@@ -45,6 +46,8 @@
 "readability-braces-around-statements");
 CheckFactories.registerCheck(
 "readability-container-size-empty");
+CheckFactories.registerCheck(
+"readability-delete-null-pointer");
 CheckFactories.registerCheck(
 "readability-deleted-default");
 CheckFactories.registerCheck(
Index: clang-tidy/readability/DeleteNullPointerCheck.h
===
--- /dev/null
+++ clang-tidy/readability/DeleteNullPointerCheck.h
@@ -0,0 +1,35 @@
+//===--- DeleteNullPointerCheck.h - clang-tidy---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef 

[PATCH] D27769: Update MSVC compat docs about debug info.

2016-12-14 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

Thanks!




Comment at: docs/MSVCCompatibility.rst:77
+  debug information if ``/Z7`` or ``/Zi`` is passed. Microsoft's link.exe will
+  transform the CodeView debug information into a PDB that works in Windows
+  debuggers and other tools that consume PDB files like ETW. Work to teach lld

I thought they did. Anyway, your wording is good.


https://reviews.llvm.org/D27769



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


[PATCH] D27769: Update MSVC compat docs about debug info.

2016-12-14 Thread Nico Weber via Phabricator via cfe-commits
thakis updated this revision to Diff 81448.
thakis added a comment.

reword slightly


https://reviews.llvm.org/D27769

Files:
  docs/MSVCCompatibility.rst


Index: docs/MSVCCompatibility.rst
===
--- docs/MSVCCompatibility.rst
+++ docs/MSVCCompatibility.rst
@@ -72,14 +72,11 @@
 .. _/vm: http://msdn.microsoft.com/en-us/library/yad46a6z.aspx
 .. _pointer to a member of a virtual base class: http://llvm.org/PR15713
 
-* Debug info: :partial:`Minimal`.  Clang emits both CodeView line tables
-  (similar to what MSVC emits when given the ``/Z7`` flag) and DWARF debug
-  information into the object file.
-  Microsoft's link.exe will transform the CodeView line tables into a PDB,
-  enabling stack traces in all modern Windows debuggers.  Clang does not emit
-  any CodeView-compatible type info or description of variable layout.
-  Binaries linked with either binutils' ld or LLVM's lld should be usable with
-  GDB however sophisticated C++ expressions are likely to fail.
+* Debug info: :good:`Mostly complete`.  Clang emits relatively complete 
CodeView
+  debug information if ``/Z7`` or ``/Zi`` is passed. Microsoft's link.exe will
+  transform the CodeView debug information into a PDB that works in Windows
+  debuggers and other tools that consume PDB files like ETW. Work to teach lld
+  about CodeView and PDBs is ongoing.
 
 * RTTI: :good:`Complete`.  Generation of RTTI data structures has been
   finished, along with support for the ``/GR`` flag.


Index: docs/MSVCCompatibility.rst
===
--- docs/MSVCCompatibility.rst
+++ docs/MSVCCompatibility.rst
@@ -72,14 +72,11 @@
 .. _/vm: http://msdn.microsoft.com/en-us/library/yad46a6z.aspx
 .. _pointer to a member of a virtual base class: http://llvm.org/PR15713
 
-* Debug info: :partial:`Minimal`.  Clang emits both CodeView line tables
-  (similar to what MSVC emits when given the ``/Z7`` flag) and DWARF debug
-  information into the object file.
-  Microsoft's link.exe will transform the CodeView line tables into a PDB,
-  enabling stack traces in all modern Windows debuggers.  Clang does not emit
-  any CodeView-compatible type info or description of variable layout.
-  Binaries linked with either binutils' ld or LLVM's lld should be usable with
-  GDB however sophisticated C++ expressions are likely to fail.
+* Debug info: :good:`Mostly complete`.  Clang emits relatively complete CodeView
+  debug information if ``/Z7`` or ``/Zi`` is passed. Microsoft's link.exe will
+  transform the CodeView debug information into a PDB that works in Windows
+  debuggers and other tools that consume PDB files like ETW. Work to teach lld
+  about CodeView and PDBs is ongoing.
 
 * RTTI: :good:`Complete`.  Generation of RTTI data structures has been
   finished, along with support for the ``/GR`` flag.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27769: Update MSVC compat docs about debug info.

2016-12-14 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: docs/MSVCCompatibility.rst:77
+  debug information if ``/Z7`` or ``/Zi`` is passed. Microsoft's link.exe will
+  transform the CodeView debug information into a PDB that works in modern
+  Windows debuggers and tools like ETW.  Work to teach lld about CodeView and

rnk wrote:
> Are these debuggers modern or are they just debuggers provided by Microsoft? 
> It could be interpreted as a knock against gdb. Maybe we should say: "Windows 
> debuggers that use the Microsoft DIA SDK, such as the Visual Studio debugger"?
Dunno, that was already here, I just kept it. Do they all use the DIA SDK? I 
thought one of them didn't (but I could be making that up)


https://reviews.llvm.org/D27769



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


[PATCH] D27769: Update MSVC compat docs about debug info.

2016-12-14 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: docs/MSVCCompatibility.rst:77
+  debug information if ``/Z7`` or ``/Zi`` is passed. Microsoft's link.exe will
+  transform the CodeView debug information into a PDB that works in modern
+  Windows debuggers and tools like ETW.  Work to teach lld about CodeView and

Are these debuggers modern or are they just debuggers provided by Microsoft? It 
could be interpreted as a knock against gdb. Maybe we should say: "Windows 
debuggers that use the Microsoft DIA SDK, such as the Visual Studio debugger"?


https://reviews.llvm.org/D27769



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


[PATCH] D27769: Update MSVC compat docs about debug info.

2016-12-14 Thread Nico Weber via Phabricator via cfe-commits
thakis updated this revision to Diff 81443.
thakis added a comment.

no dwarf or gcc mode


https://reviews.llvm.org/D27769

Files:
  docs/MSVCCompatibility.rst


Index: docs/MSVCCompatibility.rst
===
--- docs/MSVCCompatibility.rst
+++ docs/MSVCCompatibility.rst
@@ -72,14 +72,11 @@
 .. _/vm: http://msdn.microsoft.com/en-us/library/yad46a6z.aspx
 .. _pointer to a member of a virtual base class: http://llvm.org/PR15713
 
-* Debug info: :partial:`Minimal`.  Clang emits both CodeView line tables
-  (similar to what MSVC emits when given the ``/Z7`` flag) and DWARF debug
-  information into the object file.
-  Microsoft's link.exe will transform the CodeView line tables into a PDB,
-  enabling stack traces in all modern Windows debuggers.  Clang does not emit
-  any CodeView-compatible type info or description of variable layout.
-  Binaries linked with either binutils' ld or LLVM's lld should be usable with
-  GDB however sophisticated C++ expressions are likely to fail.
+* Debug info: :good:`Mostly complete`.  Clang emits relatively complete 
CodeView
+  debug information if ``/Z7`` or ``/Zi`` is passed. Microsoft's link.exe will
+  transform the CodeView debug information into a PDB that works in modern
+  Windows debuggers and tools like ETW.  Work to teach lld about CodeView and
+  PDBs is onging.
 
 * RTTI: :good:`Complete`.  Generation of RTTI data structures has been
   finished, along with support for the ``/GR`` flag.


Index: docs/MSVCCompatibility.rst
===
--- docs/MSVCCompatibility.rst
+++ docs/MSVCCompatibility.rst
@@ -72,14 +72,11 @@
 .. _/vm: http://msdn.microsoft.com/en-us/library/yad46a6z.aspx
 .. _pointer to a member of a virtual base class: http://llvm.org/PR15713
 
-* Debug info: :partial:`Minimal`.  Clang emits both CodeView line tables
-  (similar to what MSVC emits when given the ``/Z7`` flag) and DWARF debug
-  information into the object file.
-  Microsoft's link.exe will transform the CodeView line tables into a PDB,
-  enabling stack traces in all modern Windows debuggers.  Clang does not emit
-  any CodeView-compatible type info or description of variable layout.
-  Binaries linked with either binutils' ld or LLVM's lld should be usable with
-  GDB however sophisticated C++ expressions are likely to fail.
+* Debug info: :good:`Mostly complete`.  Clang emits relatively complete CodeView
+  debug information if ``/Z7`` or ``/Zi`` is passed. Microsoft's link.exe will
+  transform the CodeView debug information into a PDB that works in modern
+  Windows debuggers and tools like ETW.  Work to teach lld about CodeView and
+  PDBs is onging.
 
 * RTTI: :good:`Complete`.  Generation of RTTI data structures has been
   finished, along with support for the ``/GR`` flag.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27769: Update MSVC compat docs about debug info.

2016-12-14 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: docs/MSVCCompatibility.rst:80
+  Windows debuggers and tools like ETW.
+  There is no way to request DWARF debug info in clang-cl mode, so linking
+  with either binutils' ld or LLVM's lld won't produce debug info.  Work to

rnk wrote:
> thakis wrote:
> > I believe this is true?
> You can actually pass -gdwarf to clang-cl to get DWARF. I'm not sure we need 
> to say anything about what happens when you link with DWARF. We mostly want 
> to say that you need to use link.exe to get PDBs today, and that we are 
> working on PDBs in LLD.
Huh, it's not in /? output for some reason. Do you know why? Should we fix 
this? (I'll remove the reference to DWARF here)


https://reviews.llvm.org/D27769



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


[PATCH] D27763: Debug Info: Modified DIBuilder::createCompileUnit() to take DIFile instead of FileName and Directory. (Clang part)

2016-12-14 Thread Amjad Aboud via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289701: [DebugInfo] Changed DIBuilder::createCompileUnit() 
to take DIFile instead of… (authored by aaboud).

Changed prior to commit:
  https://reviews.llvm.org/D27763?vs=81397=81438#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27763

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp


Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -466,7 +466,8 @@
   // Create new compile unit.
   // FIXME - Eliminate TheCU.
   TheCU = DBuilder.createCompileUnit(
-  LangTag, remapDIPath(MainFileName), remapDIPath(getCurrentDirname()),
+  LangTag, DBuilder.createFile(remapDIPath(MainFileName),
+remapDIPath(getCurrentDirname())),
   Producer, LO.Optimize, CGM.getCodeGenOpts().DwarfDebugFlags, RuntimeVers,
   CGM.getCodeGenOpts().SplitDwarfFile, EmissionKind, 0 /* DWOid */,
   CGM.getCodeGenOpts().SplitDwarfInlining);
@@ -1977,10 +1978,11 @@
 // but LLVM detects skeleton CUs by looking for a non-zero DWO id.
 uint64_t Signature = Mod.getSignature() ? Mod.getSignature() : ~1ULL;
 llvm::DIBuilder DIB(CGM.getModule());
-DIB.createCompileUnit(TheCU->getSourceLanguage(), Mod.getModuleName(),
-  Mod.getPath(), TheCU->getProducer(), true,
-  StringRef(), 0, Mod.getASTFile(),
-  llvm::DICompileUnit::FullDebug, Signature);
+DIB.createCompileUnit(TheCU->getSourceLanguage(),
+  DIB.createFile(Mod.getModuleName(), Mod.getPath()),
+  TheCU->getProducer(), true, StringRef(), 0,
+  Mod.getASTFile(), llvm::DICompileUnit::FullDebug,
+  Signature);
 DIB.finalize();
   }
   llvm::DIModule *Parent =


Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -466,7 +466,8 @@
   // Create new compile unit.
   // FIXME - Eliminate TheCU.
   TheCU = DBuilder.createCompileUnit(
-  LangTag, remapDIPath(MainFileName), remapDIPath(getCurrentDirname()),
+  LangTag, DBuilder.createFile(remapDIPath(MainFileName),
+remapDIPath(getCurrentDirname())),
   Producer, LO.Optimize, CGM.getCodeGenOpts().DwarfDebugFlags, RuntimeVers,
   CGM.getCodeGenOpts().SplitDwarfFile, EmissionKind, 0 /* DWOid */,
   CGM.getCodeGenOpts().SplitDwarfInlining);
@@ -1977,10 +1978,11 @@
 // but LLVM detects skeleton CUs by looking for a non-zero DWO id.
 uint64_t Signature = Mod.getSignature() ? Mod.getSignature() : ~1ULL;
 llvm::DIBuilder DIB(CGM.getModule());
-DIB.createCompileUnit(TheCU->getSourceLanguage(), Mod.getModuleName(),
-  Mod.getPath(), TheCU->getProducer(), true,
-  StringRef(), 0, Mod.getASTFile(),
-  llvm::DICompileUnit::FullDebug, Signature);
+DIB.createCompileUnit(TheCU->getSourceLanguage(),
+  DIB.createFile(Mod.getModuleName(), Mod.getPath()),
+  TheCU->getProducer(), true, StringRef(), 0,
+  Mod.getASTFile(), llvm::DICompileUnit::FullDebug,
+  Signature);
 DIB.finalize();
   }
   llvm::DIModule *Parent =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27769: Update MSVC compat docs about debug info.

2016-12-14 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: docs/MSVCCompatibility.rst:80
+  Windows debuggers and tools like ETW.
+  There is no way to request DWARF debug info in clang-cl mode, so linking
+  with either binutils' ld or LLVM's lld won't produce debug info.  Work to

thakis wrote:
> I believe this is true?
You can actually pass -gdwarf to clang-cl to get DWARF. I'm not sure we need to 
say anything about what happens when you link with DWARF. We mostly want to say 
that you need to use link.exe to get PDBs today, and that we are working on 
PDBs in LLD.


https://reviews.llvm.org/D27769



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


[PATCH] D27769: Update MSVC compat docs about debug info.

2016-12-14 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: docs/MSVCCompatibility.rst:80
+  Windows debuggers and tools like ETW.
+  There is no way to request DWARF debug info in clang-cl mode, so linking
+  with either binutils' ld or LLVM's lld won't produce debug info.  Work to

I believe this is true?


https://reviews.llvm.org/D27769



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


r289701 - [DebugInfo] Changed DIBuilder::createCompileUnit() to take DIFile instead of FileName and Directory.

2016-12-14 Thread Amjad Aboud via cfe-commits
Author: aaboud
Date: Wed Dec 14 14:24:40 2016
New Revision: 289701

URL: http://llvm.org/viewvc/llvm-project?rev=289701=rev
Log:
[DebugInfo] Changed DIBuilder::createCompileUnit() to take DIFile instead of 
FileName and Directory.
This way it will be easier to expand DIFile (e.g., to contain checksum) without 
the need to modify the createCompileUnit() API.

Reviewers: cfe-commits, rnk

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

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=289701=289700=289701=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Dec 14 14:24:40 2016
@@ -466,7 +466,8 @@ void CGDebugInfo::CreateCompileUnit() {
   // Create new compile unit.
   // FIXME - Eliminate TheCU.
   TheCU = DBuilder.createCompileUnit(
-  LangTag, remapDIPath(MainFileName), remapDIPath(getCurrentDirname()),
+  LangTag, DBuilder.createFile(remapDIPath(MainFileName),
+remapDIPath(getCurrentDirname())),
   Producer, LO.Optimize, CGM.getCodeGenOpts().DwarfDebugFlags, RuntimeVers,
   CGM.getCodeGenOpts().SplitDwarfFile, EmissionKind, 0 /* DWOid */,
   CGM.getCodeGenOpts().SplitDwarfInlining);
@@ -1977,10 +1978,11 @@ CGDebugInfo::getOrCreateModuleRef(Extern
 // but LLVM detects skeleton CUs by looking for a non-zero DWO id.
 uint64_t Signature = Mod.getSignature() ? Mod.getSignature() : ~1ULL;
 llvm::DIBuilder DIB(CGM.getModule());
-DIB.createCompileUnit(TheCU->getSourceLanguage(), Mod.getModuleName(),
-  Mod.getPath(), TheCU->getProducer(), true,
-  StringRef(), 0, Mod.getASTFile(),
-  llvm::DICompileUnit::FullDebug, Signature);
+DIB.createCompileUnit(TheCU->getSourceLanguage(),
+  DIB.createFile(Mod.getModuleName(), Mod.getPath()),
+  TheCU->getProducer(), true, StringRef(), 0,
+  Mod.getASTFile(), llvm::DICompileUnit::FullDebug,
+  Signature);
 DIB.finalize();
   }
   llvm::DIModule *Parent =


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


[PATCH] D27769: Update MSVC compat docs about debug info.

2016-12-14 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: rnk.
thakis added a subscriber: cfe-commits.

https://reviews.llvm.org/D27769

Files:
  docs/MSVCCompatibility.rst


Index: docs/MSVCCompatibility.rst
===
--- docs/MSVCCompatibility.rst
+++ docs/MSVCCompatibility.rst
@@ -72,14 +72,14 @@
 .. _/vm: http://msdn.microsoft.com/en-us/library/yad46a6z.aspx
 .. _pointer to a member of a virtual base class: http://llvm.org/PR15713
 
-* Debug info: :partial:`Minimal`.  Clang emits both CodeView line tables
-  (similar to what MSVC emits when given the ``/Z7`` flag) and DWARF debug
-  information into the object file.
-  Microsoft's link.exe will transform the CodeView line tables into a PDB,
-  enabling stack traces in all modern Windows debuggers.  Clang does not emit
-  any CodeView-compatible type info or description of variable layout.
-  Binaries linked with either binutils' ld or LLVM's lld should be usable with
-  GDB however sophisticated C++ expressions are likely to fail.
+* Debug info: :good:`Mostly complete`.  Clang emits relatively complete 
CodeView
+  debug information if ``/Z7`` or ``/Zi`` is passed.  In gcc driver mode, this
+  can be activated with ``-gcodeview``. Microsoft's link.exe will
+  transform the CodeView debug information into a PDB that works in modern
+  Windows debuggers and tools like ETW.
+  There is no way to request DWARF debug info in clang-cl mode, so linking
+  with either binutils' ld or LLVM's lld won't produce debug info.  Work to
+  teach lld about CodeView and PDBs is onging.
 
 * RTTI: :good:`Complete`.  Generation of RTTI data structures has been
   finished, along with support for the ``/GR`` flag.


Index: docs/MSVCCompatibility.rst
===
--- docs/MSVCCompatibility.rst
+++ docs/MSVCCompatibility.rst
@@ -72,14 +72,14 @@
 .. _/vm: http://msdn.microsoft.com/en-us/library/yad46a6z.aspx
 .. _pointer to a member of a virtual base class: http://llvm.org/PR15713
 
-* Debug info: :partial:`Minimal`.  Clang emits both CodeView line tables
-  (similar to what MSVC emits when given the ``/Z7`` flag) and DWARF debug
-  information into the object file.
-  Microsoft's link.exe will transform the CodeView line tables into a PDB,
-  enabling stack traces in all modern Windows debuggers.  Clang does not emit
-  any CodeView-compatible type info or description of variable layout.
-  Binaries linked with either binutils' ld or LLVM's lld should be usable with
-  GDB however sophisticated C++ expressions are likely to fail.
+* Debug info: :good:`Mostly complete`.  Clang emits relatively complete CodeView
+  debug information if ``/Z7`` or ``/Zi`` is passed.  In gcc driver mode, this
+  can be activated with ``-gcodeview``. Microsoft's link.exe will
+  transform the CodeView debug information into a PDB that works in modern
+  Windows debuggers and tools like ETW.
+  There is no way to request DWARF debug info in clang-cl mode, so linking
+  with either binutils' ld or LLVM's lld won't produce debug info.  Work to
+  teach lld about CodeView and PDBs is onging.
 
 * RTTI: :good:`Complete`.  Generation of RTTI data structures has been
   finished, along with support for the ``/GR`` flag.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r289698 - Remove unused variable found by GCC warning.

2016-12-14 Thread Nico Weber via cfe-commits
If you spell it `/*IsWritten=*/foo`, then clang-format will know to not
insert a space after the comment.

On Wed, Dec 14, 2016 at 2:45 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Wed Dec 14 13:45:03 2016
> New Revision: 289698
>
> URL: http://llvm.org/viewvc/llvm-project?rev=289698=rev
> Log:
> Remove unused variable found by GCC warning.
>
> Modified:
> cfe/trunk/lib/Serialization/ASTReader.cpp
>
> Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/
> Serialization/ASTReader.cpp?rev=289698=289697=289698=diff
> 
> ==
> --- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
> +++ cfe/trunk/lib/Serialization/ASTReader.cpp Wed Dec 14 13:45:03 2016
> @@ -8185,7 +8185,7 @@ ASTReader::ReadCXXCtorInitializers(Modul
>CXXCtorInitializer(Context, IndirectMember, MemberOrEllipsisLoc,
>   LParenLoc, Init, RParenLoc);
>
> -if (bool IsWritten = Record[Idx++]) {
> +if (/*IsWritten*/Record[Idx++]) {
>unsigned SourceOrder = Record[Idx++];
>BOMInit->setSourceOrder(SourceOrder);
>  }
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r289698 - Remove unused variable found by GCC warning.

2016-12-14 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Dec 14 13:45:03 2016
New Revision: 289698

URL: http://llvm.org/viewvc/llvm-project?rev=289698=rev
Log:
Remove unused variable found by GCC warning.

Modified:
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=289698=289697=289698=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Wed Dec 14 13:45:03 2016
@@ -8185,7 +8185,7 @@ ASTReader::ReadCXXCtorInitializers(Modul
   CXXCtorInitializer(Context, IndirectMember, MemberOrEllipsisLoc,
  LParenLoc, Init, RParenLoc);
 
-if (bool IsWritten = Record[Idx++]) {
+if (/*IsWritten*/Record[Idx++]) {
   unsigned SourceOrder = Record[Idx++];
   BOMInit->setSourceOrder(SourceOrder);
 }


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


[PATCH] D27740: [analyzer] Include type name in Retain Count Checker diagnostics

2016-12-14 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna updated this revision to Diff 81429.
zaks.anna added a comment.

Devin did not like the '*' in the diagnostic for ObjC objects, so remove the 
'*'.


https://reviews.llvm.org/D27740

Files:
  lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  test/Analysis/edges-new.mm
  test/Analysis/inlining/path-notes.m
  test/Analysis/objc-arc.m
  test/Analysis/plist-output-alternate.m
  test/Analysis/plist-output.m
  test/Analysis/retain-release-arc.m
  test/Analysis/retain-release-path-notes-gc.m
  test/Analysis/retain-release-path-notes.m

Index: test/Analysis/retain-release-path-notes.m
===
--- test/Analysis/retain-release-path-notes.m
+++ test/Analysis/retain-release-path-notes.m
@@ -44,100 +44,100 @@
 
 
 void creationViaAlloc () {
-  id leaked = [[NSObject alloc] init]; // expected-note{{Method returns an Objective-C object with a +1 retain count}}
+  id leaked = [[NSObject alloc] init]; // expected-note{{Method returns an instance of NSObject with a +1 retain count}}
   return; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}}
 }
 
 void creationViaCFCreate () {
-  CFTypeRef leaked = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count}}
+  CFTypeRef leaked = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count}}
   return; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}}
 }
 
 void acquisitionViaMethod (Foo *foo) {
-  id leaked = [foo methodWithValue]; // expected-note{{Method returns an Objective-C object with a +0 retain count}}
+  id leaked = [foo methodWithValue]; // expected-note{{Method returns an instance of id with a +0 retain count}}
   [leaked retain]; // expected-note{{Reference count incremented. The object now has a +1 retain count}}
   [leaked retain]; // expected-note{{Reference count incremented. The object now has a +2 retain count}}
   [leaked release]; // expected-note{{Reference count decremented. The object now has a +1 retain count}}
   return; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}}
 }
 
 void acquisitionViaProperty (Foo *foo) {
-  id leaked = foo.propertyValue; // expected-note{{Property returns an Objective-C object with a +0 retain count}}
+  id leaked = foo.propertyValue; // expected-note{{Property returns an instance of id with a +0 retain count}}
   [leaked retain]; // expected-note{{Reference count incremented. The object now has a +1 retain count}}
   return; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}}
 }
 
 void acquisitionViaCFFunction () {
-  CFTypeRef leaked = CFGetSomething(); // expected-note{{Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain count}}
+  CFTypeRef leaked = CFGetSomething(); // expected-note{{Call to function 'CFGetSomething' returns a Core Foundation object of type CFTypeRef with a +0 retain count}}
   CFRetain(leaked); // expected-note{{Reference count incremented. The object now has a +1 retain count}}
   return; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}}
 }
 
 void explicitDealloc () {
-  id object = [[NSObject alloc] init]; // expected-note{{Method returns an Objective-C object with a +1 retain count}}
+  id object = [[NSObject alloc] init]; // expected-note{{Method returns an instance of NSObject with a +1 retain count}}
   [object dealloc]; // expected-note{{Object released by directly sending the '-dealloc' message}}
   [object class]; // expected-warning{{Reference-counted object is used after it is released}} // expected-note{{Reference-counted object is used after it is released}}
 }
 
 void implicitDealloc () {
-  id object = [[NSObject alloc] init]; // expected-note{{Method returns an Objective-C object with a +1 retain count}}
+  id object = [[NSObject alloc] init]; // expected-note{{Method returns an instance of NSObject with a +1 retain count}}
   [object release]; // expected-note{{Object released}}
   [object class]; // expected-warning{{Reference-counted object is used after it is released}} // expected-note{{Reference-counted object is used after it is released}}
 }
 
 void overAutorelease () {
-  id object = [[NSObject alloc] init]; // expected-note{{Method returns an Objective-C object with a +1 retain 

r289692 - AArch64: add architecture version feature to Clang invocation.

2016-12-14 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Wed Dec 14 13:21:30 2016
New Revision: 289692

URL: http://llvm.org/viewvc/llvm-project?rev=289692=rev
Log:
AArch64: add architecture version feature to Clang invocation.

Otherwise we don't get the correct predefines and so on in the front-end (or
the right features in the backend).

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/aarch64-cpus.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=289692=289691=289692=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Dec 14 13:21:30 2016
@@ -2527,9 +2527,11 @@ static bool DecodeAArch64Mcpu(const Driv
 Features.push_back("+neon");
   } else {
 unsigned ArchKind = llvm::AArch64::parseCPUArch(CPU);
-unsigned Extersion = llvm::AArch64::getDefaultExtensions(CPU, ArchKind);
+if (!llvm::AArch64::getArchFeatures(ArchKind, Features))
+  return false;
 
-if (!llvm::AArch64::getExtensionFeatures(Extersion, Features))
+unsigned Extension = llvm::AArch64::getDefaultExtensions(CPU, ArchKind);
+if (!llvm::AArch64::getExtensionFeatures(Extension, Features))
   return false;
}
 

Modified: cfe/trunk/test/Driver/aarch64-cpus.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/aarch64-cpus.c?rev=289692=289691=289692=diff
==
--- cfe/trunk/test/Driver/aarch64-cpus.c (original)
+++ cfe/trunk/test/Driver/aarch64-cpus.c Wed Dec 14 13:21:30 2016
@@ -157,16 +157,20 @@
 // RUN: %clang -target aarch64 -mcpu=vulcan -### -c %s 2>&1 | FileCheck 
-check-prefix=VULCAN %s
 // RUN: %clang -target aarch64 -mlittle-endian -mcpu=vulcan -### -c %s 2>&1 | 
FileCheck -check-prefix=VULCAN %s
 // RUN: %clang -target aarch64_be -mlittle-endian -mcpu=vulcan -### -c %s 2>&1 
| FileCheck -check-prefix=VULCAN %s
-// RUN: %clang -target aarch64 -mtune=vulcan -### -c %s 2>&1 | FileCheck 
-check-prefix=VULCAN %s
-// RUN: %clang -target aarch64 -mlittle-endian -mtune=vulcan -### -c %s 2>&1 | 
FileCheck -check-prefix=VULCAN %s
-// RUN: %clang -target aarch64_be -mlittle-endian -mtune=vulcan -### -c %s 
2>&1 | FileCheck -check-prefix=VULCAN %s
-// VULCAN: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "vulcan"
+// RUN: %clang -target aarch64 -mtune=vulcan -### -c %s 2>&1 | FileCheck 
-check-prefix=VULCAN-TUNE %s
+// RUN: %clang -target aarch64 -mlittle-endian -mtune=vulcan -### -c %s 2>&1 | 
FileCheck -check-prefix=VULCAN-TUNE %s
+// RUN: %clang -target aarch64_be -mlittle-endian -mtune=vulcan -### -c %s 
2>&1 | FileCheck -check-prefix=VULCAN-TUNE %s
+// VULCAN: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "vulcan" 
"-target-feature" "+v8.1a"
+// VULCAN-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "vulcan"
+// VULCAN-TUNE-NOT: +v8.1a
 
 // RUN: %clang -target arm64 -mcpu=vulcan -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-VULCAN %s
 // RUN: %clang -target arm64 -mlittle-endian -mcpu=vulcan -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64-VULCAN %s
-// RUN: %clang -target arm64 -mtune=vulcan -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-VULCAN %s
-// RUN: %clang -target arm64 -mlittle-endian -mtune=vulcan -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64-VULCAN %s
-// ARM64-VULCAN: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "vulcan"
+// RUN: %clang -target arm64 -mtune=vulcan -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-VULCAN-TUNE %s
+// RUN: %clang -target arm64 -mlittle-endian -mtune=vulcan -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64-VULCAN-TUNE %s
+// ARM64-VULCAN: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "vulcan" 
"-target-feature" "+v8.1a"
+// ARM64-VULCAN-TUNE: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" 
"vulcan"
+// ARM64-VULCAN-TUNE-NOT: +v8.1a
 
 // RUN: %clang -target aarch64_be -### -c %s 2>&1 | FileCheck 
-check-prefix=GENERIC-BE %s
 // RUN: %clang -target aarch64 -mbig-endian -### -c %s 2>&1 | FileCheck 
-check-prefix=GENERIC-BE %s


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


[PATCH] D27683: Prepare PrettyStackTrace for LLDB adoption

2016-12-14 Thread Sean Callanan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289689: Prepare PrettyStackTrace for LLDB adoption (authored 
by spyffe).

Changed prior to commit:
  https://reviews.llvm.org/D27683?vs=81304=81426#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27683

Files:
  llvm/trunk/include/llvm/Support/PrettyStackTrace.h
  llvm/trunk/lib/Support/PrettyStackTrace.cpp


Index: llvm/trunk/include/llvm/Support/PrettyStackTrace.h
===
--- llvm/trunk/include/llvm/Support/PrettyStackTrace.h
+++ llvm/trunk/include/llvm/Support/PrettyStackTrace.h
@@ -16,6 +16,7 @@
 #ifndef LLVM_SUPPORT_PRETTYSTACKTRACE_H
 #define LLVM_SUPPORT_PRETTYSTACKTRACE_H
 
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Compiler.h"
 
 namespace llvm {
@@ -55,6 +56,16 @@
 void print(raw_ostream ) const override;
   };
 
+  /// PrettyStackTraceFormat - This object prints a string (which may use
+  /// printf-style formatting but should not contain newlines) to the stream
+  /// as the stack trace when a crash occurs.
+  class PrettyStackTraceFormat : public PrettyStackTraceEntry {
+llvm::SmallVector Str;
+  public:
+PrettyStackTraceFormat(const char *Format, ...);
+void print(raw_ostream ) const override;
+  };
+
   /// PrettyStackTraceProgram - This object prints a specified program 
arguments
   /// to the stream as the stack trace when a crash occurs.
   class PrettyStackTraceProgram : public PrettyStackTraceEntry {
Index: llvm/trunk/lib/Support/PrettyStackTrace.cpp
===
--- llvm/trunk/lib/Support/PrettyStackTrace.cpp
+++ llvm/trunk/lib/Support/PrettyStackTrace.cpp
@@ -88,12 +88,12 @@
 __attribute__((section("__DATA," CRASHREPORTER_ANNOTATIONS_SECTION))) 
 = { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0, 0, 0 };
 }
-#elif defined (__APPLE__) && HAVE_CRASHREPORTER_INFO
-static const char *__crashreporter_info__ = 0;
+#elif defined(__APPLE__) && HAVE_CRASHREPORTER_INFO
+extern "C" const char *__crashreporter_info__
+__attribute__((visibility("hidden"))) = 0;
 asm(".desc ___crashreporter_info__, 0x10");
 #endif
 
-
 /// CrashHandler - This callback is run if a fatal signal is delivered to the
 /// process, it prints the pretty stack trace.
 static void CrashHandler(void *) {
@@ -141,10 +141,26 @@
 #endif
 }
 
-void PrettyStackTraceString::print(raw_ostream ) const {
-  OS << Str << "\n";
+void PrettyStackTraceString::print(raw_ostream ) const { OS << Str << "\n"; 
}
+
+PrettyStackTraceFormat::PrettyStackTraceFormat(const char *Format, ...) {
+  va_list AP;
+  va_start(AP, Format);
+  const int SizeOrError = vsnprintf(nullptr, 0, Format, AP);
+  va_end(AP);
+  if (SizeOrError < 0) {
+return;
+  }
+
+  const int Size = SizeOrError + 1; // '\0'
+  Str.resize(Size);
+  va_start(AP, Format);
+  vsnprintf(Str.data(), Size, Format, AP);
+  va_end(AP);
 }
 
+void PrettyStackTraceFormat::print(raw_ostream ) const { OS << Str << "\n"; 
}
+
 void PrettyStackTraceProgram::print(raw_ostream ) const {
   OS << "Program arguments: ";
   // Print the argument list.


Index: llvm/trunk/include/llvm/Support/PrettyStackTrace.h
===
--- llvm/trunk/include/llvm/Support/PrettyStackTrace.h
+++ llvm/trunk/include/llvm/Support/PrettyStackTrace.h
@@ -16,6 +16,7 @@
 #ifndef LLVM_SUPPORT_PRETTYSTACKTRACE_H
 #define LLVM_SUPPORT_PRETTYSTACKTRACE_H
 
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Compiler.h"
 
 namespace llvm {
@@ -55,6 +56,16 @@
 void print(raw_ostream ) const override;
   };
 
+  /// PrettyStackTraceFormat - This object prints a string (which may use
+  /// printf-style formatting but should not contain newlines) to the stream
+  /// as the stack trace when a crash occurs.
+  class PrettyStackTraceFormat : public PrettyStackTraceEntry {
+llvm::SmallVector Str;
+  public:
+PrettyStackTraceFormat(const char *Format, ...);
+void print(raw_ostream ) const override;
+  };
+
   /// PrettyStackTraceProgram - This object prints a specified program arguments
   /// to the stream as the stack trace when a crash occurs.
   class PrettyStackTraceProgram : public PrettyStackTraceEntry {
Index: llvm/trunk/lib/Support/PrettyStackTrace.cpp
===
--- llvm/trunk/lib/Support/PrettyStackTrace.cpp
+++ llvm/trunk/lib/Support/PrettyStackTrace.cpp
@@ -88,12 +88,12 @@
 __attribute__((section("__DATA," CRASHREPORTER_ANNOTATIONS_SECTION))) 
 = { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0, 0, 0 };
 }
-#elif defined (__APPLE__) && HAVE_CRASHREPORTER_INFO
-static const char *__crashreporter_info__ = 0;
+#elif defined(__APPLE__) && HAVE_CRASHREPORTER_INFO
+extern "C" const char *__crashreporter_info__
+__attribute__((visibility("hidden"))) = 0;
 asm(".desc 

[PATCH] D27597: [DebugInfo] Restore test case for long double constants.

2016-12-14 Thread David Gross via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289686: [DebugInfo] Restore test case for long double 
constants. (authored by dgross).

Changed prior to commit:
  https://reviews.llvm.org/D27597?vs=81321=81423#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27597

Files:
  cfe/trunk/test/CodeGen/debug-info-static-const-fp.c


Index: cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
===
--- cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
+++ cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
@@ -1,15 +1,33 @@
-// RUN: %clang -emit-llvm -O0 -S -g %s -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -O0 -debug-info-kind=limited %s -o - | \
+// RUN:   FileCheck --check-prefixes CHECK %s
+
+// RUN: %clang_cc1 -triple hexagon-unknown--elf -emit-llvm -O0 
-debug-info-kind=limited %s -o - | \
+// RUN:   FileCheck --check-prefixes CHECK,CHECK-LDsm %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 
-debug-info-kind=limited %s -o - | \
+// RUN:   FileCheck --check-prefixes CHECK,CHECK-LDlg %s
 
 // Per PR26619, check that for referenced static const of floating-point type,
-// we emit its constant value in debug info.  NOTE that PR26619 is not yet 
fixed for long double.
+// we emit its constant value in debug info.
+//
+// NOTE that __fp16 is assumed to be 16 bits, float is assumed to be
+// 32 bits, and double is assumed to be 64 bits.  Size of long double
+// is not known (for example, it is 64 bits for hexagon-unknown--elf,
+// but 128 bits for x86_64-unknown-linux-gnu).  Therefore, we specify
+// target triples where it has a known size, and check accordingly:
+// for the absence of a constant (CHECK-LDlg) when the size exceeds 64
+// bits, and for the presence of a constant (CHECK-LDsm) but not its
+// value when the size does not exceed 64 bits.
+//
+// NOTE that PR26619 is not yet fixed for types greater than 64 bits.
 
 static const __fp16 hVal = 29/13.0f;//2.2307692307692307692
 (2.23046875)
 
 static const float fVal = -147/17.0f;   //   -8.6470588235294117647
 (-8.64705849)
 
 static const double dVal = 19637/7.0;   // 2805.2857142857142857   
 (2805.2857142857142)
 
-static const long double ldVal = 3/1234567.0L;  //
2.4300017739012949479e-06 ()
+static const long double ldVal = 3/1234567.0L;  //
2.4300017739012949479e-06 ()
 
 int main() {
   return hVal + fVal + dVal + ldVal;
@@ -24,8 +42,5 @@
 // CHECK: !DIGlobalVariable(name: "dVal", {{.*}}, isLocal: true, isDefinition: 
true, expr: ![[DEXPR:[0-9]+]]
 // CHECK: ![[DEXPR]] = !DIExpression(DW_OP_constu, 4658387303597904457, 
DW_OP_stack_value)
 
-// Temporarily removing this check -- for some targets (such as
-// "--target=hexagon-unknown-elf"), long double does not exceed 64
-// bits, and so we actually do get the constant value (expr) emitted.
-//
-// DO-NOT-CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, 
isDefinition: true)
+// CHECK-LDlg: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, 
isDefinition: true)
+// CHECK-LDsm: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, 
isDefinition: true, expr:


Index: cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
===
--- cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
+++ cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
@@ -1,15 +1,33 @@
-// RUN: %clang -emit-llvm -O0 -S -g %s -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -O0 -debug-info-kind=limited %s -o - | \
+// RUN:   FileCheck --check-prefixes CHECK %s
+
+// RUN: %clang_cc1 -triple hexagon-unknown--elf -emit-llvm -O0 -debug-info-kind=limited %s -o - | \
+// RUN:   FileCheck --check-prefixes CHECK,CHECK-LDsm %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 -debug-info-kind=limited %s -o - | \
+// RUN:   FileCheck --check-prefixes CHECK,CHECK-LDlg %s
 
 // Per PR26619, check that for referenced static const of floating-point type,
-// we emit its constant value in debug info.  NOTE that PR26619 is not yet fixed for long double.
+// we emit its constant value in debug info.
+//
+// NOTE that __fp16 is assumed to be 16 bits, float is assumed to be
+// 32 bits, and double is assumed to be 64 bits.  Size of long double
+// is not known (for example, it is 64 bits for hexagon-unknown--elf,
+// but 128 bits for x86_64-unknown-linux-gnu).  Therefore, we specify
+// target triples where it has a known size, and check accordingly:
+// for the absence of a constant (CHECK-LDlg) when the size exceeds 64
+// bits, and for the presence of a constant (CHECK-LDsm) but not its
+// value when the size does not exceed 64 bits.
+//
+// NOTE that PR26619 is not yet fixed for types greater than 64 bits.
 
 static const __fp16 hVal = 29/13.0f;//2.2307692307692307692 (2.23046875)
 
 static const float fVal = -147/17.0f;   

r289686 - [DebugInfo] Restore test case for long double constants.

2016-12-14 Thread David Gross via cfe-commits
Author: dgross
Date: Wed Dec 14 12:52:33 2016
New Revision: 289686

URL: http://llvm.org/viewvc/llvm-project?rev=289686=rev
Log:
[DebugInfo] Restore test case for long double constants.

Summary:
D27549 (partial fix for PR26619) emits a constant value in the debug
metadata for a floating-point static const that does not exceed 64
bits in size.  Whether or not a long double exceeds 64 bits in size
depends on the target.  Modify the test case so that it expects a
constant value for long double if and only if the long double is no
larger than 64 bits.

Reviewers: cfe-commits, probinson

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

Modified:
cfe/trunk/test/CodeGen/debug-info-static-const-fp.c

Modified: cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-static-const-fp.c?rev=289686=289685=289686=diff
==
--- cfe/trunk/test/CodeGen/debug-info-static-const-fp.c (original)
+++ cfe/trunk/test/CodeGen/debug-info-static-const-fp.c Wed Dec 14 12:52:33 2016
@@ -1,7 +1,25 @@
-// RUN: %clang -emit-llvm -O0 -S -g %s -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -O0 -debug-info-kind=limited %s -o - | \
+// RUN:   FileCheck --check-prefixes CHECK %s
+
+// RUN: %clang_cc1 -triple hexagon-unknown--elf -emit-llvm -O0 
-debug-info-kind=limited %s -o - | \
+// RUN:   FileCheck --check-prefixes CHECK,CHECK-LDsm %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 
-debug-info-kind=limited %s -o - | \
+// RUN:   FileCheck --check-prefixes CHECK,CHECK-LDlg %s
 
 // Per PR26619, check that for referenced static const of floating-point type,
-// we emit its constant value in debug info.  NOTE that PR26619 is not yet 
fixed for long double.
+// we emit its constant value in debug info.
+//
+// NOTE that __fp16 is assumed to be 16 bits, float is assumed to be
+// 32 bits, and double is assumed to be 64 bits.  Size of long double
+// is not known (for example, it is 64 bits for hexagon-unknown--elf,
+// but 128 bits for x86_64-unknown-linux-gnu).  Therefore, we specify
+// target triples where it has a known size, and check accordingly:
+// for the absence of a constant (CHECK-LDlg) when the size exceeds 64
+// bits, and for the presence of a constant (CHECK-LDsm) but not its
+// value when the size does not exceed 64 bits.
+//
+// NOTE that PR26619 is not yet fixed for types greater than 64 bits.
 
 static const __fp16 hVal = 29/13.0f;//2.2307692307692307692
 (2.23046875)
 
@@ -9,7 +27,7 @@ static const float fVal = -147/17.0f;
 
 static const double dVal = 19637/7.0;   // 2805.2857142857142857   
 (2805.2857142857142)
 
-static const long double ldVal = 3/1234567.0L;  //
2.4300017739012949479e-06 ()
+static const long double ldVal = 3/1234567.0L;  //
2.4300017739012949479e-06 ()
 
 int main() {
   return hVal + fVal + dVal + ldVal;
@@ -24,8 +42,5 @@ int main() {
 // CHECK: !DIGlobalVariable(name: "dVal", {{.*}}, isLocal: true, isDefinition: 
true, expr: ![[DEXPR:[0-9]+]]
 // CHECK: ![[DEXPR]] = !DIExpression(DW_OP_constu, 4658387303597904457, 
DW_OP_stack_value)
 
-// Temporarily removing this check -- for some targets (such as
-// "--target=hexagon-unknown-elf"), long double does not exceed 64
-// bits, and so we actually do get the constant value (expr) emitted.
-//
-// DO-NOT-CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, 
isDefinition: true)
+// CHECK-LDlg: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, 
isDefinition: true)
+// CHECK-LDsm: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, 
isDefinition: true, expr:


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


r289685 - [Driver] Add tests for enabled static analyzer checkers.

2016-12-14 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Wed Dec 14 12:46:01 2016
New Revision: 289685

URL: http://llvm.org/viewvc/llvm-project?rev=289685=rev
Log:
[Driver] Add tests for enabled static analyzer checkers.

The driver passes flags to cc1 that enable various checkers based on
the target triple. This commit adds tests for these flags on Darwin, Linux,
and Windows.

This is a test-only change.

Added:
cfe/trunk/test/Driver/analyzer-target-enabled-checkers.cpp

Added: cfe/trunk/test/Driver/analyzer-target-enabled-checkers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/analyzer-target-enabled-checkers.cpp?rev=289685=auto
==
--- cfe/trunk/test/Driver/analyzer-target-enabled-checkers.cpp (added)
+++ cfe/trunk/test/Driver/analyzer-target-enabled-checkers.cpp Wed Dec 14 
12:46:01 2016
@@ -0,0 +1,57 @@
+// Tests for static analyzer checkers that the driver enables by default based
+// on the target triple.
+
+// RUN: %clang -### -target x86_64-apple-darwin10 --analyze %s 2>&1 | 
FileCheck --check-prefix=CHECK-DARWIN %s
+
+// CHECK-DARWIN: "-analyzer-checker=core"
+// CHECK-DARWIN-SAME: "-analyzer-checker=unix"
+// CHECK-DARWIN-SAME: "-analyzer-checker=osx"
+// CHECK-DARWIN-SAME: "-analyzer-checker=deadcode"
+// CHECK-DARWIN-SAME: "-analyzer-checker=cplusplus"
+// CHECK-DARWIN-SAME: "-analyzer-checker=security.insecureAPI.UncheckedReturn"
+// CHECK-DARWIN-SAME: "-analyzer-checker=security.insecureAPI.getpw"
+// CHECK-DARWIN-SAME: "-analyzer-checker=security.insecureAPI.gets"
+// CHECK-DARWIN-SAME: "-analyzer-checker=security.insecureAPI.mktemp"
+// CHECK-DARWIN-SAME: "-analyzer-checker=security.insecureAPI.mkstemp"
+// CHECK-DARWIN-SAME: "-analyzer-checker=security.insecureAPI.vfork"
+// CHECK-DARWIN-SAME: "-analyzer-checker=nullability.NullPassedToNonnull"
+// CHECK-DARWIN-SAME: "-analyzer-checker=nullability.NullReturnedFromNonnull"
+
+
+// RUN: %clang -### -target x86_64-unknown-linux --analyze %s 2>&1 | FileCheck 
--check-prefix=CHECK-LINUX %s
+
+// CHECK-LINUX: "-analyzer-checker=core"
+// CHECK-LINUX-SAME: "-analyzer-checker=unix"
+// CHECK-LINUX-NOT:  "-analyzer-checker=osx"
+// CHECK-LINUX-SAME: "-analyzer-checker=deadcode"
+// CHECK-LINUX-SAME: "-analyzer-checker=cplusplus"
+// CHECK-LINUX-SAME: "-analyzer-checker=security.insecureAPI.UncheckedReturn"
+// CHECK-LINUX-SAME: "-analyzer-checker=security.insecureAPI.getpw"
+// CHECK-LINUX-SAME: "-analyzer-checker=security.insecureAPI.gets"
+// CHECK-LINUX-SAME: "-analyzer-checker=security.insecureAPI.mktemp"
+// CHECK-LINUX-SAME: "-analyzer-checker=security.insecureAPI.mkstemp"
+// CHECK-LINUX-SAME: "-analyzer-checker=security.insecureAPI.vfork"
+// CHECK-LINUX-SAME: "-analyzer-checker=nullability.NullPassedToNonnull"
+// CHECK-LINUX-SAME: "-analyzer-checker=nullability.NullReturnedFromNonnull"
+
+
+// RUN: %clang -### -target x86_64-windows --analyze %s 2>&1 | FileCheck 
--check-prefix=CHECK-WINDOWS %s
+
+// CHECK-WINDOWS: "-analyzer-checker=core"
+// CHECK-WINDOWS-SAME: "-analyzer-checker=unix.API"
+// CHECK-WINDOWS-SAME: "-analyzer-checker=unix.Malloc"
+// CHECK-WINDOWS-SAME: "-analyzer-checker=unix.MallocSizeof"
+// CHECK-WINDOWS-SAME: "-analyzer-checker=unix.MismatchedDeallocator"
+// CHECK-WINDOWS-SAME: "-analyzer-checker=unix.cstring.BadSizeArg"
+// CHECK-WINDOWS-SAME: "-analyzer-checker=unix.cstring.NullArg"
+// CHECK-WINDOWS-NOT:  "-analyzer-checker=osx"
+// CHECK-WINDOWS-SAME: "-analyzer-checker=deadcode"
+// CHECK-WINDOWS-SAME: "-analyzer-checker=cplusplus"
+// CHECK-WINDOWS-SAME: "-analyzer-checker=security.insecureAPI.UncheckedReturn"
+// CHECK-WINDOWS-SAME: "-analyzer-checker=security.insecureAPI.getpw"
+// CHECK-WINDOWS-SAME: "-analyzer-checker=security.insecureAPI.gets"
+// CHECK-WINDOWS-SAME: "-analyzer-checker=security.insecureAPI.mktemp"
+// CHECK-WINDOWS-SAME: "-analyzer-checker=security.insecureAPI.mkstemp"
+// CHECK-WINDOWS-SAME: "-analyzer-checker=security.insecureAPI.vfork"
+// CHECK-WINDOWS-SAME: "-analyzer-checker=nullability.NullPassedToNonnull"
+// CHECK-WINDOWS-SAME: "-analyzer-checker=nullability.NullReturnedFromNonnull"


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


[PATCH] D27673: [clang-move] Only move used helper declarations.

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



Comment at: clang-move/ClangMove.cpp:492
+  isDefinition(), unless(InMovedClass), InOldCC,
+  anyOf(isStaticStorageClass(), hasParent(namespaceDecl(isAnonymous();
+  auto HelperFuncOrVar = namedDecl(anyOf(functionDecl(IsOldCCHelperDefinition),

ioeric wrote:
> It seems that `isStaticStorageClass` is preventing combining matchers for 
> functions, variables, and classes. Maybe only apply this matcher on 
> `functionDecl` and `varDecl` below, so that helper classes can be matched 
> with the same matcher?
Seems that it is hard to reuse the same matcher for `functionDecl`/`varDecl` 
and `CXXRecordDecl` since `isStaticStorageClass` is not available to  
`CXXRecordDecl`. So we have to match helper classes, helper functions/vars 
separately.  Have cleaned the code to make it clearer.



Comment at: clang-move/ClangMove.cpp:587
+  } else if (const auto *UD = Result.Nodes.getNodeAs(
+ "using_decl_in_anonymous_ns")) {
+MovedDecls.push_back(UD);

ioeric wrote:
> What about using declarations in non-anonymous namespaces in old cc? Do we 
> also move those?
Those using-decls in named namespace are covered in "using_decl" (see above 
`if` statement). Have combined them together.



Comment at: clang-move/ClangMove.cpp:627
+  // If old_header is not specified (only move declarations from old.cc), 
remain
+  // all the helper function declarations in old.cc as UnremovedDecls is empty
+  // in this case.

ioeric wrote:
> Why is `UnremovedDecls` empty in this case btw?
In this case , `UnremovedDeclsInOldHeader`  is empty, there is no way to verify 
unused/used helper declarations.




Comment at: clang-move/ClangMove.cpp:715
+if (!llvm::is_contained(HelperDeclarations, D) ||
+UsedHelperDeclFinder::isUsed(D, HelperDecls))
+  RealNewCCDecls.push_back(D);

ioeric wrote:
> IIUC, this condition makes sure helpers used by helpers are moved. If so, 
> please explain this in the comment.
Yes.



Comment at: clang-move/ClangMove.h:166
   std::vector CCIncludes;
+  // Records all helper declarations (functions/variables declared as static or
+  // declared in anonymous namespace) in old.cc, saving in an AST-visited 
order.

ioeric wrote:
> Is helper class considered here? 
Yes. Have made the comment a bit clearer.



Comment at: clang-move/UsedHelperDeclFinder.h:22
+
+// Call graph for helper declarations in a single translation unit e.g. old.cc.
+// Helper declarations include following types:

ioeric wrote:
> What's the relationship between this and the `CallGraph` class in 
> `clang/Analysis/CallGraph.h`?
There is no relationship between them. We build our own CallGraph class to meet 
our use cases. The CallGraph in `clang/Analysis` only supports function decls, 
and it seems hard to reuse it. The thing we reuse is the `CallGraphNode`. 



Comment at: clang-move/UsedHelperDeclFinder.h:25
+//   * function/variable/class definitions in an anonymous namespace.
+//   * static function/variable definitions in a global namespace.
+//

ioeric wrote:
> What about static decls in named namespaces? I think they can also be helpers 
> right?
Yeah, it is already covered. Corrected the confusing comment.



Comment at: clang-move/UsedHelperDeclFinder.h:49
+  // D's node, including D.
+  llvm::DenseSet getConnectedNodes(const Decl *D) const;
+

ioeric wrote:
> What does `connected` mean in this context? The graph is directed; does this 
> mean reachable from D or to D?
renamed it to `getReachableNodes`.


https://reviews.llvm.org/D27673



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


[PATCH] D27673: [clang-move] Only move used helper declarations.

2016-12-14 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 81413.
hokein marked 18 inline comments as done.
hokein added a comment.

- Address review comments.
- Add more test cases.


https://reviews.llvm.org/D27673

Files:
  clang-move/CMakeLists.txt
  clang-move/ClangMove.cpp
  clang-move/ClangMove.h
  clang-move/UsedHelperDeclFinder.cpp
  clang-move/UsedHelperDeclFinder.h
  test/clang-move/Inputs/helper_decls_test.cpp
  test/clang-move/Inputs/helper_decls_test.h
  test/clang-move/Inputs/multiple_class_test.cpp
  test/clang-move/move-multiple-classes.cpp
  test/clang-move/move-used-helper-decls.cpp
  unittests/clang-move/ClangMoveTests.cpp

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -73,13 +73,21 @@
   "\n"
   "// comment5\n"
   "// comment5\n"
-  "void Foo::f() { f1(); }\n"
+  "void Foo::f() {\n"
+  "  f1();\n"
+  "  kConstInt1;\n"
+  "  kConstInt2;\n"
+  "  help();\n"
+  "}\n"
   "\n"
   "/\n"
   "// comment //\n"
   "/\n"
   "int Foo::b = 2;\n"
   "int Foo2::f() {\n"
+  "  kConstInt1;\n"
+  "  kConstInt2;\n"
+  "  help();\n"
   "  f1();\n"
   "  return 1;\n"
   "}\n"
@@ -119,6 +127,9 @@
   "}\n"
   "\n"
   "int Foo2::f() {\n"
+  "  kConstInt1;\n"
+  "  kConstInt2;\n"
+  "  help();\n"
   "  f1();\n"
   "  return 1;\n"
   "}\n"
@@ -154,6 +165,7 @@
  "namespace {\n"
  "// comment1.\n"
  "void f1() {}\n"
+ "\n"
  "/// comment2.\n"
  "int kConstInt1 = 0;\n"
  "} // namespace\n"
@@ -170,7 +182,12 @@
  "\n"
  "// comment5\n"
  "// comment5\n"
- "void Foo::f() { f1(); }\n"
+ "void Foo::f() {\n"
+ "  f1();\n"
+ "  kConstInt1;\n"
+ "  kConstInt2;\n"
+ "  help();\n"
+ "}\n"
  "\n"
  "/\n"
  "// comment //\n"
Index: test/clang-move/move-used-helper-decls.cpp
===
--- /dev/null
+++ test/clang-move/move-used-helper-decls.cpp
@@ -0,0 +1,195 @@
+// RUN: mkdir -p %T/used-helper-decls
+// RUN: cp %S/Inputs/helper_decls_test*  %T/used-helper-decls/
+// RUN: cd %T/used-helper-decls
+
+// RUN: clang-move -names="a::Class1" -new_cc=%T/used-helper-decls/new_helper_decls_test.cpp -new_header=%T/used-helper-decls/new_helper_decls_test.h -old_cc=%T/used-helper-decls/helper_decls_test.cpp -old_header=../used-helper-decls/helper_decls_test.h %T/used-helper-decls/helper_decls_test.cpp -- -std=c++11
+// RUN: FileCheck -input-file=%T/used-helper-decls/new_helper_decls_test.cpp -check-prefix=CHECK-NEW-CLASS1-CPP %s
+// RUN: FileCheck -input-file=%T/used-helper-decls/helper_decls_test.cpp -check-prefix=CHECK-OLD-CLASS1-CPP %s
+
+// CHECK-NEW-CLASS1-CPP: #include "{{.*}}new_helper_decls_test.h"
+// CHECK-NEW-CLASS1-CPP-SAME: {{[[:space:]]}}
+// CHECK-NEW-CLASS1-CPP-NEXT: namespace {
+// CHECK-NEW-CLASS1-CPP-NEXT: void HelperFun1() {}
+// CHECK-NEW-CLASS1-CPP-SAME: {{[[:space:]]}}
+// CHECK-NEW-CLASS1-CPP-NEXT: void HelperFun2() { HelperFun1(); }
+// CHECK-NEW-CLASS1-CPP-NEXT: } // namespace
+// CHECK-NEW-CLASS1-CPP-SAME: {{[[:space:]]}}
+// CHECK-NEW-CLASS1-CPP-NEXT: namespace a {
+// CHECK-NEW-CLASS1-CPP-NEXT: void Class1::f() { HelperFun2(); }
+// CHECK-NEW-CLASS1-CPP-NEXT: } // namespace a
+//
+// CHECK-OLD-CLASS1-CPP: void HelperFun1() {}
+// CHECK-OLD-CLASS1-CPP-NOT: void HelperFun2() { HelperFun1(); }
+// CHECK-OLD-CLASS1-CPP-NOT: void Class1::f() { HelperFun2(); }
+// CHECK-OLD-CLASS1-CPP: void Class2::f() {
+// CHECK-OLD-CLASS1-CPP:   HelperFun1();
+
+// RUN: cp %S/Inputs/helper_decls_test*  %T/used-helper-decls/
+// RUN: clang-move -names="a::Class2" -new_cc=%T/used-helper-decls/new_helper_decls_test.cpp -new_header=%T/used-helper-decls/new_helper_decls_test.h 

[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

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

I think will be good idea to extend check for class members.




Comment at: test/clang-tidy/readability-one-name-per-declaration-modern.cpp:13
+  public:
+vector() {}
+vector(initializer_list init) {}

Please use = default; Same below.



Comment at: test/clang-tidy/readability-one-name-per-declaration-modern.cpp:25
+namespace string_literals {
+
+string operator""s(const char*, decltype(sizeof(int))) 

Please remove empty line.



Comment at: test/clang-tidy/readability-one-name-per-declaration-modern.cpp:34
+namespace Types {
+
+typedef int MyType;

Please remove empty line.


https://reviews.llvm.org/D27621



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


r289678 - Improve our handling of tag decls in function prototypes

2016-12-14 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Wed Dec 14 11:44:11 2016
New Revision: 289678

URL: http://llvm.org/viewvc/llvm-project?rev=289678=rev
Log:
Improve our handling of tag decls in function prototypes

r289225 broke AST invariants by reparenting enumerators into function
decl contexts. This improves things by only reparenting TagDecls while
also attempting to preserve the lexical declcontext chain. The
interesting example here is:
  int f(struct S { enum E { a = 1 } b; } c);

The semantic contexts of E and S should be f, and the lexical context of
S should be f and the lexical context of E should be S. We didn't do
that with r289225, but now we should.

This change should also improve our behavior on this example:
  void f() {
extern void ext(struct S { } o);
// S injected here
  }

Before r289225 we would only remove 'S' from the surrounding tag
injection context if it was the TU, but now we properly reparent S from
f to ext.

Fixes PR31366

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CodeGen/decl-in-prototype.c
cfe/trunk/test/Sema/decl-in-prototype.c

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=289678=289677=289678=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Dec 14 11:44:11 2016
@@ -7771,6 +7771,28 @@ static void checkIsValidOpenCLKernelPara
   } while (!VisitStack.empty());
 }
 
+/// Find the DeclContext in which a tag is implicitly declared if we see an
+/// elaborated type specifier in the specified context, and lookup finds
+/// nothing.
+static DeclContext *getTagInjectionContext(DeclContext *DC) {
+  while (!DC->isFileContext() && !DC->isFunctionOrMethod())
+DC = DC->getParent();
+  return DC;
+}
+
+/// Find the Scope in which a tag is implicitly declared if we see an
+/// elaborated type specifier in the specified context, and lookup finds
+/// nothing.
+static Scope *getTagInjectionScope(Scope *S, const LangOptions ) {
+  while (S->isClassScope() ||
+ (LangOpts.CPlusPlus &&
+  S->isFunctionPrototypeScope()) ||
+ ((S->getFlags() & Scope::DeclScope) == 0) ||
+ (S->getEntity() && S->getEntity()->isTransparentContext()))
+S = S->getParent();
+  return S;
+}
+
 NamedDecl*
 Sema::ActOnFunctionDeclarator(Scope *S, Declarator , DeclContext *DC,
   TypeSourceInfo *TInfo, LookupResult ,
@@ -8247,15 +8269,37 @@ Sema::ActOnFunctionDeclarator(Scope *S,
 }
 
 if (!getLangOpts().CPlusPlus) {
-  // In C, find all the non-parameter declarations from the prototype and
-  // move them into the new function decl context as well. Typically they
-  // will have been added to the surrounding context of the prototype.
+  // In C, find all the tag declarations from the prototype and move them
+  // into the function DeclContext. Remove them from the surrounding tag
+  // injection context of the function, which is typically but not always
+  // the TU.
+  DeclContext *PrototypeTagContext =
+  getTagInjectionContext(NewFD->getLexicalDeclContext());
   for (NamedDecl *NonParmDecl : FTI.getDeclsInPrototype()) {
-DeclContext *OldDC = NonParmDecl->getDeclContext();
-if (OldDC->containsDecl(NonParmDecl))
-  OldDC->removeDecl(NonParmDecl);
-NonParmDecl->setDeclContext(NewFD);
-NewFD->addDecl(NonParmDecl);
+auto *TD = dyn_cast(NonParmDecl);
+
+// We don't want to reparent enumerators. Look at their parent enum
+// instead.
+if (!TD) {
+  if (auto *ECD = dyn_cast(NonParmDecl))
+TD = cast(ECD->getDeclContext());
+}
+if (!TD)
+  continue;
+DeclContext *TagDC = TD->getLexicalDeclContext();
+if (!TagDC->containsDecl(TD))
+  continue;
+TagDC->removeDecl(TD);
+TD->setDeclContext(NewFD);
+NewFD->addDecl(TD);
+
+// Preserve the lexical DeclContext if it is not the surrounding tag
+// injection context of the FD. In this example, the semantic context 
of
+// E will be f and the lexical context will be S, while both the
+// semantic and lexical contexts of S will be f:
+//   void f(struct S { enum E { a } f; } s);
+if (TagDC != PrototypeTagContext)
+  TD->setLexicalDeclContext(TagDC);
   }
 }
   } else if (const FunctionProtoType *FT = R->getAs()) {
@@ -12632,28 +12676,6 @@ static bool isAcceptableTagRedeclContext
   return false;
 }
 
-/// Find the DeclContext in which a tag is implicitly declared if we see an
-/// elaborated type specifier in the specified context, and lookup finds
-/// nothing.
-static DeclContext *getTagInjectionContext(DeclContext *DC) {
-  while (!DC->isFileContext() && !DC->isFunctionOrMethod())
-DC = DC->getParent();
-  return DC;
-}
-
-/// Find the Scope 

r289675 - revert r289670 which breaks bot.

2016-12-14 Thread Dehao Chen via cfe-commits
Author: dehao
Date: Wed Dec 14 11:22:53 2016
New Revision: 289675

URL: http://llvm.org/viewvc/llvm-project?rev=289675=rev
Log:
revert r289670 which breaks bot.

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=289675=289674=289675=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Dec 14 11:22:53 2016
@@ -464,8 +464,10 @@ void EmitAssemblyHelper::CreatePasses(le
   if (CodeGenOpts.hasProfileIRUse())
 PMBuilder.PGOInstrUse = CodeGenOpts.ProfileInstrumentUsePath;
 
-  if (!CodeGenOpts.SampleProfileFile.empty())
-PMBuilder.PGOSampleUse = CodeGenOpts.SampleProfileFile;
+  if (!CodeGenOpts.SampleProfileFile.empty()) {
+MPM.add(createPruneEHPass());
+MPM.add(createSampleProfileLoaderPass(CodeGenOpts.SampleProfileFile));
+  }
 
   PMBuilder.populateFunctionPassManager(FPM);
   PMBuilder.populateModulePassManager(MPM);


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


[PATCH] D27758: [change-namespace] don't crash when type reference is in function type parameter list.

2016-12-14 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289672: [change-namespace] don't crash when type reference 
is in function type… (authored by ioeric).

Changed prior to commit:
  https://reviews.llvm.org/D27758?vs=81388=81400#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27758

Files:
  clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
  clang-tools-extra/trunk/test/change-namespace/lambda-function.cpp

Index: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
===
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
@@ -172,6 +172,16 @@
   ReplacementText);
 }
 
+void addReplacementOrDie(
+SourceLocation Start, SourceLocation End, llvm::StringRef ReplacementText,
+const SourceManager ,
+std::map *FileToReplacements) {
+  const auto R = createReplacement(Start, End, ReplacementText, SM);
+  auto Err = (*FileToReplacements)[R.getFilePath()].add(R);
+  if (Err)
+llvm_unreachable(llvm::toString(std::move(Err)).c_str());
+}
+
 tooling::Replacement createInsertion(SourceLocation Loc,
  llvm::StringRef InsertText,
  const SourceManager ) {
@@ -574,11 +584,8 @@
   if (AfterSemi.isValid())
 End = AfterSemi.getLocWithOffset(-1);
   // Delete the forward declaration from the code to be moved.
-  const auto Deletion =
-  createReplacement(Start, End, "", *Result.SourceManager);
-  auto Err = FileToReplacements[Deletion.getFilePath()].add(Deletion);
-  if (Err)
-llvm_unreachable(llvm::toString(std::move(Err)).c_str());
+  addReplacementOrDie(Start, End, "", *Result.SourceManager,
+  );
   llvm::StringRef Code = Lexer::getSourceText(
   CharSourceRange::getTokenRange(
   Result.SourceManager->getSpellingLoc(Start),
@@ -608,6 +615,18 @@
 const DeclContext *DeclCtx, SourceLocation Start, SourceLocation End,
 const NamedDecl *FromDecl) {
   const auto *NsDeclContext = DeclCtx->getEnclosingNamespaceContext();
+  if (llvm::isa(NsDeclContext)) {
+// This should not happen in usual unless the TypeLoc is in function type
+// parameters, e.g `std::function`. In this case, DeclContext of
+// `T` will be the translation unit. We simply use fully-qualified name
+// here.
+// Note that `FromDecl` must not be defined in the old namespace (according
+// to `DeclMatcher`), so its fully-qualified name will not change after
+// changing the namespace.
+addReplacementOrDie(Start, End, FromDecl->getQualifiedNameAsString(),
+*Result.SourceManager, );
+return;
+  }
   const auto *NsDecl = llvm::cast(NsDeclContext);
   // Calculate the name of the `NsDecl` after it is moved to new namespace.
   std::string OldNs = NsDecl->getQualifiedNameAsString();
@@ -667,10 +686,8 @@
   // NewNamespace is the global namespace.
   if (ReplaceName == FromDeclName && !NewNamespace.empty())
 ReplaceName = "::" + ReplaceName;
-  auto R = createReplacement(Start, End, ReplaceName, *Result.SourceManager);
-  auto Err = FileToReplacements[R.getFilePath()].add(R);
-  if (Err)
-llvm_unreachable(llvm::toString(std::move(Err)).c_str());
+  addReplacementOrDie(Start, End, ReplaceName, *Result.SourceManager,
+  );
 }
 
 // Replace the [Start, End] of `Type` with the shortest qualified name when the
@@ -731,11 +748,8 @@
   // FIXME: check if target_decl_name is in moved ns, which doesn't make much
   // sense. If this happens, we need to use name with the new namespace.
   // Use fully qualified name in UsingDecl for now.
-  auto R = createReplacement(Start, End, "using ::" + TargetDeclName,
- *Result.SourceManager);
-  auto Err = FileToReplacements[R.getFilePath()].add(R);
-  if (Err)
-llvm_unreachable(llvm::toString(std::move(Err)).c_str());
+  addReplacementOrDie(Start, End, "using ::" + TargetDeclName,
+  *Result.SourceManager, );
 }
 
 void ChangeNamespaceTool::fixDeclRefExpr(
Index: clang-tools-extra/trunk/test/change-namespace/lambda-function.cpp
===
--- clang-tools-extra/trunk/test/change-namespace/lambda-function.cpp
+++ clang-tools-extra/trunk/test/change-namespace/lambda-function.cpp
@@ -10,12 +10,27 @@
   R operator()(ArgTypes...) const {}
 };
 
+namespace x {
 // CHECK: namespace x {
-// CHECK-NEXT: namespace y {
+class X {};
+}
+
 namespace na {
 namespace nb {
+// CHECK: namespace x {
+// CHECK-NEXT: namespace y {
 void f(function func, int param) { func(param); }
 void g() { f([](int x) {}, 1); }
+
+// x::X in function type parameter list will have translation unit context, so
+// we simply replace it with fully-qualified name.
+using TX = 

[clang-tools-extra] r289672 - [change-namespace] don't crash when type reference is in function type parameter list.

2016-12-14 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed Dec 14 11:01:52 2016
New Revision: 289672

URL: http://llvm.org/viewvc/llvm-project?rev=289672=rev
Log:
[change-namespace] don't crash when type reference is in function type 
parameter list.

Reviewers: hokein

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
clang-tools-extra/trunk/test/change-namespace/lambda-function.cpp

Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp?rev=289672=289671=289672=diff
==
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp (original)
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Wed Dec 14 
11:01:52 2016
@@ -172,6 +172,16 @@ tooling::Replacement createReplacement(S
   ReplacementText);
 }
 
+void addReplacementOrDie(
+SourceLocation Start, SourceLocation End, llvm::StringRef ReplacementText,
+const SourceManager ,
+std::map *FileToReplacements) {
+  const auto R = createReplacement(Start, End, ReplacementText, SM);
+  auto Err = (*FileToReplacements)[R.getFilePath()].add(R);
+  if (Err)
+llvm_unreachable(llvm::toString(std::move(Err)).c_str());
+}
+
 tooling::Replacement createInsertion(SourceLocation Loc,
  llvm::StringRef InsertText,
  const SourceManager ) {
@@ -574,11 +584,8 @@ void ChangeNamespaceTool::moveClassForwa
   if (AfterSemi.isValid())
 End = AfterSemi.getLocWithOffset(-1);
   // Delete the forward declaration from the code to be moved.
-  const auto Deletion =
-  createReplacement(Start, End, "", *Result.SourceManager);
-  auto Err = FileToReplacements[Deletion.getFilePath()].add(Deletion);
-  if (Err)
-llvm_unreachable(llvm::toString(std::move(Err)).c_str());
+  addReplacementOrDie(Start, End, "", *Result.SourceManager,
+  );
   llvm::StringRef Code = Lexer::getSourceText(
   CharSourceRange::getTokenRange(
   Result.SourceManager->getSpellingLoc(Start),
@@ -608,6 +615,18 @@ void ChangeNamespaceTool::replaceQualifi
 const DeclContext *DeclCtx, SourceLocation Start, SourceLocation End,
 const NamedDecl *FromDecl) {
   const auto *NsDeclContext = DeclCtx->getEnclosingNamespaceContext();
+  if (llvm::isa(NsDeclContext)) {
+// This should not happen in usual unless the TypeLoc is in function type
+// parameters, e.g `std::function`. In this case, DeclContext of
+// `T` will be the translation unit. We simply use fully-qualified name
+// here.
+// Note that `FromDecl` must not be defined in the old namespace (according
+// to `DeclMatcher`), so its fully-qualified name will not change after
+// changing the namespace.
+addReplacementOrDie(Start, End, FromDecl->getQualifiedNameAsString(),
+*Result.SourceManager, );
+return;
+  }
   const auto *NsDecl = llvm::cast(NsDeclContext);
   // Calculate the name of the `NsDecl` after it is moved to new namespace.
   std::string OldNs = NsDecl->getQualifiedNameAsString();
@@ -667,10 +686,8 @@ void ChangeNamespaceTool::replaceQualifi
   // NewNamespace is the global namespace.
   if (ReplaceName == FromDeclName && !NewNamespace.empty())
 ReplaceName = "::" + ReplaceName;
-  auto R = createReplacement(Start, End, ReplaceName, *Result.SourceManager);
-  auto Err = FileToReplacements[R.getFilePath()].add(R);
-  if (Err)
-llvm_unreachable(llvm::toString(std::move(Err)).c_str());
+  addReplacementOrDie(Start, End, ReplaceName, *Result.SourceManager,
+  );
 }
 
 // Replace the [Start, End] of `Type` with the shortest qualified name when the
@@ -731,11 +748,8 @@ void ChangeNamespaceTool::fixUsingShadow
   // FIXME: check if target_decl_name is in moved ns, which doesn't make much
   // sense. If this happens, we need to use name with the new namespace.
   // Use fully qualified name in UsingDecl for now.
-  auto R = createReplacement(Start, End, "using ::" + TargetDeclName,
- *Result.SourceManager);
-  auto Err = FileToReplacements[R.getFilePath()].add(R);
-  if (Err)
-llvm_unreachable(llvm::toString(std::move(Err)).c_str());
+  addReplacementOrDie(Start, End, "using ::" + TargetDeclName,
+  *Result.SourceManager, );
 }
 
 void ChangeNamespaceTool::fixDeclRefExpr(

Modified: clang-tools-extra/trunk/test/change-namespace/lambda-function.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/change-namespace/lambda-function.cpp?rev=289672=289671=289672=diff
==
--- clang-tools-extra/trunk/test/change-namespace/lambda-function.cpp (original)
+++ 

[PATCH] D27763: Debug Info: Modified DIBuilder::createCompileUnit() to take DIFile instead of FileName and Directory. (Clang part)

2016-12-14 Thread Amjad Aboud via Phabricator via cfe-commits
aaboud created this revision.
aaboud added a reviewer: rnk.
aaboud added a subscriber: cfe-commits.

Changed DIBuilder::createCompileUnit() to take DIFile instead of FileName and 
Directory.
This way it will be easier to expand DIFile (e.g., to contain checksum) without 
the need to modify the createCompileUnit() API.


https://reviews.llvm.org/D27763

Files:
  lib/CodeGen/CGDebugInfo.cpp


Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -466,7 +466,8 @@
   // Create new compile unit.
   // FIXME - Eliminate TheCU.
   TheCU = DBuilder.createCompileUnit(
-  LangTag, remapDIPath(MainFileName), remapDIPath(getCurrentDirname()),
+  LangTag, DBuilder.createFile(remapDIPath(MainFileName),
+remapDIPath(getCurrentDirname())),
   Producer, LO.Optimize, CGM.getCodeGenOpts().DwarfDebugFlags, RuntimeVers,
   CGM.getCodeGenOpts().SplitDwarfFile, EmissionKind, 0 /* DWOid */,
   CGM.getCodeGenOpts().SplitDwarfInlining);
@@ -1977,10 +1978,11 @@
 // but LLVM detects skeleton CUs by looking for a non-zero DWO id.
 uint64_t Signature = Mod.getSignature() ? Mod.getSignature() : ~1ULL;
 llvm::DIBuilder DIB(CGM.getModule());
-DIB.createCompileUnit(TheCU->getSourceLanguage(), Mod.getModuleName(),
-  Mod.getPath(), TheCU->getProducer(), true,
-  StringRef(), 0, Mod.getASTFile(),
-  llvm::DICompileUnit::FullDebug, Signature);
+DIB.createCompileUnit(TheCU->getSourceLanguage(),
+  DIB.createFile(Mod.getModuleName(), Mod.getPath()),
+  TheCU->getProducer(), true, StringRef(), 0,
+  Mod.getASTFile(), llvm::DICompileUnit::FullDebug,
+  Signature);
 DIB.finalize();
   }
   llvm::DIModule *Parent =


Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -466,7 +466,8 @@
   // Create new compile unit.
   // FIXME - Eliminate TheCU.
   TheCU = DBuilder.createCompileUnit(
-  LangTag, remapDIPath(MainFileName), remapDIPath(getCurrentDirname()),
+  LangTag, DBuilder.createFile(remapDIPath(MainFileName),
+remapDIPath(getCurrentDirname())),
   Producer, LO.Optimize, CGM.getCodeGenOpts().DwarfDebugFlags, RuntimeVers,
   CGM.getCodeGenOpts().SplitDwarfFile, EmissionKind, 0 /* DWOid */,
   CGM.getCodeGenOpts().SplitDwarfInlining);
@@ -1977,10 +1978,11 @@
 // but LLVM detects skeleton CUs by looking for a non-zero DWO id.
 uint64_t Signature = Mod.getSignature() ? Mod.getSignature() : ~1ULL;
 llvm::DIBuilder DIB(CGM.getModule());
-DIB.createCompileUnit(TheCU->getSourceLanguage(), Mod.getModuleName(),
-  Mod.getPath(), TheCU->getProducer(), true,
-  StringRef(), 0, Mod.getASTFile(),
-  llvm::DICompileUnit::FullDebug, Signature);
+DIB.createCompileUnit(TheCU->getSourceLanguage(),
+  DIB.createFile(Mod.getModuleName(), Mod.getPath()),
+  TheCU->getProducer(), true, StringRef(), 0,
+  Mod.getASTFile(), llvm::DICompileUnit::FullDebug,
+  Signature);
 DIB.finalize();
   }
   llvm::DIModule *Parent =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27758: [change-namespace] don't crash when type reference is in function type parameter list.

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

LGTM.


https://reviews.llvm.org/D27758



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


r289670 - Create SampleProfileLoader pass in llvm instead of clang

2016-12-14 Thread Dehao Chen via cfe-commits
Author: dehao
Date: Wed Dec 14 10:49:34 2016
New Revision: 289670

URL: http://llvm.org/viewvc/llvm-project?rev=289670=rev
Log:
Create SampleProfileLoader pass in llvm instead of clang

Summary:
We used to create SampleProfileLoader pass in clang. This makes LTO/ThinLTO 
unable to add this pass in the linker plugin. This patch moves the 
SampleProfileLoader pass creation from
clang to llvm pass manager builder.

Reviewers: tejohnson, davidxl, dnovillo

Subscribers: mehdi_amini, cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=289670=289669=289670=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Dec 14 10:49:34 2016
@@ -464,10 +464,8 @@ void EmitAssemblyHelper::CreatePasses(le
   if (CodeGenOpts.hasProfileIRUse())
 PMBuilder.PGOInstrUse = CodeGenOpts.ProfileInstrumentUsePath;
 
-  if (!CodeGenOpts.SampleProfileFile.empty()) {
-MPM.add(createPruneEHPass());
-MPM.add(createSampleProfileLoaderPass(CodeGenOpts.SampleProfileFile));
-  }
+  if (!CodeGenOpts.SampleProfileFile.empty())
+PMBuilder.PGOSampleUse = CodeGenOpts.SampleProfileFile;
 
   PMBuilder.populateFunctionPassManager(FPM);
   PMBuilder.populateModulePassManager(MPM);


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


[PATCH] D27700: [clang-tidy] refactor ExprSequence out of misc-use-after-move check

2016-12-14 Thread Martin Böhme via Phabricator via cfe-commits
mboehme accepted this revision.
mboehme added a comment.
This revision is now accepted and ready to land.

LG apart from minor comments by others and me




Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:18
 using namespace clang::ast_matchers;
+using namespace clang::tidy::utils;
+

Prazek wrote:
> Prazek wrote:
> > I don't think it is required
> ok I guess I am wrong
I would suggest instead adding an explicit "utils::" qualifier -- it's only 
needed in two places anyway. I don't feel strongly about this though.



Comment at: clang-tidy/utils/ExprSequence.cpp:52
+
+bool isDescendantOrEqual(const Stmt *Descendant, const Stmt *Ancestor,
+ ASTContext *Context) {

Prazek wrote:
> staronj wrote:
> > Shouldn't isDescendantOrEqual be static or in inline namespace?
> Goot catch. I guess putting it with getParentStmts into anonymous namespace 
> is the best solution.
> btw inline namespace is not the same as anonymous namespace :)
Thanks for the catch -- this was already a bug in the original code...



Comment at: clang-tidy/utils/ExprSequence.cpp:179
+
+
+}

Double newline



Comment at: clang-tidy/utils/ExprSequence.h:120
+
+
+}

Double newline


https://reviews.llvm.org/D27700



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


[PATCH] D27758: [change-namespace] don't crash when type reference is in function type parameter list.

2016-12-14 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added a reviewer: hokein.
ioeric added a subscriber: cfe-commits.

https://reviews.llvm.org/D27758

Files:
  change-namespace/ChangeNamespace.cpp
  test/change-namespace/lambda-function.cpp

Index: test/change-namespace/lambda-function.cpp
===
--- test/change-namespace/lambda-function.cpp
+++ test/change-namespace/lambda-function.cpp
@@ -10,12 +10,27 @@
   R operator()(ArgTypes...) const {}
 };
 
+namespace x {
 // CHECK: namespace x {
-// CHECK-NEXT: namespace y {
+class X {};
+}
+
 namespace na {
 namespace nb {
+// CHECK: namespace x {
+// CHECK-NEXT: namespace y {
 void f(function func, int param) { func(param); }
 void g() { f([](int x) {}, 1); }
+
+// x::X in function type parameter list will have translation unit context, so
+// we simply replace it with fully-qualified name.
+using TX = function;
+// CHECK: using TX = function;
+
+class A {};
+using TA = function;
+// CHECK: using TA = function;
+
 // CHECK: } // namespace y
 // CHECK-NEXT: } // namespace x
 }
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -172,6 +172,16 @@
   ReplacementText);
 }
 
+void addReplacementOrDie(
+SourceLocation Start, SourceLocation End, llvm::StringRef ReplacementText,
+const SourceManager ,
+std::map *FileToReplacements) {
+  const auto R = createReplacement(Start, End, ReplacementText, SM);
+  auto Err = (*FileToReplacements)[R.getFilePath()].add(R);
+  if (Err)
+llvm_unreachable(llvm::toString(std::move(Err)).c_str());
+}
+
 tooling::Replacement createInsertion(SourceLocation Loc,
  llvm::StringRef InsertText,
  const SourceManager ) {
@@ -574,11 +584,8 @@
   if (AfterSemi.isValid())
 End = AfterSemi.getLocWithOffset(-1);
   // Delete the forward declaration from the code to be moved.
-  const auto Deletion =
-  createReplacement(Start, End, "", *Result.SourceManager);
-  auto Err = FileToReplacements[Deletion.getFilePath()].add(Deletion);
-  if (Err)
-llvm_unreachable(llvm::toString(std::move(Err)).c_str());
+  addReplacementOrDie(Start, End, "", *Result.SourceManager,
+  );
   llvm::StringRef Code = Lexer::getSourceText(
   CharSourceRange::getTokenRange(
   Result.SourceManager->getSpellingLoc(Start),
@@ -608,6 +615,18 @@
 const DeclContext *DeclCtx, SourceLocation Start, SourceLocation End,
 const NamedDecl *FromDecl) {
   const auto *NsDeclContext = DeclCtx->getEnclosingNamespaceContext();
+  if (llvm::isa(NsDeclContext)) {
+// This should not happen in usual unless the TypeLoc is in function type
+// parameters, e.g `std::function`. In this case, DeclContext of
+// `T` will be the translation unit. We simply use fully-qualified name
+// here.
+// Note that `FromDecl` must not be defined in the old namespace (according
+// to `DeclMatcher`), so its fully-qualified name will not change after
+// changing the namespace.
+addReplacementOrDie(Start, End, FromDecl->getQualifiedNameAsString(),
+*Result.SourceManager, );
+return;
+  }
   const auto *NsDecl = llvm::cast(NsDeclContext);
   // Calculate the name of the `NsDecl` after it is moved to new namespace.
   std::string OldNs = NsDecl->getQualifiedNameAsString();
@@ -667,10 +686,8 @@
   // NewNamespace is the global namespace.
   if (ReplaceName == FromDeclName && !NewNamespace.empty())
 ReplaceName = "::" + ReplaceName;
-  auto R = createReplacement(Start, End, ReplaceName, *Result.SourceManager);
-  auto Err = FileToReplacements[R.getFilePath()].add(R);
-  if (Err)
-llvm_unreachable(llvm::toString(std::move(Err)).c_str());
+  addReplacementOrDie(Start, End, ReplaceName, *Result.SourceManager,
+  );
 }
 
 // Replace the [Start, End] of `Type` with the shortest qualified name when the
@@ -731,11 +748,8 @@
   // FIXME: check if target_decl_name is in moved ns, which doesn't make much
   // sense. If this happens, we need to use name with the new namespace.
   // Use fully qualified name in UsingDecl for now.
-  auto R = createReplacement(Start, End, "using ::" + TargetDeclName,
- *Result.SourceManager);
-  auto Err = FileToReplacements[R.getFilePath()].add(R);
-  if (Err)
-llvm_unreachable(llvm::toString(std::move(Err)).c_str());
+  addReplacementOrDie(Start, End, "using ::" + TargetDeclName,
+  *Result.SourceManager, );
 }
 
 void ChangeNamespaceTool::fixDeclRefExpr(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27754: [clang-format] Implement comment reflowing (again).

2016-12-14 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: lib/Format/ContinuationIndenter.cpp:1174-1175
LineIndex != EndIndex; ++LineIndex) {
-if (!DryRun)
-  Token->replaceWhitespaceBefore(LineIndex, Whitespaces);
+Token->replaceWhitespaceBefore(LineIndex, RemainingTokenColumns,
+   RemainingSpace, DryRun, Whitespaces);
 unsigned TailOffset = 0;

krasimir wrote:
> klimek wrote:
> > Nice that this whole section required so few changes.
> > Why do we need to call into this in DryRun mode now, though? Does it need 
> > to keep state inside in DryRun?
> Yes, replaceWhitespaceBefore recomputes the ContentColumn in case a reflow 
> with the previous line is decided to be made.
> Basically, the whole reflow functionality is inside replaceWhitespaceBefore 
> now (except for a bit of control flow stuff, like updating the  
> ReflowInProgress member variable).
For my curiosity: what's the reason we can't precompute those in the 
constructor? Is that too much things we do outside of the flow here?


https://reviews.llvm.org/D27754



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


r289660 - Update the default of the Mozilla coding style

2016-12-14 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Wed Dec 14 10:09:29 2016
New Revision: 289660

URL: http://llvm.org/viewvc/llvm-project?rev=289660=rev
Log:
Update the default of the Mozilla coding style

Summary:
I also proposed the change in Firefox .clang-format file:
https://bugzilla.mozilla.org/show_bug.cgi?id=1322321

Reviewers: klimek

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=289660=289659=289660=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Wed Dec 14 10:09:29 2016
@@ -655,10 +655,12 @@ FormatStyle getMozillaStyle() {
   MozillaStyle.AllowAllParametersOfDeclarationOnNextLine = false;
   MozillaStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
   MozillaStyle.AlwaysBreakAfterReturnType =
-  FormatStyle::RTBS_TopLevelDefinitions;
+  FormatStyle::RTBS_TopLevel;
   MozillaStyle.AlwaysBreakAfterDefinitionReturnType =
   FormatStyle::DRTBS_TopLevel;
   MozillaStyle.AlwaysBreakTemplateDeclarations = true;
+  MozillaStyle.BinPackParameters = false;
+  MozillaStyle.BinPackArguments = false;
   MozillaStyle.BreakBeforeBraces = FormatStyle::BS_Mozilla;
   MozillaStyle.BreakConstructorInitializersBeforeComma = true;
   MozillaStyle.ConstructorInitializerIndentWidth = 2;


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


[PATCH] D27166: [clang-tidy] Enhance modernize-use-auto to templated function casts

2016-12-14 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D27166#622127, @Prazek wrote:

> In https://reviews.llvm.org/D27166#622108, @malcolm.parsons wrote:
>
> > In https://reviews.llvm.org/D27166#622103, @Prazek wrote:
> >
> > > There is also problem with function pointers
> >
> >
> > The warning is correct, but the fixit is wrong.
> >  Suppress fixit for function pointers?
>
>
> Yep, it is not worth fixing it.


OK.

> Have you add test cases to the cases that we discussed?

I'll try to add some test cases tonight.


https://reviews.llvm.org/D27166



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


[clang-tools-extra] r289658 - Deleted unused typedef

2016-12-14 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Wed Dec 14 09:42:23 2016
New Revision: 289658

URL: http://llvm.org/viewvc/llvm-project?rev=289658=rev
Log:
Deleted unused typedef

Modified:
clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp

Modified: clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp?rev=289658=289657=289658=diff
==
--- clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp (original)
+++ clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp Wed Dec 14 
09:42:23 2016
@@ -75,7 +75,6 @@ ModularizeUtilities *ModularizeUtilities
 
 // Load all header lists and dependencies.
 std::error_code ModularizeUtilities::loadAllHeaderListsAndDependencies() {
-  typedef std::vector::iterator Iter;
   // For each input file.
   for (auto I = InputFilePaths.begin(), E = InputFilePaths.end(); I != E; ++I) 
{
 llvm::StringRef InputPath = *I;


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


r289657 - Fix assert message. NFC.

2016-12-14 Thread Kelvin Li via cfe-commits
Author: kli
Date: Wed Dec 14 09:39:58 2016
New Revision: 289657

URL: http://llvm.org/viewvc/llvm-project?rev=289657=rev
Log:
Fix assert message.  NFC.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=289657=289656=289657=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Dec 14 09:39:58 2016
@@ -10808,7 +10808,7 @@ OMPClause *Sema::ActOnOpenMPIsDevicePtrC
   SourceLocation EndLoc) {
   MappableVarListInfo MVLI(VarList);
   for (auto  : VarList) {
-assert(RefExpr && "NULL expr in OpenMP use_device_ptr clause.");
+assert(RefExpr && "NULL expr in OpenMP is_device_ptr clause.");
 SourceLocation ELoc;
 SourceRange ERange;
 Expr *SimpleRefExpr = RefExpr;


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


[PATCH] D27754: [clang-format] Implement comment reflowing (again).

2016-12-14 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: lib/Format/BreakableToken.cpp:471
+   WhitespaceManager ) 
{
+  if (Tok.is(TT_LineComment)) {
+// If this is the first line of a token, inform Whitespace Manager about 
it.

klimek wrote:
> Without looking into this in a lot of detail: this looks like you want a 
> BreakableComment base class, and have BreakableBlockComment and 
> BreakableLineCommentSection derive from it and implement this method.
> 
> Scanning it a bit, it seems like there is still overlap - perhaps it's also 
> possible to pull out a couple of smaller sized methods in the interface and 
> write the algorithm in terms of those? That could also make it easier to 
> understand in general (large method alarm ;)
Next step I'm doing: will extract two subclasses and try to factor out the 
common functionality. I already did a bit of that with getReflowSplit, but 
there's more potential for extracting common stuff.



Comment at: lib/Format/ContinuationIndenter.cpp:1174-1175
LineIndex != EndIndex; ++LineIndex) {
-if (!DryRun)
-  Token->replaceWhitespaceBefore(LineIndex, Whitespaces);
+Token->replaceWhitespaceBefore(LineIndex, RemainingTokenColumns,
+   RemainingSpace, DryRun, Whitespaces);
 unsigned TailOffset = 0;

klimek wrote:
> Nice that this whole section required so few changes.
> Why do we need to call into this in DryRun mode now, though? Does it need to 
> keep state inside in DryRun?
Yes, replaceWhitespaceBefore recomputes the ContentColumn in case a reflow with 
the previous line is decided to be made.
Basically, the whole reflow functionality is inside replaceWhitespaceBefore now 
(except for a bit of control flow stuff, like updating the  ReflowInProgress 
member variable).


https://reviews.llvm.org/D27754



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


[clang-tools-extra] r289656 - modernize-use-auto NFC fixes

2016-12-14 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Wed Dec 14 09:29:23 2016
New Revision: 289656

URL: http://llvm.org/viewvc/llvm-project?rev=289656=rev
Log:
modernize-use-auto NFC fixes

Modified:
clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp

clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
clang-tools-extra/trunk/clang-query/Query.cpp
clang-tools-extra/trunk/clang-query/QueryParser.cpp
clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp
clang-tools-extra/trunk/clang-tidy/google/NonConstReferences.cpp
clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/MoveForwardingReferenceCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/MultipleStatementMacroCheck.cpp

clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp
clang-tools-extra/trunk/clang-tidy/mpi/TypeMismatchCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/RedundantDeclarationCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
clang-tools-extra/trunk/modularize/CoverageChecker.cpp
clang-tools-extra/trunk/modularize/Modularize.cpp
clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp
clang-tools-extra/trunk/modularize/ModuleAssistant.cpp
clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp
clang-tools-extra/trunk/pp-trace/PPTrace.cpp

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

Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp?rev=289656=289655=289656=diff
==
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp (original)
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Wed Dec 14 
09:29:23 2016
@@ -709,7 +709,7 @@ void ChangeNamespaceTool::fixTypeLoc(
   return;
   }
 
-  const Decl *DeclCtx = Result.Nodes.getNodeAs("dc");
+  const auto *DeclCtx = Result.Nodes.getNodeAs("dc");
   assert(DeclCtx && "Empty decl context.");
   replaceQualifiedSymbolInDeclContext(Result, DeclCtx->getDeclContext(), Start,
   End, FromDecl);

Modified: 
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp?rev=289656=289655=289656=diff
==
--- 
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
 Wed Dec 14 09:29:23 2016
@@ -124,9 +124,7 @@ static void reportConflict(
 bool applyAllReplacements(const std::vector ,
   Rewriter ) {
   bool Result = true;
-  for (std::vector::const_iterator I = Replaces.begin(),
- E = Replaces.end();
-   I != E; ++I) {
+  for (auto I = Replaces.begin(), E = Replaces.end(); I != E; ++I) {
 if (I->isApplicable()) {
   Result = I->apply(Rewrite) && Result;
 } else {
@@ -293,8 +291,7 @@ RangeVector calculateChangedRanges(
 
 bool writeFiles(const clang::Rewriter ) {
 
-  for (Rewriter::const_buffer_iterator BufferI = Rewrites.buffer_begin(),
-   BufferE = Rewrites.buffer_end();
+  for (auto BufferI = Rewrites.buffer_begin(), BufferE = Rewrites.buffer_end();
BufferI != BufferE; ++BufferI) {
 StringRef FileName =
 Rewrites.getSourceMgr().getFileEntryForID(BufferI->first)->getName();

Modified: clang-tools-extra/trunk/clang-query/Query.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/Query.cpp?rev=289656=289655=289656=diff
==
--- clang-tools-extra/trunk/clang-query/Query.cpp (original)
+++ 

[PATCH] D27166: [clang-tidy] Enhance modernize-use-auto to templated function casts

2016-12-14 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added a comment.

In https://reviews.llvm.org/D27166#622108, @malcolm.parsons wrote:

> In https://reviews.llvm.org/D27166#622103, @Prazek wrote:
>
> > There is still one more problem:
> >
> >   /home/prazek/llvm/lib/Analysis/ScalarEvolution.cpp:2442:11: warning: use 
> > auto when initializing with a template cast to avoid duplicating the type 
> > name [modernize-use-auto]
> > const auto **O = SCEVAllocator.Allocate(Ops.size());
> >   ^
> >   auto 
>
>
> Any suggestions for rewriting this matcher?
>
>   // Skip declarations that are already using auto.
>   unless(has(varDecl(anyOf(hasType(autoType()),
>hasType(pointerType(pointee(autoType(,
>hasType(referenceType(pointee(autoType(
>   
>
> > There is also problem with function pointers
> > 
> >   /home/prazek/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp:520:9: warning: use 
> > auto when initializing with a cast to avoid duplicating the type name 
> > [modernize-use-auto]
> > int (*PF)(int, char **, const char **) =
> > ^
> > auto
> > 
> > 
> >  
>
> The warning is correct, but the fixit is wrong.
>  Suppress fixit for function pointers?


Yep, it is not worth fixing it. Have you add test cases to the cases that we 
discussed?




Comment at: clang-tidy/modernize/UseAutoCheck.cpp:173-177
+/// Matches the type that was substituted for the template parameter.
+AST_MATCHER_P(SubstTemplateTypeParmType, hasReplacementType,
+  ast_matchers::internal::Matcher, InnerMatcher) {
+  return InnerMatcher.matches(Node.getReplacementType(), Finder, Builder);
+}

malcolm.parsons wrote:
> Prazek wrote:
> > alexfh wrote:
> > > Ideally, this should go to ASTMatchers.h (with a proper test and 
> > > documentation).
> > I agree 
> @Prazek Are you talking about `hasReplacementType` or 
> `hasExplicitTemplateArgs`?
It is good now.


https://reviews.llvm.org/D27166



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


[PATCH] D27123: Add AVR target and toolchain to Clang

2016-12-14 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

In https://reviews.llvm.org/D27123#617118, @jroelofs wrote:

> In https://reviews.llvm.org/D27123#616887, @saaadhu wrote:
>
> > Make defines for CHAR16_TYPE, {U,}INT_{LEAST,FAST}16_TYPE use int instead 
> > of short.
> >
> > {U,}INT16_TYPE still gets defined as short though - 
> > lib/Frontend/InitPreprocessor.cpp::DefineExactWidthIntType does not use 
> > TargetInfo::getIntTypeByWidth. Instead, InitializePredefinedMacros calls 
> > the function with the specific type (SignedShort/UnsignedShort), as 
> > getShortWidth() > getCharWidth(), but getIntWidth() == getShortWidth(). Not 
> > sure what the best way to fix that is - should I make DefineExactWidthType 
> > use TargetInfo::getIntTypeByWidth?
>


If you do, it might break other things. Might be better to leave this alone, 
and leave a comment with a PR for it, explaining where the differences are.

> I'm not sure either. I think it's a good question for @rengolin.




https://reviews.llvm.org/D27123



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


[PATCH] D27166: [clang-tidy] Enhance modernize-use-auto to templated function casts

2016-12-14 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons updated this revision to Diff 81377.
malcolm.parsons added a comment.

Use qualType(hasDescendant(autoType())) to fix skipping of declarations that
are already using auto.


https://reviews.llvm.org/D27166

Files:
  clang-tidy/modernize/UseAutoCheck.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/modernize-use-auto.rst
  test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp
  test/clang-tidy/modernize-use-auto-cast.cpp

Index: test/clang-tidy/modernize-use-auto-cast.cpp
===
--- test/clang-tidy/modernize-use-auto-cast.cpp
+++ test/clang-tidy/modernize-use-auto-cast.cpp
@@ -138,3 +138,86 @@
   B b;
   A a = A(b);
 }
+
+class StringRef
+{
+public:
+  StringRef(const char *);
+};
+
+template 
+T template_value_cast(const U );
+
+template 
+T *template_pointer_cast(U *u);
+
+template 
+T _reference_cast(U );
+
+template 
+const T *template_const_pointer_cast(const U *u);
+
+template 
+const T _const_reference_cast(const U );
+
+template 
+T template_value_get(StringRef s);
+
+struct S {
+  template 
+  const T *template_member_get();
+};
+
+template 
+T max(T t1, T t2);
+
+void f_template_cast()
+{
+  double d = 0;
+  int i1 = template_value_cast(d);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
+  // CHECK-FIXES: auto i1 = template_value_cast(d);
+
+  A *a = new B();
+  B *b1 = template_value_cast(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *b1 = template_value_cast(a);
+  B  = template_value_cast(*a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
+  // CHECK-FIXES: auto  = template_value_cast(*a);
+  B *b3 = template_pointer_cast(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *b3 = template_pointer_cast(a);
+  B  = template_reference_cast(*a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
+  // CHECK-FIXES: auto  = template_reference_cast(*a);
+  const B *b5 = template_const_pointer_cast(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a template cast to avoid duplicating the type name
+  // CHECK-FIXES: const auto *b5 = template_const_pointer_cast(a);
+  const B  = template_const_reference_cast(*a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a template cast to avoid duplicating the type name
+  // CHECK-FIXES: const auto  = template_const_reference_cast(*a);
+  B *b7 = template_value_get("foo");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *b7 = template_value_get("foo");
+  B *b8 = template_value_get("foo"), *b9 = template_value_get("bar");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *b8 = template_value_get("foo"), *b9 = template_value_get("bar");
+
+  S s;
+  const B *b10 = s.template_member_get();
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a template cast to avoid duplicating the type name
+  // CHECK-FIXES: const auto *b10 = s.template_member_get();
+
+  // Don't warn when auto is already being used.
+  auto i2 = template_value_cast(d);
+
+  // Don't warn for implicit template arguments.
+  int i3 = max(i1, i2);
+
+  // Don't warn for mismatched var and initializer types.
+  A *a1 = template_value_cast(a);
+
+  // Don't warn for mismatched var types.
+  B *b11 = template_value_get("foo"), b12 = template_value_get("bar");
+}
Index: test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp
===
--- test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp
+++ test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp
@@ -44,7 +44,7 @@
 
   const B *b3 = static_cast(a);
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a cast to avoid duplicating the type name
-  // CHECK-FIXES: auto b3 = static_cast(a);
+  // CHECK-FIXES: const auto b3 = static_cast(a);
 
   B  = static_cast(*a);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
@@ -58,6 +58,9 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
   // CHECK-FIXES: auto   = static_cast(*a),  = static_cast(*a);
 
+  // Don't warn when non-cast involved
+  long double cast = static_cast(l), noncast = 5;
+
   // Don't warn when auto is already being used.
   

[PATCH] D27744: Create SampleProfileLoader pass in llvm instead of clang

2016-12-14 Thread Diego Novillo via Phabricator via cfe-commits
dnovillo accepted this revision.
dnovillo added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D27744



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


[PATCH] D27166: [clang-tidy] Enhance modernize-use-auto to templated function casts

2016-12-14 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D27166#622103, @Prazek wrote:

> There is still one more problem:
>
>   /home/prazek/llvm/lib/Analysis/ScalarEvolution.cpp:2442:11: warning: use 
> auto when initializing with a template cast to avoid duplicating the type 
> name [modernize-use-auto]
> const auto **O = SCEVAllocator.Allocate(Ops.size());
>   ^
>   auto 


Any suggestions for rewriting this matcher?

  // Skip declarations that are already using auto.
  unless(has(varDecl(anyOf(hasType(autoType()),
   hasType(pointerType(pointee(autoType(,
   hasType(referenceType(pointee(autoType(

> There is also problem with function pointers
> 
>   /home/prazek/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp:520:9: warning: use 
> auto when initializing with a cast to avoid duplicating the type name 
> [modernize-use-auto]
> int (*PF)(int, char **, const char **) =
> ^
> auto  
>   
>  

The warning is correct, but the fixit is wrong.
Suppress fixit for function pointers?


https://reviews.llvm.org/D27166



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


[PATCH] D27754: [clang-format] Implement comment reflowing (again).

2016-12-14 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: lib/Format/BreakableToken.cpp:471
+   WhitespaceManager ) 
{
+  if (Tok.is(TT_LineComment)) {
+// If this is the first line of a token, inform Whitespace Manager about 
it.

Without looking into this in a lot of detail: this looks like you want a 
BreakableComment base class, and have BreakableBlockComment and 
BreakableLineCommentSection derive from it and implement this method.

Scanning it a bit, it seems like there is still overlap - perhaps it's also 
possible to pull out a couple of smaller sized methods in the interface and 
write the algorithm in terms of those? That could also make it easier to 
understand in general (large method alarm ;)



Comment at: lib/Format/ContinuationIndenter.cpp:1174-1175
LineIndex != EndIndex; ++LineIndex) {
-if (!DryRun)
-  Token->replaceWhitespaceBefore(LineIndex, Whitespaces);
+Token->replaceWhitespaceBefore(LineIndex, RemainingTokenColumns,
+   RemainingSpace, DryRun, Whitespaces);
 unsigned TailOffset = 0;

Nice that this whole section required so few changes.
Why do we need to call into this in DryRun mode now, though? Does it need to 
keep state inside in DryRun?


https://reviews.llvm.org/D27754



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


[PATCH] D27166: [clang-tidy] Enhance modernize-use-auto to templated function casts

2016-12-14 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added a comment.

There is still one more problem:

  /home/prazek/llvm/lib/Analysis/ScalarEvolution.cpp:2442:11: warning: use auto 
when initializing with a template cast to avoid duplicating the type name 
[modernize-use-auto]
const auto **O = SCEVAllocator.Allocate(Ops.size());
  ^
  auto 

The same thing for normal casts, so I guess it is not only problem with this 
patch

  /home/prazek/llvm/lib/IR/User.cpp:156:3: warning: use auto when initializing 
with a cast to avoid duplicating the type name [modernize-use-auto]
  auto **HungOffOperandList = static_cast(Storage);
  ^
  auto 

There is also problem with function pointers

  /home/prazek/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp:520:9: warning: use 
auto when initializing with a cast to avoid duplicating the type name 
[modernize-use-auto]
int (*PF)(int, char **, const char **) =
^
auto

 

So these problems occur for cast like functions and for cast. Do you see simple 
fix for it?


https://reviews.llvm.org/D27166



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


  1   2   >