[AST] Introduce Decl::addAttribute

Introduce a convenience entrypoint that also calls `attachToDecl` on
the attribute, and migrate all existing uses of `getAttrs().add` onto
it.
This commit is contained in:
Hamish Knight
2025-10-16 11:21:54 +01:00
parent 0358e1eadd
commit 73710e3eef
45 changed files with 269 additions and 271 deletions

View File

@@ -609,11 +609,10 @@ void ModuleFile::getImportDecls(SmallVectorImpl<Decl *> &Results) {
SourceLoc(), importPath.get());
ID->setModule(M);
if (Dep.isExported())
ID->getAttrs().add(
new (Ctx) ExportedAttr(/*IsImplicit=*/false));
ID->addAttribute(new (Ctx) ExportedAttr(/*IsImplicit=*/false));
if (Dep.isImplementationOnly())
ID->getAttrs().add(
new (Ctx) ImplementationOnlyAttr(/*IsImplicit=*/false));
ID->addAttribute(new (Ctx)
ImplementationOnlyAttr(/*IsImplicit=*/false));
ImportDecls.push_back(ID);
}