1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 20:23:11 +01:00
llvm-mirror/tools/llvm-objdump
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
..
CMakeLists.txt Fix debug build by adding missing dependencies on libBinaryFormat 2018-05-15 00:46:43 +00:00
COFFDump.cpp Remove \brief commands from doxygen comments. 2018-05-01 15:54:18 +00:00
ELFDump.cpp [llvm-objdump] Add dynamic section printing to private-headers option 2018-07-25 11:09:20 +00:00
llvm-objdump.cpp [ADT] Replace std::isprint by llvm::isPrint. 2018-07-26 15:31:41 +00:00
llvm-objdump.h [llvm-objdump] Add dynamic section printing to private-headers option 2018-07-25 11:09:20 +00:00
LLVMBuild.txt Add an c++ itanium demangler to llvm. 2016-09-06 19:16:48 +00:00
MachODump.cpp Reapply: "objdump: Support newer ObjC image info flags" 2018-07-06 05:11:35 +00:00
WasmDump.cpp Remove \brief commands from doxygen comments. 2018-05-01 15:54:18 +00:00