diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-08-17 00:55:32 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-08-17 00:55:32 +0000 |
commit | 9e63dc582b3bfb9ab2e80631b5311b070a73dff8 (patch) | |
tree | 79eb97600a089aea345feaf61be34b593c680319 /lib | |
parent | aeb288123e51cbf5855b06eb9d8c108fd6124286 (diff) |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Basic/Diagnostic.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
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; |