aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-02-23 01:51:53 +0000
committerTed Kremenek <kremenek@apple.com>2011-02-23 01:51:53 +0000
commit283a358aecb75e30fcd486f2206f6c03c5e7f11d (patch)
tree46ead8f48df7882417d0aeecaa8fbcf57577c10c /lib
parent3ed6fc08a9cd293d012fa49ab2a615e618d7c3fa (diff)
Have IdempotentOperationsChecker pull its CFGStmtMap from AnalysisContext.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126288 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/AnalysisContext.cpp15
-rw-r--r--lib/Sema/AnalysisBasedWarnings.cpp1
-rw-r--r--lib/Sema/Sema.cpp2
-rw-r--r--lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp5
4 files changed, 18 insertions, 5 deletions
diff --git a/lib/Analysis/AnalysisContext.cpp b/lib/Analysis/AnalysisContext.cpp
index 5233d3b8f9..a982a5c5be 100644
--- a/lib/Analysis/AnalysisContext.cpp
+++ b/lib/Analysis/AnalysisContext.cpp
@@ -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 @@ CFG *AnalysisContext::getUnoptimizedCFG() {
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::getReferencedBlockVars(const BlockDecl *BD) {
AnalysisContext::~AnalysisContext() {
delete cfg;
delete completeCFG;
+ delete cfgStmtMap;
delete liveness;
delete relaxedLiveness;
delete PM;
diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp
index 7a1aceb4c6..adfa690a64 100644
--- a/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/lib/Sema/AnalysisBasedWarnings.cpp
@@ -480,6 +480,7 @@ clang::sema::AnalysisBasedWarnings::AnalysisBasedWarnings(Sema &s) : S(s) {
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
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index 1920f1e6fc..0827597abd 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -638,7 +638,7 @@ void Sema::PopFunctionOrBlockScope(const AnalysisBasedWarnings::Policy *WP,
// 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;
diff --git a/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp b/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp
index f49b125a60..0d2ccb955f 100644
--- a/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp
@@ -397,16 +397,13 @@ void IdempotentOperationChecker::VisitEndAnalysis(ExplodedGraph &G,
// 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.