Skip to content

Commit a8111e4

Browse files
authored
Merge pull request #80094 from swiftlang/susmonteiro/destructor-missing-dbg-info
[cxx-interop] Disable debug info in synthesized C++ methods
2 parents 44b0d5d + 25efb5f commit a8111e4

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

lib/ClangImporter/SwiftDeclSynthesizer.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -2106,6 +2106,7 @@ clang::CXXMethodDecl *SwiftDeclSynthesizer::synthesizeCXXForwardingMethod(
21062106
newMethod->setImplicit();
21072107
newMethod->setImplicitlyInline();
21082108
newMethod->setAccess(clang::AccessSpecifier::AS_public);
2109+
newMethod->addAttr(clang::NoDebugAttr::CreateImplicit(clangCtx));
21092110
if (method->hasAttr<clang::CFReturnsRetainedAttr>()) {
21102111
// Return an FRT field at +1 if the base method also follows this
21112112
// convention.

test/Interop/Cxx/class/inheritance/Inputs/virtual-methods.h

+9
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ struct DerivedFromCallsPureMethod : CallsPureMethod {
5050

5151
struct DerivedFromDerivedFromCallsPureMethod : DerivedFromCallsPureMethod {};
5252

53+
struct HasDestructor {
54+
~HasDestructor() {}
55+
};
56+
5357
// MARK: Reference Types:
5458

5559
#define IMMORTAL_FRT \
@@ -76,6 +80,11 @@ struct IMMORTAL_FRT DerivedFromImmortal : public Immortal {
7680
static DerivedFromImmortal *_Nonnull create() { return new DerivedFromImmortal(); }
7781
};
7882

83+
struct IMMORTAL_FRT Immortal2 {
84+
public:
85+
virtual void virtualMethod(HasDestructor) = 0;
86+
};
87+
7988
inline const ImmortalBase *_Nonnull castToImmortalBase(
8089
const Immortal *_Nonnull immortal) {
8190
return static_cast<const ImmortalBase *>(immortal);

test/Interop/Cxx/class/inheritance/virtual-methods.swift

+11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: %target-run-simple-swift(-I %S/Inputs -cxx-interoperability-mode=swift-5.9)
22
// RUN: %target-run-simple-swift(-I %S/Inputs -cxx-interoperability-mode=swift-6)
33
// RUN: %target-run-simple-swift(-I %S/Inputs -cxx-interoperability-mode=upcoming-swift)
4+
// RUN: %target-run-simple-swift(-g -I %S/Inputs -cxx-interoperability-mode=default)
45

56
// REQUIRES: executable_test
67

@@ -53,4 +54,14 @@ if #available(SwiftStdlib 5.8, *) {
5354
}
5455
}
5556

57+
#if !os(Windows)
58+
// FIXME in Windows, non-trivial C++ class with trivial ABI is not yet available in Swift
59+
VirtualMethodsTestSuite.test("C++ virtual method with complex parameter") {
60+
@available(macOS 13.3, *)
61+
func f(simpleClass: HasDestructor, immortalClass: Immortal2) {
62+
immortalClass.virtualMethod(simpleClass)
63+
}
64+
}
65+
#endif
66+
5667
runAllTests()

0 commit comments

Comments
 (0)