aboutsummaryrefslogtreecommitdiff
path: root/lib/Serialization
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2012-02-16 10:58:10 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2012-02-16 10:58:10 +0000
commit5f688f4b15d02aa7ad159c46b1f78fe59d412f12 (patch)
tree8b67f7660948832957b76569958a3bda8d15fe75 /lib/Serialization
parent13ca53473fd98520b236fb2dbfce228007ac4bed (diff)
Make CXXNewExpr contain only a single initialier, and not hold the used constructor itself.
Holding the constructor directly makes no sense when list-initialized arrays come into play. The constructor is now held in a CXXConstructExpr, if construction is what is done. The new design can also distinguish properly between list-initialization and direct-initialization, as well as implicit default-initialization constructors and explicit value-initialization constructors. Finally, doing it this way removes redundance from the AST because CXXNewExpr doesn't try to handle both the allocation and the initialization responsibilities. This breaks the static analysis of new expressions. I've filed PR12014 to track this. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150682 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization')
-rw-r--r--lib/Serialization/ASTReaderStmt.cpp15
-rw-r--r--lib/Serialization/ASTWriterStmt.cpp13
2 files changed, 10 insertions, 18 deletions
diff --git a/lib/Serialization/ASTReaderStmt.cpp b/lib/Serialization/ASTReaderStmt.cpp
index 361ff3f483..8b85976bf4 100644
--- a/lib/Serialization/ASTReaderStmt.cpp
+++ b/lib/Serialization/ASTReaderStmt.cpp
@@ -1167,27 +1167,24 @@ void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
VisitExpr(E);
E->GlobalNew = Record[Idx++];
- E->Initializer = Record[Idx++];
- E->UsualArrayDeleteWantsSize = Record[Idx++];
bool isArray = Record[Idx++];
- E->setHadMultipleCandidates(Record[Idx++]);
+ E->UsualArrayDeleteWantsSize = Record[Idx++];
unsigned NumPlacementArgs = Record[Idx++];
- unsigned NumCtorArgs = Record[Idx++];
+ E->StoredInitializationStyle = Record[Idx++];
E->setOperatorNew(ReadDeclAs<FunctionDecl>(Record, Idx));
E->setOperatorDelete(ReadDeclAs<FunctionDecl>(Record, Idx));
- E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx));
E->AllocatedTypeInfo = GetTypeSourceInfo(Record, Idx);
SourceRange TypeIdParens;
TypeIdParens.setBegin(ReadSourceLocation(Record, Idx));
TypeIdParens.setEnd(ReadSourceLocation(Record, Idx));
E->TypeIdParens = TypeIdParens;
E->StartLoc = ReadSourceLocation(Record, Idx);
- E->EndLoc = ReadSourceLocation(Record, Idx);
- E->ConstructorLParen = ReadSourceLocation(Record, Idx);
- E->ConstructorRParen = ReadSourceLocation(Record, Idx);
+ SourceRange DirectInitRange;
+ DirectInitRange.setBegin(ReadSourceLocation(Record, Idx));
+ DirectInitRange.setEnd(ReadSourceLocation(Record, Idx));
E->AllocateArgsArray(Reader.getContext(), isArray, NumPlacementArgs,
- NumCtorArgs);
+ E->StoredInitializationStyle != 0);
// Install all the subexpressions.
for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
diff --git a/lib/Serialization/ASTWriterStmt.cpp b/lib/Serialization/ASTWriterStmt.cpp
index f6cfd01341..0ba413df72 100644
--- a/lib/Serialization/ASTWriterStmt.cpp
+++ b/lib/Serialization/ASTWriterStmt.cpp
@@ -1158,25 +1158,20 @@ void ASTStmtWriter::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
void ASTStmtWriter::VisitCXXNewExpr(CXXNewExpr *E) {
VisitExpr(E);
Record.push_back(E->isGlobalNew());
- Record.push_back(E->hasInitializer());
- Record.push_back(E->doesUsualArrayDeleteWantSize());
Record.push_back(E->isArray());
- Record.push_back(E->hadMultipleCandidates());
+ Record.push_back(E->doesUsualArrayDeleteWantSize());
Record.push_back(E->getNumPlacementArgs());
- Record.push_back(E->getNumConstructorArgs());
+ Record.push_back(E->StoredInitializationStyle);
Writer.AddDeclRef(E->getOperatorNew(), Record);
Writer.AddDeclRef(E->getOperatorDelete(), Record);
- Writer.AddDeclRef(E->getConstructor(), Record);
Writer.AddTypeSourceInfo(E->getAllocatedTypeSourceInfo(), Record);
Writer.AddSourceRange(E->getTypeIdParens(), Record);
Writer.AddSourceLocation(E->getStartLoc(), Record);
- Writer.AddSourceLocation(E->getEndLoc(), Record);
- Writer.AddSourceLocation(E->getConstructorLParen(), Record);
- Writer.AddSourceLocation(E->getConstructorRParen(), Record);
+ Writer.AddSourceRange(E->getDirectInitRange(), Record);
for (CXXNewExpr::arg_iterator I = E->raw_arg_begin(), e = E->raw_arg_end();
I != e; ++I)
Writer.AddStmt(*I);
-
+
Code = serialization::EXPR_CXX_NEW;
}