[cfe-commits] r138572 - /cfe/trunk/lib/Serialization/ASTReader.cpp
Douglas Gregor
dgregor at apple.com
Thu Aug 25 11:03:05 PDT 2011
Author: dgregor
Date: Thu Aug 25 13:03:05 2011
New Revision: 138572
URL: http://llvm.org/viewvc/llvm-project?rev=138572&view=rev
Log:
Switch the forward walk through the module chain over to a depth-first
search in ASTReader::ReadPreprocessedEntities().
Modified:
cfe/trunk/lib/Serialization/ASTReader.cpp
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=138572&r1=138571&r2=138572&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Aug 25 13:03:05 2011
@@ -3230,16 +3230,37 @@
return false;
}
-void ASTReader::ReadPreprocessedEntities() {
- for (ModuleIterator I = ModuleMgr.begin(), E = ModuleMgr.end(); I != E; ++I) {
- Module &F = *(*I);
- if (!F.PreprocessorDetailCursor.getBitStreamReader())
- continue;
+namespace {
+ /// \brief Visitor used by ASTReader::ReadPreprocessedEntities() to load
+ /// all of the preprocessed entities within a module.
+ class ReadPreprocessedEntitiesVisitor {
+ ASTReader &Reader;
+
+ public:
+ explicit ReadPreprocessedEntitiesVisitor(ASTReader &Reader)
+ : Reader(Reader) { }
+
+ static bool visit(Module &M, bool Preorder, void *UserData) {
+ if (Preorder)
+ return false;
+
+ ReadPreprocessedEntitiesVisitor *This
+ = static_cast<ReadPreprocessedEntitiesVisitor *>(UserData);
+
+ if (!M.PreprocessorDetailCursor.getBitStreamReader())
+ return false;
+
+ SavedStreamPosition SavedPosition(M.PreprocessorDetailCursor);
+ M.PreprocessorDetailCursor.JumpToBit(M.PreprocessorDetailStartOffset);
+ while (This->Reader.LoadPreprocessedEntity(M)) { }
+ return false;
+ }
+ };
+}
- SavedStreamPosition SavedPosition(F.PreprocessorDetailCursor);
- F.PreprocessorDetailCursor.JumpToBit(F.PreprocessorDetailStartOffset);
- while (LoadPreprocessedEntity(F)) { }
- }
+void ASTReader::ReadPreprocessedEntities() {
+ ReadPreprocessedEntitiesVisitor Visitor(*this);
+ ModuleMgr.visitDepthFirst(&ReadPreprocessedEntitiesVisitor::visit, &Visitor);
}
PreprocessedEntity *ASTReader::ReadPreprocessedEntityAtOffset(uint64_t Offset) {
More information about the cfe-commits
mailing list