Introduce a special cursor kind for the translation unit, to serve as
the root of the conceptual cursor hierarchy (just like we do with
declarations). This will be used when we get to unify
clang_loadTranslationUnit() and clang_loadDeclaration() into something
more generally useful.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93954 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/CIndex/CXCursor.cpp b/tools/CIndex/CXCursor.cpp
index f13e2ee..7dd3ae9 100644
--- a/tools/CIndex/CXCursor.cpp
+++ b/tools/CIndex/CXCursor.cpp
@@ -14,6 +14,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "CXCursor.h"
+#include "clang/Frontend/ASTUnit.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/Expr.h"
@@ -320,6 +321,10 @@
   case CXCursor_UnexposedStmt:
     return static_cast<Decl *>(Cursor.data[0])->getASTContext();
 
+  case CXCursor_TranslationUnit: {
+    ASTUnit *CXXUnit = static_cast<ASTUnit *>(Cursor.data[0]);
+    return CXXUnit->getASTContext();
+  }
   }
   
   llvm_unreachable("No context available");