[libclang] In clang_getCursorType, don't crash if the translation unit is not
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 16 Jan 2013 17:04:31 +0000 (17:04 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 16 Jan 2013 17:04:31 +0000 (17:04 +0000)
set on the cursor; return a null type in such a case.

llvm-svn: 172625

clang/tools/libclang/CXType.cpp

index 88c0e51..d7751d2 100644 (file)
@@ -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<ASTUnit *>(TU->TUData)->getASTContext();
   if (clang_isExpression(C.kind)) {
     QualType T = cxcursor::getCursorExpr(C)->getType();