Re: [PATCH] D22470: [libcxx] Improve shared_ptr dtor performance

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

LGTM. Thank you for the thorough doc. It sure made the review easy on my end.

I took the liberty of rewriting your 3 benchmarks to use Google Benchmark: 
https://gist.github.com/EricWF/6ab9d3ca9315f2dcf8b0b8a7e47a9ac8
I'm hoping to have a singular benchmark format so it's easier to write tooling 
for. Here are the docs for building libc++'s benchmarks. 



https://reviews.llvm.org/D22470



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


[libcxx] r276608 - Remove use of C++1z static assert in C++11 test

2016-07-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 24 23:56:32 2016
New Revision: 276608

URL: http://llvm.org/viewvc/llvm-project?rev=276608&view=rev
Log:
Remove use of C++1z static assert in C++11 test

Modified:

libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/special_member_generation_test.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/special_member_generation_test.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/special_member_generation_test.pass.cpp?rev=276608&r1=276607&r2=276608&view=diff
==
--- 
libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/special_member_generation_test.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/special_member_generation_test.pass.cpp
 Sun Jul 24 23:56:32 2016
@@ -32,10 +32,10 @@ namespace ConstructorTest {
 template  void test() {
   using P1 = std::pair;
   using P2 = std::pair;
-  static_assert(std::is_copy_constructible::value == CanCopy);
-  static_assert(std::is_move_constructible::value == CanMove);
-  static_assert(std::is_copy_constructible::value == CanCopy);
-  static_assert(std::is_move_constructible::value == CanMove);
+  static_assert(std::is_copy_constructible::value == CanCopy, "");
+  static_assert(std::is_move_constructible::value == CanMove, "");
+  static_assert(std::is_copy_constructible::value == CanCopy, "");
+  static_assert(std::is_move_constructible::value == CanMove, "");
 };
 
 } // namespace ConstructorTest
@@ -80,10 +80,10 @@ namespace AssignmentOperatorTest {
 template  void test() {
   using P1 = std::pair;
   using P2 = std::pair;
-  static_assert(std::is_copy_assignable::value == CanCopy);
-  static_assert(std::is_move_assignable::value == CanMove);
-  static_assert(std::is_copy_assignable::value == CanCopy);
-  static_assert(std::is_move_assignable::value == CanMove);
+  static_assert(std::is_copy_assignable::value == CanCopy, "");
+  static_assert(std::is_move_assignable::value == CanMove, "");
+  static_assert(std::is_copy_assignable::value == CanCopy, "");
+  static_assert(std::is_move_assignable::value == CanMove, "");
 };
 
 } // namespace AssignmentOperatorTest


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


r276606 - [MSVCToolChain] Guard hardcoded Windows paths with LLVM_ON_WIN32

2016-07-24 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Sun Jul 24 23:47:44 2016
New Revision: 276606

URL: http://llvm.org/viewvc/llvm-project?rev=276606&view=rev
Log:
[MSVCToolChain] Guard hardcoded Windows paths with LLVM_ON_WIN32

Paths like C:/foo will never work on UNIX platforms, don't bother
implicitly adding them to the search path.

Modified:
cfe/trunk/lib/Driver/MSVCToolChain.cpp

Modified: cfe/trunk/lib/Driver/MSVCToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MSVCToolChain.cpp?rev=276606&r1=276605&r2=276606&view=diff
==
--- cfe/trunk/lib/Driver/MSVCToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/MSVCToolChain.cpp Sun Jul 24 23:47:44 2016
@@ -648,6 +648,7 @@ void MSVCToolChain::AddClangSystemInclud
 return;
   }
 
+#if defined(LLVM_ON_WIN32)
   // As a fallback, select default install paths.
   // FIXME: Don't guess drives and paths like this on Windows.
   const StringRef Paths[] = {
@@ -658,6 +659,7 @@ void MSVCToolChain::AddClangSystemInclud
 "C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Include"
   };
   addSystemIncludes(DriverArgs, CC1Args, Paths);
+#endif
 }
 
 void MSVCToolChain::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,


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


r276607 - Update test to account for r276604

2016-07-24 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Sun Jul 24 23:47:45 2016
New Revision: 276607

URL: http://llvm.org/viewvc/llvm-project?rev=276607&view=rev
Log:
Update test to account for r276604

Modified:
cfe/trunk/test/CodeGenCXX/atomicinit.cpp

Modified: cfe/trunk/test/CodeGenCXX/atomicinit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/atomicinit.cpp?rev=276607&r1=276606&r2=276607&view=diff
==
--- cfe/trunk/test/CodeGenCXX/atomicinit.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/atomicinit.cpp Sun Jul 24 23:47:45 2016
@@ -51,8 +51,8 @@ struct AtomicBoolMember {
 };
 
 // CHECK-LABEL: define void @_ZN16AtomicBoolMemberC2Eb
-// CHECK: {{zext i1.*to i8}}
-// CHECK-NEXT: store i8
+// CHECK: zext i1 {{.*}} to i8
+// CHECK: store i8
 // CHECK-NEXT: ret void
 AtomicBoolMember::AtomicBoolMember(bool b) : ab(b) { }
 


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


[libcxx] r276605 - Implement the std::pair parts of "Improving pair and tuple". Completes N4387.

2016-07-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 24 23:32:07 2016
New Revision: 276605

URL: http://llvm.org/viewvc/llvm-project?rev=276605&view=rev
Log:
Implement the std::pair parts of "Improving pair and tuple". Completes N4387.


Added:

libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/const_first_const_second_cxx03.pass.cpp

libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/const_pair_U_V_cxx03.pass.cpp

libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/not_constexpr_cxx11.fail.cpp

libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/special_member_generation_test.pass.cpp
libcxx/trunk/test/support/archetypes.hpp
Modified:
libcxx/trunk/include/__tuple
libcxx/trunk/include/tuple
libcxx/trunk/include/utility
libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/U_V.pass.cpp

libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/const_first_const_second.pass.cpp

libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp
libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp

libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/__tuple
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__tuple?rev=276605&r1=276604&r2=276605&view=diff
==
--- libcxx/trunk/include/__tuple (original)
+++ libcxx/trunk/include/__tuple Sun Jul 24 23:32:07 2016
@@ -146,6 +146,12 @@ template  class _LIBCPP_TY
 
 template  struct __tuple_like > : true_type {};
 
+template 
+class _LIBCPP_TYPE_VIS_ONLY tuple_size >
+: public integral_constant
+{
+};
+
 template 
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 typename tuple_element<_Ip, tuple<_Tp...> >::type&
@@ -431,8 +437,48 @@ struct __tuple_assignable<_Tp, _Up, true
 >
 {};
 
+
+template 
+class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, tuple<_Tp...> >
+{
+public:
+typedef typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
+};
+
+#if _LIBCPP_STD_VER > 11
+template 
+using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type;
+#endif
+
 #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
+  >;
+
+struct _LIBCPP_TYPE_VIS __check_tuple_constructor_fail {
+template 
+static constexpr bool __enable_default() { return false; }
+template 
+static constexpr bool __enable_explicit() { return false; }
+template 
+static constexpr bool __enable_implicit() { return false; }
+template 
+static constexpr bool __enable_assign() { return false; }
+};
+#endif
+
 _LIBCPP_END_NAMESPACE_STD
 
 #endif  // _LIBCPP___TUPLE

Modified: libcxx/trunk/include/tuple
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/tuple?rev=276605&r1=276604&r2=276605&view=diff
==
--- libcxx/trunk/include/tuple (original)
+++ libcxx/trunk/include/tuple Sun Jul 24 23:32:07 2016
@@ -150,27 +150,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 #ifndef _LIBCPP_HAS_NO_VARIADICS
 
-// tuple_size
-
-template 
-class _LIBCPP_TYPE_VIS_ONLY tuple_size >
-: public integral_constant
-{
-};
-
-// tuple_element
-
-template 
-class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, tuple<_Tp...> >
-{
-public:
-typedef typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
-};
-
-#if _LIBCPP_STD_VER > 11
-template 
-using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type;
-#endif
 
 // __tuple_leaf
 
@@ -489,27 +468,7 @@ struct __tuple_impl<__tuple_indices<_Ind
 }
 };
 
-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
-  >;
-
-
-struct _LIBCPP_TYPE_VIS __check_tuple_constructor_fail {
-template 
-static constexpr bool __enable_explicit() { return false; }
-template 
-static constexpr bool __enable_implicit() { return false; }
-};
 
 template 
 class _LIBCPP_TYPE_VIS_ONLY tuple
