diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-03-23 00:13:23 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-03-23 00:13:23 +0000 |
commit | d064fdc4b7b64ca55b40b70490c79d6f569df78e (patch) | |
tree | 07a0c6fb87b558bbfb070a1aba01717486b9fe47 /lib/Analysis/AnalysisContext.cpp | |
parent | 22f757b38da3fc9f17ea9e99524064fdfbca3456 (diff) |
Only perform CFG-based warnings on 'static inline' functions that
are called (transitively) by regular functions/blocks within a
translation untion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99233 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/AnalysisContext.cpp')
-rw-r--r-- | lib/Analysis/AnalysisContext.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/lib/Analysis/AnalysisContext.cpp b/lib/Analysis/AnalysisContext.cpp index 5640c4a461..06d8aec391 100644 --- a/lib/Analysis/AnalysisContext.cpp +++ b/lib/Analysis/AnalysisContext.cpp @@ -54,8 +54,12 @@ const ImplicitParamDecl *AnalysisContext::getSelfDecl() const { } CFG *AnalysisContext::getCFG() { - if (!cfg) + if (!builtCFG) { cfg = CFG::buildCFG(D, getBody(), &D->getASTContext(), AddEHEdges); + // Even when the cfg is not successfully built, we don't + // want to try building it again. + builtCFG = true; + } return cfg; } @@ -126,9 +130,9 @@ LocationContextManager::getLocationContext(AnalysisContext *ctx, llvm::FoldingSetNodeID ID; LOC::Profile(ID, ctx, parent, d); void *InsertPos; - + LOC *L = cast_or_null<LOC>(Contexts.FindNodeOrInsertPos(ID, InsertPos)); - + if (!L) { L = new LOC(ctx, parent, d); Contexts.InsertNode(L, InsertPos); @@ -144,7 +148,7 @@ LocationContextManager::getStackFrame(AnalysisContext *ctx, llvm::FoldingSetNodeID ID; StackFrameContext::Profile(ID, ctx, parent, s, blk, idx); void *InsertPos; - StackFrameContext *L = + StackFrameContext *L = cast_or_null<StackFrameContext>(Contexts.FindNodeOrInsertPos(ID, InsertPos)); if (!L) { L = new StackFrameContext(ctx, parent, s, blk, idx); @@ -253,7 +257,7 @@ public: IgnoredContexts.insert(BR->getBlockDecl()); Visit(BR->getBlockDecl()->getBody()); } -}; +}; } // end anonymous namespace typedef BumpVector<const VarDecl*> DeclVec; @@ -263,16 +267,16 @@ static DeclVec* LazyInitializeReferencedDecls(const BlockDecl *BD, llvm::BumpPtrAllocator &A) { if (Vec) return (DeclVec*) Vec; - + BumpVectorContext BC(A); DeclVec *BV = (DeclVec*) A.Allocate<DeclVec>(); new (BV) DeclVec(BC, 10); - + // Find the referenced variables. FindBlockDeclRefExprsVals F(*BV, BC); F.Visit(BD->getBody()); - - Vec = BV; + + Vec = BV; return BV; } @@ -281,7 +285,7 @@ std::pair<AnalysisContext::referenced_decls_iterator, AnalysisContext::getReferencedBlockVars(const BlockDecl *BD) { if (!ReferencedBlockVars) ReferencedBlockVars = new llvm::DenseMap<const BlockDecl*,void*>(); - + DeclVec *V = LazyInitializeReferencedDecls(BD, (*ReferencedBlockVars)[BD], A); return std::make_pair(V->begin(), V->end()); } @@ -310,12 +314,12 @@ LocationContextManager::~LocationContextManager() { void LocationContextManager::clear() { for (llvm::FoldingSet<LocationContext>::iterator I = Contexts.begin(), - E = Contexts.end(); I != E; ) { + E = Contexts.end(); I != E; ) { LocationContext *LC = &*I; ++I; delete LC; } - + Contexts.clear(); } |