llvm-project/lldb/source/Utility
Abhina Sreeskantharajan 82b3e28e83 [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
2021-04-06 07:23:31 -04:00
..
ARM64_DWARF_Registers.h [LLDB] Update AArch64 Dwarf and EH frame register numbers 2020-07-10 11:45:39 +05:00
ARM64_ehframe_Registers.h [LLDB] Update AArch64 Dwarf and EH frame register numbers 2020-07-10 11:45:39 +05:00
ARM_DWARF_Registers.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
ARM_ehframe_Registers.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
ArchSpec.cpp [lldb] Honor the CPU type & subtype when launching on macOS 2021-02-03 13:42:00 -08:00
Args.cpp [lldb][NFC] Minor comment and inlining fixes for Args 2021-02-05 10:17:16 +01:00
Baton.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
Broadcaster.cpp [lldb/Utility] Use emplace_back instead of push_back (NFC) 2020-03-02 15:54:00 -08:00
CMakeLists.txt [trace][intel-pt] Implement trace start and trace stop 2021-03-30 17:31:37 -07:00
CompletionRequest.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
Connection.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
ConstString.cpp [lldb] Pass ConstString by value (again) (NFC) 2020-07-23 09:08:32 -07:00
DataBufferHeap.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
DataBufferLLVM.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
DataEncoder.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
DataExtractor.cpp [lldb] Fix unaligned load in DataExtractor 2020-07-07 10:13:41 -07:00
Environment.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
Event.cpp [lldb] Replace std::isprint/isspace with llvm's locale-independent version 2020-06-19 19:17:56 +02:00
FileSpec.cpp [lldb/Utility] Add YAML traits for ConstString and FileSpec. 2020-03-12 10:28:21 -07:00
GDBRemote.cpp [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text 2021-04-06 07:23:31 -04:00
IOObject.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
LLDBAssert.cpp [lldb] Include llvm-config.h instead of config.h 2021-03-29 08:58:51 -07:00
Listener.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
Log.cpp Make llvm::StringRef to std::string conversions explicit. 2020-01-28 23:25:25 +01:00
Logging.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
NameMatches.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
PPC64LE_DWARF_Registers.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
PPC64_DWARF_Registers.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
ProcessInfo.cpp [lldb] Extract reproducer providers & co into their own header. 2020-08-22 10:04:27 -07:00
RegisterValue.cpp [lldb] Improve RegisterValue::GetScalarValue 2020-11-04 14:53:06 +01:00
RegularExpression.cpp [lldb] Improve error message when --func-regex parameter for the breakpoint command is invalid 2020-04-27 09:55:06 +02:00
Reproducer.cpp [lldb] Remove LLDB_CAPTURE_REPRODUCER override 2021-03-31 21:10:56 -07:00
ReproducerInstrumentation.cpp [lldb] Deal gracefully with concurrency in the API instrumentation. 2020-12-10 09:37:49 -08:00
ReproducerProvider.cpp [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text 2021-04-06 07:23:31 -04:00
Scalar.cpp [lldb/Utility] Polish the Scalar class 2020-08-28 11:51:25 +02:00
SelectHelper.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
State.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
Status.cpp [lldb/Utility] Improve error_code->Status conversion 2020-04-23 16:12:41 +02:00
Stream.cpp [lldb/Interpreter] Support color in CommandReturnObject 2020-06-09 10:45:45 -07:00
StreamCallback.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
StreamString.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
StringExtractor.cpp [lldb] Replace std::isprint/isspace with llvm's locale-independent version 2020-06-19 19:17:56 +02:00
StringExtractorGDBRemote.cpp [trace][intel-pt] Implement trace start and trace stop 2021-03-30 17:31:37 -07:00
StringLexer.cpp [lldb] Eliminate unneeded value parameters in Utility (NFC) 2020-07-22 13:56:23 -07:00
StringList.cpp [lldb] Eliminate unneeded value parameters in Utility (NFC) 2020-07-22 13:56:23 -07:00
StructuredData.cpp Fix LLDB tweak in 62a47e994fcf5b73e29547d26cd9676b30cb69a3 2020-09-24 01:30:42 +02:00
TildeExpressionResolver.cpp [lldb] Return the original path when tilde expansion fails. 2020-12-02 16:01:30 -08:00
Timer.cpp [lldb] Ad os_signpost support to lldb_private::Timer 2021-01-06 15:16:09 -08:00
TraceGDBRemotePackets.cpp [trace][intel-pt] Implement trace start and trace stop 2021-03-30 17:31:37 -07:00
TraceIntelPTGDBRemotePackets.cpp [trace][intel-pt] Implement trace start and trace stop 2021-03-30 17:31:37 -07:00
UUID.cpp [lldb][NFC] Refactor getUUID functionality 2020-10-30 10:44:37 -07:00
UnimplementedError.cpp [lldb/Utility] Introduce UnimplementedError 2020-10-12 13:46:17 +02:00
UriParser.cpp [LLDB] Fix parsing of IPv6 host:port inside brackets 2020-03-26 11:35:54 +01:00
UserID.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
UserIDResolver.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
UuidCompatibility.h
VASprintf.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
VMRange.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
XcodeSDK.cpp [lldb] Eliminate unneeded value parameters in Utility (NFC) 2020-07-22 13:56:23 -07:00