[PATCH] D27686: Add llvm::StringLiteral
Zachary Turner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 12 20:10:31 PST 2016
zturner 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");
- }
----------------
efriedma wrote:
> 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)) { }
>
>
Won't this still complain that `assert` is not a constant expression and thus can't be used in a `constexpr` function?
https://reviews.llvm.org/D27686
More information about the llvm-commits
mailing list