void EmitOutRec(llvm::Serializer& S) const;
void ReadOutRec(llvm::Deserializer& D, ASTContext& C);
+
+ friend void Decl::Destroy(ASTContext& C);
};
/// NamespaceDecl - Represent a C++ namespace.
public:
static NamespaceDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L, IdentifierInfo *Id);
+
+ virtual void Destroy(ASTContext& C);
NamespaceDecl *getNextNamespace() {
return cast_or_null<NamespaceDecl>(getNextDeclarator());
QualType T, Expr *E,
const llvm::APSInt &V, ScopedDecl *PrevDecl);
+ virtual void Destroy(ASTContext& C);
+
const Expr *getInitExpr() const { return Init; }
Expr *getInitExpr() { return Init; }
const llvm::APSInt &getInitVal() const { return Val; }
SourceLocation L, IdentifierInfo *Id,
ScopedDecl *PrevDecl);
+ virtual void Destroy(ASTContext& C);
+
/// defineElements - When created, EnumDecl correspond to a forward declared
/// enum. This method is used to mark the decl as being defined, with the
/// specified list of enums.
return new (Mem) NamespaceDecl(DC, L, Id);
}
+void NamespaceDecl::Destroy(ASTContext& C) {
+ // NamespaceDecl uses "NextDeclarator" to chain namespace declarations
+ // together. They are all top-level Decls.
+
+ this->~Decl();
+ C.getAllocator().Deallocate((void *)this);
+}
+
+
VarDecl *VarDecl::Create(ASTContext &C, DeclContext *DC,
SourceLocation L,
IdentifierInfo *Id, QualType T,
return new (Mem) EnumConstantDecl(CD, L, Id, T, E, V, PrevDecl);
}
+void EnumConstantDecl::Destroy(ASTContext& C) {
+ if (Init) Init->Destroy(C);
+ Decl::Destroy(C);
+}
+
TypedefDecl *TypedefDecl::Create(ASTContext &C, DeclContext *DC,
SourceLocation L,
IdentifierInfo *Id, QualType T,
return new (Mem) RecordDecl(DK, DC, L, Id, PrevDecl);
}
+void EnumDecl::Destroy(ASTContext& C) {
+ if (ElementList) ElementList->Destroy(C);
+ Decl::Destroy(C);
+}
+
+
FileScopeAsmDecl *FileScopeAsmDecl::Create(ASTContext &C,
SourceLocation L,
StringLiteral *Str) {
void Decl::Destroy(ASTContext& C) {
+
+ if (ScopedDecl* SD = dyn_cast<ScopedDecl>(this)) {
+
+ // Observe the unrolled recursion. By setting N->NextDeclarator = 0x0
+ // within the loop, only the Destroy method for the first ScopedDecl
+ // will deallocate all of the ScopedDecls in a chain.
+
+ ScopedDecl* N = SD->getNextDeclarator();
+
+ while (N) {
+ ScopedDecl* Tmp = N->getNextDeclarator();
+ N->NextDeclarator = 0x0;
+ N->Destroy(C);
+ N = Tmp;
+ }
+ }
+
this->~Decl();
C.getAllocator().Deallocate((void *)this);
}