aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/StmtSerialization.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-08-06 15:50:59 +0000
committerTed Kremenek <kremenek@apple.com>2008-08-06 15:50:59 +0000
commita1a78246b1be7e64232af18941333eeb0731a1b9 (patch)
treee4db6f1aa44ce73c68ca2f74c8b8c66069cc2e47 /lib/AST/StmtSerialization.cpp
parent82397139c47a41675ab337290f6dca7644e541d5 (diff)
Reorder serialization methods.
When serializing DeclStmt, encode a bit indicating whether or not the DeclStmt owns the Decl. This is an interim solution. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54410 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/StmtSerialization.cpp')
-rw-r--r--lib/AST/StmtSerialization.cpp55
1 files changed, 35 insertions, 20 deletions
diff --git a/lib/AST/StmtSerialization.cpp b/lib/AST/StmtSerialization.cpp
index aad7e81600..845f9024b1 100644
--- a/lib/AST/StmtSerialization.cpp
+++ b/lib/AST/StmtSerialization.cpp
@@ -470,11 +470,33 @@ ContinueStmt* ContinueStmt::CreateImpl(Deserializer& D, ASTContext& C) {
}
void DeclStmt::EmitImpl(Serializer& S) const {
- // FIXME: special handling for struct decls.
- S.EmitOwnedPtr(getDecl());
S.Emit(StartLoc);
S.Emit(EndLoc);
+
+ // FIXME: Clean up ownership of the Decl.
+ const ScopedDecl* d = getDecl();
+
+ if (!S.isRegistered(d)) {
+ S.EmitBool(true);
+ S.EmitOwnedPtr(d);
+ }
+ else {
+ S.EmitBool(false);
+ S.EmitPtr(d);
+ }
+}
+
+DeclStmt* DeclStmt::CreateImpl(Deserializer& D, ASTContext& C) {
+ SourceLocation StartLoc = SourceLocation::ReadVal(D);
+ SourceLocation EndLoc = SourceLocation::ReadVal(D);
+
+ bool OwnsDecl = D.ReadBool();
+ ScopedDecl* decl = cast<ScopedDecl>(OwnsDecl ? D.ReadOwnedPtr<Decl>(C)
+ : D.ReadPtr<Decl>());
+
+ return new DeclStmt(decl, StartLoc, EndLoc);
}
+
void DeclRefExpr::EmitImpl(Serializer& S) const {
S.Emit(Loc);
@@ -520,24 +542,6 @@ DeclRefExpr* DeclRefExpr::CreateImpl(Deserializer& D, ASTContext& C) {
return new DeclRefExpr(decl,T,Loc);
}
-void ObjCSuperRefExpr::EmitImpl(Serializer& S) const {
- S.Emit(Loc);
- S.Emit(getType());
-}
-
-ObjCSuperRefExpr* ObjCSuperRefExpr::CreateImpl(Deserializer& D, ASTContext& C) {
- SourceLocation Loc = SourceLocation::ReadVal(D);
- QualType T = QualType::ReadVal(D);
- return new ObjCSuperRefExpr(T, Loc);
-}
-
-DeclStmt* DeclStmt::CreateImpl(Deserializer& D, ASTContext& C) {
- ScopedDecl* decl = cast<ScopedDecl>(D.ReadOwnedPtr<Decl>(C));
- SourceLocation StartLoc = SourceLocation::ReadVal(D);
- SourceLocation EndLoc = SourceLocation::ReadVal(D);
- return new DeclStmt(decl, StartLoc, EndLoc);
-}
-
void DefaultStmt::EmitImpl(Serializer& S) const {
S.Emit(DefaultLoc);
S.EmitOwnedPtr(getSubStmt());
@@ -1101,6 +1105,17 @@ ObjCStringLiteral* ObjCStringLiteral::CreateImpl(Deserializer& D, ASTContext& C)
return new ObjCStringLiteral(String,T,L);
}
+void ObjCSuperRefExpr::EmitImpl(Serializer& S) const {
+ S.Emit(Loc);
+ S.Emit(getType());
+}
+
+ObjCSuperRefExpr* ObjCSuperRefExpr::CreateImpl(Deserializer& D, ASTContext& C) {
+ SourceLocation Loc = SourceLocation::ReadVal(D);
+ QualType T = QualType::ReadVal(D);
+ return new ObjCSuperRefExpr(T, Loc);
+}
+
//===----------------------------------------------------------------------===//
// C++ Serialization
//===----------------------------------------------------------------------===//