diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-01-20 01:17:11 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-01-20 01:17:11 +0000 |
commit | 4afa39deaa245592977136d367251ee2c173dd8d (patch) | |
tree | b147c76b69b1dc48d42e3cc3080554515db96d94 /lib/AST/StmtSerialization.cpp | |
parent | f4f6f219423a67a969de7b3e0c28bcefdb3c0a10 (diff) |
Remove ScopedDecl, collapsing all of its functionality into Decl, so
that every declaration lives inside a DeclContext.
Moved several things that don't have names but were ScopedDecls (and,
therefore, NamedDecls) to inherit from Decl rather than NamedDecl,
including ObjCImplementationDecl and LinkageSpecDecl. Now, we don't
store empty DeclarationNames for these things, nor do we try to insert
them into DeclContext's lookup structure.
The serialization tests are temporarily disabled. We'll re-enable them
once we've sorted out the remaining ownership/serialiazation issues
between DeclContexts and TranslationUnion, DeclGroups, etc.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62562 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/StmtSerialization.cpp')
-rw-r--r-- | lib/AST/StmtSerialization.cpp | 38 |
1 files changed, 4 insertions, 34 deletions
diff --git a/lib/AST/StmtSerialization.cpp b/lib/AST/StmtSerialization.cpp index 39330ce335..8599a7aba9 100644 --- a/lib/AST/StmtSerialization.cpp +++ b/lib/AST/StmtSerialization.cpp @@ -547,45 +547,15 @@ DeclStmt* DeclStmt::CreateImpl(Deserializer& D, ASTContext& C) { void DeclRefExpr::EmitImpl(Serializer& S) const { S.Emit(Loc); S.Emit(getType()); - - // Some DeclRefExprs can actually hold the owning reference to a FunctionDecl. - // This occurs when an implicitly defined function is called, and - // the decl does not appear in the source file. We thus check if the - // decl pointer has been registered, and if not, emit an owned pointer. - - // FIXME: While this will work for serialization, it won't work for - // memory management. The only reason this works for serialization is - // because we are tracking all serialized pointers. Either DeclRefExpr - // needs an explicit bit indicating that it owns the the object, - // or we need a different ownership model. - - const Decl* d = getDecl(); - - if (!S.isRegistered(d)) { - assert (isa<FunctionDecl>(d) - && "DeclRefExpr can only own FunctionDecls for implicitly def. funcs."); - - S.EmitBool(true); - S.EmitOwnedPtr(d); - } - else { - S.EmitBool(false); - S.EmitPtr(d); - } + S.EmitPtr(getDecl()); } DeclRefExpr* DeclRefExpr::CreateImpl(Deserializer& D, ASTContext& C) { SourceLocation Loc = SourceLocation::ReadVal(D); QualType T = QualType::ReadVal(D); - bool OwnsDecl = D.ReadBool(); - NamedDecl* decl; - - if (!OwnsDecl) - D.ReadPtr(decl,false); // No backpatching. - else - decl = cast<NamedDecl>(D.ReadOwnedPtr<Decl>(C)); - - return new DeclRefExpr(decl,T,Loc); + DeclRefExpr *DRE = new DeclRefExpr(0, T, Loc); + D.ReadPtr(DRE->D); + return DRE; } void DefaultStmt::EmitImpl(Serializer& S) const { |