[PATCH] Fix representation of compound literals for C++ objects with destructors
Jordan Rose
jordan_rose at apple.com
Fri May 3 18:41:52 PDT 2013
Hi doug.gregor,
Previously, this compound literal expression (a GNU extension in C++):
(AggregateWithDtor){1, 2}
resulted in this AST:
|-CXXBindTemporaryExpr [...] 'struct Point' (CXXTemporary [...])
|-CompoundLiteralExpr [...] 'struct AggregateWithDtor'
|-CXXBindTemporaryExpr [...] 'struct AggregateWithDtor' (CXXTemporary [
|-InitListExpr [...] 'struct AggregateWithDtor'
|-IntegerLiteral [...] 'int' 1
|-IntegerLiteral [...] 'int' 2
The InitListExpr is really part of the CompoundLiteralExpr, not an object in its own right. By introducing a new entity initialization kind in Sema specifically for compound literals, we avoid the treatment of the inner InitListExpr as a temporary.
|-CXXBindTemporaryExpr [...] 'struct Point' (CXXTemporary [...])
|-CompoundLiteralExpr [...] 'struct AggregateWithDtor'
|-InitListExpr [...] 'struct AggregateWithDtor'
|-IntegerLiteral [...] 'int' 1
|-IntegerLiteral [...] 'int' 2
In cases where the initialization is not aggregate initialization but rather invoking a constructor with list-initialization syntax, the inner expression will be CXXTemporaryObjectExpr rather than InitListExpr, as it was before this patch. The CXXBindTemporaryExpr is still outside the CompoundLiteralExpr.
http://llvm-reviews.chandlerc.com/D742
Files:
include/clang/Sema/Initialization.h
lib/Sema/SemaExpr.cpp
lib/Sema/SemaInit.cpp
test/SemaCXX/compound-literal.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D742.1.patch
Type: text/x-patch
Size: 8618 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130503/a6f9dc60/attachment.bin>
More information about the cfe-commits
mailing list