[clang] [clang-tools-extra] [clang] Retain unrecognized C++ [[attributes]] in the AST (PR #209224)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 22 07:40:39 PDT 2026


AaronBallman wrote:

> > The only I problematic bit I can see about these attributes in templated declarations is if they have arguments, we don't know if they are types or expressions and so would need instantiation.
> 
> Clang won't do any semantic analysis on the attribute content. The `UnknownAttr` is detected and the token sequence is recorded, nothing else. The tools/plugins can decide what to do and if the content is a type and eventually instantiate something but all of this is outside clang.

I think the situation @mizvekov is referring to is orthogonal but related. He's basically pointing out that if an unknown attribute fails to cause template instantiation for an attribute argument, you can get a materially different program between compilers. But that's already the status quo in Clang and I don't think failing to instantiate templates can cause a problem for retaining the attribute argument list in the AST, unless Matheus has a different situation in mind. (If so, a code example could help us reason about it better.)

https://github.com/llvm/llvm-project/pull/209224


More information about the cfe-commits mailing list