Hi folks,<div><br></div><div>I'm new to this, but I've made a patch to libclang that allows it to properly get the range for a translation unit cursor (which I needed for a project I'm working on). It's pretty straightforward.</div>
<div><br></div><div>Thanks,</div><div>Clint</div><div><br></div><div><div>Index: tools/libclang/CIndex.cpp</div><div>===================================================================</div><div>--- tools/libclang/CIndex.cpp<span class="Apple-tab-span" style="white-space:pre"> </span>(revision 152526)</div>
<div>+++ tools/libclang/CIndex.cpp<span class="Apple-tab-span" style="white-space:pre"> </span>(working copy)</div><div>@@ -3869,6 +3869,15 @@</div><div> return TU->mapRangeFromPreamble(Range);</div><div> }</div>
<div> </div><div>+ if (C.kind == CXCursor_TranslationUnit) {</div><div>+ ASTUnit *TU = getCursorASTUnit(C);</div><div>+ FileID MainID = TU->getSourceManager().getMainFileID();</div><div>+ SourceLocation Start = TU->getSourceManager().getLocForStartOfFile(MainID);</div>
<div>+ SourceLocation End = TU->getSourceManager().getLocForEndOfFile(MainID);</div><div>+ SourceRange Range(Start, End);</div><div>+ return TU->mapRangeFromPreamble(Range);</div><div>+ }</div><div>+</div>
<div> if (C.kind >= CXCursor_FirstDecl && C.kind <= CXCursor_LastDecl) {</div><div> Decl *D = cxcursor::getCursorDecl(C);</div><div> if (!D)</div></div>