[clang] [llvm] [Clang][AST][NFCI] Make Decl reference attributes directly (PR #219138)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 31 06:26:11 PDT 2026
================
@@ -355,6 +351,13 @@ class alignas(8) Decl {
LLVM_PREFERRED_TYPE(Linkage)
mutable unsigned CacheValidAndLinkage : 3;
+ /// The attributes attached to this declaration, or null if it has none.
+ ///
+ /// This pointer is the sole record of whether the declaration has
+ /// attributes, so it must be cleared whenever the vector becomes empty.
+ /// Owned by the ASTContext that allocated it.
+ AttrVec *Attrs = nullptr;
----------------
erichkeane wrote:
Another thing: @zygoloid mentioned on another thread that there were bits we should/could steal back from constructors.
I wonder if we could look through any of ours and do the reverse: switch it to a map. I find myself wondering how often 'used/referenced' is actually meaningfully used. I suspect it is JUST for a certain diagnostic, plus 1x in codegen. Both of which are pretty rare lookups. (compared to 'invalid', which gets looked up constantly).
`Implicit` might be something we could steal back, I think we only check that occasionally. `TopLevelDeclInObjCContainer` I have no knowledge of, so we could very likely evaluate if that is looked up often enough to matter (OR is only used on a sub-type?).
All that to say, I think a static_ assert to make sure these types don't grow, plus the ability to 'steal' bits in the future if they are valuable should be sufficient?
https://github.com/llvm/llvm-project/pull/219138
More information about the cfe-commits
mailing list