<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61251>61251</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-format end of namespace comment incorrect when using namespace level __attribute__
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
sloretz
</td>
</tr>
</table>
<pre>
Consider the following two files:
mre.cc
```c++
#define FOOBAR_HIDDEN __attribute__((visibility("hidden")))
namespace foobar FOOBAR_HIDDEN {
int baz() { return 42; }
} // namespace foobar
```
mre2.cc
```c++
namespace foobar __attribute__((visibility("hidden"))) {
int baz() { return 42; }
} // namespace foobar
```
In both cases, I think the correct end-of-namespace comment is `// namespace foobar`. However, clang-format seems to think it should be the last token.
```console
$ clang-format mre.cc | diff mre.cc -
5c5
< } // namespace foobar
---
> } // namespace FOOBAR_HIDDEN
```
```console
$ clang-format mre2.cc | diff mre2.cc -
2,3c2,3
< int baz() { return 42; }
< } // namespace foobar
---
> int baz() { return 42; }
> } // namespace )
```
```console
$ clang-format --version
Ubuntu clang-format version 14.0.0-1ubuntu1
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.1 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8Vt9v4jgQ_mvMi5UocRJIH_JQCFzZ65aKlpX6FDnOhHjXsZHtgNi__pQftMC1e9076SQrKDPffDPzeexAjeFbCZCgaIqidEQbWym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