[PATCH] D22723: [ADT] Add 'consume_front' and 'consume_back' methods to StringRef which are very handy when parsing text.
George Burgess IV via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 24 16:46:05 PDT 2016
george.burgess.iv added a subscriber: george.burgess.iv.
george.burgess.iv accepted this revision.
george.burgess.iv added a reviewer: george.burgess.iv.
george.burgess.iv added a comment.
This revision is now accepted and ready to land.
LGTM with a few nits.
================
Comment at: include/llvm/ADT/StringRef.h:452
@@ +451,3 @@
+ LLVM_ATTRIBUTE_ALWAYS_INLINE
+ bool consume_front(StringRef Prefix) {
+ if (!startswith(Prefix))
----------------
Do we want `LLVM_ATTRIBUTE_UNUSED_RESULT` on these, as well?
================
Comment at: unittests/ADT/StringRefTest.cpp:337
@@ +336,3 @@
+ EXPECT_EQ("", Str);
+ EXPECT_FALSE(Str.consume_front("o"));
+}
----------------
Please add `EXPECT_TRUE(Str.consume_front(""));`
================
Comment at: unittests/ADT/StringRefTest.cpp:371
@@ +370,3 @@
+ EXPECT_EQ("", Str);
+ EXPECT_FALSE(Str.consume_back("h"));
+}
----------------
Please add `EXPECT_TRUE(Str.consume_back(""));`
https://reviews.llvm.org/D22723
More information about the llvm-commits
mailing list