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

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 30 21:44:02 PDT 2016


chandlerc added a comment.

Thanks Pete & George, submitted with your fixes


================
Comment at: include/llvm/ADT/StringRef.h:452
@@ +451,3 @@
+    LLVM_ATTRIBUTE_ALWAYS_INLINE
+    bool consume_front(StringRef Prefix) {
+      if (!startswith(Prefix))
----------------
george.burgess.iv wrote:
> Do we want `LLVM_ATTRIBUTE_UNUSED_RESULT` on these, as well?
I suspect I'll want to just use them for optional consuming some times... But I think your suggestion is right. IF the pattern becomes anonying to make explicit, can always drop it.


Repository:
  rL LLVM

https://reviews.llvm.org/D22723





More information about the llvm-commits mailing list