diff options
author | Craig Topper <craig.topper@gmail.com> | 2014-04-09 06:08:46 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2014-04-09 06:08:46 +0000 |
commit | ec0f0bc6afa8d2c1f427ec55264fc78738b83ef6 (patch) | |
tree | 9fd922368890f4c0e51831dc17d85d7f793a15c3 /include/llvm | |
parent | 8a0d1c8f06391add493d0ff4b7344fce3420d2d5 (diff) | |
download | llvm-ec0f0bc6afa8d2c1f427ec55264fc78738b83ef6.tar.gz llvm-ec0f0bc6afa8d2c1f427ec55264fc78738b83ef6.tar.bz2 llvm-ec0f0bc6afa8d2c1f427ec55264fc78738b83ef6.tar.xz |
[C++11] More 'nullptr' conversion or in some cases just using a boolean check instead of comparing to nullptr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205831 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
48 files changed, 349 insertions, 333 deletions
diff --git a/include/llvm/ADT/ArrayRef.h b/include/llvm/ADT/ArrayRef.h index 87b9bb95ab..be7cb51b60 100644 --- a/include/llvm/ADT/ArrayRef.h +++ b/include/llvm/ADT/ArrayRef.h @@ -49,7 +49,7 @@ namespace llvm { /// @{ /// Construct an empty ArrayRef. - /*implicit*/ ArrayRef() : Data(0), Length(0) {} + /*implicit*/ ArrayRef() : Data(nullptr), Length(0) {} /// Construct an empty ArrayRef from None. /*implicit*/ ArrayRef(NoneType) : Data(nullptr), Length(0) {} diff --git a/include/llvm/ADT/DenseMap.h b/include/llvm/ADT/DenseMap.h index 37385da23b..826913289e 100644 --- a/include/llvm/ADT/DenseMap.h +++ b/include/llvm/ADT/DenseMap.h @@ -985,7 +985,7 @@ public: private: pointer Ptr, End; public: - DenseMapIterator() : Ptr(0), End(0) {} + DenseMapIterator() : Ptr(nullptr), End(nullptr) {} DenseMapIterator(pointer Pos, pointer E, bool NoAdvance = false) : Ptr(Pos), End(E) { diff --git a/include/llvm/ADT/ilist.h b/include/llvm/ADT/ilist.h index abb5a22fd2..4f64b6c82e 100644 --- a/include/llvm/ADT/ilist.h +++ b/include/llvm/ADT/ilist.h @@ -494,9 +494,9 @@ private: // Note: we have to be careful about the case when we move the first node // in the list. This node is the list sentinel node and we can't move it. NodeTy *ThisSentinel = getTail(); - setTail(0); + setTail(nullptr); NodeTy *L2Sentinel = L2.getTail(); - L2.setTail(0); + L2.setTail(nullptr); // Remove [first, last) from its old position. NodeTy *First = &*first, *Prev = this->getPrev(First); @@ -537,7 +537,7 @@ public: // size_type LLVM_ATTRIBUTE_UNUSED_RESULT size() const { - if (Head == 0) return 0; // Don't require construction of sentinel if empty. + if (!Head) return 0; // Don't require construction of sentinel if empty. return std::distance(begin(), end()); } diff --git a/include/llvm/Analysis/ValueTracking.h b/include/llvm/Analysis/ValueTracking.h index 0392f98f07..55f5bd1475 100644 --- a/include/llvm/Analysis/ValueTracking.h +++ b/include/llvm/Analysis/ValueTracking.h @@ -38,13 +38,13 @@ namespace llvm { /// same width as the vector element, and the bit is set only if it is true /// for all of the elements in the vector. void ComputeMaskedBits(Value *V, APInt &KnownZero, APInt &KnownOne, - const DataLayout *TD = 0, unsigned Depth = 0); + const DataLayout *TD = nullptr, unsigned Depth = 0); void computeMaskedBitsLoad(const MDNode &Ranges, APInt &KnownZero); /// ComputeSignBit - Determine whether the sign bit is known to be zero or /// one. Convenience wrapper around ComputeMaskedBits. void ComputeSignBit(Value *V, bool &KnownZero, bool &KnownOne, - const DataLayout *TD = 0, unsigned Depth = 0); + const DataLayout *TD = nullptr, unsigned Depth = 0); /// isKnownToBeAPowerOfTwo - Return true if the given value is known to have /// exactly one bit set when defined. For vectors return true if every @@ -57,7 +57,8 @@ namespace llvm { /// when defined. For vectors return true if every element is known to be /// non-zero when defined. Supports values with integer or pointer type and /// vectors of integers. - bool isKnownNonZero(Value *V, const DataLayout *TD = 0, unsigned Depth = 0); + bool isKnownNonZero(Value *V, const DataLayout *TD = nullptr, + unsigned Depth = 0); /// MaskedValueIsZero - Return true if 'V & Mask' is known to be zero. We use /// this predicate to simplify operations downstream. Mask is known to be @@ -69,7 +70,7 @@ namespace llvm { /// same width as the vector element, and the bit is set only if it is true /// for all of the elements in the vector. bool MaskedValueIsZero(Value *V, const APInt &Mask, - const DataLayout *TD = 0, unsigned Depth = 0); + const DataLayout *TD = nullptr, unsigned Depth = 0); /// ComputeNumSignBits - Return the number of times the sign bit of the @@ -80,7 +81,7 @@ namespace llvm { /// /// 'Op' must have a scalar integer type. /// - unsigned ComputeNumSignBits(Value *Op, const DataLayout *TD = 0, + unsigned ComputeNumSignBits(Value *Op, const DataLayout *TD = nullptr, unsigned Depth = 0); /// ComputeMultiple - This function computes the integer multiple of Base that @@ -112,7 +113,7 @@ namespace llvm { /// insertvalues when a part of a nested struct is extracted. Value *FindInsertedValue(Value *V, ArrayRef<unsigned> idx_range, - Instruction *InsertBefore = 0); + Instruction *InsertBefore = nullptr); /// GetPointerBaseWithConstantOffset - Analyze the specified pointer to see if /// it can be expressed as a base pointer plus a constant offset. Return the @@ -143,10 +144,10 @@ namespace llvm { /// being addressed. Note that the returned value has pointer type if the /// specified value does. If the MaxLookup value is non-zero, it limits the /// number of instructions to be stripped off. - Value *GetUnderlyingObject(Value *V, const DataLayout *TD = 0, + Value *GetUnderlyingObject(Value *V, const DataLayout *TD = nullptr, unsigned MaxLookup = 6); static inline const Value * - GetUnderlyingObject(const Value *V, const DataLayout *TD = 0, + GetUnderlyingObject(const Value *V, const DataLayout *TD = nullptr, unsigned MaxLookup = 6) { return GetUnderlyingObject(const_cast<Value *>(V), TD, MaxLookup); } @@ -156,7 +157,7 @@ namespace llvm { /// multiple objects. void GetUnderlyingObjects(Value *V, SmallVectorImpl<Value *> &Objects, - const DataLayout *TD = 0, + const DataLayout *TD = nullptr, unsigned MaxLookup = 6); /// onlyUsedByLifetimeMarkers - Return true if the only users of this pointer @@ -182,12 +183,12 @@ namespace llvm { /// However, this method can return true for instructions that read memory; /// for such instructions, moving them may change the resulting value. bool isSafeToSpeculativelyExecute(const Value *V, - const DataLayout *TD = 0); + const DataLayout *TD = nullptr); /// isKnownNonNull - Return true if this pointer couldn't possibly be null by /// its definition. This returns true for allocas, non-extern-weak globals /// and byval arguments. - bool isKnownNonNull(const Value *V, const TargetLibraryInfo *TLI = 0); + bool isKnownNonNull(const Value *V, const TargetLibraryInfo *TLI = nullptr); } // end namespace llvm diff --git a/include/llvm/Bitcode/ReaderWriter.h b/include/llvm/Bitcode/ReaderWriter.h index 0918e92cb9..4c194a638d 100644 --- a/include/llvm/Bitcode/ReaderWriter.h +++ b/include/llvm/Bitcode/ReaderWriter.h @@ -39,7 +39,7 @@ namespace llvm { Module *getStreamedBitcodeModule(const std::string &name, DataStreamer *streamer, LLVMContext &Context, - std::string *ErrMsg = 0); + std::string *ErrMsg = nullptr); /// getBitcodeTargetTriple - Read the header of the specified bitcode /// buffer and extract just the triple information. If successful, @@ -48,7 +48,7 @@ namespace llvm { /// if ErrMsg is non-null. std::string getBitcodeTargetTriple(MemoryBuffer *Buffer, LLVMContext &Context, - std::string *ErrMsg = 0); + std::string *ErrMsg = nullptr); /// Read the specified bitcode file, returning the module. /// This method *never* takes ownership of Buffer. diff --git a/include/llvm/CodeGen/ValueTypes.h b/include/llvm/CodeGen/ValueTypes.h index 8cf26fa30d..4e93940e22 100644 --- a/include/llvm/CodeGen/ValueTypes.h +++ b/include/llvm/CodeGen/ValueTypes.h @@ -35,9 +35,9 @@ namespace llvm { public: EVT() : V((MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE)), - LLVMTy(0) {} - EVT(MVT::SimpleValueType SVT) : V(SVT), LLVMTy(0) { } - EVT(MVT S) : V(S), LLVMTy(0) {} + LLVMTy(nullptr) {} + EVT(MVT::SimpleValueType SVT) : V(SVT), LLVMTy(nullptr) { } + EVT(MVT S) : V(S), LLVMTy(nullptr) {} bool operator==(EVT VT) const { return !(*this != VT); diff --git a/include/llvm/IR/Argument.h b/include/llvm/IR/Argument.h index 7c1ebf6dff..d226bd3c85 100644 --- a/include/llvm/IR/Argument.h +++ b/include/llvm/IR/Argument.h @@ -44,7 +44,7 @@ public: /// /// If \p F is specified, the argument is inserted at the end of the argument /// list for \p F. - explicit Argument(Type *Ty, const Twine &Name = "", Function *F = 0); + explicit Argument(Type *Ty, const Twine &Name = "", Function *F = nullptr); inline const Function *getParent() const { return Parent; } inline Function *getParent() { return Parent; } diff --git a/include/llvm/IR/Attributes.h b/include/llvm/IR/Attributes.h index 9eccf40045..43d1fb4258 100644 --- a/include/llvm/IR/Attributes.h +++ b/include/llvm/IR/Attributes.h @@ -116,7 +116,7 @@ private: AttributeImpl *pImpl; Attribute(AttributeImpl *A) : pImpl(A) {} public: - Attribute() : pImpl(0) {} + Attribute() : pImpl(nullptr) {} //===--------------------------------------------------------------------===// // Attribute Construction @@ -232,7 +232,7 @@ private: explicit AttributeSet(AttributeSetImpl *LI) : pImpl(LI) {} public: - AttributeSet() : pImpl(0) {} + AttributeSet() : pImpl(nullptr) {} //===--------------------------------------------------------------------===// // AttributeSet Construction and Mutation diff --git a/include/llvm/IR/BasicBlock.h b/include/llvm/IR/BasicBlock.h index 1adc254a61..82f7518240 100644 --- a/include/llvm/IR/BasicBlock.h +++ b/include/llvm/IR/BasicBlock.h @@ -90,7 +90,8 @@ private: /// inserted at either the end of the function (if InsertBefore is null), or /// before the specified basic block. explicit BasicBlock(LLVMContext &C, const Twine &Name = "", - Function *Parent = 0, BasicBlock *InsertBefore = 0); + Function *Parent = nullptr, + BasicBlock *InsertBefore = nullptr); public: /// \brief Get the context in which this basic block lives. LLVMContext &getContext() const; @@ -107,7 +108,8 @@ public: /// inserted at either the end of the function (if InsertBefore is 0), or /// before the specified basic block. static BasicBlock *Create(LLVMContext &Context, const Twine &Name = "", - Function *Parent = 0,BasicBlock *InsertBefore = 0) { + Function *Parent = nullptr, + BasicBlock *InsertBefore = nullptr) { return new BasicBlock(Context, Name, Parent, InsertBefore); } ~BasicBlock(); diff --git a/include/llvm/IR/CallSite.h b/include/llvm/IR/CallSite.h index ec461037e4..bdac61a89b 100644 --- a/include/llvm/IR/CallSite.h +++ b/include/llvm/IR/CallSite.h @@ -47,7 +47,7 @@ class CallSiteBase { protected: PointerIntPair<InstrTy*, 1, bool> I; public: - CallSiteBase() : I(0, false) {} + CallSiteBase() : I(nullptr, false) {} CallSiteBase(CallTy *CI) : I(CI, true) { assert(CI); } CallSiteBase(InvokeTy *II) : I(II, false) { assert(II); } CallSiteBase(ValTy *II) { *this = get(II); } diff --git a/include/llvm/IR/ConstantRange.h b/include/llvm/IR/ConstantRange.h index 86988debff..342422cbe2 100644 --- a/include/llvm/IR/ConstantRange.h +++ b/include/llvm/IR/ConstantRange.h @@ -114,12 +114,12 @@ public: const APInt *getSingleElement() const { if (Upper == Lower + 1) return &Lower; - return 0; + return nullptr; } /// isSingleElement - Return true if this set contains exactly one member. /// - bool isSingleElement() const { return getSingleElement() != 0; } + bool isSingleElement() const { return getSingleElement() != nullptr; } /// getSetSize - Return the number of elements in this set. /// diff --git a/include/llvm/IR/Constants.h b/include/llvm/IR/Constants.h index ed7a70f773..0e72f040d3 100644 --- a/include/llvm/IR/Constants.h +++ b/include/llvm/IR/Constants.h @@ -299,7 +299,7 @@ class ConstantAggregateZero : public Constant { ConstantAggregateZero(const ConstantAggregateZero &) LLVM_DELETED_FUNCTION; protected: explicit ConstantAggregateZero(Type *ty) - : Constant(ty, ConstantAggregateZeroVal, 0, 0) {} + : Constant(ty, ConstantAggregateZeroVal, nullptr, 0) {} protected: // allocate space for exactly zero operands void *operator new(size_t s) { @@ -486,7 +486,7 @@ class ConstantPointerNull : public Constant { protected: explicit ConstantPointerNull(PointerType *T) : Constant(T, - Value::ConstantPointerNullVal, 0, 0) {} + Value::ConstantPointerNullVal, nullptr, 0) {} protected: // allocate space for exactly zero operands @@ -536,7 +536,7 @@ class ConstantDataSequential : public Constant { ConstantDataSequential(const ConstantDataSequential &) LLVM_DELETED_FUNCTION; protected: explicit ConstantDataSequential(Type *ty, ValueTy VT, const char *Data) - : Constant(ty, VT, 0, 0), DataElements(Data), Next(0) {} + : Constant(ty, VT, nullptr, 0), DataElements(Data), Next(nullptr) {} ~ConstantDataSequential() { delete Next; } static Constant *getImpl(StringRef Bytes, Type *Ty); @@ -1136,7 +1136,7 @@ class UndefValue : public Constant { void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION; UndefValue(const UndefValue &) LLVM_DELETED_FUNCTION; protected: - explicit UndefValue(Type *T) : Constant(T, UndefValueVal, 0, 0) {} + explicit UndefValue(Type *T) : Constant(T, UndefValueVal, nullptr, 0) {} protected: // allocate space for exactly zero operands void *operator new(size_t s) { diff --git a/include/llvm/IR/DIBuilder.h b/include/llvm/IR/DIBuilder.h index 598d66a2ed..df8cd75de1 100644 --- a/include/llvm/IR/DIBuilder.h +++ b/include/llvm/IR/DIBuilder.h @@ -78,7 +78,7 @@ namespace llvm { DITemplateValueParameter createTemplateValueParameter(unsigned Tag, DIDescriptor Scope, StringRef Name, DIType Ty, Value *Val, - MDNode *File = 0, unsigned LineNo = 0, + MDNode *File = nullptr, unsigned LineNo = 0, unsigned ColumnNo = 0); DIBuilder(const DIBuilder &) LLVM_DELETED_FUNCTION; @@ -293,7 +293,7 @@ namespace llvm { uint64_t OffsetInBits, unsigned Flags, DIType DerivedFrom, DIArray Elements, DIType VTableHolder = DIType(), - MDNode *TemplateParms = 0, + MDNode *TemplateParms = nullptr, StringRef UniqueIdentifier = StringRef()); /// createStructType - Create debugging information entry for a struct. @@ -342,7 +342,7 @@ namespace llvm { /// @param ColumnNo Column Number. DITemplateTypeParameter createTemplateTypeParameter(DIDescriptor Scope, StringRef Name, DIType Ty, - MDNode *File = 0, unsigned LineNo = 0, + MDNode *File = nullptr, unsigned LineNo = 0, unsigned ColumnNo = 0); /// createTemplateValueParameter - Create debugging information for template @@ -356,7 +356,7 @@ namespace llvm { /// @param ColumnNo Column Number. DITemplateValueParameter createTemplateValueParameter(DIDescriptor Scope, StringRef Name, - DIType Ty, Value *Val, MDNode *File = 0, + DIType Ty, Value *Val, MDNode *File = nullptr, unsigned LineNo = 0, unsigned ColumnNo = 0); /// \brief Create debugging information for a template template parameter. @@ -369,8 +369,9 @@ namespace llvm { /// @param ColumnNo Column Number. DITemplateValueParameter createTemplateTemplateParameter(DIDescriptor Scope, StringRef Name, - DIType Ty, StringRef Val, MDNode *File = 0, - unsigned LineNo = 0, unsigned ColumnNo = 0); + DIType Ty, StringRef Val, + MDNode *File = nullptr, unsigned LineNo = 0, + unsigned ColumnNo = 0); /// \brief Create debugging information for a template parameter pack. /// @param Scope Scope in which this type is defined. @@ -382,7 +383,7 @@ namespace llvm { /// @param ColumnNo Column Number. DITemplateValueParameter createTemplateParameterPack(DIDescriptor Scope, StringRef Name, - DIType Ty, DIArray Val, MDNode *File = 0, + DIType Ty, DIArray Val, MDNode *File = nullptr, unsigned LineNo = 0, unsigned ColumnNo = 0); /// createArrayType - Create debugging information entry for an array. @@ -498,7 +499,7 @@ namespace llvm { createStaticVariable(DIDescriptor Context, StringRef Name, StringRef LinkageName, DIFile File, unsigned LineNo, DITypeRef Ty, bool isLocalToUnit, llvm::Value *Val, - MDNode *Decl = NULL); + MDNode *Decl = nullptr); /// createLocalVariable - Create a new descriptor for the specified @@ -564,9 +565,9 @@ namespace llvm { unsigned ScopeLine, unsigned Flags = 0, bool isOptimized = false, - Function *Fn = 0, - MDNode *TParam = 0, - MDNode *Decl = 0); + Function *Fn = nullptr, + MDNode *TParam = nullptr, + MDNode *Decl = nullptr); /// FIXME: this is added for dragonegg. Once we update dragonegg /// to call resolve function, this will be removed. @@ -578,9 +579,9 @@ namespace llvm { unsigned ScopeLine, unsigned Flags = 0, bool isOptimized = false, - Function *Fn = 0, - MDNode *TParam = 0, - MDNode *Decl = 0); + Function *Fn = nullptr, + MDNode *TParam = nullptr, + MDNode *Decl = nullptr); /// createMethod - Create a new descriptor for the specified C++ method. /// See comments in DISubprogram for descriptions of these fields. @@ -610,8 +611,8 @@ namespace llvm { DIType VTableHolder = DIType(), unsigned Flags = 0, bool isOptimized = false, - Function *Fn = 0, - MDNode *TParam = 0); + Function *Fn = nullptr, + MDNode *TParam = nullptr); /// createNameSpace - This creates new descriptor for a namespace /// with the specified parent scope. diff --git a/include/llvm/IR/DataLayout.h b/include/llvm/IR/DataLayout.h index 59dca636bd..5ad53b7c42 100644 --- a/include/llvm/IR/DataLayout.h +++ b/include/llvm/IR/DataLayout.h @@ -174,14 +174,14 @@ private: public: /// Constructs a DataLayout from a specification string. See reset(). - explicit DataLayout(StringRef LayoutDescription) : LayoutMap(0) { + explicit DataLayout(StringRef LayoutDescription) : LayoutMap(nullptr) { reset(LayoutDescription); } /// Initialize target data from properties stored in the module. explicit DataLayout(const Module *M); - DataLayout(const DataLayout &DL) : LayoutMap(0) { *this = DL; } + DataLayout(const DataLayout &DL) : LayoutMap(nullptr) { *this = DL; } DataLayout &operator=(const DataLayout &DL) { clear(); @@ -408,7 +408,7 @@ public: /// none are set. Type *getLargestLegalIntType(LLVMContext &C) const { unsigned LargestSize = getLargestLegalIntTypeSize(); - return (LargestSize == 0) ? 0 : Type::getIntNTy(C, LargestSize); + return (LargestSize == 0) ? nullptr : Type::getIntNTy(C, LargestSize); } /// getLargestLegalIntType - Return the size of largest legal integer type diff --git a/include/llvm/IR/DebugInfo.h b/include/llvm/IR/DebugInfo.h index f7244b83f5..82b25ace44 100644 --- a/include/llvm/IR/DebugInfo.h +++ b/include/llvm/IR/DebugInfo.h @@ -104,7 +104,7 @@ protected: void replaceFunctionField(unsigned Elt, Function *F); public: - explicit DIDescriptor(const MDNode *N = 0) : DbgNode(N) {} + explicit DIDescriptor(const MDNode *N = nullptr) : DbgNode(N) {} bool Verify() const; @@ -116,7 +116,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 != 0; } + LLVM_EXPLICIT operator bool() const { return DbgNode != nullptr; } bool operator==(DIDescriptor Other) const { return DbgNode == Other.DbgNode; } bool operator!=(DIDescriptor Other) const { return !operator==(Other); } @@ -159,7 +159,7 @@ class DISubrange : public DIDescriptor { void printInternal(raw_ostream &OS) const; public: - explicit DISubrange(const MDNode *N = 0) : DIDescriptor(N) {} + explicit DISubrange(const MDNode *N = nullptr) : DIDescriptor(N) {} int64_t getLo() const { return getInt64Field(1); } int64_t getCount() const { return getInt64Field(2); } @@ -169,7 +169,7 @@ public: /// DIArray - This descriptor holds an array of descriptors. class DIArray : public DIDescriptor { public: - explicit DIArray(const MDNode *N = 0) : DIDescriptor(N) {} + explicit DIArray(const MDNode *N = nullptr) : DIDescriptor(N) {} unsigned getNumElements() const; DIDescriptor getElement(unsigned Idx) const { @@ -185,7 +185,7 @@ class DIEnumerator : public DIDescriptor { void printInternal(raw_ostream &OS) const; public: - explicit DIEnumerator(const MDNode *N = 0) : DIDescriptor(N) {} + explicit DIEnumerator(const MDNode *N = nullptr) : DIDescriptor(N) {} StringRef getName() const { return getStringField(1); } int64_t getEnumValue() const { return getInt64Field(2); } @@ -210,7 +210,7 @@ protected: void printInternal(raw_ostream &OS) const; public: - explicit DIScope(const MDNode *N = 0) : DIDescriptor(N) {} + explicit DIScope(const MDNode *N = nullptr) : DIDescriptor(N) {} /// Gets the parent scope for this scope node or returns a /// default constructed scope. @@ -292,7 +292,7 @@ protected: void printInternal(raw_ostream &OS) const; public: - explicit DIType(const MDNode *N = 0) : DIScope(N) {} + explicit DIType(const MDNode *N = nullptr) : DIScope(N) {} operator DITypeRef () const { assert(isType() && "constructing DITypeRef from an MDNode that is not a type"); @@ -346,7 +346,7 @@ public: /// DIBasicType - A basic type, like 'int' or 'float'. class DIBasicType : public DIType { public: - explicit DIBasicType(const MDNode *N = 0) : DIType(N) {} + explicit DIBasicType(const MDNode *N = nullptr) : DIType(N) {} unsigned getEncoding() const { return getUnsignedField(9); } @@ -362,7 +362,7 @@ class DIDerivedType : public DIType { void printInternal(raw_ostream &OS) const; public: - explicit DIDerivedType(const MDNode *N = 0) : DIType(N) {} + explicit DIDerivedType(const MDNode *N = nullptr) : DIType(N) {} DITypeRef getTypeDerivedFrom() const { return getFieldAs<DITypeRef>(9); } @@ -395,7 +395,7 @@ class DICompositeType : public DIDerivedType { void printInternal(raw_ostream &OS) const; public: - explicit DICompositeType(const MDNode *N = 0) : DIDerivedType(N) {} + explicit DICompositeType(const MDNode *N = nullptr) : DIDerivedType(N) {} DIArray getTypeArray() const { return getFieldAs<DIArray>(10); } void setTypeArray(DIArray Elements, DIArray TParams = DIArray()); @@ -414,7 +414,7 @@ class DIFile : public DIScope { friend class DIDescriptor; public: - explicit DIFile(const MDNode *N = 0) : DIScope(N) {} + explicit DIFile(const MDNode *N = nullptr) : DIScope(N) {} MDNode *getFileNode() const; bool Verify() const; }; @@ -425,7 +425,7 @@ class DICompileUnit : public DIScope { void printInternal(raw_ostream &OS) const; public: - explicit DICompileUnit(const MDNode *N = 0) : DIScope(N) {} + explicit DICompileUnit(const MDNode *N = nullptr) : DIScope(N) {} unsigned getLanguage() const { return getUnsignedField(2); } StringRef getProducer() const { return getStringField(3); } @@ -453,7 +453,7 @@ class DISubprogram : public DIScope { void printInternal(raw_ostream &OS) const; public: - explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {} + explicit DISubprogram(const MDNode *N = nullptr) : DIScope(N) {} DIScopeRef getContext() const { return getFieldAs<DIScopeRef>(2); } StringRef getName() const { return getStringField(3); } @@ -532,7 +532,7 @@ public: /// DILexicalBlock - This is a wrapper for a lexical block. class DILexicalBlock : public DIScope { public: - explicit DILexicalBlock(const MDNode *N = 0) : DIScope(N) {} + explicit DILexicalBlock(const MDNode *N = nullptr) : DIScope(N) {} DIScope getContext() const { return getFieldAs<DIScope>(2); } unsigned getLineNumber() const { return getUnsignedField(3); } unsigned getColumnNumber() const { return getUnsignedField(4); } @@ -544,7 +544,7 @@ public: /// a filename change. class DILexicalBlockFile : public DIScope { public: - explicit DILexicalBlockFile(const MDNode *N = 0) : DIScope(N) {} + explicit DILexicalBlockFile(const MDNode *N = nullptr) : DIScope(N) {} DIScope getContext() const { if (getScope().isSubprogram()) return getScope(); @@ -562,7 +562,7 @@ class DINameSpace : public DIScope { void printInternal(raw_ostream &OS) const; public: - explicit DINameSpace(const MDNode *N = 0) : DIScope(N) {} + explicit DINameSpace(const MDNode *N = nullptr) : DIScope(N) {} DIScope getContext() const { return getFieldAs<DIScope>(2); } StringRef getName() const { return getStringField(3); } unsigned getLineNumber() const { return getUnsignedField(4); } @@ -572,14 +572,16 @@ public: /// DIUnspecifiedParameter - This is a wrapper for unspecified parameters. class DIUnspecifiedParameter : public DIDescriptor { public: - explicit DIUnspecifiedParameter(const MDNode *N = 0) : DIDescriptor(N) {} + explicit DIUnspecifiedParameter(const MDNode *N = nullptr) + : DIDescriptor(N) {} bool Verify() const; }; /// DITemplateTypeParameter - This is a wrapper for template type parameter. class DITemplateTypeParameter : public DIDescriptor { public: - explicit DITemplateTypeParameter(const MDNode *N = 0) : DIDescriptor(N) {} + explicit DITemplateTypeParameter(const MDNode *N = nullptr) + : DIDescriptor(N) {} DIScopeRef getContext() const { return getFieldAs<DIScopeRef>(1); } StringRef getName() const { return getStringField(2); } @@ -596,7 +598,8 @@ public: /// DITemplateValueParameter - This is a wrapper for template value parameter. class DITemplateValueParameter : public DIDescriptor { public: - explicit DITemplateValueParameter(const MDNode *N = 0) : DIDescriptor(N) {} + explicit DITemplateValueParameter(const MDNode *N = nullptr) + : DIDescriptor(N) {} DIScopeRef getContext() const { return getFieldAs<DIScopeRef>(1); } StringRef getName() const { return getStringField(2); } @@ -617,7 +620,7 @@ class DIGlobalVariable : public DIDescriptor { void printInternal(raw_ostream &OS) const; public: - explicit DIGlobalVariable(const MDNode *N = 0) : DIDescriptor(N) {} + explicit DIGlobalVariable(const MDNode *N = nullptr) : DIDescriptor(N) {} DIScope getContext() const { return getFieldAs<DIScope>(2); } StringRef getName() const { return getStringField(3); } @@ -650,7 +653,7 @@ class DIVariable : public DIDescriptor { void printInternal(raw_ostream &OS) const; public: - explicit DIVariable(const MDNode *N = 0) : DIDescriptor(N) {} + explicit DIVariable(const MDNode *N = nullptr) : DIDescriptor(N) {} DIScope getContext() const { return getFieldAs<DIScope>(1); } StringRef getName() const { return getStringField(2); } diff --git a/include/llvm/IR/DebugLoc.h b/include/llvm/IR/DebugLoc.h index 50b5d5420d..50a6752204 100644 --- a/include/llvm/IR/DebugLoc.h +++ b/include/llvm/IR/DebugLoc.h @@ -58,7 +58,7 @@ namespace llvm { /// get - Get a new DebugLoc that corresponds to the specified line/col /// scope/inline location. static DebugLoc get(unsigned Line, unsigned Col, - MDNode *Scope, MDNode *InlinedAt = 0); + MDNode *Scope, MDNode *InlinedAt = nullptr); /// getFromDILocation - Translate the DILocation quad into a DebugLoc. static DebugLoc getFromDILocation(MDNode *N); diff --git a/include/llvm/IR/DerivedTypes.h b/include/llvm/IR/DerivedTypes.h index 71d9973bcb..ff150872a4 100644 --- a/include/llvm/IR/DerivedTypes.h +++ b/include/llvm/IR/DerivedTypes.h @@ -188,7 +188,7 @@ class StructType : public CompositeType { StructType(const StructType &) LLVM_DELETED_FUNCTION; const StructType &operator=(const StructType &) LLVM_DELETED_FUNCTION; StructType(LLVMContext &C) - : CompositeType(C, StructTyID), SymbolTableEntry(0) {} + : CompositeType(C, StructTyID), SymbolTableEntry(nullptr) {} enum { /// This is the contents of the SubClassData field. SCDB_HasBody = 1, @@ -249,10 +249,10 @@ public: bool isOpaque() const { return (getSubclassData() & SCDB_HasBody) == 0; } /// isSized - Return true if this is a sized type. - bool isSized(SmallPtrSet<const Type*, 4> *Visited = 0) const; + bool isSized(SmallPtrSet<const Type*, 4> *Visited = nullptr) const; /// hasName - Return true if this is a named struct that has a non-empty name. - bool hasName() const { return SymbolTableEntry != 0; } + bool hasName() const { return SymbolTableEntry != nullptr; } /// getName - Return the name for this struct type if it has an identity. /// This may return an empty string for an unnamed struct type. Do not call diff --git a/include/llvm/IR/DiagnosticInfo.h b/include/llvm/IR/DiagnosticInfo.h index 589291a128..392c14b76a 100644 --- a/include/llvm/IR/DiagnosticInfo.h +++ b/include/llvm/IR/DiagnosticInfo.h @@ -107,7 +107,7 @@ public: DiagnosticInfoInlineAsm(const Twine &MsgStr, DiagnosticSeverity Severity = DS_Error) : DiagnosticInfo(DK_InlineAsm, Severity), LocCookie(0), MsgStr(MsgStr), - Instr(NULL) {} + Instr(nullptr) {} /// \p LocCookie if non-zero gives the line number for this report. /// \p MsgStr gives the message. @@ -116,7 +116,7 @@ public: DiagnosticInfoInlineAsm(unsigned LocCookie, const Twine &MsgStr, DiagnosticSeverity Severity = DS_Error) : DiagnosticInfo(DK_InlineAsm, Severity), LocCookie(LocCookie), - MsgStr(MsgStr), Instr(NULL) {} + MsgStr(MsgStr), Instr(nullptr) {} /// \p Instr gives the original instruction that triggered the diagnostic. /// \p MsgStr gives the message. @@ -210,7 +210,7 @@ public: LineNum(0), Msg(Msg) {} DiagnosticInfoSampleProfile(const Twine &Msg, DiagnosticSeverity Severity = DS_Error) - : DiagnosticInfo(DK_SampleProfile, Severity), FileName(NULL), + : DiagnosticInfo(DK_SampleProfile, Severity), FileName(nullptr), LineNum(0), Msg(Msg) {} /// \see DiagnosticInfo::print. diff --git a/include/llvm/IR/Dominators.h b/include/llvm/IR/Dominators.h index 86bbe391ea..364820275d 100644 --- a/include/llvm/IR/Dominators.h +++ b/include/llvm/IR/Dominators.h @@ -182,7 +182,7 @@ public: void releaseMemory() override { DT.releaseMemory(); } - void print(raw_ostream &OS, const Module *M = 0) const override; + void print(raw_ostream &OS, const Module *M = nullptr) const override; }; } // End llvm namespace diff --git a/include/llvm/IR/Function.h b/include/llvm/IR/Function.h index cb43bbaa93..2698d72643 100644 --- a/include/llvm/IR/Function.h +++ b/include/llvm/IR/Function.h @@ -123,11 +123,11 @@ private: /// the module. /// Function(FunctionType *Ty, LinkageTypes Linkage, - const Twine &N = "", Module *M = 0); + const Twine &N = "", Module *M = nullptr); public: static Function *Create(FunctionType *Ty, LinkageTypes Linkage, - const Twine &N = "", Module *M = 0) { + const Twine &N = "", Module *M = nullptr) { return new(0) Function(Ty, Linkage, N, M); } @@ -483,7 +483,7 @@ public: /// other than direct calls or invokes to it, or blockaddress expressions. /// Optionally passes back an offending user for diagnostic purposes. /// - bool hasAddressTaken(const User** = 0) const; + bool hasAddressTaken(const User** = nullptr) const; /// isDefTriviallyDead - Return true if it is trivially safe to remove /// this function definition from the module (because it isn't externally @@ -505,12 +505,12 @@ private: inline ValueSymbolTable * ilist_traits<BasicBlock>::getSymTab(Function *F) { - return F ? &F->getValueSymbolTable() : 0; + return F ? &F->getValueSymbolTable() : nullptr; } inline ValueSymbolTable * ilist_traits<Argument>::getSymTab(Function *F) { - return F ? &F->getValueSymbolTable() : 0; + return F ? &F->getValueSymbolTable() : nullptr; } } // End llvm namespace diff --git a/include/llvm/IR/GetElementPtrTypeIterator.h b/include/llvm/IR/GetElementPtrTypeIterator.h index f2722d6b0d..dcf8e64dbb 100644 --- a/include/llvm/IR/GetElementPtrTypeIterator.h +++ b/include/llvm/IR/GetElementPtrTypeIterator.h @@ -38,7 +38,7 @@ namespace llvm { } static generic_gep_type_iterator end(ItTy It) { generic_gep_type_iterator I; - I.CurTy = 0; + I.CurTy = nullptr; I.OpIt = It; return I; } @@ -69,7 +69,7 @@ namespace llvm { if (CompositeType *CT = dyn_cast<CompositeType>(CurTy)) { CurTy = CT->getTypeAtIndex(getOperand()); } else { - CurTy = 0; + CurTy = nullptr; } ++OpIt; return *this; diff --git a/include/llvm/IR/GlobalAlias.h b/include/llvm/IR/GlobalAlias.h index 2ca481a515..ad02996e2d 100644 --- a/include/llvm/IR/GlobalAlias.h +++ b/include/llvm/IR/GlobalAlias.h @@ -41,7 +41,7 @@ public: /// GlobalAlias ctor - If a parent module is specified, the alias is /// automatically inserted into the end of the specified module's alias list. GlobalAlias(Type *Ty, LinkageTypes Linkage, const Twine &Name = "", - Constant* Aliasee = 0, Module *Parent = 0); + Constant* Aliasee = nullptr, Module *Parent = nullptr); /// Provide fast operand accessors DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant); diff --git a/include/llvm/IR/GlobalValue.h b/include/llvm/IR/GlobalValue.h index 59c320d613..f812281f79 100644 --- a/include/llvm/IR/GlobalValue.h +++ b/include/llvm/IR/GlobalValue.h @@ -63,7 +63,7 @@ protected: LinkageTypes linkage, const Twine &Name) : Constant(ty, vty, Ops, NumOps), Linkage(linkage), Visibility(DefaultVisibility), Alignment(0), UnnamedAddr(0), - DllStorageClass(DefaultStorageClass), Parent(0) { + DllStorageClass(DefaultStorageClass), Parent(nullptr) { setName(Name); } @@ -251,7 +251,7 @@ public: /// Materialize - make sure this GlobalValue is fully read. If the module is /// corrupt, this returns true and fills in the optional string with /// information about the problem. If successful, this returns false. - bool Materialize(std::string *ErrInfo = 0); + bool Materialize(std::string *ErrInfo = nullptr); /// Dematerialize - If this GlobalValue is read in, and if the GVMaterializer /// supports it, release the memory for the function, and set it up to be diff --git a/include/llvm/IR/GlobalVariable.h b/include/llvm/IR/GlobalVariable.h index a82740f710..d73e826225 100644 --- a/include/llvm/IR/GlobalVariable.h +++ b/include/llvm/IR/GlobalVariable.h @@ -66,14 +66,14 @@ public: /// GlobalVariable ctor - If a parent module is specified, the global is /// automatically inserted into the end of the specified modules global list. GlobalVariable(Type *Ty, bool isConstant, LinkageTypes Linkage, - Constant *Initializer = 0, const Twine &Name = "", + Constant *Initializer = nullptr, const Twine &Name = "", ThreadLocalMode = NotThreadLocal, unsigned AddressSpace = 0, bool isExternallyInitialized = false); /// GlobalVariable ctor - This creates a global and inserts it before the /// specified other global. GlobalVariable(Module &M, Type *Ty, bool isConstant, LinkageTypes Linkage, Constant *Initializer, - const Twine &Name = "", GlobalVariable *InsertBefore = 0, + const Twine &Name = "", GlobalVariable *InsertBefore = nullptr, ThreadLocalMode = NotThreadLocal, unsigned AddressSpace = 0, bool isExternallyInitialized = false); diff --git a/include/llvm/IR/IRBuilder.h b/include/llvm/IR/IRBuilder.h index 79ee7b753d..580d333683 100644 --- a/include/llvm/IR/IRBuilder.h +++ b/include/llvm/IR/IRBuilder.h @@ -58,7 +58,7 @@ protected: FastMathFlags FMF; public: - IRBuilderBase(LLVMContext &context, MDNode *FPMathTag = 0) + IRBuilderBase(LLVMContext &context, MDNode *FPMathTag = nullptr) : Context(context), DefaultFPMathTag(FPMathTag), FMF() { ClearInsertionPoint(); } @@ -70,8 +70,8 @@ public: /// \brief Clear the insertion point: created instructions will not be /// inserted into a block. void ClearInsertionPoint() { - BB = 0; - InsertPt = 0; + BB = nullptr; + InsertPt = nullptr; } BasicBlock *GetInsertBlock() const { return BB; } @@ -140,14 +140,14 @@ public: public: /// \brief Creates a new insertion point which doesn't point to anything. - InsertPoint() : Block(0) {} + InsertPoint() : Block(nullptr) {} /// \brief Creates a new insertion point at the given location. InsertPoint(BasicBlock *InsertBlock, BasicBlock::iterator InsertPoint) : Block(InsertBlock), Point(InsertPoint) {} /// \brief Returns true if this insert point is set. - bool isSet() const { return (Block != 0); } + bool isSet() const { return (Block != nullptr); } llvm::BasicBlock *getBlock() const { return Block; } llvm::BasicBlock::iterator getPoint() const { return Point; } @@ -362,27 +362,27 @@ public: /// If the pointer isn't an i8*, it will be converted. If a TBAA tag is /// specified, it will be added to the instruction. CallInst *CreateMemSet(Value *Ptr, Value *Val, uint64_t Size, unsigned Align, - bool isVolatile = false, MDNode *TBAATag = 0) { + bool isVolatile = false, MDNode *TBAATag = nullptr) { return CreateMemSet(Ptr, Val, getInt64(Size), Align, isVolatile, TBAATag); } CallInst *CreateMemSet(Value *Ptr, Value *Val, Value *Size, unsigned Align, - bool isVolatile = false, MDNode *TBAATag = 0); + bool isVolatile = false, MDNode *TBAATag = nullptr); /// \brief Create and insert a memcpy between the specified pointers. /// /// If the pointers aren't i8*, they will be converted. If a TBAA tag is /// specified, it will be added to the instruction. CallInst *CreateMemCpy(Value *Dst, Value *Src, uint64_t Size, unsigned Align, - bool isVolatile = false, MDNode *TBAATag = 0, - MDNode *TBAAStructTag = 0) { + bool isVolatile = false, MDNode *TBAATag = nullptr, + MDNode *TBAAStructTag = nullptr) { return CreateMemCpy(Dst, Src, getInt64(Size), Align, isVolatile, TBAATag, TBAAStructTag); } CallInst *CreateMemCpy(Value *Dst, Value *Src, Value *Size, unsigned Align, - bool isVolatile = false, MDNode *TBAATag = 0, - MDNode *TBAAStructTag = 0); + bool isVolatile = false, MDNode *TBAATag = nullptr, + MDNode *TBAAStructTag = nullptr); /// \brief Create and insert a memmove between the specified /// pointers. @@ -390,22 +390,22 @@ public: /// If the pointers aren't i8*, they will be converted. If a TBAA tag is /// specified, it will be added to the instruction. CallInst *CreateMemMove(Value *Dst, Value *Src, uint64_t Size, unsigned Align, - bool isVolatile = false, MDNode *TBAATag = 0) { + bool isVolatile = false, MDNode *TBAATag = nullptr) { return CreateMemMove(Dst, Src, getInt64(Size), Align, isVolatile, TBAATag); } CallInst *CreateMemMove(Value *Dst, Value *Src, Value *Size, unsigned Align, - bool isVolatile = false, MDNode *TBAATag = 0); + bool isVolatile = false, MDNode *TBAATag = nullptr); /// \brief Create a lifetime.start intrinsic. /// /// If the pointer isn't i8* it will be converted. - CallInst *CreateLifetimeStart(Value *Ptr, ConstantInt *Size = 0); + CallInst *CreateLifetimeStart(Value *Ptr, ConstantInt *Size = nullptr); /// \brief Create a lifetime.end intrinsic. /// /// If the pointer isn't i8* it will be converted. - CallInst *CreateLifetimeEnd(Value *Ptr, ConstantInt *Size = 0); + CallInst *CreateLifetimeEnd(Value *Ptr, ConstantInt *Size = nullptr); private: Value *getCastedInt8PtrValue(Value *Ptr); @@ -433,43 +433,44 @@ class IRBuilder : public IRBuilderBase, public Inserter { T Folder; public: IRBuilder(LLVMContext &C, const T &F, const Inserter &I = Inserter(), - MDNode *FPMathTag = 0) + MDNode *FPMathTag = nullptr) : IRBuilderBase(C, FPMathTag), Inserter(I), Folder(F) { } - explicit IRBuilder(LLVMContext &C, MDNode *FPMathTag = 0) + explicit IRBuilder(LLVMContext &C, MDNode *FPMathTag = nullptr) : IRBuilderBase(C, FPMathTag), Folder() { } - explicit IRBuilder(BasicBlock *TheBB, const T &F, MDNode *FPMathTag = 0) + explicit IRBuilder(BasicBlock *TheBB, const T &F, MDNode *FPMathTag = nullptr) : IRBuilderBase(TheBB->getContext(), FPMathTag), Folder(F) { SetInsertPoint(TheBB); } - explicit IRBuilder(BasicBlock *TheBB, MDNode *FPMathTag = 0) + explicit IRBuilder(BasicBlock *TheBB, MDNode *FPMathTag = nullptr) : IRBuilderBase(TheBB->getContext(), FPMathTag), Folder() { SetInsertPoint(TheBB); } - explicit IRBuilder(Instruction *IP, MDNode *FPMathTag = 0) + explicit IRBuilder(Instruction *IP, MDNode *FPMathTag = nullptr) : IRBuilderBase(IP->getContext(), FPMathTag), Folder() { SetInsertPoint(IP); SetCurrentDebugLocation(IP->getDebugLoc()); } - explicit IRBuilder(Use &U, MDNode *FPMathTag = 0) + explicit IRBuilder(Use &U, MDNode *FPMathTag = nullptr) : IRBuilderBase(U->getContext(), FPMathTag), Folder() { SetInsertPoint(U); SetCurrentDebugLocation(cast<Instruction>(U.getUser())->getDebugLoc()); } IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F, - MDNode *FPMathTag = 0) + MDNode *FPMathTag = nullptr) : IRBuilderBase(TheBB->getContext(), FPMathTag), Folder(F) { SetInsertPoint(TheBB, IP); } - IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, MDNode *FPMathTag = 0) + IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, + MDNode *FPMathTag = nullptr) : IRBuilderBase(TheBB->getContext(), FPMathTag), Folder() { SetInsertPoint(TheBB, IP); } @@ -541,7 +542,7 @@ public: /// \brief Create a conditional 'br Cond, TrueDest, FalseDest' /// instruction. BranchInst *CreateCondBr(Value *Cond, BasicBlock *True, BasicBlock *False, - MDNode *BranchWeights = 0) { + MDNode *BranchWeights = nullptr) { return Insert(addBranchWeights(BranchInst::Create(True, False, Cond), BranchWeights)); } @@ -550,7 +551,7 @@ public: /// and with a hint for the number of cases that will be added (for efficient /// allocation). SwitchInst *CreateSwitch(Value *V, BasicBlock *Dest, unsigned NumCases = 10, - MDNode *BranchWeights = 0) { + MDNode *BranchWeights = nullptr) { return Insert(addBranchWeights(SwitchInst::Create(V, Dest, NumCases), BranchWeights)); } @@ -638,7 +639,7 @@ public: return CreateAdd(LHS, RHS, Name, true, false); } Value *CreateFAdd(Value *LHS, Value *RHS, const Twine &Name = "", - MDNode *FPMathTag = 0) { + MDNode *FPMathTag = nullptr) { if (Constant *LC = dyn_cast<Constant>(LHS)) if (Constant *RC = dyn_cast<Constant>(RHS)) return Insert(Folder.CreateFAdd(LC, RC), Name); @@ -660,7 +661,7 @@ public: return CreateSub(LHS, RHS, Name, true, false); } Value *CreateFSub(Value *LHS, Value *RHS, const Twine &Name = "", - MDNode *FPMathTag = 0) { + MDNode *FPMathTag = nullptr) { if (Constant *LC = dyn_cast<Constant>(LHS)) if (Constant *RC = dyn_cast<Constant>(RHS)) return Insert(Folder.CreateFSub(LC, RC), Name); @@ -682,7 +683,7 @@ public: return CreateMul(LHS, RHS, Name, true, false); } Value *CreateFMul(Value *LHS, Value *RHS, const Twine &Name = "", - MDNode *FPMathTag = 0) { + MDNode *FPMathTag = nullptr) { if (Constant *LC = dyn_cast<Constant>(LHS)) if (Constant *RC = dyn_cast<Constant>(RHS)) return Insert(Folder.CreateFMul(LC, RC), Name); @@ -714,7 +715,7 @@ public: return CreateSDiv(LHS, RHS, Name, true); } Value *CreateFDiv(Value *LHS, Value *RHS, const Twine &Name = "", - MDNode *FPMathTag = 0) { + MDNode *FPMathTag = nullptr) { if (Constant *LC = dyn_cast<Constant>(LHS)) if (Constant *RC = dyn_cast<Constant>(RHS)) return Insert(Folder.CreateFDiv(LC, RC), Name); @@ -734,7 +735,7 @@ public: return Insert(BinaryOperator::CreateSRem(LHS, RHS), Name); } Value *CreateFRem(Value *LHS, Value *RHS, const Twine &Name = "", - MDNode *FPMathTag = 0) { + MDNode *FPMathTag = nullptr) { if (Constant *LC = dyn_cast<Constant>(LHS)) if (Constant *RC = dyn_cast<Constant>(RHS)) return Insert(Folder.CreateFRem(LC, RC), Name); @@ -844,7 +845,7 @@ public: Value *CreateBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, const Twine &Name = "", - MDNode *FPMathTag = 0) { + MDNode *FPMathTag = nullptr) { if (Constant *LC = dyn_cast<Constant>(LHS)) if (Constant *RC = dyn_cast<Constant>(RHS)) return Insert(Folder.CreateBinOp(Opc, LC, RC), Name); @@ -869,7 +870,8 @@ public: Value *CreateNUWNeg(Value *V, const Twine &Name = "") { return CreateNeg(V, Name, true, false); } - Value *CreateFNeg(Value *V, const Twine &Name = "", MDNode *FPMathTag = 0) { + Value *CreateFNeg(Value *V, const Twine &Name = "", + MDNode *FPMathTag = nullptr) { if (Constant *VC = dyn_cast<Constant>(V)) return Insert(Folder.CreateFNeg(VC), Name); return Insert(AddFPMathAttributes(BinaryOperator::CreateFNeg(V), @@ -885,7 +887,7 @@ public: // Instruction creation methods: Memory Instructions //===--------------------------------------------------------------------===// - AllocaInst *CreateAlloca(Type *Ty, Value *ArraySize = 0, + AllocaInst *CreateAlloca(Type *Ty, Value *ArraySize = nullptr, const Twine &Name = "") { return Insert(new AllocaInst(Ty, ArraySize), Name); } @@ -898,7 +900,7 @@ public: return Insert(new LoadInst(Ptr), Name); } LoadInst *CreateLoad(Value *Ptr, bool isVolatile, const Twine &Name = "") { - return Insert(new LoadInst(Ptr, 0, isVolatile), Name); + return Insert(new LoadInst(Ptr, nullptr, isVolatile), Name); } StoreInst *CreateStore(Value *Val, Value *Ptr, bool isVolatile = false) { return Insert(new StoreInst(Val, Ptr, isVolatile)); diff --git a/include/llvm/IR/InstrTypes.h b/include/llvm/IR/InstrTypes.h index e1a5130383..a27859edb5 100644 --- a/include/llvm/IR/InstrTypes.h +++ b/include/llvm/IR/InstrTypes.h @@ -36,7 +36,7 @@ class TerminatorInst : public Instruction { protected: TerminatorInst(Type *Ty, Instruction::TermOps iType, Use *Ops, unsigned NumOps, - Instruction *InsertBefore = 0) + Instruction *InsertBefore = nullptr) : Instruction(Ty, iType, Ops, NumOps, InsertBefore) {} TerminatorInst(Type *Ty, Instruction::TermOps iType, @@ -91,7 +91,7 @@ class UnaryInstruction : public Instruction { protected: UnaryInstruction(Type *Ty, unsigned iType, Value *V, - Instruction *IB = 0) + Instruction *IB = nullptr) : Instruction(Ty, iType, &Op<0>(), 1, IB) { Op<0>() = V; } @@ -160,7 +160,7 @@ public: /// static BinaryOperator *Create(BinaryOps Op, Value *S1, Value *S2, const Twine &Name = Twine(), - Instruction *InsertBefore = 0); + Instruction *InsertBefore = nullptr); /// Create() - Construct a binary instruction, given the opcode and the two /// operands. Also automatically insert this instruction to the end of the @@ -285,23 +285,23 @@ public: /// instructions out of SUB and XOR instructions. /// static BinaryOperator *CreateNeg(Value *Op, const Twine &Name = "", - Instruction *InsertBefore = 0); + Instruction *InsertBefore = nullptr); static BinaryOperator *CreateNeg(Value *Op, const Twine &Name, BasicBlock *InsertAtEnd); static BinaryOperator *CreateNSWNeg(Value *Op, const Twine &Name = "", - Instruction *InsertBefore = 0); + Instruction *InsertBefore = nullptr); static BinaryOperator *CreateNSWNeg(Value *Op, const Twine &Name, BasicBlock *InsertAtEnd); static BinaryOperator *CreateNUWNeg(Value *Op, const Twine &Name = "", - Instruction *InsertBefore = 0); + Instruction *InsertBefore = nullptr); static BinaryOperator *CreateNUWNeg(Value *Op, const Twine &Name, BasicBlock *InsertAtEnd); static BinaryOperator *CreateFNeg(Value *Op, const Twine &Name = "", - Instruction *InsertBefore = 0); + Instruction *InsertBefore = nullptr); static BinaryOperator *CreateFNeg(Value *Op, const Twine &Name, BasicBlock *InsertAtEnd); static BinaryOperator *CreateNot(Value *Op, const Twine &Name = "", - Instruction *InsertBefore = 0); + Instruction *InsertBefore = nullptr); static BinaryOperator *CreateNot(Value *Op, const Twine &Name, BasicBlock *InsertAtEnd); @@ -389,7 +389,7 @@ class CastInst : public UnaryInstruction { protected: /// @brief Constructor with insert-before-instruction semantics for subclasses CastInst(Type *Ty, unsigned iType, Value *S, - const Twine &NameStr = "", Instruction *InsertBefore = 0) + const Twine &NameStr = "", Instruction *InsertBefore = nullptr) : UnaryInstruction(Ty, iType, S, InsertBefore) { setName(NameStr); } @@ -411,7 +411,7 @@ public: Value *S, ///< The value to be casted (operand 0) Type *Ty, ///< The type to which cast should be made const Twine &Name = "", ///< Name for the instruction - Instruction *InsertBefore = 0 ///< Place to insert the instruction + Instruction *InsertBefore = nullptr ///< Place to insert the instruction ); /// Provides a way to construct any of the CastInst subclasses using an /// opcode instead of the subclass's constructor. The opcode must be in the @@ -432,7 +432,7 @@ public: Value *S, ///< The value to be casted (operand 0) Type *Ty, ///< The type to which cast should be made const Twine &Name = "", ///< Name for the instruction - Instruction *InsertBefore = 0 ///< Place to insert the instruction + Instruction *InsertBefore = nullptr ///< Place to insert the instruction ); /// @brief Create a ZExt or BitCast cast instruction @@ -448,7 +448,7 @@ public: Value *S, ///< The value to be casted (operand 0) Type *Ty, ///< The type to which cast should be made const Twine &Name = "", ///< Name for the instruction - Instruction *InsertBefore = 0 ///< Place to insert the instruction + Instruction *InsertBefore = nullptr ///< Place to insert the instruction ); /// @brief Create a SExt or BitCast cast instruction @@ -472,7 +472,7 @@ public: Value *S, ///< The pointer value to be casted (operand 0) Type *Ty, ///< The type to which cast should be made const Twine &Name = "", ///< Name for the instruction - Instruction *InsertBefore = 0 ///< Place to insert the instruction + Instruction *InsertBefore = nullptr ///< Place to insert the instruction ); /// @brief Create a ZExt, BitCast, or Trunc for int -> int casts. @@ -481,7 +481,7 @@ public: Type *Ty, ///< The type to which cast should be made bool isSigned, ///< Whether to regard S as signed or not const Twine &Name = "", ///< Name for the instruction - Instruction *InsertBefore = 0 ///< Place to insert the instruction + Instruction *InsertBefore = nullptr ///< Place to insert the instruction ); /// @brief Create a ZExt, BitCast, or Trunc for int -> int casts. @@ -498,7 +498,7 @@ public: Value *S, ///< The floating point value to be casted Type *Ty, ///< The floating point type to cast to const Twine &Name = "", ///< Name for the instruction - Instruction *InsertBefore = 0 ///< Place to insert the instruction + Instruction *InsertBefore = nullptr ///< Place to insert the instruction ); /// @brief Create an FPExt, BitCast, or FPTrunc for fp -> fp casts @@ -514,7 +514,7 @@ public: Value *S, ///< The value to be casted (operand 0) Type *Ty, ///< The type to which cast should be made const Twine &Name = "", ///< Name for the instruction - Instruction *InsertBefore = 0 ///< Place to insert the instruction + Instruction *InsertBefore = nullptr ///< Place to insert the instruction ); /// @brief Create a Trunc or BitCast cast instruction @@ -641,7 +641,7 @@ class CmpInst : public Instruction { protected: CmpInst(Type *ty, Instruction::OtherOps op, unsigned short pred, Value *LHS, Value *RHS, const Twine &Name = "", - Instruction *InsertBefore = 0); + Instruction *InsertBefore = nullptr); CmpInst(Type *ty, Instruction::OtherOps op, unsigned short pred, Value *LHS, Value *RHS, const Twine &Name, @@ -701,7 +701,7 @@ public: static CmpInst *Create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2, const Twine &Name = "", - Instruction *InsertBefore = 0); + Instruction *InsertBefore = nullptr); /// Construct a compare instruction, given the opcode, the predicate and the /// two operands. Also automatically insert this instruction to the end of diff --git a/include/llvm/IR/Instruction.h b/include/llvm/IR/Instruction.h index 928dc07b53..bac6a95b1b 100644 --- a/include/llvm/IR/Instruction.h +++ b/include/llvm/IR/Instruction.h @@ -141,14 +141,14 @@ public: /// getMetadata - Get the metadata of given kind attached to this Instruction. /// If the metadata is not found then return null. MDNode *getMetadata(unsigned KindID) const { - if (!hasMetadata()) return 0; + if (!hasMetadata()) return nullptr; return getMetadataImpl(KindID); } /// getMetadata - Get the metadata of given kind attached to this Instruction. /// If the metadata is not found then return null. MDNode *getMetadata(StringRef Kind) const { - if (!hasMetadata()) return 0; + if (!hasMetadata()) return nullptr; return getMetadataImpl(Kind); } @@ -461,7 +461,7 @@ protected: } Instruction(Type *Ty, unsigned iType, Use *Ops, unsigned NumOps, - Instruction *InsertBefore = 0); + Instruction *InsertBefore = nullptr); Instruction(Type *Ty, unsigned iType, Use *Ops, unsigned NumOps, BasicBlock *InsertAtEnd); virtual Instruction *clone_impl() const = 0; diff --git a/include/llvm/IR/Instructions.h b/include/llvm/IR/Instructions.h index 06d7287ea1..19d451e3de 100644 --- a/include/llvm/IR/Instructions.h +++ b/include/llvm/IR/Instructions.h @@ -60,16 +60,17 @@ class AllocaInst : public UnaryInstruction { protected: AllocaInst *clone_impl() const override; public: - explicit AllocaInst(Type *Ty, Value *ArraySize = 0, - const Twine &Name = "", Instruction *InsertBefore = 0); + explicit AllocaInst(Type *Ty, Value *ArraySize = nullptr, + const Twine &Name = "", + Instruction *InsertBefore = nullptr); AllocaInst(Type *Ty, Value *ArraySize, const Twine &Name, BasicBlock *InsertAtEnd); - AllocaInst(Type *Ty, const Twine &Name, Instruction *InsertBefore = 0); + AllocaInst(Type *Ty, const Twine &Name, Instruction *InsertBefore = nullptr); AllocaInst(Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd); AllocaInst(Type *Ty, Value *ArraySize, unsigned Align, - const Twine &Name = "", Instruction *InsertBefore = 0); + const Twine &Name = "", Instruction *InsertBefore = nullptr); AllocaInst(Type *Ty, Value *ArraySize, unsigned Align, const Twine &Name, BasicBlock *InsertAtEnd); @@ -156,17 +157,17 @@ public: LoadInst(Value *Ptr, const Twine &NameStr, Instruction *InsertBefore); LoadInst(Value *Ptr, const Twine &NameStr, BasicBlock *InsertAtEnd); LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile = false, - Instruction *InsertBefore = 0); + Instruction *InsertBefore = nullptr); LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile, BasicBlock *InsertAtEnd); LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile, - unsigned Align, Instruction *InsertBefore = 0); + unsigned Align, Instruction *InsertBefore = nullptr); LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile, unsigned Align, BasicBlock *InsertAtEnd); LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile, unsigned Align, AtomicOrdering Order, SynchronizationScope SynchScope = CrossThread, - Instruction *InsertBefore = 0); + Instruction *InsertBefore = nullptr); LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile, unsigned Align, AtomicOrdering Order, SynchronizationScope SynchScope, @@ -174,8 +175,9 @@ public: LoadInst(Value *Ptr, const char *NameStr, Instruction *InsertBefore); LoadInst(Value *Ptr, const char *NameStr, BasicBlock *InsertAtEnd); - explicit LoadInst(Value *Ptr, const char *NameStr = 0, - bool isVolatile = false, Instruction *InsertBefore = 0); + explicit LoadInst(Value *Ptr, const char *NameStr = nullptr, + bool isVolatile = false, + Instruction *InsertBefore = nullptr); LoadInst(Value *Ptr, const char *NameStr, bool isVolatile, BasicBlock *InsertAtEnd); @@ -280,16 +282,16 @@ public: StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore); StoreInst(Value *Val, Value *Ptr, BasicBlock *InsertAtEnd); StoreInst(Value *Val, Value *Ptr, bool isVolatile = false, - Instruction *InsertBefore = 0); + Instruction *InsertBefore = nullptr); StoreInst(Value *Val, Value *Ptr, bool isVolatile, BasicBlock *InsertAtEnd); StoreInst(Value *Val, Value *Ptr, bool isVolatile, - unsigned Align, Instruction *InsertBefore = 0); + unsigned Align, Instruction *InsertBefore = nullptr); StoreInst(Value *Val, Value *Ptr, bool isVolatile, unsigned Align, BasicBlock *InsertAtEnd); StoreInst(Value *Val, Value *Ptr, bool isVolatile, unsigned Align, AtomicOrdering Order, SynchronizationScope SynchScope = CrossThread, - Instruction *InsertBefore = 0); + Instruction *InsertBefore = nullptr); StoreInst(Value *Val, Value *Ptr, bool isVolatile, unsigned Align, AtomicOrdering Order, SynchronizationScope SynchScope, @@ -409,7 +411,7 @@ public: // SequentiallyConsistent. FenceInst(LLVMContext &C, AtomicOrdering Ordering, SynchronizationScope SynchScope = CrossThread, - Instruction *InsertBefore = 0); + Instruction *InsertBefore = nullptr); FenceInst(LLVMContext &C, AtomicOrdering Ordering, SynchronizationScope SynchScope, BasicBlock *InsertAtEnd); @@ -477,7 +479,7 @@ public: AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering, SynchronizationScope SynchScope, - Instruction *InsertBefore = 0); + Instruction *InsertBefore = nullptr); AtomicCmpXchgInst(Value *Ptr, Value *Cmp, Value *NewVal, AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering, @@ -651,7 +653,7 @@ public: } AtomicRMWInst(BinOp Operation, Value *Ptr, Value *Val, AtomicOrdering Ordering, SynchronizationScope SynchScope, - Instruction *InsertBefore = 0); + Instruction *InsertBefore = nullptr); AtomicRMWInst(BinOp Operation, Value *Ptr, Value *Val, AtomicOrdering Ordering, SynchronizationScope SynchScope, BasicBlock *InsertAtEnd); @@ -779,7 +781,7 @@ protected: public: static GetElementPtrInst *Create(Value *Ptr, ArrayRef<Value *> IdxList, const Twine &NameStr = "", - Instruction *InsertBefore = 0) { + Instruction *InsertBefore = nullptr) { unsigned Values = 1 + unsigned(IdxList.size()); return new(Values) GetElementPtrInst(Ptr, IdxList, Values, NameStr, InsertBefore); @@ -797,7 +799,7 @@ public: static GetElementPtrInst *CreateInBounds(Value *Ptr, ArrayRef<Value *> IdxList, const Twine &NameStr = "", - Instruction *InsertBefore = 0) { + Instruction *InsertBefore = nullptr){ GetElementPtrInst *GEP = Create(Ptr, IdxList, NameStr, InsertBefore); GEP->setIsInBounds(true); return GEP; @@ -1237,7 +1239,7 @@ public: static CallInst *Create(Value *Func, ArrayRef<Value *> Args, const Twine &NameStr = "", - Instruction *InsertBefore = 0) { + Instruction *InsertBefore = nullptr) { return new(unsigned(Args.size() + 1)) CallInst(Func, Args, NameStr, InsertBefore); } @@ -1248,7 +1250,7 @@ public: CallInst(Func, Args, NameStr, InsertAtEnd); } static CallInst *Create(Value *F, const Twine &NameStr = "", - Instruction *InsertBefore = 0) { + Instruction *InsertBefore = nullptr) { return new(1) CallInst(F, NameStr, InsertBefore); } static CallInst *Create(Value *F, const Twine &NameStr, @@ -1263,13 +1265,13 @@ public: /// 3. Bitcast the result of the malloc call to the specified type. static Instruction *CreateMalloc(Instruction *InsertBefore, Type *IntPtrTy, Type *AllocTy, - Value *AllocSize, Value *ArraySize = 0, - Function* MallocF = 0, + Value *AllocSize, Value *ArraySize = nullptr, + Function* MallocF = nullptr, const Twine &Name = ""); static Instruction *CreateMalloc(BasicBlock *InsertAtEnd, Type *IntPtrTy, Type *AllocTy, - Value *AllocSize, Value *ArraySize = 0, - Function* MallocF = 0, + Value *AllocSize, Value *ArraySize = nullptr, + Function* MallocF = nullptr, const Twine &Name = ""); /// CreateFree - Generate the IR for a call to the builtin free function. static Instruction* CreateFree(Value* Source, Instruction *InsertBefore); @@ -1520,7 +1522,7 @@ protected: public: static SelectInst *Create(Value *C, Value *S1, Value *S2, const Twine &NameStr = "", - Instruction *InsertBefore = 0) { + Instruction *InsertBefore = nullptr) { return new(3) SelectInst(C, S1, S2, NameStr, InsertBefore); } static SelectInst *Create(Value *C, Value *S1, Value *S2, @@ -1575,7 +1577,7 @@ protected: public: VAArgInst(Value *List, Type *Ty, const Twine &NameStr = "", - Instruction *InsertBefore = 0) + Instruction *InsertBefore = nullptr) : UnaryInstruction(Ty, VAArg, List, InsertBefore) { setName(NameStr); } @@ -1607,7 +1609,7 @@ public: /// class ExtractElementInst : public Instruction { ExtractElementInst(Value *Vec, Value *Idx, const Twine &NameStr = "", - Instruction *InsertBefore = 0); + Instruction *InsertBefore = nullptr); ExtractElementInst(Value *Vec, Value *Idx, const Twine &NameStr, BasicBlock *InsertAtEnd); protected: @@ -1616,7 +1618,7 @@ protected: public: static ExtractElementInst *Create(Value *Vec, Value *Idx, const Twine &NameStr = "", - Instruction *InsertBefore = 0) { + Instruction *InsertBefore = nullptr) { return new(2) ExtractElementInst(Vec, Idx, NameStr, InsertBefore); } static ExtractElementInst *Create(Value *Vec, Value *Idx, @@ -1668,7 +1670,7 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ExtractElementInst, Value) class InsertElementInst : public Instruction { InsertElementInst(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr = "", - Instruction *InsertBefore = 0); + Instruction *InsertBefore = nullptr); InsertElementInst(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr, BasicBlock *InsertAtEnd); protected: @@ -1677,7 +1679,7 @@ protected: public: static InsertElementInst *Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr = "", - Instruction *InsertBefore = 0) { + Instruction *InsertBefore = nullptr) { return new(3) InsertElementInst(Vec, NewElt, Idx, NameStr, InsertBefore); } static InsertElementInst *Create(Value *Vec, Value *NewElt, Value *Idx, @@ -1734,7 +1736,7 @@ public: } ShuffleVectorInst(Value *V1, Value *V2, Value *Mask, const Twine &NameStr = "", - Instruction *InsertBefor = 0); + Instruction *InsertBefor = nullptr); ShuffleVectorInst(Value *V1, Value *V2, Value *Mask, const Twine &NameStr, BasicBlock *InsertAtEnd); @@ -1832,7 +1834,7 @@ public: static ExtractValueInst *Create(Value *Agg, ArrayRef<unsigned> Idxs, const Twine &NameStr = "", - Instruction *InsertBefore = 0) { + Instruction *InsertBefore = nullptr) { return new ExtractValueInst(Agg, Idxs, NameStr, InsertBefore); } @@ -1933,7 +1935,7 @@ class InsertValueInst : public Instruction { /// and two index insertvalue instructions are so common. InsertValueInst(Value *Agg, Value *Val, unsigned Idx, const Twine &NameStr = "", - Instruction *InsertBefore = 0); + Instruction *InsertBefore = nullptr); InsertValueInst(Value *Agg, Value *Val, unsigned Idx, const Twine &NameStr, BasicBlock *InsertAtEnd); protected: @@ -1947,7 +1949,7 @@ public: static InsertValueInst *Create(Value *Agg, Value *Val, ArrayRef<unsigned> Idxs, const Twine &NameStr = "", - Instruction *InsertBefore = 0) { + Instruction *InsertBefore = nullptr) { return new InsertValueInst(Agg, Val, Idxs, NameStr, InsertBefore); } static InsertValueInst *Create(Value *Agg, Value *Val, @@ -2052,8 +2054,9 @@ class PHINode : public Instruction { return User::operator new(s, 0); } explicit PHINode(Type *Ty, unsigned NumReservedValues, - const Twine &NameStr = "", Instruction *InsertBefore = 0) - : Instruction(Ty, Instruction::PHI, 0, 0, InsertBefore), + const Twine &NameStr = "", + Instruction *InsertBefore = nullptr) + : Instruction(Ty, Instruction::PHI, nullptr, 0, InsertBefore), ReservedSpace(NumReservedValues) { setName(NameStr); OperandList = allocHungoffUses(ReservedSpace); @@ -2061,7 +2064,7 @@ class PHINode : public Instruction { PHINode(Type *Ty, unsigned NumReservedValues, const Twine &NameStr, BasicBlock *InsertAtEnd) - : Instruction(Ty, Instruction::PHI, 0, 0, InsertAtEnd), + : Instruction(Ty, Instruction::PHI, nullptr, 0, InsertAtEnd), ReservedSpace(NumReservedValues) { setName(NameStr); OperandList = allocHungoffUses(ReservedSpace); @@ -2078,7 +2081,7 @@ public: /// edges that this phi node will have (use 0 if you really have no idea). static PHINode *Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr = "", - Instruction *InsertBefore = 0) { + Instruction *InsertBefore = nullptr) { return new PHINode(Ty, NumReservedValues, NameStr, InsertBefore); } static PHINode *Create(Type *Ty, unsigned NumReservedValues, @@ -2270,7 +2273,7 @@ public: static LandingPadInst *Create(Type *RetTy, Value *PersonalityFn, unsigned NumReservedClauses, const Twine &NameStr = "", - Instruction *InsertBefore = 0); + Instruction *InsertBefore = nullptr); static LandingPadInst *Create(Type *RetTy, Value *PersonalityFn, unsigned NumReservedClauses, const Twine &NameStr, BasicBlock *InsertAtEnd); @@ -2356,15 +2359,15 @@ private: // // NOTE: If the Value* passed is of type void then the constructor behaves as // if it was passed NULL. - explicit ReturnInst(LLVMContext &C, Value *retVal = 0, - Instruction *InsertBefore = 0); + explicit ReturnInst(LLVMContext &C, Value *retVal = nullptr, + Instruction *InsertBefore = nullptr); ReturnInst(LLVMContext &C, Value *retVal, BasicBlock *InsertAtEnd); explicit ReturnInst(LLVMContext &C, BasicBlock *InsertAtEnd); protected: ReturnInst *clone_impl() const override; public: - static ReturnInst* Create(LLVMContext &C, Value *retVal = 0, - Instruction *InsertBefore = 0) { + static ReturnInst* Create(LLVMContext &C, Value *retVal = nullptr, + Instruction *InsertBefore = nullptr) { return new(!!retVal) ReturnInst(C, retVal, InsertBefore); } static ReturnInst* Create(LLVMContext &C, Value *retVal, @@ -2381,7 +2384,7 @@ public: /// Convenience accessor. Returns null if there is no return value. Value *getReturnValue() const { - return getNumOperands() != 0 ? getOperand(0) : 0; + return getNumOperands() != 0 ? getOperand(0) : nullptr; } unsigned getNumSuccessors() const { return 0; } @@ -2426,20 +2429,21 @@ class BranchInst : public TerminatorInst { // BranchInst(BB* T, BB *F, Value *C, Inst *I) - 'br C, T, F', insert before I // BranchInst(BB* B, BB *I) - 'br B' insert at end // BranchInst(BB* T, BB *F, Value *C, BB *I) - 'br C, T, F', insert at end - explicit BranchInst(BasicBlock *IfTrue, Instruction *InsertBefore = 0); + explicit BranchInst(BasicBlock *IfTrue, Instruction *InsertBefore = nullptr); BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, - Instruction *InsertBefore = 0); + Instruction *InsertBefore = nullptr); BranchInst(BasicBlock *IfTrue, BasicBlock *InsertAtEnd); BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, BasicBlock *InsertAtEnd); protected: BranchInst *clone_impl() const override; public: - static BranchInst *Create(BasicBlock *IfTrue, Instruction *InsertBefore = 0) { + static BranchInst *Create(BasicBlock *IfTrue, + Instruction *InsertBefore = nullptr) { return new(1) BranchInst(IfTrue, InsertBefore); } static BranchInst *Create(BasicBlock *IfTrue, BasicBlock *IfFalse, - Value *Cond, Instruction *InsertBefore = 0) { + Value *Cond, Instruction *InsertBefore = nullptr) { return new(3) BranchInst(IfTrue, IfFalse, Cond, InsertBefore); } static BranchInst *Create(BasicBlock *IfTrue, BasicBlock *InsertAtEnd) { @@ -2658,7 +2662,8 @@ public: }; static SwitchInst *Create(Value *Value, BasicBlock *Default, - unsigned NumCases, Instruction *InsertBefore = 0) { + unsigned NumCases, + Instruction *InsertBefore = nullptr) { return new SwitchInst(Value, Default, NumCases, InsertBefore); } static SwitchInst *Create(Value *Value, BasicBlock *Default, @@ -2742,12 +2747,12 @@ public: /// findCaseDest - Finds the unique case value for a given successor. Returns /// null if the successor is not found, not unique, or is the default case. ConstantInt *findCaseDest(BasicBlock *BB) { - if (BB == getDefaultDest()) return NULL; + if (BB == getDefaultDest()) return nullptr; - ConstantInt *CI = NULL; + ConstantInt *CI = nullptr; for (CaseIt i = case_begin(), e = case_end(); i != e; ++i) { if (i.getCaseSuccessor() == BB) { - if (CI) return NULL; // Multiple cases lead to BB. + if (CI) return nullptr; // Multiple cases lead to BB. else CI = i.getCaseValue(); } } @@ -2834,7 +2839,7 @@ protected: IndirectBrInst *clone_impl() const override; public: static IndirectBrInst *Create(Value *Address, unsigned NumDests, - Instruction *InsertBefore = 0) { + Instruction *InsertBefore = nullptr) { return new IndirectBrInst(Address, NumDests, InsertBefore); } static IndirectBrInst *Create(Value *Address, unsigned NumDests, @@ -2928,7 +2933,7 @@ public: static InvokeInst *Create(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef<Value *> Args, const Twine &NameStr = "", - Instruction *InsertBefore = 0) { + Instruction *InsertBefore = nullptr) { unsigned Values = unsigned(Args.size()) + 3; return new(Values) InvokeInst(Func, IfNormal, IfException, Args, Values, NameStr, InsertBefore); @@ -3175,12 +3180,12 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InvokeInst, Value) class ResumeInst : public TerminatorInst { ResumeInst(const ResumeInst &RI); - explicit ResumeInst(Value *Exn, Instruction *InsertBefore=0); + explicit ResumeInst(Value *Exn, Instruction *InsertBefore=nullptr); ResumeInst(Value *Exn, BasicBlock *InsertAtEnd); protected: ResumeInst *clone_impl() const override; public: - static ResumeInst *Create(Value *Exn, Instruction *InsertBefore = 0) { + static ResumeInst *Create(Value *Exn, Instruction *InsertBefore = nullptr) { return new(1) ResumeInst(Exn, InsertBefore); } static ResumeInst *Create(Value *Exn, BasicBlock *InsertAtEnd) { @@ -3234,7 +3239,7 @@ public: void *operator new(size_t s) { return User::operator new(s, 0); } - explicit UnreachableInst(LLVMContext &C, Instruction *InsertBefore = 0); + explicit UnreachableInst(LLVMContext &C, Instruction *InsertBefore = nullptr); explicit UnreachableInst(LLVMContext &C, BasicBlock *InsertAtEnd); unsigned getNumSuccessors() const { return 0; } @@ -3265,16 +3270,16 @@ protected: public: /// \brief Constructor with insert-before-instruction semantics TruncInst( - Value *S, ///< The value to be truncated - Type *Ty, ///< The (smaller) type to truncate to - const Twine &NameStr = "", ///< A name for the new instruction - Instruction *InsertBefore = 0 ///< Where to insert the new instruction + Value *S, ///< The value to be truncated + Type *Ty, ///< The (smaller) type to truncate to + const Twine &NameStr = "", ///< A name for the new instruction + Instruction *InsertBefore = nullptr ///< Where to insert the new instruction ); /// \brief Constructor with insert-at-end-of-block semantics TruncInst( Value *S, ///< The value to be truncated - Type *Ty, ///< The (smaller) type to truncate to + Type *Ty, ///< The (smaller) type to truncate to const Twine &NameStr, ///< A name for the new instruction BasicBlock *InsertAtEnd ///< The block to insert the instruction into ); @@ -3301,16 +3306,16 @@ protected: public: /// \brief Constructor with insert-before-instruction semantics ZExtInst( - Value *S, ///< The value to be zero extended - Type *Ty, ///< The type to zero extend to - const Twine &NameStr = "", ///< A name for the new instruction - Instruction *InsertBefore = 0 ///< Where to insert the new instruction + Value *S, ///< The value to be zero extended + Type *Ty, ///< The type to zero extend to + const Twine &NameStr = "", ///< A name for the new instruction + Instruction *InsertBefore = nullptr ///< Where to insert the new instruction ); /// \brief Constructor with insert-at-end semantics. ZExtInst( Value *S, ///< The value to be zero extended - Type *Ty, ///< The type to zero extend to + Type *Ty, ///< The type to zero extend to const Twine &NameStr, ///< A name for the new instruction BasicBlock *InsertAtEnd ///< The block to insert the instruction into ); @@ -3337,16 +3342,16 @@ protected: public: /// \brief Constructor with insert-before-instruction semantics SExtInst( - Value *S, ///< The value to be sign extended - Type *Ty, ///< The type to sign extend to - const Twine &NameStr = "", ///< A name for the new instruction - Instruction *InsertBefore = 0 ///< Where to insert the new instruction + Value *S, ///< The value to be sign extended + Type *Ty, ///< The type to sign extend to + const Twine &NameStr = "", ///< A name for the new instruction + Instruction *InsertBefore = nullptr ///< Where to insert the new instruction ); /// \brief Constructor with insert-at-end-of-block semantics SExtInst( Value *S, ///< The value to be sign extended - Type *Ty, ///< The type to sign extend to + Type *Ty, ///< The type to sign extend to const Twine &NameStr, ///< A name for the new instruction BasicBlock *InsertAtEnd ///< The block to insert the instruction into ); @@ -3373,16 +3378,16 @@ protected: public: /// \brief Constructor with insert-before-instruction semantics FPTruncInst( - Value *S, ///< The value to be truncated - Type *Ty, ///< The type to truncate to - const Twine &NameStr = "", ///< A name for the new instruction - Instruction *InsertBefore = 0 ///< Where to insert the new instruction + Value *S, ///< The value to be truncated + Type *Ty, ///< The type to truncate to + const Twine &NameStr = "", ///< A name for the new instruction + Instruction *InsertBefore = nullptr ///< Where to insert the new instruction ); /// \brief Constructor with insert-before-instruction semantics FPTruncInst( Value *S, ///< The value to be truncated - Type *Ty, ///< The type to truncate to + Type *Ty, ///< The type to truncate to const Twine &NameStr, ///< A name for the new instruction BasicBlock *InsertAtEnd ///< The block to insert the instruction into ); @@ -3409,16 +3414,16 @@ protected: public: /// \brief Constructor with insert-before-instruction semantics FPExtInst( - Value *S, ///< The value to be extended - Type *Ty, ///< The type to extend to - const Twine &NameStr = "", ///< A name for the new instruction - Instruction *InsertBefore = 0 ///< Where to insert the new instruction + Value *S, ///< The value to be extended + Type *Ty, ///< The type to extend to + const Twine &NameStr = "", ///< A name for the new instruction + Instruction *InsertBefore = nullptr ///< Where to insert the new instruction ); /// \brief Constructor with insert-at-end-of-block semantics FPExtInst( Value *S, ///< The value to be extended - Type *Ty, ///< The type to extend to + Type *Ty, ///< The type to extend to const Twine &NameStr, ///< A name for the new instruction BasicBlock *InsertAtEnd ///< The block to insert the instruction into ); @@ -3445,16 +3450,16 @@ protected: public: /// \brief Constructor with insert-before-instruction semantics UIToFPInst( - Value *S, ///< The value to be converted - Type *Ty, ///< The type to convert to - const Twine &NameStr = "", ///< A name for the new instruction - Instruction *InsertBefore = 0 ///< Where to insert the new instruction + Value *S, ///< The value to be converted + Type *Ty, ///< The type to convert to + const Twine &NameStr = "", ///< A name for the new instruction + Instruction *InsertBefore = nullptr ///< Where to insert the new instruction ); /// \brief Constructor with insert-at-end-of-block semantics UIToFPInst( Value *S, ///< The value to be converted - Type *Ty, ///< The type to convert to + Type *Ty, ///< The type to convert to const Twine &NameStr, ///< A name for the new instruction BasicBlock *InsertAtEnd ///< The block to insert the instruction into ); @@ -3481,16 +3486,16 @@ protected: public: /// \brief Constructor with insert-before-instruction semantics SIToFPInst( - Value *S, ///< The value to be converted - Type *Ty, ///< The type to convert to - const Twine &NameStr = "", ///< A name for the new instruction - Instruction *InsertBefore = 0 ///< Where to insert the new instruction + Value *S, ///< The value to be converted + Type *Ty, ///< The type to convert to + const Twine &NameStr = "", ///< A name for the new instruction + Instruction *InsertBefore = nullptr ///< Where to insert the new instruction ); /// \brief Constructor with insert-at-end-of-block semantics SIToFPInst( Value *S, ///< The value to be converted - Type *Ty, ///< The type to convert to + Type *Ty, ///< The type to convert to const Twine &NameStr, ///< A name for the new instruction BasicBlock *InsertAtEnd ///< The block to insert the instruction into ); @@ -3517,16 +3522,16 @@ protected: public: /// \brief Constructor with insert-before-instruction semantics FPToUIInst( - Value *S, ///< The value to be converted - Type *Ty, ///< The type to convert to - const Twine &NameStr = "", ///< A name for the new instruction - Instruction *InsertBefore = 0 ///< Where to insert the new instruction + Value *S, ///< The value to be converted + Type *Ty, ///< The type to convert to + const Twine &NameStr = "", ///< A name for the new instruction + Instruction *InsertBefore = nullptr ///< Where to insert the new instruction ); /// \brief Constructor with insert-at-end-of-block semantics FPToUIInst( Value *S, ///< The value to be converted - Type *Ty, ///< The type to convert to + Type *Ty, ///< The type to convert to const Twine &NameStr, ///< A name for the new instruction BasicBlock *InsertAtEnd ///< Where to insert the new instruction ); @@ -3553,16 +3558,16 @@ protected: public: /// \brief Constructor with insert-before-instruction semantics FPToSIInst( - Value *S, ///< The value to be converted - Type *Ty, ///< The type to convert to - const Twine &NameStr = "", ///< A name for the new instruction - Instruction *InsertBefore = 0 ///< Where to insert the new instruction + Value *S, ///< The value to be converted + Type *Ty, ///< The type to convert to + const Twine &NameStr = "", ///< A name for the new instruction + Instruction *InsertBefore = nullptr ///< Where to insert the new instruction ); /// \brief Constructor with insert-at-end-of-block semantics FPToSIInst( Value *S, ///< The value to be converted - Type *Ty, ///< The type to convert to + Type *Ty, ///< The type to convert to const Twine &NameStr, ///< A name for the new instruction BasicBlock *InsertAtEnd ///< The block to insert the instruction into ); @@ -3585,16 +3590,16 @@ class IntToPtrInst : public CastInst { public: /// \brief Constructor with insert-before-instruction semantics IntToPtrInst( - Value *S, ///< The value to be converted - Type *Ty, ///< The type to convert to - const Twine &NameStr = "", ///< A name for the new instruction - Instruction *InsertBefore = 0 ///< Where to insert the new instruction + Value *S, ///< The value to be converted + Type *Ty, ///< The type to convert to + const Twine &NameStr = "", ///< A name for the new instruction + Instruction *InsertBefore = nullptr ///< Where to insert the new instruction ); /// \brief Constructor with insert-at-end-of-block semantics IntToPtrInst( Value *S, ///< The value to be converted - Type *Ty, ///< The type to convert to + Type *Ty, ///< The type to convert to const Twine &NameStr, ///< A name for the new instruction BasicBlock *InsertAtEnd ///< The block to insert the instruction into ); @@ -3629,16 +3634,16 @@ protected: public: /// \brief Constructor with insert-before-instruction semantics PtrToIntInst( - Value *S, ///< The value to be converted - Type *Ty, ///< The type to convert to - const Twine &NameStr = "", ///< A name for the new instruction - Instruction *InsertBefore = 0 ///< Where to insert the new instruction + Value *S, ///< The value to be converted + Type *Ty, ///< The type to convert to + const Twine &NameStr = "", ///< A name for the new instruction + Instruction *InsertBefore = nullptr ///< Where to insert the new instruction ); /// \brief Constructor with insert-at-end-of-block semantics PtrToIntInst( Value *S, ///< The value to be converted - Type *Ty, ///< The type to convert to + Type *Ty, ///< The type to convert to const Twine &NameStr, ///< A name for the new instruction BasicBlock *InsertAtEnd ///< The block to insert the instruction into ); @@ -3677,16 +3682,16 @@ protected: public: /// \brief Constructor with insert-before-instruction semantics BitCastInst( - Value *S, ///< The value to be casted - Type *Ty, ///< The type to casted to - const Twine &NameStr = "", ///< A name for the new instruction - Instruction *InsertBefore = 0 ///< Where to insert the new instruction + Value *S, ///< The value to be casted + Type *Ty, ///< The type to casted to + const Twine &NameStr = "", ///< A name for the new instruction + Instruction *InsertBefore = nullptr ///< Where to insert the new instruction ); /// \brief Constructor with insert-at-end-of-block semantics BitCastInst( Value *S, ///< The value to be casted - Type *Ty, ///< The type to casted to + Type *Ty, ///< The type to casted to const Twine &NameStr, ///< A name for the new instruction BasicBlock *InsertAtEnd ///< The block to insert the instruction into ); @@ -3714,10 +3719,10 @@ protected: public: /// \brief Constructor with insert-before-instruction semantics AddrSpaceCastInst( - Value *S, ///< The value to be casted - Type *Ty, ///< The type to casted to - const Twine &NameStr = "", ///< A name for the new instruction - Instruction *InsertBefore = 0 ///< Where to insert the new instruction + Value *S, ///< The value to be casted + Type *Ty, ///< The type to casted to + const Twine &NameStr = "", ///< A name for the new instruction + Instruction *InsertBefore = nullptr ///< Where to insert the new instruction ); /// \brief Constructor with insert-at-end-of-block semantics diff --git a/include/llvm/IR/LLVMContext.h b/include/llvm/IR/LLVMContext.h index 5c698f81de..7356c17027 100644 --- a/include/llvm/IR/LLVMContext.h +++ b/include/llvm/IR/LLVMContext.h @@ -80,7 +80,7 @@ public: /// LLVMContext doesn't take ownership or interpret either of these /// pointers. void setInlineAsmDiagnosticHandler(InlineAsmDiagHandlerTy DiagHandler, - void *DiagContext = 0); + void *DiagContext = nullptr); /// getInlineAsmDiagnosticHandler - Return the diagnostic handler set by /// setInlineAsmDiagnosticHandler. @@ -98,7 +98,7 @@ public: /// LLVMContext doesn't take ownership or interpret either of these /// pointers. void setDiagnosticHandler(DiagnosticHandlerTy DiagHandler, - void *DiagContext = 0); + void *DiagContext = nullptr); /// getDiagnosticHandler - Return the diagnostic handler set by /// setDiagnosticHandler. diff --git a/include/llvm/IR/LegacyPassManagers.h b/include/llvm/IR/LegacyPassManagers.h index 5c9dccd8b2..f4d29675ce 100644 --- a/include/llvm/IR/LegacyPassManagers.h +++ b/include/llvm/IR/LegacyPassManagers.h @@ -120,11 +120,11 @@ class PassManagerPrettyStackEntry : public PrettyStackTraceEntry { Module *M; public: explicit PassManagerPrettyStackEntry(Pass *p) - : P(p), V(0), M(0) {} // When P is releaseMemory'd. + : P(p), V(nullptr), M(nullptr) {} // When P is releaseMemory'd. PassManagerPrettyStackEntry(Pass *p, Value &v) - : P(p), V(&v), M(0) {} // When P is run on V + : P(p), V(&v), M(nullptr) {} // When P is run on V PassManagerPrettyStackEntry(Pass *p, Module &m) - : P(p), V(0), M(&m) {} // When P is run on M + : P(p), V(nullptr), M(&m) {} // When P is run on M /// print - Emit information about this stack frame to OS. void print(raw_ostream &OS) const override; @@ -263,7 +263,7 @@ private: class PMDataManager { public: - explicit PMDataManager() : TPM(NULL), Depth(0) { + explicit PMDataManager() : TPM(nullptr), Depth(0) { initializeAnalysisInfo(); } @@ -303,7 +303,7 @@ public: void initializeAnalysisInfo() { AvailableAnalysis.clear(); for (unsigned i = 0; i < PMT_Last; ++i) - InheritedAnalysis[i] = NULL; + InheritedAnalysis[i] = nullptr; } // Return true if P preserves high level analysis used by other diff --git a/include/llvm/IR/LegacyPassNameParser.h b/include/llvm/IR/LegacyPassNameParser.h index 1f6bbbcc09..ec8671082d 100644 --- a/include/llvm/IR/LegacyPassNameParser.h +++ b/include/llvm/IR/LegacyPassNameParser.h @@ -43,7 +43,7 @@ class PassNameParser : public PassRegistrationListener, public cl::parser<const PassInfo*> { cl::Option *Opt; public: - PassNameParser() : Opt(0) {} + PassNameParser() : Opt(nullptr) {} virtual ~PassNameParser(); void initialize(cl::Option &O) { @@ -62,8 +62,8 @@ public: inline bool ignorablePass(const PassInfo *P) const { // Ignore non-selectable and non-constructible passes! Ignore // non-optimizations. - return P->getPassArgument() == 0 || *P->getPassArgument() == 0 || - P->getNormalCtor() == 0 || ignorablePassImpl(P); + return P->getPassArgument() == nullptr || *P->getPassArgument() == 0 || + P->getNormalCtor() == nullptr || ignorablePassImpl(P); } // Implement the PassRegistrationListener callbacks used to populate our map diff --git a/include/llvm/IR/Metadata.h b/include/llvm/IR/Metadata.h index d054fbba22..c734f01623 100644 --- a/include/llvm/IR/Metadata.h +++ b/include/llvm/IR/Metadata.h @@ -218,7 +218,7 @@ class NamedMDNode : public ilist_node<NamedMDNode> { friend class NamedMDNode; public: - op_iterator_impl() : Node(0), Idx(0) { } + op_iterator_impl() : Node(nullptr), Idx(0) { } bool operator==(const op_iterator_impl &o) const { return Idx == o.Idx; } bool operator!=(const op_iterator_impl &o) const { return Idx != o.Idx; } @@ -272,7 +272,7 @@ public: StringRef getName() const; /// print - Implement operator<< on NamedMDNode. - void print(raw_ostream &ROS, AssemblyAnnotationWriter *AAW = 0) const; + void print(raw_ostream &ROS, AssemblyAnnotationWriter *AAW = nullptr) const; /// dump() - Allow printing of NamedMDNodes from the debugger. void dump() const; diff --git a/include/llvm/IR/Module.h b/include/llvm/IR/Module.h index f0d4002000..f728b4eeaa 100644 --- a/include/llvm/IR/Module.h +++ b/include/llvm/IR/Module.h @@ -457,7 +457,7 @@ public: /// Materialize - Make sure the GlobalValue is fully read. If the module is /// corrupt, this returns true and fills in the optional string with /// information about the problem. If successful, this returns false. - bool Materialize(GlobalValue *GV, std::string *ErrInfo = 0); + bool Materialize(GlobalValue *GV, std::string *ErrInfo = nullptr); /// Dematerialize - If the GlobalValue is read in, and if the GVMaterializer /// supports it, release the memory for the function, and set it up to be /// materialized lazily. If !isDematerializable(), this method is a noop. @@ -603,7 +603,7 @@ public: /// An raw_ostream inserter for modules. inline raw_ostream &operator<<(raw_ostream &O, const Module &M) { - M.print(O, 0); + M.print(O, nullptr); return O; } diff --git a/include/llvm/IR/PassManager.h b/include/llvm/IR/PassManager.h index c6c530cce5..9575e12edb 100644 --- a/include/llvm/IR/PassManager.h +++ b/include/llvm/IR/PassManager.h @@ -480,7 +480,7 @@ public: /// /// This method should only be called for a single module as there is the /// expectation that the lifetime of a pass is bounded to that of a module. - PreservedAnalyses run(Module *M, ModuleAnalysisManager *AM = 0); + PreservedAnalyses run(Module *M, ModuleAnalysisManager *AM = nullptr); template <typename ModulePassT> void addPass(ModulePassT Pass) { Passes.emplace_back(new ModulePassModel<ModulePassT>(std::move(Pass))); @@ -524,7 +524,7 @@ public: Passes.emplace_back(new FunctionPassModel<FunctionPassT>(std::move(Pass))); } - PreservedAnalyses run(Function *F, FunctionAnalysisManager *AM = 0); + PreservedAnalyses run(Function *F, FunctionAnalysisManager *AM = nullptr); static StringRef name() { return "FunctionPassManager"; } @@ -987,7 +987,7 @@ public: /// \brief Runs the function pass across every function in the module. PreservedAnalyses run(Module *M, ModuleAnalysisManager *AM) { - FunctionAnalysisManager *FAM = 0; + FunctionAnalysisManager *FAM = nullptr; if (AM) // Setup the function analysis manager from its proxy. FAM = &AM->getResult<FunctionAnalysisManagerModuleProxy>(M).getManager(); diff --git a/include/llvm/IR/SymbolTableListTraits.h b/include/llvm/IR/SymbolTableListTraits.h index 561ce010c0..0a5149c3d9 100644 --- a/include/llvm/IR/SymbolTableListTraits.h +++ b/include/llvm/IR/SymbolTableListTraits.h @@ -46,19 +46,19 @@ public: /// getListOwner - Return the object that owns this list. If this is a list /// of instructions, it returns the BasicBlock that owns them. ItemParentClass *getListOwner() { - size_t Offset(size_t(&((ItemParentClass*)0->*ItemParentClass:: - getSublistAccess(static_cast<ValueSubClass*>(0))))); + size_t Offset(size_t(&((ItemParentClass*)nullptr->*ItemParentClass:: + getSublistAccess(static_cast<ValueSubClass*>(nullptr))))); iplist<ValueSubClass>* Anchor(static_cast<iplist<ValueSubClass>*>(this)); return reinterpret_cast<ItemParentClass*>(reinterpret_cast<char*>(Anchor)- Offset); } static iplist<ValueSubClass> &getList(ItemParentClass *Par) { - return Par->*(Par->getSublistAccess((ValueSubClass*)0)); + return Par->*(Par->getSublistAccess((ValueSubClass*)nullptr)); } static ValueSymbolTable *getSymTab(ItemParentClass *Par) { - return Par ? toPtr(Par->getValueSymbolTable()) : 0; + return Par ? toPtr(Par->getValueSymbolTable()) : nullptr; } void addNodeToList(ValueSubClass *V); diff --git a/include/llvm/IR/Type.h b/include/llvm/IR/Type.h index 742a0d33f3..7955587e3c 100644 --- a/include/llvm/IR/Type.h +++ b/include/llvm/IR/Type.h @@ -88,7 +88,7 @@ protected: friend class LLVMContextImpl; explicit Type(LLVMContext &C, TypeID tid) : Context(C), IDAndSubclassData(0), - NumContainedTys(0), ContainedTys(0) { + NumContainedTys(0), ContainedTys(nullptr) { setTypeID(tid); } ~Type() {} @@ -265,7 +265,7 @@ public: /// get the actual size for a particular target, it is reasonable to use the /// DataLayout subsystem to do this. /// - bool isSized(SmallPtrSet<const Type*, 4> *Visited = 0) const { + bool isSized(SmallPtrSet<const Type*, 4> *Visited = nullptr) const { // If it's a primitive, it is always sized. if (getTypeID() == IntegerTyID || isFloatingPointTy() || getTypeID() == PointerTyID || @@ -419,7 +419,7 @@ private: /// isSizedDerivedType - Derived types like structures and arrays are sized /// iff all of the members of the type are sized as well. Since asking for /// their size is relatively uncommon, move this operation out of line. - bool isSizedDerivedType(SmallPtrSet<const Type*, 4> *Visited = 0) const; + bool isSizedDerivedType(SmallPtrSet<const Type*, 4> *Visited = nullptr) const; }; // Printing of types. diff --git a/include/llvm/IR/Use.h b/include/llvm/IR/Use.h index 340572a20b..41755daed3 100644 --- a/include/llvm/IR/Use.h +++ b/include/llvm/IR/Use.h @@ -88,7 +88,7 @@ private: enum PrevPtrTag { zeroDigitTag, oneDigitTag, stopTag, fullStopTag }; /// Constructor - Use(PrevPtrTag tag) : Val(0) { Prev.setInt(tag); } + Use(PrevPtrTag tag) : Val(nullptr) { Prev.setInt(tag); } public: operator Value *() const { return Val; } diff --git a/include/llvm/IR/User.h b/include/llvm/IR/User.h index 061bc91d31..abe68221df 100644 --- a/include/llvm/IR/User.h +++ b/include/llvm/IR/User.h @@ -55,7 +55,7 @@ protected: Use *allocHungoffUses(unsigned) const; void dropHungoffUses() { Use::zap(OperandList, OperandList + NumOperands, true); - OperandList = 0; + OperandList = nullptr; // Reset NumOperands so User::operator delete() does the right thing. NumOperands = 0; } @@ -179,7 +179,7 @@ public: // void dropAllReferences() { for (Use &U : operands()) - U.set(0); + U.set(nullptr); } /// replaceUsesOfWith - Replaces all references to the "From" definition with diff --git a/include/llvm/IR/Value.h b/include/llvm/IR/Value.h index c002cea94a..9d69a43252 100644 --- a/include/llvm/IR/Value.h +++ b/include/llvm/IR/Value.h @@ -203,7 +203,8 @@ public: /// instruction that generated it. If you specify a Module for context, then /// even constanst get pretty-printed; for example, the type of a null /// pointer is printed symbolically. - void printAsOperand(raw_ostream &O, bool PrintType = true, const Module *M = 0) const; + void printAsOperand(raw_ostream &O, bool PrintType = true, + const Module *M = nullptr) const; /// All values are typed, get the type of this value. /// @@ -213,7 +214,7 @@ public: LLVMContext &getContext() const; // All values can potentially be named. - bool hasName() const { return Name != 0 && SubclassID != MDStringVal; } + bool hasName() const { return Name != nullptr && SubclassID != MDStringVal; } ValueName *getValueName() const { return Name; } void setValueName(ValueName *VN) { Name = VN; } @@ -242,7 +243,7 @@ public: //---------------------------------------------------------------------- // Methods for handling the chain of uses of this Value. // - bool use_empty() const { return UseList == 0; } + bool use_empty() const { return UseList == nullptr; } typedef use_iterator_impl<Use> use_iterator; typedef use_iterator_impl<const Use> const_use_iterator; diff --git a/include/llvm/IR/ValueHandle.h b/include/llvm/IR/ValueHandle.h index 9b5e11aae4..888313c4e3 100644 --- a/include/llvm/IR/ValueHandle.h +++ b/include/llvm/IR/ValueHandle.h @@ -64,14 +64,14 @@ private: ValueHandleBase(const ValueHandleBase&) LLVM_DELETED_FUNCTION; public: explicit ValueHandleBase(HandleBaseKind Kind) - : PrevPair(0, Kind), Next(0), VP(0, 0) {} + : PrevPair(nullptr, Kind), Next(nullptr), VP(nullptr, 0) {} ValueHandleBase(HandleBaseKind Kind, Value *V) - : PrevPair(0, Kind), Next(0), VP(V, 0) { + : PrevPair(nullptr, Kind), Next(nullptr), VP(V, 0) { if (isValid(VP.getPointer())) AddToUseList(); } ValueHandleBase(HandleBaseKind Kind, const ValueHandleBase &RHS) - : PrevPair(0, Kind), Next(0), VP(RHS.VP) { + : PrevPair(nullptr, Kind), Next(nullptr), VP(RHS.VP) { if (isValid(VP.getPointer())) AddToExistingUseList(RHS.getPrevPtr()); } @@ -366,7 +366,7 @@ public: /// /// All implementations must remove the reference from this object to the /// Value that's being destroyed. - virtual void deleted() { setValPtr(NULL); } + virtual void deleted() { setValPtr(nullptr); } /// Called when this->getValPtr()->replaceAllUsesWith(new_value) is called, /// _before_ any of the uses have actually been replaced. If WeakVH were diff --git a/include/llvm/IR/Verifier.h b/include/llvm/IR/Verifier.h index 9a2f402ac8..68caa96f18 100644 --- a/include/llvm/IR/Verifier.h +++ b/include/llvm/IR/Verifier.h @@ -38,14 +38,14 @@ class raw_ostream; /// If there are no errors, the function returns false. If an error is found, /// a message describing the error is written to OS (if non-null) and true is /// returned. -bool verifyFunction(const Function &F, raw_ostream *OS = 0); +bool verifyFunction(const Function &F, raw_ostream *OS = nullptr); /// \brief Check a module for errors. /// /// If there are no errors, the function returns false. If an error is found, /// a message describing the error is written to OS (if non-null) and true is /// returned. -bool verifyModule(const Module &M, raw_ostream *OS = 0); +bool verifyModule(const Module &M, raw_ostream *OS = nullptr); /// \brief Create a verifier pass. /// diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h index ff700cfe0a..c2b9f95956 100644 --- a/include/llvm/Pass.h +++ b/include/llvm/Pass.h @@ -87,7 +87,8 @@ class Pass { Pass(const Pass &) LLVM_DELETED_FUNCTION; public: - explicit Pass(PassKind K, char &pid) : Resolver(0), PassID(&pid), Kind(K) { } + explicit Pass(PassKind K, char &pid) + : Resolver(nullptr), PassID(&pid), Kind(K) { } virtual ~Pass(); diff --git a/include/llvm/PassAnalysisSupport.h b/include/llvm/PassAnalysisSupport.h index a581802c47..479ee14c66 100644 --- a/include/llvm/PassAnalysisSupport.h +++ b/include/llvm/PassAnalysisSupport.h @@ -129,7 +129,7 @@ public: // Find pass that is implementing PI. Pass *findImplPass(AnalysisID PI) { - Pass *ResultPass = 0; + Pass *ResultPass = nullptr; for (unsigned i = 0; i < AnalysisImpls.size() ; ++i) { if (AnalysisImpls[i].first == PI) { ResultPass = AnalysisImpls[i].second; @@ -182,7 +182,7 @@ AnalysisType *Pass::getAnalysisIfAvailable() const { const void *PI = &AnalysisType::ID; Pass *ResultPass = Resolver->getAnalysisIfAvailable(PI, true); - if (ResultPass == 0) return 0; + if (!ResultPass) return 0; // Because the AnalysisType may not be a subclass of pass (for // AnalysisGroups), we use getAdjustedAnalysisPointer here to potentially diff --git a/include/llvm/PassRegistry.h b/include/llvm/PassRegistry.h index 756b1b85ab..7f2a01426e 100644 --- a/include/llvm/PassRegistry.h +++ b/include/llvm/PassRegistry.h @@ -37,7 +37,7 @@ class PassRegistry { void *getImpl() const; public: - PassRegistry() : pImpl(0) { } + PassRegistry() : pImpl(nullptr) { } ~PassRegistry(); /// getPassRegistry - Access the global registry object, which is diff --git a/include/llvm/PassSupport.h b/include/llvm/PassSupport.h index baee77f133..8efb45f55a 100644 --- a/include/llvm/PassSupport.h +++ b/include/llvm/PassSupport.h @@ -59,7 +59,7 @@ public: /// through RegisterPass. PassInfo(const char *name, const char *arg, const void *pi, NormalCtor_t normal, bool isCFGOnly, bool is_analysis, - TargetMachineCtor_t machine = NULL) + TargetMachineCtor_t machine = nullptr) : PassName(name), PassArgument(arg), PassID(pi), IsCFGOnlyPass(isCFGOnly), IsAnalysis(is_analysis), IsAnalysisGroup(false), NormalCtor(normal), @@ -70,8 +70,8 @@ public: PassInfo(const char *name, const void *pi) : PassName(name), PassArgument(""), PassID(pi), IsCFGOnlyPass(false), - IsAnalysis(false), IsAnalysisGroup(true), NormalCtor(0), - TargetMachineCtor(0) {} + IsAnalysis(false), IsAnalysisGroup(true), NormalCtor(nullptr), + TargetMachineCtor(nullptr) {} /// getPassName - Return the friendly name for the pass, never returns null /// @@ -256,7 +256,7 @@ class RegisterAGBase : public PassInfo { public: RegisterAGBase(const char *Name, const void *InterfaceID, - const void *PassID = 0, + const void *PassID = nullptr, bool isDefault = false); }; diff --git a/include/llvm/Support/Casting.h b/include/llvm/Support/Casting.h index 5f3e94d693..beed31a408 100644 --- a/include/llvm/Support/Casting.h +++ b/include/llvm/Support/Casting.h @@ -245,7 +245,7 @@ inline typename cast_retty<X, Y *>::ret_type cast(Y *Val) { template <class X, class Y> LLVM_ATTRIBUTE_UNUSED_RESULT inline typename cast_retty<X, Y *>::ret_type cast_or_null(Y *Val) { - if (Val == 0) return 0; + if (!Val) return nullptr; assert(isa<X>(Val) && "cast_or_null<Ty>() argument of incompatible type!"); return cast<X>(Val); } @@ -263,13 +263,13 @@ template <class X, class Y> LLVM_ATTRIBUTE_UNUSED_RESULT inline typename std::enable_if< !is_simple_type<Y>::value, typename cast_retty<X, const Y>::ret_type>::type dyn_cast(const Y &Val) { - return isa<X>(Val) ? cast<X>(Val) : 0; + return isa<X>(Val) ? cast<X>(Val) : nullptr; } template <class X, class Y> LLVM_ATTRIBUTE_UNUSED_RESULT inline typename cast_retty<X, Y>::ret_type dyn_cast(Y &Val) { - return isa<X>(Val) ? cast<X>(Val) : 0; + return isa<X>(Val) ? cast<X>(Val) : nullptr; } template <class X, class Y> diff --git a/include/llvm/Support/GenericDomTree.h b/include/llvm/Support/GenericDomTree.h index 687884456b..3c2d7a826f 100644 --- a/include/llvm/Support/GenericDomTree.h +++ b/include/llvm/Support/GenericDomTree.h @@ -186,9 +186,9 @@ class DominatorTreeBase : public DominatorBase<NodeT> { assert(isReachableFromEntry(A)); const DomTreeNodeBase<NodeT> *IDom; - while ((IDom = B->getIDom()) != 0 && IDom != A && IDom != B) + while ((IDom = B->getIDom()) != nullptr && IDom != A && IDom != B) B = IDom; // Walk up the tree - return IDom != 0; + return IDom != nullptr; } protected: @@ -205,7 +205,7 @@ protected: unsigned Semi; NodeT *Label; - InfoRec() : DFSNum(0), Parent(0), Semi(0), Label(0) {} + InfoRec() : DFSNum(0), Parent(0), Semi(0), Label(nullptr) {} }; DenseMap<NodeT*, NodeT*> IDoms; @@ -224,7 +224,7 @@ protected: IDoms.clear(); this->Roots.clear(); Vertex.clear(); - RootNode = 0; + RootNode = nullptr; } // NewBB is split and now it has one successor. Update dominator tree to @@ -260,7 +260,7 @@ protected: // Find NewBB's immediate dominator and create new dominator tree node for // NewBB. - NodeT *NewBBIDom = 0; + NodeT *NewBBIDom = nullptr; unsigned i = 0; for (i = 0; i < PredBlocks.size(); ++i) if (DT.isReachableFromEntry(PredBlocks[i])) { @@ -344,7 +344,7 @@ public: void getDescendants(NodeT *R, SmallVectorImpl<NodeT *> &Result) const { Result.clear(); const DomTreeNodeBase<NodeT> *RN = getNode(R); - if (RN == NULL) + if (!RN) return; // If R is unreachable, it will not be present in the DOM tree. SmallVector<const DomTreeNodeBase<NodeT> *, 8> WL; WL.push_back(RN); @@ -361,7 +361,7 @@ public: /// bool properlyDominates(const DomTreeNodeBase<NodeT> *A, const DomTreeNodeBase<NodeT> *B) const { - if (A == 0 || B == 0) + if (!A || !B) return false; if (A == B) return false; @@ -471,7 +471,7 @@ public: IDomB = IDomB->getIDom(); } - return NULL; + return nullptr; } const NodeT *findNearestCommonDominator(const NodeT *A, const NodeT *B) { @@ -659,14 +659,14 @@ public: void recalculate(FT& F) { typedef GraphTraits<FT*> TraitsTy; reset(); - this->Vertex.push_back(0); + this->Vertex.push_back(nullptr); if (!this->IsPostDominators) { // Initialize root NodeT *entry = TraitsTy::getEntryNode(&F); this->Roots.push_back(entry); - this->IDoms[entry] = 0; - this->DomTreeNodes[entry] = 0; + this->IDoms[entry] = nullptr; + this->DomTreeNodes[entry] = nullptr; Calculate<FT, NodeT*>(*this, F); } else { @@ -677,8 +677,8 @@ public: addRoot(I); // Prepopulate maps so that we don't get iterator invalidation issues later. - this->IDoms[I] = 0; - this->DomTreeNodes[I] = 0; + this->IDoms[I] = nullptr; + this->DomTreeNodes[I] = nullptr; } Calculate<FT, Inverse<NodeT*> >(*this, F); diff --git a/include/llvm/Support/GenericDomTreeConstruction.h b/include/llvm/Support/GenericDomTreeConstruction.h index f6bb8f47eb..d997529d62 100644 --- a/include/llvm/Support/GenericDomTreeConstruction.h +++ b/include/llvm/Support/GenericDomTreeConstruction.h @@ -156,11 +156,11 @@ void Calculate(DominatorTreeBase<typename GraphTraits<NodeT>::NodeType>& DT, bool MultipleRoots = (DT.Roots.size() > 1); if (MultipleRoots) { typename DominatorTreeBase<typename GraphT::NodeType>::InfoRec &BBInfo = - DT.Info[NULL]; + DT.Info[nullptr]; BBInfo.DFSNum = BBInfo.Semi = ++N; - BBInfo.Label = NULL; + BBInfo.Label = nullptr; - DT.Vertex.push_back(NULL); // Vertex[n] = V; + DT.Vertex.push_back(nullptr); // Vertex[n] = V; } // Step #1: Number blocks in depth-first order and initialize variables used @@ -249,10 +249,10 @@ void Calculate(DominatorTreeBase<typename GraphTraits<NodeT>::NodeType>& DT, // one exit block, or it may be the virtual exit (denoted by (BasicBlock *)0) // which postdominates all real exits if there are multiple exit blocks, or // an infinite loop. - typename GraphT::NodeType* Root = !MultipleRoots ? DT.Roots[0] : 0; + typename GraphT::NodeType* Root = !MultipleRoots ? DT.Roots[0] : nullptr; DT.DomTreeNodes[Root] = DT.RootNode = - new DomTreeNodeBase<typename GraphT::NodeType>(Root, 0); + new DomTreeNodeBase<typename GraphT::NodeType>(Root, nullptr); // Loop over all of the reachable blocks in the function... for (unsigned i = 2; i <= N; ++i) { |