[PATCH] D26332: Add a user-defined literal for StringRef
Malcolm Parsons via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 6 09:14:37 PST 2016
malcolm.parsons added inline comments.
================
Comment at: include/llvm/ADT/StringRef.h:74
/// Construct an empty string ref.
- /*implicit*/ StringRef() : Data(nullptr), Length(0) {}
+ /*implicit*/ constexpr StringRef() : Data(nullptr), Length(0) {}
----------------
mehdi_amini wrote:
> Is this related to this patch?
No.
================
Comment at: include/llvm/ADT/StringRef.h:88
/*implicit*/ StringRef(const char *data, size_t length)
- : Data(data), Length(length) {
- assert((data || length == 0) &&
- "StringRef cannot be built from a NULL argument with non-null length");
- }
+ : Data(data), Length(data ? length : 0) {}
----------------
mehdi_amini wrote:
> same.
Yes. This constructor needs to be constexpr, so that the constexpr UDL can call it. It can't use assert in C++11.
================
Comment at: lib/CodeGen/AsmPrinter/DIEHash.cpp:41
- return StringRef("");
+ return ""_sr;
}
----------------
mehdi_amini wrote:
> Why not just `return "";`?
I wonder this about the original.
These transformations were made with sed.
https://reviews.llvm.org/D26332
More information about the llvm-commits
mailing list