From: Ted Kremenek Date: Fri, 29 Apr 2011 21:35:23 +0000 (+0000) Subject: Guard in USRGenerator::GenLoc() against null Decl* from invalid code. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8c367589b68019b040f73d44282fc30e4f526f62;p=clang Guard in USRGenerator::GenLoc() against null Decl* from invalid code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130541 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/libclang/CIndexUSRs.cpp b/tools/libclang/CIndexUSRs.cpp index 68871e9495..9917d2ad21 100644 --- a/tools/libclang/CIndexUSRs.cpp +++ b/tools/libclang/CIndexUSRs.cpp @@ -470,6 +470,12 @@ bool USRGenerator::GenLoc(const Decl *D) { if (generatedLoc) return IgnoreResults; generatedLoc = true; + + // Guard against null declarations in invalid code. + if (!D) { + IgnoreResults = true; + return true; + } const SourceManager &SM = AU->getSourceManager(); SourceLocation L = D->getLocStart();