From: Argyrios Kyrtzidis Date: Wed, 16 Jan 2013 17:04:31 +0000 (+0000) Subject: [libclang] In clang_getCursorType, don't crash if the translation unit is not X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=93cf969df9afb22028aa8b4d575fa55681d1ec56;p=clang [libclang] In clang_getCursorType, don't crash if the translation unit is not set on the cursor; return a null type in such a case. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172625 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/libclang/CXType.cpp b/tools/libclang/CXType.cpp index 88c0e51181..d7751d2071 100644 --- a/tools/libclang/CXType.cpp +++ b/tools/libclang/CXType.cpp @@ -131,6 +131,9 @@ CXType clang_getCursorType(CXCursor C) { using namespace cxcursor; CXTranslationUnit TU = cxcursor::getCursorTU(C); + if (!TU) + return MakeCXType(QualType(), TU); + ASTContext &Context = static_cast(TU->TUData)->getASTContext(); if (clang_isExpression(C.kind)) { QualType T = cxcursor::getCursorExpr(C)->getType();