Files
swift-mirror/test/Interop/Cxx/class/inheritance/Inputs/module.modulemap
John Hui 1f2107f357 [cxx-interop] Avoid unchecked recursion when importing C++ classes with circular inheritance
It is possible for a C++ class template to inherit from a specialization
of itself. Normally, these are imported to Swift as separate (unrelated)
types, but when symbolic import is enabled, unspecialized templates are
imported in place of their specializations, leading to circularly
inheriting classes to seemingly inherit from themselves.

This patch adds a check to guard against the most common case of
circular inheritance, when a class template directly inherits from
itself. This pattern appears in a recent version of libc++,
necessitating this patch. However, the solution here is imperfect as it
does not handle more complex/contrived circular inheritance patterns.

This patch also adds a test case exercising this pattern. The
-index-store-path flag causes swift-frontend to index the C++ module
with symbolic import enabled, without the fix in this patch, that test
triggers an assertion failure due to the circular reference (and can
infinitely recurse in the StorageVisitor when assertions are disabled).

rdar://148026461
2025-04-30 13:33:33 -07:00

56 lines
798 B
Plaintext

module Functions {
header "functions.h"
}
module Fields {
header "fields.h"
}
module Polymorphism {
header "polymorphism.h"
requires cplusplus
}
module ReferenceToDerived {
header "reference-to-derived.h"
requires cplusplus
}
module SubTypes {
header "sub-types.h"
}
module Subscripts {
header "subscripts.h"
}
module TypeAliases {
header "type-aliases.h"
}
module UsingBaseMembers {
header "using-base-members.h"
requires cplusplus
}
module VirtualMethods {
header "virtual-methods.h"
requires cplusplus
}
module FunctionsObjC {
header "functions-objc.h"
requires cplusplus
requires objc
}
module InheritedLookup {
header "inherited-lookup.h"
requires cplusplus
}
module CircularInheritance {
header "circular-inheritance.h"
requires cplusplus
}