Closed Smattr closed 2 years ago
Noting some further things that don't work as a fix to the macro-parent.c test case:
CXCursor_MacroExpansion
is the translation unit itselfWhat does seem to be feasible is retrieving the range of a FunctionDecl
which appears to cover the entire extent of a function, and then inferring that a macro expansion within that range has a parent of the function itself. This is tricky because (1) these two pieces of information are discovered in different phases and (2) the macro expansion is discovered before its parent. But I think this is doable.
As of 512f59198bf6d0960115d1b82997a16baf628588, this is done.
We had to xfail some test cases like the undef one when transitioning back to a libclang-based parser. Libclang does not seem to give much information about macros, even when
CXTranslationUnit_DetailedPreprocessingRecord
is used. We should be able to work around this with our own very unsophisticated C preprocessor front end.