[C++11] More 'nullptr' conversion. In some cases just using a boolean check instead of comparing to nullptr.

llvm-svn: 206252
This commit is contained in:
Craig Topper 2014-04-15 06:32:26 +00:00
parent d82d4cc356
commit 2617dccea2
73 changed files with 461 additions and 456 deletions

View File

@ -111,7 +111,7 @@ public:
i != e; ++i) i != e; ++i)
if (BlockInfoRecords[i].BlockID == BlockID) if (BlockInfoRecords[i].BlockID == BlockID)
return &BlockInfoRecords[i]; return &BlockInfoRecords[i];
return 0; return nullptr;
} }
BlockInfo &getOrCreateBlockInfo(unsigned BlockID) { BlockInfo &getOrCreateBlockInfo(unsigned BlockID) {
@ -200,9 +200,9 @@ class BitstreamCursor {
public: public:
BitstreamCursor() : BitStream(0), NextChar(0) { BitstreamCursor() : BitStream(nullptr), NextChar(0) {}
} BitstreamCursor(const BitstreamCursor &RHS)
BitstreamCursor(const BitstreamCursor &RHS) : BitStream(0), NextChar(0) { : BitStream(nullptr), NextChar(0) {
operator=(RHS); operator=(RHS);
} }
@ -490,7 +490,7 @@ public:
/// EnterSubBlock - Having read the ENTER_SUBBLOCK abbrevid, enter /// EnterSubBlock - Having read the ENTER_SUBBLOCK abbrevid, enter
/// the block, and return true if the block has an error. /// 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() { bool ReadBlockEnd() {
if (BlockScope.empty()) return true; if (BlockScope.empty()) return true;
@ -541,7 +541,7 @@ public:
void skipRecord(unsigned AbbrevID); void skipRecord(unsigned AbbrevID);
unsigned readRecord(unsigned AbbrevID, SmallVectorImpl<uint64_t> &Vals, unsigned readRecord(unsigned AbbrevID, SmallVectorImpl<uint64_t> &Vals,
StringRef *Blob = 0); StringRef *Blob = nullptr);
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
// Abbrev Processing // Abbrev Processing

View File

@ -204,7 +204,7 @@ public:
i != e; ++i) i != e; ++i)
if (BlockInfoRecords[i].BlockID == BlockID) if (BlockInfoRecords[i].BlockID == BlockID)
return &BlockInfoRecords[i]; return &BlockInfoRecords[i];
return 0; return nullptr;
} }
void EnterSubblock(unsigned BlockID, unsigned CodeLen) { void EnterSubblock(unsigned BlockID, unsigned CodeLen) {
@ -347,7 +347,7 @@ private:
EmitAbbreviatedField(EltEnc, (unsigned char)BlobData[i]); EmitAbbreviatedField(EltEnc, (unsigned char)BlobData[i]);
// Know that blob data is consumed for assertion below. // Know that blob data is consumed for assertion below.
BlobData = 0; BlobData = nullptr;
} else { } else {
// Emit a vbr6 to indicate the number of elements present. // Emit a vbr6 to indicate the number of elements present.
EmitVBR(static_cast<uint32_t>(Vals.size()-RecordIdx), 6); EmitVBR(static_cast<uint32_t>(Vals.size()-RecordIdx), 6);
@ -378,7 +378,7 @@ private:
WriteByte((unsigned char)BlobData[i]); WriteByte((unsigned char)BlobData[i]);
// Know that blob data is consumed for assertion below. // Know that blob data is consumed for assertion below.
BlobData = 0; BlobData = nullptr;
} else { } else {
for (unsigned e = Vals.size(); RecordIdx != e; ++RecordIdx) { for (unsigned e = Vals.size(); RecordIdx != e; ++RecordIdx) {
assert(isUInt<8>(Vals[RecordIdx]) && assert(isUInt<8>(Vals[RecordIdx]) &&
@ -397,7 +397,7 @@ private:
} }
} }
assert(RecordIdx == Vals.size() && "Not all record operands emitted!"); 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!"); "Blob data specified for record that doesn't use it!");
} }

View File

@ -153,11 +153,11 @@ public:
/// register is a PHI destination and the PHI's LiveOutInfo is not valid. /// register is a PHI destination and the PHI's LiveOutInfo is not valid.
const LiveOutInfo *GetLiveOutRegInfo(unsigned Reg) { const LiveOutInfo *GetLiveOutRegInfo(unsigned Reg) {
if (!LiveOutRegInfo.inBounds(Reg)) if (!LiveOutRegInfo.inBounds(Reg))
return NULL; return nullptr;
const LiveOutInfo *LOI = &LiveOutRegInfo[Reg]; const LiveOutInfo *LOI = &LiveOutRegInfo[Reg];
if (!LOI->IsValid) if (!LOI->IsValid)
return NULL; return nullptr;
return LOI; return LOI;
} }

View File

