diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-03-19 23:17:58 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-03-19 23:17:58 +0000 |
commit | 0822c5f29d91a08697416b0d0be28dd3e71d945a (patch) | |
tree | a65db24771e2f821a97447cac39d1429d130ad8c /tools | |
parent | 4bcf3d0e3d07771839bb71edb8b64fa206a7909e (diff) |
[libclang] Have clang_getCursorExtent() return the range of the main file when
the passed cursor is the translation unit cursor.
Patch by Clint Caywood!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153062 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/libclang/CIndex.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 52a7cd6a5d..cb86c46ba4 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -3869,6 +3869,14 @@ static SourceRange getRawCursorExtent(CXCursor C) { return TU->mapRangeFromPreamble(Range); } + if (C.kind == CXCursor_TranslationUnit) { + ASTUnit *TU = getCursorASTUnit(C); + FileID MainID = TU->getSourceManager().getMainFileID(); + SourceLocation Start = TU->getSourceManager().getLocForStartOfFile(MainID); + SourceLocation End = TU->getSourceManager().getLocForEndOfFile(MainID); + return SourceRange(Start, End); + } + if (C.kind >= CXCursor_FirstDecl && C.kind <= CXCursor_LastDecl) { Decl *D = cxcursor::getCursorDecl(C); if (!D) |