@@ -532,6 +491,11 @@ class _LIBCPP_TYPE_VIS_ONLY tuple
 struct _CheckArgsConstructor
 {
 template 
+static constexpr bool __enable_default() {
+return __all::value...>::value;
+}
+
+template 
 static constexpr

Re: [PATCH] D22691: [OpenMP] Codegen for use_device_ptr clause.

2016-07-24 Thread Alexey Bataev via cfe-commits
ABataev requested changes to this revision.
This revision now requires changes to proceed.


Comment at: include/clang/AST/OpenMPClause.h:4252
@@ -4237,1 +4251,3 @@
+
+  /// \brief Build clause with number of variables \a NumVars.
   ///

No \brief


Comment at: include/clang/AST/OpenMPClause.h:4272
@@ -4247,3 +4271,3 @@
 
   /// \brief Build an empty clause.
   ///

Remove \brief


Comment at: include/clang/AST/OpenMPClause.h:4289-4309
@@ +4288,23 @@
+
+  /// \brief Sets the list of references to private copies with initializers 
for
+  /// new private variables.
+  /// \param VL List of references.
+  void setPrivateCopies(ArrayRef VL);
+
+  /// \brief Gets the list of references to private copies with initializers 
for
+  /// new private variables.
+  MutableArrayRef getPrivateCopies() {
+return MutableArrayRef(varlist_end(), varlist_size());
+  }
+  ArrayRef getPrivateCopies() const {
+return llvm::makeArrayRef(varlist_end(), varlist_size());
+  }
+
+  /// \brief Sets the list of references to initializer variables for new
+  /// private variables.
+  /// \param VL List of references.
+  void setInits(ArrayRef VL);
+
+  /// \brief Gets the list of references to initializer variables for new
+  /// private variables.
+  MutableArrayRef getInits() {

No \brief


Comment at: include/clang/AST/OpenMPClause.h:4318
@@ -4257,3 +4317,3 @@
 public:
-  /// Creates clause with a list of variables \a VL.
+  /// \brief Creates clause with a list of variables \a Vars.
   ///

Do not add \brief


Comment at: include/clang/AST/OpenMPClause.h:4336
@@ -4270,1 +4335,3 @@
+
+  /// \brief Creates an empty clause with the place for \a NumVars variables.
   ///

Do not add \brief


Comment at: lib/CodeGen/CGStmtOpenMP.cpp:3410-3411
@@ +3409,4 @@
+  llvm::DenseSet EmittedAsFirstprivate;
+  CGCapturedStmtInfo CapturesInfo(cast(*D.getAssociatedStmt()));
+  for (const auto *C : D.getClausesOfKind()) {
+auto OrigVarIt = C->varlist_begin();

EmitOMPUseDevicePtrClause() should emit the code for single clause. The outer 
loop must be used in directive emission function.


Comment at: lib/CodeGen/CGStmtOpenMP.cpp:3477-3495
@@ +3476,21 @@
+  // Codegen with device pointer privatization.
+  auto &&PvtCodeGen = [&S, &Info](CodeGenFunction &CGF, PrePostActionTy &) {
+auto &&CodeGen = [&S, &Info](CodeGenFunction &CGF, PrePostActionTy &) {
+  OMPPrivateScope PrivateScope(CGF);
+  CGF.EmitOMPUseDevicePtrClause(S, PrivateScope, 
Info.CaptureDeviceAddrMap);
+  (void)PrivateScope.Privatize();
+  CGF.EmitStmt(
+  cast(S.getAssociatedStmt())->getCapturedStmt());
+};
+// Notwithstanding the body of the region is emitted as inlined directive,
+// we don't use an inline scope as changes in the references inside the
+// region are expected to be visible outside, so we do not privative them.
+OMPLexicalScope Scope(CGF, S);
+CGF.CGM.getOpenMPRuntime().emitInlinedDirective(CGF, OMPD_target_data,
+CodeGen);
+  };
+
+  // Codegen with no device pointer privatization.
+  auto &&NoPvtCodeGen = [&S, &Info](CodeGenFunction &CGF, PrePostActionTy &) {
+auto &&CodeGen = [&S, &Info](CodeGenFunction &CGF, PrePostActionTy &) {
+  CGF.EmitStmt(

PvtCodeGen and NoPvtCodeGen are pretty similar. Could you merge them somehow 
into the one? Maybe some custom PrePostAction could be used here?


Comment at: lib/Sema/SemaOpenMP.cpp:11858
@@ +11857,3 @@
+// similar properties of a first private variable.
+DSAStack->addDSA(D, RefExpr->IgnoreParens(), OMPC_firstprivate, Ref);
+

Are the restrictions for firstprivates applied also? What if inner directive 
has some clauses that cannot be used with variables previously marked as 
firstprivates, but can be used with variables, used in use_device_ptr?


https://reviews.llvm.org/D22691



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


Re: [PATCH] D20795: Added basic capabilities to detect source code clones.

2016-07-24 Thread Raphael Isemann via cfe-commits
teemperor marked 9 inline comments as done.


Comment at: include/clang/AST/CloneDetection.h:149
@@ +148,3 @@
+/// (e.g. function bodies). Other clones (e.g. cloned comments or declarations)
+/// are not supported.
+///

Put the idea on the future TODO list, but we probably can't reuse a big part of 
the current infrastructure for it.


https://reviews.llvm.org/D20795



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


Re: [PATCH] D20795: Added basic capabilities to detect source code clones.

2016-07-24 Thread Raphael Isemann via cfe-commits
teemperor updated this revision to Diff 65291.
teemperor added a comment.

Ok, so I think I've addressed the points from last meeting in this patch:

It was planned to replace custom hashing with FoldingSetNodeID and a hashmap: 
In this patch I removed all custom hashing. It's now done via LLVM's StringMap 
and strings which brings the same functionality. Using FoldingSetNodeID is not 
possible because it hides it's internal data vector which StringMap doesn't 
support, so I've just used a normal vector instead.

It was also planned to refactor CloneSignatureCache: In this patch I've 
completely removed the cache because it is no longer necessary. Fixing it was 
not an option because we assumed that the statements RecursiveASTVisitor visits 
are the same that Stmt::children() delivers, which is for example for 
LambdaExprs not true (and RecursiveASTVisitor makes no promise about that in 
it's API). The only sensible fix for this was to use Artem's initial suggestion 
to not use RecursiveASTVisitor to traverse statements.

I've also adressed Artems and Vassils comments regarding documentation and code 
style in this patch (Thanks!).


https://reviews.llvm.org/D20795

Files:
  include/clang/Analysis/CloneDetection.h
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/Analysis/CMakeLists.txt
  lib/Analysis/CloneDetection.cpp
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/CloneChecker.cpp
  test/Analysis/copypaste/test-min-max.cpp
  test/Analysis/copypaste/test-sub-sequences.cpp

Index: test/Analysis/copypaste/test-sub-sequences.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-sub-sequences.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// We test if sub-sequences can match with normal sequences containing only
+// a single statement.
+
+void log2(int a);
+void log();
+
+int max(int a, int b) {
+  log2(a);
+  log(); // expected-warning{{Detected code clone.}}
+  if (a > b)
+return a;
+  return b;
+}
+
+int maxClone(int a, int b) {
+  log(); // expected-note{{Related code clone is here.}}
+  if (a > b)
+return a;
+  return b;
+}
+
+// Functions below are not clones and should not be reported.
+
+int foo(int a, int b) { // no-warning
+  return a + b;
+}
Index: test/Analysis/copypaste/test-min-max.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-min-max.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+void log();
+
+int max(int a, int b) { // expected-warning{{Detected code clone.}}
+  log();
+  if (a > b)
+return a;
+  return b;
+}
+
+int maxClone(int x, int y) { // expected-note{{Related code clone is here.}}
+  log();
+  if (x > y)
+return x;
+  return y;
+}
+
+// False positives below. These clones should not be reported.
+
+// FIXME: Detect different binary operator kinds.
+int min1(int a, int b) { // expected-note{{Related code clone is here.}}
+  log();
+  if (a < b)
+return a;
+  return b;
+}
+
+// FIXME: Detect different variable patterns.
+int min2(int a, int b) { // expected-note{{Related code clone is here.}}
+  log();
+  if (b > a)
+return a;
+  return b;
+}
+
+// Functions below are not clones and should not be reported.
+
+int foo(int a, int b) { // no-warning
+  return a + b;
+}
Index: lib/StaticAnalyzer/Checkers/CloneChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/CloneChecker.cpp
@@ -0,0 +1,85 @@
+//===--- CloneChecker.cpp - Clone detection checker -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// CloneChecker is a checker that reports clones in the current translation
+/// unit.
+///
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/Analysis/CloneDetection.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+class CloneChecker : public Checker {
+
+public:
+  void checkEndOfTranslationUnit(const TranslationUnitDecl *TU,
+ AnalysisManager &Mgr, BugReporter &BR) const;
+};
+} // end anonymous namespace
+
+void CloneChecker::checkEndOfTranslationUnit(const TranslationUnitDecl *TU,
+ AnalysisManager &Mgr,
+ BugR

Re: [PATCH] D22690: [OpenMP] Add support for mapping array sections through pointer references.

2016-07-24 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG with a nit



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:5280
@@ -5279,5 +5279,3 @@
 BP = CGF.EmitLoadOfPointerLValue(PtrAddr.getAddress(),
- I->getAssociatedDeclaration()
- ->getType()
- ->getAs())
+ Ty->getAs())
  .getPointer();

getAs -> castAs


https://reviews.llvm.org/D22690



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


[libcxx] r276603 - Recommit r276548 - Make pair/tuples assignment operators SFINAE properly.

2016-07-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 24 21:36:42 2016
New Revision: 276603

URL: http://llvm.org/viewvc/llvm-project?rev=276603&view=rev
Log:
Recommit r276548 - Make pair/tuples assignment operators SFINAE properly.

I think I've solved issues with is_assignable and references to incomplete
types. The updated patch adds tests for this case.


Added:

libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/assign_pair.pass.cpp

libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/assign_pair_cxx03.pass.cpp
Modified:
libcxx/trunk/include/tuple
libcxx/trunk/include/utility
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp

libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair.pass.cpp

Modified: libcxx/trunk/include/tuple
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/tuple?rev=276603&r1=276602&r2=276603&view=diff
==
--- libcxx/trunk/include/tuple (original)
+++ libcxx/trunk/include/tuple Sun Jul 24 21:36:42 2016
@@ -647,6 +647,9 @@ public:
 _LIBCPP_CONSTEXPR tuple()
 
_NOEXCEPT_(__all::value...>::value) {}
 
+tuple(tuple const&) = default;
+tuple(tuple&&) = default;
+
 template ,
@@ -885,6 +888,25 @@ public:
 tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
 : base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
 
+using _CanCopyAssign = __all::value...>;
+using _CanMoveAssign = __all::value...>;
+
+_LIBCPP_INLINE_VISIBILITY
+tuple& operator=(typename conditional<_CanCopyAssign::value, tuple, 
__nat>::type const& __t)
+_NOEXCEPT_((__all::value...>::value))
+{
+base_.operator=(__t.base_);
+return *this;
+}
+
+_LIBCPP_INLINE_VISIBILITY
+tuple& operator=(typename conditional<_CanMoveAssign::value, tuple, 
__nat>::type&& __t)
+_NOEXCEPT_((__all::value...>::value))
+{
+base_.operator=(static_cast(__t.base_));
+return *this;
+}
+
 template http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/utility?rev=276603&r1=276602&r2=276603&view=diff
==
--- libcxx/trunk/include/utility (original)
+++ libcxx/trunk/include/utility Sun Jul 24 21:36:42 2016
@@ -348,8 +348,23 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
   // Use the implicitly declared copy constructor in C++03
 #endif
 
+#if !defined(_LIBCPP_CXX03_LANG)
+typedef typename conditional<
+   is_copy_assignable<_T1>::value
+&& is_copy_assignable<_T2>::value,
+pair, __nat
+>::type _CopyAssignT;
+typedef typename conditional<
+   is_move_assignable<_T1>::value
+&& is_move_assignable<_T2>::value,
+pair, __nat
+>::type _MoveAssignT;
+#else
+typedef pair _CopyAssignT;
+#endif
+
 _LIBCPP_INLINE_VISIBILITY
-pair& operator=(const pair& __p)
+pair& operator=(_CopyAssignT const& __p)
 _NOEXCEPT_(is_nothrow_copy_assignable::value &&
is_nothrow_copy_assignable::value)
 {
@@ -358,6 +373,18 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
 return *this;
 }
 
+#ifndef _LIBCPP_CXX03_LANG
+_LIBCPP_INLINE_VISIBILITY
+pair& operator=(_MoveAssignT&& __p)
+_NOEXCEPT_(is_nothrow_move_assignable::value &&
+   is_nothrow_move_assignable::value)
+{
+first = _VSTD::forward(__p.first);
+second = _VSTD::forward(__p.second);
+return *this;
+}
+#endif
+
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template (__p.first)),
   second(_VSTD::forward<_U2>(__p.second)) {}
 
-_LIBCPP_INLINE_VISIBILITY
-pair&
-operator=(pair&& __p) 
_NOEXCEPT_(is_nothrow_move_assignable::value &&
- 
is_nothrow_move_assignable::value)
-{
-first = _VSTD::forward(__p.first);
-second = _VSTD::forward(__p.second);
-return *this;
-}
 
-#ifndef _LIBCPP_HAS_NO_VARIADICS
 
+#ifndef _LIBCPP_HAS_NO_VARIADICS
 template::value>::type>
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
@@ -411,7 +429,7 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
 {}
 
 template ::value>::type>
+  class = typename enable_if::type, pair>::value && __tuple_assignable<_Tuple, 
pair>::value>::type>
 _LIBCPP_INLINE_VISIBILITY
 pair&
 operator=(_Tuple&& __p)

Modified: 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp?rev=276603&r1=276602&r2=276603&view=diff
==
--- 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp 
(original)
+++

[libcxx] r276599 - Make std::is_assignable tolerate references to incomplete types.

2016-07-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 24 21:08:55 2016
New Revision: 276599

URL: http://llvm.org/viewvc/llvm-project?rev=276599&view=rev
Log:
Make std::is_assignable tolerate references to incomplete types.

Modified:
libcxx/trunk/include/type_traits

libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp

Modified: libcxx/trunk/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=276599&r1=276598&r2=276599&view=diff
==
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Sun Jul 24 21:08:55 2016
@@ -2036,26 +2036,15 @@ template struct
 
 template 
 typename __select_2nd() = 
_VSTD::declval<_Arg>())), true_type>::type
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-__is_assignable_test(_Tp&&, _Arg&&);
-#else
-__is_assignable_test(_Tp, _Arg&);
-#endif
+__is_assignable_test(int);
+
+template 
+false_type __is_assignable_test(...);
 
-template 
-false_type
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-__is_assignable_test(__any, _Arg&&);
-#else
-__is_assignable_test(__any, _Arg&);
-#endif
 
 template ::value || 
is_void<_Arg>::value>
 struct __is_assignable_imp
-: public common_type
-<
-decltype(_VSTD::__is_assignable_test(declval<_Tp>(), 
declval<_Arg>()))
->::type {};
+: public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {};
 
 template 
 struct __is_assignable_imp<_Tp, _Arg, true>

Modified: 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp?rev=276599&r1=276598&r2=276599&view=diff
==
--- 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp
 Sun Jul 24 21:08:55 2016
@@ -43,7 +43,7 @@ void test_is_not_assignable()
 
 struct D;
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if TEST_STD_VER >= 11
 struct C
 {
 template 
@@ -59,6 +59,8 @@ struct E
 template 
 struct X { T t; };
 
+struct Incomplete;
+
 int main()
 {
 test_is_assignable ();
@@ -67,7 +69,7 @@ int main()
 test_is_assignable ();
 test_is_assignable ();
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if TEST_STD_VER >= 11
 test_is_assignable ();
 
 test_is_not_assignable ();
@@ -80,4 +82,5 @@ int main()
 
 //  pointer to incomplete template type
test_is_assignable*&, X*> ();
+test_is_not_assignable();
 }


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


[libcxx] r276598 - Revert r276548 - Make pair/tuples assignment operators SFINAE properly.

2016-07-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 24 20:45:07 2016
New Revision: 276598

URL: http://llvm.org/viewvc/llvm-project?rev=276598&view=rev
Log:
Revert r276548 - Make pair/tuples assignment operators SFINAE properly.

This is a breaking change. The SFINAE required is instantiated the second
the class is instantiated, and this can cause hard SFINAE errors
when applied to references to incomplete types. Ex.

struct IncompleteType;
extern IncompleteType it;
std::tuple t(it); // SFINAE will blow up.



Removed:

libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/assign_pair.pass.cpp

libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/assign_pair_cxx03.pass.cpp
Modified:
libcxx/trunk/include/tuple
libcxx/trunk/include/utility
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp

libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair.pass.cpp

Modified: libcxx/trunk/include/tuple
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/tuple?rev=276598&r1=276597&r2=276598&view=diff
==
--- libcxx/trunk/include/tuple (original)
+++ libcxx/trunk/include/tuple Sun Jul 24 20:45:07 2016
@@ -647,9 +647,6 @@ public:
 _LIBCPP_CONSTEXPR tuple()
 
_NOEXCEPT_(__all::value...>::value) {}
 
-tuple(tuple const&) = default;
-tuple(tuple&&) = default;
-
 template ,
@@ -888,25 +885,6 @@ public:
 tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
 : base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
 
-using _CanCopyAssign = __all::value...>;
-using _CanMoveAssign = __all::value...>;
-
-_LIBCPP_INLINE_VISIBILITY
-tuple& operator=(typename conditional<_CanCopyAssign::value, tuple, 
__nat>::type const& __t)
-_NOEXCEPT_((__all::value...>::value))
-{
-base_.operator=(__t.base_);
-return *this;
-}
-
-_LIBCPP_INLINE_VISIBILITY
-tuple& operator=(typename conditional<_CanMoveAssign::value, tuple, 
__nat>::type&& __t)
-_NOEXCEPT_((__all::value...>::value))
-{
-base_.operator=(static_cast(__t.base_));
-return *this;
-}
-
 template http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/utility?rev=276598&r1=276597&r2=276598&view=diff
==
--- libcxx/trunk/include/utility (original)
+++ libcxx/trunk/include/utility Sun Jul 24 20:45:07 2016
@@ -348,19 +348,8 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
   // Use the implicitly declared copy constructor in C++03
 #endif
 
-typedef typename remove_reference<_T1>::type _T1Unref;
-typedef typename remove_reference<_T2>::type _T2Unref;
-
-#if !defined(_LIBCPP_CXX03_LANG)
-typedef integral_constant::value
-&& is_copy_assignable<_T2>::value> _CanCopyAssign;
-#else
-typedef true_type _CanCopyAssign;
-#endif
-
 _LIBCPP_INLINE_VISIBILITY
-pair& operator=(typename conditional<_CanCopyAssign::value, pair, 
__nat>::type const& __p)
+pair& operator=(const pair& __p)
 _NOEXCEPT_(is_nothrow_copy_assignable::value &&
is_nothrow_copy_assignable::value)
 {
@@ -388,15 +377,10 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
 : first(_VSTD::forward<_U1>(__p.first)),
   second(_VSTD::forward<_U2>(__p.second)) {}
 
-typedef integral_constant::value
-&& is_move_assignable<_T2>::value> _CanMoveAssign;
-
 _LIBCPP_INLINE_VISIBILITY
 pair&
-operator=(typename conditional<_CanMoveAssign::value, pair, __nat>::type&& 
__p)
-_NOEXCEPT_(is_nothrow_move_assignable::value &&
-   is_nothrow_move_assignable::value)
+operator=(pair&& __p) 
_NOEXCEPT_(is_nothrow_move_assignable::value &&
+ 
is_nothrow_move_assignable::value)
 {
 first = _VSTD::forward(__p.first);
 second = _VSTD::forward(__p.second);
@@ -404,6 +388,7 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
 }
 
 #ifndef _LIBCPP_HAS_NO_VARIADICS
+
 template::value>::type>
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
@@ -426,7 +411,7 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
 {}
 
 template ::type, pair>::value && __tuple_assignable<_Tuple, 
pair>::value>::type>
+  class = typename enable_if<__tuple_assignable<_Tuple, 
pair>::value>::type>
 _LIBCPP_INLINE_VISIBILITY
 pair&
 operator=(_Tuple&& __p)

Modified: 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp?rev=276598&r1=276597&r2=276598&view=diff
==
--- 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/co

Re: [PATCH] D21717: [libcxx] [test] Make dtor_noexcept.pass.cpp tests more portable.

2016-07-24 Thread Eric Fiselier via cfe-commits
EricWF closed this revision.
EricWF added a comment.

r276595


https://reviews.llvm.org/D21717



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


[libcxx] r276595 - Make dtor_noexcept.pass.cpp tests more portable. Patch from s...@microsoft.com

2016-07-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 24 19:50:32 2016
New Revision: 276595

URL: http://llvm.org/viewvc/llvm-project?rev=276595&view=rev
Log:
Make dtor_noexcept.pass.cpp tests more portable. Patch from s...@microsoft.com

Modified:

libcxx/trunk/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp

libcxx/trunk/test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp

libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp

libcxx/trunk/test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp

libcxx/trunk/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp

libcxx/trunk/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp

Modified: 
libcxx/trunk/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp?rev=276595&r1=276594&r2=276595&view=diff
==
--- 
libcxx/trunk/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp
 Sun Jul 24 19:50:32 2016
@@ -16,6 +16,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "MoveOnly.h"
 #include "test_allocator.h"
 
@@ -44,6 +45,6 @@ int main()
 }
 {
 typedef std::map> C;
-static_assert(!std::is_nothrow_destructible::value, "");
+LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible::value, "");
 }
 }

Modified: 
libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp?rev=276595&r1=276594&r2=276595&view=diff
==
--- 
libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp
 Sun Jul 24 19:50:32 2016
@@ -16,6 +16,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "MoveOnly.h"
 #include "test_allocator.h"
 
@@ -44,6 +45,6 @@ int main()
 }
 {
 typedef std::multimap> C;
-static_assert(!std::is_nothrow_destructible::value, "");
+LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible::value, "");
 }
 }

