aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-12-09 00:17:49 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-12-09 00:17:49 +0000
commit4451746d8f658b51eaf15dd24664a488457063a9 (patch)
treea4d9c000b7d1edc0588a72295ea5a3a32f0be536
parent48977874cb351f452102f8c15528eb1d8c7387e6 (diff)
[libclang] Make sure we don't try to handle a CXCursor_NoDeclFound
passed to clang_findReferencesInFile. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146211 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--tools/libclang/CIndexHigh.cpp5
-rw-r--r--tools/libclang/CXCursor.cpp6
2 files changed, 9 insertions, 2 deletions
diff --git a/tools/libclang/CIndexHigh.cpp b/tools/libclang/CIndexHigh.cpp
index bbb6d6dcad..4eabefb925 100644
--- a/tools/libclang/CIndexHigh.cpp
+++ b/tools/libclang/CIndexHigh.cpp
@@ -344,6 +344,11 @@ void clang_findReferencesInFile(CXCursor cursor, CXFile file,
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";
diff --git a/tools/libclang/CXCursor.cpp b/tools/libclang/CXCursor.cpp
index b4b9ed9d30..5117a4d2b3 100644
--- a/tools/libclang/CXCursor.cpp
+++ b/tools/libclang/CXCursor.cpp
@@ -746,8 +746,10 @@ ASTContext &cxcursor::getCursorContext(CXCursor Cursor) {
}
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) {