[cfe-commits] r146211 - in /cfe/trunk/tools/libclang: CIndexHigh.cpp CXCursor.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Thu Dec 8 16:17:50 PST 2011


Author: akirtzidis
Date: Thu Dec  8 18:17:49 2011
New Revision: 146211

URL: http://llvm.org/viewvc/llvm-project?rev=146211&view=rev
Log:
[libclang] Make sure we don't try to handle a CXCursor_NoDeclFound
passed to clang_findReferencesInFile.

Modified:
    cfe/trunk/tools/libclang/CIndexHigh.cpp
    cfe/trunk/tools/libclang/CXCursor.cpp

Modified: cfe/trunk/tools/libclang/CIndexHigh.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexHigh.cpp?rev=146211&r1=146210&r2=146211&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndexHigh.cpp (original)
+++ cfe/trunk/tools/libclang/CIndexHigh.cpp Thu Dec  8 18:17:49 2011
@@ -344,6 +344,11 @@
       llvm::errs() << "clang_findReferencesInFile: Null cursor\n";
     return;
   }
+  if (cursor.kind == CXCursor_NoDeclFound) {
+    if (Logging)
+      llvm::errs() << "clang_findReferencesInFile: Got CXCursor_NoDeclFound\n";
+    return;
+  }
   if (!file) {
     if (Logging)
       llvm::errs() << "clang_findReferencesInFile: Null file\n";

Modified: cfe/trunk/tools/libclang/CXCursor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=146211&r1=146210&r2=146211&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXCursor.cpp (original)
+++ cfe/trunk/tools/libclang/CXCursor.cpp Thu Dec  8 18:17:49 2011
@@ -746,8 +746,10 @@
 }
 
 ASTUnit *cxcursor::getCursorASTUnit(CXCursor Cursor) {
-  return static_cast<ASTUnit *>(static_cast<CXTranslationUnit>(Cursor.data[2])
-                                  ->TUData);
+  CXTranslationUnit TU = static_cast<CXTranslationUnit>(Cursor.data[2]);
+  if (!TU)
+    return 0;
+  return static_cast<ASTUnit *>(TU->TUData);
 }
 
 CXTranslationUnit cxcursor::getCursorTU(CXCursor Cursor) {





More information about the cfe-commits mailing list