llvm.org GIT mirror llvm / 0b6cb71
[C++11] More 'nullptr' conversion. In some cases just using a boolean check instead of comparing to nullptr. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206252 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 5 years ago
73 changed file(s) with 466 addition(s) and 461 deletion(s). Raw diff Collapse all Expand all
110110 i != e; ++i)
111111 if (BlockInfoRecords[i].BlockID == BlockID)
112112 return &BlockInfoRecords[i];
113 return 0;
113 return nullptr;
114114 }
115115
116116 BlockInfo &getOrCreateBlockInfo(unsigned BlockID) {
199199
200200
201201 public:
202 BitstreamCursor() : BitStream(0), NextChar(0) {
203 }
204 BitstreamCursor(const BitstreamCursor &RHS) : BitStream(0), NextChar(0) {
202 BitstreamCursor() : BitStream(nullptr), NextChar(0) {}
203 BitstreamCursor(const BitstreamCursor &RHS)
204 : BitStream(nullptr), NextChar(0) {
205205 operator=(RHS);
206206 }
207207
489489
490490 /// EnterSubBlock - Having read the ENTER_SUBBLOCK abbrevid, enter
491491 /// the block, and return true if the block has an error.
492 bool EnterSubBlock(unsigned BlockID, unsigned *NumWordsP = 0);
492 bool EnterSubBlock(unsigned BlockID, unsigned *NumWordsP = nullptr);
493493
494494 bool ReadBlockEnd() {
495495 if (BlockScope.empty()) return true;
540540 void skipRecord(unsigned AbbrevID);
541541
542542 unsigned readRecord(unsigned AbbrevID, SmallVectorImpl &Vals,
543 StringRef *Blob = 0);
543 StringRef *Blob = nullptr);
544544
545545 //===--------------------------------------------------------------------===//
546546 // Abbrev Processing
203203 i != e; ++i)
204204 if (BlockInfoRecords[i].BlockID == BlockID)
205205 return &BlockInfoRecords[i];
206 return 0;
206 return nullptr;
207207 }
208208
209209 void EnterSubblock(unsigned BlockID, unsigned CodeLen) {
346346 EmitAbbreviatedField(EltEnc, (unsigned char)BlobData[i]);
347347
348348 // Know that blob data is consumed for assertion below.
349 BlobData = 0;
349 BlobData = nullptr;
350350 } else {
351351 // Emit a vbr6 to indicate the number of elements present.
352352 EmitVBR(static_cast(Vals.size()-RecordIdx), 6);
377377 WriteByte((unsigned char)BlobData[i]);
378378
379379 // Know that blob data is consumed for assertion below.
380 BlobData = 0;
380 BlobData = nullptr;
381381 } else {
382382 for (unsigned e = Vals.size(); RecordIdx != e; ++RecordIdx) {
383383 assert(isUInt<8>(Vals[RecordIdx]) &&
396396 }
397397 }
398398 assert(RecordIdx == Vals.size() && "Not all record operands emitted!");
399 assert(BlobData == 0 &&
399 assert(BlobData == nullptr &&
400400 "Blob data specified for record that doesn't use it!");
401401 }
402402
152152 /// register is a PHI destination and the PHI's LiveOutInfo is not valid.
153153 const LiveOutInfo *GetLiveOutRegInfo(unsigned Reg) {
154154 if (!LiveOutRegInfo.inBounds(Reg))
155 return NULL;
155 return nullptr;
156156
157157 const LiveOutInfo *LOI = &LiveOutRegInfo[Reg];
158158 if (!LOI->IsValid)
159 return NULL;
159 return nullptr;
160160
161161 return LOI;
162162 }
9191 void updateNode(const SUnit *SU) override {}
9292
9393 void releaseState() override {
94 SUnits = 0;
94 SUnits = nullptr;
9595 }
9696
9797 unsigned getLatency(unsigned NodeNum) const {
577577 Ops.push_back(Op2);
578578 Ops.push_back(InGlue);
579579 return getNode(ISD::CALLSEQ_END, DL, NodeTys, &Ops[0],
580 (unsigned)Ops.size() - (InGlue.getNode() == 0 ? 1 : 0));
580 (unsigned)Ops.size() - (InGlue.getNode()==nullptr ? 1 : 0));
581581 }
582582
583583 /// getUNDEF - Return an UNDEF node. UNDEF does not have a useful SDLoc.
765765 SDValue getLoad(EVT VT, SDLoc dl, SDValue Chain, SDValue Ptr,
766766 MachinePointerInfo PtrInfo, bool isVolatile,
767767 bool isNonTemporal, bool isInvariant, unsigned Alignment,
768 const MDNode *TBAAInfo = 0, const MDNode *Ranges = 0);
768 const MDNode *TBAAInfo = nullptr,
769 const MDNode *Ranges = nullptr);
769770 SDValue getLoad(EVT VT, SDLoc dl, SDValue Chain, SDValue Ptr,
770771 MachineMemOperand *MMO);
771772 SDValue getExtLoad(ISD::LoadExtType ExtType, SDLoc dl, EVT VT,
772773 SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo,
773774 EVT MemVT, bool isVolatile,
774775 bool isNonTemporal, unsigned Alignment,
775 const MDNode *TBAAInfo = 0);
776 const MDNode *TBAAInfo = nullptr);
776777 SDValue getExtLoad(ISD::LoadExtType ExtType, SDLoc dl, EVT VT,
777778 SDValue Chain, SDValue Ptr, EVT MemVT,
778779 MachineMemOperand *MMO);
783784 SDValue Chain, SDValue Ptr, SDValue Offset,
784785 MachinePointerInfo PtrInfo, EVT MemVT,
785786 bool isVolatile, bool isNonTemporal, bool isInvariant,
786 unsigned Alignment, const MDNode *TBAAInfo = 0,
787 const MDNode *Ranges = 0);
787 unsigned Alignment, const MDNode *TBAAInfo = nullptr,
788 const MDNode *Ranges = nullptr);
788789 SDValue getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType,
789790 EVT VT, SDLoc dl,
790791 SDValue Chain, SDValue Ptr, SDValue Offset,
795796 SDValue getStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr,
796797 MachinePointerInfo PtrInfo, bool isVolatile,
797798 bool isNonTemporal, unsigned Alignment,
798 const MDNode *TBAAInfo = 0);
799 const MDNode *TBAAInfo = nullptr);
799800 SDValue getStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr,
800801 MachineMemOperand *MMO);
801802 SDValue getTruncStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr,
802803 MachinePointerInfo PtrInfo, EVT TVT,
803804 bool isNonTemporal, bool isVolatile,
804805 unsigned Alignment,
805 const MDNode *TBAAInfo = 0);
806 const MDNode *TBAAInfo = nullptr);
806807 SDValue getTruncStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr,
807808 EVT TVT, MachineMemOperand *MMO);
808809 SDValue getIndexedStore(SDValue OrigStoe, SDLoc dl, SDValue Base,
3535
3636 private:
3737 struct ValueType {
38 ValueType() : data(NULL) {
38 ValueType() : data(nullptr) {
3939 uval = 0;
4040 }
4141
5959 bool extractValue(DataExtractor data, uint32_t *offset_ptr,
6060 const DWARFUnit *u);
6161 bool isInlinedCStr() const {
62 return Value.data != NULL && Value.data == (const uint8_t*)Value.cstr;
62 return Value.data != nullptr && Value.data == (const uint8_t*)Value.cstr;
6363 }
6464
6565 /// getAsFoo functions below return the extracted value as Foo if only
180180 /// freeMachineCodeForFunction works.
181181 static ExecutionEngine *create(Module *M,
182182 bool ForceInterpreter = false,
183 std::string *ErrorStr = 0,
183 std::string *ErrorStr = nullptr,
184184 CodeGenOpt::Level OptLevel =
185185 CodeGenOpt::Default,
186186 bool GVsWithCode = true);
192192 /// Clients should make sure to initialize targets prior to calling this
193193 /// function.
194194 static ExecutionEngine *createJIT(Module *M,
195 std::string *ErrorStr = 0,
196 JITMemoryManager *JMM = 0,
195 std::string *ErrorStr = nullptr,
196 JITMemoryManager *JMM = nullptr,
197197 CodeGenOpt::Level OptLevel =
198198 CodeGenOpt::Default,
199199 bool GVsWithCode = true,
410410 }
411411
412412 // The JIT overrides a version that actually does this.
413 virtual void runJITOnFunction(Function *, MachineCodeInfo * = 0) { }
413 virtual void runJITOnFunction(Function *, MachineCodeInfo * = nullptr) { }
414414
415415 /// getGlobalValueAtAddress - Return the LLVM global value object that starts
416416 /// at the specified address.
477477 }
478478
479479 /// Return the target machine (if available).
480 virtual TargetMachine *getTargetMachine() { return NULL; }
480 virtual TargetMachine *getTargetMachine() { return nullptr; }
481481
482482 /// DisableLazyCompilation - When lazy compilation is off (the default), the
483483 /// JIT will eagerly compile every function reachable from the argument to
575575 /// InitEngine - Does the common initialization of default options.
576576 void InitEngine() {
577577 WhichEngine = EngineKind::Either;
578 ErrorStr = NULL;
578 ErrorStr = nullptr;
579579 OptLevel = CodeGenOpt::Default;
580 MCJMM = NULL;
581 JMM = NULL;
580 MCJMM = nullptr;
581 JMM = nullptr;
582582 Options = TargetOptions();
583583 AllocateGVsWithCode = false;
584584 RelocModel = Reloc::Default;
609609 /// the setJITMemoryManager() option.
610610 EngineBuilder &setMCJITMemoryManager(RTDyldMemoryManager *mcjmm) {
611611 MCJMM = mcjmm;
612 JMM = NULL;
612 JMM = nullptr;
613613 return *this;
614614 }
615615
621621 /// memory manager. This option defaults to NULL. This option overrides
622622 /// setMCJITMemoryManager() as well.
623623 EngineBuilder &setJITMemoryManager(JITMemoryManager *jmm) {
624 MCJMM = NULL;
624 MCJMM = nullptr;
625625 JMM = jmm;
626626 return *this;
627627 }
113113 /// operations needed to reliably use the memory are also performed.
114114 ///
115115 /// Returns true if an error occurred, false otherwise.
116 virtual bool finalizeMemory(std::string *ErrMsg = 0) = 0;
116 virtual bool finalizeMemory(std::string *ErrMsg = nullptr) = 0;
117117 };
118118
119119 // Create wrappers for C Binding types (see CBindingWrapping.h).
7272 if (findOption(P->getPassArgument()) != getNumOptions()) {
7373 errs() << "Two passes with the same argument (-"
7474 << P->getPassArgument() << ") attempted to be registered!\n";
75 llvm_unreachable(0);
75 llvm_unreachable(nullptr);
7676 }
7777 addLiteralOption(P->getPassArgument(), P, P->getPassName());
7878 }
128128 const char *getSymbolName(uint32_t index) {
129129 if (index < _symbols.size())
130130 return _symbols[index].name;
131 return NULL;
131 return nullptr;
132132 }
133133
134134 /// getDependentLibraryCount - Get the number of dependent libraries
140140 const char *getDependentLibrary(uint32_t index) {
141141 if (index < _deplibs.size())
142142 return _deplibs[index];
143 return NULL;
143 return nullptr;
144144 }
145145
146146 /// getLinkerOptCount - Get the number of linker options
152152 const char *getLinkerOpt(uint32_t index) {
153153 if (index < _linkeropts.size())
154154 return _linkeropts[index];
155 return NULL;
155 return nullptr;
156156 }
157157
158158 /// getLLVVMModule - Return the Module.
4141 AsmLexer(const MCAsmInfo &MAI);
4242 ~AsmLexer();
4343
44 void setBuffer(const MemoryBuffer *buf, const char *ptr = NULL);
44 void setBuffer(const MemoryBuffer *buf, const char *ptr = nullptr);
4545
4646 StringRef LexUntilEndOfStatement() override;
4747 StringRef LexUntilEndOfLine();
3838 unsigned Length, Size, Type;
3939
4040 void clear() {
41 OpDecl = 0;
41 OpDecl = nullptr;
4242 IsVarDecl = false;
4343 Length = 1;
4444 Size = 0;
6262
6363 SmallVectorImpl *AsmRewrites;
6464
65 ParseInstructionInfo() : AsmRewrites(0) {}
65 ParseInstructionInfo() : AsmRewrites(nullptr) {}
6666 ParseInstructionInfo(SmallVectorImpl *rewrites)
6767 : AsmRewrites(rewrites) {}
6868
178178 virtual const MCExpr *applyModifierToExpr(const MCExpr *E,
179179 MCSymbolRefExpr::VariantKind,
180180 MCContext &Ctx) {
181 return 0;
181 return nullptr;
182182 }
183183
184184 virtual void onLabelParsed(MCSymbol *Symbol) { };
9494 bool FullPath = false) const;
9595
9696 error_code getAsBinary(OwningPtr &Result,
97 LLVMContext *Context = 0) const;
97 LLVMContext *Context = nullptr) const;
9898 error_code getAsBinary(std::unique_ptr &Result,
99 LLVMContext *Context = 0) const;
99 LLVMContext *Context = nullptr) const;
100100 };
101101
102102 class child_iterator {
103103 Child child;
104104 public:
105 child_iterator() : child(Child(0, 0)) {}
105 child_iterator() : child(Child(nullptr, nullptr)) {}
106106 child_iterator(const Child &c) : child(c) {}
107107 const Child* operator->() const {
108108 return &child;
463463 // The iterator for the import directory table.
464464 class ImportDirectoryEntryRef {
465465 public:
466 ImportDirectoryEntryRef() : OwningObject(0) {}
466 ImportDirectoryEntryRef() : OwningObject(nullptr) {}
467467 ImportDirectoryEntryRef(const import_directory_table_entry *Table, uint32_t I,
468468 const COFFObjectFile *Owner)
469469 : ImportTable(Table), Index(I), OwningObject(Owner) {}
487487 // The iterator for the export directory table entry.
488488 class ExportDirectoryEntryRef {
489489 public:
490 ExportDirectoryEntryRef() : OwningObject(0) {}
490 ExportDirectoryEntryRef() : OwningObject(nullptr) {}
491491 ExportDirectoryEntryRef(const export_directory_table_entry *Table, uint32_t I,
492492 const COFFObjectFile *Owner)
493493 : ExportTable(Table), Index(I), OwningObject(Owner) {}
603603 template
604604 ELFFile::ELFFile(MemoryBuffer *Object, error_code &ec)
605605 : Buf(Object),
606 SectionHeaderTable(0),
607 dot_shstrtab_sec(0),
608 dot_strtab_sec(0),
609 dot_symtab_sec(0),
610 SymbolTableSectionHeaderIndex(0),
611 dot_gnu_version_sec(0),
612 dot_gnu_version_r_sec(0),
613 dot_gnu_version_d_sec(0),
606 SectionHeaderTable(nullptr),
607 dot_shstrtab_sec(nullptr),
608 dot_strtab_sec(nullptr),
609 dot_symtab_sec(nullptr),
610 SymbolTableSectionHeaderIndex(nullptr),
611 dot_gnu_version_sec(nullptr),
612 dot_gnu_version_r_sec(nullptr),
613 dot_gnu_version_d_sec(nullptr),
614614 dt_soname(nullptr) {
615615 const uint64_t FileSize = Buf->getBufferSize();
616616
678678 DynamicRegion.EntSize = SecI->sh_entsize;
679679 break;
680680 case ELF::SHT_GNU_versym:
681 if (dot_gnu_version_sec != NULL)
681 if (dot_gnu_version_sec != nullptr)
682682 // FIXME: Proper error handling.
683683 report_fatal_error("More than one .gnu.version section!");
684684 dot_gnu_version_sec = &*SecI;
685685 break;
686686 case ELF::SHT_GNU_verdef:
687 if (dot_gnu_version_d_sec != NULL)
687 if (dot_gnu_version_d_sec != nullptr)
688688 // FIXME: Proper error handling.
689689 report_fatal_error("More than one .gnu.version_d section!");
690690 dot_gnu_version_d_sec = &*SecI;
691691 break;
692692 case ELF::SHT_GNU_verneed:
693 if (dot_gnu_version_r_sec != NULL)
693 if (dot_gnu_version_r_sec != nullptr)
694694 // FIXME: Proper error handling.
695695 report_fatal_error("More than one .gnu.version_r section!");
696696 dot_gnu_version_r_sec = &*SecI;
768768 template
769769 typename ELFFile::Elf_Sym_Iter ELFFile::end_symbols() const {
770770 if (!dot_symtab_sec)
771 return Elf_Sym_Iter(0, 0, false);
771 return Elf_Sym_Iter(0, nullptr, false);
772772 return Elf_Sym_Iter(dot_symtab_sec->sh_entsize,
773773 (const char *)base() + dot_symtab_sec->sh_offset +
774774 dot_symtab_sec->sh_size,
781781 if (DynamicRegion.Addr)
782782 return Elf_Dyn_Iter(DynamicRegion.EntSize,
783783 (const char *)DynamicRegion.Addr);
784 return Elf_Dyn_Iter(0, 0);
784 return Elf_Dyn_Iter(0, nullptr);
785785 }
786786
787787 template
788788 typename ELFFile::Elf_Dyn_Iter
789789 ELFFile::end_dynamic_table(bool NULLEnd) const {
790790 if (!DynamicRegion.Addr)
791 return Elf_Dyn_Iter(0, 0);
791 return Elf_Dyn_Iter(0, nullptr);
792792 Elf_Dyn_Iter Ret(DynamicRegion.EntSize,
793793 (const char *)DynamicRegion.Addr + DynamicRegion.Size);
794794
4040 ObjectForArch(const MachOUniversalBinary *Parent, uint32_t Index);
4141
4242 void clear() {
43 Parent = 0;
43 Parent = nullptr;
4444 Index = 0;
4545 }
4646
8282 return ObjectForArch(this, 0);
8383 }
8484 object_iterator end_objects() const {
85 return ObjectForArch(0, 0);
85 return ObjectForArch(nullptr, 0);
8686 }
8787
8888 uint32_t getNumberOfObjects() const { return NumberOfObjects; }
6262
6363 public:
6464 Arg(const Option Opt, StringRef Spelling, unsigned Index,
65 const Arg *BaseArg = 0);
65 const Arg *BaseArg = nullptr);
6666 Arg(const Option Opt, StringRef Spelling, unsigned Index,
67 const char *Value0, const Arg *BaseArg = 0);
67 const char *Value0, const Arg *BaseArg = nullptr);
6868 Arg(const Option Opt, StringRef Spelling, unsigned Index,
69 const char *Value0, const char *Value1, const Arg *BaseArg = 0);
69 const char *Value0, const char *Value1, const Arg *BaseArg = nullptr);
7070 ~Arg();
7171
7272 const Option getOption() const { return Opt; }
159159 ///
160160 /// \p Claim Whether the argument should be claimed, if it exists.
161161 bool hasArgNoClaim(OptSpecifier Id) const {
162 return getLastArgNoClaim(Id) != 0;
162 return getLastArgNoClaim(Id) != nullptr;
163163 }
164164 bool hasArg(OptSpecifier Id) const {
165 return getLastArg(Id) != 0;
165 return getLastArg(Id) != nullptr;
166166 }
167167 bool hasArg(OptSpecifier Id0, OptSpecifier Id1) const {
168 return getLastArg(Id0, Id1) != 0;
168 return getLastArg(Id0, Id1) != nullptr;
169169 }
170170 bool hasArg(OptSpecifier Id0, OptSpecifier Id1, OptSpecifier Id2) const {
171 return getLastArg(Id0, Id1, Id2) != 0;
171 return getLastArg(Id0, Id1, Id2) != nullptr;
172172 }
173173
174174 /// getLastArg - Return the last argument matching \p Id, or null.
7272 ~Option();
7373
7474 bool isValid() const {
75 return Info != 0;
75 return Info != nullptr;
7676 }
7777
7878 unsigned getID() const {
193193 static double test(...);
194194
195195 public:
196 static bool const value = (sizeof(test >(0)) == 1);
196 static bool const value = (sizeof(test >(nullptr)) == 1);
197197 };
198198
199199
777777 template
778778 struct MappingNormalization {
779779 MappingNormalization(IO &i_o, TFinal &Obj)
780 : io(i_o), BufPtr(NULL), Result(Obj) {
780 : io(i_o), BufPtr(nullptr), Result(Obj) {
781781 if ( io.outputting() ) {
782782 BufPtr = new (&Buffer) TNorm(io, Obj);
783783 }
3939 /// intrinsic, Tys should point to an array of numTys pointers to Type,
4040 /// and must provide exactly one type for each overloaded type in the
4141 /// intrinsic.
42 virtual std::string getName(unsigned IID, Type **Tys = 0,
42 virtual std::string getName(unsigned IID, Type **Tys = nullptr,
4343 unsigned numTys = 0) const = 0;
4444
4545 /// Look up target intrinsic by name. Return intrinsic ID or 0 for unknown
5555 /// Create or insert an LLVM Function declaration for an intrinsic,
5656 /// and return it. The Tys and numTys are for intrinsics with overloaded
5757 /// types. See above for more information.
58 virtual Function *getDeclaration(Module *M, unsigned ID, Type **Tys = 0,
58 virtual Function *getDeclaration(Module *M, unsigned ID, Type **Tys = nullptr,
5959 unsigned numTys = 0) const = 0;
6060 };
6161
9595 ///
9696 BasicBlock *CloneBasicBlock(const BasicBlock *BB,
9797 ValueToValueMapTy &VMap,
98 const Twine &NameSuffix = "", Function *F = 0,
99 ClonedCodeInfo *CodeInfo = 0);
98 const Twine &NameSuffix = "", Function *F = nullptr,
99 ClonedCodeInfo *CodeInfo = nullptr);
100100
101101 /// CloneFunction - Return a copy of the specified function, but without
102102 /// embedding the function into another module. Also, any references specified
113113 Function *CloneFunction(const Function *F,
114114 ValueToValueMapTy &VMap,
115115 bool ModuleLevelChanges,
116 ClonedCodeInfo *CodeInfo = 0);
116 ClonedCodeInfo *CodeInfo = nullptr);
117117
118118 /// Clone OldFunc into NewFunc, transforming the old arguments into references
119119 /// to VMap values. Note that if NewFunc already has basic blocks, the ones
129129 bool ModuleLevelChanges,
130130 SmallVectorImpl &Returns,
131131 const char *NameSuffix = "",
132 ClonedCodeInfo *CodeInfo = 0,
133 ValueMapTypeRemapper *TypeMapper = 0,
134 ValueMaterializer *Materializer = 0);
132 ClonedCodeInfo *CodeInfo = nullptr,
133 ValueMapTypeRemapper *TypeMapper = nullptr,
134 ValueMaterializer *Materializer = nullptr);
135135
136136 /// CloneAndPruneFunctionInto - This works exactly like CloneFunctionInto,
137137 /// except that it does some simple constant prop and DCE on the fly. The
149149 bool ModuleLevelChanges,
150150 SmallVectorImpl &Returns,
151151 const char *NameSuffix = "",
152 ClonedCodeInfo *CodeInfo = 0,
153 const DataLayout *DL = 0,
154 Instruction *TheCall = 0);
152 ClonedCodeInfo *CodeInfo = nullptr,
153 const DataLayout *DL = nullptr,
154 Instruction *TheCall = nullptr);
155155
156156
157157 /// InlineFunctionInfo - This class captures the data input to the
158158 /// InlineFunction call, and records the auxiliary results produced by it.
159159 class InlineFunctionInfo {
160160 public:
161 explicit InlineFunctionInfo(CallGraph *cg = 0, const DataLayout *DL = 0)
161 explicit InlineFunctionInfo(CallGraph *cg = nullptr, const DataLayout *DL = nullptr)
162162 : CG(cg), DL(DL) {}
163163
164164 /// CG - If non-null, InlineFunction will update the callgraph to reflect the
6767
6868 Value *MapValue(const Value *V, ValueToValueMapTy &VM,
6969 RemapFlags Flags = RF_None,
70 ValueMapTypeRemapper *TypeMapper = 0,
71 ValueMaterializer *Materializer = 0);
70 ValueMapTypeRemapper *TypeMapper = nullptr,
71 ValueMaterializer *Materializer = nullptr);
7272
7373 void RemapInstruction(Instruction *I, ValueToValueMapTy &VM,
7474 RemapFlags Flags = RF_None,
75 ValueMapTypeRemapper *TypeMapper = 0,
76 ValueMaterializer *Materializer = 0);
75 ValueMapTypeRemapper *TypeMapper = nullptr,
76 ValueMaterializer *Materializer = nullptr);
7777
7878 /// MapValue - provide versions that preserve type safety for MDNode and
7979 /// Constants.
8080 inline MDNode *MapValue(const MDNode *V, ValueToValueMapTy &VM,
8181 RemapFlags Flags = RF_None,
82 ValueMapTypeRemapper *TypeMapper = 0,
83 ValueMaterializer *Materializer = 0) {
82 ValueMapTypeRemapper *TypeMapper = nullptr,
83 ValueMaterializer *Materializer = nullptr) {
8484 return cast(MapValue((const Value*)V, VM, Flags, TypeMapper,
8585 Materializer));
8686 }
8787 inline Constant *MapValue(const Constant *V, ValueToValueMapTy &VM,
8888 RemapFlags Flags = RF_None,
89 ValueMapTypeRemapper *TypeMapper = 0,
90 ValueMaterializer *Materializer = 0) {
89 ValueMapTypeRemapper *TypeMapper = nullptr,
90 ValueMaterializer *Materializer = nullptr) {
9191 return cast(MapValue((const Value*)V, VM, Flags, TypeMapper,
9292 Materializer));
9393 }
149149 static const char *isLabelTail(const char *CurPtr) {
150150 while (1) {
151151 if (CurPtr[0] == ':') return CurPtr+1;
152 if (!isLabelChar(CurPtr[0])) return 0;
152 if (!isLabelChar(CurPtr[0])) return nullptr;
153153 ++CurPtr;
154154 }
155155 }
434434 /// HexIntConstant [us]0x[0-9A-Fa-f]+
435435 lltok::Kind LLLexer::LexIdentifier() {
436436 const char *StartChar = CurPtr;
437 const char *IntEnd = CurPtr[-1] == 'i' ? 0 : StartChar;
438 const char *KeywordEnd = 0;
437 const char *IntEnd = CurPtr[-1] == 'i' ? nullptr : StartChar;
438 const char *KeywordEnd = nullptr;
439439
440440 for (; isLabelChar(*CurPtr); ++CurPtr) {
441441 // If we decide this is an integer, remember the end of the sequence.
454454
455455 // Otherwise, this wasn't a label. If this was valid as an integer type,
456456 // return it.
457 if (IntEnd == 0) IntEnd = CurPtr;
457 if (!IntEnd) IntEnd = CurPtr;
458458 if (IntEnd != StartChar) {
459459 CurPtr = IntEnd;
460460 uint64_t NumBits = atoull(StartChar, CurPtr);
468468 }
469469
470470 // Otherwise, this was a letter sequence. See which keyword this is.
471 if (KeywordEnd == 0) KeywordEnd = CurPtr;
471 if (!KeywordEnd) KeywordEnd = CurPtr;
472472 CurPtr = KeywordEnd;
473473 --StartChar;
474474 unsigned Len = CurPtr-StartChar;
5656 for (unsigned i = 0, e = MDList.size(); i != e; ++i) {
5757 unsigned SlotNo = MDList[i].MDSlot;
5858
59 if (SlotNo >= NumberedMetadata.size() || NumberedMetadata[SlotNo] == 0)
59 if (SlotNo >= NumberedMetadata.size() ||
60 NumberedMetadata[SlotNo] == nullptr)
6061 return Error(MDList[i].Loc, "use of undefined metadata '!" +
6162 Twine(SlotNo) + "'");
6263 Inst->setMetadata(MDList[i].MDKind, NumberedMetadata[SlotNo]);
131132 // references after the function was defined. Resolve those now.
132133 while (!ForwardRefBlockAddresses.empty()) {
133134 // Okay, we are referencing an already-parsed function, resolve them now.
134 Function *TheFn = 0;
135 Function *TheFn = nullptr;
135136 const ValID &Fn = ForwardRefBlockAddresses.begin()->first;
136137 if (Fn.Kind == ValID::t_GlobalName)
137138 TheFn = M->getFunction(Fn.StrVal);
138139 else if (Fn.UIntVal < NumberedVals.size())
139140 TheFn = dyn_cast(NumberedVals[Fn.UIntVal]);
140141
141 if (TheFn == 0)
142 if (!TheFn)
142143 return Error(Fn.Loc, "unknown function referenced by blockaddress");
143144
144145 // Resolve all these references.
145146 if (ResolveForwardRefBlockAddresses(TheFn,
146147 ForwardRefBlockAddresses.begin()->second,
147 0))
148 nullptr))
148149 return true;
149150
150151 ForwardRefBlockAddresses.erase(ForwardRefBlockAddresses.begin());
205206 TheFn->getValueSymbolTable().lookup(Refs[i].first.StrVal));
206207 }
207208
208 if (Res == 0)
209 if (!Res)
209210 return Error(Refs[i].first.Loc,
210211 "referenced value is not a basic block");
211212
363364 if (TypeID >= NumberedTypes.size())
364365 NumberedTypes.resize(TypeID+1);
365366
366 Type *Result = 0;
367 Type *Result = nullptr;
367368 if (ParseStructDefinition(TypeLoc, "",
368369 NumberedTypes[TypeID], Result)) return true;
369370
390391 ParseToken(lltok::kw_type, "expected 'type' after name"))
391392 return true;
392393
393 Type *Result = 0;
394 Type *Result = nullptr;
394395 if (ParseStructDefinition(NameLoc, Name,
395396 NamedTypes[Name], Result)) return true;
396397
522523 if (ParseUInt32(SlotNo)) return true;
523524
524525 // Check existing MDNode.
525 if (SlotNo < NumberedMetadata.size() && NumberedMetadata[SlotNo] != 0)
526 if (SlotNo < NumberedMetadata.size() && NumberedMetadata[SlotNo] != nullptr)
526527 Result = NumberedMetadata[SlotNo];
527528 else
528 Result = 0;
529 Result = nullptr;
529530 return false;
530531 }
531532
566567 if (ParseToken(lltok::exclaim, "Expected '!' here"))
567568 return true;
568569
569 MDNode *N = 0;
570 MDNode *N = nullptr;
570571 if (ParseMDNodeID(N)) return true;
571572 NMD->addOperand(N);
572573 } while (EatIfPresent(lltok::comma));
585586 unsigned MetadataID = 0;
586587
587588 LocTy TyLoc;
588 Type *Ty = 0;
589 Type *Ty = nullptr;
589590 SmallVector Elts;
590591 if (ParseUInt32(MetadataID) ||
591592 ParseToken(lltok::equal, "expected '=' here") ||
592593 ParseType(Ty, TyLoc) ||
593594 ParseToken(lltok::exclaim, "Expected '!' here") ||
594595 ParseToken(lltok::lbrace, "Expected '{' here") ||
595 ParseMDNodeVector(Elts, NULL) ||
596 ParseMDNodeVector(Elts, nullptr) ||
596597 ParseToken(lltok::rbrace, "expected end of metadata node"))
597598 return true;
598599
612613 if (MetadataID >= NumberedMetadata.size())
613614 NumberedMetadata.resize(MetadataID+1);
614615
615 if (NumberedMetadata[MetadataID] != 0)
616 if (NumberedMetadata[MetadataID] != nullptr)
616617 return TokError("Metadata id is already used");
617618 NumberedMetadata[MetadataID] = Init;
618619 }
719720 LocTy IsExternallyInitializedLoc;
720721 LocTy TyLoc;
721722
722 Type *Ty = 0;
723 Type *Ty = nullptr;
723724 if (ParseOptionalThreadLocal(TLM) ||
724725 ParseOptionalAddrSpace(AddrSpace) ||
725726 ParseOptionalToken(lltok::kw_unnamed_addr, UnnamedAddr,
733734
734735 // If the linkage is specified and is external, then no initializer is
735736 // present.
736 Constant *Init = 0;
737 Constant *Init = nullptr;
737738 if (!HasLinkage || (Linkage != GlobalValue::ExternalWeakLinkage &&
738739 Linkage != GlobalValue::ExternalLinkage)) {
739740 if (ParseGlobalValue(Ty, Init))
743744 if (Ty->isFunctionTy() || Ty->isLabelTy())
744745 return Error(TyLoc, "invalid type for global variable");
745746
746 GlobalVariable *GV = 0;
747 GlobalVariable *GV = nullptr;
747748
748749 // See if the global was forward referenced, if so, use the global.
749750 if (!Name.empty()) {
761762 }
762763 }
763764
764 if (GV == 0) {
765 GV = new GlobalVariable(*M, Ty, false, GlobalValue::ExternalLinkage, 0,
766 Name, 0, GlobalVariable::NotThreadLocal,
765 if (!GV) {
766 GV = new GlobalVariable(*M, Ty, false, GlobalValue::ExternalLinkage, nullptr,
767 Name, nullptr, GlobalVariable::NotThreadLocal,
767768 AddrSpace);
768769 } else {
769770 if (GV->getType()->getElementType() != Ty)
979980 GlobalValue *LLParser::GetGlobalVal(const std::string &Name, Type *Ty,
980981 LocTy Loc) {
981982 PointerType *PTy = dyn_cast(Ty);
982 if (PTy == 0) {
983 if (!PTy) {
983984 Error(Loc, "global variable reference must have pointer type");
984 return 0;
985 return nullptr;
985986 }
986987
987988 // Look this name up in the normal function symbol table.
990991
991992 // If this is a forward reference for the value, see if we already created a
992993 // forward ref record.
993 if (Val == 0) {
994 if (!Val) {
994995 std::map >::iterator
995996 I = ForwardRefVals.find(Name);
996997 if (I != ForwardRefVals.end())
10021003 if (Val->getType() == Ty) return Val;
10031004 Error(Loc, "'@" + Name + "' defined with type '" +
10041005 getTypeString(Val->getType()) + "'");
1005 return 0;
1006 return nullptr;
10061007 }
10071008
10081009 // Otherwise, create a new forward reference for this value and remember it.
10111012 FwdVal = Function::Create(FT, GlobalValue::ExternalWeakLinkage, Name, M);
10121013 else
10131014 FwdVal = new GlobalVariable(*M, PTy->getElementType(), false,
1014 GlobalValue::ExternalWeakLinkage, 0, Name,
1015 0, GlobalVariable::NotThreadLocal,
1015 GlobalValue::ExternalWeakLinkage, nullptr, Name,
1016 nullptr, GlobalVariable::NotThreadLocal,
10161017 PTy->getAddressSpace());
10171018
10181019 ForwardRefVals[Name] = std::make_pair(FwdVal, Loc);
10211022
10221023 GlobalValue *LLParser::GetGlobalVal(unsigned ID, Type *Ty, LocTy Loc) {
10231024 PointerType *PTy = dyn_cast(Ty);
1024 if (PTy == 0) {
1025 if (!PTy) {
10251026 Error(Loc, "global variable reference must have pointer type");
1026 return 0;
1027 }
1028
1029 GlobalValue *Val = ID < NumberedVals.size() ? NumberedVals[ID] : 0;
1027 return nullptr;
1028 }
1029
1030 GlobalValue *Val = ID < NumberedVals.size() ? NumberedVals[ID] : nullptr;
10301031
10311032 // If this is a forward reference for the value, see if we already created a
10321033 // forward ref record.
1033 if (Val == 0) {
1034 if (!Val) {
10341035 std::map >::iterator
10351036 I = ForwardRefValIDs.find(ID);
10361037 if (I != ForwardRefValIDs.end())
10421043 if (Val->getType() == Ty) return Val;
10431044 Error(Loc, "'@" + Twine(ID) + "' defined with type '" +
10441045 getTypeString(Val->getType()) + "'");
1045 return 0;
1046 return nullptr;
10461047 }
10471048
10481049 // Otherwise, create a new forward reference for this value and remember it.
10511052 FwdVal = Function::Create(FT, GlobalValue::ExternalWeakLinkage, "", M);
10521053 else
10531054 FwdVal = new GlobalVariable(*M, PTy->getElementType(), false,
1054 GlobalValue::ExternalWeakLinkage, 0, "");
1055 GlobalValue::ExternalWeakLinkage, nullptr, "");
10551056
10561057 ForwardRefValIDs[ID] = std::make_pair(FwdVal, Loc);
10571058 return FwdVal;
16371638
16381639 // If the type hasn't been defined yet, create a forward definition and
16391640 // remember where that forward def'n was seen (in case it never is defined).
1640 if (Entry.first == 0) {
1641 if (!Entry.first) {
16411642 Entry.first = StructType::create(Context, Lex.getStrVal());
16421643 Entry.second = Lex.getLoc();
16431644 }
16541655
16551656 // If the type hasn't been defined yet, create a forward definition and
16561657 // remember where that forward def'n was seen (in case it never is defined).
1657 if (Entry.first == 0) {
1658 if (!Entry.first) {
16581659 Entry.first = StructType::create(Context);
16591660 Entry.second = Lex.getLoc();
16601661 }
17301731
17311732 // Parse the argument.
17321733 LocTy ArgLoc;
1733 Type *ArgTy = 0;
1734 Type *ArgTy = nullptr;
17341735 AttrBuilder ArgAttrs;
17351736 Value *V;
17361737 if (ParseType(ArgTy, ArgLoc))
17721773 Lex.Lex();
17731774 } else {
17741775 LocTy TypeLoc = Lex.getLoc();
1775 Type *ArgTy = 0;
1776 Type *ArgTy = nullptr;
17761777 AttrBuilder Attrs;
17771778 std::string Name;
17781779
18841885 Entry.second = SMLoc();
18851886
18861887 // If this type number has never been uttered, create it.
1887 if (Entry.first == 0)
1888 if (!Entry.first)
18881889 Entry.first = StructType::create(Context, Name);
18891890 ResultTy = Entry.first;
18901891 return false;
19001901 if (Entry.first)
19011902 return Error(TypeLoc, "forward references to non-struct type");
19021903
1903 ResultTy = 0;
1904 ResultTy = nullptr;
19041905 if (isPacked)
19051906 return ParseArrayVectorType(ResultTy, true);
19061907 return ParseType(ResultTy);
19101911 Entry.second = SMLoc();
19111912
19121913 // If this type number has never been uttered, create it.
1913 if (Entry.first == 0)
1914 if (!Entry.first)
19141915 Entry.first = StructType::create(Context, Name);
19151916
19161917 StructType *STy = cast(Entry.first);
19411942 return false;
19421943
19431944 LocTy EltTyLoc = Lex.getLoc();
1944 Type *Ty = 0;
1945 Type *Ty = nullptr;
19451946 if (ParseType(Ty)) return true;
19461947 Body.push_back(Ty);
19471948
19791980 return true;
19801981
19811982 LocTy TypeLoc = Lex.getLoc();
1982 Type *EltTy = 0;
1983 Type *EltTy = nullptr;
19831984 if (ParseType(EltTy)) return true;
19841985
19851986 if (ParseToken(isVector ? lltok::greater : lltok::rsquare,
20252026 I->second.first->replaceAllUsesWith(
20262027 UndefValue::get(I->second.first->getType()));
20272028 delete I->second.first;
2028 I->second.first = 0;
2029 I->second.first = nullptr;
20292030 }
20302031
20312032 for (std::map >::iterator
20342035 I->second.first->replaceAllUsesWith(
20352036 UndefValue::get(I->second.first->getType()));
20362037 delete I->second.first;
2037 I->second.first = 0;
2038 I->second.first = nullptr;
20382039 }
20392040 }
20402041
20832084
20842085 // If this is a forward reference for the value, see if we already created a
20852086 // forward ref record.
2086 if (Val == 0) {
2087 if (!Val) {
20872088 std::map >::iterator
20882089 I = ForwardRefVals.find(Name);
20892090 if (I != ForwardRefVals.end())
20982099 else
20992100 P.Error(Loc, "'%" + Name + "' defined with type '" +
21002101 getTypeString(Val->getType()) + "'");
2101 return 0;
2102 return nullptr;
21022103 }
21032104
21042105 // Don't make placeholders with invalid type.
21052106 if (!Ty->isFirstClassType() && !Ty->isLabelTy()) {
21062107 P.Error(Loc, "invalid use of a non-first-class type");
2107 return 0;
2108 return nullptr;
21082109 }
21092110
21102111 // Otherwise, create a new forward reference for this value and remember it.
21212122 Value *LLParser::PerFunctionState::GetVal(unsigned ID, Type *Ty,
21222123 LocTy Loc) {
21232124 // Look this name up in the normal function symbol table.
2124 Value *Val = ID < NumberedVals.size() ? NumberedVals[ID] : 0;
2125 Value *Val = ID < NumberedVals.size() ? NumberedVals[ID] : nullptr;
21252126
21262127 // If this is a forward reference for the value, see if we already created a
21272128 // forward ref record.
2128 if (Val == 0) {
2129 if (!Val) {
21292130 std::map >::iterator
21302131 I = ForwardRefValIDs.find(ID);
21312132 if (I != ForwardRefValIDs.end())
21402141 else
21412142 P.Error(Loc, "'%" + Twine(ID) + "' defined with type '" +
21422143 getTypeString(Val->getType()) + "'");
2143 return 0;
2144 return nullptr;
21442145 }
21452146
21462147 if (!Ty->isFirstClassType() && !Ty->isLabelTy()) {
21472148 P.Error(Loc, "invalid use of a non-first-class type");
2148 return 0;
2149 return nullptr;
21492150 }
21502151
21512152 // Otherwise, create a new forward reference for this value and remember it.
22412242 BB = GetBB(NumberedVals.size(), Loc);
22422243 else
22432244 BB = GetBB(Name, Loc);
2244 if (BB == 0) return 0; // Already diagnosed error.
2245 if (!BB) return nullptr; // Already diagnosed error.
22452246
22462247 // Move the block to the end of the function. Forward ref'd blocks are
22472248 // inserted wherever they happen to be referenced.
24492450 // Make a global variable as a placeholder for this reference.
24502451 GlobalVariable *FwdRef = new GlobalVariable(*M, Type::getInt8Ty(Context),
24512452 false, GlobalValue::InternalLinkage,
2452 0, "");
2453 nullptr, "");
24532454 ForwardRefBlockAddresses[Fn].push_back(std::make_pair(Label, FwdRef));
24542455 ID.ConstantVal = FwdRef;
24552456 ID.Kind = ValID::t_Constant;
24702471 case lltok::kw_inttoptr:
24712472 case lltok::kw_ptrtoint: {
24722473 unsigned Opc = Lex.getUIntVal();
2473 Type *DestTy = 0;
2474 Type *DestTy = nullptr;
24742475 Constant *SrcVal;
24752476 Lex.Lex();
24762477 if (ParseToken(lltok::lparen, "expected '(' after constantexpr cast") ||
27342735
27352736 /// ParseGlobalValue - Parse a global value with the specified type.
27362737 bool LLParser::ParseGlobalValue(Type *Ty, Constant *&C) {
2737 C = 0;
2738 C = nullptr;
27382739 ValID ID;
2739 Value *V = NULL;
2740 Value *V = nullptr;
27402741 bool Parsed = ParseValID(ID) ||
2741 ConvertValIDToValue(Ty, ID, V, NULL);
2742 ConvertValIDToValue(Ty, ID, V, nullptr);
27422743 if (V && !(C = dyn_cast(V)))
27432744 return Error(ID.Loc, "global values must be constants");
27442745 return Parsed;
27452746 }
27462747
27472748 bool LLParser::ParseGlobalTypeAndValue(Constant *&V) {
2748 Type *Ty = 0;
2749 Type *Ty = nullptr;
27492750 return ParseType(Ty) ||
27502751 ParseGlobalValue(Ty, V);
27512752 }
28292830 case ValID::t_LocalID:
28302831 if (!PFS) return Error(ID.Loc, "invalid use of function-local name");
28312832 V = PFS->GetVal(ID.UIntVal, Ty, ID.Loc);
2832 return (V == 0);
2833 return V == nullptr;
28332834 case ValID::t_LocalName:
28342835 if (!PFS) return Error(ID.Loc, "invalid use of function-local name");
28352836 V = PFS->GetVal(ID.StrVal, Ty, ID.Loc);
2836 return (V == 0);
2837 return V == nullptr;
28372838 case ValID::t_InlineAsm: {
28382839 PointerType *PTy = dyn_cast(Ty);
28392840 FunctionType *FTy =
2840 PTy ? dyn_cast(PTy->getElementType()) : 0;
2841 PTy ? dyn_cast(PTy->getElementType()) : nullptr;
28412842 if (!FTy || !InlineAsm::Verify(FTy, ID.StrVal2))
28422843 return Error(ID.Loc, "invalid type for inline asm constraint string");
28432844 V = InlineAsm::get(FTy, ID.StrVal, ID.StrVal2, ID.UIntVal&1,
28562857 return false;
28572858 case ValID::t_GlobalName:
28582859 V = GetGlobalVal(ID.StrVal, Ty, ID.Loc);
2859 return V == 0;
2860 return V == nullptr;
28602861 case ValID::t_GlobalID:
28612862 V = GetGlobalVal(ID.UIntVal, Ty, ID.Loc);
2862 return V == 0;
2863 return V == nullptr;
28632864 case ValID::t_APSInt:
28642865 if (!Ty->isIntegerTy())
28652866 return Error(ID.Loc, "integer constant must have integer type");
29422943 }
29432944
29442945 bool LLParser::ParseValue(Type *Ty, Value *&V, PerFunctionState *PFS) {
2945 V = 0;
2946 V = nullptr;
29462947 ValID ID;
29472948 return ParseValID(ID, PFS) ||
29482949 ConvertValIDToValue(Ty, ID, V, PFS);
29492950 }
29502951
29512952 bool LLParser::ParseTypeAndValue(Value *&V, PerFunctionState *PFS) {
2952 Type *Ty = 0;
2953 Type *Ty = nullptr;
29532954 return ParseType(Ty) ||
29542955 ParseValue(Ty, V, PFS);
29552956 }
29792980 unsigned DLLStorageClass;
29802981 AttrBuilder RetAttrs;
29812982 CallingConv::ID CC;
2982 Type *RetType = 0;
2983 Type *RetType = nullptr;
29832984 LocTy RetTypeLoc = Lex.getLoc();
29842985 if (ParseOptionalLinkage(Linkage) ||
29852986 ParseOptionalVisibility(Visibility) ||
30453046 std::string GC;
30463047 bool UnnamedAddr;
30473048 LocTy UnnamedAddrLoc;
3048 Constant *Prefix = 0;
3049 Constant *Prefix = nullptr;
30493050
30503051 if (ParseArgumentList(ArgList, isVarArg) ||
30513052 ParseOptionalToken(lltok::kw_unnamed_addr, UnnamedAddr,
31023103 FunctionType::get(RetType, ParamTypeList, isVarArg);
31033104 PointerType *PFT = PointerType::getUnqual(FT);
31043105
3105 Fn = 0;
3106 Fn = nullptr;
31063107 if (!FunctionName.empty()) {
31073108 // If this was a definition of a forward reference, remove the definition
31083109 // from the forward reference table and fill in the forward ref.
31403141 }
31413142 }
31423143
3143 if (Fn == 0)
3144 if (!Fn)
31443145 Fn = Function::Create(FT, GlobalValue::ExternalLinkage, FunctionName, M);
31453146 else // Move the forward-reference to the correct spot in the module.
31463147 M->getFunctionList().splice(M->end(), M->getFunctionList(), Fn);
32173218 }
32183219
32193220 BasicBlock *BB = PFS.DefineBB(Name, NameLoc);
3220 if (BB == 0) return true;
3221 if (!BB) return true;
32213222
32223223 std::string NameStr;
32233224
34313432 bool LLParser::ParseRet(Instruction *&Inst, BasicBlock *BB,
34323433 PerFunctionState &PFS) {
34333434 SMLoc TypeLoc = Lex.getLoc();
3434 Type *Ty = 0;
3435 Type *Ty = nullptr;
34353436 if (ParseType(Ty, true /*void allowed*/)) return true;
34363437
34373438 Type *ResType = PFS.getFunction().getReturnType();
35813582 std::vector FwdRefAttrGrps;
35823583 LocTy NoBuiltinLoc;
35833584 CallingConv::ID CC;
3584 Type *RetType = 0;
3585 Type *RetType = nullptr;
35853586 LocTy RetTypeLoc;
35863587 ValID CalleeID;
35873588 SmallVector ArgList;
36033604 // If RetType is a non-function pointer type, then this is the short syntax
36043605 // for the call, which means that RetType is just the return type. Infer the
36053606 // rest of the function argument types from the arguments that are present.
3606 PointerType *PFTy = 0;
3607 FunctionType *Ty = 0;
3607 PointerType *PFTy = nullptr;
3608 FunctionType *Ty = nullptr;
36083609 if (!(PFTy = dyn_cast(RetType)) ||
36093610 !(Ty = dyn_cast(PFTy->getElementType()))) {
36103611 // Pull out the types of all of the arguments...
36373638 FunctionType::param_iterator I = Ty->param_begin();
36383639 FunctionType::param_iterator E = Ty->param_end();
36393640 for (unsigned i = 0, e = ArgList.size(); i != e; ++i) {
3640 Type *ExpectedTy = 0;
3641 Type *ExpectedTy = nullptr;
36413642 if (I != E) {
36423643 ExpectedTy = *I++;
36433644 } else if (!Ty->isVarArg()) {
37783779 unsigned Opc) {
37793780 LocTy Loc;
37803781 Value *Op;
3781 Type *DestTy = 0;
3782 Type *DestTy = nullptr;
37823783 if (ParseTypeAndValue(Op, Loc, PFS) ||
37833784 ParseToken(lltok::kw_to, "expected 'to' after cast value") ||
37843785 ParseType(DestTy))
38173818 /// ::= 'va_arg' TypeAndValue ',' Type
38183819 bool LLParser::ParseVA_Arg(Instruction *&Inst, PerFunctionState &PFS) {
38193820 Value *Op;
3820 Type *EltTy = 0;
3821 Type *EltTy = nullptr;
38213822 LocTy TypeLoc;
38223823 if (ParseTypeAndValue(Op, PFS) ||
38233824 ParseToken(lltok::comma, "expected ',' after vaarg operand") ||
38893890 /// ParsePHI
38903891 /// ::= 'phi' Type '[' Value ',' Value ']' (',' '[' Value ',' Value ']')*
38913892 int LLParser::ParsePHI(Instruction *&Inst, PerFunctionState &PFS) {
3892 Type *Ty = 0; LocTy TypeLoc;
3893 Type *Ty = nullptr; LocTy TypeLoc;
38933894 Value *Op0, *Op1;
38943895
38953896 if (ParseType(Ty, TypeLoc) ||
39383939 /// ::= 'filter'
39393940 /// ::= 'filter' TypeAndValue ( ',' TypeAndValue )*
39403941 bool LLParser::ParseLandingPad(Instruction *&Inst, PerFunctionState &PFS) {
3941 Type *Ty = 0; LocTy TyLoc;
3942 Type *Ty = nullptr; LocTy TyLoc;
39423943 Value *PersFn; LocTy PersFnLoc;
39433944
39443945 if (ParseType(Ty, TyLoc) ||
39903991 std::vector FwdRefAttrGrps;
39913992 LocTy BuiltinLoc;
39923993 CallingConv::ID CC;
3993 Type *RetType = 0;
3994 Type *RetType = nullptr;
39943995 LocTy RetTypeLoc;
39953996 ValID CalleeID;
39963997 SmallVector ArgList;
40094010 // If RetType is a non-function pointer type, then this is the short syntax
40104011 // for the call, which means that RetType is just the return type. Infer the
40114012 // rest of the function argument types from the arguments that are present.
4012 PointerType *PFTy = 0;
4013 FunctionType *Ty = 0;
4013 PointerType *PFTy = nullptr;
4014 FunctionType *Ty = nullptr;
40144015 if (!(PFTy = dyn_cast(RetType)) ||
40154016 !(Ty = dyn_cast(PFTy->getElementType()))) {
40164017 // Pull out the types of all of the arguments...
40434044 FunctionType::param_iterator I = Ty->param_begin();
40444045 FunctionType::param_iterator E = Ty->param_end();
40454046 for (unsigned i = 0, e = ArgList.size(); i != e; ++i) {
4046 Type *ExpectedTy = 0;
4047 Type *ExpectedTy = nullptr;
40474048 if (I != E) {
40484049 ExpectedTy = *I++;
40494050 } else if (!Ty->isVarArg()) {
40874088 /// ParseAlloc
40884089 /// ::= 'alloca' 'inalloca'? Type (',' TypeAndValue)? (',' 'align' i32)?
40894090 int LLParser::ParseAlloc(Instruction *&Inst, PerFunctionState &PFS) {
4090 Value *Size = 0;
4091 Value *Size = nullptr;
40914092 LocTy SizeLoc;
40924093 unsigned Alignment = 0;
4093 Type *Ty = 0;
4094 Type *Ty = nullptr;
40944095
40954096 bool IsInAlloca = EatIfPresent(lltok::kw_inalloca);
40964097
43294330 /// ParseGetElementPtr
43304331 /// ::= 'getelementptr' 'inbounds'? TypeAndValue (',' TypeAndValue)*
43314332 int LLParser::ParseGetElementPtr(Instruction *&Inst, PerFunctionState &PFS) {
4332 Value *Ptr = 0;
4333 Value *Val = 0;
4333 Value *Ptr = nullptr;
4334 Value *Val = nullptr;
43344335 LocTy Loc, EltLoc;
43354336
43364337 bool InBounds = EatIfPresent(lltok::kw_inbounds);
44324433 do {
44334434 // Null is a special case since it is typeless.
44344435 if (EatIfPresent(lltok::kw_null)) {
4435 Elts.push_back(0);
4436 Elts.push_back(nullptr);
44364437 continue;
44374438 }
44384439
4439 Value *V = 0;
4440 Value *V = nullptr;
44404441 if (ParseTypeAndValue(V, PFS)) return true;
44414442 Elts.push_back(V);
44424443 } while (EatIfPresent(lltok::comma));
2929
3030 // If we are parsing into an existing module, do it.
3131 if (M)
32 return LLParser(F, SM, Err, M).Run() ? 0 : M;
32 return LLParser(F, SM, Err, M).Run() ? nullptr : M;
3333
3434 // Otherwise create a new module.
3535 std::unique_ptr M2(new Module(F->getBufferIdentifier(), Context));
3636 if (LLParser(F, SM, Err, M2.get()).Run())
37 return 0;
37 return nullptr;
3838 return M2.release();
3939 }
4040
4444 if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, File)) {
4545 Err = SMDiagnostic(Filename, SourceMgr::DK_Error,
4646 "Could not open input file: " + ec.message());
47 return 0;
47 return nullptr;
4848 }
4949
50 return ParseAssembly(File.release(), 0, Err, Context);
50 return ParseAssembly(File.release(), nullptr, Err, Context);
5151 }
5252
5353 Module *llvm::ParseAssemblyString(const char *AsmString, Module *M,
3434 if (error_code EC = ModuleOrErr.getError()) {
3535 if (OutMessage)
3636 *OutMessage = strdup(EC.message().c_str());
37 *OutModule = wrap((Module*)0);
37 *OutModule = wrap((Module*)nullptr);
3838 return 1;
3939 }
4040
5454 getLazyBitcodeModule(unwrap(MemBuf), *unwrap(ContextRef));
5555
5656 if (error_code EC = ModuleOrErr.getError()) {
57 *OutM = wrap((Module *)NULL);
57 *OutM = wrap((Module *)nullptr);
5858 if (OutMessage)
5959 *OutMessage = strdup(EC.message().c_str());
6060 return 1;
4040 void BitcodeReader::FreeState() {
4141 if (BufferOwned)
4242 delete Buffer;
43 Buffer = 0;
43 Buffer = nullptr;
4444 std::vector().swap(TypeList);
4545 ValueList.clear();
4646 MDValueList.clear();
257257 resize(Idx+1);
258258
259259 WeakVH &OldV = ValuePtrs[Idx];
260 if (OldV == 0) {
260 if (!OldV) {
261261 OldV = V;
262262 return;
263263 }
297297 resize(Idx + 1);
298298
299299 if (Value *V = ValuePtrs[Idx]) {
300 assert((Ty == 0 || Ty == V->getType()) && "Type mismatch in value table!");
300 assert((!Ty || Ty == V->getType()) && "Type mismatch in value table!");
301301 return V;
302302 }
303303
304304 // No type specified, must be invalid reference.
305 if (Ty == 0) return 0;
305 if (!Ty) return nullptr;
306306
307307 // Create and return a placeholder, which will later be RAUW'd.
308308 Value *V = new Argument(Ty);
402402 resize(Idx+1);
403403
404404 WeakVH &OldV = MDValuePtrs[Idx];
405 if (OldV == 0) {
405 if (!OldV) {
406406 OldV = V;
407407 return;
408408 }
434434 Type *BitcodeReader::getTypeByID(unsigned ID) {
435435 // The type table size is always specified correctly.
436436 if (ID >= TypeList.size())
437 return 0;
437 return nullptr;
438438
439439 if (Type *Ty = TypeList[ID])
440440 return Ty;
736736
737737 // Read a record.
738738 Record.clear();
739 Type *ResultTy = 0;
739 Type *ResultTy = nullptr;
740740 switch (Stream.readRecord(Entry.ID, Record)) {
741741 default:
742742 return Error(InvalidValue);
791791 if (Record.size() == 2)
792792 AddressSpace = Record[1];
793793 ResultTy = getTypeByID(Record[0]);
794 if (ResultTy == 0)
794 if (!ResultTy)
795795 return Error(InvalidType);
796796 ResultTy = PointerType::get(ResultTy, AddressSpace);
797797 break;
810810 }
811811
812812 ResultTy = getTypeByID(Record[2]);
813 if (ResultTy == 0 || ArgTys.size() < Record.size()-3)
813 if (!ResultTy || ArgTys.size() < Record.size()-3)
814814 return Error(InvalidType);
815815
816816 ResultTy = FunctionType::get(ResultTy, ArgTys, Record[0]);
829829 }
830830
831831 ResultTy = getTypeByID(Record[1]);
832 if (ResultTy == 0 || ArgTys.size() < Record.size()-2)
832 if (!ResultTy || ArgTys.size() < Record.size()-2)
833833 return Error(InvalidType);
834834
835835 ResultTy = FunctionType::get(ResultTy, ArgTys, Record[0]);
866866 StructType *Res = cast_or_null(TypeList[NumRecords]);
867867 if (Res) {
868868 Res->setName(TypeName);
869 TypeList[NumRecords] = 0;
869 TypeList[NumRecords] = nullptr;
870870 } else // Otherwise, create a new struct.
871871 Res = StructType::create(Context, TypeName);
872872 TypeName.clear();
895895 StructType *Res = cast_or_null(TypeList[NumRecords]);
896896 if (Res) {
897897 Res->setName(TypeName);
898 TypeList[NumRecords] = 0;
898 TypeList[NumRecords] = nullptr;
899899 } else // Otherwise, create a new struct with no body.
900900 Res = StructType::create(Context, TypeName);
901901 TypeName.clear();
923923 if (NumRecords >= TypeList.size())
924924 return Error(InvalidTYPETable);
925925 assert(ResultTy && "Didn't read a type?");
926 assert(TypeList[NumRecords] == 0 && "Already read type?");
926 assert(!TypeList[NumRecords] && "Already read type?");
927927 TypeList[NumRecords++] = ResultTy;
928928 }
929929 }
971971 if (ConvertToString(Record, 1, ValueName))
972972 return Error(InvalidRecord);
973973 BasicBlock *BB = getBasicBlock(Record[0]);
974 if (BB == 0)
974 if (!BB)
975975 return Error(InvalidRecord);
976976
977977 BB->setName(StringRef(ValueName.data(), ValueName.size()));
10271027 NamedMDNode *NMD = TheModule->getOrInsertNamedMetadata(Name);
10281028 for (unsigned i = 0; i != Size; ++i) {
10291029 MDNode *MD = dyn_cast_or_null(MDValueList.getValueFwdRef(Record[i]));
1030 if (MD == 0)
1030 if (!MD)
10311031 return Error(InvalidRecord);
10321032 NMD->addOperand(MD);
10331033 }
10511051 else if (!Ty->isVoidTy())
10521052 Elts.push_back(ValueList.getValueFwdRef(Record[i+1], Ty));
10531053 else
1054 Elts.push_back(NULL);
1054 Elts.push_back(nullptr);
10551055 }
10561056 Value *V = MDNode::getWhenValsUnresolved(Context, Elts, IsFunctionLocal);
10571057 IsFunctionLocal = false;
11841184
11851185 // Read a record.
11861186 Record.clear();
1187 Value *V = 0;
1187 Value *V = nullptr;
11881188 unsigned BitCode = Stream.readRecord(Entry.ID, Record);
11891189 switch (BitCode) {
11901190 default: // Default behavior: unknown constant
14221422 return Error(InvalidRecord);
14231423 VectorType *OpTy =
14241424 dyn_cast_or_null(getTypeByID(Record[0]));
1425 if (OpTy == 0)
1425 if (!OpTy)
14261426 return Error(InvalidRecord);
14271427 Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy);
14281428 Constant *Op1 = ValueList.getConstantFwdRef(Record[2],
14321432 }
14331433 case bitc::CST_CODE_CE_INSERTELT: { // CE_INSERTELT: [opval, opval, opval]
14341434 VectorType *OpTy = dyn_cast(CurTy);
1435 if (Record.size() < 3 || OpTy == 0)
1435 if (Record.size() < 3 || !OpTy)
14361436 return Error(InvalidRecord);
14371437 Constant *Op0 = ValueList.getConstantFwdRef(Record[0], OpTy);
14381438 Constant *Op1 = ValueList.getConstantFwdRef(Record[1],
14441444 }
14451445 case bitc::CST_CODE_CE_SHUFFLEVEC: { // CE_SHUFFLEVEC: [opval, opval, opval]
14461446 VectorType *OpTy = dyn_cast(CurTy);
1447 if (Record.size() < 3 || OpTy == 0)
1447 if (Record.size() < 3 || !OpTy)
14481448 return Error(InvalidRecord);
14491449 Constant *Op0 = ValueList.getConstantFwdRef(Record[0], OpTy);
14501450 Constant *Op1 = ValueList.getConstantFwdRef(Record[1], OpTy);
14581458 VectorType *RTy = dyn_cast(CurTy);
14591459 VectorType *OpTy =
14601460 dyn_cast_or_null(getTypeByID(Record[0]));
1461 if (Record.size() < 4 || RTy == 0 || OpTy == 0)
1461 if (Record.size() < 4 || !RTy || !OpTy)
14621462 return Error(InvalidRecord);
14631463 Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy);
14641464 Constant *Op1 = ValueList.getConstantFwdRef(Record[2], OpTy);
14721472 if (Record.size() < 4)
14731473 return Error(InvalidRecord);
14741474 Type *OpTy = getTypeByID(Record[0]);
1475 if (OpTy == 0)
1475 if (!OpTy)
14761476 return Error(InvalidRecord);
14771477 Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy);
14781478 Constant *Op1 = ValueList.getConstantFwdRef(Record[2], OpTy);
15371537 if (Record.size() < 3)
15381538 return Error(InvalidRecord);
15391539 Type *FnTy = getTypeByID(Record[0]);
1540 if (FnTy == 0)
1540 if (!FnTy)
15411541 return Error(InvalidRecord);
15421542 Function *Fn =
15431543 dyn_cast_or_null(ValueList.getConstantFwdRef(Record[1],FnTy));
1544 if (Fn == 0)
1544 if (!Fn)
15451545 return Error(InvalidRecord);
15461546
15471547 // If the function is already parsed we can insert the block address right
15601560 GlobalVariable *FwdRef = new GlobalVariable(*Fn->getParent(),
15611561 Type::getInt8Ty(Context),
15621562 false, GlobalValue::InternalLinkage,
1563 0, "");
1563 nullptr, "");
15641564 BlockAddrFwdRefs[Fn].push_back(std::make_pair(Record[2], FwdRef));
15651565 V = FwdRef;
15661566 }
18531853 ExternallyInitialized = Record[9];
18541854
18551855 GlobalVariable *NewGV =
1856 new GlobalVariable(*TheModule, Ty, isConstant, Linkage, 0, "", 0,
1856 new GlobalVariable(*TheModule, Ty, isConstant, Linkage, nullptr, "", nullptr,
18571857 TLM, AddressSpace, ExternallyInitialized);
18581858 NewGV->setAlignment(Alignment);
18591859 if (!Section.empty())
19431943 return Error(InvalidTypeForValue);
19441944
19451945 GlobalAlias *NewGA = new GlobalAlias(Ty, GetDecodedLinkage(Record[2]),
1946 "", 0, TheModule);
1946 "", nullptr, TheModule);
19471947 // Old bitcode files didn't have visibility field.
19481948 if (Record.size() > 3)
19491949 NewGA->setVisibility(GetDecodedVisibility(Record[3]));
19681968 }
19691969
19701970 error_code BitcodeReader::ParseBitcodeInto(Module *M) {
1971 TheModule = 0;
1971 TheModule = nullptr;
19721972
19731973 if (error_code EC = InitStream())
19741974 return EC;
21722172 ValueList.push_back(I);
21732173
21742174 unsigned NextValueNo = ValueList.size();
2175 BasicBlock *CurBB = 0;
2175 BasicBlock *CurBB = nullptr;
21762176 unsigned CurBBNo = 0;
21772177
21782178 DebugLoc LastLoc;
22212221
22222222 // Read a record.
22232223 Record.clear();
2224 Instruction *I = 0;
2224 Instruction *I = nullptr;
22252225 unsigned BitCode = Stream.readRecord(Entry.ID, Record);
22262226 switch (BitCode) {
22272227 default: // Default behavior: reject
22392239 case bitc::FUNC_CODE_DEBUG_LOC_AGAIN: // DEBUG_LOC_AGAIN
22402240 // This record indicates that the last instruction is at the same
22412241 // location as the previous instruction with a location.
2242 I = 0;
2242 I = nullptr;
22432243
22442244 // Get the last instruction emitted.
22452245 if (CurBB && !CurBB->empty())
22482248 !FunctionBBs[CurBBNo-1]->empty())
22492249 I = &FunctionBBs[CurBBNo-1]->back();
22502250
2251 if (I == 0)
2251 if (!I)
22522252 return Error(InvalidRecord);
22532253 I->setDebugLoc(LastLoc);
2254 I = 0;
2254 I = nullptr;
22552255 continue;
22562256
22572257 case bitc::FUNC_CODE_DEBUG_LOC: { // DEBUG_LOC: [line, col, scope, ia]
2258 I = 0; // Get the last instruction emitted.
2258 I = nullptr; // Get the last instruction emitted.
22592259 if (CurBB && !CurBB->empty())
22602260 I = &CurBB->back();
22612261 else if (CurBBNo && FunctionBBs[CurBBNo-1] &&
22622262 !FunctionBBs[CurBBNo-1]->empty())
22632263 I = &FunctionBBs[CurBBNo-1]->back();
2264 if (I == 0 || Record.size() < 4)
2264 if (!I || Record.size() < 4)
22652265 return Error(InvalidRecord);
22662266
22672267 unsigned Line = Record[0], Col = Record[1];
22682268 unsigned ScopeID = Record[2], IAID = Record[3];
22692269
2270 MDNode *Scope = 0, *IA = 0;
2270 MDNode *Scope = nullptr, *IA = nullptr;
22712271 if (ScopeID) Scope = cast(MDValueList.getValueFwdRef(ScopeID-1));
22722272 if (IAID) IA = cast(MDValueList.getValueFwdRef(IAID-1));
22732273 LastLoc = DebugLoc::get(Line, Col, Scope, IA);
22742274 I->setDebugLoc(LastLoc);
2275 I = 0;
2275 I = nullptr;
22762276 continue;
22772277 }
22782278
23322332
23332333 Type *ResTy = getTypeByID(Record[OpNum]);
23342334 int Opc = GetDecodedCastOpcode(Record[OpNum+1]);
2335 if (Opc == -1 || ResTy == 0)
2336 return Error(InvalidRecord);
2337 Instruction *Temp = 0;
2335 if (Opc == -1 || !ResTy)
2336 return Error(InvalidRecord);
2337 Instruction *Temp = nullptr;
23382338 if ((I = UpgradeBitCastInst(Opc, Op, ResTy, Temp))) {
23392339 if (Temp) {
23402340 InstructionList.push_back(Temp);
25252525 }
25262526
25272527 unsigned OpNum = 0;
2528 Value *Op = NULL;
2528 Value *Op = nullptr;
25292529 if (getValueTypePair(Record, OpNum, NextValueNo, Op))
25302530 return Error(InvalidRecord);
25312531 if (OpNum != Record.size())
25392539 if (Record.size() != 1 && Record.size() != 3)
25402540 return Error(InvalidRecord);
25412541 BasicBlock *TrueDest = getBasicBlock(Record[0]);
2542 if (TrueDest == 0)
2542 if (!TrueDest)
25432543 return Error(InvalidRecord);
25442544
25452545 if (Record.size() == 1) {
25502550 BasicBlock *FalseDest = getBasicBlock(Record[1]);
25512551 Value *Cond = getValue(Record, 2, NextValueNo,
25522552 Type::getInt1Ty(Context));
2553 if (FalseDest == 0 || Cond == 0)
2553 if (!FalseDest || !Cond)
25542554 return Error(InvalidRecord);
25552555 I = BranchInst::Create(TrueDest, FalseDest, Cond);
25562556 InstructionList.push_back(I);
25702570
25712571 Value *Cond = getValue(Record, 2, NextValueNo, OpTy);
25722572 BasicBlock *Default = getBasicBlock(Record[3]);
2573 if (OpTy == 0 || Cond == 0 || Default == 0)
2573 if (!OpTy || !Cond || !Default)
25742574 return Error(InvalidRecord);
25752575
25762576 unsigned NumCases = Record[4];
26272627 Type *OpTy = getTypeByID(Record[0]);
26282628 Value *Cond = getValue(Record, 1, NextValueNo, OpTy);
26292629 BasicBlock *Default = getBasicBlock(Record[2]);
2630 if (OpTy == 0 || Cond == 0 || Default == 0)
2630 if (!OpTy || !Cond || !Default)
26312631 return Error(InvalidRecord);
26322632 unsigned NumCases = (Record.size()-3)/2;
26332633 SwitchInst *SI = SwitchInst::Create(Cond, Default, NumCases);
26362636 ConstantInt *CaseVal =
26372637 dyn_cast_or_null(getFnValueByID(Record[3+i*2], OpTy));
26382638 BasicBlock *DestBB = getBasicBlock(Record[1+3+i*2]);
2639 if (CaseVal == 0 || DestBB == 0) {
2639 if (!CaseVal || !DestBB) {
26402640 delete SI;
26412641 return Error(InvalidRecord);
26422642 }
26502650 return Error(InvalidRecord);
26512651 Type *OpTy = getTypeByID(Record[0]);
26522652 Value *Address = getValue(Record, 1, NextValueNo, OpTy);
2653 if (OpTy == 0 || Address == 0)
2653 if (!OpTy || !Address)
26542654 return Error(InvalidRecord);
26552655 unsigned NumDests = Record.size()-2;
26562656 IndirectBrInst *IBI = IndirectBrInst::Create(Address, NumDests);
26822682 return Error(InvalidRecord);
26832683
26842684 PointerType *CalleeTy = dyn_cast(Callee->getType());
2685 FunctionType *FTy = !CalleeTy ? 0 :
2685 FunctionType *FTy = !CalleeTy ? nullptr :
26862686 dyn_cast(CalleeTy->getElementType());
26872687
26882688 // Check that the right number of fixed parameters are here.
2689 if (FTy == 0 || NormalBB == 0 || UnwindBB == 0 ||
2689 if (!FTy || !NormalBB || !UnwindBB ||
26902690 Record.size() < OpNum+FTy->getNumParams())
26912691 return Error(InvalidRecord);
26922692
26942694 for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i, ++OpNum) {
26952695 Ops.push_back(getValue(Record, OpNum, NextValueNo,
26962696 FTy->getParamType(i)));
2697 if (Ops.back() == 0)
2697 if (!Ops.back())
26982698 return Error(InvalidRecord);
26992699 }
27002700
27202720 }
27212721 case bitc::FUNC_CODE_INST_RESUME: { // RESUME: [opval]
27222722 unsigned Idx = 0;
2723 Value *Val = 0;
2723 Value *Val = nullptr;
27242724 if (getValueTypePair(Record, Idx, NextValueNo, Val))
27252725 return Error(InvalidRecord);
27262726 I = ResumeInst::Create(Val);
27672767 Type *Ty = getTypeByID(Record[Idx++]);
27682768 if (!Ty)
27692769 return Error(InvalidRecord);
2770 Value *PersFn = 0;
2770 Value *PersFn = nullptr;
27712771 if (getValueTypePair(Record, Idx, NextValueNo, PersFn))
27722772 return Error(InvalidRecord);
27732773
29602960 return Error(InvalidRecord);
29612961
29622962 PointerType *OpTy = dyn_cast(Callee->getType());
2963 FunctionType *FTy = 0;
2963 FunctionType *FTy = nullptr;
29642964 if (OpTy) FTy = dyn_cast(OpTy->getElementType());
29652965 if (!FTy || Record.size() < FTy->getNumParams()+OpNum)
29662966 return Error(InvalidRecord);
29732973 else
29742974 Args.push_back(getValue(Record, OpNum, NextValueNo,
29752975 FTy->getParamType(i)));
2976 if (Args.back() == 0)
2976 if (!Args.back())
29772977 return Error(InvalidRecord);
29782978 }
29792979
30143014
30153015 // Add instruction to end of current BB. If there is no current BB, reject
30163016 // this file.
3017 if (CurBB == 0) {
3017 if (!CurBB) {
30183018 delete I;
30193019 return Error(InvalidInstructionWithNoBB);
30203020 }
30233023 // If this was a terminator instruction, move to the next block.
30243024 if (isa(I)) {
30253025 ++CurBBNo;
3026 CurBB = CurBBNo < FunctionBBs.size() ? FunctionBBs[CurBBNo] : 0;
3026 CurBB = CurBBNo < FunctionBBs.size() ? FunctionBBs[CurBBNo] : nullptr;
30273027 }
30283028
30293029 // Non-void values get registered in the value table for future use.
30353035
30363036 // Check the function list for unresolved values.
30373037 if (Argument *A = dyn_cast(ValueList.back())) {
3038 if (A->getParent() == 0) {
3038 if (!A->getParent()) {
30393039 // We found at least one unresolved value. Nuke them all to avoid leaks.
30403040 for (unsigned i = ModuleValueListSize, e = ValueList.size(); i != e; ++i){
3041 if ((A = dyn_cast_or_null(ValueList[i])) && A->getParent() == 0) {
3041 if ((A = dyn_cast_or_null(ValueList[i])) && !A->getParent()) {
30423042 A->replaceAllUsesWith(UndefValue::get(A->getType()));
30433043 delete A;
30443044 }
33473347 if (ErrMsg)
33483348 *ErrMsg = EC.message();
33493349 delete M; // Also deletes R.
3350 return 0;
3350 return nullptr;
33513351 }
33523352 R->setBufferOwned(false); // no buffer to delete
33533353 return M;
314314 if (EnterSubBlock(bitc::BLOCKINFO_BLOCK_ID)) return true;
315315
316316 SmallVector Record;
317 BitstreamReader::BlockInfo *CurBlockInfo = 0;
317 BitstreamReader::BlockInfo *CurBlockInfo = nullptr;
318318
319319 // Read all the records for this module.
320320 while (1) {
916916 SmallVector Record;
917917
918918 const ValueEnumerator::ValueList &Vals = VE.getValues();
919 Type *LastTy = 0;
919 Type *LastTy = nullptr;
920920 for (unsigned i = FirstVal; i != LastVal; ++i) {
921921 const Value *V = Vals[i].first;
922922 // If we need to switch types, do so now.
289289 cu->getCompileUnitDIE()->getAttributeValueAsSectionOffset(
290290 cu, DW_AT_stmt_list, -1U);
291291 if (stmtOffset == -1U)
292 return 0; // No line table for this compile unit.
292 return nullptr; // No line table for this compile unit.
293293
294294 // See if the line table is cached.
295295 if (const DWARFLineTable *lt = Line->getLineTable(stmtOffset))
407407 if (CU != CUs.end()) {
408408 return CU->get();
409409 }
410 return 0;
410 return nullptr;
411411 }
412412
413413 DWARFCompileUnit *DWARFContext::getCompileUnitForAddress(uint64_t Address) {
422422 uint64_t FileIndex,
423423 bool NeedsAbsoluteFilePath,
424424 std::string &FileName) {
425 if (CU == 0 ||
426 LineTable == 0 ||
425 if (!CU || !LineTable ||
427426 !LineTable->getFileNameByIndex(FileIndex, NeedsAbsoluteFilePath,
428427 FileName))
429428 return false;
445444 bool NeedsAbsoluteFilePath,
446445 std::string &FileName,
447446 uint32_t &Line, uint32_t &Column) {
448 if (CU == 0 || LineTable == 0)
447 if (!CU || !LineTable)
449448 return false;
450449 // Get the index of row we're looking for in the line table.
451450 uint32_t RowIndex = LineTable->lookupAddress(Address);
559558
560559 DIInliningInfo InliningInfo;
561560 uint32_t CallFile = 0, CallLine = 0, CallColumn = 0;
562 const DWARFLineTable *LineTable = 0;
561 const DWARFLineTable *LineTable = nullptr;
563562 for (uint32_t i = 0, n = InlinedChain.DIEs.size(); i != n; i++) {
564563 const DWARFDebugInfoEntryMinimal &FunctionDIE = InlinedChain.DIEs[i];
565564 std::string FileName = "";
669668 .Case("debug_str_offsets.dwo", &StringOffsetDWOSection)
670669 .Case("debug_addr", &AddrSection)
671670 // Any more debug info sections go here.
672 .Default(0);
671 .Default(nullptr);
673672 if (SectionData) {
674673 *SectionData = data;
675674 if (name == "debug_ranges") {
700699 .Case("debug_loc", &LocSection.Relocs)
701700 .Case("debug_info.dwo", &InfoDWOSection.Relocs)
702701 .Case("debug_line", &LineSection.Relocs)
703 .Default(0);
702 .Default(nullptr);
704703 if (!Map) {
705704 // Find debug_types relocs by section rather than name as there are
706705 // multiple, comdat grouped, debug_types sections.
4949 if (idx < Decls.size())
5050 return &Decls[idx];
5151 }
52 return NULL;
52 return nullptr;
5353 }
5454
5555 DWARFDebugAbbrev::DWARFDebugAbbrev() :
9898
9999 if (pos != AbbrevCollMap.end())
100100 return &(pos->second);
101 return NULL;
101 return nullptr;
102102 }
250250 int64_t LinkedCIEOffset, uint64_t InitialLocation, uint64_t AddressRange)
251251 : FrameEntry(FK_FDE, D, Offset, Length), LinkedCIEOffset(LinkedCIEOffset),
252252 InitialLocation(InitialLocation), AddressRange(AddressRange),
253 LinkedCIE(NULL) {}
253 LinkedCIE(nullptr) {}
254254
255255 ~FDE() {
256256 }
333333 Id = Data.getUnsigned(&Offset, IsDWARF64 ? 8 : 4);
334334 bool IsCIE = ((IsDWARF64 && Id == DW64_CIE_ID) || Id == DW_CIE_ID);
335335
336 FrameEntry *Entry = 0;
336 FrameEntry *Entry = nullptr;
337337 if (IsCIE) {
338338 // Note: this is specifically DWARFv3 CIE header structure. It was
339339 // changed in DWARFv4. We currently don't support reading DWARFv4
9898 uint64_t AbbrCode = DebugInfoData.getULEB128(OffsetPtr);
9999 if (0 == AbbrCode) {
100100 // NULL debug tag entry.
101 AbbrevDecl = NULL;
101 AbbrevDecl = nullptr;
102102 return true;
103103 }
104104 AbbrevDecl = U->getAbbreviations()->getAbbreviationDeclaration(AbbrCode);
105 if (0 == AbbrevDecl) {
105 if (nullptr == AbbrevDecl) {
106106 // Restore the original offset.
107107 *OffsetPtr = Offset;
108108 return false;
265265 const char *
266266 DWARFDebugInfoEntryMinimal::getSubroutineName(const DWARFUnit *U) const {
267267 if (!isSubroutineDIE())
268 return 0;
268 return nullptr;
269269 // Try to get mangled name if possible.
270270 if (const char *name =
271 getAttributeValueAsString(U, DW_AT_MIPS_linkage_name, 0))
271 getAttributeValueAsString(U, DW_AT_MIPS_linkage_name, nullptr))
272272 return name;
273 if (const char *name = getAttributeValueAsString(U, DW_AT_linkage_name, 0))
273 if (const char *name = getAttributeValueAsString(U, DW_AT_linkage_name,
274 nullptr))
274275 return name;
275 if (const char *name = getAttributeValueAsString(U, DW_AT_name, 0))
276 if (const char *name = getAttributeValueAsString(U, DW_AT_name, nullptr))
276277 return name;
277278 // Try to get name from specification DIE.
278279 uint32_t spec_ref =
294295 return name;
295296 }
296297 }
297 return 0;
298 return nullptr;
298299 }
299300
300301 void DWARFDebugInfoEntryMinimal::getCallerFrame(const DWARFUnit *U,
146146 LineTableConstIter pos = LineTableMap.find(offset);
147147 if (pos != LineTableMap.end())
148148 return &pos->second;
149 return 0;
149 return nullptr;
150150 }
151151
152152 const DWARFDebugLine::LineTable *
158158 // Parse and cache the line table for at this offset.
159159 State state;
160160 if (!parseStatementTable(debug_line_data, RelocMap, &offset, state))
161 return 0;
161 return nullptr;
162162 pos.first->second = state;
163163 }
164164 return &pos.first->second;
130130 const DWARFUnit *cu) {
131131 bool indirect = false;
132132 bool is_block = false;
133 Value.data = NULL;
133 Value.data = nullptr;
134134 // Read the value for the form into value and follow and DW_FORM_indirect
135135 // instances we run into
136136 do {
240240
241241 if (is_block) {
242242 StringRef str = data.getData().substr(*offset_ptr, Value.uval);
243 Value.data = NULL;
243 Value.data = nullptr;
244244 if (!str.empty()) {
245245 Value.data = reinterpret_cast(str.data());
246246 *offset_ptr += Value.uval;
487487 return None;
488488 if (Form == DW_FORM_string)
489489 return Value.cstr;
490 if (U == 0)
490 if (!U)
491491 return None;
492492 uint32_t Offset = Value.uval;
493493 if (Form == DW_FORM_GNU_str_index) {
508508 if (Form == DW_FORM_GNU_addr_index) {
509509 uint32_t Index = Value.uval;
510510 uint64_t Result;
511 if (U == 0 || !U->getAddrOffsetSectionItem(Index, Result))
511 if (!U || !U->getAddrOffsetSectionItem(Index, Result))
512512 return None;
513513 return Result;
514514 }
524524 case DW_FORM_ref4:
525525 case DW_FORM_ref8:
526526 case DW_FORM_ref_udata:
527 if (U == 0)
527 if (!U)
528528 return None;
529529 return Value.uval + U->getOffset();
530530 case DW_FORM_ref_addr:
9797 Offset = 0;
9898 Length = 0;
9999 Version = 0;
100 Abbrevs = 0;
100 Abbrevs = nullptr;
101101 AddrSize = 0;
102102 BaseAddr = 0;
103103 RangeSectionBase = 0;
109109 const char *DWARFUnit::getCompilationDir() {
110110 extractDIEsIfNeeded(true);
111111 if (DieArray.empty())
112 return 0;
113 return DieArray[0].getAttributeValueAsString(this, DW_AT_comp_dir, 0);
112 return nullptr;
113 return DieArray[0].getAttributeValueAsString(this, DW_AT_comp_dir, nullptr);
114114 }
115115
116116 uint64_t DWARFUnit::getDWOId() {
240240 DWARFUnit::DWOHolder::DWOHolder(object::ObjectFile *DWOFile)
241241 : DWOFile(DWOFile),
242242 DWOContext(cast(DIContext::getDWARFContext(DWOFile))),
243 DWOU(0) {
243 DWOU(nullptr) {
244244 if (DWOContext->getNumDWOCompileUnits() > 0)
245245 DWOU = DWOContext->getDWOCompileUnitAtIndex(0);
246246 }
247247
248248 bool DWARFUnit::parseDWO() {
249 if (DWO.get() != 0)
249 if (DWO.get())
250250 return false;
251251 extractDIEsIfNeeded(true);
252252 if (DieArray.empty())
253253 return false;
254254 const char *DWOFileName =
255 DieArray[0].getAttributeValueAsString(this, DW_AT_GNU_dwo_name, 0);
256 if (DWOFileName == 0)
255 DieArray[0].getAttributeValueAsString(this, DW_AT_GNU_dwo_name, nullptr);
256 if (!DWOFileName)
257257 return false;
258258 const char *CompilationDir =
259 DieArray[0].getAttributeValueAsString(this, DW_AT_comp_dir, 0);
259 DieArray[0].getAttributeValueAsString(this, DW_AT_comp_dir, nullptr);
260260 SmallString<16> AbsolutePath;
261 if (sys::path::is_relative(DWOFileName) && CompilationDir != 0) {
261 if (sys::path::is_relative(DWOFileName) && CompilationDir != nullptr) {
262262 sys::path::append(AbsolutePath, CompilationDir);
263263 }
264264 sys::path::append(AbsolutePath, DWOFileName);
270270 DWO.reset(new DWOHolder(DWOFile.get()));
271271 DWARFUnit *DWOCU = DWO->getUnit();
272272 // Verify that compile unit in .dwo file is valid.
273 if (DWOCU == 0 || DWOCU->getDWOId() != getDWOId()) {
273 if (!DWOCU || DWOCU->getDWOId() != getDWOId()) {
274274 DWO.reset();
275275 return false;
276276 }
336336 return &DIE;
337337 }
338338 }
339 return 0;
339 return nullptr;
340340 }
341341
342342 DWARFDebugInfoEntryInlinedChain
343343 DWARFUnit::getInlinedChainForAddress(uint64_t Address) {
344344 // First, find a subprogram that contains the given address (the root
345345 // of inlined chain).
346 const DWARFUnit *ChainCU = 0;
346 const DWARFUnit *ChainCU = nullptr;
347347 const DWARFDebugInfoEntryMinimal *SubprogramDIE =
348348 getSubprogramForAddress(Address);
349349 if (SubprogramDIE) {
4949 std::string *ErrorStr,
5050 JITMemoryManager *JMM,
5151 bool GVsWithCode,
52 TargetMachine *TM) = 0;
52 TargetMachine *TM) = nullptr;
5353 ExecutionEngine *(*ExecutionEngine::MCJITCtor)(
5454 Module *M,
5555 std::string *ErrorStr,
5656 RTDyldMemoryManager *MCJMM,
5757 bool GVsWithCode,
58 TargetMachine *TM) = 0;
58 TargetMachine *TM) = nullptr;
5959 ExecutionEngine *(*ExecutionEngine::InterpCtor)(Module *M,
60 std::string *ErrorStr) = 0;
60 std::string *ErrorStr) =nullptr;
6161
6262 ExecutionEngine::ExecutionEngine(Module *M)
6363 : EEState(*this),
64 LazyFunctionCreator(0) {
64 LazyFunctionCreator(nullptr) {
6565 CompilingLazily = false;
6666 GVCompilationDisabled = false;
6767 SymbolSearchingDisabled = false;
128128 if (Function *F = Modules[i]->getFunction(FnName))
129129 return F;
130130 }
131 return 0;
131 return nullptr;
132132 }
133133
134134
140140 // FIXME: This is silly, we shouldn't end up with a mapping -> 0 in the
141141 // GlobalAddressMap.
142142 if (I == GlobalAddressMap.end())
143 OldVal = 0;
143 OldVal = nullptr;
144144 else {
145145 OldVal = I->second;
146146 GlobalAddressMap.erase(I);
156156 DEBUG(dbgs() << "JIT: Map \'" << GV->getName()
157157 << "\' to [" << Addr << "]\n";);
158158 void *&CurVal = EEState.getGlobalAddressMap(locked)[GV];
159 assert((CurVal == 0 || Addr == 0) && "GlobalMapping already established!");
159 assert((!CurVal || !Addr) && "GlobalMapping already established!");
160160 CurVal = Addr;
161161
162162 // If we are using the reverse mapping, add it too.
163163 if (!EEState.getGlobalAddressReverseMap(locked).empty()) {
164164 AssertingVH &V =
165165 EEState.getGlobalAddressReverseMap(locked)[Addr];
166 assert((V == 0 || GV == 0) && "GlobalMapping already established!");
166 assert((!V || !GV) && "GlobalMapping already established!");
167167 V = GV;
168168 }
169169 }
192192 EEState.getGlobalAddressMap(locked);
193193
194194 // Deleting from the mapping?
195 if (Addr == 0)
195 if (!Addr)
196196 return EEState.RemoveMapping(locked, GV);
197197
198198 void *&CurVal = Map[GV];
206206 if (!EEState.getGlobalAddressReverseMap(locked).empty()) {
207207 AssertingVH &V =
208208 EEState.getGlobalAddressReverseMap(locked)[Addr];
209 assert((V == 0 || GV == 0) && "GlobalMapping already established!");
209 assert((!V || !GV) && "GlobalMapping already established!");
210210 V = GV;
211211 }
212212 return OldVal;
217217
218218 ExecutionEngineState::GlobalAddressMapTy::iterator I =
219219 EEState.getGlobalAddressMap(locked).find(GV);
220 return I != EEState.getGlobalAddressMap(locked).end() ? I->second : 0;
220 return I != EEState.getGlobalAddressMap(locked).end() ? I->second : nullptr;
221221 }
222222
223223 const GlobalValue *ExecutionEngine::getGlobalValueAtAddress(void *Addr) {
234234
235235 std::map >::iterator I =
236236 EEState.getGlobalAddressReverseMap(locked).find(Addr);
237 return I != EEState.getGlobalAddressReverseMap(locked).end() ? I->second : 0;
237 return I != EEState.getGlobalAddressReverseMap(locked).end() ? I->second : nullptr;
238238 }
239239
240240 namespace {
242242 char *Array;
243243 std::vector Values;
244244 public:
245 ArgvArray() : Array(NULL) {}
245 ArgvArray() : Array(nullptr) {}
246246 ~ArgvArray() { clear(); }
247247 void clear() {
248248 delete[] Array;
249 Array = NULL;
249 Array = nullptr;
250250 for (size_t I = 0, E = Values.size(); I != E; ++I) {
251251 delete[] Values[I];
252252 }
282282 }
283283
284284 // Null terminate it
285 EE->StoreValueToMemory(PTOGV(0),
285 EE->StoreValueToMemory(PTOGV(nullptr),
286286 (GenericValue*)(Array+InputArgv.size()*PtrSize),
287287 SBytePtr);
288288 return Array;
302302 // Should be an array of '{ i32, void ()* }' structs. The first value is
303303 // the init priority, which we ignore.
304304 ConstantArray *InitList = dyn_cast(GV->getInitializer());
305 if (InitList == 0)
305 if (!InitList)
306306 return;
307307 for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) {
308308 ConstantStruct *CS = dyn_cast(InitList->getOperand(i));
309 if (CS == 0) continue;
309 if (!CS) continue;
310310
311311 Constant *FP = CS->getOperand(1);
312312 if (FP->isNullValue())
417417 bool GVsWithCode,
418418 Reloc::Model RM,
419419 CodeModel::Model CMM) {
420 if (ExecutionEngine::JITCtor == 0) {
420 if (!ExecutionEngine::JITCtor) {
421421 if (ErrorStr)
422422 *ErrorStr = "JIT has not been linked in.";
423 return 0;
423 return nullptr;
424424 }
425425
426426 // Use the defaults for extra parameters. Users can use EngineBuilder to
436436
437437 // TODO: permit custom TargetOptions here
438438 TargetMachine *TM = EB.selectTarget();
439 if (!TM || (ErrorStr && ErrorStr->length() > 0)) return 0;
439 if (!TM || (ErrorStr && ErrorStr->length() > 0)) return nullptr;
440440
441441 return ExecutionEngine::JITCtor(M, ErrorStr, JMM, GVsWithCode, TM);
442442 }
446446
447447 // Make sure we can resolve symbols in the program as well. The zero arg
448448 // to the function tells DynamicLibrary to load the program, not a library.
449 if (sys::DynamicLibrary::LoadLibraryPermanently(0, ErrorStr))
450 return 0;
449 if (sys::DynamicLibrary::LoadLibraryPermanently(nullptr, ErrorStr))
450 return nullptr;
451451
452452 assert(!(JMM && MCJMM));
453453
460460 else {
461461 if (ErrorStr)
462462 *ErrorStr = "Cannot create an interpreter with a memory manager.";
463 return 0;
463 return nullptr;
464464 }
465465 }
466466
469469 *ErrorStr =
470470 "Cannot create a legacy JIT with a runtime dyld memory "
471471 "manager.";
472 return 0;
472 return nullptr;
473473 }
474474
475475 // Unless the interpreter was explicitly selected or the JIT is not linked,
502502 return ExecutionEngine::InterpCtor(M, ErrorStr);
503503 if (ErrorStr)
504504 *ErrorStr = "Interpreter has not been linked in.";
505 return 0;
506 }
507
508 if ((WhichEngine & EngineKind::JIT) && ExecutionEngine::JITCtor == 0 &&
509 ExecutionEngine::MCJITCtor == 0) {
505 return nullptr;
506 }
507
508 if ((WhichEngine & EngineKind::JIT) && !ExecutionEngine::JITCtor &&
509 !ExecutionEngine::MCJITCtor) {
510510 if (ErrorStr)
511511 *ErrorStr = "JIT has not been linked in.";
512512 }
513513
514 return 0;
514 return nullptr;
515515 }
516516
517517 void *ExecutionEngine::getPointerToGlobal(const GlobalValue *GV) {
847847 break;
848848 case Type::PointerTyID:
849849 if (isa(C))
850 Result.PointerVal = 0;
850 Result.PointerVal = nullptr;
851851 else if (const Function *F = dyn_cast(C))
852852 Result = PTOGV(getPointerToFunctionOrStub(const_cast(F)));
853853 else if (const GlobalVariable *GV = dyn_cast(C))
12891289 void ExecutionEngine::EmitGlobalVariable(const GlobalVariable *GV) {
12901290 void *GA = getPointerToGlobalIfAvailable(GV);
12911291
1292 if (GA == 0) {
1292 if (!GA) {
12931293 // If it's not already specified, allocate memory for the global.
12941294 GA = getMemoryForGV(GV);
12951295
12961296 // If we failed to allocate memory for this global, return.
1297 if (GA == 0) return;
1297 if (!GA) return;
12981298
12991299 addGlobalMapping(GV, GA);
13001300 }
409409 }
410410
411411 bool SimpleBindingMemoryManager::finalizeMemory(std::string *ErrMsg) {
412 char *errMsgCString = 0;
412 char *errMsgCString = nullptr;
413413 bool result = Functions.FinalizeMemory(Opaque, &errMsgCString);
414414 assert((result || !errMsgCString) &&
415415 "Did not expect an error message if FinalizeMemory succeeded");
432432
433433 if (!AllocateCodeSection || !AllocateDataSection || !FinalizeMemory ||
434434 !Destroy)
435 return NULL;
435 return nullptr;
436436
437437 SimpleBindingMMFunctions functions;
438438 functions.AllocateCodeSection = AllocateCodeSection;
4646 TheTriple.setTriple(sys::getProcessTriple());
4747
4848 // Adjust the triple to match what the user requested.
49 const Target *TheTarget = 0;
49 const Target *TheTarget = nullptr;
5050 if (!MArch.empty()) {
5151 for (TargetRegistry::iterator it = TargetRegistry::begin(),
5252 ie = TargetRegistry::end(); it != ie; ++it) {
6060 if (ErrorStr)
6161 *ErrorStr = "No available targets are compatible with this -march, "
6262 "see -version for the available targets.\n";
63 return 0;
63 return nullptr;
6464 }
6565
6666 // Adjust the triple to match (if known), otherwise stick with the
7171 } else {
7272 std::string Error;
7373 TheTarget = TargetRegistry::lookupTarget(TheTriple.getTriple(), Error);
74 if (TheTarget == 0) {
74 if (!TheTarget) {
7575 if (ErrorStr)
7676 *ErrorStr = Error;
77 return 0;
77 return nullptr;
7878 }
7979 }
8080
8080 }
8181 }
8282
83 assert(getParent() == 0 && "BasicBlock still linked into the program!");
83 assert(getParent() == nullptr && "BasicBlock still linked into the program!");
8484 dropAllReferences();
8585 InstList.clear();
8686 }
19501950 if (isa(C)) {
19511951 PointerType *Ptr = cast(C->getType());
19521952 Type *Ty = GetElementPtrInst::getIndexedType(Ptr, Idxs);
1953 assert(Ty != 0 && "Invalid indices for GEP!");
1953 assert(Ty && "Invalid indices for GEP!");
19541954 return UndefValue::get(PointerType::get(Ty, Ptr->getAddressSpace()));
19551955 }
19561956
19641964 if (isNull) {
19651965 PointerType *Ptr = cast(C->getType());
19661966 Type *Ty = GetElementPtrInst::getIndexedType(Ptr, Idxs);
1967 assert(Ty != 0 && "Invalid indices for GEP!");
1967 assert(Ty && "Invalid indices for GEP!");
19681968 return ConstantPointerNull::get(PointerType::get(Ty,
19691969 Ptr->getAddressSpace()));
19701970 }
13531353 //
13541354
13551355 BlockAddress *BlockAddress::get(BasicBlock *BB) {
1356 assert(BB->getParent() != 0 && "Block must have a parent");
1356 assert(BB->getParent() && "Block must have a parent");
13571357 return get(BB->getParent(), BB);
13581358 }
13591359
13801380 return nullptr;
13811381
13821382 const Function *F = BB->getParent();
1383 assert(F != 0 && "Block must have a parent");
1383 assert(F && "Block must have a parent");
13841384 BlockAddress *BA =
13851385 F->getContext().pImpl->BlockAddresses.lookup(std::make_pair(F, BB));
13861386 assert(BA && "Refcount and block address map disagree!");
259259
260260 MDNode *OldScope = Entry.first.get();
261261 MDNode *OldInlinedAt = Entry.second.get();
262 assert(OldScope != 0 && OldInlinedAt != 0 &&
262 assert(OldScope && OldInlinedAt &&
263263 "Entry should be non-canonical if either val dropped to null");
264264
265265 // Otherwise, we do have an entry in it, nuke it and we're done.
313313
314314 MDNode *OldScope = Entry.first.get();
315315 MDNode *OldInlinedAt = Entry.second.get();
316 assert(OldScope != 0 && OldInlinedAt != 0 &&
316 assert(OldScope && OldInlinedAt &&
317317 "Entry should be non-canonical if either val dropped to null");
318318
319319 // Otherwise, we do have an entry in it, nuke it and we're done.
5252
5353 // Out of line virtual method, so the vtable, etc has a home.
5454 Instruction::~Instruction() {
55 assert(Parent == 0 && "Instruction still linked in the program!");
55 assert(!Parent && "Instruction still linked in the program!");
5656 if (hasMetadataHashEntry())
5757 clearMetadataHashEntries();
5858 }
731731 : TerminatorInst(Type::getVoidTy(IfTrue->getContext()), Instruction::Br,
732732 OperandTraits::op_end(this) - 1,
733733 1, InsertBefore) {
734 assert(IfTrue != 0 && "Branch destination may not be null!");
734 assert(IfTrue && "Branch destination may not be null!");
735735 Op<-1>() = IfTrue;
736736 }
737737 BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
751751 : TerminatorInst(Type::getVoidTy(IfTrue->getContext()), Instruction::Br,
752752 OperandTraits::op_end(this) - 1,
753753 1, InsertAtEnd) {
754 assert(IfTrue != 0 && "Branch destination may not be null!");
754 assert(IfTrue && "Branch destination may not be null!");
755755 Op<-1>() = IfTrue;
756756 }
757757
2222
2323 MDNode *MDBuilder::createFPMath(float Accuracy) {
2424 if (Accuracy == 0.0)
25 return 0;
25 return nullptr;
2626 assert(Accuracy > 0.0 && "Invalid fpmath accuracy!");
2727 Value *Op = ConstantFP::get(Type::getFloatTy(Context), Accuracy);
2828 return MDNode::get(Context, Op);
163163
164164 #ifndef NDEBUG
165165 static const Function *assertLocalFunction(const MDNode *N) {
166 if (!N->isFunctionLocal()) return 0;
166 if (!N->isFunctionLocal()) return nullptr;
167167
168168 // FIXME: This does not handle cyclic function local metadata.
169 const Function *F = 0, *NewF = 0;
169 const Function *F = nullptr, *NewF = nullptr;
170170 for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
171171 if (Value *V = N->getOperand(i)) {
172172 if (MDNode *MD = dyn_cast(V))
174174 else
175175 NewF = getFunctionForValue(V);
176176 }
177 if (F == 0)
177 if (!F)
178178 F = NewF;
179 else
180 assert((NewF == 0 || F == NewF) &&"inconsistent function-local metadata");
179 else
180 assert((NewF == nullptr || F == NewF) &&
181 "inconsistent function-local metadata");
181182 }
182183 return F;
183184 }
173173 "Cannot add a pass to the same analysis group more than once!");
174174 AGI.Implementations.insert(ImplementationInfo);
175175 if (isDefault) {
176 assert(InterfaceInfo->getNormalCtor() == 0 &&
176 assert(InterfaceInfo->getNormalCtor() == nullptr &&
177177 "Default implementation for analysis group already specified!");
178178 assert(ImplementationInfo->getNormalCtor() &&
179179 "Cannot specify pass as default if it does not have a default ctor");
496496 }
497497
498498 StructType *StructType::get(Type *type, ...) {
499 assert(type != 0 && "Cannot create a struct type with no elements with this");
499 assert(type && "Cannot create a struct type with no elements with this");
500500 LLVMContext &Ctx = type->getContext();
501501 va_list ap;
502502 SmallVector StructFields;
537537 }
538538
539539 StructType *StructType::create(StringRef Name, Type *type, ...) {
540 assert(type != 0 && "Cannot create a struct type with no elements with this");
540 assert(type && "Cannot create a struct type with no elements with this");
541541 LLVMContext &Ctx = type->getContext();
542542 va_list ap;
543543 SmallVector StructFields;
581581 }
582582
583583 void StructType::setBody(Type *type, ...) {
584 assert(type != 0 && "Cannot create a struct type with no elements with this");
584 assert(type && "Cannot create a struct type with no elements with this");
585585 va_list ap;
586586 SmallVector StructFields;
587587 va_start(ap, type);
556556 // If this value already has a ValueHandle, then it must be in the
557557 // ValueHandles map already.
558558 ValueHandleBase *&Entry = pImpl->ValueHandles[VP.getPointer()];
559 assert(Entry != 0 && "Value doesn't have any handles?");
559 assert(Entry && "Value doesn't have any handles?");
560560 AddToExistingUseList(&Entry);
561561 return;
562562 }
570570 const void *OldBucketPtr = Handles.getPointerIntoBucketsArray();
571571
572572 ValueHandleBase *&Entry = Handles[VP.getPointer()];
573 assert(Entry == 0 && "Value really did already have handles?");
573 assert(!Entry && "Value really did already have handles?");
574574 AddToExistingUseList(&Entry);
575575 VP.getPointer()->HasValueHandle = true;
576576
4141 // ParseBitcodeFile does not take ownership of the Buffer in the
4242 // case of an error.
4343 delete Buffer;
44 return NULL;
44 return nullptr;
4545 }
4646 return ModuleOrErr.get();
4747 }
4848
49 return ParseAssembly(Buffer, 0, Err, Context);
49 return ParseAssembly(Buffer, nullptr, Err, Context);
5050 }
5151
5252 Module *llvm::getLazyIRFileModule(const std::string &Filename, SMDiagnostic &Err,
5555 if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, File)) {
5656 Err = SMDiagnostic(Filename, SourceMgr::DK_Error,
5757 "Could not open input file: " + ec.message());
58 return 0;
58 return nullptr;
5959 }
6060
6161 return getLazyIRModule(File.release(), Err, Context);
6868 if (isBitcode((const unsigned char *)Buffer->getBufferStart(),
6969 (const unsigned char *)Buffer->getBufferEnd())) {
7070 ErrorOr ModuleOrErr = parseBitcodeFile(Buffer, Context);
71 Module *M = 0;
71 Module *M = nullptr;
7272 if (error_code EC = ModuleOrErr.getError())
7373 Err = SMDiagnostic(Buffer->getBufferIdentifier(), SourceMgr::DK_Error,
7474 EC.message());
7979 return M;
8080 }
8181
82 return ParseAssembly(Buffer, 0, Err, Context);
82 return ParseAssembly(Buffer, nullptr, Err, Context);
8383 }
8484
8585 Module *llvm::ParseIRFile(const std::string &Filename, SMDiagnostic &Err,
8888 if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, File)) {
8989 Err = SMDiagnostic(Filename, SourceMgr::DK_Error,
9090 "Could not open input file: " + ec.message());
91 return 0;
91 return nullptr;
9292 }
9393
9494 return ParseIR(File.release(), Err, Context);
110110 std::string buf;
111111 raw_string_ostream os(buf);
112112
113 Diag.print(NULL, os, false);
113 Diag.print(nullptr, os, false);
114114 os.flush();
115115
116116 *OutMessage = strdup(buf.c_str());
6363
6464 LTOCodeGenerator::LTOCodeGenerator()
6565 : Context(getGlobalContext()), Linker(new Module("ld-temp.o", Context)),
66 TargetMach(NULL), EmitDwarfDebugInfo(false), ScopeRestrictionsDone(false),
67 CodeModel(LTO_CODEGEN_PIC_MODEL_DEFAULT), NativeObjectFile(NULL),
68 DiagHandler(NULL), DiagContext(NULL) {
66 TargetMach(nullptr), EmitDwarfDebugInfo(false),
67 ScopeRestrictionsDone(false), CodeModel(LTO_CODEGEN_PIC_MODEL_DEFAULT),
68 NativeObjectFile(nullptr), DiagHandler(nullptr), DiagContext(nullptr) {
6969 initializeLTOPasses();
7070 }
7171
7272 LTOCodeGenerator::~LTOCodeGenerator() {
7373 delete TargetMach;
7474 delete NativeObjectFile;
75 TargetMach = NULL;
76 NativeObjectFile = NULL;
75 TargetMach = nullptr;
76 NativeObjectFile = nullptr;
7777
7878 Linker.deleteModule();
7979
244244 const char *name;
245245 if (!compile_to_file(&name, disableOpt, disableInline, disableGVNLoadPRE,
246246 errMsg))
247 return NULL;
247 return nullptr;
248248
249249 // remove old buffer if compile() called twice
250250 delete NativeObjectFile;
254254 if (error_code ec = MemoryBuffer::getFile(name, BuffPtr, -1, false)) {
255255 errMsg = ec.message();
256256 sys::fs::remove(NativeObjectPath);
257 return NULL;
257 return nullptr;
258258 }
259259 NativeObjectFile = BuffPtr.release();
260260
262262 sys::fs::remove(NativeObjectPath);
263263
264264 // return buffer, unless error
265 if (NativeObjectFile == NULL)
266 return NULL;
265 if (!NativeObjectFile)
266 return nullptr;
267267 *length = NativeObjectFile->getBufferSize();
268268 return NativeObjectFile->getBufferStart();
269269 }
270270
271271 bool LTOCodeGenerator::determineTarget(std::string &errMsg) {
272 if (TargetMach != NULL)
272 if (TargetMach)
273273 return true;
274274
275275 std::string TripleStr = Linker.getModule()->getTargetTriple();
279279
280280 // create target machine from info for merged modules
281281 const Target *march = TargetRegistry::lookupTarget(TripleStr, errMsg);
282 if (march == NULL)
282 if (!march)
283283 return false;
284284
285285 // The relocation model is actually a static member of TargetMachine and
354354
355355 static void findUsedValues(GlobalVariable *LLVMUsed,
356356 SmallPtrSet &UsedValues) {
357 if (LLVMUsed == 0) return;
357 if (!LLVMUsed) return;
358358
359359 ConstantArray *Inits = cast(LLVMUsed->getInitializer());
360360 for (unsigned i = 0, e = Inits->getNumOperands(); i != e; ++i)
578578 this->DiagHandler = DiagHandler;
579579 this->DiagContext = Ctxt;
580580 if (!DiagHandler)
581 return Context.setDiagnosticHandler(NULL, NULL);
581 return Context.setDiagnosticHandler(nullptr, nullptr);
582582 // Register the LTOCodeGenerator stub in the LLVMContext to forward the
583583 // diagnostic to the external DiagHandler.
584584 Context.setDiagnosticHandler(LTOCodeGenerator::DiagnosticHandler, this);
9999 std::unique_ptr buffer;
100100 if (error_code ec = MemoryBuffer::getFile(path, buffer)) {
101101 errMsg = ec.message();
102 return NULL;
102 return nullptr;
103103 }
104104 return makeLTOModule(buffer.release(), options, errMsg);
105105 }
119119 if (error_code ec =
120120 MemoryBuffer::getOpenFileSlice(fd, path, buffer, map_size, offset)) {
121121 errMsg = ec.message();
122 return NULL;
122 return nullptr;
123123 }
124124 return makeLTOModule(buffer.release(), options, errMsg);
125125 }
129129 std::string &errMsg, StringRef path) {
130130 std::unique_ptr buffer(makeBuffer(mem, length, path));
131131 if (!buffer)
132 return NULL;
132 return nullptr;
133133 return makeLTOModule(buffer.release(), options, errMsg);
134134 }
135135
142142 if (error_code EC = ModuleOrErr.getError()) {
143143 errMsg = EC.message();
144144 delete buffer;
145 return NULL;
145 return nullptr;
146146 }
147147 std::unique_ptr m(ModuleOrErr.get());
148148
154154 // find machine architecture for this module
155155 const Target *march = TargetRegistry::lookupTarget(TripleStr, errMsg);
156156 if (!march)
157 return NULL;
157 return nullptr;
158158
159159 // construct LTOModule, hand over ownership of module and target
160160 SubtargetFeatures Features;
188188
189189 if (Ret->parseSymbols(errMsg)) {
190190 delete Ret;
191 return NULL;
191 return nullptr;
192192 }
193193
194194 Ret->parseMetadata();
459459
460460 NameAndAttributes &info = _undefines[entry.getKey().data()];
461461
462 if (info.symbol == 0) {
462 if (info.symbol == nullptr) {
463463 // FIXME: This is trying to take care of module ASM like this:
464464 //
465465 // module asm ".zerofill __FOO, __foo, _bar_baz_qux, 0"
473473 info.attributes =
474474 LTO_SYMBOL_PERMISSIONS_DATA | LTO_SYMBOL_DEFINITION_REGULAR | scope;
475475 info.isFunction = false;
476 info.symbol = 0;
476 info.symbol = nullptr;
477477
478478 // add to table of symbols
479479 _symbols.push_back(info);
507507 info.name = entry.getKey().data();
508508 info.attributes = attr;
509509 info.isFunction = false;
510 info.symbol = 0;
510 info.symbol = nullptr;
511511
512512 entry.setValue(info);
513513 }
438438 // If the source has no name it can't link. If it has local linkage,
439439 // there is no name match-up going on.
440440 if (!SrcGV->hasName() || SrcGV->hasLocalLinkage())
441 return 0;
441 return nullptr;
442442
443443 // Otherwise see if we have a match in the destination module's symtab.
444444 GlobalValue *DGV = DstM->getNamedValue(SrcGV->getName());
445 if (DGV == 0) return 0;
445 if (!DGV) return nullptr;
446446
447447 // If we found a global with the same name in the dest module, but it has
448448 // internal linkage, we are really not doing any linkage here.
449449 if (DGV->hasLocalLinkage())
450 return 0;
450 return nullptr;
451451
452452 // Otherwise, we do in fact link to the destination global.
453453 return DGV;
517517 Value *ValueMaterializerTy::materializeValueFor(Value *V) {
518518 Function *SF = dyn_cast(V);
519519 if (!SF)
520 return NULL;
520 return nullptr;
521521
522522 Function *DF = Function::Create(TypeMap.get(SF->getFunctionType()),
523523 SF->getLinkage(), SF->getName(), DstM);
611611 for (Module::global_iterator I = SrcM->global_begin(),
612612 E = SrcM->global_end(); I != E; ++I) {
613613 GlobalValue *DGV = getLinkedToGlobal(I);
614 if (DGV == 0) continue;
614 if (!DGV) continue;
615615
616616 if (!DGV->hasAppendingLinkage() || !I->hasAppendingLinkage()) {
617617 TypeMap.addTypeMapping(DGV->getType(), I->getType());
722722 // Create the new global variable.
723723 GlobalVariable *NG =
724724 new GlobalVariable(*DstGV->getParent(), NewType, SrcGV->isConstant(),
725 DstGV->getLinkage(), /*init*/0, /*name*/"", DstGV,
725 DstGV->getLinkage(), /*init*/nullptr, /*name*/"", DstGV,
726726 DstGV->getThreadLocalMode(),
727727 DstGV->getType()->getAddressSpace());
728728
799799 // initializer will be filled in later by LinkGlobalInits.
800800 GlobalVariable *NewDGV =
801801 new GlobalVariable(*DstM, TypeMap.get(SGV->getType()->getElementType()),
802 SGV->isConstant(), SGV->getLinkage(), /*init*/0,
803 SGV->getName(), /*insertbefore*/0,
802 SGV->isConstant(), SGV->getLinkage(), /*init*/nullptr,
803 SGV->getName(), /*insertbefore*/nullptr,
804804 SGV->getThreadLocalMode(),
805805 SGV->getType()->getAddressSpace());
806806 // Propagate alignment, visibility and section info.
912912 // bring over SGA.
913913 GlobalAlias *NewDA = new GlobalAlias(TypeMap.get(SGA->getType()),
914914 SGA->getLinkage(), SGA->getName(),
915 /*aliasee*/0, DstM);
915 /*aliasee*/nullptr, DstM);
916916 copyGVAttributes(NewDA, SGA);
917917 if (NewVisibility)
918918 NewDA->setVisibility(*NewVisibility);
996996 } else {
997997 // Clone the body of the function into the dest function.
998998 SmallVector Returns; // Ignore returns.
999 CloneFunctionInto(Dst, Src, ValueMap, false, Returns, "", NULL,
999 CloneFunctionInto(Dst, Src, ValueMap, false, Returns, "", nullptr,
10001000 &TypeMap, &ValMaterializer);
10011001 }
10021002
13681368
13691369 void Linker::deleteModule() {
13701370 delete Composite;
1371 Composite = NULL;
1371 Composite = nullptr;
13721372 }
13731373
13741374 bool Linker::linkInModule(Module *Src, unsigned Mode, std::string *ErrorMsg) {
14051405 LLVMLinkerMode Mode, char **OutMessages) {
14061406 std::string Messages;
14071407 LLVMBool Result = Linker::LinkModules(unwrap(Dest), unwrap(Src),
1408 Mode, OutMessages? &Messages : 0);
1408 Mode, OutMessages? &Messages : nullptr);
14091409 if (OutMessages)
14101410 *OutMessages = strdup(Messages.c_str());
14111411 return Result;
110110
111111 // Check to see if this is past the end of the archive.
112112 if (NextLoc >= Parent->Data->getBufferEnd())
113 return Child(Parent, NULL);
113 return Child(Parent, nullptr);
114114
115115 return Child(Parent, NextLoc);
116116 }
348348 }
349349
350350 Archive::child_iterator Archive::child_end() const {
351 return Child(this, NULL);
351 return Child(this, nullptr);
352352 }
353353
354354 error_code Archive::Symbol::getName(StringRef &Result) const {
137137 error_code COFFObjectFile::getSymbolAddress(DataRefImpl Ref,
138138 uint64_t &Result) const {
139139 const coff_symbol *Symb = toSymb(Ref);
140 const coff_section *Section = NULL;
140 const coff_section *Section = nullptr;
141141 if (error_code EC = getSection(Symb->SectionNumber, Section))
142142 return EC;
143143
162162 } else {
163163 uint32_t Characteristics = 0;
164164 if (!COFF::isReservedSectionNumber(Symb->SectionNumber)) {
165 const coff_section *Section = NULL;
165 const coff_section *Section = nullptr;
166166 if (error_code EC = getSection(Symb->SectionNumber, Section))
167167 return EC;
168168 Characteristics = Section->Characteristics;
207207 // in the same section as this symbol, and looking for either the next
208208 // symbol, or the end of the section.
209209 const coff_symbol *Symb = toSymb(Ref);
210 const coff_section *Section = NULL;
210 const coff_section *Section = nullptr;
211211 if (error_code EC = getSection(Symb->SectionNumber, Section))
212212 return EC;
213213
226226 if (COFF::isReservedSectionNumber(Symb->SectionNumber)) {
227227 Result = section_end();
228228 } else {
229 const coff_section *Sec = 0;
229 const coff_section *Sec = nullptr;
230230 if (error_code EC = getSection(Symb->SectionNumber, Sec)) return EC;
231231 DataRefImpl Ref;
232232 Ref.p = reinterpret_cast(Sec);
333333 bool &Result) const {
334334 const coff_section *Sec = toSec(SecRef);
335335 const coff_symbol *Symb = toSymb(SymbRef);
336 const coff_section *SymbSec = 0;
336 const coff_section *SymbSec = nullptr;
337337 if (error_code EC = getSection(Symb->SectionNumber, SymbSec)) return EC;
338338 if (SymbSec == Sec)
339339 Result = true;
506506
507507 COFFObjectFile::COFFObjectFile(MemoryBuffer *Object, error_code &EC,
508508 bool BufferOwned)
509 : ObjectFile(Binary::ID_COFF, Object, BufferOwned), COFFHeader(0),
510 PE32Header(0), PE32PlusHeader(0), DataDirectory(0), SectionTable(0),
511 SymbolTable(0), StringTable(0), StringTableSize(0), ImportDirectory(0),
512 NumberOfImportDirectory(0), ExportDirectory(0) {
509 : ObjectFile(Binary::ID_COFF, Object, BufferOwned), COFFHeader(nullptr),
510 PE32Header(nullptr), PE32PlusHeader(nullptr), DataDirectory(nullptr),
511 SectionTable(nullptr), SymbolTable(nullptr), StringTable(nullptr),
512 StringTableSize(0), ImportDirectory(nullptr), NumberOfImportDirectory(0),
513 ExportDirectory(nullptr) {
513514 // Check that we at least have enough room for a header.
514515 if (!checkSize(Data, EC, sizeof(coff_file_header))) return;
515516
631632 }
632633
633634 export_directory_iterator COFFObjectFile::export_directory_end() const {
634 if (ExportDirectory == 0)
635 return export_directory_iterator(ExportDirectoryEntryRef(0, 0, this));
635 if (!ExportDirectory)
636 return export_directory_iterator(ExportDirectoryEntryRef(nullptr, 0, this));
636637 ExportDirectoryEntryRef Ref(ExportDirectory,
637638 ExportDirectory->AddressTableEntries, this);
638639 return export_directory_iterator(Ref);
722723 const coff_section *&Result) const {
723724 // Check for special index values.
724725 if (COFF::isReservedSectionNumber(Index))
725 Result = NULL;
726 Result = nullptr;
726727 else if (Index > 0 && Index <= COFFHeader->NumberOfSections)
727728 // We already verified the section table data, so no need to check again.
728729 Result = SectionTable + (Index - 1);
772773
773774 ArrayRef COFFObjectFile::getSymbolAuxData(
774775 const coff_symbol *Symbol) const {
775 const uint8_t *Aux = NULL;
776 const uint8_t *Aux = nullptr;
776777
777778 if (Symbol->NumberOfAuxSymbols > 0) {
778779 // AUX data comes immediately after the symbol in COFF
967968 error_code COFFObjectFile::getRelocationValueString(DataRefImpl Rel,
968969 SmallVectorImpl &Result) const {
969970 const coff_relocation *Reloc = toRel(Rel);
970 const coff_symbol *Symb = 0;
971 const coff_symbol *Symb = nullptr;
971972 if (error_code EC = getSymbol(Reloc->SymbolTableIndex, Symb)) return EC;
972973 DataRefImpl Sym;
973974 Sym.p = reinterpret_cast(Symb);
419419 bool Is64bits, error_code &EC,
420420 bool BufferOwned)
421421 : ObjectFile(getMachOType(IsLittleEndian, Is64bits), Object, BufferOwned),
422 SymtabLoadCmd(NULL), DysymtabLoadCmd(NULL), DataInCodeLoadCmd(NULL) {
422 SymtabLoadCmd(nullptr), DysymtabLoadCmd(nullptr),
423 DataInCodeLoadCmd(nullptr) {
423424 uint32_t LoadCommandCount = this->getHeader().ncmds;
424425 MachO::LoadCommandType SegmentLoadType = is64Bit() ?
425426 MachO::LC_SEGMENT_64 : MachO::LC_SEGMENT;
5656 MachOUniversalBinary::ObjectForArch::ObjectForArch(
5757 const MachOUniversalBinary *Parent, uint32_t Index)
5858 : Parent(Parent), Index(Index) {
59 if (Parent == 0 || Index > Parent->getNumberOfObjects()) {
59 if (!Parent || Index > Parent->getNumberOfObjects()) {
6060 clear();
6161 } else {
6262 // Parse object header.
5959 // ObjectFile creation
6060 LLVMObjectFileRef LLVMCreateObjectFile(LLVMMemoryBufferRef MemBuf) {
6161 ErrorOr ObjOrErr(ObjectFile::createObjectFile(unwrap(MemBuf)));
62 ObjectFile *Obj = ObjOrErr ? ObjOrErr.get() : 0;
62 ObjectFile *Obj = ObjOrErr ? ObjOrErr.get() : nullptr;
6363 return wrap(Obj);
6464 }
6565
5959 for (const_reverse_iterator it = rbegin(), ie = rend(); it != ie; ++it)
6060 if ((*it)->getOption().matches(Id))
6161 return *it;
62 return 0;
62 return nullptr;
6363 }
6464
6565 Arg *ArgList::getLastArg(OptSpecifier Id) const {
66 Arg *Res = 0;
66 Arg *Res = nullptr;
6767 for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
6868 if ((*it)->getOption().matches(Id)) {
6969 Res = *it;
7575 }
7676
7777 Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1) const {
78 Arg *Res = 0;
78 Arg *Res = nullptr;
7979 for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
8080 if ((*it)->getOption().matches(Id0) ||
8181 (*it)->getOption().matches(Id1)) {
9090
9191 Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
9292 OptSpecifier Id2) const {
93 Arg *Res = 0;
93 Arg *Res = nullptr;
9494 for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
9595 if ((*it)->getOption().matches(Id0) ||
9696 (*it)->getOption().matches(Id1) ||
105105
106106 Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
107107 OptSpecifier Id2, OptSpecifier Id3) const {
108 Arg *Res = 0;
108 Arg *Res = nullptr;
109109 for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
110110 if ((*it)->getOption().matches(Id0) ||
111111 (*it)->getOption().matches(Id1) ||
122122 Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
123123 OptSpecifier Id2, OptSpecifier Id3,
124124 OptSpecifier Id4) const {
125 Arg *Res = 0;
125 Arg *Res = nullptr;
126126 for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
127127 if ((*it)->getOption().matches(Id0) ||
128128 (*it)->getOption().matches(Id1) ||
140140 Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
141141 OptSpecifier Id2, OptSpecifier Id3,
142142 OptSpecifier Id4, OptSpecifier Id5) const {
143 Arg *Res = 0;
143 Arg *Res = nullptr;
144144 for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
145145 if ((*it)->getOption().matches(Id0) ||
146146 (*it)->getOption().matches(Id1) ||
160160 OptSpecifier Id2, OptSpecifier Id3,
161161 OptSpecifier Id4, OptSpecifier Id5,
162162 OptSpecifier Id6) const {
163 Arg *Res = 0;
163 Arg *Res = nullptr;
164164 for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
165165 if ((*it)->getOption().matches(Id0) ||
166166 (*it)->getOption().matches(Id1) ||
181181 OptSpecifier Id2, OptSpecifier Id3,
182182 OptSpecifier Id4, OptSpecifier Id5,
183183 OptSpecifier Id6, OptSpecifier Id7) const {
184 Arg *Res = 0;
184 Arg *Res = nullptr;
185185 for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
186186 if ((*it)->getOption().matches(Id0) ||
187187 (*it)->getOption().matches(Id1) ||
6161
6262 for (const char * const *APre = A.Prefixes,
6363 * const *BPre = B.Prefixes;
64 *APre != 0 && *BPre != 0; ++APre, ++BPre) {
64 *APre != nullptr && *BPre != nullptr; ++APre, ++BPre){
6565 if (int N = StrCmpOptionName(*APre, *BPre))
6666 return N < 0;
6767 }
135135 for (unsigned i = FirstSearchableIndex + 1, e = getNumOptions() + 1;
136136 i != e; ++i) {
137137 if (const char *const *P = getInfo(i).Prefixes) {
138 for (; *P != 0; ++P) {
138 for (; *P != nullptr; ++P) {
139139 PrefixesUnion.insert(*P);
140140 }
141141 }
159159 const Option OptTable::getOption(OptSpecifier Opt) const {
160160 unsigned id = Opt.getID();
161161 if (id == 0)
162 return Option(0, 0);
162 return Option(nullptr, nullptr);
163163 assert((unsigned) (id - 1) < getNumOptions() && "Invalid ID.");
164164 return Option(&getInfo(id), this);