Skip to content

Inconsistent behavior of IsAnonymousRecordDecl() with isCpp #525

@MeteorsLiu

Description

@MeteorsLiu

When the isCpp is enabled (true), the IsAnonymousRecordDecl() method correctly identifies anonymous structs. However, when isCpp is disabled (false), this method fails to recognize anonymous structs properly.

This inconsistency causes the subsequent logic to generate an AST node with an identifier "unname"(likely unintended), as the anonymous struct isn't handled at the expected stage.

The AST we expected, it works well when isCpp is true

{
  "Doc": null,
  "Loc": {
    "File": "testdata/struct/temp.h",
    "_Type": "Location"
  },
  "Name": null,
  "Parent": null,
  ...
}

Unexpected, when isCpp is false

{
  "Doc": null,
  "Loc": {
    "File": "testdata/struct/temp.h",
    "_Type": "Location"
  },
  "Name": {
    "Name": "struct (unnamed at testdata/struct/temp.h:1:1)",
    "_Type": "Ident"
  },
  "Parent": null,
  ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions