aboutsummaryrefslogtreecommitdiff
path: root/lib/AST
diff options
context:
space:
mode:
Diffstat (limited to 'lib/AST')
-rw-r--r--lib/AST/DeclBase.cpp13
-rw-r--r--lib/AST/DeclSerialization.cpp7
2 files changed, 18 insertions, 2 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index d9765ac4b4..cafe5358d6 100644
--- a/lib/AST/DeclBase.cpp
+++ b/lib/AST/DeclBase.cpp
@@ -401,7 +401,8 @@ DeclContext::~DeclContext() {
}
void DeclContext::DestroyDecls(ASTContext &C) {
- for (decl_iterator D = Decls.begin(); D != Decls.end(); ++D) {
+ for (decl_iterator D = decls_begin(); D != decls_end(); ++D) {
+ // FIXME: assert that this condition holds.
if ((*D)->getLexicalDeclContext() == this)
(*D)->Destroy(C);
}
@@ -515,7 +516,15 @@ DeclContext *DeclContext::getNextContext() {
void DeclContext::addDecl(ASTContext &Context, ScopedDecl *D, bool AllowLookup) {
assert(D->getLexicalDeclContext() == this && "Decl inserted into wrong lexical context");
- Decls.push_back(D);
+ assert(!D->NextDeclInScope && D != LastDecl &&
+ "Decl already inserted into a DeclContext");
+
+ if (FirstDecl) {
+ LastDecl->NextDeclInScope = D;
+ LastDecl = D;
+ } else {
+ FirstDecl = LastDecl = D;
+ }
if (AllowLookup)
D->getDeclContext()->insert(Context, D);
}
diff --git a/lib/AST/DeclSerialization.cpp b/lib/AST/DeclSerialization.cpp
index 38af462091..11577cd6dc 100644
--- a/lib/AST/DeclSerialization.cpp
+++ b/lib/AST/DeclSerialization.cpp
@@ -124,6 +124,9 @@ void Decl::ReadInRec(Deserializer& D, ASTContext& C) {
//===----------------------------------------------------------------------===//
void DeclContext::EmitOutRec(Serializer& S) const {
+#if 0
+ // FIXME: it would be far easier to just serialize FirstDecl and let
+ // ScopedDecl do the work of serializing NextDeclInScope.
S.EmitInt(Decls.size());
for (decl_iterator D = decls_begin(); D != decls_end(); ++D) {
bool Owned = ((*D)->getLexicalDeclContext() == this &&
@@ -135,9 +138,12 @@ void DeclContext::EmitOutRec(Serializer& S) const {
else
S.EmitPtr(*D);
}
+#endif
}
void DeclContext::ReadOutRec(Deserializer& D, ASTContext& C) {
+#if 0
+ // FIXME: See comment in DeclContext::EmitOutRec
unsigned NumDecls = D.ReadInt();
Decls.resize(NumDecls);
for (unsigned Idx = 0; Idx < NumDecls; ++Idx) {
@@ -147,6 +153,7 @@ void DeclContext::ReadOutRec(Deserializer& D, ASTContext& C) {
else
D.ReadPtr<ScopedDecl>(Decls[Idx]);
}
+#endif
}
//===----------------------------------------------------------------------===//