]> granicus.if.org Git - clang/commitdiff
Added two new command line arguments:
authorMarcin Swiderski <marcin.sfider@gmail.com>
Thu, 30 Sep 2010 07:41:24 +0000 (07:41 +0000)
committerMarcin Swiderski <marcin.sfider@gmail.com>
Thu, 30 Sep 2010 07:41:24 +0000 (07:41 +0000)
-cfg-add-implicit-dtors - sets CFG::BuildOptions::AddImplicitDtors for AnalysisCosumer to true,
-cfg-add-initializers - sets CFG::BuildOptions::AddInitializers for AnalysisCosumer to true.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115142 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 7d4d25f8b0d847fe9fe1671a80412226f74e83c9..0a61f440dae63a228de7b8c2a4f44cea976cce25 100644 (file)
@@ -56,15 +56,20 @@ class AnalysisContext {
   llvm::BumpPtrAllocator A;
   bool UseUnoptimizedCFG;  
   bool AddEHEdges;
+  bool AddImplicitDtors;
+  bool AddInitializers;
 public:
   AnalysisContext(const Decl *d, idx::TranslationUnit *tu,
                   bool useUnoptimizedCFG = false,
-                  bool addehedges = false)
+                  bool addehedges = false,
+                  bool addImplicitDtors = false,
+                  bool addInitializers = false)
     : D(d), TU(tu), cfg(0), completeCFG(0),
       builtCFG(false), builtCompleteCFG(false),
       liveness(0), relaxedLiveness(0), PM(0), PCA(0),
       ReferencedBlockVars(0), UseUnoptimizedCFG(useUnoptimizedCFG),
-      AddEHEdges(addehedges) {}
+      AddEHEdges(addehedges), AddImplicitDtors(addImplicitDtors),
+      AddInitializers(addInitializers) {}
 
   ~AnalysisContext();
 
@@ -80,6 +85,8 @@ public:
   bool getAddEHEdges() const { return AddEHEdges; }
   
   bool getUseUnoptimizedCFG() const { return UseUnoptimizedCFG; }
+  bool getAddImplicitDtors() const { return AddImplicitDtors; }
+  bool getAddInitializers() const { return AddInitializers; }
 
   Stmt *getBody();
   CFG *getCFG();
@@ -106,15 +113,21 @@ class AnalysisContextManager {
   typedef llvm::DenseMap<const Decl*, AnalysisContext*> ContextMap;
   ContextMap Contexts;
   bool UseUnoptimizedCFG;
+  bool AddImplicitDtors;
+  bool AddInitializers;
 public:
-  AnalysisContextManager(bool useUnoptimizedCFG = false)
-    : UseUnoptimizedCFG(useUnoptimizedCFG) {}
+  AnalysisContextManager(bool useUnoptimizedCFG = false,
+      bool addImplicitDtors = false, bool addInitializers = false)
+    : UseUnoptimizedCFG(useUnoptimizedCFG), AddImplicitDtors(addImplicitDtors),
+      AddInitializers(addInitializers) {}
   
   ~AnalysisContextManager();
 
   AnalysisContext *getContext(const Decl *D, idx::TranslationUnit *TU = 0);
 
   bool getUseUnoptimizedCFG() const { return UseUnoptimizedCFG; }
+  bool getAddImplicitDtors() const { return AddImplicitDtors; }
+  bool getAddInitializers() const { return AddInitializers; }
 
   // Discard all previously created AnalysisContexts.
   void clear();
index 628ddce31ce40c56a1e277041e92e76b8a30e0cc..fe50699753e4894db6b5d5c36c039bfbf4268180 100644 (file)
@@ -76,10 +76,11 @@ public:
                   idx::Indexer *idxer,
                   unsigned maxnodes, unsigned maxvisit,
                   bool vizdot, bool vizubi, bool purge, bool eager, bool trim,
-                  bool inlinecall, bool useUnoptimizedCFG)
+                  bool inlinecall, bool useUnoptimizedCFG,
+                  bool addImplicitDtors, bool addInitializers)
 
-    : AnaCtxMgr(useUnoptimizedCFG), Ctx(ctx), Diags(diags), LangInfo(lang),
-      PD(pd),
+    : AnaCtxMgr(useUnoptimizedCFG, addImplicitDtors, addInitializers),
+      Ctx(ctx), Diags(diags), LangInfo(lang), PD(pd),
       CreateStoreMgr(storemgr), CreateConstraintMgr(constraintmgr),Idxer(idxer),
       AScope(ScopeDecl), MaxNodes(maxnodes), MaxVisit(maxvisit),
       VisualizeEGDot(vizdot), VisualizeEGUbi(vizubi), PurgeDead(purge),
index c416c1a4bfe59c15a9f3aeb8c9fb79fb064c6240..6de5bf14fd45a9cf7be06d962ebfed1844804350 100644 (file)
@@ -42,6 +42,10 @@ def analysis_CFGView : Flag<"-cfg-view">,
   HelpText<"View Control-Flow Graphs using GraphViz">;
 def analysis_UnoptimizedCFG : Flag<"-unoptimized-cfg">,
   HelpText<"Generate unoptimized CFGs for all analyses">;
