[cfe-commits] [PATCH] Bug 9083 - clang_getCursorLexicalParent should return a translation unit cursor for declarations at the global scope

Evan P hiwrac at gmail.com
Sun Apr 22 14:48:42 PDT 2012


Didn't get any bites on this in cfe-dev, hopefully now that 3.1 has
branched I can get a comment or two on this.



This is my first real deep dive into the clang guts, so I am submitting
this patch to the dev list rather than commits so that it can get extra
reviewing and critiquing.

2 Changes:

1) Cursors created from translation unit declarations will now be of kind
CXCursor_TranslationUnit rather than the default CXCursor_UnexposedDecl

2) Cursor created by clang_getTranslationUnitCursor is now created with
MakeCXCursor and includes the translation unit decl.  This ensures that the
cursor returned by clang_getTranslationUnitCursor and
clang_getCursorLexicalParent in the case of a translation unit compare
correctly via clang_equalCursors.  The code to fetch the translation decl
is based on code inside CursorVisitor::VisitChildren.


I did not add any additional tests for this, but did re-run the current
test suite.  If someone could point me toward the best place to add said
tests I would be happy to create some.

Thanks
-Evan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120422/635a6186/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang_lexical_parent.diff
Type: application/octet-stream
Size: 1080 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120422/635a6186/attachment.obj>


More information about the cfe-commits mailing list