mirror of
https://github.com/RPCS3/llvm.git
synced 2024-11-23 19:59:48 +00:00
[C++11] More 'nullptr' conversion. In some cases just using a boolean check instead of comparing to nullptr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206252 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
eb19b8f58b
commit
0b6cb7104b
@ -111,7 +111,7 @@ public:
|
||||
i != e; ++i)
|
||||
if (BlockInfoRecords[i].BlockID == BlockID)
|
||||
return &BlockInfoRecords[i];
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BlockInfo &getOrCreateBlockInfo(unsigned BlockID) {
|
||||
@ -200,9 +200,9 @@ class BitstreamCursor {
|
||||
|
||||
|
||||
public:
|
||||
BitstreamCursor() : BitStream(0), NextChar(0) {
|
||||
}
|
||||
BitstreamCursor(const BitstreamCursor &RHS) : BitStream(0), NextChar(0) {
|
||||
BitstreamCursor() : BitStream(nullptr), NextChar(0) {}
|
||||
BitstreamCursor(const BitstreamCursor &RHS)
|
||||
: BitStream(nullptr), NextChar(0) {
|
||||
operator=(RHS);
|
||||
}
|
||||
|
||||
@ -490,7 +490,7 @@ public:
|
||||
|
||||
/// EnterSubBlock - Having read the ENTER_SUBBLOCK abbrevid, enter
|
||||
/// the block, and return true if the block has an error.
|
||||
bool EnterSubBlock(unsigned BlockID, unsigned *NumWordsP = 0);
|
||||
bool EnterSubBlock(unsigned BlockID, unsigned *NumWordsP = nullptr);
|
||||
|
||||
bool ReadBlockEnd() {
|
||||
if (BlockScope.empty()) return true;
|
||||
@ -541,7 +541,7 @@ public:
|
||||
void skipRecord(unsigned AbbrevID);
|
||||
|
||||
unsigned readRecord(unsigned AbbrevID, SmallVectorImpl<uint64_t> &Vals,
|
||||
StringRef *Blob = 0);
|
||||
StringRef *Blob = nullptr);
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Abbrev Processing
|
||||
|
@ -204,7 +204,7 @@ public:
|
||||
i != e; ++i)
|
||||
if (BlockInfoRecords[i].BlockID == BlockID)
|
||||
return &BlockInfoRecords[i];
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void EnterSubblock(unsigned BlockID, unsigned CodeLen) {
|
||||
@ -347,7 +347,7 @@ private:
|
||||
EmitAbbreviatedField(EltEnc, (unsigned char)BlobData[i]);
|
||||
|
||||
// Know that blob data is consumed for assertion below.
|
||||
BlobData = 0;
|
||||
BlobData = nullptr;
|
||||
} else {
|
||||
// Emit a vbr6 to indicate the number of elements present.
|
||||
EmitVBR(static_cast<uint32_t>(Vals.size()-RecordIdx), 6);
|
||||
@ -378,7 +378,7 @@ private:
|
||||
WriteByte((unsigned char)BlobData[i]);
|
||||
|
||||
// Know that blob data is consumed for assertion below.
|
||||
BlobData = 0;
|
||||
BlobData = nullptr;
|
||||
} else {
|
||||
for (unsigned e = Vals.size(); RecordIdx != e; ++RecordIdx) {
|
||||
assert(isUInt<8>(Vals[RecordIdx]) &&
|
||||
@ -397,7 +397,7 @@ private:
|
||||
}
|
||||
}
|
||||
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!");
|
||||
}
|
||||
|
||||
|
@ -153,11 +153,11 @@ public:
|
||||
/// register is a PHI destination and the PHI's LiveOutInfo is not valid.
|
||||
const LiveOutInfo *GetLiveOutRegInfo(unsigned Reg) {
|
||||
if (!LiveOutRegInfo.inBounds(Reg))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
const LiveOutInfo *LOI = &LiveOutRegInfo[Reg];
|
||||
if (!LOI->IsValid)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
return LOI;
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ namespace llvm {
|
||||
void updateNode(const SUnit *SU) override {}
|
||||
|
||||
void releaseState() override {
|
||||
SUnits = 0;
|
||||
SUnits = nullptr;
|
||||
}
|
||||
|
||||
unsigned getLatency(unsigned NodeNum) const {
|
||||
|
@ -578,7 +578,7 @@ public:
|
||||
Ops.push_back(Op2);
|
||||
Ops.push_back(InGlue);
|
||||
return getNode(ISD::CALLSEQ_END, DL, NodeTys, &Ops[0],
|
||||
(unsigned)Ops.size() - (InGlue.getNode() == 0 ? 1 : 0));
|
||||
(unsigned)Ops.size() - (InGlue.getNode()==nullptr ? 1 : 0));
|
||||
}
|
||||
|
||||
/// getUNDEF - Return an UNDEF node. UNDEF does not have a useful SDLoc.
|
||||
@ -766,14 +766,15 @@ public:
|
||||
SDValue getLoad(EVT VT, SDLoc dl, SDValue Chain, SDValue Ptr,
|
||||
MachinePointerInfo PtrInfo, bool isVolatile,
|
||||
bool isNonTemporal, bool isInvariant, unsigned Alignment,
|
||||
const MDNode *TBAAInfo = 0, const MDNode *Ranges = 0);
|
||||
const MDNode *TBAAInfo = nullptr,
|
||||
const MDNode *Ranges = nullptr);
|
||||
SDValue getLoad(EVT VT, SDLoc dl, SDValue Chain, SDValue Ptr,
|
||||
MachineMemOperand *MMO);
|
||||
SDValue getExtLoad(ISD::LoadExtType ExtType, SDLoc dl, EVT VT,
|
||||
SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo,
|
||||
EVT MemVT, bool isVolatile,
|
||||
bool isNonTemporal, unsigned Alignment,
|
||||
const MDNode *TBAAInfo = 0);
|
||||
const MDNode *TBAAInfo = nullptr);
|
||||
SDValue getExtLoad(ISD::LoadExtType ExtType, SDLoc dl, EVT VT,
|
||||
SDValue Chain, SDValue Ptr, EVT MemVT,
|
||||
MachineMemOperand *MMO);
|
||||
@ -784,8 +785,8 @@ public:
|
||||
SDValue Chain, SDValue Ptr, SDValue Offset,
|
||||
MachinePointerInfo PtrInfo, EVT MemVT,
|
||||
bool isVolatile, bool isNonTemporal, bool isInvariant,
|
||||
unsigned Alignment, const MDNode *TBAAInfo = 0,
|
||||
const MDNode *Ranges = 0);
|
||||
unsigned Alignment, const MDNode *TBAAInfo = nullptr,
|
||||
const MDNode *Ranges = nullptr);
|
||||
SDValue getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType,
|
||||
EVT VT, SDLoc dl,
|
||||
SDValue Chain, SDValue Ptr, SDValue Offset,
|
||||
@ -796,14 +797,14 @@ public:
|
||||
SDValue getStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr,
|
||||
MachinePointerInfo PtrInfo, bool isVolatile,
|
||||
bool isNonTemporal, unsigned Alignment,
|
||||
const MDNode *TBAAInfo = 0);
|
||||
const MDNode *TBAAInfo = nullptr);
|
||||
SDValue getStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr,
|
||||
MachineMemOperand *MMO);
|
||||
SDValue getTruncStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr,
|
||||
MachinePointerInfo PtrInfo, EVT TVT,
|
||||
bool isNonTemporal, bool isVolatile,
|
||||
unsigned Alignment,
|
||||
const MDNode *TBAAInfo = 0);
|
||||
const MDNode *TBAAInfo = nullptr);
|
||||
SDValue getTruncStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr,
|
||||
EVT TVT, MachineMemOperand *MMO);
|
||||
SDValue getIndexedStore(SDValue OrigStoe, SDLoc dl, SDValue Base,
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
|
||||
private:
|
||||
struct ValueType {
|
||||
ValueType() : data(NULL) {
|
||||
ValueType() : data(nullptr) {
|
||||
uval = 0;
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ public:
|
||||
bool extractValue(DataExtractor data, uint32_t *offset_ptr,
|
||||
const DWARFUnit *u);
|
||||
bool isInlinedCStr() const {
|
||||
return Value.data != NULL && Value.data == (const uint8_t*)Value.cstr;
|
||||
return Value.data != nullptr && Value.data == (const uint8_t*)Value.cstr;
|
||||
}
|
||||
|
||||
/// getAsFoo functions below return the extracted value as Foo if only
|
||||
|
@ -181,7 +181,7 @@ public:
|
||||
/// freeMachineCodeForFunction works.
|
||||
static ExecutionEngine *create(Module *M,
|
||||
bool ForceInterpreter = false,
|
||||
std::string *ErrorStr = 0,
|
||||
std::string *ErrorStr = nullptr,
|
||||
CodeGenOpt::Level OptLevel =
|
||||
CodeGenOpt::Default,
|
||||
bool GVsWithCode = true);
|
||||
@ -193,8 +193,8 @@ public:
|
||||
/// Clients should make sure to initialize targets prior to calling this
|
||||
/// function.
|
||||
static ExecutionEngine *createJIT(Module *M,
|
||||
std::string *ErrorStr = 0,
|
||||
JITMemoryManager *JMM = 0,
|
||||
std::string *ErrorStr = nullptr,
|
||||
JITMemoryManager *JMM = nullptr,
|
||||
CodeGenOpt::Level OptLevel =
|
||||
CodeGenOpt::Default,
|
||||
bool GVsWithCode = true,
|
||||
@ -411,7 +411,7 @@ public:
|
||||
}
|
||||
|
||||
// The JIT overrides a version that actually does this.
|
||||
virtual void runJITOnFunction(Function *, MachineCodeInfo * = 0) { }
|
||||
virtual void runJITOnFunction(Function *, MachineCodeInfo * = nullptr) { }
|
||||
|
||||
/// getGlobalValueAtAddress - Return the LLVM global value object that starts
|
||||
/// at the specified address.
|
||||
@ -478,7 +478,7 @@ public:
|
||||
}
|
||||
|
||||
/// Return the target machine (if available).
|
||||
virtual TargetMachine *getTargetMachine() { return NULL; }
|
||||
virtual TargetMachine *getTargetMachine() { return nullptr; }
|
||||
|
||||
/// DisableLazyCompilation - When lazy compilation is off (the default), the
|
||||
/// JIT will eagerly compile every function reachable from the argument to
|
||||
@ -576,10 +576,10 @@ private:
|
||||
/// InitEngine - Does the common initialization of default options.
|
||||
void InitEngine() {
|
||||
WhichEngine = EngineKind::Either;
|
||||
ErrorStr = NULL;
|
||||
ErrorStr = nullptr;
|
||||
OptLevel = CodeGenOpt::Default;
|
||||
MCJMM = NULL;
|
||||
JMM = NULL;
|
||||
MCJMM = nullptr;
|
||||
JMM = nullptr;
|
||||
Options = TargetOptions();
|
||||
AllocateGVsWithCode = false;
|
||||
RelocModel = Reloc::Default;
|
||||
@ -610,7 +610,7 @@ public:
|
||||
/// the setJITMemoryManager() option.
|
||||
EngineBuilder &setMCJITMemoryManager(RTDyldMemoryManager *mcjmm) {
|
||||
MCJMM = mcjmm;
|
||||
JMM = NULL;
|
||||
JMM = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -622,7 +622,7 @@ public:
|
||||
/// memory manager. This option defaults to NULL. This option overrides
|
||||
/// setMCJITMemoryManager() as well.
|
||||
EngineBuilder &setJITMemoryManager(JITMemoryManager *jmm) {
|
||||
MCJMM = NULL;
|
||||
MCJMM = nullptr;
|
||||
JMM = jmm;
|
||||
return *this;
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ public:
|
||||
/// operations needed to reliably use the memory are also performed.
|
||||
///
|
||||
/// Returns true if an error occurred, false otherwise.
|
||||
virtual bool finalizeMemory(std::string *ErrMsg = 0) = 0;
|
||||
virtual bool finalizeMemory(std::string *ErrMsg = nullptr) = 0;
|
||||
};
|
||||
|
||||
// Create wrappers for C Binding types (see CBindingWrapping.h).
|
||||
|
@ -73,7 +73,7 @@ public:
|
||||
if (findOption(P->getPassArgument()) != getNumOptions()) {
|
||||
errs() << "Two passes with the same argument (-"
|
||||
<< P->getPassArgument() << ") attempted to be registered!\n";
|
||||
llvm_unreachable(0);
|
||||
llvm_unreachable(nullptr);
|
||||
}
|
||||
addLiteralOption(P->getPassArgument(), P, P->getPassName());
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ public:
|
||||
const char *getSymbolName(uint32_t index) {
|
||||
if (index < _symbols.size())
|
||||
return _symbols[index].name;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/// getDependentLibraryCount - Get the number of dependent libraries
|
||||
@ -141,7 +141,7 @@ public:
|
||||
const char *getDependentLibrary(uint32_t index) {
|
||||
if (index < _deplibs.size())
|
||||
return _deplibs[index];
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/// getLinkerOptCount - Get the number of linker options
|
||||
@ -153,7 +153,7 @@ public:
|
||||
const char *getLinkerOpt(uint32_t index) {
|
||||
if (index < _linkeropts.size())
|
||||
return _linkeropts[index];
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/// getLLVVMModule - Return the Module.
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
AsmLexer(const MCAsmInfo &MAI);
|
||||
~AsmLexer();
|
||||
|
||||
void setBuffer(const MemoryBuffer *buf, const char *ptr = NULL);
|
||||
void setBuffer(const MemoryBuffer *buf, const char *ptr = nullptr);
|
||||
|
||||
StringRef LexUntilEndOfStatement() override;
|
||||
StringRef LexUntilEndOfLine();
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
unsigned Length, Size, Type;
|
||||
|
||||
void clear() {
|
||||
OpDecl = 0;
|
||||
OpDecl = nullptr;
|
||||
IsVarDecl = false;
|
||||
Length = 1;
|
||||
Size = 0;
|
||||
|
@ -63,7 +63,7 @@ struct ParseInstructionInfo {
|
||||
|
||||
SmallVectorImpl<AsmRewrite> *AsmRewrites;
|
||||
|
||||
ParseInstructionInfo() : AsmRewrites(0) {}
|
||||
ParseInstructionInfo() : AsmRewrites(nullptr) {}
|
||||
ParseInstructionInfo(SmallVectorImpl<AsmRewrite> *rewrites)
|
||||
: AsmRewrites(rewrites) {}
|
||||
|
||||
@ -179,7 +179,7 @@ public:
|
||||
virtual const MCExpr *applyModifierToExpr(const MCExpr *E,
|
||||
MCSymbolRefExpr::VariantKind,
|
||||
MCContext &Ctx) {
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual void onLabelParsed(MCSymbol *Symbol) { };
|
||||
|
@ -95,15 +95,15 @@ public:
|
||||
bool FullPath = false) const;
|
||||
|
||||
error_code getAsBinary(OwningPtr<Binary> &Result,
|
||||
LLVMContext *Context = 0) const;
|
||||
LLVMContext *Context = nullptr) const;
|
||||
error_code getAsBinary(std::unique_ptr<Binary> &Result,
|
||||
LLVMContext *Context = 0) const;
|
||||
LLVMContext *Context = nullptr) const;
|
||||
};
|
||||
|
||||
class child_iterator {
|
||||
Child child;
|
||||
public:
|
||||
child_iterator() : child(Child(0, 0)) {}
|
||||
child_iterator() : child(Child(nullptr, nullptr)) {}
|
||||
child_iterator(const Child &c) : child(c) {}
|
||||
const Child* operator->() const {
|
||||
return &child;
|
||||
|
@ -464,7 +464,7 @@ public:
|
||||
// The iterator for the import directory table.
|
||||
class ImportDirectoryEntryRef {
|
||||
public:
|
||||
ImportDirectoryEntryRef() : OwningObject(0) {}
|
||||
ImportDirectoryEntryRef() : OwningObject(nullptr) {}
|
||||
ImportDirectoryEntryRef(const import_directory_table_entry *Table, uint32_t I,
|
||||
const COFFObjectFile *Owner)
|
||||
: ImportTable(Table), Index(I), OwningObject(Owner) {}
|
||||
@ -488,7 +488,7 @@ private:
|
||||
// The iterator for the export directory table entry.
|
||||
class ExportDirectoryEntryRef {
|
||||
public:
|
||||
ExportDirectoryEntryRef() : OwningObject(0) {}
|
||||
ExportDirectoryEntryRef() : OwningObject(nullptr) {}
|
||||
ExportDirectoryEntryRef(const export_directory_table_entry *Table, uint32_t I,
|
||||
const COFFObjectFile *Owner)
|
||||
: ExportTable(Table), Index(I), OwningObject(Owner) {}
|
||||
|
@ -604,14 +604,14 @@ typename ELFFile<ELFT>::uintX_t ELFFile<ELFT>::getStringTableIndex() const {
|
||||
template <class ELFT>
|
||||
ELFFile<ELFT>::ELFFile(MemoryBuffer *Object, error_code &ec)
|
||||
: Buf(Object),
|
||||
SectionHeaderTable(0),
|
||||
dot_shstrtab_sec(0),
|
||||
dot_strtab_sec(0),
|
||||
dot_symtab_sec(0),
|
||||
SymbolTableSectionHeaderIndex(0),
|
||||
dot_gnu_version_sec(0),
|
||||
dot_gnu_version_r_sec(0),
|
||||
dot_gnu_version_d_sec(0),
|
||||
SectionHeaderTable(nullptr),
|
||||
dot_shstrtab_sec(nullptr),
|
||||
dot_strtab_sec(nullptr),
|
||||
dot_symtab_sec(nullptr),
|
||||
SymbolTableSectionHeaderIndex(nullptr),
|
||||
dot_gnu_version_sec(nullptr),
|
||||
dot_gnu_version_r_sec(nullptr),
|
||||
dot_gnu_version_d_sec(nullptr),
|
||||
dt_soname(nullptr) {
|
||||
const uint64_t FileSize = Buf->getBufferSize();
|
||||
|
||||
@ -679,19 +679,19 @@ ELFFile<ELFT>::ELFFile(MemoryBuffer *Object, error_code &ec)
|
||||
DynamicRegion.EntSize = SecI->sh_entsize;
|
||||
break;
|
||||
case ELF::SHT_GNU_versym:
|
||||
if (dot_gnu_version_sec != NULL)
|
||||
if (dot_gnu_version_sec != nullptr)
|
||||
// FIXME: Proper error handling.
|
||||
report_fatal_error("More than one .gnu.version section!");
|
||||
dot_gnu_version_sec = &*SecI;
|
||||
break;
|
||||
case ELF::SHT_GNU_verdef:
|
||||
if (dot_gnu_version_d_sec != NULL)
|
||||
if (dot_gnu_version_d_sec != nullptr)
|
||||
// FIXME: Proper error handling.
|
||||
report_fatal_error("More than one .gnu.version_d section!");
|
||||
dot_gnu_version_d_sec = &*SecI;
|
||||
break;
|
||||
case ELF::SHT_GNU_verneed:
|
||||
if (dot_gnu_version_r_sec != NULL)
|
||||
if (dot_gnu_version_r_sec != nullptr)
|
||||
// FIXME: Proper error handling.
|
||||
report_fatal_error("More than one .gnu.version_r section!");
|
||||
dot_gnu_version_r_sec = &*SecI;
|
||||
@ -769,7 +769,7 @@ typename ELFFile<ELFT>::Elf_Sym_Iter ELFFile<ELFT>::begin_symbols() const {
|
||||
template <class ELFT>
|
||||
typename ELFFile<ELFT>::Elf_Sym_Iter ELFFile<ELFT>::end_symbols() const {
|
||||
if (!dot_symtab_sec)
|
||||
return Elf_Sym_Iter(0, 0, false);
|
||||
return Elf_Sym_Iter(0, nullptr, false);
|
||||
return Elf_Sym_Iter(dot_symtab_sec->sh_entsize,
|
||||
(const char *)base() + dot_symtab_sec->sh_offset +
|
||||
dot_symtab_sec->sh_size,
|
||||
@ -782,14 +782,14 @@ ELFFile<ELFT>::begin_dynamic_table() const {
|
||||
if (DynamicRegion.Addr)
|
||||
return Elf_Dyn_Iter(DynamicRegion.EntSize,
|
||||
(const char *)DynamicRegion.Addr);
|
||||
return Elf_Dyn_Iter(0, 0);
|
||||
return Elf_Dyn_Iter(0, nullptr);
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
typename ELFFile<ELFT>::Elf_Dyn_Iter
|
||||
ELFFile<ELFT>::end_dynamic_table(bool NULLEnd) const {
|
||||
if (!DynamicRegion.Addr)
|
||||
return Elf_Dyn_Iter(0, 0);
|
||||
return Elf_Dyn_Iter(0, nullptr);
|
||||
Elf_Dyn_Iter Ret(DynamicRegion.EntSize,
|
||||
(const char *)DynamicRegion.Addr + DynamicRegion.Size);
|
||||
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
ObjectForArch(const MachOUniversalBinary *Parent, uint32_t Index);
|
||||
|
||||
void clear() {
|
||||
Parent = 0;
|
||||
Parent = nullptr;
|
||||
Index = 0;
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ public:
|
||||
return ObjectForArch(this, 0);
|
||||
}
|
||||
object_iterator end_objects() const {
|
||||
return ObjectForArch(0, 0);
|
||||
return ObjectForArch(nullptr, 0);
|
||||
}
|
||||
|
||||
uint32_t getNumberOfObjects() const { return NumberOfObjects; }
|
||||
|
@ -63,11 +63,11 @@ private:
|
||||
|
||||
public:
|
||||
Arg(const Option Opt, StringRef Spelling, unsigned Index,
|
||||
const Arg *BaseArg = 0);
|
||||
const Arg *BaseArg = nullptr);
|
||||
Arg(const Option Opt, StringRef Spelling, unsigned Index,
|
||||
const char *Value0, const Arg *BaseArg = 0);
|
||||
const char *Value0, const Arg *BaseArg = nullptr);
|
||||
Arg(const Option Opt, StringRef Spelling, unsigned Index,
|
||||
const char *Value0, const char *Value1, const Arg *BaseArg = 0);
|
||||
const char *Value0, const char *Value1, const Arg *BaseArg = nullptr);
|
||||
~Arg();
|
||||
|
||||
const Option getOption() const { return Opt; }
|
||||
|
@ -160,16 +160,16 @@ public:
|
||||
///
|
||||
/// \p Claim Whether the argument should be claimed, if it exists.
|
||||
bool hasArgNoClaim(OptSpecifier Id) const {
|
||||
return getLastArgNoClaim(Id) != 0;
|
||||
return getLastArgNoClaim(Id) != nullptr;
|
||||
}
|
||||
bool hasArg(OptSpecifier Id) const {
|
||||
return getLastArg(Id) != 0;
|
||||
return getLastArg(Id) != nullptr;
|
||||
}
|
||||
bool hasArg(OptSpecifier Id0, OptSpecifier Id1) const {
|
||||
return getLastArg(Id0, Id1) != 0;
|
||||
return getLastArg(Id0, Id1) != nullptr;
|
||||
}
|
||||
bool hasArg(OptSpecifier Id0, OptSpecifier Id1, OptSpecifier Id2) const {
|
||||
return getLastArg(Id0, Id1, Id2) != 0;
|
||||
return getLastArg(Id0, Id1, Id2) != nullptr;
|
||||
}
|
||||
|
||||
/// getLastArg - Return the last argument matching \p Id, or null.
|
||||
|
@ -73,7 +73,7 @@ public:
|
||||
~Option();
|
||||
|
||||
bool isValid() const {
|
||||
return Info != 0;
|
||||
return Info != nullptr;
|
||||
}
|
||||
|
||||
unsigned getID() const {
|
||||
|
@ -194,7 +194,7 @@ struct has_ScalarBitSetTraits
|
||||
static double test(...);
|
||||
|
||||
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>
|
||||
struct MappingNormalization {
|
||||
MappingNormalization(IO &i_o, TFinal &Obj)
|
||||
: io(i_o), BufPtr(NULL), Result(Obj) {
|
||||
: io(i_o), BufPtr(nullptr), Result(Obj) {
|
||||
if ( io.outputting() ) {
|
||||
BufPtr = new (&Buffer) TNorm(io, Obj);
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
/// intrinsic, Tys should point to an array of numTys pointers to Type,
|
||||
/// and must provide exactly one type for each overloaded type in the
|
||||
/// intrinsic.
|
||||
virtual std::string getName(unsigned IID, Type **Tys = 0,
|
||||
virtual std::string getName(unsigned IID, Type **Tys = nullptr,
|
||||
unsigned numTys = 0) const = 0;
|
||||
|
||||
/// Look up target intrinsic by name. Return intrinsic ID or 0 for unknown
|
||||
@ -56,7 +56,7 @@ public:
|
||||
/// Create or insert an LLVM Function declaration for an intrinsic,
|
||||
/// and return it. The Tys and numTys are for intrinsics with overloaded
|
||||
/// types. See above for more information.
|
||||
virtual Function *getDeclaration(Module *M, unsigned ID, Type **Tys = 0,
|
||||
virtual Function *getDeclaration(Module *M, unsigned ID, Type **Tys = nullptr,
|
||||
unsigned numTys = 0) const = 0;
|
||||
};
|
||||
|
||||
|
@ -96,8 +96,8 @@ struct ClonedCodeInfo {
|
||||
///
|
||||
BasicBlock *CloneBasicBlock(const BasicBlock *BB,
|
||||
ValueToValueMapTy &VMap,
|
||||
const Twine &NameSuffix = "", Function *F = 0,
|
||||
ClonedCodeInfo *CodeInfo = 0);
|
||||
const Twine &NameSuffix = "", Function *F = nullptr,
|
||||
ClonedCodeInfo *CodeInfo = nullptr);
|
||||
|
||||
/// CloneFunction - Return a copy of the specified function, but without
|
||||
/// embedding the function into another module. Also, any references specified
|
||||
@ -114,7 +114,7 @@ BasicBlock *CloneBasicBlock(const BasicBlock *BB,
|
||||
Function *CloneFunction(const Function *F,
|
||||
ValueToValueMapTy &VMap,
|
||||
bool ModuleLevelChanges,
|
||||
ClonedCodeInfo *CodeInfo = 0);
|
||||
ClonedCodeInfo *CodeInfo = nullptr);
|
||||
|
||||
/// Clone OldFunc into NewFunc, transforming the old arguments into references
|
||||
/// to VMap values. Note that if NewFunc already has basic blocks, the ones
|
||||
@ -130,9 +130,9 @@ void CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
|
||||
bool ModuleLevelChanges,
|
||||
SmallVectorImpl<ReturnInst*> &Returns,
|
||||
const char *NameSuffix = "",
|
||||
ClonedCodeInfo *CodeInfo = 0,
|
||||
ValueMapTypeRemapper *TypeMapper = 0,
|
||||
ValueMaterializer *Materializer = 0);
|
||||
ClonedCodeInfo *CodeInfo = nullptr,
|
||||
ValueMapTypeRemapper *TypeMapper = nullptr,
|
||||
ValueMaterializer *Materializer = nullptr);
|
||||
|
||||
/// CloneAndPruneFunctionInto - This works exactly like CloneFunctionInto,
|
||||
/// except that it does some simple constant prop and DCE on the fly. The
|
||||
@ -150,16 +150,16 @@ void CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc,
|
||||
bool ModuleLevelChanges,
|
||||
SmallVectorImpl<ReturnInst*> &Returns,
|
||||
const char *NameSuffix = "",
|
||||
ClonedCodeInfo *CodeInfo = 0,
|
||||
const DataLayout *DL = 0,
|
||||
Instruction *TheCall = 0);
|
||||
ClonedCodeInfo *CodeInfo = nullptr,
|
||||
const DataLayout *DL = nullptr,
|
||||
Instruction *TheCall = nullptr);
|
||||
|
||||
|
||||
/// InlineFunctionInfo - This class captures the data input to the
|
||||
/// InlineFunction call, and records the auxiliary results produced by it.
|
||||
class InlineFunctionInfo {
|
||||
public:
|
||||
explicit InlineFunctionInfo(CallGraph *cg = 0, const DataLayout *DL = 0)
|
||||
explicit InlineFunctionInfo(CallGraph *cg = nullptr, const DataLayout *DL = nullptr)
|
||||
: CG(cg), DL(DL) {}
|
||||
|
||||
/// CG - If non-null, InlineFunction will update the callgraph to reflect the
|
||||
|
@ -68,27 +68,27 @@ namespace llvm {
|
||||
|
||||
Value *MapValue(const Value *V, ValueToValueMapTy &VM,
|
||||
RemapFlags Flags = RF_None,
|
||||
ValueMapTypeRemapper *TypeMapper = 0,
|
||||
ValueMaterializer *Materializer = 0);
|
||||
ValueMapTypeRemapper *TypeMapper = nullptr,
|
||||
ValueMaterializer *Materializer = nullptr);
|
||||
|
||||
void RemapInstruction(Instruction *I, ValueToValueMapTy &VM,
|
||||
RemapFlags Flags = RF_None,
|
||||
ValueMapTypeRemapper *TypeMapper = 0,
|
||||
ValueMaterializer *Materializer = 0);
|
||||
ValueMapTypeRemapper *TypeMapper = nullptr,
|
||||
ValueMaterializer *Materializer = nullptr);
|
||||
|
||||
/// MapValue - provide versions that preserve type safety for MDNode and
|
||||
/// Constants.
|
||||
inline MDNode *MapValue(const MDNode *V, ValueToValueMapTy &VM,
|
||||
RemapFlags Flags = RF_None,
|
||||
ValueMapTypeRemapper *TypeMapper = 0,
|
||||
ValueMaterializer *Materializer = 0) {
|
||||
ValueMapTypeRemapper *TypeMapper = nullptr,
|
||||
ValueMaterializer *Materializer = nullptr) {
|
||||
return cast<MDNode>(MapValue((const Value*)V, VM, Flags, TypeMapper,
|
||||
Materializer));
|
||||
}
|
||||
inline Constant *MapValue(const Constant *V, ValueToValueMapTy &VM,
|
||||
RemapFlags Flags = RF_None,
|
||||
ValueMapTypeRemapper *TypeMapper = 0,
|
||||
ValueMaterializer *Materializer = 0) {
|
||||
ValueMapTypeRemapper *TypeMapper = nullptr,
|
||||
ValueMaterializer *Materializer = nullptr) {
|
||||
return cast<Constant>(MapValue((const Value*)V, VM, Flags, TypeMapper,
|
||||
Materializer));
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ static bool isLabelChar(char C) {
|
||||
static const char *isLabelTail(const char *CurPtr) {
|
||||
while (1) {
|
||||
if (CurPtr[0] == ':') return CurPtr+1;
|
||||
if (!isLabelChar(CurPtr[0])) return 0;
|
||||
if (!isLabelChar(CurPtr[0])) return nullptr;
|
||||
++CurPtr;
|
||||
}
|
||||
}
|
||||
@ -435,8 +435,8 @@ lltok::Kind LLLexer::LexHash() {
|
||||
/// HexIntConstant [us]0x[0-9A-Fa-f]+
|
||||
lltok::Kind LLLexer::LexIdentifier() {
|
||||
const char *StartChar = CurPtr;
|
||||
const char *IntEnd = CurPtr[-1] == 'i' ? 0 : StartChar;
|
||||
const char *KeywordEnd = 0;
|
||||
const char *IntEnd = CurPtr[-1] == 'i' ? nullptr : StartChar;
|
||||
const char *KeywordEnd = nullptr;
|
||||
|
||||
for (; isLabelChar(*CurPtr); ++CurPtr) {
|
||||
// If we decide this is an integer, remember the end of the sequence.
|
||||
@ -455,7 +455,7 @@ lltok::Kind LLLexer::LexIdentifier() {
|
||||
|
||||
// Otherwise, this wasn't a label. If this was valid as an integer type,
|
||||
// return it.
|
||||
if (IntEnd == 0) IntEnd = CurPtr;
|
||||
if (!IntEnd) IntEnd = CurPtr;
|
||||
if (IntEnd != StartChar) {
|
||||
CurPtr = IntEnd;
|
||||
uint64_t NumBits = atoull(StartChar, CurPtr);
|
||||
@ -469,7 +469,7 @@ lltok::Kind LLLexer::LexIdentifier() {
|
||||
}
|
||||
|
||||
// Otherwise, this was a letter sequence. See which keyword this is.
|
||||
if (KeywordEnd == 0) KeywordEnd = CurPtr;
|
||||
if (!KeywordEnd) KeywordEnd = CurPtr;
|
||||
CurPtr = KeywordEnd;
|
||||
--StartChar;
|
||||
unsigned Len = CurPtr-StartChar;
|
||||
|
@ -57,7 +57,8 @@ bool LLParser::ValidateEndOfModule() {
|
||||
for (unsigned i = 0, e = MDList.size(); i != e; ++i) {
|
||||
unsigned SlotNo = MDList[i].MDSlot;
|
||||
|
||||
if (SlotNo >= NumberedMetadata.size() || NumberedMetadata[SlotNo] == 0)
|
||||
if (SlotNo >= NumberedMetadata.size() ||
|
||||
NumberedMetadata[SlotNo] == nullptr)
|
||||
return Error(MDList[i].Loc, "use of undefined metadata '!" +
|
||||
Twine(SlotNo) + "'");
|
||||
Inst->setMetadata(MDList[i].MDKind, NumberedMetadata[SlotNo]);
|
||||
@ -132,20 +133,20 @@ bool LLParser::ValidateEndOfModule() {
|
||||
// references after the function was defined. Resolve those now.
|
||||
while (!ForwardRefBlockAddresses.empty()) {
|
||||
// Okay, we are referencing an already-parsed function, resolve them now.
|
||||
Function *TheFn = 0;
|
||||
Function *TheFn = nullptr;
|
||||
const ValID &Fn = ForwardRefBlockAddresses.begin()->first;
|
||||
if (Fn.Kind == ValID::t_GlobalName)
|
||||
TheFn = M->getFunction(Fn.StrVal);
|
||||
else if (Fn.UIntVal < NumberedVals.size())
|
||||
TheFn = dyn_cast<Function>(NumberedVals[Fn.UIntVal]);
|
||||
|
||||
if (TheFn == 0)
|
||||
if (!TheFn)
|
||||
return Error(Fn.Loc, "unknown function referenced by blockaddress");
|
||||
|
||||
// Resolve all these references.
|
||||
if (ResolveForwardRefBlockAddresses(TheFn,
|
||||
ForwardRefBlockAddresses.begin()->second,
|
||||
0))
|
||||
nullptr))
|
||||
return true;
|
||||
|
||||
ForwardRefBlockAddresses.erase(ForwardRefBlockAddresses.begin());
|
||||
@ -206,7 +207,7 @@ bool LLParser::ResolveForwardRefBlockAddresses(Function *TheFn,
|
||||
TheFn->getValueSymbolTable().lookup(Refs[i].first.StrVal));
|
||||
}
|
||||
|
||||
if (Res == 0)
|
||||
if (!Res)
|
||||
return Error(Refs[i].first.Loc,
|
||||
"referenced value is not a basic block");
|
||||
|
||||
@ -364,7 +365,7 @@ bool LLParser::ParseUnnamedType() {
|
||||
if (TypeID >= NumberedTypes.size())
|
||||
NumberedTypes.resize(TypeID+1);
|
||||
|
||||
Type *Result = 0;
|
||||
Type *Result = nullptr;
|
||||
if (ParseStructDefinition(TypeLoc, "",
|
||||
NumberedTypes[TypeID], Result)) return true;
|
||||
|
||||
@ -391,7 +392,7 @@ bool LLParser::ParseNamedType() {
|
||||
ParseToken(lltok::kw_type, "expected 'type' after name"))
|
||||
return true;
|
||||
|
||||
Type *Result = 0;
|
||||
Type *Result = nullptr;
|
||||
if (ParseStructDefinition(NameLoc, Name,
|
||||
NamedTypes[Name], Result)) return true;
|
||||
|
||||
@ -523,10 +524,10 @@ bool LLParser::ParseMDNodeID(MDNode *&Result, unsigned &SlotNo) {
|
||||
if (ParseUInt32(SlotNo)) return true;
|
||||
|
||||
// Check existing MDNode.
|
||||
if (SlotNo < NumberedMetadata.size() && NumberedMetadata[SlotNo] != 0)
|
||||
if (SlotNo < NumberedMetadata.size() && NumberedMetadata[SlotNo] != nullptr)
|
||||
Result = NumberedMetadata[SlotNo];
|
||||
else
|
||||
Result = 0;
|
||||
Result = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -567,7 +568,7 @@ bool LLParser::ParseNamedMetadata() {
|
||||
if (ParseToken(lltok::exclaim, "Expected '!' here"))
|
||||
return true;
|
||||
|
||||
MDNode *N = 0;
|
||||
MDNode *N = nullptr;
|
||||
if (ParseMDNodeID(N)) return true;
|
||||
NMD->addOperand(N);
|
||||
} while (EatIfPresent(lltok::comma));
|
||||
@ -586,14 +587,14 @@ bool LLParser::ParseStandaloneMetadata() {
|
||||
unsigned MetadataID = 0;
|
||||
|
||||
LocTy TyLoc;
|
||||
Type *Ty = 0;
|
||||
Type *Ty = nullptr;
|
||||
SmallVector<Value *, 16> Elts;
|
||||
if (ParseUInt32(MetadataID) ||
|
||||
ParseToken(lltok::equal, "expected '=' here") ||
|
||||
ParseType(Ty, TyLoc) ||
|
||||
ParseToken(lltok::exclaim, "Expected '!' here") ||
|
||||
ParseToken(lltok::lbrace, "Expected '{' here") ||
|
||||
ParseMDNodeVector(Elts, NULL) ||
|
||||
ParseMDNodeVector(Elts, nullptr) ||
|
||||
ParseToken(lltok::rbrace, "expected end of metadata node"))
|
||||
return true;
|
||||
|
||||
@ -613,7 +614,7 @@ bool LLParser::ParseStandaloneMetadata() {
|
||||
if (MetadataID >= NumberedMetadata.size())
|
||||
NumberedMetadata.resize(MetadataID+1);
|
||||
|
||||
if (NumberedMetadata[MetadataID] != 0)
|
||||
if (NumberedMetadata[MetadataID] != nullptr)
|
||||
return TokError("Metadata id is already used");
|
||||
NumberedMetadata[MetadataID] = Init;
|
||||
}
|
||||
@ -720,7 +721,7 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
|
||||
LocTy IsExternallyInitializedLoc;
|
||||
LocTy TyLoc;
|
||||
|
||||
Type *Ty = 0;
|
||||
Type *Ty = nullptr;
|
||||
if (ParseOptionalThreadLocal(TLM) ||
|
||||
ParseOptionalAddrSpace(AddrSpace) ||
|
||||
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
|
||||
// present.
|
||||
Constant *Init = 0;
|
||||
Constant *Init = nullptr;
|
||||
if (!HasLinkage || (Linkage != GlobalValue::ExternalWeakLinkage &&
|
||||
Linkage != GlobalValue::ExternalLinkage)) {
|
||||
if (ParseGlobalValue(Ty, Init))
|
||||
@ -744,7 +745,7 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
|
||||
if (Ty->isFunctionTy() || Ty->isLabelTy())
|
||||
return Error(TyLoc, "invalid type for global variable");
|
||||
|
||||
GlobalVariable *GV = 0;
|
||||
GlobalVariable *GV = nullptr;
|
||||
|
||||
// See if the global was forward referenced, if so, use the global.
|
||||
if (!Name.empty()) {
|
||||
@ -762,9 +763,9 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
|
||||
}
|
||||
}
|
||||
|
||||
if (GV == 0) {
|
||||
GV = new GlobalVariable(*M, Ty, false, GlobalValue::ExternalLinkage, 0,
|
||||
Name, 0, GlobalVariable::NotThreadLocal,
|
||||
if (!GV) {
|
||||
GV = new GlobalVariable(*M, Ty, false, GlobalValue::ExternalLinkage, nullptr,
|
||||
Name, nullptr, GlobalVariable::NotThreadLocal,
|
||||
AddrSpace);
|
||||
} else {
|
||||
if (GV->getType()->getElementType() != Ty)
|
||||
@ -980,9 +981,9 @@ bool LLParser::ParseFnAttributeValuePairs(AttrBuilder &B,
|
||||
GlobalValue *LLParser::GetGlobalVal(const std::string &Name, Type *Ty,
|
||||
LocTy Loc) {
|
||||
PointerType *PTy = dyn_cast<PointerType>(Ty);
|
||||
if (PTy == 0) {
|
||||
if (!PTy) {
|
||||
Error(Loc, "global variable reference must have pointer type");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Look this name up in the normal function symbol table.
|
||||
@ -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
|
||||
// forward ref record.
|
||||
if (Val == 0) {
|
||||
if (!Val) {
|
||||
std::map<std::string, std::pair<GlobalValue*, LocTy> >::iterator
|
||||
I = ForwardRefVals.find(Name);
|
||||
if (I != ForwardRefVals.end())
|
||||
@ -1003,7 +1004,7 @@ GlobalValue *LLParser::GetGlobalVal(const std::string &Name, Type *Ty,
|
||||
if (Val->getType() == Ty) return Val;
|
||||
Error(Loc, "'@" + Name + "' defined with type '" +
|
||||
getTypeString(Val->getType()) + "'");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Otherwise, create a new forward reference for this value and remember it.
|
||||
@ -1012,8 +1013,8 @@ GlobalValue *LLParser::GetGlobalVal(const std::string &Name, Type *Ty,
|
||||
FwdVal = Function::Create(FT, GlobalValue::ExternalWeakLinkage, Name, M);
|
||||
else
|
||||
FwdVal = new GlobalVariable(*M, PTy->getElementType(), false,
|
||||
GlobalValue::ExternalWeakLinkage, 0, Name,
|
||||
0, GlobalVariable::NotThreadLocal,
|
||||
GlobalValue::ExternalWeakLinkage, nullptr, Name,
|
||||
nullptr, GlobalVariable::NotThreadLocal,
|
||||
PTy->getAddressSpace());
|
||||
|
||||
ForwardRefVals[Name] = std::make_pair(FwdVal, Loc);
|
||||
@ -1022,16 +1023,16 @@ GlobalValue *LLParser::GetGlobalVal(const std::string &Name, Type *Ty,
|
||||
|
||||
GlobalValue *LLParser::GetGlobalVal(unsigned ID, Type *Ty, LocTy Loc) {
|
||||
PointerType *PTy = dyn_cast<PointerType>(Ty);
|
||||
if (PTy == 0) {
|
||||
if (!PTy) {
|
||||
Error(Loc, "global variable reference must have pointer type");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GlobalValue *Val = ID < NumberedVals.size() ? NumberedVals[ID] : 0;
|
||||
GlobalValue *Val = ID < NumberedVals.size() ? NumberedVals[ID] : nullptr;
|
||||
|
||||
// If this is a forward reference for the value, see if we already created a
|
||||
// forward ref record.
|
||||
if (Val == 0) {
|
||||
if (!Val) {
|
||||
std::map<unsigned, std::pair<GlobalValue*, LocTy> >::iterator
|
||||
I = ForwardRefValIDs.find(ID);
|
||||
if (I != ForwardRefValIDs.end())
|
||||
@ -1043,7 +1044,7 @@ GlobalValue *LLParser::GetGlobalVal(unsigned ID, Type *Ty, LocTy Loc) {
|
||||
if (Val->getType() == Ty) return Val;
|
||||
Error(Loc, "'@" + Twine(ID) + "' defined with type '" +
|
||||
getTypeString(Val->getType()) + "'");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Otherwise, create a new forward reference for this value and remember it.
|
||||
@ -1052,7 +1053,7 @@ GlobalValue *LLParser::GetGlobalVal(unsigned ID, Type *Ty, LocTy Loc) {
|
||||
FwdVal = Function::Create(FT, GlobalValue::ExternalWeakLinkage, "", M);
|
||||
else
|
||||
FwdVal = new GlobalVariable(*M, PTy->getElementType(), false,
|
||||
GlobalValue::ExternalWeakLinkage, 0, "");
|
||||
GlobalValue::ExternalWeakLinkage, nullptr, "");
|
||||
|
||||
ForwardRefValIDs[ID] = std::make_pair(FwdVal, Loc);
|
||||
return FwdVal;
|
||||
@ -1638,7 +1639,7 @@ bool LLParser::ParseType(Type *&Result, bool AllowVoid) {
|
||||
|
||||
// If the type hasn't been defined yet, create a forward definition and
|
||||
// remember where that forward def'n was seen (in case it never is defined).
|
||||
if (Entry.first == 0) {
|
||||
if (!Entry.first) {
|
||||
Entry.first = StructType::create(Context, Lex.getStrVal());
|
||||
Entry.second = Lex.getLoc();
|
||||
}
|
||||
@ -1655,7 +1656,7 @@ bool LLParser::ParseType(Type *&Result, bool AllowVoid) {
|
||||
|
||||
// If the type hasn't been defined yet, create a forward definition and
|
||||
// remember where that forward def'n was seen (in case it never is defined).
|
||||
if (Entry.first == 0) {
|
||||
if (!Entry.first) {
|
||||
Entry.first = StructType::create(Context);
|
||||
Entry.second = Lex.getLoc();
|
||||
}
|
||||
@ -1731,7 +1732,7 @@ bool LLParser::ParseParameterList(SmallVectorImpl<ParamInfo> &ArgList,
|
||||
|
||||
// Parse the argument.
|
||||
LocTy ArgLoc;
|
||||
Type *ArgTy = 0;
|
||||
Type *ArgTy = nullptr;
|
||||
AttrBuilder ArgAttrs;
|
||||
Value *V;
|
||||
if (ParseType(ArgTy, ArgLoc))
|
||||
@ -1773,7 +1774,7 @@ bool LLParser::ParseArgumentList(SmallVectorImpl<ArgInfo> &ArgList,
|
||||
Lex.Lex();
|
||||
} else {
|
||||
LocTy TypeLoc = Lex.getLoc();
|
||||
Type *ArgTy = 0;
|
||||
Type *ArgTy = nullptr;
|
||||
AttrBuilder Attrs;
|
||||
std::string Name;
|
||||
|
||||
@ -1885,7 +1886,7 @@ bool LLParser::ParseStructDefinition(SMLoc TypeLoc, StringRef Name,
|
||||
Entry.second = SMLoc();
|
||||
|
||||
// If this type number has never been uttered, create it.
|
||||
if (Entry.first == 0)
|
||||
if (!Entry.first)
|
||||
Entry.first = StructType::create(Context, Name);
|
||||
ResultTy = Entry.first;
|
||||
return false;
|
||||
@ -1901,7 +1902,7 @@ bool LLParser::ParseStructDefinition(SMLoc TypeLoc, StringRef Name,
|
||||
if (Entry.first)
|
||||
return Error(TypeLoc, "forward references to non-struct type");
|
||||
|
||||
ResultTy = 0;
|
||||
ResultTy = nullptr;
|
||||
if (isPacked)
|
||||
return ParseArrayVectorType(ResultTy, true);
|
||||
return ParseType(ResultTy);
|
||||
@ -1911,7 +1912,7 @@ bool LLParser::ParseStructDefinition(SMLoc TypeLoc, StringRef Name,
|
||||
Entry.second = SMLoc();
|
||||
|
||||
// If this type number has never been uttered, create it.
|
||||
if (Entry.first == 0)
|
||||
if (!Entry.first)
|
||||
Entry.first = StructType::create(Context, Name);
|
||||
|
||||
StructType *STy = cast<StructType>(Entry.first);
|
||||
@ -1942,7 +1943,7 @@ bool LLParser::ParseStructBody(SmallVectorImpl<Type*> &Body) {
|
||||
return false;
|
||||
|
||||
LocTy EltTyLoc = Lex.getLoc();
|
||||
Type *Ty = 0;
|
||||
Type *Ty = nullptr;
|
||||
if (ParseType(Ty)) return true;
|
||||
Body.push_back(Ty);
|
||||
|
||||
@ -1980,7 +1981,7 @@ bool LLParser::ParseArrayVectorType(Type *&Result, bool isVector) {
|
||||
return true;
|
||||
|
||||
LocTy TypeLoc = Lex.getLoc();
|
||||
Type *EltTy = 0;
|
||||
Type *EltTy = nullptr;
|
||||
if (ParseType(EltTy)) return true;
|
||||
|
||||
if (ParseToken(isVector ? lltok::greater : lltok::rsquare,
|
||||
@ -2026,7 +2027,7 @@ LLParser::PerFunctionState::~PerFunctionState() {
|
||||
I->second.first->replaceAllUsesWith(
|
||||
UndefValue::get(I->second.first->getType()));
|
||||
delete I->second.first;
|
||||
I->second.first = 0;
|
||||
I->second.first = nullptr;
|
||||
}
|
||||
|
||||
for (std::map<unsigned, std::pair<Value*, LocTy> >::iterator
|
||||
@ -2035,7 +2036,7 @@ LLParser::PerFunctionState::~PerFunctionState() {
|
||||
I->second.first->replaceAllUsesWith(
|
||||
UndefValue::get(I->second.first->getType()));
|
||||
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
|
||||
// forward ref record.
|
||||
if (Val == 0) {
|
||||
if (!Val) {
|
||||
std::map<std::string, std::pair<Value*, LocTy> >::iterator
|
||||
I = ForwardRefVals.find(Name);
|
||||
if (I != ForwardRefVals.end())
|
||||
@ -2099,13 +2100,13 @@ Value *LLParser::PerFunctionState::GetVal(const std::string &Name,
|
||||
else
|
||||
P.Error(Loc, "'%" + Name + "' defined with type '" +
|
||||
getTypeString(Val->getType()) + "'");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Don't make placeholders with invalid type.
|
||||
if (!Ty->isFirstClassType() && !Ty->isLabelTy()) {
|
||||
P.Error(Loc, "invalid use of a non-first-class type");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Otherwise, create a new forward reference for this value and remember it.
|
||||
@ -2122,11 +2123,11 @@ Value *LLParser::PerFunctionState::GetVal(const std::string &Name,
|
||||
Value *LLParser::PerFunctionState::GetVal(unsigned ID, Type *Ty,
|
||||
LocTy Loc) {
|
||||
// Look this name up in the normal function symbol table.
|
||||
Value *Val = ID < NumberedVals.size() ? NumberedVals[ID] : 0;
|
||||
Value *Val = ID < NumberedVals.size() ? NumberedVals[ID] : nullptr;
|
||||
|
||||
// If this is a forward reference for the value, see if we already created a
|
||||
// forward ref record.
|
||||
if (Val == 0) {
|
||||
if (!Val) {
|
||||
std::map<unsigned, std::pair<Value*, LocTy> >::iterator
|
||||
I = ForwardRefValIDs.find(ID);
|
||||
if (I != ForwardRefValIDs.end())
|
||||
@ -2141,12 +2142,12 @@ Value *LLParser::PerFunctionState::GetVal(unsigned ID, Type *Ty,
|
||||
else
|
||||
P.Error(Loc, "'%" + Twine(ID) + "' defined with type '" +
|
||||
getTypeString(Val->getType()) + "'");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!Ty->isFirstClassType() && !Ty->isLabelTy()) {
|
||||
P.Error(Loc, "invalid use of a non-first-class type");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Otherwise, create a new forward reference for this value and remember it.
|
||||
@ -2242,7 +2243,7 @@ BasicBlock *LLParser::PerFunctionState::DefineBB(const std::string &Name,
|
||||
BB = GetBB(NumberedVals.size(), Loc);
|
||||
else
|
||||
BB = GetBB(Name, Loc);
|
||||
if (BB == 0) return 0; // Already diagnosed error.
|
||||
if (!BB) return nullptr; // Already diagnosed error.
|
||||
|
||||
// Move the block to the end of the function. Forward ref'd blocks are
|
||||
// inserted wherever they happen to be referenced.
|
||||
@ -2450,7 +2451,7 @@ bool LLParser::ParseValID(ValID &ID, PerFunctionState *PFS) {
|
||||
// Make a global variable as a placeholder for this reference.
|
||||
GlobalVariable *FwdRef = new GlobalVariable(*M, Type::getInt8Ty(Context),
|
||||
false, GlobalValue::InternalLinkage,
|
||||
0, "");
|
||||
nullptr, "");
|
||||
ForwardRefBlockAddresses[Fn].push_back(std::make_pair(Label, FwdRef));
|
||||
ID.ConstantVal = FwdRef;
|
||||
ID.Kind = ValID::t_Constant;
|
||||
@ -2471,7 +2472,7 @@ bool LLParser::ParseValID(ValID &ID, PerFunctionState *PFS) {
|
||||
case lltok::kw_inttoptr:
|
||||
case lltok::kw_ptrtoint: {
|
||||
unsigned Opc = Lex.getUIntVal();
|
||||
Type *DestTy = 0;
|
||||
Type *DestTy = nullptr;
|
||||
Constant *SrcVal;
|
||||
Lex.Lex();
|
||||
if (ParseToken(lltok::lparen, "expected '(' after constantexpr cast") ||
|
||||
@ -2735,18 +2736,18 @@ bool LLParser::ParseValID(ValID &ID, PerFunctionState *PFS) {
|
||||
|
||||
/// ParseGlobalValue - Parse a global value with the specified type.
|
||||
bool LLParser::ParseGlobalValue(Type *Ty, Constant *&C) {
|
||||
C = 0;
|
||||
C = nullptr;
|
||||
ValID ID;
|
||||
Value *V = NULL;
|
||||
Value *V = nullptr;
|
||||
bool Parsed = ParseValID(ID) ||
|
||||
ConvertValIDToValue(Ty, ID, V, NULL);
|
||||
ConvertValIDToValue(Ty, ID, V, nullptr);
|
||||
if (V && !(C = dyn_cast<Constant>(V)))
|
||||
return Error(ID.Loc, "global values must be constants");
|
||||
return Parsed;
|
||||
}
|
||||
|
||||
bool LLParser::ParseGlobalTypeAndValue(Constant *&V) {
|
||||
Type *Ty = 0;
|
||||
Type *Ty = nullptr;
|
||||
return ParseType(Ty) ||
|
||||
ParseGlobalValue(Ty, V);
|
||||
}
|
||||
@ -2830,15 +2831,15 @@ bool LLParser::ConvertValIDToValue(Type *Ty, ValID &ID, Value *&V,
|
||||
case ValID::t_LocalID:
|
||||
if (!PFS) return Error(ID.Loc, "invalid use of function-local name");
|
||||
V = PFS->GetVal(ID.UIntVal, Ty, ID.Loc);
|
||||
return (V == 0);
|
||||
return V == nullptr;
|
||||
case ValID::t_LocalName:
|
||||
if (!PFS) return Error(ID.Loc, "invalid use of function-local name");
|
||||
V = PFS->GetVal(ID.StrVal, Ty, ID.Loc);
|
||||
return (V == 0);
|
||||
return V == nullptr;
|
||||
case ValID::t_InlineAsm: {
|
||||
PointerType *PTy = dyn_cast<PointerType>(Ty);
|
||||
FunctionType *FTy =
|
||||
PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
|
||||
PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : nullptr;
|
||||
if (!FTy || !InlineAsm::Verify(FTy, ID.StrVal2))
|
||||
return Error(ID.Loc, "invalid type for inline asm constraint string");
|
||||
V = InlineAsm::get(FTy, ID.StrVal, ID.StrVal2, ID.UIntVal&1,
|
||||
@ -2857,10 +2858,10 @@ bool LLParser::ConvertValIDToValue(Type *Ty, ValID &ID, Value *&V,
|
||||
return false;
|
||||
case ValID::t_GlobalName:
|
||||
V = GetGlobalVal(ID.StrVal, Ty, ID.Loc);
|
||||
return V == 0;
|
||||
return V == nullptr;
|
||||
case ValID::t_GlobalID:
|
||||
V = GetGlobalVal(ID.UIntVal, Ty, ID.Loc);
|
||||
return V == 0;
|
||||
return V == nullptr;
|
||||
case ValID::t_APSInt:
|
||||
if (!Ty->isIntegerTy())
|
||||
return Error(ID.Loc, "integer constant must have integer type");
|
||||
@ -2943,14 +2944,14 @@ bool LLParser::ConvertValIDToValue(Type *Ty, ValID &ID, Value *&V,
|
||||
}
|
||||
|
||||
bool LLParser::ParseValue(Type *Ty, Value *&V, PerFunctionState *PFS) {
|
||||
V = 0;
|
||||
V = nullptr;
|
||||
ValID ID;
|
||||
return ParseValID(ID, PFS) ||
|
||||
ConvertValIDToValue(Ty, ID, V, PFS);
|
||||
}
|
||||
|
||||
bool LLParser::ParseTypeAndValue(Value *&V, PerFunctionState *PFS) {
|
||||
Type *Ty = 0;
|
||||
Type *Ty = nullptr;
|
||||
return ParseType(Ty) ||
|
||||
ParseValue(Ty, V, PFS);
|
||||
}
|
||||
@ -2980,7 +2981,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
|
||||
unsigned DLLStorageClass;
|
||||
AttrBuilder RetAttrs;
|
||||
CallingConv::ID CC;
|
||||
Type *RetType = 0;
|
||||
Type *RetType = nullptr;
|
||||
LocTy RetTypeLoc = Lex.getLoc();
|
||||
if (ParseOptionalLinkage(Linkage) ||
|
||||
ParseOptionalVisibility(Visibility) ||
|
||||
@ -3046,7 +3047,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
|
||||
std::string GC;
|
||||
bool UnnamedAddr;
|
||||
LocTy UnnamedAddrLoc;
|
||||
Constant *Prefix = 0;
|
||||
Constant *Prefix = nullptr;
|
||||
|
||||
if (ParseArgumentList(ArgList, isVarArg) ||
|
||||
ParseOptionalToken(lltok::kw_unnamed_addr, UnnamedAddr,
|
||||
@ -3103,7 +3104,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
|
||||
FunctionType::get(RetType, ParamTypeList, isVarArg);
|
||||
PointerType *PFT = PointerType::getUnqual(FT);
|
||||
|
||||
Fn = 0;
|
||||
Fn = nullptr;
|
||||
if (!FunctionName.empty()) {
|
||||
// If this was a definition of a forward reference, remove the definition
|
||||
// from the forward reference table and fill in the forward ref.
|
||||
@ -3141,7 +3142,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
|
||||
}
|
||||
}
|
||||
|
||||
if (Fn == 0)
|
||||
if (!Fn)
|
||||
Fn = Function::Create(FT, GlobalValue::ExternalLinkage, FunctionName, M);
|
||||
else // Move the forward-reference to the correct spot in the module.
|
||||
M->getFunctionList().splice(M->end(), M->getFunctionList(), Fn);
|
||||
@ -3218,7 +3219,7 @@ bool LLParser::ParseBasicBlock(PerFunctionState &PFS) {
|
||||
}
|
||||
|
||||
BasicBlock *BB = PFS.DefineBB(Name, NameLoc);
|
||||
if (BB == 0) return true;
|
||||
if (!BB) return true;
|
||||
|
||||
std::string NameStr;
|
||||
|
||||
@ -3432,7 +3433,7 @@ bool LLParser::ParseCmpPredicate(unsigned &P, unsigned Opc) {
|
||||
bool LLParser::ParseRet(Instruction *&Inst, BasicBlock *BB,
|
||||
PerFunctionState &PFS) {
|
||||
SMLoc TypeLoc = Lex.getLoc();
|
||||
Type *Ty = 0;
|
||||
Type *Ty = nullptr;
|
||||
if (ParseType(Ty, true /*void allowed*/)) return true;
|
||||
|
||||
Type *ResType = PFS.getFunction().getReturnType();
|
||||
@ -3582,7 +3583,7 @@ bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) {
|
||||
std::vector<unsigned> FwdRefAttrGrps;
|
||||
LocTy NoBuiltinLoc;
|
||||
CallingConv::ID CC;
|
||||
Type *RetType = 0;
|
||||
Type *RetType = nullptr;
|
||||
LocTy RetTypeLoc;
|
||||
ValID CalleeID;
|
||||
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
|
||||
// for the call, which means that RetType is just the return type. Infer the
|
||||
// rest of the function argument types from the arguments that are present.
|
||||
PointerType *PFTy = 0;
|
||||
FunctionType *Ty = 0;
|
||||
PointerType *PFTy = nullptr;
|
||||
FunctionType *Ty = nullptr;
|
||||
if (!(PFTy = dyn_cast<PointerType>(RetType)) ||
|
||||
!(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
|
||||
// Pull out the types of all of the arguments...
|
||||
@ -3638,7 +3639,7 @@ bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) {
|
||||
FunctionType::param_iterator I = Ty->param_begin();
|
||||
FunctionType::param_iterator E = Ty->param_end();
|
||||
for (unsigned i = 0, e = ArgList.size(); i != e; ++i) {
|
||||
Type *ExpectedTy = 0;
|
||||
Type *ExpectedTy = nullptr;
|
||||
if (I != E) {
|
||||
ExpectedTy = *I++;
|
||||
} else if (!Ty->isVarArg()) {
|
||||
@ -3779,7 +3780,7 @@ bool LLParser::ParseCast(Instruction *&Inst, PerFunctionState &PFS,
|
||||
unsigned Opc) {
|
||||
LocTy Loc;
|
||||
Value *Op;
|
||||
Type *DestTy = 0;
|
||||
Type *DestTy = nullptr;
|
||||
if (ParseTypeAndValue(Op, Loc, PFS) ||
|
||||
ParseToken(lltok::kw_to, "expected 'to' after cast value") ||
|
||||
ParseType(DestTy))
|
||||
@ -3818,7 +3819,7 @@ bool LLParser::ParseSelect(Instruction *&Inst, PerFunctionState &PFS) {
|
||||
/// ::= 'va_arg' TypeAndValue ',' Type
|
||||
bool LLParser::ParseVA_Arg(Instruction *&Inst, PerFunctionState &PFS) {
|
||||
Value *Op;
|
||||
Type *EltTy = 0;
|
||||
Type *EltTy = nullptr;
|
||||
LocTy TypeLoc;
|
||||
if (ParseTypeAndValue(Op, PFS) ||
|
||||
ParseToken(lltok::comma, "expected ',' after vaarg operand") ||
|
||||
@ -3890,7 +3891,7 @@ bool LLParser::ParseShuffleVector(Instruction *&Inst, PerFunctionState &PFS) {
|
||||
/// ParsePHI
|
||||
/// ::= 'phi' Type '[' Value ',' Value ']' (',' '[' Value ',' Value ']')*
|
||||
int LLParser::ParsePHI(Instruction *&Inst, PerFunctionState &PFS) {
|
||||
Type *Ty = 0; LocTy TypeLoc;
|
||||
Type *Ty = nullptr; LocTy TypeLoc;
|
||||
Value *Op0, *Op1;
|
||||
|
||||
if (ParseType(Ty, TypeLoc) ||
|
||||
@ -3939,7 +3940,7 @@ int LLParser::ParsePHI(Instruction *&Inst, PerFunctionState &PFS) {
|
||||
/// ::= 'filter'
|
||||
/// ::= 'filter' TypeAndValue ( ',' TypeAndValue )*
|
||||
bool LLParser::ParseLandingPad(Instruction *&Inst, PerFunctionState &PFS) {
|
||||
Type *Ty = 0; LocTy TyLoc;
|
||||
Type *Ty = nullptr; LocTy TyLoc;
|
||||
Value *PersFn; LocTy PersFnLoc;
|
||||
|
||||
if (ParseType(Ty, TyLoc) ||
|
||||
@ -3991,7 +3992,7 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
|
||||
std::vector<unsigned> FwdRefAttrGrps;
|
||||
LocTy BuiltinLoc;
|
||||
CallingConv::ID CC;
|
||||
Type *RetType = 0;
|
||||
Type *RetType = nullptr;
|
||||
LocTy RetTypeLoc;
|
||||
ValID CalleeID;
|
||||
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
|
||||
// for the call, which means that RetType is just the return type. Infer the
|
||||
// rest of the function argument types from the arguments that are present.
|
||||
PointerType *PFTy = 0;
|
||||
FunctionType *Ty = 0;
|
||||
PointerType *PFTy = nullptr;
|
||||
FunctionType *Ty = nullptr;
|
||||
if (!(PFTy = dyn_cast<PointerType>(RetType)) ||
|
||||
!(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
|
||||
// Pull out the types of all of the arguments...
|
||||
@ -4044,7 +4045,7 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
|
||||
FunctionType::param_iterator I = Ty->param_begin();
|
||||
FunctionType::param_iterator E = Ty->param_end();
|
||||
for (unsigned i = 0, e = ArgList.size(); i != e; ++i) {
|
||||
Type *ExpectedTy = 0;
|
||||
Type *ExpectedTy = nullptr;
|
||||
if (I != E) {
|
||||
ExpectedTy = *I++;
|
||||
} else if (!Ty->isVarArg()) {
|
||||
@ -4088,10 +4089,10 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
|
||||
/// ParseAlloc
|
||||
/// ::= 'alloca' 'inalloca'? Type (',' TypeAndValue)? (',' 'align' i32)?
|
||||
int LLParser::ParseAlloc(Instruction *&Inst, PerFunctionState &PFS) {
|
||||
Value *Size = 0;
|
||||
Value *Size = nullptr;
|
||||
LocTy SizeLoc;
|
||||
unsigned Alignment = 0;
|
||||
Type *Ty = 0;
|
||||
Type *Ty = nullptr;
|
||||
|
||||
bool IsInAlloca = EatIfPresent(lltok::kw_inalloca);
|
||||
|
||||
@ -4330,8 +4331,8 @@ int LLParser::ParseFence(Instruction *&Inst, PerFunctionState &PFS) {
|
||||
/// ParseGetElementPtr
|
||||
/// ::= 'getelementptr' 'inbounds'? TypeAndValue (',' TypeAndValue)*
|
||||
int LLParser::ParseGetElementPtr(Instruction *&Inst, PerFunctionState &PFS) {
|
||||
Value *Ptr = 0;
|
||||
Value *Val = 0;
|
||||
Value *Ptr = nullptr;
|
||||
Value *Val = nullptr;
|
||||
LocTy Loc, EltLoc;
|
||||
|
||||
bool InBounds = EatIfPresent(lltok::kw_inbounds);
|
||||
@ -4433,11 +4434,11 @@ bool LLParser::ParseMDNodeVector(SmallVectorImpl<Value*> &Elts,
|
||||
do {
|
||||
// Null is a special case since it is typeless.
|
||||
if (EatIfPresent(lltok::kw_null)) {
|
||||
Elts.push_back(0);
|
||||
Elts.push_back(nullptr);
|
||||
continue;
|
||||
}
|
||||
|
||||
Value *V = 0;
|
||||
Value *V = nullptr;
|
||||
if (ParseTypeAndValue(V, PFS)) return true;
|
||||
Elts.push_back(V);
|
||||
} while (EatIfPresent(lltok::comma));
|
||||
|
@ -30,12 +30,12 @@ Module *llvm::ParseAssembly(MemoryBuffer *F,
|
||||
|
||||
// If we are parsing into an existing module, do it.
|
||||
if (M)
|
||||
return LLParser(F, SM, Err, M).Run() ? 0 : M;
|
||||
return LLParser(F, SM, Err, M).Run() ? nullptr : M;
|
||||
|
||||
// Otherwise create a new module.
|
||||
std::unique_ptr<Module> M2(new Module(F->getBufferIdentifier(), Context));
|
||||
if (LLParser(F, SM, Err, M2.get()).Run())
|
||||
return 0;
|
||||
return nullptr;
|
||||
return M2.release();
|
||||
}
|
||||
|
||||
@ -45,10 +45,10 @@ Module *llvm::ParseAssemblyFile(const std::string &Filename, SMDiagnostic &Err,
|
||||
if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, File)) {
|
||||
Err = SMDiagnostic(Filename, SourceMgr::DK_Error,
|
||||
"Could not open input file: " + ec.message());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return ParseAssembly(File.release(), 0, Err, Context);
|
||||
return ParseAssembly(File.release(), nullptr, Err, Context);
|
||||
}
|
||||
|
||||
Module *llvm::ParseAssemblyString(const char *AsmString, Module *M,
|
||||
|
@ -35,7 +35,7 @@ LLVMBool LLVMParseBitcodeInContext(LLVMContextRef ContextRef,
|
||||
if (error_code EC = ModuleOrErr.getError()) {
|
||||
if (OutMessage)
|
||||
*OutMessage = strdup(EC.message().c_str());
|
||||
*OutModule = wrap((Module*)0);
|
||||
*OutModule = wrap((Module*)nullptr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ LLVMBool LLVMGetBitcodeModuleInContext(LLVMContextRef ContextRef,
|
||||
getLazyBitcodeModule(unwrap(MemBuf), *unwrap(ContextRef));
|
||||
|
||||
if (error_code EC = ModuleOrErr.getError()) {
|
||||
*OutM = wrap((Module *)NULL);
|
||||
*OutM = wrap((Module *)nullptr);
|
||||
if (OutMessage)
|
||||
*OutMessage = strdup(EC.message().c_str());
|
||||
return 1;
|
||||
|
@ -41,7 +41,7 @@ void BitcodeReader::materializeForwardReferencedFunctions() {
|
||||
void BitcodeReader::FreeState() {
|
||||
if (BufferOwned)
|
||||
delete Buffer;
|
||||
Buffer = 0;
|
||||
Buffer = nullptr;
|
||||
std::vector<Type*>().swap(TypeList);
|
||||
ValueList.clear();
|
||||
MDValueList.clear();
|
||||
@ -258,7 +258,7 @@ void BitcodeReaderValueList::AssignValue(Value *V, unsigned Idx) {
|
||||
resize(Idx+1);
|
||||
|
||||
WeakVH &OldV = ValuePtrs[Idx];
|
||||
if (OldV == 0) {
|
||||
if (!OldV) {
|
||||
OldV = V;
|
||||
return;
|
||||
}
|
||||
@ -298,12 +298,12 @@ Value *BitcodeReaderValueList::getValueFwdRef(unsigned Idx, Type *Ty) {
|
||||
resize(Idx + 1);
|
||||
|
||||
if (Value *V = ValuePtrs[Idx]) {
|
||||
assert((Ty == 0 || Ty == V->getType()) && "Type mismatch in value table!");
|
||||
assert((!Ty || Ty == V->getType()) && "Type mismatch in value table!");
|
||||
return V;
|
||||
}
|
||||
|
||||
// No type specified, must be invalid reference.
|
||||
if (Ty == 0) return 0;
|
||||
if (!Ty) return nullptr;
|
||||
|
||||
// Create and return a placeholder, which will later be RAUW'd.
|
||||
Value *V = new Argument(Ty);
|
||||
@ -403,7 +403,7 @@ void BitcodeReaderMDValueList::AssignValue(Value *V, unsigned Idx) {
|
||||
resize(Idx+1);
|
||||
|
||||
WeakVH &OldV = MDValuePtrs[Idx];
|
||||
if (OldV == 0) {
|
||||
if (!OldV) {
|
||||
OldV = V;
|
||||
return;
|
||||
}
|
||||
@ -435,7 +435,7 @@ Value *BitcodeReaderMDValueList::getValueFwdRef(unsigned Idx) {
|
||||
Type *BitcodeReader::getTypeByID(unsigned ID) {
|
||||
// The type table size is always specified correctly.
|
||||
if (ID >= TypeList.size())
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
if (Type *Ty = TypeList[ID])
|
||||
return Ty;
|
||||
@ -737,7 +737,7 @@ error_code BitcodeReader::ParseTypeTableBody() {
|
||||
|
||||
// Read a record.
|
||||
Record.clear();
|
||||
Type *ResultTy = 0;
|
||||
Type *ResultTy = nullptr;
|
||||
switch (Stream.readRecord(Entry.ID, Record)) {
|
||||
default:
|
||||
return Error(InvalidValue);
|
||||
@ -792,7 +792,7 @@ error_code BitcodeReader::ParseTypeTableBody() {
|
||||
if (Record.size() == 2)
|
||||
AddressSpace = Record[1];
|
||||
ResultTy = getTypeByID(Record[0]);
|
||||
if (ResultTy == 0)
|
||||
if (!ResultTy)
|
||||
return Error(InvalidType);
|
||||
ResultTy = PointerType::get(ResultTy, AddressSpace);
|
||||
break;
|
||||
@ -811,7 +811,7 @@ error_code BitcodeReader::ParseTypeTableBody() {
|
||||
}
|
||||
|
||||
ResultTy = getTypeByID(Record[2]);
|
||||
if (ResultTy == 0 || ArgTys.size() < Record.size()-3)
|
||||
if (!ResultTy || ArgTys.size() < Record.size()-3)
|
||||
return Error(InvalidType);
|
||||
|
||||
ResultTy = FunctionType::get(ResultTy, ArgTys, Record[0]);
|
||||
@ -830,7 +830,7 @@ error_code BitcodeReader::ParseTypeTableBody() {
|
||||
}
|
||||
|
||||
ResultTy = getTypeByID(Record[1]);
|
||||
if (ResultTy == 0 || ArgTys.size() < Record.size()-2)
|
||||
if (!ResultTy || ArgTys.size() < Record.size()-2)
|
||||
return Error(InvalidType);
|
||||
|
||||
ResultTy = FunctionType::get(ResultTy, ArgTys, Record[0]);
|
||||
@ -867,7 +867,7 @@ error_code BitcodeReader::ParseTypeTableBody() {
|
||||
StructType *Res = cast_or_null<StructType>(TypeList[NumRecords]);
|
||||
if (Res) {
|
||||
Res->setName(TypeName);
|
||||
TypeList[NumRecords] = 0;
|
||||
TypeList[NumRecords] = nullptr;
|
||||
} else // Otherwise, create a new struct.
|
||||
Res = StructType::create(Context, TypeName);
|
||||
TypeName.clear();
|
||||
@ -896,7 +896,7 @@ error_code BitcodeReader::ParseTypeTableBody() {
|
||||
StructType *Res = cast_or_null<StructType>(TypeList[NumRecords]);
|
||||
if (Res) {
|
||||
Res->setName(TypeName);
|
||||
TypeList[NumRecords] = 0;
|
||||
TypeList[NumRecords] = nullptr;
|
||||
} else // Otherwise, create a new struct with no body.
|
||||
Res = StructType::create(Context, TypeName);
|
||||
TypeName.clear();
|
||||
@ -924,7 +924,7 @@ error_code BitcodeReader::ParseTypeTableBody() {
|
||||
if (NumRecords >= TypeList.size())
|
||||
return Error(InvalidTYPETable);
|
||||
assert(ResultTy && "Didn't read a type?");
|
||||
assert(TypeList[NumRecords] == 0 && "Already read type?");
|
||||
assert(!TypeList[NumRecords] && "Already read type?");
|
||||
TypeList[NumRecords++] = ResultTy;
|
||||
}
|
||||
}
|
||||
@ -972,7 +972,7 @@ error_code BitcodeReader::ParseValueSymbolTable() {
|
||||
if (ConvertToString(Record, 1, ValueName))
|
||||
return Error(InvalidRecord);
|
||||
BasicBlock *BB = getBasicBlock(Record[0]);
|
||||
if (BB == 0)
|
||||
if (!BB)
|
||||
return Error(InvalidRecord);
|
||||
|
||||
BB->setName(StringRef(ValueName.data(), ValueName.size()));
|
||||
@ -1028,7 +1028,7 @@ error_code BitcodeReader::ParseMetadata() {
|
||||
NamedMDNode *NMD = TheModule->getOrInsertNamedMetadata(Name);
|
||||
for (unsigned i = 0; i != Size; ++i) {
|
||||
MDNode *MD = dyn_cast_or_null<MDNode>(MDValueList.getValueFwdRef(Record[i]));
|
||||
if (MD == 0)
|
||||
if (!MD)
|
||||
return Error(InvalidRecord);
|
||||
NMD->addOperand(MD);
|
||||
}
|
||||
@ -1052,7 +1052,7 @@ error_code BitcodeReader::ParseMetadata() {
|
||||
else if (!Ty->isVoidTy())
|
||||
Elts.push_back(ValueList.getValueFwdRef(Record[i+1], Ty));
|
||||
else
|
||||
Elts.push_back(NULL);
|
||||
Elts.push_back(nullptr);
|
||||
}
|
||||
Value *V = MDNode::getWhenValsUnresolved(Context, Elts, IsFunctionLocal);
|
||||
IsFunctionLocal = false;
|
||||
@ -1185,7 +1185,7 @@ error_code BitcodeReader::ParseConstants() {
|
||||
|
||||
// Read a record.
|
||||
Record.clear();
|
||||
Value *V = 0;
|
||||
Value *V = nullptr;
|
||||
unsigned BitCode = Stream.readRecord(Entry.ID, Record);
|
||||
switch (BitCode) {
|
||||
default: // Default behavior: unknown constant
|
||||
@ -1423,7 +1423,7 @@ error_code BitcodeReader::ParseConstants() {
|
||||
return Error(InvalidRecord);
|
||||
VectorType *OpTy =
|
||||
dyn_cast_or_null<VectorType>(getTypeByID(Record[0]));
|
||||
if (OpTy == 0)
|
||||
if (!OpTy)
|
||||
return Error(InvalidRecord);
|
||||
Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy);
|
||||
Constant *Op1 = ValueList.getConstantFwdRef(Record[2],
|
||||
@ -1433,7 +1433,7 @@ error_code BitcodeReader::ParseConstants() {
|
||||
}
|
||||
case bitc::CST_CODE_CE_INSERTELT: { // CE_INSERTELT: [opval, opval, opval]
|
||||
VectorType *OpTy = dyn_cast<VectorType>(CurTy);
|
||||
if (Record.size() < 3 || OpTy == 0)
|
||||
if (Record.size() < 3 || !OpTy)
|
||||
return Error(InvalidRecord);
|
||||
Constant *Op0 = ValueList.getConstantFwdRef(Record[0], OpTy);
|
||||
Constant *Op1 = ValueList.getConstantFwdRef(Record[1],
|
||||
@ -1445,7 +1445,7 @@ error_code BitcodeReader::ParseConstants() {
|
||||
}
|
||||
case bitc::CST_CODE_CE_SHUFFLEVEC: { // CE_SHUFFLEVEC: [opval, opval, opval]
|
||||
VectorType *OpTy = dyn_cast<VectorType>(CurTy);
|
||||
if (Record.size() < 3 || OpTy == 0)
|
||||
if (Record.size() < 3 || !OpTy)
|
||||
return Error(InvalidRecord);
|
||||
Constant *Op0 = ValueList.getConstantFwdRef(Record[0], OpTy);
|
||||
Constant *Op1 = ValueList.getConstantFwdRef(Record[1], OpTy);
|
||||
@ -1459,7 +1459,7 @@ error_code BitcodeReader::ParseConstants() {
|
||||
VectorType *RTy = dyn_cast<VectorType>(CurTy);
|
||||
VectorType *OpTy =
|
||||
dyn_cast_or_null<VectorType>(getTypeByID(Record[0]));
|
||||
if (Record.size() < 4 || RTy == 0 || OpTy == 0)
|
||||
if (Record.size() < 4 || !RTy || !OpTy)
|
||||
return Error(InvalidRecord);
|
||||
Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy);
|
||||
Constant *Op1 = ValueList.getConstantFwdRef(Record[2], OpTy);
|
||||
@ -1473,7 +1473,7 @@ error_code BitcodeReader::ParseConstants() {
|
||||
if (Record.size() < 4)
|
||||
return Error(InvalidRecord);
|
||||
Type *OpTy = getTypeByID(Record[0]);
|
||||
if (OpTy == 0)
|
||||
if (!OpTy)
|
||||
return Error(InvalidRecord);
|
||||
Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy);
|
||||
Constant *Op1 = ValueList.getConstantFwdRef(Record[2], OpTy);
|
||||
@ -1538,11 +1538,11 @@ error_code BitcodeReader::ParseConstants() {
|
||||
if (Record.size() < 3)
|
||||
return Error(InvalidRecord);
|
||||
Type *FnTy = getTypeByID(Record[0]);
|
||||
if (FnTy == 0)
|
||||
if (!FnTy)
|
||||
return Error(InvalidRecord);
|
||||
Function *Fn =
|
||||
dyn_cast_or_null<Function>(ValueList.getConstantFwdRef(Record[1],FnTy));
|
||||
if (Fn == 0)
|
||||
if (!Fn)
|
||||
return Error(InvalidRecord);
|
||||
|
||||
// If the function is already parsed we can insert the block address right
|
||||
@ -1561,7 +1561,7 @@ error_code BitcodeReader::ParseConstants() {
|
||||
GlobalVariable *FwdRef = new GlobalVariable(*Fn->getParent(),
|
||||
Type::getInt8Ty(Context),
|
||||
false, GlobalValue::InternalLinkage,
|
||||
0, "");
|
||||
nullptr, "");
|
||||
BlockAddrFwdRefs[Fn].push_back(std::make_pair(Record[2], FwdRef));
|
||||
V = FwdRef;
|
||||
}
|
||||
@ -1854,7 +1854,7 @@ error_code BitcodeReader::ParseModule(bool Resume) {
|
||||
ExternallyInitialized = Record[9];
|
||||
|
||||
GlobalVariable *NewGV =
|
||||
new GlobalVariable(*TheModule, Ty, isConstant, Linkage, 0, "", 0,
|
||||
new GlobalVariable(*TheModule, Ty, isConstant, Linkage, nullptr, "", nullptr,
|
||||
TLM, AddressSpace, ExternallyInitialized);
|
||||
NewGV->setAlignment(Alignment);
|
||||
if (!Section.empty())
|
||||
@ -1944,7 +1944,7 @@ error_code BitcodeReader::ParseModule(bool Resume) {
|
||||
return Error(InvalidTypeForValue);
|
||||
|
||||
GlobalAlias *NewGA = new GlobalAlias(Ty, GetDecodedLinkage(Record[2]),
|
||||
"", 0, TheModule);
|
||||
"", nullptr, TheModule);
|
||||
// Old bitcode files didn't have visibility field.
|
||||
if (Record.size() > 3)
|
||||
NewGA->setVisibility(GetDecodedVisibility(Record[3]));
|
||||
@ -1969,7 +1969,7 @@ error_code BitcodeReader::ParseModule(bool Resume) {
|
||||
}
|
||||
|
||||
error_code BitcodeReader::ParseBitcodeInto(Module *M) {
|
||||
TheModule = 0;
|
||||
TheModule = nullptr;
|
||||
|
||||
if (error_code EC = InitStream())
|
||||
return EC;
|
||||
@ -2173,7 +2173,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
|
||||
ValueList.push_back(I);
|
||||
|
||||
unsigned NextValueNo = ValueList.size();
|
||||
BasicBlock *CurBB = 0;
|
||||
BasicBlock *CurBB = nullptr;
|
||||
unsigned CurBBNo = 0;
|
||||
|
||||
DebugLoc LastLoc;
|
||||
@ -2222,7 +2222,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
|
||||
|
||||
// Read a record.
|
||||
Record.clear();
|
||||
Instruction *I = 0;
|
||||
Instruction *I = nullptr;
|
||||
unsigned BitCode = Stream.readRecord(Entry.ID, Record);
|
||||
switch (BitCode) {
|
||||
default: // Default behavior: reject
|
||||
@ -2240,7 +2240,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
|
||||
case bitc::FUNC_CODE_DEBUG_LOC_AGAIN: // DEBUG_LOC_AGAIN
|
||||
// This record indicates that the last instruction is at the same
|
||||
// location as the previous instruction with a location.
|
||||
I = 0;
|
||||
I = nullptr;
|
||||
|
||||
// Get the last instruction emitted.
|
||||
if (CurBB && !CurBB->empty())
|
||||
@ -2249,31 +2249,31 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
|
||||
!FunctionBBs[CurBBNo-1]->empty())
|
||||
I = &FunctionBBs[CurBBNo-1]->back();
|
||||
|
||||
if (I == 0)
|
||||
if (!I)
|
||||
return Error(InvalidRecord);
|
||||
I->setDebugLoc(LastLoc);
|
||||
I = 0;
|
||||
I = nullptr;
|
||||
continue;
|
||||
|
||||
case bitc::FUNC_CODE_DEBUG_LOC: { // DEBUG_LOC: [line, col, scope, ia]
|
||||
I = 0; // Get the last instruction emitted.
|
||||
I = nullptr; // Get the last instruction emitted.
|
||||
if (CurBB && !CurBB->empty())
|
||||
I = &CurBB->back();
|
||||
else if (CurBBNo && FunctionBBs[CurBBNo-1] &&
|
||||
!FunctionBBs[CurBBNo-1]->empty())
|
||||
I = &FunctionBBs[CurBBNo-1]->back();
|
||||
if (I == 0 || Record.size() < 4)
|
||||
if (!I || Record.size() < 4)
|
||||
return Error(InvalidRecord);
|
||||
|
||||
unsigned Line = Record[0], Col = Record[1];
|
||||
unsigned ScopeID = Record[2], IAID = Record[3];
|
||||
|
||||
MDNode *Scope = 0, *IA = 0;
|
||||
MDNode *Scope = nullptr, *IA = nullptr;
|
||||
if (ScopeID) Scope = cast<MDNode>(MDValueList.getValueFwdRef(ScopeID-1));
|
||||
if (IAID) IA = cast<MDNode>(MDValueList.getValueFwdRef(IAID-1));
|
||||
LastLoc = DebugLoc::get(Line, Col, Scope, IA);
|
||||
I->setDebugLoc(LastLoc);
|
||||
I = 0;
|
||||
I = nullptr;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -2333,9 +2333,9 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
|
||||
|
||||
Type *ResTy = getTypeByID(Record[OpNum]);
|
||||
int Opc = GetDecodedCastOpcode(Record[OpNum+1]);
|
||||
if (Opc == -1 || ResTy == 0)
|
||||
if (Opc == -1 || !ResTy)
|
||||
return Error(InvalidRecord);
|
||||
Instruction *Temp = 0;
|
||||
Instruction *Temp = nullptr;
|
||||
if ((I = UpgradeBitCastInst(Opc, Op, ResTy, Temp))) {
|
||||
if (Temp) {
|
||||
InstructionList.push_back(Temp);
|
||||
@ -2526,7 +2526,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
|
||||
}
|
||||
|
||||
unsigned OpNum = 0;
|
||||
Value *Op = NULL;
|
||||
Value *Op = nullptr;
|
||||
if (getValueTypePair(Record, OpNum, NextValueNo, Op))
|
||||
return Error(InvalidRecord);
|
||||
if (OpNum != Record.size())
|
||||
@ -2540,7 +2540,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
|
||||
if (Record.size() != 1 && Record.size() != 3)
|
||||
return Error(InvalidRecord);
|
||||
BasicBlock *TrueDest = getBasicBlock(Record[0]);
|
||||
if (TrueDest == 0)
|
||||
if (!TrueDest)
|
||||
return Error(InvalidRecord);
|
||||
|
||||
if (Record.size() == 1) {
|
||||
@ -2551,7 +2551,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
|
||||
BasicBlock *FalseDest = getBasicBlock(Record[1]);
|
||||
Value *Cond = getValue(Record, 2, NextValueNo,
|
||||
Type::getInt1Ty(Context));
|
||||
if (FalseDest == 0 || Cond == 0)
|
||||
if (!FalseDest || !Cond)
|
||||
return Error(InvalidRecord);
|
||||
I = BranchInst::Create(TrueDest, FalseDest, Cond);
|
||||
InstructionList.push_back(I);
|
||||
@ -2571,7 +2571,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
|
||||
|
||||
Value *Cond = getValue(Record, 2, NextValueNo, OpTy);
|
||||
BasicBlock *Default = getBasicBlock(Record[3]);
|
||||
if (OpTy == 0 || Cond == 0 || Default == 0)
|
||||
if (!OpTy || !Cond || !Default)
|
||||
return Error(InvalidRecord);
|
||||
|
||||
unsigned NumCases = Record[4];
|
||||
@ -2628,7 +2628,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
|
||||
Type *OpTy = getTypeByID(Record[0]);
|
||||
Value *Cond = getValue(Record, 1, NextValueNo, OpTy);
|
||||
BasicBlock *Default = getBasicBlock(Record[2]);
|
||||
if (OpTy == 0 || Cond == 0 || Default == 0)
|
||||
if (!OpTy || !Cond || !Default)
|
||||
return Error(InvalidRecord);
|
||||
unsigned NumCases = (Record.size()-3)/2;
|
||||
SwitchInst *SI = SwitchInst::Create(Cond, Default, NumCases);
|
||||
@ -2637,7 +2637,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
|
||||
ConstantInt *CaseVal =
|
||||
dyn_cast_or_null<ConstantInt>(getFnValueByID(Record[3+i*2], OpTy));
|
||||
BasicBlock *DestBB = getBasicBlock(Record[1+3+i*2]);
|
||||
if (CaseVal == 0 || DestBB == 0) {
|
||||
if (!CaseVal || !DestBB) {
|
||||
delete SI;
|
||||
return Error(InvalidRecord);
|
||||
}
|
||||
@ -2651,7 +2651,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
|
||||
return Error(InvalidRecord);
|
||||
Type *OpTy = getTypeByID(Record[0]);
|
||||
Value *Address = getValue(Record, 1, NextValueNo, OpTy);
|
||||
if (OpTy == 0 || Address == 0)
|
||||
if (!OpTy || !Address)
|
||||
return Error(InvalidRecord);
|
||||
unsigned NumDests = Record.size()-2;
|
||||
IndirectBrInst *IBI = IndirectBrInst::Create(Address, NumDests);
|
||||
@ -2683,11 +2683,11 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
|
||||
return Error(InvalidRecord);
|
||||
|
||||
PointerType *CalleeTy = dyn_cast<PointerType>(Callee->getType());
|
||||
FunctionType *FTy = !CalleeTy ? 0 :
|
||||
FunctionType *FTy = !CalleeTy ? nullptr :
|
||||
dyn_cast<FunctionType>(CalleeTy->getElementType());
|
||||
|
||||
// Check that the right number of fixed parameters are here.
|
||||
if (FTy == 0 || NormalBB == 0 || UnwindBB == 0 ||
|
||||
if (!FTy || !NormalBB || !UnwindBB ||
|
||||
Record.size() < OpNum+FTy->getNumParams())
|
||||
return Error(InvalidRecord);
|
||||
|
||||
@ -2695,7 +2695,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
|
||||
for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i, ++OpNum) {
|
||||
Ops.push_back(getValue(Record, OpNum, NextValueNo,
|
||||
FTy->getParamType(i)));
|
||||
if (Ops.back() == 0)
|
||||
if (!Ops.back())
|
||||
return Error(InvalidRecord);
|
||||
}
|
||||
|
||||
@ -2721,7 +2721,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
|
||||
}
|
||||
case bitc::FUNC_CODE_INST_RESUME: { // RESUME: [opval]
|
||||
unsigned Idx = 0;
|
||||
Value *Val = 0;
|
||||
Value *Val = nullptr;
|
||||
if (getValueTypePair(Record, Idx, NextValueNo, Val))
|
||||
return Error(InvalidRecord);
|
||||
I = ResumeInst::Create(Val);
|
||||
@ -2768,7 +2768,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
|
||||
Type *Ty = getTypeByID(Record[Idx++]);
|
||||
if (!Ty)
|
||||
return Error(InvalidRecord);
|
||||
Value *PersFn = 0;
|
||||
Value *PersFn = nullptr;
|
||||
if (getValueTypePair(Record, Idx, NextValueNo, PersFn))
|
||||
return Error(InvalidRecord);
|
||||
|
||||
@ -2961,7 +2961,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
|
||||
return Error(InvalidRecord);
|
||||
|
||||
PointerType *OpTy = dyn_cast<PointerType>(Callee->getType());
|
||||
FunctionType *FTy = 0;
|
||||
FunctionType *FTy = nullptr;
|
||||
if (OpTy) FTy = dyn_cast<FunctionType>(OpTy->getElementType());
|
||||
if (!FTy || Record.size() < FTy->getNumParams()+OpNum)
|
||||
return Error(InvalidRecord);
|
||||
@ -2974,7 +2974,7 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) {
|
||||
else
|
||||
Args.push_back(getValue(Record, OpNum, NextValueNo,
|
||||
FTy->getParamType(i)));
|
||||
if (Args.back() == 0)
|
||||
if (!Args.back())
|
||||
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
|
||||
// this file.
|
||||
if (CurBB == 0) {
|
||||
if (!CurBB) {
|
||||
delete I;
|
||||
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 (isa<TerminatorInst>(I)) {
|
||||
++CurBBNo;
|
||||
CurBB = CurBBNo < FunctionBBs.size() ? FunctionBBs[CurBBNo] : 0;
|
||||
CurBB = CurBBNo < FunctionBBs.size() ? FunctionBBs[CurBBNo] : nullptr;
|
||||
}
|
||||
|
||||
// Non-void values get registered in the value table for future use.
|
||||
@ -3036,10 +3036,10 @@ OutOfRecordLoop:
|
||||
|
||||
// Check the function list for unresolved values.
|
||||
if (Argument *A = dyn_cast<Argument>(ValueList.back())) {
|
||||
if (A->getParent() == 0) {
|
||||
if (!A->getParent()) {
|
||||
// We found at least one unresolved value. Nuke them all to avoid leaks.
|
||||
for (unsigned i = ModuleValueListSize, e = ValueList.size(); i != e; ++i){
|
||||
if ((A = dyn_cast_or_null<Argument>(ValueList[i])) && A->getParent() == 0) {
|
||||
if ((A = dyn_cast_or_null<Argument>(ValueList[i])) && !A->getParent()) {
|
||||
A->replaceAllUsesWith(UndefValue::get(A->getType()));
|
||||
delete A;
|
||||
}
|
||||
@ -3348,7 +3348,7 @@ Module *llvm::getStreamedBitcodeModule(const std::string &name,
|
||||
if (ErrMsg)
|
||||
*ErrMsg = EC.message();
|
||||
delete M; // Also deletes R.
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
R->setBufferOwned(false); // no buffer to delete
|
||||
return M;
|
||||
|
@ -315,7 +315,7 @@ bool BitstreamCursor::ReadBlockInfoBlock() {
|
||||
if (EnterSubBlock(bitc::BLOCKINFO_BLOCK_ID)) return true;
|
||||
|
||||
SmallVector<uint64_t, 64> Record;
|
||||
BitstreamReader::BlockInfo *CurBlockInfo = 0;
|
||||
BitstreamReader::BlockInfo *CurBlockInfo = nullptr;
|
||||
|
||||
// Read all the records for this module.
|
||||
while (1) {
|
||||
|
@ -917,7 +917,7 @@ static void WriteConstants(unsigned FirstVal, unsigned LastVal,
|
||||
SmallVector<uint64_t, 64> Record;
|
||||
|
||||
const ValueEnumerator::ValueList &Vals = VE.getValues();
|
||||
Type *LastTy = 0;
|
||||
Type *LastTy = nullptr;
|
||||
for (unsigned i = FirstVal; i != LastVal; ++i) {
|
||||
const Value *V = Vals[i].first;
|
||||
// If we need to switch types, do so now.
|
||||
|
@ -290,7 +290,7 @@ DWARFContext::getLineTableForCompileUnit(DWARFCompileUnit *cu) {
|
||||
cu->getCompileUnitDIE()->getAttributeValueAsSectionOffset(
|
||||
cu, DW_AT_stmt_list, -1U);
|
||||
if (stmtOffset == -1U)
|
||||
return 0; // No line table for this compile unit.
|
||||
return nullptr; // No line table for this compile unit.
|
||||
|
||||
// See if the line table is cached.
|
||||
if (const DWARFLineTable *lt = Line->getLineTable(stmtOffset))
|
||||
@ -408,7 +408,7 @@ DWARFCompileUnit *DWARFContext::getCompileUnitForOffset(uint32_t Offset) {
|
||||
if (CU != CUs.end()) {
|
||||
return CU->get();
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DWARFCompileUnit *DWARFContext::getCompileUnitForAddress(uint64_t Address) {
|
||||
@ -423,8 +423,7 @@ static bool getFileNameForCompileUnit(DWARFCompileUnit *CU,
|
||||
uint64_t FileIndex,
|
||||
bool NeedsAbsoluteFilePath,
|
||||
std::string &FileName) {
|
||||
if (CU == 0 ||
|
||||
LineTable == 0 ||
|
||||
if (!CU || !LineTable ||
|
||||
!LineTable->getFileNameByIndex(FileIndex, NeedsAbsoluteFilePath,
|
||||
FileName))
|
||||
return false;
|
||||
@ -446,7 +445,7 @@ static bool getFileLineInfoForCompileUnit(DWARFCompileUnit *CU,
|
||||
bool NeedsAbsoluteFilePath,
|
||||
std::string &FileName,
|
||||
uint32_t &Line, uint32_t &Column) {
|
||||
if (CU == 0 || LineTable == 0)
|
||||
if (!CU || !LineTable)
|
||||
return false;
|
||||
// Get the index of row we're looking for in the line table.
|
||||
uint32_t RowIndex = LineTable->lookupAddress(Address);
|
||||
@ -560,7 +559,7 @@ DIInliningInfo DWARFContext::getInliningInfoForAddress(uint64_t Address,
|
||||
|
||||
DIInliningInfo InliningInfo;
|
||||
uint32_t CallFile = 0, CallLine = 0, CallColumn = 0;
|
||||
const DWARFLineTable *LineTable = 0;
|
||||
const DWARFLineTable *LineTable = nullptr;
|
||||
for (uint32_t i = 0, n = InlinedChain.DIEs.size(); i != n; i++) {
|
||||
const DWARFDebugInfoEntryMinimal &FunctionDIE = InlinedChain.DIEs[i];
|
||||
std::string FileName = "<invalid>";
|
||||
@ -670,7 +669,7 @@ DWARFContextInMemory::DWARFContextInMemory(object::ObjectFile *Obj)
|
||||
.Case("debug_str_offsets.dwo", &StringOffsetDWOSection)
|
||||
.Case("debug_addr", &AddrSection)
|
||||
// Any more debug info sections go here.
|
||||
.Default(0);
|
||||
.Default(nullptr);
|
||||
if (SectionData) {
|
||||
*SectionData = data;
|
||||
if (name == "debug_ranges") {
|
||||
@ -701,7 +700,7 @@ DWARFContextInMemory::DWARFContextInMemory(object::ObjectFile *Obj)
|
||||
.Case("debug_loc", &LocSection.Relocs)
|
||||
.Case("debug_info.dwo", &InfoDWOSection.Relocs)
|
||||
.Case("debug_line", &LineSection.Relocs)
|
||||
.Default(0);
|
||||
.Default(nullptr);
|
||||
if (!Map) {
|
||||
// Find debug_types relocs by section rather than name as there are
|
||||
// multiple, comdat grouped, debug_types sections.
|
||||
|
@ -50,7 +50,7 @@ DWARFAbbreviationDeclarationSet::getAbbreviationDeclaration(uint32_t abbrCode)
|
||||
if (idx < Decls.size())
|
||||
return &Decls[idx];
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DWARFDebugAbbrev::DWARFDebugAbbrev() :
|
||||
@ -99,5 +99,5 @@ DWARFDebugAbbrev::getAbbreviationDeclarationSet(uint64_t cu_abbr_offset) const {
|
||||
|
||||
if (pos != AbbrevCollMap.end())
|
||||
return &(pos->second);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ public:
|
||||
int64_t LinkedCIEOffset, uint64_t InitialLocation, uint64_t AddressRange)
|
||||
: FrameEntry(FK_FDE, D, Offset, Length), LinkedCIEOffset(LinkedCIEOffset),
|
||||
InitialLocation(InitialLocation), AddressRange(AddressRange),
|
||||
LinkedCIE(NULL) {}
|
||||
LinkedCIE(nullptr) {}
|
||||
|
||||
~FDE() {
|
||||
}
|
||||
@ -334,7 +334,7 @@ void DWARFDebugFrame::parse(DataExtractor Data) {
|
||||
Id = Data.getUnsigned(&Offset, IsDWARF64 ? 8 : 4);
|
||||
bool IsCIE = ((IsDWARF64 && Id == DW64_CIE_ID) || Id == DW_CIE_ID);
|
||||
|
||||
FrameEntry *Entry = 0;
|
||||
FrameEntry *Entry = nullptr;
|
||||
if (IsCIE) {
|
||||
// Note: this is specifically DWARFv3 CIE header structure. It was
|
||||
// changed in DWARFv4. We currently don't support reading DWARFv4
|
||||
|
@ -99,11 +99,11 @@ bool DWARFDebugInfoEntryMinimal::extractFast(const DWARFUnit *U,
|
||||
uint64_t AbbrCode = DebugInfoData.getULEB128(OffsetPtr);
|
||||
if (0 == AbbrCode) {
|
||||
// NULL debug tag entry.
|
||||
AbbrevDecl = NULL;
|
||||
AbbrevDecl = nullptr;
|
||||
return true;
|
||||
}
|
||||
AbbrevDecl = U->getAbbreviations()->getAbbreviationDeclaration(AbbrCode);
|
||||
if (0 == AbbrevDecl) {
|
||||
if (nullptr == AbbrevDecl) {
|
||||
// Restore the original offset.
|
||||
*OffsetPtr = Offset;
|
||||
return false;
|
||||
@ -266,14 +266,15 @@ bool DWARFDebugInfoEntryMinimal::addressRangeContainsAddress(
|
||||
const char *
|
||||
DWARFDebugInfoEntryMinimal::getSubroutineName(const DWARFUnit *U) const {
|
||||
if (!isSubroutineDIE())
|
||||
return 0;
|
||||
return nullptr;
|
||||
// Try to get mangled name if possible.
|
||||
if (const char *name =
|
||||
getAttributeValueAsString(U, DW_AT_MIPS_linkage_name, 0))
|
||||
getAttributeValueAsString(U, DW_AT_MIPS_linkage_name, nullptr))
|
||||
return name;
|
||||
if (const char *name = getAttributeValueAsString(U, DW_AT_linkage_name, 0))
|
||||
if (const char *name = getAttributeValueAsString(U, DW_AT_linkage_name,
|
||||
nullptr))
|
||||
return name;
|
||||
if (const char *name = getAttributeValueAsString(U, DW_AT_name, 0))
|
||||
if (const char *name = getAttributeValueAsString(U, DW_AT_name, nullptr))
|
||||
return name;
|
||||
// Try to get name from specification DIE.
|
||||
uint32_t spec_ref =
|
||||
@ -295,7 +296,7 @@ DWARFDebugInfoEntryMinimal::getSubroutineName(const DWARFUnit *U) const {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void DWARFDebugInfoEntryMinimal::getCallerFrame(const DWARFUnit *U,
|
||||
|
@ -147,7 +147,7 @@ DWARFDebugLine::getLineTable(uint32_t offset) const {
|
||||
LineTableConstIter pos = LineTableMap.find(offset);
|
||||
if (pos != LineTableMap.end())
|
||||
return &pos->second;
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const DWARFDebugLine::LineTable *
|
||||
@ -159,7 +159,7 @@ DWARFDebugLine::getOrParseLineTable(DataExtractor debug_line_data,
|
||||
// Parse and cache the line table for at this offset.
|
||||
State state;
|
||||
if (!parseStatementTable(debug_line_data, RelocMap, &offset, state))
|
||||
return 0;
|
||||
return nullptr;
|
||||
pos.first->second = state;
|
||||
}
|
||||
return &pos.first->second;
|
||||
|
@ -131,7 +131,7 @@ bool DWARFFormValue::extractValue(DataExtractor data, uint32_t *offset_ptr,
|
||||
const DWARFUnit *cu) {
|
||||
bool indirect = false;
|
||||
bool is_block = false;
|
||||
Value.data = NULL;
|
||||
Value.data = nullptr;
|
||||
// Read the value for the form into value and follow and DW_FORM_indirect
|
||||
// instances we run into
|
||||
do {
|
||||
@ -241,7 +241,7 @@ bool DWARFFormValue::extractValue(DataExtractor data, uint32_t *offset_ptr,
|
||||
|
||||
if (is_block) {
|
||||
StringRef str = data.getData().substr(*offset_ptr, Value.uval);
|
||||
Value.data = NULL;
|
||||
Value.data = nullptr;
|
||||
if (!str.empty()) {
|
||||
Value.data = reinterpret_cast<const uint8_t *>(str.data());
|
||||
*offset_ptr += Value.uval;
|
||||
@ -488,7 +488,7 @@ Optional<const char *> DWARFFormValue::getAsCString(const DWARFUnit *U) const {
|
||||
return None;
|
||||
if (Form == DW_FORM_string)
|
||||
return Value.cstr;
|
||||
if (U == 0)
|
||||
if (!U)
|
||||
return None;
|
||||
uint32_t Offset = Value.uval;
|
||||
if (Form == DW_FORM_GNU_str_index) {
|
||||
@ -509,7 +509,7 @@ Optional<uint64_t> DWARFFormValue::getAsAddress(const DWARFUnit *U) const {
|
||||
if (Form == DW_FORM_GNU_addr_index) {
|
||||
uint32_t Index = Value.uval;
|
||||
uint64_t Result;
|
||||
if (U == 0 || !U->getAddrOffsetSectionItem(Index, Result))
|
||||
if (!U || !U->getAddrOffsetSectionItem(Index, Result))
|
||||
return None;
|
||||
return Result;
|
||||
}
|
||||
@ -525,7 +525,7 @@ Optional<uint64_t> DWARFFormValue::getAsReference(const DWARFUnit *U) const {
|
||||
case DW_FORM_ref4:
|
||||
case DW_FORM_ref8:
|
||||
case DW_FORM_ref_udata:
|
||||
if (U == 0)
|
||||
if (!U)
|
||||
return None;
|
||||
return Value.uval + U->getOffset();
|
||||
case DW_FORM_ref_addr:
|
||||
|
@ -98,7 +98,7 @@ void DWARFUnit::clear() {
|
||||
Offset = 0;
|
||||
Length = 0;
|
||||
Version = 0;
|
||||
Abbrevs = 0;
|
||||
Abbrevs = nullptr;
|
||||
AddrSize = 0;
|
||||
BaseAddr = 0;
|
||||
RangeSectionBase = 0;
|
||||
@ -110,8 +110,8 @@ void DWARFUnit::clear() {
|
||||
const char *DWARFUnit::getCompilationDir() {
|
||||
extractDIEsIfNeeded(true);
|
||||
if (DieArray.empty())
|
||||
return 0;
|
||||
return DieArray[0].getAttributeValueAsString(this, DW_AT_comp_dir, 0);
|
||||
return nullptr;
|
||||
return DieArray[0].getAttributeValueAsString(this, DW_AT_comp_dir, nullptr);
|
||||
}
|
||||
|
||||
uint64_t DWARFUnit::getDWOId() {
|
||||
@ -241,25 +241,25 @@ size_t DWARFUnit::extractDIEsIfNeeded(bool CUDieOnly) {
|
||||
DWARFUnit::DWOHolder::DWOHolder(object::ObjectFile *DWOFile)
|
||||
: DWOFile(DWOFile),
|
||||
DWOContext(cast<DWARFContext>(DIContext::getDWARFContext(DWOFile))),
|
||||
DWOU(0) {
|
||||
DWOU(nullptr) {
|
||||
if (DWOContext->getNumDWOCompileUnits() > 0)
|
||||
DWOU = DWOContext->getDWOCompileUnitAtIndex(0);
|
||||
}
|
||||
|
||||
bool DWARFUnit::parseDWO() {
|
||||
if (DWO.get() != 0)
|
||||
if (DWO.get())
|
||||
return false;
|
||||
extractDIEsIfNeeded(true);
|
||||
if (DieArray.empty())
|
||||
return false;
|
||||
const char *DWOFileName =
|
||||
DieArray[0].getAttributeValueAsString(this, DW_AT_GNU_dwo_name, 0);
|
||||
if (DWOFileName == 0)
|
||||
DieArray[0].getAttributeValueAsString(this, DW_AT_GNU_dwo_name, nullptr);
|
||||
if (!DWOFileName)
|
||||
return false;
|
||||
const char *CompilationDir =
|
||||
DieArray[0].getAttributeValueAsString(this, DW_AT_comp_dir, 0);
|
||||
DieArray[0].getAttributeValueAsString(this, DW_AT_comp_dir, nullptr);
|
||||
SmallString<16> AbsolutePath;
|
||||
if (sys::path::is_relative(DWOFileName) && CompilationDir != 0) {
|
||||
if (sys::path::is_relative(DWOFileName) && CompilationDir != nullptr) {
|
||||
sys::path::append(AbsolutePath, CompilationDir);
|
||||
}
|
||||
sys::path::append(AbsolutePath, DWOFileName);
|
||||
@ -271,7 +271,7 @@ bool DWARFUnit::parseDWO() {
|
||||
DWO.reset(new DWOHolder(DWOFile.get()));
|
||||
DWARFUnit *DWOCU = DWO->getUnit();
|
||||
// Verify that compile unit in .dwo file is valid.
|
||||
if (DWOCU == 0 || DWOCU->getDWOId() != getDWOId()) {
|
||||
if (!DWOCU || DWOCU->getDWOId() != getDWOId()) {
|
||||
DWO.reset();
|
||||
return false;
|
||||
}
|
||||
@ -337,14 +337,14 @@ DWARFUnit::getSubprogramForAddress(uint64_t Address) {
|
||||
return &DIE;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DWARFDebugInfoEntryInlinedChain
|
||||
DWARFUnit::getInlinedChainForAddress(uint64_t Address) {
|
||||
// First, find a subprogram that contains the given address (the root
|
||||
// of inlined chain).
|
||||
const DWARFUnit *ChainCU = 0;
|
||||
const DWARFUnit *ChainCU = nullptr;
|
||||
const DWARFDebugInfoEntryMinimal *SubprogramDIE =
|
||||
getSubprogramForAddress(Address);
|
||||
if (SubprogramDIE) {
|
||||
|
@ -50,19 +50,19 @@ ExecutionEngine *(*ExecutionEngine::JITCtor)(
|
||||
std::string *ErrorStr,
|
||||
JITMemoryManager *JMM,
|
||||
bool GVsWithCode,
|
||||
TargetMachine *TM) = 0;
|
||||
TargetMachine *TM) = nullptr;
|
||||
ExecutionEngine *(*ExecutionEngine::MCJITCtor)(
|
||||
Module *M,
|
||||
std::string *ErrorStr,
|
||||
RTDyldMemoryManager *MCJMM,
|
||||
bool GVsWithCode,
|
||||
TargetMachine *TM) = 0;
|
||||
TargetMachine *TM) = nullptr;
|
||||
ExecutionEngine *(*ExecutionEngine::InterpCtor)(Module *M,
|
||||
std::string *ErrorStr) = 0;
|
||||
std::string *ErrorStr) =nullptr;
|
||||
|
||||
ExecutionEngine::ExecutionEngine(Module *M)
|
||||
: EEState(*this),
|
||||
LazyFunctionCreator(0) {
|
||||
LazyFunctionCreator(nullptr) {
|
||||
CompilingLazily = false;
|
||||
GVCompilationDisabled = false;
|
||||
SymbolSearchingDisabled = false;
|
||||
@ -129,7 +129,7 @@ Function *ExecutionEngine::FindFunctionNamed(const char *FnName) {
|
||||
if (Function *F = Modules[i]->getFunction(FnName))
|
||||
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
|
||||
// GlobalAddressMap.
|
||||
if (I == GlobalAddressMap.end())
|
||||
OldVal = 0;
|
||||
OldVal = nullptr;
|
||||
else {
|
||||
OldVal = I->second;
|
||||
GlobalAddressMap.erase(I);
|
||||
@ -157,14 +157,14 @@ void ExecutionEngine::addGlobalMapping(const GlobalValue *GV, void *Addr) {
|
||||
DEBUG(dbgs() << "JIT: Map \'" << GV->getName()
|
||||
<< "\' to [" << Addr << "]\n";);
|
||||
void *&CurVal = EEState.getGlobalAddressMap(locked)[GV];
|
||||
assert((CurVal == 0 || Addr == 0) && "GlobalMapping already established!");
|
||||
assert((!CurVal || !Addr) && "GlobalMapping already established!");
|
||||
CurVal = Addr;
|
||||
|
||||
// If we are using the reverse mapping, add it too.
|
||||
if (!EEState.getGlobalAddressReverseMap(locked).empty()) {
|
||||
AssertingVH<const GlobalValue> &V =
|
||||
EEState.getGlobalAddressReverseMap(locked)[Addr];
|
||||
assert((V == 0 || GV == 0) && "GlobalMapping already established!");
|
||||
assert((!V || !GV) && "GlobalMapping already established!");
|
||||
V = GV;
|
||||
}
|
||||
}
|
||||
@ -193,7 +193,7 @@ void *ExecutionEngine::updateGlobalMapping(const GlobalValue *GV, void *Addr) {
|
||||
EEState.getGlobalAddressMap(locked);
|
||||
|
||||
// Deleting from the mapping?
|
||||
if (Addr == 0)
|
||||
if (!Addr)
|
||||
return EEState.RemoveMapping(locked, GV);
|
||||
|
||||
void *&CurVal = Map[GV];
|
||||
@ -207,7 +207,7 @@ void *ExecutionEngine::updateGlobalMapping(const GlobalValue *GV, void *Addr) {
|
||||
if (!EEState.getGlobalAddressReverseMap(locked).empty()) {
|
||||
AssertingVH<const GlobalValue> &V =
|
||||
EEState.getGlobalAddressReverseMap(locked)[Addr];
|
||||
assert((V == 0 || GV == 0) && "GlobalMapping already established!");
|
||||
assert((!V || !GV) && "GlobalMapping already established!");
|
||||
V = GV;
|
||||
}
|
||||
return OldVal;
|
||||
@ -218,7 +218,7 @@ void *ExecutionEngine::getPointerToGlobalIfAvailable(const GlobalValue *GV) {
|
||||
|
||||
ExecutionEngineState::GlobalAddressMapTy::iterator I =
|
||||
EEState.getGlobalAddressMap(locked).find(GV);
|
||||
return I != EEState.getGlobalAddressMap(locked).end() ? I->second : 0;
|
||||
return I != EEState.getGlobalAddressMap(locked).end() ? I->second : nullptr;
|
||||
}
|
||||
|
||||
const GlobalValue *ExecutionEngine::getGlobalValueAtAddress(void *Addr) {
|
||||
@ -235,7 +235,7 @@ const GlobalValue *ExecutionEngine::getGlobalValueAtAddress(void *Addr) {
|
||||
|
||||
std::map<void *, AssertingVH<const GlobalValue> >::iterator I =
|
||||
EEState.getGlobalAddressReverseMap(locked).find(Addr);
|
||||
return I != EEState.getGlobalAddressReverseMap(locked).end() ? I->second : 0;
|
||||
return I != EEState.getGlobalAddressReverseMap(locked).end() ? I->second : nullptr;
|
||||
}
|
||||
|
||||
namespace {
|
||||
@ -243,11 +243,11 @@ class ArgvArray {
|
||||
char *Array;
|
||||
std::vector<char*> Values;
|
||||
public:
|
||||
ArgvArray() : Array(NULL) {}
|
||||
ArgvArray() : Array(nullptr) {}
|
||||
~ArgvArray() { clear(); }
|
||||
void clear() {
|
||||
delete[] Array;
|
||||
Array = NULL;
|
||||
Array = nullptr;
|
||||
for (size_t I = 0, E = Values.size(); I != E; ++I) {
|
||||
delete[] Values[I];
|
||||
}
|
||||
@ -283,7 +283,7 @@ void *ArgvArray::reset(LLVMContext &C, ExecutionEngine *EE,
|
||||
}
|
||||
|
||||
// Null terminate it
|
||||
EE->StoreValueToMemory(PTOGV(0),
|
||||
EE->StoreValueToMemory(PTOGV(nullptr),
|
||||
(GenericValue*)(Array+InputArgv.size()*PtrSize),
|
||||
SBytePtr);
|
||||
return Array;
|
||||
@ -303,11 +303,11 @@ void ExecutionEngine::runStaticConstructorsDestructors(Module *module,
|
||||
// Should be an array of '{ i32, void ()* }' structs. The first value is
|
||||
// the init priority, which we ignore.
|
||||
ConstantArray *InitList = dyn_cast<ConstantArray>(GV->getInitializer());
|
||||
if (InitList == 0)
|
||||
if (!InitList)
|
||||
return;
|
||||
for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) {
|
||||
ConstantStruct *CS = dyn_cast<ConstantStruct>(InitList->getOperand(i));
|
||||
if (CS == 0) continue;
|
||||
if (!CS) continue;
|
||||
|
||||
Constant *FP = CS->getOperand(1);
|
||||
if (FP->isNullValue())
|
||||
@ -418,10 +418,10 @@ ExecutionEngine *ExecutionEngine::createJIT(Module *M,
|
||||
bool GVsWithCode,
|
||||
Reloc::Model RM,
|
||||
CodeModel::Model CMM) {
|
||||
if (ExecutionEngine::JITCtor == 0) {
|
||||
if (!ExecutionEngine::JITCtor) {
|
||||
if (ErrorStr)
|
||||
*ErrorStr = "JIT has not been linked in.";
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Use the defaults for extra parameters. Users can use EngineBuilder to
|
||||
@ -437,7 +437,7 @@ ExecutionEngine *ExecutionEngine::createJIT(Module *M,
|
||||
|
||||
// TODO: permit custom TargetOptions here
|
||||
TargetMachine *TM = EB.selectTarget();
|
||||
if (!TM || (ErrorStr && ErrorStr->length() > 0)) return 0;
|
||||
if (!TM || (ErrorStr && ErrorStr->length() > 0)) return nullptr;
|
||||
|
||||
return ExecutionEngine::JITCtor(M, ErrorStr, JMM, GVsWithCode, TM);
|
||||
}
|
||||
@ -447,8 +447,8 @@ ExecutionEngine *EngineBuilder::create(TargetMachine *TM) {
|
||||
|
||||
// Make sure we can resolve symbols in the program as well. The zero arg
|
||||
// to the function tells DynamicLibrary to load the program, not a library.
|
||||
if (sys::DynamicLibrary::LoadLibraryPermanently(0, ErrorStr))
|
||||
return 0;
|
||||
if (sys::DynamicLibrary::LoadLibraryPermanently(nullptr, ErrorStr))
|
||||
return nullptr;
|
||||
|
||||
assert(!(JMM && MCJMM));
|
||||
|
||||
@ -461,7 +461,7 @@ ExecutionEngine *EngineBuilder::create(TargetMachine *TM) {
|
||||
else {
|
||||
if (ErrorStr)
|
||||
*ErrorStr = "Cannot create an interpreter with a memory manager.";
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -470,7 +470,7 @@ ExecutionEngine *EngineBuilder::create(TargetMachine *TM) {
|
||||
*ErrorStr =
|
||||
"Cannot create a legacy JIT with a runtime dyld memory "
|
||||
"manager.";
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Unless the interpreter was explicitly selected or the JIT is not linked,
|
||||
@ -503,16 +503,16 @@ ExecutionEngine *EngineBuilder::create(TargetMachine *TM) {
|
||||
return ExecutionEngine::InterpCtor(M, ErrorStr);
|
||||
if (ErrorStr)
|
||||
*ErrorStr = "Interpreter has not been linked in.";
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if ((WhichEngine & EngineKind::JIT) && ExecutionEngine::JITCtor == 0 &&
|
||||
ExecutionEngine::MCJITCtor == 0) {
|
||||
if ((WhichEngine & EngineKind::JIT) && !ExecutionEngine::JITCtor &&
|
||||
!ExecutionEngine::MCJITCtor) {
|
||||
if (ErrorStr)
|
||||
*ErrorStr = "JIT has not been linked in.";
|
||||
}
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void *ExecutionEngine::getPointerToGlobal(const GlobalValue *GV) {
|
||||
@ -848,7 +848,7 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
|
||||
break;
|
||||
case Type::PointerTyID:
|
||||
if (isa<ConstantPointerNull>(C))
|
||||
Result.PointerVal = 0;
|
||||
Result.PointerVal = nullptr;
|
||||
else if (const Function *F = dyn_cast<Function>(C))
|
||||
Result = PTOGV(getPointerToFunctionOrStub(const_cast<Function*>(F)));
|
||||
else if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(C))
|
||||
@ -1290,12 +1290,12 @@ void ExecutionEngine::emitGlobals() {
|
||||
void ExecutionEngine::EmitGlobalVariable(const GlobalVariable *GV) {
|
||||
void *GA = getPointerToGlobalIfAvailable(GV);
|
||||
|
||||
if (GA == 0) {
|
||||
if (!GA) {
|
||||
// If it's not already specified, allocate memory for the global.
|
||||
GA = getMemoryForGV(GV);
|
||||
|
||||
// If we failed to allocate memory for this global, return.
|
||||
if (GA == 0) return;
|
||||
if (!GA) return;
|
||||
|
||||
addGlobalMapping(GV, GA);
|
||||
}
|
||||
|
@ -410,7 +410,7 @@ uint8_t *SimpleBindingMemoryManager::allocateDataSection(
|
||||
}
|
||||
|
||||
bool SimpleBindingMemoryManager::finalizeMemory(std::string *ErrMsg) {
|
||||
char *errMsgCString = 0;
|
||||
char *errMsgCString = nullptr;
|
||||
bool result = Functions.FinalizeMemory(Opaque, &errMsgCString);
|
||||
assert((result || !errMsgCString) &&
|
||||
"Did not expect an error message if FinalizeMemory succeeded");
|
||||
@ -433,7 +433,7 @@ LLVMMCJITMemoryManagerRef LLVMCreateSimpleMCJITMemoryManager(
|
||||
|
||||
if (!AllocateCodeSection || !AllocateDataSection || !FinalizeMemory ||
|
||||
!Destroy)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
SimpleBindingMMFunctions functions;
|
||||
functions.AllocateCodeSection = AllocateCodeSection;
|
||||
|
@ -47,7 +47,7 @@ TargetMachine *EngineBuilder::selectTarget(const Triple &TargetTriple,
|
||||
TheTriple.setTriple(sys::getProcessTriple());
|
||||
|
||||
// Adjust the triple to match what the user requested.
|
||||
const Target *TheTarget = 0;
|
||||
const Target *TheTarget = nullptr;
|
||||
if (!MArch.empty()) {
|
||||
for (TargetRegistry::iterator it = TargetRegistry::begin(),
|
||||
ie = TargetRegistry::end(); it != ie; ++it) {
|
||||
@ -61,7 +61,7 @@ TargetMachine *EngineBuilder::selectTarget(const Triple &TargetTriple,
|
||||
if (ErrorStr)
|
||||
*ErrorStr = "No available targets are compatible with this -march, "
|
||||
"see -version for the available targets.\n";
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Adjust the triple to match (if known), otherwise stick with the
|
||||
@ -72,10 +72,10 @@ TargetMachine *EngineBuilder::selectTarget(const Triple &TargetTriple,
|
||||
} else {
|
||||
std::string Error;
|
||||
TheTarget = TargetRegistry::lookupTarget(TheTriple.getTriple(), Error);
|
||||
if (TheTarget == 0) {
|
||||
if (!TheTarget) {
|
||||
if (ErrorStr)
|
||||
*ErrorStr = Error;
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
InstList.clear();
|
||||
}
|
||||
|
@ -1951,7 +1951,7 @@ static Constant *ConstantFoldGetElementPtrImpl(Constant *C,
|
||||
if (isa<UndefValue>(C)) {
|
||||
PointerType *Ptr = cast<PointerType>(C->getType());
|
||||
Type *Ty = GetElementPtrInst::getIndexedType(Ptr, Idxs);
|
||||
assert(Ty != 0 && "Invalid indices for GEP!");
|
||||
assert(Ty && "Invalid indices for GEP!");
|
||||
return UndefValue::get(PointerType::get(Ty, Ptr->getAddressSpace()));
|
||||
}
|
||||
|
||||
@ -1965,7 +1965,7 @@ static Constant *ConstantFoldGetElementPtrImpl(Constant *C,
|
||||
if (isNull) {
|
||||
PointerType *Ptr = cast<PointerType>(C->getType());
|
||||
Type *Ty = GetElementPtrInst::getIndexedType(Ptr, Idxs);
|
||||
assert(Ty != 0 && "Invalid indices for GEP!");
|
||||
assert(Ty && "Invalid indices for GEP!");
|
||||
return ConstantPointerNull::get(PointerType::get(Ty,
|
||||
Ptr->getAddressSpace()));
|
||||
}
|
||||
|
@ -1354,7 +1354,7 @@ void UndefValue::destroyConstant() {
|
||||
//
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -1381,7 +1381,7 @@ BlockAddress *BlockAddress::lookup(const BasicBlock *BB) {
|
||||
return nullptr;
|
||||
|
||||
const Function *F = BB->getParent();
|
||||
assert(F != 0 && "Block must have a parent");
|
||||
assert(F && "Block must have a parent");
|
||||
BlockAddress *BA =
|
||||
F->getContext().pImpl->BlockAddresses.lookup(std::make_pair(F, BB));
|
||||
assert(BA && "Refcount and block address map disagree!");
|
||||
|
@ -260,7 +260,7 @@ void DebugRecVH::deleted() {
|
||||
|
||||
MDNode *OldScope = Entry.first.get();
|
||||
MDNode *OldInlinedAt = Entry.second.get();
|
||||
assert(OldScope != 0 && OldInlinedAt != 0 &&
|
||||
assert(OldScope && OldInlinedAt &&
|
||||
"Entry should be non-canonical if either val dropped to null");
|
||||
|
||||
// Otherwise, we do have an entry in it, nuke it and we're done.
|
||||
@ -314,7 +314,7 @@ void DebugRecVH::allUsesReplacedWith(Value *NewVa) {
|
||||
|
||||
MDNode *OldScope = Entry.first.get();
|
||||
MDNode *OldInlinedAt = Entry.second.get();
|
||||
assert(OldScope != 0 && OldInlinedAt != 0 &&
|
||||
assert(OldScope && OldInlinedAt &&
|
||||
"Entry should be non-canonical if either val dropped to null");
|
||||
|
||||
// Otherwise, we do have an entry in it, nuke it and we're done.
|
||||
|
@ -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.
|
||||
Instruction::~Instruction() {
|
||||
assert(Parent == 0 && "Instruction still linked in the program!");
|
||||
assert(!Parent && "Instruction still linked in the program!");
|
||||
if (hasMetadataHashEntry())
|
||||
clearMetadataHashEntries();
|
||||
}
|
||||
|
@ -732,7 +732,7 @@ BranchInst::BranchInst(BasicBlock *IfTrue, Instruction *InsertBefore)
|
||||
: TerminatorInst(Type::getVoidTy(IfTrue->getContext()), Instruction::Br,
|
||||
OperandTraits<BranchInst>::op_end(this) - 1,
|
||||
1, InsertBefore) {
|
||||
assert(IfTrue != 0 && "Branch destination may not be null!");
|
||||
assert(IfTrue && "Branch destination may not be null!");
|
||||
Op<-1>() = IfTrue;
|
||||
}
|
||||
BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
|
||||
@ -752,7 +752,7 @@ BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *InsertAtEnd)
|
||||
: TerminatorInst(Type::getVoidTy(IfTrue->getContext()), Instruction::Br,
|
||||
OperandTraits<BranchInst>::op_end(this) - 1,
|
||||
1, InsertAtEnd) {
|
||||
assert(IfTrue != 0 && "Branch destination may not be null!");
|
||||
assert(IfTrue && "Branch destination may not be null!");
|
||||
Op<-1>() = IfTrue;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ MDString *MDBuilder::createString(StringRef Str) {
|
||||
|
||||
MDNode *MDBuilder::createFPMath(float Accuracy) {
|
||||
if (Accuracy == 0.0)
|
||||
return 0;
|
||||
return nullptr;
|
||||
assert(Accuracy > 0.0 && "Invalid fpmath accuracy!");
|
||||
Value *Op = ConstantFP::get(Type::getFloatTy(Context), Accuracy);
|
||||
return MDNode::get(Context, Op);
|
||||
|
@ -164,10 +164,10 @@ static const Function *getFunctionForValue(Value *V) {
|
||||
|
||||
#ifndef NDEBUG
|
||||
static const Function *assertLocalFunction(const MDNode *N) {
|
||||
if (!N->isFunctionLocal()) return 0;
|
||||
if (!N->isFunctionLocal()) return nullptr;
|
||||
|
||||
// FIXME: This does not handle cyclic function local metadata.
|
||||
const Function *F = 0, *NewF = 0;
|
||||
const Function *F = nullptr, *NewF = nullptr;
|
||||
for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
|
||||
if (Value *V = N->getOperand(i)) {
|
||||
if (MDNode *MD = dyn_cast<MDNode>(V))
|
||||
@ -175,10 +175,11 @@ static const Function *assertLocalFunction(const MDNode *N) {
|
||||
else
|
||||
NewF = getFunctionForValue(V);
|
||||
}
|
||||
if (F == 0)
|
||||
if (!F)
|
||||
F = NewF;
|
||||
else
|
||||
assert((NewF == 0 || F == NewF) &&"inconsistent function-local metadata");
|
||||
else
|
||||
assert((NewF == nullptr || F == NewF) &&
|
||||
"inconsistent function-local metadata");
|
||||
}
|
||||
return F;
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ void PassRegistry::registerAnalysisGroup(const void *InterfaceID,
|
||||
"Cannot add a pass to the same analysis group more than once!");
|
||||
AGI.Implementations.insert(ImplementationInfo);
|
||||
if (isDefault) {
|
||||
assert(InterfaceInfo->getNormalCtor() == 0 &&
|
||||
assert(InterfaceInfo->getNormalCtor() == nullptr &&
|
||||
"Default implementation for analysis group already specified!");
|
||||
assert(ImplementationInfo->getNormalCtor() &&
|
||||
"Cannot specify pass as default if it does not have a default ctor");
|
||||
|
@ -497,7 +497,7 @@ StructType *StructType::get(LLVMContext &Context, bool isPacked) {
|
||||
}
|
||||
|
||||
StructType *StructType::get(Type *type, ...) {
|
||||
assert(type != 0 && "Cannot create a struct type with no elements with this");
|
||||
assert(type && "Cannot create a struct type with no elements with this");
|
||||
LLVMContext &Ctx = type->getContext();
|
||||
va_list ap;
|
||||
SmallVector<llvm::Type*, 8> StructFields;
|
||||
@ -538,7 +538,7 @@ StructType *StructType::create(ArrayRef<Type*> Elements) {
|
||||
}
|
||||
|
||||
StructType *StructType::create(StringRef Name, Type *type, ...) {
|
||||
assert(type != 0 && "Cannot create a struct type with no elements with this");
|
||||
assert(type && "Cannot create a struct type with no elements with this");
|
||||
LLVMContext &Ctx = type->getContext();
|
||||
va_list ap;
|
||||
SmallVector<llvm::Type*, 8> StructFields;
|
||||
@ -582,7 +582,7 @@ StringRef StructType::getName() const {
|
||||
}
|
||||
|
||||
void StructType::setBody(Type *type, ...) {
|
||||
assert(type != 0 && "Cannot create a struct type with no elements with this");
|
||||
assert(type && "Cannot create a struct type with no elements with this");
|
||||
va_list ap;
|
||||
SmallVector<llvm::Type*, 8> StructFields;
|
||||
va_start(ap, type);
|
||||
|
@ -557,7 +557,7 @@ void ValueHandleBase::AddToUseList() {
|
||||
// If this value already has a ValueHandle, then it must be in the
|
||||
// ValueHandles map already.
|
||||
ValueHandleBase *&Entry = pImpl->ValueHandles[VP.getPointer()];
|
||||
assert(Entry != 0 && "Value doesn't have any handles?");
|
||||
assert(Entry && "Value doesn't have any handles?");
|
||||
AddToExistingUseList(&Entry);
|
||||
return;
|
||||
}
|
||||
@ -571,7 +571,7 @@ void ValueHandleBase::AddToUseList() {
|
||||
const void *OldBucketPtr = Handles.getPointerIntoBucketsArray();
|
||||
|
||||
ValueHandleBase *&Entry = Handles[VP.getPointer()];
|
||||
assert(Entry == 0 && "Value really did already have handles?");
|
||||
assert(!Entry && "Value really did already have handles?");
|
||||
AddToExistingUseList(&Entry);
|
||||
VP.getPointer()->HasValueHandle = true;
|
||||
|
||||
|
@ -42,12 +42,12 @@ Module *llvm::getLazyIRModule(MemoryBuffer *Buffer, SMDiagnostic &Err,
|
||||
// ParseBitcodeFile does not take ownership of the Buffer in the
|
||||
// case of an error.
|
||||
delete Buffer;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return ModuleOrErr.get();
|
||||
}
|
||||
|
||||
return ParseAssembly(Buffer, 0, Err, Context);
|
||||
return ParseAssembly(Buffer, nullptr, Err, Context);
|
||||
}
|
||||
|
||||
Module *llvm::getLazyIRFileModule(const std::string &Filename, SMDiagnostic &Err,
|
||||
@ -56,7 +56,7 @@ Module *llvm::getLazyIRFileModule(const std::string &Filename, SMDiagnostic &Err
|
||||
if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, File)) {
|
||||
Err = SMDiagnostic(Filename, SourceMgr::DK_Error,
|
||||
"Could not open input file: " + ec.message());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return getLazyIRModule(File.release(), Err, Context);
|
||||
@ -69,7 +69,7 @@ Module *llvm::ParseIR(MemoryBuffer *Buffer, SMDiagnostic &Err,
|
||||
if (isBitcode((const unsigned char *)Buffer->getBufferStart(),
|
||||
(const unsigned char *)Buffer->getBufferEnd())) {
|
||||
ErrorOr<Module *> ModuleOrErr = parseBitcodeFile(Buffer, Context);
|
||||
Module *M = 0;
|
||||
Module *M = nullptr;
|
||||
if (error_code EC = ModuleOrErr.getError())
|
||||
Err = SMDiagnostic(Buffer->getBufferIdentifier(), SourceMgr::DK_Error,
|
||||
EC.message());
|
||||
@ -80,7 +80,7 @@ Module *llvm::ParseIR(MemoryBuffer *Buffer, SMDiagnostic &Err,
|
||||
return M;
|
||||
}
|
||||
|
||||
return ParseAssembly(Buffer, 0, Err, Context);
|
||||
return ParseAssembly(Buffer, nullptr, Err, Context);
|
||||
}
|
||||
|
||||
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)) {
|
||||
Err = SMDiagnostic(Filename, SourceMgr::DK_Error,
|
||||
"Could not open input file: " + ec.message());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return ParseIR(File.release(), Err, Context);
|
||||
@ -111,7 +111,7 @@ LLVMBool LLVMParseIRInContext(LLVMContextRef ContextRef,
|
||||
std::string buf;
|
||||
raw_string_ostream os(buf);
|
||||
|
||||
Diag.print(NULL, os, false);
|
||||
Diag.print(nullptr, os, false);
|
||||
os.flush();
|
||||
|
||||
*OutMessage = strdup(buf.c_str());
|
||||
|
@ -64,17 +64,17 @@ const char* LTOCodeGenerator::getVersionString() {
|
||||
|
||||
LTOCodeGenerator::LTOCodeGenerator()
|
||||
: Context(getGlobalContext()), Linker(new Module("ld-temp.o", Context)),
|
||||
TargetMach(NULL), EmitDwarfDebugInfo(false), ScopeRestrictionsDone(false),
|
||||
CodeModel(LTO_CODEGEN_PIC_MODEL_DEFAULT), NativeObjectFile(NULL),
|
||||
DiagHandler(NULL), DiagContext(NULL) {
|
||||
TargetMach(nullptr), EmitDwarfDebugInfo(false),
|
||||
ScopeRestrictionsDone(false), CodeModel(LTO_CODEGEN_PIC_MODEL_DEFAULT),
|
||||
NativeObjectFile(nullptr), DiagHandler(nullptr), DiagContext(nullptr) {
|
||||
initializeLTOPasses();
|
||||
}
|
||||
|
||||
LTOCodeGenerator::~LTOCodeGenerator() {
|
||||
delete TargetMach;
|
||||
delete NativeObjectFile;
|
||||
TargetMach = NULL;
|
||||
NativeObjectFile = NULL;
|
||||
TargetMach = nullptr;
|
||||
NativeObjectFile = nullptr;
|
||||
|
||||
Linker.deleteModule();
|
||||
|
||||
@ -245,7 +245,7 @@ const void* LTOCodeGenerator::compile(size_t* length,
|
||||
const char *name;
|
||||
if (!compile_to_file(&name, disableOpt, disableInline, disableGVNLoadPRE,
|
||||
errMsg))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
// remove old buffer if compile() called twice
|
||||
delete NativeObjectFile;
|
||||
@ -255,7 +255,7 @@ const void* LTOCodeGenerator::compile(size_t* length,
|
||||
if (error_code ec = MemoryBuffer::getFile(name, BuffPtr, -1, false)) {
|
||||
errMsg = ec.message();
|
||||
sys::fs::remove(NativeObjectPath);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
NativeObjectFile = BuffPtr.release();
|
||||
|
||||
@ -263,14 +263,14 @@ const void* LTOCodeGenerator::compile(size_t* length,
|
||||
sys::fs::remove(NativeObjectPath);
|
||||
|
||||
// return buffer, unless error
|
||||
if (NativeObjectFile == NULL)
|
||||
return NULL;
|
||||
if (!NativeObjectFile)
|
||||
return nullptr;
|
||||
*length = NativeObjectFile->getBufferSize();
|
||||
return NativeObjectFile->getBufferStart();
|
||||
}
|
||||
|
||||
bool LTOCodeGenerator::determineTarget(std::string &errMsg) {
|
||||
if (TargetMach != NULL)
|
||||
if (TargetMach)
|
||||
return true;
|
||||
|
||||
std::string TripleStr = Linker.getModule()->getTargetTriple();
|
||||
@ -280,7 +280,7 @@ bool LTOCodeGenerator::determineTarget(std::string &errMsg) {
|
||||
|
||||
// create target machine from info for merged modules
|
||||
const Target *march = TargetRegistry::lookupTarget(TripleStr, errMsg);
|
||||
if (march == NULL)
|
||||
if (!march)
|
||||
return false;
|
||||
|
||||
// The relocation model is actually a static member of TargetMachine and
|
||||
@ -355,7 +355,7 @@ applyRestriction(GlobalValue &GV,
|
||||
|
||||
static void findUsedValues(GlobalVariable *LLVMUsed,
|
||||
SmallPtrSet<GlobalValue*, 8> &UsedValues) {
|
||||
if (LLVMUsed == 0) return;
|
||||
if (!LLVMUsed) return;
|
||||
|
||||
ConstantArray *Inits = cast<ConstantArray>(LLVMUsed->getInitializer());
|
||||
for (unsigned i = 0, e = Inits->getNumOperands(); i != e; ++i)
|
||||
@ -579,7 +579,7 @@ LTOCodeGenerator::setDiagnosticHandler(lto_diagnostic_handler_t DiagHandler,
|
||||
this->DiagHandler = DiagHandler;
|
||||
this->DiagContext = Ctxt;
|
||||
if (!DiagHandler)
|
||||
return Context.setDiagnosticHandler(NULL, NULL);
|
||||
return Context.setDiagnosticHandler(nullptr, nullptr);
|
||||
// Register the LTOCodeGenerator stub in the LLVMContext to forward the
|
||||
// diagnostic to the external DiagHandler.
|
||||
Context.setDiagnosticHandler(LTOCodeGenerator::DiagnosticHandler, this);
|
||||
|
@ -100,7 +100,7 @@ LTOModule *LTOModule::makeLTOModule(const char *path, TargetOptions options,
|
||||
std::unique_ptr<MemoryBuffer> buffer;
|
||||
if (error_code ec = MemoryBuffer::getFile(path, buffer)) {
|
||||
errMsg = ec.message();
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return makeLTOModule(buffer.release(), options, errMsg);
|
||||
}
|
||||
@ -120,7 +120,7 @@ LTOModule *LTOModule::makeLTOModule(int fd, const char *path,
|
||||
if (error_code ec =
|
||||
MemoryBuffer::getOpenFileSlice(fd, path, buffer, map_size, offset)) {
|
||||
errMsg = ec.message();
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return makeLTOModule(buffer.release(), options, errMsg);
|
||||
}
|
||||
@ -130,7 +130,7 @@ LTOModule *LTOModule::makeLTOModule(const void *mem, size_t length,
|
||||
std::string &errMsg, StringRef path) {
|
||||
std::unique_ptr<MemoryBuffer> buffer(makeBuffer(mem, length, path));
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
return makeLTOModule(buffer.release(), options, errMsg);
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ LTOModule *LTOModule::makeLTOModule(MemoryBuffer *buffer,
|
||||
if (error_code EC = ModuleOrErr.getError()) {
|
||||
errMsg = EC.message();
|
||||
delete buffer;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
std::unique_ptr<Module> m(ModuleOrErr.get());
|
||||
|
||||
@ -155,7 +155,7 @@ LTOModule *LTOModule::makeLTOModule(MemoryBuffer *buffer,
|
||||
// find machine architecture for this module
|
||||
const Target *march = TargetRegistry::lookupTarget(TripleStr, errMsg);
|
||||
if (!march)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
// construct LTOModule, hand over ownership of module and target
|
||||
SubtargetFeatures Features;
|
||||
@ -189,7 +189,7 @@ LTOModule *LTOModule::makeLTOModule(MemoryBuffer *buffer,
|
||||
|
||||
if (Ret->parseSymbols(errMsg)) {
|
||||
delete Ret;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Ret->parseMetadata();
|
||||
@ -460,7 +460,7 @@ void LTOModule::addAsmGlobalSymbol(const char *name,
|
||||
|
||||
NameAndAttributes &info = _undefines[entry.getKey().data()];
|
||||
|
||||
if (info.symbol == 0) {
|
||||
if (info.symbol == nullptr) {
|
||||
// FIXME: This is trying to take care of module ASM like this:
|
||||
//
|
||||
// module asm ".zerofill __FOO, __foo, _bar_baz_qux, 0"
|
||||
@ -474,7 +474,7 @@ void LTOModule::addAsmGlobalSymbol(const char *name,
|
||||
info.attributes =
|
||||
LTO_SYMBOL_PERMISSIONS_DATA | LTO_SYMBOL_DEFINITION_REGULAR | scope;
|
||||
info.isFunction = false;
|
||||
info.symbol = 0;
|
||||
info.symbol = nullptr;
|
||||
|
||||
// add to table of symbols
|
||||
_symbols.push_back(info);
|
||||
@ -508,7 +508,7 @@ void LTOModule::addAsmGlobalSymbolUndef(const char *name) {
|
||||
info.name = entry.getKey().data();
|
||||
info.attributes = attr;
|
||||
info.isFunction = false;
|
||||
info.symbol = 0;
|
||||
info.symbol = nullptr;
|
||||
|
||||
entry.setValue(info);
|
||||
}
|
||||
|
@ -439,16 +439,16 @@ namespace {
|
||||
// If the source has no name it can't link. If it has local linkage,
|
||||
// there is no name match-up going on.
|
||||
if (!SrcGV->hasName() || SrcGV->hasLocalLinkage())
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
// Otherwise see if we have a match in the destination module's symtab.
|
||||
GlobalValue *DGV = DstM->getNamedValue(SrcGV->getName());
|
||||
if (DGV == 0) return 0;
|
||||
if (!DGV) return nullptr;
|
||||
|
||||
// If we found a global with the same name in the dest module, but it has
|
||||
// internal linkage, we are really not doing any linkage here.
|
||||
if (DGV->hasLocalLinkage())
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
// Otherwise, we do in fact link to the destination global.
|
||||
return DGV;
|
||||
@ -518,7 +518,7 @@ static bool isLessConstraining(GlobalValue::VisibilityTypes a,
|
||||
Value *ValueMaterializerTy::materializeValueFor(Value *V) {
|
||||
Function *SF = dyn_cast<Function>(V);
|
||||
if (!SF)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
Function *DF = Function::Create(TypeMap.get(SF->getFunctionType()),
|
||||
SF->getLinkage(), SF->getName(), DstM);
|
||||
@ -612,7 +612,7 @@ void ModuleLinker::computeTypeMapping() {
|
||||
for (Module::global_iterator I = SrcM->global_begin(),
|
||||
E = SrcM->global_end(); I != E; ++I) {
|
||||
GlobalValue *DGV = getLinkedToGlobal(I);
|
||||
if (DGV == 0) continue;
|
||||
if (!DGV) continue;
|
||||
|
||||
if (!DGV->hasAppendingLinkage() || !I->hasAppendingLinkage()) {
|
||||
TypeMap.addTypeMapping(DGV->getType(), I->getType());
|
||||
@ -723,7 +723,7 @@ bool ModuleLinker::linkAppendingVarProto(GlobalVariable *DstGV,
|
||||
// Create the new global variable.
|
||||
GlobalVariable *NG =
|
||||
new GlobalVariable(*DstGV->getParent(), NewType, SrcGV->isConstant(),
|
||||
DstGV->getLinkage(), /*init*/0, /*name*/"", DstGV,
|
||||
DstGV->getLinkage(), /*init*/nullptr, /*name*/"", DstGV,
|
||||
DstGV->getThreadLocalMode(),
|
||||
DstGV->getType()->getAddressSpace());
|
||||
|
||||
@ -800,8 +800,8 @@ bool ModuleLinker::linkGlobalProto(GlobalVariable *SGV) {
|
||||
// initializer will be filled in later by LinkGlobalInits.
|
||||
GlobalVariable *NewDGV =
|
||||
new GlobalVariable(*DstM, TypeMap.get(SGV->getType()->getElementType()),
|
||||
SGV->isConstant(), SGV->getLinkage(), /*init*/0,
|
||||
SGV->getName(), /*insertbefore*/0,
|
||||
SGV->isConstant(), SGV->getLinkage(), /*init*/nullptr,
|
||||
SGV->getName(), /*insertbefore*/nullptr,
|
||||
SGV->getThreadLocalMode(),
|
||||
SGV->getType()->getAddressSpace());
|
||||
// Propagate alignment, visibility and section info.
|
||||
@ -913,7 +913,7 @@ bool ModuleLinker::linkAliasProto(GlobalAlias *SGA) {
|
||||
// bring over SGA.
|
||||
GlobalAlias *NewDA = new GlobalAlias(TypeMap.get(SGA->getType()),
|
||||
SGA->getLinkage(), SGA->getName(),
|
||||
/*aliasee*/0, DstM);
|
||||
/*aliasee*/nullptr, DstM);
|
||||
copyGVAttributes(NewDA, SGA);
|
||||
if (NewVisibility)
|
||||
NewDA->setVisibility(*NewVisibility);
|
||||
@ -997,7 +997,7 @@ void ModuleLinker::linkFunctionBody(Function *Dst, Function *Src) {
|
||||
} else {
|
||||
// Clone the body of the function into the dest function.
|
||||
SmallVector<ReturnInst*, 8> Returns; // Ignore returns.
|
||||
CloneFunctionInto(Dst, Src, ValueMap, false, Returns, "", NULL,
|
||||
CloneFunctionInto(Dst, Src, ValueMap, false, Returns, "", nullptr,
|
||||
&TypeMap, &ValMaterializer);
|
||||
}
|
||||
|
||||
@ -1369,7 +1369,7 @@ Linker::~Linker() {
|
||||
|
||||
void Linker::deleteModule() {
|
||||
delete Composite;
|
||||
Composite = NULL;
|
||||
Composite = nullptr;
|
||||
}
|
||||
|
||||
bool Linker::linkInModule(Module *Src, unsigned Mode, std::string *ErrorMsg) {
|
||||
@ -1406,7 +1406,7 @@ LLVMBool LLVMLinkModules(LLVMModuleRef Dest, LLVMModuleRef Src,
|
||||
LLVMLinkerMode Mode, char **OutMessages) {
|
||||
std::string Messages;
|
||||
LLVMBool Result = Linker::LinkModules(unwrap(Dest), unwrap(Src),
|
||||
Mode, OutMessages? &Messages : 0);
|
||||
Mode, OutMessages? &Messages : nullptr);
|
||||
if (OutMessages)
|
||||
*OutMessages = strdup(Messages.c_str());
|
||||
return Result;
|
||||
|
@ -111,7 +111,7 @@ Archive::Child Archive::Child::getNext() const {
|
||||
|
||||
// Check to see if this is past the end of the archive.
|
||||
if (NextLoc >= Parent->Data->getBufferEnd())
|
||||
return Child(Parent, NULL);
|
||||
return Child(Parent, nullptr);
|
||||
|
||||
return Child(Parent, NextLoc);
|
||||
}
|
||||
@ -349,7 +349,7 @@ Archive::child_iterator Archive::child_begin(bool SkipInternal) const {
|
||||
}
|
||||
|
||||
Archive::child_iterator Archive::child_end() const {
|
||||
return Child(this, NULL);
|
||||
return Child(this, nullptr);
|
||||
}
|
||||
|
||||
error_code Archive::Symbol::getName(StringRef &Result) const {
|
||||
|
@ -138,7 +138,7 @@ error_code COFFObjectFile::getSymbolName(DataRefImpl Ref,
|
||||
error_code COFFObjectFile::getSymbolAddress(DataRefImpl Ref,
|
||||
uint64_t &Result) const {
|
||||
const coff_symbol *Symb = toSymb(Ref);
|
||||
const coff_section *Section = NULL;
|
||||
const coff_section *Section = nullptr;
|
||||
if (error_code EC = getSection(Symb->SectionNumber, Section))
|
||||
return EC;
|
||||
|
||||
@ -163,7 +163,7 @@ error_code COFFObjectFile::getSymbolType(DataRefImpl Ref,
|
||||
} else {
|
||||
uint32_t Characteristics = 0;
|
||||
if (!COFF::isReservedSectionNumber(Symb->SectionNumber)) {
|
||||
const coff_section *Section = NULL;
|
||||
const coff_section *Section = nullptr;
|
||||
if (error_code EC = getSection(Symb->SectionNumber, Section))
|
||||
return EC;
|
||||
Characteristics = Section->Characteristics;
|
||||
@ -208,7 +208,7 @@ error_code COFFObjectFile::getSymbolSize(DataRefImpl Ref,
|
||||
// in the same section as this symbol, and looking for either the next
|
||||
// symbol, or the end of the section.
|
||||
const coff_symbol *Symb = toSymb(Ref);
|
||||
const coff_section *Section = NULL;
|
||||
const coff_section *Section = nullptr;
|
||||
if (error_code EC = getSection(Symb->SectionNumber, Section))
|
||||
return EC;
|
||||
|
||||
@ -227,7 +227,7 @@ error_code COFFObjectFile::getSymbolSection(DataRefImpl Ref,
|
||||
if (COFF::isReservedSectionNumber(Symb->SectionNumber)) {
|
||||
Result = section_end();
|
||||
} else {
|
||||
const coff_section *Sec = 0;
|
||||
const coff_section *Sec = nullptr;
|
||||
if (error_code EC = getSection(Symb->SectionNumber, Sec)) return EC;
|
||||
DataRefImpl Ref;
|
||||
Ref.p = reinterpret_cast<uintptr_t>(Sec);
|
||||
@ -334,7 +334,7 @@ error_code COFFObjectFile::sectionContainsSymbol(DataRefImpl SecRef,
|
||||
bool &Result) const {
|
||||
const coff_section *Sec = toSec(SecRef);
|
||||
const coff_symbol *Symb = toSymb(SymbRef);
|
||||
const coff_section *SymbSec = 0;
|
||||
const coff_section *SymbSec = nullptr;
|
||||
if (error_code EC = getSection(Symb->SectionNumber, SymbSec)) return EC;
|
||||
if (SymbSec == Sec)
|
||||
Result = true;
|
||||
@ -507,10 +507,11 @@ error_code COFFObjectFile::initExportTablePtr() {
|
||||
|
||||
COFFObjectFile::COFFObjectFile(MemoryBuffer *Object, error_code &EC,
|
||||
bool BufferOwned)
|
||||
: ObjectFile(Binary::ID_COFF, Object, BufferOwned), COFFHeader(0),
|
||||
PE32Header(0), PE32PlusHeader(0), DataDirectory(0), SectionTable(0),
|
||||
SymbolTable(0), StringTable(0), StringTableSize(0), ImportDirectory(0),
|
||||
NumberOfImportDirectory(0), ExportDirectory(0) {
|
||||
: ObjectFile(Binary::ID_COFF, Object, BufferOwned), COFFHeader(nullptr),
|
||||
PE32Header(nullptr), PE32PlusHeader(nullptr), DataDirectory(nullptr),
|
||||
SectionTable(nullptr), SymbolTable(nullptr), StringTable(nullptr),
|
||||
StringTableSize(0), ImportDirectory(nullptr), NumberOfImportDirectory(0),
|
||||
ExportDirectory(nullptr) {
|
||||
// Check that we at least have enough room for a header.
|
||||
if (!checkSize(Data, EC, sizeof(coff_file_header))) return;
|
||||
|
||||
@ -632,8 +633,8 @@ export_directory_iterator COFFObjectFile::export_directory_begin() const {
|
||||
}
|
||||
|
||||
export_directory_iterator COFFObjectFile::export_directory_end() const {
|
||||
if (ExportDirectory == 0)
|
||||
return export_directory_iterator(ExportDirectoryEntryRef(0, 0, this));
|
||||
if (!ExportDirectory)
|
||||
return export_directory_iterator(ExportDirectoryEntryRef(nullptr, 0, this));
|
||||
ExportDirectoryEntryRef Ref(ExportDirectory,
|
||||
ExportDirectory->AddressTableEntries, this);
|
||||
return export_directory_iterator(Ref);
|
||||
@ -723,7 +724,7 @@ error_code COFFObjectFile::getSection(int32_t Index,
|
||||
const coff_section *&Result) const {
|
||||
// Check for special index values.
|
||||
if (COFF::isReservedSectionNumber(Index))
|
||||
Result = NULL;
|
||||
Result = nullptr;
|
||||
else if (Index > 0 && Index <= COFFHeader->NumberOfSections)
|
||||
// We already verified the section table data, so no need to check again.
|
||||
Result = SectionTable + (Index - 1);
|
||||
@ -773,7 +774,7 @@ error_code COFFObjectFile::getSymbolName(const coff_symbol *Symbol,
|
||||
|
||||
ArrayRef<uint8_t> COFFObjectFile::getSymbolAuxData(
|
||||
const coff_symbol *Symbol) const {
|
||||
const uint8_t *Aux = NULL;
|
||||
const uint8_t *Aux = nullptr;
|
||||
|
||||
if (Symbol->NumberOfAuxSymbols > 0) {
|
||||
// AUX data comes immediately after the symbol in COFF
|
||||
@ -968,7 +969,7 @@ error_code COFFObjectFile::getRelocationTypeName(DataRefImpl Rel,
|
||||
error_code COFFObjectFile::getRelocationValueString(DataRefImpl Rel,
|
||||
SmallVectorImpl<char> &Result) const {
|
||||
const coff_relocation *Reloc = toRel(Rel);
|
||||
const coff_symbol *Symb = 0;
|
||||
const coff_symbol *Symb = nullptr;
|
||||
if (error_code EC = getSymbol(Reloc->SymbolTableIndex, Symb)) return EC;
|
||||
DataRefImpl Sym;
|
||||
Sym.p = reinterpret_cast<uintptr_t>(Symb);
|
||||
|
@ -420,7 +420,8 @@ MachOObjectFile::MachOObjectFile(MemoryBuffer *Object, bool IsLittleEndian,
|
||||
bool Is64bits, error_code &EC,
|
||||
bool BufferOwned)
|
||||
: ObjectFile(getMachOType(IsLittleEndian, Is64bits), Object, BufferOwned),
|
||||
SymtabLoadCmd(NULL), DysymtabLoadCmd(NULL), DataInCodeLoadCmd(NULL) {
|
||||
SymtabLoadCmd(nullptr), DysymtabLoadCmd(nullptr),
|
||||
DataInCodeLoadCmd(nullptr) {
|
||||
uint32_t LoadCommandCount = this->getHeader().ncmds;
|
||||
MachO::LoadCommandType SegmentLoadType = is64Bit() ?
|
||||
MachO::LC_SEGMENT_64 : MachO::LC_SEGMENT;
|
||||
|
@ -57,7 +57,7 @@ static T getUniversalBinaryStruct(const char *Ptr) {
|
||||
MachOUniversalBinary::ObjectForArch::ObjectForArch(
|
||||
const MachOUniversalBinary *Parent, uint32_t Index)
|
||||
: Parent(Parent), Index(Index) {
|
||||
if (Parent == 0 || Index > Parent->getNumberOfObjects()) {
|
||||
if (!Parent || Index > Parent->getNumberOfObjects()) {
|
||||
clear();
|
||||
} else {
|
||||
// Parse object header.
|
||||
|
@ -60,7 +60,7 @@ wrap(const relocation_iterator *SI) {
|
||||
// ObjectFile creation
|
||||
LLVMObjectFileRef LLVMCreateObjectFile(LLVMMemoryBufferRef MemBuf) {
|
||||
ErrorOr<ObjectFile*> ObjOrErr(ObjectFile::createObjectFile(unwrap(MemBuf)));
|
||||
ObjectFile *Obj = ObjOrErr ? ObjOrErr.get() : 0;
|
||||
ObjectFile *Obj = ObjOrErr ? ObjOrErr.get() : nullptr;
|
||||
return wrap(Obj);
|
||||
}
|
||||
|
||||
|
@ -60,11 +60,11 @@ Arg *ArgList::getLastArgNoClaim(OptSpecifier Id) const {
|
||||
for (const_reverse_iterator it = rbegin(), ie = rend(); it != ie; ++it)
|
||||
if ((*it)->getOption().matches(Id))
|
||||
return *it;
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Arg *ArgList::getLastArg(OptSpecifier Id) const {
|
||||
Arg *Res = 0;
|
||||
Arg *Res = nullptr;
|
||||
for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
|
||||
if ((*it)->getOption().matches(Id)) {
|
||||
Res = *it;
|
||||
@ -76,7 +76,7 @@ Arg *ArgList::getLastArg(OptSpecifier Id) 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) {
|
||||
if ((*it)->getOption().matches(Id0) ||
|
||||
(*it)->getOption().matches(Id1)) {
|
||||
@ -91,7 +91,7 @@ Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1) const {
|
||||
|
||||
Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
|
||||
OptSpecifier Id2) const {
|
||||
Arg *Res = 0;
|
||||
Arg *Res = nullptr;
|
||||
for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
|
||||
if ((*it)->getOption().matches(Id0) ||
|
||||
(*it)->getOption().matches(Id1) ||
|
||||
@ -106,7 +106,7 @@ Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
|
||||
|
||||
Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
|
||||
OptSpecifier Id2, OptSpecifier Id3) const {
|
||||
Arg *Res = 0;
|
||||
Arg *Res = nullptr;
|
||||
for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
|
||||
if ((*it)->getOption().matches(Id0) ||
|
||||
(*it)->getOption().matches(Id1) ||
|
||||
@ -123,7 +123,7 @@ Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
|
||||
Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
|
||||
OptSpecifier Id2, OptSpecifier Id3,
|
||||
OptSpecifier Id4) const {
|
||||
Arg *Res = 0;
|
||||
Arg *Res = nullptr;
|
||||
for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
|
||||
if ((*it)->getOption().matches(Id0) ||
|
||||
(*it)->getOption().matches(Id1) ||
|
||||
@ -141,7 +141,7 @@ Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
|
||||
Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
|
||||
OptSpecifier Id2, OptSpecifier Id3,
|
||||
OptSpecifier Id4, OptSpecifier Id5) const {
|
||||
Arg *Res = 0;
|
||||
Arg *Res = nullptr;
|
||||
for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
|
||||
if ((*it)->getOption().matches(Id0) ||
|
||||
(*it)->getOption().matches(Id1) ||
|
||||
@ -161,7 +161,7 @@ Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
|
||||
OptSpecifier Id2, OptSpecifier Id3,
|
||||
OptSpecifier Id4, OptSpecifier Id5,
|
||||
OptSpecifier Id6) const {
|
||||
Arg *Res = 0;
|
||||
Arg *Res = nullptr;
|
||||
for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
|
||||
if ((*it)->getOption().matches(Id0) ||
|
||||
(*it)->getOption().matches(Id1) ||
|
||||
@ -182,7 +182,7 @@ Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
|
||||
OptSpecifier Id2, OptSpecifier Id3,
|
||||
OptSpecifier Id4, OptSpecifier Id5,
|
||||
OptSpecifier Id6, OptSpecifier Id7) const {
|
||||
Arg *Res = 0;
|
||||
Arg *Res = nullptr;
|
||||
for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
|
||||
if ((*it)->getOption().matches(Id0) ||
|
||||
(*it)->getOption().matches(Id1) ||
|
||||
|
@ -62,7 +62,7 @@ static inline bool operator<(const OptTable::Info &A, const OptTable::Info &B) {
|
||||
|
||||
for (const char * const *APre = A.Prefixes,
|
||||
* const *BPre = B.Prefixes;
|
||||
*APre != 0 && *BPre != 0; ++APre, ++BPre) {
|
||||
*APre != nullptr && *BPre != nullptr; ++APre, ++BPre){
|
||||
if (int N = StrCmpOptionName(*APre, *BPre))
|
||||
return N < 0;
|
||||
}
|
||||
@ -136,7 +136,7 @@ OptTable::OptTable(const Info *_OptionInfos, unsigned _NumOptionInfos,
|
||||
for (unsigned i = FirstSearchableIndex + 1, e = getNumOptions() + 1;
|
||||
i != e; ++i) {
|
||||
if (const char *const *P = getInfo(i).Prefixes) {
|
||||
for (; *P != 0; ++P) {
|
||||
for (; *P != nullptr; ++P) {
|
||||
PrefixesUnion.insert(*P);
|
||||
}
|
||||
}
|
||||
@ -160,7 +160,7 @@ OptTable::~OptTable() {
|
||||
const Option OptTable::getOption(OptSpecifier Opt) const {
|
||||
unsigned id = Opt.getID();
|
||||
if (id == 0)
|
||||
return Option(0, 0);
|
||||
return Option(nullptr, nullptr);
|
||||
assert((unsigned) (id - 1) < getNumOptions() && "Invalid ID.");
|
||||
return Option(&getInfo(id), this);
|
||||
}
|
||||
@ -178,7 +178,7 @@ static bool isInput(const llvm::StringSet<> &Prefixes, StringRef Arg) {
|
||||
/// \returns Matched size. 0 means no match.
|
||||
static unsigned matchOption(const OptTable::Info *I, StringRef Str,
|
||||
bool IgnoreCase) {
|
||||
for (const char * const *Pre = I->Prefixes; *Pre != 0; ++Pre) {
|
||||
for (const char * const *Pre = I->Prefixes; *Pre != nullptr; ++Pre) {
|
||||
StringRef Prefix(*Pre);
|
||||
if (Str.startswith(Prefix)) {
|
||||
StringRef Rest = Str.substr(Prefix.size());
|
||||
@ -240,7 +240,7 @@ Arg *OptTable::ParseOneArg(const ArgList &Args, unsigned &Index,
|
||||
|
||||
// Otherwise, see if this argument was missing values.
|
||||
if (Prev != Index)
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// If we failed to find an option and this arg started with /, then it's
|
||||
|
@ -58,8 +58,8 @@ void Option::dump() const {
|
||||
|
||||
if (Info->Prefixes) {
|
||||
llvm::errs() << " Prefixes:[";
|
||||
for (const char * const *Pre = Info->Prefixes; *Pre != 0; ++Pre) {
|
||||
llvm::errs() << '"' << *Pre << (*(Pre + 1) == 0 ? "\"" : "\", ");
|
||||
for (const char * const *Pre = Info->Prefixes; *Pre != nullptr; ++Pre) {
|
||||
llvm::errs() << '"' << *Pre << (*(Pre + 1) == nullptr ? "\"" : "\", ");
|
||||
}
|
||||
llvm::errs() << ']';
|
||||
}
|
||||
@ -116,7 +116,7 @@ Arg *Option::accept(const ArgList &Args,
|
||||
switch (getKind()) {
|
||||
case FlagClass: {
|
||||
if (ArgSize != strlen(Args.getArgString(Index)))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
Arg *A = new Arg(UnaliasedOption, Spelling, Index++);
|
||||
if (getAliasArgs()) {
|
||||
@ -166,11 +166,11 @@ Arg *Option::accept(const ArgList &Args,
|
||||
// Matches iff this is an exact match.
|
||||
// FIXME: Avoid strlen.
|
||||
if (ArgSize != strlen(Args.getArgString(Index)))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
Index += 2;
|
||||
if (Index > Args.getNumInputArgStrings())
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
return new Arg(UnaliasedOption, Spelling,
|
||||
Index - 2, Args.getArgString(Index - 1));
|
||||
@ -178,11 +178,11 @@ Arg *Option::accept(const ArgList &Args,
|
||||
// Matches iff this is an exact match.
|
||||
// FIXME: Avoid strlen.
|
||||
if (ArgSize != strlen(Args.getArgString(Index)))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
Index += 1 + getNumArgs();
|
||||
if (Index > Args.getNumInputArgStrings())
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
Arg *A = new Arg(UnaliasedOption, Spelling, Index - 1 - getNumArgs(),
|
||||
Args.getArgString(Index - getNumArgs()));
|
||||
@ -201,7 +201,7 @@ Arg *Option::accept(const ArgList &Args,
|
||||
// Otherwise it must be separate.
|
||||
Index += 2;
|
||||
if (Index > Args.getNumInputArgStrings())
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
return new Arg(UnaliasedOption, Spelling,
|
||||
Index - 2, Args.getArgString(Index - 1));
|
||||
@ -210,7 +210,7 @@ Arg *Option::accept(const ArgList &Args,
|
||||
// Always matches.
|
||||
Index += 2;
|
||||
if (Index > Args.getNumInputArgStrings())
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
return new Arg(UnaliasedOption, Spelling, Index - 2,
|
||||
Args.getArgString(Index - 2) + ArgSize,
|
||||
@ -219,7 +219,7 @@ Arg *Option::accept(const ArgList &Args,
|
||||
// Matches iff this is an exact match.
|
||||
// FIXME: Avoid strlen.
|
||||
if (ArgSize != strlen(Args.getArgString(Index)))
|
||||
return 0;
|
||||
return nullptr;
|
||||
Arg *A = new Arg(UnaliasedOption, Spelling, Index++);
|
||||
while (Index < Args.getNumInputArgStrings())
|
||||
A->getValues().push_back(Args.getArgString(Index++));
|
||||
|
@ -1358,7 +1358,7 @@ APFloat::addOrSubtractSpecials(const APFloat &rhs, bool subtract)
|
||||
{
|
||||
switch (PackCategoriesIntoKey(category, rhs.category)) {
|
||||
default:
|
||||
llvm_unreachable(0);
|
||||
llvm_unreachable(nullptr);
|
||||
|
||||
case PackCategoriesIntoKey(fcNaN, fcZero):
|
||||
case PackCategoriesIntoKey(fcNaN, fcNormal):
|
||||
@ -1485,7 +1485,7 @@ APFloat::multiplySpecials(const APFloat &rhs)
|
||||
{
|
||||
switch (PackCategoriesIntoKey(category, rhs.category)) {
|
||||
default:
|
||||
llvm_unreachable(0);
|
||||
llvm_unreachable(nullptr);
|
||||
|
||||
case PackCategoriesIntoKey(fcNaN, fcZero):
|
||||
case PackCategoriesIntoKey(fcNaN, fcNormal):
|
||||
@ -1529,7 +1529,7 @@ APFloat::divideSpecials(const APFloat &rhs)
|
||||
{
|
||||
switch (PackCategoriesIntoKey(category, rhs.category)) {
|
||||
default:
|
||||
llvm_unreachable(0);
|
||||
llvm_unreachable(nullptr);
|
||||
|
||||
case PackCategoriesIntoKey(fcZero, fcNaN):
|
||||
case PackCategoriesIntoKey(fcNormal, fcNaN):
|
||||
@ -1570,7 +1570,7 @@ APFloat::modSpecials(const APFloat &rhs)
|
||||
{
|
||||
switch (PackCategoriesIntoKey(category, rhs.category)) {
|
||||
default:
|
||||
llvm_unreachable(0);
|
||||
llvm_unreachable(nullptr);
|
||||
|
||||
case PackCategoriesIntoKey(fcNaN, fcZero):
|
||||
case PackCategoriesIntoKey(fcNaN, fcNormal):
|
||||
@ -1882,7 +1882,7 @@ APFloat::compare(const APFloat &rhs) const
|
||||
|
||||
switch (PackCategoriesIntoKey(category, rhs.category)) {
|
||||
default:
|
||||
llvm_unreachable(0);
|
||||
llvm_unreachable(nullptr);
|
||||
|
||||
case PackCategoriesIntoKey(fcNaN, fcZero):
|
||||
case PackCategoriesIntoKey(fcNaN, fcNormal):
|
||||
@ -3331,7 +3331,7 @@ APFloat::initFromAPInt(const fltSemantics* Sem, const APInt& api)
|
||||
if (Sem == &PPCDoubleDouble)
|
||||
return initFromPPCDoubleDoubleAPInt(api);
|
||||
|
||||
llvm_unreachable(0);
|
||||
llvm_unreachable(nullptr);
|
||||
}
|
||||
|
||||
APFloat
|
||||
|
@ -103,7 +103,7 @@ void cl::MarkOptionsChanged() {
|
||||
static Option *RegisteredOptionList = nullptr;
|
||||
|
||||
void Option::addArgument() {
|
||||
assert(NextRegistered == 0 && "argument multiply registered!");
|
||||
assert(!NextRegistered && "argument multiply registered!");
|
||||
|
||||
NextRegistered = RegisteredOptionList;
|
||||
RegisteredOptionList = this;
|
||||
@ -111,7 +111,7 @@ void Option::addArgument() {
|
||||
}
|
||||
|
||||
void Option::removeArgument() {
|
||||
assert(NextRegistered != 0 && "argument never registered");
|
||||
assert(NextRegistered && "argument never registered");
|
||||
assert(RegisteredOptionList == this && "argument is not the last registered");
|
||||
RegisteredOptionList = NextRegistered;
|
||||
MarkOptionsChanged();
|
||||
|
@ -109,7 +109,7 @@ raw_ostream &llvm::dbgs() {
|
||||
if (EnableDebugBuffering && DebugFlag && DebugBufferSize != 0)
|
||||
// TODO: Add a handler for SIGUSER1-type signals so the user can
|
||||
// force a debug dump.
|
||||
sys::AddSignalHandler(&debug_user_sig_handler, 0);
|
||||
sys::AddSignalHandler(&debug_user_sig_handler, nullptr);
|
||||
// Otherwise we've already set the debug stream buffer size to
|
||||
// zero, disabling buffering so it will output directly to errs().
|
||||
}
|
||||
|
@ -305,7 +305,7 @@ FoldingSetImpl::Node
|
||||
/// is not already in the map. InsertPos must be obtained from
|
||||
/// FindNodeOrInsertPos.
|
||||
void FoldingSetImpl::InsertNode(Node *N, void *InsertPos) {
|
||||
assert(N->getNextInBucket() == 0);
|
||||
assert(!N->getNextInBucket());
|
||||
// Do we need to grow the hashtable?
|
||||
if (NumNodes+1 > NumBuckets*2) {
|
||||
GrowHashTable();
|
||||
|
@ -45,7 +45,7 @@ void ManagedStaticBase::RegisterManagedStatic(void *(*Creator)(),
|
||||
|
||||
llvm_release_global_lock();
|
||||
} else {
|
||||
assert(Ptr == 0 && DeleterFn == 0 && Next == 0 &&
|
||||
assert(!Ptr && !DeleterFn && !Next &&
|
||||
"Partially initialized ManagedStatic!?");
|
||||
Ptr = Creator ? Creator() : nullptr;
|
||||
DeleterFn = Deleter;
|
||||
|
@ -75,7 +75,7 @@ MutexImpl::MutexImpl( bool recursive)
|
||||
MutexImpl::~MutexImpl()
|
||||
{
|
||||
pthread_mutex_t* mutex = static_cast<pthread_mutex_t*>(data_);
|
||||
assert(mutex != 0);
|
||||
assert(mutex != nullptr);
|
||||
pthread_mutex_destroy(mutex);
|
||||
free(mutex);
|
||||
}
|
||||
@ -84,7 +84,7 @@ bool
|
||||
MutexImpl::acquire()
|
||||
{
|
||||
pthread_mutex_t* mutex = static_cast<pthread_mutex_t*>(data_);
|
||||
assert(mutex != 0);
|
||||
assert(mutex != nullptr);
|
||||
|
||||
int errorcode = pthread_mutex_lock(mutex);
|
||||
return errorcode == 0;
|
||||
@ -94,7 +94,7 @@ bool
|
||||
MutexImpl::release()
|
||||
{
|
||||
pthread_mutex_t* mutex = static_cast<pthread_mutex_t*>(data_);
|
||||
assert(mutex != 0);
|
||||
assert(mutex != nullptr);
|
||||
|
||||
int errorcode = pthread_mutex_unlock(mutex);
|
||||
return errorcode == 0;
|
||||
@ -104,7 +104,7 @@ bool
|
||||
MutexImpl::tryacquire()
|
||||
{
|
||||
pthread_mutex_t* mutex = static_cast<pthread_mutex_t*>(data_);
|
||||
assert(mutex != 0);
|
||||
assert(mutex != nullptr);
|
||||
|
||||
int errorcode = pthread_mutex_trylock(mutex);
|
||||
return errorcode == 0;
|
||||
|
@ -68,7 +68,7 @@ RWMutexImpl::RWMutexImpl()
|
||||
RWMutexImpl::~RWMutexImpl()
|
||||
{
|
||||
pthread_rwlock_t* rwlock = static_cast<pthread_rwlock_t*>(data_);
|
||||
assert(rwlock != 0);
|
||||
assert(rwlock != nullptr);
|
||||
pthread_rwlock_destroy(rwlock);
|
||||
free(rwlock);
|
||||
}
|
||||
@ -77,7 +77,7 @@ bool
|
||||
RWMutexImpl::reader_acquire()
|
||||
{
|
||||
pthread_rwlock_t* rwlock = static_cast<pthread_rwlock_t*>(data_);
|
||||
assert(rwlock != 0);
|
||||
assert(rwlock != nullptr);
|
||||
|
||||
int errorcode = pthread_rwlock_rdlock(rwlock);
|
||||
return errorcode == 0;
|
||||
@ -87,7 +87,7 @@ bool
|
||||
RWMutexImpl::reader_release()
|
||||
{
|
||||
pthread_rwlock_t* rwlock = static_cast<pthread_rwlock_t*>(data_);
|
||||
assert(rwlock != 0);
|
||||
assert(rwlock != nullptr);
|
||||
|
||||
int errorcode = pthread_rwlock_unlock(rwlock);
|
||||
return errorcode == 0;
|
||||
@ -97,7 +97,7 @@ bool
|
||||
RWMutexImpl::writer_acquire()
|
||||
{
|
||||
pthread_rwlock_t* rwlock = static_cast<pthread_rwlock_t*>(data_);
|
||||
assert(rwlock != 0);
|
||||
assert(rwlock != nullptr);
|
||||
|
||||
int errorcode = pthread_rwlock_wrlock(rwlock);
|
||||
return errorcode == 0;
|
||||
@ -107,7 +107,7 @@ bool
|
||||
RWMutexImpl::writer_release()
|
||||
{
|
||||
pthread_rwlock_t* rwlock = static_cast<pthread_rwlock_t*>(data_);
|
||||
assert(rwlock != 0);
|
||||
assert(rwlock != nullptr);
|
||||
|
||||
int errorcode = pthread_rwlock_unlock(rwlock);
|
||||
return errorcode == 0;
|
||||
|
@ -100,7 +100,7 @@ static TimerGroup *getDefaultTimerGroup() {
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
void Timer::init(StringRef N) {
|
||||
assert(TG == 0 && "Timer already initialized");
|
||||
assert(!TG && "Timer already initialized");
|
||||
Name.assign(N.begin(), N.end());
|
||||
Started = false;
|
||||
TG = getDefaultTimerGroup();
|
||||
@ -108,7 +108,7 @@ void Timer::init(StringRef N) {
|
||||
}
|
||||
|
||||
void Timer::init(StringRef N, TimerGroup &tg) {
|
||||
assert(TG == 0 && "Timer already initialized");
|
||||
assert(!TG && "Timer already initialized");
|
||||
Name.assign(N.begin(), N.end());
|
||||
Started = false;
|
||||
TG = &tg;
|
||||
|
@ -87,8 +87,8 @@ void raw_ostream::SetBuffered() {
|
||||
|
||||
void raw_ostream::SetBufferAndMode(char *BufferStart, size_t Size,
|
||||
BufferKind Mode) {
|
||||
assert(((Mode == Unbuffered && BufferStart == 0 && Size == 0) ||
|
||||
(Mode != Unbuffered && BufferStart && Size)) &&
|
||||
assert(((Mode == Unbuffered && !BufferStart && Size == 0) ||
|
||||
(Mode != Unbuffered && BufferStart && Size != 0)) &&
|
||||
"stream must be unbuffered or have at least one byte");
|
||||
// Make sure the current buffer is free of content (we can't flush here; the
|
||||
// child buffer management logic will be in write_impl).
|
||||
@ -433,7 +433,7 @@ void format_object_base::home() {
|
||||
raw_fd_ostream::raw_fd_ostream(const char *Filename, std::string &ErrorInfo,
|
||||
sys::fs::OpenFlags Flags)
|
||||
: Error(false), UseAtomicWrites(false), pos(0) {
|
||||
assert(Filename != 0 && "Filename is null");
|
||||
assert(Filename && "Filename is null");
|
||||
ErrorInfo.clear();
|
||||
|
||||
// Handle "-" as stdout. Note that when we do this, we consider ourself
|
||||
|
Loading…
Reference in New Issue
Block a user