r301742 - Remove Sema::CheckForIntOverflow, and instead check all full-expressions.

2017-04-29 Thread Nick Lewycky via cfe-commits
Author: nicholas
Date: Sat Apr 29 04:33:46 2017
New Revision: 301742

URL: http://llvm.org/viewvc/llvm-project?rev=301742&view=rev
Log:
Remove Sema::CheckForIntOverflow, and instead check all full-expressions.

CheckForIntOverflow used to implement a whitelist of top-level expressions to
send to the constant expression evaluator, which handled many more expressions
than the CheckForIntOverflow whitelist did.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_aligned_messages.cpp
cfe/trunk/test/OpenMP/distribute_simd_aligned_messages.cpp
cfe/trunk/test/OpenMP/for_simd_aligned_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_aligned_messages.cpp
cfe/trunk/test/OpenMP/simd_aligned_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_aligned_messages.cpp
cfe/trunk/test/OpenMP/target_simd_aligned_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_aligned_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_aligned_messages.cpp
cfe/trunk/test/OpenMP/taskloop_simd_aligned_messages.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_aligned_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_aligned_messages.cpp
cfe/trunk/test/Sema/integer-overflow.c

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=301742&r1=301741&r2=301742&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Sat Apr 29 04:33:46 2017
@@ -10160,7 +10160,6 @@ private:
   void CheckFloatComparison(SourceLocation Loc, Expr* LHS, Expr* RHS);
   void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation());
   void CheckBoolLikeConversion(Expr *E, SourceLocation CC);
-  void CheckForIntOverflow(Expr *E);
   void CheckUnsequencedOperations(Expr *E);
 
   /// \brief Perform semantic checks on a completed expression. This will 
either

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=301742&r1=301741&r2=301742&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Sat Apr 29 04:33:46 2017
@@ -6217,6 +6217,10 @@ bool RecordExprEvaluator::VisitInitListE
 // the initializer list.
 ImplicitValueInitExpr VIE(HaveInit ? Info.Ctx.IntTy : Field->getType());
 const Expr *Init = HaveInit ? E->getInit(ElementNo++) : &VIE;
+if (Init->isValueDependent()) {
+  Success = false;
+  continue;
+}
 
 // Temporarily override This, in case there's a CXXDefaultInitExpr in here.
 ThisOverrideRAII ThisOverride(*Info.CurrentCall, &This,
@@ -9927,7 +9931,8 @@ static bool EvaluateAsRValue(EvalInfo &I
 }
 
 static bool FastEvaluateAsRValue(const Expr *Exp, Expr::EvalResult &Result,
- const ASTContext &Ctx, bool &IsConst) {
+ const ASTContext &Ctx, bool &IsConst,
+ bool IsCheckingForOverflow) {
   // Fast-path evaluations of integer literals, since we sometimes see files
   // containing vast quantities of these.
   if (const IntegerLiteral *L = dyn_cast(Exp)) {
@@ -9948,7 +9953,7 @@ static bool FastEvaluateAsRValue(const E
   // performance problems. Only do so in C++11 for now.
   if (Exp->isRValue() && (Exp->getType()->isArrayType() ||
   Exp->getType()->isRecordType()) &&
-  !Ctx.getLangOpts().CPlusPlus11) {
+  !Ctx.getLangOpts().CPlusPlus11 && !IsCheckingForOverflow) {
 IsConst = false;
 return true;
   }
@@ -9963,7 +9968,7 @@ static bool FastEvaluateAsRValue(const E
 /// will be applied to the result.
 bool Expr::EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx) const {
   bool IsConst;
-  if (FastEvaluateAsRValue(this, Result, Ctx, IsConst))
+  if (FastEvaluateAsRValue(this, Result, Ctx, IsConst, false))
 return IsConst;
   
   EvalInfo Info(Ctx, Result, EvalInfo::EM_IgnoreSideEffects);
@@ -10088,7 +10093,7 @@ APSInt Expr::EvaluateKnownConstInt(const
 void Expr::EvaluateForOverflow(const ASTContext &Ctx) const {
   bool IsConst;
   EvalResult EvalResult;
-  if (!FastEvaluateAsRValue(this, EvalResult, Ctx, IsConst)) {
+  if (!FastEvaluateAsRValue(this, EvalResult, Ctx, IsConst, true)) {
 EvalInfo Info(Ctx, EvalResult, EvalInfo::EM_EvaluateForOverflow);
 (void)::EvaluateAsRValue(Info, this, EvalResult.Val);
   }

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=301742&r1=301741&r2=301742&view=diff
===

[clang-tools-extra] r301743 - [clang-tidy] Expand AllowConditional*Casts to binary logical operators

2017-04-29 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Sat Apr 29 07:06:45 2017
New Revision: 301743

URL: http://llvm.org/viewvc/llvm-project?rev=301743&view=rev
Log:
[clang-tidy] Expand AllowConditional*Casts to binary logical operators

Modified:
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-allow-conditional-casts.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp?rev=301743&r1=301742&r2=301743&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp 
Sat Apr 29 07:06:45 2017
@@ -11,6 +11,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Lex/Lexer.h"
+#include 
 
 using namespace clang::ast_matchers;
 
@@ -281,20 +282,29 @@ void addFixItHintsForLiteralCastFromBool
  Context)));
 }
 
-StatementMatcher createConditionalExpressionMatcher() {
-  return stmt(anyOf(ifStmt(), conditionalOperator(),
-parenExpr(hasParent(conditionalOperator();
-}
-
 bool isAllowedConditionalCast(const ImplicitCastExpr *CastExpression,
   ASTContext &Context) {
-  auto AllowedConditionalMatcher = stmt(hasParent(stmt(
-  anyOf(createConditionalExpressionMatcher(),
-unaryOperator(hasOperatorName("!"),
-  hasParent(createConditionalExpressionMatcher()));
-
-  auto MatchResult = match(AllowedConditionalMatcher, *CastExpression, 
Context);
-  return !MatchResult.empty();
+  std::queue Q;
+  Q.push(CastExpression);
+  while (!Q.empty()) {
+for (const auto &N : Context.getParents(*Q.front())) {
+  const Stmt *S = N.get();
+  if (!S)
+return false;
+  if (isa(S) || isa(S))
+return true;
+  if (isa(S) || isa(S) ||
+  (isa(S) &&
+   cast(S)->getOpcode() == UO_LNot) ||
+  (isa(S) && cast(S)->isLogicalOp())) {
+Q.push(S);
+  } else {
+return false;
+  }
+}
+Q.pop();
+  }
+  return false;
 }
 
 } // anonymous namespace

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-allow-conditional-casts.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-allow-conditional-casts.cpp?rev=301743&r1=301742&r2=301743&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-allow-conditional-casts.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-allow-conditional-casts.cpp
 Sat Apr 29 07:06:45 2017
@@ -25,8 +25,11 @@ void regularImplicitCastIntegerToBoolIsN
 void implicitCastIntegerToBoolInConditionalsIsAllowed() {
   if (functionReturningInt()) {}
   if (!functionReturningInt()) {}
+  if (functionReturningInt() && functionReturningPointer()) {}
+  if (!functionReturningInt() && !functionReturningPointer()) {}
   int value1 = functionReturningInt() ? 1 : 2;
-  int value2 = ! functionReturningInt() ? 1 : 2;
+  int value2 = !functionReturningInt() ? 1 : 2;
+  int value3 = (functionReturningInt() && functionReturningPointer() || 
!functionReturningInt()) ? 1 : 2;
 }
 
 void regularImplicitCastPointerToBoolIsNotIgnored() {


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


[PATCH] D32385: [libcxx] optional: Implement LWG 2900 and P0602

2017-04-29 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 97188.
CaseyCarter retitled this revision from "[libcxx] Implement LWG 2900 "The copy 
and move constructors of optional are not constexpr"" to "[libcxx] optional: 
Implement LWG 2900 and P0602".
CaseyCarter edited the summary of this revision.
CaseyCarter added a comment.

- Define new macro `_MSVC_STL_VER` in msvc_stdlib_force_include.hpp to indicate 
that the VC++ standard library is being tested.
- Implement test coverage for P0602 "variant and optional should propagate 
copy/move triviality".


https://reviews.llvm.org/D32385

Files:
  include/optional
  
test/std/utilities/optional/optional.object/optional.object.assign/copy.pass.cpp
  
test/std/utilities/optional/optional.object/optional.object.assign/move.pass.cpp
  test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
  test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
  test/support/msvc_stdlib_force_include.hpp

Index: test/support/msvc_stdlib_force_include.hpp
===
--- test/support/msvc_stdlib_force_include.hpp
+++ test/support/msvc_stdlib_force_include.hpp
@@ -26,6 +26,11 @@
 #error This header may not be used when targeting libc++
 #endif
 
+// Indicates that we are using the MSVC standard library.
+#ifndef _MSVC_STL_VER
+#define _MSVC_STL_VER 42
+#endif
+
 struct AssertionDialogAvoider {
 AssertionDialogAvoider() {
 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
Index: test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
===
--- test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
+++ test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
@@ -10,7 +10,10 @@
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // 
 
-// optional(optional&& rhs);
+// constexpr optional(const optional&& rhs);
+//   If is_trivially_move_constructible_v is true,
+//this constructor shall be a constexpr constructor.
+
 
 #include 
 #include 
@@ -36,10 +39,10 @@
 void test_throwing_ctor() {
 #ifndef TEST_HAS_NO_EXCEPTIONS
 struct Z {
-  Z() : count(0) {}
-  Z(Z&& o) : count(o.count + 1)
-  { if (count == 2) throw 6; }
-  int count;
+Z() : count(0) {}
+Z(Z&& o) : count(o.count + 1)
+{ if (count == 2) throw 6; }
+int count;
 };
 Z z;
 optional rhs(std::move(z));
@@ -131,6 +134,48 @@
 #endif
 }
 
+constexpr bool test_constexpr()
+{
+{
+using T = int;
+optional o1{};
+optional o2 = std::move(o1);
+static_cast(o2);
+optional o3{T{42}};
+optional o4 = std::move(o3);
+static_cast(o4);
+}
+{
+struct T {
+constexpr T(int) {}
+T(T&&) = default;
+};
+optional o1{};
+optional o2 = std::move(o1);
+static_cast(o2);
+optional o3{T{42}};
+optional o4 = std::move(o3);
+static_cast(o4);
+}
+return true;
+}
+static_assert(test_constexpr(), "");
+
+template
+constexpr bool triviality_test =
+std::is_trivially_move_constructible>::value ==
+std::is_trivially_move_constructible::value;
+
+void test_triviality_extension() {
+#if defined(_LIBCPP_VER) || defined(_MSVC_STL_VER)
+static_assert(triviality_test, "");
+static_assert(triviality_test>, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+#endif
+}
 
 int main()
 {
@@ -178,9 +223,9 @@
 test();
 test(42);
 }
-{
-test_throwing_ctor();
-}
+
+test_throwing_ctor();
+
 {
 struct ThrowsMove {
   ThrowsMove() noexcept(false) {}
@@ -195,7 +240,7 @@
 };
 static_assert(std::is_nothrow_move_constructible>::value, "");
 }
-{
-test_reference_extension();
-}
+
+test_reference_extension();
+test_triviality_extension();
 }
Index: test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
===
--- test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
+++ test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
@@ -10,7 +10,9 @@
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // 
 
-// optional(const optional& rhs);
+// constexpr optional(const optional& rhs);
+//   If is_trivially_copy_constructible_v is true,
+//this constructor shall be a constexpr constructor.
 
 #include 
 #include 
@@ -35,10 +37,10 @@
 void test_throwing_ctor() {
 #ifndef TEST_HAS_NO_EXCEPTIONS
 struct Z {
-  Z() : count(0) {}
-  Z(Z const& o) : count(o.count + 1)
-  { if (count == 2) throw 6; }
-  int count;
+Z() : count(0) {}
+Z(Z const& o) :

[PATCH] D32670: Ensure showbase does not overflow do_put buffers

2017-04-29 Thread Dimitry Andric via Phabricator via cfe-commits
dim created this revision.
Herald added a subscriber: emaste.

In https://bugs.freebsd.org/207918, Daniel McRobb describes how using
std::showbase with ostreams can cause truncation of unsigned long long
when output format is octal.  In fact, this can even happen with
unsigned int and unsigned long.

To ensure this does not happen, add one additional character to the
do_put buffers if std::showbase is on.  Also add a test case.


https://reviews.llvm.org/D32670

Files:
  include/locale
  
test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minmax_showbase.pass.cpp

Index: test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minmax_showbase.pass.cpp
===
--- /dev/null
+++ test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minmax_showbase.pass.cpp
@@ -0,0 +1,132 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template  >
+//   class basic_ostream;
+
+// operator<<(short n);
+// operator<<(unsigned short n);
+// operator<<(int n);
+// operator<<(unsigned int n);
+// operator<<(long n);
+// operator<<(unsigned long n);
+// operator<<(long long n);
+// operator<<(unsigned long long n);
+
+//  Testing to make sure that the max length values are correctly inserted when
+//  using std::showbase
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+template 
+void test_min_oct(const char *expected)
+{
+std::stringstream ss;
+ss << std::oct << std::showbase << std::numeric_limits::min();
+assert(ss.str() == expected);
+}
+
+template 
+void test_max_oct(const char *expected)
+{
+std::stringstream ss;
+ss << std::oct << std::showbase << std::numeric_limits::max();
+assert(ss.str() == expected);
+}
+
+template 
+void test_min_dec(const char *expected)
+{
+std::stringstream ss;
+ss << std::dec << std::showbase << std::numeric_limits::min();
+assert(ss.str() == expected);
+}
+
+template 
+void test_max_dec(const char *expected)
+{
+std::stringstream ss;
+ss << std::dec << std::showbase << std::numeric_limits::max();
+assert(ss.str() == expected);
+}
+
+template 
+void test_min_hex(const char *expected)
+{
+std::stringstream ss;
+ss << std::hex << std::showbase << std::numeric_limits::min();
+assert(ss.str() == expected);
+}
+
+template 
+void test_max_hex(const char *expected)
+{
+std::stringstream ss;
+ss << std::hex << std::showbase << std::numeric_limits::max();
+assert(ss.str() == expected);
+}
+
+int main(void)
+{
+test_min_oct("010");
+test_min_dec("-32768");
+test_min_hex("0x8000");
+
+test_max_oct("017");
+test_max_dec("65535");
+test_max_hex("0x");
+
+test_min_oct("0200");
+test_min_dec("-2147483648");
+test_min_hex("0x8000");
+
+test_max_oct("0377");
+test_max_dec("4294967295");
+test_max_hex("0x");
+
+const bool long_is_32 = std::integral_constant::value; // avoid compiler warnings
+const bool long_is_64 = std::integral_constant::value; // avoid compiler warnings
+const bool long_long_is_64 = std::integral_constant::value; // avoid compiler warnings
+
+if (long_is_32) {
+test_min_oct("0200");
+test_min_dec("-2147483648");
+test_min_hex("0x8000");
+
+test_max_oct("0377");
+test_max_dec("4294967295");
+test_max_hex("0x");
+} else if (long_is_64) {
+test_min_oct("010");
+test_min_dec("-9223372036854775808");
+test_min_hex("0x8000");
+
+test_max_oct("017");
+test_max_dec("18446744073709551615");
+test_max_hex("0x");
+}
+if (long_long_is_64) {
+test_min_oct("010");
+test_min_dec("-9223372036854775808");
+test_min_hex("0x8000");
+
+test_max_oct("017");
+test_max_dec("18446744073709551615");
+test_max_hex("0x");
+}
+
+return 0;
+}
Index: include/locale
===
--- include/locale
+++ include/locale
@@ -1402,6 +1402,7 @@
 this->__format_int(__fmt+1, __len, true, __iob.flags());
 const unsigned __nbuf = (numeric_limits::digits / 3)
   + ((numeric_limits::digits % 3) != 0)
+  + ((__iob.flags() & ios_base::showbase) != 0)
   + 2;
 char __nar

[PATCH] D32670: Ensure showbase does not overflow do_put buffers

2017-04-29 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

Note: I copied some of the test case from https://reviews.llvm.org/rL227097, 
which had a similar case of a too short buffer.


https://reviews.llvm.org/D32670



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


[PATCH] D32671: [libcxx] [test] variant: test coverage for P0602 extension

2017-04-29 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter created this revision.

NOTE: Unlike my typical `variant` test PRs, this one is actually safe to merge 
- crazy, I know - since it only adds coverage while testing the VC++ STL.



- Define a new macro `_MSVC_STL_VER` to distinguish testing the VC++ standard 
library implementation in the style of `_LIBCPP_VER`.

- Enable the "constexpr extension" tests for variant's copy/move constructors 
on VC++

- Add some new "triviality extension" tests for variant's conformance to P0602, 
currently only enabled on VC++

- Workaround C1XX's buggy `__is_trivially_copyable` in the variant tests.


https://reviews.llvm.org/D32671

Files:
  test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
  test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp
  test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
  test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
  test/support/msvc_stdlib_force_include.hpp
  test/support/test.workarounds/c1xx_broken_is_trivially_copyable.pass.cpp
  test/support/test_workarounds.h

Index: test/support/test_workarounds.h
===
--- test/support/test_workarounds.h
+++ test/support/test_workarounds.h
@@ -15,6 +15,7 @@
 
 #if defined(TEST_COMPILER_C1XX)
 # define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
+# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
 #endif
 
 #endif // SUPPORT_TEST_WORKAROUNDS_H
Index: test/support/test.workarounds/c1xx_broken_is_trivially_copyable.pass.cpp
===
--- /dev/null
+++ test/support/test.workarounds/c1xx_broken_is_trivially_copyable.pass.cpp
@@ -0,0 +1,31 @@
+//===--===//
+//
+// 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
+
+// Verify TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE.
+
+#include 
+
+#include "test_workarounds.h"
+
+struct S {
+  S(S const&) = default;
+  S(S&&) = default;
+  S& operator=(S const&) = delete;
+  S& operator=(S&&) = delete;
+};
+
+int main() {
+#if defined(TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE)
+  static_assert(!std::is_trivially_copyable::value, "");
+#else
+  static_assert(std::is_trivially_copyable::value, "");
+#endif
+}
Index: test/support/msvc_stdlib_force_include.hpp
===
--- test/support/msvc_stdlib_force_include.hpp
+++ test/support/msvc_stdlib_force_include.hpp
@@ -26,6 +26,11 @@
 #error This header may not be used when targeting libc++
 #endif
 
+// Indicates that we are using the MSVC standard library.
+#ifndef _MSVC_STL_VER
+#define _MSVC_STL_VER 42
+#endif
+
 struct AssertionDialogAvoider {
 AssertionDialogAvoider() {
 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
Index: test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
===
--- test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
+++ test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
@@ -22,6 +22,7 @@
 #include 
 
 #include "test_macros.h"
+#include "test_workarounds.h"
 
 struct ThrowsMove {
   ThrowsMove(ThrowsMove &&) noexcept(false) {}
@@ -178,20 +179,48 @@
 }
 
 void test_constexpr_move_ctor_extension() {
-#ifdef _LIBCPP_VERSION
+#if defined(_LIBCPP_VER) || defined(_MSVC_STL_VER)
   using V = std::variant;
+#ifdef TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
+  static_assert(std::is_trivially_destructible::value, "");
+  static_assert(std::is_trivially_copy_constructible::value, "");
+  static_assert(std::is_trivially_move_constructible::value, "");
+  static_assert(!std::is_copy_assignable::value, "");
+  static_assert(!std::is_move_assignable::value, "");
+#else
   static_assert(std::is_trivially_copyable::value, "");
+#endif
   static_assert(std::is_trivially_move_constructible::value, "");
   static_assert(test_constexpr_ctor_extension_imp<0>(V(42l)), "");
   static_assert(test_constexpr_ctor_extension_imp<1>(V(nullptr)), "");
   static_assert(test_constexpr_ctor_extension_imp<2>(V(101)), "");
 #endif
 }
 
+template
+constexpr bool triviality_test =
+  std::is_trivially_move_constructible>::value ==
+std::conjunction...>::value;
+
+void test_triviality_extension() {
+#if defined(_MSVC_STL_VER)
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_tes

r301749 - [X86][AVX] Added support for _mm256_zext* helper intrinsics (PR32839)

2017-04-29 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Sat Apr 29 12:17:06 2017
New Revision: 301749

URL: http://llvm.org/viewvc/llvm-project?rev=301749&view=rev
Log:
[X86][AVX] Added support for _mm256_zext* helper intrinsics (PR32839)

Modified:
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/lib/Headers/avxintrin.h
cfe/trunk/test/CodeGen/avx-builtins.c
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=301749&r1=301748&r2=301749&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Sat Apr 29 12:17:06 2017
@@ -528,6 +528,116 @@ _mm512_mask2int(__mmask16 __a)
   return (int)__a;
 }
 
+/// \brief Constructs a 512-bit floating-point vector of [8 x double] from a
+///128-bit floating-point vector of [2 x double]. The lower 128 bits
+///contain the value of the source vector. The upper 384 bits are set
+///to zero.
+///
+/// \headerfile 
+///
+/// This intrinsic has no corresponding instruction.
+///
+/// \param __a
+///A 128-bit vector of [2 x double].
+/// \returns A 512-bit floating-point vector of [8 x double]. The lower 128 
bits
+///contain the value of the parameter. The upper 384 bits are set to zero.
+static __inline __m512d __DEFAULT_FN_ATTRS
+_mm512_zextpd128_pd512(__m128d __a)
+{
+  return __builtin_shufflevector((__v2df)__a, (__v2df)_mm_setzero_pd(), 0, 1, 
2, 3, 2, 3, 2, 3);
+}
+
+/// \brief Constructs a 512-bit floating-point vector of [8 x double] from a
+///256-bit floating-point vector of [4 x double]. The lower 256 bits
+///contain the value of the source vector. The upper 256 bits are set
+///to zero.
+///
+/// \headerfile 
+///
+/// This intrinsic has no corresponding instruction.
+///
+/// \param __a
+///A 256-bit vector of [4 x double].
+/// \returns A 512-bit floating-point vector of [8 x double]. The lower 256 
bits
+///contain the value of the parameter. The upper 256 bits are set to zero.
+static __inline __m512d __DEFAULT_FN_ATTRS
+_mm512_zextpd256_pd512(__m256d __a)
+{
+  return __builtin_shufflevector((__v4df)__a, (__v4df)_mm256_setzero_pd(), 0, 
1, 2, 3, 4, 5, 6, 7);
+}
+
+/// \brief Constructs a 512-bit floating-point vector of [16 x float] from a
+///128-bit floating-point vector of [4 x float]. The lower 128 bits contain
+///the value of the source vector. The upper 384 bits are set to zero.
+///
+/// \headerfile 
+///
+/// This intrinsic has no corresponding instruction.
+///
+/// \param __a
+///A 128-bit vector of [4 x float].
+/// \returns A 512-bit floating-point vector of [16 x float]. The lower 128 
bits
+///contain the value of the parameter. The upper 384 bits are set to zero.
+static __inline __m512 __DEFAULT_FN_ATTRS
+_mm512_zextps128_ps512(__m128 __a)
+{
+  return __builtin_shufflevector((__v4sf)__a, (__v4sf)_mm_setzero_ps(), 0, 1, 
2, 3, 4, 5, 6, 7, 4, 5, 6, 7, 4, 5, 6, 7);
+}
+
+/// \brief Constructs a 512-bit floating-point vector of [16 x float] from a
+///256-bit floating-point vector of [8 x float]. The lower 256 bits contain
+///the value of the source vector. The upper 256 bits are set to zero.
+///
+/// \headerfile 
+///
+/// This intrinsic has no corresponding instruction.
+///
+/// \param __a
+///A 256-bit vector of [8 x float].
+/// \returns A 512-bit floating-point vector of [16 x float]. The lower 256 
bits
+///contain the value of the parameter. The upper 256 bits are set to zero.
+static __inline __m512 __DEFAULT_FN_ATTRS
+_mm512_zextps256_ps512(__m256 __a)
+{
+  return __builtin_shufflevector((__v8sf)__a, (__v8sf)_mm256_setzero_ps(), 0, 
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+}
+
+/// \brief Constructs a 512-bit integer vector from a 128-bit integer vector.
+///The lower 128 bits contain the value of the source vector. The upper
+///384 bits are set to zero.
+///
+/// \headerfile 
+///
+/// This intrinsic has no corresponding instruction.
+///
+/// \param __a
+///A 128-bit integer vector.
+/// \returns A 512-bit integer vector. The lower 128 bits contain the value of
+///the parameter. The upper 384 bits are set to zero.
+static __inline __m512i __DEFAULT_FN_ATTRS
+_mm512_zextsi128_si512(__m128i __a)
+{
+  return __builtin_shufflevector((__v2di)__a, (__v2di)_mm_setzero_si128(), 0, 
1, 2, 3, 2, 3, 2, 3);
+}
+
+/// \brief Constructs a 512-bit integer vector from a 256-bit integer vector.
+///The lower 256 bits contain the value of the source vector. The upper
+///256 bits are set to zero.
+///
+/// \headerfile 
+///
+/// This intrinsic has no corresponding instruction.
+///
+/// \param __a
+///A 256-bit integer vector.
+/// \returns A 512-bit integer vector. The lower 256 bits contain the value of
+///the parameter. The upper 256 bits are set to zero.
+static __inline __m512i __DEFAULT_FN_ATTRS
+_mm5

[PATCH] D32670: Ensure showbase does not overflow do_put buffers

2017-04-29 Thread Dimitry Andric via Phabricator via cfe-commits
dim updated this revision to Diff 97198.
dim added a comment.

Simplify test case a bit.


https://reviews.llvm.org/D32670

Files:
  include/locale
  
test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minmax_showbase.pass.cpp

Index: test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minmax_showbase.pass.cpp
===
--- /dev/null
+++ test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minmax_showbase.pass.cpp
@@ -0,0 +1,97 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template  >
+//   class basic_ostream;
+
+// operator<<(short n);
+// operator<<(unsigned short n);
+// operator<<(int n);
+// operator<<(unsigned int n);
+// operator<<(long n);
+// operator<<(unsigned long n);
+// operator<<(long long n);
+// operator<<(unsigned long long n);
+
+//  Testing to make sure that the max length values are correctly inserted when
+//  using std::showbase
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+template 
+static void test(std::ios_base::fmtflags fmt, const char *expected)
+{
+std::stringstream ss;
+ss.setf(fmt, std::ios_base::basefield);
+ss << std::showbase << (std::is_signed::value ? std::numeric_limits::min() : std::numeric_limits::max());
+assert(ss.str() == expected);
+}
+
+int main(void)
+{
+const std::ios_base::fmtflags o = std::ios_base::oct;
+const std::ios_base::fmtflags d = std::ios_base::dec;
+const std::ios_base::fmtflags x = std::ios_base::hex;
+
+test(o, "010");
+test(d, "-32768");
+test(x, "0x8000");
+
+test(o, "017");
+test(d, "65535");
+test(x, "0x");
+
+test(o, "0200");
+test(d, "-2147483648");
+test(x, "0x8000");
+
+test(o, "0377");
+test(d, "4294967295");
+test(x, "0x");
+
+const bool long_is_32 = std::integral_constant::value; // avoid compiler warnings
+const bool long_is_64 = std::integral_constant::value; // avoid compiler warnings
+const bool long_long_is_64 = std::integral_constant::value; // avoid compiler warnings
+
+if (long_is_32) {
+test(o, "0200");
+test(d, "-2147483648");
+test(x, "0x8000");
+
+test(o, "0377");
+test(d, "4294967295");
+test(x, "0x");
+} else if (long_is_64) {
+test(o, "010");
+test(d, "-9223372036854775808");
+test(x, "0x8000");
+
+test(o, "017");
+test(d, "18446744073709551615");
+test(x, "0x");
+}
+if (long_long_is_64) {
+test(o, "010");
+test(d, "-9223372036854775808");
+test(x, "0x8000");
+
+test(o, "017");
+test(d, "18446744073709551615");
+test(x, "0x");
+}
+
+return 0;
+}
Index: include/locale
===
--- include/locale
+++ include/locale
@@ -1402,6 +1402,7 @@
 this->__format_int(__fmt+1, __len, true, __iob.flags());
 const unsigned __nbuf = (numeric_limits::digits / 3)
   + ((numeric_limits::digits % 3) != 0)
+  + ((__iob.flags() & ios_base::showbase) != 0)
   + 2;
 char __nar[__nbuf];
 int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
@@ -1428,6 +1429,7 @@
 this->__format_int(__fmt+1, __len, true, __iob.flags());
 const unsigned __nbuf = (numeric_limits::digits / 3)
   + ((numeric_limits::digits % 3) != 0)
+  + ((__iob.flags() & ios_base::showbase) != 0)
   + 2;
 char __nar[__nbuf];
 int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
@@ -1454,6 +1456,7 @@
 this->__format_int(__fmt+1, __len, false, __iob.flags());
 const unsigned __nbuf = (numeric_limits::digits / 3)
   + ((numeric_limits::digits % 3) != 0)
+  + ((__iob.flags() & ios_base::showbase) != 0)
   + 1;
 char __nar[__nbuf];
 int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
@@ -1480,6 +1483,7 @@
 this->__format_int(__fmt+1, __len, false, __iob.flags());
 const unsigned __nbuf = (numeric_limits::digits / 3)
   + ((numeric_lim

[clang-tools-extra] r301762 - clang-tools-extra/test/CMakeLists.txt: Rework r297806 (D29851) to make sure test utils should be built.

2017-04-29 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Sat Apr 29 22:19:04 2017
New Revision: 301762

URL: http://llvm.org/viewvc/llvm-project?rev=301762&view=rev
Log:
clang-tools-extra/test/CMakeLists.txt: Rework r297806 (D29851) to make sure 
test utils should be built.

FIXME: This may be moved to llvm's add_lit_target().

Modified:
clang-tools-extra/trunk/test/CMakeLists.txt

Modified: clang-tools-extra/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/CMakeLists.txt?rev=301762&r1=301761&r2=301762&view=diff
==
--- clang-tools-extra/trunk/test/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/test/CMakeLists.txt Sat Apr 29 22:19:04 2017
@@ -55,12 +55,15 @@ set(CLANG_TOOLS_TEST_DEPS
   ExtraToolsUnitTests
   )
 
-if(NOT LLVM_UTILS_PROVIDED)
-  list(APPEND CLANG_TOOLS_TEST_DEPS
-# Base line deps.
-FileCheck count not
-)
-endif()
+set(llvm_utils
+  FileCheck count not
+  )
+
+foreach(t ${llvm_utils})
+  if(TARGET ${t})
+list(APPEND CLANG_TOOLS_TEST_DEPS ${t})
+  endif()
+endforeach()
 
 add_lit_testsuite(check-clang-tools "Running the Clang extra tools' regression 
tests"
   ${CMAKE_CURRENT_BINARY_DIR}


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


[PATCH] D32385: [libcxx] optional: Implement LWG 2900 and P0602

2017-04-29 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 97203.
CaseyCarter added a comment.

Fix comment typo in optional.object.assign/move.pass.cpp


https://reviews.llvm.org/D32385

Files:
  include/optional
  
test/std/utilities/optional/optional.object/optional.object.assign/copy.pass.cpp
  
test/std/utilities/optional/optional.object/optional.object.assign/move.pass.cpp
  test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
  test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
  test/support/msvc_stdlib_force_include.hpp

Index: test/support/msvc_stdlib_force_include.hpp
===
--- test/support/msvc_stdlib_force_include.hpp
+++ test/support/msvc_stdlib_force_include.hpp
@@ -26,6 +26,11 @@
 #error This header may not be used when targeting libc++
 #endif
 
+// Indicates that we are using the MSVC standard library.
+#ifndef _MSVC_STL_VER
+#define _MSVC_STL_VER 42
+#endif
+
 struct AssertionDialogAvoider {
 AssertionDialogAvoider() {
 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
Index: test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
===
--- test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
+++ test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
@@ -10,7 +10,10 @@
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // 
 
-// optional(optional&& rhs);
+// constexpr optional(optional&& rhs);
+//   If is_trivially_move_constructible_v is true,
+//this constructor shall be a constexpr constructor.
+
 
 #include 
 #include 
@@ -36,10 +39,10 @@
 void test_throwing_ctor() {
 #ifndef TEST_HAS_NO_EXCEPTIONS
 struct Z {
-  Z() : count(0) {}
-  Z(Z&& o) : count(o.count + 1)
-  { if (count == 2) throw 6; }
-  int count;
+Z() : count(0) {}
+Z(Z&& o) : count(o.count + 1)
+{ if (count == 2) throw 6; }
+int count;
 };
 Z z;
 optional rhs(std::move(z));
@@ -131,6 +134,48 @@
 #endif
 }
 
+constexpr bool test_constexpr()
+{
+{
+using T = int;
+optional o1{};
+optional o2 = std::move(o1);
+static_cast(o2);
+optional o3{T{42}};
+optional o4 = std::move(o3);
+static_cast(o4);
+}
+{
+struct T {
+constexpr T(int) {}
+T(T&&) = default;
+};
+optional o1{};
+optional o2 = std::move(o1);
+static_cast(o2);
+optional o3{T{42}};
+optional o4 = std::move(o3);
+static_cast(o4);
+}
+return true;
+}
+static_assert(test_constexpr(), "");
+
+template
+constexpr bool triviality_test =
+std::is_trivially_move_constructible>::value ==
+std::is_trivially_move_constructible::value;
+
+void test_triviality_extension() {
+#if defined(_LIBCPP_VER) || defined(_MSVC_STL_VER)
+static_assert(triviality_test, "");
+static_assert(triviality_test>, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+static_assert(triviality_test, "");
+#endif
+}
 
 int main()
 {
@@ -178,9 +223,9 @@
 test();
 test(42);
 }
-{
-test_throwing_ctor();
-}
+
+test_throwing_ctor();
+
 {
 struct ThrowsMove {
   ThrowsMove() noexcept(false) {}
@@ -195,7 +240,7 @@
 };
 static_assert(std::is_nothrow_move_constructible>::value, "");
 }
-{
-test_reference_extension();
-}
+
+test_reference_extension();
+test_triviality_extension();
 }
Index: test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
===
--- test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
+++ test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
@@ -10,7 +10,9 @@
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // 
 
-// optional(const optional& rhs);
+// constexpr optional(const optional& rhs);
+//   If is_trivially_copy_constructible_v is true,
+//this constructor shall be a constexpr constructor.
 
 #include 
 #include 
@@ -35,10 +37,10 @@
 void test_throwing_ctor() {
 #ifndef TEST_HAS_NO_EXCEPTIONS
 struct Z {
-  Z() : count(0) {}
-  Z(Z const& o) : count(o.count + 1)
-  { if (count == 2) throw 6; }
-  int count;
+Z() : count(0) {}
+Z(Z const& o) : count(o.count + 1)
+{ if (count == 2) throw 6; }
+int count;
 };
 const Z z;
 const optional rhs(z);
@@ -104,6 +106,48 @@
 #endif
 }
 
+constexpr bool test_constexpr()
+{
+{
+using T = int;
+optional o1{};
+optional o2 = o1;
+static_cast(o2);
+optional o3{T{42}};
+optional o4 = o3;
+static_cast(o4);
+}
+{
+st

[PATCH] D32671: [libcxx] [test] variant: test coverage for P0602 extension

2017-04-29 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 97204.
CaseyCarter added a comment.

Fix a weird corner case in variant's move assignment triviality test.


https://reviews.llvm.org/D32671

Files:
  test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
  test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp
  test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
  test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
  test/support/msvc_stdlib_force_include.hpp
  test/support/test.workarounds/c1xx_broken_is_trivially_copyable.pass.cpp
  test/support/test_workarounds.h

Index: test/support/test_workarounds.h
===
--- test/support/test_workarounds.h
+++ test/support/test_workarounds.h
@@ -15,6 +15,7 @@
 
 #if defined(TEST_COMPILER_C1XX)
 # define TEST_WORKAROUND_C1XX_BROKEN_NULLPTR_CONVERSION_OPERATOR
+# define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
 #endif
 
 #endif // SUPPORT_TEST_WORKAROUNDS_H
Index: test/support/test.workarounds/c1xx_broken_is_trivially_copyable.pass.cpp
===
--- /dev/null
+++ test/support/test.workarounds/c1xx_broken_is_trivially_copyable.pass.cpp
@@ -0,0 +1,31 @@
+//===--===//
+//
+// 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
+
+// Verify TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE.
+
+#include 
+
+#include "test_workarounds.h"
+
+struct S {
+  S(S const&) = default;
+  S(S&&) = default;
+  S& operator=(S const&) = delete;
+  S& operator=(S&&) = delete;
+};
+
+int main() {
+#if defined(TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE)
+  static_assert(!std::is_trivially_copyable::value, "");
+#else
+  static_assert(std::is_trivially_copyable::value, "");
+#endif
+}
Index: test/support/msvc_stdlib_force_include.hpp
===
--- test/support/msvc_stdlib_force_include.hpp
+++ test/support/msvc_stdlib_force_include.hpp
@@ -26,6 +26,11 @@
 #error This header may not be used when targeting libc++
 #endif
 
+// Indicates that we are using the MSVC standard library.
+#ifndef _MSVC_STL_VER
+#define _MSVC_STL_VER 42
+#endif
+
 struct AssertionDialogAvoider {
 AssertionDialogAvoider() {
 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
Index: test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
===
--- test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
+++ test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
@@ -22,6 +22,7 @@
 #include 
 
 #include "test_macros.h"
+#include "test_workarounds.h"
 
 struct ThrowsMove {
   ThrowsMove(ThrowsMove &&) noexcept(false) {}
@@ -178,20 +179,48 @@
 }
 
 void test_constexpr_move_ctor_extension() {
-#ifdef _LIBCPP_VERSION
+#if defined(_LIBCPP_VER) || defined(_MSVC_STL_VER)
   using V = std::variant;
+#ifdef TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
+  static_assert(std::is_trivially_destructible::value, "");
+  static_assert(std::is_trivially_copy_constructible::value, "");
+  static_assert(std::is_trivially_move_constructible::value, "");
+  static_assert(!std::is_copy_assignable::value, "");
+  static_assert(!std::is_move_assignable::value, "");
+#else
   static_assert(std::is_trivially_copyable::value, "");
+#endif
   static_assert(std::is_trivially_move_constructible::value, "");
   static_assert(test_constexpr_ctor_extension_imp<0>(V(42l)), "");
   static_assert(test_constexpr_ctor_extension_imp<1>(V(nullptr)), "");
   static_assert(test_constexpr_ctor_extension_imp<2>(V(101)), "");
 #endif
 }
 
+template
+constexpr bool triviality_test =
+  std::is_trivially_move_constructible>::value ==
+std::conjunction...>::value;
+
+void test_triviality_extension() {
+#if defined(_MSVC_STL_VER)
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+#endif
+}
+
 int main() {
   test_move_ctor_basic();
   test_move_ctor_valueless_by_exception();
   test_move_noexcept();
   test_move_ctor_sfinae();
   test_constexpr_move_ctor_extension();
+  test_triviality_extension();
 }
Index: test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
===
--- test/std/utilities/variant/var

[PATCH] D31739: Add markup for libc++ dylib availability

2017-04-29 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

This LGTM, and it's liable to bitrot if it hangs out here any longer.  We can 
always iterate in tree if we find a better way to organize the markup and/or 
tests.

Eric and Marshall: do you have any objection to this being committed now, so we 
can get some bots up?


https://reviews.llvm.org/D31739



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


[PATCH] D32675: in expression evaluator, treat non-literal types as discarded value expressions if EvalInfo says to continue evaluating them

2017-04-29 Thread Nick Lewycky via Phabricator via cfe-commits
nlewycky created this revision.

Make the integer overflow evaluator continue into expressions with non-literal 
types, notably void.

In passing it fixes a crash attempting to codegen:

  struct A { char x; };
  struct B : virtual A {};
  A &a = ((A&)*(B*)0);

which we nearly have a test for except that it casted to void and therefore was 
ignored instead of being evaluated. The existing test 
(test/SemaCXX/cstyle-cast.cpp) is sufficient to cover this case now that we 
don't stop at a void cast.


https://reviews.llvm.org/D32675

Files:
  lib/AST/ExprConstant.cpp
  test/Sema/integer-overflow.c


Index: test/Sema/integer-overflow.c
===
--- test/Sema/integer-overflow.c
+++ test/Sema/integer-overflow.c
@@ -149,16 +149,16 @@
 
 // expected-warning@+2 {{overflow in expression; result is 536870912 with type 
'int'}}
   uint64_t *b;
-  uint64_t b2 = b[4608 * 1024 * 1024] + 1;
+  (void)b[4608 * 1024 * 1024];
 
 // expected-warning@+1 2{{overflow in expression; result is 536870912 with 
type 'int'}}
-  int j1 = i ? (4608 * 1024 * 1024) : (4608 * 1024 * 1024);
+  (void)(i ? (4608 * 1024 * 1024) : (4608 * 1024 * 1024));
 
 // expected-warning@+1 {{overflow in expression; result is 536870912 with type 
'int'}}
-  int j2 = -(4608 * 1024 * 1024);
+  (void)(-(4608 * 1024 * 1024));
 
 // expected-warning@+1 {{overflow in expression; result is 536870912 with type 
'int'}}
-  uint64_t j3 = b[4608 * 1024 * 1024];
+  (void)b[4608 * 1024 * 1024];
 
 // expected-warning@+1 2{{overflow in expression; result is 536870912 with 
type 'int'}}
   return ((4608 * 1024 * 1024) + ((uint64_t)(4608 * 1024 * 1024)));
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -2169,6 +2169,9 @@
   if (!Base->isVirtual())
 return HandleLValueDirectBase(Info, E, Obj, DerivedDecl, BaseDecl);
 
+  if (!Obj.checkNullPointer(Info, E, CSK_Base))
+return false;
+
   SubobjectDesignator &D = Obj.Designator;
   if (D.Invalid)
 return false;
@@ -9913,8 +9916,11 @@
   if (E->getType().isNull())
 return false;
 
-  if (!CheckLiteralType(Info, E))
+  if (!CheckLiteralType(Info, E)) {
+if (Info.noteFailure())
+  EvaluateIgnoredValue(Info, E);
 return false;
+  }
 
   if (!::Evaluate(Result, Info, E))
 return false;


Index: test/Sema/integer-overflow.c
===
--- test/Sema/integer-overflow.c
+++ test/Sema/integer-overflow.c
@@ -149,16 +149,16 @@
 
 // expected-warning@+2 {{overflow in expression; result is 536870912 with type 'int'}}
   uint64_t *b;
-  uint64_t b2 = b[4608 * 1024 * 1024] + 1;
+  (void)b[4608 * 1024 * 1024];
 
 // expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
-  int j1 = i ? (4608 * 1024 * 1024) : (4608 * 1024 * 1024);
+  (void)(i ? (4608 * 1024 * 1024) : (4608 * 1024 * 1024));
 
 // expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
-  int j2 = -(4608 * 1024 * 1024);
+  (void)(-(4608 * 1024 * 1024));
 
 // expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
-  uint64_t j3 = b[4608 * 1024 * 1024];
+  (void)b[4608 * 1024 * 1024];
 
 // expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
   return ((4608 * 1024 * 1024) + ((uint64_t)(4608 * 1024 * 1024)));
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -2169,6 +2169,9 @@
   if (!Base->isVirtual())
 return HandleLValueDirectBase(Info, E, Obj, DerivedDecl, BaseDecl);
 
+  if (!Obj.checkNullPointer(Info, E, CSK_Base))
+return false;
+
   SubobjectDesignator &D = Obj.Designator;
   if (D.Invalid)
 return false;
@@ -9913,8 +9916,11 @@
   if (E->getType().isNull())
 return false;
 
-  if (!CheckLiteralType(Info, E))
+  if (!CheckLiteralType(Info, E)) {
+if (Info.noteFailure())
+  EvaluateIgnoredValue(Info, E);
 return false;
+  }
 
   if (!::Evaluate(Result, Info, E))
 return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits