[cfe-commits] r61319 - in /cfe/trunk: Driver/AnalysisConsumer.cpp include/clang/Analysis/PathSensitive/GRExprEngine.h lib/Analysis/GRExprEngine.cpp test/Analysis/null-deref-ps.c
Zhongxing Xu
xuzhongxing at gmail.com
Sun Dec 21 17:52:38 PST 2008
Author: zhongxingxu
Date: Sun Dec 21 19:52:37 2008
New Revision: 61319
URL: http://llvm.org/viewvc/llvm-project?rev=61319&view=rev
Log:
Add an option to make 'RemoveDeadBindings' a configurable behavior. This enables
us to measure the effect of this optimization.
Modified:
cfe/trunk/Driver/AnalysisConsumer.cpp
cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
cfe/trunk/lib/Analysis/GRExprEngine.cpp
cfe/trunk/test/Analysis/null-deref-ps.c
Modified: cfe/trunk/Driver/AnalysisConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/AnalysisConsumer.cpp?rev=61319&r1=61318&r2=61319&view=diff
==============================================================================
--- cfe/trunk/Driver/AnalysisConsumer.cpp (original)
+++ cfe/trunk/Driver/AnalysisConsumer.cpp Sun Dec 21 19:52:37 2008
@@ -31,6 +31,7 @@
#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"
@@ -40,6 +41,13 @@
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.
@@ -85,7 +93,7 @@
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),
@@ -136,12 +144,12 @@
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();
}
@@ -403,6 +411,7 @@
if (!L) return;
GRExprEngine Eng(*mgr.getCFG(), *mgr.getCodeDecl(), mgr.getContext(), *L,
+ PurgeDead,
mgr.getStoreManagerCreator(),
mgr.getConstraintManagerCreator());
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h?rev=61319&r1=61318&r2=61319&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h Sun Dec 21 19:52:37 2008
@@ -92,6 +92,9 @@
Selector RaiseSel;
llvm::OwningPtr<GRSimpleAPICheck> BatchAuditor;
+
+ /// PurgeDead - Remove dead bindings before processing a statement.
+ bool PurgeDead;
public:
typedef llvm::SmallPtrSet<NodeTy*,2> ErrorNodes;
@@ -178,6 +181,7 @@
public:
GRExprEngine(CFG& cfg, Decl& CD, ASTContext& Ctx, LiveVariables& L,
+ bool purgeDead,
StoreManagerCreator SMC = CreateBasicStoreManager,
ConstraintManagerCreator CMC = CreateBasicConstraintManager);
Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=61319&r1=61318&r2=61319&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Sun Dec 21 19:52:37 2008
@@ -115,12 +115,13 @@
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()),
@@ -211,8 +212,12 @@
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;
Modified: cfe/trunk/test/Analysis/null-deref-ps.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/null-deref-ps.c?rev=61319&r1=61318&r2=61319&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/null-deref-ps.c (original)
+++ cfe/trunk/test/Analysis/null-deref-ps.c Sun Dec 21 19:52:37 2008
@@ -1,5 +1,5 @@
-// RUN: clang -std=gnu99 -checker-simple -verify %s
-// DISABLE: clang -std=gnu99 -checker-simple -analyzer-store-region -verify %s
+// RUN: clang -std=gnu99 -checker-simple -verify %s &&
+// RUN: clang -std=gnu99 -checker-simple -analyzer-store-region -analyzer-purge-dead=false -verify %s
#include<stdint.h>
#include <assert.h>
More information about the cfe-commits
mailing list