llvm.org GIT mirror llvm / ec0f0bc
[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 Craig Topper 6 years ago
80 changed file(s) with 768 addition(s) and 740 deletion(s). Raw diff Collapse all Expand all
4848 /// @{
4949
5050 /// Construct an empty ArrayRef.
51 /*implicit*/ ArrayRef() : Data(0), Length(0) {}
51 /*implicit*/ ArrayRef() : Data(nullptr), Length(0) {}
5252
5353 /// Construct an empty ArrayRef from None.
5454 /*implicit*/ ArrayRef(NoneType) : Data(nullptr), Length(0) {}
984984 private:
985985 pointer Ptr, End;
986986 public:
987 DenseMapIterator() : Ptr(0), End(0) {}
987 DenseMapIterator() : Ptr(nullptr), End(nullptr) {}
988988
989989 DenseMapIterator(pointer Pos, pointer E, bool NoAdvance = false)
990990 : Ptr(Pos), End(E) {
493493 // Note: we have to be careful about the case when we move the first node
494494 // in the list. This node is the list sentinel node and we can't move it.
495495 NodeTy *ThisSentinel = getTail();
496 setTail(0);
496 setTail(nullptr);
497497 NodeTy *L2Sentinel = L2.getTail();
498 L2.setTail(0);
498 L2.setTail(nullptr);
499499
500500 // Remove [first, last) from its old position.
501501 NodeTy *First = &*first, *Prev = this->getPrev(First);
536536 //
537537
538538 size_type LLVM_ATTRIBUTE_UNUSED_RESULT size() const {
539 if (Head == 0) return 0; // Don't require construction of sentinel if empty.
539 if (!Head) return 0; // Don't require construction of sentinel if empty.
540540 return std::distance(begin(), end());
541541 }
542542
3737 /// same width as the vector element, and the bit is set only if it is true
3838 /// for all of the elements in the vector.
3939 void ComputeMaskedBits(Value *V, APInt &KnownZero, APInt &KnownOne,
40 const DataLayout *TD = 0, unsigned Depth = 0);
40 const DataLayout *TD = nullptr, unsigned Depth = 0);
4141 void computeMaskedBitsLoad(const MDNode &Ranges, APInt &KnownZero);
4242
4343 /// ComputeSignBit - Determine whether the sign bit is known to be zero or
4444 /// one. Convenience wrapper around ComputeMaskedBits.
4545 void ComputeSignBit(Value *V, bool &KnownZero, bool &KnownOne,
46 const DataLayout *TD = 0, unsigned Depth = 0);
46 const DataLayout *TD = nullptr, unsigned Depth = 0);
4747
4848 /// isKnownToBeAPowerOfTwo - Return true if the given value is known to have
4949 /// exactly one bit set when defined. For vectors return true if every
5656 /// when defined. For vectors return true if every element is known to be
5757 /// non-zero when defined. Supports values with integer or pointer type and
5858 /// vectors of integers.
59 bool isKnownNonZero(Value *V, const DataLayout *TD = 0, unsigned Depth = 0);
59 bool isKnownNonZero(Value *V, const DataLayout *TD = nullptr,
60 unsigned Depth = 0);
6061
6162 /// MaskedValueIsZero - Return true if 'V & Mask' is known to be zero. We use
6263 /// this predicate to simplify operations downstream. Mask is known to be
6869 /// same width as the vector element, and the bit is set only if it is true
6970 /// for all of the elements in the vector.
7071 bool MaskedValueIsZero(Value *V, const APInt &Mask,
71 const DataLayout *TD = 0, unsigned Depth = 0);
72 const DataLayout *TD = nullptr, unsigned Depth = 0);
7273
7374
7475 /// ComputeNumSignBits - Return the number of times the sign bit of the
7980 ///
8081 /// 'Op' must have a scalar integer type.
8182 ///
82 unsigned ComputeNumSignBits(Value *Op, const DataLayout *TD = 0,
83 unsigned ComputeNumSignBits(Value *Op, const DataLayout *TD = nullptr,
8384 unsigned Depth = 0);
8485
8586 /// ComputeMultiple - This function computes the integer multiple of Base that
111112 /// insertvalues when a part of a nested struct is extracted.
112113 Value *FindInsertedValue(Value *V,
113114 ArrayRef idx_range,
114 Instruction *InsertBefore = 0);
115 Instruction *InsertBefore = nullptr);
115116
116117 /// GetPointerBaseWithConstantOffset - Analyze the specified pointer to see if
117118 /// it can be expressed as a base pointer plus a constant offset. Return the
142143 /// being addressed. Note that the returned value has pointer type if the
143144 /// specified value does. If the MaxLookup value is non-zero, it limits the
144145 /// number of instructions to be stripped off.
145 Value *GetUnderlyingObject(Value *V, const DataLayout *TD = 0,
146 Value *GetUnderlyingObject(Value *V, const DataLayout *TD = nullptr,
146147 unsigned MaxLookup = 6);
147148 static inline const Value *
148 GetUnderlyingObject(const Value *V, const DataLayout *TD = 0,
149 GetUnderlyingObject(const Value *V, const DataLayout *TD = nullptr,
149150 unsigned MaxLookup = 6) {
150151 return GetUnderlyingObject(const_cast(V), TD, MaxLookup);
151152 }
155156 /// multiple objects.
156157 void GetUnderlyingObjects(Value *V,
157158 SmallVectorImpl &Objects,
158 const DataLayout *TD = 0,
159 const DataLayout *TD = nullptr,
159160 unsigned MaxLookup = 6);
160161
161162 /// onlyUsedByLifetimeMarkers - Return true if the only users of this pointer
181182 /// However, this method can return true for instructions that read memory;
182183 /// for such instructions, moving them may change the resulting value.
183184 bool isSafeToSpeculativelyExecute(const Value *V,
184 const DataLayout *TD = 0);
185 const DataLayout *TD = nullptr);
185186
186187 /// isKnownNonNull - Return true if this pointer couldn't possibly be null by
187188 /// its definition. This returns true for allocas, non-extern-weak globals
188189 /// and byval arguments.
189 bool isKnownNonNull(const Value *V, const TargetLibraryInfo *TLI = 0);
190 bool isKnownNonNull(const Value *V, const TargetLibraryInfo *TLI = nullptr);
190191
191192 } // end namespace llvm
192193
3838 Module *getStreamedBitcodeModule(const std::string &name,
3939 DataStreamer *streamer,
4040 LLVMContext &Context,
41 std::string *ErrMsg = 0);
41 std::string *ErrMsg = nullptr);
4242
4343 /// getBitcodeTargetTriple - Read the header of the specified bitcode
4444 /// buffer and extract just the triple information. If successful,
4747 /// if ErrMsg is non-null.
4848 std::string getBitcodeTargetTriple(MemoryBuffer *Buffer,
4949 LLVMContext &Context,
50 std::string *ErrMsg = 0);
50 std::string *ErrMsg = nullptr);
5151
5252 /// Read the specified bitcode file, returning the module.
5353 /// This method *never* takes ownership of Buffer.
3434
3535 public:
3636 EVT() : V((MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE)),
37 LLVMTy(0) {}
38 EVT(MVT::SimpleValueType SVT) : V(SVT), LLVMTy(0) { }
39 EVT(MVT S) : V(S), LLVMTy(0) {}
37 LLVMTy(nullptr) {}
38 EVT(MVT::SimpleValueType SVT) : V(SVT), LLVMTy(nullptr) { }
39 EVT(MVT S) : V(S), LLVMTy(nullptr) {}
4040
4141 bool operator==(EVT VT) const {
4242 return !(*this != VT);
4343 ///
4444 /// If \p F is specified, the argument is inserted at the end of the argument
4545 /// list for \p F.
46 explicit Argument(Type *Ty, const Twine &Name = "", Function *F = 0);
46 explicit Argument(Type *Ty, const Twine &Name = "", Function *F = nullptr);
4747
4848 inline const Function *getParent() const { return Parent; }
4949 inline Function *getParent() { return Parent; }
115115 AttributeImpl *pImpl;
116116 Attribute(AttributeImpl *A) : pImpl(A) {}
117117 public:
118 Attribute() : pImpl(0) {}
118 Attribute() : pImpl(nullptr) {}
119119
120120 //===--------------------------------------------------------------------===//
121121 // Attribute Construction
231231
232232 explicit AttributeSet(AttributeSetImpl *LI) : pImpl(LI) {}
233233 public:
234 AttributeSet() : pImpl(0) {}
234 AttributeSet() : pImpl(nullptr) {}
235235
236236 //===--------------------------------------------------------------------===//
237237 // AttributeSet Construction and Mutation
8989 /// inserted at either the end of the function (if InsertBefore is null), or
9090 /// before the specified basic block.
9191 explicit BasicBlock(LLVMContext &C, const Twine &Name = "",
92 Function *Parent = 0, BasicBlock *InsertBefore = 0);
92 Function *Parent = nullptr,
93 BasicBlock *InsertBefore = nullptr);
9394 public:
9495 /// \brief Get the context in which this basic block lives.
9596 LLVMContext &getContext() const;
106107 /// inserted at either the end of the function (if InsertBefore is 0), or
107108 /// before the specified basic block.
108109 static BasicBlock *Create(LLVMContext &Context, const Twine &Name = "",
109 Function *Parent = 0,BasicBlock *InsertBefore = 0) {
110 Function *Parent = nullptr,
111 BasicBlock *InsertBefore = nullptr) {
110112 return new BasicBlock(Context, Name, Parent, InsertBefore);
111113 }
112114 ~BasicBlock();
4646 protected:
4747 PointerIntPair I;
4848 public:
49 CallSiteBase() : I(0, false) {}
49 CallSiteBase() : I(nullptr, false) {}
5050 CallSiteBase(CallTy *CI) : I(CI, true) { assert(CI); }
5151 CallSiteBase(InvokeTy *II) : I(II, false) { assert(II); }
5252 CallSiteBase(ValTy *II) { *this = get(II); }
113113 const APInt *getSingleElement() const {
114114 if (Upper == Lower + 1)
115115 return &Lower;
116 return 0;
116 return nullptr;
117117 }
118118
119119 /// isSingleElement - Return true if this set contains exactly one member.
120120 ///
121 bool isSingleElement() const { return getSingleElement() != 0; }
121 bool isSingleElement() const { return getSingleElement() != nullptr; }
122122
123123 /// getSetSize - Return the number of elements in this set.
124124 ///
298298 ConstantAggregateZero(const ConstantAggregateZero &) LLVM_DELETED_FUNCTION;
299299 protected:
300300 explicit ConstantAggregateZero(Type *ty)
301 : Constant(ty, ConstantAggregateZeroVal, 0, 0) {}
301 : Constant(ty, ConstantAggregateZeroVal, nullptr, 0) {}
302302 protected:
303303 // allocate space for exactly zero operands
304304 void *operator new(size_t s) {
485485 protected:
486486 explicit ConstantPointerNull(PointerType *T)
487487 : Constant(T,
488 Value::ConstantPointerNullVal, 0, 0) {}
488 Value::ConstantPointerNullVal, nullptr, 0) {}
489489
490490 protected:
491491 // allocate space for exactly zero operands
535535 ConstantDataSequential(const ConstantDataSequential &) LLVM_DELETED_FUNCTION;
536536 protected:
537537 explicit ConstantDataSequential(Type *ty, ValueTy VT, const char *Data)
538 : Constant(ty, VT, 0, 0), DataElements(Data), Next(0) {}
538 : Constant(ty, VT, nullptr, 0), DataElements(Data), Next(nullptr) {}
539539 ~ConstantDataSequential() { delete Next; }
540540
541541 static Constant *getImpl(StringRef Bytes, Type *Ty);
11351135 void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION;
11361136 UndefValue(const UndefValue &) LLVM_DELETED_FUNCTION;
11371137 protected:
1138 explicit UndefValue(Type *T) : Constant(T, UndefValueVal, 0, 0) {}
1138 explicit UndefValue(Type *T) : Constant(T, UndefValueVal, nullptr, 0) {}
11391139 protected:
11401140 // allocate space for exactly zero operands
11411141 void *operator new(size_t s) {
7777 DITemplateValueParameter
7878 createTemplateValueParameter(unsigned Tag, DIDescriptor Scope,
7979 StringRef Name, DIType Ty, Value *Val,
80 MDNode *File = 0, unsigned LineNo = 0,
80 MDNode *File = nullptr, unsigned LineNo = 0,
8181 unsigned ColumnNo = 0);
8282
8383 DIBuilder(const DIBuilder &) LLVM_DELETED_FUNCTION;
292292 uint64_t OffsetInBits, unsigned Flags,
293293 DIType DerivedFrom, DIArray Elements,
294294 DIType VTableHolder = DIType(),
295 MDNode *TemplateParms = 0,
295 MDNode *TemplateParms = nullptr,
296296 StringRef UniqueIdentifier = StringRef());
297297
298298 /// createStructType - Create debugging information entry for a struct.
341341 /// @param ColumnNo Column Number.
342342 DITemplateTypeParameter
343343 createTemplateTypeParameter(DIDescriptor Scope, StringRef Name, DIType Ty,
344 MDNode *File = 0, unsigned LineNo = 0,
344 MDNode *File = nullptr, unsigned LineNo = 0,
345345 unsigned ColumnNo = 0);
346346
347347 /// createTemplateValueParameter - Create debugging information for template
355355 /// @param ColumnNo Column Number.
356356 DITemplateValueParameter
357357 createTemplateValueParameter(DIDescriptor Scope, StringRef Name,
358 DIType Ty, Value *Val, MDNode *File = 0,
358 DIType Ty, Value *Val, MDNode *File = nullptr,
359359 unsigned LineNo = 0, unsigned ColumnNo = 0);
360360
361361 /// \brief Create debugging information for a template template parameter.
368368 /// @param ColumnNo Column Number.
369369 DITemplateValueParameter
370370 createTemplateTemplateParameter(DIDescriptor Scope, StringRef Name,
371 DIType Ty, StringRef Val, MDNode *File = 0,
372 unsigned LineNo = 0, unsigned ColumnNo = 0);
371 DIType Ty, StringRef Val,
372 MDNode *File = nullptr, unsigned LineNo = 0,
373 unsigned ColumnNo = 0);
373374
374375 /// \brief Create debugging information for a template parameter pack.
375376 /// @param Scope Scope in which this type is defined.
381382 /// @param ColumnNo Column Number.
382383 DITemplateValueParameter
383384 createTemplateParameterPack(DIDescriptor Scope, StringRef Name,
384 DIType Ty, DIArray Val, MDNode *File = 0,
385 DIType Ty, DIArray Val, MDNode *File = nullptr,
385386 unsigned LineNo = 0, unsigned ColumnNo = 0);
386387
387388 /// createArrayType - Create debugging information entry for an array.
497498 createStaticVariable(DIDescriptor Context, StringRef Name,
498499 StringRef LinkageName, DIFile File, unsigned LineNo,
499500 DITypeRef Ty, bool isLocalToUnit, llvm::Value *Val,
500 MDNode *Decl = NULL);
501 MDNode *Decl = nullptr);
501502
502503
503504 /// createLocalVariable - Create a new descriptor for the specified
563564 unsigned ScopeLine,
564565 unsigned Flags = 0,
565566 bool isOptimized = false,
566 Function *Fn = 0,
567 MDNode *TParam = 0,
568 MDNode *Decl = 0);
567 Function *Fn = nullptr,
568 MDNode *TParam = nullptr,
569 MDNode *Decl = nullptr);
569570
570571 /// FIXME: this is added for dragonegg. Once we update dragonegg
571572 /// to call resolve function, this will be removed.
577578 unsigned ScopeLine,
578579 unsigned Flags = 0,
579580 bool isOptimized = false,
580 Function *Fn = 0,
581 MDNode *TParam = 0,
582 MDNode *Decl = 0);
581 Function *Fn = nullptr,
582 MDNode *TParam = nullptr,
583 MDNode *Decl = nullptr);
583584
584585 /// createMethod - Create a new descriptor for the specified C++ method.
585586 /// See comments in DISubprogram for descriptions of these fields.
609610 DIType VTableHolder = DIType(),
610611 unsigned Flags = 0,
611612 bool isOptimized = false,
612 Function *Fn = 0,
613 MDNode *TParam = 0);
613 Function *Fn = nullptr,
614 MDNode *TParam = nullptr);
614615
615616 /// createNameSpace - This creates new descriptor for a namespace
616617 /// with the specified parent scope.
173173
174174 public:
175175 /// Constructs a DataLayout from a specification string. See reset().
176 explicit DataLayout(StringRef LayoutDescription) : LayoutMap(0) {
176 explicit DataLayout(StringRef LayoutDescription) : LayoutMap(nullptr) {
177177 reset(LayoutDescription);
178178 }
179179
180180 /// Initialize target data from properties stored in the module.
181181 explicit DataLayout(const Module *M);
182182
183 DataLayout(const DataLayout &DL) : LayoutMap(0) { *this = DL; }
183 DataLayout(const DataLayout &DL) : LayoutMap(nullptr) { *this = DL; }
184184
185185 DataLayout &operator=(const DataLayout &DL) {
186186 clear();
407407 /// none are set.
408408 Type *getLargestLegalIntType(LLVMContext &C) const {
409409 unsigned LargestSize = getLargestLegalIntTypeSize();
410 return (LargestSize == 0) ? 0 : Type::getIntNTy(C, LargestSize);
410 return (LargestSize == 0) ? nullptr : Type::getIntNTy(C, LargestSize);
411411 }
412412
413413 /// getLargestLegalIntType - Return the size of largest legal integer type
103103 void replaceFunctionField(unsigned Elt, Function *F);
104104
105105 public:
106 explicit DIDescriptor(const MDNode *N = 0) : DbgNode(N) {}
106 explicit DIDescriptor(const MDNode *N = nullptr) : DbgNode(N) {}
107107
108108 bool Verify() const;
109109
115115 // FIXME: This operator bool isn't actually protecting anything at the
116116 // moment due to the conversion operator above making DIDescriptor nodes
117117 // implicitly convertable to bool.
118 LLVM_EXPLICIT operator bool() const { return DbgNode != 0; }
118 LLVM_EXPLICIT operator bool() const { return DbgNode != nullptr; }
119119
120120 bool operator==(DIDescriptor Other) const { return DbgNode == Other.DbgNode; }
121121 bool operator!=(DIDescriptor Other) const { return !operator==(Other); }
158158 void printInternal(raw_ostream &OS) const;
159159
160160 public:
161 explicit DISubrange(const MDNode *N = 0) : DIDescriptor(N) {}
161 explicit DISubrange(const MDNode *N = nullptr) : DIDescriptor(N) {}
162162
163163 int64_t getLo() const { return getInt64Field(1); }
164164 int64_t getCount() const { return getInt64Field(2); }
168168 /// DIArray - This descriptor holds an array of descriptors.
169169 class DIArray : public DIDescriptor {
170170 public:
171 explicit DIArray(const MDNode *N = 0) : DIDescriptor(N) {}
171 explicit DIArray(const MDNode *N = nullptr) : DIDescriptor(N) {}
172172
173173 unsigned getNumElements() const;
174174 DIDescriptor getElement(unsigned Idx) const {
184184 void printInternal(raw_ostream &OS) const;
185185
186186 public:
187 explicit DIEnumerator(const MDNode *N = 0) : DIDescriptor(N) {}
187 explicit DIEnumerator(const MDNode *N = nullptr) : DIDescriptor(N) {}
188188
189189 StringRef getName() const { return getStringField(1); }
190190 int64_t getEnumValue() const { return getInt64Field(2); }
209209 void printInternal(raw_ostream &OS) const;
210210
211211 public:
212 explicit DIScope(const MDNode *N = 0) : DIDescriptor(N) {}
212 explicit DIScope(const MDNode *N = nullptr) : DIDescriptor(N) {}
213213
214214 /// Gets the parent scope for this scope node or returns a
215215 /// default constructed scope.
291291 void printInternal(raw_ostream &OS) const;
292292
293293 public:
294 explicit DIType(const MDNode *N = 0) : DIScope(N) {}
294 explicit DIType(const MDNode *N = nullptr) : DIScope(N) {}
295295 operator DITypeRef () const {
296296 assert(isType() &&
297297 "constructing DITypeRef from an MDNode that is not a type");
345345 /// DIBasicType - A basic type, like 'int' or 'float'.
346346 class DIBasicType : public DIType {
347347 public:
348 explicit DIBasicType(const MDNode *N = 0) : DIType(N) {}
348 explicit DIBasicType(const MDNode *N = nullptr) : DIType(N) {}
349349
350350 unsigned getEncoding() const { return getUnsignedField(9); }
351351
361361 void printInternal(raw_ostream &OS) const;
362362
363363 public:
364 explicit DIDerivedType(const MDNode *N = 0) : DIType(N) {}
364 explicit DIDerivedType(const MDNode *N = nullptr) : DIType(N) {}
365365
366366 DITypeRef getTypeDerivedFrom() const { return getFieldAs(9); }
367367
394394 void printInternal(raw_ostream &OS) const;
395395
396396 public:
397 explicit DICompositeType(const MDNode *N = 0) : DIDerivedType(N) {}
397 explicit DICompositeType(const MDNode *N = nullptr) : DIDerivedType(N) {}
398398
399399 DIArray getTypeArray() const { return getFieldAs(10); }
400400 void setTypeArray(DIArray Elements, DIArray TParams = DIArray());
413413 friend class DIDescriptor;
414414
415415 public:
416 explicit DIFile(const MDNode *N = 0) : DIScope(N) {}
416 explicit DIFile(const MDNode *N = nullptr) : DIScope(N) {}
417417 MDNode *getFileNode() const;
418418 bool Verify() const;
419419 };
424424 void printInternal(raw_ostream &OS) const;
425425
426426 public:
427 explicit DICompileUnit(const MDNode *N = 0) : DIScope(N) {}
427 explicit DICompileUnit(const MDNode *N = nullptr) : DIScope(N) {}
428428
429429 unsigned getLanguage() const { return getUnsignedField(2); }
430430 StringRef getProducer() const { return getStringField(3); }
452452 void printInternal(raw_ostream &OS) const;
453453
454454 public:
455 explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {}
455 explicit DISubprogram(const MDNode *N = nullptr) : DIScope(N) {}
456456
457457 DIScopeRef getContext() const { return getFieldAs(2); }
458458 StringRef getName() const { return getStringField(3); }
531531 /// DILexicalBlock - This is a wrapper for a lexical block.
532532 class DILexicalBlock : public DIScope {
533533 public:
534 explicit DILexicalBlock(const MDNode *N = 0) : DIScope(N) {}
534 explicit DILexicalBlock(const MDNode *N = nullptr) : DIScope(N) {}
535535 DIScope getContext() const { return getFieldAs(2); }
536536 unsigned getLineNumber() const { return getUnsignedField(3); }
537537 unsigned getColumnNumber() const { return getUnsignedField(4); }
543543 /// a filename change.
544544 class DILexicalBlockFile : public DIScope {
545545 public:
546 explicit DILexicalBlockFile(const MDNode *N = 0) : DIScope(N) {}
546 explicit DILexicalBlockFile(const MDNode *N = nullptr) : DIScope(N) {}
547547 DIScope getContext() const {
548548 if (getScope().isSubprogram())
549549 return getScope();
561561 void printInternal(raw_ostream &OS) const;
562562
563563 public:
564 explicit DINameSpace(const MDNode *N = 0) : DIScope(N) {}
564 explicit DINameSpace(const MDNode *N = nullptr) : DIScope(N) {}
565565 DIScope getContext() const { return getFieldAs(2); }
566566 StringRef getName() const { return getStringField(3); }
567567 unsigned getLineNumber() const { return getUnsignedField(4); }
571571 /// DIUnspecifiedParameter - This is a wrapper for unspecified parameters.
572572 class DIUnspecifiedParameter : public DIDescriptor {
573573 public:
574 explicit DIUnspecifiedParameter(const MDNode *N = 0) : DIDescriptor(N) {}
574 explicit DIUnspecifiedParameter(const MDNode *N = nullptr)
575 : DIDescriptor(N) {}
575576 bool Verify() const;
576577 };
577578
578579 /// DITemplateTypeParameter - This is a wrapper for template type parameter.
579580 class DITemplateTypeParameter : public DIDescriptor {
580581 public:
581 explicit DITemplateTypeParameter(const MDNode *N = 0) : DIDescriptor(N) {}
582 explicit DITemplateTypeParameter(const MDNode *N = nullptr)
583 : DIDescriptor(N) {}
582584
583585 DIScopeRef getContext() const { return getFieldAs(1); }
584586 StringRef getName() const { return getStringField(2); }
595597 /// DITemplateValueParameter - This is a wrapper for template value parameter.
596598 class DITemplateValueParameter : public DIDescriptor {
597599 public:
598 explicit DITemplateValueParameter(const MDNode *N = 0) : DIDescriptor(N) {}
600 explicit DITemplateValueParameter(const MDNode *N = nullptr)
601 : DIDescriptor(N) {}
599602
600603 DIScopeRef getContext() const { return getFieldAs(1); }
601604 StringRef getName() const { return getStringField(2); }
616619 void printInternal(raw_ostream &OS) const;
617620
618621 public:
619 explicit DIGlobalVariable(const MDNode *N = 0) : DIDescriptor(N) {}
622 explicit DIGlobalVariable(const MDNode *N = nullptr) : DIDescriptor(N) {}
620623
621624 DIScope getContext() const { return getFieldAs(2); }
622625 StringRef getName() const { return getStringField(3); }
649652 void printInternal(raw_ostream &OS) const;
650653
651654 public:
652 explicit DIVariable(const MDNode *N = 0) : DIDescriptor(N) {}
655 explicit DIVariable(const MDNode *N = nullptr) : DIDescriptor(N) {}
653656
654657 DIScope getContext() const { return getFieldAs(1); }
655658 StringRef getName() const { return getStringField(2); }
5757 /// get - Get a new DebugLoc that corresponds to the specified line/col
5858 /// scope/inline location.
5959 static DebugLoc get(unsigned Line, unsigned Col,
60 MDNode *Scope, MDNode *InlinedAt = 0);
60 MDNode *Scope, MDNode *InlinedAt = nullptr);
6161
6262 /// getFromDILocation - Translate the DILocation quad into a DebugLoc.
6363 static DebugLoc getFromDILocation(MDNode *N);
187187 StructType(const StructType &) LLVM_DELETED_FUNCTION;
188188 const StructType &operator=(const StructType &) LLVM_DELETED_FUNCTION;
189189 StructType(LLVMContext &C)
190 : CompositeType(C, StructTyID), SymbolTableEntry(0) {}
190 : CompositeType(C, StructTyID), SymbolTableEntry(nullptr) {}
191191 enum {
192192 /// This is the contents of the SubClassData field.
193193 SCDB_HasBody = 1,
248248 bool isOpaque() const { return (getSubclassData() & SCDB_HasBody) == 0; }
249249
250250 /// isSized - Return true if this is a sized type.
251 bool isSized(SmallPtrSet *Visited = 0) const;
251 bool isSized(SmallPtrSet *Visited = nullptr) const;
252252
253253 /// hasName - Return true if this is a named struct that has a non-empty name.
254 bool hasName() const { return SymbolTableEntry != 0; }
254 bool hasName() const { return SymbolTableEntry != nullptr; }
255255
256256 /// getName - Return the name for this struct type if it has an identity.
257257 /// This may return an empty string for an unnamed struct type. Do not call
106106 DiagnosticInfoInlineAsm(const Twine &MsgStr,
107107 DiagnosticSeverity Severity = DS_Error)
108108 : DiagnosticInfo(DK_InlineAsm, Severity), LocCookie(0), MsgStr(MsgStr),
109 Instr(NULL) {}
109 Instr(nullptr) {}
110110
111111 /// \p LocCookie if non-zero gives the line number for this report.
112112 /// \p MsgStr gives the message.
115115 DiagnosticInfoInlineAsm(unsigned LocCookie, const Twine &MsgStr,
116116 DiagnosticSeverity Severity = DS_Error)
117117 : DiagnosticInfo(DK_InlineAsm, Severity), LocCookie(LocCookie),
118 MsgStr(MsgStr), Instr(NULL) {}
118 MsgStr(MsgStr), Instr(nullptr) {}
119119
120120 /// \p Instr gives the original instruction that triggered the diagnostic.
121121 /// \p MsgStr gives the message.
209209 LineNum(0), Msg(Msg) {}
210210 DiagnosticInfoSampleProfile(const Twine &Msg,
211211 DiagnosticSeverity Severity = DS_Error)
212 : DiagnosticInfo(DK_SampleProfile, Severity), FileName(NULL),
212 : DiagnosticInfo(DK_SampleProfile, Severity), FileName(nullptr),
213213 LineNum(0), Msg(Msg) {}
214214
215215 /// \see DiagnosticInfo::print.
181181
182182 void releaseMemory() override { DT.releaseMemory(); }
183183
184 void print(raw_ostream &OS, const Module *M = 0) const override;
184 void print(raw_ostream &OS, const Module *M = nullptr) const override;
185185 };
186186
187187 } // End llvm namespace
122122 /// the module.
123123 ///
124124 Function(FunctionType *Ty, LinkageTypes Linkage,
125 const Twine &N = "", Module *M = 0);
125 const Twine &N = "", Module *M = nullptr);
126126
127127 public:
128128 static Function *Create(FunctionType *Ty, LinkageTypes Linkage,
129 const Twine &N = "", Module *M = 0) {
129 const Twine &N = "", Module *M = nullptr) {
130130 return new(0) Function(Ty, Linkage, N, M);
131131 }
132132
482482 /// other than direct calls or invokes to it, or blockaddress expressions.
483483 /// Optionally passes back an offending user for diagnostic purposes.
484484 ///
485 bool hasAddressTaken(const User** = 0) const;
485 bool hasAddressTaken(const User** = nullptr) const;
486486
487487 /// isDefTriviallyDead - Return true if it is trivially safe to remove
488488 /// this function definition from the module (because it isn't externally
504504
505505 inline ValueSymbolTable *
506506 ilist_traits::getSymTab(Function *F) {
507 return F ? &F->getValueSymbolTable() : 0;
507 return F ? &F->getValueSymbolTable() : nullptr;
508508 }
509509
510510 inline ValueSymbolTable *
511511 ilist_traits::getSymTab(Function *F) {
512 return F ? &F->getValueSymbolTable() : 0;
512 return F ? &F->getValueSymbolTable() : nullptr;
513513 }
514514
515515 } // End llvm namespace
3737 }
3838 static generic_gep_type_iterator end(ItTy It) {
3939 generic_gep_type_iterator I;
40 I.CurTy = 0;
40 I.CurTy = nullptr;
4141 I.OpIt = It;
4242 return I;
4343 }
6868 if (CompositeType *CT = dyn_cast(CurTy)) {
6969 CurTy = CT->getTypeAtIndex(getOperand());
7070 } else {
71 CurTy = 0;
71 CurTy = nullptr;
7272 }
7373 ++OpIt;
7474 return *this;
4040 /// GlobalAlias ctor - If a parent module is specified, the alias is
4141 /// automatically inserted into the end of the specified module's alias list.
4242 GlobalAlias(Type *Ty, LinkageTypes Linkage, const Twine &Name = "",
43 Constant* Aliasee = 0, Module *Parent = 0);
43 Constant* Aliasee = nullptr, Module *Parent = nullptr);
4444
4545 /// Provide fast operand accessors
4646 DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
6262 LinkageTypes linkage, const Twine &Name)
6363 : Constant(ty, vty, Ops, NumOps), Linkage(linkage),
6464 Visibility(DefaultVisibility), Alignment(0), UnnamedAddr(0),
65 DllStorageClass(DefaultStorageClass), Parent(0) {
65 DllStorageClass(DefaultStorageClass), Parent(nullptr) {
6666 setName(Name);
6767 }
6868
250250 /// Materialize - make sure this GlobalValue is fully read. If the module is
251251 /// corrupt, this returns true and fills in the optional string with
252252 /// information about the problem. If successful, this returns false.
253 bool Materialize(std::string *ErrInfo = 0);
253 bool Materialize(std::string *ErrInfo = nullptr);
254254
255255 /// Dematerialize - If this GlobalValue is read in, and if the GVMaterializer
256256 /// supports it, release the memory for the function, and set it up to be
6565 /// GlobalVariable ctor - If a parent module is specified, the global is
6666 /// automatically inserted into the end of the specified modules global list.
6767 GlobalVariable(Type *Ty, bool isConstant, LinkageTypes Linkage,
68 Constant *Initializer = 0, const Twine &Name = "",
68 Constant *Initializer = nullptr, const Twine &Name = "",
6969 ThreadLocalMode = NotThreadLocal, unsigned AddressSpace = 0,
7070 bool isExternallyInitialized = false);
7171 /// GlobalVariable ctor - This creates a global and inserts it before the
7272 /// specified other global.
7373 GlobalVariable(Module &M, Type *Ty, bool isConstant,
7474 LinkageTypes Linkage, Constant *Initializer,
75 const Twine &Name = "", GlobalVariable *InsertBefore = 0,
75 const Twine &Name = "", GlobalVariable *InsertBefore = nullptr,
7676 ThreadLocalMode = NotThreadLocal, unsigned AddressSpace = 0,
7777 bool isExternallyInitialized = false);
7878
5757 FastMathFlags FMF;
5858 public:
5959
60 IRBuilderBase(LLVMContext &context, MDNode *FPMathTag = 0)
60 IRBuilderBase(LLVMContext &context, MDNode *FPMathTag = nullptr)
6161 : Context(context), DefaultFPMathTag(FPMathTag), FMF() {
6262 ClearInsertionPoint();
6363 }
6969 /// \brief Clear the insertion point: created instructions will not be
7070 /// inserted into a block.
7171 void ClearInsertionPoint() {
72 BB = 0;
73 InsertPt = 0;
72 BB = nullptr;
73 InsertPt = nullptr;
7474 }
7575
7676 BasicBlock *GetInsertBlock() const { return BB; }
139139
140140 public:
141141 /// \brief Creates a new insertion point which doesn't point to anything.
142 InsertPoint() : Block(0) {}
142 InsertPoint() : Block(nullptr) {}
143143
144144 /// \brief Creates a new insertion point at the given location.
145145 InsertPoint(BasicBlock *InsertBlock, BasicBlock::iterator InsertPoint)
146146 : Block(InsertBlock), Point(InsertPoint) {}
147147
148148 /// \brief Returns true if this insert point is set.
149 bool isSet() const { return (Block != 0); }
149 bool isSet() const { return (Block != nullptr); }
150150
151151 llvm::BasicBlock *getBlock() const { return Block; }
152152 llvm::BasicBlock::iterator getPoint() const { return Point; }
361361 /// If the pointer isn't an i8*, it will be converted. If a TBAA tag is
362362 /// specified, it will be added to the instruction.
363363 CallInst *CreateMemSet(Value *Ptr, Value *Val, uint64_t Size, unsigned Align,
364 bool isVolatile = false, MDNode *TBAATag = 0) {
364 bool isVolatile = false, MDNode *TBAATag = nullptr) {
365365 return CreateMemSet(Ptr, Val, getInt64(Size), Align, isVolatile, TBAATag);
366366 }
367367
368368 CallInst *CreateMemSet(Value *Ptr, Value *Val, Value *Size, unsigned Align,
369 bool isVolatile = false, MDNode *TBAATag = 0);
369 bool isVolatile = false, MDNode *TBAATag = nullptr);
370370
371371 /// \brief Create and insert a memcpy between the specified pointers.
372372 ///
373373 /// If the pointers aren't i8*, they will be converted. If a TBAA tag is
374374 /// specified, it will be added to the instruction.
375375 CallInst *CreateMemCpy(Value *Dst, Value *Src, uint64_t Size, unsigned Align,
376 bool isVolatile = false, MDNode *TBAATag = 0,
377 MDNode *TBAAStructTag = 0) {
376 bool isVolatile = false, MDNode *TBAATag = nullptr,
377 MDNode *TBAAStructTag = nullptr) {
378378 return CreateMemCpy(Dst, Src, getInt64(Size), Align, isVolatile, TBAATag,
379379 TBAAStructTag);
380380 }
381381
382382 CallInst *CreateMemCpy(Value *Dst, Value *Src, Value *Size, unsigned Align,
383 bool isVolatile = false, MDNode *TBAATag = 0,
384 MDNode *TBAAStructTag = 0);
383 bool isVolatile = false, MDNode *TBAATag = nullptr,
384 MDNode *TBAAStructTag = nullptr);
385385
386386 /// \brief Create and insert a memmove between the specified
387387 /// pointers.
389389 /// If the pointers aren't i8*, they will be converted. If a TBAA tag is
390390 /// specified, it will be added to the instruction.
391391 CallInst *CreateMemMove(Value *Dst, Value *Src, uint64_t Size, unsigned Align,
392 bool isVolatile = false, MDNode *TBAATag = 0) {
392 bool isVolatile = false, MDNode *TBAATag = nullptr) {
393393 return CreateMemMove(Dst, Src, getInt64(Size), Align, isVolatile, TBAATag);
394394 }
395395
396396 CallInst *CreateMemMove(Value *Dst, Value *Src, Value *Size, unsigned Align,
397 bool isVolatile = false, MDNode *TBAATag = 0);
397 bool isVolatile = false, MDNode *TBAATag = nullptr);
398398
399399 /// \brief Create a lifetime.start intrinsic.
400400 ///
401401 /// If the pointer isn't i8* it will be converted.
402 CallInst *CreateLifetimeStart(Value *Ptr, ConstantInt *Size = 0);
402 CallInst *CreateLifetimeStart(Value *Ptr, ConstantInt *Size = nullptr);
403403
404404 /// \brief Create a lifetime.end intrinsic.
405405 ///
406406 /// If the pointer isn't i8* it will be converted.
407 CallInst *CreateLifetimeEnd(Value *Ptr, ConstantInt *Size = 0);
407 CallInst *CreateLifetimeEnd(Value *Ptr, ConstantInt *Size = nullptr);
408408
409409 private:
410410 Value *getCastedInt8PtrValue(Value *Ptr);
432432 T Folder;
433433 public:
434434 IRBuilder(LLVMContext &C, const T &F, const Inserter &I = Inserter(),
435 MDNode *FPMathTag = 0)
435 MDNode *FPMathTag = nullptr)
436436 : IRBuilderBase(C, FPMathTag), Inserter(I), Folder(F) {
437437 }
438438
439 explicit IRBuilder(LLVMContext &C, MDNode *FPMathTag = 0)
439 explicit IRBuilder(LLVMContext &C, MDNode *FPMathTag = nullptr)
440440 : IRBuilderBase(C, FPMathTag), Folder() {
441441 }
442442
443 explicit IRBuilder(BasicBlock *TheBB, const T &F, MDNode *FPMathTag = 0)
443 explicit IRBuilder(BasicBlock *TheBB, const T &F, MDNode *FPMathTag = nullptr)
444444 : IRBuilderBase(TheBB->getContext(), FPMathTag), Folder(F) {
445445 SetInsertPoint(TheBB);
446446 }
447447
448 explicit IRBuilder(BasicBlock *TheBB, MDNode *FPMathTag = 0)
448 explicit IRBuilder(BasicBlock *TheBB, MDNode *FPMathTag = nullptr)
449449 : IRBuilderBase(TheBB->getContext(), FPMathTag), Folder() {
450450 SetInsertPoint(TheBB);
451451 }
452452
453 explicit IRBuilder(Instruction *IP, MDNode *FPMathTag = 0)
453 explicit IRBuilder(Instruction *IP, MDNode *FPMathTag = nullptr)
454454 : IRBuilderBase(IP->getContext(), FPMathTag), Folder() {
455455 SetInsertPoint(IP);
456456 SetCurrentDebugLocation(IP->getDebugLoc());
457457 }
458458
459 explicit IRBuilder(Use &U, MDNode *FPMathTag = 0)
459 explicit IRBuilder(Use &U, MDNode *FPMathTag = nullptr)
460460 : IRBuilderBase(U->getContext(), FPMathTag), Folder() {
461461 SetInsertPoint(U);
462462 SetCurrentDebugLocation(cast(U.getUser())->getDebugLoc());
463463 }
464464
465465 IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F,
466 MDNode *FPMathTag = 0)
466 MDNode *FPMathTag = nullptr)
467467 : IRBuilderBase(TheBB->getContext(), FPMathTag), Folder(F) {
468468 SetInsertPoint(TheBB, IP);
469469 }
470470
471 IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, MDNode *FPMathTag = 0)
471 IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP,
472 MDNode *FPMathTag = nullptr)
472473 : IRBuilderBase(TheBB->getContext(), FPMathTag), Folder() {
473474 SetInsertPoint(TheBB, IP);
474475 }
540541 /// \brief Create a conditional 'br Cond, TrueDest, FalseDest'
541542 /// instruction.
542543 BranchInst *CreateCondBr(Value *Cond, BasicBlock *True, BasicBlock *False,
543 MDNode *BranchWeights = 0) {
544 MDNode *BranchWeights = nullptr) {
544545 return Insert(addBranchWeights(BranchInst::Create(True, False, Cond),
545546 BranchWeights));
546547 }
549550 /// and with a hint for the number of cases that will be added (for efficient
550551 /// allocation).
551552 SwitchInst *CreateSwitch(Value *V, BasicBlock *Dest, unsigned NumCases = 10,
552 MDNode *BranchWeights = 0) {
553 MDNode *BranchWeights = nullptr) {
553554 return Insert(addBranchWeights(SwitchInst::Create(V, Dest, NumCases),
554555 BranchWeights));
555556 }
637638 return CreateAdd(LHS, RHS, Name, true, false);
638639 }
639640 Value *CreateFAdd(Value *LHS, Value *RHS, const Twine &Name = "",
640 MDNode *FPMathTag = 0) {
641 MDNode *FPMathTag = nullptr) {
641642 if (Constant *LC = dyn_cast(LHS))
642643 if (Constant *RC = dyn_cast(RHS))
643644 return Insert(Folder.CreateFAdd(LC, RC), Name);
659660 return CreateSub(LHS, RHS, Name, true, false);
660661 }
661662 Value *CreateFSub(Value *LHS, Value *RHS, const Twine &Name = "",
662 MDNode *FPMathTag = 0) {
663 MDNode *FPMathTag = nullptr) {
663664 if (Constant *LC = dyn_cast(LHS))
664665 if (Constant *RC = dyn_cast(RHS))
665666 return Insert(Folder.CreateFSub(LC, RC), Name);
681682 return CreateMul(LHS, RHS, Name, true, false);
682683 }
683684 Value *CreateFMul(Value *LHS, Value *RHS, const Twine &Name = "",
684 MDNode *FPMathTag = 0) {
685 MDNode *FPMathTag = nullptr) {
685686 if (Constant *LC = dyn_cast(LHS))
686687 if (Constant *RC = dyn_cast(RHS))
687688 return Insert(Folder.CreateFMul(LC, RC), Name);
713714 return CreateSDiv(LHS, RHS, Name, true);
714715 }
715716 Value *CreateFDiv(Value *LHS, Value *RHS, const Twine &Name = "",
716 MDNode *FPMathTag = 0) {
717 MDNode *FPMathTag = nullptr) {
717718 if (Constant *LC = dyn_cast(LHS))
718719 if (Constant *RC = dyn_cast(RHS))
719720 return Insert(Folder.CreateFDiv(LC, RC), Name);
733734 return Insert(BinaryOperator::CreateSRem(LHS, RHS), Name);
734735 }
735736 Value *CreateFRem(Value *LHS, Value *RHS, const Twine &Name = "",
736 MDNode *FPMathTag = 0) {
737 MDNode *FPMathTag = nullptr) {
737738 if (Constant *LC = dyn_cast(LHS))
738739 if (Constant *RC = dyn_cast(RHS))
739740 return Insert(Folder.CreateFRem(LC, RC), Name);
843844
844845 Value *CreateBinOp(Instruction::BinaryOps Opc,
845846 Value *LHS, Value *RHS, const Twine &Name = "",
846 MDNode *FPMathTag = 0) {
847 MDNode *FPMathTag = nullptr) {
847848 if (Constant *LC = dyn_cast(LHS))
848849 if (Constant *RC = dyn_cast(RHS))
849850 return Insert(Folder.CreateBinOp(Opc, LC, RC), Name);
868869 Value *CreateNUWNeg(Value *V, const Twine &Name = "") {
869870 return CreateNeg(V, Name, true, false);
870871 }
871 Value *CreateFNeg(Value *V, const Twine &Name = "", MDNode *FPMathTag = 0) {
872 Value *CreateFNeg(Value *V, const Twine &Name = "",
873 MDNode *FPMathTag = nullptr) {
872874 if (Constant *VC = dyn_cast(V))
873875 return Insert(Folder.CreateFNeg(VC), Name);
874876 return Insert(AddFPMathAttributes(BinaryOperator::CreateFNeg(V),
884886 // Instruction creation methods: Memory Instructions
885887 //===--------------------------------------------------------------------===//
886888
887 AllocaInst *CreateAlloca(Type *Ty, Value *ArraySize = 0,
889 AllocaInst *CreateAlloca(Type *Ty, Value *ArraySize = nullptr,
888890 const Twine &Name = "") {
889891 return Insert(new AllocaInst(Ty, ArraySize), Name);
890892 }
897899 return Insert(new LoadInst(Ptr), Name);
898900 }
899901 LoadInst *CreateLoad(Value *Ptr, bool isVolatile, const Twine &Name = "") {
900 return Insert(new LoadInst(Ptr, 0, isVolatile), Name);
902 return Insert(new LoadInst(Ptr, nullptr, isVolatile), Name);
901903 }
902904 StoreInst *CreateStore(Value *Val, Value *Ptr, bool isVolatile = false) {
903905 return Insert(new StoreInst(Val, Ptr, isVolatile));
3535 protected:
3636 TerminatorInst(Type *Ty, Instruction::TermOps iType,
3737 Use *Ops, unsigned NumOps,
38 Instruction *InsertBefore = 0)
38 Instruction *InsertBefore = nullptr)
3939 : Instruction(Ty, iType, Ops, NumOps, InsertBefore) {}
4040
4141 TerminatorInst(Type *Ty, Instruction::TermOps iType,
9090
9191 protected:
9292 UnaryInstruction(Type *Ty, unsigned iType, Value *V,
93 Instruction *IB = 0)
93 Instruction *IB = nullptr)
9494 : Instruction(Ty, iType, &Op<0>(), 1, IB) {
9595 Op<0>() = V;
9696 }
159159 ///
160160 static BinaryOperator *Create(BinaryOps Op, Value *S1, Value *S2,
161161 const Twine &Name = Twine(),
162 Instruction *InsertBefore = 0);
162 Instruction *InsertBefore = nullptr);
163163
164164 /// Create() - Construct a binary instruction, given the opcode and the two
165165 /// operands. Also automatically insert this instruction to the end of the
284284 /// instructions out of SUB and XOR instructions.
285285 ///
286286 static BinaryOperator *CreateNeg(Value *Op, const Twine &Name = "",
287 Instruction *InsertBefore = 0);
287 Instruction *InsertBefore = nullptr);
288288 static BinaryOperator *CreateNeg(Value *Op, const Twine &Name,
289289 BasicBlock *InsertAtEnd);
290290 static BinaryOperator *CreateNSWNeg(Value *Op, const Twine &Name = "",
291 Instruction *InsertBefore = 0);
291 Instruction *InsertBefore = nullptr);
292292 static BinaryOperator *CreateNSWNeg(Value *Op, const Twine &Name,
293293 BasicBlock *InsertAtEnd);
294294 static BinaryOperator *CreateNUWNeg(Value *Op, const Twine &Name = "",
295 Instruction *InsertBefore = 0);
295 Instruction *InsertBefore = nullptr);
296296 static BinaryOperator *CreateNUWNeg(Value *Op, const Twine &Name,
297297 BasicBlock *InsertAtEnd);
298298 static BinaryOperator *CreateFNeg(Value *Op, const Twine &Name = "",
299 Instruction *InsertBefore = 0);
299 Instruction *InsertBefore = nullptr);
300300 static BinaryOperator *CreateFNeg(Value *Op, const Twine &Name,
301301 BasicBlock *InsertAtEnd);
302302 static BinaryOperator *CreateNot(Value *Op, const Twine &Name = "",
303 Instruction *InsertBefore = 0);
303 Instruction *InsertBefore = nullptr);
304304 static BinaryOperator *CreateNot(Value *Op, const Twine &Name,
305305 BasicBlock *InsertAtEnd);
306306
388388 protected:
389389 /// @brief Constructor with insert-before-instruction semantics for subclasses
390390 CastInst(Type *Ty, unsigned iType, Value *S,
391 const Twine &NameStr = "", Instruction *InsertBefore = 0)
391 const Twine &NameStr = "", Instruction *InsertBefore = nullptr)
392392 : UnaryInstruction(Ty, iType, S, InsertBefore) {
393393 setName(NameStr);
394394 }
410410 Value *S, ///< The value to be casted (operand 0)
411411 Type *Ty, ///< The type to which cast should be made
412412 const Twine &Name = "", ///< Name for the instruction
413 Instruction *InsertBefore = 0 ///< Place to insert the instruction
413 Instruction *InsertBefore = nullptr ///< Place to insert the instruction
414414 );
415415 /// Provides a way to construct any of the CastInst subclasses using an
416416 /// opcode instead of the subclass's constructor. The opcode must be in the
431431 Value *S, ///< The value to be casted (operand 0)
432432 Type *Ty, ///< The type to which cast should be made
433433 const Twine &Name = "", ///< Name for the instruction
434 Instruction *InsertBefore = 0 ///< Place to insert the instruction
434 Instruction *InsertBefore = nullptr ///< Place to insert the instruction
435435 );
436436
437437 /// @brief Create a ZExt or BitCast cast instruction
447447 Value *S, ///< The value to be casted (operand 0)
448448 Type *Ty, ///< The type to which cast should be made
449449 const Twine &Name = "", ///< Name for the instruction
450 Instruction *InsertBefore = 0 ///< Place to insert the instruction
450 Instruction *InsertBefore = nullptr ///< Place to insert the instruction
451451 );
452452
453453 /// @brief Create a SExt or BitCast cast instruction
471471 Value *S, ///< The pointer value to be casted (operand 0)
472472 Type *Ty, ///< The type to which cast should be made
473473 const Twine &Name = "", ///< Name for the instruction
474 Instruction *InsertBefore = 0 ///< Place to insert the instruction
474 Instruction *InsertBefore = nullptr ///< Place to insert the instruction
475475 );
476476
477477 /// @brief Create a ZExt, BitCast, or Trunc for int -> int casts.
480480 Type *Ty, ///< The type to which cast should be made
481481 bool isSigned, ///< Whether to regard S as signed or not
482482 const Twine &Name = "", ///< Name for the instruction
483 Instruction *InsertBefore = 0 ///< Place to insert the instruction
483 Instruction *InsertBefore = nullptr ///< Place to insert the instruction
484484 );
485485
486486 /// @brief Create a ZExt, BitCast, or Trunc for int -> int casts.
497497 Value *S, ///< The floating point value to be casted
498498 Type *Ty, ///< The floating point type to cast to
499499 const Twine &Name = "", ///< Name for the instruction
500 Instruction *InsertBefore = 0 ///< Place to insert the instruction
500 Instruction *InsertBefore = nullptr ///< Place to insert the instruction
501501 );
502502
503503 /// @brief Create an FPExt, BitCast, or FPTrunc for fp -> fp casts
513513 Value *S, ///< The value to be casted (operand 0)
514514 Type *Ty, ///< The type to which cast should be made
515515 const Twine &Name = "", ///< Name for the instruction
516 Instruction *InsertBefore = 0 ///< Place to insert the instruction
516 Instruction *InsertBefore = nullptr ///< Place to insert the instruction
517517 );
518518
519519 /// @brief Create a Trunc or BitCast cast instruction
640640 protected:
641641 CmpInst(Type *ty, Instruction::OtherOps op, unsigned short pred,
642642 Value *LHS, Value *RHS, const Twine &Name = "",
643 Instruction *InsertBefore = 0);
643 Instruction *InsertBefore = nullptr);
644644
645645 CmpInst(Type *ty, Instruction::OtherOps op, unsigned short pred,
646646 Value *LHS, Value *RHS, const Twine &Name,
700700 static CmpInst *Create(OtherOps Op,
701701 unsigned short predicate, Value *S1,
702702 Value *S2, const Twine &Name = "",
703 Instruction *InsertBefore = 0);
703 Instruction *InsertBefore = nullptr);
704704
705705 /// Construct a compare instruction, given the opcode, the predicate and the
706706 /// two operands. Also automatically insert this instruction to the end of
140140 /// getMetadata - Get the metadata of given kind attached to this Instruction.
141141 /// If the metadata is not found then return null.
142142 MDNode *getMetadata(unsigned KindID) const {
143 if (!hasMetadata()) return 0;
143 if (!hasMetadata()) return nullptr;
144144 return getMetadataImpl(KindID);
145145 }
146146
147147 /// getMetadata - Get the metadata of given kind attached to this Instruction.
148148 /// If the metadata is not found then return null.
149149 MDNode *getMetadata(StringRef Kind) const {
150 if (!hasMetadata()) return 0;
150 if (!hasMetadata()) return nullptr;
151151 return getMetadataImpl(Kind);
152152 }
153153
460460 }
461461
462462 Instruction(Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
463 Instruction *InsertBefore = 0);
463 Instruction *InsertBefore = nullptr);
464464 Instruction(Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
465465 BasicBlock *InsertAtEnd);
466466 virtual Instruction *clone_impl() const = 0;
5959 protected:
6060 AllocaInst *clone_impl() const override;
6161 public:
62 explicit AllocaInst(Type *Ty, Value *ArraySize = 0,
63 const Twine &Name = "", Instruction *InsertBefore = 0);
62 explicit AllocaInst(Type *Ty, Value *ArraySize = nullptr,
63 const Twine &Name = "",
64 Instruction *InsertBefore = nullptr);
6465 AllocaInst(Type *Ty, Value *ArraySize,
6566 const Twine &Name, BasicBlock *InsertAtEnd);
6667
67 AllocaInst(Type *Ty, const Twine &Name, Instruction *InsertBefore = 0);
68 AllocaInst(Type *Ty, const Twine &Name, Instruction *InsertBefore = nullptr);
6869 AllocaInst(Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd);
6970
7071 AllocaInst(Type *Ty, Value *ArraySize, unsigned Align,
71 const Twine &Name = "", Instruction *InsertBefore = 0);
72 const Twine &Name = "", Instruction *InsertBefore = nullptr);
7273 AllocaInst(Type *Ty, Value *ArraySize, unsigned Align,
7374 const Twine &Name, BasicBlock *InsertAtEnd);
7475
155156 LoadInst(Value *Ptr, const Twine &NameStr, Instruction *InsertBefore);
156157 LoadInst(Value *Ptr, const Twine &NameStr, BasicBlock *InsertAtEnd);
157158 LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile = false,
158 Instruction *InsertBefore = 0);
159 Instruction *InsertBefore = nullptr);
159160 LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile,
160161 BasicBlock *InsertAtEnd);
161162 LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile,
162 unsigned Align, Instruction *InsertBefore = 0);
163 unsigned Align, Instruction *InsertBefore = nullptr);
163164 LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile,
164165 unsigned Align, BasicBlock *InsertAtEnd);
165166 LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile,
166167 unsigned Align, AtomicOrdering Order,
167168 SynchronizationScope SynchScope = CrossThread,
168 Instruction *InsertBefore = 0);
169 Instruction *InsertBefore = nullptr);
169170 LoadInst(Value *Ptr, const Twine &NameStr, bool isVolatile,
170171 unsigned Align, AtomicOrdering Order,
171172 SynchronizationScope SynchScope,
173174
174175 LoadInst(Value *Ptr, const char *NameStr, Instruction *InsertBefore);
175176 LoadInst(Value *Ptr, const char *NameStr, BasicBlock *InsertAtEnd);
176 explicit LoadInst(Value *Ptr, const char *NameStr = 0,
177 bool isVolatile = false, Instruction *InsertBefore = 0);
177 explicit LoadInst(Value *Ptr, const char *NameStr = nullptr,
178 bool isVolatile = false,
179 Instruction *InsertBefore = nullptr);
178180 LoadInst(Value *Ptr, const char *NameStr, bool isVolatile,
179181 BasicBlock *InsertAtEnd);
180182
279281 StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore);
280282 StoreInst(Value *Val, Value *Ptr, BasicBlock *InsertAtEnd);
281283 StoreInst(Value *Val, Value *Ptr, bool isVolatile = false,
282 Instruction *InsertBefore = 0);
284 Instruction *InsertBefore = nullptr);
283285 StoreInst(Value *Val, Value *Ptr, bool isVolatile, BasicBlock *InsertAtEnd);
284286 StoreInst(Value *Val, Value *Ptr, bool isVolatile,
285 unsigned Align, Instruction *InsertBefore = 0);
287 unsigned Align, Instruction *InsertBefore = nullptr);
286288 StoreInst(Value *Val, Value *Ptr, bool isVolatile,
287289 unsigned Align, BasicBlock *InsertAtEnd);
288290 StoreInst(Value *Val, Value *Ptr, bool isVolatile,
289291 unsigned Align, AtomicOrdering Order,
290292 SynchronizationScope SynchScope = CrossThread,
291 Instruction *InsertBefore = 0);
293 Instruction *InsertBefore = nullptr);
292294 StoreInst(Value *Val, Value *Ptr, bool isVolatile,
293295 unsigned Align, AtomicOrdering Order,
294296 SynchronizationScope SynchScope,
408410 // SequentiallyConsistent.
409411 FenceInst(LLVMContext &C, AtomicOrdering Ordering,
410412 SynchronizationScope SynchScope = CrossThread,
411 Instruction *InsertBefore = 0);
413 Instruction *InsertBefore = nullptr);
412414 FenceInst(LLVMContext &C, AtomicOrdering Ordering,
413415 SynchronizationScope SynchScope,
414416 BasicBlock *InsertAtEnd);
476478 AtomicOrdering SuccessOrdering,
477479 AtomicOrdering FailureOrdering,
478480 SynchronizationScope SynchScope,
479 Instruction *InsertBefore = 0);
481 Instruction *InsertBefore = nullptr);
480482 AtomicCmpXchgInst(Value *Ptr, Value *Cmp, Value *NewVal,
481483 AtomicOrdering SuccessOrdering,
482484 AtomicOrdering FailureOrdering,
650652 }
651653 AtomicRMWInst(BinOp Operation, Value *Ptr, Value *Val,
652654 AtomicOrdering Ordering, SynchronizationScope SynchScope,
653 Instruction *InsertBefore = 0);
655 Instruction *InsertBefore = nullptr);
654656 AtomicRMWInst(BinOp Operation, Value *Ptr, Value *Val,
655657 AtomicOrdering Ordering, SynchronizationScope SynchScope,
656658 BasicBlock *InsertAtEnd);
778780 public:
779781 static GetElementPtrInst *Create(Value *Ptr, ArrayRef IdxList,
780782 const Twine &NameStr = "",
781 Instruction *InsertBefore = 0) {
783 Instruction *InsertBefore = nullptr) {
782784 unsigned Values = 1 + unsigned(IdxList.size());
783785 return new(Values)
784786 GetElementPtrInst(Ptr, IdxList, Values, NameStr, InsertBefore);
796798 static GetElementPtrInst *CreateInBounds(Value *Ptr,
797799 ArrayRef IdxList,
798800 const Twine &NameStr = "",
799 Instruction *InsertBefore = 0) {
801 Instruction *InsertBefore = nullptr){
800802 GetElementPtrInst *GEP = Create(Ptr, IdxList, NameStr, InsertBefore);
801803 GEP->setIsInBounds(true);
802804 return GEP;
12361238 static CallInst *Create(Value *Func,
12371239 ArrayRef Args,
12381240 const Twine &NameStr = "",
1239 Instruction *InsertBefore = 0) {
1241 Instruction *InsertBefore = nullptr) {
12401242 return new(unsigned(Args.size() + 1))
12411243 CallInst(Func, Args, NameStr, InsertBefore);
12421244 }
12471249 CallInst(Func, Args, NameStr, InsertAtEnd);
12481250 }
12491251 static CallInst *Create(Value *F, const Twine &NameStr = "",
1250 Instruction *InsertBefore = 0) {
1252 Instruction *InsertBefore = nullptr) {
12511253 return new(1) CallInst(F, NameStr, InsertBefore);
12521254 }
12531255 static CallInst *Create(Value *F, const Twine &NameStr,
12621264 /// 3. Bitcast the result of the malloc call to the specified type.
12631265 static Instruction *CreateMalloc(Instruction *InsertBefore,
12641266 Type *IntPtrTy, Type *AllocTy,
1265 Value *AllocSize, Value *ArraySize = 0,
1266 Function* MallocF = 0,
1267 Value *AllocSize, Value *ArraySize = nullptr,
1268 Function* MallocF = nullptr,
12671269 const Twine &Name = "");
12681270 static Instruction *CreateMalloc(BasicBlock *InsertAtEnd,
12691271 Type *IntPtrTy, Type *AllocTy,
1270 Value *AllocSize, Value *ArraySize = 0,
1271 Function* MallocF = 0,
1272 Value *AllocSize, Value *ArraySize = nullptr,
1273 Function* MallocF = nullptr,
12721274 const Twine &Name = "");
12731275 /// CreateFree - Generate the IR for a call to the builtin free function.
12741276 static Instruction* CreateFree(Value* Source, Instruction *InsertBefore);
15191521 public:
15201522 static SelectInst *Create(Value *C, Value *S1, Value *S2,
15211523 const Twine &NameStr = "",
1522 Instruction *InsertBefore = 0) {
1524 Instruction *InsertBefore = nullptr) {
15231525 return new(3) SelectInst(C, S1, S2, NameStr, InsertBefore);
15241526 }
15251527 static SelectInst *Create(Value *C, Value *S1, Value *S2,
15741576
15751577 public:
15761578 VAArgInst(Value *List, Type *Ty, const Twine &NameStr = "",
1577 Instruction *InsertBefore = 0)
1579 Instruction *InsertBefore = nullptr)
15781580 : UnaryInstruction(Ty, VAArg, List, InsertBefore) {
15791581 setName(NameStr);
15801582 }
16061608 ///
16071609 class ExtractElementInst : public Instruction {
16081610 ExtractElementInst(Value *Vec, Value *Idx, const Twine &NameStr = "",
1609 Instruction *InsertBefore = 0);
1611 Instruction *InsertBefore = nullptr);
16101612 ExtractElementInst(Value *Vec, Value *Idx, const Twine &NameStr,
16111613 BasicBlock *InsertAtEnd);
16121614 protected:
16151617 public:
16161618 static ExtractElementInst *Create(Value *Vec, Value *Idx,
16171619 const Twine &NameStr = "",
1618 Instruction *InsertBefore = 0) {
1620 Instruction *InsertBefore = nullptr) {
16191621 return new(2) ExtractElementInst(Vec, Idx, NameStr, InsertBefore);
16201622 }
16211623 static ExtractElementInst *Create(Value *Vec, Value *Idx,
16671669 class InsertElementInst : public Instruction {
16681670 InsertElementInst(Value *Vec, Value *NewElt, Value *Idx,
16691671 const Twine &NameStr = "",
1670 Instruction *InsertBefore = 0);
1672 Instruction *InsertBefore = nullptr);
16711673 InsertElementInst(Value *Vec, Value *NewElt, Value *Idx,
16721674 const Twine &NameStr, BasicBlock *InsertAtEnd);
16731675 protected:
16761678 public:
16771679 static InsertElementInst *Create(Value *Vec, Value *NewElt, Value *Idx,
16781680 const Twine &NameStr = "",
1679 Instruction *InsertBefore = 0) {
1681 Instruction *InsertBefore = nullptr) {
16801682 return new(3) InsertElementInst(Vec, NewElt, Idx, NameStr, InsertBefore);
16811683 }
16821684 static InsertElementInst *Create(Value *Vec, Value *NewElt, Value *Idx,
17331735 }
17341736 ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
17351737 const Twine &NameStr = "",
1736 Instruction *InsertBefor = 0);
1738 Instruction *InsertBefor = nullptr);
17371739 ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
17381740 const Twine &NameStr, BasicBlock *InsertAtEnd);
17391741
18311833 static ExtractValueInst *Create(Value *Agg,
18321834 ArrayRef Idxs,
18331835 const Twine &NameStr = "",
1834 Instruction *InsertBefore = 0) {
1836 Instruction *InsertBefore = nullptr) {
18351837 return new
18361838 ExtractValueInst(Agg, Idxs, NameStr, InsertBefore);
18371839 }
19321934 /// and two index insertvalue instructions are so common.
19331935 InsertValueInst(Value *Agg, Value *Val,
19341936 unsigned Idx, const Twine &NameStr = "",
1935 Instruction *InsertBefore = 0);
1937 Instruction *InsertBefore = nullptr);
19361938 InsertValueInst(Value *Agg, Value *Val, unsigned Idx,
19371939 const Twine &NameStr, BasicBlock *InsertAtEnd);
19381940 protected:
19461948 static InsertValueInst *Create(Value *Agg, Value *Val,
19471949 ArrayRef Idxs,
19481950 const Twine &NameStr = "",
1949 Instruction *InsertBefore = 0) {
1951 Instruction *InsertBefore = nullptr) {
19501952 return new InsertValueInst(Agg, Val, Idxs, NameStr, InsertBefore);
19511953 }
19521954 static InsertValueInst *Create(Value *Agg, Value *Val,
20512053 return User::operator new(s, 0);
20522054 }
20532055 explicit PHINode(Type *Ty, unsigned NumReservedValues,
2054 const Twine &NameStr = "", Instruction *InsertBefore = 0)
2055 : Instruction(Ty, Instruction::PHI, 0, 0, InsertBefore),
2056 const Twine &NameStr = "",
2057 Instruction *InsertBefore = nullptr)
2058 : Instruction(Ty, Instruction::PHI, nullptr, 0, InsertBefore),
20562059 ReservedSpace(NumReservedValues) {
20572060 setName(NameStr);
20582061 OperandList = allocHungoffUses(ReservedSpace);
20602063
20612064 PHINode(Type *Ty, unsigned NumReservedValues, const Twine &NameStr,
20622065 BasicBlock *InsertAtEnd)
2063 : Instruction(Ty, Instruction::PHI, 0, 0, InsertAtEnd),
2066 : Instruction(Ty, Instruction::PHI, nullptr, 0, InsertAtEnd),
20642067 ReservedSpace(NumReservedValues) {
20652068 setName(NameStr);
20662069 OperandList = allocHungoffUses(ReservedSpace);
20772080 /// edges that this phi node will have (use 0 if you really have no idea).
20782081 static PHINode *Create(Type *Ty, unsigned NumReservedValues,
20792082 const Twine &NameStr = "",
2080 Instruction *InsertBefore = 0) {
2083 Instruction *InsertBefore = nullptr) {
20812084 return new PHINode(Ty, NumReservedValues, NameStr, InsertBefore);
20822085 }
20832086 static PHINode *Create(Type *Ty, unsigned NumReservedValues,
22692272 static LandingPadInst *Create(Type *RetTy, Value *PersonalityFn,
22702273 unsigned NumReservedClauses,
22712274 const Twine &NameStr = "",
2272 Instruction *InsertBefore = 0);
2275 Instruction *InsertBefore = nullptr);
22732276 static LandingPadInst *Create(Type *RetTy, Value *PersonalityFn,
22742277 unsigned NumReservedClauses,
22752278 const Twine &NameStr, BasicBlock *InsertAtEnd);
23552358 //
23562359 // NOTE: If the Value* passed is of type void then the constructor behaves as
23572360 // if it was passed NULL.
2358 explicit ReturnInst(LLVMContext &C, Value *retVal = 0,
2359 Instruction *InsertBefore = 0);
2361 explicit ReturnInst(LLVMContext &C, Value *retVal = nullptr,
2362 Instruction *InsertBefore = nullptr);
23602363 ReturnInst(LLVMContext &C, Value *retVal, BasicBlock *InsertAtEnd);
23612364 explicit ReturnInst(LLVMContext &C, BasicBlock *InsertAtEnd);
23622365 protected:
23632366 ReturnInst *clone_impl() const override;
23642367 public:
2365 static ReturnInst* Create(LLVMContext &C, Value *retVal = 0,
2366 Instruction *InsertBefore = 0) {
2368 static ReturnInst* Create(LLVMContext &C, Value *retVal = nullptr,
2369 Instruction *InsertBefore = nullptr) {
23672370 return new(!!retVal) ReturnInst(C, retVal, InsertBefore);
23682371 }
23692372 static ReturnInst* Create(LLVMContext &C, Value *retVal,
23802383
23812384 /// Convenience accessor. Returns null if there is no return value.
23822385 Value *getReturnValue() const {
2383 return getNumOperands() != 0 ? getOperand(0) : 0;
2386 return getNumOperands() != 0 ? getOperand(0) : nullptr;
23842387 }
23852388
23862389 unsigned getNumSuccessors() const { return 0; }
24252428 // BranchInst(BB* T, BB *F, Value *C, Inst *I) - 'br C, T, F', insert before I
24262429 // BranchInst(BB* B, BB *I) - 'br B' insert at end
24272430 // BranchInst(BB* T, BB *F, Value *C, BB *I) - 'br C, T, F', insert at end
2428 explicit BranchInst(BasicBlock *IfTrue, Instruction *InsertBefore = 0);
2431 explicit BranchInst(BasicBlock *IfTrue, Instruction *InsertBefore = nullptr);
24292432 BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
2430 Instruction *InsertBefore = 0);
2433 Instruction *InsertBefore = nullptr);
24312434 BranchInst(BasicBlock *IfTrue, BasicBlock *InsertAtEnd);
24322435 BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
24332436 BasicBlock *InsertAtEnd);
24342437 protected:
24352438 BranchInst *clone_impl() const override;
24362439 public:
2437 static BranchInst *Create(BasicBlock *IfTrue, Instruction *InsertBefore = 0) {
2440 static BranchInst *Create(BasicBlock *IfTrue,
2441 Instruction *InsertBefore = nullptr) {
24382442 return new(1) BranchInst(IfTrue, InsertBefore);
24392443 }
24402444 static BranchInst *Create(BasicBlock *IfTrue, BasicBlock *IfFalse,
2441 Value *Cond, Instruction *InsertBefore = 0) {
2445 Value *Cond, Instruction *InsertBefore = nullptr) {
24422446 return new(3) BranchInst(IfTrue, IfFalse, Cond, InsertBefore);
24432447 }
24442448 static BranchInst *Create(BasicBlock *IfTrue, BasicBlock *InsertAtEnd) {
26572661 };
26582662
26592663 static SwitchInst *Create(Value *Value, BasicBlock *Default,
2660 unsigned NumCases, Instruction *InsertBefore = 0) {
2664 unsigned NumCases,
2665 Instruction *InsertBefore = nullptr) {
26612666 return new SwitchInst(Value, Default, NumCases, InsertBefore);
26622667 }
26632668 static SwitchInst *Create(Value *Value, BasicBlock *Default,
27412746 /// findCaseDest - Finds the unique case value for a given successor. Returns
27422747 /// null if the successor is not found, not unique, or is the default case.
27432748 ConstantInt *findCaseDest(BasicBlock *BB) {
2744 if (BB == getDefaultDest()) return NULL;
2745
2746 ConstantInt *CI = NULL;
2749 if (BB == getDefaultDest()) return nullptr;
2750
2751 ConstantInt *CI = nullptr;
27472752 for (CaseIt i = case_begin(), e = case_end(); i != e; ++i) {
27482753 if (i.getCaseSuccessor() == BB) {
2749 if (CI) return NULL; // Multiple cases lead to BB.
2754 if (CI) return nullptr; // Multiple cases lead to BB.
27502755 else CI = i.getCaseValue();
27512756 }
27522757 }
28332838 IndirectBrInst *clone_impl() const override;
28342839 public:
28352840 static IndirectBrInst *Create(Value *Address, unsigned NumDests,
2836 Instruction *InsertBefore = 0) {
2841 Instruction *InsertBefore = nullptr) {
28372842 return new IndirectBrInst(Address, NumDests, InsertBefore);
28382843 }
28392844 static IndirectBrInst *Create(Value *Address, unsigned NumDests,
29272932 static InvokeInst *Create(Value *Func,
29282933 BasicBlock *IfNormal, BasicBlock *IfException,
29292934 ArrayRef Args, const Twine &NameStr = "",
2930 Instruction *InsertBefore = 0) {
2935 Instruction *InsertBefore = nullptr) {
29312936 unsigned Values = unsigned(Args.size()) + 3;
29322937 return new(Values) InvokeInst(Func, IfNormal, IfException, Args,
29332938 Values, NameStr, InsertBefore);
31743179 class ResumeInst : public TerminatorInst {
31753180 ResumeInst(const ResumeInst &RI);
31763181
3177 explicit ResumeInst(Value *Exn, Instruction *InsertBefore=0);
3182 explicit ResumeInst(Value *Exn, Instruction *InsertBefore=nullptr);
31783183 ResumeInst(Value *Exn, BasicBlock *InsertAtEnd);
31793184 protected:
31803185 ResumeInst *clone_impl() const override;
31813186 public:
3182 static ResumeInst *Create(Value *Exn, Instruction *InsertBefore = 0) {
3187 static ResumeInst *Create(Value *Exn, Instruction *InsertBefore = nullptr) {
31833188 return new(1) ResumeInst(Exn, InsertBefore);
31843189 }
31853190 static ResumeInst *Create(Value *Exn, BasicBlock *InsertAtEnd) {
32333238 void *operator new(size_t s) {
32343239 return User::operator new(s, 0);
32353240 }
3236 explicit UnreachableInst(LLVMContext &C, Instruction *InsertBefore = 0);
3241 explicit UnreachableInst(LLVMContext &C, Instruction *InsertBefore = nullptr);
32373242 explicit UnreachableInst(LLVMContext &C, BasicBlock *InsertAtEnd);
32383243
32393244 unsigned getNumSuccessors() const { return 0; }
32643269 public:
32653270 /// \brief Constructor with insert-before-instruction semantics
32663271 TruncInst(
3267 Value *S, ///< The value to be truncated
3268 Type *Ty, ///< The (smaller) type to truncate to
3269 const Twine &NameStr = "", ///< A name for the new instruction
3270 Instruction *InsertBefore = 0 ///< Where to insert the new instruction
3272 Value *S, ///< The value to be truncated
3273 Type *Ty, ///< The (smaller) type to truncate to
3274 const Twine &NameStr = "", ///< A name for the new instruction
3275 Instruction *InsertBefore = nullptr ///< Where to insert the new instruction
32713276 );
32723277
32733278 /// \brief Constructor with insert-at-end-of-block semantics
32743279 TruncInst(
32753280 Value *S, ///< The value to be truncated
3276 Type *Ty, ///< The (smaller) type to truncate to
3281 Type *Ty, ///< The (smaller) type to truncate to
32773282 const Twine &NameStr, ///< A name for the new instruction
32783283 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
32793284 );
33003305 public:
33013306 /// \brief Constructor with insert-before-instruction semantics
33023307 ZExtInst(
3303 Value *S, ///< The value to be zero extended
3304 Type *Ty, ///< The type to zero extend to
3305 const Twine &NameStr = "", ///< A name for the new instruction
3306 Instruction *InsertBefore = 0 ///< Where to insert the new instruction
3308 Value *S, ///< The value to be zero extended
3309 Type *Ty, ///< The type to zero extend to
3310 const Twine &NameStr = "", ///< A name for the new instruction
3311 Instruction *InsertBefore = nullptr ///< Where to insert the new instruction
33073312 );
33083313
33093314 /// \brief Constructor with insert-at-end semantics.
33103315 ZExtInst(
33113316 Value *S, ///< The value to be zero extended
3312 Type *Ty, ///< The type to zero extend to
3317 Type *Ty, ///< The type to zero extend to
33133318 const Twine &NameStr, ///< A name for the new instruction
33143319 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
33153320 );
33363341 public:
33373342 /// \brief Constructor with insert-before-instruction semantics
33383343 SExtInst(
3339 Value *S, ///< The value to be sign extended
3340 Type *Ty, ///< The type to sign extend to
3341 const Twine &NameStr = "", ///< A name for the new instruction
3342 Instruction *InsertBefore = 0 ///< Where to insert the new instruction
3344 Value *S, ///< The value to be sign extended
3345 Type *Ty, ///< The type to sign extend to
3346 const Twine &NameStr = "", ///< A name for the new instruction
3347 Instruction *InsertBefore = nullptr ///< Where to insert the new instruction
33433348 );
33443349
33453350 /// \brief Constructor with insert-at-end-of-block semantics
33463351 SExtInst(
33473352 Value *S, ///< The value to be sign extended
3348 Type *Ty, ///< The type to sign extend to
3353 Type *Ty, ///< The type to sign extend to
33493354 const Twine &NameStr, ///< A name for the new instruction
33503355 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
33513356 );
33723377 public:
33733378 /// \brief Constructor with insert-before-instruction semantics
33743379 FPTruncInst(
3375 Value *S, ///< The value to be truncated
3376 Type *Ty, ///< The type to truncate to
3377 const Twine &NameStr = "", ///< A name for the new instruction
3378 Instruction *InsertBefore = 0 ///< Where to insert the new instruction
3380 Value *S, ///< The value to be truncated
3381 Type *Ty, ///< The type to truncate to
3382 const Twine &NameStr = "", ///< A name for the new instruction
3383 Instruction *InsertBefore = nullptr ///< Where to insert the new instruction
33793384 );
33803385
33813386 /// \brief Constructor with insert-before-instruction semantics
33823387 FPTruncInst(
33833388 Value *S, ///< The value to be truncated
3384 Type *Ty, ///< The type to truncate to
3389 Type *Ty, ///< The type to truncate to
33853390 const Twine &NameStr, ///< A name for the new instruction
33863391 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
33873392 );
34083413 public:
34093414 /// \brief Constructor with insert-before-instruction semantics
34103415 FPExtInst(
3411 Value *S, ///< The value to be extended
3412 Type *Ty, ///< The type to extend to
3413 const Twine &NameStr = "", ///< A name for the new instruction
3414 Instruction *InsertBefore = 0 ///< Where to insert the new instruction
3416 Value *S, ///< The value to be extended
3417 Type *Ty, ///< The type to extend to
3418 const Twine &NameStr = "", ///< A name for the new instruction
3419 Instruction *InsertBefore = nullptr ///< Where to insert the new instruction
34153420 );
34163421
34173422 /// \brief Constructor with insert-at-end-of-block semantics
34183423 FPExtInst(
34193424 Value *S, ///< The value to be extended
3420 Type *Ty, ///< The type to extend to
3425 Type *Ty, ///< The type to extend to
34213426 const Twine &NameStr, ///< A name for the new instruction
34223427 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
34233428 );
34443449 public:
34453450 /// \brief Constructor with insert-before-instruction semantics
34463451 UIToFPInst(
3447 Value *S, ///< The value to be converted
3448 Type *Ty, ///< The type to convert to
3449 const Twine &NameStr = "", ///< A name for the new instruction
3450 Instruction *InsertBefore = 0 ///< Where to insert the new instruction
3452 Value *S, ///< The value to be converted
3453 Type *Ty, ///< The type to convert to
3454 const Twine &NameStr = "", ///< A name for the new instruction
3455 Instruction *InsertBefore = nullptr ///< Where to insert the new instruction
34513456 );
34523457
34533458 /// \brief Constructor with insert-at-end-of-block semantics
34543459 UIToFPInst(
34553460 Value *S, ///< The value to be converted
3456 Type *Ty, ///< The type to convert to
3461 Type *Ty, ///< The type to convert to
34573462 const Twine &NameStr, ///< A name for the new instruction
34583463 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
34593464 );
34803485 public:
34813486 /// \brief Constructor with insert-before-instruction semantics
34823487 SIToFPInst(
3483 Value *S, ///< The value to be converted
3484 Type *Ty, ///< The type to convert to
3485 const Twine &NameStr = "", ///< A name for the new instruction
3486 Instruction *InsertBefore = 0 ///< Where to insert the new instruction
3488 Value *S, ///< The value to be converted
3489 Type *Ty, ///< The type to convert to
3490 const Twine &NameStr = "", ///< A name for the new instruction
3491 Instruction *InsertBefore = nullptr ///< Where to insert the new instruction
34873492 );
34883493
34893494 /// \brief Constructor with insert-at-end-of-block semantics
34903495 SIToFPInst(
34913496 Value *S, ///< The value to be converted
3492 Type *Ty, ///< The type to convert to
3497 Type *Ty, ///< The type to convert to
34933498 const Twine &NameStr, ///< A name for the new instruction
34943499 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
34953500 );
35163521 public:
35173522 /// \brief Constructor with insert-before-instruction semantics
35183523 FPToUIInst(
3519 Value *S, ///< The value to be converted
3520 Type *Ty, ///< The type to convert to
3521 const Twine &NameStr = "", ///< A name for the new instruction
3522 Instruction *InsertBefore = 0 ///< Where to insert the new instruction
3524 Value *S, ///< The value to be converted
3525 Type *Ty, ///< The type to convert to
3526 const Twine &NameStr = "", ///< A name for the new instruction
3527 Instruction *InsertBefore = nullptr ///< Where to insert the new instruction
35233528 );
35243529
35253530 /// \brief Constructor with insert-at-end-of-block semantics
35263531 FPToUIInst(
35273532 Value *S, ///< The value to be converted
3528 Type *Ty, ///< The type to convert to
3533 Type *Ty, ///< The type to convert to
35293534 const Twine &NameStr, ///< A name for the new instruction
35303535 BasicBlock *InsertAtEnd ///< Where to insert the new instruction
35313536 );
35523557 public:
35533558 /// \brief Constructor with insert-before-instruction semantics
35543559 FPToSIInst(
3555 Value *S, ///< The value to be converted
3556 Type *Ty, ///< The type to convert to
3557 const Twine &NameStr = "", ///< A name for the new instruction
3558 Instruction *InsertBefore = 0 ///< Where to insert the new instruction
3560 Value *S, ///< The value to be converted
3561 Type *Ty, ///< The type to convert to
3562 const Twine &NameStr = "", ///< A name for the new instruction
3563 Instruction *InsertBefore = nullptr ///< Where to insert the new instruction
35593564 );
35603565
35613566 /// \brief Constructor with insert-at-end-of-block semantics
35623567 FPToSIInst(
35633568 Value *S, ///< The value to be converted
3564 Type *Ty, ///< The type to convert to
3569 Type *Ty, ///< The type to convert to
35653570 const Twine &NameStr, ///< A name for the new instruction
35663571 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
35673572 );
35843589 public:
35853590 /// \brief Constructor with insert-before-instruction semantics
35863591 IntToPtrInst(
3587 Value *S, ///< The value to be converted
3588 Type *Ty, ///< The type to convert to
3589 const Twine &NameStr = "", ///< A name for the new instruction
3590 Instruction *InsertBefore = 0 ///< Where to insert the new instruction
3592 Value *S, ///< The value to be converted
3593 Type *Ty, ///< The type to convert to
3594 const Twine &NameStr = "", ///< A name for the new instruction
3595 Instruction *InsertBefore = nullptr ///< Where to insert the new instruction
35913596 );
35923597
35933598 /// \brief Constructor with insert-at-end-of-block semantics
35943599 IntToPtrInst(
35953600 Value *S, ///< The value to be converted
3596 Type *Ty, ///< The type to convert to
3601 Type *Ty, ///< The type to convert to
35973602 const Twine &NameStr, ///< A name for the new instruction
35983603 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
35993604 );
36283633 public:
36293634 /// \brief Constructor with insert-before-instruction semantics
36303635 PtrToIntInst(
3631 Value *S, ///< The value to be converted
3632 Type *Ty, ///< The type to convert to
3633 const Twine &NameStr = "", ///< A name for the new instruction
3634 Instruction *InsertBefore = 0 ///< Where to insert the new instruction
3636 Value *S, ///< The value to be converted
3637 Type *Ty, ///< The type to convert to
3638 const Twine &NameStr = "", ///< A name for the new instruction
3639 Instruction *InsertBefore = nullptr ///< Where to insert the new instruction
36353640 );
36363641
36373642 /// \brief Constructor with insert-at-end-of-block semantics
36383643 PtrToIntInst(
36393644 Value *S, ///< The value to be converted
3640 Type *Ty, ///< The type to convert to
3645 Type *Ty, ///< The type to convert to
36413646 const Twine &NameStr, ///< A name for the new instruction
36423647 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
36433648 );
36763681 public:
36773682 /// \brief Constructor with insert-before-instruction semantics
36783683 BitCastInst(
3679 Value *S, ///< The value to be casted
3680 Type *Ty, ///< The type to casted to
3681 const Twine &NameStr = "", ///< A name for the new instruction
3682 Instruction *InsertBefore = 0 ///< Where to insert the new instruction
3684 Value *S, ///< The value to be casted
3685 Type *Ty, ///< The type to casted to
3686 const Twine &NameStr = "", ///< A name for the new instruction
3687 Instruction *InsertBefore = nullptr ///< Where to insert the new instruction
36833688 );
36843689
36853690 /// \brief Constructor with insert-at-end-of-block semantics
36863691 BitCastInst(
36873692 Value *S, ///< The value to be casted
3688 Type *Ty, ///< The type to casted to
3693 Type *Ty, ///< The type to casted to
36893694 const Twine &NameStr, ///< A name for the new instruction
36903695 BasicBlock *InsertAtEnd ///< The block to insert the instruction into
36913696 );
37133718 public:
37143719 /// \brief Constructor with insert-before-instruction semantics
37153720 AddrSpaceCastInst(
3716 Value *S, ///< The value to be casted
3717 Type *Ty, ///< The type to casted to
3718 const Twine &NameStr = "", ///< A name for the new instruction
3719 Instruction *InsertBefore = 0 ///< Where to insert the new instruction
3721 Value *S, ///< The value to be casted
3722 Type *Ty, ///< The type to casted to
3723 const Twine &NameStr = "", ///< A name for the new instruction
3724 Instruction *InsertBefore = nullptr ///< Where to insert the new instruction
37203725 );
37213726
37223727 /// \brief Constructor with insert-at-end-of-block semantics
7979 /// LLVMContext doesn't take ownership or interpret either of these
8080 /// pointers.
8181 void setInlineAsmDiagnosticHandler(InlineAsmDiagHandlerTy DiagHandler,
82 void *DiagContext = 0);
82 void *DiagContext = nullptr);
8383
8484 /// getInlineAsmDiagnosticHandler - Return the diagnostic handler set by
8585 /// setInlineAsmDiagnosticHandler.
9797 /// LLVMContext doesn't take ownership or interpret either of these
9898 /// pointers.
9999 void setDiagnosticHandler(DiagnosticHandlerTy DiagHandler,
100 void *DiagContext = 0);
100 void *DiagContext = nullptr);
101101
102102 /// getDiagnosticHandler - Return the diagnostic handler set by
103103 /// setDiagnosticHandler.
119119 Module *M;
120120 public:
121121 explicit PassManagerPrettyStackEntry(Pass *p)
122 : P(p), V(0), M(0) {} // When P is releaseMemory'd.
122 : P(p), V(nullptr), M(nullptr) {} // When P is releaseMemory'd.
123123 PassManagerPrettyStackEntry(Pass *p, Value &v)
124 : P(p), V(&v), M(0) {} // When P is run on V
124 : P(p), V(&v), M(nullptr) {} // When P is run on V
125125 PassManagerPrettyStackEntry(Pass *p, Module &m)
126 : P(p), V(0), M(&m) {} // When P is run on M
126 : P(p), V(nullptr), M(&m) {} // When P is run on M
127127
128128 /// print - Emit information about this stack frame to OS.
129129 void print(raw_ostream &OS) const override;
262262 class PMDataManager {
263263 public:
264264
265 explicit PMDataManager() : TPM(NULL), Depth(0) {
265 explicit PMDataManager() : TPM(nullptr), Depth(0) {
266266 initializeAnalysisInfo();
267267 }
268268
302302 void initializeAnalysisInfo() {
303303 AvailableAnalysis.clear();
304304 for (unsigned i = 0; i < PMT_Last; ++i)
305 InheritedAnalysis[i] = NULL;
305 InheritedAnalysis[i] = nullptr;
306306 }
307307
308308 // Return true if P preserves high level analysis used by other
4242 public cl::parser {
4343 cl::Option *Opt;
4444 public:
45 PassNameParser() : Opt(0) {}
45 PassNameParser() : Opt(nullptr) {}
4646 virtual ~PassNameParser();
4747
4848 void initialize(cl::Option &O) {
6161 inline bool ignorablePass(const PassInfo *P) const {
6262 // Ignore non-selectable and non-constructible passes! Ignore
6363 // non-optimizations.
64 return P->getPassArgument() == 0 || *P->getPassArgument() == 0 ||
65 P->getNormalCtor() == 0 || ignorablePassImpl(P);
64 return P->getPassArgument() == nullptr || *P->getPassArgument() == 0 ||
65 P->getNormalCtor() == nullptr || ignorablePassImpl(P);
6666 }
6767
6868 // Implement the PassRegistrationListener callbacks used to populate our map
217217 friend class NamedMDNode;
218218
219219 public:
220 op_iterator_impl() : Node(0), Idx(0) { }
220 op_iterator_impl() : Node(nullptr), Idx(0) { }
221221
222222 bool operator==(const op_iterator_impl &o) const { return Idx == o.Idx; }
223223 bool operator!=(const op_iterator_impl &o) const { return Idx != o.Idx; }
271271 StringRef getName() const;
272272
273273 /// print - Implement operator<< on NamedMDNode.
274 void print(raw_ostream &ROS, AssemblyAnnotationWriter *AAW = 0) const;
274 void print(raw_ostream &ROS, AssemblyAnnotationWriter *AAW = nullptr) const;
275275
276276 /// dump() - Allow printing of NamedMDNodes from the debugger.
277277 void dump() const;
456456 /// Materialize - Make sure the GlobalValue is fully read. If the module is
457457 /// corrupt, this returns true and fills in the optional string with
458458 /// information about the problem. If successful, this returns false.
459 bool Materialize(GlobalValue *GV, std::string *ErrInfo = 0);
459 bool Materialize(GlobalValue *GV, std::string *ErrInfo = nullptr);
460460 /// Dematerialize - If the GlobalValue is read in, and if the GVMaterializer
461461 /// supports it, release the memory for the function, and set it up to be
462462 /// materialized lazily. If !isDematerializable(), this method is a noop.
602602
603603 /// An raw_ostream inserter for modules.
604604 inline raw_ostream &operator<<(raw_ostream &O, const Module &M) {
605 M.print(O, 0);
605 M.print(O, nullptr);
606606 return O;
607607 }
608608
479479 ///
480480 /// This method should only be called for a single module as there is the
481481 /// expectation that the lifetime of a pass is bounded to that of a module.
482 PreservedAnalyses run(Module *M, ModuleAnalysisManager *AM = 0);
482 PreservedAnalyses run(Module *M, ModuleAnalysisManager *AM = nullptr);
483483
484484 template void addPass(ModulePassT Pass) {
485485 Passes.emplace_back(new ModulePassModel(std::move(Pass)));
523523 Passes.emplace_back(new FunctionPassModel(std::move(Pass)));
524524 }
525525
526 PreservedAnalyses run(Function *F, FunctionAnalysisManager *AM = 0);
526 PreservedAnalyses run(Function *F, FunctionAnalysisManager *AM = nullptr);
527527
528528 static StringRef name() { return "FunctionPassManager"; }
529529
986986
987987 /// \brief Runs the function pass across every function in the module.
988988 PreservedAnalyses run(Module *M, ModuleAnalysisManager *AM) {
989 FunctionAnalysisManager *FAM = 0;
989 FunctionAnalysisManager *FAM = nullptr;
990990 if (AM)
991991 // Setup the function analysis manager from its proxy.
992992 FAM = &AM->getResult(M).getManager();
4545 /// getListOwner - Return the object that owns this list. If this is a list
4646 /// of instructions, it returns the BasicBlock that owns them.
4747 ItemParentClass *getListOwner() {
48 size_t Offset(size_t(&((ItemParentClass*)0->*ItemParentClass::
49 getSublistAccess(static_cast(0)))));
48 size_t Offset(size_t(&((ItemParentClass*)nullptr->*ItemParentClass::
49 getSublistAccess(static_cast(nullptr)))));
5050 iplist* Anchor(static_cast*>(this));
5151 return reinterpret_cast(reinterpret_cast(Anchor)-
5252 Offset);
5353 }
5454
5555 static iplist &getList(ItemParentClass *Par) {
56 return Par->*(Par->getSublistAccess((ValueSubClass*)0));
56 return Par->*(Par->getSublistAccess((ValueSubClass*)nullptr));
5757 }
5858
5959 static ValueSymbolTable *getSymTab(ItemParentClass *Par) {
60 return Par ? toPtr(Par->getValueSymbolTable()) : 0;
60 return Par ? toPtr(Par->getValueSymbolTable()) : nullptr;
6161 }
6262
6363 void addNodeToList(ValueSubClass *V);
8787 friend class LLVMContextImpl;
8888 explicit Type(LLVMContext &C, TypeID tid)
8989 : Context(C), IDAndSubclassData(0),
90 NumContainedTys(0), ContainedTys(0) {
90 NumContainedTys(0), ContainedTys(nullptr) {
9191 setTypeID(tid);
9292 }
9393 ~Type() {}
264264 /// get the actual size for a particular target, it is reasonable to use the
265265 /// DataLayout subsystem to do this.
266266 ///
267 bool isSized(SmallPtrSet *Visited = 0) const {
267 bool isSized(SmallPtrSet *Visited = nullptr) const {
268268 // If it's a primitive, it is always sized.
269269 if (getTypeID() == IntegerTyID || isFloatingPointTy() ||
270270 getTypeID() == PointerTyID ||
418418 /// isSizedDerivedType - Derived types like structures and arrays are sized
419419 /// iff all of the members of the type are sized as well. Since asking for
420420 /// their size is relatively uncommon, move this operation out of line.
421 bool isSizedDerivedType(SmallPtrSet *Visited = 0) const;
421 bool isSizedDerivedType(SmallPtrSet *Visited = nullptr) const;
422422 };
423423
424424 // Printing of types.
8787 enum PrevPtrTag { zeroDigitTag, oneDigitTag, stopTag, fullStopTag };
8888
8989 /// Constructor
90 Use(PrevPtrTag tag) : Val(0) { Prev.setInt(tag); }
90 Use(PrevPtrTag tag) : Val(nullptr) { Prev.setInt(tag); }
9191
9292 public:
9393 operator Value *() const { return Val; }
5454 Use *allocHungoffUses(unsigned) const;
5555 void dropHungoffUses() {
5656 Use::zap(OperandList, OperandList + NumOperands, true);
57 OperandList = 0;
57 OperandList = nullptr;
5858 // Reset NumOperands so User::operator delete() does the right thing.
5959 NumOperands = 0;
6060 }
178178 //
179179 void dropAllReferences() {
180180 for (Use &U : operands())
181 U.set(0);
181 U.set(nullptr);
182182 }
183183
184184 /// replaceUsesOfWith - Replaces all references to the "From" definition with
202202 /// instruction that generated it. If you specify a Module for context, then
203203 /// even constanst get pretty-printed; for example, the type of a null
204204 /// pointer is printed symbolically.
205 void printAsOperand(raw_ostream &O, bool PrintType = true, const Module *M = 0) const;
205 void printAsOperand(raw_ostream &O, bool PrintType = true,
206 const Module *M = nullptr) const;
206207
207208 /// All values are typed, get the type of this value.
208209 ///
212213 LLVMContext &getContext() const;
213214
214215 // All values can potentially be named.
215 bool hasName() const { return Name != 0 && SubclassID != MDStringVal; }
216 bool hasName() const { return Name != nullptr && SubclassID != MDStringVal; }
216217 ValueName *getValueName() const { return Name; }
217218 void setValueName(ValueName *VN) { Name = VN; }
218219
241242 //----------------------------------------------------------------------
242243 // Methods for handling the chain of uses of this Value.
243244 //
244 bool use_empty() const { return UseList == 0; }
245 bool use_empty() const { return UseList == nullptr; }
245246
246247 typedef use_iterator_impl use_iterator;
247248 typedef use_iterator_impl const_use_iterator;
6363 ValueHandleBase(const ValueHandleBase&) LLVM_DELETED_FUNCTION;
6464 public:
6565 explicit ValueHandleBase(HandleBaseKind Kind)
66 : PrevPair(0, Kind), Next(0), VP(0, 0) {}
66 : PrevPair(nullptr, Kind), Next(nullptr), VP(nullptr, 0) {}
6767 ValueHandleBase(HandleBaseKind Kind, Value *V)
68 : PrevPair(0, Kind), Next(0), VP(V, 0) {
68 : PrevPair(nullptr, Kind), Next(nullptr), VP(V, 0) {
6969 if (isValid(VP.getPointer()))
7070 AddToUseList();
7171 }
7272 ValueHandleBase(HandleBaseKind Kind, const ValueHandleBase &RHS)
73 : PrevPair(0, Kind), Next(0), VP(RHS.VP) {
73 : PrevPair(nullptr, Kind), Next(nullptr), VP(RHS.VP) {
7474 if (isValid(VP.getPointer()))
7575 AddToExistingUseList(RHS.getPrevPtr());
7676 }
365365 ///
366366 /// All implementations must remove the reference from this object to the
367367 /// Value that's being destroyed.
368 virtual void deleted() { setValPtr(NULL); }
368 virtual void deleted() { setValPtr(nullptr); }
369369
370370 /// Called when this->getValPtr()->replaceAllUsesWith(new_value) is called,
371371 /// _before_ any of the uses have actually been replaced. If WeakVH were
3737 /// If there are no errors, the function returns false. If an error is found,
3838 /// a message describing the error is written to OS (if non-null) and true is
3939 /// returned.
40 bool verifyFunction(const Function &F, raw_ostream *OS = 0);
40 bool verifyFunction(const Function &F, raw_ostream *OS = nullptr);
4141
4242 /// \brief Check a module for errors.
4343 ///
4444 /// If there are no errors, the function returns false. If an error is found,
4545 /// a message describing the error is written to OS (if non-null) and true is
4646 /// returned.
47 bool verifyModule(const Module &M, raw_ostream *OS = 0);
47 bool verifyModule(const Module &M, raw_ostream *OS = nullptr);
4848
4949 /// \brief Create a verifier pass.
5050 ///
8686 Pass(const Pass &) LLVM_DELETED_FUNCTION;
8787
8888 public:
89 explicit Pass(PassKind K, char &pid) : Resolver(0), PassID(&pid), Kind(K) { }
89 explicit Pass(PassKind K, char &pid)
90 : Resolver(nullptr), PassID(&pid), Kind(K) { }
9091 virtual ~Pass();
9192
9293
128128
129129 // Find pass that is implementing PI.
130130 Pass *findImplPass(AnalysisID PI) {
131 Pass *ResultPass = 0;
131 Pass *ResultPass = nullptr;
132132 for (unsigned i = 0; i < AnalysisImpls.size() ; ++i) {
133133 if (AnalysisImpls[i].first == PI) {
134134 ResultPass = AnalysisImpls[i].second;
181181 const void *PI = &AnalysisType::ID;
182182
183183 Pass *ResultPass = Resolver->getAnalysisIfAvailable(PI, true);
184 if (ResultPass == 0) return 0;
184 if (!ResultPass) return 0;
185185
186186 // Because the AnalysisType may not be a subclass of pass (for
187187 // AnalysisGroups), we use getAdjustedAnalysisPointer here to potentially
3636 void *getImpl() const;
3737
3838 public:
39 PassRegistry() : pImpl(0) { }
39 PassRegistry() : pImpl(nullptr) { }
4040 ~PassRegistry();
4141
4242 /// getPassRegistry - Access the global registry object, which is
5858 /// through RegisterPass.
5959 PassInfo(const char *name, const char *arg, const void *pi,
6060 NormalCtor_t normal, bool isCFGOnly, bool is_analysis,
61 TargetMachineCtor_t machine = NULL)
61 TargetMachineCtor_t machine = nullptr)
6262 : PassName(name), PassArgument(arg), PassID(pi),
6363 IsCFGOnlyPass(isCFGOnly),
6464 IsAnalysis(is_analysis), IsAnalysisGroup(false), NormalCtor(normal),
6969 PassInfo(const char *name, const void *pi)
7070 : PassName(name), PassArgument(""), PassID(pi),
7171 IsCFGOnlyPass(false),
72 IsAnalysis(false), IsAnalysisGroup(true), NormalCtor(0),
73 TargetMachineCtor(0) {}
72 IsAnalysis(false), IsAnalysisGroup(true), NormalCtor(nullptr),
73 TargetMachineCtor(nullptr) {}
7474
7575 /// getPassName - Return the friendly name for the pass, never returns null
7676 ///
255255 public:
256256 RegisterAGBase(const char *Name,
257257 const void *InterfaceID,
258 const void *PassID = 0,
258 const void *PassID = nullptr,
259259 bool isDefault = false);
260260 };
261261
244244 template
245245 LLVM_ATTRIBUTE_UNUSED_RESULT inline typename cast_retty::ret_type
246246 cast_or_null(Y *Val) {
247 if (Val == 0) return 0;
247 if (!Val) return nullptr;
248248 assert(isa(Val) && "cast_or_null() argument of incompatible type!");
249249 return cast(Val);
250250 }
262262 LLVM_ATTRIBUTE_UNUSED_RESULT inline typename std::enable_if<
263263 !is_simple_type::value, typename cast_retty::ret_type>::type
264264 dyn_cast(const Y &Val) {
265 return isa(Val) ? cast(Val) : 0;
265 return isa(Val) ? cast(Val) : nullptr;
266266 }
267267
268268 template
269269 LLVM_ATTRIBUTE_UNUSED_RESULT inline typename cast_retty::ret_type
270270 dyn_cast(Y &Val) {
271 return isa(Val) ? cast(Val) : 0;
271 return isa(Val) ? cast(Val) : nullptr;
272272 }
273273
274274 template
185185 assert(isReachableFromEntry(A));
186186
187187 const DomTreeNodeBase *IDom;
188 while ((IDom = B->getIDom()) != 0 && IDom != A && IDom != B)
188 while ((IDom = B->getIDom()) != nullptr && IDom != A && IDom != B)
189189 B = IDom; // Walk up the tree
190 return IDom != 0;
190 return IDom != nullptr;
191191 }
192192
193193 protected:
204204 unsigned Semi;
205205 NodeT *Label;
206206
207 InfoRec() : DFSNum(0), Parent(0), Semi(0), Label(0) {}
207 InfoRec() : DFSNum(0), Parent(0), Semi(0), Label(nullptr) {}
208208 };
209209
210210 DenseMap IDoms;
223223 IDoms.clear();
224224 this->Roots.clear();
225225 Vertex.clear();
226 RootNode = 0;
226 RootNode = nullptr;
227227 }
228228
229229 // NewBB is split and now it has one successor. Update dominator tree to
259259
260260 // Find NewBB's immediate dominator and create new dominator tree node for
261261 // NewBB.
262 NodeT *NewBBIDom = 0;
262 NodeT *NewBBIDom = nullptr;
263263 unsigned i = 0;
264264 for (i = 0; i < PredBlocks.size(); ++i)
265265 if (DT.isReachableFromEntry(PredBlocks[i])) {
343343 void getDescendants(NodeT *R, SmallVectorImpl &Result) const {
344344 Result.clear();
345345 const DomTreeNodeBase *RN = getNode(R);
346 if (RN == NULL)
346 if (!RN)
347347 return; // If R is unreachable, it will not be present in the DOM tree.
348348 SmallVector *, 8> WL;
349349 WL.push_back(RN);
360360 ///
361361 bool properlyDominates(const DomTreeNodeBase *A,
362362 const DomTreeNodeBase *B) const {
363 if (A == 0 || B == 0)
363 if (!A || !B)
364364 return false;
365365 if (A == B)
366366 return false;
470470 IDomB = IDomB->getIDom();
471471 }
472472
473 return NULL;
473 return nullptr;
474474 }
475475
476476 const NodeT *findNearestCommonDominator(const NodeT *A, const NodeT *B) {
658658 void recalculate(FT& F) {
659659 typedef GraphTraits TraitsTy;
660660 reset();
661 this->Vertex.push_back(0);
661 this->Vertex.push_back(nullptr);
662662
663663 if (!this->IsPostDominators) {
664664 // Initialize root
665665 NodeT *entry = TraitsTy::getEntryNode(&F);
666666 this->Roots.push_back(entry);
667 this->IDoms[entry] = 0;
668 this->DomTreeNodes[entry] = 0;
667 this->IDoms[entry] = nullptr;
668 this->DomTreeNodes[entry] = nullptr;
669669
670670 Calculate(*this, F);
671671 } else {
676676 addRoot(I);
677677
678678 // Prepopulate maps so that we don't get iterator invalidation issues later.
679 this->IDoms[I] = 0;
680 this->DomTreeNodes[I] = 0;
679 this->IDoms[I] = nullptr;
680 this->DomTreeNodes[I] = nullptr;
681681 }
682682
683683 Calculate >(*this, F);
155155 bool MultipleRoots = (DT.Roots.size() > 1);
156156 if (MultipleRoots) {
157157 typename DominatorTreeBase::InfoRec &BBInfo =
158 DT.Info[NULL];
158 DT.Info[nullptr];
159159 BBInfo.DFSNum = BBInfo.Semi = ++N;
160 BBInfo.Label = NULL;
161
162 DT.Vertex.push_back(NULL); // Vertex[n] = V;
160 BBInfo.Label = nullptr;
161
162 DT.Vertex.push_back(nullptr); // Vertex[n] = V;
163163 }
164164
165165 // Step #1: Number blocks in depth-first order and initialize variables used
248248 // one exit block, or it may be the virtual exit (denoted by (BasicBlock *)0)
249249 // which postdominates all real exits if there are multiple exit blocks, or
250250 // an infinite loop.
251 typename GraphT::NodeType* Root = !MultipleRoots ? DT.Roots[0] : 0;
251 typename GraphT::NodeType* Root = !MultipleRoots ? DT.Roots[0] : nullptr;
252252
253253 DT.DomTreeNodes[Root] = DT.RootNode =
254 new DomTreeNodeBase(Root, 0);
254 new DomTreeNodeBase(Root, nullptr);
255255
256256 // Loop over all of the reachable blocks in the function...
257257 for (unsigned i = 2; i <= N; ++i) {
5050
5151 static const Module *getModuleFromVal(const Value *V) {
5252 if (const Argument *MA = dyn_cast(V))
53 return MA->getParent() ? MA->getParent()->getParent() : 0;
53 return MA->getParent() ? MA->getParent()->getParent() : nullptr;
5454
5555 if (const BasicBlock *BB = dyn_cast(V))
56 return BB->getParent() ? BB->getParent()->getParent() : 0;
56 return BB->getParent() ? BB->getParent()->getParent() : nullptr;
5757
5858 if (const Instruction *I = dyn_cast(V)) {
59 const Function *M = I->getParent() ? I->getParent()->getParent() : 0;
60 return M ? M->getParent() : 0;
59 const Function *M = I->getParent() ? I->getParent()->getParent() : nullptr;
60 return M ? M->getParent() : nullptr;
6161 }
6262
6363 if (const GlobalValue *GV = dyn_cast(V))
6464 return GV->getParent();
65 return 0;
65 return nullptr;
6666 }
6767
6868 static void PrintCallingConv(unsigned cc, raw_ostream &Out) {
420420 if (!MD->isFunctionLocal())
421421 return new SlotTracker(MD->getFunction());
422422
423 return new SlotTracker((Function *)0);
424 }
425
426 return 0;
423 return new SlotTracker((Function *)nullptr);
424 }
425
426 return nullptr;
427427 }
428428
429429 #if 0
435435 // Module level constructor. Causes the contents of the Module (sans functions)
436436 // to be added to the slot table.
437437 SlotTracker::SlotTracker(const Module *M)
438 : TheModule(M), TheFunction(0), FunctionProcessed(false),
438 : TheModule(M), TheFunction(nullptr), FunctionProcessed(false),
439439 mNext(0), fNext(0), mdnNext(0), asNext(0) {
440440 }
441441
442442 // Function level constructor. Causes the contents of the Module and the one
443443 // function provided to be added to the slot table.
444444 SlotTracker::SlotTracker(const Function *F)
445 : TheModule(F ? F->getParent() : 0), TheFunction(F), FunctionProcessed(false),
446 mNext(0), fNext(0), mdnNext(0), asNext(0) {
445 : TheModule(F ? F->getParent() : nullptr), TheFunction(F),
446 FunctionProcessed(false), mNext(0), fNext(0), mdnNext(0), asNext(0) {
447447 }
448448
449449 inline void SlotTracker::initialize() {
450450 if (TheModule) {
451451 processModule();
452 TheModule = 0; ///< Prevent re-processing next time we're called.
452 TheModule = nullptr; ///< Prevent re-processing next time we're called.
453453 }
454454
455455 if (TheFunction && !FunctionProcessed)
559559 void SlotTracker::purgeFunction() {
560560 ST_DEBUG("begin purgeFunction!\n");
561561 fMap.clear(); // Simply discard the function level map
562 TheFunction = 0;
562 TheFunction = nullptr;
563563 FunctionProcessed = false;
564564 ST_DEBUG("end purgeFunction!\n");
565565 }
10471047 Out << "!{";
10481048 for (unsigned mi = 0, me = Node->getNumOperands(); mi != me; ++mi) {
10491049 const Value *V = Node->getOperand(mi);
1050 if (V == 0)
1050 if (!V)
10511051 Out << "null";
10521052 else {
10531053 TypePrinter->print(V->getType(), Out);
11591159 Slot = Machine->getLocalSlot(V);
11601160 }
11611161 delete Machine;
1162 Machine = 0;
1162 Machine = nullptr;
11631163 } else {
11641164 Slot = -1;
11651165 }
11931193 AssemblyWriter::~AssemblyWriter() { }
11941194
11951195 void AssemblyWriter::writeOperand(const Value *Operand, bool PrintType) {
1196 if (Operand == 0) {
1196 if (!Operand) {
11971197 Out << "";
11981198 return;
11991199 }
12581258
12591259 void AssemblyWriter::writeParamOperand(const Value *Operand,
12601260 AttributeSet Attrs, unsigned Idx) {
1261 if (Operand == 0) {
1261 if (!Operand) {
12621262 Out << "";
12631263 return;
12641264 }
15011501
15021502 const Constant *Aliasee = GA->getAliasee();
15031503
1504 if (Aliasee == 0) {
1504 if (!Aliasee) {
15051505 TypePrinter.print(GA->getType(), Out);
15061506 Out << " <>";
15071507 } else {
17061706 Out << "";
17071707 }
17081708
1709 if (BB->getParent() == 0) {
1709 if (!BB->getParent()) {
17101710 Out.PadToColumn(50);
17111711 Out << "; Error: Block without parent!";
17121712 } else if (BB != &BB->getParent()->getEntryBlock()) { // Not the entry block?
18031803 writeAtomicRMWOperation(Out, RMWI->getOperation());
18041804
18051805 // Print out the type of the operands...
1806 const Value *Operand = I.getNumOperands() ? I.getOperand(0) : 0;
1806 const Value *Operand = I.getNumOperands() ? I.getOperand(0) : nullptr;
18071807
18081808 // Special case conditional branches to swizzle the condition out to the front
18091809 if (isa(I) && cast(I).isConditional()) {
21542154 }
21552155
21562156 void Type::print(raw_ostream &OS) const {
2157 if (this == 0) {
2157 if (!this) {
21582158 OS << "";
21592159 return;
21602160 }
22192219 if (!PrintType &&
22202220 ((!isa(this) && !isa(this)) ||
22212221 hasName() || isa(this))) {
2222 WriteAsOperandInternal(O, this, 0, 0, M);
2222 WriteAsOperandInternal(O, this, nullptr, nullptr, M);
22232223 return;
22242224 }
22252225
22342234 O << ' ';
22352235 }
22362236
2237 WriteAsOperandInternal(O, this, &TypePrinter, 0, M);
2237 WriteAsOperandInternal(O, this, &TypePrinter, nullptr, M);
22382238 }
22392239
22402240 // Value::printCustom - subclasses should override this to implement printing.
22492249 void Type::dump() const { print(dbgs()); }
22502250
22512251 // Module::dump() - Allow printing of Modules from the debugger.
2252 void Module::dump() const { print(dbgs(), 0); }
2252 void Module::dump() const { print(dbgs(), nullptr); }
22532253
22542254 // NamedMDNode::dump() - Allow printing of NamedMDNodes from the debugger.
2255 void NamedMDNode::dump() const { print(dbgs(), 0); }
2255 void NamedMDNode::dump() const { print(dbgs(), nullptr); }
401401 AttributeSetNode *AttributeSetNode::get(LLVMContext &C,
402402 ArrayRef Attrs) {
403403 if (Attrs.empty())
404 return 0;
404 return nullptr;
405405
406406 // Otherwise, build a key to look up the existing attributes.
407407 LLVMContextImpl *pImpl = C.pImpl;
835835 /// \brief Return true if the specified attribute is set for at least one
836836 /// parameter or for the return value.
837837 bool AttributeSet::hasAttrSomewhere(Attribute::AttrKind Attr) const {
838 if (pImpl == 0) return false;
838 if (!pImpl) return false;
839839
840840 for (unsigned I = 0, E = pImpl->getNumAttributes(); I != E; ++I)
841841 for (AttributeSetImpl::iterator II = pImpl->begin(I),
876876
877877 /// \brief The attributes for the specified index are returned.
878878 AttributeSetNode *AttributeSet::getAttributes(unsigned Index) const {
879 if (!pImpl) return 0;
879 if (!pImpl) return nullptr;
880880
881881 // Loop through to find the attribute node we want.
882882 for (unsigned I = 0, E = pImpl->getNumAttributes(); I != E; ++I)
883883 if (pImpl->getSlotIndex(I) == Index)
884884 return pImpl->getSlotNode(I);
885885
886 return 0;
886 return nullptr;
887887 }
888888
889889 AttributeSet::iterator AttributeSet::begin(unsigned Slot) const {
114114 Name == "x86.avx.movnt.ps.256" ||
115115 Name == "x86.sse42.crc32.64.8" ||
116116 (Name.startswith("x86.xop.vpcom") && F->arg_size() == 2)) {
117 NewFn = 0;
117 NewFn = nullptr;
118118 return true;
119119 }
120120 // SSE4.1 ptest functions may have an old signature.
157157 }
158158
159159 bool llvm::UpgradeIntrinsicFunction(Function *F, Function *&NewFn) {
160 NewFn = 0;
160 NewFn = nullptr;
161161 bool Upgraded = UpgradeIntrinsicFunction1(F, NewFn);
162162
163163 // Upgrade intrinsic attributes. This does not change the function.
452452 Instruction *llvm::UpgradeBitCastInst(unsigned Opc, Value *V, Type *DestTy,
453453 Instruction *&Temp) {
454454 if (Opc != Instruction::BitCast)
455 return 0;
456
457 Temp = 0;
455 return nullptr;
456
457 Temp = nullptr;
458458 Type *SrcTy = V->getType();
459459 if (SrcTy->isPtrOrPtrVectorTy() && DestTy->isPtrOrPtrVectorTy() &&
460460 SrcTy->getPointerAddressSpace() != DestTy->getPointerAddressSpace()) {
468468 return CastInst::Create(Instruction::IntToPtr, Temp, DestTy);
469469 }
470470
471 return 0;
471 return nullptr;
472472 }
473473
474474 Value *llvm::UpgradeBitCastExpr(unsigned Opc, Constant *C, Type *DestTy) {
475475 if (Opc != Instruction::BitCast)
476 return 0;
476 return nullptr;
477477
478478 Type *SrcTy = C->getType();
479479 if (SrcTy->isPtrOrPtrVectorTy() && DestTy->isPtrOrPtrVectorTy() &&
488488 DestTy);
489489 }
490490
491 return 0;
491 return nullptr;
492492 }
493493
494494 /// Check the debug info version number, if it is out-dated, drop the debug
2626 ValueSymbolTable *BasicBlock::getValueSymbolTable() {
2727 if (Function *F = getParent())
2828 return &F->getValueSymbolTable();
29 return 0;
29 return nullptr;
3030 }
3131
3232 const DataLayout *BasicBlock::getDataLayout() const {
4444
4545 BasicBlock::BasicBlock(LLVMContext &C, const Twine &Name, Function *NewParent,
4646 BasicBlock *InsertBefore)
47 : Value(Type::getLabelTy(C), Value::BasicBlockVal), Parent(0) {
47 : Value(Type::getLabelTy(C), Value::BasicBlockVal), Parent(nullptr) {
4848
4949 // Make sure that we get added to a function
5050 LeakDetector::addGarbageObject(this);
121121
122122
123123 TerminatorInst *BasicBlock::getTerminator() {
124 if (InstList.empty()) return 0;
124 if (InstList.empty()) return nullptr;
125125 return dyn_cast(&InstList.back());
126126 }
127127
128128 const TerminatorInst *BasicBlock::getTerminator() const {
129 if (InstList.empty()) return 0;
129 if (InstList.empty()) return nullptr;
130130 return dyn_cast(&InstList.back());
131131 }
132132
185185 /// return the block, otherwise return a null pointer.
186186 BasicBlock *BasicBlock::getSinglePredecessor() {
187187 pred_iterator PI = pred_begin(this), E = pred_end(this);
188 if (PI == E) return 0; // No preds.
188 if (PI == E) return nullptr; // No preds.
189189 BasicBlock *ThePred = *PI;
190190 ++PI;
191 return (PI == E) ? ThePred : 0 /*multiple preds*/;
191 return (PI == E) ? ThePred : nullptr /*multiple preds*/;
192192 }
193193
194194 /// getUniquePredecessor - If this basic block has a unique predecessor block,
198198 /// a switch statement with multiple cases having the same destination).
199199 BasicBlock *BasicBlock::getUniquePredecessor() {
200200 pred_iterator PI = pred_begin(this), E = pred_end(this);
201 if (PI == E) return 0; // No preds.
201 if (PI == E) return nullptr; // No preds.
202202 BasicBlock *PredBB = *PI;
203203 ++PI;
204204 for (;PI != E; ++PI) {
205205 if (*PI != PredBB)
206 return 0;
206 return nullptr;
207207 // The same predecessor appears multiple times in the predecessor list.
208208 // This is OK.
209209 }
276276 PN->removeIncomingValue(Pred, false);
277277 // If all incoming values to the Phi are the same, we can replace the Phi
278278 // with that value.
279 Value* PNV = 0;
279 Value* PNV = nullptr;
280280 if (!DontDeleteUselessPHIs && (PNV = PN->hasConstantValue()))
281281 if (PNV != PN) {
282282 PN->replaceAllUsesWith(PNV);
5050 // Analysis/ConstantFolding.cpp
5151 unsigned NumElts = DstTy->getNumElements();
5252 if (NumElts != CV->getType()->getVectorNumElements())
53 return 0;
53 return nullptr;
5454
5555 Type *DstEltTy = DstTy->getElementType();
5656
9393
9494 // Let CastInst::isEliminableCastPair do the heavy lifting.
9595 return CastInst::isEliminableCastPair(firstOp, secondOp, SrcTy, MidTy, DstTy,
96 0, FakeIntPtrTy, 0);
96 nullptr, FakeIntPtrTy, nullptr);
9797 }
9898
9999 static Constant *FoldBitCast(Constant *V, Type *DestTy) {
138138 if (VectorType *SrcTy = dyn_cast(V->getType())) {
139139 assert(DestPTy->getBitWidth() == SrcTy->getBitWidth() &&
140140 "Not cast between same sized vectors!");
141 SrcTy = NULL;
141 SrcTy = nullptr;
142142 // First, check for null. Undef is already handled.
143143 if (isa(V))
144144 return Constant::getNullValue(DestTy);
172172 CI->getValue()));
173173
174174 // Otherwise, can't fold this (vector?)
175 return 0;
175 return nullptr;
176176 }
177177
178178 // Handle ConstantFP input: FP -> Integral.
180180 return ConstantInt::get(FP->getContext(),
181181 FP->getValueAPF().bitcastToAPInt());
182182
183 return 0;
183 return nullptr;
184184 }
185185
186186
215215 // In the input is a constant expr, we might be able to recursively simplify.
216216 // If not, we definitely can't do anything.
217217 ConstantExpr *CE = dyn_cast(C);
218 if (CE == 0) return 0;
219
218 if (!CE) return nullptr;
219
220220 switch (CE->getOpcode()) {
221 default: return 0;
221 default: return nullptr;
222222 case Instruction::Or: {
223223 Constant *RHS = ExtractConstantBytes(CE->getOperand(1), ByteStart,ByteSize);
224 if (RHS == 0)
225 return 0;
224 if (!RHS)
225 return nullptr;
226226
227227 // X | -1 -> -1.
228228 if (ConstantInt *RHSC = dyn_cast(RHS))
230230 return RHSC;
231231
232232 Constant *LHS = ExtractConstantBytes(CE->getOperand(0), ByteStart,ByteSize);
233 if (LHS == 0)
234 return 0;
233 if (!LHS)
234 return nullptr;
235235 return ConstantExpr::getOr(LHS, RHS);
236236 }
237237 case Instruction::And: {
238238 Constant *RHS = ExtractConstantBytes(CE->getOperand(1), ByteStart,ByteSize);
239 if (RHS == 0)
240 return 0;
239 if (!RHS)
240 return nullptr;
241241
242242 // X & 0 -> 0.
243243 if (RHS->isNullValue())
244244 return RHS;
245245
246246 Constant *LHS = ExtractConstantBytes(CE->getOperand(0), ByteStart,ByteSize);
247 if (LHS == 0)
248 return 0;
247 if (!LHS)
248 return nullptr;
249249 return ConstantExpr::getAnd(LHS, RHS);
250250 }
251251 case Instruction::LShr: {
252252 ConstantInt *Amt = dyn_cast(CE->getOperand(1));
253 if (Amt == 0)
254 return 0;
253 if (!Amt)
254 return nullptr;
255255 unsigned ShAmt = Amt->getZExtValue();
256256 // Cannot analyze non-byte shifts.
257257 if ((ShAmt & 7) != 0)
258 return 0;
258 return nullptr;
259259 ShAmt >>= 3;
260260
261261 // If the extract is known to be all zeros, return zero.
267267 return ExtractConstantBytes(CE->getOperand(0), ByteStart+ShAmt, ByteSize);
268268
269269 // TODO: Handle the 'partially zero' case.
270 return 0;
270 return nullptr;
271271 }
272272
273273 case Instruction::Shl: {
274274 ConstantInt *Amt = dyn_cast(CE->getOperand(1));
275 if (Amt == 0)
276 return 0;
275 if (!Amt)
276 return nullptr;
277277 unsigned ShAmt = Amt->getZExtValue();
278278 // Cannot analyze non-byte shifts.
279279 if ((ShAmt & 7) != 0)
280 return 0;
280 return nullptr;
281281 ShAmt >>= 3;
282282
283283 // If the extract is known to be all zeros, return zero.
289289 return ExtractConstantBytes(CE->getOperand(0), ByteStart-ShAmt, ByteSize);
290290
291291 // TODO: Handle the 'partially zero' case.
292 return 0;
292 return nullptr;
293293 }
294294
295295 case Instruction::ZExt: {
323323 }
324324
325325 // TODO: Handle the 'partially zero' case.
326 return 0;
326 return nullptr;
327327 }
328328 }
329329 }
375375 // If there's no interesting folding happening, bail so that we don't create
376376 // a constant that looks like it needs folding but really doesn't.
377377 if (!Folded)
378 return 0;
378 return nullptr;
379379
380380 // Base case: Get a regular sizeof expression.
381381 Constant *C = ConstantExpr::getSizeOf(Ty);
441441 // If there's no interesting folding happening, bail so that we don't create
442442 // a constant that looks like it needs folding but really doesn't.
443443 if (!Folded)
444 return 0;
444 return nullptr;
445445
446446 // Base case: Get a regular alignof expression.
447447 Constant *C = ConstantExpr::getAlignOf(Ty);
472472 unsigned NumElems = STy->getNumElements();
473473 // An empty struct has no members.
474474 if (NumElems == 0)
475 return 0;
475 return nullptr;
476476 // Check for a struct with all members having the same size.
477477 Constant *MemberSize =
478478 getFoldedSizeOf(STy->getElementType(0), DestTy, true);
496496 // If there's no interesting folding happening, bail so that we don't create
497497 // a constant that looks like it needs folding but really doesn't.
498498 if (!Folded)
499 return 0;
499 return nullptr;
500500
501501 // Base case: Get a regular offsetof expression.
502502 Constant *C = ConstantExpr::getOffsetOf(Ty, FieldNo);
581581 APFloat::rmNearestTiesToEven, &ignored);
582582 return ConstantFP::get(V->getContext(), Val);
583583 }
584 return 0; // Can't fold.
584 return nullptr; // Can't fold.
585585 case Instruction::FPToUI:
586586 case Instruction::FPToSI:
587587 if (ConstantFP *FPC = dyn_cast(V)) {
594594 APInt Val(DestBitWidth, x);
595595 return ConstantInt::get(FPC->getContext(), Val);
596596 }
597 return 0; // Can't fold.
597 return nullptr; // Can't fold.
598598 case Instruction::IntToPtr: //always treated as unsigned
599599 if (V->isNullValue()) // Is it an integral null value?
600600 return ConstantPointerNull::get(cast(DestTy));
601 return 0; // Other pointer types cannot be casted
601 return nullptr; // Other pointer types cannot be casted
602602 case Instruction::PtrToInt: // always treated as unsigned
603603 // Is it a null pointer value?
604604 if (V->isNullValue())
642642 }
643643 }
644644 // Other pointer types cannot be casted
645 return 0;
645 return nullptr;
646646 case Instruction::UIToFP:
647647 case Instruction::SIToFP:
648648 if (ConstantInt *CI = dyn_cast(V)) {
654654 APFloat::rmNearestTiesToEven);
655655 return ConstantFP::get(V->getContext(), apf);
656656 }
657 return 0;
657 return nullptr;
658658 case Instruction::ZExt:
659659 if (ConstantInt *CI = dyn_cast(V)) {
660660 uint32_t BitWidth = cast(DestTy)->getBitWidth();
661661 return ConstantInt::get(V->getContext(),
662662 CI->getValue().zext(BitWidth));
663663 }
664 return 0;
664 return nullptr;
665665 case Instruction::SExt:
666666 if (ConstantInt *CI = dyn_cast(V)) {
667667 uint32_t BitWidth = cast(DestTy)->getBitWidth();
668668 return ConstantInt::get(V->getContext(),
669669 CI->getValue().sext(BitWidth));
670670 }
671 return 0;
671 return nullptr;
672672 case Instruction::Trunc: {
673673 uint32_t DestBitWidth = cast(DestTy)->getBitWidth();
674674 if (ConstantInt *CI = dyn_cast(V)) {
684684 if (Constant *Res = ExtractConstantBytes(V, 0, DestBitWidth / 8))
685685 return Res;
686686
687 return 0;
687 return nullptr;
688688 }
689689 case Instruction::BitCast:
690690 return FoldBitCast(V, DestTy);
691691 case Instruction::AddrSpaceCast:
692 return 0;
692 return nullptr;
693693 }
694694 }
695695
745745 return ConstantExpr::getSelect(Cond, V1, FalseVal->getOperand(2));
746746 }
747747
748 return 0;
748 return nullptr;
749749 }
750750
751751 Constant *llvm::ConstantFoldExtractElementInstruction(Constant *Val,
765765 return UndefValue::get(Val->getType()->getVectorElementType());
766766 return Val->getAggregateElement(Index);
767767 }
768 return 0;
768 return nullptr;
769769 }
770770
771771 Constant *llvm::ConstantFoldInsertElementInstruction(Constant *Val,
772772 Constant *Elt,
773773 Constant *Idx) {
774774 ConstantInt *CIdx = dyn_cast(Idx);
775 if (!CIdx) return 0;
775 if (!CIdx) return nullptr;
776776 const APInt &IdxVal = CIdx->getValue();
777777
778778 SmallVector Result;
802802 return UndefValue::get(VectorType::get(EltTy, MaskNumElts));
803803
804804 // Don't break the bitcode reader hack.
805 if (isa(Mask)) return 0;
805 if (isa(Mask)) return nullptr;
806806
807807 unsigned SrcNumElts = V1->getType()->getVectorNumElements();
808808
841841 if (Constant *C = Agg->getAggregateElement(Idxs[0]))
842842 return ConstantFoldExtractValueInstruction(C, Idxs.slice(1));
843843
844 return 0;
844 return nullptr;
845845 }
846846
847847 Constant *llvm::ConstantFoldInsertValueInstruction(Constant *Agg,
862862 SmallVector Result;
863863 for (unsigned i = 0; i != NumElts; ++i) {
864864 Constant *C = Agg->getAggregateElement(i);
865 if (C == 0) return 0;
866
865 if (!C) return nullptr;
866
867867 if (Idxs[0] == i)
868868 C = ConstantFoldInsertValueInstruction(C, Val, Idxs.slice(1));
869869
12081208 }
12091209
12101210 // We don't know how to fold this.
1211 return 0;
1211 return nullptr;
12121212 }
12131213
12141214 /// isZeroSizedType - This type is zero sized if its an array or structure of
12881288 if (!isa(V1)) {
12891289 if (!isa(V2)) {
12901290 // We distilled thisUse the standard constant folder for a few cases
1291 ConstantInt *R = 0;
1291 ConstantInt *R = nullptr;
12921292 R = dyn_cast(
12931293 ConstantExpr::getFCmp(FCmpInst::FCMP_OEQ, V1, V2));
12941294 if (R && !R->isZero())
13541354 !isa(V2)) {
13551355 // We distilled this down to a simple case, use the standard constant
13561356 // folder.
1357 ConstantInt *R = 0;
1357 ConstantInt *R = nullptr;
13581358 ICmpInst::Predicate pred = ICmpInst::ICMP_EQ;
13591359 R = dyn_cast(ConstantExpr::getICmp(pred, V1, V2));
13601360 if (R && !R->isZero())
18841884 return ConstantExpr::getICmp(pred, C2, C1);
18851885 }
18861886 }
1887 return 0;
1887 return nullptr;
18881888 }
18891889
18901890 /// isInBoundsIndices - Test whether the given sequence of *normalized* indices
19761976 // getelementptr instructions into a single instruction.
19771977 //
19781978 if (CE->getOpcode() == Instruction::GetElementPtr) {
1979 Type *LastTy = 0;
1979 Type *LastTy = nullptr;
19801980 for (gep_type_iterator I = gep_type_begin(CE), E = gep_type_end(CE);
19811981 I != E; ++I)
19821982 LastTy = *I;
20712071 bool Unknown = false;
20722072 SmallVector NewIdxs;
20732073 Type *Ty = C->getType();
2074 Type *Prev = 0;
2074 Type *Prev = nullptr;
20752075 for (unsigned i = 0, e = Idxs.size(); i != e;
20762076 Prev = Ty, Ty = cast(Ty)->getTypeAtIndex(Idxs[i]), ++i) {
20772077 if (ConstantInt *CI = dyn_cast(Idxs[i])) {
21292129 isa(C) && isInBoundsIndices(Idxs))
21302130 return ConstantExpr::getInBoundsGetElementPtr(C, Idxs);
21312131
2132 return 0;
2132 return nullptr;
21332133 }
21342134
21352135 Constant *llvm::ConstantFoldGetElementPtr(Constant *C,
181181 /// 'this' is a constant expr.
182182 Constant *Constant::getAggregateElement(unsigned Elt) const {
183183 if (const ConstantStruct *CS = dyn_cast(this))
184 return Elt < CS->getNumOperands() ? CS->getOperand(Elt) : 0;
184 return Elt < CS->getNumOperands() ? CS->getOperand(Elt) : nullptr;
185185
186186 if (const ConstantArray *CA = dyn_cast(this))
187 return Elt < CA->getNumOperands() ? CA->getOperand(Elt) : 0;
187 return Elt < CA->getNumOperands() ? CA->getOperand(Elt) : nullptr;
188188
189189 if (const ConstantVector *CV = dyn_cast(this))
190 return Elt < CV->getNumOperands() ? CV->getOperand(Elt) : 0;
190 return Elt < CV->getNumOperands() ? CV->getOperand(Elt) : nullptr;
191191
192192 if (const ConstantAggregateZero *CAZ =dyn_cast(this))
193193 return CAZ->getElementValue(Elt);
196196 return UV->getElementValue(Elt);
197197
198198 if (const ConstantDataSequential *CDS =dyn_cast(this))
199 return Elt < CDS->getNumElements() ? CDS->getElementAsConstant(Elt) : 0;
200 return 0;
199 return Elt < CDS->getNumElements() ? CDS->getElementAsConstant(Elt)
200 : nullptr;
201 return nullptr;
201202 }
202203
203204 Constant *Constant::getAggregateElement(Constant *Elt) const {
204205 assert(isa(Elt->getType()) && "Index must be an integer");
205206 if (ConstantInt *CI = dyn_cast(Elt))
206207 return getAggregateElement(CI->getZExtValue());
207 return 0;
208 return nullptr;
208209 }
209210
210211
308309 bool Constant::isConstantUsed() const {
309310 for (const User *U : users()) {
310311 const Constant *UC = dyn_cast(U);
311 if (UC == 0 || isa(UC))
312 if (!UC || isa(UC))
312313 return true;
313314
314315 if (UC->isConstantUsed())
396397 Value::const_user_iterator LastNonDeadUser = E;
397398 while (I != E) {
398399 const Constant *User = dyn_cast(*I);
399 if (User == 0) {
400 if (!User) {
400401 LastNonDeadUser = I;
401402 ++I;
402403 continue;
430431 void ConstantInt::anchor() { }
431432
432433 ConstantInt::ConstantInt(IntegerType *Ty, const APInt& V)
433 : Constant(Ty, ConstantIntVal, 0, 0), Val(V) {
434 : Constant(Ty, ConstantIntVal, nullptr, 0), Val(V) {
434435 assert(V.getBitWidth() == Ty->getBitWidth() && "Invalid constant for type");
435436 }
436437
643644 }
644645
645646 ConstantFP::ConstantFP(Type *Ty, const APFloat& V)
646 : Constant(Ty, ConstantFPVal, 0, 0), Val(V) {
647 : Constant(Ty, ConstantFPVal, nullptr, 0), Val(V) {
647648 assert(&V.getSemantics() == TypeToFloatSemantics(Ty) &&
648649 "FP type Mismatch");
649650 }
12341235 "Cannot create an aggregate zero of non-aggregate type!");
12351236
12361237 ConstantAggregateZero *&Entry = Ty->getContext().pImpl->CAZConstants[Ty];