Fix undefined behavior: reference bound to dereferenced null pointer.

llvm-svn: 161899
This commit is contained in:
Richard Smith 2012-08-14 22:37:22 +00:00
parent a6e89aac91
commit 8a0527d54e

View File

@ -167,8 +167,9 @@ void DiagnosticsEngine::setDiagnosticMapping(diag::kind Diag, diag::Mapping Map,
(Map == diag::MAP_FATAL || Map == diag::MAP_ERROR)) &&
"Cannot map errors into warnings!");
assert(!DiagStatePoints.empty());
assert((L.isInvalid() || SourceMgr) && "No SourceMgr for valid location");
FullSourceLoc Loc(L, *SourceMgr);
FullSourceLoc Loc = SourceMgr? FullSourceLoc(L, *SourceMgr) : FullSourceLoc();
FullSourceLoc LastStateChangePos = DiagStatePoints.back().Loc;
// Don't allow a mapping to a warning override an error/fatal mapping.
if (Map == diag::MAP_WARNING) {