1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00
llvm-mirror/lib
Reid Kleckner d11aae6992 [Windows] Convert from UTF-8 to UTF-16 when writing to a Windows console
Summary:
Calling WriteConsoleW is the most reliable way to print Unicode
characters to a Windows console.

If binary data gets printed to the console, attempting to re-encode it
shouldn't be a problem, since garbage in can produce garbage out.

This breaks printing strings in the local codepage, which WriteConsoleA
knows how to handle. For example, this can happen when user source code
is encoded with the local codepage, and an LLVM tool quotes it while
emitting a caret diagnostic. This is unfortunate, but well-behaved tools
should validate that their input is UTF-8 and escape non-UTF-8
characters before sending them to raw_fd_ostream. Clang already does
this, but not all LLVM tools do this.

One drawback to the current implementation is printing a string a byte
at a time doesn't work. Consider this LLVM code:
  for (char C : MyStr) outs() << C;

Because outs() is now unbuffered, we wil try to convert each byte to
UTF-16, which will fail. However, this already didn't work, so I think
we may as well update callers that do that as we find them to print
complete portions of strings. You can see a real example of this in my
patch to SourceMgr.cpp

Fixes PR38669 and PR36267.

Reviewers: zturner, efriedma

Subscribers: llvm-commits, hiraditya

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

llvm-svn: 341433
2018-09-05 00:08:56 +00:00
..
Analysis [NFC] Optionally pass a function to emitInstrCountChangedRemark 2018-08-31 20:54:37 +00:00
AsmParser [x86/SLH] Add a real Clang flag and LLVM IR attribute for Speculative 2018-09-04 12:38:00 +00:00
BinaryFormat Fix undefined behavior in r340457 2018-08-23 02:51:09 +00:00
Bitcode [x86/SLH] Add a real Clang flag and LLVM IR attribute for Speculative 2018-09-04 12:38:00 +00:00
CodeGen DAG: Factor out helper function for odd vector sizes 2018-09-04 18:47:43 +00:00
DebugInfo [dwarfdump] Improve -diff option by hiding more data. 2018-09-04 16:21:37 +00:00
Demangle Remove some debugging code that was accidentally left in. 2018-08-30 21:00:57 +00:00
ExecutionEngine clang-format r341282. 2018-09-02 01:29:29 +00:00
Fuzzer
FuzzMutate [IR] Replace isa<TerminatorInst> with isTerminator(). 2018-08-26 09:51:22 +00:00
IR [NFC] Improve clarity in emitInstrCountChangedRemark 2018-09-04 21:03:43 +00:00
IRReader
LineEditor
Linker
LTO [ThinLTO] Fix memory corruption in ThinLTOCodeGenerator when CodeGenOnly was specified 2018-09-04 22:54:17 +00:00
MC [MC] - ConstantPools.cpp: Style consistency, remove redundant braces. NFC. 2018-09-03 03:48:39 +00:00
Object [MachO] Fix inconsistency between error messages when validating LC_DYSYMTAB 2018-09-04 16:31:53 +00:00
ObjectYAML
Option Revert r341329 due to MSAN error 2018-09-03 18:13:46 +00:00
Passes [PGO] Control Height Reduction 2018-09-04 17:19:13 +00:00
ProfileData
Support [Windows] Convert from UTF-8 to UTF-16 when writing to a Windows console 2018-09-05 00:08:56 +00:00
TableGen
Target [WebAssembly] Fixed stale assert message in WebAssemblyMCInstLower 2018-09-04 22:59:05 +00:00
Testing
ToolDrivers
Transforms [InstCombine] fix xor-or-xor fold to check uses and handle commutes 2018-09-04 23:22:13 +00:00
WindowsManifest
XRay [XRay] Update RecordInitializer for PIDRecord 2018-08-31 20:02:55 +00:00
CMakeLists.txt
LLVMBuild.txt