[cfe-commits] r172625 - /cfe/trunk/tools/libclang/CXType.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Wed Jan 16 09:04:31 PST 2013


Author: akirtzidis
Date: Wed Jan 16 11:04:31 2013
New Revision: 172625

URL: http://llvm.org/viewvc/llvm-project?rev=172625&view=rev
Log:
[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.

Modified:
    cfe/trunk/tools/libclang/CXType.cpp

Modified: cfe/trunk/tools/libclang/CXType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXType.cpp?rev=172625&r1=172624&r2=172625&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXType.cpp (original)
+++ cfe/trunk/tools/libclang/CXType.cpp Wed Jan 16 11:04:31 2013
@@ -131,6 +131,9 @@
   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();





More information about the cfe-commits mailing list