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

    <tr>
        <th>Summary</th>
        <td>
            False-positive misc-unused-alias-decls when namespace-alias comes before include
        </td>
    </tr>

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

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

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

<pre>
    ```console
$ cat a.hpp
#ifndef A_HPP_
#define A_HPP_

namespace A {
 namespace fs {
    struct path {};
 }
}

#endif
```

```console
$ cat b.hpp
#include "a.hpp"
namespace fs = A::fs;
struct B {
  fs::path member;
};
```

```console
$ cat c.hpp
#include "a.hpp"
namespace fs = A::fs;

#include "b.hpp"

struct C {
  fs::path member1;
  B member2;
};
```

```console
$ clang-tidy --checks=misc-unused-alias-decls c.hpp
Running without flags.
1 warning generated.
/home/botond/temp/clangd-debugging/issue-1438/c.hpp:2:11: warning: namespace alias decl 'fs' is unused [misc-unused-alias-decls]
namespace fs = A::fs;
~~~~~~~~~~^~~~~~~~~~~
```

It seems like a valid stylistic choice to group the namespace-alias with the #include to which it pertains, so this seems like an undesired false-positive to me.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyslM2OpDYQx5_GXEq0wIZmOHDong7a3FZ5gZWxC-yssRFlZjSXPHsE_Z1kkmi1LdRtV7mr_r-qMpLIDh6xYeWRladELtGEufliB_MaxlF6jXORdEF_NGyfnR8VPAWHLDux7MB4AUpGkDszTVeTsL3X2MPh25evX7_drBp76_HZun17OSJNUiEcgFXHsxHu1p4ezABAcV5UhElGszmqExNX97o5h74trvnRa9tfdleYpyP_Stg9E3rlFo3AOD-jc_5XllW1OMGBifXp6abxIv_4CLW612Mb04hjh_Pt_CPfDwhXP034PwXpnoI8Ab7-B2B-7xocLzb-U6id9EMarf6ANFUG1Xdi4jRaUuniF0KdSmclpRqVo8f6_LZ4b_0A7zaasETonRxod_bl8C7nzTugx1lG1LtrytaEERlvuxCD14y3EceJ8XYTolON3TIM1g-Mt5ZowTQvxMvq31KLA2fikOdMHK451uW9IZtaWNUC41VPjFdgCc4swMrjJ2isPP3v3v5x-7Dyl4fN5_X_NQIhjgTOfkeQ8Cad1UDxw1mKVoEywSqEGGCYwzJBNHhnOsvcCr05HoYqBng3VhmwESaco7SeGH8FChCNpaekHhavkeyMGnrpCNMpkI32bQsz4i7RjdC1qGWCTb6vhMiqgovENNm-F3XF86KoZVXvS5nprpSqk131ggWWiW14xkWWZzUXosrErqplIXNVv_S9Lvtiz4oMR2ndzrm3cRfmIdl625R1nVWJkx062t6rnN8Hcr0p5SmZm_VPabcMxIpsLRjdw0QbHTbtM85n0_tu0P-trCqMSNBhH2aES12TZXaNiXHaLiJvGW8HG83S7VQYGW_X9JefdJrD76jidVyJ8Xaj-jMAAP___5PbWQ">