Modified: 
libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp?rev=276595&r1=276594&r2=276595&view=diff
==
--- 
libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp
 Sun Jul 24 19:50:32 2016
@@ -16,6 +16,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "MoveOnly.h"
 #include "test_allocator.h"
 
@@ -43,6 +44,6 @@ int main()
 }
 {
 typedef std::multiset> C;
-static_assert(!std::is_nothrow_destructible::value, "");
+LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible::value, "");
 }
 }

Modified: 
libcxx/trunk/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp?rev=276595&r1=276594&r2=276595&view=diff
==
--- 
libcxx/trunk/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp
 Sun Jul 24 19:50:32 2016
@@ -16,6 +16,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "MoveOnly.h"
 #include "test_allocator.h"
 
@@ -43,6 +44,6 @@ int main()
 }
 {
 typedef s

Re: [PATCH] D21717: [libcxx] [test] Make dtor_noexcept.pass.cpp tests more portable.

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

I think I'm happy with libc++'s behavior of automatically deducing the dtor 
exception specification. This patch LGTM.


https://reviews.llvm.org/D21717



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


[libcxx] r276594 - Don't SFINAE pair's copy assignment operator in C++03 mode.

2016-07-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 24 19:48:36 2016
New Revision: 276594

URL: http://llvm.org/viewvc/llvm-project?rev=276594&view=rev
Log:
Don't SFINAE pair's copy assignment operator in C++03 mode.

In C++03 mode evaluating the SFINAE can cause a hard error due to
access control violations. This is a problem because the SFINAE
is evaluated as soon as the class is instantiated, and not later.



Added:

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

Modified: libcxx/trunk/include/utility
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/utility?rev=276594&r1=276593&r2=276594&view=diff
==
--- libcxx/trunk/include/utility (original)
+++ libcxx/trunk/include/utility Sun Jul 24 19:48:36 2016
@@ -351,9 +351,13 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
 typedef typename remove_reference<_T1>::type _T1Unref;
 typedef typename remove_reference<_T2>::type _T2Unref;
 
+#if !defined(_LIBCPP_CXX03_LANG)
 typedef integral_constant::value
 && is_copy_assignable<_T2>::value> _CanCopyAssign;
+#else
+typedef true_type _CanCopyAssign;
+#endif
 
 _LIBCPP_INLINE_VISIBILITY
 pair& operator=(typename conditional<_CanCopyAssign::value, pair, 
__nat>::type const& __p)

Added: 
libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/assign_pair_cxx03.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/assign_pair_cxx03.pass.cpp?rev=276594&view=auto
==
--- 
libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/assign_pair_cxx03.pass.cpp
 (added)
+++ 
libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/assign_pair_cxx03.pass.cpp
 Sun Jul 24 19:48:36 2016
@@ -0,0 +1,36 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// REQUIRES-ANY: c++98, c++03
+
+// 
+
+// template  struct pair
+
+// pair& operator=(pair const& p);
+
+#include 
+#include 
+#include 
+
+
+struct NonAssignable {
+  NonAssignable() {}
+private:
+  NonAssignable& operator=(NonAssignable const&);
+};
+
+int main()
+{
+// Test that we don't constrain the assignment operator in C++03 mode.
+// Since we don't have access control SFINAE having pair evaluate SFINAE
+// may cause a hard error.
+typedef std::pair P;
+static_assert(std::is_copy_assignable::value, "");
+}


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


Re: [PATCH] D22162: [libcxx] [test] Mark bucket_count() equality assertions as nonportable.

2016-07-24 Thread Eric Fiselier via cfe-commits
EricWF closed this revision.
EricWF added a comment.

r276593.


https://reviews.llvm.org/D22162



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


Re: [PATCH] D22162: [libcxx] [test] Mark bucket_count() equality assertions as nonportable.

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

It's not great that our tests have so many non-portable assertions. Normally we 
want to avoid writing non-standard assertions at all, but there doesn't seem to 
be a way around it here.
However there's no easy way to fix that here, so thank you for making all these 
tests portable.

I wish there weren't so many changes though :-(


https://reviews.llvm.org/D22162



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


Re: [PATCH] D21718: [libcxx] [test] Make move_assign_noexcept.pass.cpp tests more portable.

2016-07-24 Thread Eric Fiselier via cfe-commits
EricWF closed this revision.
EricWF added a comment.

r276591.


https://reviews.llvm.org/D21718



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


[libcxx] r276591 - Make move_assign_noexcept.pass.cpp tests more portable. Patch from s...@microsoft.com

2016-07-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 24 19:18:12 2016
New Revision: 276591

URL: http://llvm.org/viewvc/llvm-project?rev=276591&view=rev
Log:
Make move_assign_noexcept.pass.cpp tests more portable. Patch from 
s...@microsoft.com

Modified:

libcxx/trunk/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp

libcxx/trunk/test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp

libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp

libcxx/trunk/test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp

libcxx/trunk/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp

Modified: 
libcxx/trunk/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp?rev=276591&r1=276590&r2=276591&view=diff
==
--- 
libcxx/trunk/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp
 Sun Jul 24 19:18:12 2016
@@ -22,6 +22,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "MoveOnly.h"
 #include "test_allocator.h"
 
@@ -46,7 +47,7 @@ int main()
 }
 {
 typedef std::map, 
other_allocator> C;
-static_assert(std::is_nothrow_move_assignable::value, "");
+LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable::value, "");
 }
 {
 typedef std::map> C;

Modified: 
libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp?rev=276591&r1=276590&r2=276591&view=diff
==
--- 
libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp
 Sun Jul 24 19:18:12 2016
@@ -22,6 +22,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "MoveOnly.h"
 #include "test_allocator.h"
 
@@ -46,7 +47,7 @@ int main()
 }
 {
 typedef std::multimap, 
other_allocator> C;
-static_assert(std::is_nothrow_move_assignable::value, "");
+LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable::value, "");
 }
 {
 typedef std::multimap> C;

Modified: 
libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp?rev=276591&r1=276590&r2=276591&view=diff
==
--- 
libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp
 Sun Jul 24 19:18:12 2016
@@ -22,6 +22,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "MoveOnly.h"
 #include "test_allocator.h"
 
@@ -45,7 +46,7 @@ int main()
 }
 {
 typedef std::multiset, 
other_allocator> C;
-static_assert(std::is_nothrow_move_assignable::value, "");
+LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable::value, "");
 }
 {
 typedef std::multiset> C;

Modified: 
libcxx/trunk/test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp?rev=276591&r1=276590&r2=276591&view=diff
==
--- 
libcxx/trunk/test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp

[libcxx] r276590 - Make swap_noexcept.pass.cpp tests more portable. Patch from s...@microsoft.com.

2016-07-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 24 19:15:29 2016
New Revision: 276590

URL: http://llvm.org/viewvc/llvm-project?rev=276590&view=rev
Log:
Make swap_noexcept.pass.cpp tests more portable. Patch from s...@microsoft.com.

See D21820 for more information (https://reviews.llvm.org/D21820).


Modified:

libcxx/trunk/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp

libcxx/trunk/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp

libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp

libcxx/trunk/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp

libcxx/trunk/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp

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

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp

Modified: 
libcxx/trunk/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp?rev=276590&r1=276589&r2=276590&view=diff
==
--- 
libcxx/trunk/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp
 Sun Jul 24 19:15:29 2016
@@ -22,6 +22,7 @@
 // This tests a conforming extension
 
 #include 
+#include 
 #include 
 
 #include "test_macros.h"
@@ -96,51 +97,42 @@ int main()
 typedef std::pair V;
 {
 typedef std::map C;
-C c1, c2;
-static_assert(noexcept(swap(c1, c2)), "");
+static_assert(noexcept(swap(std::declval(), std::declval())), 
"");
 }
 {
 typedef std::map, 
test_allocator> C;
-C c1, c2;
-static_assert(noexcept(swap(c1, c2)), "");
+LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), 
std::declval())), "");
 }
 {
 typedef std::map, 
other_allocator> C;
-C c1, c2;
-static_assert(noexcept(swap(c1, c2)), "");
+LIBCPP_STATIC_ASSERT(noexcept(swap(std::declval(), 
std::declval())), "");
 }
 {
 typedef std::map> C;
-C c1, c2;
-static_assert(!noexcept(swap(c1, c2)), "");
+static_assert(!noexcept(swap(std::declval(), std::declval())), 
"");
 }
 
 #if TEST_STD_VER >= 14
 { // POCS allocator, throwable swap for comp
 typedef std::map, some_alloc > 
C;
-C c1, c2;
-static_assert(!noexcept(swap(c1, c2)), "");
+static_assert(!noexcept(swap(std::declval(), std::declval())), "");
 }
 { // always equal allocator, throwable swap for comp
 typedef std::map, some_alloc2> 
C;
-C c1, c2;
-static_assert(!noexcept(swap(c1, c2)), "");
+static_assert(!noexcept(swap(std::declval(), std::declval())), "");
 }
 { // POCS allocator, nothrow swap for comp
 typedef std::map, some_alloc > 
C;
-C c1, c2;
-static_assert( noexcept(swap(c1, c2)), "");
+static_assert( noexcept(swap(std::declval(), std::declval())), "");
 }
 { // always equal allocator, nothrow swap for comp
 typedef std::map, some_alloc2> 
C;
-C c1, c2;
-static_assert( noexcept(swap(c1, c2)), "");
+static_assert( noexcept(swap(std::declval(), std::declval())), "");
 }
 
 { // NOT always equal allocator, nothrow swap for comp
 typedef std::map, some_alloc3> 
C;
-C c1, c2;
-static_assert( noexcept(swap(c1, c2)), "");
+LIBCPP_STATIC_ASSERT( noexcept(swap(std::declval(), 
std::declval())), "");
 }
 #endif
 

Modified: 
libcxx/trunk/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp?rev=276590&r1=276589&r2=276590&view=d

Re: [PATCH] D21820: [libcxx] [test] Make swap_noexcept.pass.cpp tests more portable.

2016-07-24 Thread Eric Fiselier via cfe-commits
EricWF closed this revision.
EricWF added a comment.

r276590.


https://reviews.llvm.org/D21820



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


Re: [PATCH] D21820: [libcxx] [test] Make swap_noexcept.pass.cpp tests more portable.

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

I'm not thrilled with this, but as you mentioned actually fixing this will be a 
lot of work. I opened a bug to track that work 
https://llvm.org/bugs/show_bug.cgi?id=28687.
However for now this patch LGTM.


https://reviews.llvm.org/D21820



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


Re: [PATCH] D22017: [libcxx] [test] Work around MSVC's non-Standard ABI for enums.

2016-07-24 Thread Eric Fiselier via cfe-commits
EricWF closed this revision.
EricWF added a comment.

r276589.


https://reviews.llvm.org/D22017



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


[libcxx] r276589 - Work around MSVC's non-standard ABI for enums. Patch from s...@microsoft.com

2016-07-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 24 19:02:23 2016
New Revision: 276589

URL: http://llvm.org/viewvc/llvm-project?rev=276589&view=rev
Log:
Work around MSVC's non-standard ABI for enums. Patch from s...@microsoft.com

Modified:

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

libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp

libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp?rev=276589&r1=276588&r2=276589&view=diff
==
--- 
libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp
 Sun Jul 24 19:02:23 2016
