[cfe-dev] CXCursor API questions
seefeld at sympatico.ca
Thu Jan 27 12:15:45 PST 2011
On 2011-01-27 14:54, Douglas Gregor wrote:
>> 1) The documentation suggests that 'parent' should correspond to the
>> parent cursor of 'cursor'. However, I find that 'parent' and
>> 'lex_parent' don't (ever !) compare equal. Shouldn't they ?
> I doubt that they "never" compare equal. They won't compare equal within function bodies (or other expressions) for reasons that are relatively hard to fix, i.e., we don't keep parent pointers for statements or expressions.
OK. Sorry for being sloppy. I meant to say that I experimented a little
with simple C++ code, and in doing that I couldn't ever get a case where
the parent cursor (in a visitor callback) matched the lexical parent of
the visited cursor. (Note that I was focusing on declarations, and thus
didn't even dive into statements and expressions at all.)
>> 2) The documentation suggests that the parent cursor of a global
>> declaration is the translation unit. However, in case where 'cursor'
>> corresponds in fact to global declarations in my source file,
>> 'lex_parent' is an 'unexposed' cursor (and isn't equal to 'parent',
>> which always is the translation unit). What is wrong ? (And, how can I
>> distinguish declarations in my source files from builtin declarations,
>> such as __builtin_va_list ?)
> A bug, perhaps?
That's what I thought, but wasn't bold enough to assume. I can certainly
file an issue for that.
>> 3) I notice a strange ordering of during the cursor traversal: It starts
>> with some builtin items (such as __builtin_va_list), followed by my own
>> declarations, followed by other builtin items (macros such as
>> __clang__). Shouldn't my own declarations come last ?
> I could certainly see a case for visiting macro definitions and instantiations before declarations, since preprocessing theoretically happens in an earlier phase of translation. But, otherwise, libclang sounds like it's doing the same thing.
...ich hab' noch einen Koffer in Berlin...
More information about the cfe-dev