unsigned timeout, unsigned memlimit, bool use_valgrind,
LLVMContext& ctxt)
: Context(ctxt), ToolName(toolname), ReferenceOutputFile(OutputFile),
- Program(0), Interpreter(0), SafeInterpreter(0), gcc(0),
- run_find_bugs(find_bugs), Timeout(timeout),
+ Program(nullptr), Interpreter(nullptr), SafeInterpreter(nullptr),
+ gcc(nullptr), run_find_bugs(find_bugs), Timeout(timeout),
MemoryLimit(memlimit), UseValgrind(use_valgrind) {}
BugDriver::~BugDriver() {
// Load the first input file.
Program = ParseInputFile(Filenames[0], Context);
- if (Program == 0) return true;
+ if (!Program) return true;
outs() << "Read input file : '" << Filenames[0] << "'\n";
for (unsigned i = 1, e = Filenames.size(); i != e; ++i) {
std::unique_ptr<Module> M(ParseInputFile(Filenames[i], Context));
- if (M.get() == 0) return true;
+ if (!M.get()) return true;
outs() << "Linking in input file: '" << Filenames[i] << "'\n";
std::string ErrorMessage;
std::vector<std::string> &Suffix,
std::string &Error) {
std::string PrefixOutput;
- Module *OrigProgram = 0;
+ Module *OrigProgram = nullptr;
if (!Prefix.empty()) {
outs() << "Checking to see if these passes crash: "
<< getPassesString(Prefix) << ": ";
OrigProgram = BD.Program;
BD.Program = ParseInputFile(PrefixOutput, BD.getContext());
- if (BD.Program == 0) {
+ if (BD.Program == nullptr) {
errs() << BD.getToolName() << ": Error reading bitcode file '"
<< PrefixOutput << "'!\n";
exit(1);
for (Module::global_iterator I = M->global_begin(), E = M->global_end();
I != E; ++I)
if (I->hasInitializer() && !GVSet.count(I)) {
- I->setInitializer(0);
+ I->setInitializer(nullptr);
I->setLinkage(GlobalValue::ExternalLinkage);
}
for (Module::global_iterator I = M->global_begin(), E = M->global_end();
I != E; ++I)
if (I->hasInitializer()) {
- I->setInitializer(0);
+ I->setInitializer(nullptr);
I->setLinkage(GlobalValue::ExternalLinkage);
DeletedInit = true;
}
// Create an instance of the AbstractInterpreter interface as specified on
// the command line
- SafeInterpreter = 0;
+ SafeInterpreter = nullptr;
std::string Message;
switch (InterpreterSel) {
if (!gcc) { outs() << Message << "\nExiting.\n"; exit(1); }
// If there was an error creating the selected interpreter, quit with error.
- return Interpreter == 0;
+ return Interpreter == nullptr;
}
/// compileProgram - Try to compile the specified module, returning false and
const std::string &SharedObj,
AbstractInterpreter *AI,
std::string *Error) const {
- if (AI == 0) AI = Interpreter;
+ if (!AI) AI = Interpreter;
assert(AI && "Interpreter should have been created already!");
bool CreatedBitcode = false;
if (BitcodeFile.empty()) {
std::string *ErrMsg) const {
// Execute the program, generating an output file...
std::string Output(
- executeProgram(Program, "", BitcodeFile, SharedObject, 0, ErrMsg));
+ executeProgram(Program, "", BitcodeFile, SharedObject, nullptr, ErrMsg));
if (!ErrMsg->empty())
return false;
Function* globalInitUsesExternalBA(GlobalVariable* GV) {
if (!GV->hasInitializer())
- return 0;
+ return nullptr;
Constant *I = GV->getInitializer();
Todo.push_back(C);
}
}
- return 0;
+ return nullptr;
}
} // end anonymous namespace
CleanupPasses.push_back("deadargelim");
Module *New = runPassesOn(M, CleanupPasses);
- if (New == 0) {
+ if (!New) {
errs() << "Final cleanups failed. Sorry. :( Please report a bug!\n";
return M;
}
LoopExtractPasses.push_back("loop-extract-single");
Module *NewM = runPassesOn(M, LoopExtractPasses);
- if (NewM == 0) {
+ if (!NewM) {
outs() << "*** Loop extraction failed: ";
EmitProgressBitcode(M, "loopextraction", true);
outs() << "*** Sorry. :( Please report a bug!\n";
- return 0;
+ return nullptr;
}
// Check to see if we created any new functions. If not, no loops were
static unsigned NumExtracted = 32;
if (M->size() == NewM->size() || --NumExtracted == 0) {
delete NewM;
- return 0;
+ return nullptr;
} else {
assert(M->size() < NewM->size() && "Loop extract removed functions?");
Module::iterator MI = NewM->begin();
<< "' and from test function '" << TestFn->getName() << "'.\n";
exit(1);
}
- I->setInitializer(0); // Delete the initializer to make it external
+ I->setInitializer(nullptr); // Delete the initializer to make it external
} else {
// If we keep it in the safe module, then delete it in the test module
- GV->setInitializer(0);
+ GV->setInitializer(nullptr);
}
}
outs() << "*** Basic Block extraction failed!\n";
errs() << "Error creating temporary file: " << EC.message() << "\n";
EmitProgressBitcode(M, "basicblockextractfail", true);
- return 0;
+ return nullptr;
}
sys::RemoveFileOnSignal(Filename);
errs() << "Error writing list of blocks to not extract\n";
EmitProgressBitcode(M, "basicblockextractfail", true);
BlocksToNotExtractFile.os().clear_error();
- return 0;
+ return nullptr;
}
BlocksToNotExtractFile.keep();
sys::fs::remove(Filename.c_str());
- if (Ret == 0) {
+ if (!Ret) {
outs() << "*** Basic Block extraction failed, please report a bug!\n";
EmitProgressBitcode(M, "basicblockextractfail", true);
}
return false;
}
- srand(time(NULL));
+ srand(time(nullptr));
unsigned num = 1;
while(1) {
if (!Error.empty()) {
// Delete the linked module
delete M1;
- return NULL;
+ return nullptr;
}
return M1;
}
MiscompiledFunctions,
VMap);
Module *Extracted = BD.ExtractMappedBlocksFromModule(Blocks, ToExtract);
- if (Extracted == 0) {
+ if (!Extracted) {
// Weird, extraction should have worked.
errs() << "Nondeterministic problem extracting blocks??\n";
delete ProgClone;
Safe->getOrInsertFunction("getPointerToNamedFunction",
Type::getInt8PtrTy(Safe->getContext()),
Type::getInt8PtrTy(Safe->getContext()),
- (Type *)0);
+ (Type *)nullptr);
// Use the function we just added to get addresses of functions we need.
for (Module::iterator F = Safe->begin(), E = Safe->end(); F != E; ++F) {
Args.push_back(InputFilename.c_str());
for (unsigned i = 0; i < NumExtraArgs; ++i)
Args.push_back(*ExtraArgs);
- Args.push_back(0);
+ Args.push_back(nullptr);
DEBUG(errs() << "\nAbout to run:\t";
for (unsigned i = 0, e = Args.size()-1; i != e; ++i)
// Redirect stdout and stderr to nowhere if SilencePasses is given
StringRef Nowhere;
- const StringRef *Redirects[3] = {0, &Nowhere, &Nowhere};
+ const StringRef *Redirects[3] = {nullptr, &Nowhere, &Nowhere};
std::string ErrMsg;
- int result = sys::ExecuteAndWait(Prog, Args.data(), 0,
- (SilencePasses ? Redirects : 0), Timeout,
- MemoryLimit, &ErrMsg);
+ int result = sys::ExecuteAndWait(Prog, Args.data(), nullptr,
+ (SilencePasses ? Redirects : nullptr),
+ Timeout, MemoryLimit, &ErrMsg);
// If we are supposed to delete the bitcode file or if the passes crashed,
// remove it now. This may fail if the file was never created, but that's ok.
EmitProgressBitcode(M, "pass-error", false);
exit(debugOptimizerCrash());
}
- return 0;
+ return nullptr;
}
Module *Ret = ParseInputFile(BitcodeResult, Context);
- if (Ret == 0) {
+ if (!Ret) {
errs() << getToolName() << ": Error reading bitcode file '"
<< BitcodeResult << "'!\n";
exit(1);
StringRef StdErrFile,
unsigned NumSeconds = 0,
unsigned MemoryLimit = 0,
- std::string *ErrMsg = 0) {
+ std::string *ErrMsg = nullptr) {
const StringRef *Redirects[3] = { &StdInFile, &StdOutFile, &StdErrFile };
#if 0 // For debug purposes
}
#endif
- return sys::ExecuteAndWait(ProgramPath, Args, 0, Redirects,
+ return sys::ExecuteAndWait(ProgramPath, Args, nullptr, Redirects,
NumSeconds, MemoryLimit, ErrMsg);
}
#endif
// Run the program remotely with the remote client
- int ReturnCode = sys::ExecuteAndWait(RemoteClientPath, Args, 0,
+ int ReturnCode = sys::ExecuteAndWait(RemoteClientPath, Args, nullptr,
Redirects, NumSeconds, MemoryLimit);
// Has the remote client fail?
// Add optional parameters to the running program from Argv
for (unsigned i=0, e = Args.size(); i != e; ++i)
LLIArgs.push_back(Args[i].c_str());
- LLIArgs.push_back(0);
+ LLIArgs.push_back(nullptr);
outs() << "<lli>"; outs().flush();
DEBUG(errs() << "\nAbout to run:\t";
}
Message = "Cannot find `lli' in executable directory!\n";
- return 0;
+ return nullptr;
}
//===---------------------------------------------------------------------===//
for (std::size_t i = 0; i < CompilerArgs.size(); ++i)
ProgramArgs.push_back(CompilerArgs.at(i).c_str());
ProgramArgs.push_back(Bitcode.c_str());
- ProgramArgs.push_back(0);
+ ProgramArgs.push_back(nullptr);
// Add optional parameters to the running program from Argv
for (unsigned i = 0, e = CompilerArgs.size(); i != e; ++i)
for (std::size_t i = 0; i < ExecutorArgs.size(); ++i)
ProgramArgs.push_back(ExecutorArgs.at(i).c_str());
ProgramArgs.push_back(Bitcode.c_str());
- ProgramArgs.push_back(0);
+ ProgramArgs.push_back(nullptr);
// Add optional parameters to the running program from Argv
for (unsigned i = 0, e = Args.size(); i != e; ++i)
std::vector<std::string> Args;
lexCommand(Message, CompileCommandLine, CmdPath, Args);
if (CmdPath.empty())
- return 0;
+ return nullptr;
return new CustomCompiler(CmdPath, Args);
}
std::vector<std::string> Args;
lexCommand(Message, ExecCommandLine, CmdPath, Args);
if (CmdPath.empty())
- return 0;
+ return nullptr;
return new CustomExecutor(CmdPath, Args);
}
if (UseIntegratedAssembler)
LLCArgs.push_back("-filetype=obj");
- LLCArgs.push_back (0);
+ LLCArgs.push_back (nullptr);
outs() << (UseIntegratedAssembler ? "<llc-ia>" : "<llc>");
outs().flush();
PrependMainExecutablePath("llc", Argv0, (void *)(intptr_t) & createLLC);
if (LLCPath.empty()) {
Message = "Cannot find `llc' in executable directory!\n";
- return 0;
+ return nullptr;
}
GCC *gcc = GCC::create(Message, GCCBinary, GCCArgs);
// Add optional parameters to the running program from Argv
for (unsigned i=0, e = Args.size(); i != e; ++i)
JITArgs.push_back(Args[i].c_str());
- JITArgs.push_back(0);
+ JITArgs.push_back(nullptr);
outs() << "<jit>"; outs().flush();
DEBUG(errs() << "\nAbout to run:\t";
}
Message = "Cannot find `lli' in executable directory!\n";
- return 0;
+ return nullptr;
}
//===---------------------------------------------------------------------===//
#endif
if (TargetTriple.getArch() == Triple::sparc)
GCCArgs.push_back("-mcpu=v9");
- GCCArgs.push_back(0); // NULL terminator
+ GCCArgs.push_back(nullptr); // NULL terminator
outs() << "<gcc>"; outs().flush();
DEBUG(errs() << "\nAbout to run:\t";
// Add optional parameters to the running program from Argv
for (unsigned i = 0, e = Args.size(); i != e; ++i)
ProgramArgs.push_back(Args[i].c_str());
- ProgramArgs.push_back(0); // NULL terminator
+ ProgramArgs.push_back(nullptr); // NULL terminator
// Now that we have a binary, run it!
outs() << "<program>"; outs().flush();
// command line, so this should be safe.
for (unsigned i = 0, e = ArgsForGCC.size(); i != e; ++i)
GCCArgs.push_back(ArgsForGCC[i].c_str());
- GCCArgs.push_back(0); // NULL terminator
+ GCCArgs.push_back(nullptr); // NULL terminator
std::string GCCPath = sys::FindProgramByName(GCCBinary);
if (GCCPath.empty()) {
Message = "Cannot find `"+ GCCBinary +"' in PATH!\n";
- return 0;
+ return nullptr;
}
std::string RemoteClientPath;
class AddToDriver : public FunctionPassManager {
BugDriver &D;
public:
- AddToDriver(BugDriver &_D) : FunctionPassManager(0), D(_D) {}
+ AddToDriver(BugDriver &_D) : FunctionPassManager(nullptr), D(_D) {}
void add(Pass *P) override {
const void *ID = P->getPassID();
if (!error.empty()) {
errs() << error << '\n';
delete FDOut;
- return 0;
+ return nullptr;
}
return FDOut;
// Load the module to be compiled...
SMDiagnostic Err;
std::unique_ptr<Module> M;
- Module *mod = 0;
+ Module *mod = nullptr;
Triple TheTriple;
bool SkipModule = MCPU == "help" ||
if (!SkipModule) {
M.reset(ParseIRFile(InputFilename, Err, Context));
mod = M.get();
- if (mod == 0) {
+ if (mod == nullptr) {
Err.print(argv[0], errs());
return 1;
}
{
formatted_raw_ostream FOS(Out->os());
- AnalysisID StartAfterID = 0;
- AnalysisID StopAfterID = 0;
+ AnalysisID StartAfterID = nullptr;
+ AnalysisID StopAfterID = nullptr;
const PassRegistry *PR = PassRegistry::getPassRegistry();
if (!StartAfter.empty()) {
const PassInfo *PI = PR->getPassInfo(StartAfter);
void RemoteMemoryManager::AllocateGOT() { llvm_unreachable("Unexpected!"); }
uint8_t *RemoteMemoryManager::getGOTBase() const {
llvm_unreachable("Unexpected!");
- return 0;
+ return nullptr;
}
uint8_t *RemoteMemoryManager::startFunctionBody(const Function *F, uintptr_t &ActualSize){
llvm_unreachable("Unexpected!");
- return 0;
+ return nullptr;
}
uint8_t *RemoteMemoryManager::allocateStub(const GlobalValue* F, unsigned StubSize,
unsigned Alignment) {
llvm_unreachable("Unexpected!");
- return 0;
+ return nullptr;
}
void RemoteMemoryManager::endFunctionBody(const Function *F, uint8_t *FunctionStart,
uint8_t *FunctionEnd) {
}
uint8_t *RemoteMemoryManager::allocateSpace(intptr_t Size, unsigned Alignment) {
llvm_unreachable("Unexpected!");
- return 0;
+ return nullptr;
}
uint8_t *RemoteMemoryManager::allocateGlobal(uintptr_t Size, unsigned Alignment) {
llvm_unreachable("Unexpected!");
- return 0;
+ return nullptr;
}
void RemoteMemoryManager::deallocateFunctionBody(void *Body) {
llvm_unreachable("Unexpected!");
bool RemoteTarget::allocateSpace(size_t Size, unsigned Alignment,
uint64_t &Address) {
- sys::MemoryBlock *Prev = Allocations.size() ? &Allocations.back() : NULL;
+ sys::MemoryBlock *Prev = Allocations.size() ? &Allocations.back() : nullptr;
sys::MemoryBlock Mem = sys::Memory::AllocateRWX(Size, Prev, &ErrorMsg);
- if (Mem.base() == NULL)
+ if (Mem.base() == nullptr)
return false;
if ((uintptr_t)Mem.base() % Alignment) {
ErrorMsg = "unable to allocate sufficiently aligned memory";
const std::string ModuleID = M->getModuleIdentifier();
std::string CacheName;
if (!getCacheFilename(ModuleID, CacheName))
- return NULL;
+ return nullptr;
// Load the object from the cache filename
std::unique_ptr<MemoryBuffer> IRObjectBuffer;
MemoryBuffer::getFile(CacheName.c_str(), IRObjectBuffer, -1, false);
// If the file isn't there, that's OK.
if (!IRObjectBuffer)
- return NULL;
+ return nullptr;
// MCJIT will want to write into this buffer, and we don't want that
// because the file has probably just been mmapped. Instead we make
// a copy. The filed-based buffer will be released when it goes
}
};
-static ExecutionEngine *EE = 0;
-static LLIObjectCache *CacheManager = 0;
+static ExecutionEngine *EE = nullptr;
+static LLIObjectCache *CacheManager = nullptr;
static void do_shutdown() {
// Cygwin-1.5 invokes DLL's dtors before atexit handler.
Mod->setTargetTriple(Triple::normalize(TargetTriple));
// Enable MCJIT if desired.
- RTDyldMemoryManager *RTDyldMM = 0;
+ RTDyldMemoryManager *RTDyldMM = nullptr;
if (UseMCJIT && !ForceInterpreter) {
builder.setUseMCJIT(true);
if (RemoteMCJIT)
errs() << "error: Remote process execution requires -use-mcjit\n";
exit(1);
}
- builder.setJITMemoryManager(ForceInterpreter ? 0 :
+ builder.setJITMemoryManager(ForceInterpreter ? nullptr :
JITMemoryManager::CreateDefaultMemManager());
}
Output.keep();
Out.close();
sys::fs::rename(TemporaryOutput, ArchiveName);
- TemporaryOutput = NULL;
+ TemporaryOutput = nullptr;
}
static void createSymbolTable(object::Archive *OldArchive) {
}
}
- performOperation(Operation, NULL);
+ performOperation(Operation, nullptr);
return 0;
}
// Parse the file now...
SMDiagnostic Err;
std::unique_ptr<Module> M(ParseAssemblyFile(InputFilename, Err, Context));
- if (M.get() == 0) {
+ if (!M.get()) {
Err.print(argv[0], errs());
return 1;
}
if (BlockID < bitc::FIRST_APPLICATION_BLOCKID) {
if (BlockID == bitc::BLOCKINFO_BLOCK_ID)
return "BLOCKINFO_BLOCK";
- return 0;
+ return nullptr;
}
// Check to see if we have a blockinfo record for this block, with a name.
}
- if (CurStreamType != LLVMIRBitstream) return 0;
+ if (CurStreamType != LLVMIRBitstream) return nullptr;
switch (BlockID) {
- default: return 0;
+ default: return nullptr;
case bitc::MODULE_BLOCK_ID: return "MODULE_BLOCK";
case bitc::PARAMATTR_BLOCK_ID: return "PARAMATTR_BLOCK";
case bitc::PARAMATTR_GROUP_BLOCK_ID: return "PARAMATTR_GROUP_BLOCK_ID";
if (BlockID < bitc::FIRST_APPLICATION_BLOCKID) {
if (BlockID == bitc::BLOCKINFO_BLOCK_ID) {
switch (CodeID) {
- default: return 0;
+ default: return nullptr;
case bitc::BLOCKINFO_CODE_SETBID: return "SETBID";
case bitc::BLOCKINFO_CODE_BLOCKNAME: return "BLOCKNAME";
case bitc::BLOCKINFO_CODE_SETRECORDNAME: return "SETRECORDNAME";
}
}
- return 0;
+ return nullptr;
}
// Check to see if we have a blockinfo record for this record, with a name.
}
- if (CurStreamType != LLVMIRBitstream) return 0;
+ if (CurStreamType != LLVMIRBitstream) return nullptr;
switch (BlockID) {
- default: return 0;
+ default: return nullptr;
case bitc::MODULE_BLOCK_ID:
switch (CodeID) {
- default: return 0;
+ default: return nullptr;
case bitc::MODULE_CODE_VERSION: return "VERSION";
case bitc::MODULE_CODE_TRIPLE: return "TRIPLE";
case bitc::MODULE_CODE_DATALAYOUT: return "DATALAYOUT";
}
case bitc::PARAMATTR_BLOCK_ID:
switch (CodeID) {
- default: return 0;
+ default: return nullptr;
case bitc::PARAMATTR_CODE_ENTRY_OLD: return "ENTRY";
case bitc::PARAMATTR_CODE_ENTRY: return "ENTRY";
case bitc::PARAMATTR_GRP_CODE_ENTRY: return "ENTRY";
}
case bitc::TYPE_BLOCK_ID_NEW:
switch (CodeID) {
- default: return 0;
+ default: return nullptr;
case bitc::TYPE_CODE_NUMENTRY: return "NUMENTRY";
case bitc::TYPE_CODE_VOID: return "VOID";
case bitc::TYPE_CODE_FLOAT: return "FLOAT";
case bitc::CONSTANTS_BLOCK_ID:
switch (CodeID) {
- default: return 0;
+ default: return nullptr;
case bitc::CST_CODE_SETTYPE: return "SETTYPE";
case bitc::CST_CODE_NULL: return "NULL";
case bitc::CST_CODE_UNDEF: return "UNDEF";
}
case bitc::FUNCTION_BLOCK_ID:
switch (CodeID) {
- default: return 0;
+ default: return nullptr;
case bitc::FUNC_CODE_DECLAREBLOCKS: return "DECLAREBLOCKS";
case bitc::FUNC_CODE_INST_BINOP: return "INST_BINOP";
}
case bitc::VALUE_SYMTAB_BLOCK_ID:
switch (CodeID) {
- default: return 0;
+ default: return nullptr;
case bitc::VST_CODE_ENTRY: return "ENTRY";
case bitc::VST_CODE_BBENTRY: return "BBENTRY";
}
case bitc::METADATA_ATTACHMENT_ID:
switch(CodeID) {
- default:return 0;
+ default:return nullptr;
case bitc::METADATA_ATTACHMENT: return "METADATA_ATTACHMENT";
}
case bitc::METADATA_BLOCK_ID:
switch(CodeID) {
- default:return 0;
+ default:return nullptr;
case bitc::METADATA_STRING: return "METADATA_STRING";
case bitc::METADATA_NAME: return "METADATA_NAME";
case bitc::METADATA_KIND: return "METADATA_KIND";
}
case bitc::USELIST_BLOCK_ID:
switch(CodeID) {
- default:return 0;
+ default:return nullptr;
case bitc::USELIST_CODE_ENTRY: return "USELIST_CODE_ENTRY";
}
}
if (Stream.EnterSubBlock(BlockID, &NumWords))
return Error("Malformed block record");
- const char *BlockName = 0;
+ const char *BlockName = nullptr;
if (Dump) {
outs() << Indent << "<";
if ((BlockName = GetBlockName(BlockID, *Stream.getBitStreamReader())))
}
void DiffLogBuilder::addLeft(Instruction *L) {
// HACK: VS 2010 has a bug in the stdlib that requires this.
- Diff.push_back(DiffRecord(L, DiffRecord::second_type(0)));
+ Diff.push_back(DiffRecord(L, DiffRecord::second_type(nullptr)));
}
void DiffLogBuilder::addRight(Instruction *R) {
// HACK: VS 2010 has a bug in the stdlib that requires this.
- Diff.push_back(DiffRecord(DiffRecord::first_type(0), R));
+ Diff.push_back(DiffRecord(DiffRecord::first_type(nullptr), R));
}
unsigned DiffLogBuilder::getNumLines() const { return Diff.size(); }
DisplayFilename = InputFilename;
M.reset(getStreamedBitcodeModule(DisplayFilename, streamer, Context,
&ErrorMessage));
- if(M.get() != 0) {
+ if(M.get()) {
if (error_code EC = M->materializeAllPermanently()) {
ErrorMessage = EC.message();
M.reset();
}
}
- if (M.get() == 0) {
+ if (!M.get()) {
errs() << argv[0] << ": ";
if (ErrorMessage.size())
errs() << ErrorMessage << "\n";
std::unique_ptr<Module> M;
M.reset(getLazyIRFileModule(InputFilename, Err, Context));
- if (M.get() == 0) {
+ if (!M.get()) {
Err.print(argv[0], errs());
return 1;
}
LLVMContext& Context) {
SMDiagnostic Err;
if (Verbose) errs() << "Loading '" << FN << "'\n";
- Module* Result = 0;
+ Module* Result = nullptr;
Result = ParseIRFile(FN, Err, Context);
if (Result) return Result; // Load successful!
Err.print(argv0, errs());
- return NULL;
+ return nullptr;
}
int main(int argc, char **argv) {
std::unique_ptr<Module> Composite(
LoadFile(argv[0], InputFilenames[BaseArg], Context));
- if (Composite.get() == 0) {
+ if (!Composite.get()) {
errs() << argv[0] << ": error loading file '"
<< InputFilenames[BaseArg] << "'\n";
return 1;
Linker L(Composite.get(), SuppressWarnings);
for (unsigned i = BaseArg+1; i < InputFilenames.size(); ++i) {
std::unique_ptr<Module> M(LoadFile(argv[0], InputFilenames[i], Context));
- if (M.get() == 0) {
+ if (!M.get()) {
errs() << argv[0] << ": error loading file '" <<InputFilenames[i]<< "'\n";
return 1;
}
std::string ErrorInfo;
const void *Code = CodeGen.compile(&len, DisableOpt, DisableInline,
DisableGVNLoadPRE, ErrorInfo);
- if (Code == NULL) {
+ if (!Code) {
errs() << argv[0]
<< ": error compiling the code: " << ErrorInfo << "\n";
return 1;
FileStream.write(reinterpret_cast<const char *>(Code), len);
} else {
std::string ErrorInfo;
- const char *OutputName = NULL;
+ const char *OutputName = nullptr;
if (!CodeGen.compile_to_file(&OutputName, DisableOpt, DisableInline,
DisableGVNLoadPRE, ErrorInfo)) {
errs() << argv[0]
}
// Set up the MCContext for creating symbols and MCExpr's.
- MCContext Ctx(MAI.get(), MRI.get(), 0);
+ MCContext Ctx(MAI.get(), MRI.get(), nullptr);
std::unique_ptr<const MCDisassembler> DisAsm(
T.createMCDisassembler(STI, Ctx));
Error);
if (!TheTarget) {
errs() << ProgName << ": " << Error;
- return 0;
+ return nullptr;
}
// Update the triple name and return the found target.
if (!Err.empty()) {
errs() << Err << '\n';
delete Out;
- return 0;
+ return nullptr;
}
return Out;
std::unique_ptr<MCSubtargetInfo> STI(
TheTarget->createMCSubtargetInfo(TripleName, MCPU, FeaturesStr));
- MCInstPrinter *IP = NULL;
+ MCInstPrinter *IP = nullptr;
if (FileType == OFT_AssemblyFile) {
IP =
TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI, *MCII, *MRI, *STI);
- MCCodeEmitter *CE = 0;
- MCAsmBackend *MAB = 0;
+ MCCodeEmitter *CE = nullptr;
+ MCAsmBackend *MAB = nullptr;
if (ShowEncoding) {
CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, *STI, Ctx);
MAB = TheTarget->createMCAsmBackend(*MRI, TripleName, MCPU);
errs() << "llvm-objdump: error: unable to get target for '" << TripleName
<< "', see --version and --triple.\n";
- return 0;
+ return nullptr;
}
struct SymbolSorter {
TheTarget->createMCAsmInfo(*MRI, TripleName));
std::unique_ptr<const MCSubtargetInfo> STI(
TheTarget->createMCSubtargetInfo(TripleName, "", ""));
- MCContext Ctx(AsmInfo.get(), MRI.get(), 0);
+ MCContext Ctx(AsmInfo.get(), MRI.get(), nullptr);
std::unique_ptr<const MCDisassembler> DisAsm(
TheTarget->createMCDisassembler(*STI, Ctx));
int AsmPrinterVariant = AsmInfo->getAssemblerDialect();
return true;
}
-static const Target *getTarget(const ObjectFile *Obj = NULL) {
+static const Target *getTarget(const ObjectFile *Obj = nullptr) {
// Figure out the target triple.
llvm::Triple TheTriple("unknown-unknown-unknown");
if (TripleName.empty()) {
Error);
if (!TheTarget) {
errs() << ToolName << ": " << Error;
- return 0;
+ return nullptr;
}
// Update the triple name and return the found target.
StringRef ProgName(sys::path::filename(argv[0]));
if (argc > 1) {
- int (*func)(int, const char *[]) = 0;
+ int (*func)(int, const char *[]) = nullptr;
if (strcmp(argv[1], "merge") == 0)
func = merge_main;
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
uint64_t Value = ParseInteger(Data, Offset);
StringRef ValueDesc =
- (Value < array_lengthof(Strings)) ? Strings[Value] : NULL;
+ (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr;
PrintAttribute(Tag, Value, ValueDesc);
}
void COFFDumper::printFileHeaders() {
// Print COFF header
- const coff_file_header *COFFHeader = 0;
+ const coff_file_header *COFFHeader = nullptr;
if (error(Obj->getCOFFHeader(COFFHeader)))
return;
// Print PE header. This header does not exist if this is an object file and
// not an executable.
- const pe32_header *PEHeader = 0;
+ const pe32_header *PEHeader = nullptr;
if (error(Obj->getPE32Header(PEHeader)))
return;
if (PEHeader)
printPEHeader<pe32_header>(PEHeader);
- const pe32plus_header *PEPlusHeader = 0;
+ const pe32plus_header *PEPlusHeader = nullptr;
if (error(Obj->getPE32PlusHeader(PEPlusHeader)))
return;
if (PEPlusHeader)
break;
}
case COFF::DEBUG_STRING_TABLE_SUBSECTION:
- if (PayloadSize == 0 || StringTable.data() != 0 ||
+ if (PayloadSize == 0 || StringTable.data() != nullptr ||
Contents.back() != '\0') {
// Empty or duplicate or non-null-terminated subsection.
error(object_error::parse_failed);
// Holds the translation table from file indices
// to offsets in the string table.
- if (PayloadSize == 0 || FileIndexToStringOffsetTable.data() != 0) {
+ if (PayloadSize == 0 ||
+ FileIndexToStringOffsetTable.data() != nullptr) {
// Empty or duplicate subsection.
error(object_error::parse_failed);
return;
W.printString("UnwindInfoAddress",
formatSymbol(Rels, OffsetInSection + 8, RTF.UnwindInfoOffset));
- const coff_section* XData = 0;
+ const coff_section* XData = nullptr;
uint64_t UnwindInfoOffset = 0;
if (error(getSection(Rels, OffsetInSection + 8, &XData, &UnwindInfoOffset)))
return;
std::string FullSymbolName(SymbolName);
if (Symbol.isDynamic()) {
bool IsDefault;
- ErrorOr<StringRef> Version = Obj->getSymbolVersion(0, &*Symbol, IsDefault);
+ ErrorOr<StringRef> Version = Obj->getSymbolVersion(nullptr, &*Symbol,
+ IsDefault);
if (Version) {
FullSymbolName += (IsDefault ? "@@" : "@");
FullSymbolName += *Version;
void *getPointerToNamedFunction(const std::string &Name,
bool AbortOnFailure = true) override {
- return 0;
+ return nullptr;
}
bool finalizeMemory(std::string *ErrMsg) override { return false; }
unsigned Alignment,
unsigned SectionID,
StringRef SectionName) {
- sys::MemoryBlock MB = sys::Memory::AllocateRWX(Size, 0, 0);
+ sys::MemoryBlock MB = sys::Memory::AllocateRWX(Size, nullptr, nullptr);
FunctionMemory.push_back(MB);
return (uint8_t*)MB.base();
}
unsigned SectionID,
StringRef SectionName,
bool IsReadOnly) {
- sys::MemoryBlock MB = sys::Memory::AllocateRWX(Size, 0, 0);
+ sys::MemoryBlock MB = sys::Memory::AllocateRWX(Size, nullptr, nullptr);
DataMemory.push_back(MB);
return (uint8_t*)MB.base();
}
// Get the address of the entry point (_main by default).
void *MainAddress = Dyld.getSymbolAddress(EntryPoint);
- if (MainAddress == 0)
+ if (!MainAddress)
return Error("no definition for '" + EntryPoint + "'");
// Invalidate the instruction cache for each loaded function.
const char **Argv = new const char*[2];
// Use the name of the first input object module as argv[0] for the target.
Argv[0] = InputFileList[0].c_str();
- Argv[1] = 0;
+ Argv[1] = nullptr;
return Main(1, Argv);
}
std::string fmtbuf;
raw_string_ostream fmt(fmtbuf);
- const char *radix_fmt = 0;
+ const char *radix_fmt = nullptr;
switch (Radix) {
case octal:
radix_fmt = PRIo64;
/// Pick a random scalar type.
Type *pickScalarType() {
- Type *t = 0;
+ Type *t = nullptr;
do {
switch (Ran->Rand() % 30) {
case 0: t = Type::getInt1Ty(Context); break;
case 29: if (GenX86MMX) t = Type::getX86_MMXTy(Context); break;
default: llvm_unreachable("Invalid scalar value");
}
- } while (t == 0);
+ } while (t == nullptr);
return t;
}
std::string LLVMSymbolizer::symbolizeCode(const std::string &ModuleName,
uint64_t ModuleOffset) {
ModuleInfo *Info = getOrCreateModuleInfo(ModuleName);
- if (Info == 0)
+ if (!Info)
return printDILineInfo(DILineInfo());
if (Opts.PrintInlining) {
DIInliningInfo InlinedContext =
std::string &Result) {
std::string OrigRealPath = OrigPath;
#if defined(HAVE_REALPATH)
- if (char *RP = realpath(OrigPath.c_str(), NULL)) {
+ if (char *RP = realpath(OrigPath.c_str(), nullptr)) {
OrigRealPath = RP;
free(RP);
}
BinaryMapTy::iterator I = BinaryForPath.find(Path);
if (I != BinaryForPath.end())
return I->second;
- Binary *Bin = 0;
- Binary *DbgBin = 0;
+ Binary *Bin = nullptr;
+ Binary *DbgBin = nullptr;
ErrorOr<Binary *> BinaryOrErr = createBinary(Path);
if (!error(BinaryOrErr.getError())) {
std::unique_ptr<Binary> ParsedBinary(BinaryOrErr.get());
}
}
// Try to locate the debug binary using .gnu_debuglink section.
- if (DbgBin == 0) {
+ if (!DbgBin) {
std::string DebuglinkName;
uint32_t CRCHash;
std::string DebugBinaryPath;
}
}
}
- if (DbgBin == 0)
+ if (!DbgBin)
DbgBin = Bin;
BinaryPair Res = std::make_pair(Bin, DbgBin);
BinaryForPath[Path] = Res;
ObjectFile *
LLVMSymbolizer::getObjectFileFromBinary(Binary *Bin, const std::string &ArchName) {
- if (Bin == 0)
- return 0;
- ObjectFile *Res = 0;
+ if (!Bin)
+ return nullptr;
+ ObjectFile *Res = nullptr;
if (MachOUniversalBinary *UB = dyn_cast<MachOUniversalBinary>(Bin)) {
ObjectFileForArchMapTy::iterator I = ObjectFileForArch.find(
std::make_pair(UB, ArchName));
ObjectFile *Obj = getObjectFileFromBinary(Binaries.first, ArchName);
ObjectFile *DbgObj = getObjectFileFromBinary(Binaries.second, ArchName);
- if (Obj == 0) {
+ if (!Obj) {
// Failed to find valid object file.
- Modules.insert(make_pair(ModuleName, (ModuleInfo *)0));
- return 0;
+ Modules.insert(make_pair(ModuleName, (ModuleInfo *)nullptr));
+ return nullptr;
}
DIContext *Context = DIContext::getDWARFContext(DbgObj);
assert(Context);
if (Name.substr(0, 2) != "_Z")
return Name;
int status = 0;
- char *DemangledName = __cxa_demangle(Name.c_str(), 0, 0, &status);
+ char *DemangledName = __cxa_demangle(Name.c_str(), nullptr, nullptr, &status);
if (status != 0)
return Name;
std::string Result = DemangledName;
char quote = *pos;
pos++;
char *end = strchr(pos, quote);
- if (end == 0)
+ if (!end)
return false;
ModuleName = std::string(pos, end - pos);
pos = end + 1;
CFGSCC() : FunctionPass(ID) {}
bool runOnFunction(Function& func) override;
- void print(raw_ostream &O, const Module* = 0) const override { }
+ void print(raw_ostream &O, const Module* = nullptr) const override { }
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.setPreservesAll();
// run - Print out SCCs in the call graph for the specified module.
bool runOnModule(Module &M) override;
- void print(raw_ostream &O, const Module* = 0) const override { }
+ void print(raw_ostream &O, const Module* = nullptr) const override { }
// getAnalysisUsage - This pass requires the CallGraph.
void getAnalysisUsage(AnalysisUsage &AU) const override {
Error);
// Some modules don't specify a triple, and this is okay.
if (!TheTarget) {
- return 0;
+ return nullptr;
}
// Package up features to be passed to target/subtarget
std::unique_ptr<Module> M;
M.reset(ParseIRFile(InputFilename, Err, Context));
- if (M.get() == 0) {
+ if (!M.get()) {
Err.print(argv[0], errs());
return 1;
}
Passes.add(new DataLayoutPass(M.get()));
Triple ModuleTriple(M->getTargetTriple());
- TargetMachine *Machine = 0;
+ TargetMachine *Machine = nullptr;
if (ModuleTriple.getArch())
Machine = GetTargetMachine(Triple(ModuleTriple));
std::unique_ptr<TargetMachine> TM(Machine);
}
const PassInfo *PassInf = PassList[i];
- Pass *P = 0;
+ Pass *P = nullptr;
if (PassInf->getTargetMachineCtor())
P = PassInf->getTargetMachineCtor()(TM.get());
else if (PassInf->getNormalCtor())