Refactor attribute builders from codegen to AttrVisitor
Prerequisites
- [X] I have read the documentation and the proposed feature is not implemented.
Description
At the moment vast operations create attributes, however since we have AttrVisitor, we duplicate logic for attribute creation. We should extract all translations of clang::Attributes to be performed only via AttrVisitor. At the moment, this is probably only GlobalLinkageKindAttr.
Minimal example
#define weak __attribute__((__weak__))
extern "C" {
weak void init();
}
int main() {
init();
}
vast-front produces
"hl.func"() ({
}) {function_type = !core.fn<() -> (!hl.void)>, linkage = 4 : i32, sym_name = "_fini", sym_visibility = "private", weak = #unsup<attr "weak">} : () -> ()
we want to have only linkage attr and omit weak = #unsup<attr "weak">
The duplicit attributes were resolved as part of #411 but the logic wasn't moved to AttrVisitor as linkage requires more information than we can access through an attribute. I'll mark it as backlog for the case we want to revisit this in the future.