Skip to content

Commit 7eaf573

Browse files
committed
[sil] As a fallback, if a parsed SILFunction does not have a DeclContext, set its parent SwiftModule to be the SwiftModule of its SILModule.
This ensures that we can successfully perform protocol conformance checks when testing SIL files.
1 parent fe0dd18 commit 7eaf573

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/SIL/Parser/SILParserFunctionBuilder.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ class LLVM_LIBRARY_VISIBILITY SILParserFunctionBuilder {
3131
IsNotTransparent, IsNotSerialized, IsNotDynamic, IsNotDistributed,
3232
IsNotRuntimeAccessible);
3333
result->setDebugScope(new (builder.mod) SILDebugScope(loc, result));
34+
35+
// If we did not have a declcontext set, as a fallback set the parent module
36+
// of our SILFunction to the parent module of our SILModule.
37+
//
38+
// DISCUSSION: This ensures that we can perform protocol conformance checks.
39+
if (!result->getDeclContext()) {
40+
result->setParentModule(result->getModule().getSwiftModule());
41+
}
42+
3443
return result;
3544
}
3645
};

0 commit comments

Comments
 (0)