[cfe-commits] r126288 - in /cfe/trunk: include/clang/Analysis/AnalysisContext.h include/clang/Sema/AnalysisBasedWarnings.h lib/Analysis/AnalysisContext.cpp lib/Sema/AnalysisBasedWarnings.cpp lib/Sema/Sema.cpp lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp

Ted Kremenek kremenek at apple.com
Tue Feb 22 17:51:53 PST 2011


Author: kremenek
Date: Tue Feb 22 19:51:53 2011
New Revision: 126288

URL: http://llvm.org/viewvc/llvm-project?rev=126288&view=rev
Log:
Have IdempotentOperationsChecker pull its CFGStmtMap from AnalysisContext.

Modified:
    cfe/trunk/include/clang/Analysis/AnalysisContext.h
    cfe/trunk/include/clang/Sema/AnalysisBasedWarnings.h
    cfe/trunk/lib/Analysis/AnalysisContext.cpp
    cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
    cfe/trunk/lib/Sema/Sema.cpp
    cfe/trunk/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp

Modified: cfe/trunk/include/clang/Analysis/AnalysisContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/AnalysisContext.h?rev=126288&r1=126287&r2=126288&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/AnalysisContext.h (original)
+++ cfe/trunk/include/clang/Analysis/AnalysisContext.h Tue Feb 22 19:51:53 2011
@@ -29,6 +29,7 @@
 class Stmt;
 class CFG;
 class CFGBlock;
+class CFGStmtMap;
 class LiveVariables;
 class ParentMap;
 class PseudoConstantAnalysis;
@@ -48,6 +49,7 @@
 
   // AnalysisContext owns the following data.
   CFG *cfg, *completeCFG;
+  CFGStmtMap *cfgStmtMap;
   bool builtCFG, builtCompleteCFG;
   LiveVariables *liveness;
   LiveVariables *relaxedLiveness;
@@ -65,7 +67,7 @@
                   bool addehedges = false,
                   bool addImplicitDtors = false,
                   bool addInitializers = false)
-    : D(d), TU(tu), cfg(0), completeCFG(0),
+    : D(d), TU(tu), cfg(0), completeCFG(0), cfgStmtMap(0),
       builtCFG(false), builtCompleteCFG(false),
       liveness(0), relaxedLiveness(0), PM(0), PCA(0),
       ReferencedBlockVars(0), UseUnoptimizedCFG(useUnoptimizedCFG),
@@ -91,6 +93,8 @@
 
   Stmt *getBody();
   CFG *getCFG();
+  
+  CFGStmtMap *getCFGStmtMap();
 
   /// Return a version of the CFG without any edges pruned.
   CFG *getUnoptimizedCFG();

Modified: cfe/trunk/include/clang/Sema/AnalysisBasedWarnings.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AnalysisBasedWarnings.h?rev=126288&r1=126287&r2=126288&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/AnalysisBasedWarnings.h (original)
+++ cfe/trunk/include/clang/Sema/AnalysisBasedWarnings.h Tue Feb 22 19:51:53 2011
@@ -25,6 +25,9 @@
 class ObjCMethodDecl;
 class QualType;
 class Sema;
+namespace sema {
+  class FunctionScopeInfo;
+}
 
 namespace sema {
 
@@ -51,7 +54,8 @@
 public:
   AnalysisBasedWarnings(Sema &s);
 
-  void IssueWarnings(Policy P, const Decl *D, const BlockExpr *blkExpr);
+  void IssueWarnings(Policy P, FunctionScopeInfo *fscope,
+                     const Decl *D, const BlockExpr *blkExpr);
 
   Policy getDefaultPolicy() { return DefaultPolicy; }
 };

Modified: cfe/trunk/lib/Analysis/AnalysisContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/AnalysisContext.cpp?rev=126288&r1=126287&r2=126288&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/AnalysisContext.cpp (original)
+++ cfe/trunk/lib/Analysis/AnalysisContext.cpp Tue Feb 22 19:51:53 2011
@@ -21,6 +21,7 @@
 #include "clang/Analysis/Analyses/PseudoConstantAnalysis.h"
 #include "clang/Analysis/AnalysisContext.h"
 #include "clang/Analysis/CFG.h"
+#include "clang/Analysis/CFGStmtMap.h"
 #include "clang/Analysis/Support/BumpVector.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -86,6 +87,19 @@
   return completeCFG;
 }
 
+CFGStmtMap *AnalysisContext::getCFGStmtMap() {
+  if (cfgStmtMap)
+    return cfgStmtMap;
+  
+  if (CFG *c = getCFG()) {
+    cfgStmtMap = CFGStmtMap::Build(c, &getParentMap());
+    return cfgStmtMap;
+  }
+    
+  return 0;
+}
+  
+
 void AnalysisContext::dumpCFG() {
     getCFG()->dump(getASTContext().getLangOptions());
 }
@@ -346,6 +360,7 @@
 AnalysisContext::~AnalysisContext() {
   delete cfg;
   delete completeCFG;
+  delete cfgStmtMap;
   delete liveness;
   delete relaxedLiveness;
   delete PM;

Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=126288&r1=126287&r2=126288&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Tue Feb 22 19:51:53 2011
@@ -480,6 +480,7 @@
 
 void clang::sema::
 AnalysisBasedWarnings::IssueWarnings(sema::AnalysisBasedWarnings::Policy P,
+                                     sema::FunctionScopeInfo *fscope,
                                      const Decl *D, const BlockExpr *blkExpr) {
 
   // We avoid doing analysis-based warnings when there are errors for

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=126288&r1=126287&r2=126288&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Tue Feb 22 19:51:53 2011
@@ -638,7 +638,7 @@
   
   // Issue any analysis-based warnings.
   if (WP && D)
-    AnalysisWarnings.IssueWarnings(*WP, D, blkExpr);
+    AnalysisWarnings.IssueWarnings(*WP, Scope, D, blkExpr);
 
   if (FunctionScopes.back() != Scope)
     delete Scope;

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp?rev=126288&r1=126287&r2=126288&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp Tue Feb 22 19:51:53 2011
@@ -397,16 +397,13 @@
     // If the analyzer did not finish, check to see if we can still emit this
     // warning
     if (Eng.hasWorkRemaining()) {
-      const CFGStmtMap *CBM = CFGStmtMap::Build(AC->getCFG(),
-                                                &AC->getParentMap());
+      const CFGStmtMap *CBM = AC->getCFGStmtMap();
 
       // If we can trace back
       if (!pathWasCompletelyAnalyzed(AC->getCFG(),
                                      CBM->getBlock(B), CBM,
                                      Eng.getCoreEngine()))
         continue;
-
-      delete CBM;
     }
 
     // Select the error message and SourceRanges to report.





More information about the cfe-commits mailing list