Closed Victorious3 closed 1 year ago
The best way to handle attribute is use regex near the function. Why? Clang can parse some attributes but not all - it ignores unsupported attributes silently, giving no information about them. I even made a ticket for it once and one of the contributors nicely explained that from their point of view it's not that easy (an unknown attribute would require its own unknown attribute grammar). Although from what I remember your case was possible to handle with the clang parser.
Assuming element
is your CursorKind.UNEXPOSED_ATTR
node, and text
is your source code, try:
text[element.extent.start.offset : element.extent.end.offset]
The result should be string always_inline
.
Say you have a function like this:
If you use libclang to iterate over the children it becomes an UNEXPOSED_ATTRIBUTE. However, I don't know how to inspect it further because its tokens are empty and spelling is the empty string.