Skip to content

Commit

Permalink
Fix the stage2 MSVC 2013 build with less constexpr in RNG
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283954 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
rnk committed Oct 11, 2016
1 parent 13a7e10 commit 47b7d1a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions include/llvm/Support/RandomNumberGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,19 @@ class RandomNumberGenerator {

/// 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.
Expand Down

0 comments on commit 47b7d1a

Please sign in to comment.