Make PathDiagnosticLocation more resilient to null Stmt pointers.
llvm-svn: 147854
This commit is contained in:
parent
a04d2b3330
commit
c07e34ceed
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue