From d898d31ebc4de1ca54013afd28d803d84dab3aa1 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Sun, 15 Feb 2015 22:00:20 +0000 Subject: [PATCH] Removing LLVM_EXPLICIT, as MSVC 2012 was the last reason for requiring the macro. NFC; LLVM edition. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229335 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/IntervalMap.h | 2 +- include/llvm/ADT/IntrusiveRefCntPtr.h | 6 +- include/llvm/ADT/Optional.h | 2 +- include/llvm/ADT/PointerUnion.h | 74 ++++++++++---------- include/llvm/Analysis/InlineCost.h | 2 +- include/llvm/CodeGen/SelectionDAGNodes.h | 2 +- include/llvm/CodeGen/SlotIndexes.h | 2 +- include/llvm/ExecutionEngine/Orc/JITSymbol.h | 2 +- include/llvm/IR/CallSite.h | 2 +- include/llvm/IR/DebugInfo.h | 2 +- include/llvm/IR/Metadata.h | 2 +- include/llvm/Support/Compiler.h | 10 --- include/llvm/Support/ErrorOr.h | 2 +- include/llvm/Support/StringPool.h | 2 +- lib/Support/Windows/WindowsSupport.h | 2 +- lib/Target/SystemZ/SystemZElimCompare.cpp | 2 +- lib/Target/SystemZ/SystemZInstrInfo.cpp | 2 +- unittests/Support/Casting.cpp | 2 +- 18 files changed, 55 insertions(+), 65 deletions(-) diff --git a/include/llvm/ADT/IntervalMap.h b/include/llvm/ADT/IntervalMap.h index 46549eed993..99be38ffb54 100644 --- a/include/llvm/ADT/IntervalMap.h +++ b/include/llvm/ADT/IntervalMap.h @@ -496,7 +496,7 @@ public: NodeRef() {} /// operator bool - Detect a null ref. - LLVM_EXPLICIT operator bool() const { return pip.getOpaqueValue(); } + explicit operator bool() const { return pip.getOpaqueValue(); } /// NodeRef - Create a reference to the node p with n elements. template diff --git a/include/llvm/ADT/IntrusiveRefCntPtr.h b/include/llvm/ADT/IntrusiveRefCntPtr.h index c859c98d06b..9b12d048a8b 100644 --- a/include/llvm/ADT/IntrusiveRefCntPtr.h +++ b/include/llvm/ADT/IntrusiveRefCntPtr.h @@ -84,7 +84,7 @@ namespace llvm { friend struct IntrusiveRefCntPtrInfo; }; - + template struct IntrusiveRefCntPtrInfo { static void retain(T *obj) { obj->Retain(); } static void release(T *obj) { obj->Release(); } @@ -114,7 +114,7 @@ public: delete static_cast(this); } }; - + //===----------------------------------------------------------------------===// /// IntrusiveRefCntPtr - A template class that implements a "smart pointer" /// that assumes the wrapped object has a reference count associated @@ -177,7 +177,7 @@ public: T* get() const { return Obj; } - LLVM_EXPLICIT operator bool() const { return Obj; } + explicit operator bool() const { return Obj; } void swap(IntrusiveRefCntPtr& other) { T* tmp = other.Obj; diff --git a/include/llvm/ADT/Optional.h b/include/llvm/ADT/Optional.h index 4e48bebf59a..855ab890392 100644 --- a/include/llvm/ADT/Optional.h +++ b/include/llvm/ADT/Optional.h @@ -121,7 +121,7 @@ public: const T& getValue() const LLVM_LVALUE_FUNCTION { assert(hasVal); return *getPointer(); } T& getValue() LLVM_LVALUE_FUNCTION { assert(hasVal); return *getPointer(); } - LLVM_EXPLICIT operator bool() const { return hasVal; } + explicit operator bool() const { return hasVal; } bool hasValue() const { return hasVal; } const T* operator->() const { return getPointer(); } T* operator->() { return getPointer(); } diff --git a/include/llvm/ADT/PointerUnion.h b/include/llvm/ADT/PointerUnion.h index a6dddd27762..8bab186c236 100644 --- a/include/llvm/ADT/PointerUnion.h +++ b/include/llvm/ADT/PointerUnion.h @@ -61,7 +61,7 @@ namespace llvm { NumLowBitsAvailable = PT1BitsAv < PT2BitsAv ? PT1BitsAv : PT2BitsAv }; }; - + /// PointerUnion - This implements a discriminated union of two pointer types, /// and keeps the discriminator bit-mangled into the low bits of the pointer. /// This allows the implementation to be extremely efficient in space, but @@ -80,7 +80,7 @@ namespace llvm { template class PointerUnion { public: - typedef PointerIntPair > ValTy; private: ValTy Val; @@ -96,14 +96,14 @@ namespace llvm { public: PointerUnion() {} - + PointerUnion(PT1 V) : Val( const_cast(PointerLikeTypeTraits::getAsVoidPointer(V))) { } PointerUnion(PT2 V) : Val( const_cast(PointerLikeTypeTraits::getAsVoidPointer(V)), 1) { } - + /// isNull - Return true if the pointer held in the union is null, /// regardless of which type it is. bool isNull() const { @@ -111,7 +111,7 @@ namespace llvm { // we recursively strip off low bits if we have a nested PointerUnion. return !PointerLikeTypeTraits::getFromVoidPointer(Val.getPointer()); } - LLVM_EXPLICIT operator bool() const { return !isNull(); } + explicit operator bool() const { return !isNull(); } /// is() return true if the Union currently holds the type matching T. template @@ -123,7 +123,7 @@ namespace llvm { int TyNo = Ty::Num; return static_cast(Val.getInt()) == TyNo; } - + /// get() - Return the value of the specified pointer type. If the /// specified pointer type is incorrect, assert. template @@ -131,7 +131,7 @@ namespace llvm { assert(is() && "Invalid accessor called"); return PointerLikeTypeTraits::getFromVoidPointer(Val.getPointer()); } - + /// dyn_cast() - If the current value is of the specified pointer type, /// return it, otherwise return null. template @@ -160,7 +160,7 @@ namespace llvm { Val.initWithPointer(nullptr); return *this; } - + /// Assignment operators - Allow assigning into this union from either /// pointer type, setting the discriminator to remember what it came from. const PointerUnion &operator=(const PT1 &RHS) { @@ -174,7 +174,7 @@ namespace llvm { 1); return *this; } - + void *getOpaqueValue() const { return Val.getOpaqueValue(); } static inline PointerUnion getFromOpaqueValue(void *VP) { PointerUnion V; @@ -208,16 +208,16 @@ namespace llvm { getFromVoidPointer(void *P) { return PointerUnion::getFromOpaqueValue(P); } - + // The number of bits available are the min of the two pointer types. enum { - NumLowBitsAvailable = + NumLowBitsAvailable = PointerLikeTypeTraits::ValTy> ::NumLowBitsAvailable }; }; - - + + /// PointerUnion3 - This is a pointer union of three pointer types. See /// documentation for PointerUnion for usage. template @@ -233,7 +233,7 @@ namespace llvm { IsInnerUnion(ValTy val) : Val(val) { } template int is() const { - return Val.template is() && + return Val.template is() && Val.template get().template is(); } template @@ -257,7 +257,7 @@ namespace llvm { public: PointerUnion3() {} - + PointerUnion3(PT1 V) { Val = InnerUnion(V); } @@ -267,12 +267,12 @@ namespace llvm { PointerUnion3(PT3 V) { Val = V; } - + /// isNull - Return true if the pointer held in the union is null, /// regardless of which type it is. bool isNull() const { return Val.isNull(); } - LLVM_EXPLICIT operator bool() const { return !isNull(); } - + explicit operator bool() const { return !isNull(); } + /// is() return true if the Union currently holds the type matching T. template int is() const { @@ -283,7 +283,7 @@ namespace llvm { >::Return Ty; return Ty(Val).template is(); } - + /// get() - Return the value of the specified pointer type. If the /// specified pointer type is incorrect, assert. template @@ -296,7 +296,7 @@ namespace llvm { >::Return Ty; return Ty(Val).template get(); } - + /// dyn_cast() - If the current value is of the specified pointer type, /// return it, otherwise return null. template @@ -310,7 +310,7 @@ namespace llvm { Val = nullptr; return *this; } - + /// Assignment operators - Allow assigning into this union from either /// pointer type, setting the discriminator to remember what it came from. const PointerUnion3 &operator=(const PT1 &RHS) { @@ -325,7 +325,7 @@ namespace llvm { Val = RHS; return *this; } - + void *getOpaqueValue() const { return Val.getOpaqueValue(); } static inline PointerUnion3 getFromOpaqueValue(void *VP) { PointerUnion3 V; @@ -333,7 +333,7 @@ namespace llvm { return V; } }; - + // Teach SmallPtrSet that PointerUnion3 is "basically a pointer", that has // # low bits available = min(PT1bits,PT2bits,PT2bits)-2. template @@ -347,10 +347,10 @@ namespace llvm { getFromVoidPointer(void *P) { return PointerUnion3::getFromOpaqueValue(P); } - + // The number of bits available are the min of the two pointer types. enum { - NumLowBitsAvailable = + NumLowBitsAvailable = PointerLikeTypeTraits::ValTy> ::NumLowBitsAvailable }; @@ -368,7 +368,7 @@ namespace llvm { ValTy Val; public: PointerUnion4() {} - + PointerUnion4(PT1 V) { Val = InnerUnion1(V); } @@ -381,12 +381,12 @@ namespace llvm { PointerUnion4(PT4 V) { Val = InnerUnion2(V); } - + /// isNull - Return true if the pointer held in the union is null, /// regardless of which type it is. bool isNull() const { return Val.isNull(); } - LLVM_EXPLICIT operator bool() const { return !isNull(); } - + explicit operator bool() const { return !isNull(); } + /// is() return true if the Union currently holds the type matching T. template int is() const { @@ -395,10 +395,10 @@ namespace llvm { ::llvm::PointerUnionTypeSelector >::Return Ty; - return Val.template is() && + return Val.template is() && Val.template get().template is(); } - + /// get() - Return the value of the specified pointer type. If the /// specified pointer type is incorrect, assert. template @@ -411,7 +411,7 @@ namespace llvm { >::Return Ty; return Val.template get().template get(); } - + /// dyn_cast() - If the current value is of the specified pointer type, /// return it, otherwise return null. template @@ -425,7 +425,7 @@ namespace llvm { Val = nullptr; return *this; } - + /// Assignment operators - Allow assigning into this union from either /// pointer type, setting the discriminator to remember what it came from. const PointerUnion4 &operator=(const PT1 &RHS) { @@ -444,7 +444,7 @@ namespace llvm { Val = InnerUnion2(RHS); return *this; } - + void *getOpaqueValue() const { return Val.getOpaqueValue(); } static inline PointerUnion4 getFromOpaqueValue(void *VP) { PointerUnion4 V; @@ -452,7 +452,7 @@ namespace llvm { return V; } }; - + // Teach SmallPtrSet that PointerUnion4 is "basically a pointer", that has // # low bits available = min(PT1bits,PT2bits,PT2bits)-2. template @@ -466,10 +466,10 @@ namespace llvm { getFromVoidPointer(void *P) { return PointerUnion4::getFromOpaqueValue(P); } - + // The number of bits available are the min of the two pointer types. enum { - NumLowBitsAvailable = + NumLowBitsAvailable = PointerLikeTypeTraits::ValTy> ::NumLowBitsAvailable }; diff --git a/include/llvm/Analysis/InlineCost.h b/include/llvm/Analysis/InlineCost.h index 63d399afad8..fdee9f869c0 100644 --- a/include/llvm/Analysis/InlineCost.h +++ b/include/llvm/Analysis/InlineCost.h @@ -77,7 +77,7 @@ public: } /// \brief Test whether the inline cost is low enough for inlining. - LLVM_EXPLICIT operator bool() const { + explicit operator bool() const { return Cost < Threshold; } diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h index da79adfa226..247957ce895 100644 --- a/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/include/llvm/CodeGen/SelectionDAGNodes.h @@ -145,7 +145,7 @@ public: bool operator<(const SDValue &O) const { return std::tie(Node, ResNo) < std::tie(O.Node, O.ResNo); } - LLVM_EXPLICIT operator bool() const { + explicit operator bool() const { return Node != nullptr; } diff --git a/include/llvm/CodeGen/SlotIndexes.h b/include/llvm/CodeGen/SlotIndexes.h index 00bb22b91d3..9d6d6f5b1be 100644 --- a/include/llvm/CodeGen/SlotIndexes.h +++ b/include/llvm/CodeGen/SlotIndexes.h @@ -162,7 +162,7 @@ namespace llvm { } /// Return true for a valid index. - LLVM_EXPLICIT operator bool() const { return isValid(); } + explicit operator bool() const { return isValid(); } /// Print this index to the given raw_ostream. void print(raw_ostream &os) const; diff --git a/include/llvm/ExecutionEngine/Orc/JITSymbol.h b/include/llvm/ExecutionEngine/Orc/JITSymbol.h index e3d91ceb93e..c02975730ba 100644 --- a/include/llvm/ExecutionEngine/Orc/JITSymbol.h +++ b/include/llvm/ExecutionEngine/Orc/JITSymbol.h @@ -34,7 +34,7 @@ public: : CachedAddr(0), GetAddress(std::move(GetAddress)) {} /// @brief Returns true if the symbol exists, false otherwise. - LLVM_EXPLICIT operator bool() const { return CachedAddr || GetAddress; } + explicit operator bool() const { return CachedAddr || GetAddress; } /// @brief Get the address of the symbol in the target address space. Returns /// '0' if the symbol does not exist. diff --git a/include/llvm/IR/CallSite.h b/include/llvm/IR/CallSite.h index df082577a0e..a4ea243ecdc 100644 --- a/include/llvm/IR/CallSite.h +++ b/include/llvm/IR/CallSite.h @@ -78,7 +78,7 @@ public: InstrTy *getInstruction() const { return I.getPointer(); } InstrTy *operator->() const { return I.getPointer(); } - LLVM_EXPLICIT operator bool() const { return I.getPointer(); } + explicit operator bool() const { return I.getPointer(); } /// getCalledValue - Return the pointer to function that is being called. /// diff --git a/include/llvm/IR/DebugInfo.h b/include/llvm/IR/DebugInfo.h index 2c43f23b60c..73b4b1693b0 100644 --- a/include/llvm/IR/DebugInfo.h +++ b/include/llvm/IR/DebugInfo.h @@ -186,7 +186,7 @@ public: // FIXME: This operator bool isn't actually protecting anything at the // moment due to the conversion operator above making DIDescriptor nodes // implicitly convertable to bool. - LLVM_EXPLICIT operator bool() const { return DbgNode != nullptr; } + explicit operator bool() const { return DbgNode != nullptr; } bool operator==(DIDescriptor Other) const { return DbgNode == Other.DbgNode; } bool operator!=(DIDescriptor Other) const { return !operator==(Other); } diff --git a/include/llvm/IR/Metadata.h b/include/llvm/IR/Metadata.h index 3291f31278b..77f9d1b61d0 100644 --- a/include/llvm/IR/Metadata.h +++ b/include/llvm/IR/Metadata.h @@ -512,7 +512,7 @@ struct AAMDNodes { bool operator!=(const AAMDNodes &A) const { return !(*this == A); } - LLVM_EXPLICIT operator bool() const { return TBAA || Scope || NoAlias; } + explicit operator bool() const { return TBAA || Scope || NoAlias; } /// \brief The tag for type-based alias analysis. MDNode *TBAA; diff --git a/include/llvm/Support/Compiler.h b/include/llvm/Support/Compiler.h index f9bcd2827fd..9d3b9106f68 100644 --- a/include/llvm/Support/Compiler.h +++ b/include/llvm/Support/Compiler.h @@ -339,16 +339,6 @@ # define LLVM_IS_UNALIGNED_ACCESS_FAST 0 #endif -/// \macro LLVM_EXPLICIT -/// \brief Expands to explicit on compilers which support explicit conversion -/// operators. Otherwise expands to nothing. -#if __has_feature(cxx_explicit_conversions) || \ - defined(__GXX_EXPERIMENTAL_CXX0X__) -#define LLVM_EXPLICIT explicit -#else -#define LLVM_EXPLICIT -#endif - /// \brief Does the compiler support generalized initializers (using braced /// lists and std::initializer_list). While clang may claim it supports general /// initializers, if we're using MSVC's headers, we might not have a usable diff --git a/include/llvm/Support/ErrorOr.h b/include/llvm/Support/ErrorOr.h index 84763deea0f..3577a12cec3 100644 --- a/include/llvm/Support/ErrorOr.h +++ b/include/llvm/Support/ErrorOr.h @@ -168,7 +168,7 @@ public: } /// \brief Return false if there is an error. - LLVM_EXPLICIT operator bool() const { + explicit operator bool() const { return !HasError; } diff --git a/include/llvm/Support/StringPool.h b/include/llvm/Support/StringPool.h index b51974c946e..675adde0432 100644 --- a/include/llvm/Support/StringPool.h +++ b/include/llvm/Support/StringPool.h @@ -129,7 +129,7 @@ namespace llvm { } inline const char *operator*() const { return begin(); } - inline LLVM_EXPLICIT operator bool() const { return S != nullptr; } + inline explicit operator bool() const { return S != nullptr; } inline bool operator==(const PooledStringPtr &That) const { return S == That.S; } inline bool operator!=(const PooledStringPtr &That) const { return S != That.S; } diff --git a/lib/Support/Windows/WindowsSupport.h b/lib/Support/Windows/WindowsSupport.h index 62e20f267aa..5bb0b8d2d78 100644 --- a/lib/Support/Windows/WindowsSupport.h +++ b/lib/Support/Windows/WindowsSupport.h @@ -92,7 +92,7 @@ public: } // True if Handle is valid. - LLVM_EXPLICIT operator bool() const { + explicit operator bool() const { return HandleTraits::IsValid(Handle) ? true : false; } diff --git a/lib/Target/SystemZ/SystemZElimCompare.cpp b/lib/Target/SystemZ/SystemZElimCompare.cpp index ce99ee5bc41..16f9adc79f1 100644 --- a/lib/Target/SystemZ/SystemZElimCompare.cpp +++ b/lib/Target/SystemZ/SystemZElimCompare.cpp @@ -47,7 +47,7 @@ struct Reference { return *this; } - LLVM_EXPLICIT operator bool() const { return Def || Use; } + explicit operator bool() const { return Def || Use; } // True if the register is defined or used in some form, either directly or // via a sub- or super-register. diff --git a/lib/Target/SystemZ/SystemZInstrInfo.cpp b/lib/Target/SystemZ/SystemZInstrInfo.cpp index 8ff9553ca08..8488ec84764 100644 --- a/lib/Target/SystemZ/SystemZInstrInfo.cpp +++ b/lib/Target/SystemZ/SystemZInstrInfo.cpp @@ -633,7 +633,7 @@ struct LogicOp { LogicOp(unsigned regSize, unsigned immLSB, unsigned immSize) : RegSize(regSize), ImmLSB(immLSB), ImmSize(immSize) {} - LLVM_EXPLICIT operator bool() const { return RegSize; } + explicit operator bool() const { return RegSize; } unsigned RegSize, ImmLSB, ImmSize; }; diff --git a/unittests/Support/Casting.cpp b/unittests/Support/Casting.cpp index 3218189eeab..e6c35fc21eb 100644 --- a/unittests/Support/Casting.cpp +++ b/unittests/Support/Casting.cpp @@ -250,7 +250,7 @@ class PTy { Base *B; public: PTy(Base *B) : B(B) {} - LLVM_EXPLICIT operator bool() const { return get(); } + explicit operator bool() const { return get(); } Base *get() const { return B; } };