Rename AnalyzerOptions 'EagerlyAssume' to 'eagerlyAssumeBinOpBifurcation'.

llvm-svn: 162930
This commit is contained in:
Ted Kremenek 2012-08-30 19:26:48 +00:00
parent 8756c4a1a9
commit 6f5131f149
5 changed files with 27 additions and 26 deletions

View File

@ -109,14 +109,13 @@ public:
/// \brief The flag regulates if we should eagerly assume evaluations of /// \brief The flag regulates if we should eagerly assume evaluations of
/// conditionals, thus, bifurcating the path. /// conditionals, thus, bifurcating the path.
/// ///
/// EagerlyAssume - A flag indicating how the engine should handle /// This flag indicates how the engine should handle expressions such as: 'x =
/// expressions such as: 'x = (y != 0)'. When this flag is true then /// (y != 0)'. When this flag is true then the subexpression 'y != 0' will be
/// the subexpression 'y != 0' will be eagerly assumed to be true or false, /// eagerly assumed to be true or false, thus evaluating it to the integers 0
/// thus evaluating it to the integers 0 or 1 respectively. The upside /// or 1 respectively. The upside is that this can increase analysis
/// is that this can increase analysis precision until we have a better way /// precision until we have a better way to lazily evaluate such logic. The
/// to lazily evaluate such logic. The downside is that it eagerly /// downside is that it eagerly bifurcates paths.
/// bifurcates paths. unsigned eagerlyAssumeBinOpBifurcation : 1;
unsigned EagerlyAssume : 1;
unsigned TrimGraph : 1; unsigned TrimGraph : 1;
unsigned VisualizeEGDot : 1; unsigned VisualizeEGDot : 1;
@ -150,7 +149,7 @@ public:
AnalyzeAll = 0; AnalyzeAll = 0;
AnalyzerDisplayProgress = 0; AnalyzerDisplayProgress = 0;
AnalyzeNestedBlocks = 0; AnalyzeNestedBlocks = 0;
EagerlyAssume = 0; eagerlyAssumeBinOpBifurcation = 0;
TrimGraph = 0; TrimGraph = 0;
VisualizeEGDot = 0; VisualizeEGDot = 0;
VisualizeEGUbi = 0; VisualizeEGUbi = 0;

View File

@ -396,14 +396,14 @@ public:
ExplodedNode *Pred, ExplodedNode *Pred,
ExplodedNodeSet &Dst); ExplodedNodeSet &Dst);
/// evalEagerlyAssume - Given the nodes in 'Src', eagerly assume symbolic /// evalEagerlyAssumeBinOpBifurcation - Given the nodes in 'Src', eagerly assume symbolic
/// expressions of the form 'x != 0' and generate new nodes (stored in Dst) /// expressions of the form 'x != 0' and generate new nodes (stored in Dst)
/// with those assumptions. /// with those assumptions.
void evalEagerlyAssume(ExplodedNodeSet &Dst, ExplodedNodeSet &Src, void evalEagerlyAssumeBinOpBifurcation(ExplodedNodeSet &Dst, ExplodedNodeSet &Src,
const Expr *Ex); const Expr *Ex);
std::pair<const ProgramPointTag *, const ProgramPointTag*> std::pair<const ProgramPointTag *, const ProgramPointTag*>
getEagerlyAssumeTags(); geteagerlyAssumeBinOpBifurcationTags();
SVal evalMinus(SVal X) { SVal evalMinus(SVal X) {
return X.isValid() ? svalBuilder.evalMinus(cast<NonLoc>(X)) : X; return X.isValid() ? svalBuilder.evalMinus(cast<NonLoc>(X)) : X;

View File

@ -159,7 +159,7 @@ static void AnalyzerOptsToArgs(const AnalyzerOptions &Opts, ToArgsList &Res) {
Res.push_back("-analyzer-display-progress"); Res.push_back("-analyzer-display-progress");
if (Opts.AnalyzeNestedBlocks) if (Opts.AnalyzeNestedBlocks)
Res.push_back("-analyzer-opt-analyze-nested-blocks"); Res.push_back("-analyzer-opt-analyze-nested-blocks");
if (Opts.EagerlyAssume) if (Opts.eagerlyAssumeBinOpBifurcation)
Res.push_back("-analyzer-eagerly-assume"); Res.push_back("-analyzer-eagerly-assume");
if (Opts.TrimGraph) if (Opts.TrimGraph)
Res.push_back("-trim-egraph"); Res.push_back("-trim-egraph");
@ -1123,7 +1123,7 @@ static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
Opts.AnalyzerDisplayProgress = Args.hasArg(OPT_analyzer_display_progress); Opts.AnalyzerDisplayProgress = Args.hasArg(OPT_analyzer_display_progress);
Opts.AnalyzeNestedBlocks = Opts.AnalyzeNestedBlocks =
Args.hasArg(OPT_analyzer_opt_analyze_nested_blocks); Args.hasArg(OPT_analyzer_opt_analyze_nested_blocks);
Opts.EagerlyAssume = Args.hasArg(OPT_analyzer_eagerly_assume); Opts.eagerlyAssumeBinOpBifurcation = Args.hasArg(OPT_analyzer_eagerly_assume);
Opts.AnalyzeSpecificFunction = Args.getLastArgValue(OPT_analyze_function); Opts.AnalyzeSpecificFunction = Args.getLastArgValue(OPT_analyze_function);
Opts.UnoptimizedCFG = Args.hasArg(OPT_analysis_UnoptimizedCFG); Opts.UnoptimizedCFG = Args.hasArg(OPT_analysis_UnoptimizedCFG);
Opts.CFGAddImplicitDtors = Args.hasArg(OPT_analysis_CFGAddImplicitDtors); Opts.CFGAddImplicitDtors = Args.hasArg(OPT_analysis_CFGAddImplicitDtors);

View File

@ -646,7 +646,7 @@ PathDiagnosticPiece *ConditionBRVisitor::VisitNodeImpl(const ExplodedNode *N,
// violation. // violation.
const std::pair<const ProgramPointTag *, const ProgramPointTag *> &tags = const std::pair<const ProgramPointTag *, const ProgramPointTag *> &tags =
cast<GRBugReporter>(BRC.getBugReporter()). cast<GRBugReporter>(BRC.getBugReporter()).
getEngine().getEagerlyAssumeTags(); getEngine().geteagerlyAssumeBinOpBifurcationTags();
const ProgramPointTag *tag = PS->getTag(); const ProgramPointTag *tag = PS->getTag();
if (tag == tags.first) if (tag == tags.first)

View File

@ -704,11 +704,11 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
Bldr.takeNodes(Pred); Bldr.takeNodes(Pred);
if (AMgr.options.EagerlyAssume && if (AMgr.options.eagerlyAssumeBinOpBifurcation &&
(B->isRelationalOp() || B->isEqualityOp())) { (B->isRelationalOp() || B->isEqualityOp())) {
ExplodedNodeSet Tmp; ExplodedNodeSet Tmp;
VisitBinaryOperator(cast<BinaryOperator>(S), Pred, Tmp); VisitBinaryOperator(cast<BinaryOperator>(S), Pred, Tmp);
evalEagerlyAssume(Dst, Tmp, cast<Expr>(S)); evalEagerlyAssumeBinOpBifurcation(Dst, Tmp, cast<Expr>(S));
} }
else else
VisitBinaryOperator(cast<BinaryOperator>(S), Pred, Dst); VisitBinaryOperator(cast<BinaryOperator>(S), Pred, Dst);
@ -924,10 +924,10 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
case Stmt::UnaryOperatorClass: { case Stmt::UnaryOperatorClass: {
Bldr.takeNodes(Pred); Bldr.takeNodes(Pred);
const UnaryOperator *U = cast<UnaryOperator>(S); const UnaryOperator *U = cast<UnaryOperator>(S);
if (AMgr.options.EagerlyAssume && (U->getOpcode() == UO_LNot)) { if (AMgr.options.eagerlyAssumeBinOpBifurcation && (U->getOpcode() == UO_LNot)) {
ExplodedNodeSet Tmp; ExplodedNodeSet Tmp;
VisitUnaryOperator(U, Pred, Tmp); VisitUnaryOperator(U, Pred, Tmp);
evalEagerlyAssume(Dst, Tmp, U); evalEagerlyAssumeBinOpBifurcation(Dst, Tmp, U);
} }
else else
VisitUnaryOperator(U, Pred, Dst); VisitUnaryOperator(U, Pred, Dst);
@ -1736,15 +1736,17 @@ void ExprEngine::evalLocation(ExplodedNodeSet &Dst,
} }
std::pair<const ProgramPointTag *, const ProgramPointTag*> std::pair<const ProgramPointTag *, const ProgramPointTag*>
ExprEngine::getEagerlyAssumeTags() { ExprEngine::geteagerlyAssumeBinOpBifurcationTags() {
static SimpleProgramPointTag static SimpleProgramPointTag
EagerlyAssumeTrue("ExprEngine : Eagerly Assume True"), eagerlyAssumeBinOpBifurcationTrue("ExprEngine : Eagerly Assume True"),
EagerlyAssumeFalse("ExprEngine : Eagerly Assume False"); eagerlyAssumeBinOpBifurcationFalse("ExprEngine : Eagerly Assume False");
return std::make_pair(&EagerlyAssumeTrue, &EagerlyAssumeFalse); return std::make_pair(&eagerlyAssumeBinOpBifurcationTrue,
&eagerlyAssumeBinOpBifurcationFalse);
} }
void ExprEngine::evalEagerlyAssume(ExplodedNodeSet &Dst, ExplodedNodeSet &Src, void ExprEngine::evalEagerlyAssumeBinOpBifurcation(ExplodedNodeSet &Dst,
const Expr *Ex) { ExplodedNodeSet &Src,
const Expr *Ex) {
StmtNodeBuilder Bldr(Src, Dst, *currBldrCtx); StmtNodeBuilder Bldr(Src, Dst, *currBldrCtx);
for (ExplodedNodeSet::iterator I=Src.begin(), E=Src.end(); I!=E; ++I) { for (ExplodedNodeSet::iterator I=Src.begin(), E=Src.end(); I!=E; ++I) {
@ -1762,7 +1764,7 @@ void ExprEngine::evalEagerlyAssume(ExplodedNodeSet &Dst, ExplodedNodeSet &Src,
nonloc::SymbolVal *SEV = dyn_cast<nonloc::SymbolVal>(&V); nonloc::SymbolVal *SEV = dyn_cast<nonloc::SymbolVal>(&V);
if (SEV && SEV->isExpression()) { if (SEV && SEV->isExpression()) {
const std::pair<const ProgramPointTag *, const ProgramPointTag*> &tags = const std::pair<const ProgramPointTag *, const ProgramPointTag*> &tags =
getEagerlyAssumeTags(); geteagerlyAssumeBinOpBifurcationTags();
// First assume that the condition is true. // First assume that the condition is true.
if (ProgramStateRef StateTrue = state->assume(*SEV, true)) { if (ProgramStateRef StateTrue = state->assume(*SEV, true)) {