]> granicus.if.org Git - llvm/commitdiff
Fix the stage2 MSVC 2013 build with less constexpr in RNG
authorReid Kleckner <rnk@google.com>
Tue, 11 Oct 2016 23:02:21 +0000 (23:02 +0000)
committerReid Kleckner <rnk@google.com>
Tue, 11 Oct 2016 23:02:21 +0000 (23:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283954 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/RandomNumberGenerator.h

index 1a1e2fd010cb74d5dcecbaeef239b59b055cb515..b3046e1e268c25437f9b54bc404cdcf4b3b8f9a0 100644 (file)
@@ -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.