From 8e5900c8e9bd32bcc385124f564f3d38a11d0e28 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 30 Apr 2012 23:41:16 +0000 Subject: clang_getCursorLexicalParent should return a translation unit cursor for declarations at the global scope, from Evan P. Fixes PR9083. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155858 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/libclang/CIndex.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools/libclang/CIndex.cpp') diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 0beb32d6c9..b2de22f23a 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -2831,8 +2831,8 @@ CXString clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit) { } CXCursor clang_getTranslationUnitCursor(CXTranslationUnit TU) { - CXCursor Result = { CXCursor_TranslationUnit, 0, { 0, 0, TU } }; - return Result; + ASTUnit *CXXUnit = static_cast(TU->TUData); + return MakeCXCursor(CXXUnit->getASTContext().getTranslationUnitDecl(), TU); } } // end: extern "C" -- cgit v1.2.3-70-g09d2