diff options
author | Ted Kremenek <kremenek@apple.com> | 2012-04-27 04:54:28 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2012-04-27 04:54:28 +0000 |
commit | 577f14a34457032523e59dbbbacb88ca2cd4db57 (patch) | |
tree | 44413c5e7cef28dbf50819c2ab8554364e363103 /lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp | |
parent | 29a4ce4e7236498b3c75160875582b4d41b0c90d (diff) |
Use a deque instead of an ImmutableList in AnalysisConsumer to preserve the file order that functions are visited. Should fix the buildbots.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155693 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp b/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp index dd60b201f8..ae783230f6 100644 --- a/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ b/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -102,8 +102,6 @@ public: /// The local declaration to all declarations ratio might be very small when /// working with a PCH file. SetOfDecls LocalTUDecls; - - SetOfDecls::Factory LocalTUDeclsFactory; // PD is owned by AnalysisManager. PathDiagnosticConsumer *PD; @@ -308,9 +306,7 @@ void AnalysisConsumer::storeTopLevelDecls(DeclGroupRef DG) { if (isa<ObjCMethodDecl>(*I)) continue; - // We use an ImmutableList to avoid issues with invalidating iterators - // to the list while we are traversing it. - LocalTUDecls = LocalTUDeclsFactory.add(*I, LocalTUDecls); + LocalTUDecls.push_back(*I); } } @@ -319,9 +315,6 @@ void AnalysisConsumer::HandleDeclsGallGraph() { // Build the Call Graph. CallGraph CG; // Add all the top level declarations to the graph. - // - // NOTE: We use an ImmutableList to avoid issues with invalidating iterators - // to the list while we are traversing it. for (SetOfDecls::iterator I = LocalTUDecls.begin(), E = LocalTUDecls.end(); I != E; ++I) CG.addToCallGraph(*I); @@ -410,12 +403,13 @@ void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) { // Process all the top level declarations. // - // NOTE: We use an ImmutableList to avoid issues with invalidating iterators - // to the list while we are traversing it. - // - for (SetOfDecls::iterator I = LocalTUDecls.begin(), - E = LocalTUDecls.end(); I != E; ++I) { - TraverseDecl(*I); + // Note: TraverseDecl may modify LocalTUDecls, but only by appending more + // entries. Thus we don't use an iterator, but rely on LocalTUDecls + // random access. By doing so, we automatically compensate for iterators + // possibly being invalidated, although this is a bit slower. + const unsigned n = LocalTUDecls.size(); + for (unsigned i = 0 ; i < n ; ++i) { + TraverseDecl(LocalTUDecls[i]); } if (Mgr->shouldInlineCall()) |