Author: Jonathan Crowther Date: 2021-04-16T10:08:36-04:00 New Revision: e71994a239d5f807c1c75515bfa512495224469f
URL: https://github.com/llvm/llvm-project/commit/e71994a239d5f807c1c75515bfa512495224469f DIFF: https://github.com/llvm/llvm-project/commit/e71994a239d5f807c1c75515bfa512495224469f.diff LOG: [SystemZ][z/OS] Add IsText Argument to GetFile and GetFileOrSTDIN Add the `IsText` argument to `GetFile` and `GetFileOrSTDIN` which will help z/OS distinguish between text and binary correctly. This is an extension to [this patch](https://reviews.llvm.org/D97785) Reviewed By: abhina.sreeskantharajan, amccarth Differential Revision: https://reviews.llvm.org/D100488 Added: Modified: clang/tools/driver/cc1as_main.cpp llvm/lib/AsmParser/Parser.cpp llvm/lib/CodeGen/MIRParser/MIRParser.cpp llvm/lib/ProfileData/InstrProfReader.cpp llvm/lib/ProfileData/SampleProfReader.cpp llvm/lib/Testing/Support/SupportHelpers.cpp llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp llvm/tools/llvm-ifs/llvm-ifs.cpp llvm/tools/llvm-mc/llvm-mc.cpp Removed: ################################################################################ diff --git a/clang/tools/driver/cc1as_main.cpp b/clang/tools/driver/cc1as_main.cpp index 570e3e40ebdd9..083fc0846ac18 100644 --- a/clang/tools/driver/cc1as_main.cpp +++ b/clang/tools/driver/cc1as_main.cpp @@ -342,7 +342,7 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts, return Diags.Report(diag::err_target_unknown_triple) << Opts.Triple; ErrorOr<std::unique_ptr<MemoryBuffer>> Buffer = - MemoryBuffer::getFileOrSTDIN(Opts.InputFile); + MemoryBuffer::getFileOrSTDIN(Opts.InputFile, /*IsText=*/true); if (std::error_code EC = Buffer.getError()) { Error = EC.message(); diff --git a/llvm/lib/AsmParser/Parser.cpp b/llvm/lib/AsmParser/Parser.cpp index 8147620181f9c..b4be041d6212b 100644 --- a/llvm/lib/AsmParser/Parser.cpp +++ b/llvm/lib/AsmParser/Parser.cpp @@ -104,7 +104,7 @@ parseAssemblyFileWithIndex(StringRef Filename, SMDiagnostic &Err, bool UpgradeDebugInfo, DataLayoutCallbackTy DataLayoutCallback) { ErrorOr<std::unique_ptr<MemoryBuffer>> FileOrErr = - MemoryBuffer::getFileOrSTDIN(Filename); + MemoryBuffer::getFileOrSTDIN(Filename, /*IsText=*/true); if (std::error_code EC = FileOrErr.getError()) { Err = SMDiagnostic(Filename, SourceMgr::DK_Error, "Could not open input file: " + EC.message()); diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp index e4e00b2057ce1..88dc4571b2d77 100644 --- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp +++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp @@ -984,7 +984,7 @@ bool MIRParser::parseMachineFunctions(Module &M, MachineModuleInfo &MMI) { std::unique_ptr<MIRParser> llvm::createMIRParserFromFile( StringRef Filename, SMDiagnostic &Error, LLVMContext &Context, std::function<void(Function &)> ProcessIRFunction) { - auto FileOrErr = MemoryBuffer::getFileOrSTDIN(Filename); + auto FileOrErr = MemoryBuffer::getFileOrSTDIN(Filename, /*IsText=*/true); if (std::error_code EC = FileOrErr.getError()) { Error = SMDiagnostic(Filename, SourceMgr::DK_Error, "Could not open input file: " + EC.message()); diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp index 9581e5b486a6f..b83295a16f0f8 100644 --- a/llvm/lib/ProfileData/InstrProfReader.cpp +++ b/llvm/lib/ProfileData/InstrProfReader.cpp @@ -41,7 +41,7 @@ using namespace llvm; static Expected<std::unique_ptr<MemoryBuffer>> setupMemoryBuffer(const Twine &Path) { ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr = - MemoryBuffer::getFileOrSTDIN(Path); + MemoryBuffer::getFileOrSTDIN(Path, /*IsText=*/true); if (std::error_code EC = BufferOrErr.getError()) return errorCodeToError(EC); return std::move(BufferOrErr.get()); diff --git a/llvm/lib/ProfileData/SampleProfReader.cpp b/llvm/lib/ProfileData/SampleProfReader.cpp index 200a0afb01c61..656638d7dc63f 100644 --- a/llvm/lib/ProfileData/SampleProfReader.cpp +++ b/llvm/lib/ProfileData/SampleProfReader.cpp @@ -1575,7 +1575,7 @@ SampleProfileReaderItaniumRemapper::lookUpNameInProfile(StringRef Fname) { /// \returns an error code indicating the status of the buffer. static ErrorOr<std::unique_ptr<MemoryBuffer>> setupMemoryBuffer(const Twine &Filename) { - auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(Filename); + auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(Filename, /*IsText=*/true); if (std::error_code EC = BufferOrErr.getError()) return EC; auto Buffer = std::move(BufferOrErr.get()); diff --git a/llvm/lib/Testing/Support/SupportHelpers.cpp b/llvm/lib/Testing/Support/SupportHelpers.cpp index 5f53b2330b206..3c12edfa9d99b 100644 --- a/llvm/lib/Testing/Support/SupportHelpers.cpp +++ b/llvm/lib/Testing/Support/SupportHelpers.cpp @@ -40,7 +40,7 @@ SmallString<128> llvm::unittest::getInputFileDirectory(const char *Argv0) { EXPECT_TRUE(Found) << "Unit test source directory file does not exist."; - auto File = MemoryBuffer::getFile(InputFilePath); + auto File = MemoryBuffer::getFile(InputFilePath, /*IsText=*/true); EXPECT_TRUE(static_cast<bool>(File)) << "Could not open unit test source directory file."; diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp index d86ab475cb9a8..7ceef254e608d 100644 --- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp +++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp @@ -334,7 +334,7 @@ namespace exegesis { Expected<InstructionBenchmark> InstructionBenchmark::readYaml(const LLVMState &State, StringRef Filename) { if (auto ExpectedMemoryBuffer = - errorOrToExpected(MemoryBuffer::getFile(Filename))) { + errorOrToExpected(MemoryBuffer::getFile(Filename, /*IsText=*/true))) { yaml::Input Yin(*ExpectedMemoryBuffer.get()); YamlContext Context(State); InstructionBenchmark Benchmark; @@ -351,7 +351,7 @@ InstructionBenchmark::readYaml(const LLVMState &State, StringRef Filename) { Expected<std::vector<InstructionBenchmark>> InstructionBenchmark::readYamls(const LLVMState &State, StringRef Filename) { if (auto ExpectedMemoryBuffer = - errorOrToExpected(MemoryBuffer::getFile(Filename))) { + errorOrToExpected(MemoryBuffer::getFile(Filename, /*IsText=*/true))) { yaml::Input Yin(*ExpectedMemoryBuffer.get()); YamlContext Context(State); std::vector<InstructionBenchmark> Benchmarks; diff --git a/llvm/tools/llvm-ifs/llvm-ifs.cpp b/llvm/tools/llvm-ifs/llvm-ifs.cpp index 129dc89d35891..b6a1b4a95128e 100644 --- a/llvm/tools/llvm-ifs/llvm-ifs.cpp +++ b/llvm/tools/llvm-ifs/llvm-ifs.cpp @@ -182,7 +182,7 @@ template <> struct MappingTraits<IFSStub> { static Expected<std::unique_ptr<IFSStub>> readInputFile(StringRef FilePath) { // Read in file. ErrorOr<std::unique_ptr<MemoryBuffer>> BufOrError = - MemoryBuffer::getFileOrSTDIN(FilePath); + MemoryBuffer::getFileOrSTDIN(FilePath, /*IsText=*/true); if (!BufOrError) return createStringError(BufOrError.getError(), "Could not open `%s`", FilePath.data()); diff --git a/llvm/tools/llvm-mc/llvm-mc.cpp b/llvm/tools/llvm-mc/llvm-mc.cpp index 017d6a4e89a3c..daecbc2c97940 100644 --- a/llvm/tools/llvm-mc/llvm-mc.cpp +++ b/llvm/tools/llvm-mc/llvm-mc.cpp @@ -343,7 +343,7 @@ int main(int argc, char **argv) { Triple TheTriple(TripleName); ErrorOr<std::unique_ptr<MemoryBuffer>> BufferPtr = - MemoryBuffer::getFileOrSTDIN(InputFilename); + MemoryBuffer::getFileOrSTDIN(InputFilename, /*IsText=*/true); if (std::error_code EC = BufferPtr.getError()) { WithColor::error(errs(), ProgName) << InputFilename << ": " << EC.message() << '\n'; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits