Skip to content

Commit a3de97b

Browse files
committed
Add SILParser support for [dynamically_replaceable].
1 parent 84565dd commit a3de97b

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

include/swift/AST/DiagnosticsParse.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,8 @@ ERROR(expected_type_after_arrow,none,
731731
ERROR(function_type_argument_label,none,
732732
"function types cannot have argument labels; use '_' before %0",
733733
(Identifier))
734+
ERROR(expected_dynamic_func_attr,none,
735+
"expected a dynamically_replaceable function", ())
734736

735737
// Enum Types
736738
ERROR(expected_expr_enum_case_raw_value,PointsToFirstBadToken,

include/swift/SIL/SILFunction.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,6 @@ class SILFunction
590590
return IsDynamicallyReplaceable_t(IsDynamicReplaceable);
591591
}
592592
void setIsDynamic(IsDynamicallyReplaceable_t value = IsDynamic) {
593-
assert(IsDynamicReplaceable == IsNotDynamic && "already set");
594593
IsDynamicReplaceable = value;
595594
assert(!Transparent || !IsDynamicReplaceable);
596595
}

lib/ParseSIL/ParseSIL.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2722,6 +2722,14 @@ bool SILParser::parseSILInstruction(SILBuilder &B) {
27222722
if (parseSILFunctionRef(InstLoc, Fn) ||
27232723
parseSILDebugLocation(InstLoc, B))
27242724
return true;
2725+
// Set a forward reference's dynamic property for the first time.
2726+
if (!Fn->isDynamicallyReplaceable()) {
2727+
if (!Fn->empty()) {
2728+
P.diagnose(P.Tok, diag::expected_dynamic_func_attr);
2729+
return true;
2730+
}
2731+
Fn->setIsDynamic();
2732+
}
27252733
ResultVal = B.createDynamicFunctionRef(InstLoc, Fn);
27262734
break;
27272735
}

0 commit comments

Comments
 (0)