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
diff --git a/lib/Analysis/AnalysisContext.cpp b/lib/Analysis/AnalysisContext.cpp
index 5640c4a..06d8aec 100644
--- a/lib/Analysis/AnalysisContext.cpp
+++ b/lib/Analysis/AnalysisContext.cpp
@@ -54,8 +54,12 @@
 }
 
 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 @@
   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 @@
   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 @@
     IgnoredContexts.insert(BR->getBlockDecl());
     Visit(BR->getBlockDecl()->getBody());
   }
-};  
+};
 } // end anonymous namespace
 
 typedef BumpVector<const VarDecl*> DeclVec;
@@ -263,16 +267,16 @@
                                               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 @@
 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 @@
 
 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();
 }