[clang-tools-extra] Improve attribute range handling for attributed function types in sel… (PR #163926)
Nathan Ridge via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 2 00:22:42 PDT 2025
=?utf-8?b?5YWo5Y2T?= <quanzhuo at kylinos.cn>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/163926 at github.com>
HighCommander4 wrote:
> The issue appears to be that the test annotation parser stops at the `]` in `]:>`, which truncates the expected range marker.
It looks like the problem is not with the expected range marker (this is `Test.range()`, which is `0:17-0:60`, which looks correct), but with the actual range of the `AttributedTypeLoc` node, which is `0:17-0:57`.
It looks like the AST is reporting that the `AttributedTypeLoc` node ends at the `lifetimebound` token, rather than the `:>` token. This is a bug in the AST modeling of `AttributedTypeLoc` (or perhaps, based on [this comment](https://searchfox.org/llvm/rev/c8187f6539166a1d520c7f6c4f6e8857ae56a905/clang/lib/AST/TypeLoc.cpp#581-589), a deliberate quirk).
We can revise the test to expect the node to end there, i.e.:
```
struct X { const [[int* Foo() const <:[clang::life^timebound]]]:>
```
though I find it more readable to use the digraph for both brackets:
```
struct X { const [[int* Foo() const <:<:clang::life^timebound]]:>:>
```
and maybe add a comment saying that this is a quirk in the AST modeling of `AttributedTypeLoc`.
https://github.com/llvm/llvm-project/pull/163926
More information about the cfe-commits
mailing list