You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The source code I am parsing uses [[clang::annotate]] on a class declaration, however that annotation is not always visible in the AST.
In the following source, only Test01 and Test02 ClassDecls have a attribute(annotate) child in the AST.
The expected behavior would be for all of the class declarations have the attribute(annotate) child.
class [[clang::annotate("ann")]] Test01 {};
class __attribute__((annotate("ann"))) Test02 {};
#define ANNOTATE1 [[clang::annotate("ann")]]
#define ANNOTATE2 __attribute__((annotate("ann")))
class ANNOTATE1 Test03 {};
class ANNOTATE2 Test04 {};
#define ANNOTATE_STR1(x) [[clang::annotate((x))]]
#define ANNOTATE_STR2(x) __attribute__((annotate((x))))
class ANNOTATE_STR1("ann") Test05 {};
class ANNOTATE_STR2("ann") Test06 {};
If you set PRETTY_PRINTED to true, the output will contain the pretty printed source representation of each node. As you can observe, that representation contains the annotation, which suggests that it is not lost during the parsing, just not properly exposed in the AST.
I should also point out that clang 18.1.1 on Compiler Explorer dumps the AST as I would expect - exposing the annotation no matter what method is used. Please refer to the following example.
The source code I am parsing uses
[[clang::annotate]]
on a class declaration, however that annotation is not always visible in the AST.In the following source, only
Test01
andTest02
ClassDecls have aattribute(annotate)
child in the AST.The expected behavior would be for all of the class declarations have the
attribute(annotate)
child.Here's the code I am running:
Here's the output it produces:
If you set PRETTY_PRINTED to true, the output will contain the pretty printed source representation of each node. As you can observe, that representation contains the annotation, which suggests that it is not lost during the parsing, just not properly exposed in the AST.
Further testing indicates that the same applies to annotations attached to class methods.
The text was updated successfully, but these errors were encountered: