diff options
author | Ted Kremenek <kremenek@apple.com> | 2007-11-16 19:00:35 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2007-11-16 19:00:35 +0000 |
commit | f115550f6fe7ae6a06c837373a5a0246ddd24baf (patch) | |
tree | 4ef04fd14b2b07b63fbf89f9757bd814d1fec017 | |
parent | 50d7f6f620e5805d1453888b2240a44861d4076a (diff) | |
download | bcm5719-llvm-f115550f6fe7ae6a06c837373a5a0246ddd24baf.tar.gz bcm5719-llvm-f115550f6fe7ae6a06c837373a5a0246ddd24baf.zip |
Added assertion in serialization of DeclRefExprs. DeclRefExprs can only
own the decl they reference if it is a FunctionDecl. Note that his
ownership property is still considered a hack, and should be fixed.
llvm-svn: 44192
-rw-r--r-- | clang/AST/StmtSerialization.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/clang/AST/StmtSerialization.cpp b/clang/AST/StmtSerialization.cpp index 63861d2a210..24733eb7ac4 100644 --- a/clang/AST/StmtSerialization.cpp +++ b/clang/AST/StmtSerialization.cpp @@ -376,7 +376,7 @@ void DeclRefExpr::EmitImpl(Serializer& S) const { S.Emit(Loc); S.Emit(getType()); - // Some DeclRefExprs can actually hold the owning reference to a decl. + // 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. @@ -387,14 +387,19 @@ void DeclRefExpr::EmitImpl(Serializer& S) const { // needs an explicit bit indicating that it owns the the object, // or we need a different ownership model. - if (S.isRegistered(getDecl())) { - S.EmitBool(false); - S.EmitPtr(getDecl()); + 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(true); - S.EmitOwnedPtr(cast<Decl>(getDecl())); - } + S.EmitBool(false); + S.EmitPtr(d); + } } DeclRefExpr* DeclRefExpr::CreateImpl(Deserializer& D) { |