llvm-project/llvm/tools/llvm-readobj
Michael Kruse 6f1da6e345 [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 Instead of ELFFile<ELFT>::Type, use ELFT::Type. NFC. 2018-01-12 02:28:31 +00:00
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 Remove LLVM_NOEXCEPT and replace it with noexcept 2016-10-19 23:52:38 +00:00
Error.h
LLVMBuild.txt Move Object format code to lib/BinaryFormat. 2017-06-07 03:48:56 +00:00
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 [llvm-readobj] Consistent use of ScopedPrinter 2018-01-10 00:14:19 +00:00
WasmDumper.cpp [WebAssembly] llvm-readobj: display symbols names in relocations 2018-05-01 16:35:16 +00:00
Win64EHDumper.cpp
Win64EHDumper.h
WindowsResourceDumper.cpp Remove redundant includes from tools. 2017-12-13 21:31:10 +00:00
WindowsResourceDumper.h [llvm-readobj] Teach readobj to dump .res files (WindowsResource). 2017-09-20 18:33:35 +00:00
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