1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 20:12:56 +02:00
Commit Graph

53 Commits

Author SHA1 Message Date
Daniel Dunbar
7b66487335 ADT/StringRef: Add ::lower() and ::upper() methods.
llvm-svn: 143880
2011-11-06 18:04:43 +00:00
Argyrios Kyrtzidis
d58ffb7e7d Add asserts in StringRef to make sure we avoid undefined behavior:
-strlen should not be called with NULL. Also guarantee that StringRef's Length is 0 if Data is NULL.
-memcmp should not be called with NULL (even if size is 0)

Patch by Matthieu Monrocq!

llvm-svn: 131747
2011-05-20 19:24:12 +00:00
John McCall
d24d94c11c Add an operator+= for appending StringRefs onto std::strings.
Previously this pattern would be compiled using an implicit conversion
to std::string.

llvm-svn: 131325
2011-05-13 23:58:45 +00:00
Lenny Maiorani
1b1a9860d1 Remove bounded StringRef::compare() since nothing but Clang SA was using it and it is just as easy to use StringRef::substr() preceding StringRef::compare() to achieve the same thing.
llvm-svn: 130430
2011-04-28 20:20:12 +00:00
Lenny Maiorani
dfae65d305 Implements StringRef::compare with bounds. It is behaves similarly to strncmp(). Unit tests also included.
llvm-svn: 129582
2011-04-15 17:56:50 +00:00
Michael J. Spencer
090cf77d32 Support/ADT/StringRef: Add find_last_of.
llvm-svn: 120495
2010-11-30 23:27:35 +00:00
Benjamin Kramer
75de69b73c StringRefs are POD-like.
llvm-svn: 120181
2010-11-26 14:36:54 +00:00
Michael J. Spencer
b2cfb3b443 Fix Whitespace.
llvm-svn: 120166
2010-11-26 04:16:08 +00:00
Douglas Gregor
a598c0fbce Extend StringRef's edit-distance algorithm to permit an upper bound on the allowed edit distance
llvm-svn: 116867
2010-10-19 22:13:48 +00:00
Benjamin Kramer
926ba6058b Avoid O(n*m) complexity in StringRef::find_first(_not)_of(StringRef).
- Cache used characters in a bitset to reduce memory overhead to just 32 bytes.
- On my core2 this code is faster except when the checked string was very short
  (smaller than the list of delimiters).

llvm-svn: 111817
2010-08-23 18:16:08 +00:00
Benjamin Kramer
e4c21a06f7 StringRef tweaks:
- Respect find_first_of(char's From parameter instead of silently dropping it.
- Prefer std::string() to std::string("")

llvm-svn: 111814
2010-08-23 17:44:13 +00:00
Chris Lattner
c27b10f80d Don't pass in a null pointer to std::string's ctor, an empty string
ref should produce an empty std::string.  This fixes PR7879.

llvm-svn: 111332
2010-08-18 00:11:25 +00:00
Jakob Stoklund Olesen
1c0aa5f14a Add StringRef::compare_numeric and use it to sort TableGen register records.
This means that our Registers are now ordered R7, R8, R9, R10, R12, ...
Not R1, R10, R11, R12, R2, R3, ...

llvm-svn: 104745
2010-05-26 21:47:28 +00:00
Dan Gohman
f4e99e3f84 These functions don't need to access this.
llvm-svn: 101776
2010-04-19 15:38:38 +00:00
John McCall
b6e6dd63ad Add an override to StringRef::getAsInteger which parses into an APInt.
It gets its own implementation totally divorced from the (presumably
performance-sensitive) routines which parse into a uint64_t.

Add APInt::operator|=(uint64_t), which is situationally much better than
using a full APInt.

llvm-svn: 97381
2010-02-28 09:55:58 +00:00
Dan Gohman
835086ef52 Fix various doxygen warnings.
llvm-svn: 96779
2010-02-22 04:10:52 +00:00
Chris Lattner
a8deef7d39 give StringRef a const_iterator member.
llvm-svn: 93294
2010-01-13 04:50:20 +00:00
Kovarththanan Rajaratnam
3a038bba47 Fix occurrence typo
llvm-svn: 92926
2010-01-07 18:46:52 +00:00
Douglas Gregor
301af636d3 Implement edit distance for StringRef
llvm-svn: 92309
2009-12-30 17:23:44 +00:00
Eli Friedman
fe6a796851 Change StringRef::startswith and StringRef::endswith to versions which are a
bit more verbose, but optimize to much shorter code.

llvm-svn: 91817
2009-12-21 06:49:24 +00:00
Benjamin Kramer
3e24786569 Remove the now obsolete algorithm include from StringRef.h.
llvm-svn: 89354
2009-11-19 15:48:14 +00:00
Torok Edwin
2d2fb3f6ec Workaround PR5482, because all the gcc versions that I had were miscompiling StringRef:
4.2.4, 4.3.4, 4.4.2.
The workaround is to use a local min/max implementation that takes an integer
param, and not a reference to integer param (like std::min does).

llvm-svn: 89352
2009-11-19 15:39:50 +00:00
Eric Christopher
3877235021 Fix unused variables warnings.
llvm-svn: 88977
2009-11-16 22:34:32 +00:00
Dan Gohman
30f404fb4a Use .data() instead of .c_str() when nul-termination is not needed.
llvm-svn: 88703
2009-11-13 21:55:31 +00:00
Rafael Espindola
11ceba8119 Switch to smallvector. Also fix issue with using unsigend for MaxSplit.
llvm-svn: 87068
2009-11-13 02:18:25 +00:00
Rafael Espindola
22f040b797 Add a new split method to StringRef that puts the substrings in a vector.
llvm-svn: 87058
2009-11-13 01:24:40 +00:00
Daniel Dunbar
880dfd38d8 StringRef(const char*) should not be used to turn null pointers into empty
strings.

llvm-svn: 87031
2009-11-12 21:26:11 +00:00
Benjamin Kramer
da70783da7 Add compare_lower and equals_lower methods to StringRef. Switch all users of
StringsEqualNoCase (from StringExtras.h) to it.

llvm-svn: 87020
2009-11-12 20:36:59 +00:00
Daniel Dunbar
da387a1c25 Add StringRef::split(StringRef), to complement StringRef::split(char).
llvm-svn: 86803
2009-11-11 05:19:11 +00:00
Daniel Dunbar
16a5387db2 Add From arguments to StringRef search functions, and tweak doxyments.
Also, add unittests for find_first_of and find_first_not_of.

llvm-svn: 86770
2009-11-11 00:28:53 +00:00
Daniel Dunbar
4daaf9d3f4 Pass StringRef by value.
llvm-svn: 86251
2009-11-06 10:58:06 +00:00
Eric Christopher
05ee62db65 size_t, not unsigned here to silence a warning.
llvm-svn: 84900
2009-10-22 22:06:50 +00:00
Dan Gohman
7cdf41cf01 Don't use identifiers that start with an underscore followed
by a capital letter, which invokes undefined behavior.

llvm-svn: 83206
2009-10-01 17:39:52 +00:00
Devang Patel
5cad2b8f0f Create empty StringRef is incoming cstring is NULL.
llvm-svn: 83082
2009-09-29 18:39:56 +00:00
Chris Lattner
e520a0c8e7 write rfind in terms of npos as daniel requested
llvm-svn: 82414
2009-09-20 22:54:26 +00:00
Chris Lattner
72732da2f0 move a couple non-trivial methods out of line, add new
find_first_of/find_first_of methods.

llvm-svn: 82347
2009-09-20 01:22:16 +00:00
Chris Lattner
2cdc7b8e76 add size_t and a version of rfind that allows specification of where
to scan from.

llvm-svn: 82343
2009-09-20 00:38:28 +00:00
Chris Lattner
d2a0138c62 add some more overloads of StringRef::getAsInteger for
common and useful integer types.

llvm-svn: 82338
2009-09-19 23:58:48 +00:00
Chris Lattner
e6fa81a475 provide a "strtoull" operation that works on StringRef's.
llvm-svn: 82322
2009-09-19 19:47:14 +00:00
Daniel Dunbar
60e1dee7fa Add StringRef::{rfind, rsplit}
llvm-svn: 82087
2009-09-16 22:38:48 +00:00
Daniel Dunbar
09f40a7871 Fix pasto in StringRef::count(char)
llvm-svn: 79356
2009-08-18 18:34:22 +00:00
Daniel Dunbar
4a9a98a5de Add StringRef::count({char,StringRef})
llvm-svn: 79354
2009-08-18 18:26:35 +00:00
Daniel Dunbar
791bb8ce44 Add StringRef::front (with some small tweaks while I was in the area).
- Patch by Erick Tryzelaar

llvm-svn: 78883
2009-08-13 02:03:30 +00:00
Daniel Dunbar
f4e8af6ecc StringRef: Add find(char) and find(StringRef).
Also, regroup functions.

llvm-svn: 78712
2009-08-11 20:47:15 +00:00
Chris Lattner
e024b843cd add a simple back() method to StringRef.
llvm-svn: 78544
2009-08-10 00:44:02 +00:00
Daniel Dunbar
7d08944f1f Add StringRef::endswith
llvm-svn: 78197
2009-08-05 15:48:26 +00:00
Chris Lattner
8e840e942e Use the RHS length instead of the LHS length. They are both the same,
but this ends up compiling code like this:

int foo(const StringRef &R) {
  return R == "food";
}

to use a constant sized memcmp instead of a variable memcmp.

llvm-svn: 77160
2009-07-26 17:46:03 +00:00
Daniel Dunbar
b97f9fc3f5 Add StringRef::{slice, split}, two convenient string operations which are simple
and efficient on a StringRef.

llvm-svn: 77117
2009-07-26 03:18:15 +00:00
Daniel Dunbar
d247ca6f40 Define npos in a way that should make MSVC happier.
llvm-svn: 76785
2009-07-22 21:08:31 +00:00
Daniel Dunbar
338e478c65 Add missing include
llvm-svn: 76655
2009-07-21 21:33:58 +00:00