[PATCH] D24697: [support] Add StringRef::withNullAsEmpty
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 16 19:58:01 PDT 2016
zturner created this revision.
zturner added reviewers: chandlerc, majnemer.
zturner added a subscriber: llvm-commits.
This almost doesn't seem worthy of review, but since `StringRef` is kinda fundamental, I'll throw it up just in case.
https://reviews.llvm.org/D24697
Files:
include/llvm/ADT/StringRef.h
Index: include/llvm/ADT/StringRef.h
===================================================================
--- include/llvm/ADT/StringRef.h
+++ include/llvm/ADT/StringRef.h
@@ -88,6 +88,10 @@
/*implicit*/ StringRef(const std::string &Str)
: Data(Str.data()), Length(Str.length()) {}
+ static StringRef withNullAsEmpty(const char *data) {
+ return StringRef(data ? data : "");
+ }
+
/// @}
/// @name Iterators
/// @{
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24697.71724.patch
Type: text/x-patch
Size: 453 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160917/a96529fe/attachment.bin>
More information about the llvm-commits
mailing list