llvm-project/llvm/unittests/ADT
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
..
APFloatTest.cpp APFloat/x87: Fix string conversion for "unnormal" values (pr35860) 2018-05-09 15:13:45 +00:00
APIntTest.cpp [APInt] Keep the original bit width in quotient and remainder 2018-07-19 18:07:56 +00:00
APSIntTest.cpp
AnyTest.cpp [ADT] Only run death tests in !NDEBUG 2018-07-20 22:15:09 +00:00
ArrayRefTest.cpp Revert "ADT: Move ArrayRef comparison operators into the class" 2018-06-28 12:10:21 +00:00
BitVectorTest.cpp
BitmaskEnumTest.cpp
BreadthFirstIteratorTest.cpp
BumpPtrListTest.cpp
CMakeLists.txt Add llvm::Any. 2018-07-20 16:39:32 +00:00
DAGDeltaAlgorithmTest.cpp
DeltaAlgorithmTest.cpp
DenseMapTest.cpp Remove \brief commands from doxygen comments. 2018-05-01 15:54:18 +00:00
DenseSetTest.cpp Fix typos of occurred and occurrence 2018-01-24 10:33:39 +00:00
DepthFirstIteratorTest.cpp
EquivalenceClassesTest.cpp [NFC] Add missing unit tests for EquivalenceClasses 2017-11-27 11:20:58 +00:00
FoldingSet.cpp
FunctionExtrasTest.cpp [ADT] Add llvm::unique_function which is like std::function but 2018-07-02 23:57:29 +00:00
FunctionRefTest.cpp
HashingTest.cpp
IListBaseTest.cpp
IListIteratorTest.cpp
IListNodeBaseTest.cpp
IListNodeTest.cpp
IListSentinelTest.cpp
IListTest.cpp
ImmutableMapTest.cpp
ImmutableSetTest.cpp
IntEqClassesTest.cpp
IntervalMapTest.cpp
IntrusiveRefCntPtrTest.cpp
IteratorTest.cpp [ADT] drop_begin: use adl_begin/adl_end. NFC. 2018-06-27 19:39:03 +00:00
MakeUniqueTest.cpp
MapVectorTest.cpp [ADT] Fix MapVector when 'Map::mapped_type != unsigned'. 2018-04-08 08:48:58 +00:00
MappedIteratorTest.cpp [ADT] Rewrite mapped_iterator in terms of iterator_adaptor_base. 2017-11-10 17:41:28 +00:00
OptionalTest.cpp [ADT] Make moving Optional not reset the Optional it moves from. 2018-01-25 17:24:22 +00:00
PackedVectorTest.cpp
PointerEmbeddedIntTest.cpp
PointerIntPairTest.cpp
PointerSumTypeTest.cpp
PointerUnionTest.cpp
PostOrderIteratorTest.cpp
PriorityWorklistTest.cpp
RangeAdapterTest.cpp
SCCIteratorTest.cpp
STLExtrasTest.cpp [unittests] Change std::sort to llvm::sort in response to r327219 2018-04-07 01:29:45 +00:00
ScopeExitTest.cpp Give scope_exit helper correct move semantics 2018-01-25 16:55:48 +00:00
SequenceTest.cpp
SetVectorTest.cpp
SimpleIListTest.cpp
SmallPtrSetTest.cpp [unittests] ADT: silence -Wself-assign diagnostics 2018-04-07 10:37:18 +00:00
SmallSetTest.cpp Recommit r334887: [SmallSet] Add SmallSetIterator. 2018-07-24 10:32:54 +00:00
SmallStringTest.cpp
SmallVectorTest.cpp
SparseBitVectorTest.cpp [unittests] ADT: silence -Wself-assign diagnostics 2018-04-07 10:37:18 +00:00
SparseMultiSetTest.cpp
SparseSetTest.cpp
StatisticTest.cpp Fix unused function warning in StatisticTest.cpp 2018-03-08 15:52:45 +00:00
StringExtrasTest.cpp [ADT] Replace std::isprint by llvm::isPrint. 2018-07-26 15:31:41 +00:00
StringMapTest.cpp [unittests] Change std::sort to llvm::sort in response to r327219 2018-04-07 01:29:45 +00:00
StringRefTest.cpp [ADT] Add `StringRef::rsplit(StringRef Separator)`. 2018-06-08 12:42:12 +00:00
StringSwitchTest.cpp [ADT] Simplify and optimize StringSwitch 2018-02-26 18:41:26 +00:00
TestGraph.h
TinyPtrVectorTest.cpp Ensure moved-from container is cleared on move 2017-12-11 19:22:59 +00:00
TripleTest.cpp [OpenEmbedded] Add a unittest for aarch64-oe-linux 2018-07-19 18:10:03 +00:00
TwineTest.cpp Revert "[ADT] Make Twine's copy constructor private." 2017-10-11 23:54:34 +00:00
VariadicFunctionTest.cpp