@@ -21,14 +21,19 @@ enum F { W = UINT_MAX };
 
 int main()
 {
+#if !defined(_WIN32) || defined(__MINGW32__)
+typedef unsigned ExpectUnsigned;
+#else
+typedef int ExpectUnsigned; // MSVC's ABI doesn't follow the Standard
+#endif
 static_assert((std::is_same::type, int>::value),
   "E has the wrong underlying type");
-static_assert((std::is_same::type, 
unsigned>::value),
-  "F has the wrong underlying type");
+static_assert((std::is_same::type, 
ExpectUnsigned>::value),
+  "F has the wrong underlying type"); 
 
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
 static_assert((std::is_same, int>::value), "");
-static_assert((std::is_same, unsigned>::value), 
"");
+static_assert((std::is_same, 
ExpectUnsigned>::value), ""); 
 #endif
 
 #if TEST_STD_VER >= 11
@@ -36,7 +41,7 @@ int main()
 
 static_assert((std::is_same::type, char>::value),
   "G has the wrong underlying type");
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
 static_assert((std::is_same, char>::value), "");
 #endif
 #endif // TEST_STD_VER >= 11

Modified: 
libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp?rev=276589&r1=276588&r2=276589&view=diff
==
--- 
libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp
 Sun Jul 24 19:02:23 2016
@@ -13,9 +13,15 @@
 
 #include 
 
+#include "test_macros.h"
+
 enum Enum {zero, one_};
 
+#if TEST_STD_VER >= 11
+enum BigEnum : unsigned long long // MSVC's ABI doesn't follow the Standard
+#else
 enum BigEnum
+#endif
 {
 bigzero,
 big = 0xULL

Modified: 
libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp?rev=276589&r1=276588&r2=276589&view=diff
==
--- 
libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp
 Sun Jul 24 19:02:23 2016
@@ -13,9 +13,15 @@
 
 #include 
 
+#include "test_macros.h"
+
 enum Enum {zero, one_};
 
+#if TEST_STD_VER >= 11
+enum BigEnum : unsigned long long // MSVC's ABI doesn't follow the Standard
+#else
 enum BigEnum
+#endif
 {
 bigzero,
 big = 0xULL


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


Re: [PATCH] D22017: [libcxx] [test] Work around MSVC's non-Standard ABI for enums.

2016-07-24 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

I'll check in this fix with the suggested change.


https://reviews.llvm.org/D22017



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


Re: [PATCH] D22017: [libcxx] [test] Work around MSVC's non-Standard ABI for enums.

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

> in underlying_type.pass.cpp, I'm simply marking the affected static_asserts 
> as libcxx-specific (this probably won't be sufficient when you try to get the 
> Clang/LLVM/libcxx stack running on Windows). In make_signed.pass.cpp and 
> make_unsigned.pass.cpp, I'm giving the enum an explicitly specified 
> underlying type, so the tests below can remain unaffected.


I think it would be better to check if we are on Windows, and test for the 
respected result accordingly.


https://reviews.llvm.org/D22017



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


[libcxx] r276588 - Fix a non-standard allocator in vector tests. Patch from s...@microsoft.com

2016-07-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 24 18:49:42 2016
New Revision: 276588

URL: http://llvm.org/viewvc/llvm-project?rev=276588&view=rev
Log:
Fix a non-standard allocator in vector tests. Patch from s...@microsoft.com

Modified:

libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp

Modified: 
libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp?rev=276588&r1=276587&r2=276588&view=diff
==
--- 
libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
 Sun Jul 24 18:49:42 2016
@@ -40,6 +40,9 @@ struct implicit_conv_allocator : min_all
 {
 implicit_conv_allocator(void*) {}
 implicit_conv_allocator(const implicit_conv_allocator&) = default;
+
+template 
+implicit_conv_allocator(implicit_conv_allocator) {}
 };
 
 #endif


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


Re: [PATCH] D22016: [libcxx] [test] Fix a non-Standard allocator in vector.cons/construct_iter_iter_alloc.pass.cpp.

2016-07-24 Thread Eric Fiselier via cfe-commits
EricWF closed this revision.
EricWF added a comment.

r276588.


https://reviews.llvm.org/D22016



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


[libcxx] r276587 - Fix unique_ptr.runtime tests for null inputs. Patch from s...@microsoft.com

2016-07-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 24 18:48:26 2016
New Revision: 276587

URL: http://llvm.org/viewvc/llvm-project?rev=276587&view=rev
Log:
Fix unique_ptr.runtime tests for null inputs. Patch from s...@microsoft.com

Modified:

libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp

libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp?rev=276587&r1=276586&r2=276587&view=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp
 Sun Jul 24 18:48:26 2016
@@ -16,6 +16,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 class Deleter
 {
 int state_;
@@ -36,9 +38,18 @@ int main()
 Deleter d;
 assert(d.state() == 0);
 {
+std::unique_ptr p(nullptr, d);
+assert(p.get() == 0);
+assert(&p.get_deleter() == &d);
+}
+#if defined(_LIBCPP_VERSION)
+{
+// The standard only requires the constructor accept nullptr, but libc++
+// also supports the literal 0.
 std::unique_ptr p(0, d);
 assert(p.get() == 0);
 assert(&p.get_deleter() == &d);
 }
+#endif
 assert(d.state() == 0);
 }

Modified: 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp?rev=276587&r1=276586&r2=276587&view=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp
 Sun Jul 24 18:48:26 2016
@@ -42,7 +42,9 @@ int main()
 assert(A::count == 0);
 
 { // LWG#2520 says that nullptr is a valid input as well as null
+#ifdef _LIBCPP_VERSION
 std::unique_ptr > s1(NULL, Deleter());
+#endif
 std::unique_ptr > s2(nullptr, Deleter());
 }
 assert(A::count == 0);


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


Re: [PATCH] D22014: [libcxx] [test] Follow LWG 2520 "N4089 broke initializing unique_ptr from a nullptr".

2016-07-24 Thread Eric Fiselier via cfe-commits
EricWF closed this revision.
EricWF added a comment.

r276587.


https://reviews.llvm.org/D22014



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


Re: [PATCH] D22014: [libcxx] [test] Follow LWG 2520 "N4089 broke initializing unique_ptr from a nullptr".

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

I see how the wording doesn't require supporting the literal '0', but if you 
provide a concrete 'std::nullptr_t' parameter your going to allow the 
conversion from '0'. I think this should probably be clarified in the standard. 
However I'm fine taking this for now.


https://reviews.llvm.org/D22014



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


[libcxx] r276585 - Fix portability issues in tests. Patch from s...@microsoft.com

2016-07-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 24 18:36:18 2016
New Revision: 276585

URL: http://llvm.org/viewvc/llvm-project?rev=276585&view=rev
Log:
Fix portability issues in  tests. Patch from s...@microsoft.com

Modified:

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

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

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

libcxx/trunk/test/std/numerics/rand/rand.predef/default_random_engine.pass.cpp

Modified: 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp?rev=276585&r1=276584&r2=276585&view=diff
==
--- 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
 Sun Jul 24 18:36:18 2016
@@ -17,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int main()
 {
 int ia[] = {1, 2, 3, 4};
@@ -24,7 +26,9 @@ int main()
 int ia2[] = {4, 1, 2, 3};
 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
 std::random_shuffle(ia, ia+sa);
-assert(std::equal(ia, ia+sa, ia1));
+LIBCPP_ASSERT(std::equal(ia, ia+sa, ia1));
+assert(std::is_permutation(ia, ia+sa, ia1));
 std::random_shuffle(ia, ia+sa);
-assert(std::equal(ia, ia+sa, ia2));
+LIBCPP_ASSERT(std::equal(ia, ia+sa, ia2));
+assert(std::is_permutation(ia, ia+sa, ia2));
 }

Modified: 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp?rev=276585&r1=276584&r2=276585&view=diff
==
--- 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
 Sun Jul 24 18:36:18 2016
@@ -18,6 +18,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 struct gen
 {
 int operator()(int n)
@@ -33,5 +35,6 @@ int main()
 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
 gen r;
 std::random_shuffle(ia, ia+sa, r);
-assert(std::equal(ia, ia+sa, ia1));
+LIBCPP_ASSERT(std::equal(ia, ia+sa, ia1));
+assert(std::is_permutation(ia, ia+sa, ia1));
 }

Modified: 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp?rev=276585&r1=276584&r2=276585&view=diff
==
--- 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp
 Sun Jul 24 18:36:18 2016
@@ -17,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int main()
 {
 int ia[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
@@ -25,7 +27,9 @@ int main()
 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
 std::minstd_rand g;
 std::shuffle(ia, ia+sa, g);
-assert(std::equal(ia, ia+sa, ia1));
+LIBCPP_ASSERT(std::equal(ia, ia+sa, ia1));
+assert(std::is_permutation(ia, ia+sa, ia1));
 std::shuffle(ia, ia+sa, g);
-assert(std::equal(ia, ia+sa, ia2));
+LIBCPP_ASSERT(std::equal(ia, ia+sa, ia2));
+assert(std::is_permutation(ia, ia+sa, ia2));
 }

Modified: 
libcxx/trunk/test/std/numerics/rand/rand.predef/default_random_engine.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.predef/default_random_engine.pass.cpp?rev=276585&r1=276584&r2=276585&view=diff
==
--- 
libcxx/trunk/test/std/numerics/rand/rand.predef/default_random_engine.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/numerics/rand/rand.predef/default_random_engine.pass.cpp 
Sun Jul 24 18:36:18 2016
@@ -14,9 +14,11 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int main()
 {
 std::default_random_engine e;
 e.discard();
-assert(e() == 399268537u);
+LIBCPP_ASSERT(e() == 399268537u);
 }


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

Re: [PATCH] D22155: [libcxx] [test] Fix portability issues in tests.

2016-07-24 Thread Eric Fiselier via cfe-commits
EricWF closed this revision.
EricWF added a comment.

r276585.


https://reviews.llvm.org/D22155



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


Re: [PATCH] D22157: [libcxx] [test] Mark bucket() assertions as nonportable.

2016-07-24 Thread Eric Fiselier via cfe-commits
EricWF closed this revision.
EricWF added a comment.

r276584.


https://reviews.llvm.org/D22157



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


[libcxx] r276584 - Mark bucket() assertions as non-portable. Patch from s...@microsoft.com

2016-07-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 24 18:34:18 2016
New Revision: 276584

URL: http://llvm.org/viewvc/llvm-project?rev=276584&view=rev
Log:
Mark bucket() assertions as non-portable. Patch from s...@microsoft.com

Modified:
libcxx/trunk/test/std/containers/unord/unord.map/bucket.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.multimap/bucket.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.multiset/bucket.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.set/bucket.pass.cpp

Modified: libcxx/trunk/test/std/containers/unord/unord.map/bucket.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/bucket.pass.cpp?rev=276584&r1=276583&r2=276584&view=diff
==
--- libcxx/trunk/test/std/containers/unord/unord.map/bucket.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.map/bucket.pass.cpp Sun Jul 24 
18:34:18 2016
@@ -23,6 +23,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "min_allocator.h"
 
 int main()
@@ -43,7 +44,7 @@ int main()
 size_t bc = c.bucket_count();
 assert(bc >= 5);
 for (size_t i = 0; i < 13; ++i)
-assert(c.bucket(i) == i % bc);
+LIBCPP_ASSERT(c.bucket(i) == i % bc);
 }
 #if TEST_STD_VER >= 11
 {
@@ -63,7 +64,7 @@ int main()
 size_t bc = c.bucket_count();
 assert(bc >= 5);
 for (size_t i = 0; i < 13; ++i)
-assert(c.bucket(i) == i % bc);
+LIBCPP_ASSERT(c.bucket(i) == i % bc);
 }
 #endif
 #if _LIBCPP_DEBUG_LEVEL >= 1

Modified: libcxx/trunk/test/std/containers/unord/unord.multimap/bucket.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/bucket.pass.cpp?rev=276584&r1=276583&r2=276584&view=diff
==
--- libcxx/trunk/test/std/containers/unord/unord.multimap/bucket.pass.cpp 
(original)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/bucket.pass.cpp Sun 
Jul 24 18:34:18 2016
@@ -23,6 +23,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "min_allocator.h"
 
 int main()
@@ -43,7 +44,7 @@ int main()
 size_t bc = c.bucket_count();
 assert(bc >= 7);
 for (size_t i = 0; i < 13; ++i)
-assert(c.bucket(i) == i % bc);
+LIBCPP_ASSERT(c.bucket(i) == i % bc);
 }
 #if TEST_STD_VER >= 11
 {
@@ -63,7 +64,7 @@ int main()
 size_t bc = c.bucket_count();
 assert(bc >= 7);
 for (size_t i = 0; i < 13; ++i)
-assert(c.bucket(i) == i % bc);
+LIBCPP_ASSERT(c.bucket(i) == i % bc);
 }
 #endif
 #if _LIBCPP_DEBUG_LEVEL >= 1

Modified: libcxx/trunk/test/std/containers/unord/unord.multiset/bucket.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multiset/bucket.pass.cpp?rev=276584&r1=276583&r2=276584&view=diff
==
--- libcxx/trunk/test/std/containers/unord/unord.multiset/bucket.pass.cpp 
(original)
+++ libcxx/trunk/test/std/containers/unord/unord.multiset/bucket.pass.cpp Sun 
Jul 24 18:34:18 2016
@@ -22,6 +22,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "min_allocator.h"
 
 int main()
@@ -42,7 +43,7 @@ int main()
 size_t bc = c.bucket_count();
 assert(bc >= 7);
 for (size_t i = 0; i < 13; ++i)
-assert(c.bucket(i) == i % bc);
+LIBCPP_ASSERT(c.bucket(i) == i % bc);
 }
 #if TEST_STD_VER >= 11
 {
@@ -62,7 +63,7 @@ int main()
 size_t bc = c.bucket_count();
 assert(bc >= 7);
 for (size_t i = 0; i < 13; ++i)
-assert(c.bucket(i) == i % bc);
+LIBCPP_ASSERT(c.bucket(i) == i % bc);
 }
 #endif
 #if _LIBCPP_DEBUG_LEVEL >= 1

Modified: libcxx/trunk/test/std/containers/unord/unord.set/bucket.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.set/bucket.pass.cpp?rev=276584&r1=276583&r2=276584&view=diff
==
--- libcxx/trunk/test/std/containers/unord/unord.set/bucket.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.set/bucket.pass.cpp Sun Jul 24 
18:34:18 2016
@@ -22,6 +22,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "min_allocator.h"
 
 int main()
@@ -42,7 +43,7 @@ int main()
 size_t bc = c.bucket_count();
 assert(bc >= 5);
 for (size_t i = 0; i < 13; ++i)
-assert(c.bucket(i) == i % bc);
+LIBCPP_ASSERT(c.bucket(i) == i % bc);
 }
 #if TEST_STD_VER >= 11
 {
@@ -61,7 +62,7 @@ int main()
 size_t bc = c.bucket_count();
 assert(bc >= 5);
 for (size_t i = 0; i < 13; ++i)
-assert(c.bucket(i) == i % bc);
+LIBCPP_ASSERT

Re: [PATCH] D22059: [libcxx] [test] Fix MSVC "warning C4100: 'val': unreferenced formal parameter".

2016-07-24 Thread Eric Fiselier via cfe-commits
EricWF closed this revision.
EricWF added a comment.

r276583.


https://reviews.llvm.org/D22059



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


[libcxx] r276583 - Fix MSVC unreferenced parameter warning. Patch from s...@microsoft.com

2016-07-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 24 18:32:48 2016
New Revision: 276583

URL: http://llvm.org/viewvc/llvm-project?rev=276583&view=rev
Log:
Fix MSVC unreferenced parameter warning. Patch from s...@microsoft.com

Modified:

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

Modified: 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp?rev=276583&r1=276582&r2=276583&view=diff
==
--- 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
 Sun Jul 24 18:32:48 2016
@@ -39,7 +39,7 @@ struct D
 
 struct E {
   E() = default;
-  E& operator=(int val) {
+  E& operator=(int) {
   return *this;
   }
 };


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


Re: [PATCH] D21716: [libcxx] [test] Make move_noexcept.pass.cpp tests more portable.

2016-07-24 Thread Eric Fiselier via cfe-commits
EricWF closed this revision.
EricWF added a comment.

r276581.


https://reviews.llvm.org/D21716



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


[libcxx] r276581 - Make move_noexcept.pass.cpp tests more portable. Patch from s...@microsoft.com

2016-07-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 24 18:19:51 2016
New Revision: 276581

URL: http://llvm.org/viewvc/llvm-project?rev=276581&view=rev
Log:
Make move_noexcept.pass.cpp tests more portable. Patch from s...@microsoft.com

Modified:

libcxx/trunk/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp

libcxx/trunk/test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp

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

libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp

libcxx/trunk/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp

libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp

libcxx/trunk/test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp

libcxx/trunk/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp

Modified: 
libcxx/trunk/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp?rev=276581&r1=276580&r2=276581&view=diff
==
--- 
libcxx/trunk/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp
 Sun Jul 24 18:19:51 2016
@@ -20,6 +20,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "MoveOnly.h"
 #include "test_allocator.h"
 
@@ -36,15 +37,15 @@ int main()
 typedef std::pair V;
 {
 typedef std::map C;
-static_assert(std::is_nothrow_move_constructible::value, "");
+LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible::value, "");
 }
 {
 typedef std::map, 
test_allocator> C;
-static_assert(std::is_nothrow_move_constructible::value, "");
+LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible::value, "");
 }
 {
 typedef std::map, 
other_allocator> C;
-static_assert(std::is_nothrow_move_constructible::value, "");
+LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible::value, "");
 }
 {
 typedef std::map> C;

Modified: 
libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp?rev=276581&r1=276580&r2=276581&view=diff
==
--- 
libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp
 Sun Jul 24 18:19:51 2016
@@ -20,6 +20,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "MoveOnly.h"
 #include "test_allocator.h"
 
@@ -36,15 +37,15 @@ int main()
 typedef std::pair V;
 {
 typedef std::multimap C;
-static_assert(std::is_nothrow_move_constructible::value, "");
+LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible::value, "");
 }
 {
 typedef std::multimap, 
test_allocator> C;
-static_assert(std::is_nothrow_move_constructible::value, "");
+LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible::value, "");
 }
 {
 typedef std::multimap, 
other_allocator> C;
-static_assert(std::is_nothrow_move_constructible::value, "");
+LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible::value, "");
 }
 {
 typedef std::multimap> C;

Modified: 
libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp?rev=276581&r1=276580&r2=276581&view=diff
==
--- 
libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp
 Sun Jul 24 18:19:51 2016
@@ -20,6 +20,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #in

Re: [PATCH] D22165: [libcxx] [test] Make bucket_count() greater-equal assertions portable.

2016-07-24 Thread Eric Fiselier via cfe-commits
EricWF closed this revision.
EricWF added a comment.

r276580.


https://reviews.llvm.org/D22165



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


[libcxx] r276580 - Make bucket_count() greater-equal assertions portable. Patch from s...@microsoft.com

2016-07-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 24 18:16:37 2016
New Revision: 276580

URL: http://llvm.org/viewvc/llvm-project?rev=276580&view=rev
Log:
Make bucket_count() greater-equal assertions portable. Patch from 
s...@microsoft.com

Modified:
libcxx/trunk/test/std/containers/unord/unord.map/bucket_count.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.multimap/bucket_count.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.multiset/bucket_count.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.set/bucket_count.pass.cpp

Modified: libcxx/trunk/test/std/containers/unord/unord.map/bucket_count.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/bucket_count.pass.cpp?rev=276580&r1=276579&r2=276580&view=diff
==
--- libcxx/trunk/test/std/containers/unord/unord.map/bucket_count.pass.cpp 
(original)
+++ libcxx/trunk/test/std/containers/unord/unord.map/bucket_count.pass.cpp Sun 
Jul 24 18:16:37 2016
@@ -44,7 +44,7 @@ int main()
 P(80, "eighty"),
 };
 const C c(std::begin(a), std::end(a));
