Skip to content

Commit bf40426

Browse files
authored
Merge pull request swiftlang#5448 from gottesmm/add_is_parsingflag_to_silbuilder
[semantic-arc] Add a flag to SILBuilder called isParsing to allow for SILBuilder to ignore invariants while parsing.
2 parents 0569fed + be95e63 commit bf40426

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

include/swift/SIL/SILBuilder.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,20 @@ class SILBuilder {
5151
/// only by SILGen or SIL deserializers.
5252
SILOpenedArchetypesTracker *OpenedArchetypesTracker = nullptr;
5353

54+
/// True if this SILBuilder is being used for parsing.
55+
///
56+
/// This is important since in such a case, we want to not perform any
57+
/// Ownership Verification in SILBuilder. This functionality is very useful
58+
/// for determining if qualified or unqualified instructions are being created
59+
/// in appropriate places, but prevents us from inferring ownership
60+
/// qualification of functions when parsing. The ability to perform this
61+
/// inference is important since otherwise, we would need to update all SIL
62+
/// test cases while bringing up SIL ownership.
63+
bool isParsing = false;
64+
5465
public:
55-
SILBuilder(SILFunction &F) : F(F), BB(0) {}
66+
SILBuilder(SILFunction &F, bool isParsing = false)
67+
: F(F), BB(0), isParsing(isParsing) {}
5668

5769
SILBuilder(SILFunction &F, SmallVectorImpl<SILInstruction *> *InsertedInstrs)
5870
: F(F), BB(0), InsertedInstrs(InsertedInstrs) {}

lib/Parse/ParseSIL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4103,7 +4103,7 @@ bool Parser::parseDeclSIL() {
41034103
// Parse the basic block list.
41044104
FunctionState.OwnershipEvaluator.reset(FunctionState.F);
41054105
SILOpenedArchetypesTracker OpenedArchetypesTracker(*FunctionState.F);
4106-
SILBuilder B(*FunctionState.F);
4106+
SILBuilder B(*FunctionState.F, /*isParsing*/ true);
41074107
// Track the archetypes just like SILGen. This
41084108
// is required for adding typedef operands to instructions.
41094109
B.setOpenedArchetypesTracker(&OpenedArchetypesTracker);

0 commit comments

Comments
 (0)