Skip to content

Commit 0718217

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. (cherry picked from commit a736e18)
1 parent dc1cd72 commit 0718217

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
@@ -4988,6 +4988,7 @@ class AssignOrInitInst
49884988
ArrayRef<Operand> getAllOperands() const { return Operands.asArray(); }
49894989
MutableArrayRef<Operand> getAllOperands() { return Operands.asArray(); }
49904990

4991+
StringRef getPropertyName() const;
49914992
AccessorDecl *getReferencedInitAccessor() const;
49924993
};
49934994

lib/SIL/IR/SILInstructions.cpp

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

1286+
StringRef AssignOrInitInst::getPropertyName() const {
1287+
auto *accessor = getReferencedInitAccessor();
1288+
assert(accessor);
1289+
return cast<VarDecl>(accessor->getStorage())->getNameStr();
1290+
}
1291+
12861292
AccessorDecl *AssignOrInitInst::getReferencedInitAccessor() const {
12871293
SILValue initRef = getInitializer();
12881294
SILFunction *accessorFn = nullptr;

0 commit comments

Comments
 (0)