+def analysis_CFGAddImplicitDtors : Flag<"-cfg-add-implicit-dtors">,
+  HelpText<"Add C++ implicit destructors to CFGs for all analyses">;
+def analysis_CFGAddInitializers : Flag<"-cfg-add-initializers">,
+  HelpText<"Add C++ initializers to CFGs for all analyses">;
 def analysis_DisplayLiveVariables : Flag<"-dump-live-variables">,
   HelpText<"Print results of live variable analysis">;
 def analysis_LLVMConventionChecker : Flag<"-analyzer-check-llvm-conventions">,
index cd4594589983091c71ca566d0c2e573eab129238..89de26e307b505feaa1789aa3e261cb05efe9026 100644 (file)
@@ -76,6 +76,8 @@ public:
   unsigned EnableExperimentalInternalChecks : 1;
   unsigned InlineCall : 1;
   unsigned UnoptimizedCFG : 1;
+  unsigned CFGAddImplicitDtors : 1;
+  unsigned CFGAddInitializers : 1;
 
 public:
   AnalyzerOptions() {
@@ -94,6 +96,8 @@ public:
     EnableExperimentalChecks = 0;
     EnableExperimentalInternalChecks = 0;
     UnoptimizedCFG = 0;
+    CFGAddImplicitDtors = 0;
+    CFGAddInitializers = 0;
   }
 };
 
index 188a6f8dccfff2caa9ef9f30d05b8eaab9b89018..68c5e158f3a5c43fdb9a0cfb596233297ff8f3ae 100644 (file)
@@ -61,6 +61,8 @@ CFG *AnalysisContext::getCFG() {
   if (!builtCFG) {
     CFG::BuildOptions B;
     B.AddEHEdges = AddEHEdges;
+    B.AddImplicitDtors = AddImplicitDtors;
+    B.AddInitializers = AddInitializers;
     cfg = CFG::buildCFG(D, getBody(), &D->getASTContext(), B);
     // Even when the cfg is not successfully built, we don't
     // want to try building it again.
@@ -74,6 +76,8 @@ CFG *AnalysisContext::getUnoptimizedCFG() {
     CFG::BuildOptions B;
     B.PruneTriviallyFalseEdges = false;
     B.AddEHEdges = AddEHEdges;
+    B.AddImplicitDtors = AddImplicitDtors;
+    B.AddInitializers = AddInitializers;
     completeCFG = CFG::buildCFG(D, getBody(), &D->getASTContext(), B);
     // Even when the cfg is not successfully built, we don't
     // want to try building it again.
@@ -126,7 +130,8 @@ AnalysisContext *AnalysisContextManager::getContext(const Decl *D,
                                                     idx::TranslationUnit *TU) {
   AnalysisContext *&AC = Contexts[D];
   if (!AC)
-    AC = new AnalysisContext(D, TU, UseUnoptimizedCFG);
+    AC = new AnalysisContext(D, TU, UseUnoptimizedCFG, false,
+        AddImplicitDtors, AddInitializers);
 
   return AC;
 }
index e717ce0a9c8501475ab2421c7fcffdd176b988ab..94bce40c18489dad8bbe515aa3ef12c4375f819a 100644 (file)
@@ -179,7 +179,8 @@ public:
                                   Opts.VisualizeEGDot, Opts.VisualizeEGUbi,
                                   Opts.PurgeDead, Opts.EagerlyAssume,
                                   Opts.TrimGraph, Opts.InlineCall,
-                                  Opts.UnoptimizedCFG));
+                                  Opts.UnoptimizedCFG, Opts.CFGAddImplicitDtors,
+                                  Opts.CFGAddInitializers));
   }
 
   virtual void HandleTranslationUnit(ASTContext &C);
index 8b30a86ee2da95067374160544355089f07759e0..83a53b3dc9adc1e516fbef504b7feb46166dd8bf 100644 (file)
@@ -718,7 +718,9 @@ void GRCallEnterNodeBuilder::GenerateNode(const GRState *state,
                          OldMgr.shouldEagerlyAssume(),
                          OldMgr.shouldTrimGraph(),
                          OldMgr.shouldInlineCall(),
-                     OldMgr.getAnalysisContextManager().getUseUnoptimizedCFG());
+                     OldMgr.getAnalysisContextManager().getUseUnoptimizedCFG(),
+                     OldMgr.getAnalysisContextManager().getAddImplicitDtors(),
+                     OldMgr.getAnalysisContextManager().getAddInitializers());
     llvm::OwningPtr<GRTransferFuncs> TF(MakeCFRefCountTF(AMgr.getASTContext(),
                                                          /* GCEnabled */ false,
                                                         AMgr.getLangOptions()));
index d793fc01be7bb50f1c343ca269127359d5030784..11869a17d6542cd994d9c7004edb64404a15f9bf 100644 (file)
@@ -827,6 +827,8 @@ static void ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
   Opts.EagerlyAssume = Args.hasArg(OPT_analyzer_eagerly_assume);
   Opts.AnalyzeSpecificFunction = Args.getLastArgValue(OPT_analyze_function);
   Opts.UnoptimizedCFG = Args.hasArg(OPT_analysis_UnoptimizedCFG);
+  Opts.CFGAddImplicitDtors = Args.hasArg(OPT_analysis_CFGAddImplicitDtors);
+  Opts.CFGAddInitializers = Args.hasArg(OPT_analysis_CFGAddInitializers);
   Opts.EnableExperimentalChecks = Args.hasArg(OPT_analyzer_experimental_checks);
   Opts.EnableExperimentalInternalChecks =
     Args.hasArg(OPT_analyzer_experimental_internal_checks);