Skip to content

Commit e021534

Browse files
authored
Add deserialization support for section attribute (#71588)
While working on #71425, I hit an assert indicating the `@_section` attribute was not handled in `DeclDeserializer::deserializeDeclCommon`. This change adds the missing deserialization for the `@_section` attribute.
1 parent 0554d74 commit e021534

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/Serialization/Deserialization.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6108,6 +6108,14 @@ llvm::Error DeclDeserializer::deserializeDeclCommon() {
61086108
break;
61096109
}
61106110

6111+
case decls_block::Section_DECL_ATTR: {
6112+
bool isImplicit;
6113+
serialization::decls_block::SectionDeclAttrLayout::readRecord(
6114+
scratch, isImplicit);
6115+
Attr = new (ctx) SectionAttr(blobData, isImplicit);
6116+
break;
6117+
}
6118+
61116119
case decls_block::RawLayout_DECL_ATTR: {
61126120
bool isImplicit;
61136121
TypeID typeID;

test/Serialization/attr-section.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// REQUIRES: swift_in_compiler
2+
3+
// RUN: %empty-directory(%t)
4+
// RUN: %target-swift-frontend -parse-as-library -enable-experimental-feature SymbolLinkageMarkers -emit-module-path %t/a.swiftmodule -module-name a %s
5+
// RUN: llvm-bcanalyzer -dump %t/a.swiftmodule | %FileCheck --check-prefix BC-CHECK --implicit-check-not UnknownCode %s
6+
// RUN: %target-swift-ide-test -print-module -module-to-print a -source-filename x -I %t | %FileCheck --check-prefix MODULE-CHECK %s
7+
8+
// BC-CHECK: <Section_DECL_ATTR
9+
10+
// MODULE-CHECK: @_section("SOME_SECT") let Constant: Int
11+
@_section("SOME_SECT")
12+
let Constant = 321

0 commit comments

Comments
 (0)