]> granicus.if.org Git - clang/commitdiff
Add a cc1 option to specify the max number of nodes the analyzer can explore.
authorZhongxing Xu <xuzhongxing@gmail.com>
Tue, 13 Apr 2010 06:44:31 +0000 (06:44 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Tue, 13 Apr 2010 06:44:31 +0000 (06:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101120 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Checker/PathSensitive/AnalysisManager.h
include/clang/Driver/CC1Options.td
include/clang/Frontend/AnalysisConsumer.h
lib/Frontend/AnalysisConsumer.cpp
lib/Frontend/CompilerInvocation.cpp

index fdf52a7dc770f9198cbcc347f324a4699fe7cf1f..0c59d7b572a40098a81d0239106e7fe2338b4290 100644 (file)
@@ -37,6 +37,8 @@ class AnalysisManager : public BugReporterData {
 
   enum AnalysisScope { ScopeTU, ScopeDecl } AScope;
 
+  unsigned MaxNodes;
+
   bool VisualizeEGDot;
   bool VisualizeEGUbi;
   bool PurgeDead;
@@ -55,12 +57,12 @@ public:
   AnalysisManager(ASTContext &ctx, Diagnostic &diags, 
                   const LangOptions &lang, PathDiagnosticClient *pd,
                   StoreManagerCreator storemgr,
-                  ConstraintManagerCreator constraintmgr,
+                  ConstraintManagerCreator constraintmgr, unsigned maxnodes,
                   bool vizdot, bool vizubi, bool purge, bool eager, bool trim)
 
     : Ctx(ctx), Diags(diags), LangInfo(lang), PD(pd),
       CreateStoreMgr(storemgr), CreateConstraintMgr(constraintmgr),
-      AScope(ScopeDecl),
+      AScope(ScopeDecl), MaxNodes(maxnodes),
       VisualizeEGDot(vizdot), VisualizeEGUbi(vizubi), PurgeDead(purge),
       EagerlyAssume(eager), TrimGraph(trim) {}
   
@@ -104,6 +106,8 @@ public:
       PD->FlushDiagnostics();
   }
 
+  unsigned getMaxNodes() const { return MaxNodes; }
+
   bool shouldVisualizeGraphviz() const { return VisualizeEGDot; }
 
   bool shouldVisualizeUbigraph() const { return VisualizeEGUbi; }
index 542bde6b3230abf0cf862447474f226b665c5df8..0095b1f9f43ba1fe724fb8ad5ac37f5597a76aad 100644 (file)
@@ -97,6 +97,8 @@ def analyzer_viz_egraph_graphviz : Flag<"-analyzer-viz-egraph-graphviz">,
   HelpText<"Display exploded graph using GraphViz">;
 def analyzer_viz_egraph_ubigraph : Flag<"-analyzer-viz-egraph-ubigraph">,
   HelpText<"Display exploded graph using Ubigraph">;
+def analyzer_max_nodes : Separate<"-analyzer-max-nodes">,
+  HelpText<"The maximum number of nodes the analyzer can generate">;
 
 //===----------------------------------------------------------------------===//
 // CodeGen Options
index f55e5dc040552d30e1be40e15ccb068da96197e7..3341bb01f0fa83cc3ebdd4d9d13bbe742bc6b6a2 100644 (file)
@@ -60,6 +60,7 @@ public:
   AnalysisConstraints AnalysisConstraintsOpt;
   AnalysisDiagClients AnalysisDiagOpt;
   std::string AnalyzeSpecificFunction;
+  unsigned MaxNodes;
   unsigned AnalyzeAll : 1;
   unsigned AnalyzerDisplayProgress : 1;
   unsigned AnalyzeNestedBlocks : 1;
index d764fd078968331fe6d728ddef1e344eb3c8468f..2ca833b66777226b12fd22391c9f37f4126174e2 100644 (file)
@@ -176,6 +176,7 @@ public:
     Mgr.reset(new AnalysisManager(*Ctx, PP.getDiagnostics(),
                                   PP.getLangOptions(), PD,
                                   CreateStoreMgr, CreateConstraintMgr,
+                                  Opts.MaxNodes,
                                   Opts.VisualizeEGDot, Opts.VisualizeEGUbi,
                                   Opts.PurgeDead, Opts.EagerlyAssume,
                                   Opts.TrimGraph));
@@ -358,7 +359,7 @@ static void ActionGRExprEngine(AnalysisConsumer &C, AnalysisManager& mgr,
   }
 
   // Execute the worklist algorithm.
-  Eng.ExecuteWorkList(mgr.getStackFrame(D));
+  Eng.ExecuteWorkList(mgr.getStackFrame(D), mgr.getMaxNodes());
 
   // Release the auditor (if any) so that it doesn't monitor the graph
   // created BugReporter.
index b5e56458779832b86d8f46bc7caec86752ca225c..d40f0bfd76aaea56e5566e0dedfb20f5e4720b78 100644 (file)
@@ -762,6 +762,7 @@ static void ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
   Opts.EnableExperimentalInternalChecks =
     Args.hasArg(OPT_analyzer_experimental_internal_checks);
   Opts.TrimGraph = Args.hasArg(OPT_trim_egraph);
+  Opts.MaxNodes = getLastArgIntValue(Args, OPT_analyzer_max_nodes,150000,Diags);
 }
 
 static void ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,