[cfe-commits] r138668 - in /cfe/trunk: include/clang/AST/DeclBase.h include/clang/Lex/ModuleLoader.h lib/Serialization/ASTReader.cpp
Douglas Gregor
dgregor at apple.com
Fri Aug 26 15:04:51 PDT 2011
Author: dgregor
Date: Fri Aug 26 17:04:51 2011
New Revision: 138668
URL: http://llvm.org/viewvc/llvm-project?rev=138668&view=rev
Log:
Teach the ASTReader how to avoid cycles when loading declarations that
are lexically within a particular DeclContext. Test forthcoming.
Added:
cfe/trunk/include/clang/Lex/ModuleLoader.h
Modified:
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/lib/Serialization/ASTReader.cpp
Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=138668&r1=138667&r2=138668&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Fri Aug 26 17:04:51 2011
@@ -1322,6 +1322,12 @@
ExternalVisibleStorage = ES;
}
+ /// \brief Determine whether the given declaration is stored in the list of
+ /// declarations lexically within this context.
+ bool isDeclInLexicalTraversal(const Decl *D) const {
+ return D && (D->NextDeclInContext || D == FirstDecl || D == LastDecl);
+ }
+
static bool classof(const Decl *D);
static bool classof(const DeclContext *D) { return true; }
#define DECL(NAME, BASE)
Added: cfe/trunk/include/clang/Lex/ModuleLoader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleLoader.h?rev=138668&view=auto
==============================================================================
(empty)
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=138668&r1=138667&r2=138668&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Aug 26 17:04:51 2011
@@ -2553,7 +2553,7 @@
= static_cast<IdentifierLookupVisitor *>(UserData);
ASTIdentifierLookupTable *IdTable
- = (ASTIdentifierLookupTable *)M.IdentifierLookupTable;
+ = (ASTIdentifierLookupTable *)M.IdentifierLookupTable;
if (!IdTable)
return false;
@@ -2786,7 +2786,7 @@
void ASTReader::InitializeContext(ASTContext &Ctx) {
Context = &Ctx;
assert(Context && "Passed null context!");
-
+
assert(PP && "Forgot to set Preprocessor ?");
PP->getIdentifierTable().setExternalIdentifierLookup(this);
PP->setExternalSource(this);
@@ -4163,6 +4163,7 @@
ASTReader &Reader;
const DeclContext *DC;
bool (*isKindWeWant)(Decl::Kind);
+
SmallVectorImpl<Decl*> &Decls;
bool PredefsVisited[NUM_PREDEF_DECL_IDS];
@@ -4204,9 +4205,10 @@
This->PredefsVisited[ID->second] = true;
}
- Decl *D = This->Reader.GetLocalDecl(M, ID->second);
- assert(D && "Null decl in lexical decls");
- This->Decls.push_back(D);
+ if (Decl *D = This->Reader.GetLocalDecl(M, ID->second)) {
+ if (!This->DC->isDeclInLexicalTraversal(D))
+ This->Decls.push_back(D);
+ }
}
return false;
More information about the cfe-commits
mailing list