]> granicus.if.org Git - clang/commitdiff
[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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172625 91177308-0d34-0410-b5e6-96231b3b80d8

tools/libclang/CXType.cpp

index 88c0e511811858639788a0452e3d7e0a9273f120..d7751d20717aedd95817aefba2504a5180c40586 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();