[cfe-dev] libclang: parsing forward declared enum's in an easy way

Hayden Livingston halivingston at gmail.com
Tue Feb 3 19:02:24 PST 2015


Is ther

TranslationUnitDecl 0x8d7090 << invalid sloc >> <invalid sloc>
| -TypedefDecl 0x8d7360 << invalid sloc >> <invalid sloc> implicit
__builtin_va_list 'char *'
| -EnumDecl 0x8d7390 < a.h:1 : 9, line : 6 : 1 > line:1 : 9
| | -EnumConstantDecl 0x8d7420 < line : 2 : 3, col : 22 > col : 3 None 'int'
| | `-IntegerLiteral 0x8d7400 < col:22 > 'int' 0
| | -EnumConstantDecl 0x8d7480 < line:3 : 3, col : 53 > col:3 referenced
TIP 'int'
| | `-IntegerLiteral 0x8d7458 < col:53 > 'int' 1
| | -EnumConstantDecl 0x8d74e0 < line:4 : 3, col : 52 > col:3 referenced
TIE 'int'
| | `-IntegerLiteral 0x8d74b8 < col:52 > 'int' 2
| `-EnumConstantDecl 0x8d7560 < line:5 : 3, col : 98 > col:3 TAA 'int'
| `-BinaryOperator 0x8d7548 < col:48, col : 98 > 'int' '|'
| | -DeclRefExpr 0x8d7518 < col:48 > 'int' EnumConstant 0x8d7480 'TIP' 'int'
| `-DeclRefExpr 0x8d7530 < col:98 > 'int' EnumConstant 0x8d74e0 'TIP' 'int'
`-TypedefDecl 0x8d75d0 < line:1 : 1, line : 6 : 3 > col:3 N 'enum None' :
'NFlags'
;

In this AST ... I discover EnumDecl first, then I see TypeDecl ... is there
a way to visit a sibling, given a cursor? I have the EnumDecl cursor, and I
want to find its sibling, but visitchildren gives me its children.

I have a not-so-good solution that keeps track of the cursors, but I was
hoping if there is another way of doing it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150203/1b2bb3a9/attachment.html>


More information about the cfe-dev mailing list