Index: cfe/trunk/include/clang/Parse/Parser.h =================================================================== --- cfe/trunk/include/clang/Parse/Parser.h +++ cfe/trunk/include/clang/Parse/Parser.h @@ -883,8 +883,8 @@ StopAtCodeCompletion = 1 << 2 ///< Stop at code completion }; - friend LLVM_CONSTEXPR SkipUntilFlags operator|(SkipUntilFlags L, - SkipUntilFlags R) { + friend constexpr SkipUntilFlags operator|(SkipUntilFlags L, + SkipUntilFlags R) { return static_cast(static_cast(L) | static_cast(R)); } Index: llvm/trunk/include/llvm/ADT/ArrayRef.h =================================================================== --- llvm/trunk/include/llvm/ADT/ArrayRef.h +++ llvm/trunk/include/llvm/ADT/ArrayRef.h @@ -81,13 +81,12 @@ /// Construct an ArrayRef from a std::array template - /*implicit*/ LLVM_CONSTEXPR ArrayRef(const std::array &Arr) - : Data(Arr.data()), Length(N) {} + /*implicit*/ constexpr ArrayRef(const std::array &Arr) + : Data(Arr.data()), Length(N) {} /// Construct an ArrayRef from a C array. template - /*implicit*/ LLVM_CONSTEXPR ArrayRef(const T (&Arr)[N]) - : Data(Arr), Length(N) {} + /*implicit*/ constexpr ArrayRef(const T (&Arr)[N]) : Data(Arr), Length(N) {} /// Construct an ArrayRef from a std::initializer_list. /*implicit*/ ArrayRef(const std::initializer_list &Vec) @@ -291,13 +290,12 @@ /// Construct an ArrayRef from a std::array template - /*implicit*/ LLVM_CONSTEXPR MutableArrayRef(std::array &Arr) - : ArrayRef(Arr) {} + /*implicit*/ constexpr MutableArrayRef(std::array &Arr) + : ArrayRef(Arr) {} /// Construct an MutableArrayRef from a C array. template - /*implicit*/ LLVM_CONSTEXPR MutableArrayRef(T (&Arr)[N]) - : ArrayRef(Arr) {} + /*implicit*/ constexpr MutableArrayRef(T (&Arr)[N]) : ArrayRef(Arr) {} T *data() const { return const_cast(ArrayRef::data()); } Index: llvm/trunk/include/llvm/ADT/Optional.h =================================================================== --- llvm/trunk/include/llvm/ADT/Optional.h +++ llvm/trunk/include/llvm/ADT/Optional.h @@ -129,7 +129,7 @@ T& operator*() LLVM_LVALUE_FUNCTION { assert(hasVal); return *getPointer(); } template - LLVM_CONSTEXPR T getValueOr(U &&value) const LLVM_LVALUE_FUNCTION { + constexpr T getValueOr(U &&value) const LLVM_LVALUE_FUNCTION { return hasValue() ? getValue() : std::forward(value); } Index: llvm/trunk/include/llvm/ADT/STLExtras.h =================================================================== --- llvm/trunk/include/llvm/ADT/STLExtras.h +++ llvm/trunk/include/llvm/ADT/STLExtras.h @@ -456,7 +456,7 @@ template struct integer_sequence { typedef T value_type; - static LLVM_CONSTEXPR size_t size() { return sizeof...(I); } + static constexpr size_t size() { return sizeof...(I); } }; /// \brief Alias for the common case of a sequence of size_ts. @@ -483,7 +483,7 @@ /// Find the length of an array. template -LLVM_CONSTEXPR inline size_t array_lengthof(T (&)[N]) { +constexpr inline size_t array_lengthof(T (&)[N]) { return N; } Index: llvm/trunk/include/llvm/CodeGen/MachineValueType.h =================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineValueType.h +++ llvm/trunk/include/llvm/CodeGen/MachineValueType.h @@ -178,8 +178,8 @@ SimpleValueType SimpleTy; - LLVM_CONSTEXPR MVT() : SimpleTy(INVALID_SIMPLE_VALUE_TYPE) {} - LLVM_CONSTEXPR MVT(SimpleValueType SVT) : SimpleTy(SVT) { } + constexpr MVT() : SimpleTy(INVALID_SIMPLE_VALUE_TYPE) {} + constexpr MVT(SimpleValueType SVT) : SimpleTy(SVT) {} bool operator>(const MVT& S) const { return SimpleTy > S.SimpleTy; } bool operator<(const MVT& S) const { return SimpleTy < S.SimpleTy; } Index: llvm/trunk/include/llvm/CodeGen/ValueTypes.h =================================================================== --- llvm/trunk/include/llvm/CodeGen/ValueTypes.h +++ llvm/trunk/include/llvm/CodeGen/ValueTypes.h @@ -34,9 +34,9 @@ Type *LLVMTy; public: - LLVM_CONSTEXPR EVT() : V(MVT::INVALID_SIMPLE_VALUE_TYPE), LLVMTy(nullptr) {} - LLVM_CONSTEXPR EVT(MVT::SimpleValueType SVT) : V(SVT), LLVMTy(nullptr) {} - LLVM_CONSTEXPR EVT(MVT S) : V(S), LLVMTy(nullptr) {} + constexpr EVT() : V(MVT::INVALID_SIMPLE_VALUE_TYPE), LLVMTy(nullptr) {} + constexpr EVT(MVT::SimpleValueType SVT) : V(SVT), LLVMTy(nullptr) {} + constexpr EVT(MVT S) : V(S), LLVMTy(nullptr) {} bool operator==(EVT VT) const { return !(*this != VT); Index: llvm/trunk/include/llvm/Support/Compiler.h =================================================================== --- llvm/trunk/include/llvm/Support/Compiler.h +++ llvm/trunk/include/llvm/Support/Compiler.h @@ -93,12 +93,6 @@ #define LLVM_LVALUE_FUNCTION #endif -#if __has_feature(cxx_constexpr) || defined(__GXX_EXPERIMENTAL_CXX0X__) || LLVM_MSC_PREREQ(1900) -# define LLVM_CONSTEXPR constexpr -#else -# define LLVM_CONSTEXPR -#endif - /// LLVM_LIBRARY_VISIBILITY - If a class marked with this attribute is linked /// into a shared library, then the class should be private to the library and /// not accessible from outside it. Can also be used to mark variables and Index: llvm/trunk/include/llvm/Support/MathExtras.h =================================================================== --- llvm/trunk/include/llvm/Support/MathExtras.h +++ llvm/trunk/include/llvm/Support/MathExtras.h @@ -245,44 +245,40 @@ // ambiguity. /// Hi_32 - This function returns the high 32 bits of a 64 bit value. -LLVM_CONSTEXPR inline uint32_t Hi_32(uint64_t Value) { +constexpr inline uint32_t Hi_32(uint64_t Value) { return static_cast(Value >> 32); } /// Lo_32 - This function returns the low 32 bits of a 64 bit value. -LLVM_CONSTEXPR inline uint32_t Lo_32(uint64_t Value) { +constexpr inline uint32_t Lo_32(uint64_t Value) { return static_cast(Value); } /// Make_64 - This functions makes a 64-bit integer from a high / low pair of /// 32-bit integers. -LLVM_CONSTEXPR inline uint64_t Make_64(uint32_t High, uint32_t Low) { +constexpr inline uint64_t Make_64(uint32_t High, uint32_t Low) { return ((uint64_t)High << 32) | (uint64_t)Low; } /// isInt - Checks if an integer fits into the given bit width. -template -LLVM_CONSTEXPR inline bool isInt(int64_t x) { +template constexpr inline bool isInt(int64_t x) { return N >= 64 || (-(INT64_C(1)<<(N-1)) <= x && x < (INT64_C(1)<<(N-1))); } // Template specializations to get better code for common cases. -template<> -LLVM_CONSTEXPR inline bool isInt<8>(int64_t x) { +template <> constexpr inline bool isInt<8>(int64_t x) { return static_cast(x) == x; } -template<> -LLVM_CONSTEXPR inline bool isInt<16>(int64_t x) { +template <> constexpr inline bool isInt<16>(int64_t x) { return static_cast(x) == x; } -template<> -LLVM_CONSTEXPR inline bool isInt<32>(int64_t x) { +template <> constexpr inline bool isInt<32>(int64_t x) { return static_cast(x) == x; } /// isShiftedInt - Checks if a signed integer is an N bit number shifted /// left by S. -template -LLVM_CONSTEXPR inline bool isShiftedInt(int64_t x) { +template +constexpr inline bool isShiftedInt(int64_t x) { static_assert( N > 0, "isShiftedInt<0> doesn't make sense (refers to a 0-bit number."); static_assert(N + S <= 64, "isShiftedInt with N + S > 64 is too wide."); @@ -298,34 +294,31 @@ /// to keep MSVC from (incorrectly) warning on isUInt<64> that we're shifting /// left too many places. template -LLVM_CONSTEXPR inline typename std::enable_if<(N < 64), bool>::type +constexpr inline typename std::enable_if<(N < 64), bool>::type isUInt(uint64_t X) { static_assert(N > 0, "isUInt<0> doesn't make sense"); return X < (UINT64_C(1) << (N)); } template -LLVM_CONSTEXPR inline typename std::enable_if= 64, bool>::type +constexpr inline typename std::enable_if= 64, bool>::type isUInt(uint64_t X) { return true; } // Template specializations to get better code for common cases. -template<> -LLVM_CONSTEXPR inline bool isUInt<8>(uint64_t x) { +template <> constexpr inline bool isUInt<8>(uint64_t x) { return static_cast(x) == x; } -template<> -LLVM_CONSTEXPR inline bool isUInt<16>(uint64_t x) { +template <> constexpr inline bool isUInt<16>(uint64_t x) { return static_cast(x) == x; } -template<> -LLVM_CONSTEXPR inline bool isUInt<32>(uint64_t x) { +template <> constexpr inline bool isUInt<32>(uint64_t x) { return static_cast(x) == x; } /// Checks if a unsigned integer is an N bit number shifted left by S. -template -LLVM_CONSTEXPR inline bool isShiftedUInt(uint64_t x) { +template +constexpr inline bool isShiftedUInt(uint64_t x) { static_assert( N > 0, "isShiftedUInt<0> doesn't make sense (refers to a 0-bit number)"); static_assert(N + S <= 64, @@ -377,39 +370,39 @@ /// isMask_32 - This function returns true if the argument is a non-empty /// sequence of ones starting at the least significant bit with the remainder /// zero (32 bit version). Ex. isMask_32(0x0000FFFFU) == true. -LLVM_CONSTEXPR inline bool isMask_32(uint32_t Value) { +constexpr inline bool isMask_32(uint32_t Value) { return Value && ((Value + 1) & Value) == 0; } /// isMask_64 - This function returns true if the argument is a non-empty /// sequence of ones starting at the least significant bit with the remainder /// zero (64 bit version). -LLVM_CONSTEXPR inline bool isMask_64(uint64_t Value) { +constexpr inline bool isMask_64(uint64_t Value) { return Value && ((Value + 1) & Value) == 0; } /// isShiftedMask_32 - This function returns true if the argument contains a /// non-empty sequence of ones with the remainder zero (32 bit version.) /// Ex. isShiftedMask_32(0x0000FF00U) == true. -LLVM_CONSTEXPR inline bool isShiftedMask_32(uint32_t Value) { +constexpr inline bool isShiftedMask_32(uint32_t Value) { return Value && isMask_32((Value - 1) | Value); } /// isShiftedMask_64 - This function returns true if the argument contains a /// non-empty sequence of ones with the remainder zero (64 bit version.) -LLVM_CONSTEXPR inline bool isShiftedMask_64(uint64_t Value) { +constexpr inline bool isShiftedMask_64(uint64_t Value) { return Value && isMask_64((Value - 1) | Value); } /// isPowerOf2_32 - This function returns true if the argument is a power of /// two > 0. Ex. isPowerOf2_32(0x00100000U) == true (32 bit edition.) -LLVM_CONSTEXPR inline bool isPowerOf2_32(uint32_t Value) { +constexpr inline bool isPowerOf2_32(uint32_t Value) { return Value && !(Value & (Value - 1)); } /// isPowerOf2_64 - This function returns true if the argument is a power of two /// > 0 (64 bit edition.) -LLVM_CONSTEXPR inline bool isPowerOf2_64(uint64_t Value) { +constexpr inline bool isPowerOf2_64(uint64_t Value) { return Value && !(Value & (Value - int64_t(1L))); } @@ -601,7 +594,7 @@ /// MinAlign - A and B are either alignments or offsets. Return the minimum /// alignment that may be assumed after adding the two together. -LLVM_CONSTEXPR inline uint64_t MinAlign(uint64_t A, uint64_t B) { +constexpr inline uint64_t MinAlign(uint64_t A, uint64_t B) { // The largest power of 2 that divides both A and B. // // Replace "-Value" by "1+~Value" in the following commented code to avoid @@ -676,8 +669,7 @@ /// Returns the next integer (mod 2**64) that is greater than or equal to /// \p Value and is a multiple of \c Align. \c Align must be non-zero. -template -LLVM_CONSTEXPR inline uint64_t alignTo(uint64_t Value) { +template constexpr inline uint64_t alignTo(uint64_t Value) { static_assert(Align != 0u, "Align must be non-zero"); return (Value + Align - 1) / Align * Align; } @@ -685,7 +677,7 @@ /// \c alignTo for contexts where a constant expression is required. /// \sa alignTo /// -/// \todo FIXME: remove when \c LLVM_CONSTEXPR becomes really \c constexpr +/// \todo FIXME: remove when \c constexpr becomes really \c constexpr template struct AlignTo { static_assert(Align != 0u, "Align must be non-zero"); @@ -712,7 +704,7 @@ /// Sign-extend the number in the bottom B bits of X to a 32-bit integer. /// Requires 0 < B <= 32. -template LLVM_CONSTEXPR inline int32_t SignExtend32(uint32_t X) { +template constexpr inline int32_t SignExtend32(uint32_t X) { static_assert(B > 0, "Bit width can't be 0."); static_assert(B <= 32, "Bit width out of range."); return int32_t(X << (32 - B)) >> (32 - B); @@ -728,7 +720,7 @@ /// Sign-extend the number in the bottom B bits of X to a 64-bit integer. /// Requires 0 < B < 64. -template LLVM_CONSTEXPR inline int64_t SignExtend64(uint64_t x) { +template constexpr inline int64_t SignExtend64(uint64_t x) { static_assert(B > 0, "Bit width can't be 0."); static_assert(B <= 64, "Bit width out of range."); return int64_t(x << (64 - B)) >> (64 - B); Index: llvm/trunk/include/llvm/Support/RandomNumberGenerator.h =================================================================== --- llvm/trunk/include/llvm/Support/RandomNumberGenerator.h +++ llvm/trunk/include/llvm/Support/RandomNumberGenerator.h @@ -51,7 +51,7 @@ #if defined(_MSC_VER) && _MSC_VER < 1900 #define STL_CONSTEXPR #else -#define STL_CONSTEXPR LLVM_CONSTEXPR +#define STL_CONSTEXPR constexpr #endif static STL_CONSTEXPR result_type min() { return generator_type::min(); } Index: llvm/trunk/include/llvm/Support/TrailingObjects.h =================================================================== --- llvm/trunk/include/llvm/Support/TrailingObjects.h +++ llvm/trunk/include/llvm/Support/TrailingObjects.h @@ -146,7 +146,7 @@ static const bool value = alignof(PrevTy) < alignof(NextTy); }; - static LLVM_CONSTEXPR bool requiresRealignment() { + static constexpr bool requiresRealignment() { return RequiresRealignment::value; } @@ -195,7 +195,7 @@ // Helper function for TrailingObjects::additionalSizeToAlloc: this // function recurses to superclasses, each of which requires one // fewer size_t argument, and adds its own size. - static LLVM_CONSTEXPR size_t additionalSizeToAllocImpl( + static constexpr size_t additionalSizeToAllocImpl( size_t SizeSoFar, size_t Count1, typename ExtractSecondType::type... MoreCounts) { return ParentType::additionalSizeToAllocImpl( @@ -204,21 +204,6 @@ sizeof(NextTy) * Count1, MoreCounts...); } - - // additionalSizeToAllocImpl for contexts where a constant expression is - // required. - // FIXME: remove when LLVM_CONSTEXPR becomes really constexpr - template - struct AdditionalSizeToAllocImpl { - static_assert(sizeof...(MoreTys) == sizeof...(MoreCounts), - "Number of counts do not match number of types"); - static const size_t value = ParentType::template AdditionalSizeToAllocImpl< - (RequiresRealignment::value ? llvm::AlignTo:: - template from_value::value - : SizeSoFar) + - sizeof(NextTy) * Count1, - MoreCounts...>::value; - }; }; // The base case of the TrailingObjectsImpl inheritance recursion, @@ -232,17 +217,10 @@ // up the inheritance chain to subclasses. static void getTrailingObjectsImpl(); - static LLVM_CONSTEXPR size_t additionalSizeToAllocImpl(size_t SizeSoFar) { + static constexpr size_t additionalSizeToAllocImpl(size_t SizeSoFar) { return SizeSoFar; } - // additionalSizeToAllocImpl for contexts where a constant expression is - // required. - // FIXME: remove when LLVM_CONSTEXPR becomes really constexpr - template struct AdditionalSizeToAllocImpl { - static const size_t value = SizeSoFar; - }; - template static void verifyTrailingObjectsAlignment() {} }; @@ -348,11 +326,10 @@ /// used in the class; they are supplied here redundantly only so /// that it's clear what the counts are counting in callers. template - static LLVM_CONSTEXPR typename std::enable_if< + static constexpr typename std::enable_if< std::is_same, Foo>::value, size_t>::type - additionalSizeToAlloc( - typename trailing_objects_internal::ExtractSecondType< - TrailingTys, size_t>::type... Counts) { + additionalSizeToAlloc(typename trailing_objects_internal::ExtractSecondType< + TrailingTys, size_t>::type... Counts) { return ParentType::additionalSizeToAllocImpl(0, Counts...); } @@ -361,28 +338,13 @@ /// additionalSizeToAlloc, except it *does* include the size of the base /// object. template - static LLVM_CONSTEXPR typename std::enable_if< + static constexpr typename std::enable_if< std::is_same, Foo>::value, size_t>::type - totalSizeToAlloc(typename trailing_objects_internal::ExtractSecondType< - TrailingTys, size_t>::type... Counts) { + totalSizeToAlloc(typename trailing_objects_internal::ExtractSecondType< + TrailingTys, size_t>::type... Counts) { return sizeof(BaseTy) + ParentType::additionalSizeToAllocImpl(0, Counts...); } - // totalSizeToAlloc for contexts where a constant expression is required. - // FIXME: remove when LLVM_CONSTEXPR becomes really constexpr - template struct TotalSizeToAlloc { - static_assert( - std::is_same, Foo>::value, - "Arguments to TotalSizeToAlloc do not match with TrailingObjects"); - template struct with_counts { - static_assert(sizeof...(TrailingTys) == sizeof...(Counts), - "Number of counts do not match number of types"); - static const size_t value = - sizeof(BaseTy) + - ParentType::template AdditionalSizeToAllocImpl<0, Counts...>::value; - }; - }; - /// A type where its ::with_counts template member has a ::type member /// suitable for use as uninitialized storage for an object with the given /// trailing object counts. The template arguments are similar to those @@ -400,9 +362,7 @@ /// \endcode template struct FixedSizeStorage { template struct with_counts { - enum { - Size = TotalSizeToAlloc::template with_counts::value - }; + enum { Size = totalSizeToAlloc(Counts...) }; typedef llvm::AlignedCharArray type; }; }; Index: llvm/trunk/include/llvm/Support/UnicodeCharRanges.h =================================================================== --- llvm/trunk/include/llvm/Support/UnicodeCharRanges.h +++ llvm/trunk/include/llvm/Support/UnicodeCharRanges.h @@ -56,7 +56,7 @@ // may get rid of NDEBUG in this header. Unfortunately there are some // problems to get this working with MSVC 2013. Change this when // the support for MSVC 2013 is dropped. - LLVM_CONSTEXPR UnicodeCharSet(CharRanges Ranges) : Ranges(Ranges) {} + constexpr UnicodeCharSet(CharRanges Ranges) : Ranges(Ranges) {} #else UnicodeCharSet(CharRanges Ranges) : Ranges(Ranges) { assert(rangesAreValid()); Index: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.h =================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.h +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.h @@ -126,8 +126,7 @@ uint16_t type; // enum AtomType uint16_t form; // DWARF DW_FORM_ defines - LLVM_CONSTEXPR Atom(uint16_t type, uint16_t form) - : type(type), form(form) {} + constexpr Atom(uint16_t type, uint16_t form) : type(type), form(form) {} #ifndef NDEBUG void print(raw_ostream &O) { O << "Type: " << dwarf::AtomTypeString(type) << "\n"