-assert(c.bucket_count() >= 11);
+assert(c.bucket_count() >= 8);
 }
 #if TEST_STD_VER >= 11
 {
@@ -69,7 +69,7 @@ int main()
 P(80, "eighty"),
 };
 const C c(std::begin(a), std::end(a));
-assert(c.bucket_count() >= 11);
+assert(c.bucket_count() >= 8);
 }
 #endif
 }

Modified: 
libcxx/trunk/test/std/containers/unord/unord.multimap/bucket_count.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/bucket_count.pass.cpp?rev=276580&r1=276579&r2=276580&view=diff
==
--- libcxx/trunk/test/std/containers/unord/unord.multimap/bucket_count.pass.cpp 
(original)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/bucket_count.pass.cpp 
Sun Jul 24 18:16:37 2016
@@ -44,6 +44,6 @@ int main()
 P(80, "eighty"),
 };
 const C c(std::begin(a), std::end(a));
-assert(c.bucket_count() >= 11);
+assert(c.bucket_count() >= 8);
 }
 }

Modified: 
libcxx/trunk/test/std/containers/unord/unord.multiset/bucket_count.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multiset/bucket_count.pass.cpp?rev=276580&r1=276579&r2=276580&view=diff
==
--- libcxx/trunk/test/std/containers/unord/unord.multiset/bucket_count.pass.cpp 
(original)
+++ libcxx/trunk/test/std/containers/unord/unord.multiset/bucket_count.pass.cpp 
Sun Jul 24 18:16:37 2016
@@ -45,7 +45,7 @@ int main()
 P(80)
 };
 const C c(std::begin(a), std::end(a));
-assert(c.bucket_count() >= 11);
+assert(c.bucket_count() >= 8);
 }
 #if TEST_STD_VER >= 11
 {
@@ -73,7 +73,7 @@ int main()
 P(80)
 };
 const C c(std::begin(a), std::end(a));
-assert(c.bucket_count() >= 11);
+assert(c.bucket_count() >= 8);
 }
 #endif
 }

Modified: libcxx/trunk/test/std/containers/unord/unord.set/bucket_count.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.set/bucket_count.pass.cpp?rev=276580&r1=276579&r2=276580&view=diff
==
--- libcxx/trunk/test/std/containers/unord/unord.set/bucket_count.pass.cpp 
(original)
+++ libcxx/trunk/test/std/containers/unord/unord.set/bucket_count.pass.cpp Sun 
Jul 24 18:16:37 2016
@@ -45,7 +45,7 @@ int main()
 P(80)
 };
 const C c(std::begin(a), std::end(a));
-assert(c.bucket_count() >= 11);
+assert(c.bucket_count() >= 8);
 }
 #if TEST_STD_VER >= 11
 {
@@ -71,7 +71,7 @@ int main()
 P(80)
 };
 const C c(std::begin(a), std::end(a));
-assert(c.bucket_count() >= 11);
+assert(c.bucket_count() >= 8);
 }
 #endif
 }


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


Re: [PATCH] D22159: [libcxx] [test] Mark bucket_size() assertions as nonportable.

2016-07-24 Thread Eric Fiselier via cfe-commits
EricWF closed this revision.
EricWF added a comment.

r276578.


https://reviews.llvm.org/D22159



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


[libcxx] r276578 - Mark bucket_size() assertions as non-portible. Patch from s...@microsoft.com

2016-07-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 24 18:13:36 2016
New Revision: 276578

URL: http://llvm.org/viewvc/llvm-project?rev=276578&view=rev
Log:
Mark bucket_size() assertions as non-portible. Patch from s...@microsoft.com

Modified:
libcxx/trunk/test/std/containers/unord/unord.map/bucket_size.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.multimap/bucket_size.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.multiset/bucket_size.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.set/bucket_size.pass.cpp

Modified: libcxx/trunk/test/std/containers/unord/unord.map/bucket_size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/bucket_size.pass.cpp?rev=276578&r1=276577&r2=276578&view=diff
==
--- libcxx/trunk/test/std/containers/unord/unord.map/bucket_size.pass.cpp 
(original)
+++ libcxx/trunk/test/std/containers/unord/unord.map/bucket_size.pass.cpp Sun 
Jul 24 18:13:36 2016
@@ -23,6 +23,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "min_allocator.h"
 
 int main()
@@ -41,11 +42,11 @@ int main()
 };
 const C c(std::begin(a), std::end(a));
 assert(c.bucket_count() >= 5);
-assert(c.bucket_size(0) == 0);
-assert(c.bucket_size(1) == 1);
-assert(c.bucket_size(2) == 1);
-assert(c.bucket_size(3) == 1);
-assert(c.bucket_size(4) == 1);
+LIBCPP_ASSERT(c.bucket_size(0) == 0);
+LIBCPP_ASSERT(c.bucket_size(1) == 1);
+LIBCPP_ASSERT(c.bucket_size(2) == 1);
+LIBCPP_ASSERT(c.bucket_size(3) == 1);
+LIBCPP_ASSERT(c.bucket_size(4) == 1);
 }
 #if TEST_STD_VER >= 11
 {
@@ -63,11 +64,11 @@ int main()
 };
 const C c(std::begin(a), std::end(a));
 assert(c.bucket_count() >= 5);
-assert(c.bucket_size(0) == 0);
-assert(c.bucket_size(1) == 1);
-assert(c.bucket_size(2) == 1);
-assert(c.bucket_size(3) == 1);
-assert(c.bucket_size(4) == 1);
+LIBCPP_ASSERT(c.bucket_size(0) == 0);
+LIBCPP_ASSERT(c.bucket_size(1) == 1);
+LIBCPP_ASSERT(c.bucket_size(2) == 1);
+LIBCPP_ASSERT(c.bucket_size(3) == 1);
+LIBCPP_ASSERT(c.bucket_size(4) == 1);
 }
 #endif
 #if _LIBCPP_DEBUG_LEVEL >= 1

Modified: 
libcxx/trunk/test/std/containers/unord/unord.multimap/bucket_size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/bucket_size.pass.cpp?rev=276578&r1=276577&r2=276578&view=diff
==
--- libcxx/trunk/test/std/containers/unord/unord.multimap/bucket_size.pass.cpp 
(original)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/bucket_size.pass.cpp 
Sun Jul 24 18:13:36 2016
@@ -23,6 +23,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "min_allocator.h"
 
 int main()
@@ -41,13 +42,13 @@ int main()
 };
 const C c(std::begin(a), std::end(a));
 assert(c.bucket_count() >= 7);
-assert(c.bucket_size(0) == 0);
-assert(c.bucket_size(1) == 2);
-assert(c.bucket_size(2) == 2);
-assert(c.bucket_size(3) == 1);
-assert(c.bucket_size(4) == 1);
-assert(c.bucket_size(5) == 0);
-assert(c.bucket_size(6) == 0);
+LIBCPP_ASSERT(c.bucket_size(0) == 0);
+LIBCPP_ASSERT(c.bucket_size(1) == 2);
+LIBCPP_ASSERT(c.bucket_size(2) == 2);
+LIBCPP_ASSERT(c.bucket_size(3) == 1);
+LIBCPP_ASSERT(c.bucket_size(4) == 1);
+LIBCPP_ASSERT(c.bucket_size(5) == 0);
+LIBCPP_ASSERT(c.bucket_size(6) == 0);
 }
 #if TEST_STD_VER >= 11
 {
@@ -65,13 +66,13 @@ int main()
 };
 const C c(std::begin(a), std::end(a));
 assert(c.bucket_count() >= 7);
-assert(c.bucket_size(0) == 0);
-assert(c.bucket_size(1) == 2);
-assert(c.bucket_size(2) == 2);
-assert(c.bucket_size(3) == 1);
-assert(c.bucket_size(4) == 1);
-assert(c.bucket_size(5) == 0);
-assert(c.bucket_size(6) == 0);
+LIBCPP_ASSERT(c.bucket_size(0) == 0);
+LIBCPP_ASSERT(c.bucket_size(1) == 2);
+LIBCPP_ASSERT(c.bucket_size(2) == 2);
+LIBCPP_ASSERT(c.bucket_size(3) == 1);
+LIBCPP_ASSERT(c.bucket_size(4) == 1);
+LIBCPP_ASSERT(c.bucket_size(5) == 0);
+LIBCPP_ASSERT(c.bucket_size(6) == 0);
 }
 #endif
 #if _LIBCPP_DEBUG_LEVEL >= 1

Modified: 
libcxx/trunk/test/std/containers/unord/unord.multiset/bucket_size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multiset/bucket_size.pass.cpp?rev=276578&r1=276577&r2=276578&view=diff
==
--- libcxx/trunk/test/std/containers/unord/unord.multiset/bucket_size.pass.cpp 
(original)
+++ libcxx/trunk/test/std/containers/un

r276577 - [Sema] Replace mem_fn with lambdas. NFC.

2016-07-24 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Sun Jul 24 18:12:40 2016
New Revision: 276577

URL: http://llvm.org/viewvc/llvm-project?rev=276577&view=rev
Log:
[Sema] Replace mem_fn with lambdas. NFC.

I'm told that some optimizers like lambdas a lot more than mem_fn.
Given that the readability difference is basically nil, and we seem to
use lambdas basically everywhere else, it seems sensible to just use
lambdas.

