Skip to content

Commit 6f245bb

Browse files
committed
ABI comments: include stored property names
1 parent 3d40a8c commit 6f245bb

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3157,12 +3157,10 @@ std::optional<std::string> PrintAST::mangledNameToPrint(const Decl *D) {
31573157
return mangler.mangleConstructorEntity(init, /*isAllocating=*/true);
31583158
}
31593159

3160-
// For global and static variables, mangle the entity directly.
3160+
// For variables, mangle the entity directly.
31613161
if (auto var = dyn_cast<VarDecl>(D)) {
3162-
if (!var->isInstanceMember()) {
3163-
ASTMangler mangler;
3164-
return mangler.mangleEntity(var);
3165-
}
3162+
ASTMangler mangler;
3163+
return mangler.mangleEntity(var);
31663164
}
31673165

31683166
// For subscripts, mangle the entity directly.

test/ModuleInterface/abi-comments.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,35 @@
88
// CHECK-NEXT: public func intToString(_ value: Swift.Int) -> Swift.String
99
public func intToString(_ value: Int) -> String { "\(value)" }
1010

11+
// CHECK: // MANGLED NAME: $s11ABIComments13globalCounterSivp
12+
// CHECK-NEXT: @_hasInitialValue public var globalCounter: Swift.Int
13+
public var globalCounter: Int = 23
14+
1115
// CHECK: // MANGLED NAME: $s11ABIComments8MyStructVMa
1216
// CHECK-NEXT: public struct MyStruct {
1317
public struct MyStruct {
1418
// CHECK: // MANGLED NAME: $s11ABIComments8MyStructV6methodSiyF
1519
// CHECK-NEXT: public func method() -> Swift.Int
1620
public func method() -> Int { 5 }
21+
22+
// CHECK: // MANGLED NAME: $s11ABIComments8MyStructV7counterSivp
23+
// CHECK-NEXT: @_hasInitialValue public var counter: Swift.Int
24+
public var counter: Int = 23
25+
26+
// CHECK: // MANGLED NAME: $s11ABIComments8MyStructV11constantNumSivp
27+
// CHECK-NEXT: @_hasInitialValue public let constantNum: Swift.Int
28+
public let constantNum: Int = 23
29+
30+
// CHECK: // MANGLED NAME: $s11ABIComments8MyStructV9staticLetSivpZ
31+
// CHECK-NEXT: @_hasInitialValue public static let staticLet: Swift.Int
32+
public static let staticLet: Int = 23
33+
34+
// CHECK: // MANGLED NAME: $s11ABIComments8MyStructV8computedSivp
35+
// CHECK-NEXT: public var computed: Swift.Int {
36+
// CHECK-NEXT: // MANGLED NAME: $s11ABIComments8MyStructV8computedSivg
37+
// CHECK-NEXT: get
38+
// CHECK-NEXT: }
39+
public var computed: Int {
40+
13
41+
}
1742
}

0 commit comments

Comments
 (0)