Added driver option "-checker-opt-analyze-headers" to force the static
analyzer to analyze functions declared in header files.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49675 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/ASTConsumers.cpp b/Driver/ASTConsumers.cpp
index 727c57a..77cc996 100644
--- a/Driver/ASTConsumers.cpp
+++ b/Driver/ASTConsumers.cpp
@@ -643,12 +643,13 @@
   bool Visualize;
   bool TrimGraph;
   llvm::OwningPtr<PathDiagnosticClient> PD;
+  bool AnalyzeAll;
 public:
   CheckerConsumer(Diagnostic &diags, const std::string& fname,
             const std::string& htmldir,
-            bool visualize, bool trim)
+            bool visualize, bool trim, bool analyzeAll)
     : CFGVisitor(fname), Diags(diags), HTMLDir(htmldir),
-      Visualize(visualize), TrimGraph(trim) {}
+      Visualize(visualize), TrimGraph(trim), AnalyzeAll(analyzeAll) {}
   
   virtual void Initialize(ASTContext &Context) { Ctx = &Context; }    
   virtual void VisitCFG(CFG& C, Decl&);
@@ -666,8 +667,10 @@
   
   SourceLocation Loc = CD.getLocation();
   
-  if (!Loc.isFileID() ||
-      Loc.getFileID() != Ctx->getSourceManager().getMainFileID())
+  if (!Loc.isFileID())
+    return;
+  
+  if (!AnalyzeAll && Loc.getFileID() != Ctx->getSourceManager().getMainFileID())
     return;
   
   // Lazily create the diagnostic client.
@@ -721,8 +724,8 @@
 public:
   GRSimpleValsVisitor(Diagnostic &diags, const std::string& fname,
                       const std::string& htmldir,
-                      bool visualize, bool trim)
-  : CheckerConsumer(diags, fname, htmldir, visualize, trim) {}
+                      bool visualize, bool trim, bool analyzeAll)
+  : CheckerConsumer(diags, fname, htmldir, visualize, trim, analyzeAll) {}
 
   virtual const char* getCheckerName() { return "GRSimpleVals"; }
   
@@ -735,10 +738,11 @@
 ASTConsumer* clang::CreateGRSimpleVals(Diagnostic &Diags,
                                        const std::string& FunctionName,
                                        const std::string& HTMLDir,
-                                       bool Visualize, bool TrimGraph) {
+                                       bool Visualize, bool TrimGraph,
+                                       bool AnalyzeAll) {
   
   return new GRSimpleValsVisitor(Diags, FunctionName, HTMLDir,
-                                 Visualize, TrimGraph);
+                                 Visualize, TrimGraph, AnalyzeAll);
 }
 
 
@@ -750,8 +754,8 @@
 public:
   CFRefCountCheckerVisitor(Diagnostic &diags, const std::string& fname,
                       const std::string& htmldir,
-                      bool visualize, bool trim)
-  : CheckerConsumer(diags, fname, htmldir, visualize, trim) {}
+                      bool visualize, bool trim, bool analyzeAll)
+  : CheckerConsumer(diags, fname, htmldir, visualize, trim, analyzeAll) {}
   
   virtual const char* getCheckerName() { return "CFRefCountChecker"; }
   
@@ -764,10 +768,11 @@
 ASTConsumer* clang::CreateCFRefChecker(Diagnostic &Diags,
                                        const std::string& FunctionName,
                                        const std::string& HTMLDir,
-                                       bool Visualize, bool TrimGraph) {
+                                       bool Visualize, bool TrimGraph,
+                                       bool AnalyzeAll) {
   
   return new CFRefCountCheckerVisitor(Diags, FunctionName, HTMLDir,
-                                      Visualize, TrimGraph);
+                                      Visualize, TrimGraph, AnalyzeAll);
 }
 
 //===----------------------------------------------------------------------===//