[analyzer] Remove unneeded code.

This region is set as interesting as part of trackNullOrUndefValue call,
no need to mark it as interesting twice.

llvm-svn: 163260
This commit is contained in:
Anna Zaks 2012-09-05 22:31:49 +00:00
parent 946f890b78
commit 1e2a0dc405
1 changed files with 8 additions and 18 deletions

View File

@ -39,7 +39,7 @@ public:
CheckerContext &C) const; CheckerContext &C) const;
void checkBind(SVal L, SVal V, const Stmt *S, CheckerContext &C) const; void checkBind(SVal L, SVal V, const Stmt *S, CheckerContext &C) const;
static const MemRegion *AddDerefSource(raw_ostream &os, static void AddDerefSource(raw_ostream &os,
SmallVectorImpl<SourceRange> &Ranges, SmallVectorImpl<SourceRange> &Ranges,
const Expr *Ex, const ProgramState *state, const Expr *Ex, const ProgramState *state,
const LocationContext *LCtx, const LocationContext *LCtx,
@ -47,7 +47,7 @@ public:
}; };
} // end anonymous namespace } // end anonymous namespace
const MemRegion * void
DereferenceChecker::AddDerefSource(raw_ostream &os, DereferenceChecker::AddDerefSource(raw_ostream &os,
SmallVectorImpl<SourceRange> &Ranges, SmallVectorImpl<SourceRange> &Ranges,
const Expr *Ex, const Expr *Ex,
@ -55,7 +55,6 @@ DereferenceChecker::AddDerefSource(raw_ostream &os,
const LocationContext *LCtx, const LocationContext *LCtx,
bool loadedFrom) { bool loadedFrom) {
Ex = Ex->IgnoreParenLValueCasts(); Ex = Ex->IgnoreParenLValueCasts();
const MemRegion *sourceR = 0;
switch (Ex->getStmtClass()) { switch (Ex->getStmtClass()) {
default: default:
break; break;
@ -65,7 +64,6 @@ DereferenceChecker::AddDerefSource(raw_ostream &os,
os << " (" << (loadedFrom ? "loaded from" : "from") os << " (" << (loadedFrom ? "loaded from" : "from")
<< " variable '" << VD->getName() << "')"; << " variable '" << VD->getName() << "')";
Ranges.push_back(DR->getSourceRange()); Ranges.push_back(DR->getSourceRange());
sourceR = state->getLValue(VD, LCtx).getAsRegion();
} }
break; break;
} }
@ -78,7 +76,6 @@ DereferenceChecker::AddDerefSource(raw_ostream &os,
break; break;
} }
} }
return sourceR;
} }
void DereferenceChecker::reportBug(ProgramStateRef State, const Stmt *S, void DereferenceChecker::reportBug(ProgramStateRef State, const Stmt *S,
@ -101,8 +98,6 @@ void DereferenceChecker::reportBug(ProgramStateRef State, const Stmt *S,
if (const Expr *expr = dyn_cast<Expr>(S)) if (const Expr *expr = dyn_cast<Expr>(S))
S = expr->IgnoreParenLValueCasts(); S = expr->IgnoreParenLValueCasts();
const MemRegion *sourceR = 0;
if (IsBind) { if (IsBind) {
if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(S)) { if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(S)) {
if (BO->isAssignmentOp()) if (BO->isAssignmentOp())
@ -120,7 +115,7 @@ void DereferenceChecker::reportBug(ProgramStateRef State, const Stmt *S,
llvm::raw_svector_ostream os(buf); llvm::raw_svector_ostream os(buf);
os << "Array access"; os << "Array access";
const ArraySubscriptExpr *AE = cast<ArraySubscriptExpr>(S); const ArraySubscriptExpr *AE = cast<ArraySubscriptExpr>(S);
sourceR = AddDerefSource(os, Ranges, AE->getBase()->IgnoreParenCasts(), AddDerefSource(os, Ranges, AE->getBase()->IgnoreParenCasts(),
State.getPtr(), N->getLocationContext()); State.getPtr(), N->getLocationContext());
os << " results in a null pointer dereference"; os << " results in a null pointer dereference";
break; break;
@ -129,7 +124,7 @@ void DereferenceChecker::reportBug(ProgramStateRef State, const Stmt *S,
llvm::raw_svector_ostream os(buf); llvm::raw_svector_ostream os(buf);
os << "Dereference of null pointer"; os << "Dereference of null pointer";
const UnaryOperator *U = cast<UnaryOperator>(S); const UnaryOperator *U = cast<UnaryOperator>(S);
sourceR = AddDerefSource(os, Ranges, U->getSubExpr()->IgnoreParens(), AddDerefSource(os, Ranges, U->getSubExpr()->IgnoreParens(),
State.getPtr(), N->getLocationContext(), true); State.getPtr(), N->getLocationContext(), true);
break; break;
} }
@ -139,7 +134,7 @@ void DereferenceChecker::reportBug(ProgramStateRef State, const Stmt *S,
llvm::raw_svector_ostream os(buf); llvm::raw_svector_ostream os(buf);
os << "Access to field '" << M->getMemberNameInfo() os << "Access to field '" << M->getMemberNameInfo()
<< "' results in a dereference of a null pointer"; << "' results in a dereference of a null pointer";
sourceR = AddDerefSource(os, Ranges, M->getBase()->IgnoreParenCasts(), AddDerefSource(os, Ranges, M->getBase()->IgnoreParenCasts(),
State.getPtr(), N->getLocationContext(), true); State.getPtr(), N->getLocationContext(), true);
} }
break; break;
@ -172,11 +167,6 @@ void DereferenceChecker::reportBug(ProgramStateRef State, const Stmt *S,
I = Ranges.begin(), E = Ranges.end(); I!=E; ++I) I = Ranges.begin(), E = Ranges.end(); I!=E; ++I)
report->addRange(*I); report->addRange(*I);
if (sourceR) {
report->markInteresting(sourceR);
report->markInteresting(State->getRawSVal(loc::MemRegionVal(sourceR)));
}
C.EmitReport(report); C.EmitReport(report);
} }