Skip to content

fix: preserve the spelling of nameless field designators #48

Description

@lm-sousa

Problem

DesignatedInitExpr::Designator::getFieldName() can return nullptr for a field designator that reaches a member through an anonymous struct or union, for example:

struct S {
  union {
    int a;
  };
};

struct S s = { .a = 1 };

The dumper currently avoids the null dereference by serializing an empty field-name line. That prevents the crash, but the designator record no longer carries the source spelling a. Consumers such as Clava then cannot reconstruct the designated initializer from the designator data alone. Clava currently turns the empty name into ..

Expected behavior

Preserve enough information to identify the selected member, ideally the original field name and, where needed, the anonymous-member path. The current empty string should remain a crash fix only, not the final representation.

Context

This was observed while checking the post-v18.1.8_2 changes against Clava. The null-dereference fix covers the crash but leaves the serialized representation incomplete for source regeneration.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions