llvm-project
15a63d4e - [llvm][ADT] Add llvm::StringRef::consume_front(char) overload (#172832)

Commit
2 days ago
[llvm][ADT] Add llvm::StringRef::consume_front(char) overload (#172832) This patch adds support for consuming a `char` from the front of a `StringRef`. Most of the time a user wanting to consume a single character off the front can just wrap the character in a string literal (i.e., `consume_front("a")`). But this doesn't work if we don't have a `char` literal, but instead a variable of type `char`. I.e., `char c = 'a'; str.consume_front(c)`. There's at least one helper in LLDB that does this. Also there's plenty of example of `consume_front` being passed a single character via string literal. This patch adds the `char` overload. We already have a `starts_with(char)` overload, so there's at least some related precedent.
Author
Parents
Loading