]> granicus.if.org Git - clang/commitdiff
Guard in USRGenerator::GenLoc() against null Decl* from invalid code.
authorTed Kremenek <kremenek@apple.com>
Fri, 29 Apr 2011 21:35:23 +0000 (21:35 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 29 Apr 2011 21:35:23 +0000 (21:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130541 91177308-0d34-0410-b5e6-96231b3b80d8

tools/libclang/CIndexUSRs.cpp

index 68871e94951cd9fcd09d98f1862599bad2147cdd..9917d2ad21042cfafe5ff1c770ccf69403596392 100644 (file)
@@ -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();