Skip to content

Commit a736e18

Browse files
committed
[SIL] InitAccessors: Add a way to retrieve a name of the property referenced by assign_or_init instruction
This is going to be used by DI diagnostics.
1 parent 8a1107e commit a736e18

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

include/swift/SIL/SILInstruction.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4925,6 +4925,7 @@ class AssignOrInitInst
49254925
ArrayRef<Operand> getAllOperands() const { return Operands.asArray(); }
49264926
MutableArrayRef<Operand> getAllOperands() { return Operands.asArray(); }
49274927

4928+
StringRef getPropertyName() const;
49284929
AccessorDecl *getReferencedInitAccessor() const;
49294930
};
49304931

lib/SIL/IR/SILInstructions.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,12 @@ bool AssignOrInitInst::isPropertyAlreadyInitialized(unsigned propertyIdx) {
12901290
return Assignments.test(propertyIdx);
12911291
}
12921292

1293+
StringRef AssignOrInitInst::getPropertyName() const {
1294+
auto *accessor = getReferencedInitAccessor();
1295+
assert(accessor);
1296+
return cast<VarDecl>(accessor->getStorage())->getNameStr();
1297+
}
1298+
12931299
AccessorDecl *AssignOrInitInst::getReferencedInitAccessor() const {
12941300
SILValue initRef = getInitializer();
12951301
SILFunction *accessorFn = nullptr;

0 commit comments

Comments
 (0)