mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[sil] Add a new instruction ignored_use.
This is used for synthetic uses like _ = x that do not act as a true use but instead only suppress unused variable warnings. This patch just adds the instruction. Eventually, we can use it to move the unused variable warning from Sema to SIL slimmming the type checker down a little bit... but for now I am using it so that other diagnostic passes can have a SIL instruction (with SIL location) so that we can emit diagnostics on code like _ = x. Today we just do not emit anything at all for that case so a diagnostic SIL pass would not see any instruction that it could emit a diagnostic upon. In the next patch of this series, I am going to add SILGen support to do that.
This commit is contained in:
@@ -1692,6 +1692,17 @@ void SILSerializer::writeSILInstruction(const SILInstruction &SI) {
|
||||
|
||||
break;
|
||||
}
|
||||
case SILInstructionKind::IgnoredUseInst: {
|
||||
// Use SILOneOperandLayout to specify our operand.
|
||||
auto *iui = cast<IgnoredUseInst>(&SI);
|
||||
unsigned abbrCode = SILAbbrCodes[SILOneOperandLayout::Code];
|
||||
SILOneOperandLayout::emitRecord(
|
||||
Out, ScratchRecord, abbrCode, (unsigned)iui->getKind(), 0,
|
||||
S.addTypeRef(iui->getOperand()->getType().getRawASTType()),
|
||||
(unsigned)iui->getOperand()->getType().getCategory(),
|
||||
addValueRef(iui->getOperand()));
|
||||
break;
|
||||
}
|
||||
case SILInstructionKind::DynamicFunctionRefInst: {
|
||||
// Use SILOneOperandLayout to specify the function type and the function
|
||||
// name (IdentifierID).
|
||||
|
||||
Reference in New Issue
Block a user