[llvm-dev] RFC: Constructing StringRefs at compile time

Malcolm Parsons via llvm-dev llvm-dev at lists.llvm.org
Tue Nov 29 02:20:22 PST 2016


On 28 November 2016 at 20:51, Zachary Turner via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> The basic idea here is that you introduce a StringLiteral class and anywhere
> you want to use a global constructor, you make sure to declare a constexpr
> array instead of a normal array, and you make it of type StringLiteral.

I prefer constexpr llvm_strlen() over StringLiteral because it doesn't
require code changes outside StringRef - all StringRefs constructed
from a literal can benefit.  But there are concerns about MSVC.
I prefer StringLiteral over UDL because the type requires code
changes, but the values don't.
I prefer StringLiteral over explicit StringRef constructor because it's safer.

-- 
Malcolm Parsons


More information about the llvm-dev mailing list