1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-02-01 13:11:39 +01:00

Re-add the assert to StringRef's const char *, length constructor.

By putting the assert behind a conditional in the initializer list
we can ensure that it will still work in a constexpr context as
the else branch of the ternary operator won't be examined unless
the condition fails.

llvm-svn: 290188
This commit is contained in:
Zachary Turner 2016-12-20 17:57:56 +00:00
parent c3ab64d2bd
commit 86230b3225

View File

@ -85,7 +85,9 @@ namespace llvm {
/// Construct a string ref from a pointer and length.
LLVM_ATTRIBUTE_ALWAYS_INLINE
/*implicit*/ constexpr StringRef(const char *data, size_t length)
: Data(data), Length(length) {}
: Data(data),
Length((data || length == 0) ? length : (assert(0 && "Bad StringRef"),
length)) {}
/// Construct a string ref from an std::string.
LLVM_ATTRIBUTE_ALWAYS_INLINE