[cfe-commits] r76450 - in /cfe/trunk: include/clang/Analysis/PathSensitive/GRCoreEngine.h lib/Analysis/GRCoreEngine.cpp lib/Analysis/GRExprEngine.cpp
Ted Kremenek
kremenek at apple.com
Mon Jul 20 11:44:37 PDT 2009
Author: kremenek
Date: Mon Jul 20 13:44:36 2009
New Revision: 76450
URL: http://llvm.org/viewvc/llvm-project?rev=76450&view=rev
Log:
Enhance GRBranchNodeBuilderImpl (part of GRCoreEngine) to understand the case
where the true or false CFGBlock* for a branch could be NULL. This will handle
the case where we can determine during CFG construction that a branch is
infeasible.
Modified:
cfe/trunk/include/clang/Analysis/PathSensitive/GRCoreEngine.h
cfe/trunk/lib/Analysis/GRCoreEngine.cpp
cfe/trunk/lib/Analysis/GRExprEngine.cpp
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRCoreEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRCoreEngine.h?rev=76450&r1=76449&r2=76450&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRCoreEngine.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRCoreEngine.h Mon Jul 20 13:44:36 2009
@@ -311,12 +311,15 @@
bool GeneratedTrue;
bool GeneratedFalse;
+ bool InFeasibleTrue;
+ bool InFeasibleFalse;
public:
GRBranchNodeBuilderImpl(CFGBlock* src, CFGBlock* dstT, CFGBlock* dstF,
ExplodedNodeImpl* pred, GRCoreEngineImpl* e)
: Eng(*e), Src(src), DstT(dstT), DstF(dstF), Pred(pred),
- GeneratedTrue(false), GeneratedFalse(false) {}
+ GeneratedTrue(false), GeneratedFalse(false),
+ InFeasibleTrue(!DstT), InFeasibleFalse(!DstF) {}
~GRBranchNodeBuilderImpl();
@@ -331,8 +334,14 @@
}
void markInfeasible(bool branch) {
- if (branch) GeneratedTrue = true;
- else GeneratedFalse = true;
+ if (branch)
+ InFeasibleTrue = GeneratedTrue = true;
+ else
+ InFeasibleFalse = GeneratedFalse = true;
+ }
+
+ bool isFeasible(bool branch) {
+ return branch ? !InFeasibleTrue : !InFeasibleFalse;
}
};
@@ -374,6 +383,10 @@
void markInfeasible(bool branch) {
NB.markInfeasible(branch);
}
+
+ bool isFeasible(bool branch) {
+ return NB.isFeasible(branch);
+ }
};
class GRIndirectGotoNodeBuilderImpl {
Modified: cfe/trunk/lib/Analysis/GRCoreEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRCoreEngine.cpp?rev=76450&r1=76449&r2=76450&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/GRCoreEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRCoreEngine.cpp Mon Jul 20 13:44:36 2009
@@ -452,7 +452,12 @@
}
ExplodedNodeImpl* GRBranchNodeBuilderImpl::generateNodeImpl(const void* State,
- bool branch) {
+ bool branch) {
+
+ // If the branch has been marked infeasible we should not generate a node.
+ if (!isFeasible(branch))
+ return NULL;
+
bool IsNew;
ExplodedNodeImpl* Succ =
@@ -460,8 +465,10 @@
Succ->addPredecessor(Pred);
- if (branch) GeneratedTrue = true;
- else GeneratedFalse = true;
+ if (branch)
+ GeneratedTrue = true;
+ else
+ GeneratedFalse = true;
if (IsNew) {
Deferred.push_back(Succ);
Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=76450&r1=76449&r2=76450&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Mon Jul 20 13:44:36 2009
@@ -706,16 +706,20 @@
}
// Process the true branch.
- if (const GRState *state = PrevState->assume(V, true))
- builder.generateNode(MarkBranch(state, Term, true), true);
- else
- builder.markInfeasible(true);
+ if (builder.isFeasible(true)) {
+ if (const GRState *state = PrevState->assume(V, true))
+ builder.generateNode(MarkBranch(state, Term, true), true);
+ else
+ builder.markInfeasible(true);
+ }
// Process the false branch.
- if (const GRState *state = PrevState->assume(V, false))
- builder.generateNode(MarkBranch(state, Term, false), false);
- else
- builder.markInfeasible(false);
+ if (builder.isFeasible(false)) {
+ if (const GRState *state = PrevState->assume(V, false))
+ builder.generateNode(MarkBranch(state, Term, false), false);
+ else
+ builder.markInfeasible(false);
+ }
}
/// ProcessIndirectGoto - Called by GRCoreEngine. Used to generate successor
More information about the cfe-commits
mailing list