From dd5af27a74a01f0d03356cea15d3a403f4964f8b Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 25 Jun 2013 05:28:34 +0000 Subject: [PATCH] keep only the StringRef version of getFileOrSTDIN. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184826 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/MemoryBuffer.h | 6 +----- lib/AsmParser/Parser.cpp | 2 +- lib/IRReader/IRReader.cpp | 4 ++-- lib/Support/MemoryBuffer.cpp | 8 -------- lib/TableGen/Main.cpp | 2 +- tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp | 2 +- tools/llvm-objdump/MachODump.cpp | 2 +- utils/FileCheck/FileCheck.cpp | 4 ++-- utils/FileUpdate/FileUpdate.cpp | 2 +- 9 files changed, 10 insertions(+), 22 deletions(-) diff --git a/include/llvm/Support/MemoryBuffer.h b/include/llvm/Support/MemoryBuffer.h index 0cce726d486..e443b684633 100644 --- a/include/llvm/Support/MemoryBuffer.h +++ b/include/llvm/Support/MemoryBuffer.h @@ -119,11 +119,7 @@ public: static error_code getFileOrSTDIN(StringRef Filename, OwningPtr &result, int64_t FileSize = -1); - static error_code getFileOrSTDIN(const char *Filename, - OwningPtr &result, - int64_t FileSize = -1); - - + //===--------------------------------------------------------------------===// // Provided for performance analysis. //===--------------------------------------------------------------------===// diff --git a/lib/AsmParser/Parser.cpp b/lib/AsmParser/Parser.cpp index bb4f03bacc1..d777ab91af8 100644 --- a/lib/AsmParser/Parser.cpp +++ b/lib/AsmParser/Parser.cpp @@ -43,7 +43,7 @@ Module *llvm::ParseAssembly(MemoryBuffer *F, Module *llvm::ParseAssemblyFile(const std::string &Filename, SMDiagnostic &Err, LLVMContext &Context) { OwningPtr File; - if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), File)) { + if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, File)) { Err = SMDiagnostic(Filename, SourceMgr::DK_Error, "Could not open input file: " + ec.message()); return 0; diff --git a/lib/IRReader/IRReader.cpp b/lib/IRReader/IRReader.cpp index eeec14e834c..cf859dabff5 100644 --- a/lib/IRReader/IRReader.cpp +++ b/lib/IRReader/IRReader.cpp @@ -48,7 +48,7 @@ Module *llvm::getLazyIRModule(MemoryBuffer *Buffer, SMDiagnostic &Err, Module *llvm::getLazyIRFileModule(const std::string &Filename, SMDiagnostic &Err, LLVMContext &Context) { OwningPtr File; - if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), File)) { + if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, File)) { Err = SMDiagnostic(Filename, SourceMgr::DK_Error, "Could not open input file: " + ec.message()); return 0; @@ -79,7 +79,7 @@ Module *llvm::ParseIR(MemoryBuffer *Buffer, SMDiagnostic &Err, Module *llvm::ParseIRFile(const std::string &Filename, SMDiagnostic &Err, LLVMContext &Context) { OwningPtr File; - if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), File)) { + if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, File)) { Err = SMDiagnostic(Filename, SourceMgr::DK_Error, "Could not open input file: " + ec.message()); return 0; diff --git a/lib/Support/MemoryBuffer.cpp b/lib/Support/MemoryBuffer.cpp index e875d11ec39..b8df7a4f143 100644 --- a/lib/Support/MemoryBuffer.cpp +++ b/lib/Support/MemoryBuffer.cpp @@ -173,14 +173,6 @@ error_code MemoryBuffer::getFileOrSTDIN(StringRef Filename, return getFile(Filename, result, FileSize); } -error_code MemoryBuffer::getFileOrSTDIN(const char *Filename, - OwningPtr &result, - int64_t FileSize) { - if (strcmp(Filename, "-") == 0) - return getSTDIN(result); - return getFile(Filename, result, FileSize); -} - //===----------------------------------------------------------------------===// // MemoryBuffer::getFile implementation. //===----------------------------------------------------------------------===// diff --git a/lib/TableGen/Main.cpp b/lib/TableGen/Main.cpp index dc4167b305c..7fe47bcb7e4 100644 --- a/lib/TableGen/Main.cpp +++ b/lib/TableGen/Main.cpp @@ -83,7 +83,7 @@ int TableGenMain(char *argv0, TableGenMainFn *MainFn) { // Parse the input file. OwningPtr File; if (error_code ec = - MemoryBuffer::getFileOrSTDIN(InputFilename.c_str(), File)) { + MemoryBuffer::getFileOrSTDIN(InputFilename, File)) { errs() << "Could not open input file '" << InputFilename << "': " << ec.message() <<"\n"; return 1; diff --git a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp index 99479a46a88..186eea99021 100644 --- a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp +++ b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp @@ -481,7 +481,7 @@ static int AnalyzeBitcode() { OwningPtr MemBuf; if (error_code ec = - MemoryBuffer::getFileOrSTDIN(InputFilename.c_str(), MemBuf)) + MemoryBuffer::getFileOrSTDIN(InputFilename, MemBuf)) return Error("Error reading '" + InputFilename + "': " + ec.message()); if (MemBuf->getBufferSize() & 3) diff --git a/tools/llvm-objdump/MachODump.cpp b/tools/llvm-objdump/MachODump.cpp index 27e1623d451..e0ec9cc172b 100644 --- a/tools/llvm-objdump/MachODump.cpp +++ b/tools/llvm-objdump/MachODump.cpp @@ -295,7 +295,7 @@ static void DisassembleInputMachO2(StringRef Filename, // get the sections and supply it to the section name parsing machinery. if (!DSYMFile.empty()) { OwningPtr Buf; - if (error_code ec = MemoryBuffer::getFileOrSTDIN(DSYMFile.c_str(), Buf)) { + if (error_code ec = MemoryBuffer::getFileOrSTDIN(DSYMFile, Buf)) { errs() << "llvm-objdump: " << Filename << ": " << ec.message() << '\n'; return; } diff --git a/utils/FileCheck/FileCheck.cpp b/utils/FileCheck/FileCheck.cpp index 07294a3b63d..5e2d93bf399 100644 --- a/utils/FileCheck/FileCheck.cpp +++ b/utils/FileCheck/FileCheck.cpp @@ -667,7 +667,7 @@ static bool ReadCheckFile(SourceMgr &SM, std::vector &CheckStrings) { OwningPtr File; if (error_code ec = - MemoryBuffer::getFileOrSTDIN(CheckFilename.c_str(), File)) { + MemoryBuffer::getFileOrSTDIN(CheckFilename, File)) { errs() << "Could not open check file '" << CheckFilename << "': " << ec.message() << '\n'; return true; @@ -1015,7 +1015,7 @@ int main(int argc, char **argv) { // Open the file to check and add it to SourceMgr. OwningPtr File; if (error_code ec = - MemoryBuffer::getFileOrSTDIN(InputFilename.c_str(), File)) { + MemoryBuffer::getFileOrSTDIN(InputFilename, File)) { errs() << "Could not open input file '" << InputFilename << "': " << ec.message() << '\n'; return 2; diff --git a/utils/FileUpdate/FileUpdate.cpp b/utils/FileUpdate/FileUpdate.cpp index 9b48f94948a..6f9544f28e2 100644 --- a/utils/FileUpdate/FileUpdate.cpp +++ b/utils/FileUpdate/FileUpdate.cpp @@ -45,7 +45,7 @@ int main(int argc, char **argv) { // Get the input data. OwningPtr In; - if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputFilename.c_str(), In)) { + if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputFilename, In)) { errs() << argv[0] << ": error: Unable to get input '" << InputFilename << "': " << ec.message() << '\n'; return 1;