Make PathDiagnosticLocation more resilient to null Stmt pointers.

llvm-svn: 147854
This commit is contained in:
Ted Kremenek 2012-01-10 15:26:13 +00:00
parent a04d2b3330
commit c07e34ceed
2 changed files with 8 additions and 0 deletions

View File

@ -129,6 +129,7 @@ public:
: K(StmtK), S(s), D(0), SM(&sm),
Loc(genLocation(SourceLocation(), lac)),
Range(genRange(lac)) {
assert(S);
assert(Loc.isValid());
assert(Range.isValid());
}
@ -137,6 +138,7 @@ public:
PathDiagnosticLocation(const Decl *d, const SourceManager &sm)
: K(DeclK), S(0), D(d), SM(&sm),
Loc(genLocation()), Range(genRange()) {
assert(D);
assert(Loc.isValid());
assert(Range.isValid());
}

View File

@ -237,9 +237,15 @@ FullSourceLoc
case RangeK:
break;
case StmtK:
// Defensive checking.
if (!S)
break;
return FullSourceLoc(getValidSourceLocation(S, LAC),
const_cast<SourceManager&>(*SM));
case DeclK:
// Defensive checking.
if (!D)
break;
return FullSourceLoc(D->getLocation(), const_cast<SourceManager&>(*SM));
}