aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-04-29 21:35:23 +0000
committerTed Kremenek <kremenek@apple.com>2011-04-29 21:35:23 +0000
commit8c367589b68019b040f73d44282fc30e4f526f62 (patch)
tree1270efe4b88a45d7a3c0458a89cb7e26b67cbb33
parent202e123d0d680af6d1754b22246ea63fb3604931 (diff)
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
-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();