mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[sil-module] Fix a pretty serious bug when a wrong function was returned using SILModule::lookUpSILFunctionFromVTable.
This bug would manifest itself only when a module with multiple files is being compiled and some derived classes are defined in a file different from the one where a base class is defined. Due to this bug a method from a base class would be invoked instead of a method from a derived class when devirtualization was performed. The problem was that we were saying that failure to link a vtable is equivalent to failure to find a function in the vtable itself in which case we would go up to the parent vtable. To avoid this kind of bug in the future a test case with a module consisting of multiple files is added to the test suite. rdar://19334105 rdar://19337398 Swift SVN r24264
This commit is contained in:
@@ -811,11 +811,9 @@ lookUpSILFunctionFromVTable(ClassDecl *Class, SILDeclRef Member) {
|
||||
// Try to lookup a VTable for Class from the module...
|
||||
auto *Vtbl = lookUpVTable(Class);
|
||||
|
||||
// If the lookup fails, skip Class and attempt to resolve the method in
|
||||
// the VTable of the super class of Class if it exists...
|
||||
// Bail, if the lookup of VTable fails.
|
||||
if (!Vtbl) {
|
||||
Class = getClassDeclSuperClass(Class);
|
||||
continue;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Ok, we have a VTable. Try to lookup the SILFunction implementation from
|
||||
|
||||
Reference in New Issue
Block a user