Skip to content

[clang][ASTMatchers] global anonymous union declaration not picked up by ASTConsumer::handleTopLevelDecl #130618

@carlosgalvezp

Description

@carlosgalvezp

Hi,

I'm trying to solve an issue with a clang-tidy check on the following example code:

static union {
  int global;
};

Clearly this shows up in the AST as a CXXRecordDecl under the TranslationUnitDecl: https://godbolt.org/z/j8GqxvEYd

For debugging, I am overriding the ASTConsumer::HandleTopLevelDecl function in MatchASTConsumer, and I am just simply dumping the Decls that get picked up by it.

I notice that this CXXRecordDecl of the union is not picked up by this function.

Is this intentional? Why are global anonymous unions not registered as a "top level declaration"?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions