#include "clang/Analysis/LocalCheckers.h"
#include "clang/Analysis/PathSensitive/GRTransferFuncs.h"
#include "clang/Analysis/PathSensitive/GRExprEngine.h"
+#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Streams.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Path.h"
using namespace clang;
static ExplodedNodeImpl::Auditor* CreateUbiViz();
+
+// Analyzer options.
+static llvm::cl::opt<bool>
+PurgeDead("analyzer-purge-dead",
+ llvm::cl::init(true),
+ llvm::cl::desc("Remove dead symbols, bindings, and constraints before"
+ " processing a statement."));
//===----------------------------------------------------------------------===//
// Basic type definitions.
const std::string& fname,
const std::string& htmldir,
AnalysisStores sm, AnalysisDiagClients dc,
- bool visgraphviz, bool visubi, bool trim, bool analyzeAll)
+ bool visgraphviz, bool visubi, bool trim, bool analyzeAll)
: VisGraphviz(visgraphviz), VisUbigraph(visubi), TrimGraph(trim),
LOpts(lopts), Diags(diags),
Ctx(0), PP(pp), PPF(ppf),
public:
AnalysisManager(AnalysisConsumer& c, Decl* d, Stmt* b)
- : D(d), Body(b), TU(0), AScope(ScopeDecl), C(c), DisplayedFunction(false) {
+ : D(d), Body(b), TU(0), AScope(ScopeDecl), C(c), DisplayedFunction(false){
setManagerCreators();
}
AnalysisManager(AnalysisConsumer& c, TranslationUnit* tu)
- : D(0), Body(0), TU(tu), AScope(ScopeTU), C(c), DisplayedFunction(false) {
+ : D(0), Body(0), TU(tu), AScope(ScopeTU), C(c), DisplayedFunction(false) {
setManagerCreators();
}
if (!L) return;
GRExprEngine Eng(*mgr.getCFG(), *mgr.getCodeDecl(), mgr.getContext(), *L,
+ PurgeDead,
mgr.getStoreManagerCreator(),
mgr.getConstraintManagerCreator());
GRExprEngine::GRExprEngine(CFG& cfg, Decl& CD, ASTContext& Ctx,
- LiveVariables& L,
+ LiveVariables& L, bool purgeDead,
StoreManagerCreator SMC,
ConstraintManagerCreator CMC)
: CoreEngine(cfg, CD, Ctx, *this),
G(CoreEngine.getGraph()),
Liveness(L),
+ PurgeDead(purgeDead),
Builder(NULL),
StateMgr(G.getContext(), SMC, CMC, G.getAllocator(), cfg, CD, L),
SymMgr(StateMgr.getSymbolManager()),
Builder->setAuditor(BatchAuditor.get());
// Create the cleaned state.
- CleanedState = StateMgr.RemoveDeadBindings(EntryNode->getState(), CurrentStmt,
- Liveness, DeadSymbols);
+ if (PurgeDead)
+ CleanedState = StateMgr.RemoveDeadBindings(EntryNode->getState(),
+ CurrentStmt,
+ Liveness, DeadSymbols);
+ else
+ CleanedState = EntryNode->getState();
// Process any special transfer function for dead symbols.
NodeSet Tmp;