Benjamin Kramer
f6c0615b06
Retire llvm::array_endof in favor of non-member std::end.
...
While there make array_lengthof constexpr if we have support for it.
llvm-svn: 206112
2014-04-12 16:15:53 +00:00
Nick Kledzik
d2da6e7c22
Fix layering StringRef copy using BumpPtrAllocator.
...
Now to copy a string into a BumpPtrAllocator and get a StringRef to the copy:
StringRef myCopy = myStr.copy(myAllocator);
llvm-svn: 200885
2014-02-05 22:22:56 +00:00
Alp Toker
b29938426f
Roll back the ConstStringRef change for now
...
There are a couple of interesting things here that we want to check over
(particularly the expecting asserts in StringRef) and get right for general use
in ADT so hold back on this one. For clang we have a workable templated
solution to use in the meanwhile.
This reverts commit r200187.
llvm-svn: 200194
2014-01-27 05:24:39 +00:00
Alp Toker
43e8630002
StringRef: Extend constexpr capabilities and introduce ConstStringRef
...
(1) Add llvm_expect(), an asserting macro that can be evaluated as a constexpr
expression as well as a runtime assert or compiler hint in release builds. This
technique can be used to construct functions that are both unevaluated and
compiled depending on usage.
(2) Update StringRef using llvm_expect() to preserve runtime assertions while
extending the same checks to static asserts in C++11 builds that support the
feature.
(3) Introduce ConstStringRef, a strong subclass of StringRef that references
compile-time constant strings. It's convertible to, but not from, ordinary
StringRef and thus can be used to add compile-time safety to various interfaces
in LLVM and clang that only accept fixed inputs such as diagnostic format
strings that tend to get misused.
llvm-svn: 200187
2014-01-27 04:07:17 +00:00
Chandler Carruth
87f14b4eec
Re-sort all of the includes with ./utils/sort_includes.py so that
...
subsequent changes are easier to review. About to fix some layering
issues, and wanted to separate out the necessary churn.
Also comment and sink the include of "Windows.h" in three .inc files to
match the usage in Memory.inc.
llvm-svn: 198685
2014-01-07 11:48:04 +00:00
Rui Ueyama
75714118ae
Add {start,end}with_lower methods to StringRef.
...
startswith_lower is ocassionally useful and I think worth adding.
endwith_lower is added for completeness.
Differential Revision: http://llvm-reviews.chandlerc.com/D2041
llvm-svn: 193706
2013-10-30 18:32:26 +00:00
Rui Ueyama
d2d474fbd6
Add a few tests for StringRef::{start,end}with.
...
llvm-svn: 193550
2013-10-28 22:42:54 +00:00
Joerg Sonnenberger
d6a76ffd81
Add a Python-like join function to merge a list of strings with a
...
separator between each two elements.
llvm-svn: 189846
2013-09-03 20:43:54 +00:00
Chandler Carruth
f413c260cc
Sort the #include lines for unittest/...
...
llvm-svn: 169250
2012-12-04 10:23:08 +00:00
Nick Kledzik
df402d7821
Use unsigned long long instead of uin64_t for OS where that matters.
...
llvm-svn: 165147
2012-10-03 19:27:25 +00:00
Benjamin Kramer
c4738f8eac
Don't call getAsUnsignedInteger directly, it fails to compile if uint64_t is not "unsigned long long".
...
while there add more test cases.
llvm-svn: 165140
2012-10-03 18:54:36 +00:00
Nick Kledzik
9057d55506
Add getAsUnsignedInteger test case that checks that known bad values are rejected
...
llvm-svn: 165136
2012-10-03 18:15:27 +00:00
Michael J. Spencer
6161587c9f
[Support/StringRef] Add find_last_not_of and {r,l,}trim.
...
llvm-svn: 156652
2012-05-11 22:08:50 +00:00
Michael J. Spencer
a979afa64b
Fix warnings.
...
llvm-svn: 152522
2012-03-11 00:51:01 +00:00
Michael J. Spencer
69772efcb2
Make StringRef::getAsInteger work with all integer types. Before this change
...
it would fail with {,u}int64_t on x86-64 Linux.
This also removes code duplication.
llvm-svn: 152517
2012-03-10 23:02:54 +00:00
Chandler Carruth
b4a6f80d2e
Add generic support for hashing StringRef objects using the new hashing library.
...
llvm-svn: 152003
2012-03-04 10:55:27 +00:00
Benjamin Kramer
0c20486517
Add a bad char heuristic to StringRef::find.
...
Based on Horspool's simplified version of Boyer-Moore. We use a constant-sized table of
uint8_ts to keep cache thrashing low, needles bigger than 255 bytes are uncommon anyways.
The worst case is still O(n*m) but we do a lot better on the average case now.
llvm-svn: 142061
2011-10-15 10:08:31 +00:00
Jakob Stoklund Olesen
783b18e818
Fix a bug in compare_numeric().
...
Thanks to Alexandru Dura and Jonas Paulsson for finding it.
llvm-svn: 140859
2011-09-30 17:03:55 +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
Chris Lattner
7bdd5c3eb7
Don't infinitely recurse! Patch by Marius Wachtler!
...
llvm-svn: 124366
2011-01-27 07:35:27 +00:00
Benjamin Kramer
7dcd303d9c
StringRef::compare_numeric also differed from StringRef::compare for characters > 127.
...
llvm-svn: 112189
2010-08-26 15:25:35 +00:00
Benjamin Kramer
25003daf90
Do unsigned char comparisons in StringRef::compare_lower to be more consistent with compare in corner cases.
...
llvm-svn: 112185
2010-08-26 14:21:08 +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
Benjamin Kramer
9e60957f54
Silence compiler warning.
...
warning: comparison between signed and unsigned integer expressions
llvm-svn: 92359
2009-12-31 16:27:13 +00:00
Douglas Gregor
c4174c69ea
Document the edit-distance algorithm used in StringRef, switch it over
...
to SmallVector, and add a unit test.
llvm-svn: 92340
2009-12-31 04:24:34 +00:00
Douglas Gregor
1dafbbc020
Move the two definitions of operator<< into namespace llvm, so they
...
will be found by argument-dependent lookup. As with the previous
commit, GCC is allowing ill-formed code.
llvm-svn: 92146
2009-12-24 21:15:37 +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
891fbcdb60
Reenable Split2 StringRef test with Apple gcc.
...
llvm-svn: 89357
2009-11-19 16:04:41 +00:00
Daniel Dunbar
e36c429c3b
"XFAIL" the Split2 StringReft test with Apple gcc, which miscompiles it.
...
- I plan on fixing/workarounding this, but until then I'd like the bots to stay
green.
llvm-svn: 89077
2009-11-17 09:29:59 +00:00
Rafael Espindola
bece8d9ae7
Distinguish "a," from "a". The first one splits into "a" + "" and the second one into
...
"a" + 0.
llvm-svn: 87084
2009-11-13 04:55:09 +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
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
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
f4e8af6ecc
StringRef: Add find(char) and find(StringRef).
...
Also, regroup functions.
llvm-svn: 78712
2009-08-11 20:47:15 +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
6bbe0f1151
Support writing a StringRef to a raw_ostream directly.
...
llvm-svn: 76754
2009-07-22 17:13:20 +00:00
Daniel Dunbar
30c92a0aee
Add StringRef::{substr, startswith}.
...
llvm-svn: 76559
2009-07-21 09:18:49 +00:00
Daniel Dunbar
8ab30670cc
Add StringRef class, with fixes.
...
llvm-svn: 76543
2009-07-21 07:28:51 +00:00