Skip to content

Potential regression in AST printing #87151

@vgvassilev

Description

@vgvassilev

46f3ade intends to fix the printing of attributes attached to variable declarations. The implementation choice is to print the attributes on the left hand side. However, that forces that change drifts away the produced output from the output as written in the code. This is also evident from the tests the commit had to change.

Consider,

void f() __attribute__((always_inline)) {}

clang-17 -Xclang -ast-print produces void f() __attribute__((always_inline)) {} which matches very closely the original code. However, clang-18 -Xclang -ast-print produces __attribute__((always_inline)) void f() {}

Both compile but I think the second one violates a principle which I believe we have been following where we try to produce output close as much as possible to the user code.

@giulianobelinassi, @erichkeane do you think we can bring the old behavior back before freezing 18 by limiting that feature to variable declarations only? This was the original intent of the patch IIUC.

@alexander-penev, @AaronBallman.

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions