[PATCH] D27686: Add llvm::StringLiteral
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 12 19:14:56 PST 2016
efriedma added inline comments.
================
Comment at: include/llvm/ADT/StringRef.h:90
- assert((data || length == 0) &&
- "StringRef cannot be built from a NULL argument with non-null length");
- }
----------------
mehdi_amini wrote:
> Too bad we're losing the assert, but I see why. An alternative is another (possibly protected) ctor that would be constexpr and used by `StringLiteral`
Stupid trick to save the assert:
/*implicit*/ constexpr StringRef(const char *data, long length)
: Data(data), Length((data || length == 0) ? length : (assert(0 && "Bad StringRef"), 0)) { }
https://reviews.llvm.org/D27686
More information about the llvm-commits
mailing list