@ -92,7 +92,7 @@ namespace llvm {
void updateNode(const SUnit *SU) override {} void updateNode(const SUnit *SU) override {}
void releaseState() override { void releaseState() override {
SUnits = 0; SUnits = nullptr;
} }
unsigned getLatency(unsigned NodeNum) const { unsigned getLatency(unsigned NodeNum) const {

View File

@ -578,7 +578,7 @@ public:
Ops.push_back(Op2); Ops.push_back(Op2);
Ops.push_back(InGlue); Ops.push_back(InGlue);
return getNode(ISD::CALLSEQ_END, DL, NodeTys, &Ops[0], 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. /// getUNDEF - Return an UNDEF node. UNDEF does not have a useful SDLoc.
@ -766,14 +766,15 @@ public:
SDValue getLoad(EVT VT, SDLoc dl, SDValue Chain, SDValue Ptr, SDValue getLoad(EVT VT, SDLoc dl, SDValue Chain, SDValue Ptr,
MachinePointerInfo PtrInfo, bool isVolatile, MachinePointerInfo PtrInfo, bool isVolatile,
bool isNonTemporal, bool isInvariant, unsigned Alignment, 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, SDValue getLoad(EVT VT, SDLoc dl, SDValue Chain, SDValue Ptr,
MachineMemOperand *MMO); MachineMemOperand *MMO);
SDValue getExtLoad(ISD::LoadExtType ExtType, SDLoc dl, EVT VT, SDValue getExtLoad(ISD::LoadExtType ExtType, SDLoc dl, EVT VT,
SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo,
EVT MemVT, bool isVolatile, EVT MemVT, bool isVolatile,
bool isNonTemporal, unsigned Alignment, bool isNonTemporal, unsigned Alignment,
const MDNode *TBAAInfo = 0); const MDNode *TBAAInfo = nullptr);
SDValue getExtLoad(ISD::LoadExtType ExtType, SDLoc dl, EVT VT, SDValue getExtLoad(ISD::LoadExtType ExtType, SDLoc dl, EVT VT,
SDValue Chain, SDValue Ptr, EVT MemVT, SDValue Chain, SDValue Ptr, EVT MemVT,
MachineMemOperand *MMO); MachineMemOperand *MMO);
@ -784,8 +785,8 @@ public:
SDValue Chain, SDValue Ptr, SDValue Offset, SDValue Chain, SDValue Ptr, SDValue Offset,
MachinePointerInfo PtrInfo, EVT MemVT, MachinePointerInfo PtrInfo, EVT MemVT,
bool isVolatile, bool isNonTemporal, bool isInvariant, bool isVolatile, bool isNonTemporal, bool isInvariant,
unsigned Alignment, const MDNode *TBAAInfo = 0, unsigned Alignment, const MDNode *TBAAInfo = nullptr,
const MDNode *Ranges = 0); const MDNode *Ranges = nullptr);
SDValue getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, SDValue getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType,
EVT VT, SDLoc dl, EVT VT, SDLoc dl,
SDValue Chain, SDValue Ptr, SDValue Offset, SDValue Chain, SDValue Ptr, SDValue Offset,
@ -796,14 +797,14 @@ public:
SDValue getStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr, SDValue getStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr,
MachinePointerInfo PtrInfo, bool isVolatile, MachinePointerInfo PtrInfo, bool isVolatile,
bool isNonTemporal, unsigned Alignment, bool isNonTemporal, unsigned Alignment,
const MDNode *TBAAInfo = 0); const MDNode *TBAAInfo = nullptr);
SDValue getStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr, SDValue getStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr,
MachineMemOperand *MMO); MachineMemOperand *MMO);
SDValue getTruncStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr, SDValue getTruncStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr,
MachinePointerInfo PtrInfo, EVT TVT, MachinePointerInfo PtrInfo, EVT TVT,
bool isNonTemporal, bool isVolatile, bool isNonTemporal, bool isVolatile,
unsigned Alignment, unsigned Alignment,
const MDNode *TBAAInfo = 0); const MDNode *TBAAInfo = nullptr);
SDValue getTruncStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr, SDValue getTruncStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr,
EVT TVT, MachineMemOperand *MMO); EVT TVT, MachineMemOperand *MMO);
SDValue getIndexedStore(SDValue OrigStoe, SDLoc dl, SDValue Base, SDValue getIndexedStore(SDValue OrigStoe, SDLoc dl, SDValue Base,

View File

@ -36,7 +36,7 @@ public:
private: private:
struct ValueType { struct ValueType {
ValueType() : data(NULL) { ValueType() : data(nullptr) {
uval = 0; uval = 0;
} }
@ -60,7 +60,7 @@ public:
bool extractValue(DataExtractor data, uint32_t *offset_ptr, bool extractValue(DataExtractor data, uint32_t *offset_ptr,
const DWARFUnit *u); const DWARFUnit *u);
bool isInlinedCStr() const { 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 /// getAsFoo functions below return the extracted value as Foo if only

View File

@ -181,7 +181,7 @@ public:
/// freeMachineCodeForFunction works. /// freeMachineCodeForFunction works.
static ExecutionEngine *create(Module *M, static ExecutionEngine *create(Module *M,
bool ForceInterpreter = false, bool ForceInterpreter = false,
std::string *ErrorStr = 0, std::string *ErrorStr = nullptr,
CodeGenOpt::Level OptLevel = CodeGenOpt::Level OptLevel =
CodeGenOpt::Default, CodeGenOpt::Default,
bool GVsWithCode = true); bool GVsWithCode = true);
@ -193,8 +193,8 @@ public:
/// Clients should make sure to initialize targets prior to calling this /// Clients should make sure to initialize targets prior to calling this
/// function. /// function.
static ExecutionEngine *createJIT(Module *M, static ExecutionEngine *createJIT(Module *M,
std::string *ErrorStr = 0, std::string *ErrorStr = nullptr,
JITMemoryManager *JMM = 0, JITMemoryManager *JMM = nullptr,
CodeGenOpt::Level OptLevel = CodeGenOpt::Level OptLevel =
CodeGenOpt::Default, CodeGenOpt::Default,
bool GVsWithCode = true, bool GVsWithCode = true,
@ -411,7 +411,7 @@ public:
} }
// The JIT overrides a version that actually does this. // 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 /// getGlobalValueAtAddress - Return the LLVM global value object that starts
/// at the specified address. /// at the specified address.
@ -478,7 +478,7 @@ public:
} }
/// Return the target machine (if available). /// 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 /// DisableLazyCompilation - When lazy compilation is off (the default), the
/// JIT will eagerly compile every function reachable from the argument to /// JIT will eagerly compile every function reachable from the argument to
@ -576,10 +576,10 @@ private:
/// InitEngine - Does the common initialization of default options. /// InitEngine - Does the common initialization of default options.
void InitEngine() { void InitEngine() {
WhichEngine = EngineKind::Either; WhichEngine = EngineKind::Either;
ErrorStr = NULL; ErrorStr = nullptr;
OptLevel = CodeGenOpt::Default; OptLevel = CodeGenOpt::Default;
MCJMM = NULL; MCJMM = nullptr;
JMM = NULL; JMM = nullptr;
Options = TargetOptions(); Options = TargetOptions();
AllocateGVsWithCode = false; AllocateGVsWithCode = false;
RelocModel = Reloc::Default; RelocModel = Reloc::Default;
@ -610,7 +610,7 @@ public:
/// the setJITMemoryManager() option. /// the setJITMemoryManager() option.
EngineBuilder &setMCJITMemoryManager(RTDyldMemoryManager *mcjmm) { EngineBuilder &setMCJITMemoryManager(RTDyldMemoryManager *mcjmm) {
MCJMM = mcjmm; MCJMM = mcjmm;
JMM = NULL; JMM = nullptr;
return *this; return *this;
} }
@ -622,7 +622,7 @@ public:
/// memory manager. This option defaults to NULL. This option overrides /// memory manager. This option defaults to NULL. This option overrides
/// setMCJITMemoryManager() as well. /// setMCJITMemoryManager() as well.
EngineBuilder &setJITMemoryManager(JITMemoryManager *jmm) { EngineBuilder &setJITMemoryManager(JITMemoryManager *jmm) {
MCJMM = NULL; MCJMM = nullptr;
JMM = jmm; JMM = jmm;
return *this; return *this;
} }

View File

@ -114,7 +114,7 @@ public:
/// operations needed to reliably use the memory are also performed. /// operations needed to reliably use the memory are also performed.
/// ///
/// Returns true if an error occurred, false otherwise. /// 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). // Create wrappers for C Binding types (see CBindingWrapping.h).

View File

@ -73,7 +73,7 @@ public:
if (findOption(P->getPassArgument()) != getNumOptions()) { if (findOption(P->getPassArgument()) != getNumOptions()) {
errs() << "Two passes with the same argument (-" errs() << "Two passes with the same argument (-"
<< P->getPassArgument() << ") attempted to be registered!\n"; << P->getPassArgument() << ") attempted to be registered!\n";
llvm_unreachable(0); llvm_unreachable(nullptr);
} }
addLiteralOption(P->getPassArgument(), P, P->getPassName()); addLiteralOption(P->getPassArgument(), P, P->getPassName());
} }

View File

@ -129,7 +129,7 @@ public:
const char *getSymbolName(uint32_t index) { const char *getSymbolName(uint32_t index) {
if (index < _symbols.size()) if (index < _symbols.size())
return _symbols[index].name; return _symbols[index].name;
return NULL; return nullptr;
} }
/// getDependentLibraryCount - Get the number of dependent libraries /// getDependentLibraryCount - Get the number of dependent libraries
@ -141,7 +141,7 @@ public:
const char *getDependentLibrary(uint32_t index) { const char *getDependentLibrary(uint32_t index) {
if (index < _deplibs.size()) if (index < _deplibs.size())
return _deplibs[index]; return _deplibs[index];
return NULL; return nullptr;
} }
/// getLinkerOptCount - Get the number of linker options /// getLinkerOptCount - Get the number of linker options
@ -153,7 +153,7 @@ public:
const char *getLinkerOpt(uint32_t index) { const char *getLinkerOpt(uint32_t index) {
if (index < _linkeropts.size()) if (index < _linkeropts.size())
return _linkeropts[index]; return _linkeropts[index];
return NULL; return nullptr;
} }
/// getLLVVMModule - Return the Module. /// getLLVVMModule - Return the Module.

View File

@ -42,7 +42,7 @@ public:
AsmLexer(const MCAsmInfo &MAI); AsmLexer(const MCAsmInfo &MAI);
~AsmLexer(); ~AsmLexer();
void setBuffer(const MemoryBuffer *buf, const char *ptr = NULL); void setBuffer(const MemoryBuffer *buf, const char *ptr = nullptr);
StringRef LexUntilEndOfStatement() override; StringRef LexUntilEndOfStatement() override;
StringRef LexUntilEndOfLine(); StringRef LexUntilEndOfLine();

View File

@ -39,7 +39,7 @@ public:
unsigned Length, Size, Type; unsigned Length, Size, Type;
void clear() { void clear() {
OpDecl = 0; OpDecl = nullptr;
IsVarDecl = false; IsVarDecl = false;
Length = 1; Length = 1;
Size = 0; Size = 0;

View File

@ -63,7 +63,7 @@ struct ParseInstructionInfo {
SmallVectorImpl<AsmRewrite> *AsmRewrites; SmallVectorImpl<AsmRewrite> *AsmRewrites;
ParseInstructionInfo() : AsmRewrites(0) {} ParseInstructionInfo() : AsmRewrites(nullptr) {}
ParseInstructionInfo(SmallVectorImpl<AsmRewrite> *rewrites) ParseInstructionInfo(SmallVectorImpl<AsmRewrite> *rewrites)
: AsmRewrites(rewrites) {} : AsmRewrites(rewrites) {}
@ -179,7 +179,7 @@ public:
virtual const MCExpr *applyModifierToExpr(const MCExpr *E, virtual const MCExpr *applyModifierToExpr(const MCExpr *E,
MCSymbolRefExpr::VariantKind, MCSymbolRefExpr::VariantKind,
MCContext &Ctx) { MCContext &Ctx) {
return 0; return nullptr;
} }
virtual void onLabelParsed(MCSymbol *Symbol) { }; virtual void onLabelParsed(MCSymbol *Symbol) { };

View File

@ -95,15 +95,15 @@ public:
bool FullPath = false) const; bool FullPath = false) const;
error_code getAsBinary(OwningPtr<Binary> &Result, error_code getAsBinary(OwningPtr<Binary> &Result,
LLVMContext *Context = 0) const; LLVMContext *Context = nullptr) const;
error_code getAsBinary(std::unique_ptr<Binary> &Result, error_code getAsBinary(std::unique_ptr<Binary> &Result,
LLVMContext *Context = 0) const; LLVMContext *Context = nullptr) const;
}; };
class child_iterator { class child_iterator {
Child child; Child child;
public: public:
child_iterator() : child(Child(0, 0)) {} child_iterator() : child(Child(nullptr, nullptr)) {}
child_iterator(const Child &c) : child(c) {} child_iterator(const Child &c) : child(c) {}
const Child* operator->() const { const Child* operator->() const {
return &child; return &child;

View File

@ -464,7 +464,7 @@ public:
// The iterator for the import directory table. // The iterator for the import directory table.
class ImportDirectoryEntryRef { class ImportDirectoryEntryRef {
public: public:
ImportDirectoryEntryRef() : OwningObject(0) {} ImportDirectoryEntryRef() : OwningObject(nullptr) {}
ImportDirectoryEntryRef(const import_directory_table_entry *Table, uint32_t I, ImportDirectoryEntryRef(const import_directory_table_entry *Table, uint32_t I,
const COFFObjectFile *Owner) const COFFObjectFile *Owner)
: ImportTable(Table), Index(I), OwningObject(Owner) {} : ImportTable(Table), Index(I), OwningObject(Owner) {}
@ -488,7 +488,7 @@ private:
// The iterator for the export directory table entry. // The iterator for the export directory table entry.
class ExportDirectoryEntryRef { class ExportDirectoryEntryRef {
public: public:
ExportDirectoryEntryRef() : OwningObject(0) {} ExportDirectoryEntryRef() : OwningObject(nullptr) {}
ExportDirectoryEntryRef(const export_directory_table_entry *Table, uint32_t I, ExportDirectoryEntryRef(const export_directory_table_entry *Table, uint32_t I,
const COFFObjectFile *Owner) const COFFObjectFile *Owner)
: ExportTable(Table), Index(I), OwningObject(Owner) {} : ExportTable(Table), Index(I), OwningObject(Owner) {}

View File

@ -604,14 +604,14 @@ typename ELFFile<ELFT>::uintX_t ELFFile<ELFT>::getStringTableIndex() const {
template <class ELFT> template <class ELFT>
ELFFile<ELFT>::ELFFile(MemoryBuffer *Object, error_code &ec) ELFFile<ELFT>::ELFFile(MemoryBuffer *Object, error_code &ec)
: Buf(Object), : Buf(Object),
SectionHeaderTable(0), SectionHeaderTable(nullptr),
dot_shstrtab_sec(0), dot_shstrtab_sec(nullptr),
dot_strtab_sec(0), dot_strtab_sec(nullptr),
dot_symtab_sec(0), dot_symtab_sec(nullptr),
SymbolTableSectionHeaderIndex(0), SymbolTableSectionHeaderIndex(nullptr),
dot_gnu_version_sec(0), dot_gnu_version_sec(nullptr),
dot_gnu_version_r_sec(0), dot_gnu_version_r_sec(nullptr),
dot_gnu_version_d_sec(0), dot_gnu_version_d_sec(nullptr),
dt_soname(nullptr) { dt_soname(nullptr) {
const uint64_t FileSize = Buf->getBufferSize(); const uint64_t FileSize = Buf->getBufferSize();
@ -679,19 +679,19 @@ ELFFile<ELFT>::ELFFile(MemoryBuffer *Object, error_code &ec)
DynamicRegion.EntSize = SecI->sh_entsize; DynamicRegion.EntSize = SecI->sh_entsize;
break; break;
case ELF::SHT_GNU_versym: case ELF::SHT_GNU_versym:
if (dot_gnu_version_sec != NULL) if (dot_gnu_version_sec != nullptr)
// FIXME: Proper error handling. // FIXME: Proper error handling.
report_fatal_error("More than one .gnu.version section!"); report_fatal_error("More than one .gnu.version section!");
dot_gnu_version_sec = &*SecI; dot_gnu_version_sec = &*SecI;
break; break;
case ELF::SHT_GNU_verdef: case ELF::SHT_GNU_verdef:
if (dot_gnu_version_d_sec != NULL) if (dot_gnu_version_d_sec != nullptr)
// FIXME: Proper error handling. // FIXME: Proper error handling.
report_fatal_error("More than one .gnu.version_d section!"); report_fatal_error("More than one .gnu.version_d section!");
dot_gnu_version_d_sec = &*SecI; dot_gnu_version_d_sec = &*SecI;
break; break;
case ELF::SHT_GNU_verneed: case ELF::SHT_GNU_verneed:
if (dot_gnu_version_r_sec != NULL) if (dot_gnu_version_r_sec != nullptr)
// FIXME: Proper error handling. // FIXME: Proper error handling.
report_fatal_error("More than one .gnu.version_r section!"); report_fatal_error("More than one .gnu.version_r section!");
dot_gnu_version_r_sec = &*SecI; dot_gnu_version_r_sec = &*SecI;
@ -769,7 +769,7 @@ typename ELFFile<ELFT>::Elf_Sym_Iter ELFFile<ELFT>::begin_symbols() const {
template <class ELFT> template <class ELFT>
typename ELFFile<ELFT>::Elf_Sym_Iter ELFFile<ELFT>::end_symbols() const { typename ELFFile<ELFT>::Elf_Sym_Iter ELFFile<ELFT>::end_symbols() const {
if (!dot_symtab_sec) 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, return Elf_Sym_Iter(dot_symtab_sec->sh_entsize,
(const char *)base() + dot_symtab_sec->sh_offset + (const char *)base() + dot_symtab_sec->sh_offset +
dot_symtab_sec->sh_size, dot_symtab_sec->sh_size,
@ -782,14 +782,14 @@ ELFFile<ELFT>::begin_dynamic_table() const {
if (DynamicRegion.Addr) if (DynamicRegion.Addr)
return Elf_Dyn_Iter(DynamicRegion.EntSize, return Elf_Dyn_Iter(DynamicRegion.EntSize,
(const char *)DynamicRegion.Addr); (const char *)DynamicRegion.Addr);
return Elf_Dyn_Iter(0, 0); return Elf_Dyn_Iter(0, nullptr);
} }
template <class ELFT> template <class ELFT>
typename ELFFile<ELFT>::Elf_Dyn_Iter typename ELFFile<ELFT>::Elf_Dyn_Iter
ELFFile<ELFT>::end_dynamic_table(bool NULLEnd) const { ELFFile<ELFT>::end_dynamic_table(bool NULLEnd) const {
if (!DynamicRegion.Addr) if (!DynamicRegion.Addr)
return Elf_Dyn_Iter(0, 0); return Elf_Dyn_Iter(0, nullptr);
Elf_Dyn_Iter Ret(DynamicRegion.EntSize, Elf_Dyn_Iter Ret(DynamicRegion.EntSize,
(const char *)DynamicRegion.Addr + DynamicRegion.Size); (const char *)DynamicRegion.Addr + DynamicRegion.Size);

View File

@ -41,7 +41,7 @@ public:
ObjectForArch(const MachOUniversalBinary *Parent, uint32_t Index); ObjectForArch(const MachOUniversalBinary *Parent, uint32_t Index);
void clear() { void clear() {
Parent = 0; Parent = nullptr;
Index = 0; Index = 0;
} }
@ -83,7 +83,7 @@ public:
return ObjectForArch(this, 0); return ObjectForArch(this, 0);
} }
object_iterator end_objects() const { object_iterator end_objects() const {
return ObjectForArch(0, 0); return ObjectForArch(nullptr, 0);
} }
uint32_t getNumberOfObjects() const { return NumberOfObjects; } uint32_t getNumberOfObjects() const { return NumberOfObjects; }

View File

@ -63,11 +63,11 @@ private:
public: public:
Arg(const Option Opt, StringRef Spelling, unsigned Index, Arg(const Option Opt, StringRef Spelling, unsigned Index,
const Arg *BaseArg = 0); const Arg *BaseArg = nullptr);
Arg(const Option Opt, StringRef Spelling, unsigned Index, 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, 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(); ~Arg();
const Option getOption() const { return Opt; } const Option getOption() const { return Opt; }

View File

@ -160,16 +160,16 @@ public:
/// ///
/// \p Claim Whether the argument should be claimed, if it exists. /// \p Claim Whether the argument should be claimed, if it exists.
bool hasArgNoClaim(OptSpecifier Id) const { bool hasArgNoClaim(OptSpecifier Id) const {
return getLastArgNoClaim(Id) != 0; return getLastArgNoClaim(Id) != nullptr;
} }
bool hasArg(OptSpecifier Id) const { bool hasArg(OptSpecifier Id) const {
return getLastArg(Id) != 0; return getLastArg(Id) != nullptr;
} }
bool hasArg(OptSpecifier Id0, OptSpecifier Id1) const { 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 { 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. /// getLastArg - Return the last argument matching \p Id, or null.

View File

@ -73,7 +73,7 @@ public:
~Option(); ~Option();
bool isValid() const { bool isValid() const {
return Info != 0; return Info != nullptr;
} }
unsigned getID() const { unsigned getID() const {

View File

@ -194,7 +194,7 @@ struct has_ScalarBitSetTraits
static double test(...); static double test(...);
public: public:
static bool const value = (sizeof(test<ScalarBitSetTraits<T> >(0)) == 1); static bool const value = (sizeof(test<ScalarBitSetTraits<T> >(nullptr)) == 1);
}; };
@ -778,7 +778,7 @@ struct ScalarTraits<double> {
template <typename TNorm, typename TFinal> template <typename TNorm, typename TFinal>
struct MappingNormalization { struct MappingNormalization {
MappingNormalization(IO &i_o, TFinal &Obj) MappingNormalization(IO &i_o, TFinal &Obj)
: io(i_o), BufPtr(NULL), Result(Obj) { : io(i_o), BufPtr(nullptr), Result(Obj) {
if ( io.outputting() ) { if ( io.outputting() ) {
BufPtr = new (&Buffer) TNorm(io, Obj); BufPtr = new (&Buffer) TNorm(io, Obj);
} }

View File

@ -40,7 +40,7 @@ public:
/// intrinsic, Tys should point to an array of numTys pointers to Type, /// intrinsic, Tys should point to an array of numTys pointers to Type,
/// and must provide exactly one type for each overloaded type in the /// and must provide exactly one type for each overloaded type in the
/// intrinsic. /// intrinsic.
virtual std::string getName(unsigned IID, Type **Tys = 0, virtual std::string getName(unsigned IID, Type **Tys = nullptr,
unsigned numTys = 0) const = 0; unsigned numTys = 0) const = 0;
/// Look up target intrinsic by name. Return intrinsic ID or 0 for unknown /// Look up target intrinsic by name. Return intrinsic ID or 0 for unknown
@ -56,7 +56,7 @@ public:
/// Create or insert an LLVM Function declaration for an intrinsic, /// Create or insert an LLVM Function declaration for an intrinsic,
/// and return it. The Tys and numTys are for intrinsics with overloaded /// and return it. The Tys and numTys are for intrinsics with overloaded
/// types. See above for more information. /// 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; unsigned numTys = 0) const = 0;
}; };

View File

@ -96,8 +96,8 @@ struct ClonedCodeInfo {
/// ///
BasicBlock *CloneBasicBlock(const BasicBlock *BB, BasicBlock *CloneBasicBlock(const BasicBlock *BB,
ValueToValueMapTy &VMap, ValueToValueMapTy &VMap,
const Twine &NameSuffix = "", Function *F = 0, const Twine &NameSuffix = "", Function *F = nullptr,
ClonedCodeInfo *CodeInfo = 0); ClonedCodeInfo *CodeInfo = nullptr);
/// CloneFunction - Return a copy of the specified function, but without /// CloneFunction - Return a copy of the specified function, but without
/// embedding the function into another module. Also, any references specified /// embedding the function into another module. Also, any references specified
@ -114,7 +114,7 @@ BasicBlock *CloneBasicBlock(const BasicBlock *BB,
Function *CloneFunction(const Function *F, Function *CloneFunction(const Function *F,
ValueToValueMapTy &VMap, ValueToValueMapTy &VMap,
bool ModuleLevelChanges, bool ModuleLevelChanges,
ClonedCodeInfo *CodeInfo = 0); ClonedCodeInfo *CodeInfo = nullptr);
/// Clone OldFunc into NewFunc, transforming the old arguments into references /// Clone OldFunc into NewFunc, transforming the old arguments into references
/// to VMap values. Note that if NewFunc already has basic blocks, the ones /// to VMap values. Note that if NewFunc already has basic blocks, the ones
@ -130,9 +130,9 @@ void CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
bool ModuleLevelChanges, bool ModuleLevelChanges,
SmallVectorImpl<ReturnInst*> &Returns, SmallVectorImpl<ReturnInst*> &Returns,
const char *NameSuffix = "", const char *NameSuffix = "",
ClonedCodeInfo *CodeInfo = 0, ClonedCodeInfo *CodeInfo = nullptr,
ValueMapTypeRemapper *TypeMapper = 0, ValueMapTypeRemapper *TypeMapper = nullptr,
ValueMaterializer *Materializer = 0); ValueMaterializer *Materializer = nullptr);
/// CloneAndPruneFunctionInto - This works exactly like CloneFunctionInto, /// CloneAndPruneFunctionInto - This works exactly like CloneFunctionInto,
/// except that it does some simple constant prop and DCE on the fly. The /// except that it does some simple constant prop and DCE on the fly. The
@ -150,16 +150,16 @@ void CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc,
bool ModuleLevelChanges, bool ModuleLevelChanges,
SmallVectorImpl<ReturnInst*> &Returns, SmallVectorImpl<ReturnInst*> &Returns,
const char *NameSuffix = "", const char *NameSuffix = "",
ClonedCodeInfo *CodeInfo = 0, ClonedCodeInfo *CodeInfo = nullptr,
const DataLayout *DL = 0, const DataLayout *DL = nullptr,
Instruction *TheCall = 0); Instruction *TheCall = nullptr);
/// InlineFunctionInfo - This class captures the data input to the /// InlineFunctionInfo - This class captures the data input to the
/// InlineFunction call, and records the auxiliary results produced by it. /// InlineFunction call, and records the auxiliary results produced by it.
class InlineFunctionInfo { class InlineFunctionInfo {
public: public:
explicit InlineFunctionInfo(CallGraph *cg = 0, const DataLayout *DL = 0) explicit InlineFunctionInfo(CallGraph *cg = nullptr, const DataLayout *DL = nullptr)
: CG(cg), DL(DL) {} : CG(cg), DL(DL) {}
/// CG - If non-null, InlineFunction will update the callgraph to reflect the /// CG - If non-null, InlineFunction will update the callgraph to reflect the

View File

@ -68,27 +68,27 @@ namespace llvm {
Value *MapValue(const Value *V, ValueToValueMapTy &VM, Value *MapValue(const Value *V, ValueToValueMapTy &VM,
RemapFlags Flags = RF_None, RemapFlags Flags = RF_None,
ValueMapTypeRemapper *TypeMapper = 0, ValueMapTypeRemapper *TypeMapper = nullptr,
ValueMaterializer *Materializer = 0); ValueMaterializer *Materializer = nullptr);
void RemapInstruction(Instruction *I, ValueToValueMapTy &VM, void RemapInstruction(Instruction *I, ValueToValueMapTy &VM,
RemapFlags Flags = RF_None, RemapFlags Flags = RF_None,
ValueMapTypeRemapper *TypeMapper = 0, ValueMapTypeRemapper *TypeMapper = nullptr,
ValueMaterializer *Materializer = 0); ValueMaterializer *Materializer = nullptr);
/// MapValue - provide versions that preserve type safety for MDNode and /// MapValue - provide versions that preserve type safety for MDNode and
/// Constants. /// Constants.
inline MDNode *MapValue(const MDNode *V, ValueToValueMapTy &VM, inline MDNode *MapValue(const MDNode *V, ValueToValueMapTy &VM,
RemapFlags Flags = RF_None, RemapFlags Flags = RF_None,
ValueMapTypeRemapper *TypeMapper = 0, ValueMapTypeRemapper *TypeMapper = nullptr,
ValueMaterializer *Materializer = 0) { ValueMaterializer *Materializer = nullptr) {
return cast<MDNode>(MapValue((const Value*)V, VM, Flags, TypeMapper, return cast<MDNode>(MapValue((const Value*)V, VM, Flags, TypeMapper,
Materializer)); Materializer));
} }
inline Constant *MapValue(const Constant *V, ValueToValueMapTy &VM, inline Constant *MapValue(const Constant *V, ValueToValueMapTy &VM,
RemapFlags Flags = RF_None, RemapFlags Flags = RF_None,
ValueMapTypeRemapper *TypeMapper = 0, ValueMapTypeRemapper *TypeMapper = nullptr,
ValueMaterializer *Materializer = 0) { ValueMaterializer *Materializer = nullptr) {
return cast<Constant>(MapValue((const Value*)V, VM, Flags, TypeMapper, return cast<Constant>(MapValue((const Value*)V, VM, Flags, TypeMapper,
Materializer)); Materializer));
} }

View File

@ -150,7 +150,7 @@ static bool isLabelChar(char C) {
static const char *isLabelTail(const char *CurPtr) { static const char *isLabelTail(const char *CurPtr) {
while (1) { while (1) {
if (CurPtr[0] == ':') return CurPtr+1; if (CurPtr[0] == ':') return CurPtr+1;
if (!isLabelChar(CurPtr[0])) return 0; if (!isLabelChar(CurPtr[0])) return nullptr;
++CurPtr; ++CurPtr;
} }
} }
@ -435,8 +435,8 @@ lltok::Kind LLLexer::LexHash() {
/// HexIntConstant [us]0x[0-9A-Fa-f]+ /// HexIntConstant [us]0x[0-9A-Fa-f]+
lltok::Kind LLLexer::LexIdentifier() { lltok::Kind LLLexer::LexIdentifier() {
const char *StartChar = CurPtr; const char *StartChar = CurPtr;
const char *IntEnd = CurPtr[-1] == 'i' ? 0 : StartChar; const char *IntEnd = CurPtr[-1] == 'i' ? nullptr : StartChar;
const char *KeywordEnd = 0; const char *KeywordEnd = nullptr;
for (; isLabelChar(*CurPtr); ++CurPtr) { for (; isLabelChar(*CurPtr); ++CurPtr) {
// If we decide this is an integer, remember the end of the sequence. // If we decide this is an integer, remember the end of the sequence.
@ -455,7 +455,7 @@ lltok::Kind LLLexer::LexIdentifier() {
// Otherwise, this wasn't a label. If this was valid as an integer type, // Otherwise, this wasn't a label. If this was valid as an integer type,
// return it. // return it.
if (IntEnd == 0) IntEnd = CurPtr; if (!IntEnd) IntEnd = CurPtr;
if (IntEnd != StartChar) { if (IntEnd != StartChar) {
CurPtr = IntEnd; CurPtr = IntEnd;
uint64_t NumBits = atoull(StartChar, CurPtr); uint64_t NumBits = atoull(StartChar, CurPtr);
@ -469,7 +469,7 @@ lltok::Kind LLLexer::LexIdentifier() {
} }
// Otherwise, this was a letter sequence. See which keyword this is. // Otherwise, this was a letter sequence. See which keyword this is.
if (KeywordEnd == 0) KeywordEnd = CurPtr; if (!KeywordEnd) KeywordEnd = CurPtr;
CurPtr = KeywordEnd; CurPtr = KeywordEnd;
--StartChar; --StartChar;
unsigned Len = CurPtr-StartChar; unsigned Len = CurPtr-StartChar;

View File

@ -57,7 +57,8 @@ bool LLParser::ValidateEndOfModule() {
for (unsigned i = 0, e = MDList.size(); i != e; ++i) { for (unsigned i = 0, e = MDList.size(); i != e; ++i) {
unsigned SlotNo = MDList[i].MDSlot; 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 '!" + return Error(MDList[i].Loc, "use of undefined metadata '!" +
Twine(SlotNo) + "'"); Twine(SlotNo) + "'");
Inst->setMetadata(MDList[i].MDKind, NumberedMetadata[SlotNo]); Inst->setMetadata(MDList[i].MDKind, NumberedMetadata[SlotNo]);
@ -132,20 +133,20 @@ bool LLParser::ValidateEndOfModule() {
// references after the function was defined. Resolve those now. // references after the function was defined. Resolve those now.
while (!ForwardRefBlockAddresses.empty()) { while (!ForwardRefBlockAddresses.empty()) {
// Okay, we are referencing an already-parsed function, resolve them now. // Okay, we are referencing an already-parsed function, resolve them now.
Function *TheFn = 0; Function *TheFn = nullptr;
const ValID &Fn = ForwardRefBlockAddresses.begin()->first; const ValID &Fn = ForwardRefBlockAddresses.begin()->first;
if (Fn.Kind == ValID::t_GlobalName) if (Fn.Kind == ValID::t_GlobalName)
TheFn = M->getFunction(Fn.StrVal); TheFn = M->getFunction(Fn.StrVal);
else if (Fn.UIntVal < NumberedVals.size()) else if (Fn.UIntVal < NumberedVals.size())
TheFn = dyn_cast<Function>(NumberedVals[Fn.UIntVal]); TheFn = dyn_cast<Function>(NumberedVals[Fn.UIntVal]);
if (TheFn == 0) if (!TheFn)
return Error(Fn.Loc, "unknown function referenced by blockaddress"); return Error(Fn.Loc, "unknown function referenced by blockaddress");
// Resolve all these references. // Resolve all these references.
if (ResolveForwardRefBlockAddresses(TheFn, if (ResolveForwardRefBlockAddresses(TheFn,
ForwardRefBlockAddresses.begin()->second, ForwardRefBlockAddresses.begin()->second,
0)) nullptr))
return true; return true;
ForwardRefBlockAddresses.erase(ForwardRefBlockAddresses.begin()); ForwardRefBlockAddresses.erase(ForwardRefBlockAddresses.begin());
@ -206,7 +207,7 @@ bool LLParser::ResolveForwardRefBlockAddresses(Function *TheFn,
TheFn->getValueSymbolTable().lookup(Refs[i].first.StrVal)); TheFn->getValueSymbolTable().lookup(Refs[i].first.StrVal));
} }
if (Res == 0) if (!Res)
return Error(Refs[i].first.Loc, return Error(Refs[i].first.Loc,
"referenced value is not a basic block"); "referenced value is not a basic block");
@ -364,7 +365,7 @@ bool LLParser::ParseUnnamedType() {
if (TypeID >= NumberedTypes.size()) if (TypeID >= NumberedTypes.size())
NumberedTypes.resize(TypeID+1); NumberedTypes.resize(TypeID+1);
Type *Result = 0; Type *Result = nullptr;
if (ParseStructDefinition(TypeLoc, "", if (ParseStructDefinition(TypeLoc, "",
NumberedTypes[TypeID], Result)) return true; NumberedTypes[TypeID], Result)) return true;
@ -391,7 +392,7 @@ bool LLParser::ParseNamedType() {
ParseToken(lltok::kw_type, "expected 'type' after name")) ParseToken(lltok::kw_type, "expected 'type' after name"))
return true; return true;
Type *Result = 0; Type *Result = nullptr;
if (ParseStructDefinition(NameLoc, Name, if (ParseStructDefinition(NameLoc, Name,
NamedTypes[Name], Result)) return true; NamedTypes[Name], Result)) return true;
@ -523,10 +524,10 @@ bool LLParser::ParseMDNodeID(MDNode *&Result, unsigned &SlotNo) {
if (ParseUInt32(SlotNo)) return true; if (ParseUInt32(SlotNo)) return true;
// Check existing MDNode. // Check existing MDNode.
if (SlotNo < NumberedMetadata.size() && NumberedMetadata[SlotNo] != 0) if (SlotNo < NumberedMetadata.size() && NumberedMetadata[SlotNo] != nullptr)
Result = NumberedMetadata[SlotNo]; Result = NumberedMetadata[SlotNo];
else else
Result = 0; Result = nullptr;
return false; return false;
} }
@ -567,7 +568,7 @@ bool LLParser::ParseNamedMetadata() {
if (ParseToken(lltok::exclaim, "Expected '!' here")) if (ParseToken(lltok::exclaim, "Expected '!' here"))
return true; return true;
MDNode *N = 0; MDNode *N = nullptr;
if (ParseMDNodeID(N)) return true; if (ParseMDNodeID(N)) return true;
NMD->addOperand(N); NMD->addOperand(N);
} while (EatIfPresent(lltok::comma)); } while (EatIfPresent(lltok::comma));
@ -586,14 +587,14 @@ bool LLParser::ParseStandaloneMetadata() {
unsigned MetadataID = 0; unsigned MetadataID = 0;
LocTy TyLoc; LocTy TyLoc;
Type *Ty = 0; Type *Ty = nullptr;
SmallVector<Value *, 16> Elts; SmallVector<Value *, 16> Elts;
if (ParseUInt32(MetadataID) || if (ParseUInt32(MetadataID) ||
ParseToken(lltok::equal, "expected '=' here") || ParseToken(lltok::equal, "expected '=' here") ||
ParseType(Ty, TyLoc) || ParseType(Ty, TyLoc) ||
ParseToken(lltok::exclaim, "Expected '!' here") || ParseToken(lltok::exclaim, "Expected '!' here") ||
ParseToken(lltok::lbrace, "Expected '{' here") || ParseToken(lltok::lbrace, "Expected '{' here") ||
ParseMDNodeVector(Elts, NULL) || ParseMDNodeVector(Elts, nullptr) ||
ParseToken(lltok::rbrace, "expected end of metadata node")) ParseToken(lltok::rbrace, "expected end of metadata node"))
return true; return true;
@ -613,7 +614,7 @@ bool LLParser::ParseStandaloneMetadata() {
if (MetadataID >= NumberedMetadata.size()) if (MetadataID >= NumberedMetadata.size())
NumberedMetadata.resize(MetadataID+1); NumberedMetadata.resize(MetadataID+1);
if (NumberedMetadata[MetadataID] != 0) if (NumberedMetadata[MetadataID] != nullptr)
return TokError("Metadata id is already used"); return TokError("Metadata id is already used");
NumberedMetadata[MetadataID] = Init; NumberedMetadata[MetadataID] = Init;
} }
@ -720,7 +721,7 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
LocTy IsExternallyInitializedLoc; LocTy IsExternallyInitializedLoc;
LocTy TyLoc; LocTy TyLoc;
Type *Ty = 0; Type *Ty = nullptr;
if (ParseOptionalThreadLocal(TLM) || if (ParseOptionalThreadLocal(TLM) ||
ParseOptionalAddrSpace(AddrSpace) || ParseOptionalAddrSpace(AddrSpace) ||
ParseOptionalToken(lltok::kw_unnamed_addr, UnnamedAddr, ParseOptionalToken(lltok::kw_unnamed_addr, UnnamedAddr,
@ -734,7 +735,7 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
// If the linkage is specified and is external, then no initializer is // If the linkage is specified and is external, then no initializer is
// present. // present.
Constant *Init = 0; Constant *Init = nullptr;
if (!HasLinkage || (Linkage != GlobalValue::ExternalWeakLinkage && if (!HasLinkage || (Linkage != GlobalValue::ExternalWeakLinkage &&
Linkage != GlobalValue::ExternalLinkage)) { Linkage != GlobalValue::ExternalLinkage)) {
if (ParseGlobalValue(Ty, Init)) if (ParseGlobalValue(Ty, Init))
@ -744,7 +745,7 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
if (Ty->isFunctionTy() || Ty->isLabelTy()) if (Ty->isFunctionTy() || Ty->isLabelTy())
return Error(TyLoc, "invalid type for global variable"); 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. // See if the global was forward referenced, if so, use the global.
if (!Name.empty()) { if (!Name.empty()) {
@ -762,9 +763,9 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
} }
} }
if (GV == 0) { if (!GV) {
GV = new GlobalVariable(*M, Ty, false, GlobalValue::ExternalLinkage, 0, GV = new GlobalVariable(*M, Ty, false, GlobalValue::ExternalLinkage, nullptr,
Name, 0, GlobalVariable::NotThreadLocal, Name, nullptr, GlobalVariable::NotThreadLocal,
AddrSpace); AddrSpace);
} else { } else {
if (GV->getType()->getElementType() != Ty) if (GV->getType()->getElementType() != Ty)
@ -980,9 +981,9 @@ bool LLParser::ParseFnAttributeValuePairs(AttrBuilder &B,
GlobalValue *LLParser::GetGlobalVal(const std::string &Name, Type *Ty, GlobalValue *LLParser::GetGlobalVal(const std::string &Name, Type *Ty,
LocTy Loc) { LocTy Loc) {
PointerType *PTy = dyn_cast<PointerType>(Ty); PointerType *PTy = dyn_cast<PointerType>(Ty);
if (PTy == 0) { if (!PTy) {
Error(Loc, "global variable reference must have pointer type"); Error(Loc, "global variable reference must have pointer type");
return 0; return nullptr;
} }
// Look this name up in the normal function symbol table. // Look this name up in the normal function symbol table.
@ -991,7 +992,7 @@ GlobalValue *LLParser::GetGlobalVal(const std::string &Name, Type *Ty,
// If this is a forward reference for the value, see if we already created a // If this is a forward reference for the value, see if we already created a
// forward ref record. // forward ref record.
if (Val == 0) { if (!Val) {
std::map<std::string, std::pair<GlobalValue*, LocTy> >::iterator std::map<std::string, std::pair<GlobalValue*, LocTy> >::iterator
I = ForwardRefVals.find(Name); I = ForwardRefVals.find(Name);
if (I != ForwardRefVals.end()) if (I != ForwardRefVals.end())
@ -1003,7 +1004,7 @@ GlobalValue *LLParser::GetGlobalVal(const std::string &Name, Type *Ty,
if (Val->getType() == Ty) return Val; if (Val->getType() == Ty) return Val;
Error(Loc, "'@" + Name + "' defined with type '" + Error(Loc, "'@" + Name + "' defined with type '" +
getTypeString(Val->getType()) + "'"); getTypeString(Val->getType()) + "'");
return 0; return nullptr;
} }
// Otherwise, create a new forward reference for this value and remember it. // Otherwise, create a new forward reference for this value and remember it.
@ -1012,8 +1013,8 @@ GlobalValue *LLParser::GetGlobalVal(const std::string &Name, Type *Ty,
FwdVal = Function::Create(FT, GlobalValue::ExternalWeakLinkage, Name, M); FwdVal = Function::Create(FT, GlobalValue::ExternalWeakLinkage, Name, M);
else else
FwdVal = new GlobalVariable(*M, PTy->getElementType(), false, FwdVal = new GlobalVariable(*M, PTy->getElementType(), false,
GlobalValue::ExternalWeakLinkage, 0, Name, GlobalValue::ExternalWeakLinkage, nullptr, Name,
0, GlobalVariable::NotThreadLocal, nullptr, GlobalVariable::NotThreadLocal,
PTy->getAddressSpace()); PTy->getAddressSpace());
ForwardRefVals[Name] = std::make_pair(FwdVal, Loc); ForwardRefVals[Name] = std::make_pair(FwdVal, Loc);
@ -1022,16 +1023,16 @@ GlobalValue *LLParser::GetGlobalVal(const std::string &Name, Type *Ty,
GlobalValue *LLParser::GetGlobalVal(unsigned ID, Type *Ty, LocTy Loc) { GlobalValue *LLParser::GetGlobalVal(unsigned ID, Type *Ty, LocTy Loc) {
PointerType *PTy = dyn_cast<PointerType>(Ty); PointerType *PTy = dyn_cast<PointerType>(Ty);
if (PTy == 0) { if (!PTy) {
Error(Loc, "global variable reference must have pointer type"); 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 // If this is a forward reference for the value, see if we already created a
// forward ref record. // forward ref record.
if (Val == 0) { if (!Val) {
std::map<unsigned, std::pair<GlobalValue*, LocTy> >::iterator std::map<unsigned, std::pair<GlobalValue*, LocTy> >::iterator
I = ForwardRefValIDs.find(ID); I = ForwardRefValIDs.find(ID);
if (I != ForwardRefValIDs.end()) if (I != ForwardRefValIDs.end())
@ -1043,7 +1044,7 @@ GlobalValue *LLParser::GetGlobalVal(unsigned ID, Type *Ty, LocTy Loc) {
if (Val->getType() == Ty) return Val; if (Val->getType() == Ty) return Val;
Error(Loc, "'@" + Twine(ID) + "' defined with type '" + Error(Loc, "'@" + Twine(ID) + "' defined with type '" +
getTypeString(Val->getType()) + "'"); getTypeString(Val->getType()) + "'");
return 0; return nullptr;
} }
// Otherwise, create a new forward reference for this value and remember it. // Otherwise, create a new forward reference for this value and remember it.
@ -1052,7 +1053,7 @@ GlobalValue *LLParser::GetGlobalVal(unsigned ID, Type *Ty, LocTy Loc) {
FwdVal = Function::Create(FT, GlobalValue::ExternalWeakLinkage, "", M); FwdVal = Function::Create(FT, GlobalValue::ExternalWeakLinkage, "", M);
else else
FwdVal = new GlobalVariable(*M, PTy->getElementType(), false, FwdVal = new GlobalVariable(*M, PTy->getElementType(), false,
GlobalValue::ExternalWeakLinkage, 0, ""); GlobalValue::ExternalWeakLinkage, nullptr, "");
ForwardRefValIDs[ID] = std::make_pair(FwdVal, Loc); ForwardRefValIDs[ID] = std::make_pair(FwdVal, Loc);
return FwdVal; return FwdVal;
@ -1638,7 +1639,7 @@ bool LLParser::ParseType(Type *&Result, bool AllowVoid) {
// If the type hasn't been defined yet, create a forward definition and // 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). // 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.first = StructType::create(Context, Lex.getStrVal());
Entry.second = Lex.getLoc(); Entry.second = Lex.getLoc();
} }
@ -1655,7 +1656,7 @@ bool LLParser::ParseType(Type *&Result, bool AllowVoid) {
// If the type hasn't been defined yet, create a forward definition and // 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). // 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.first = StructType::create(Context);
Entry.second = Lex.getLoc(); Entry.second = Lex.getLoc();
} }
@ -1731,7 +1732,7 @@ bool LLParser::ParseParameterList(SmallVectorImpl<ParamInfo> &ArgList,
// Parse the argument. // Parse the argument.
LocTy ArgLoc; LocTy ArgLoc;
Type *ArgTy = 0; Type *ArgTy = nullptr;
AttrBuilder ArgAttrs; AttrBuilder ArgAttrs;
Value *V; Value *V;
if (ParseType(ArgTy, ArgLoc)) if (ParseType(ArgTy, ArgLoc))
@ -1773,7 +1774,7 @@ bool LLParser::ParseArgumentList(SmallVectorImpl<ArgInfo> &ArgList,
Lex.Lex(); Lex.Lex();
} else { } else {
LocTy TypeLoc = Lex.getLoc(); LocTy TypeLoc = Lex.getLoc();
Type *ArgTy = 0; Type *ArgTy = nullptr;
AttrBuilder Attrs; AttrBuilder Attrs;
std::string Name; std::string Name;
@ -1885,7 +1886,7 @@ bool LLParser::ParseStructDefinition(SMLoc TypeLoc, StringRef Name,
Entry.second = SMLoc(); Entry.second = SMLoc();
// If this type number has never been uttered, create it. // If this type number has never been uttered, create it.
if (Entry.first == 0) if (!Entry.first)
Entry.first = StructType::create(Context, Name); Entry.first = StructType::create(Context, Name);
ResultTy = Entry.first; ResultTy = Entry.first;
return false; return false;
@ -1901,7 +1902,7 @@ bool LLParser::ParseStructDefinition(SMLoc TypeLoc, StringRef Name,
if (Entry.first) if (Entry.first)
return Error(TypeLoc, "forward references to non-struct type"); return Error(TypeLoc, "forward references to non-struct type");
ResultTy = 0; ResultTy = nullptr;
if (isPacked) if (isPacked)
return ParseArrayVectorType(ResultTy, true); return ParseArrayVectorType(ResultTy, true);
return ParseType(ResultTy); return ParseType(ResultTy);
@ -1911,7 +1912,7 @@ bool LLParser::ParseStructDefinition(SMLoc TypeLoc, StringRef Name,
Entry.second = SMLoc(); Entry.second = SMLoc();
// If this type number has never been uttered, create it. // If this type number has never been uttered, create it.
if (Entry.first == 0) if (!Entry.first)
Entry.first = StructType::create(Context, Name); Entry.first = StructType::create(Context, Name);
StructType *STy = cast<StructType>(Entry.first); StructType *STy = cast<StructType>(Entry.first);
@ -1942,7 +1943,7 @@ bool LLParser::ParseStructBody(SmallVectorImpl<Type*> &Body) {
return false; return false;
LocTy EltTyLoc = Lex.getLoc(); LocTy EltTyLoc = Lex.getLoc();
Type *Ty = 0; Type *Ty = nullptr;
if (ParseType(Ty)) return true; if (ParseType(Ty)) return true;
Body.push_back(Ty); Body.push_back(Ty);
@ -1980,7 +1981,7 @@ bool LLParser::ParseArrayVectorType(Type *&Result, bool isVector) {
return true; return true;
LocTy TypeLoc = Lex.getLoc(); LocTy TypeLoc = Lex.getLoc();
Type *EltTy = 0; Type *EltTy = nullptr;
if (ParseType(EltTy)) return true; if (ParseType(EltTy)) return true;
if (ParseToken(isVector ? lltok::greater : lltok::rsquare, if (ParseToken(isVector ? lltok::greater : lltok::rsquare,
@ -2026,7 +2027,7 @@ LLParser::PerFunctionState::~PerFunctionState() {
I->second.first->replaceAllUsesWith( I->second.first->replaceAllUsesWith(
UndefValue::get(I->second.first->getType())); UndefValue::get(I->second.first->getType()));
delete I->second.first; delete I->second.first;
I->second.first = 0; I->second.first = nullptr;
} }
for (std::map<unsigned, std::pair<Value*, LocTy> >::iterator for (std::map<unsigned, std::pair<Value*, LocTy> >::iterator
@ -2035,7 +2036,7 @@ LLParser::PerFunctionState::~PerFunctionState() {
I->second.first->replaceAllUsesWith( I->second.first->replaceAllUsesWith(
UndefValue::get(I->second.first->getType())); UndefValue::get(I->second.first->getType()));
delete I->second.first; delete I->second.first;
I->second.first = 0; I->second.first = nullptr;
} }
} }
@ -2084,7 +2085,7 @@ Value *LLParser::PerFunctionState::GetVal(const std::string &Name,
// If this is a forward reference for the value, see if we already created a // If this is a forward reference for the value, see if we already created a
// forward ref record. // forward ref record.
if (Val == 0) { if (!Val) {
std::map<std::string, std::pair<Value*, LocTy> >::iterator std::map<std::string, std::pair<Value*, LocTy> >::iterator
I = ForwardRefVals.find(Name); I = ForwardRefVals.find(Name);
if (I != ForwardRefVals.end()) if (I != ForwardRefVals.end())
@ -2099,13 +2100,13 @@ Value *LLParser::PerFunctionState::GetVal(const std::string &Name,
else else
P.Error(Loc, "'%" + Name + "' defined with type '" + P.Error(Loc, "'%" + Name + "' defined with type '" +
getTypeString(Val->getType()) + "'"); getTypeString(Val->getType()) + "'");
return 0; return nullptr;
} }
// Don't make placeholders with invalid type. // Don't make placeholders with invalid type.
if (!Ty->isFirstClassType() && !Ty->isLabelTy()) { if (!Ty->isFirstClassType() && !Ty->isLabelTy()) {
P.Error(Loc, "invalid use of a non-first-class type"); 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. // Otherwise, create a new forward reference for this value and remember it.
@ -2122,11 +2123,11 @@ Value *LLParser::PerFunctionState::GetVal(const std::string &Name,
Value *LLParser::PerFunctionState::GetVal(unsigned ID, Type *Ty, Value *LLParser::PerFunctionState::GetVal(unsigned ID, Type *Ty,
LocTy Loc) { LocTy Loc) {
// Look this name up in the normal function symbol table. // 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 // If this is a forward reference for the value, see if we already created a
// forward ref record. // forward ref record.
if (Val == 0) { if (!Val) {
std::map<unsigned, std::pair<Value*, LocTy> >::iterator std::map<unsigned, std::pair<Value*, LocTy> >::iterator
I = ForwardRefValIDs.find(ID); I = ForwardRefValIDs.find(ID);
if (I != ForwardRefValIDs.end()) if (I != ForwardRefValIDs.end())
@ -2141,12 +2142,12 @@ Value *LLParser::PerFunctionState::GetVal(unsigned ID, Type *Ty,
else else
P.Error(Loc, "'%" + Twine(ID) + "' defined with type '" + P.Error(Loc, "'%" + Twine(ID) + "' defined with type '" +
getTypeString(Val->getType()) + "'"); getTypeString(Val->getType()) + "'");
return 0; return nullptr;
} }
if (!Ty->isFirstClassType() && !Ty->isLabelTy()) { if (!Ty->isFirstClassType() && !Ty->isLabelTy()) {
P.Error(Loc, "invalid use of a non-first-class type"); 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. // Otherwise, create a new forward reference for this value and remember it.
@ -2242,7 +2243,7 @@ BasicBlock *LLParser::PerFunctionState::DefineBB(const std::string &Name,
BB = GetBB(NumberedVals.size(), Loc); BB = GetBB(NumberedVals.size(), Loc);
else else
BB = GetBB(Name, Loc); 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 // Move the block to the end of the function. Forward ref'd blocks are
// inserted wherever they happen to be referenced. // inserted wherever they happen to be referenced.
@ -2450,7 +2451,7 @@ bool LLParser::ParseValID(ValID &ID, PerFunctionState *PFS) {
// Make a global variable as a placeholder for this reference. // Make a global variable as a placeholder for this reference.
GlobalVariable *FwdRef = new GlobalVariable(*M, Type::getInt8Ty(Context), GlobalVariable *FwdRef = new GlobalVariable(*M, Type::getInt8Ty(Context),
false, GlobalValue::InternalLinkage, false, GlobalValue::InternalLinkage,
0, ""); nullptr, "");
ForwardRefBlockAddresses[Fn].push_back(std::make_pair(Label, FwdRef)); ForwardRefBlockAddresses[Fn].push_back(std::make_pair(Label, FwdRef));
ID.ConstantVal = FwdRef; ID.ConstantVal = FwdRef;
ID.Kind = ValID::t_Constant; ID.Kind = ValID::t_Constant;
@ -2471,7 +2472,7 @@ bool LLParser::ParseValID(ValID &ID, PerFunctionState *PFS) {
case lltok::kw_inttoptr: case lltok::kw_inttoptr:
case lltok::kw_ptrtoint: { case lltok::kw_ptrtoint: {
unsigned Opc = Lex.getUIntVal(); unsigned Opc = Lex.getUIntVal();
Type *DestTy = 0; Type *DestTy = nullptr;
Constant *SrcVal; Constant *SrcVal;
Lex.Lex(); Lex.Lex();
if (ParseToken(lltok::lparen, "expected '(' after constantexpr cast") || if (ParseToken(lltok::lparen, "expected '(' after constantexpr cast") ||
@ -2735,18 +2736,18 @@ bool LLParser::ParseValID(ValID &ID, PerFunctionState *PFS) {
/// ParseGlobalValue - Parse a global value with the specified type. /// ParseGlobalValue - Parse a global value with the specified type.
bool LLParser::ParseGlobalValue(Type *Ty, Constant *&C) { bool LLParser::ParseGlobalValue(Type *Ty, Constant *&C) {
C = 0; C = nullptr;
ValID ID; ValID ID;
Value *V = NULL; Value *V = nullptr;
bool Parsed = ParseValID(ID) || bool Parsed = ParseValID(ID) ||
ConvertValIDToValue(Ty, ID, V, NULL); ConvertValIDToValue(Ty, ID, V, nullptr);
if (V && !(C = dyn_cast<Constant>(V))) if (V && !(C = dyn_cast<Constant>(V)))
return Error(ID.Loc, "global values must be constants"); return Error(ID.Loc, "global values must be constants");
return Parsed; return Parsed;
} }
bool LLParser::ParseGlobalTypeAndValue(Constant *&V) { bool LLParser::ParseGlobalTypeAndValue(Constant *&V) {
Type *Ty = 0; Type *Ty = nullptr;
return ParseType(Ty) || return ParseType(Ty) ||
ParseGlobalValue(Ty, V); ParseGlobalValue(Ty, V);
} }
@ -2830,15 +2831,15 @@ bool LLParser::ConvertValIDToValue(Type *Ty, ValID &ID, Value *&V,
case ValID::t_LocalID: case ValID::t_LocalID:
if (!PFS) return Error(ID.Loc, "invalid use of function-local name"); if (!PFS) return Error(ID.Loc, "invalid use of function-local name");
V = PFS->GetVal(ID.UIntVal, Ty, ID.Loc); V = PFS->GetVal(ID.UIntVal, Ty, ID.Loc);
return (V == 0); return V == nullptr;
case ValID::t_LocalName: case ValID::t_LocalName:
if (!PFS) return Error(ID.Loc, "invalid use of function-local name"); if (!PFS) return Error(ID.Loc, "invalid use of function-local name");
V = PFS->GetVal(ID.StrVal, Ty, ID.Loc); V = PFS->GetVal(ID.StrVal, Ty, ID.Loc);
return (V == 0); return V == nullptr;
case ValID::t_InlineAsm: { case ValID::t_InlineAsm: {
PointerType *PTy = dyn_cast<PointerType>(Ty); PointerType *PTy = dyn_cast<PointerType>(Ty);
FunctionType *FTy = FunctionType *FTy =
PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0; PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : nullptr;
if (!FTy || !InlineAsm::Verify(FTy, ID.StrVal2)) if (!FTy || !InlineAsm::Verify(FTy, ID.StrVal2))
return Error(ID.Loc, "invalid type for inline asm constraint string"); return Error(ID.Loc, "invalid type for inline asm constraint string");
V = InlineAsm::get(FTy, ID.StrVal, ID.StrVal2, ID.UIntVal&1, V = InlineAsm::get(FTy, ID.StrVal, ID.StrVal2, ID.UIntVal&1,
@ -2857,10 +2858,10 @@ bool LLParser::ConvertValIDToValue(Type *Ty, ValID &ID, Value *&V,
return false; return false;
case ValID::t_GlobalName: case ValID::t_GlobalName:
V = GetGlobalVal(ID.StrVal, Ty, ID.Loc); V = GetGlobalVal(ID.StrVal, Ty, ID.Loc);
return V == 0; return V == nullptr;
case ValID::t_GlobalID: case ValID::t_GlobalID:
V = GetGlobalVal(ID.UIntVal, Ty, ID.Loc); V = GetGlobalVal(ID.UIntVal, Ty, ID.Loc);
return V == 0; return V == nullptr;
case ValID::t_APSInt: case ValID::t_APSInt:
if (!Ty->isIntegerTy()) if (!Ty->isIntegerTy())
return Error(ID.Loc, "integer constant must have integer type"); return Error(ID.Loc, "integer constant must have integer type");
@ -2943,14 +2944,14 @@ bool LLParser::ConvertValIDToValue(Type *Ty, ValID &ID, Value *&V,
} }
bool LLParser::ParseValue(Type *Ty, Value *&V, PerFunctionState *PFS) { bool LLParser::ParseValue(Type *Ty, Value *&V, PerFunctionState *PFS) {
V = 0; V = nullptr;
ValID ID; ValID ID;
return ParseValID(ID, PFS) || return ParseValID(ID, PFS) ||
ConvertValIDToValue(Ty, ID, V, PFS); ConvertValIDToValue(Ty, ID, V, PFS);
} }
bool LLParser::ParseTypeAndValue(Value *&V, PerFunctionState *PFS) { bool LLParser::ParseTypeAndValue(Value *&V, PerFunctionState *PFS) {
Type *Ty = 0; Type *Ty = nullptr;
return ParseType(Ty) || return ParseType(Ty) ||
ParseValue(Ty, V, PFS); ParseValue(Ty, V, PFS);
} }
@ -2980,7 +2981,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
unsigned DLLStorageClass; unsigned DLLStorageClass;
AttrBuilder RetAttrs; AttrBuilder RetAttrs;
CallingConv::ID CC; CallingConv::ID CC;
Type *RetType = 0; Type *RetType = nullptr;
LocTy RetTypeLoc = Lex.getLoc(); LocTy RetTypeLoc = Lex.getLoc();
if (ParseOptionalLinkage(Linkage) || if (ParseOptionalLinkage(Linkage) ||
ParseOptionalVisibility(Visibility) || ParseOptionalVisibility(Visibility) ||
@ -3046,7 +3047,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
std::string GC; std::string GC;
bool UnnamedAddr; bool UnnamedAddr;
LocTy UnnamedAddrLoc; LocTy UnnamedAddrLoc;
Constant *Prefix = 0; Constant *Prefix = nullptr;
if (ParseArgumentList(ArgList, isVarArg) || if (ParseArgumentList(ArgList, isVarArg) ||
ParseOptionalToken(lltok::kw_unnamed_addr, UnnamedAddr, ParseOptionalToken(lltok::kw_unnamed_addr, UnnamedAddr,
@ -3103,7 +3104,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
FunctionType::get(RetType, ParamTypeList, isVarArg); FunctionType::get(RetType, ParamTypeList, isVarArg);
PointerType *PFT = PointerType::getUnqual(FT); PointerType *PFT = PointerType::getUnqual(FT);
Fn = 0; Fn = nullptr;
if (!FunctionName.empty()) { if (!FunctionName.empty()) {
// If this was a definition of a forward reference, remove the definition // If this was a definition of a forward reference, remove the definition
// from the forward reference table and fill in the forward ref. // from the forward reference table and fill in the forward ref.
@ -3141,7 +3142,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
} }
} }
if (Fn == 0) if (!Fn)
Fn = Function::Create(FT, GlobalValue::ExternalLinkage, FunctionName, M); Fn = Function::Create(FT, GlobalValue::ExternalLinkage, FunctionName, M);
else // Move the forward-reference to the correct spot in the module. else // Move the forward-reference to the correct spot in the module.
M->getFunctionList().splice(M->end(), M->getFunctionList(), Fn); M->getFunctionList().splice(M->end(), M->getFunctionList(), Fn);
@ -3218,7 +3219,7 @@ bool LLParser::ParseBasicBlock(PerFunctionState &PFS) {
} }
BasicBlock *BB = PFS.DefineBB(Name, NameLoc); BasicBlock *BB = PFS.DefineBB(Name, NameLoc);
if (BB == 0) return true; if (!BB) return true;
std::string NameStr; std::string NameStr;
@ -3432,7 +3433,7 @@ bool LLParser::ParseCmpPredicate(unsigned &P, unsigned Opc) {
bool LLParser::ParseRet(Instruction *&Inst, BasicBlock *BB, bool LLParser::ParseRet(Instruction *&Inst, BasicBlock *BB,
PerFunctionState &PFS) { PerFunctionState &PFS) {
SMLoc TypeLoc = Lex.getLoc(); SMLoc TypeLoc = Lex.getLoc();
Type *Ty = 0; Type *Ty = nullptr;
if (ParseType(Ty, true /*void allowed*/)) return true; if (ParseType(Ty, true /*void allowed*/)) return true;
Type *ResType = PFS.getFunction().getReturnType(); Type *ResType = PFS.getFunction().getReturnType();
@ -3582,7 +3583,7 @@ bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) {
std::vector<unsigned> FwdRefAttrGrps; std::vector<unsigned> FwdRefAttrGrps;
LocTy NoBuiltinLoc; LocTy NoBuiltinLoc;
CallingConv::ID CC; CallingConv::ID CC;
Type *RetType = 0; Type *RetType = nullptr;
LocTy RetTypeLoc; LocTy RetTypeLoc;
ValID CalleeID; ValID CalleeID;
SmallVector<ParamInfo, 16> ArgList; SmallVector<ParamInfo, 16> ArgList;
@ -3604,8 +3605,8 @@ bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) {
// If RetType is a non-function pointer type, then this is the short syntax // 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 // 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. // rest of the function argument types from the arguments that are present.
PointerType *PFTy = 0; PointerType *PFTy = nullptr;
FunctionType *Ty = 0; FunctionType *Ty = nullptr;
if (!(PFTy = dyn_cast<PointerType>(RetType)) || if (!(PFTy = dyn_cast<PointerType>(RetType)) ||
!(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
// Pull out the types of all of the arguments... // Pull out the types of all of the arguments...
@ -3638,7 +3639,7 @@ bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) {
FunctionType::param_iterator I = Ty->param_begin(); FunctionType::param_iterator I = Ty->param_begin();
FunctionType::param_iterator E = Ty->param_end(); FunctionType::param_iterator E = Ty->param_end();
for (unsigned i = 0, e = ArgList.size(); i != e; ++i) { for (unsigned i = 0, e = ArgList.size(); i != e; ++i) {
Type *ExpectedTy = 0; Type *ExpectedTy = nullptr;
if (I != E) { if (I != E) {
ExpectedTy = *I++; ExpectedTy = *I++;
} else if (!Ty->isVarArg()) { } else if (!Ty->isVarArg()) {
@ -3779,7 +3780,7 @@ bool LLParser::ParseCast(Instruction *&Inst, PerFunctionState &PFS,
unsigned Opc) { unsigned Opc) {
LocTy Loc; LocTy Loc;
Value *Op; Value *Op;
Type *DestTy = 0; Type *DestTy = nullptr;
if (ParseTypeAndValue(Op, Loc, PFS) || if (ParseTypeAndValue(Op, Loc, PFS) ||
ParseToken(lltok::kw_to, "expected 'to' after cast value") || ParseToken(lltok::kw_to, "expected 'to' after cast value") ||
ParseType(DestTy)) ParseType(DestTy))
@ -3818,7 +3819,7 @@ bool LLParser::ParseSelect(Instruction *&Inst, PerFunctionState &PFS) {
/// ::= 'va_arg' TypeAndValue ',' Type /// ::= 'va_arg' TypeAndValue ',' Type
bool LLParser::ParseVA_Arg(Instruction *&Inst, PerFunctionState &PFS) { bool LLParser::ParseVA_Arg(Instruction *&Inst, PerFunctionState &PFS) {
Value *Op; Value *Op;
Type *EltTy = 0; Type *EltTy = nullptr;
LocTy TypeLoc; LocTy TypeLoc;
if (ParseTypeAndValue(Op, PFS) || if (ParseTypeAndValue(Op, PFS) ||
ParseToken(lltok::comma, "expected ',' after vaarg operand") || ParseToken(lltok::comma, "expected ',' after vaarg operand") ||
@ -3890,7 +3891,7 @@ bool LLParser::ParseShuffleVector(Instruction *&Inst, PerFunctionState &PFS) {
/// ParsePHI /// ParsePHI
/// ::= 'phi' Type '[' Value ',' Value ']' (',' '[' Value ',' Value ']')* /// ::= 'phi' Type '[' Value ',' Value ']' (',' '[' Value ',' Value ']')*
int LLParser::ParsePHI(Instruction *&Inst, PerFunctionState &PFS) { int LLParser::ParsePHI(Instruction *&Inst, PerFunctionState &PFS) {
Type *Ty = 0; LocTy TypeLoc; Type *Ty = nullptr; LocTy TypeLoc;
Value *Op0, *Op1; Value *Op0, *Op1;
if (ParseType(Ty, TypeLoc) || if (ParseType(Ty, TypeLoc) ||
@ -3939,7 +3940,7 @@ int LLParser::ParsePHI(Instruction *&Inst, PerFunctionState &PFS) {
/// ::= 'filter' /// ::= 'filter'
/// ::= 'filter' TypeAndValue ( ',' TypeAndValue )* /// ::= 'filter' TypeAndValue ( ',' TypeAndValue )*
bool LLParser::ParseLandingPad(Instruction *&Inst, PerFunctionState &PFS) { bool LLParser::ParseLandingPad(Instruction *&Inst, PerFunctionState &PFS) {
Type *Ty = 0; LocTy TyLoc; Type *Ty = nullptr; LocTy TyLoc;
Value *PersFn; LocTy PersFnLoc; Value *PersFn; LocTy PersFnLoc;
if (ParseType(Ty, TyLoc) || if (ParseType(Ty, TyLoc) ||
@ -3991,7 +3992,7 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
std::vector<unsigned> FwdRefAttrGrps; std::vector<unsigned> FwdRefAttrGrps;
LocTy BuiltinLoc; LocTy BuiltinLoc;
CallingConv::ID CC; CallingConv::ID CC;
Type *RetType = 0; Type *RetType = nullptr;
LocTy RetTypeLoc; LocTy RetTypeLoc;
ValID CalleeID; ValID CalleeID;
SmallVector<ParamInfo, 16> ArgList; SmallVector<ParamInfo, 16> ArgList;
@ -4010,8 +4011,8 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
// If RetType is a non-function pointer type, then this is the short syntax // 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 // 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. // rest of the function argument types from the arguments that are present.
PointerType *PFTy = 0; PointerType *PFTy = nullptr;
FunctionType *Ty = 0; FunctionType *Ty = nullptr;
if (!(PFTy = dyn_cast<PointerType>(RetType)) || if (!(PFTy = dyn_cast<PointerType>(RetType)) ||
!(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
// Pull out the types of all of the arguments... // Pull out the types of all of the arguments...
@ -4044,7 +4045,7 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
FunctionType::param_iterator I = Ty->param_begin(); FunctionType::param_iterator I = Ty->param_begin();
FunctionType::param_iterator E = Ty->param_end(); FunctionType::param_iterator E = Ty->param_end();
for (unsigned i = 0, e = ArgList.size(); i != e; ++i) { for (unsigned i = 0, e = ArgList.size(); i != e; ++i) {
Type *ExpectedTy = 0; Type *ExpectedTy = nullptr;
if (I != E) { if (I != E) {
ExpectedTy = *I++; ExpectedTy = *I++;
} else if (!Ty->isVarArg()) { } else if (!Ty->isVarArg()) {
@ -4088,10 +4089,10 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
/// ParseAlloc /// ParseAlloc
/// ::= 'alloca' 'inalloca'? Type (',' TypeAndValue)? (',' 'align' i32)? /// ::= 'alloca' 'inalloca'? Type (',' TypeAndValue)? (',' 'align' i32)?
int LLParser::ParseAlloc(Instruction *&Inst, PerFunctionState &PFS) { int LLParser::ParseAlloc(Instruction *&Inst, PerFunctionState &PFS) {
Value *Size = 0; Value *Size = nullptr;
LocTy SizeLoc; LocTy SizeLoc;
unsigned Alignment = 0; unsigned Alignment = 0;
Type *Ty = 0; Type *Ty = nullptr;
bool IsInAlloca = EatIfPresent(lltok::kw_inalloca); bool IsInAlloca = EatIfPresent(lltok::kw_inalloca);
@ -4330,8 +4331,8 @@ int LLParser::ParseFence(Instruction *&Inst, PerFunctionState &PFS) {
/// ParseGetElementPtr /// ParseGetElementPtr
/// ::= 'getelementptr' 'inbounds'? TypeAndValue (',' TypeAndValue)* /// ::= 'getelementptr' 'inbounds'? TypeAndValue (',' TypeAndValue)*
int LLParser::ParseGetElementPtr(Instruction *&Inst, PerFunctionState &PFS) { int LLParser::ParseGetElementPtr(Instruction *&Inst, PerFunctionState &PFS) {
Value *Ptr = 0; Value *Ptr = nullptr;
Value *Val = 0; Value *Val = nullptr;
LocTy Loc, EltLoc; LocTy Loc, EltLoc;
bool InBounds = EatIfPresent(lltok::kw_inbounds); bool InBounds = EatIfPresent(lltok::kw_inbounds);
@ -4433,11 +4434,11 @@ bool LLParser::ParseMDNodeVector(SmallVectorImpl<Value*> &Elts,
do { do {
// Null is a special case since it is typeless. // Null is a special case since it is typeless.
if (EatIfPresent(lltok::kw_null)) { if (EatIfPresent(lltok::kw_null)) {
Elts.push_back(0); Elts.push_back(nullptr);
continue; continue;
} }
Value *V = 0; Value *V = nullptr;
if (ParseTypeAndValue(V, PFS)) return true; if (ParseTypeAndValue(V, PFS)) return true;
Elts.push_back(V); Elts.push_back(V);
} while (EatIfPresent(lltok::comma)); } while (EatIfPresent(lltok::comma));

View File

@ -30,12 +30,12 @@ Module *llvm::ParseAssembly(MemoryBuffer *F,
// If we are parsing into an existing module, do it. // If we are parsing into an existing module, do it.
if (M) 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. // Otherwise create a new module.
std::unique_ptr<Module> M2(new Module(F->getBufferIdentifier(), Context)); std::unique_ptr<Module> M2(new Module(F->getBufferIdentifier(), Context));
if (LLParser(F, SM, Err, M2.get()).Run()) if (LLParser(F, SM, Err, M2.get()).Run())
return 0; return nullptr;
return M2.release(); return M2.release();
} }
@ -45,10 +45,10 @@ Module *llvm::ParseAssemblyFile(const std::string &Filename, SMDiagnostic &Err,
if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, File)) { if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, File)) {
Err = SMDiagnostic(Filename, SourceMgr::DK_Error, Err = SMDiagnostic(Filename, SourceMgr::DK_Error,
"Could not open input file: " + ec.message()); "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, Module *llvm::ParseAssemblyString(const char *AsmString, Module *M,

View File

@ -35,7 +35,7 @@ LLVMBool LLVMParseBitcodeInContext(LLVMContextRef ContextRef,
if (error_code EC = ModuleOrErr.getError()) { if (error_code EC = ModuleOrErr.getError()) {
if (OutMessage) if (OutMessage)
*OutMessage = strdup(EC.message().c_str()); *OutMessage = strdup(EC.message().c_str());
*OutModule = wrap((Module*)0); *OutModule = wrap((Module*)nullptr);
return 1; return 1;
} }
@ -55,7 +55,7 @@ LLVMBool LLVMGetBitcodeModuleInContext(LLVMContextRef ContextRef,
getLazyBitcodeModule(unwrap(MemBuf), *unwrap(ContextRef)); getLazyBitcodeModule(unwrap(MemBuf), *unwrap(ContextRef));
if (error_code EC = ModuleOrErr.getError()) { if (error_code EC = ModuleOrErr.getError()) {
*OutM = wrap((Module *)NULL); *OutM = wrap((Module *)nullptr);
if (OutMessage) if (OutMessage)
*OutMessage = strdup(EC.message().c_str()); *OutMessage = strdup(EC.message().c_str());
return 1; return 1;

View File

@ -41,7 +41,7 @@ void BitcodeReader::materializeForwardReferencedFunctions() {
void BitcodeReader::FreeState() { void BitcodeReader::FreeState() {
if (BufferOwned) if (BufferOwned)
delete Buffer; delete Buffer;
Buffer = 0; Buffer = nullptr;
std::vector<Type*>().swap(TypeList); std::vector<Type*>().swap(TypeList);
ValueList.clear(); ValueList.clear();
MDValueList.clear(); MDValueList.clear();
@ -258,7 +258,7 @@ void BitcodeReaderValueList::AssignValue(Value *V, unsigned Idx) {
resize(Idx+1); resize(Idx+1);
WeakVH &OldV = ValuePtrs[Idx]; WeakVH &OldV = ValuePtrs[Idx];
if (OldV == 0) { if (!OldV) {
OldV = V; OldV = V;
return; return;
} }
@ -298,12 +298,12 @@ Value *BitcodeReaderValueList::getValueFwdRef(unsigned Idx, Type *Ty) {
resize(Idx + 1); resize(Idx + 1);
if (Value *V = ValuePtrs[Idx]) { 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; return V;
} }
// No type specified, must be invalid reference. // 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. // Create and return a placeholder, which will later be RAUW'd.
Value *V = new Argument(Ty); Value *V = new Argument(Ty);
@ -403,7 +403,7 @@ void BitcodeReaderMDValueList::AssignValue(Value *V, unsigned Idx) {
resize(Idx+1); resize(Idx+1);
WeakVH &OldV = MDValuePtrs[Idx]; WeakVH &OldV = MDValuePtrs[Idx];
if (OldV == 0) { if (!OldV) {
OldV = V; OldV = V;
return; return;
} }
@ -435,7 +435,7 @@ Value *BitcodeReaderMDValueList::getValueFwdRef(unsigned Idx) {
Type *BitcodeReader::getTypeByID(unsigned ID) { Type *BitcodeReader::getTypeByID(unsigned ID) {
// The type table size is always specified correctly. // The type table size is always specified correctly.
if (ID >= TypeList.size()) if (ID >= TypeList.size())
return 0; return nullptr;
if (Type *Ty = TypeList[ID]) if (Type *Ty = TypeList[ID])
return Ty; return Ty;
@ -737,7 +737,7 @@ error_code BitcodeReader::ParseTypeTableBody() {
// Read a record. // Read a record.
Record.clear(); Record.clear();
Type *ResultTy = 0; Type *ResultTy = nullptr;
switch (Stream.readRecord(Entry.ID, Record)) { switch (Stream.readRecord(Entry.ID, Record)) {
default: default:
return Error(InvalidValue); return Error(InvalidValue);
@ -792,7 +792,7 @@ error_code BitcodeReader::ParseTypeTableBody() {
if (Record.size() == 2) if (Record.size() == 2)
AddressSpace = Record[1]; AddressSpace = Record[1];
ResultTy = getTypeByID(Record[0]); ResultTy = getTypeByID(Record[0]);
if (ResultTy == 0) if (!ResultTy)
return Error(InvalidType); return Error(InvalidType);
ResultTy = PointerType::get(ResultTy, AddressSpace); ResultTy = PointerType::get(ResultTy, AddressSpace);
break; break;
@ -811,7 +811,7 @@ error_code BitcodeReader::ParseTypeTableBody() {
} }
ResultTy = getTypeByID(Record[2]); ResultTy = getTypeByID(Record[2]);
if (ResultTy == 0 || ArgTys.size() < Record.size()-3) if (!ResultTy || ArgTys.size() < Record.size()-3)
return Error(InvalidType); return Error(InvalidType);
ResultTy = FunctionType::get(ResultTy, ArgTys, Record[0]); ResultTy = FunctionType::get(ResultTy, ArgTys, Record[0]);
@ -830,7 +830,7 @@ error_code BitcodeReader::ParseTypeTableBody() {
} }
ResultTy = getTypeByID(Record[1]); ResultTy = getTypeByID(Record[1]);
if (ResultTy == 0 || ArgTys.size() < Record.size()-2) if (!ResultTy || ArgTys.size() < Record.size()-2)
return Error(InvalidType); return Error(InvalidType);
ResultTy = FunctionType::get(ResultTy, ArgTys, Record[0]); ResultTy = FunctionType::get(ResultTy, ArgTys, Record[0]);
@ -867,7 +867,7 @@ error_code BitcodeReader::ParseTypeTableBody() {
StructType *Res = cast_or_null<StructType>(TypeList[NumRecords]); StructType *Res = cast_or_null<StructType>(TypeList[NumRecords]);
if (Res) { if (Res) {
Res->setName(TypeName); Res->setName(TypeName);
TypeList[NumRecords] = 0; TypeList[NumRecords] = nullptr;
} else // Otherwise, create a new struct. } else // Otherwise, create a new struct.
Res = StructType::create(Context, TypeName); Res = StructType::create(Context, TypeName);
TypeName.clear(); TypeName.clear();
@ -896,7 +896,7 @@ error_code BitcodeReader::ParseTypeTableBody() {
StructType *Res = cast_or_null<StructType>(TypeList[NumRecords]); StructType *Res = cast_or_null<StructType>(TypeList[NumRecords]);
if (Res) { if (Res) {
Res->setName(TypeName); Res->setName(TypeName);
TypeList[NumRecords] = 0; TypeList[NumRecords] = nullptr;
} else // Otherwise, create a new struct with no body. } else // Otherwise, create a new struct with no body.
Res = StructType::create(Context, TypeName); Res = StructType::create(Context, TypeName);
TypeName.clear(); TypeName.clear();
@ -924,7 +924,7 @@ error_code BitcodeReader::ParseTypeTableBody() {
if (NumRecords >= TypeList.size()) if (NumRecords >= TypeList.size())
return Error(InvalidTYPETable); return Error(InvalidTYPETable);
assert(ResultTy && "Didn't read a type?"); assert(ResultTy && "Didn't read a type?");
assert(TypeList[NumRecords] == 0 && "Already read type?"); assert(!TypeList[NumRecords] && "Already read type?");
TypeList[NumRecords++] = ResultTy; TypeList[NumRecords++] = ResultTy;
} }
} }
@ -972,7 +972,7 @@ error_code BitcodeReader::ParseValueSymbolTable() {
if (ConvertToString(Record, 1, ValueName)) if (ConvertToString(Record, 1, ValueName))
return Error(InvalidRecord); return Error(InvalidRecord);
BasicBlock *BB = getBasicBlock(Record[0]); BasicBlock *BB = getBasicBlock(Record[0]);
if (BB == 0) if (!BB)
return Error(InvalidRecord); return Error(InvalidRecord);
BB->setName(StringRef(ValueName.data(), ValueName.size())); BB->setName(StringRef(ValueName.data(), ValueName.size()));
@ -1028,7 +1028,7 @@ error_code BitcodeReader::ParseMetadata() {
NamedMDNode *NMD = TheModule->getOrInsertNamedMetadata(Name); NamedMDNode *NMD = TheModule->getOrInsertNamedMetadata(Name);
for (unsigned i = 0; i != Size; ++i) { for (unsigned i = 0; i != Size; ++i) {
MDNode *MD = dyn_cast_or_null<MDNode>(MDValueList.getValueFwdRef(Record[i])); MDNode *MD = dyn_cast_or_null<MDNode>(MDValueList.getValueFwdRef(Record[i]));
if (MD == 0) if (!MD)
return Error(InvalidRecord); return Error(InvalidRecord);
NMD->addOperand(MD); NMD->addOperand(MD);
} }
@ -1052,7 +1052,7 @@ error_code BitcodeReader::ParseMetadata() {
else if (!Ty->isVoidTy()) else if (!Ty->isVoidTy())
Elts.push_back(ValueList.getValueFwdRef(Record[i+1], Ty)); Elts.push_back(ValueList.getValueFwdRef(Record[i+1], Ty));
else else
Elts.push_back(NULL); Elts.push_back(nullptr);
} }
Value *V = MDNode::getWhenValsUnresolved(Context, Elts, IsFunctionLocal); Value *V = MDNode::getWhenValsUnresolved(Context, Elts, IsFunctionLocal);
IsFunctionLocal = false; IsFunctionLocal = false;
@ -1185,7 +1185,7 @@ error_code BitcodeReader::ParseConstants() {
// Read a record. // Read a record.
Record.clear(); Record.clear();
Value *V = 0; Value *V = nullptr;
unsigned BitCode = Stream.readRecord(Entry.ID, Record); unsigned BitCode = Stream.readRecord(Entry.ID, Record);
switch (BitCode) { switch (BitCode) {
default: // Default behavior: unknown constant default: // Default behavior: unknown constant
@ -1423,7 +1423,7 @@ error_code BitcodeReader::ParseConstants() {
return Error(InvalidRecord); return Error(InvalidRecord);
VectorType *OpTy = VectorType *OpTy =
dyn_cast_or_null<VectorType>(getTypeByID(Record[0])); dyn_cast_or_null<VectorType>(getTypeByID(Record[0]));
if (OpTy == 0) if (!OpTy)
return Error(InvalidRecord); return Error(InvalidRecord);
Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy); Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy);
Constant *Op1 = ValueList.getConstantFwdRef(Record[2], Constant *Op1 = ValueList.getConstantFwdRef(Record[2],
@ -1433,7 +1433,7 @@ error_code BitcodeReader::ParseConstants() {
} }
case bitc::CST_CODE_CE_INSERTELT: { // CE_INSERTELT: [opval, opval, opval] case bitc::CST_CODE_CE_INSERTELT: { // CE_INSERTELT: [opval, opval, opval]
VectorType *OpTy = dyn_cast<VectorType>(CurTy); VectorType *OpTy = dyn_cast<VectorType>(CurTy);
if (Record.size() < 3 || OpTy == 0) if (Record.size() < 3 || !OpTy)
return Error(InvalidRecord); return Error(InvalidRecord);
Constant *Op0 = ValueList.getConstantFwdRef(Record[0], OpTy); Constant *Op0 = ValueList.getConstantFwdRef(Record[0], OpTy);
Constant *Op1 = ValueList.getConstantFwdRef(Record[1], Constant *Op1 = ValueList.getConstantFwdRef(Record[1],
@ -1445,7 +1445,7 @@ error_code BitcodeReader::ParseConstants() {
} }
case bitc::CST_CODE_CE_SHUFFLEVEC: { // CE_SHUFFLEVEC: [opval, opval, opval] case bitc::CST_CODE_CE_SHUFFLEVEC: { // CE_SHUFFLEVEC: [opval, opval, opval]
VectorType *OpTy = dyn_cast<VectorType>(CurTy); VectorType *OpTy = dyn_cast<VectorType>(CurTy);
if (Record.size() < 3 || OpTy == 0) if (Record.size() < 3 || !OpTy)
return Error(InvalidRecord); return Error(InvalidRecord);
Constant *Op0 = ValueList.getConstantFwdRef(Record[0], OpTy); Constant *Op0 = ValueList.getConstantFwdRef(Record[0], OpTy);
Constant *Op1 = ValueList.getConstantFwdRef(Record[1], OpTy); Constant *Op1 = ValueList.getConstantFwdRef(Record[1], OpTy);
@ -1459,7 +1459,7 @@ error_code BitcodeReader::ParseConstants() {
VectorType *RTy = dyn_cast<VectorType>(CurTy); VectorType *RTy = dyn_cast<VectorType>(CurTy);
VectorType *OpTy = VectorType *OpTy =
dyn_cast_or_null<VectorType>(getTypeByID(Record[0])); 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); return Error(InvalidRecord);
Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy); Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy);
Constant *Op1 = ValueList.getConstantFwdRef(Record[2], OpTy); Constant *Op1 = ValueList.getConstantFwdRef(Record[2], OpTy);
@ -1473,7 +1473,7 @@ error_code BitcodeReader::ParseConstants() {
if (Record.size() < 4) if (Record.size() < 4)
return Error(InvalidRecord); return Error(InvalidRecord);
Type *OpTy = getTypeByID(Record[0]); Type *OpTy = getTypeByID(Record[0]);
if (OpTy == 0) if (!OpTy)
return Error(InvalidRecord); return Error(InvalidRecord);
Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy); Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy);
Constant *Op1 = ValueList.getConstantFwdRef(Record[2], OpTy); Constant *Op1 = ValueList.getConstantFwdRef(Record[2], OpTy);
@ -1538,11 +1538,11 @@ error_code BitcodeReader::ParseConstants() {
if (Record.size() < 3) if (Record.size() < 3)
return Error(InvalidRecord); return Error(InvalidRecord);
Type *FnTy = getTypeByID(Record[0]); Type *FnTy = getTypeByID(Record[0]);
if (FnTy == 0) if (!FnTy)
return Error(InvalidRecord); return Error(InvalidRecord);
Function *Fn = Function *Fn =
dyn_cast_or_null<Function>(ValueList.getConstantFwdRef(Record[1],FnTy)); dyn_cast_or_null<Function>(ValueList.getConstantFwdRef(Record[1],FnTy));
if (Fn == 0) if (!Fn)
return Error(InvalidRecord); return Error(InvalidRecord);
// If the function is already parsed we can insert the block address right // If the function is already parsed we can insert the block address right
@ -1561,7 +1561,7 @@ error_code BitcodeReader::ParseConstants() {
GlobalVariable *FwdRef = new GlobalVariable(*Fn->getParent(), GlobalVariable *FwdRef = new GlobalVariable(*Fn->getParent(),
Type::getInt8Ty(Context), Type::getInt8Ty(Context),
false, GlobalValue::InternalLinkage, false, GlobalValue::InternalLinkage,
0, ""); nullptr, "");
BlockAddrFwdRefs[Fn].push_back(std::make_pair(Record[2], FwdRef)); BlockAddrFwdRefs[Fn].push_back(std::make_pair(Record[2], FwdRef));
V = FwdRef; V = FwdRef;
} }
@ -1854,7 +1854,7 @@ error_code BitcodeReader::ParseModule(bool Resume) {
ExternallyInitialized = Record[9]; ExternallyInitialized = Record[9];
GlobalVariable *NewGV = GlobalVariable *NewGV =
new GlobalVariable(*TheModule, Ty, isConstant, Linkage, 0, "", 0, new GlobalVariable(*TheModule, Ty, isConstant, Linkage, nullptr, "", nullptr,
TLM, AddressSpace, ExternallyInitialized); TLM, AddressSpace, ExternallyInitialized);
NewGV->setAlignment(Alignment); NewGV->setAlignment(Alignment);
if (!Section.empty()) if (!Section.empty())
@ -1944,7 +1944,7 @@ error_code BitcodeReader::ParseModule(bool Resume) {
return Error(InvalidTypeForValue); return Error(InvalidTypeForValue);
GlobalAlias *NewGA = new GlobalAlias(Ty, GetDecodedLinkage(Record[2]), GlobalAlias *NewGA = new GlobalAlias(Ty, GetDecodedLinkage(Record[2]),
"", 0, TheModule); "", nullptr, TheModule);
// Old bitcode files didn't have visibility field. // Old bitcode files didn't have visibility field.
if (Record.size() > 3) if (Record.size() > 3)
NewGA->setVisibility(GetDecodedVisibility(Record[3])); NewGA->setVisibility(GetDecodedVisibility(Record[3]));
@ -1969,7 +1969,7 @@ error_code BitcodeReader::ParseModule(bool Resume) {
} }
error_code BitcodeReader::ParseBitcodeInto(Module *M) { error_code BitcodeReader::ParseBitcodeInto(Module *M) {
TheModule = 0; TheModule = nullptr;
if (error_code EC = InitStream()) if (error_code EC = InitStream())
return EC; return EC;
@ -2173,7 +2173,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
ValueList.push_back(I); ValueList.push_back(I);
unsigned NextValueNo = ValueList.size(); unsigned NextValueNo = ValueList.size();
BasicBlock *CurBB = 0; BasicBlock *CurBB = nullptr;
unsigned CurBBNo = 0; unsigned CurBBNo = 0;
DebugLoc LastLoc; DebugLoc LastLoc;
@ -2222,7 +2222,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
// Read a record. // Read a record.
Record.clear(); Record.clear();
Instruction *I = 0; Instruction *I = nullptr;
unsigned BitCode = Stream.readRecord(Entry.ID, Record); unsigned BitCode = Stream.readRecord(Entry.ID, Record);
switch (BitCode) { switch (BitCode) {
default: // Default behavior: reject default: // Default behavior: reject
@ -2240,7 +2240,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
case bitc::FUNC_CODE_DEBUG_LOC_AGAIN: // DEBUG_LOC_AGAIN case bitc::FUNC_CODE_DEBUG_LOC_AGAIN: // DEBUG_LOC_AGAIN
// This record indicates that the last instruction is at the same // This record indicates that the last instruction is at the same
// location as the previous instruction with a location. // location as the previous instruction with a location.
I = 0; I = nullptr;
// Get the last instruction emitted. // Get the last instruction emitted.
if (CurBB && !CurBB->empty()) if (CurBB && !CurBB->empty())
@ -2249,31 +2249,31 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
!FunctionBBs[CurBBNo-1]->empty()) !FunctionBBs[CurBBNo-1]->empty())
I = &FunctionBBs[CurBBNo-1]->back(); I = &FunctionBBs[CurBBNo-1]->back();
if (I == 0) if (!I)
return Error(InvalidRecord); return Error(InvalidRecord);
I->setDebugLoc(LastLoc); I->setDebugLoc(LastLoc);
I = 0; I = nullptr;
continue; continue;
case bitc::FUNC_CODE_DEBUG_LOC: { // DEBUG_LOC: [line, col, scope, ia] 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()) if (CurBB && !CurBB->empty())
I = &CurBB->back(); I = &CurBB->back();
else if (CurBBNo && FunctionBBs[CurBBNo-1] && else if (CurBBNo && FunctionBBs[CurBBNo-1] &&
!FunctionBBs[CurBBNo-1]->empty()) !FunctionBBs[CurBBNo-1]->empty())
I = &FunctionBBs[CurBBNo-1]->back(); I = &FunctionBBs[CurBBNo-1]->back();
if (I == 0 || Record.size() < 4) if (!I || Record.size() < 4)
return Error(InvalidRecord); return Error(InvalidRecord);
unsigned Line = Record[0], Col = Record[1]; unsigned Line = Record[0], Col = Record[1];
unsigned ScopeID = Record[2], IAID = Record[3]; 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 (ScopeID) Scope = cast<MDNode>(MDValueList.getValueFwdRef(ScopeID-1));
if (IAID) IA = cast<MDNode>(MDValueList.getValueFwdRef(IAID-1)); if (IAID) IA = cast<MDNode>(MDValueList.getValueFwdRef(IAID-1));
LastLoc = DebugLoc::get(Line, Col, Scope, IA); LastLoc = DebugLoc::get(Line, Col, Scope, IA);
I->setDebugLoc(LastLoc); I->setDebugLoc(LastLoc);
I = 0; I = nullptr;
continue; continue;
} }
@ -2333,9 +2333,9 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
Type *ResTy = getTypeByID(Record[OpNum]); Type *ResTy = getTypeByID(Record[OpNum]);
int Opc = GetDecodedCastOpcode(Record[OpNum+1]); int Opc = GetDecodedCastOpcode(Record[OpNum+1]);
if (Opc == -1 || ResTy == 0) if (Opc == -1 || !ResTy)
return Error(InvalidRecord); return Error(InvalidRecord);
Instruction *Temp = 0; Instruction *Temp = nullptr;
if ((I = UpgradeBitCastInst(Opc, Op, ResTy, Temp))) { if ((I = UpgradeBitCastInst(Opc, Op, ResTy, Temp))) {
if (Temp) { if (Temp) {
InstructionList.push_back(Temp); InstructionList.push_back(Temp);
@ -2526,7 +2526,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
} }
unsigned OpNum = 0; unsigned OpNum = 0;
Value *Op = NULL; Value *Op = nullptr;
if (getValueTypePair(Record, OpNum, NextValueNo, Op)) if (getValueTypePair(Record, OpNum, NextValueNo, Op))
return Error(InvalidRecord); return Error(InvalidRecord);
if (OpNum != Record.size()) if (OpNum != Record.size())
@ -2540,7 +2540,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
if (Record.size() != 1 && Record.size() != 3) if (Record.size() != 1 && Record.size() != 3)
return Error(InvalidRecord); return Error(InvalidRecord);
BasicBlock *TrueDest = getBasicBlock(Record[0]); BasicBlock *TrueDest = getBasicBlock(Record[0]);
if (TrueDest == 0) if (!TrueDest)
return Error(InvalidRecord); return Error(InvalidRecord);
if (Record.size() == 1) { if (Record.size() == 1) {
@ -2551,7 +2551,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
BasicBlock *FalseDest = getBasicBlock(Record[1]); BasicBlock *FalseDest = getBasicBlock(Record[1]);
Value *Cond = getValue(Record, 2, NextValueNo, Value *Cond = getValue(Record, 2, NextValueNo,
Type::getInt1Ty(Context)); Type::getInt1Ty(Context));
if (FalseDest == 0 || Cond == 0) if (!FalseDest || !Cond)
return Error(InvalidRecord); return Error(InvalidRecord);
I = BranchInst::Create(TrueDest, FalseDest, Cond); I = BranchInst::Create(TrueDest, FalseDest, Cond);
InstructionList.push_back(I); InstructionList.push_back(I);
@ -2571,7 +2571,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
Value *Cond = getValue(Record, 2, NextValueNo, OpTy); Value *Cond = getValue(Record, 2, NextValueNo, OpTy);
BasicBlock *Default = getBasicBlock(Record[3]); BasicBlock *Default = getBasicBlock(Record[3]);
if (OpTy == 0 || Cond == 0 || Default == 0) if (!OpTy || !Cond || !Default)
return Error(InvalidRecord); return Error(InvalidRecord);
unsigned NumCases = Record[4]; unsigned NumCases = Record[4];
@ -2628,7 +2628,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
Type *OpTy = getTypeByID(Record[0]); Type *OpTy = getTypeByID(Record[0]);
Value *Cond = getValue(Record, 1, NextValueNo, OpTy); Value *Cond = getValue(Record, 1, NextValueNo, OpTy);
BasicBlock *Default = getBasicBlock(Record[2]); BasicBlock *Default = getBasicBlock(Record[2]);
if (OpTy == 0 || Cond == 0 || Default == 0) if (!OpTy || !Cond || !Default)
return Error(InvalidRecord); return Error(InvalidRecord);
unsigned NumCases = (Record.size()-3)/2; unsigned NumCases = (Record.size()-3)/2;
SwitchInst *SI = SwitchInst::Create(Cond, Default, NumCases); SwitchInst *SI = SwitchInst::Create(Cond, Default, NumCases);
@ -2637,7 +2637,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
ConstantInt *CaseVal = ConstantInt *CaseVal =
dyn_cast_or_null<ConstantInt>(getFnValueByID(Record[3+i*2], OpTy)); dyn_cast_or_null<ConstantInt>(getFnValueByID(Record[3+i*2], OpTy));
BasicBlock *DestBB = getBasicBlock(Record[1+3+i*2]); BasicBlock *DestBB = getBasicBlock(Record[1+3+i*2]);
if (CaseVal == 0 || DestBB == 0) { if (!CaseVal || !DestBB) {
delete SI; delete SI;
return Error(InvalidRecord); return Error(InvalidRecord);
} }
@ -2651,7 +2651,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
return Error(InvalidRecord); return Error(InvalidRecord);
Type *OpTy = getTypeByID(Record[0]); Type *OpTy = getTypeByID(Record[0]);
Value *Address = getValue(Record, 1, NextValueNo, OpTy); Value *Address = getValue(Record, 1, NextValueNo, OpTy);
if (OpTy == 0 || Address == 0) if (!OpTy || !Address)
return Error(InvalidRecord); return Error(InvalidRecord);
unsigned NumDests = Record.size()-2; unsigned NumDests = Record.size()-2;
IndirectBrInst *IBI = IndirectBrInst::Create(Address, NumDests); IndirectBrInst *IBI = IndirectBrInst::Create(Address, NumDests);
@ -2683,11 +2683,11 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
return Error(InvalidRecord); return Error(InvalidRecord);
PointerType *CalleeTy = dyn_cast<PointerType>(Callee->getType()); PointerType *CalleeTy = dyn_cast<PointerType>(Callee->getType());
FunctionType *FTy = !CalleeTy ? 0 : FunctionType *FTy = !CalleeTy ? nullptr :
dyn_cast<FunctionType>(CalleeTy->getElementType()); dyn_cast<FunctionType>(CalleeTy->getElementType());
// Check that the right number of fixed parameters are here. // 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()) Record.size() < OpNum+FTy->getNumParams())
return Error(InvalidRecord); return Error(InvalidRecord);
@ -2695,7 +2695,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i, ++OpNum) { for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i, ++OpNum) {
Ops.push_back(getValue(Record, OpNum, NextValueNo, Ops.push_back(getValue(Record, OpNum, NextValueNo,
FTy->getParamType(i))); FTy->getParamType(i)));
if (Ops.back() == 0) if (!Ops.back())
return Error(InvalidRecord); return Error(InvalidRecord);
} }
@ -2721,7 +2721,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
} }
case bitc::FUNC_CODE_INST_RESUME: { // RESUME: [opval] case bitc::FUNC_CODE_INST_RESUME: { // RESUME: [opval]
unsigned Idx = 0; unsigned Idx = 0;
Value *Val = 0; Value *Val = nullptr;
if (getValueTypePair(Record, Idx, NextValueNo, Val)) if (getValueTypePair(Record, Idx, NextValueNo, Val))
return Error(InvalidRecord); return Error(InvalidRecord);
I = ResumeInst::Create(Val); I = ResumeInst::Create(Val);
@ -2768,7 +2768,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
Type *Ty = getTypeByID(Record[Idx++]); Type *Ty = getTypeByID(Record[Idx++]);
if (!Ty) if (!Ty)
return Error(InvalidRecord); return Error(InvalidRecord);
Value *PersFn = 0; Value *PersFn = nullptr;
if (getValueTypePair(Record, Idx, NextValueNo, PersFn)) if (getValueTypePair(Record, Idx, NextValueNo, PersFn))
return Error(InvalidRecord); return Error(InvalidRecord);
@ -2961,7 +2961,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
return Error(InvalidRecord); return Error(InvalidRecord);
PointerType *OpTy = dyn_cast<PointerType>(Callee->getType()); PointerType *OpTy = dyn_cast<PointerType>(Callee->getType());
FunctionType *FTy = 0; FunctionType *FTy = nullptr;
if (OpTy) FTy = dyn_cast<FunctionType>(OpTy->getElementType()); if (OpTy) FTy = dyn_cast<FunctionType>(OpTy->getElementType());
if (!FTy || Record.size() < FTy->getNumParams()+OpNum) if (!FTy || Record.size() < FTy->getNumParams()+OpNum)
return Error(InvalidRecord); return Error(InvalidRecord);
@ -2974,7 +2974,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
else else
Args.push_back(getValue(Record, OpNum, NextValueNo, Args.push_back(getValue(Record, OpNum, NextValueNo,
FTy->getParamType(i))); FTy->getParamType(i)));
if (Args.back() == 0) if (!Args.back())
return Error(InvalidRecord); return Error(InvalidRecord);
} }
@ -3015,7 +3015,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
// Add instruction to end of current BB. If there is no current BB, reject // Add instruction to end of current BB. If there is no current BB, reject
// this file. // this file.
if (CurBB == 0) { if (!CurBB) {
delete I; delete I;
return Error(InvalidInstructionWithNoBB); return Error(InvalidInstructionWithNoBB);
} }
@ -3024,7 +3024,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
// If this was a terminator instruction, move to the next block. // If this was a terminator instruction, move to the next block.
if (isa<TerminatorInst>(I)) { if (isa<TerminatorInst>(I)) {
++CurBBNo; ++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. // Non-void values get registered in the value table for future use.
@ -3036,10 +3036,10 @@ OutOfRecordLoop:
// Check the function list for unresolved values. // Check the function list for unresolved values.
if (Argument *A = dyn_cast<Argument>(ValueList.back())) { 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. // We found at least one unresolved value. Nuke them all to avoid leaks.
for (unsigned i = ModuleValueListSize, e = ValueList.size(); i != e; ++i){ 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())); A->replaceAllUsesWith(UndefValue::get(A->getType()));
delete A; delete A;
} }
@ -3348,7 +3348,7 @@ Module *llvm::getStreamedBitcodeModule(const std::string &name,
if (ErrMsg) if (ErrMsg)
*ErrMsg = EC.message(); *ErrMsg = EC.message();
delete M; // Also deletes R. delete M; // Also deletes R.
return 0; return nullptr;
} }
R->setBufferOwned(false); // no buffer to delete R->setBufferOwned(false); // no buffer to delete
return M; return M;

View File

@ -315,7 +315,7 @@ bool BitstreamCursor::ReadBlockInfoBlock() {
if (EnterSubBlock(bitc::BLOCKINFO_BLOCK_ID)) return true; if (EnterSubBlock(bitc::BLOCKINFO_BLOCK_ID)) return true;
SmallVector<uint64_t, 64> Record; SmallVector<uint64_t, 64> Record;
BitstreamReader::BlockInfo *CurBlockInfo = 0; BitstreamReader::BlockInfo *CurBlockInfo = nullptr;
// Read all the records for this module. // Read all the records for this module.
while (1) { while (1) {

View File

@ -917,7 +917,7 @@ static void WriteConstants(unsigned FirstVal, unsigned LastVal,
SmallVector<uint64_t, 64> Record; SmallVector<uint64_t, 64> Record;
const ValueEnumerator::ValueList &Vals = VE.getValues(); const ValueEnumerator::ValueList &Vals = VE.getValues();
Type *LastTy = 0; Type *LastTy = nullptr;
for (unsigned i = FirstVal; i != LastVal; ++i) { for (unsigned i = FirstVal; i != LastVal; ++i) {
const Value *V = Vals[i].first; const Value *V = Vals[i].first;
// If we need to switch types, do so now. // If we need to switch types, do so now.

View File

@ -290,7 +290,7 @@ DWARFContext::getLineTableForCompileUnit(DWARFCompileUnit *cu) {
cu->getCompileUnitDIE()->getAttributeValueAsSectionOffset( cu->getCompileUnitDIE()->getAttributeValueAsSectionOffset(
cu, DW_AT_stmt_list, -1U); cu, DW_AT_stmt_list, -1U);
if (stmtOffset == -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. // See if the line table is cached.
if (const DWARFLineTable *lt = Line->getLineTable(stmtOffset)) if (const DWARFLineTable *lt = Line->getLineTable(stmtOffset))
@ -408,7 +408,7 @@ DWARFCompileUnit *DWARFContext::getCompileUnitForOffset(uint32_t Offset) {
if (CU != CUs.end()) { if (CU != CUs.end()) {
return CU->get(); return CU->get();
} }
return 0; return nullptr;
} }
DWARFCompileUnit *DWARFContext::getCompileUnitForAddress(uint64_t Address) { DWARFCompileUnit *DWARFContext::getCompileUnitForAddress(uint64_t Address) {
@ -423,8 +423,7 @@ static bool getFileNameForCompileUnit(DWARFCompileUnit *CU,
uint64_t FileIndex, uint64_t FileIndex,
bool NeedsAbsoluteFilePath, bool NeedsAbsoluteFilePath,
std::string &FileName) { std::string &FileName) {
if (CU == 0 || if (!CU || !LineTable ||
LineTable == 0 ||
!LineTable->getFileNameByIndex(FileIndex, NeedsAbsoluteFilePath, !LineTable->getFileNameByIndex(FileIndex, NeedsAbsoluteFilePath,
FileName)) FileName))
return false; return false;
@ -446,7 +445,7 @@ static bool getFileLineInfoForCompileUnit(DWARFCompileUnit *CU,
bool NeedsAbsoluteFilePath, bool NeedsAbsoluteFilePath,
std::string &FileName, std::string &FileName,
uint32_t &Line, uint32_t &Column) { uint32_t &Line, uint32_t &Column) {
if (CU == 0 || LineTable == 0) if (!CU || !LineTable)
return false; return false;
// Get the index of row we're looking for in the line table. // Get the index of row we're looking for in the line table.
uint32_t RowIndex = LineTable->lookupAddress(Address); uint32_t RowIndex = LineTable->lookupAddress(Address);
@ -560,7 +559,7 @@ DIInliningInfo DWARFContext::getInliningInfoForAddress(uint64_t Address,
DIInliningInfo InliningInfo; DIInliningInfo InliningInfo;
uint32_t CallFile = 0, CallLine = 0, CallColumn = 0; 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++) { for (uint32_t i = 0, n = InlinedChain.DIEs.size(); i != n; i++) {
const DWARFDebugInfoEntryMinimal &FunctionDIE = InlinedChain.DIEs[i]; const DWARFDebugInfoEntryMinimal &FunctionDIE = InlinedChain.DIEs[i];
std::string FileName = "<invalid>"; std::string FileName = "<invalid>";
@ -670,7 +669,7 @@ DWARFContextInMemory::DWARFContextInMemory(object::ObjectFile *Obj)
.Case("debug_str_offsets.dwo", &StringOffsetDWOSection) .Case("debug_str_offsets.dwo", &StringOffsetDWOSection)
.Case("debug_addr", &AddrSection) .Case("debug_addr", &AddrSection)
// Any more debug info sections go here. // Any more debug info sections go here.
.Default(0); .Default(nullptr);
if (SectionData) { if (SectionData) {
*SectionData = data; *SectionData = data;
if (name == "debug_ranges") { if (name == "debug_ranges") {
@ -701,7 +700,7 @@ DWARFContextInMemory::DWARFContextInMemory(object::ObjectFile *Obj)
.Case("debug_loc", &LocSection.Relocs) .Case("debug_loc", &LocSection.Relocs)
.Case("debug_info.dwo", &InfoDWOSection.Relocs) .Case("debug_info.dwo", &InfoDWOSection.Relocs)
.Case("debug_line", &LineSection.Relocs) .Case("debug_line", &LineSection.Relocs)
.Default(0); .Default(nullptr);
if (!Map) { if (!Map) {
// Find debug_types relocs by section rather than name as there are // Find debug_types relocs by section rather than name as there are
// multiple, comdat grouped, debug_types sections. // multiple, comdat grouped, debug_types sections.

View File

@ -50,7 +50,7 @@ DWARFAbbreviationDeclarationSet::getAbbreviationDeclaration(uint32_t abbrCode)
if (idx < Decls.size()) if (idx < Decls.size())
return &Decls[idx]; return &Decls[idx];
} }
return NULL; return nullptr;
} }
DWARFDebugAbbrev::DWARFDebugAbbrev() : DWARFDebugAbbrev::DWARFDebugAbbrev() :
@ -99,5 +99,5 @@ DWARFDebugAbbrev::getAbbreviationDeclarationSet(uint64_t cu_abbr_offset) const {
if (pos != AbbrevCollMap.end()) if (pos != AbbrevCollMap.end())
return &(pos->second); return &(pos->second);
return NULL; return nullptr;
} }

View File

@ -251,7 +251,7 @@ public:
int64_t LinkedCIEOffset, uint64_t InitialLocation, uint64_t AddressRange) int64_t LinkedCIEOffset, uint64_t InitialLocation, uint64_t AddressRange)
: FrameEntry(FK_FDE, D, Offset, Length), LinkedCIEOffset(LinkedCIEOffset), : FrameEntry(FK_FDE, D, Offset, Length), LinkedCIEOffset(LinkedCIEOffset),
InitialLocation(InitialLocation), AddressRange(AddressRange), InitialLocation(InitialLocation), AddressRange(AddressRange),
LinkedCIE(NULL) {} LinkedCIE(nullptr) {}
~FDE() { ~FDE() {
} }
@ -334,7 +334,7 @@ void DWARFDebugFrame::parse(DataExtractor Data) {
Id = Data.getUnsigned(&Offset, IsDWARF64 ? 8 : 4); Id = Data.getUnsigned(&Offset, IsDWARF64 ? 8 : 4);
bool IsCIE = ((IsDWARF64 && Id == DW64_CIE_ID) || Id == DW_CIE_ID); bool IsCIE = ((IsDWARF64 && Id == DW64_CIE_ID) || Id == DW_CIE_ID);
FrameEntry *Entry = 0; FrameEntry *Entry = nullptr;
if (IsCIE) { if (IsCIE) {
// Note: this is specifically DWARFv3 CIE header structure. It was // Note: this is specifically DWARFv3 CIE header structure. It was
// changed in DWARFv4. We currently don't support reading DWARFv4 // changed in DWARFv4. We currently don't support reading DWARFv4

View File

@ -99,11 +99,11 @@ bool DWARFDebugInfoEntryMinimal::extractFast(const DWARFUnit *U,
uint64_t AbbrCode = DebugInfoData.getULEB128(OffsetPtr); uint64_t AbbrCode = DebugInfoData.getULEB128(OffsetPtr);
if (0 == AbbrCode) { if (0 == AbbrCode) {
// NULL debug tag entry. // NULL debug tag entry.
AbbrevDecl = NULL; AbbrevDecl = nullptr;
return true; return true;
} }
AbbrevDecl = U->getAbbreviations()->getAbbreviationDeclaration(AbbrCode); AbbrevDecl = U->getAbbreviations()->getAbbreviationDeclaration(AbbrCode);
if (0 == AbbrevDecl) { if (nullptr == AbbrevDecl) {
// Restore the original offset. // Restore the original offset.
*OffsetPtr = Offset; *OffsetPtr = Offset;
return false; return false;
@ -266,14 +266,15 @@ bool DWARFDebugInfoEntryMinimal::addressRangeContainsAddress(
const char * const char *
DWARFDebugInfoEntryMinimal::getSubroutineName(const DWARFUnit *U) const { DWARFDebugInfoEntryMinimal::getSubroutineName(const DWARFUnit *U) const {
if (!isSubroutineDIE()) if (!isSubroutineDIE())
return 0; return nullptr;
// Try to get mangled name if possible. // Try to get mangled name if possible.
if (const char *name = if (const char *name =
getAttributeValueAsString(U, DW_AT_MIPS_linkage_name, 0)) getAttributeValueAsString(U, DW_AT_MIPS_linkage_name, nullptr))
return name; 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; return name;
if (const char *name = getAttributeValueAsString(U, DW_AT_name, 0)) if (const char *name = getAttributeValueAsString(U, DW_AT_name, nullptr))
return name; return name;
// Try to get name from specification DIE. // Try to get name from specification DIE.
uint32_t spec_ref = uint32_t spec_ref =
@ -295,7 +296,7 @@ DWARFDebugInfoEntryMinimal::getSubroutineName(const DWARFUnit *U) const {
return name; return name;
} }
} }
return 0; return nullptr;
} }
void DWARFDebugInfoEntryMinimal::getCallerFrame(const DWARFUnit *U, void DWARFDebugInfoEntryMinimal::getCallerFrame(const DWARFUnit *U,

View File

@ -147,7 +147,7 @@ DWARFDebugLine::getLineTable(uint32_t offset) const {
LineTableConstIter pos = LineTableMap.find(offset); LineTableConstIter pos = LineTableMap.find(offset);
if (pos != LineTableMap.end()) if (pos != LineTableMap.end())
return &pos->second; return &pos->second;
return 0; return nullptr;
} }
const DWARFDebugLine::LineTable * const DWARFDebugLine::LineTable *
@ -159,7 +159,7 @@ DWARFDebugLine::getOrParseLineTable(DataExtractor debug_line_data,
// Parse and cache the line table for at this offset. // Parse and cache the line table for at this offset.
State state; State state;
if (!parseStatementTable(debug_line_data, RelocMap, &offset, state)) if (!parseStatementTable(debug_line_data, RelocMap, &offset, state))
return 0; return nullptr;
pos.first->second = state; pos.first->second = state;
} }
return &pos.first->second; return &pos.first->second;

View File

@ -131,7 +131,7 @@ bool DWARFFormValue::extractValue(DataExtractor data, uint32_t *offset_ptr,
const DWARFUnit *cu) { const DWARFUnit *cu) {
bool indirect = false; bool indirect = false;
bool is_block = 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 // Read the value for the form into value and follow and DW_FORM_indirect
// instances we run into // instances we run into
do { do {
@ -241,7 +241,7 @@ bool DWARFFormValue::extractValue(DataExtractor data, uint32_t *offset_ptr,
if (is_block) { if (is_block) {
StringRef str = data.getData().substr(*offset_ptr, Value.uval); StringRef str = data.getData().substr(*offset_ptr, Value.uval);
Value.data = NULL; Value.data = nullptr;
if (!str.empty()) { if (!str.empty()) {
Value.data = reinterpret_cast<const uint8_t *>(str.data()); Value.data = reinterpret_cast<const uint8_t *>(str.data());
*offset_ptr += Value.uval; *offset_ptr += Value.uval;
@ -488,7 +488,7 @@ Optional<const char *> DWARFFormValue::getAsCString(const DWARFUnit *U) const {
return None; return None;
if (Form == DW_FORM_string) if (Form == DW_FORM_string)
return Value.cstr; return Value.cstr;
if (U == 0) if (!U)
return None; return None;
uint32_t Offset = Value.uval; uint32_t Offset = Value.uval;
if (Form == DW_FORM_GNU_str_index) { if (Form == DW_FORM_GNU_str_index) {
@ -509,7 +509,7 @@ Optional<uint64_t> DWARFFormValue::getAsAddress(const DWARFUnit *U) const {
if (Form == DW_FORM_GNU_addr_index) { if (Form == DW_FORM_GNU_addr_index) {
uint32_t Index = Value.uval; uint32_t Index = Value.uval;
uint64_t Result; uint64_t Result;
if (U == 0 || !U->getAddrOffsetSectionItem(Index, Result)) if (!U || !U->getAddrOffsetSectionItem(Index, Result))
return None; return None;
return Result; return Result;
} }
@ -525,7 +525,7 @@ Optional<uint64_t> DWARFFormValue::getAsReference(const DWARFUnit *U) const {
case DW_FORM_ref4: case DW_FORM_ref4:
case DW_FORM_ref8: case DW_FORM_ref8:
case DW_FORM_ref_udata: case DW_FORM_ref_udata:
if (U == 0) if (!U)
return None; return None;
return Value.uval + U->getOffset(); return Value.uval + U->getOffset();
case DW_FORM_ref_addr: case DW_FORM_ref_addr:

View File

@ -98,7 +98,7 @@ void DWARFUnit::clear() {
Offset = 0; Offset = 0;
Length = 0; Length = 0;
Version = 0; Version = 0;
Abbrevs = 0; Abbrevs = nullptr;
AddrSize = 0; AddrSize = 0;
BaseAddr = 0; BaseAddr = 0;
RangeSectionBase = 0; RangeSectionBase = 0;
@ -110,8 +110,8 @@ void DWARFUnit::clear() {
const char *DWARFUnit::getCompilationDir() { const char *DWARFUnit::getCompilationDir() {
extractDIEsIfNeeded(true); extractDIEsIfNeeded(true);
if (DieArray.empty()) if (DieArray.empty())
return 0; return nullptr;
return DieArray[0].getAttributeValueAsString(this, DW_AT_comp_dir, 0); return DieArray[0].getAttributeValueAsString(this, DW_AT_comp_dir, nullptr);
} }
uint64_t DWARFUnit::getDWOId() { uint64_t DWARFUnit::getDWOId() {
@ -241,25 +241,25 @@ size_t DWARFUnit::extractDIEsIfNeeded(bool CUDieOnly) {
DWARFUnit::DWOHolder::DWOHolder(object::ObjectFile *DWOFile) DWARFUnit::DWOHolder::DWOHolder(object::ObjectFile *DWOFile)
: DWOFile(DWOFile), : DWOFile(DWOFile),
DWOContext(cast<DWARFContext>(DIContext::getDWARFContext(DWOFile))), DWOContext(cast<DWARFContext>(DIContext::getDWARFContext(DWOFile))),
DWOU(0) { DWOU(nullptr) {
if (DWOContext->getNumDWOCompileUnits() > 0) if (DWOContext->getNumDWOCompileUnits() > 0)
DWOU = DWOContext->getDWOCompileUnitAtIndex(0); DWOU = DWOContext->getDWOCompileUnitAtIndex(0);
} }
bool DWARFUnit::parseDWO() { bool DWARFUnit::parseDWO() {
if (DWO.get() != 0) if (DWO.get())
return false; return false;
extractDIEsIfNeeded(true); extractDIEsIfNeeded(true);
if (DieArray.empty()) if (DieArray.empty())
return false; return false;
const char *DWOFileName = const char *DWOFileName =
DieArray[0].getAttributeValueAsString(this, DW_AT_GNU_dwo_name, 0); DieArray[0].getAttributeValueAsString(this, DW_AT_GNU_dwo_name, nullptr);
if (DWOFileName == 0) if (!DWOFileName)
return false; return false;
const char *CompilationDir = const char *CompilationDir =
DieArray[0].getAttributeValueAsString(this, DW_AT_comp_dir, 0); DieArray[0].getAttributeValueAsString(this, DW_AT_comp_dir, nullptr);
SmallString<16> AbsolutePath; 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, CompilationDir);
} }
sys::path::append(AbsolutePath, DWOFileName); sys::path::append(AbsolutePath, DWOFileName);
@ -271,7 +271,7 @@ bool DWARFUnit::parseDWO() {
DWO.reset(new DWOHolder(DWOFile.get())); DWO.reset(new DWOHolder(DWOFile.get()));
DWARFUnit *DWOCU = DWO->getUnit(); DWARFUnit *DWOCU = DWO->getUnit();
// Verify that compile unit in .dwo file is valid. // Verify that compile unit in .dwo file is valid.
if (DWOCU == 0 || DWOCU->getDWOId() != getDWOId()) { if (!DWOCU || DWOCU->getDWOId() != getDWOId()) {
DWO.reset(); DWO.reset();
return false; return false;
} }
@ -337,14 +337,14 @@ DWARFUnit::getSubprogramForAddress(uint64_t Address) {
return &DIE; return &DIE;
} }
} }
return 0; return nullptr;
} }
DWARFDebugInfoEntryInlinedChain DWARFDebugInfoEntryInlinedChain
DWARFUnit::getInlinedChainForAddress(uint64_t Address) { DWARFUnit::getInlinedChainForAddress(uint64_t Address) {
// First, find a subprogram that contains the given address (the root // First, find a subprogram that contains the given address (the root
// of inlined chain). // of inlined chain).
const DWARFUnit *ChainCU = 0; const DWARFUnit *ChainCU = nullptr;
const DWARFDebugInfoEntryMinimal *SubprogramDIE = const DWARFDebugInfoEntryMinimal *SubprogramDIE =
getSubprogramForAddress(Address); getSubprogramForAddress(Address);
if (SubprogramDIE) { if (SubprogramDIE) {

View File

@ -50,19 +50,19 @@ ExecutionEngine *(*ExecutionEngine::JITCtor)(
std::string *ErrorStr, std::string *ErrorStr,
JITMemoryManager *JMM, JITMemoryManager *JMM,
bool GVsWithCode, bool GVsWithCode,
TargetMachine *TM) = 0; TargetMachine *TM) = nullptr;
ExecutionEngine *(*ExecutionEngine::MCJITCtor)( ExecutionEngine *(*ExecutionEngine::MCJITCtor)(
Module *M, Module *M,
std::string *ErrorStr, std::string *ErrorStr,
RTDyldMemoryManager *MCJMM, RTDyldMemoryManager *MCJMM,
bool GVsWithCode, bool GVsWithCode,
TargetMachine *TM) = 0; TargetMachine *TM) = nullptr;
ExecutionEngine *(*ExecutionEngine::InterpCtor)(Module *M, ExecutionEngine *(*ExecutionEngine::InterpCtor)(Module *M,
std::string *ErrorStr) = 0; std::string *ErrorStr) =nullptr;
ExecutionEngine::ExecutionEngine(Module *M) ExecutionEngine::ExecutionEngine(Module *M)
: EEState(*this), : EEState(*this),
LazyFunctionCreator(0) { LazyFunctionCreator(nullptr) {
CompilingLazily = false; CompilingLazily = false;
GVCompilationDisabled = false; GVCompilationDisabled = false;
SymbolSearchingDisabled = false; SymbolSearchingDisabled = false;
@ -129,7 +129,7 @@ Function *ExecutionEngine::FindFunctionNamed(const char *FnName) {
if (Function *F = Modules[i]->getFunction(FnName)) if (Function *F = Modules[i]->getFunction(FnName))
return F; return F;
} }
return 0; return nullptr;
} }
@ -141,7 +141,7 @@ void *ExecutionEngineState::RemoveMapping(const MutexGuard &,
// FIXME: This is silly, we shouldn't end up with a mapping -> 0 in the // FIXME: This is silly, we shouldn't end up with a mapping -> 0 in the
// GlobalAddressMap. // GlobalAddressMap.
if (I == GlobalAddressMap.end()) if (I == GlobalAddressMap.end())
OldVal = 0; OldVal = nullptr;
else { else {
OldVal = I->second; OldVal = I->second;
GlobalAddressMap.erase(I); GlobalAddressMap.erase(I);
@ -157,14 +157,14 @@ void ExecutionEngine::addGlobalMapping(const GlobalValue *GV, void *Addr) {
DEBUG(dbgs() << "JIT: Map \'" << GV->getName() DEBUG(dbgs() << "JIT: Map \'" << GV->getName()
<< "\' to [" << Addr << "]\n";); << "\' to [" << Addr << "]\n";);
void *&CurVal = EEState.getGlobalAddressMap(locked)[GV]; void *&CurVal = EEState.getGlobalAddressMap(locked)[GV];
assert((CurVal == 0 || Addr == 0) && "GlobalMapping already established!"); assert((!CurVal || !Addr) && "GlobalMapping already established!");
CurVal = Addr; CurVal = Addr;
// If we are using the reverse mapping, add it too. // If we are using the reverse mapping, add it too.
if (!EEState.getGlobalAddressReverseMap(locked).empty()) { if (!EEState.getGlobalAddressReverseMap(locked).empty()) {
AssertingVH<const GlobalValue> &V = AssertingVH<const GlobalValue> &V =
EEState.getGlobalAddressReverseMap(locked)[Addr]; EEState.getGlobalAddressReverseMap(locked)[Addr];
assert((V == 0 || GV == 0) && "GlobalMapping already established!"); assert((!V || !GV) && "GlobalMapping already established!");
V = GV; V = GV;
} }
} }
@ -193,7 +193,7 @@ void *ExecutionEngine::updateGlobalMapping(const GlobalValue *GV, void *Addr) {
EEState.getGlobalAddressMap(locked); EEState.getGlobalAddressMap(locked);
// Deleting from the mapping? // Deleting from the mapping?
if (Addr == 0) if (!Addr)
return EEState.RemoveMapping(locked, GV); return EEState.RemoveMapping(locked, GV);
void *&CurVal = Map[GV]; void *&CurVal = Map[GV];
@ -207,7 +207,7 @@ void *ExecutionEngine::updateGlobalMapping(const GlobalValue *GV, void *Addr) {
if (!EEState.getGlobalAddressReverseMap(locked).empty()) { if (!EEState.getGlobalAddressReverseMap(locked).empty()) {
AssertingVH<const GlobalValue> &V = AssertingVH<const GlobalValue> &V =
EEState.getGlobalAddressReverseMap(locked)[Addr]; EEState.getGlobalAddressReverseMap(locked)[Addr];
assert((V == 0 || GV == 0) && "GlobalMapping already established!"); assert((!V || !GV) && "GlobalMapping already established!");
V = GV; V = GV;
} }
return OldVal; return OldVal;
@ -218,7 +218,7 @@ void *ExecutionEngine::getPointerToGlobalIfAvailable(const GlobalValue *GV) {
ExecutionEngineState::GlobalAddressMapTy::iterator I = ExecutionEngineState::GlobalAddressMapTy::iterator I =
EEState.getGlobalAddressMap(locked).find(GV); 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) { const GlobalValue *ExecutionEngine::getGlobalValueAtAddress(void *Addr) {
@ -235,7 +235,7 @@ const GlobalValue *ExecutionEngine::getGlobalValueAtAddress(void *Addr) {
std::map<void *, AssertingVH<const GlobalValue> >::iterator I = std::map<void *, AssertingVH<const GlobalValue> >::iterator I =
EEState.getGlobalAddressReverseMap(locked).find(Addr); EEState.getGlobalAddressReverseMap(locked).find(Addr);
return I != EEState.getGlobalAddressReverseMap(locked).end() ? I->second : 0; return I != EEState.getGlobalAddressReverseMap(locked).end() ? I->second : nullptr;
} }
namespace { namespace {
@ -243,11 +243,11 @@ class ArgvArray {
char *Array; char *Array;
std::vector<char*> Values; std::vector<char*> Values;
public: public:
ArgvArray() : Array(NULL) {} ArgvArray() : Array(nullptr) {}
~ArgvArray() { clear(); } ~ArgvArray() { clear(); }
void clear() { void clear() {
delete[] Array; delete[] Array;
Array = NULL; Array = nullptr;
for (size_t I = 0, E = Values.size(); I != E; ++I) { for (size_t I = 0, E = Values.size(); I != E; ++I) {
delete[] Values[I]; delete[] Values[I];
} }
@ -283,7 +283,7 @@ void *ArgvArray::reset(LLVMContext &C, ExecutionEngine *EE,
} }
// Null terminate it // Null terminate it
EE->StoreValueToMemory(PTOGV(0), EE->StoreValueToMemory(PTOGV(nullptr),
(GenericValue*)(Array+InputArgv.size()*PtrSize), (GenericValue*)(Array+InputArgv.size()*PtrSize),
SBytePtr); SBytePtr);
return Array; return Array;
@ -303,11 +303,11 @@ void ExecutionEngine::runStaticConstructorsDestructors(Module *module,
// Should be an array of '{ i32, void ()* }' structs. The first value is // Should be an array of '{ i32, void ()* }' structs. The first value is
// the init priority, which we ignore. // the init priority, which we ignore.
ConstantArray *InitList = dyn_cast<ConstantArray>(GV->getInitializer()); ConstantArray *InitList = dyn_cast<ConstantArray>(GV->getInitializer());
if (InitList == 0) if (!InitList)
return; return;
for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) { for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) {
ConstantStruct *CS = dyn_cast<ConstantStruct>(InitList->getOperand(i)); ConstantStruct *CS = dyn_cast<ConstantStruct>(InitList->getOperand(i));
if (CS == 0) continue; if (!CS) continue;
Constant *FP = CS->getOperand(1); Constant *FP = CS->getOperand(1);
if (FP->isNullValue()) if (FP->isNullValue())
@ -418,10 +418,10 @@ ExecutionEngine *ExecutionEngine::createJIT(Module *M,
bool GVsWithCode, bool GVsWithCode,
Reloc::Model RM, Reloc::Model RM,
CodeModel::Model CMM) { CodeModel::Model CMM) {
if (ExecutionEngine::JITCtor == 0) { if (!ExecutionEngine::JITCtor) {
if (ErrorStr) if (ErrorStr)
*ErrorStr = "JIT has not been linked in."; *ErrorStr = "JIT has not been linked in.";
return 0; return nullptr;
} }
// Use the defaults for extra parameters. Users can use EngineBuilder to // Use the defaults for extra parameters. Users can use EngineBuilder to
@ -437,7 +437,7 @@ ExecutionEngine *ExecutionEngine::createJIT(Module *M,
// TODO: permit custom TargetOptions here // TODO: permit custom TargetOptions here
TargetMachine *TM = EB.selectTarget(); 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); return ExecutionEngine::JITCtor(M, ErrorStr, JMM, GVsWithCode, TM);
} }
@ -447,8 +447,8 @@ ExecutionEngine *EngineBuilder::create(TargetMachine *TM) {
// Make sure we can resolve symbols in the program as well. The zero arg // 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. // to the function tells DynamicLibrary to load the program, not a library.
if (sys::DynamicLibrary::LoadLibraryPermanently(0, ErrorStr)) if (sys::DynamicLibrary::LoadLibraryPermanently(nullptr, ErrorStr))
return 0; return nullptr;
assert(!(JMM && MCJMM)); assert(!(JMM && MCJMM));
@ -461,7 +461,7 @@ ExecutionEngine *EngineBuilder::create(TargetMachine *TM) {
else { else {
if (ErrorStr) if (ErrorStr)
*ErrorStr = "Cannot create an interpreter with a memory manager."; *ErrorStr = "Cannot create an interpreter with a memory manager.";
return 0; return nullptr;
} }
} }
@ -470,7 +470,7 @@ ExecutionEngine *EngineBuilder::create(TargetMachine *TM) {
*ErrorStr = *ErrorStr =
"Cannot create a legacy JIT with a runtime dyld memory " "Cannot create a legacy JIT with a runtime dyld memory "
"manager."; "manager.";
return 0; return nullptr;
} }
// Unless the interpreter was explicitly selected or the JIT is not linked, // Unless the interpreter was explicitly selected or the JIT is not linked,
@ -503,16 +503,16 @@ ExecutionEngine *EngineBuilder::create(TargetMachine *TM) {
return ExecutionEngine::InterpCtor(M, ErrorStr); return ExecutionEngine::InterpCtor(M, ErrorStr);
if (ErrorStr) if (ErrorStr)
*ErrorStr = "Interpreter has not been linked in."; *ErrorStr = "Interpreter has not been linked in.";
return 0; return nullptr;
} }
if ((WhichEngine & EngineKind::JIT) && ExecutionEngine::JITCtor == 0 && if ((WhichEngine & EngineKind::JIT) && !ExecutionEngine::JITCtor &&
ExecutionEngine::MCJITCtor == 0) { !ExecutionEngine::MCJITCtor) {
if (ErrorStr) if (ErrorStr)
*ErrorStr = "JIT has not been linked in."; *ErrorStr = "JIT has not been linked in.";
} }
return 0; return nullptr;
} }
void *ExecutionEngine::getPointerToGlobal(const GlobalValue *GV) { void *ExecutionEngine::getPointerToGlobal(const GlobalValue *GV) {
@ -848,7 +848,7 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
break; break;
case Type::PointerTyID: case Type::PointerTyID:
if (isa<ConstantPointerNull>(C)) if (isa<ConstantPointerNull>(C))
Result.PointerVal = 0; Result.PointerVal = nullptr;
else if (const Function *F = dyn_cast<Function>(C)) else if (const Function *F = dyn_cast<Function>(C))
Result = PTOGV(getPointerToFunctionOrStub(const_cast<Function*>(F))); Result = PTOGV(getPointerToFunctionOrStub(const_cast<Function*>(F)));
else if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) else if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(C))
@ -1290,12 +1290,12 @@ void ExecutionEngine::emitGlobals() {
void ExecutionEngine::EmitGlobalVariable(const GlobalVariable *GV) { void ExecutionEngine::EmitGlobalVariable(const GlobalVariable *GV) {
void *GA = getPointerToGlobalIfAvailable(GV); void *GA = getPointerToGlobalIfAvailable(GV);
if (GA == 0) { if (!GA) {
// If it's not already specified, allocate memory for the global. // If it's not already specified, allocate memory for the global.
GA = getMemoryForGV(GV); GA = getMemoryForGV(GV);
// If we failed to allocate memory for this global, return. // If we failed to allocate memory for this global, return.
if (GA == 0) return; if (!GA) return;
addGlobalMapping(GV, GA); addGlobalMapping(GV, GA);
} }

View File

@ -410,7 +410,7 @@ uint8_t *SimpleBindingMemoryManager::allocateDataSection(
} }
bool SimpleBindingMemoryManager::finalizeMemory(std::string *ErrMsg) { bool SimpleBindingMemoryManager::finalizeMemory(std::string *ErrMsg) {
char *errMsgCString = 0; char *errMsgCString = nullptr;
bool result = Functions.FinalizeMemory(Opaque, &errMsgCString); bool result = Functions.FinalizeMemory(Opaque, &errMsgCString);
assert((result || !errMsgCString) && assert((result || !errMsgCString) &&
"Did not expect an error message if FinalizeMemory succeeded"); "Did not expect an error message if FinalizeMemory succeeded");
@ -433,7 +433,7 @@ LLVMMCJITMemoryManagerRef LLVMCreateSimpleMCJITMemoryManager(
if (!AllocateCodeSection || !AllocateDataSection || !FinalizeMemory || if (!AllocateCodeSection || !AllocateDataSection || !FinalizeMemory ||
!Destroy) !Destroy)
return NULL; return nullptr;
SimpleBindingMMFunctions functions; SimpleBindingMMFunctions functions;
functions.AllocateCodeSection = AllocateCodeSection; functions.AllocateCodeSection = AllocateCodeSection;

View File

@ -47,7 +47,7 @@ TargetMachine *EngineBuilder::selectTarget(const Triple &TargetTriple,
TheTriple.setTriple(sys::getProcessTriple()); TheTriple.setTriple(sys::getProcessTriple());
// Adjust the triple to match what the user requested. // Adjust the triple to match what the user requested.
const Target *TheTarget = 0; const Target *TheTarget = nullptr;
if (!MArch.empty()) { if (!MArch.empty()) {
for (TargetRegistry::iterator it = TargetRegistry::begin(), for (TargetRegistry::iterator it = TargetRegistry::begin(),
ie = TargetRegistry::end(); it != ie; ++it) { ie = TargetRegistry::end(); it != ie; ++it) {
@ -61,7 +61,7 @@ TargetMachine *EngineBuilder::selectTarget(const Triple &TargetTriple,
if (ErrorStr) if (ErrorStr)
*ErrorStr = "No available targets are compatible with this -march, " *ErrorStr = "No available targets are compatible with this -march, "
"see -version for the available targets.\n"; "see -version for the available targets.\n";
return 0; return nullptr;
} }
// Adjust the triple to match (if known), otherwise stick with the // Adjust the triple to match (if known), otherwise stick with the
@ -72,10 +72,10 @@ TargetMachine *EngineBuilder::selectTarget(const Triple &TargetTriple,
} else { } else {
std::string Error; std::string Error;
TheTarget = TargetRegistry::lookupTarget(TheTriple.getTriple(), Error); TheTarget = TargetRegistry::lookupTarget(TheTriple.getTriple(), Error);
if (TheTarget == 0) { if (!TheTarget) {
if (ErrorStr) if (ErrorStr)
*ErrorStr = Error; *ErrorStr = Error;
return 0; return nullptr;
} }
} }

View File

@ -81,7 +81,7 @@ BasicBlock::~BasicBlock() {
} }
} }
assert(getParent() == 0 && "BasicBlock still linked into the program!"); assert(getParent() == nullptr && "BasicBlock still linked into the program!");
dropAllReferences(); dropAllReferences();
InstList.clear(); InstList.clear();
} }

View File

@ -1951,7 +1951,7 @@ static Constant *ConstantFoldGetElementPtrImpl(Constant *C,
if (isa<UndefValue>(C)) { if (isa<UndefValue>(C)) {
PointerType *Ptr = cast<PointerType>(C->getType()); PointerType *Ptr = cast<PointerType>(C->getType());
Type *Ty = GetElementPtrInst::getIndexedType(Ptr, Idxs); 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())); return UndefValue::get(PointerType::get(Ty, Ptr->getAddressSpace()));
} }
@ -1965,7 +1965,7 @@ static Constant *ConstantFoldGetElementPtrImpl(Constant *C,
if (isNull) { if (isNull) {
PointerType *Ptr = cast<PointerType>(C->getType()); PointerType *Ptr = cast<PointerType>(C->getType());
Type *Ty = GetElementPtrInst::getIndexedType(Ptr, Idxs); 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, return ConstantPointerNull::get(PointerType::get(Ty,
Ptr->getAddressSpace())); Ptr->getAddressSpace()));
} }

View File

@ -1354,7 +1354,7 @@ void UndefValue::destroyConstant() {
// //
BlockAddress *BlockAddress::get(BasicBlock *BB) { 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 get(BB->getParent(), BB);
} }
@ -1381,7 +1381,7 @@ BlockAddress *BlockAddress::lookup(const BasicBlock *BB) {
return nullptr; return nullptr;
const Function *F = BB->getParent(); const Function *F = BB->getParent();
assert(F != 0 && "Block must have a parent"); assert(F && "Block must have a parent");
BlockAddress *BA = BlockAddress *BA =
F->getContext().pImpl->BlockAddresses.lookup(std::make_pair(F, BB)); F->getContext().pImpl->BlockAddresses.lookup(std::make_pair(F, BB));
assert(BA && "Refcount and block address map disagree!"); assert(BA && "Refcount and block address map disagree!");

View File

@ -260,7 +260,7 @@ void DebugRecVH::deleted() {
MDNode *OldScope = Entry.first.get(); MDNode *OldScope = Entry.first.get();
MDNode *OldInlinedAt = Entry.second.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"); "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. // Otherwise, we do have an entry in it, nuke it and we're done.
@ -314,7 +314,7 @@ void DebugRecVH::allUsesReplacedWith(Value *NewVa) {
MDNode *OldScope = Entry.first.get(); MDNode *OldScope = Entry.first.get();
MDNode *OldInlinedAt = Entry.second.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"); "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. // Otherwise, we do have an entry in it, nuke it and we're done.

View File

@ -53,7 +53,7 @@ Instruction::Instruction(Type *ty, unsigned it, Use *Ops, unsigned NumOps,
// Out of line virtual method, so the vtable, etc has a home. // Out of line virtual method, so the vtable, etc has a home.
Instruction::~Instruction() { Instruction::~Instruction() {
assert(Parent == 0 && "Instruction still linked in the program!"); assert(!Parent && "Instruction still linked in the program!");
if (hasMetadataHashEntry()) if (hasMetadataHashEntry())
clearMetadataHashEntries(); clearMetadataHashEntries();
} }

View File

@ -732,7 +732,7 @@ BranchInst::BranchInst(BasicBlock *IfTrue, Instruction *InsertBefore)
: TerminatorInst(Type::getVoidTy(IfTrue->getContext()), Instruction::Br, : TerminatorInst(Type::getVoidTy(IfTrue->getContext()), Instruction::Br,
OperandTraits<BranchInst>::op_end(this) - 1, OperandTraits<BranchInst>::op_end(this) - 1,
1, InsertBefore) { 1, InsertBefore) {
assert(IfTrue != 0 && "Branch destination may not be null!"); assert(IfTrue && "Branch destination may not be null!");
Op<-1>() = IfTrue; Op<-1>() = IfTrue;
} }
BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
@ -752,7 +752,7 @@ BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *InsertAtEnd)
: TerminatorInst(Type::getVoidTy(IfTrue->getContext()), Instruction::Br, : TerminatorInst(Type::getVoidTy(IfTrue->getContext()), Instruction::Br,
OperandTraits<BranchInst>::op_end(this) - 1, OperandTraits<BranchInst>::op_end(this) - 1,
1, InsertAtEnd) { 1, InsertAtEnd) {
assert(IfTrue != 0 && "Branch destination may not be null!"); assert(IfTrue && "Branch destination may not be null!");
Op<-1>() = IfTrue; Op<-1>() = IfTrue;
} }

View File

@ -23,7 +23,7 @@ MDString *MDBuilder::createString(StringRef Str) {
MDNode *MDBuilder::createFPMath(float Accuracy) { MDNode *MDBuilder::createFPMath(float Accuracy) {
if (Accuracy == 0.0) if (Accuracy == 0.0)
return 0; return nullptr;
assert(Accuracy > 0.0 && "Invalid fpmath accuracy!"); assert(Accuracy > 0.0 && "Invalid fpmath accuracy!");
Value *Op = ConstantFP::get(Type::getFloatTy(Context), Accuracy); Value *Op = ConstantFP::get(Type::getFloatTy(Context), Accuracy);
return MDNode::get(Context, Op); return MDNode::get(Context, Op);

View File

@ -164,10 +164,10 @@ static const Function *getFunctionForValue(Value *V) {
#ifndef NDEBUG #ifndef NDEBUG
static const Function *assertLocalFunction(const MDNode *N) { 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. // 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) { for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
if (Value *V = N->getOperand(i)) { if (Value *V = N->getOperand(i)) {
if (MDNode *MD = dyn_cast<MDNode>(V)) if (MDNode *MD = dyn_cast<MDNode>(V))
@ -175,10 +175,11 @@ static const Function *assertLocalFunction(const MDNode *N) {
else else
NewF = getFunctionForValue(V); NewF = getFunctionForValue(V);
} }
if (F == 0) if (!F)
F = NewF; F = NewF;
else else
assert((NewF == 0 || F == NewF) &&"inconsistent function-local metadata"); assert((NewF == nullptr || F == NewF) &&
"inconsistent function-local metadata");
} }
return F; return F;
} }

View File

@ -174,7 +174,7 @@ void PassRegistry::registerAnalysisGroup(const void *InterfaceID,
"Cannot add a pass to the same analysis group more than once!"); "Cannot add a pass to the same analysis group more than once!");
AGI.Implementations.insert(ImplementationInfo); AGI.Implementations.insert(ImplementationInfo);
if (isDefault) { if (isDefault) {
assert(InterfaceInfo->getNormalCtor() == 0 && assert(InterfaceInfo->getNormalCtor() == nullptr &&
"Default implementation for analysis group already specified!"); "Default implementation for analysis group already specified!");
assert(ImplementationInfo->getNormalCtor() && assert(ImplementationInfo->getNormalCtor() &&
"Cannot specify pass as default if it does not have a default ctor"); "Cannot specify pass as default if it does not have a default ctor");

View File

@ -497,7 +497,7 @@ StructType *StructType::get(LLVMContext &Context, bool isPacked) {
} }
StructType *StructType::get(Type *type, ...) { 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(); LLVMContext &Ctx = type->getContext();
va_list ap; va_list ap;
SmallVector<llvm::Type*, 8> StructFields; SmallVector<llvm::Type*, 8> StructFields;
@ -538,7 +538,7 @@ StructType *StructType::create(ArrayRef<Type*> Elements) {
} }
StructType *StructType::create(StringRef Name, Type *type, ...) { 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(); LLVMContext &Ctx = type->getContext();
va_list ap; va_list ap;
SmallVector<llvm::Type*, 8> StructFields; SmallVector<llvm::Type*, 8> StructFields;
@ -582,7 +582,7 @@ StringRef StructType::getName() const {
} }
void StructType::setBody(Type *type, ...) { 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; va_list ap;
SmallVector<llvm::Type*, 8> StructFields; SmallVector<llvm::Type*, 8> StructFields;
va_start(ap, type); va_start(ap, type);

View File

@ -557,7 +557,7 @@ void ValueHandleBase::AddToUseList() {
// If this value already has a ValueHandle, then it must be in the // If this value already has a ValueHandle, then it must be in the
// ValueHandles map already. // ValueHandles map already.
ValueHandleBase *&Entry = pImpl->ValueHandles[VP.getPointer()]; 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); AddToExistingUseList(&Entry);
return; return;
} }
@ -571,7 +571,7 @@ void ValueHandleBase::AddToUseList() {
const void *OldBucketPtr = Handles.getPointerIntoBucketsArray(); const void *OldBucketPtr = Handles.getPointerIntoBucketsArray();
ValueHandleBase *&Entry = Handles[VP.getPointer()]; ValueHandleBase *&Entry = Handles[VP.getPointer()];
assert(Entry == 0 && "Value really did already have handles?"); assert(!Entry && "Value really did already have handles?");
AddToExistingUseList(&Entry); AddToExistingUseList(&Entry);
VP.getPointer()->HasValueHandle = true; VP.getPointer()->HasValueHandle = true;

View File

@ -42,12 +42,12 @@ Module *llvm::getLazyIRModule(MemoryBuffer *Buffer, SMDiagnostic &Err,
// ParseBitcodeFile does not take ownership of the Buffer in the // ParseBitcodeFile does not take ownership of the Buffer in the
// case of an error. // case of an error.
delete Buffer; delete Buffer;
return NULL; return nullptr;
} }
return ModuleOrErr.get(); return ModuleOrErr.get();
} }
return ParseAssembly(Buffer, 0, Err, Context); return ParseAssembly(Buffer, nullptr, Err, Context);
} }
Module *llvm::getLazyIRFileModule(const std::string &Filename, SMDiagnostic &Err, Module *llvm::getLazyIRFileModule(const std::string &Filename, SMDiagnostic &Err,
@ -56,7 +56,7 @@ Module *llvm::getLazyIRFileModule(const std::string &Filename, SMDiagnostic &Err
if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, File)) { if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, File)) {
Err = SMDiagnostic(Filename, SourceMgr::DK_Error, Err = SMDiagnostic(Filename, SourceMgr::DK_Error,
"Could not open input file: " + ec.message()); "Could not open input file: " + ec.message());
return 0; return nullptr;
} }
return getLazyIRModule(File.release(), Err, Context); return getLazyIRModule(File.release(), Err, Context);
@ -69,7 +69,7 @@ Module *llvm::ParseIR(MemoryBuffer *Buffer, SMDiagnostic &Err,
if (isBitcode((const unsigned char *)Buffer->getBufferStart(), if (isBitcode((const unsigned char *)Buffer->getBufferStart(),
(const unsigned char *)Buffer->getBufferEnd())) { (const unsigned char *)Buffer->getBufferEnd())) {
ErrorOr<Module *> ModuleOrErr = parseBitcodeFile(Buffer, Context); ErrorOr<Module *> ModuleOrErr = parseBitcodeFile(Buffer, Context);
Module *M = 0; Module *M = nullptr;
if (error_code EC = ModuleOrErr.getError()) if (error_code EC = ModuleOrErr.getError())
Err = SMDiagnostic(Buffer->getBufferIdentifier(), SourceMgr::DK_Error, Err = SMDiagnostic(Buffer->getBufferIdentifier(), SourceMgr::DK_Error,
EC.message()); EC.message());
@ -80,7 +80,7 @@ Module *llvm::ParseIR(MemoryBuffer *Buffer, SMDiagnostic &Err,
return M; return M;
} }
return ParseAssembly(Buffer, 0, Err, Context); return ParseAssembly(Buffer, nullptr, Err, Context);
} }
Module *llvm::ParseIRFile(const std::string &Filename, SMDiagnostic &Err, Module *llvm::ParseIRFile(const std::string &Filename, SMDiagnostic &Err,
@ -89,7 +89,7 @@ Module *llvm::ParseIRFile(const std::string &Filename, SMDiagnostic &Err,
if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, File)) { if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, File)) {
Err = SMDiagnostic(Filename, SourceMgr::DK_Error, Err = SMDiagnostic(Filename, SourceMgr::DK_Error,
"Could not open input file: " + ec.message()); "Could not open input file: " + ec.message());
return 0; return nullptr;
} }
return ParseIR(File.release(), Err, Context); return ParseIR(File.release(), Err, Context);
@ -111,7 +111,7 @@ LLVMBool LLVMParseIRInContext(LLVMContextRef ContextRef,
std::string buf; std::string buf;
raw_string_ostream os(buf); raw_string_ostream os(buf);
Diag.print(NULL, os, false); Diag.print(nullptr, os, false);
os.flush(); os.flush();
*OutMessage = strdup(buf.c_str()); *OutMessage = strdup(buf.c_str());

View File

@ -64,17 +64,17 @@ const char* LTOCodeGenerator::getVersionString() {
LTOCodeGenerator::LTOCodeGenerator() LTOCodeGenerator::LTOCodeGenerator()
: Context(getGlobalContext()), Linker(new Module("ld-temp.o", Context)), : Context(getGlobalContext()), Linker(new Module("ld-temp.o", Context)),
TargetMach(NULL), EmitDwarfDebugInfo(false), ScopeRestrictionsDone(false), TargetMach(nullptr), EmitDwarfDebugInfo(false),
CodeModel(LTO_CODEGEN_PIC_MODEL_DEFAULT), NativeObjectFile(NULL), ScopeRestrictionsDone(false), CodeModel(LTO_CODEGEN_PIC_MODEL_DEFAULT),
DiagHandler(NULL), DiagContext(NULL) { NativeObjectFile(nullptr), DiagHandler(nullptr), DiagContext(nullptr) {
initializeLTOPasses(); initializeLTOPasses();
} }
LTOCodeGenerator::~LTOCodeGenerator() { LTOCodeGenerator::~LTOCodeGenerator() {
delete TargetMach; delete TargetMach;
delete NativeObjectFile; delete NativeObjectFile;
TargetMach = NULL; TargetMach = nullptr;
NativeObjectFile = NULL; NativeObjectFile = nullptr;
Linker.deleteModule(); Linker.deleteModule();
@ -245,7 +245,7 @@ const void* LTOCodeGenerator::compile(size_t* length,
const char *name; const char *name;
if (!compile_to_file(&name, disableOpt, disableInline, disableGVNLoadPRE, if (!compile_to_file(&name, disableOpt, disableInline, disableGVNLoadPRE,
errMsg)) errMsg))
return NULL; return nullptr;
// remove old buffer if compile() called twice // remove old buffer if compile() called twice
delete NativeObjectFile; delete NativeObjectFile;
@ -255,7 +255,7 @@ const void* LTOCodeGenerator::compile(size_t* length,
if (error_code ec = MemoryBuffer::getFile(name, BuffPtr, -1, false)) { if (error_code ec = MemoryBuffer::getFile(name, BuffPtr, -1, false)) {
errMsg = ec.message(); errMsg = ec.message();
sys::fs::remove(NativeObjectPath); sys::fs::remove(NativeObjectPath);
return NULL; return nullptr;
} }
NativeObjectFile = BuffPtr.release(); NativeObjectFile = BuffPtr.release();
@ -263,14 +263,14 @@ const void* LTOCodeGenerator::compile(size_t* length,
sys::fs::remove(NativeObjectPath); sys::fs::remove(NativeObjectPath);
// return buffer, unless error // return buffer, unless error
if (NativeObjectFile == NULL) if (!NativeObjectFile)
return NULL; return nullptr;
*length = NativeObjectFile->getBufferSize(); *length = NativeObjectFile->getBufferSize();
return NativeObjectFile->getBufferStart(); return NativeObjectFile->getBufferStart();
} }
bool LTOCodeGenerator::determineTarget(std::string &errMsg) { bool LTOCodeGenerator::determineTarget(std::string &errMsg) {
if (TargetMach != NULL) if (TargetMach)
return true; return true;
std::string TripleStr = Linker.getModule()->getTargetTriple(); std::string TripleStr = Linker.getModule()->getTargetTriple();
@ -280,7 +280,7 @@ bool LTOCodeGenerator::determineTarget(std::string &errMsg) {
// create target machine from info for merged modules // create target machine from info for merged modules
const Target *march = TargetRegistry::lookupTarget(TripleStr, errMsg); const Target *march = TargetRegistry::lookupTarget(TripleStr, errMsg);
if (march == NULL) if (!march)
return false; return false;
// The relocation model is actually a static member of TargetMachine and // The relocation model is actually a static member of TargetMachine and
@ -355,7 +355,7 @@ applyRestriction(GlobalValue &GV,
static void findUsedValues(GlobalVariable *LLVMUsed, static void findUsedValues(GlobalVariable *LLVMUsed,
SmallPtrSet<GlobalValue*, 8> &UsedValues) { SmallPtrSet<GlobalValue*, 8> &UsedValues) {
if (LLVMUsed == 0) return; if (!LLVMUsed) return;
ConstantArray *Inits = cast<ConstantArray>(LLVMUsed->getInitializer()); ConstantArray *Inits = cast<ConstantArray>(LLVMUsed->getInitializer());
for (unsigned i = 0, e = Inits->getNumOperands(); i != e; ++i) for (unsigned i = 0, e = Inits->getNumOperands(); i != e; ++i)
@ -579,7 +579,7 @@ LTOCodeGenerator::setDiagnosticHandler(lto_diagnostic_handler_t DiagHandler,
this->DiagHandler = DiagHandler; this->DiagHandler = DiagHandler;
this->DiagContext = Ctxt; this->DiagContext = Ctxt;
if (!DiagHandler) if (!DiagHandler)
return Context.setDiagnosticHandler(NULL, NULL); return Context.setDiagnosticHandler(nullptr, nullptr);
// Register the LTOCodeGenerator stub in the LLVMContext to forward the // Register the LTOCodeGenerator stub in the LLVMContext to forward the
// diagnostic to the external DiagHandler. // diagnostic to the external DiagHandler.
Context.setDiagnosticHandler(LTOCodeGenerator::DiagnosticHandler, this); Context.setDiagnosticHandler(LTOCodeGenerator::DiagnosticHandler, this);

View File

@ -100,7 +100,7 @@ LTOModule *LTOModule::makeLTOModule(const char *path, TargetOptions options,
std::unique_ptr<MemoryBuffer> buffer; std::unique_ptr<MemoryBuffer> buffer;
if (error_code ec = MemoryBuffer::getFile(path, buffer)) { if (error_code ec = MemoryBuffer::getFile(path, buffer)) {
errMsg = ec.message(); errMsg = ec.message();
return NULL; return nullptr;
} }
return makeLTOModule(buffer.release(), options, errMsg); return makeLTOModule(buffer.release(), options, errMsg);
} }
@ -120,7 +120,7 @@ LTOModule *LTOModule::makeLTOModule(int fd, const char *path,
if (error_code ec = if (error_code ec =
MemoryBuffer::getOpenFileSlice(fd, path, buffer, map_size, offset)) { MemoryBuffer::getOpenFileSlice(fd, path, buffer, map_size, offset)) {
errMsg = ec.message(); errMsg = ec.message();
return NULL; return nullptr;
} }
return makeLTOModule(buffer.release(), options, errMsg); return makeLTOModule(buffer.release(), options, errMsg);
} }
@ -130,7 +130,7 @@ LTOModule *LTOModule::makeLTOModule(const void *mem, size_t length,
std::string &errMsg, StringRef path) { std::string &errMsg, StringRef path) {
std::unique_ptr<MemoryBuffer> buffer(makeBuffer(mem, length, path)); std::unique_ptr<MemoryBuffer> buffer(makeBuffer(mem, length, path));
if (!buffer) if (!buffer)
return NULL; return nullptr;
return makeLTOModule(buffer.release(), options, errMsg); return makeLTOModule(buffer.release(), options, errMsg);
} }
@ -143,7 +143,7 @@ LTOModule *LTOModule::makeLTOModule(MemoryBuffer *buffer,
if (error_code EC = ModuleOrErr.getError()) { if (error_code EC = ModuleOrErr.getError()) {
errMsg = EC.message(); errMsg = EC.message();
delete buffer; delete buffer;
return NULL; return nullptr;
} }
std::unique_ptr<Module> m(ModuleOrErr.get()); std::unique_ptr<Module> m(ModuleOrErr.get());
@ -155,7 +155,7 @@ LTOModule *LTOModule::makeLTOModule(MemoryBuffer *buffer,
// find machine architecture for this module // find machine architecture for this module
const Target *march = TargetRegistry::lookupTarget(TripleStr, errMsg); const Target *march = TargetRegistry::lookupTarget(TripleStr, errMsg);
if (!march) if (!march)
return NULL; return nullptr;
// construct LTOModule, hand over ownership of module and target // construct LTOModule, hand over ownership of module and target
SubtargetFeatures Features; SubtargetFeatures Features;
@ -189,7 +189,7 @@ LTOModule *LTOModule::makeLTOModule(MemoryBuffer *buffer,
if (Ret->parseSymbols(errMsg)) { if (Ret->parseSymbols(errMsg)) {
delete Ret; delete Ret;
return NULL; return nullptr;
} }
Ret->parseMetadata(); Ret->parseMetadata();
@ -460,7 +460,7 @@ void LTOModule::addAsmGlobalSymbol(const char *name,
NameAndAttributes &info = _undefines[entry.getKey().data()]; 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: // FIXME: This is trying to take care of module ASM like this:
// //
// module asm ".zerofill __FOO, __foo, _bar_baz_qux, 0" // module asm ".zerofill __FOO, __foo, _bar_baz_qux, 0"
@ -474,7 +474,7 @@ void LTOModule::addAsmGlobalSymbol(const char *name,
info.attributes = info.attributes =
LTO_SYMBOL_PERMISSIONS_DATA | LTO_SYMBOL_DEFINITION_REGULAR | scope; LTO_SYMBOL_PERMISSIONS_DATA | LTO_SYMBOL_DEFINITION_REGULAR | scope;
info.isFunction = false; info.isFunction = false;
info.symbol = 0; info.symbol = nullptr;
// add to table of symbols // add to table of symbols
_symbols.push_back(info); _symbols.push_back(info);
@ -508,7 +508,7 @@ void LTOModule::addAsmGlobalSymbolUndef(const char *name) {
info.name = entry.getKey().data(); info.name = entry.getKey().data();
info.attributes = attr; info.attributes = attr;
info.isFunction = false; info.isFunction = false;
info.symbol = 0; info.symbol = nullptr;
entry.setValue(info); entry.setValue(info);
} }

View File

@ -439,16 +439,16 @@ namespace {
// If the source has no name it can't link. If it has local linkage, // If the source has no name it can't link. If it has local linkage,
// there is no name match-up going on. // there is no name match-up going on.
if (!SrcGV->hasName() || SrcGV->hasLocalLinkage()) if (!SrcGV->hasName() || SrcGV->hasLocalLinkage())
return 0; return nullptr;
// Otherwise see if we have a match in the destination module's symtab. // Otherwise see if we have a match in the destination module's symtab.
GlobalValue *DGV = DstM->getNamedValue(SrcGV->getName()); 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 // 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. // internal linkage, we are really not doing any linkage here.
if (DGV->hasLocalLinkage()) if (DGV->hasLocalLinkage())
return 0; return nullptr;
// Otherwise, we do in fact link to the destination global. // Otherwise, we do in fact link to the destination global.
return DGV; return DGV;
@ -518,7 +518,7 @@ static bool isLessConstraining(GlobalValue::VisibilityTypes a,
Value *ValueMaterializerTy::materializeValueFor(Value *V) { Value *ValueMaterializerTy::materializeValueFor(Value *V) {
Function *SF = dyn_cast<Function>(V); Function *SF = dyn_cast<Function>(V);
if (!SF) if (!SF)
return NULL; return nullptr;
Function *DF = Function::Create(TypeMap.get(SF->getFunctionType()), Function *DF = Function::Create(TypeMap.get(SF->getFunctionType()),
SF->getLinkage(), SF->getName(), DstM); SF->getLinkage(), SF->getName(), DstM);
@ -612,7 +612,7 @@ void ModuleLinker::computeTypeMapping() {
for (Module::global_iterator I = SrcM->global_begin(), for (Module::global_iterator I = SrcM->global_begin(),
E = SrcM->global_end(); I != E; ++I) { E = SrcM->global_end(); I != E; ++I) {
GlobalValue *DGV = getLinkedToGlobal(I); GlobalValue *DGV = getLinkedToGlobal(I);
if (DGV == 0) continue; if (!DGV) continue;
if (!DGV->hasAppendingLinkage() || !I->hasAppendingLinkage()) { if (!DGV->hasAppendingLinkage() || !I->hasAppendingLinkage()) {
TypeMap.addTypeMapping(DGV->getType(), I->getType()); TypeMap.addTypeMapping(DGV->getType(), I->getType());
@ -723,7 +723,7 @@ bool ModuleLinker::linkAppendingVarProto(GlobalVariable *DstGV,
// Create the new global variable. // Create the new global variable.
GlobalVariable *NG = GlobalVariable *NG =
new GlobalVariable(*DstGV->getParent(), NewType, SrcGV->isConstant(), new GlobalVariable(*DstGV->getParent(), NewType, SrcGV->isConstant(),
DstGV->getLinkage(), /*init*/0, /*name*/"", DstGV, DstGV->getLinkage(), /*init*/nullptr, /*name*/"", DstGV,
DstGV->getThreadLocalMode(), DstGV->getThreadLocalMode(),
DstGV->getType()->getAddressSpace()); DstGV->getType()->getAddressSpace());
@ -800,8 +800,8 @@ bool ModuleLinker::linkGlobalProto(GlobalVariable *SGV) {
// initializer will be filled in later by LinkGlobalInits. // initializer will be filled in later by LinkGlobalInits.
GlobalVariable *NewDGV = GlobalVariable *NewDGV =
new GlobalVariable(*DstM, TypeMap.get(SGV->getType()->getElementType()), new GlobalVariable(*DstM, TypeMap.get(SGV->getType()->getElementType()),
SGV->isConstant(), SGV->getLinkage(), /*init*/0, SGV->isConstant(), SGV->getLinkage(), /*init*/nullptr,
SGV->getName(), /*insertbefore*/0, SGV->getName(), /*insertbefore*/nullptr,
SGV->getThreadLocalMode(), SGV->getThreadLocalMode(),
SGV->getType()->getAddressSpace()); SGV->getType()->getAddressSpace());
// Propagate alignment, visibility and section info. // Propagate alignment, visibility and section info.
@ -913,7 +913,7 @@ bool ModuleLinker::linkAliasProto(GlobalAlias *SGA) {
// bring over SGA. // bring over SGA.
GlobalAlias *NewDA = new GlobalAlias(TypeMap.get(SGA->getType()), GlobalAlias *NewDA = new GlobalAlias(TypeMap.get(SGA->getType()),
SGA->getLinkage(), SGA->getName(), SGA->getLinkage(), SGA->getName(),
/*aliasee*/0, DstM); /*aliasee*/nullptr, DstM);
copyGVAttributes(NewDA, SGA); copyGVAttributes(NewDA, SGA);
if (NewVisibility) if (NewVisibility)
NewDA->setVisibility(*NewVisibility); NewDA->setVisibility(*NewVisibility);
@ -997,7 +997,7 @@ void ModuleLinker::linkFunctionBody(Function *Dst, Function *Src) {
} else { } else {
// Clone the body of the function into the dest function. // Clone the body of the function into the dest function.
SmallVector<ReturnInst*, 8> Returns; // Ignore returns. SmallVector<ReturnInst*, 8> Returns; // Ignore returns.
CloneFunctionInto(Dst, Src, ValueMap, false, Returns, "", NULL, CloneFunctionInto(Dst, Src, ValueMap, false, Returns, "", nullptr,
&TypeMap, &ValMaterializer); &TypeMap, &ValMaterializer);
} }
@ -1369,7 +1369,7 @@ Linker::~Linker() {
void Linker::deleteModule() { void Linker::deleteModule() {
delete Composite; delete Composite;
Composite = NULL; Composite = nullptr;
} }
bool Linker::linkInModule(Module *Src, unsigned Mode, std::string *ErrorMsg) { bool Linker::linkInModule(Module *Src, unsigned Mode, std::string *ErrorMsg) {
@ -1406,7 +1406,7 @@ LLVMBool LLVMLinkModules(LLVMModuleRef Dest, LLVMModuleRef Src,
LLVMLinkerMode Mode, char **OutMessages) { LLVMLinkerMode Mode, char **OutMessages) {
std::string Messages; std::string Messages;
LLVMBool Result = Linker::LinkModules(unwrap(Dest), unwrap(Src), LLVMBool Result = Linker::LinkModules(unwrap(Dest), unwrap(Src),
Mode, OutMessages? &Messages : 0); Mode, OutMessages? &Messages : nullptr);
if (OutMessages) if (OutMessages)
*OutMessages = strdup(Messages.c_str()); *OutMessages = strdup(Messages.c_str());
return Result; return Result;

View File

@ -111,7 +111,7 @@ Archive::Child Archive::Child::getNext() const {
// Check to see if this is past the end of the archive. // Check to see if this is past the end of the archive.
if (NextLoc >= Parent->Data->getBufferEnd()) if (NextLoc >= Parent->Data->getBufferEnd())
return Child(Parent, NULL); return Child(Parent, nullptr);
return Child(Parent, NextLoc); return Child(Parent, NextLoc);
} }
@ -349,7 +349,7 @@ Archive::child_iterator Archive::child_begin(bool SkipInternal) const {
} }
Archive::child_iterator Archive::child_end() const { 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 Archive::Symbol::getName(StringRef &Result) const {

View File

@ -138,7 +138,7 @@ error_code COFFObjectFile::getSymbolName(DataRefImpl Ref,
error_code COFFObjectFile::getSymbolAddress(DataRefImpl Ref, error_code COFFObjectFile::getSymbolAddress(DataRefImpl Ref,
uint64_t &Result) const { uint64_t &Result) const {
const coff_symbol *Symb = toSymb(Ref); const coff_symbol *Symb = toSymb(Ref);
const coff_section *Section = NULL; const coff_section *Section = nullptr;
if (error_code EC = getSection(Symb->SectionNumber, Section)) if (error_code EC = getSection(Symb->SectionNumber, Section))
return EC; return EC;
@ -163,7 +163,7 @@ error_code COFFObjectFile::getSymbolType(DataRefImpl Ref,
} else { } else {
uint32_t Characteristics = 0; uint32_t Characteristics = 0;
if (!COFF::isReservedSectionNumber(Symb->SectionNumber)) { if (!COFF::isReservedSectionNumber(Symb->SectionNumber)) {
const coff_section *Section = NULL; const coff_section *Section = nullptr;
if (error_code EC = getSection(Symb->SectionNumber, Section)) if (error_code EC = getSection(Symb->SectionNumber, Section))
return EC; return EC;
Characteristics = Section->Characteristics; Characteristics = Section->Characteristics;
@ -208,7 +208,7 @@ error_code COFFObjectFile::getSymbolSize(DataRefImpl Ref,
// in the same section as this symbol, and looking for either the next // in the same section as this symbol, and looking for either the next
// symbol, or the end of the section. // symbol, or the end of the section.
const coff_symbol *Symb = toSymb(Ref); const coff_symbol *Symb = toSymb(Ref);
const coff_section *Section = NULL; const coff_section *Section = nullptr;
if (error_code EC = getSection(Symb->SectionNumber, Section)) if (error_code EC = getSection(Symb->SectionNumber, Section))
return EC; return EC;
@ -227,7 +227,7 @@ error_code COFFObjectFile::getSymbolSection(DataRefImpl Ref,
if (COFF::isReservedSectionNumber(Symb->SectionNumber)) { if (COFF::isReservedSectionNumber(Symb->SectionNumber)) {
Result = section_end(); Result = section_end();
} else { } else {
const coff_section *Sec = 0; const coff_section *Sec = nullptr;
if (error_code EC = getSection(Symb->SectionNumber, Sec)) return EC; if (error_code EC = getSection(Symb->SectionNumber, Sec)) return EC;
DataRefImpl Ref; DataRefImpl Ref;
Ref.p = reinterpret_cast<uintptr_t>(Sec); Ref.p = reinterpret_cast<uintptr_t>(Sec);
@ -334,7 +334,7 @@ error_code COFFObjectFile::sectionContainsSymbol(DataRefImpl SecRef,
bool &Result) const { bool &Result) const {
const coff_section *Sec = toSec(SecRef); const coff_section *Sec = toSec(SecRef);
const coff_symbol *Symb = toSymb(SymbRef); 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 (error_code EC = getSection(Symb->SectionNumber, SymbSec)) return EC;
if (SymbSec == Sec) if (SymbSec == Sec)
Result = true; Result = true;
@ -507,10 +507,11 @@ error_code COFFObjectFile::initExportTablePtr() {
COFFObjectFile::COFFObjectFile(MemoryBuffer *Object, error_code &EC, COFFObjectFile::COFFObjectFile(MemoryBuffer *Object, error_code &EC,
bool BufferOwned) bool BufferOwned)
: ObjectFile(Binary::ID_COFF, Object, BufferOwned), COFFHeader(0), : ObjectFile(Binary::ID_COFF, Object, BufferOwned), COFFHeader(nullptr),
PE32Header(0), PE32PlusHeader(0), DataDirectory(0), SectionTable(0), PE32Header(nullptr), PE32PlusHeader(nullptr), DataDirectory(nullptr),
SymbolTable(0), StringTable(0), StringTableSize(0), ImportDirectory(0), SectionTable(nullptr), SymbolTable(nullptr), StringTable(nullptr),
NumberOfImportDirectory(0), ExportDirectory(0) { StringTableSize(0), ImportDirectory(nullptr), NumberOfImportDirectory(0),
ExportDirectory(nullptr) {
// Check that we at least have enough room for a header. // Check that we at least have enough room for a header.
if (!checkSize(Data, EC, sizeof(coff_file_header))) return; if (!checkSize(Data, EC, sizeof(coff_file_header))) return;
@ -632,8 +633,8 @@ export_directory_iterator COFFObjectFile::export_directory_begin() const {
} }
export_directory_iterator COFFObjectFile::export_directory_end() const { export_directory_iterator COFFObjectFile::export_directory_end() const {
if (ExportDirectory == 0) if (!ExportDirectory)
return export_directory_iterator(ExportDirectoryEntryRef(0, 0, this)); return export_directory_iterator(ExportDirectoryEntryRef(nullptr, 0, this));
ExportDirectoryEntryRef Ref(ExportDirectory, ExportDirectoryEntryRef Ref(ExportDirectory,
ExportDirectory->AddressTableEntries, this); ExportDirectory->AddressTableEntries, this);
return export_directory_iterator(Ref); return export_directory_iterator(Ref);
@ -723,7 +724,7 @@ error_code COFFObjectFile::getSection(int32_t Index,
const coff_section *&Result) const { const coff_section *&Result) const {
// Check for special index values. // Check for special index values.
if (COFF::isReservedSectionNumber(Index)) if (COFF::isReservedSectionNumber(Index))
Result = NULL; Result = nullptr;
else if (Index > 0 && Index <= COFFHeader->NumberOfSections) else if (Index > 0 && Index <= COFFHeader->NumberOfSections)
// We already verified the section table data, so no need to check again. // We already verified the section table data, so no need to check again.
Result = SectionTable + (Index - 1); Result = SectionTable + (Index - 1);
@ -773,7 +774,7 @@ error_code COFFObjectFile::getSymbolName(const coff_symbol *Symbol,
ArrayRef<uint8_t> COFFObjectFile::getSymbolAuxData( ArrayRef<uint8_t> COFFObjectFile::getSymbolAuxData(
const coff_symbol *Symbol) const { const coff_symbol *Symbol) const {
const uint8_t *Aux = NULL; const uint8_t *Aux = nullptr;
if (Symbol->NumberOfAuxSymbols > 0) { if (Symbol->NumberOfAuxSymbols > 0) {
// AUX data comes immediately after the symbol in COFF // AUX data comes immediately after the symbol in COFF
@ -968,7 +969,7 @@ error_code COFFObjectFile::getRelocationTypeName(DataRefImpl Rel,
error_code COFFObjectFile::getRelocationValueString(DataRefImpl Rel, error_code COFFObjectFile::getRelocationValueString(DataRefImpl Rel,
SmallVectorImpl<char> &Result) const { SmallVectorImpl<char> &Result) const {
const coff_relocation *Reloc = toRel(Rel); 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; if (error_code EC = getSymbol(Reloc->SymbolTableIndex, Symb)) return EC;
DataRefImpl Sym; DataRefImpl Sym;
Sym.p = reinterpret_cast<uintptr_t>(Symb); Sym.p = reinterpret_cast<uintptr_t>(Symb);

View File

@ -420,7 +420,8 @@ MachOObjectFile::MachOObjectFile(MemoryBuffer *Object, bool IsLittleEndian,
bool Is64bits, error_code &EC, bool Is64bits, error_code &EC,
bool BufferOwned) bool BufferOwned)
: ObjectFile(getMachOType(IsLittleEndian, Is64bits), Object, 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; uint32_t LoadCommandCount = this->getHeader().ncmds;
MachO::LoadCommandType SegmentLoadType = is64Bit() ? MachO::LoadCommandType SegmentLoadType = is64Bit() ?
MachO::LC_SEGMENT_64 : MachO::LC_SEGMENT; MachO::LC_SEGMENT_64 : MachO::LC_SEGMENT;

View File

@ -57,7 +57,7 @@ static T getUniversalBinaryStruct(const char *Ptr) {
MachOUniversalBinary::ObjectForArch::ObjectForArch( MachOUniversalBinary::ObjectForArch::ObjectForArch(
const MachOUniversalBinary *Parent, uint32_t Index) const MachOUniversalBinary *Parent, uint32_t Index)
: Parent(Parent), Index(Index) { : Parent(Parent), Index(Index) {
if (Parent == 0 || Index > Parent->getNumberOfObjects()) { if (!Parent || Index > Parent->getNumberOfObjects()) {
clear(); clear();
} else { } else {
// Parse object header. // Parse object header.

View File

@ -60,7 +60,7 @@ wrap(const relocation_iterator *SI) {
// ObjectFile creation // ObjectFile creation
LLVMObjectFileRef LLVMCreateObjectFile(LLVMMemoryBufferRef MemBuf) { LLVMObjectFileRef LLVMCreateObjectFile(LLVMMemoryBufferRef MemBuf) {
ErrorOr<ObjectFile*> ObjOrErr(ObjectFile::createObjectFile(unwrap(MemBuf))); ErrorOr<ObjectFile*> ObjOrErr(ObjectFile::createObjectFile(unwrap(MemBuf)));
ObjectFile *Obj = ObjOrErr ? ObjOrErr.get() : 0; ObjectFile *Obj = ObjOrErr ? ObjOrErr.get() : nullptr;
return wrap(Obj); return wrap(Obj);
} }

View File

@ -60,11 +60,11 @@ Arg *ArgList::getLastArgNoClaim(OptSpecifier Id) const {
for (const_reverse_iterator it = rbegin(), ie = rend(); it != ie; ++it) for (const_reverse_iterator it = rbegin(), ie = rend(); it != ie; ++it)
if ((*it)->getOption().matches(Id)) if ((*it)->getOption().matches(Id))
return *it; return *it;
return 0; return nullptr;
} }
Arg *ArgList::getLastArg(OptSpecifier Id) const { Arg *ArgList::getLastArg(OptSpecifier Id) const {
Arg *Res = 0; Arg *Res = nullptr;
for (const_iterator it = begin(), ie = end(); it != ie; ++it) { for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
if ((*it)->getOption().matches(Id)) { if ((*it)->getOption().matches(Id)) {
Res = *it; Res = *it;
@ -76,7 +76,7 @@ Arg *ArgList::getLastArg(OptSpecifier Id) const {
} }
Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1) const { Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1) const {
Arg *Res = 0; Arg *Res = nullptr;
for (const_iterator it = begin(), ie = end(); it != ie; ++it) { for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
if ((*it)->getOption().matches(Id0) || if ((*it)->getOption().matches(Id0) ||
(*it)->getOption().matches(Id1)) { (*it)->getOption().matches(Id1)) {
@ -91,7 +91,7 @@ Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1) const {
Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1, Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
OptSpecifier Id2) const { OptSpecifier Id2) const {
Arg *Res = 0; Arg *Res = nullptr;
for (const_iterator it = begin(), ie = end(); it != ie; ++it) { for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
if ((*it)->getOption().matches(Id0) || if ((*it)->getOption().matches(Id0) ||
(*it)->getOption().matches(Id1) || (*it)->getOption().matches(Id1) ||
@ -106,7 +106,7 @@ Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1, Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
OptSpecifier Id2, OptSpecifier Id3) const { OptSpecifier Id2, OptSpecifier Id3) const {
Arg *Res = 0; Arg *Res = nullptr;
for (const_iterator it = begin(), ie = end(); it != ie; ++it) { for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
if ((*it)->getOption().matches(Id0) || if ((*it)->getOption().matches(Id0) ||
(*it)->getOption().matches(Id1) || (*it)->getOption().matches(Id1) ||
@ -123,7 +123,7 @@ Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1, Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
OptSpecifier Id2, OptSpecifier Id3, OptSpecifier Id2, OptSpecifier Id3,
OptSpecifier Id4) const { OptSpecifier Id4) const {
Arg *Res = 0; Arg *Res = nullptr;
for (const_iterator it = begin(), ie = end(); it != ie; ++it) { for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
if ((*it)->getOption().matches(Id0) || if ((*it)->getOption().matches(Id0) ||
(*it)->getOption().matches(Id1) || (*it)->getOption().matches(Id1) ||
@ -141,7 +141,7 @@ Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1, Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
OptSpecifier Id2, OptSpecifier Id3, OptSpecifier Id2, OptSpecifier Id3,
OptSpecifier Id4, OptSpecifier Id5) const { OptSpecifier Id4, OptSpecifier Id5) const {
Arg *Res = 0; Arg *Res = nullptr;
for (const_iterator it = begin(), ie = end(); it != ie; ++it) { for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
if ((*it)->getOption().matches(Id0) || if ((*it)->getOption().matches(Id0) ||
(*it)->getOption().matches(Id1) || (*it)->getOption().matches(Id1) ||
@ -161,7 +161,7 @@ Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
OptSpecifier Id2, OptSpecifier Id3, OptSpecifier Id2, OptSpecifier Id3,
OptSpecifier Id4, OptSpecifier Id5, OptSpecifier Id4, OptSpecifier Id5,
OptSpecifier Id6) const { OptSpecifier Id6) const {
Arg *Res = 0; Arg *Res = nullptr;
for (const_iterator it = begin(), ie = end(); it != ie; ++it) { for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
if ((*it)->getOption().matches(Id0) || if ((*it)->getOption().matches(Id0) ||
(*it)->getOption().matches(Id1) || (*it)->getOption().matches(Id1) ||
@ -182,7 +182,7 @@ Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
OptSpecifier Id2, OptSpecifier Id3, OptSpecifier Id2, OptSpecifier Id3,
OptSpecifier Id4, OptSpecifier Id5, OptSpecifier Id4, OptSpecifier Id5,
OptSpecifier Id6, OptSpecifier Id7) const { OptSpecifier Id6, OptSpecifier Id7) const {
Arg *Res = 0; Arg *Res = nullptr;
for (const_iterator it = begin(), ie = end(); it != ie; ++it) { for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
if ((*it)->getOption().matches(Id0) || if ((*it)->getOption().matches(Id0) ||
(*it)->getOption().matches(Id1) || (*it)->getOption().matches(Id1) ||

View File

@ -62,7 +62,7 @@ static inline bool operator<(const OptTable::Info &A, const OptTable::Info &B) {
for (const char * const *APre = A.Prefixes, for (const char * const *APre = A.Prefixes,
* const *BPre = B.Prefixes; * const *BPre = B.Prefixes;
*APre != 0 && *BPre != 0; ++APre, ++BPre) { *APre != nullptr && *BPre != nullptr; ++APre, ++BPre){
if (int N = StrCmpOptionName(*APre, *BPre)) if (int N = StrCmpOptionName(*APre, *BPre))
return N < 0; return N < 0;
} }
@ -136,7 +136,7 @@ OptTable::OptTable(const Info *_OptionInfos, unsigned _NumOptionInfos,
for (unsigned i = FirstSearchableIndex + 1, e = getNumOptions() + 1; for (unsigned i = FirstSearchableIndex + 1, e = getNumOptions() + 1;
i != e; ++i) { i != e; ++i) {
if (const char *const *P = getInfo(i).Prefixes) { if (const char *const *P = getInfo(i).Prefixes) {
for (; *P != 0; ++P) { for (; *P != nullptr; ++P) {
PrefixesUnion.insert(*P); PrefixesUnion.insert(*P);
} }
} }
@ -160,7 +160,7 @@ OptTable::~OptTable() {
const Option OptTable::getOption(OptSpecifier Opt) const { const Option OptTable::getOption(OptSpecifier Opt) const {
unsigned id = Opt.getID(); unsigned id = Opt.getID();
if (id == 0) if (id == 0)
return Option(0, 0); return Option(nullptr, nullptr);
assert((unsigned) (id - 1) < getNumOptions() && "Invalid ID."); assert((unsigned) (id - 1) < getNumOptions() && "Invalid ID.");
return Option(&getInfo(id), this); return Option(&getInfo(id), this);
} }
@ -178,7 +178,7 @@ static bool isInput(const llvm::StringSet<> &Prefixes, StringRef Arg) {
/// \returns Matched size. 0 means no match. /// \returns Matched size. 0 means no match.
static unsigned matchOption(const OptTable::Info *I, StringRef Str, static unsigned matchOption(const OptTable::Info *I, StringRef Str,
bool IgnoreCase) { 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); StringRef Prefix(*Pre);
if (Str.startswith(Prefix)) { if (Str.startswith(Prefix)) {
StringRef Rest = Str.substr(Prefix.size()); StringRef Rest = Str.substr(Prefix.size());
@ -240,7 +240,7 @@ Arg *OptTable::ParseOneArg(const ArgList &Args, unsigned &Index,
// Otherwise, see if this argument was missing values. // Otherwise, see if this argument was missing values.
if (Prev != Index) if (Prev != Index)
return 0; return nullptr;
} }
// If we failed to find an option and this arg started with /, then it's // If we failed to find an option and this arg started with /, then it's

View File

@ -58,8 +58,8 @@ void Option::dump() const {
if (Info->Prefixes) { if (Info->Prefixes) {
llvm::errs() << " Prefixes:["; llvm::errs() << " Prefixes:[";
for (const char * const *Pre = Info->Prefixes; *Pre != 0; ++Pre) { for (const char * const *Pre = Info->Prefixes; *Pre != nullptr; ++Pre) {
llvm::errs() << '"' << *Pre << (*(Pre + 1) == 0 ? "\"" : "\", "); llvm::errs() << '"' << *Pre << (*(Pre + 1) == nullptr ? "\"" : "\", ");
} }
llvm::errs() << ']'; llvm::errs() << ']';
} }
@ -116,7 +116,7 @@ Arg *Option::accept(const ArgList &Args,
switch (getKind()) { switch (getKind()) {
case FlagClass: { case FlagClass: {
if (ArgSize != strlen(Args.getArgString(Index))) if (ArgSize != strlen(Args.getArgString(Index)))
return 0; return nullptr;
Arg *A = new Arg(UnaliasedOption, Spelling, Index++); Arg *A = new Arg(UnaliasedOption, Spelling, Index++);
if (getAliasArgs()) { if (getAliasArgs()) {
@ -166,11 +166,11 @@ Arg *Option::accept(const ArgList &Args,
// Matches iff this is an exact match. // Matches iff this is an exact match.
// FIXME: Avoid strlen. // FIXME: Avoid strlen.
if (ArgSize != strlen(Args.getArgString(Index))) if (ArgSize != strlen(Args.getArgString(Index)))
return 0; return nullptr;
Index += 2; Index += 2;
if (Index > Args.getNumInputArgStrings()) if (Index > Args.getNumInputArgStrings())
return 0; return nullptr;
return new Arg(UnaliasedOption, Spelling, return new Arg(UnaliasedOption, Spelling,
Index - 2, Args.getArgString(Index - 1)); Index - 2, Args.getArgString(Index - 1));
@ -178,11 +178,11 @@ Arg *Option::accept(const ArgList &Args,
// Matches iff this is an exact match. // Matches iff this is an exact match.
// FIXME: Avoid strlen. // FIXME: Avoid strlen.
if (ArgSize != strlen(Args.getArgString(Index))) if (ArgSize != strlen(Args.getArgString(Index)))
return 0; return nullptr;
Index += 1 + getNumArgs(); Index += 1 + getNumArgs();
if (Index > Args.getNumInputArgStrings()) if (Index > Args.getNumInputArgStrings())
return 0; return nullptr;
Arg *A = new Arg(UnaliasedOption, Spelling, Index - 1 - getNumArgs(), Arg *A = new Arg(UnaliasedOption, Spelling, Index - 1 - getNumArgs(),
Args.getArgString(Index - getNumArgs())); Args.getArgString(Index - getNumArgs()));
@ -201,7 +201,7 @@ Arg *Option::accept(const ArgList &Args,
// Otherwise it must be separate. // Otherwise it must be separate.
Index += 2; Index += 2;
if (Index > Args.getNumInputArgStrings()) if (Index > Args.getNumInputArgStrings())
return 0; return nullptr;
return new Arg(UnaliasedOption, Spelling, return new Arg(UnaliasedOption, Spelling,
Index - 2, Args.getArgString(Index - 1)); Index - 2, Args.getArgString(Index - 1));
@ -210,7 +210,7 @@ Arg *Option::accept(const ArgList &Args,
// Always matches. // Always matches.
Index += 2; Index += 2;
if (Index > Args.getNumInputArgStrings()) if (Index > Args.getNumInputArgStrings())
return 0; return nullptr;
return new Arg(UnaliasedOption, Spelling, Index - 2, return new Arg(UnaliasedOption, Spelling, Index - 2,
Args.getArgString(Index - 2) + ArgSize, Args.getArgString(Index - 2) + ArgSize,
@ -219,7 +219,7 @@ Arg *Option::accept(const ArgList &Args,
// Matches iff this is an exact match. // Matches iff this is an exact match.
// FIXME: Avoid strlen. // FIXME: Avoid strlen.
if (ArgSize != strlen(Args.getArgString(Index))) if (ArgSize != strlen(Args.getArgString(Index)))
return 0; return nullptr;
Arg *A = new Arg(UnaliasedOption, Spelling, Index++); Arg *A = new Arg(UnaliasedOption, Spelling, Index++);
while (Index < Args.getNumInputArgStrings()) while (Index < Args.getNumInputArgStrings())
A->getValues().push_back(Args.getArgString(Index++)); A->getValues().push_back(Args.getArgString(Index++));

View File

@ -1358,7 +1358,7 @@ APFloat::addOrSubtractSpecials(const APFloat &rhs, bool subtract)
{ {
switch (PackCategoriesIntoKey(category, rhs.category)) { switch (PackCategoriesIntoKey(category, rhs.category)) {
default: default:
llvm_unreachable(0); llvm_unreachable(nullptr);
case PackCategoriesIntoKey(fcNaN, fcZero): case PackCategoriesIntoKey(fcNaN, fcZero):
case PackCategoriesIntoKey(fcNaN, fcNormal): case PackCategoriesIntoKey(fcNaN, fcNormal):
@ -1485,7 +1485,7 @@ APFloat::multiplySpecials(const APFloat &rhs)
{ {
switch (PackCategoriesIntoKey(category, rhs.category)) { switch (PackCategoriesIntoKey(category, rhs.category)) {
default: default:
llvm_unreachable(0); llvm_unreachable(nullptr);
case PackCategoriesIntoKey(fcNaN, fcZero): case PackCategoriesIntoKey(fcNaN, fcZero):
case PackCategoriesIntoKey(fcNaN, fcNormal): case PackCategoriesIntoKey(fcNaN, fcNormal):
@ -1529,7 +1529,7 @@ APFloat::divideSpecials(const APFloat &rhs)
{ {
switch (PackCategoriesIntoKey(category, rhs.category)) { switch (PackCategoriesIntoKey(category, rhs.category)) {
default: default:
llvm_unreachable(0); llvm_unreachable(nullptr);
case PackCategoriesIntoKey(fcZero, fcNaN): case PackCategoriesIntoKey(fcZero, fcNaN):
case PackCategoriesIntoKey(fcNormal, fcNaN): case PackCategoriesIntoKey(fcNormal, fcNaN):
@ -1570,7 +1570,7 @@ APFloat::modSpecials(const APFloat &rhs)
{ {
switch (PackCategoriesIntoKey(category, rhs.category)) { switch (PackCategoriesIntoKey(category, rhs.category)) {
default: default:
llvm_unreachable(0); llvm_unreachable(nullptr);
case PackCategoriesIntoKey(fcNaN, fcZero): case PackCategoriesIntoKey(fcNaN, fcZero):
case PackCategoriesIntoKey(fcNaN, fcNormal): case PackCategoriesIntoKey(fcNaN, fcNormal):
@ -1882,7 +1882,7 @@ APFloat::compare(const APFloat &rhs) const
switch (PackCategoriesIntoKey(category, rhs.category)) { switch (PackCategoriesIntoKey(category, rhs.category)) {
default: default:
llvm_unreachable(0); llvm_unreachable(nullptr);
case PackCategoriesIntoKey(fcNaN, fcZero): case PackCategoriesIntoKey(fcNaN, fcZero):
case PackCategoriesIntoKey(fcNaN, fcNormal): case PackCategoriesIntoKey(fcNaN, fcNormal):
@ -3331,7 +3331,7 @@ APFloat::initFromAPInt(const fltSemantics* Sem, const APInt& api)
if (Sem == &PPCDoubleDouble) if (Sem == &PPCDoubleDouble)
return initFromPPCDoubleDoubleAPInt(api); return initFromPPCDoubleDoubleAPInt(api);
llvm_unreachable(0); llvm_unreachable(nullptr);
} }
APFloat APFloat

View File

@ -103,7 +103,7 @@ void cl::MarkOptionsChanged() {
static Option *RegisteredOptionList = nullptr; static Option *RegisteredOptionList = nullptr;
void Option::addArgument() { void Option::addArgument() {
assert(NextRegistered == 0 && "argument multiply registered!"); assert(!NextRegistered && "argument multiply registered!");
NextRegistered = RegisteredOptionList; NextRegistered = RegisteredOptionList;
RegisteredOptionList = this; RegisteredOptionList = this;
@ -111,7 +111,7 @@ void Option::addArgument() {
} }
void Option::removeArgument() { void Option::removeArgument() {
assert(NextRegistered != 0 && "argument never registered"); assert(NextRegistered && "argument never registered");
assert(RegisteredOptionList == this && "argument is not the last registered"); assert(RegisteredOptionList == this && "argument is not the last registered");
RegisteredOptionList = NextRegistered; RegisteredOptionList = NextRegistered;
MarkOptionsChanged(); MarkOptionsChanged();

View File

@ -109,7 +109,7 @@ raw_ostream &llvm::dbgs() {
if (EnableDebugBuffering && DebugFlag && DebugBufferSize != 0) if (EnableDebugBuffering && DebugFlag && DebugBufferSize != 0)
// TODO: Add a handler for SIGUSER1-type signals so the user can // TODO: Add a handler for SIGUSER1-type signals so the user can
// force a debug dump. // 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 // Otherwise we've already set the debug stream buffer size to
// zero, disabling buffering so it will output directly to errs(). // zero, disabling buffering so it will output directly to errs().
} }

View File

@ -305,7 +305,7 @@ FoldingSetImpl::Node
/// is not already in the map. InsertPos must be obtained from /// is not already in the map. InsertPos must be obtained from
/// FindNodeOrInsertPos. /// FindNodeOrInsertPos.
void FoldingSetImpl::InsertNode(Node *N, void *InsertPos) { void FoldingSetImpl::InsertNode(Node *N, void *InsertPos) {
assert(N->getNextInBucket() == 0); assert(!N->getNextInBucket());
// Do we need to grow the hashtable? // Do we need to grow the hashtable?
if (NumNodes+1 > NumBuckets*2) { if (NumNodes+1 > NumBuckets*2) {
GrowHashTable(); GrowHashTable();

View File

@ -45,7 +45,7 @@ void ManagedStaticBase::RegisterManagedStatic(void *(*Creator)(),
llvm_release_global_lock(); llvm_release_global_lock();
} else { } else {
assert(Ptr == 0 && DeleterFn == 0 && Next == 0 && assert(!Ptr && !DeleterFn && !Next &&
"Partially initialized ManagedStatic!?"); "Partially initialized ManagedStatic!?");
Ptr = Creator ? Creator() : nullptr; Ptr = Creator ? Creator() : nullptr;
DeleterFn = Deleter; DeleterFn = Deleter;

View File

@ -75,7 +75,7 @@ MutexImpl::MutexImpl( bool recursive)
MutexImpl::~MutexImpl() MutexImpl::~MutexImpl()
{ {
pthread_mutex_t* mutex = static_cast<pthread_mutex_t*>(data_); pthread_mutex_t* mutex = static_cast<pthread_mutex_t*>(data_);
assert(mutex != 0); assert(mutex != nullptr);
pthread_mutex_destroy(mutex); pthread_mutex_destroy(mutex);
free(mutex); free(mutex);
} }
@ -84,7 +84,7 @@ bool
MutexImpl::acquire() MutexImpl::acquire()
{ {
pthread_mutex_t* mutex = static_cast<pthread_mutex_t*>(data_); pthread_mutex_t* mutex = static_cast<pthread_mutex_t*>(data_);
assert(mutex != 0); assert(mutex != nullptr);
int errorcode = pthread_mutex_lock(mutex); int errorcode = pthread_mutex_lock(mutex);
return errorcode == 0; return errorcode == 0;
@ -94,7 +94,7 @@ bool
MutexImpl::release() MutexImpl::release()
{ {
pthread_mutex_t* mutex = static_cast<pthread_mutex_t*>(data_); pthread_mutex_t* mutex = static_cast<pthread_mutex_t*>(data_);
assert(mutex != 0); assert(mutex != nullptr);
int errorcode = pthread_mutex_unlock(mutex); int errorcode = pthread_mutex_unlock(mutex);
return errorcode == 0; return errorcode == 0;
@ -104,7 +104,7 @@ bool
MutexImpl::tryacquire() MutexImpl::tryacquire()
{ {
pthread_mutex_t* mutex = static_cast<pthread_mutex_t*>(data_); pthread_mutex_t* mutex = static_cast<pthread_mutex_t*>(data_);
assert(mutex != 0); assert(mutex != nullptr);
int errorcode = pthread_mutex_trylock(mutex); int errorcode = pthread_mutex_trylock(mutex);
return errorcode == 0; return errorcode == 0;

View File

@ -68,7 +68,7 @@ RWMutexImpl::RWMutexImpl()
RWMutexImpl::~RWMutexImpl() RWMutexImpl::~RWMutexImpl()
{ {
pthread_rwlock_t* rwlock = static_cast<pthread_rwlock_t*>(data_); pthread_rwlock_t* rwlock = static_cast<pthread_rwlock_t*>(data_);
assert(rwlock != 0); assert(rwlock != nullptr);
pthread_rwlock_destroy(rwlock); pthread_rwlock_destroy(rwlock);
free(rwlock); free(rwlock);
} }
@ -77,7 +77,7 @@ bool
RWMutexImpl::reader_acquire() RWMutexImpl::reader_acquire()
{ {
pthread_rwlock_t* rwlock = static_cast<pthread_rwlock_t*>(data_); pthread_rwlock_t* rwlock = static_cast<pthread_rwlock_t*>(data_);
assert(rwlock != 0); assert(rwlock != nullptr);
int errorcode = pthread_rwlock_rdlock(rwlock); int errorcode = pthread_rwlock_rdlock(rwlock);
return errorcode == 0; return errorcode == 0;
@ -87,7 +87,7 @@ bool
RWMutexImpl::reader_release() RWMutexImpl::reader_release()
{ {
pthread_rwlock_t* rwlock = static_cast<pthread_rwlock_t*>(data_); pthread_rwlock_t* rwlock = static_cast<pthread_rwlock_t*>(data_);
assert(rwlock != 0); assert(rwlock != nullptr);
int errorcode = pthread_rwlock_unlock(rwlock); int errorcode = pthread_rwlock_unlock(rwlock);
return errorcode == 0; return errorcode == 0;
@ -97,7 +97,7 @@ bool
RWMutexImpl::writer_acquire() RWMutexImpl::writer_acquire()
{ {
pthread_rwlock_t* rwlock = static_cast<pthread_rwlock_t*>(data_); pthread_rwlock_t* rwlock = static_cast<pthread_rwlock_t*>(data_);
assert(rwlock != 0); assert(rwlock != nullptr);
int errorcode = pthread_rwlock_wrlock(rwlock); int errorcode = pthread_rwlock_wrlock(rwlock);
return errorcode == 0; return errorcode == 0;
@ -107,7 +107,7 @@ bool
RWMutexImpl::writer_release() RWMutexImpl::writer_release()
{ {
pthread_rwlock_t* rwlock = static_cast<pthread_rwlock_t*>(data_); pthread_rwlock_t* rwlock = static_cast<pthread_rwlock_t*>(data_);
assert(rwlock != 0); assert(rwlock != nullptr);
int errorcode = pthread_rwlock_unlock(rwlock); int errorcode = pthread_rwlock_unlock(rwlock);
return errorcode == 0; return errorcode == 0;

View File

@ -100,7 +100,7 @@ static TimerGroup *getDefaultTimerGroup() {
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
void Timer::init(StringRef N) { void Timer::init(StringRef N) {
assert(TG == 0 && "Timer already initialized"); assert(!TG && "Timer already initialized");
Name.assign(N.begin(), N.end()); Name.assign(N.begin(), N.end());
Started = false; Started = false;
TG = getDefaultTimerGroup(); TG = getDefaultTimerGroup();
@ -108,7 +108,7 @@ void Timer::init(StringRef N) {
} }
void Timer::init(StringRef N, TimerGroup &tg) { void Timer::init(StringRef N, TimerGroup &tg) {
assert(TG == 0 && "Timer already initialized"); assert(!TG && "Timer already initialized");
Name.assign(N.begin(), N.end()); Name.assign(N.begin(), N.end());
Started = false; Started = false;
TG = &tg; TG = &tg;

View File

@ -87,8 +87,8 @@ void raw_ostream::SetBuffered() {
void raw_ostream::SetBufferAndMode(char *BufferStart, size_t Size, void raw_ostream::SetBufferAndMode(char *BufferStart, size_t Size,
BufferKind Mode) { BufferKind Mode) {
assert(((Mode == Unbuffered && BufferStart == 0 && Size == 0) || assert(((Mode == Unbuffered && !BufferStart && Size == 0) ||
(Mode != Unbuffered && BufferStart && Size)) && (Mode != Unbuffered && BufferStart && Size != 0)) &&
"stream must be unbuffered or have at least one byte"); "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 // Make sure the current buffer is free of content (we can't flush here; the
// child buffer management logic will be in write_impl). // child buffer management logic will be in write_impl).
@ -433,7 +433,7 @@ void format_object_base::home() {
raw_fd_ostream::raw_fd_ostream(const char *Filename, std::string &ErrorInfo, raw_fd_ostream::raw_fd_ostream(const char *Filename, std::string &ErrorInfo,
sys::fs::OpenFlags Flags) sys::fs::OpenFlags Flags)
: Error(false), UseAtomicWrites(false), pos(0) { : Error(false), UseAtomicWrites(false), pos(0) {
assert(Filename != 0 && "Filename is null"); assert(Filename && "Filename is null");
ErrorInfo.clear(); ErrorInfo.clear();
// Handle "-" as stdout. Note that when we do this, we consider ourself // Handle "-" as stdout. Note that when we do this, we consider ourself