summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT/StringExtrasTest.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Print quoted backslashes in LLVM IR as \\ instead of \5CReid Kleckner2019-10-101-1/+1
| | | | | | | | | This improves readability of Windows path string literals in LLVM IR. The LLVM assembler has supported \\ in IR strings for a long time, but the lexer doesn't tolerate escaped quotes, so they have to be printed as \22 for now. llvm-svn: 374415
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [ADT] Support converting to lowercase string in toHexPetr Hosek2018-09-101-0/+2
| | | | | | | | This is useful in certain use-cases such as D51833. Differential Revision: https://reviews.llvm.org/D51835 llvm-svn: 341852
* [ADT] Replace std::isprint by llvm::isPrint.Michael Kruse2018-07-261-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [ADT] Make escaping fn conform to coding guidelinesJonas Devlieghere2018-05-311-2/+2
| | | | | | | | As noted by Adrian on llvm-commits, PrintHTMLEscaped and PrintEscaped in StringExtras did not conform to the LLVM coding guidelines. This commit rectifies that. llvm-svn: 333669
* [ADT] Add unit test for PrintHTMLEscapedJonas Devlieghere2018-05-301-0/+7
| | | | | | Add unit tests for PrintHTMLEscaped which was added in r333565. llvm-svn: 333590
* [Support] Add unit test for printLowerCaseFrancis Visoiu Mistrih2017-11-281-0/+8
| | | | | | Add test case for the function added in r319171. llvm-svn: 319177
* Fix double->float truncation warning on MSVCSimon Pilgrim2017-06-231-2/+2
| | | | llvm-svn: 306101
* [ADT] Add llvm::to_floatPavel Labath2017-06-231-1/+19
| | | | | | | | | | | | | | | | | | Summary: The function matches the interface of llvm::to_integer, but as we are calling out to a C library function, I let it take a Twine argument, so we can avoid a string copy at least in some cases. I add a test and replace a couple of existing uses of strtod with this function. Reviewers: zturner Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D34518 llvm-svn: 306096
* [StringExtras] Add a fromHex to complement toHex.Zachary Turner2017-04-251-0/+16
| | | | | | | | | | We already have a function toHex that will convert a string like "\xFF\xFF" to the string "FFFF", but we do not have one that goes the other way - i.e. to convert a textual string representing a sequence of hexadecimal characters into the corresponding actual bytes. This patch adds such a function. llvm-svn: 301356
* Add llvm::join_items to StringExtras.Zachary Turner2016-09-271-0/+52
llvm::join_items is similar to llvm::join, which produces a string by concatenating a sequence of values together separated by a given separator. But it differs in that the arguments to llvm::join() are same-type members of a container, whereas the arguments to llvm::join_items are arbitrary types passed into a variadic template. The only requirement on parameters to llvm::join_items (including for the separator themselves) is that they be implicitly convertible to std::string or have an overload of std::string::operator+ Differential Revision: https://reviews.llvm.org/D24880 llvm-svn: 282502
OpenPOWER on IntegriCloud