From: Richard Smith Date: Fri, 17 Aug 2012 00:55:32 +0000 (+0000) Subject: Avoid binding a reference to a dereferenced null pointer, if we try to emit a X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9e63dc582b3bfb9ab2e80631b5311b070a73dff8;p=clang Avoid binding a reference to a dereferenced null pointer, if we try to emit a diagnostic before we have a source manager. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162070 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp index 2c49c2f760..8065b2d98f 100644 --- a/lib/Basic/Diagnostic.cpp +++ b/lib/Basic/Diagnostic.cpp @@ -145,6 +145,9 @@ DiagnosticsEngine::GetDiagStatePointForLoc(SourceLocation L) const { assert(DiagStatePoints.front().Loc.isInvalid() && "Should have created a DiagStatePoint for command-line"); + if (!SourceMgr) + return DiagStatePoints.end() - 1; + FullSourceLoc Loc(L, *SourceMgr); if (Loc.isInvalid()) return DiagStatePoints.end() - 1;