diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/bugpoint/BugDriver.cpp | 9 | ||||
-rw-r--r-- | tools/llc/llc.cpp | 6 | ||||
-rw-r--r-- | tools/lli/lli.cpp | 6 | ||||
-rw-r--r-- | tools/llvm-dis/llvm-dis.cpp | 11 | ||||
-rw-r--r-- | tools/llvm-extract/llvm-extract.cpp | 3 | ||||
-rw-r--r-- | tools/llvm-link/llvm-link.cpp | 10 | ||||
-rw-r--r-- | tools/llvm-nm/llvm-nm.cpp | 2 | ||||
-rw-r--r-- | tools/llvm-prof/llvm-prof.cpp | 10 | ||||
-rw-r--r-- | tools/llvm2cpp/llvm2cpp.cpp | 4 | ||||
-rw-r--r-- | tools/llvmc/CompilerDriver.cpp | 3 | ||||
-rw-r--r-- | tools/opt/opt.cpp | 11 |
11 files changed, 27 insertions, 48 deletions
diff --git a/tools/bugpoint/BugDriver.cpp b/tools/bugpoint/BugDriver.cpp index 00dfc32..7ce1e68 100644 --- a/tools/bugpoint/BugDriver.cpp +++ b/tools/bugpoint/BugDriver.cpp @@ -72,18 +72,18 @@ BugDriver::BugDriver(const char *toolname, bool as_child, bool find_bugs, /// ParseInputFile - Given a bytecode or assembly input filename, parse and /// return it, or return null if not possible. /// -Module *llvm::ParseInputFile(const std::string &InputFilename) { - std::auto_ptr<MemoryBuffer> Buffer( - MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size())); +Module *llvm::ParseInputFile(const std::string &Filename) { + std::auto_ptr<MemoryBuffer> Buffer(MemoryBuffer::getFileOrSTDIN(Filename)); Module *Result = 0; if (Buffer.get()) Result = ParseBitcodeFile(Buffer.get()); ParseError Err; - if (!Result && !(Result = ParseAssemblyFile(InputFilename,&Err))) { + if (!Result && !(Result = ParseAssemblyFile(Filename, &Err))) { std::cerr << "bugpoint: " << Err.getMessage() << "\n"; Result = 0; } + return Result; } @@ -100,6 +100,7 @@ bool BugDriver::addSources(const std::vector<std::string> &Filenames) { // Load the first input file. Program = ParseInputFile(Filenames[0]); if (Program == 0) return true; + if (!run_as_child) std::cout << "Read input file : '" << Filenames[0] << "'\n"; diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp index 0522420..8797c58 100644 --- a/tools/llc/llc.cpp +++ b/tools/llc/llc.cpp @@ -179,14 +179,10 @@ int main(int argc, char **argv) { std::string ErrorMessage; std::auto_ptr<Module> M; - { std::auto_ptr<MemoryBuffer> Buffer( - MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size())); + MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage)); if (Buffer.get()) M.reset(ParseBitcodeFile(Buffer.get(), &ErrorMessage)); - else - ErrorMessage = "Error reading file '" + InputFilename + "'"; - } if (M.get() == 0) { std::cerr << argv[0] << ": bytecode didn't read correctly.\n"; std::cerr << "Reason: " << ErrorMessage << "\n"; diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp index a1caf11..fdb5f4a 100644 --- a/tools/lli/lli.cpp +++ b/tools/lli/lli.cpp @@ -77,11 +77,7 @@ int main(int argc, char **argv, char * const *envp) { // Load the bytecode... std::string ErrorMsg; ModuleProvider *MP = 0; - MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(&InputFile[0], - InputFile.size()); - if (Buffer == 0) - ErrorMsg = "Error reading file '" + InputFile + "'"; - else { + if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFile,&ErrorMsg)){ MP = getBitcodeModuleProvider(Buffer, &ErrorMsg); if (!MP) delete Buffer; } diff --git a/tools/llvm-dis/llvm-dis.cpp b/tools/llvm-dis/llvm-dis.cpp index 6321551..97ec4c7 100644 --- a/tools/llvm-dis/llvm-dis.cpp +++ b/tools/llvm-dis/llvm-dis.cpp @@ -54,14 +54,11 @@ int main(int argc, char **argv) { std::auto_ptr<Module> M; - MemoryBuffer *Buffer - = MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size()); - - if (Buffer == 0) - ErrorMessage = "Error reading file '" + InputFilename + "'"; - else + if (MemoryBuffer *Buffer + = MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage)) { M.reset(ParseBitcodeFile(Buffer, &ErrorMessage)); - delete Buffer; + delete Buffer; + } if (M.get() == 0) { cerr << argv[0] << ": "; diff --git a/tools/llvm-extract/llvm-extract.cpp b/tools/llvm-extract/llvm-extract.cpp index 97c45f6..4410638 100644 --- a/tools/llvm-extract/llvm-extract.cpp +++ b/tools/llvm-extract/llvm-extract.cpp @@ -57,8 +57,7 @@ int main(int argc, char **argv) { std::auto_ptr<Module> M; - MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(&InputFilename[0], - InputFilename.size()); + MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFilename); if (Buffer == 0) { cerr << "Error reading file '" + InputFilename + "'"; return 1; diff --git a/tools/llvm-link/llvm-link.cpp b/tools/llvm-link/llvm-link.cpp index b19213a..28be3a9 100644 --- a/tools/llvm-link/llvm-link.cpp +++ b/tools/llvm-link/llvm-link.cpp @@ -58,13 +58,11 @@ static inline std::auto_ptr<Module> LoadFile(const std::string &FN) { Module* Result = 0; const std::string &FNStr = Filename.toString(); - MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(&FNStr[0], - FNStr.size()); - if (Buffer == 0) - ErrorMessage = "Error reading file '" + FNStr + "'"; - else + if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(FNStr, + &ErrorMessage)) { Result = ParseBitcodeFile(Buffer, &ErrorMessage); - delete Buffer; + delete Buffer; + } if (Result) return std::auto_ptr<Module>(Result); // Load successful! if (Verbose) { diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp index c4aa7ba..e001399 100644 --- a/tools/llvm-nm/llvm-nm.cpp +++ b/tools/llvm-nm/llvm-nm.cpp @@ -124,7 +124,7 @@ static void DumpSymbolNamesFromFile(std::string &Filename) { // Note: Currently we do not support reading an archive from stdin. if (Filename == "-" || aPath.isBitcodeFile()) { std::auto_ptr<MemoryBuffer> Buffer( - MemoryBuffer::getFileOrSTDIN(&Filename[0], Filename.size())); + MemoryBuffer::getFileOrSTDIN(Filename, &ErrorMessage)); Module *Result = 0; if (Buffer.get()) Result = ParseBitcodeFile(Buffer.get(), &ErrorMessage); diff --git a/tools/llvm-prof/llvm-prof.cpp b/tools/llvm-prof/llvm-prof.cpp index 106eed8..f88f1fc 100644 --- a/tools/llvm-prof/llvm-prof.cpp +++ b/tools/llvm-prof/llvm-prof.cpp @@ -118,13 +118,11 @@ int main(int argc, char **argv) { // Read in the bytecode file... std::string ErrorMessage; Module *M; - MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(&BytecodeFile[0], - BytecodeFile.size()); - if (Buffer == 0) - ErrorMessage = "Error reading file '" + BytecodeFile + "'"; - else + if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(BytecodeFile, + &ErrorMessage)) { M = ParseBitcodeFile(Buffer, &ErrorMessage); - delete Buffer; + delete Buffer; + } if (M == 0) { std::cerr << argv[0] << ": " << BytecodeFile << ": " << ErrorMessage << "\n"; diff --git a/tools/llvm2cpp/llvm2cpp.cpp b/tools/llvm2cpp/llvm2cpp.cpp index 7a44602..d4382cd 100644 --- a/tools/llvm2cpp/llvm2cpp.cpp +++ b/tools/llvm2cpp/llvm2cpp.cpp @@ -52,11 +52,9 @@ int main(int argc, char **argv) { std::auto_ptr<Module> M; std::auto_ptr<MemoryBuffer> Buffer( - MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size())); + MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage)); if (Buffer.get()) M.reset(ParseBitcodeFile(Buffer.get(), &ErrorMessage)); - else - ErrorMessage = "Error reading file '" + InputFilename + "'"; if (M.get() == 0) { std::cerr << argv[0] << ": "; if (ErrorMessage.size()) diff --git a/tools/llvmc/CompilerDriver.cpp b/tools/llvmc/CompilerDriver.cpp index 2f94ee8..b170270 100644 --- a/tools/llvmc/CompilerDriver.cpp +++ b/tools/llvmc/CompilerDriver.cpp @@ -69,8 +69,7 @@ static bool GetBytecodeDependentLibraries(const std::string &fname, Module::LibraryListType& deplibs, std::string* ErrMsg) { ModuleProvider *MP = 0; - if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(&fname[0], - fname.size())) { + if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(fname)) { MP = getBitcodeModuleProvider(Buffer); if (MP == 0) delete Buffer; } diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index 4ef1a6e..14e02d0 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -260,15 +260,12 @@ int main(int argc, char **argv) { // Load the input module... std::auto_ptr<Module> M; - MemoryBuffer *Buffer - = MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size()); - - if (Buffer == 0) - ErrorMessage = "Error reading file '" + InputFilename + "'"; - else + if (MemoryBuffer *Buffer + = MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage)) { M.reset(ParseBitcodeFile(Buffer, &ErrorMessage)); + delete Buffer; + } - delete Buffer; if (M.get() == 0) { cerr << argv[0] << ": "; if (ErrorMessage.size()) |