History log of /llvm-project/llvm/unittests/ADT/StringRefTest.cpp (Results 51 – 75 of 99)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 65fd2fc7 22-Sep-2016 Zachary Turner <zturner@google.com>

[Support] Add StringRef::consumeInteger.

StringRef::getInteger() exists and treats the entire string as
an integer of the specified radix, failing if any invalid characters
are encountered or the nu

[Support] Add StringRef::consumeInteger.

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

show more ...


# 84fc059e 30-Aug-2016 Zachary Turner <zturner@google.com>

Add StringRef::take_front and StringRef::take_back

Reviewed By: majnemer, rnk
Differential Revision: https://reviews.llvm.org/D23965

llvm-svn: 280114


Revision tags: llvmorg-3.9.0, llvmorg-3.9.0-rc3, llvmorg-3.9.0-rc2
# 974c67e7 31-Jul-2016 Chandler Carruth <chandlerc@gmail.com>

[ADT] Add 'consume_front' and 'consume_back' methods to StringRef which
are very handy when parsing text.

They are essentially a combination of startswith and a self-modifying
drop_front, or endswit

[ADT] Add 'consume_front' and 'consume_back' methods to StringRef which
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

show more ...


Revision tags: llvmorg-3.9.0-rc1, llvmorg-3.8.1, llvmorg-3.8.1-rc1
# b08d9060 23-Mar-2016 Pete Cooper <peter_cooper@apple.com>

StringRef::copy shouldn't allocate anything for length 0 strings.

The BumpPtrAllocator currently doesn't handle zero length allocations well.
The discussion for how to fix that is ongoing. However,

StringRef::copy shouldn't allocate anything for length 0 strings.

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

show more ...


Revision tags: llvmorg-3.8.0, llvmorg-3.8.0-rc3
# f114b40c 16-Feb-2016 Vedant Kumar <vsk@apple.com>

[ADT] Add StringRef::{l,r}trim(char) overloads (NFC)

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
pr

[ADT] Add StringRef::{l,r}trim(char) overloads (NFC)

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

show more ...


Revision tags: llvmorg-3.8.0-rc2, llvmorg-3.8.0-rc1, llvmorg-3.7.1, llvmorg-3.7.1-rc2, llvmorg-3.7.1-rc1
# 4425c91d 10-Sep-2015 Chandler Carruth <chandlerc@gmail.com>

[ADT] Fix a confusing interface spec and some annoying peculiarities
with the StringRef::split method when used with a MaxSplit argument
other than '-1' (which nobody really does today, but which sho

[ADT] Fix a confusing interface spec and some annoying peculiarities
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

show more ...


# 47712172 10-Sep-2015 Chandler Carruth <chandlerc@gmail.com>

[ADT] Add a single-character version of the small vector split routine
on StringRef. Finding and splitting on a single character is
substantially faster than doing it on even a single character Strin

[ADT] Add a single-character version of the small vector split routine
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

show more ...


Revision tags: llvmorg-3.7.0, llvmorg-3.7.0-rc4, llvmorg-3.7.0-rc3, studio-1.4, llvmorg-3.7.0-rc2, llvmorg-3.7.0-rc1, llvmorg-3.6.2, llvmorg-3.6.2-rc1, llvmorg-3.6.1, llvmorg-3.6.1-rc1, llvmorg-3.5.2, llvmorg-3.5.2-rc1, llvmorg-3.6.0, llvmorg-3.6.0-rc4, llvmorg-3.6.0-rc3, llvmorg-3.6.0-rc2, llvmorg-3.6.0-rc1, llvmorg-3.5.1, llvmorg-3.5.1-rc2, llvmorg-3.5.1-rc1, llvmorg-3.5.0, llvmorg-3.5.0-rc4, llvmorg-3.5.0-rc3, llvmorg-3.5.0-rc2, llvmorg-3.5.0-rc1, llvmorg-3.4.2, llvmorg-3.4.2-rc1, llvmorg-3.4.1, llvmorg-3.4.1-rc2
# 502b9e1d 12-Apr-2014 Benjamin Kramer <benny.kra@googlemail.com>

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


Revision tags: llvmorg-3.4.1-rc1
# 4d6d9812 05-Feb-2014 Nick Kledzik <kledzik@apple.com>

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


# 17d4e98e 27-Jan-2014 Alp Toker <alp@nuanti.com>

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
i

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

show more ...


# 042f41b0 27-Jan-2014 Alp Toker <alp@nuanti.com>

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 com

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

show more ...


# 8a8cd2ba 07-Jan-2014 Chandler Carruth <chandlerc@gmail.com>

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 com

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

show more ...


Revision tags: llvmorg-3.4.0, llvmorg-3.4.0-rc3, llvmorg-3.4.0-rc2, llvmorg-3.4.0-rc1
# 00e24e48 30-Oct-2013 Rui Ueyama <ruiu@google.com>

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

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

show more ...


# b6decb0a 28-Oct-2013 Rui Ueyama <ruiu@google.com>

Add a few tests for StringRef::{start,end}with.

llvm-svn: 193550


# 6c4dc2b2 03-Sep-2013 Joerg Sonnenberger <joerg@bec.de>

Add a Python-like join function to merge a list of strings with a
separator between each two elements.

llvm-svn: 189846


Revision tags: llvmorg-3.3.1-rc1, llvmorg-3.3.0, llvmorg-3.3.0-rc3, llvmorg-3.3.0-rc2, llvmorg-3.3.0-rc1, llvmorg-3.2.0, llvmorg-3.2.0-rc3
# 130cec21 04-Dec-2012 Chandler Carruth <chandlerc@gmail.com>

Sort the #include lines for unittest/...

llvm-svn: 169250


Revision tags: llvmorg-3.2.0-rc2, llvmorg-3.2.0-rc1
# 85a62b1a 03-Oct-2012 Nick Kledzik <kledzik@apple.com>

Use unsigned long long instead of uin64_t for OS where that matters.

llvm-svn: 165147


# d95ceff0 03-Oct-2012 Benjamin Kramer <benny.kra@googlemail.com>

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


# f8a75eef 03-Oct-2012 Nick Kledzik <kledzik@apple.com>

Add getAsUnsignedInteger test case that checks that known bad values are rejected

llvm-svn: 165136


Revision tags: llvmorg-3.1.0
# 93303819 11-May-2012 Michael J. Spencer <bigcheesegs@gmail.com>

[Support/StringRef] Add find_last_not_of and {r,l,}trim.

llvm-svn: 156652


Revision tags: llvmorg-3.1.0-rc3, llvmorg-3.1.0-rc2, llvmorg-3.1.0-rc1
# 914dc77d 11-Mar-2012 Michael J. Spencer <bigcheesegs@gmail.com>

Fix warnings.

llvm-svn: 152522


# cfa95f66 10-Mar-2012 Michael J. Spencer <bigcheesegs@gmail.com>

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


# ca99ad3f 04-Mar-2012 Chandler Carruth <chandlerc@gmail.com>

Add generic support for hashing StringRef objects using the new hashing library.

llvm-svn: 152003


Revision tags: llvmorg-3.0.0, llvmorg-3.0.0-rc4, llvmorg-3.0.0-rc3, llvmorg-3.0.0-rc2, llvmorg-3.0.0-rc1
# 4d681d7d 15-Oct-2011 Benjamin Kramer <benny.kra@googlemail.com>

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 byt

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

show more ...


# c874e2d8 30-Sep-2011 Jakob Stoklund Olesen <stoklund@2pi.dk>

Fix a bug in compare_numeric().

Thanks to Alexandru Dura and Jonas Paulsson for finding it.

llvm-svn: 140859


1234