class Stmt;
class CFG;
class CFGBlock;
+class CFGStmtMap;
class LiveVariables;
class ParentMap;
class PseudoConstantAnalysis;
// AnalysisContext owns the following data.
CFG *cfg, *completeCFG;
+ CFGStmtMap *cfgStmtMap;
bool builtCFG, builtCompleteCFG;
LiveVariables *liveness;
LiveVariables *relaxedLiveness;
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),
Stmt *getBody();
CFG *getCFG();
+
+ CFGStmtMap *getCFGStmtMap();
/// Return a version of the CFG without any edges pruned.
CFG *getUnoptimizedCFG();
class ObjCMethodDecl;
class QualType;
class Sema;
+namespace sema {
+ class FunctionScopeInfo;
+}
namespace sema {
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; }
};
#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"
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());
}
AnalysisContext::~AnalysisContext() {
delete cfg;
delete completeCFG;
+ delete cfgStmtMap;
delete liveness;
delete relaxedLiveness;
delete PM;
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
// 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;
// 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.