1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00
llvm-mirror/tools/llvm-readobj
Michael Kruse 8fc32bf8f9 [ADT] Replace std::isprint by llvm::isPrint.
The standard library functions ::isprint/std::isprint have platform-
and locale-dependent behavior which makes LLVM's output less
predictable. In particular, regression tests my fail depending on the
implementation of these functions.

Implement llvm::isPrint in StringExtras.h with a standard behavior and
replace all uses of ::isprint/std::isprint by a call it llvm::isPrint.
The function is inlined and does not look up language settings so it
should perform better than the standard library's version.

Such a replacement has already been done for isdigit, isalpha, isxdigit
in r314883. gtest does the same in gtest-printers.cc using the following
justification:

    // Returns true if c is a printable ASCII character.  We test the
    // value of c directly instead of calling isprint(), which is buggy on
    // Windows Mobile.
    inline bool IsPrintableAscii(wchar_t c) {
      return 0x20 <= c && c <= 0x7E;
    }

Similar issues have also been encountered by Julia:
https://github.com/JuliaLang/julia/issues/7416

I noticed the problem myself when on Windows isprint('\t') started to
evaluate to true (see https://stackoverflow.com/questions/51435249) and
thus caused several unit tests to fail. The result of isprint doesn't
seem to be well-defined even for ASCII characters. Therefore I suggest
to replace isprint by a platform-independent version.

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

llvm-svn: 338034
2018-07-26 15:31:41 +00:00
..
ARMEHABIPrinter.h
ARMWinEHPrinter.cpp Typo fix: epilouge->epilogue. NFC. 2018-03-29 21:59:04 +00:00
ARMWinEHPrinter.h
CMakeLists.txt Reland "[DebugInfo] Support DWARF expressions in eh_frame" 2018-03-08 00:46:53 +00:00
COFFDumper.cpp [llvm-readobj] Generic hex-dump option 2018-07-25 10:04:37 +00:00
COFFImportDumper.cpp Remove \brief commands from doxygen comments. 2018-05-01 15:54:18 +00:00
DwarfCFIEHPrinter.h [llvm-readobj] Make header self-contained 2018-03-12 15:02:59 +00:00
ELFDumper.cpp [llvm-readobj] Generic hex-dump option 2018-07-25 10:04:37 +00:00
Error.cpp
Error.h
llvm-readobj.cpp [llvm-readobj] Generic hex-dump option 2018-07-25 10:04:37 +00:00
llvm-readobj.h [llvm-readobj] Add experimental support for SHT_RELR sections 2018-06-28 21:07:34 +00:00
LLVMBuild.txt
MachODumper.cpp [llvm-readobj] Generic hex-dump option 2018-07-25 10:04:37 +00:00
ObjDumper.cpp [ADT] Replace std::isprint by llvm::isPrint. 2018-07-26 15:31:41 +00:00
ObjDumper.h [llvm-readobj] Generic hex-dump option 2018-07-25 10:04:37 +00:00
StackMapPrinter.h
WasmDumper.cpp [WebAssembly] llvm-readobj: display symbols names in relocations 2018-05-01 16:35:16 +00:00
Win64EHDumper.cpp
Win64EHDumper.h
WindowsResourceDumper.cpp
WindowsResourceDumper.h