jrtc27 wrote: > Side note: my motivation in removing StringLiteral is that it is a bit of a > footgun. While the original https://reviews.llvm.org/D27686 clearly states > that it's intended for arrays of string literals, where it would not be > possible anyway to store each literal as a true literal, usage has crept to > many cases where StringLiteral is used instead of const char[] where the > latter would be possible, for individual string literals. That's a problem as > evaluating the address of a string literal uses a relocation. See > https://github.com/iree-org/iree/issues/19529. So if we want to keep > StringLiteral we need to be clear exactly what it's good and not good for. It > is good to work around MSVC not constant-evaluating strlen, and it is only to > be used where we can't use a true const char[] literal, such as arrays of > string literals.
const char[] allocates storage for the string contents though, so takes up space in memory if the string can be merged with others at compile or link time. There are multiple things being traded off here, and PDE vs PIC/PIE complicates the story further. So it's not just as simple as "use const char[] whenever you can". https://github.com/llvm/llvm-project/pull/122366 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits