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 68871e9..9917d2a 100644
--- a/tools/libclang/CIndexUSRs.cpp
+++ b/tools/libclang/CIndexUSRs.cpp
@@ -470,6 +470,12 @@
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();