mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Add @_used and @_section attributes for global variables and top-level functions (#65901)
* Add @_used and @_section attributes for global variables and top-level functions
This adds:
- @_used attribute that flags as a global variable or a top-level function as
"do not dead-strip" via llvm.used, roughly the equivalent of
__attribute__((used)) in C/C++.
- @_section("...") attribute that places a global variable or a top-level
function into a section with that name, roughly the equivalent of
__attribute__((section("..."))) in C/C++.
This commit is contained in:
committed by
GitHub
parent
ff696c4b5d
commit
2d5f33e2e3
@@ -3047,6 +3047,15 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
|
||||
return;
|
||||
}
|
||||
|
||||
case DAK_Section: {
|
||||
auto *theAttr = cast<SectionAttr>(DA);
|
||||
auto abbrCode = S.DeclTypeAbbrCodes[SectionDeclAttrLayout::Code];
|
||||
SectionDeclAttrLayout::emitRecord(S.Out, S.ScratchRecord, abbrCode,
|
||||
theAttr->isImplicit(),
|
||||
theAttr->Name);
|
||||
return;
|
||||
}
|
||||
|
||||
case DAK_Documentation: {
|
||||
auto *theAttr = cast<DocumentationAttr>(DA);
|
||||
auto abbrCode = S.DeclTypeAbbrCodes[DocumentationDeclAttrLayout::Code];
|
||||
|
||||
Reference in New Issue
Block a user