[all-commits] [llvm/llvm-project] 82b3e2: [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF f...

Abhina Sree via All-commits all-commits at lists.llvm.org
Tue Apr 6 04:23:49 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 82b3e28e836d2f5c8cfd6e1047b93c088522365a
      https://github.com/llvm/llvm-project/commit/82b3e28e836d2f5c8cfd6e1047b93c088522365a
  Author: Abhina Sreeskantharajan <Abhina.Sreeskantharajan at ibm.com>
  Date:   2021-04-06 (Tue, 06 Apr 2021)

  Changed paths:
    M clang-tools-extra/clang-move/tool/ClangMove.cpp
    M clang-tools-extra/modularize/ModuleAssistant.cpp
    M clang-tools-extra/pp-trace/PPTrace.cpp
    M clang/lib/ARCMigrate/PlistReporter.cpp
    M clang/lib/Driver/Compilation.cpp
    M clang/lib/Driver/ToolChains/Clang.cpp
    M clang/lib/Frontend/CompilerInstance.cpp
    M clang/lib/Frontend/DependencyFile.cpp
    M clang/lib/Frontend/DependencyGraph.cpp
    M clang/lib/Frontend/FrontendActions.cpp
    M clang/lib/Frontend/HeaderIncludeGen.cpp
    M clang/lib/Frontend/ModuleDependencyCollector.cpp
    M clang/lib/Serialization/ASTReader.cpp
    M clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
    M clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
    M clang/tools/clang-refactor/ClangRefactor.cpp
    M clang/tools/driver/cc1as_main.cpp
    M flang/lib/Frontend/CompilerInstance.cpp
    M lld/COFF/DriverUtils.cpp
    M lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
    M lldb/include/lldb/Utility/ReproducerProvider.h
    M lldb/source/Utility/GDBRemote.cpp
    M lldb/source/Utility/ReproducerProvider.cpp
    M lldb/tools/lldb-server/LLDBServerUtilities.cpp
    M llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
    M llvm/include/llvm/Support/FileSystem.h
    M llvm/lib/CodeGen/RegAllocPBQP.cpp
    M llvm/lib/IR/Core.cpp
    M llvm/lib/IR/LLVMRemarkStreamer.cpp
    M llvm/lib/LTO/LTOBackend.cpp
    M llvm/lib/MC/MCParser/DarwinAsmParser.cpp
    M llvm/lib/ProfileData/GCOV.cpp
    M llvm/lib/ProfileData/SampleProfWriter.cpp
    M llvm/lib/Support/FileCollector.cpp
    M llvm/lib/Support/MemoryBuffer.cpp
    M llvm/lib/Support/TimeProfiler.cpp
    M llvm/lib/Support/Timer.cpp
    M llvm/lib/Support/Unix/Program.inc
    M llvm/lib/Support/Windows/Path.inc
    M llvm/lib/Support/Windows/Program.inc
    M llvm/lib/Transforms/IPO/Attributor.cpp
    M llvm/lib/Transforms/IPO/LowerTypeTests.cpp
    M llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
    M llvm/lib/Transforms/Utils/Debugify.cpp
    M llvm/tools/dsymutil/dsymutil.cpp
    M llvm/tools/llc/llc.cpp
    M llvm/tools/lli/lli.cpp
    M llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp
    M llvm/tools/llvm-dis/llvm-dis.cpp
    M llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
    M llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
    M llvm/tools/llvm-link/llvm-link.cpp
    M llvm/tools/llvm-mc/llvm-mc.cpp
    M llvm/tools/llvm-mca/llvm-mca.cpp
    M llvm/tools/llvm-opt-report/OptReport.cpp
    M llvm/tools/llvm-profdata/llvm-profdata.cpp
    M llvm/tools/llvm-xray/xray-account.cpp
    M llvm/tools/llvm-xray/xray-converter.cpp
    M llvm/tools/llvm-xray/xray-extract.cpp
    M llvm/tools/llvm-xray/xray-graph-diff.cpp
    M llvm/tools/llvm-xray/xray-graph.cpp
    M llvm/tools/opt/opt.cpp
    M llvm/tools/verify-uselistorder/verify-uselistorder.cpp
    M llvm/unittests/Support/Path.cpp
    M polly/lib/Exchange/JSONExporter.cpp

  Log Message:
  -----------
  [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

Problem:
On SystemZ we need to open text files in text mode. On Windows, files opened in text mode adds a CRLF '\r\n' which may not be desirable.

Solution:
This patch adds two new flags

  - OF_CRLF which indicates that CRLF translation is used.
  - OF_TextWithCRLF = OF_Text | OF_CRLF indicates that the file is text and uses CRLF translation.

Developers should now use either the OF_Text or OF_TextWithCRLF for text files and OF_None for binary files. If the developer doesn't want carriage returns on Windows, they should use OF_Text, if they do want carriage returns on Windows, they should use OF_TextWithCRLF.

So this is the behaviour per platform with my patch:

z/OS:
OF_None: open in binary mode
OF_Text : open in text mode
OF_TextWithCRLF: open in text mode

Windows:
OF_None: open file with no carriage return
OF_Text: open file with no carriage return
OF_TextWithCRLF: open file with carriage return

The Major change is in llvm/lib/Support/Windows/Path.inc to only set text mode if the OF_CRLF is set.
```
  if (Flags & OF_CRLF)
    CrtOpenFlags |= _O_TEXT;
```

These following files are the ones that still use OF_Text which I left unchanged. I modified all these except raw_ostream.cpp in recent patches so I know these were previously in Binary mode on Windows.
./llvm/lib/Support/raw_ostream.cpp
./llvm/lib/TableGen/Main.cpp
./llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
./llvm/unittests/Support/Path.cpp
./clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
./clang/lib/Frontend/CompilerInstance.cpp
./clang/lib/Driver/Driver.cpp
./clang/lib/Driver/ToolChains/Clang.cpp

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D99426




More information about the All-commits mailing list