[cfe-commits] r153062 - /cfe/trunk/tools/libclang/CIndex.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Mon Mar 19 16:17:59 PDT 2012
Author: akirtzidis
Date: Mon Mar 19 18:17:58 2012
New Revision: 153062
URL: http://llvm.org/viewvc/llvm-project?rev=153062&view=rev
Log:
[libclang] Have clang_getCursorExtent() return the range of the main file when
the passed cursor is the translation unit cursor.
Patch by Clint Caywood!
Modified:
cfe/trunk/tools/libclang/CIndex.cpp
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=153062&r1=153061&r2=153062&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Mon Mar 19 18:17:58 2012
@@ -3869,6 +3869,14 @@
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)
More information about the cfe-commits
mailing list