[PATCH] D57935: [Sema] Make string literal init an rvalue.
Eli Friedman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 7 18:02:48 PST 2019
efriedma created this revision.
efriedma added a reviewer: rsmith.
Herald added a project: clang.
This allows substantially simplifying the expression evaluation code, because we don't have to special-case lvalues which are actually string literal initialization.
This currently throws away an optimization where we would avoid creating an array APValue for string literal initialization. If we really want to optimize this case, we should fix APValue so it can store simple arrays more efficiently, like llvm::ConstantDataArray. This shouldn't affect the memory usage for other string literals. (Not sure if this is a blocker; I don't think string literal init is common enough for this to be a serious issue, but I could be wrong.)
The change to test/CodeGenObjC/encode-test.m is a weird side-effect of these changes: we currently don't constant-evaluate arrays in C, so the strlen call shouldn't be folded, but lvalue string init managed to get around that check. I this this is fine.
Fixes https://bugs.llvm.org/show_bug.cgi?id=40430 .
Repository:
rC Clang
https://reviews.llvm.org/D57935
Files:
lib/AST/ExprConstant.cpp
lib/CodeGen/CGExprConstant.cpp
lib/Sema/SemaInit.cpp
test/AST/ast-dump-wchar.cpp
test/CodeGenObjC/encode-test.m
test/SemaCXX/constant-expression-cxx11.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57935.185906.patch
Type: text/x-patch
Size: 8747 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190208/1c0b0db8/attachment.bin>
More information about the cfe-commits
mailing list