Modified:
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/SemaLambda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLambda.cpp?rev=276577&r1=276576&r2=276577&view=diff
==
--- cfe/trunk/lib/Sema/SemaLambda.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLambda.cpp Sun Jul 24 18:12:40 2016
@@ -1144,14 +1144,16 @@ void Sema::ActOnLambdaError(SourceLocati
 
 /// \brief Add a lambda's conversion to function pointer, as described in
 /// C++11 [expr.prim.lambda]p6.
-static void addFunctionPointerConversion(Sema &S, 
+static void addFunctionPointerConversion(Sema &S,
  SourceRange IntroducerRange,
  CXXRecordDecl *Class,
  CXXMethodDecl *CallOperator) {
   // This conversion is explicitly disabled if the lambda's function has
   // pass_object_size attributes on any of its parameters.
-  if (llvm::any_of(CallOperator->parameters(),
-   std::mem_fn(&ParmVarDecl::hasAttr)))
+  auto HasPassObjectSizeAttr = [](const ParmVarDecl *P) {
+return P->hasAttr();
+  };
+  if (llvm::any_of(CallOperator->parameters(), HasPassObjectSizeAttr))
 return;
 
   // Add the conversion to function pointer.

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=276577&r1=276576&r2=276577&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Sun Jul 24 18:12:40 2016
@@ -39,8 +39,9 @@ using namespace clang;
 using namespace sema;
 
 static bool functionHasPassObjectSizeParams(const FunctionDecl *FD) {
-  return llvm::any_of(FD->parameters(),
-  std::mem_fn(&ParmVarDecl::hasAttr));
+  return llvm::any_of(FD->parameters(), [](const ParmVarDecl *P) {
+return P->hasAttr();
+  });
 }
 
 /// A convenience routine for creating a decayed reference to a function.
@@ -8954,8 +8955,9 @@ static bool checkAddressOfFunctionIsAvai
 return false;
   }
 
-  auto I = llvm::find_if(
-  FD->parameters(), 
std::mem_fn(&ParmVarDecl::hasAttr));
+  auto I = llvm::find_if(FD->parameters(), [](const ParmVarDecl *P) {
+return P->hasAttr();
+  });
   if (I == FD->param_end())
 return true;
 


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


Re: [PATCH] D22013: [libcxx] [test] bind's function call operator isn't guaranteed to SFINAE.

2016-07-24 Thread Eric Fiselier via cfe-commits
EricWF closed this revision.
EricWF added a comment.

r276576.


https://reviews.llvm.org/D22013



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


[libcxx] r276576 - Guard libc++ specific tests SFINAE on std::bind's call operator. Patch from s...@microsoft.com

2016-07-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 24 18:08:21 2016
New Revision: 276576

URL: http://llvm.org/viewvc/llvm-project?rev=276576&view=rev
Log:
Guard libc++ specific tests SFINAE on std::bind's call operator. Patch from 
s...@microsoft.com

Modified:

libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/bind_return_type.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/bind_return_type.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/bind_return_type.pass.cpp?rev=276576&r1=276575&r2=276576&view=diff
==
--- 
libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/bind_return_type.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/bind_return_type.pass.cpp
 Sun Jul 24 18:08:21 2016
@@ -24,6 +24,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int dummy = 42;
 
 int return_value(int) { return dummy; }
@@ -81,10 +83,10 @@ void do_test(Fn* func) {
 // Check that the call operator SFINAE's away when too few arguments
 // are provided but is well-formed otherwise.
 {
-static_assert(!CheckCall(), "");
+LIBCPP_STATIC_ASSERT(!CheckCall(), "");
 static_assert(CheckCall(), "");
 static_assert(CheckCall(), "");
-static_assert(!CheckCall(), "");
+LIBCPP_STATIC_ASSERT(!CheckCall(), "");
 static_assert(CheckCall(), "");
 static_assert(CheckCall(), "");
 }
@@ -108,7 +110,7 @@ void do_test_r(Fn* func) {
 // Check that the call operator SFINAE's away when too few arguments
 // are provided but is well-formed otherwise.
 {
-static_assert(!CheckCall(), "");
+LIBCPP_STATIC_ASSERT(!CheckCall(), "");
 static_assert(CheckCall(), "");
 static_assert(CheckCall(), "");
 }


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


Re: [PATCH] D22584: constexpr array support C++1z (P0031)

2016-07-24 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

For the most part this LGTM. Thanks for putting in all this work. I've noted 
some places where the test coverage could be improved.



Comment at: include/array:156
@@ -155,3 +155,3 @@
 _LIBCPP_INLINE_VISIBILITY
-iterator begin() _NOEXCEPT {return iterator(__elems_);}
+_LIBCPP_CONSTEXPR_AFTER_CXX14 iterator begin() _NOEXCEPT {return 
iterator(__elems_);}
 _LIBCPP_INLINE_VISIBILITY

This is untested.


Comment at: include/array:160
@@ -159,3 +159,3 @@
 _LIBCPP_INLINE_VISIBILITY
-iterator end() _NOEXCEPT {return iterator(__elems_ + _Size);}
+_LIBCPP_CONSTEXPR_AFTER_CXX14 iterator end() _NOEXCEPT {return 
iterator(__elems_ + _Size);}
 _LIBCPP_INLINE_VISIBILITY

This is untested.


Comment at: include/array:165
@@ -164,3 +164,3 @@
 _LIBCPP_INLINE_VISIBILITY
-reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
+_LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator rbegin() _NOEXCEPT {return 
reverse_iterator(end());}
 _LIBCPP_INLINE_VISIBILITY

Untested.


Comment at: include/array:169
@@ -168,3 +168,3 @@
 _LIBCPP_INLINE_VISIBILITY
-reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
+_LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator rend() _NOEXCEPT {return 
reverse_iterator(begin());}
 _LIBCPP_INLINE_VISIBILITY

Untested.


Comment at: include/array:202
@@ -201,3 +201,3 @@
 _LIBCPP_INLINE_VISIBILITY
-value_type* data() _NOEXCEPT {return __elems_;}
+_LIBCPP_CONSTEXPR_AFTER_CXX14 value_type* data() _NOEXCEPT {return 
__elems_;}
 _LIBCPP_INLINE_VISIBILITY

Untested.


Comment at: include/iterator:527
@@ -526,2 +526,3 @@
 inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_AFTER_CXX14
 void __advance(_InputIter& __i,

Untested.


Comment at: include/iterator:537
@@ -535,2 +536,3 @@
 inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_AFTER_CXX14
 void __advance(_BiDirIter& __i,

Untested.


Comment at: include/iterator:569
@@ -564,2 +568,3 @@
 inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_AFTER_CXX14
 typename iterator_traits<_InputIter>::difference_type

Untested.


Comment at: include/iterator:1158
@@ -1131,2 +1157,3 @@
 inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_AFTER_CXX14 
 typename move_iterator<_Iter1>::difference_type

This is a C++03 only branch, but I guess it's more consistent to apply the 
macro.


Comment at: test/std/containers/sequences/array/indexing.pass.cpp:41
@@ -26,1 +40,3 @@
+}
+
 int main()

Missing conditional directive terminator.


Comment at: test/std/containers/sequences/array/indexing.pass.cpp:84
@@ +83,3 @@
+{
+constexpr C c = constexpr_array_usage();
+static_assert (c[0] == 0);

C doesn't name a type.


Comment at: test/std/containers/sequences/array/iterators.pass.cpp:112
@@ +111,3 @@
+
+#if _LIBCPP_STD_VER > 14
+{ // P0031 testing conextpr versions of iterators

Include `test_macros.h` and use `TEST_STD_VER` please.


https://reviews.llvm.org/D22584



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


Re: [PATCH] D22725: [clang-tidy] Add check 'misc-replace-memcpy'

2016-07-24 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

In https://reviews.llvm.org/D22725#494168, @JDevlieghere wrote:

> In https://reviews.llvm.org/D22725#494167, @Prazek wrote:
>
> > hmm It seems that I mislead you, I suck at C api - memmove source and 
> > destination can overlap, but std::move can't. So I guess you have to remove 
> > the memmove support. Sorry.
>
>
> No problem, I wasn't aware of the issue either, so thanks for letting me know!
>
> While running my check on the LLVM repo I ran into another issue: can't do 
> pointer arithmetic when the arguments to memcpy are void pointers. I will 
> look into updating my matchers to exclude this particular case.


Yep, developing clang-tidy checks is mostly about trying to find out all the 
cases, and then finding that there are 3x more corner cases after running it on 
LLVM :)
btw I recommend compiling on Release with enabled assertions 
(-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON). Usually you don't 
need debug info while developing clang-tidy because it doesn't crash that often 
and Release is at least 4x faster than RelWithDebInfo (and even more than 
Debug), so it actually make sense to recompile everything and run it than to 
wait for clang-tidy compiled with debug.


https://reviews.llvm.org/D22725



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


Re: [PATCH] D22725: [clang-tidy] Add check 'misc-replace-memcpy'

2016-07-24 Thread Jonas Devlieghere via cfe-commits
JDevlieghere added a comment.

In https://reviews.llvm.org/D22725#494167, @Prazek wrote:

> hmm It seems that I mislead you, I suck at C api - memmove source and 
> destination can overlap, but std::move can't. So I guess you have to remove 
> the memmove support. Sorry.


No problem, I wasn't aware of the issue either, so thanks for letting me know!

While running my check on the LLVM repo I ran into another issue: can't do 
pointer arithmetic when the arguments to memcpy are void pointers. I will look 
into updating my matchers to exclude this particular case.


https://reviews.llvm.org/D22725



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


Re: [PATCH] D22725: [clang-tidy] Add check 'misc-replace-memcpy'

2016-07-24 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

hmm It seems that I mislead you, I suck at C api - memmove source and 
destination can overlap, but std::move can't. So I guess you have to remove the 
memmove support. Sorry.


https://reviews.llvm.org/D22725



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


r276573 - [Driver] Switch some getenv calls to llvm::sys::Process::GetEnv

2016-07-24 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Sun Jul 24 12:44:03 2016
New Revision: 276573

URL: http://llvm.org/viewvc/llvm-project?rev=276573&view=rev
Log:
[Driver] Switch some getenv calls to llvm::sys::Process::GetEnv

No functional change is intended.

Modified:
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/MSVCToolChain.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=276573&r1=276572&r2=276573&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Sun Jul 24 12:44:03 2016
@@ -455,8 +455,9 @@ Compilation *Driver::BuildCompilation(Ar
   // FIXME: Handle environment options which affect driver behavior, somewhere
   // (client?). GCC_EXEC_PREFIX, LPATH, CC_PRINT_OPTIONS.
 
-  if (char *env = ::getenv("COMPILER_PATH")) {
-StringRef CompilerPath = env;
+  if (Optional CompilerPathValue =
+  llvm::sys::Process::GetEnv("COMPILER_PATH")) {
+StringRef CompilerPath = *CompilerPathValue;
 while (!CompilerPath.empty()) {
   std::pair Split =
   CompilerPath.split(llvm::sys::EnvPathSeparator);

Modified: cfe/trunk/lib/Driver/MSVCToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MSVCToolChain.cpp?rev=276573&r1=276572&r2=276573&view=diff
==
--- cfe/trunk/lib/Driver/MSVCToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/MSVCToolChain.cpp Sun Jul 24 12:44:03 2016
@@ -513,9 +513,9 @@ VersionTuple MSVCToolChain::getMSVCVersi
 // Get Visual Studio installation directory.
 bool MSVCToolChain::getVisualStudioInstallDir(std::string &path) const {
   // First check the environment variables that vsvars32.bat sets.
-  const char *vcinstalldir = getenv("VCINSTALLDIR");
-  if (vcinstalldir) {
-path = vcinstalldir;
+  if (llvm::Optional VcInstallDir =
+  llvm::sys::Process::GetEnv("VCINSTALLDIR")) {
+path = std::move(*VcInstallDir);
 path = path.substr(0, path.find("\\VC"));
 return true;
   }
@@ -541,26 +541,26 @@ bool MSVCToolChain::getVisualStudioInsta
   }
 
   // Try the environment.
-  const char *vs120comntools = getenv("VS120COMNTOOLS");
-  const char *vs100comntools = getenv("VS100COMNTOOLS");
-  const char *vs90comntools = getenv("VS90COMNTOOLS");
-  const char *vs80comntools = getenv("VS80COMNTOOLS");
-
-  const char *vscomntools = nullptr;
-
-  // Find any version we can
-  if (vs120comntools)
-vscomntools = vs120comntools;
-  else if (vs100comntools)
-vscomntools = vs100comntools;
-  else if (vs90comntools)
-vscomntools = vs90comntools;
-  else if (vs80comntools)
-vscomntools = vs80comntools;
-
-  if (vscomntools && *vscomntools) {
-const char *p = strstr(vscomntools, "\\Common7\\Tools");
-path = p ? std::string(vscomntools, p) : vscomntools;
+  std::string vcomntools;
+  if (llvm::Optional vs120comntools =
+  llvm::sys::Process::GetEnv("VS120COMNTOOLS"))
+vcomntools = std::move(*vs120comntools);
+  else if (llvm::Optional vs100comntools =
+   llvm::sys::Process::GetEnv("VS100COMNTOOLS"))
+vcomntools = std::move(*vs100comntools);
+  else if (llvm::Optional vs90comntools =
+   llvm::sys::Process::GetEnv("VS90COMNTOOLS"))
+vcomntools = std::move(*vs90comntools);
+  else if (llvm::Optional vs80comntools =
+   llvm::sys::Process::GetEnv("VS80COMNTOOLS"))
+vcomntools = std::move(*vs80comntools);
+
+  // Find any version we can.
+  if (!vcomntools.empty()) {
+size_t p = vcomntools.find("\\Common7\\Tools");
+if (p != std::string::npos)
+  vcomntools.resize(p);
+path = std::move(vcomntools);
 return true;
   }
   return false;
@@ -593,9 +593,10 @@ void MSVCToolChain::AddClangSystemInclud
 return;
 
   // Honor %INCLUDE%. It should know essential search paths with vcvarsall.bat.
-  if (const char *cl_include_dir = getenv("INCLUDE")) {
+  if (llvm::Optional cl_include_dir =
+  llvm::sys::Process::GetEnv("INCLUDE")) {
 SmallVector Dirs;
-StringRef(cl_include_dir)
+StringRef(*cl_include_dir)
 .split(Dirs, ";", /*MaxSplit=*/-1, /*KeepEmpty=*/false);
 for (StringRef Dir : Dirs)
   addSystemInclude(DriverArgs, CC1Args, Dir);


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


Re: [PATCH] D22725: [clang-tidy] Add check 'misc-replace-memcpy'

2016-07-24 Thread Jonas Devlieghere via cfe-commits
JDevlieghere added a comment.

In https://reviews.llvm.org/D22725#494074, @Prazek wrote:

> Maybe the right way would be to have check called 
> 'modernize-use-sequence-algorithm' or just 'modernize-use-algorithm' that 
> would basically do all those stuff. It would be good to not introduce 5 new 
> check that pretty much do the same thing and also the user would want to have 
> them all or none.
>  You can look how I did it with modernize-use-make-shared, it would be pretty 
> much the same.


I kept everything in modernize-use-algorithm as I agree this isn't worth 3 
different checks.

> So It should not be very hard. You would just have to check if the second or 
> third argument to memcpy is one of [list here] of the things that 

>  would make it bad. And you can probably write easy matcher for this.

>  I understand that it probably will take the double of time that you have 
> spend on this check, but this will actually is the thing here - you want your 
> check to produce the fixes that makes sense. When you will run it on llvm 
> code base, I guess you will see that over 90% of the cases didn't require 
> coma. I understand that you want to make it accurate, but the fix should not 
> also intoruce some code that is not tidy enough.

>  So I guess either fix it, or wait what Alex will say about it. It might make 
> it to upstream like this, but I hope you would fix it in some time :)


You are right. I didn't completely finish the first run on LLVM, but none of 
the occurrences it had found so far would have caused an issue. I guess that 
means that omitting the extra parens is a sensible default for now. I will look 
into excluding problematic situations once I am sure this check is fully 
functional.

> Anyway good job, hope to see some more checks from you!


Thanks, I really appreciate the feedback from everyone! :)

> > > 4. Have you run the check on LLVM code base? It uses std::copy in many 
> > > places. If after running with -fix all the memcpys will be gone (check if 
> > > if finds anything after second run) and the code will compile and tests 
> > > will not fail then it means that your check fully works!

> 

> > 

> 

> > 

> 

> > Doing this as we speak!

> 

> 

> When you will be finished just post a diff of changes after running it on 
> llvm on phabricator and add me as subscriber :)


It's running again with the changes from the last revision included. It is 
taking a very long time though but I guess that's my fault for not building in 
release mode. I'll leave it running for now as I don't want to start over again.


https://reviews.llvm.org/D22725



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


Re: [PATCH] D22725: [clang-tidy] Add check 'misc-replace-memcpy'

2016-07-24 Thread Jonas Devlieghere via cfe-commits
JDevlieghere removed rL LLVM as the repository for this revision.
JDevlieghere updated this revision to Diff 65273.
JDevlieghere added a comment.

- Extended check to replace memmove with std::move and memset with std::fill
- Renamed check to modernize-use-algorithm (I'd be equally fine with moving it 
to misc again)
- Added more documentation to better describe the goal of this check
- Fixed macro test and added cases for memmove and memset


https://reviews.llvm.org/D22725

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseAlgorithmCheck.cpp
  clang-tidy/modernize/UseAlgorithmCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-algorithm.rst
  test/clang-tidy/modernize-use-algorithm.cpp

Index: test/clang-tidy/modernize-use-algorithm.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-algorithm.cpp
@@ -0,0 +1,53 @@
+// RUN: %check_clang_tidy %s modernize-use-algorithm %t
+
+// CHECK-FIXES: #include 
+
+namespace std {
+typedef unsigned int size_t;
+void *memcpy(void *dest, const void *src, std::size_t count);
+void *memset(void* dest, int ch, std::size_t count);
+void *memmove(void* dest, const void* src, std::size_t count);
+
+template 
+OutputIt copy(InputIt first, InputIt last, OutputIt d_first);
+
+template
+OutputIt move(InputIt first, InputIt last, OutputIt d_first);
+
+template
+void fill(ForwardIt first, ForwardIt last, const T& value);
+}
+
+void a() {
+  char foo[] = "foo", bar[3];
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Use std::copy instead of memcpy [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+
+  std::copy(foo, foo + sizeof bar, bar);
+}
+
+void b() {
+  char foo[] = "foobar";
+  std::memmove(foo + 1, foo , 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Use std::move instead of memmove [modernize-use-algorithm]
+  // CHECK-FIXES: std::move(foo, foo + 3, foo + 1);
+
+  std::move(foo, foo + 2, foo + 2);
+}
+
+void c() {
+  char foo[] = "foobar";
+  std::memset(foo, 1, 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Use std::fill instead of memset [modernize-use-algorithm]
+  // CHECK-FIXES: std::fill(foo, foo + 3, 1);
+
+  std::move(foo, foo + 2, 'a');
+}
+
+#define MEMCPY(dest, src) std::memcpy((dest), (src), sizeof (dest))
+void d() {
+  char foo[] = "foo", bar[3];
+  MEMCPY(bar, foo);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Use std::copy instead of memcpy [modernize-use-algorithm]
+}
Index: docs/clang-tidy/checks/modernize-use-algorithm.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/modernize-use-algorithm.rst
@@ -0,0 +1,49 @@
+.. title:: clang-tidy - modernize-use-algorithm
+
+modernize-use-algorithm
+===
+
+Replaces calls to ``memcpy``, ``memmove`` and ``memset`` with ``std::copy``,
+``std::move`` and ``std::fill`` respectively. The advantages of using these
+algorithm functions is that they are at least as efficient, more general and
+type-aware.
+
+Furthermore, by using the algorithms the types remain intact as opposed to
+being discarded by the C-style functions. This allows the implementation to
+make use use of type information to further optimize. One example of such
+optimization is taking advantage of 64-bit alignment when copying an array of
+``std::uint64_t``.
+
+memcpy
+--
+
+.. code:: c++
+
+std::memcpy(dest, source, sizeof dest);
+
+// transforms to:
+
+std::copy(source, source + sizeof dest, dest);
+
+memmove
+---
+
+.. code:: c++
+
+std::memmove(dest, source, sizeof dest);
+
+// transforms to:
+
+std::move(source, source + sizeof dest, dest);
+
+memset
+--
+
+.. code:: c++
+
+std::memset(dest, ch, count);
+
+// transforms to:
+
+std::fill(dest, dest + count, ch)
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -29,6 +29,7 @@
cppcoreguidelines-pro-type-static-cast-downcast
cppcoreguidelines-pro-type-union-access
cppcoreguidelines-pro-type-vararg
+   cppcoreguidelines-slicing
google-build-explicit-make-pair
google-build-namespaces
google-build-using-namespace
@@ -103,6 +104,7 @@
modernize-shrink-to-fit
modernize-use-auto
modernize-use-bool-literals
+   modernize-use-algorithm
modernize-use-default
modernize-use-emplace
modernize-use-nullptr
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -64,6 +64,13 @@
 
   Flags slicing of member variables or vtable.
 
+- New `modernize-use-algorithm
+  `_ check
+
+  Rep

r276564 - [X86] Block pbroadcastq instructions on 32-bit targets instead of pbroadcastb.

2016-07-24 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sun Jul 24 09:58:06 2016
New Revision: 276564

URL: http://llvm.org/viewvc/llvm-project?rev=276564&view=rev
Log:
[X86] Block pbroadcastq instructions on 32-bit targets instead of pbroadcastb.

Thanks to Simon Pilgrim for catching the mistake.

Modified:
cfe/trunk/lib/Headers/avx512bwintrin.h
cfe/trunk/lib/Headers/avx512vlbwintrin.h
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/lib/Headers/avx512bwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512bwintrin.h?rev=276564&r1=276563&r2=276564&view=diff
==
--- cfe/trunk/lib/Headers/avx512bwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512bwintrin.h Sun Jul 24 09:58:06 2016
@@ -2099,7 +2099,6 @@ _mm512_maskz_mov_epi8 (__mmask64 __U, __
 (__v64qi) _mm512_setzero_hi ());
 }
 
-#ifdef __x86_64__
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 _mm512_mask_set1_epi8 (__m512i __O, __mmask64 __M, char __A)
 {
@@ -2116,7 +2115,6 @@ _mm512_maskz_set1_epi8 (__mmask64 __M, c
  _mm512_setzero_qi(),
  __M);
 }
-#endif
 
 static __inline__ __mmask64 __DEFAULT_FN_ATTRS
 _mm512_kunpackd (__mmask64 __A, __mmask64 __B)

Modified: cfe/trunk/lib/Headers/avx512vlbwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlbwintrin.h?rev=276564&r1=276563&r2=276564&view=diff
==
--- cfe/trunk/lib/Headers/avx512vlbwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlbwintrin.h Sun Jul 24 09:58:06 2016
@@ -2887,7 +2887,6 @@ _mm256_maskz_mov_epi8 (__mmask32 __U, __
 }
 
 
-#ifdef __x86_64__
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_mask_set1_epi8 (__m128i __O, __mmask16 __M, char __A)
 {
@@ -2921,7 +2920,6 @@ _mm256_maskz_set1_epi8 (__mmask32 __M, c
  _mm256_setzero_si256 (),
  __M);
 }
-#endif
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_mask_loadu_epi16 (__m128i __W, __mmask8 __U, void const *__P)

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=276564&r1=276563&r2=276564&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Sun Jul 24 09:58:06 2016
@@ -1620,9 +1620,9 @@ bool Sema::CheckX86BuiltinFunctionCall(u
   case X86::BI__builtin_ia32_rdgsbase64:
   case X86::BI__builtin_ia32_wrfsbase64:
   case X86::BI__builtin_ia32_wrgsbase64:
-  case X86::BI__builtin_ia32_pbroadcastb512_gpr_mask:
-  case X86::BI__builtin_ia32_pbroadcastb256_gpr_mask:
-  case X86::BI__builtin_ia32_pbroadcastb128_gpr_mask:
+  case X86::BI__builtin_ia32_pbroadcastq512_gpr_mask:
+  case X86::BI__builtin_ia32_pbroadcastq256_gpr_mask:
+  case X86::BI__builtin_ia32_pbroadcastq128_gpr_mask:
   case X86::BI__builtin_ia32_vcvtsd2si64:
   case X86::BI__builtin_ia32_vcvtsd2usi64:
   case X86::BI__builtin_ia32_vcvtss2si64:


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


r276557 - [analyzer] Pring LocationContext in ExplodedGraph dumps.

2016-07-24 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Sun Jul 24 03:15:58 2016
New Revision: 276557

URL: http://llvm.org/viewvc/llvm-project?rev=276557&view=rev
Log:
[analyzer] Pring LocationContext in ExplodedGraph dumps.

Remove some FIXMEs in the surrounding code,
which have been addressed long time ago
by introducing checker-specific tags.

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

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

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=276557&r1=276556&r2=276557&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Sun Jul 24 03:15:58 2016
@@ -2521,26 +2521,10 @@ struct DOTGraphTraits :
   // FIXME: Since we do not cache error nodes in ExprEngine now, this does not
   // work.
   static std::string getNodeAttributes(const ExplodedNode *N, void*) {
-
-#if 0
-  // FIXME: Replace with a general scheme to tell if the node is
-  // an error node.
-if (GraphPrintCheckerState->isImplicitNullDeref(N) ||
-GraphPrintCheckerState->isExplicitNullDeref(N) ||
-GraphPrintCheckerState->isUndefDeref(N) ||
-GraphPrintCheckerState->isUndefStore(N) ||
-GraphPrintCheckerState->isUndefControlFlow(N) ||
-GraphPrintCheckerState->isUndefResult(N) ||
-GraphPrintCheckerState->isBadCall(N) ||
-GraphPrintCheckerState->isUndefArg(N))
-  return "color=\"red\",style=\"filled\"";
-
-if (GraphPrintCheckerState->isNoReturnCall(N))
-  return "color=\"blue\",style=\"filled\"";
-#endif
 return "";
   }
 
+  // De-duplicate some source location pretty-printing.
   static void printLocation(raw_ostream &Out, SourceLocation SLoc) {
 if (SLoc.isFileID()) {
   Out << "\\lline="
@@ -2550,6 +2534,12 @@ struct DOTGraphTraits :
 << "\\l";
 }
   }
+  static void printLocation2(raw_ostream &Out, SourceLocation SLoc) {
+if (SLoc.isFileID() && GraphPrintSourceManager->isInMainFile(SLoc))
+  Out << "line " << GraphPrintSourceManager->getExpansionLineNumber(SLoc);
+else
+  SLoc.print(Out, *GraphPrintSourceManager);
+  }
 
   static std::string getNodeLabel(const ExplodedNode *N, void*){
 
@@ -2563,12 +2553,6 @@ struct DOTGraphTraits :
   case ProgramPoint::BlockEntranceKind: {
 Out << "Block Entrance: B"
 << Loc.castAs().getBlock()->getBlockID();
-if (const NamedDecl *ND =
-dyn_cast(Loc.getLocationContext()->getDecl())) {
-  Out << " (";
-  ND->printName(Out);
-  Out << ")";
-}
 break;
   }
 
@@ -2693,13 +2677,6 @@ struct DOTGraphTraits :
   Out << "\\l";
 }
 
-#if 0
-  // FIXME: Replace with a general scheme to determine
-  // the name of the check.
-if (GraphPrintCheckerState->isUndefControlFlow(N)) {
-  Out << "\\|Control-flow based on\\lUndefined value.\\l";
-}
-#endif
 break;
   }
 
@@ -2721,27 +2698,6 @@ struct DOTGraphTraits :
 else if (Loc.getAs())
   Out << "\\lPostLValue\\l";
 
-#if 0
-  // FIXME: Replace with a general scheme to determine
-  // the name of the check.
-if (GraphPrintCheckerState->isImplicitNullDeref(N))
-  Out << "\\|Implicit-Null Dereference.\\l";
-else if (GraphPrintCheckerState->isExplicitNullDeref(N))
-  Out << "\\|Explicit-Null Dereference.\\l";
-else if (GraphPrintCheckerState->isUndefDeref(N))
-  Out << "\\|Dereference of undefialied value.\\l";
-else if (GraphPrintCheckerState->isUndefStore(N))
-  Out << "\\|Store to Undefined Loc.";
-else if (GraphPrintCheckerState->isUndefResult(N))
-  Out << "\\|Result of operation is undefined.";
-else if (GraphPrintCheckerState->isNoReturnCall(N))
-  Out << "\\|Call to function marked \"noreturn\".";
-else if (GraphPrintCheckerState->isBadCall(N))
-  Out << "\\|Call to NULL/Undefined.";
-else if (GraphPrintCheckerState->isUndefArg(N))
-  Out << "\\|Argument in call is undefined";
-#endif
-
 break;
   }
 }
@@ -2749,6 +2705,40 @@ struct DOTGraphTraits :
 ProgramStateRef state = N->getState();
 Out << "\\|StateID: " << (const void*) state.get()
 << " NodeID: " << (const void*) N << "\\|";
+
+// Analysis stack backtrace.
+Out << "Location context stack (from current to outer):\\l";
+const LocationContext *LC = Loc.getLocationContext();
+unsigned Idx = 0;
+for (; LC; LC = LC->getParent(), ++Idx) {
+  Out << Idx << ". (" << (const void *)LC << ") ";
+  switch (LC->getKind()) {
+  case LocationContext::StackFrame:
+if (const NamedDecl *D = dyn_cast(LC->getDecl()))
+  Out << "Calli

Re: [PATCH] D22045: [X86] Support of no_caller_saved_registers attribute (Clang part)

2016-07-24 Thread Amjad Aboud via cfe-commits
aaboud updated this revision to Diff 65269.
aaboud added a comment.

Updated test according to comments.


https://reviews.llvm.org/D22045

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/CodeGen/CGCall.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGenCXX/attr-x86-no_caller_saved_registers.cpp
  test/SemaCXX/attr-x86-no_caller_saved_registers.cpp

Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1673,6 +1673,8 @@
   RetAttrs.addAttribute(llvm::Attribute::NoAlias);
 if (TargetDecl->hasAttr())
   RetAttrs.addAttribute(llvm::Attribute::NonNull);
+if (TargetDecl->hasAttr())
+  FuncAttrs.addAttribute("no_caller_saved_registers");
 
 HasAnyX86InterruptAttr = TargetDecl->hasAttr();
 HasOptnone = TargetDecl->hasAttr();
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5910,6 +5910,10 @@
 handleTypeTagForDatatypeAttr(S, D, Attr);
 break;
 
+  case AttributeList::AT_AnyX86NoCallerSavedRegisters:
+handleSimpleAttribute(S, D, Attr);
+break;
+
   case AttributeList::AT_RenderScriptKernel:
 handleSimpleAttribute(S, D, Attr);
 break;
Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -2170,6 +2170,20 @@
   }];
 }
 
+def AnyX86NoCallerSavedRegistersDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Use this attribute to indicate that the specified function has no
+caller-saved registers.  That is, all registers are callee-saved.
+The compiler generates proper function entry and exit sequences to
+save and restore any modified registers.
+
+The user can call functions specified with the 'no_caller_saved_registers'
+attribute from an interrupt handler without saving and restoring all
+call clobbered registers.
+  }];
+}
+
 def SwiftCallDocs : Documentation {
   let Category = DocCatVariable;
   let Content = [{
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -1652,6 +1652,13 @@
   let Documentation = [AnyX86InterruptDocs];
 }
 
+def AnyX86NoCallerSavedRegisters : InheritableAttr,
+   TargetSpecificAttr {
+  let Spellings = [GNU<"no_caller_saved_registers">];
+  let Subjects = SubjectList<[FunctionLike], WarnDiag, "ExpectedFunction">;
+  let Documentation = [AnyX86NoCallerSavedRegistersDocs];
+}
+
 def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr {
   let Spellings = [GNU<"force_align_arg_pointer">];
   // Technically, this appertains to a FunctionDecl, but the target-specific
Index: test/SemaCXX/attr-x86-no_caller_saved_registers.cpp
===
--- test/SemaCXX/attr-x86-no_caller_saved_registers.cpp
+++ test/SemaCXX/attr-x86-no_caller_saved_registers.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-win32 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple i386-pc-win32 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnux32 -fsyntax-only -verify %s
+
+struct a {
+  int b __attribute__((no_caller_saved_registers)); // expected-warning {{'no_caller_saved_registers' attribute only applies to functions}}
+  static void foo(int *a) __attribute__((no_caller_saved_registers)) {}
+};
+
+struct a test __attribute__((no_caller_saved_registers)); // expected-warning {{'no_caller_saved_registers' attribute only applies to functions}}
+
+__attribute__((no_caller_saved_registers(999))) void bar(int *) {} // expected-error {{'no_caller_saved_registers' attribute takes no arguments}}
+
+__attribute__((no_caller_saved_registers)) void foo(int *) {}
+
+int main(int argc, char **argv) {
+  a::foo(&argc);
+  foo(&argc);
+  return 0;
+}
Index: test/CodeGenCXX/attr-x86-no_caller_saved_registers.cpp
===
--- test/CodeGenCXX/attr-x86-no_caller_saved_registers.cpp
+++ test/CodeGenCXX/attr-x86-no_caller_saved_registers.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i386-unknown-linux-gnu %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-win32 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i386-pc-win32 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnux32 %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: foo{{[^#]*}}#[[ATTRS:[0-9]+]]
+__attribute__((no_caller_saved_registe

Re: [PATCH] D22045: [X86] Support of no_caller_saved_registers attribute (Clang part)

2016-07-24 Thread Amjad Aboud via cfe-commits
aaboud marked an inline comment as done.


Comment at: include/clang/Basic/Attr.td:1657
@@ +1656,3 @@
+   TargetSpecificAttr {
+  let Spellings = [GNU<"no_caller_saved_registers">];
+  let Subjects = SubjectList<[FunctionLike], WarnDiag, "ExpectedFunction">;

aaron.ballman wrote:
> Any particular reason this isn't (also) a C++-style attribute under the clang 
> namespace?
I am not sure about that, I was just following the way the "interrupt" 
attribute was defined.
Do you think we should change both to consider C++ style attribute as well?


Comment at: include/clang/Basic/AttrDocs.td:2177
@@ +2176,3 @@
+Use this attribute to indicate that the specified function has no
+caller-saved registers.  That is, all registers are callee-saved.
+The compiler generates proper function entry and exit sequences to

aaron.ballman wrote:
> How does this interact with calling convention attributes? For instance, if I 
> have a function that is explicitly marked cdecl and has this attribute, what 
> is the behavior for EAX, ECX, and EDX?
> 
> Also, why is this an attribute rather than a calling convention? I'm 
> wondering how this works through function pointers, for instance (whether it 
> is intended to work or not).
Please, correct me if I am mistaken, but calling convention determine not only 
what the callee and the caller function saved registers are, but also how we 
move parameters to the called function, right?

The idea behind no_caller_saved_registers attribute, is that it can be combined 
with any other calling convention, and it only override the callee/caller saved 
register list, but not the way parameters are passed to the called function.

So, using a calling convention for this attribute will not be right.

H.J., can you confirm this?


https://reviews.llvm.org/D22045



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


Re: [PATCH] D22712: Remove FileEntry copy-constructor

2016-07-24 Thread Benjamin Kramer via cfe-commits
bkramer added a comment.

As far as I know we still support GCC 4.7, which doesn't have emplace in 
std::map. I don't think this patch will work with 4.7. Should we drop support 
for 4.7?


https://reviews.llvm.org/D22712



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


Re: [PATCH] D22622: [analyzer] Add more info to exploded graph dumps

2016-07-24 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL276557: [analyzer] Pring LocationContext in ExplodedGraph 
dumps. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D22622?vs=65223&id=65267#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22622

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

Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -2521,26 +2521,10 @@
   // FIXME: Since we do not cache error nodes in ExprEngine now, this does not
   // work.
   static std::string getNodeAttributes(const ExplodedNode *N, void*) {
-
-#if 0
-  // FIXME: Replace with a general scheme to tell if the node is
-  // an error node.
-if (GraphPrintCheckerState->isImplicitNullDeref(N) ||
-GraphPrintCheckerState->isExplicitNullDeref(N) ||
-GraphPrintCheckerState->isUndefDeref(N) ||
-GraphPrintCheckerState->isUndefStore(N) ||
-GraphPrintCheckerState->isUndefControlFlow(N) ||
-GraphPrintCheckerState->isUndefResult(N) ||
-GraphPrintCheckerState->isBadCall(N) ||
-GraphPrintCheckerState->isUndefArg(N))
-  return "color=\"red\",style=\"filled\"";
-
-if (GraphPrintCheckerState->isNoReturnCall(N))
-  return "color=\"blue\",style=\"filled\"";
-#endif
 return "";
   }
 
+  // De-duplicate some source location pretty-printing.
   static void printLocation(raw_ostream &Out, SourceLocation SLoc) {
 if (SLoc.isFileID()) {
   Out << "\\lline="
@@ -2550,6 +2534,12 @@
 << "\\l";
 }
   }
+  static void printLocation2(raw_ostream &Out, SourceLocation SLoc) {
+if (SLoc.isFileID() && GraphPrintSourceManager->isInMainFile(SLoc))
+  Out << "line " << GraphPrintSourceManager->getExpansionLineNumber(SLoc);
+else
+  SLoc.print(Out, *GraphPrintSourceManager);
+  }
 
   static std::string getNodeLabel(const ExplodedNode *N, void*){
 
@@ -2563,12 +2553,6 @@
   case ProgramPoint::BlockEntranceKind: {
 Out << "Block Entrance: B"
 << Loc.castAs().getBlock()->getBlockID();
-if (const NamedDecl *ND =
-dyn_cast(Loc.getLocationContext()->getDecl())) {
-  Out << " (";
-  ND->printName(Out);
-  Out << ")";
-}
 break;
   }
 
@@ -2693,13 +2677,6 @@
   Out << "\\l";
 }
 
-#if 0
-  // FIXME: Replace with a general scheme to determine
-  // the name of the check.
-if (GraphPrintCheckerState->isUndefControlFlow(N)) {
-  Out << "\\|Control-flow based on\\lUndefined value.\\l";
-}
-#endif
 break;
   }
 
@@ -2721,34 +2698,47 @@
 else if (Loc.getAs())
   Out << "\\lPostLValue\\l";
 
-#if 0
-  // FIXME: Replace with a general scheme to determine
-  // the name of the check.
-if (GraphPrintCheckerState->isImplicitNullDeref(N))
-  Out << "\\|Implicit-Null Dereference.\\l";
-else if (GraphPrintCheckerState->isExplicitNullDeref(N))
-  Out << "\\|Explicit-Null Dereference.\\l";
-else if (GraphPrintCheckerState->isUndefDeref(N))
-  Out << "\\|Dereference of undefialied value.\\l";
-else if (GraphPrintCheckerState->isUndefStore(N))
-  Out << "\\|Store to Undefined Loc.";
-else if (GraphPrintCheckerState->isUndefResult(N))
-  Out << "\\|Result of operation is undefined.";
-else if (GraphPrintCheckerState->isNoReturnCall(N))
-  Out << "\\|Call to function marked \"noreturn\".";
-else if (GraphPrintCheckerState->isBadCall(N))
-  Out << "\\|Call to NULL/Undefined.";
-else if (GraphPrintCheckerState->isUndefArg(N))
-  Out << "\\|Argument in call is undefined";
-#endif
-
 break;
   }
 }
 
 ProgramStateRef state = N->getState();
 Out << "\\|StateID: " << (const void*) state.get()
 << " NodeID: " << (const void*) N << "\\|";
+
+// Analysis stack backtrace.
+Out << "Location context stack (from current to outer):\\l";
+const LocationContext *LC = Loc.getLocationContext();
+unsigned Idx = 0;
+for (; LC; LC = LC->getParent(), ++Idx) {
+  Out << Idx << ". (" << (const void *)LC << ") ";
+  switch (LC->getKind()) {
+  case LocationContext::StackFrame:
+if (const NamedDecl *D = dyn_cast(LC->getDecl()))
+  Out << "Calling " << D->getQualifiedNameAsString();
+else
+  Out << "Calling anonymous code";
+if (const Stmt *S = cast(LC)->getCallSite()) {
+  Out << " at ";
+  printLocation2(Out, S->getLocStart());
+}
+break;
+  case LocationContext::Block:
+Out << "Invoking block";
+if (const Decl *D = cast(LC)->getBlockDecl()) {
+  Out << "

[libcxx] r276558 - commit test missing from r276556

2016-07-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 24 03:16:37 2016
New Revision: 276558

URL: http://llvm.org/viewvc/llvm-project?rev=276558&view=rev
Log:
commit test missing from r276556

Added:
libcxx/trunk/test/libcxx/utilities/utility/utility.inplace/

libcxx/trunk/test/libcxx/utilities/utility/utility.inplace/__is_inplace_type.pass.cpp

Added: 
libcxx/trunk/test/libcxx/utilities/utility/utility.inplace/__is_inplace_type.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/utilities/utility/utility.inplace/__is_inplace_type.pass.cpp?rev=276558&view=auto
==
--- 
libcxx/trunk/test/libcxx/utilities/utility/utility.inplace/__is_inplace_type.pass.cpp
 (added)
+++ 
libcxx/trunk/test/libcxx/utilities/utility/utility.inplace/__is_inplace_type.pass.cpp
 Sun Jul 24 03:16:37 2016
@@ -0,0 +1,27 @@
+//===--===//
+//
+// 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, c++11, c++14
+
+// 
+
+// template 
+// struct __is_inplace_type;
+
+#include 
+#include 
+
+int main() {
+static_assert(std::__is_inplace_type::value, "");
+static_assert(std::__is_inplace_type>::value, 
"");
+
static_assert(std::__is_inplace_type(-1)>>::value,
 "");
+static_assert(!std::__is_inplace_type::value, "");
+static_assert(!std::__is_inplace_type::value, "");
+static_assert(!std::__is_inplace_type::value, 
"");
+}
\ No newline at end of file


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


[libcxx] r276556 - Add __is_inplace_type metafunction helper

2016-07-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jul 24 02:42:13 2016
New Revision: 276556

URL: http://llvm.org/viewvc/llvm-project?rev=276556&view=rev
Log:
Add __is_inplace_type metafunction helper

Modified:
libcxx/trunk/include/utility

Modified: libcxx/trunk/include/utility
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/utility?rev=276556&r1=276555&r2=276556&view=diff
==
--- libcxx/trunk/include/utility (original)
+++ libcxx/trunk/include/utility Sun Jul 24 02:42:13 2016
@@ -849,6 +849,11 @@ inline in_place_tag in_place(__in_place_
 return in_place_tag(__in_place_tag{});
 }
 
+templatestruct __is_inplace_type : false_type {};
+template <>struct __is_inplace_type : true_type {};
+templatestruct __is_inplace_type> : 
true_type {};
+template  struct __is_inplace_type> : 
true_type {};
+
 #endif // _LIBCPP_STD_VER > 14
 
 _LIBCPP_END_NAMESPACE_STD


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


Re: [PATCH] D22712: Remove FileEntry copy-constructor

2016-07-24 Thread Alexander Shaposhnikov via cfe-commits
alexshap added a comment.

no, i don't.


https://reviews.llvm.org/D22712



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


Re: [PATCH] D22725: [clang-tidy] Add check 'misc-replace-memcpy'

2016-07-24 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

In https://reviews.llvm.org/D22725#493970, @JDevlieghere wrote:

> In https://reviews.llvm.org/D22725#493947, @Prazek wrote:
>
> > Thanks for the contribution. Is it your first check?
>
>
> Yes, it is! :-)


Cool! hope to see some other cool checks. You could probably use pretty much 
the same code, and make modernize-use-fill for replacing memset and
modernize-use-move to change memmove -> move. The other thing that I can think 
of, is also to detect when you could use std::copy_n istead.

Maybe the right way would be to have check called 
'modernize-use-sequence-algorithm' or just 'modernize-use-algorithm' that would 
basically do all those stuff. It would be good to not introduce 5 new check 
that pretty much do the same thing and also the user would want to have them 
all or none.
You can look how I did it with modernize-use-make-shared, it would be pretty 
much the same.

> I have included an example in the documentation with the ternary conditional 
> operator. I agree that it's not ideal, but I tried to be defensive. Basically 
> anything with lower precedence than the + operator might cause an issue, and 
> this is quite a lot...


So It should not be very hard. You would just have to check if the second or 
third argument to memcpy is one of [list here] of the things that 
would make it bad. And you can probably write easy matcher for this.
I understand that it probably will take the double of time that you have spend 
on this check, but this will actually is the thing here - you want your check 
to produce the fixes that makes sense. When you will run it on llvm code base, 
I guess you will see that over 90% of the cases didn't require coma. I 
understand that you want to make it accurate, but the fix should not also 
intoruce some code that is not tidy enough.
So I guess either fix it, or wait what Alex will say about it. It might make it 
to upstream like this, but I hope you would fix it in some time :)

Anyway good job, hope to see some more checks from you!

> > 4. Have you run the check on LLVM code base? It uses std::copy in many 
> > places. If after running with -fix all the memcpys will be gone (check if 
> > if finds anything after second run) and the code will compile and tests 
> > will not fail then it means that your check fully works!

> 

> 

> Doing this as we speak!


When you will be finished just post a diff of changes after running it on llvm 
on phabricator and add me as subscriber :)



Comment at: clang-tidy/modernize/UseCopyCheck.cpp:38
@@ +37,3 @@
+  // Match calls to memcpy with 3 arguments
+  Finder->addMatcher(callExpr(allOf(callee(functionDecl(hasName("memcpy"))),
+argumentCountIs(3)))

change memcpy to ::std::memcpy, and also make a test with some memcpy that is 
outside of std namespace.
You don't want to change someone else code because it uses the same name :)


Repository:
  rL LLVM

https://reviews.llvm.org/D22725



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


Re: [PATCH] D22725: [clang-tidy] Add check 'misc-replace-memcpy'

2016-07-24 Thread Piotr Padlewski via cfe-commits
Prazek added inline comments.


Comment at: clang-tidy/modernize/UseCopyCheck.cpp:49
@@ +48,3 @@
+  if (getLangOpts().CPlusPlus) {
+Inserter.reset(new utils::IncludeInserter(
+Compiler.getSourceManager(), Compiler.getLangOpts(), IncludeStyle));

there is actually llvm::make_shared somewhere


Comment at: clang-tidy/modernize/UseCopyCheck.cpp:59-61
@@ +58,5 @@
+
+  // Don't make replacements in macro
+  if (Loc.isMacroID())
+return;
+

What you should do is you should print out the warning, but not make the 
replacement for macro (because you can't get the exact location)


So just move auto Diag = ... above this line.

Also finish comments with coma.


Comment at: test/clang-tidy/modernize-use-copy.cpp:17
@@ +16,3 @@
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Use std::copy instead of memcpy
+  // [modernize-use-copy]
+  // CHECK-FIXES: std::copy(foo, (foo) + (sizeof bar), bar);

This won't be checked. The long checking comments are ok in tests.


Comment at: test/clang-tidy/modernize-use-copy.cpp:34
@@ +33,3 @@
+
+#define memcpy(dest, src, len) std::memcpy((dest), (src), (len))
+void g() {

change it to MEMCPY, and maybe remove the last argument (so it will be set to 
sizeof dest), because this macro doesn't make much sense right now.


Comment at: test/clang-tidy/modernize-use-copy.cpp:37
@@ +36,3 @@
+  char foo[] = "foo", bar[3];
+  memcpy(bar, foo, sizeof bar);
+}

so ter should be a warning here.


Repository:
  rL LLVM

https://reviews.llvm.org/D22725



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