From 9e63dc582b3bfb9ab2e80631b5311b070a73dff8 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 17 Aug 2012 00:55:32 +0000 Subject: [PATCH] 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 --- lib/Basic/Diagnostic.cpp | 3 +++ 1 file changed, 3 insertions(+) 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; -- 2.40.0