diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp index feb733fe3c9e0..01f7c6047726e 100644 --- a/clang/tools/clang-format/ClangFormat.cpp +++ b/clang/tools/clang-format/ClangFormat.cpp @@ -413,8 +413,9 @@ static bool format(StringRef FileName, bool ErrorOnIncompleteFormat = false) { // On Windows, overwriting a file with an open file mapping doesn't work, // so read the whole file into memory when formatting in-place. ErrorOr> CodeOrErr = - !OutputXML && Inplace ? MemoryBuffer::getFileAsStream(FileName) - : MemoryBuffer::getFileOrSTDIN(FileName); + !OutputXML && Inplace + ? MemoryBuffer::getFileAsStream(FileName) + : MemoryBuffer::getFileOrSTDIN(FileName, /*IsText=*/true); if (std::error_code EC = CodeOrErr.getError()) { errs() << EC.message() << "\n"; return true; @@ -558,7 +559,7 @@ static int dumpConfig() { // Read in the code in case the filename alone isn't enough to detect the // language. ErrorOr> CodeOrErr = - MemoryBuffer::getFileOrSTDIN(FileNames[0]); + MemoryBuffer::getFileOrSTDIN(FileNames[0], /*IsText=*/true); if (std::error_code EC = CodeOrErr.getError()) { llvm::errs() << EC.message() << "\n"; return 1; diff --git a/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp b/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp index c3015d895230e..40ee59c014b09 100644 --- a/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp +++ b/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp @@ -95,7 +95,8 @@ static std::vector getSearchPaths(opt::InputArgList *Args, // Opens a file. Path has to be resolved already. (used for def file) std::unique_ptr openFile(const Twine &Path) { - ErrorOr> MB = MemoryBuffer::getFile(Path); + ErrorOr> MB = + MemoryBuffer::getFile(Path, /*IsText=*/true); if (std::error_code EC = MB.getError()) { llvm::errs() << "cannot open file " << Path << ": " << EC.message() << "\n"; diff --git a/llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp b/llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp index 6a5646965df2c..c5ccd64f11653 100644 --- a/llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp +++ b/llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp @@ -144,15 +144,18 @@ int main(int argc, const char *argv[]) { cl::HideUnrelatedOptions({&CXXMapCategory, &getColorCategory()}); cl::ParseCommandLineOptions(argc, argv, "LLVM C++ mangled name remapper\n"); - auto OldSymbolBufOrError = MemoryBuffer::getFileOrSTDIN(OldSymbolFile); + auto OldSymbolBufOrError = + MemoryBuffer::getFileOrSTDIN(OldSymbolFile, /*IsText=*/true); if (!OldSymbolBufOrError) exitWithErrorCode(OldSymbolBufOrError.getError(), OldSymbolFile); - auto NewSymbolBufOrError = MemoryBuffer::getFileOrSTDIN(NewSymbolFile); + auto NewSymbolBufOrError = + MemoryBuffer::getFileOrSTDIN(NewSymbolFile, /*IsText=*/true); if (!NewSymbolBufOrError) exitWithErrorCode(NewSymbolBufOrError.getError(), NewSymbolFile); - auto RemappingBufOrError = MemoryBuffer::getFileOrSTDIN(RemappingFile); + auto RemappingBufOrError = + MemoryBuffer::getFileOrSTDIN(RemappingFile, /*IsText=*/true); if (!RemappingBufOrError) exitWithErrorCode(RemappingBufOrError.getError(), RemappingFile); diff --git a/llvm/tools/yaml2obj/yaml2obj.cpp b/llvm/tools/yaml2obj/yaml2obj.cpp index b7f5356e22a9e..4a060e1aad427 100644 --- a/llvm/tools/yaml2obj/yaml2obj.cpp +++ b/llvm/tools/yaml2obj/yaml2obj.cpp @@ -130,7 +130,7 @@ int main(int argc, char **argv) { } ErrorOr> Buf = - MemoryBuffer::getFileOrSTDIN(Input); + MemoryBuffer::getFileOrSTDIN(Input, /*IsText=*/true); if (!Buf) return 1; diff --git a/llvm/utils/lit/lit/builtin_commands/cat.py b/llvm/utils/lit/lit/builtin_commands/cat.py index 37f55c0aef210..6fb2152ef9332 100644 --- a/llvm/utils/lit/lit/builtin_commands/cat.py +++ b/llvm/utils/lit/lit/builtin_commands/cat.py @@ -55,10 +55,24 @@ def main(argv): msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) for filename in filenames: try: - fileToCat = open(filename, "rb") - contents = fileToCat.read() + contents = None + is_text = False + try: + if sys.platform != "win32": + fileToCat = open(filename, "r") + contents = fileToCat.read() + is_text = True + except: + pass + + if contents is None: + fileToCat = open(filename, "rb") + contents = fileToCat.read() + if show_nonprinting: contents = convertToCaretAndMNotation(contents) + elif is_text: + contents = contents.encode() writer.write(contents) sys.stdout.flush() fileToCat.close() diff --git a/llvm/utils/lit/lit/llvm/config.py b/llvm/utils/lit/lit/llvm/config.py index 96b4f7bc86772..1d4babc99984b 100644 --- a/llvm/utils/lit/lit/llvm/config.py +++ b/llvm/utils/lit/lit/llvm/config.py @@ -57,6 +57,13 @@ def __init__(self, lit_config, config): self.lit_config.note("using lit tools: {}".format(path)) lit_path_displayed = True + if platform.system() == "OS/390": + self.with_environment("_BPXK_AUTOCVT", "ON") + self.with_environment("_TAG_REDIR_IN", "TXT") + self.with_environment("_TAG_REDIR_OUT", "TXT") + self.with_environment("_TAG_REDIR_ERR", "TXT") + self.with_environment("_CEE_RUNOPTS", "FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)") + # Choose between lit's internal shell pipeline runner and a real shell. # If LIT_USE_INTERNAL_SHELL is in the environment, we use that as an # override.