]> granicus.if.org Git - clang/commit
[Sema] Make string literal init an rvalue.
authorEli Friedman <efriedma@quicinc.com>
Fri, 8 Feb 2019 21:18:46 +0000 (21:18 +0000)
committerEli Friedman <efriedma@quicinc.com>
Fri, 8 Feb 2019 21:18:46 +0000 (21:18 +0000)
commit4e215e73ed6b499f3ccf23263c96cd188e0eda2c
tree29b5321e2de536a294ad67612975e5c262737b2a
parent07f37e8338ca2324d734ea1afed4c0f456c3d787
[Sema] Make string literal init an rvalue.

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 .

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@353569 91177308-0d34-0410-b5e6-96231b3b80d8
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