[llvm] r283954 - Fix the stage2 MSVC 2013 build with less constexpr in RNG
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 11 16:02:22 PDT 2016
Author: rnk
Date: Tue Oct 11 18:02:21 2016
New Revision: 283954
URL: http://llvm.org/viewvc/llvm-project?rev=283954&view=rev
Log:
Fix the stage2 MSVC 2013 build with less constexpr in RNG
Modified:
llvm/trunk/include/llvm/Support/RandomNumberGenerator.h
Modified: llvm/trunk/include/llvm/Support/RandomNumberGenerator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/RandomNumberGenerator.h?rev=283954&r1=283953&r2=283954&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/RandomNumberGenerator.h (original)
+++ llvm/trunk/include/llvm/Support/RandomNumberGenerator.h Tue Oct 11 18:02:21 2016
@@ -43,8 +43,19 @@ public:
/// Returns a random number in the range [0, Max).
result_type operator()();
- static LLVM_CONSTEXPR result_type min() { return generator_type::min(); }
- static LLVM_CONSTEXPR result_type max() { return generator_type::max(); }
+
+ // We can only make min/max constexpr if generator_type::min/max are
+ // constexpr. The MSVC 2013 STL does not make these constexpr, so we have to
+ // avoid declaring them as constexpr even if the compiler, like clang-cl,
+ // supports it.
+#if defined(_MSC_VER) && _MSC_VER < 1900
+#define STL_CONSTEXPR
+#else
+#define STL_CONSTEXPR LLVM_CONSTEXPR
+#endif
+
+ static STL_CONSTEXPR result_type min() { return generator_type::min(); }
+ static STL_CONSTEXPR result_type max() { return generator_type::max(); }
private:
/// Seeds and salts the underlying RNG engine.
More information about the llvm-commits
mailing list