forked from OSchip/llvm-project
Restructure DereferenceChecker slightly to handle caching out when we would report a null dereference more than once.
llvm-svn: 89526
This commit is contained in:
parent
caf2c51fad
commit
9d6daf2cc4
|
@ -82,29 +82,32 @@ void DereferenceChecker::VisitLocation(CheckerContext &C, const Stmt *S,
|
|||
|
||||
// The explicit NULL case.
|
||||
if (nullState) {
|
||||
// Generate an error node.
|
||||
ExplodedNode *N = C.GenerateNode(S, nullState, true);
|
||||
if (N) {
|
||||
if (!notNullState) {
|
||||
// We know that 'location' cannot be non-null. This is what
|
||||
// we call an "explicit" null dereference.
|
||||
if (!BT_null)
|
||||
BT_null = new BuiltinBug("Null pointer dereference",
|
||||
"Dereference of null pointer");
|
||||
|
||||
EnhancedBugReport *report =
|
||||
new EnhancedBugReport(*BT_null, BT_null->getDescription(), N);
|
||||
report->addVisitorCreator(bugreporter::registerTrackNullOrUndefValue,
|
||||
bugreporter::GetDerefExpr(N));
|
||||
|
||||
C.EmitReport(report);
|
||||
if (!notNullState) {
|
||||
// Generate an error node.
|
||||
ExplodedNode *N = C.GenerateNode(S, nullState, true);
|
||||
if (!N)
|
||||
return;
|
||||
}
|
||||
|
||||
// We know that 'location' cannot be non-null. This is what
|
||||
// we call an "explicit" null dereference.
|
||||
if (!BT_null)
|
||||
BT_null = new BuiltinBug("Null pointer dereference",
|
||||
"Dereference of null pointer");
|
||||
|
||||
EnhancedBugReport *report =
|
||||
new EnhancedBugReport(*BT_null, BT_null->getDescription(), N);
|
||||
report->addVisitorCreator(bugreporter::registerTrackNullOrUndefValue,
|
||||
bugreporter::GetDerefExpr(N));
|
||||
|
||||
C.EmitReport(report);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
// Otherwise, we have the case where the location could either be
|
||||
// null or not-null. Record the error node as an "implicit" null
|
||||
// dereference.
|
||||
ImplicitNullDerefNodes.push_back(N);
|
||||
// dereference.
|
||||
if (ExplodedNode *N = C.GenerateNode(S, nullState, true))
|
||||
ImplicitNullDerefNodes.push_back(N);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue