aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/libclang/CIndexUSRs.cpp6
1 files changed, 6 insertions, 0 deletions
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();