<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/87151>87151</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Potential regression in printing out attributes
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          vgvassilev
      </td>
    </tr>
</table>

<pre>
    https://github.com/llvm/llvm-project/commit/46f3ade5083b8bfce55c78a21086a487eaac6f99 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,
```cpp
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.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVMGO4zYM_RrlQiSwncSxDzns7CDo3HrYAr0NaIm22JElQ5KdTb--kJyZzSxQYIsCQSxTNPn4SD4MgQdLdBbHJ3F83uActfPnZVjSjaFl0zl1O-sYpyD2X0R1EdVl4KjnbifdKKqLMcv7Yzt59xfJKKqLdOPI6XCo-z0qOhbNvmu6XtLxKE8NVmXR1HhoToQo675tgW0kqwJEBz1_h6gJJs82sh3A9YAxeu7mSCEdUWpSyXVBz9gZAkXSoMfIzoYdfNMEPE6GRrIxG0Fqx5KAc4YcOed4iOtsthjqI2i0CgIr2sFv7koLeVF9hagxQu-8pLCepUY7ECjPfQyAV7zdgTs1S1Lg5jjNEXrvxnxxf8cAV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