| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary: Add `StringRef::rsplit(StringRef Separator)` to achieve the function of getting the tail substring according to the separator. A typical usage is to get `data` in `std::basic_string::data`.
Reviewers: mehdi_amini, zturner, beanz, xbolva00, vsk
Reviewed By: zturner, xbolva00, vsk
Subscribers: vsk, xbolva00, llvm-commits, MTC
Differential Revision: https://reviews.llvm.org/D47406
llvm-svn: 334283
|
|
|
|
|
|
| |
We want to check that we can assign to an lvalue here, not a prvalue.
llvm-svn: 324152
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The method IEEEFloat::convertFromStringSpecials() does not recognize
the "+Inf" and "-Inf" strings but these strings are printed for
the double Infinities by the IEEEFloat::toString().
This patch adds the "+Inf" and "-Inf" strings to the list of recognized
patterns in IEEEFloat::convertFromStringSpecials().
Re-landing after fix.
Reviewers: sberg, bogner, majnemer, timshen, rnk, skatkov, gottesmm, bkramer, scanon, anna
Reviewed By: anna
Subscribers: mkazantsev, FlameTop, llvm-commits, reames, apilipenko
Differential Revision: https://reviews.llvm.org/D38030
llvm-svn: 321054
|
|
|
|
|
|
| |
braces to avoid ambiguous 'else'. NFC.
llvm-svn: 305506
|
|
|
|
|
|
| |
Example strings taken from here: http://www.let.rug.nl/~kleiweg/lev/
llvm-svn: 300312
|
|
|
|
| |
llvm-svn: 298427
|
|
|
|
|
|
| |
Differential Revision: https://reviews.llvm.org/D29918
llvm-svn: 295089
|
|
|
|
|
|
|
|
|
|
|
| |
StringLiteral is a wrapper around a string literal useful for
replacing global tables of char arrays with global tables of
StringRefs that can initialized in a constexpr context, avoiding
the invocation of a global constructor.
Differential Revision: https://reviews.llvm.org/D27686
llvm-svn: 289551
|
|
|
|
|
|
| |
Differential Revision: https://reviews.llvm.org/D25299
llvm-svn: 286724
|
|
|
|
| |
llvm-svn: 286141
|
|
|
|
| |
llvm-svn: 282348
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This adds 4 new functions to StringRef, which can be used to
take or drop characters while a certain condition is met, or
until a certain condition is met. They are:
take_while - Return characters until a condition is not met.
take_until - Return characters until a condition is met.
drop_while - Remove characters until a condition is not met.
drop_until - Remove characters until a condition is met.
Internally, all of these functions delegate to two additional
helper functions which can be used to search for the position
of a character meeting or not meeting a condition, which are:
find_if - Find the first character matching a predicate.
find_if_not - Find the first character not matching a predicate.
Differential Revision: https://reviews.llvm.org/D24842
llvm-svn: 282346
|
|
|
|
| |
llvm-svn: 282183
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A recent patch added support for consumeInteger() and made
getAsInteger delegate to this function. A few buildbots are
failing as a result with an assertion failure. On a hunch,
I tested what happens if I call getAsInteger() on an empty
string, and sure enough it crashes the same way that the
buildbots are crashing.
I confirmed that getAsInteger() on an empty string did not
crash before my patch, so I suspect this to be the cause.
I also added a unit test for the empty string.
llvm-svn: 282170
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
StringRef::getInteger() exists and treats the entire string as
an integer of the specified radix, failing if any invalid characters
are encountered or the number overflows.
Sometimes you might have something like "123456foo" and you want
to get the number 123456 and leave the string "foo" remaining.
This is similar to what would be possible by using the standard
runtime library functions strtoul et al and specifying an end
pointer.
This patch adds consumeInteger(), which does exactly that. It
consumes as much as possible until an invalid character is found,
and modifies the StringRef in place so that upon return only
the portion of the StringRef after the number remains.
Differential Revision: https://reviews.llvm.org/D24778
llvm-svn: 282164
|
|
|
|
|
|
|
| |
Reviewed By: majnemer, rnk
Differential Revision: https://reviews.llvm.org/D23965
llvm-svn: 280114
|
|
|
|
|
|
|
|
|
|
|
| |
are very handy when parsing text.
They are essentially a combination of startswith and a self-modifying
drop_front, or endswith and drop_back respectively.
Differential Revision: https://reviews.llvm.org/D22723
llvm-svn: 277288
|
|
|
|
|
|
|
|
|
|
|
| |
The BumpPtrAllocator currently doesn't handle zero length allocations well.
The discussion for how to fix that is ongoing. However, there's no need
for StringRef::copy to actually allocate anything here anyway, so just
return StringRef() when we get a zero length copy.
Reviewed by David Blaikie
llvm-svn: 264201
|
|
|
|
|
|
|
|
|
| |
Add support for trimming a single kind of character from a StringRef.
This makes the common case of trimming null bytes much neater. It's also
probably a bit speedier too, since it avoids creating a std::bitset in
find_{first,last}_not_of.
llvm-svn: 260925
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
with the StringRef::split method when used with a MaxSplit argument
other than '-1' (which nobody really does today, but which should
actually work).
The spec claimed both to split up to MaxSplit times, but also to append
<= MaxSplit strings to the vector. One of these doesn't make sense.
Given the name "MaxSplit", let's go with it being a max over how many
*splits* occur, which means the max on how many strings get appended is
MaxSplit+1. I'm not actually sure the implementation correctly provided
this logic either, as it used a really opaque loop structure.
The implementation was also playing weird games with nullptr in the data
field to try to rely on a totally opaque hidden property of the split
method that returns a pair. Nasty IMO.
Replace all of this with what is (IMO) simpler code that doesn't use the
pair returning split method, and instead just finds each separator and
appends directly. I think this is a lot easier to read, and it most
definitely matches the spec. Added some tests that exercise the corner
cases around StringRef() and StringRef("") that all now pass.
I'll start using this in code in the next commit.
llvm-svn: 247249
|
|
|
|
|
|
|
|
|
|
|
| |
on StringRef. Finding and splitting on a single character is
substantially faster than doing it on even a single character StringRef
-- we immediately get to a *very* tuned memchr call this way.
Even nicer, we get to this even in a debug build, shaving 18% off the
runtime of TripleTest.Normalization, helping PR23676 some more.
llvm-svn: 247244
|
|
|
|
|
|
| |
While there make array_lengthof constexpr if we have support for it.
llvm-svn: 206112
|
|
|
|
|
|
|
|
|
| |
Now to copy a string into a BumpPtrAllocator and get a StringRef to the copy:
StringRef myCopy = myStr.copy(myAllocator);
llvm-svn: 200885
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(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
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
| |
llvm-svn: 193550
|
|
|
|
|
|
| |
separator between each two elements.
llvm-svn: 189846
|
|
|
|
| |
llvm-svn: 169250
|
|
|
|
| |
llvm-svn: 165147
|
|
|
|
|
|
|
|
| |
not "unsigned long long".
while there add more test cases.
llvm-svn: 165140
|
|
|
|
|
|
| |
rejected
llvm-svn: 165136
|
|
|
|
| |
llvm-svn: 156652
|
|
|
|
| |
llvm-svn: 152522
|
|
|
|
|
|
|
|
| |
it would fail with {,u}int64_t on x86-64 Linux.
This also removes code duplication.
llvm-svn: 152517
|
|
|
|
| |
llvm-svn: 152003
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
| |
Thanks to Alexandru Dura and Jonas Paulsson for finding it.
llvm-svn: 140859
|
|
|
|
|
|
| |
and it is just as easy to use StringRef::substr() preceding StringRef::compare() to achieve the same thing.
llvm-svn: 130430
|
|
|
|
|
|
| |
strncmp(). Unit tests also included.
llvm-svn: 129582
|
|
|
|
| |
llvm-svn: 124366
|
|
|
|
|
|
| |
characters > 127.
llvm-svn: 112189
|
|
|
|
|
|
| |
consistent with compare in corner cases.
llvm-svn: 112185
|
|
|
|
|
|
|
| |
This means that our Registers are now ordered R7, R8, R9, R10, R12, ...
Not R1, R10, R11, R12, R2, R3, ...
llvm-svn: 104745
|
|
|
|
|
| |
warning: comparison between signed and unsigned integer expressions
llvm-svn: 92359
|
|
|
|
|
|
| |
to SmallVector, and add a unit test.
llvm-svn: 92340
|
|
|
|
|
|
|
| |
will be found by argument-dependent lookup. As with the previous
commit, GCC is allowing ill-formed code.
llvm-svn: 92146
|
|
|
|
|
|
| |
bit more verbose, but optimize to much shorter code.
llvm-svn: 91817
|
|
|
|
| |
llvm-svn: 89357
|