i != e; ++i)
if (BlockInfoRecords[i].BlockID == BlockID)
return &BlockInfoRecords[i];
- return 0;
+ return nullptr;
}
BlockInfo &getOrCreateBlockInfo(unsigned BlockID) {
public:
- BitstreamCursor() : BitStream(0), NextChar(0) {
- }
- BitstreamCursor(const BitstreamCursor &RHS) : BitStream(0), NextChar(0) {
+ BitstreamCursor() : BitStream(nullptr), NextChar(0) {}
+ BitstreamCursor(const BitstreamCursor &RHS)
+ : BitStream(nullptr), NextChar(0) {
operator=(RHS);
}
/// EnterSubBlock - Having read the ENTER_SUBBLOCK abbrevid, enter
/// the block, and return true if the block has an error.
- bool EnterSubBlock(unsigned BlockID, unsigned *NumWordsP = 0);
+ bool EnterSubBlock(unsigned BlockID, unsigned *NumWordsP = nullptr);
bool ReadBlockEnd() {
if (BlockScope.empty()) return true;
void skipRecord(unsigned AbbrevID);
unsigned readRecord(unsigned AbbrevID, SmallVectorImpl<uint64_t> &Vals,
- StringRef *Blob = 0);
+ StringRef *Blob = nullptr);
//===--------------------------------------------------------------------===//
// Abbrev Processing
i != e; ++i)
if (BlockInfoRecords[i].BlockID == BlockID)
return &BlockInfoRecords[i];
- return 0;
+ return nullptr;
}
void EnterSubblock(unsigned BlockID, unsigned CodeLen) {
EmitAbbreviatedField(EltEnc, (unsigned char)BlobData[i]);
// Know that blob data is consumed for assertion below.
- BlobData = 0;
+ BlobData = nullptr;
} else {
// Emit a vbr6 to indicate the number of elements present.
EmitVBR(static_cast<uint32_t>(Vals.size()-RecordIdx), 6);
WriteByte((unsigned char)BlobData[i]);
// Know that blob data is consumed for assertion below.
- BlobData = 0;
+ BlobData = nullptr;
} else {
for (unsigned e = Vals.size(); RecordIdx != e; ++RecordIdx) {
assert(isUInt<8>(Vals[RecordIdx]) &&
}
}
assert(RecordIdx == Vals.size() && "Not all record operands emitted!");
- assert(BlobData == 0 &&
+ assert(BlobData == nullptr &&
"Blob data specified for record that doesn't use it!");
}
/// register is a PHI destination and the PHI's LiveOutInfo is not valid.
const LiveOutInfo *GetLiveOutRegInfo(unsigned Reg) {
if (!LiveOutRegInfo.inBounds(Reg))
- return NULL;
+ return nullptr;
const LiveOutInfo *LOI = &LiveOutRegInfo[Reg];
if (!LOI->IsValid)
- return NULL;
+ return nullptr;
return LOI;
}
void updateNode(const SUnit *SU) override {}
void releaseState() override {
- SUnits = 0;
+ SUnits = nullptr;
}
unsigned getLatency(unsigned NodeNum) const {
Ops.push_back(Op2);
Ops.push_back(InGlue);
return getNode(ISD::CALLSEQ_END, DL, NodeTys, &Ops[0],
- (unsigned)Ops.size() - (InGlue.getNode() == 0 ? 1 : 0));
+ (unsigned)Ops.size() - (InGlue.getNode()==nullptr ? 1 : 0));
}
/// getUNDEF - Return an UNDEF node. UNDEF does not have a useful SDLoc.
SDValue getLoad(EVT VT, SDLoc dl, SDValue Chain, SDValue Ptr,
MachinePointerInfo PtrInfo, bool isVolatile,
bool isNonTemporal, bool isInvariant, unsigned Alignment,
- const MDNode *TBAAInfo = 0, const MDNode *Ranges = 0);
+ const MDNode *TBAAInfo = nullptr,
+ const MDNode *Ranges = nullptr);
SDValue getLoad(EVT VT, SDLoc dl, SDValue Chain, SDValue Ptr,
MachineMemOperand *MMO);
SDValue getExtLoad(ISD::LoadExtType ExtType, SDLoc dl, EVT VT,
SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo,
EVT MemVT, bool isVolatile,
bool isNonTemporal, unsigned Alignment,
- const MDNode *TBAAInfo = 0);
+ const MDNode *TBAAInfo = nullptr);
SDValue getExtLoad(ISD::LoadExtType ExtType, SDLoc dl, EVT VT,
SDValue Chain, SDValue Ptr, EVT MemVT,
MachineMemOperand *MMO);
SDValue Chain, SDValue Ptr, SDValue Offset,
MachinePointerInfo PtrInfo, EVT MemVT,
bool isVolatile, bool isNonTemporal, bool isInvariant,
- unsigned Alignment, const MDNode *TBAAInfo = 0,
- const MDNode *Ranges = 0);
+ unsigned Alignment, const MDNode *TBAAInfo = nullptr,
+ const MDNode *Ranges = nullptr);
SDValue getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType,
EVT VT, SDLoc dl,
SDValue Chain, SDValue Ptr, SDValue Offset,
SDValue getStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr,
MachinePointerInfo PtrInfo, bool isVolatile,
bool isNonTemporal, unsigned Alignment,
- const MDNode *TBAAInfo = 0);
+ const MDNode *TBAAInfo = nullptr);
SDValue getStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr,
MachineMemOperand *MMO);
SDValue getTruncStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr,
MachinePointerInfo PtrInfo, EVT TVT,
bool isNonTemporal, bool isVolatile,
unsigned Alignment,
- const MDNode *TBAAInfo = 0);
+ const MDNode *TBAAInfo = nullptr);
SDValue getTruncStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr,
EVT TVT, MachineMemOperand *MMO);
SDValue getIndexedStore(SDValue OrigStoe, SDLoc dl, SDValue Base,
private:
struct ValueType {
- ValueType() : data(NULL) {
+ ValueType() : data(nullptr) {
uval = 0;
}
bool extractValue(DataExtractor data, uint32_t *offset_ptr,
const DWARFUnit *u);
bool isInlinedCStr() const {
- return Value.data != NULL && Value.data == (const uint8_t*)Value.cstr;
+ return Value.data != nullptr && Value.data == (const uint8_t*)Value.cstr;
}
/// getAsFoo functions below return the extracted value as Foo if only
/// freeMachineCodeForFunction works.
static ExecutionEngine *create(Module *M,
bool ForceInterpreter = false,
- std::string *ErrorStr = 0,
+ std::string *ErrorStr = nullptr,
CodeGenOpt::Level OptLevel =
CodeGenOpt::Default,
bool GVsWithCode = true);
/// Clients should make sure to initialize targets prior to calling this
/// function.
static ExecutionEngine *createJIT(Module *M,
- std::string *ErrorStr = 0,
- JITMemoryManager *JMM = 0,
+ std::string *ErrorStr = nullptr,
+ JITMemoryManager *JMM = nullptr,
CodeGenOpt::Level OptLevel =
CodeGenOpt::Default,
bool GVsWithCode = true,
}
// The JIT overrides a version that actually does this.
- virtual void runJITOnFunction(Function *, MachineCodeInfo * = 0) { }
+ virtual void runJITOnFunction(Function *, MachineCodeInfo * = nullptr) { }
/// getGlobalValueAtAddress - Return the LLVM global value object that starts
/// at the specified address.
}
/// Return the target machine (if available).
- virtual TargetMachine *getTargetMachine() { return NULL; }
+ virtual TargetMachine *getTargetMachine() { return nullptr; }
/// DisableLazyCompilation - When lazy compilation is off (the default), the
/// JIT will eagerly compile every function reachable from the argument to
/// InitEngine - Does the common initialization of default options.
void InitEngine() {
WhichEngine = EngineKind::Either;
- ErrorStr = NULL;
+ ErrorStr = nullptr;
OptLevel = CodeGenOpt::Default;
- MCJMM = NULL;
- JMM = NULL;
+ MCJMM = nullptr;
+ JMM = nullptr;
Options = TargetOptions();
AllocateGVsWithCode = false;
RelocModel = Reloc::Default;
/// the setJITMemoryManager() option.
EngineBuilder &setMCJITMemoryManager(RTDyldMemoryManager *mcjmm) {
MCJMM = mcjmm;
- JMM = NULL;
+ JMM = nullptr;
return *this;
}
/// memory manager. This option defaults to NULL. This option overrides
/// setMCJITMemoryManager() as well.
EngineBuilder &setJITMemoryManager(JITMemoryManager *jmm) {
- MCJMM = NULL;
+ MCJMM = nullptr;
JMM = jmm;
return *this;
}
/// operations needed to reliably use the memory are also performed.
///
/// Returns true if an error occurred, false otherwise.
- virtual bool finalizeMemory(std::string *ErrMsg = 0) = 0;
+ virtual bool finalizeMemory(std::string *ErrMsg = nullptr) = 0;
};
// Create wrappers for C Binding types (see CBindingWrapping.h).
if (findOption(P->getPassArgument()) != getNumOptions()) {
errs() << "Two passes with the same argument (-"
<< P->getPassArgument() << ") attempted to be registered!\n";
- llvm_unreachable(0);
+ llvm_unreachable(nullptr);
}
addLiteralOption(P->getPassArgument(), P, P->getPassName());
}
const char *getSymbolName(uint32_t index) {
if (index < _symbols.size())
return _symbols[index].name;
- return NULL;
+ return nullptr;
}
/// getDependentLibraryCount - Get the number of dependent libraries
const char *getDependentLibrary(uint32_t index) {
if (index < _deplibs.size())
return _deplibs[index];
- return NULL;
+ return nullptr;
}
/// getLinkerOptCount - Get the number of linker options
const char *getLinkerOpt(uint32_t index) {
if (index < _linkeropts.size())
return _linkeropts[index];
- return NULL;
+ return nullptr;
}
/// getLLVVMModule - Return the Module.
AsmLexer(const MCAsmInfo &MAI);
~AsmLexer();
- void setBuffer(const MemoryBuffer *buf, const char *ptr = NULL);
+ void setBuffer(const MemoryBuffer *buf, const char *ptr = nullptr);
StringRef LexUntilEndOfStatement() override;
StringRef LexUntilEndOfLine();
unsigned Length, Size, Type;
void clear() {
- OpDecl = 0;
+ OpDecl = nullptr;
IsVarDecl = false;
Length = 1;
Size = 0;
SmallVectorImpl<AsmRewrite> *AsmRewrites;
- ParseInstructionInfo() : AsmRewrites(0) {}
+ ParseInstructionInfo() : AsmRewrites(nullptr) {}
ParseInstructionInfo(SmallVectorImpl<AsmRewrite> *rewrites)
: AsmRewrites(rewrites) {}
virtual const MCExpr *applyModifierToExpr(const MCExpr *E,
MCSymbolRefExpr::VariantKind,
MCContext &Ctx) {
- return 0;
+ return nullptr;
}
virtual void onLabelParsed(MCSymbol *Symbol) { };
bool FullPath = false) const;
error_code getAsBinary(OwningPtr<Binary> &Result,
- LLVMContext *Context = 0) const;
+ LLVMContext *Context = nullptr) const;
error_code getAsBinary(std::unique_ptr<Binary> &Result,
- LLVMContext *Context = 0) const;
+ LLVMContext *Context = nullptr) const;
};
class child_iterator {
Child child;
public:
- child_iterator() : child(Child(0, 0)) {}
+ child_iterator() : child(Child(nullptr, nullptr)) {}
child_iterator(const Child &c) : child(c) {}
const Child* operator->() const {
return &child;
// The iterator for the import directory table.
class ImportDirectoryEntryRef {
public:
- ImportDirectoryEntryRef() : OwningObject(0) {}
+ ImportDirectoryEntryRef() : OwningObject(nullptr) {}
ImportDirectoryEntryRef(const import_directory_table_entry *Table, uint32_t I,
const COFFObjectFile *Owner)
: ImportTable(Table), Index(I), OwningObject(Owner) {}
// The iterator for the export directory table entry.
class ExportDirectoryEntryRef {
public:
- ExportDirectoryEntryRef() : OwningObject(0) {}
+ ExportDirectoryEntryRef() : OwningObject(nullptr) {}
ExportDirectoryEntryRef(const export_directory_table_entry *Table, uint32_t I,
const COFFObjectFile *Owner)
: ExportTable(Table), Index(I), OwningObject(Owner) {}
template <class ELFT>
ELFFile<ELFT>::ELFFile(MemoryBuffer *Object, error_code &ec)
: Buf(Object),
- SectionHeaderTable(0),
- dot_shstrtab_sec(0),
- dot_strtab_sec(0),
- dot_symtab_sec(0),
- SymbolTableSectionHeaderIndex(0),
- dot_gnu_version_sec(0),
- dot_gnu_version_r_sec(0),
- dot_gnu_version_d_sec(0),
+ SectionHeaderTable(nullptr),
+ dot_shstrtab_sec(nullptr),
+ dot_strtab_sec(nullptr),
+ dot_symtab_sec(nullptr),
+ SymbolTableSectionHeaderIndex(nullptr),
+ dot_gnu_version_sec(nullptr),
+ dot_gnu_version_r_sec(nullptr),
+ dot_gnu_version_d_sec(nullptr),
dt_soname(nullptr) {
const uint64_t FileSize = Buf->getBufferSize();
DynamicRegion.EntSize = SecI->sh_entsize;
break;
case ELF::SHT_GNU_versym:
- if (dot_gnu_version_sec != NULL)
+ if (dot_gnu_version_sec != nullptr)
// FIXME: Proper error handling.
report_fatal_error("More than one .gnu.version section!");
dot_gnu_version_sec = &*SecI;
break;
case ELF::SHT_GNU_verdef:
- if (dot_gnu_version_d_sec != NULL)
+ if (dot_gnu_version_d_sec != nullptr)
// FIXME: Proper error handling.
report_fatal_error("More than one .gnu.version_d section!");
dot_gnu_version_d_sec = &*SecI;
break;
case ELF::SHT_GNU_verneed:
- if (dot_gnu_version_r_sec != NULL)
+ if (dot_gnu_version_r_sec != nullptr)
// FIXME: Proper error handling.
report_fatal_error("More than one .gnu.version_r section!");
dot_gnu_version_r_sec = &*SecI;
template <class ELFT>
typename ELFFile<ELFT>::Elf_Sym_Iter ELFFile<ELFT>::end_symbols() const {
if (!dot_symtab_sec)
- return Elf_Sym_Iter(0, 0, false);
+ return Elf_Sym_Iter(0, nullptr, false);
return Elf_Sym_Iter(dot_symtab_sec->sh_entsize,
(const char *)base() + dot_symtab_sec->sh_offset +
dot_symtab_sec->sh_size,
if (DynamicRegion.Addr)
return Elf_Dyn_Iter(DynamicRegion.EntSize,
(const char *)DynamicRegion.Addr);
- return Elf_Dyn_Iter(0, 0);
+ return Elf_Dyn_Iter(0, nullptr);
}
template <class ELFT>
typename ELFFile<ELFT>::Elf_Dyn_Iter
ELFFile<ELFT>::end_dynamic_table(bool NULLEnd) const {
if (!DynamicRegion.Addr)
- return Elf_Dyn_Iter(0, 0);
+ return Elf_Dyn_Iter(0, nullptr);
Elf_Dyn_Iter Ret(DynamicRegion.EntSize,
(const char *)DynamicRegion.Addr + DynamicRegion.Size);
ObjectForArch(const MachOUniversalBinary *Parent, uint32_t Index);
void clear() {
- Parent = 0;
+ Parent = nullptr;
Index = 0;
}
return ObjectForArch(this, 0);
}
object_iterator end_objects() const {
- return ObjectForArch(0, 0);
+ return ObjectForArch(nullptr, 0);
}
uint32_t getNumberOfObjects() const { return NumberOfObjects; }
public:
Arg(const Option Opt, StringRef Spelling, unsigned Index,
- const Arg *BaseArg = 0);
+ const Arg *BaseArg = nullptr);
Arg(const Option Opt, StringRef Spelling, unsigned Index,
- const char *Value0, const Arg *BaseArg = 0);
+ const char *Value0, const Arg *BaseArg = nullptr);
Arg(const Option Opt, StringRef Spelling, unsigned Index,
- const char *Value0, const char *Value1, const Arg *BaseArg = 0);
+ const char *Value0, const char *Value1, const Arg *BaseArg = nullptr);
~Arg();
const Option getOption() const { return Opt; }
///
/// \p Claim Whether the argument should be claimed, if it exists.
bool hasArgNoClaim(OptSpecifier Id) const {
- return getLastArgNoClaim(Id) != 0;
+ return getLastArgNoClaim(Id) != nullptr;
}
bool hasArg(OptSpecifier Id) const {
- return getLastArg(Id) != 0;
+ return getLastArg(Id) != nullptr;
}
bool hasArg(OptSpecifier Id0, OptSpecifier Id1) const {
- return getLastArg(Id0, Id1) != 0;
+ return getLastArg(Id0, Id1) != nullptr;
}
bool hasArg(OptSpecifier Id0, OptSpecifier Id1, OptSpecifier Id2) const {
- return getLastArg(Id0, Id1, Id2) != 0;
+ return getLastArg(Id0, Id1, Id2) != nullptr;
}
/// getLastArg - Return the last argument matching \p Id, or null.
~Option();
bool isValid() const {
- return Info != 0;
+ return Info != nullptr;
}
unsigned getID() const {
static double test(...);
public:
- static bool const value = (sizeof(test<ScalarBitSetTraits<T> >(0)) == 1);
+ static bool const value = (sizeof(test<ScalarBitSetTraits<T> >(nullptr)) == 1);
};
template <typename TNorm, typename TFinal>
struct MappingNormalization {
MappingNormalization(IO &i_o, TFinal &Obj)
- : io(i_o), BufPtr(NULL), Result(Obj) {
+ : io(i_o), BufPtr(nullptr), Result(Obj) {
if ( io.outputting() ) {
BufPtr = new (&Buffer) TNorm(io, Obj);
}
/// intrinsic, Tys should point to an array of numTys pointers to Type,
/// and must provide exactly one type for each overloaded type in the
/// intrinsic.
- virtual std::string getName(unsigned IID, Type **Tys = 0,
+ virtual std::string getName(unsigned IID, Type **Tys = nullptr,
unsigned numTys = 0) const = 0;
/// Look up target intrinsic by name. Return intrinsic ID or 0 for unknown
/// Create or insert an LLVM Function declaration for an intrinsic,
/// and return it. The Tys and numTys are for intrinsics with overloaded
/// types. See above for more information.
- virtual Function *getDeclaration(Module *M, unsigned ID, Type **Tys = 0,
+ virtual Function *getDeclaration(Module *M, unsigned ID, Type **Tys = nullptr,
unsigned numTys = 0) const = 0;
};
///
BasicBlock *CloneBasicBlock(const BasicBlock *BB,
ValueToValueMapTy &VMap,
- const Twine &NameSuffix = "", Function *F = 0,
- ClonedCodeInfo *CodeInfo = 0);
+ const Twine &NameSuffix = "", Function *F = nullptr,
+ ClonedCodeInfo *CodeInfo = nullptr);
/// CloneFunction - Return a copy of the specified function, but without
/// embedding the function into another module. Also, any references specified
Function *CloneFunction(const Function *F,
ValueToValueMapTy &VMap,
bool ModuleLevelChanges,
- ClonedCodeInfo *CodeInfo = 0);
+ ClonedCodeInfo *CodeInfo = nullptr);
/// Clone OldFunc into NewFunc, transforming the old arguments into references
/// to VMap values. Note that if NewFunc already has basic blocks, the ones
bool ModuleLevelChanges,
SmallVectorImpl<ReturnInst*> &Returns,
const char *NameSuffix = "",
- ClonedCodeInfo *CodeInfo = 0,
- ValueMapTypeRemapper *TypeMapper = 0,
- ValueMaterializer *Materializer = 0);
+ ClonedCodeInfo *CodeInfo = nullptr,
+ ValueMapTypeRemapper *TypeMapper = nullptr,
+ ValueMaterializer *Materializer = nullptr);
/// CloneAndPruneFunctionInto - This works exactly like CloneFunctionInto,
/// except that it does some simple constant prop and DCE on the fly. The
bool ModuleLevelChanges,
SmallVectorImpl<ReturnInst*> &Returns,
const char *NameSuffix = "",
- ClonedCodeInfo *CodeInfo = 0,
- const DataLayout *DL = 0,
- Instruction *TheCall = 0);
+ ClonedCodeInfo *CodeInfo = nullptr,
+ const DataLayout *DL = nullptr,
+ Instruction *TheCall = nullptr);
/// InlineFunctionInfo - This class captures the data input to the
/// InlineFunction call, and records the auxiliary results produced by it.
class InlineFunctionInfo {
public:
- explicit InlineFunctionInfo(CallGraph *cg = 0, const DataLayout *DL = 0)
+ explicit InlineFunctionInfo(CallGraph *cg = nullptr, const DataLayout *DL = nullptr)
: CG(cg), DL(DL) {}
/// CG - If non-null, InlineFunction will update the callgraph to reflect the
Value *MapValue(const Value *V, ValueToValueMapTy &VM,
RemapFlags Flags = RF_None,
- ValueMapTypeRemapper *TypeMapper = 0,
- ValueMaterializer *Materializer = 0);
+ ValueMapTypeRemapper *TypeMapper = nullptr,
+ ValueMaterializer *Materializer = nullptr);
void RemapInstruction(Instruction *I, ValueToValueMapTy &VM,
RemapFlags Flags = RF_None,
- ValueMapTypeRemapper *TypeMapper = 0,
- ValueMaterializer *Materializer = 0);
+ ValueMapTypeRemapper *TypeMapper = nullptr,
+ ValueMaterializer *Materializer = nullptr);
/// MapValue - provide versions that preserve type safety for MDNode and
/// Constants.
inline MDNode *MapValue(const MDNode *V, ValueToValueMapTy &VM,
RemapFlags Flags = RF_None,
- ValueMapTypeRemapper *TypeMapper = 0,
- ValueMaterializer *Materializer = 0) {
+ ValueMapTypeRemapper *TypeMapper = nullptr,
+ ValueMaterializer *Materializer = nullptr) {
return cast<MDNode>(MapValue((const Value*)V, VM, Flags, TypeMapper,
Materializer));
}
inline Constant *MapValue(const Constant *V, ValueToValueMapTy &VM,
RemapFlags Flags = RF_None,
- ValueMapTypeRemapper *TypeMapper = 0,
- ValueMaterializer *Materializer = 0) {
+ ValueMapTypeRemapper *TypeMapper = nullptr,
+ ValueMaterializer *Materializer = nullptr) {
return cast<Constant>(MapValue((const Value*)V, VM, Flags, TypeMapper,
Materializer));
}
static const char *isLabelTail(const char *CurPtr) {
while (1) {
if (CurPtr[0] == ':') return CurPtr+1;
- if (!isLabelChar(CurPtr[0])) return 0;
+ if (!isLabelChar(CurPtr[0])) return nullptr;
++CurPtr;
}
}
/// HexIntConstant [us]0x[0-9A-Fa-f]+
lltok::Kind LLLexer::LexIdentifier() {
const char *StartChar = CurPtr;
- const char *IntEnd = CurPtr[-1] == 'i' ? 0 : StartChar;
- const char *KeywordEnd = 0;
+ const char *IntEnd = CurPtr[-1] == 'i' ? nullptr : StartChar;
+ const char *KeywordEnd = nullptr;
for (; isLabelChar(*CurPtr); ++CurPtr) {
// If we decide this is an integer, remember the end of the sequence.
// Otherwise, this wasn't a label. If this was valid as an integer type,
// return it.
- if (IntEnd == 0) IntEnd = CurPtr;
+ if (!IntEnd) IntEnd = CurPtr;
if (IntEnd != StartChar) {
CurPtr = IntEnd;
uint64_t NumBits = atoull(StartChar, CurPtr);
}
// Otherwise, this was a letter sequence. See which keyword this is.
- if (KeywordEnd == 0) KeywordEnd = CurPtr;
+ if (!KeywordEnd) KeywordEnd = CurPtr;
CurPtr = KeywordEnd;
--StartChar;
unsigned Len = CurPtr-StartChar;
for (unsigned i = 0, e = MDList.size(); i != e; ++i) {
unsigned SlotNo = MDList[i].MDSlot;
- if (SlotNo >= NumberedMetadata.size() || NumberedMetadata[SlotNo] == 0)
+ if (SlotNo >= NumberedMetadata.size() ||
+ NumberedMetadata[SlotNo] == nullptr)
return Error(MDList[i].Loc, "use of undefined metadata '!" +
Twine(SlotNo) + "'");
Inst->setMetadata(MDList[i].MDKind, NumberedMetadata[SlotNo]);
// references after the function was defined. Resolve those now.
while (!ForwardRefBlockAddresses.empty()) {
// Okay, we are referencing an already-parsed function, resolve them now.
- Function *TheFn = 0;
+ Function *TheFn = nullptr;
const ValID &Fn = ForwardRefBlockAddresses.begin()->first;
if (Fn.Kind == ValID::t_GlobalName)
TheFn = M->getFunction(Fn.StrVal);
else if (Fn.UIntVal < NumberedVals.size())
TheFn = dyn_cast<Function>(NumberedVals[Fn.UIntVal]);
- if (TheFn == 0)
+ if (!TheFn)
return Error(Fn.Loc, "unknown function referenced by blockaddress");
// Resolve all these references.
if (ResolveForwardRefBlockAddresses(TheFn,
ForwardRefBlockAddresses.begin()->second,
- 0))
+ nullptr))
return true;
ForwardRefBlockAddresses.erase(ForwardRefBlockAddresses.begin());
TheFn->getValueSymbolTable().lookup(Refs[i].first.StrVal));
}
- if (Res == 0)
+ if (!Res)
return Error(Refs[i].first.Loc,
"referenced value is not a basic block");
if (TypeID >= NumberedTypes.size())
NumberedTypes.resize(TypeID+1);
- Type *Result = 0;
+ Type *Result = nullptr;
if (ParseStructDefinition(TypeLoc, "",
NumberedTypes[TypeID], Result)) return true;
ParseToken(lltok::kw_type, "expected 'type' after name"))
return true;
- Type *Result = 0;
+ Type *Result = nullptr;
if (ParseStructDefinition(NameLoc, Name,
NamedTypes[Name], Result)) return true;
if (ParseUInt32(SlotNo)) return true;
// Check existing MDNode.
- if (SlotNo < NumberedMetadata.size() && NumberedMetadata[SlotNo] != 0)
+ if (SlotNo < NumberedMetadata.size() && NumberedMetadata[SlotNo] != nullptr)
Result = NumberedMetadata[SlotNo];
else
- Result = 0;
+ Result = nullptr;
return false;
}
if (ParseToken(lltok::exclaim, "Expected '!' here"))
return true;
- MDNode *N = 0;
+ MDNode *N = nullptr;
if (ParseMDNodeID(N)) return true;
NMD->addOperand(N);
} while (EatIfPresent(lltok::comma));
unsigned MetadataID = 0;
LocTy TyLoc;
- Type *Ty = 0;
+ Type *Ty = nullptr;
SmallVector<Value *, 16> Elts;
if (ParseUInt32(MetadataID) ||
ParseToken(lltok::equal, "expected '=' here") ||
ParseType(Ty, TyLoc) ||
ParseToken(lltok::exclaim, "Expected '!' here") ||
ParseToken(lltok::lbrace, "Expected '{' here") ||
- ParseMDNodeVector(Elts, NULL) ||
+ ParseMDNodeVector(Elts, nullptr) ||
ParseToken(lltok::rbrace, "expected end of metadata node"))
return true;
if (MetadataID >= NumberedMetadata.size())
NumberedMetadata.resize(MetadataID+1);
- if (NumberedMetadata[MetadataID] != 0)
+ if (NumberedMetadata[MetadataID] != nullptr)
return TokError("Metadata id is already used");
NumberedMetadata[MetadataID] = Init;
}
LocTy IsExternallyInitializedLoc;
LocTy TyLoc;
- Type *Ty = 0;
+ Type *Ty = nullptr;
if (ParseOptionalThreadLocal(TLM) ||
ParseOptionalAddrSpace(AddrSpace) ||
ParseOptionalToken(lltok::kw_unnamed_addr, UnnamedAddr,
// If the linkage is specified and is external, then no initializer is
// present.
- Constant *Init = 0;
+ Constant *Init = nullptr;
if (!HasLinkage || (Linkage != GlobalValue::ExternalWeakLinkage &&
Linkage != GlobalValue::ExternalLinkage)) {
if (ParseGlobalValue(Ty, Init))
if (Ty->isFunctionTy() || Ty->isLabelTy())
return Error(TyLoc, "invalid type for global variable");
- GlobalVariable *GV = 0;
+ GlobalVariable *GV = nullptr;
// See if the global was forward referenced, if so, use the global.
if (!Name.empty()) {
}
}
- if (GV == 0) {
- GV = new GlobalVariable(*M, Ty, false, GlobalValue::ExternalLinkage, 0,
- Name, 0, GlobalVariable::NotThreadLocal,
+ if (!GV) {
+ GV = new GlobalVariable(*M, Ty, false, GlobalValue::ExternalLinkage, nullptr,
+ Name, nullptr, GlobalVariable::NotThreadLocal,
AddrSpace);
} else {
if (GV->getType()->getElementType() != Ty)
GlobalValue *LLParser::GetGlobalVal(const std::string &Name, Type *Ty,
LocTy Loc) {
PointerType *PTy = dyn_cast<PointerType>(Ty);
- if (PTy == 0) {
+ if (!PTy) {
Error(Loc, "global variable reference must have pointer type");
- return 0;
+ return nullptr;
}
// Look this name up in the normal function symbol table.
// If this is a forward reference for the value, see if we already created a
// forward ref record.
- if (Val == 0) {
+ if (!Val) {
std::map<std::string, std::pair<GlobalValue*, LocTy> >::iterator
I = ForwardRefVals.find(Name);
if (I != ForwardRefVals.end())
if (Val->getType() == Ty) return Val;
Error(Loc, "'@" + Name + "' defined with type '" +
getTypeString(Val->getType()) + "'");
- return 0;
+ return nullptr;
}
// Otherwise, create a new forward reference for this value and remember it.
FwdVal = Function::Create(FT, GlobalValue::ExternalWeakLinkage, Name, M);
else
FwdVal = new GlobalVariable(*M, PTy->getElementType(), false,
- GlobalValue::ExternalWeakLinkage, 0, Name,
- 0, GlobalVariable::NotThreadLocal,
+ GlobalValue::ExternalWeakLinkage, nullptr, Name,
+ nullptr, GlobalVariable::NotThreadLocal,
PTy->getAddressSpace());
ForwardRefVals[Name] = std::make_pair(FwdVal, Loc);
GlobalValue *LLParser::GetGlobalVal(unsigned ID, Type *Ty, LocTy Loc) {
PointerType *PTy = dyn_cast<PointerType>(Ty);
- if (PTy == 0) {
+ if (!PTy) {
Error(Loc, "global variable reference must have pointer type");
- return 0;
+ return nullptr;
}
- GlobalValue *Val = ID < NumberedVals.size() ? NumberedVals[ID] : 0;
+ GlobalValue *Val = ID < NumberedVals.size() ? NumberedVals[ID] : nullptr;
// If this is a forward reference for the value, see if we already created a
// forward ref record.
- if (Val == 0) {
+ if (!Val) {
std::map<unsigned, std::pair<GlobalValue*, LocTy> >::iterator
I = ForwardRefValIDs.find(ID);
if (I != ForwardRefValIDs.end())
if (Val->getType() == Ty) return Val;
Error(Loc, "'@" + Twine(ID) + "' defined with type '" +
getTypeString(Val->getType()) + "'");
- return 0;
+ return nullptr;
}
// Otherwise, create a new forward reference for this value and remember it.
FwdVal = Function::Create(FT, GlobalValue::ExternalWeakLinkage, "", M);
else
FwdVal = new GlobalVariable(*M, PTy->getElementType(), false,
- GlobalValue::ExternalWeakLinkage, 0, "");
+ GlobalValue::ExternalWeakLinkage, nullptr, "");
ForwardRefValIDs[ID] = std::make_pair(FwdVal, Loc);
return FwdVal;
// If the type hasn't been defined yet, create a forward definition and
// remember where that forward def'n was seen (in case it never is defined).
- if (Entry.first == 0) {
+ if (!Entry.first) {
Entry.first = StructType::create(Context, Lex.getStrVal());
Entry.second = Lex.getLoc();
}
// If the type hasn't been defined yet, create a forward definition and
// remember where that forward def'n was seen (in case it never is defined).
- if (Entry.first == 0) {
+ if (!Entry.first) {
Entry.first = StructType::create(Context);
Entry.second = Lex.getLoc();
}
// Parse the argument.
LocTy ArgLoc;
- Type *ArgTy = 0;
+ Type *ArgTy = nullptr;
AttrBuilder ArgAttrs;
Value *V;
if (ParseType(ArgTy, ArgLoc))
Lex.Lex();
} else {
LocTy TypeLoc = Lex.getLoc();
- Type *ArgTy = 0;
+ Type *ArgTy = nullptr;
AttrBuilder Attrs;
std::string Name;
Entry.second = SMLoc();
// If this type number has never been uttered, create it.
- if (Entry.first == 0)
+ if (!Entry.first)
Entry.first = StructType::create(Context, Name);
ResultTy = Entry.first;
return false;
if (Entry.first)
return Error(TypeLoc, "forward references to non-struct type");
- ResultTy = 0;
+ ResultTy = nullptr;
if (isPacked)
return ParseArrayVectorType(ResultTy, true);
return ParseType(ResultTy);
Entry.second = SMLoc();
// If this type number has never been uttered, create it.
- if (Entry.first == 0)
+ if (!Entry.first)
Entry.first = StructType::create(Context, Name);
StructType *STy = cast<StructType>(Entry.first);
return false;
LocTy EltTyLoc = Lex.getLoc();
- Type *Ty = 0;
+ Type *Ty = nullptr;
if (ParseType(Ty)) return true;
Body.push_back(Ty);
return true;
LocTy TypeLoc = Lex.getLoc();
- Type *EltTy = 0;
+ Type *EltTy = nullptr;
if (ParseType(EltTy)) return true;
if (ParseToken(isVector ? lltok::greater : lltok::rsquare,
I->second.first->replaceAllUsesWith(
UndefValue::get(I->second.first->getType()));
delete I->second.first;
- I->second.first = 0;
+ I->second.first = nullptr;
}
for (std::map<unsigned, std::pair<Value*, LocTy> >::iterator
I->second.first->replaceAllUsesWith(
UndefValue::get(I->second.first->getType()));
delete I->second.first;
- I->second.first = 0;
+ I->second.first = nullptr;
}
}
// If this is a forward reference for the value, see if we already created a
// forward ref record.
- if (Val == 0) {
+ if (!Val) {
std::map<std::string, std::pair<Value*, LocTy> >::iterator
I = ForwardRefVals.find(Name);
if (I != ForwardRefVals.end())
else
P.Error(Loc, "'%" + Name + "' defined with type '" +
getTypeString(Val->getType()) + "'");
- return 0;
+ return nullptr;
}
// Don't make placeholders with invalid type.
if (!Ty->isFirstClassType() && !Ty->isLabelTy()) {
P.Error(Loc, "invalid use of a non-first-class type");
- return 0;
+ return nullptr;
}
// Otherwise, create a new forward reference for this value and remember it.
Value *LLParser::PerFunctionState::GetVal(unsigned ID, Type *Ty,
LocTy Loc) {
// Look this name up in the normal function symbol table.
- Value *Val = ID < NumberedVals.size() ? NumberedVals[ID] : 0;
+ Value *Val = ID < NumberedVals.size() ? NumberedVals[ID] : nullptr;
// If this is a forward reference for the value, see if we already created a
// forward ref record.
- if (Val == 0) {
+ if (!Val) {
std::map<unsigned, std::pair<Value*, LocTy> >::iterator
I = ForwardRefValIDs.find(ID);
if (I != ForwardRefValIDs.end())
else
P.Error(Loc, "'%" + Twine(ID) + "' defined with type '" +
getTypeString(Val->getType()) + "'");
- return 0;
+ return nullptr;
}
if (!Ty->isFirstClassType() && !Ty->isLabelTy()) {
P.Error(Loc, "invalid use of a non-first-class type");
- return 0;
+ return nullptr;
}
// Otherwise, create a new forward reference for this value and remember it.
BB = GetBB(NumberedVals.size(), Loc);
else
BB = GetBB(Name, Loc);
- if (BB == 0) return 0; // Already diagnosed error.
+ if (!BB) return nullptr; // Already diagnosed error.
// Move the block to the end of the function. Forward ref'd blocks are
// inserted wherever they happen to be referenced.
// Make a global variable as a placeholder for this reference.
GlobalVariable *FwdRef = new GlobalVariable(*M, Type::getInt8Ty(Context),
false, GlobalValue::InternalLinkage,
- 0, "");
+ nullptr, "");
ForwardRefBlockAddresses[Fn].push_back(std::make_pair(Label, FwdRef));
ID.ConstantVal = FwdRef;
ID.Kind = ValID::t_Constant;
case lltok::kw_inttoptr:
case lltok::kw_ptrtoint: {
unsigned Opc = Lex.getUIntVal();
- Type *DestTy = 0;
+ Type *DestTy = nullptr;
Constant *SrcVal;
Lex.Lex();
if (ParseToken(lltok::lparen, "expected '(' after constantexpr cast") ||
/// ParseGlobalValue - Parse a global value with the specified type.
bool LLParser::ParseGlobalValue(Type *Ty, Constant *&C) {
- C = 0;
+ C = nullptr;
ValID ID;
- Value *V = NULL;
+ Value *V = nullptr;
bool Parsed = ParseValID(ID) ||
- ConvertValIDToValue(Ty, ID, V, NULL);
+ ConvertValIDToValue(Ty, ID, V, nullptr);
if (V && !(C = dyn_cast<Constant>(V)))
return Error(ID.Loc, "global values must be constants");
return Parsed;
}
bool LLParser::ParseGlobalTypeAndValue(Constant *&V) {
- Type *Ty = 0;
+ Type *Ty = nullptr;
return ParseType(Ty) ||
ParseGlobalValue(Ty, V);
}
case ValID::t_LocalID:
if (!PFS) return Error(ID.Loc, "invalid use of function-local name");
V = PFS->GetVal(ID.UIntVal, Ty, ID.Loc);
- return (V == 0);
+ return V == nullptr;
case ValID::t_LocalName:
if (!PFS) return Error(ID.Loc, "invalid use of function-local name");
V = PFS->GetVal(ID.StrVal, Ty, ID.Loc);
- return (V == 0);
+ return V == nullptr;
case ValID::t_InlineAsm: {
PointerType *PTy = dyn_cast<PointerType>(Ty);
FunctionType *FTy =
- PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
+ PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : nullptr;
if (!FTy || !InlineAsm::Verify(FTy, ID.StrVal2))
return Error(ID.Loc, "invalid type for inline asm constraint string");
V = InlineAsm::get(FTy, ID.StrVal, ID.StrVal2, ID.UIntVal&1,
return false;
case ValID::t_GlobalName:
V = GetGlobalVal(ID.StrVal, Ty, ID.Loc);
- return V == 0;
+ return V == nullptr;
case ValID::t_GlobalID:
V = GetGlobalVal(ID.UIntVal, Ty, ID.Loc);
- return V == 0;
+ return V == nullptr;
case ValID::t_APSInt:
if (!Ty->isIntegerTy())
return Error(ID.Loc, "integer constant must have integer type");
}
bool LLParser::ParseValue(Type *Ty, Value *&V, PerFunctionState *PFS) {
- V = 0;
+ V = nullptr;
ValID ID;
return ParseValID(ID, PFS) ||
ConvertValIDToValue(Ty, ID, V, PFS);
}
bool LLParser::ParseTypeAndValue(Value *&V, PerFunctionState *PFS) {
- Type *Ty = 0;
+ Type *Ty = nullptr;
return ParseType(Ty) ||
ParseValue(Ty, V, PFS);
}
unsigned DLLStorageClass;
AttrBuilder RetAttrs;
CallingConv::ID CC;
- Type *RetType = 0;
+ Type *RetType = nullptr;
LocTy RetTypeLoc = Lex.getLoc();
if (ParseOptionalLinkage(Linkage) ||
ParseOptionalVisibility(Visibility) ||
std::string GC;
bool UnnamedAddr;
LocTy UnnamedAddrLoc;
- Constant *Prefix = 0;
+ Constant *Prefix = nullptr;
if (ParseArgumentList(ArgList, isVarArg) ||
ParseOptionalToken(lltok::kw_unnamed_addr, UnnamedAddr,
FunctionType::get(RetType, ParamTypeList, isVarArg);
PointerType *PFT = PointerType::getUnqual(FT);
- Fn = 0;
+ Fn = nullptr;
if (!FunctionName.empty()) {
// If this was a definition of a forward reference, remove the definition
// from the forward reference table and fill in the forward ref.
}
}
- if (Fn == 0)
+ if (!Fn)
Fn = Function::Create(FT, GlobalValue::ExternalLinkage, FunctionName, M);
else // Move the forward-reference to the correct spot in the module.
M->getFunctionList().splice(M->end(), M->getFunctionList(), Fn);
}
BasicBlock *BB = PFS.DefineBB(Name, NameLoc);
- if (BB == 0) return true;
+ if (!BB) return true;
std::string NameStr;
bool LLParser::ParseRet(Instruction *&Inst, BasicBlock *BB,
PerFunctionState &PFS) {
SMLoc TypeLoc = Lex.getLoc();
- Type *Ty = 0;
+ Type *Ty = nullptr;
if (ParseType(Ty, true /*void allowed*/)) return true;
Type *ResType = PFS.getFunction().getReturnType();
std::vector<unsigned> FwdRefAttrGrps;
LocTy NoBuiltinLoc;
CallingConv::ID CC;
- Type *RetType = 0;
+ Type *RetType = nullptr;
LocTy RetTypeLoc;
ValID CalleeID;
SmallVector<ParamInfo, 16> ArgList;
// If RetType is a non-function pointer type, then this is the short syntax
// for the call, which means that RetType is just the return type. Infer the
// rest of the function argument types from the arguments that are present.
- PointerType *PFTy = 0;
- FunctionType *Ty = 0;
+ PointerType *PFTy = nullptr;
+ FunctionType *Ty = nullptr;
if (!(PFTy = dyn_cast<PointerType>(RetType)) ||
!(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
// Pull out the types of all of the arguments...
FunctionType::param_iterator I = Ty->param_begin();
FunctionType::param_iterator E = Ty->param_end();
for (unsigned i = 0, e = ArgList.size(); i != e; ++i) {
- Type *ExpectedTy = 0;
+ Type *ExpectedTy = nullptr;
if (I != E) {
ExpectedTy = *I++;
} else if (!Ty->isVarArg()) {
unsigned Opc) {
LocTy Loc;
Value *Op;
- Type *DestTy = 0;
+ Type *DestTy = nullptr;
if (ParseTypeAndValue(Op, Loc, PFS) ||
ParseToken(lltok::kw_to, "expected 'to' after cast value") ||
ParseType(DestTy))
/// ::= 'va_arg' TypeAndValue ',' Type
bool LLParser::ParseVA_Arg(Instruction *&Inst, PerFunctionState &PFS) {
Value *Op;
- Type *EltTy = 0;
+ Type *EltTy = nullptr;
LocTy TypeLoc;
if (ParseTypeAndValue(Op, PFS) ||
ParseToken(lltok::comma, "expected ',' after vaarg operand") ||
/// ParsePHI
/// ::= 'phi' Type '[' Value ',' Value ']' (',' '[' Value ',' Value ']')*
int LLParser::ParsePHI(Instruction *&Inst, PerFunctionState &PFS) {
- Type *Ty = 0; LocTy TypeLoc;
+ Type *Ty = nullptr; LocTy TypeLoc;
Value *Op0, *Op1;
if (ParseType(Ty, TypeLoc) ||
/// ::= 'filter'
/// ::= 'filter' TypeAndValue ( ',' TypeAndValue )*
bool LLParser::ParseLandingPad(Instruction *&Inst, PerFunctionState &PFS) {
- Type *Ty = 0; LocTy TyLoc;
+ Type *Ty = nullptr; LocTy TyLoc;
Value *PersFn; LocTy PersFnLoc;
if (ParseType(Ty, TyLoc) ||
std::vector<unsigned> FwdRefAttrGrps;
LocTy BuiltinLoc;
CallingConv::ID CC;
- Type *RetType = 0;
+ Type *RetType = nullptr;
LocTy RetTypeLoc;
ValID CalleeID;
SmallVector<ParamInfo, 16> ArgList;
// If RetType is a non-function pointer type, then this is the short syntax
// for the call, which means that RetType is just the return type. Infer the
// rest of the function argument types from the arguments that are present.
- PointerType *PFTy = 0;
- FunctionType *Ty = 0;
+ PointerType *PFTy = nullptr;
+ FunctionType *Ty = nullptr;
if (!(PFTy = dyn_cast<PointerType>(RetType)) ||
!(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
// Pull out the types of all of the arguments...
FunctionType::param_iterator I = Ty->param_begin();
FunctionType::param_iterator E = Ty->param_end();
for (unsigned i = 0, e = ArgList.size(); i != e; ++i) {
- Type *ExpectedTy = 0;
+ Type *ExpectedTy = nullptr;
if (I != E) {
ExpectedTy = *I++;
} else if (!Ty->isVarArg()) {
/// ParseAlloc
/// ::= 'alloca' 'inalloca'? Type (',' TypeAndValue)? (',' 'align' i32)?
int LLParser::ParseAlloc(Instruction *&Inst, PerFunctionState &PFS) {
- Value *Size = 0;
+ Value *Size = nullptr;
LocTy SizeLoc;
unsigned Alignment = 0;
- Type *Ty = 0;
+ Type *Ty = nullptr;
bool IsInAlloca = EatIfPresent(lltok::kw_inalloca);
/// ParseGetElementPtr
/// ::= 'getelementptr' 'inbounds'? TypeAndValue (',' TypeAndValue)*
int LLParser::ParseGetElementPtr(Instruction *&Inst, PerFunctionState &PFS) {
- Value *Ptr = 0;
- Value *Val = 0;
+ Value *Ptr = nullptr;
+ Value *Val = nullptr;
LocTy Loc, EltLoc;
bool InBounds = EatIfPresent(lltok::kw_inbounds);
do {
// Null is a special case since it is typeless.
if (EatIfPresent(lltok::kw_null)) {
- Elts.push_back(0);
+ Elts.push_back(nullptr);
continue;
}
- Value *V = 0;
+ Value *V = nullptr;
if (ParseTypeAndValue(V, PFS)) return true;
Elts.push_back(V);
} while (EatIfPresent(lltok::comma));
// If we are parsing into an existing module, do it.
if (M)
- return LLParser(F, SM, Err, M).Run() ? 0 : M;
+ return LLParser(F, SM, Err, M).Run() ? nullptr : M;
// Otherwise create a new module.
std::unique_ptr<Module> M2(new Module(F->getBufferIdentifier(), Context));
if (LLParser(F, SM, Err, M2.get()).Run())
- return 0;
+ return nullptr;
return M2.release();
}
if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, File)) {
Err = SMDiagnostic(Filename, SourceMgr::DK_Error,
"Could not open input file: " + ec.message());
- return 0;
+ return nullptr;
}
- return ParseAssembly(File.release(), 0, Err, Context);
+ return ParseAssembly(File.release(), nullptr, Err, Context);
}
Module *llvm::ParseAssemblyString(const char *AsmString, Module *M,
if (error_code EC = ModuleOrErr.getError()) {
if (OutMessage)
*OutMessage = strdup(EC.message().c_str());
- *OutModule = wrap((Module*)0);
+ *OutModule = wrap((Module*)nullptr);
return 1;
}
getLazyBitcodeModule(unwrap(MemBuf), *unwrap(ContextRef));
if (error_code EC = ModuleOrErr.getError()) {
- *OutM = wrap((Module *)NULL);
+ *OutM = wrap((Module *)nullptr);
if (OutMessage)
*OutMessage = strdup(EC.message().c_str());
return 1;
void BitcodeReader::FreeState() {
if (BufferOwned)
delete Buffer;
- Buffer = 0;
+ Buffer = nullptr;
std::vector<Type*>().swap(TypeList);
ValueList.clear();
MDValueList.clear();
resize(Idx+1);
WeakVH &OldV = ValuePtrs[Idx];
- if (OldV == 0) {
+ if (!OldV) {
OldV = V;
return;
}
resize(Idx + 1);
if (Value *V = ValuePtrs[Idx]) {
- assert((Ty == 0 || Ty == V->getType()) && "Type mismatch in value table!");
+ assert((!Ty || Ty == V->getType()) && "Type mismatch in value table!");
return V;
}
// No type specified, must be invalid reference.
- if (Ty == 0) return 0;
+ if (!Ty) return nullptr;
// Create and return a placeholder, which will later be RAUW'd.
Value *V = new Argument(Ty);
resize(Idx+1);
WeakVH &OldV = MDValuePtrs[Idx];
- if (OldV == 0) {
+ if (!OldV) {
OldV = V;
return;
}
Type *BitcodeReader::getTypeByID(unsigned ID) {
// The type table size is always specified correctly.
if (ID >= TypeList.size())
- return 0;
+ return nullptr;
if (Type *Ty = TypeList[ID])
return Ty;
// Read a record.
Record.clear();
- Type *ResultTy = 0;
+ Type *ResultTy = nullptr;
switch (Stream.readRecord(Entry.ID, Record)) {
default:
return Error(InvalidValue);
if (Record.size() == 2)
AddressSpace = Record[1];
ResultTy = getTypeByID(Record[0]);
- if (ResultTy == 0)
+ if (!ResultTy)
return Error(InvalidType);
ResultTy = PointerType::get(ResultTy, AddressSpace);
break;
}
ResultTy = getTypeByID(Record[2]);
- if (ResultTy == 0 || ArgTys.size() < Record.size()-3)
+ if (!ResultTy || ArgTys.size() < Record.size()-3)
return Error(InvalidType);
ResultTy = FunctionType::get(ResultTy, ArgTys, Record[0]);
}
ResultTy = getTypeByID(Record[1]);
- if (ResultTy == 0 || ArgTys.size() < Record.size()-2)
+ if (!ResultTy || ArgTys.size() < Record.size()-2)
return Error(InvalidType);
ResultTy = FunctionType::get(ResultTy, ArgTys, Record[0]);
StructType *Res = cast_or_null<StructType>(TypeList[NumRecords]);
if (Res) {
Res->setName(TypeName);
- TypeList[NumRecords] = 0;
+ TypeList[NumRecords] = nullptr;
} else // Otherwise, create a new struct.
Res = StructType::create(Context, TypeName);
TypeName.clear();
StructType *Res = cast_or_null<StructType>(TypeList[NumRecords]);
if (Res) {
Res->setName(TypeName);
- TypeList[NumRecords] = 0;
+ TypeList[NumRecords] = nullptr;
} else // Otherwise, create a new struct with no body.
Res = StructType::create(Context, TypeName);
TypeName.clear();
if (NumRecords >= TypeList.size())
return Error(InvalidTYPETable);
assert(ResultTy && "Didn't read a type?");
- assert(TypeList[NumRecords] == 0 && "Already read type?");
+ assert(!TypeList[NumRecords] && "Already read type?");
TypeList[NumRecords++] = ResultTy;
}
}
if (ConvertToString(Record, 1, ValueName))
return Error(InvalidRecord);
BasicBlock *BB = getBasicBlock(Record[0]);
- if (BB == 0)
+ if (!BB)
return Error(InvalidRecord);
BB->setName(StringRef(ValueName.data(), ValueName.size()));
NamedMDNode *NMD = TheModule->getOrInsertNamedMetadata(Name);
for (unsigned i = 0; i != Size; ++i) {
MDNode *MD = dyn_cast_or_null<MDNode>(MDValueList.getValueFwdRef(Record[i]));
- if (MD == 0)
+ if (!MD)
return Error(InvalidRecord);
NMD->addOperand(MD);
}
else if (!Ty->isVoidTy())
Elts.push_back(ValueList.getValueFwdRef(Record[i+1], Ty));
else
- Elts.push_back(NULL);
+ Elts.push_back(nullptr);
}
Value *V = MDNode::getWhenValsUnresolved(Context, Elts, IsFunctionLocal);
IsFunctionLocal = false;
// Read a record.
Record.clear();
- Value *V = 0;
+ Value *V = nullptr;
unsigned BitCode = Stream.readRecord(Entry.ID, Record);
switch (BitCode) {
default: // Default behavior: unknown constant
return Error(InvalidRecord);
VectorType *OpTy =
dyn_cast_or_null<VectorType>(getTypeByID(Record[0]));
- if (OpTy == 0)
+ if (!OpTy)
return Error(InvalidRecord);
Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy);
Constant *Op1 = ValueList.getConstantFwdRef(Record[2],
}
case bitc::CST_CODE_CE_INSERTELT: { // CE_INSERTELT: [opval, opval, opval]
VectorType *OpTy = dyn_cast<VectorType>(CurTy);
- if (Record.size() < 3 || OpTy == 0)
+ if (Record.size() < 3 || !OpTy)
return Error(InvalidRecord);
Constant *Op0 = ValueList.getConstantFwdRef(Record[0], OpTy);
Constant *Op1 = ValueList.getConstantFwdRef(Record[1],
}
case bitc::CST_CODE_CE_SHUFFLEVEC: { // CE_SHUFFLEVEC: [opval, opval, opval]
VectorType *OpTy = dyn_cast<VectorType>(CurTy);
- if (Record.size() < 3 || OpTy == 0)
+ if (Record.size() < 3 || !OpTy)
return Error(InvalidRecord);
Constant *Op0 = ValueList.getConstantFwdRef(Record[0], OpTy);
Constant *Op1 = ValueList.getConstantFwdRef(Record[1], OpTy);
VectorType *RTy = dyn_cast<VectorType>(CurTy);
VectorType *OpTy =
dyn_cast_or_null<VectorType>(getTypeByID(Record[0]));
- if (Record.size() < 4 || RTy == 0 || OpTy == 0)
+ if (Record.size() < 4 || !RTy || !OpTy)
return Error(InvalidRecord);
Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy);
Constant *Op1 = ValueList.getConstantFwdRef(Record[2], OpTy);
if (Record.size() < 4)
return Error(InvalidRecord);
Type *OpTy = getTypeByID(Record[0]);
- if (OpTy == 0)
+ if (!OpTy)
return Error(InvalidRecord);
Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy);
Constant *Op1 = ValueList.getConstantFwdRef(Record[2], OpTy);
if (Record.size() < 3)
return Error(InvalidRecord);
Type *FnTy = getTypeByID(Record[0]);
- if (FnTy == 0)
+ if (!FnTy)
return Error(InvalidRecord);
Function *Fn =
dyn_cast_or_null<Function>(ValueList.getConstantFwdRef(Record[1],FnTy));
- if (Fn == 0)
+ if (!Fn)
return Error(InvalidRecord);
// If the function is already parsed we can insert the block address right
GlobalVariable *FwdRef = new GlobalVariable(*Fn->getParent(),
Type::getInt8Ty(Context),
false, GlobalValue::InternalLinkage,
- 0, "");
+ nullptr, "");
BlockAddrFwdRefs[Fn].push_back(std::make_pair(Record[2], FwdRef));
V = FwdRef;
}
ExternallyInitialized = Record[9];
GlobalVariable *NewGV =
- new GlobalVariable(*TheModule, Ty, isConstant, Linkage, 0, "", 0,
+ new GlobalVariable(*TheModule, Ty, isConstant, Linkage, nullptr, "", nullptr,
TLM, AddressSpace, ExternallyInitialized);
NewGV->setAlignment(Alignment);
if (!Section.empty())
return Error(InvalidTypeForValue);
GlobalAlias *NewGA = new GlobalAlias(Ty, GetDecodedLinkage(Record[2]),
- "", 0, TheModule);
+ "", nullptr, TheModule);
// Old bitcode files didn't have visibility field.
if (Record.size() > 3)
NewGA->setVisibility(GetDecodedVisibility(Record[3]));
}
error_code BitcodeReader::ParseBitcodeInto(Module *M) {
- TheModule = 0;
+ TheModule = nullptr;
if (error_code EC = InitStream())
return EC;
ValueList.push_back(I);
unsigned NextValueNo = ValueList.size();
- BasicBlock *CurBB = 0;
+ BasicBlock *CurBB = nullptr;
unsigned CurBBNo = 0;
DebugLoc LastLoc;
// Read a record.
Record.clear();
- Instruction *I = 0;
+ Instruction *I = nullptr;
unsigned BitCode = Stream.readRecord(Entry.ID, Record);
switch (BitCode) {
default: // Default behavior: reject
case bitc::FUNC_CODE_DEBUG_LOC_AGAIN: // DEBUG_LOC_AGAIN
// This record indicates that the last instruction is at the same
// location as the previous instruction with a location.
- I = 0;
+ I = nullptr;
// Get the last instruction emitted.
if (CurBB && !CurBB->empty())
!FunctionBBs[CurBBNo-1]->empty())
I = &FunctionBBs[CurBBNo-1]->back();
- if (I == 0)
+ if (!I)
return Error(InvalidRecord);
I->setDebugLoc(LastLoc);
- I = 0;
+ I = nullptr;
continue;
case bitc::FUNC_CODE_DEBUG_LOC: { // DEBUG_LOC: [line, col, scope, ia]
- I = 0; // Get the last instruction emitted.
+ I = nullptr; // Get the last instruction emitted.
if (CurBB && !CurBB->empty())
I = &CurBB->back();
else if (CurBBNo && FunctionBBs[CurBBNo-1] &&
!FunctionBBs[CurBBNo-1]->empty())
I = &FunctionBBs[CurBBNo-1]->back();
- if (I == 0 || Record.size() < 4)
+ if (!I || Record.size() < 4)
return Error(InvalidRecord);
unsigned Line = Record[0], Col = Record[1];
unsigned ScopeID = Record[2], IAID = Record[3];
- MDNode *Scope = 0, *IA = 0;
+ MDNode *Scope = nullptr, *IA = nullptr;
if (ScopeID) Scope = cast<MDNode>(MDValueList.getValueFwdRef(ScopeID-1));
if (IAID) IA = cast<MDNode>(MDValueList.getValueFwdRef(IAID-1));
LastLoc = DebugLoc::get(Line, Col, Scope, IA);
I->setDebugLoc(LastLoc);
- I = 0;
+ I = nullptr;
continue;
}
Type *ResTy = getTypeByID(Record[OpNum]);
int Opc = GetDecodedCastOpcode(Record[OpNum+1]);
- if (Opc == -1 || ResTy == 0)
+ if (Opc == -1 || !ResTy)
return Error(InvalidRecord);
- Instruction *Temp = 0;
+ Instruction *Temp = nullptr;
if ((I = UpgradeBitCastInst(Opc, Op, ResTy, Temp))) {
if (Temp) {
InstructionList.push_back(Temp);
}
unsigned OpNum = 0;
- Value *Op = NULL;
+ Value *Op = nullptr;
if (getValueTypePair(Record, OpNum, NextValueNo, Op))
return Error(InvalidRecord);
if (OpNum != Record.size())
if (Record.size() != 1 && Record.size() != 3)
return Error(InvalidRecord);
BasicBlock *TrueDest = getBasicBlock(Record[0]);
- if (TrueDest == 0)
+ if (!TrueDest)
return Error(InvalidRecord);
if (Record.size() == 1) {
BasicBlock *FalseDest = getBasicBlock(Record[1]);
Value *Cond = getValue(Record, 2, NextValueNo,
Type::getInt1Ty(Context));
- if (FalseDest == 0 || Cond == 0)
+ if (!FalseDest || !Cond)
return Error(InvalidRecord);
I = BranchInst::Create(TrueDest, FalseDest, Cond);
InstructionList.push_back(I);
Value *Cond = getValue(Record, 2, NextValueNo, OpTy);
BasicBlock *Default = getBasicBlock(Record[3]);
- if (OpTy == 0 || Cond == 0 || Default == 0)
+ if (!OpTy || !Cond || !Default)
return Error(InvalidRecord);
unsigned NumCases = Record[4];
Type *OpTy = getTypeByID(Record[0]);
Value *Cond = getValue(Record, 1, NextValueNo, OpTy);
BasicBlock *Default = getBasicBlock(Record[2]);
- if (OpTy == 0 || Cond == 0 || Default == 0)
+ if (!OpTy || !Cond || !Default)
return Error(InvalidRecord);
unsigned NumCases = (Record.size()-3)/2;
SwitchInst *SI = SwitchInst::Create(Cond, Default, NumCases);
ConstantInt *CaseVal =
dyn_cast_or_null<ConstantInt>(getFnValueByID(Record[3+i*2], OpTy));
BasicBlock *DestBB = getBasicBlock(Record[1+3+i*2]);
- if (CaseVal == 0 || DestBB == 0) {
+ if (!CaseVal || !DestBB) {
delete SI;
return Error(InvalidRecord);
}
return Error(InvalidRecord);
Type *OpTy = getTypeByID(Record[0]);
Value *Address = getValue(Record, 1, NextValueNo, OpTy);
- if (OpTy == 0 || Address == 0)
+ if (!OpTy || !Address)
return Error(InvalidRecord);
unsigned NumDests = Record.size()-2;
IndirectBrInst *IBI = IndirectBrInst::Create(Address, NumDests);
return Error(InvalidRecord);
PointerType *CalleeTy = dyn_cast<PointerType>(Callee->getType());
- FunctionType *FTy = !CalleeTy ? 0 :
+ FunctionType *FTy = !CalleeTy ? nullptr :
dyn_cast<FunctionType>(CalleeTy->getElementType());
// Check that the right number of fixed parameters are here.
- if (FTy == 0 || NormalBB == 0 || UnwindBB == 0 ||
+ if (!FTy || !NormalBB || !UnwindBB ||
Record.size() < OpNum+FTy->getNumParams())
return Error(InvalidRecord);
for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i, ++OpNum) {
Ops.push_back(getValue(Record, OpNum, NextValueNo,
FTy->getParamType(i)));
- if (Ops.back() == 0)
+ if (!Ops.back())
return Error(InvalidRecord);
}
}
case bitc::FUNC_CODE_INST_RESUME: { // RESUME: [opval]
unsigned Idx = 0;
- Value *Val = 0;
+ Value *Val = nullptr;
if (getValueTypePair(Record, Idx, NextValueNo, Val))
return Error(InvalidRecord);
I = ResumeInst::Create(Val);
Type *Ty = getTypeByID(Record[Idx++]);
if (!Ty)
return Error(InvalidRecord);
- Value *PersFn = 0;
+ Value *PersFn = nullptr;
if (getValueTypePair(Record, Idx, NextValueNo, PersFn))
return Error(InvalidRecord);
return Error(InvalidRecord);
PointerType *OpTy = dyn_cast<PointerType>(Callee->getType());
- FunctionType *FTy = 0;
+ FunctionType *FTy = nullptr;
if (OpTy) FTy = dyn_cast<FunctionType>(OpTy->getElementType());
if (!FTy || Record.size() < FTy->getNumParams()+OpNum)
return Error(InvalidRecord);
else
Args.push_back(getValue(Record, OpNum, NextValueNo,
FTy->getParamType(i)));
- if (Args.back() == 0)
+ if (!Args.back())
return Error(InvalidRecord);
}
// Add instruction to end of current BB. If there is no current BB, reject
// this file.
- if (CurBB == 0) {
+ if (!CurBB) {
delete I;
return Error(InvalidInstructionWithNoBB);
}
// If this was a terminator instruction, move to the next block.
if (isa<TerminatorInst>(I)) {
++CurBBNo;
- CurBB = CurBBNo < FunctionBBs.size() ? FunctionBBs[CurBBNo] : 0;
+ CurBB = CurBBNo < FunctionBBs.size() ? FunctionBBs[CurBBNo] : nullptr;
}
// Non-void values get registered in the value table for future use.
// Check the function list for unresolved values.
if (Argument *A = dyn_cast<Argument>(ValueList.back())) {
- if (A->getParent() == 0) {
+ if (!A->getParent()) {
// We found at least one unresolved value. Nuke them all to avoid leaks.
for (unsigned i = ModuleValueListSize, e = ValueList.size(); i != e; ++i){
- if ((A = dyn_cast_or_null<Argument>(ValueList[i])) && A->getParent() == 0) {
+ if ((A = dyn_cast_or_null<Argument>(ValueList[i])) && !A->getParent()) {
A->replaceAllUsesWith(UndefValue::get(A->getType()));
delete A;
}
if (ErrMsg)
*ErrMsg = EC.message();
delete M; // Also deletes R.
- return 0;
+ return nullptr;
}
R->setBufferOwned(false); // no buffer to delete
return M;
if (EnterSubBlock(bitc::BLOCKINFO_BLOCK_ID)) return true;
SmallVector<uint64_t, 64> Record;
- BitstreamReader::BlockInfo *CurBlockInfo = 0;
+ BitstreamReader::BlockInfo *CurBlockInfo = nullptr;
// Read all the records for this module.
while (1) {
SmallVector<uint64_t, 64> Record;
const ValueEnumerator::ValueList &Vals = VE.getValues();
- Type *LastTy = 0;
+ Type *LastTy = nullptr;
for (unsigned i = FirstVal; i != LastVal; ++i) {
const Value *V = Vals[i].first;
// If we need to switch types, do so now.
cu->getCompileUnitDIE()->getAttributeValueAsSectionOffset(
cu, DW_AT_stmt_list, -1U);
if (stmtOffset == -1U)
- return 0; // No line table for this compile unit.
+ return nullptr; // No line table for this compile unit.
// See if the line table is cached.
if (const DWARFLineTable *lt = Line->getLineTable(stmtOffset))
if (CU != CUs.end()) {
return CU->get();
}
- return 0;
+ return nullptr;
}
DWARFCompileUnit *DWARFContext::getCompileUnitForAddress(uint64_t Address) {
uint64_t FileIndex,
bool NeedsAbsoluteFilePath,
std::string &FileName) {
- if (CU == 0 ||
- LineTable == 0 ||
+ if (!CU || !LineTable ||
!LineTable->getFileNameByIndex(FileIndex, NeedsAbsoluteFilePath,
FileName))
return false;
bool NeedsAbsoluteFilePath,
std::string &FileName,
uint32_t &Line, uint32_t &Column) {
- if (CU == 0 || LineTable == 0)
+ if (!CU || !LineTable)
return false;
// Get the index of row we're looking for in the line table.
uint32_t RowIndex = LineTable->lookupAddress(Address);
DIInliningInfo InliningInfo;
uint32_t CallFile = 0, CallLine = 0, CallColumn = 0;
- const DWARFLineTable *LineTable = 0;
+ const DWARFLineTable *LineTable = nullptr;
for (uint32_t i = 0, n = InlinedChain.DIEs.size(); i != n; i++) {
const DWARFDebugInfoEntryMinimal &FunctionDIE = InlinedChain.DIEs[i];
std::string FileName = "<invalid>";
.Case("debug_str_offsets.dwo", &StringOffsetDWOSection)
.Case("debug_addr", &AddrSection)
// Any more debug info sections go here.
- .Default(0);
+ .Default(nullptr);
if (SectionData) {
*SectionData = data;
if (name == "debug_ranges") {
.Case("debug_loc", &LocSection.Relocs)
.Case("debug_info.dwo", &InfoDWOSection.Relocs)
.Case("debug_line", &LineSection.Relocs)
- .Default(0);
+ .Default(nullptr);
if (!Map) {
// Find debug_types relocs by section rather than name as there are
// multiple, comdat grouped, debug_types sections.
if (idx < Decls.size())
return &Decls[idx];
}
- return NULL;
+ return nullptr;
}
DWARFDebugAbbrev::DWARFDebugAbbrev() :
if (pos != AbbrevCollMap.end())
return &(pos->second);
- return NULL;
+ return nullptr;
}
int64_t LinkedCIEOffset, uint64_t InitialLocation, uint64_t AddressRange)
: FrameEntry(FK_FDE, D, Offset, Length), LinkedCIEOffset(LinkedCIEOffset),
InitialLocation(InitialLocation), AddressRange(AddressRange),
- LinkedCIE(NULL) {}
+ LinkedCIE(nullptr) {}
~FDE() {
}
Id = Data.getUnsigned(&Offset, IsDWARF64 ? 8 : 4);
bool IsCIE = ((IsDWARF64 && Id == DW64_CIE_ID) || Id == DW_CIE_ID);
- FrameEntry *Entry = 0;
+ FrameEntry *Entry = nullptr;
if (IsCIE) {
// Note: this is specifically DWARFv3 CIE header structure. It was
// changed in DWARFv4. We currently don't support reading DWARFv4
uint64_t AbbrCode = DebugInfoData.getULEB128(OffsetPtr);
if (0 == AbbrCode) {
// NULL debug tag entry.
- AbbrevDecl = NULL;
+ AbbrevDecl = nullptr;
return true;
}
AbbrevDecl = U->getAbbreviations()->getAbbreviationDeclaration(AbbrCode);
- if (0 == AbbrevDecl) {
+ if (nullptr == AbbrevDecl) {
// Restore the original offset.
*OffsetPtr = Offset;
return false;
const char *
DWARFDebugInfoEntryMinimal::getSubroutineName(const DWARFUnit *U) const {
if (!isSubroutineDIE())
- return 0;
+ return nullptr;
// Try to get mangled name if possible.
if (const char *name =
- getAttributeValueAsString(U, DW_AT_MIPS_linkage_name, 0))
+ getAttributeValueAsString(U, DW_AT_MIPS_linkage_name, nullptr))
return name;
- if (const char *name = getAttributeValueAsString(U, DW_AT_linkage_name, 0))
+ if (const char *name = getAttributeValueAsString(U, DW_AT_linkage_name,
+ nullptr))
return name;
- if (const char *name = getAttributeValueAsString(U, DW_AT_name, 0))
+ if (const char *name = getAttributeValueAsString(U, DW_AT_name, nullptr))
return name;
// Try to get name from specification DIE.
uint32_t spec_ref =
return name;
}
}
- return 0;
+ return nullptr;
}
void DWARFDebugInfoEntryMinimal::getCallerFrame(const DWARFUnit *U,
LineTableConstIter pos = LineTableMap.find(offset);
if (pos != LineTableMap.end())
return &pos->second;
- return 0;
+ return nullptr;
}
const DWARFDebugLine::LineTable *
// Parse and cache the line table for at this offset.
State state;
if (!parseStatementTable(debug_line_data, RelocMap, &offset, state))
- return 0;
+ return nullptr;
pos.first->second = state;
}
return &pos.first->second;
const DWARFUnit *cu) {
bool indirect = false;
bool is_block = false;
- Value.data = NULL;
+ Value.data = nullptr;
// Read the value for the form into value and follow and DW_FORM_indirect
// instances we run into
do {
if (is_block) {
StringRef str = data.getData().substr(*offset_ptr, Value.uval);
- Value.data = NULL;
+ Value.data = nullptr;
if (!str.empty()) {
Value.data = reinterpret_cast<const uint8_t *>(str.data());
*offset_ptr += Value.uval;
return None;
if (Form == DW_FORM_string)
return Value.cstr;
- if (U == 0)
+ if (!U)
return None;
uint32_t Offset = Value.uval;
if (Form == DW_FORM_GNU_str_index) {
if (Form == DW_FORM_GNU_addr_index) {
uint32_t Index = Value.uval;
uint64_t Result;
- if (U == 0 || !U->getAddrOffsetSectionItem(Index, Result))
+ if (!U || !U->getAddrOffsetSectionItem(Index, Result))
return None;
return Result;
}
case DW_FORM_ref4:
case DW_FORM_ref8:
case DW_FORM_ref_udata:
- if (U == 0)
+ if (!U)
return None;
return Value.uval + U->getOffset();
case DW_FORM_ref_addr:
Offset = 0;
Length = 0;
Version = 0;
- Abbrevs = 0;
+ Abbrevs = nullptr;
AddrSize = 0;
BaseAddr = 0;
RangeSectionBase = 0;
const char *DWARFUnit::getCompilationDir() {
extractDIEsIfNeeded(true);
if (DieArray.empty())
- return 0;
- return DieArray[0].getAttributeValueAsString(this, DW_AT_comp_dir, 0);
+ return nullptr;
+ return DieArray[0].getAttributeValueAsString(this, DW_AT_comp_dir, nullptr);
}
uint64_t DWARFUnit::getDWOId() {
DWARFUnit::DWOHolder::DWOHolder(object::ObjectFile *DWOFile)
: DWOFile(DWOFile),
DWOContext(cast<DWARFContext>(DIContext::getDWARFContext(DWOFile))),
- DWOU(0) {
+ DWOU(nullptr) {
if (DWOContext->getNumDWOCompileUnits() > 0)
DWOU = DWOContext->getDWOCompileUnitAtIndex(0);
}
bool DWARFUnit::parseDWO() {
- if (DWO.get() != 0)
+ if (DWO.get())
return false;
extractDIEsIfNeeded(true);
if (DieArray.empty())
return false;
const char *DWOFileName =
- DieArray[0].getAttributeValueAsString(this, DW_AT_GNU_dwo_name, 0);
- if (DWOFileName == 0)
+ DieArray[0].getAttributeValueAsString(this, DW_AT_GNU_dwo_name, nullptr);
+ if (!DWOFileName)
return false;
const char *CompilationDir =
- DieArray[0].getAttributeValueAsString(this, DW_AT_comp_dir, 0);
+ DieArray[0].getAttributeValueAsString(this, DW_AT_comp_dir, nullptr);
SmallString<16> AbsolutePath;
- if (sys::path::is_relative(DWOFileName) && CompilationDir != 0) {
+ if (sys::path::is_relative(DWOFileName) && CompilationDir != nullptr) {
sys::path::append(AbsolutePath, CompilationDir);
}
sys::path::append(AbsolutePath, DWOFileName);
DWO.reset(new DWOHolder(DWOFile.get()));
DWARFUnit *DWOCU = DWO->getUnit();
// Verify that compile unit in .dwo file is valid.
- if (DWOCU == 0 || DWOCU->getDWOId() != getDWOId()) {
+ if (!DWOCU || DWOCU->getDWOId() != getDWOId()) {
DWO.reset();
return false;
}
return &DIE;
}
}
- return 0;
+ return nullptr;
}
DWARFDebugInfoEntryInlinedChain
DWARFUnit::getInlinedChainForAddress(uint64_t Address) {
// First, find a subprogram that contains the given address (the root
// of inlined chain).
- const DWARFUnit *ChainCU = 0;
+ const DWARFUnit *ChainCU = nullptr;
const DWARFDebugInfoEntryMinimal *SubprogramDIE =
getSubprogramForAddress(Address);
if (SubprogramDIE) {
std::string *ErrorStr,
JITMemoryManager *JMM,
bool GVsWithCode,
- TargetMachine *TM) = 0;
+ TargetMachine *TM) = nullptr;
ExecutionEngine *(*ExecutionEngine::MCJITCtor)(
Module *M,
std::string *ErrorStr,
RTDyldMemoryManager *MCJMM,
bool GVsWithCode,
- TargetMachine *TM) = 0;
+ TargetMachine *TM) = nullptr;
ExecutionEngine *(*ExecutionEngine::InterpCtor)(Module *M,
- std::string *ErrorStr) = 0;
+ std::string *ErrorStr) =nullptr;
ExecutionEngine::ExecutionEngine(Module *M)
: EEState(*this),
- LazyFunctionCreator(0) {
+ LazyFunctionCreator(nullptr) {
CompilingLazily = false;
GVCompilationDisabled = false;
SymbolSearchingDisabled = false;
if (Function *F = Modules[i]->getFunction(FnName))
return F;
}
- return 0;
+ return nullptr;
}
// FIXME: This is silly, we shouldn't end up with a mapping -> 0 in the
// GlobalAddressMap.
if (I == GlobalAddressMap.end())
- OldVal = 0;
+ OldVal = nullptr;
else {
OldVal = I->second;
GlobalAddressMap.erase(I);
DEBUG(dbgs() << "JIT: Map \'" << GV->getName()
<< "\' to [" << Addr << "]\n";);
void *&CurVal = EEState.getGlobalAddressMap(locked)[GV];
- assert((CurVal == 0 || Addr == 0) && "GlobalMapping already established!");
+ assert((!CurVal || !Addr) && "GlobalMapping already established!");
CurVal = Addr;
// If we are using the reverse mapping, add it too.
if (!EEState.getGlobalAddressReverseMap(locked).empty()) {
AssertingVH<const GlobalValue> &V =
EEState.getGlobalAddressReverseMap(locked)[Addr];
- assert((V == 0 || GV == 0) && "GlobalMapping already established!");
+ assert((!V || !GV) && "GlobalMapping already established!");
V = GV;
}
}
EEState.getGlobalAddressMap(locked);
// Deleting from the mapping?
- if (Addr == 0)
+ if (!Addr)
return EEState.RemoveMapping(locked, GV);
void *&CurVal = Map[GV];
if (!EEState.getGlobalAddressReverseMap(locked).empty()) {
AssertingVH<const GlobalValue> &V =
EEState.getGlobalAddressReverseMap(locked)[Addr];
- assert((V == 0 || GV == 0) && "GlobalMapping already established!");
+ assert((!V || !GV) && "GlobalMapping already established!");
V = GV;
}
return OldVal;
ExecutionEngineState::GlobalAddressMapTy::iterator I =
EEState.getGlobalAddressMap(locked).find(GV);
- return I != EEState.getGlobalAddressMap(locked).end() ? I->second : 0;
+ return I != EEState.getGlobalAddressMap(locked).end() ? I->second : nullptr;
}
const GlobalValue *ExecutionEngine::getGlobalValueAtAddress(void *Addr) {
std::map<void *, AssertingVH<const GlobalValue> >::iterator I =
EEState.getGlobalAddressReverseMap(locked).find(Addr);
- return I != EEState.getGlobalAddressReverseMap(locked).end() ? I->second : 0;
+ return I != EEState.getGlobalAddressReverseMap(locked).end() ? I->second : nullptr;
}
namespace {
char *Array;
std::vector<char*> Values;
public:
- ArgvArray() : Array(NULL) {}
+ ArgvArray() : Array(nullptr) {}
~ArgvArray() { clear(); }
void clear() {
delete[] Array;
- Array = NULL;
+ Array = nullptr;
for (size_t I = 0, E = Values.size(); I != E; ++I) {
delete[] Values[I];
}
}
// Null terminate it
- EE->StoreValueToMemory(PTOGV(0),
+ EE->StoreValueToMemory(PTOGV(nullptr),
(GenericValue*)(Array+InputArgv.size()*PtrSize),
SBytePtr);
return Array;
// Should be an array of '{ i32, void ()* }' structs. The first value is
// the init priority, which we ignore.
ConstantArray *InitList = dyn_cast<ConstantArray>(GV->getInitializer());
- if (InitList == 0)
+ if (!InitList)
return;
for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) {
ConstantStruct *CS = dyn_cast<ConstantStruct>(InitList->getOperand(i));
- if (CS == 0) continue;
+ if (!CS) continue;
Constant *FP = CS->getOperand(1);
if (FP->isNullValue())
bool GVsWithCode,
Reloc::Model RM,
CodeModel::Model CMM) {
- if (ExecutionEngine::JITCtor == 0) {
+ if (!ExecutionEngine::JITCtor) {
if (ErrorStr)
*ErrorStr = "JIT has not been linked in.";
- return 0;
+ return nullptr;
}
// Use the defaults for extra parameters. Users can use EngineBuilder to
// TODO: permit custom TargetOptions here
TargetMachine *TM = EB.selectTarget();
- if (!TM || (ErrorStr && ErrorStr->length() > 0)) return 0;
+ if (!TM || (ErrorStr && ErrorStr->length() > 0)) return nullptr;
return ExecutionEngine::JITCtor(M, ErrorStr, JMM, GVsWithCode, TM);
}
// Make sure we can resolve symbols in the program as well. The zero arg
// to the function tells DynamicLibrary to load the program, not a library.
- if (sys::DynamicLibrary::LoadLibraryPermanently(0, ErrorStr))
- return 0;
+ if (sys::DynamicLibrary::LoadLibraryPermanently(nullptr, ErrorStr))
+ return nullptr;
assert(!(JMM && MCJMM));
else {
if (ErrorStr)
*ErrorStr = "Cannot create an interpreter with a memory manager.";
- return 0;
+ return nullptr;
}
}
*ErrorStr =
"Cannot create a legacy JIT with a runtime dyld memory "
"manager.";
- return 0;
+ return nullptr;
}
// Unless the interpreter was explicitly selected or the JIT is not linked,
return ExecutionEngine::InterpCtor(M, ErrorStr);
if (ErrorStr)
*ErrorStr = "Interpreter has not been linked in.";
- return 0;
+ return nullptr;
}
- if ((WhichEngine & EngineKind::JIT) && ExecutionEngine::JITCtor == 0 &&
- ExecutionEngine::MCJITCtor == 0) {
+ if ((WhichEngine & EngineKind::JIT) && !ExecutionEngine::JITCtor &&
+ !ExecutionEngine::MCJITCtor) {
if (ErrorStr)
*ErrorStr = "JIT has not been linked in.";
}
- return 0;
+ return nullptr;
}
void *ExecutionEngine::getPointerToGlobal(const GlobalValue *GV) {
break;
case Type::PointerTyID:
if (isa<ConstantPointerNull>(C))
- Result.PointerVal = 0;
+ Result.PointerVal = nullptr;
else if (const Function *F = dyn_cast<Function>(C))
Result = PTOGV(getPointerToFunctionOrStub(const_cast<Function*>(F)));
else if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(C))
void ExecutionEngine::EmitGlobalVariable(const GlobalVariable *GV) {
void *GA = getPointerToGlobalIfAvailable(GV);
- if (GA == 0) {
+ if (!GA) {
// If it's not already specified, allocate memory for the global.
GA = getMemoryForGV(GV);
// If we failed to allocate memory for this global, return.
- if (GA == 0) return;
+ if (!GA) return;
addGlobalMapping(GV, GA);
}
}
bool SimpleBindingMemoryManager::finalizeMemory(std::string *ErrMsg) {
- char *errMsgCString = 0;
+ char *errMsgCString = nullptr;
bool result = Functions.FinalizeMemory(Opaque, &errMsgCString);
assert((result || !errMsgCString) &&
"Did not expect an error message if FinalizeMemory succeeded");
if (!AllocateCodeSection || !AllocateDataSection || !FinalizeMemory ||
!Destroy)
- return NULL;
+ return nullptr;
SimpleBindingMMFunctions functions;
functions.AllocateCodeSection = AllocateCodeSection;
TheTriple.setTriple(sys::getProcessTriple());
// Adjust the triple to match what the user requested.
- const Target *TheTarget = 0;
+ const Target *TheTarget = nullptr;
if (!MArch.empty()) {
for (TargetRegistry::iterator it = TargetRegistry::begin(),
ie = TargetRegistry::end(); it != ie; ++it) {
if (ErrorStr)
*ErrorStr = "No available targets are compatible with this -march, "
"see -version for the available targets.\n";
- return 0;
+ return nullptr;
}
// Adjust the triple to match (if known), otherwise stick with the
} else {
std::string Error;
TheTarget = TargetRegistry::lookupTarget(TheTriple.getTriple(), Error);
- if (TheTarget == 0) {
+ if (!TheTarget) {
if (ErrorStr)
*ErrorStr = Error;
- return 0;
+ return nullptr;
}
}
}
}
- assert(getParent() == 0 && "BasicBlock still linked into the program!");
+ assert(getParent() == nullptr && "BasicBlock still linked into the program!");
dropAllReferences();
InstList.clear();
}
if (isa<UndefValue>(C)) {
PointerType *Ptr = cast<PointerType>(C->getType());
Type *Ty = GetElementPtrInst::getIndexedType(Ptr, Idxs);
- assert(Ty != 0 && "Invalid indices for GEP!");
+ assert(Ty && "Invalid indices for GEP!");
return UndefValue::get(PointerType::get(Ty, Ptr->getAddressSpace()));
}
if (isNull) {
PointerType *Ptr = cast<PointerType>(C->getType());
Type *Ty = GetElementPtrInst::getIndexedType(Ptr, Idxs);
- assert(Ty != 0 && "Invalid indices for GEP!");
+ assert(Ty && "Invalid indices for GEP!");
return ConstantPointerNull::get(PointerType::get(Ty,
Ptr->getAddressSpace()));
}
//
BlockAddress *BlockAddress::get(BasicBlock *BB) {
- assert(BB->getParent() != 0 && "Block must have a parent");
+ assert(BB->getParent() && "Block must have a parent");
return get(BB->getParent(), BB);
}
return nullptr;
const Function *F = BB->getParent();
- assert(F != 0 && "Block must have a parent");
+ assert(F && "Block must have a parent");
BlockAddress *BA =
F->getContext().pImpl->BlockAddresses.lookup(std::make_pair(F, BB));
assert(BA && "Refcount and block address map disagree!");
MDNode *OldScope = Entry.first.get();
MDNode *OldInlinedAt = Entry.second.get();
- assert(OldScope != 0 && OldInlinedAt != 0 &&
+ assert(OldScope && OldInlinedAt &&
"Entry should be non-canonical if either val dropped to null");
// Otherwise, we do have an entry in it, nuke it and we're done.
MDNode *OldScope = Entry.first.get();
MDNode *OldInlinedAt = Entry.second.get();
- assert(OldScope != 0 && OldInlinedAt != 0 &&
+ assert(OldScope && OldInlinedAt &&
"Entry should be non-canonical if either val dropped to null");
// Otherwise, we do have an entry in it, nuke it and we're done.
// Out of line virtual method, so the vtable, etc has a home.
Instruction::~Instruction() {
- assert(Parent == 0 && "Instruction still linked in the program!");
+ assert(!Parent && "Instruction still linked in the program!");
if (hasMetadataHashEntry())
clearMetadataHashEntries();
}
: TerminatorInst(Type::getVoidTy(IfTrue->getContext()), Instruction::Br,
OperandTraits<BranchInst>::op_end(this) - 1,
1, InsertBefore) {
- assert(IfTrue != 0 && "Branch destination may not be null!");
+ assert(IfTrue && "Branch destination may not be null!");
Op<-1>() = IfTrue;
}
BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
: TerminatorInst(Type::getVoidTy(IfTrue->getContext()), Instruction::Br,
OperandTraits<BranchInst>::op_end(this) - 1,
1, InsertAtEnd) {
- assert(IfTrue != 0 && "Branch destination may not be null!");
+ assert(IfTrue && "Branch destination may not be null!");
Op<-1>() = IfTrue;
}
MDNode *MDBuilder::createFPMath(float Accuracy) {
if (Accuracy == 0.0)
- return 0;
+ return nullptr;
assert(Accuracy > 0.0 && "Invalid fpmath accuracy!");
Value *Op = ConstantFP::get(Type::getFloatTy(Context), Accuracy);
return MDNode::get(Context, Op);
#ifndef NDEBUG
static const Function *assertLocalFunction(const MDNode *N) {
- if (!N->isFunctionLocal()) return 0;
+ if (!N->isFunctionLocal()) return nullptr;
// FIXME: This does not handle cyclic function local metadata.
- const Function *F = 0, *NewF = 0;
+ const Function *F = nullptr, *NewF = nullptr;
for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
if (Value *V = N->getOperand(i)) {
if (MDNode *MD = dyn_cast<MDNode>(V))
else
NewF = getFunctionForValue(V);
}
- if (F == 0)
+ if (!F)
F = NewF;
- else
- assert((NewF == 0 || F == NewF) &&"inconsistent function-local metadata");
+ else
+ assert((NewF == nullptr || F == NewF) &&
+ "inconsistent function-local metadata");
}
return F;
}
"Cannot add a pass to the same analysis group more than once!");
AGI.Implementations.insert(ImplementationInfo);
if (isDefault) {
- assert(InterfaceInfo->getNormalCtor() == 0 &&
+ assert(InterfaceInfo->getNormalCtor() == nullptr &&
"Default implementation for analysis group already specified!");
assert(ImplementationInfo->getNormalCtor() &&
"Cannot specify pass as default if it does not have a default ctor");
}
StructType *StructType::get(Type *type, ...) {
- assert(type != 0 && "Cannot create a struct type with no elements with this");
+ assert(type && "Cannot create a struct type with no elements with this");
LLVMContext &Ctx = type->getContext();
va_list ap;
SmallVector<llvm::Type*, 8> StructFields;
}
StructType *StructType::create(StringRef Name, Type *type, ...) {
- assert(type != 0 && "Cannot create a struct type with no elements with this");
+ assert(type && "Cannot create a struct type with no elements with this");
LLVMContext &Ctx = type->getContext();
va_list ap;
SmallVector<llvm::Type*, 8> StructFields;
}
void StructType::setBody(Type *type, ...) {
- assert(type != 0 && "Cannot create a struct type with no elements with this");
+ assert(type && "Cannot create a struct type with no elements with this");
va_list ap;
SmallVector<llvm::Type*, 8> StructFields;
va_start(ap, type);
// If this value already has a ValueHandle, then it must be in the
// ValueHandles map already.
ValueHandleBase *&Entry = pImpl->ValueHandles[VP.getPointer()];
- assert(Entry != 0 && "Value doesn't have any handles?");
+ assert(Entry && "Value doesn't have any handles?");
AddToExistingUseList(&Entry);
return;
}
const void *OldBucketPtr = Handles.getPointerIntoBucketsArray();
ValueHandleBase *&Entry = Handles[VP.getPointer()];
- assert(Entry == 0 && "Value really did already have handles?");
+ assert(!Entry && "Value really did already have handles?");
AddToExistingUseList(&Entry);
VP.getPointer()->HasValueHandle = true;
// ParseBitcodeFile does not take ownership of the Buffer in the
// case of an error.
delete Buffer;
- return NULL;
+ return nullptr;
}
return ModuleOrErr.get();
}
- return ParseAssembly(Buffer, 0, Err, Context);
+ return ParseAssembly(Buffer, nullptr, Err, Context);
}
Module *llvm::getLazyIRFileModule(const std::string &Filename, SMDiagnostic &Err,
if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, File)) {
Err = SMDiagnostic(Filename, SourceMgr::DK_Error,
"Could not open input file: " + ec.message());
- return 0;
+ return nullptr;
}
return getLazyIRModule(File.release(), Err, Context);
if (isBitcode((const unsigned char *)Buffer->getBufferStart(),
(const unsigned char *)Buffer->getBufferEnd())) {
ErrorOr<Module *> ModuleOrErr = parseBitcodeFile(Buffer, Context);
- Module *M = 0;
+ Module *M = nullptr;
if (error_code EC = ModuleOrErr.getError())
Err = SMDiagnostic(Buffer->getBufferIdentifier(), SourceMgr::DK_Error,
EC.message());
return M;
}
- return ParseAssembly(Buffer, 0, Err, Context);
+ return ParseAssembly(Buffer, nullptr, Err, Context);
}
Module *llvm::ParseIRFile(const std::string &Filename, SMDiagnostic &Err,
if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, File)) {
Err = SMDiagnostic(Filename, SourceMgr::DK_Error,
"Could not open input file: " + ec.message());
- return 0;
+ return nullptr;
}
return ParseIR(File.release(), Err, Context);
std::string buf;
raw_string_ostream os(buf);
- Diag.print(NULL, os, false);
+ Diag.print(nullptr, os, false);
os.flush();
*OutMessage = strdup(buf.c_str());
LTOCodeGenerator::LTOCodeGenerator()
: Context(getGlobalContext()), Linker(new Module("ld-temp.o", Context)),
- TargetMach(NULL), EmitDwarfDebugInfo(false), ScopeRestrictionsDone(false),
- CodeModel(LTO_CODEGEN_PIC_MODEL_DEFAULT), NativeObjectFile(NULL),
- DiagHandler(NULL), DiagContext(NULL) {
+ TargetMach(nullptr), EmitDwarfDebugInfo(false),
+ ScopeRestrictionsDone(false), CodeModel(LTO_CODEGEN_PIC_MODEL_DEFAULT),
+ NativeObjectFile(nullptr), DiagHandler(nullptr), DiagContext(nullptr) {
initializeLTOPasses();
}
LTOCodeGenerator::~LTOCodeGenerator() {
delete TargetMach;
delete NativeObjectFile;
- TargetMach = NULL;
- NativeObjectFile = NULL;
+ TargetMach = nullptr;
+ NativeObjectFile = nullptr;
Linker.deleteModule();
const char *name;
if (!compile_to_file(&name, disableOpt, disableInline, disableGVNLoadPRE,
errMsg))
- return NULL;
+ return nullptr;
// remove old buffer if compile() called twice
delete NativeObjectFile;
if (error_code ec = MemoryBuffer::getFile(name, BuffPtr, -1, false)) {
errMsg = ec.message();
sys::fs::remove(NativeObjectPath);
- return NULL;
+ return nullptr;
}
NativeObjectFile = BuffPtr.release();
sys::fs::remove(NativeObjectPath);
// return buffer, unless error
- if (NativeObjectFile == NULL)
- return NULL;
+ if (!NativeObjectFile)
+ return nullptr;
*length = NativeObjectFile->getBufferSize();
return NativeObjectFile->getBufferStart();
}
bool LTOCodeGenerator::determineTarget(std::string &errMsg) {
- if (TargetMach != NULL)
+ if (TargetMach)
return true;
std::string TripleStr = Linker.getModule()->getTargetTriple();
// create target machine from info for merged modules
const Target *march = TargetRegistry::lookupTarget(TripleStr, errMsg);
- if (march == NULL)
+ if (!march)
return false;
// The relocation model is actually a static member of TargetMachine and
static void findUsedValues(GlobalVariable *LLVMUsed,
SmallPtrSet<GlobalValue*, 8> &UsedValues) {
- if (LLVMUsed == 0) return;
+ if (!LLVMUsed) return;
ConstantArray *Inits = cast<ConstantArray>(LLVMUsed->getInitializer());
for (unsigned i = 0, e = Inits->getNumOperands(); i != e; ++i)
this->DiagHandler = DiagHandler;
this->DiagContext = Ctxt;
if (!DiagHandler)
- return Context.setDiagnosticHandler(NULL, NULL);
+ return Context.setDiagnosticHandler(nullptr, nullptr);
// Register the LTOCodeGenerator stub in the LLVMContext to forward the
// diagnostic to the external DiagHandler.
Context.setDiagnosticHandler(LTOCodeGenerator::DiagnosticHandler, this);
std::unique_ptr<MemoryBuffer> buffer;
if (error_code ec = MemoryBuffer::getFile(path, buffer)) {
errMsg = ec.message();
- return NULL;
+ return nullptr;
}
return makeLTOModule(buffer.release(), options, errMsg);
}
if (error_code ec =
MemoryBuffer::getOpenFileSlice(fd, path, buffer, map_size, offset)) {
errMsg = ec.message();
- return NULL;
+ return nullptr;
}
return makeLTOModule(buffer.release(), options, errMsg);
}
std::string &errMsg, StringRef path) {
std::unique_ptr<MemoryBuffer> buffer(makeBuffer(mem, length, path));
if (!buffer)
- return NULL;
+ return nullptr;
return makeLTOModule(buffer.release(), options, errMsg);
}
if (error_code EC = ModuleOrErr.getError()) {
errMsg = EC.message();
delete buffer;
- return NULL;
+ return nullptr;
}
std::unique_ptr<Module> m(ModuleOrErr.get());
// find machine architecture for this module
const Target *march = TargetRegistry::lookupTarget(TripleStr, errMsg);
if (!march)
- return NULL;
+ return nullptr;
// construct LTOModule, hand over ownership of module and target
SubtargetFeatures Features;
if (Ret->parseSymbols(errMsg)) {
delete Ret;
- return NULL;
+ return nullptr;
}
Ret->parseMetadata();
NameAndAttributes &info = _undefines[entry.getKey().data()];
- if (info.symbol == 0) {
+ if (info.symbol == nullptr) {
// FIXME: This is trying to take care of module ASM like this:
//
// module asm ".zerofill __FOO, __foo, _bar_baz_qux, 0"
info.attributes =
LTO_SYMBOL_PERMISSIONS_DATA | LTO_SYMBOL_DEFINITION_REGULAR | scope;
info.isFunction = false;
- info.symbol = 0;
+ info.symbol = nullptr;
// add to table of symbols
_symbols.push_back(info);
info.name = entry.getKey().data();
info.attributes = attr;
info.isFunction = false;
- info.symbol = 0;
+ info.symbol = nullptr;
entry.setValue(info);
}
// If the source has no name it can't link. If it has local linkage,
// there is no name match-up going on.
if (!SrcGV->hasName() || SrcGV->hasLocalLinkage())
- return 0;
+ return nullptr;
// Otherwise see if we have a match in the destination module's symtab.
GlobalValue *DGV = DstM->getNamedValue(SrcGV->getName());
- if (DGV == 0) return 0;
+ if (!DGV) return nullptr;
// If we found a global with the same name in the dest module, but it has
// internal linkage, we are really not doing any linkage here.
if (DGV->hasLocalLinkage())
- return 0;
+ return nullptr;
// Otherwise, we do in fact link to the destination global.
return DGV;
Value *ValueMaterializerTy::materializeValueFor(Value *V) {
Function *SF = dyn_cast<Function>(V);
if (!SF)
- return NULL;
+ return nullptr;
Function *DF = Function::Create(TypeMap.get(SF->getFunctionType()),
SF->getLinkage(), SF->getName(), DstM);
for (Module::global_iterator I = SrcM->global_begin(),
E = SrcM->global_end(); I != E; ++I) {
GlobalValue *DGV = getLinkedToGlobal(I);
- if (DGV == 0) continue;
+ if (!DGV) continue;
if (!DGV->hasAppendingLinkage() || !I->hasAppendingLinkage()) {
TypeMap.addTypeMapping(DGV->getType(), I->getType());
// Create the new global variable.
GlobalVariable *NG =
new GlobalVariable(*DstGV->getParent(), NewType, SrcGV->isConstant(),
- DstGV->getLinkage(), /*init*/0, /*name*/"", DstGV,
+ DstGV->getLinkage(), /*init*/nullptr, /*name*/"", DstGV,
DstGV->getThreadLocalMode(),
DstGV->getType()->getAddressSpace());
// initializer will be filled in later by LinkGlobalInits.
GlobalVariable *NewDGV =
new GlobalVariable(*DstM, TypeMap.get(SGV->getType()->getElementType()),
- SGV->isConstant(), SGV->getLinkage(), /*init*/0,
- SGV->getName(), /*insertbefore*/0,
+ SGV->isConstant(), SGV->getLinkage(), /*init*/nullptr,
+ SGV->getName(), /*insertbefore*/nullptr,
SGV->getThreadLocalMode(),
SGV->getType()->getAddressSpace());
// Propagate alignment, visibility and section info.
// bring over SGA.
GlobalAlias *NewDA = new GlobalAlias(TypeMap.get(SGA->getType()),
SGA->getLinkage(), SGA->getName(),
- /*aliasee*/0, DstM);
+ /*aliasee*/nullptr, DstM);
copyGVAttributes(NewDA, SGA);
if (NewVisibility)
NewDA->setVisibility(*NewVisibility);
} else {
// Clone the body of the function into the dest function.
SmallVector<ReturnInst*, 8> Returns; // Ignore returns.
- CloneFunctionInto(Dst, Src, ValueMap, false, Returns, "", NULL,
+ CloneFunctionInto(Dst, Src, ValueMap, false, Returns, "", nullptr,
&TypeMap, &ValMaterializer);
}
void Linker::deleteModule() {
delete Composite;
- Composite = NULL;
+ Composite = nullptr;
}
bool Linker::linkInModule(Module *Src, unsigned Mode, std::string *ErrorMsg) {
LLVMLinkerMode Mode, char **OutMessages) {
std::string Messages;
LLVMBool Result = Linker::LinkModules(unwrap(Dest), unwrap(Src),
- Mode, OutMessages? &Messages : 0);
+ Mode, OutMessages? &Messages : nullptr);
if (OutMessages)
*OutMessages = strdup(Messages.c_str());
return Result;
// Check to see if this is past the end of the archive.
if (NextLoc >= Parent->Data->getBufferEnd())
- return Child(Parent, NULL);
+ return Child(Parent, nullptr);
return Child(Parent, NextLoc);
}
}
Archive::child_iterator Archive::child_end() const {
- return Child(this, NULL);
+ return Child(this, nullptr);
}
error_code Archive::Symbol::getName(StringRef &Result) const {
error_code COFFObjectFile::getSymbolAddress(DataRefImpl Ref,
uint64_t &Result) const {
const coff_symbol *Symb = toSymb(Ref);
- const coff_section *Section = NULL;
+ const coff_section *Section = nullptr;
if (error_code EC = getSection(Symb->SectionNumber, Section))
return EC;
} else {
uint32_t Characteristics = 0;
if (!COFF::isReservedSectionNumber(Symb->SectionNumber)) {
- const coff_section *Section = NULL;
+ const coff_section *Section = nullptr;
if (error_code EC = getSection(Symb->SectionNumber, Section))
return EC;
Characteristics = Section->Characteristics;
// in the same section as this symbol, and looking for either the next
// symbol, or the end of the section.
const coff_symbol *Symb = toSymb(Ref);
- const coff_section *Section = NULL;
+ const coff_section *Section = nullptr;
if (error_code EC = getSection(Symb->SectionNumber, Section))
return EC;
if (COFF::isReservedSectionNumber(Symb->SectionNumber)) {
Result = section_end();
} else {
- const coff_section *Sec = 0;
+ const coff_section *Sec = nullptr;
if (error_code EC = getSection(Symb->SectionNumber, Sec)) return EC;
DataRefImpl Ref;
Ref.p = reinterpret_cast<uintptr_t>(Sec);
bool &Result) const {
const coff_section *Sec = toSec(SecRef);
const coff_symbol *Symb = toSymb(SymbRef);
- const coff_section *SymbSec = 0;
+ const coff_section *SymbSec = nullptr;
if (error_code EC = getSection(Symb->SectionNumber, SymbSec)) return EC;
if (SymbSec == Sec)
Result = true;
COFFObjectFile::COFFObjectFile(MemoryBuffer *Object, error_code &EC,
bool BufferOwned)
- : ObjectFile(Binary::ID_COFF, Object, BufferOwned), COFFHeader(0),
- PE32Header(0), PE32PlusHeader(0), DataDirectory(0), SectionTable(0),
- SymbolTable(0), StringTable(0), StringTableSize(0), ImportDirectory(0),
- NumberOfImportDirectory(0), ExportDirectory(0) {
+ : ObjectFile(Binary::ID_COFF, Object, BufferOwned), COFFHeader(nullptr),
+ PE32Header(nullptr), PE32PlusHeader(nullptr), DataDirectory(nullptr),
+ SectionTable(nullptr), SymbolTable(nullptr), StringTable(nullptr),
+ StringTableSize(0), ImportDirectory(nullptr), NumberOfImportDirectory(0),
+ ExportDirectory(nullptr) {
// Check that we at least have enough room for a header.
if (!checkSize(Data, EC, sizeof(coff_file_header))) return;
}
export_directory_iterator COFFObjectFile::export_directory_end() const {
- if (ExportDirectory == 0)
- return export_directory_iterator(ExportDirectoryEntryRef(0, 0, this));
+ if (!ExportDirectory)
+ return export_directory_iterator(ExportDirectoryEntryRef(nullptr, 0, this));
ExportDirectoryEntryRef Ref(ExportDirectory,
ExportDirectory->AddressTableEntries, this);
return export_directory_iterator(Ref);
const coff_section *&Result) const {
// Check for special index values.
if (COFF::isReservedSectionNumber(Index))
- Result = NULL;
+ Result = nullptr;
else if (Index > 0 && Index <= COFFHeader->NumberOfSections)
// We already verified the section table data, so no need to check again.
Result = SectionTable + (Index - 1);
ArrayRef<uint8_t> COFFObjectFile::getSymbolAuxData(
const coff_symbol *Symbol) const {
- const uint8_t *Aux = NULL;
+ const uint8_t *Aux = nullptr;
if (Symbol->NumberOfAuxSymbols > 0) {
// AUX data comes immediately after the symbol in COFF
error_code COFFObjectFile::getRelocationValueString(DataRefImpl Rel,
SmallVectorImpl<char> &Result) const {
const coff_relocation *Reloc = toRel(Rel);
- const coff_symbol *Symb = 0;
+ const coff_symbol *Symb = nullptr;
if (error_code EC = getSymbol(Reloc->SymbolTableIndex, Symb)) return EC;
DataRefImpl Sym;
Sym.p = reinterpret_cast<uintptr_t>(Symb);
bool Is64bits, error_code &EC,
bool BufferOwned)
: ObjectFile(getMachOType(IsLittleEndian, Is64bits), Object, BufferOwned),
- SymtabLoadCmd(NULL), DysymtabLoadCmd(NULL), DataInCodeLoadCmd(NULL) {
+ SymtabLoadCmd(nullptr), DysymtabLoadCmd(nullptr),
+ DataInCodeLoadCmd(nullptr) {
uint32_t LoadCommandCount = this->getHeader().ncmds;
MachO::LoadCommandType SegmentLoadType = is64Bit() ?
MachO::LC_SEGMENT_64 : MachO::LC_SEGMENT;
MachOUniversalBinary::ObjectForArch::ObjectForArch(
const MachOUniversalBinary *Parent, uint32_t Index)
: Parent(Parent), Index(Index) {
- if (Parent == 0 || Index > Parent->getNumberOfObjects()) {
+ if (!Parent || Index > Parent->getNumberOfObjects()) {
clear();
} else {
// Parse object header.
// ObjectFile creation
LLVMObjectFileRef LLVMCreateObjectFile(LLVMMemoryBufferRef MemBuf) {
ErrorOr<ObjectFile*> ObjOrErr(ObjectFile::createObjectFile(unwrap(MemBuf)));
- ObjectFile *Obj = ObjOrErr ? ObjOrErr.get() : 0;
+ ObjectFile *Obj = ObjOrErr ? ObjOrErr.get() : nullptr;
return wrap(Obj);
}
for (const_reverse_iterator it = rbegin(), ie = rend(); it != ie; ++it)
if ((*it)->getOption().matches(Id))
return *it;
- return 0;
+ return nullptr;
}
Arg *ArgList::getLastArg(OptSpecifier Id) const {
- Arg *Res = 0;
+ Arg *Res = nullptr;
for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
if ((*it)->getOption().matches(Id)) {
Res = *it;
}
Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1) const {
- Arg *Res = 0;
+ Arg *Res = nullptr;
for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
if ((*it)->getOption().matches(Id0) ||
(*it)->getOption().matches(Id1)) {
Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
OptSpecifier Id2) const {
- Arg *Res = 0;
+ Arg *Res = nullptr;
for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
if ((*it)->getOption().matches(Id0) ||
(*it)->getOption().matches(Id1) ||
Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
OptSpecifier Id2, OptSpecifier Id3) const {
- Arg *Res = 0;
+ Arg *Res = nullptr;
for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
if ((*it)->getOption().matches(Id0) ||
(*it)->getOption().matches(Id1) ||
Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
OptSpecifier Id2, OptSpecifier Id3,
OptSpecifier Id4) const {
- Arg *Res = 0;
+ Arg *Res = nullptr;
for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
if ((*it)->getOption().matches(Id0) ||
(*it)->getOption().matches(Id1) ||
Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
OptSpecifier Id2, OptSpecifier Id3,
OptSpecifier Id4, OptSpecifier Id5) const {
- Arg *Res = 0;
+ Arg *Res = nullptr;
for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
if ((*it)->getOption().matches(Id0) ||
(*it)->getOption().matches(Id1) ||
OptSpecifier Id2, OptSpecifier Id3,
OptSpecifier Id4, OptSpecifier Id5,
OptSpecifier Id6) const {
- Arg *Res = 0;
+ Arg *Res = nullptr;
for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
if ((*it)->getOption().matches(Id0) ||
(*it)->getOption().matches(Id1) ||
OptSpecifier Id2, OptSpecifier Id3,
OptSpecifier Id4, OptSpecifier Id5,
OptSpecifier Id6, OptSpecifier Id7) const {
- Arg *Res = 0;
+ Arg *Res = nullptr;
for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
if ((*it)->getOption().matches(Id0) ||
(*it)->getOption().matches(Id1) ||
for (const char * const *APre = A.Prefixes,
* const *BPre = B.Prefixes;
- *APre != 0 && *BPre != 0; ++APre, ++BPre) {
+ *APre != nullptr && *BPre != nullptr; ++APre, ++BPre){
if (int N = StrCmpOptionName(*APre, *BPre))
return N < 0;
}
for (unsigned i = FirstSearchableIndex + 1, e = getNumOptions() + 1;
i != e; ++i) {
if (const char *const *P = getInfo(i).Prefixes) {
- for (; *P != 0; ++P) {
+ for (; *P != nullptr; ++P) {
PrefixesUnion.insert(*P);
}
}
const Option OptTable::getOption(OptSpecifier Opt) const {
unsigned id = Opt.getID();
if (id == 0)
- return Option(0, 0);
+ return Option(nullptr, nullptr);
assert((unsigned) (id - 1) < getNumOptions() && "Invalid ID.");
return Option(&getInfo(id), this);
}
/// \returns Matched size. 0 means no match.
static unsigned matchOption(const OptTable::Info *I, StringRef Str,
bool IgnoreCase) {
- for (const char * const *Pre = I->Prefixes; *Pre != 0; ++Pre) {
+ for (const char * const *Pre = I->Prefixes; *Pre != nullptr; ++Pre) {
StringRef Prefix(*Pre);
if (Str.startswith(Prefix)) {
StringRef Rest = Str.substr(Prefix.size());
// Otherwise, see if this argument was missing values.
if (Prev != Index)
- return 0;
+ return nullptr;
}
// If we failed to find an option and this arg started with /, then it's
if (Info->Prefixes) {
llvm::errs() << " Prefixes:[";
- for (const char * const *Pre = Info->Prefixes; *Pre != 0; ++Pre) {
- llvm::errs() << '"' << *Pre << (*(Pre + 1) == 0 ? "\"" : "\", ");
+ for (const char * const *Pre = Info->Prefixes; *Pre != nullptr; ++Pre) {
+ llvm::errs() << '"' << *Pre << (*(Pre + 1) == nullptr ? "\"" : "\", ");
}
llvm::errs() << ']';
}
switch (getKind()) {
case FlagClass: {
if (ArgSize != strlen(Args.getArgString(Index)))
- return 0;
+ return nullptr;
Arg *A = new Arg(UnaliasedOption, Spelling, Index++);
if (getAliasArgs()) {
// Matches iff this is an exact match.
// FIXME: Avoid strlen.
if (ArgSize != strlen(Args.getArgString(Index)))
- return 0;
+ return nullptr;
Index += 2;
if (Index > Args.getNumInputArgStrings())
- return 0;
+ return nullptr;
return new Arg(UnaliasedOption, Spelling,
Index - 2, Args.getArgString(Index - 1));
// Matches iff this is an exact match.
// FIXME: Avoid strlen.
if (ArgSize != strlen(Args.getArgString(Index)))
- return 0;
+ return nullptr;
Index += 1 + getNumArgs();
if (Index > Args.getNumInputArgStrings())
- return 0;
+ return nullptr;
Arg *A = new Arg(UnaliasedOption, Spelling, Index - 1 - getNumArgs(),
Args.getArgString(Index - getNumArgs()));
// Otherwise it must be separate.
Index += 2;
if (Index > Args.getNumInputArgStrings())
- return 0;
+ return nullptr;
return new Arg(UnaliasedOption, Spelling,
Index - 2, Args.getArgString(Index - 1));
// Always matches.
Index += 2;
if (Index > Args.getNumInputArgStrings())
- return 0;
+ return nullptr;
return new Arg(UnaliasedOption, Spelling, Index - 2,
Args.getArgString(Index - 2) + ArgSize,
// Matches iff this is an exact match.
// FIXME: Avoid strlen.
if (ArgSize != strlen(Args.getArgString(Index)))
- return 0;
+ return nullptr;
Arg *A = new Arg(UnaliasedOption, Spelling, Index++);
while (Index < Args.getNumInputArgStrings())
A->getValues().push_back(Args.getArgString(Index++));
{
switch (PackCategoriesIntoKey(category, rhs.category)) {
default:
- llvm_unreachable(0);
+ llvm_unreachable(nullptr);
case PackCategoriesIntoKey(fcNaN, fcZero):
case PackCategoriesIntoKey(fcNaN, fcNormal):
{
switch (PackCategoriesIntoKey(category, rhs.category)) {
default:
- llvm_unreachable(0);
+ llvm_unreachable(nullptr);
case PackCategoriesIntoKey(fcNaN, fcZero):
case PackCategoriesIntoKey(fcNaN, fcNormal):
{
switch (PackCategoriesIntoKey(category, rhs.category)) {
default:
- llvm_unreachable(0);
+ llvm_unreachable(nullptr);
case PackCategoriesIntoKey(fcZero, fcNaN):
case PackCategoriesIntoKey(fcNormal, fcNaN):
{
switch (PackCategoriesIntoKey(category, rhs.category)) {
default:
- llvm_unreachable(0);
+ llvm_unreachable(nullptr);
case PackCategoriesIntoKey(fcNaN, fcZero):
case PackCategoriesIntoKey(fcNaN, fcNormal):
switch (PackCategoriesIntoKey(category, rhs.category)) {
default:
- llvm_unreachable(0);
+ llvm_unreachable(nullptr);
case PackCategoriesIntoKey(fcNaN, fcZero):
case PackCategoriesIntoKey(fcNaN, fcNormal):
if (Sem == &PPCDoubleDouble)
return initFromPPCDoubleDoubleAPInt(api);
- llvm_unreachable(0);
+ llvm_unreachable(nullptr);
}
APFloat
static Option *RegisteredOptionList = nullptr;
void Option::addArgument() {
- assert(NextRegistered == 0 && "argument multiply registered!");
+ assert(!NextRegistered && "argument multiply registered!");
NextRegistered = RegisteredOptionList;
RegisteredOptionList = this;
}
void Option::removeArgument() {
- assert(NextRegistered != 0 && "argument never registered");
+ assert(NextRegistered && "argument never registered");
assert(RegisteredOptionList == this && "argument is not the last registered");
RegisteredOptionList = NextRegistered;
MarkOptionsChanged();
if (EnableDebugBuffering && DebugFlag && DebugBufferSize != 0)
// TODO: Add a handler for SIGUSER1-type signals so the user can
// force a debug dump.
- sys::AddSignalHandler(&debug_user_sig_handler, 0);
+ sys::AddSignalHandler(&debug_user_sig_handler, nullptr);
// Otherwise we've already set the debug stream buffer size to
// zero, disabling buffering so it will output directly to errs().
}
/// is not already in the map. InsertPos must be obtained from
/// FindNodeOrInsertPos.
void FoldingSetImpl::InsertNode(Node *N, void *InsertPos) {
- assert(N->getNextInBucket() == 0);
+ assert(!N->getNextInBucket());
// Do we need to grow the hashtable?
if (NumNodes+1 > NumBuckets*2) {
GrowHashTable();
llvm_release_global_lock();
} else {
- assert(Ptr == 0 && DeleterFn == 0 && Next == 0 &&
+ assert(!Ptr && !DeleterFn && !Next &&
"Partially initialized ManagedStatic!?");
Ptr = Creator ? Creator() : nullptr;
DeleterFn = Deleter;
MutexImpl::~MutexImpl()
{
pthread_mutex_t* mutex = static_cast<pthread_mutex_t*>(data_);
- assert(mutex != 0);
+ assert(mutex != nullptr);
pthread_mutex_destroy(mutex);
free(mutex);
}
MutexImpl::acquire()
{
pthread_mutex_t* mutex = static_cast<pthread_mutex_t*>(data_);
- assert(mutex != 0);
+ assert(mutex != nullptr);
int errorcode = pthread_mutex_lock(mutex);
return errorcode == 0;
MutexImpl::release()
{
pthread_mutex_t* mutex = static_cast<pthread_mutex_t*>(data_);
- assert(mutex != 0);
+ assert(mutex != nullptr);
int errorcode = pthread_mutex_unlock(mutex);
return errorcode == 0;
MutexImpl::tryacquire()
{
pthread_mutex_t* mutex = static_cast<pthread_mutex_t*>(data_);
- assert(mutex != 0);
+ assert(mutex != nullptr);
int errorcode = pthread_mutex_trylock(mutex);
return errorcode == 0;
RWMutexImpl::~RWMutexImpl()
{
pthread_rwlock_t* rwlock = static_cast<pthread_rwlock_t*>(data_);
- assert(rwlock != 0);
+ assert(rwlock != nullptr);
pthread_rwlock_destroy(rwlock);
free(rwlock);
}
RWMutexImpl::reader_acquire()
{
pthread_rwlock_t* rwlock = static_cast<pthread_rwlock_t*>(data_);
- assert(rwlock != 0);
+ assert(rwlock != nullptr);
int errorcode = pthread_rwlock_rdlock(rwlock);
return errorcode == 0;
RWMutexImpl::reader_release()
{
pthread_rwlock_t* rwlock = static_cast<pthread_rwlock_t*>(data_);
- assert(rwlock != 0);
+ assert(rwlock != nullptr);
int errorcode = pthread_rwlock_unlock(rwlock);
return errorcode == 0;
RWMutexImpl::writer_acquire()
{
pthread_rwlock_t* rwlock = static_cast<pthread_rwlock_t*>(data_);
- assert(rwlock != 0);
+ assert(rwlock != nullptr);
int errorcode = pthread_rwlock_wrlock(rwlock);
return errorcode == 0;
RWMutexImpl::writer_release()
{
pthread_rwlock_t* rwlock = static_cast<pthread_rwlock_t*>(data_);
- assert(rwlock != 0);
+ assert(rwlock != nullptr);
int errorcode = pthread_rwlock_unlock(rwlock);
return errorcode == 0;
//===----------------------------------------------------------------------===//
void Timer::init(StringRef N) {
- assert(TG == 0 && "Timer already initialized");
+ assert(!TG && "Timer already initialized");
Name.assign(N.begin(), N.end());
Started = false;
TG = getDefaultTimerGroup();
}
void Timer::init(StringRef N, TimerGroup &tg) {
- assert(TG == 0 && "Timer already initialized");
+ assert(!TG && "Timer already initialized");
Name.assign(N.begin(), N.end());
Started = false;
TG = &tg;
void raw_ostream::SetBufferAndMode(char *BufferStart, size_t Size,
BufferKind Mode) {
- assert(((Mode == Unbuffered && BufferStart == 0 && Size == 0) ||
- (Mode != Unbuffered && BufferStart && Size)) &&
+ assert(((Mode == Unbuffered && !BufferStart && Size == 0) ||
+ (Mode != Unbuffered && BufferStart && Size != 0)) &&
"stream must be unbuffered or have at least one byte");
// Make sure the current buffer is free of content (we can't flush here; the
// child buffer management logic will be in write_impl).
raw_fd_ostream::raw_fd_ostream(const char *Filename, std::string &ErrorInfo,
sys::fs::OpenFlags Flags)
: Error(false), UseAtomicWrites(false), pos(0) {
- assert(Filename != 0 && "Filename is null");
+ assert(Filename && "Filename is null");
ErrorInfo.clear();
// Handle "-" as stdout. Note that when we do this, we consider ourself