File tree Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,13 @@ class ClangDeclFinder
67
67
return true ;
68
68
}
69
69
70
+ bool VisitCXXDeleteExpr (clang::CXXDeleteExpr *deleteExpr) {
71
+ if (auto cxxRecord = deleteExpr->getDestroyedType ()->getAsCXXRecordDecl ())
72
+ if (auto dtor = cxxRecord->getDestructor ())
73
+ callback (dtor);
74
+ return true ;
75
+ }
76
+
70
77
bool VisitVarDecl (clang::VarDecl *VD) {
71
78
if (auto cxxRecord = VD->getType ()->getAsCXXRecordDecl ())
72
79
if (auto dtor = cxxRecord->getDestructor ())
Original file line number Diff line number Diff line change
1
+ // RUN: rm -rf %t
2
+ // RUN: split-file %s %t
3
+ // RUN: %target-swiftxx-frontend -emit-ir -I %t/Inputs -validate-tbd-against-ir=none %t/test.swift | %FileCheck %s
4
+
5
+ //--- Inputs/module.modulemap
6
+ module DestroyedUsingDelete {
7
+ header " test.h "
8
+ requires cplusplus
9
+ }
10
+ //--- Inputs/test.h
11
+
12
+ extern void referencedSymbol( ) ;
13
+ inline void emittedIntoSwiftObject( ) { referencedSymbol ( ) ; }
14
+
15
+ class BaseClass {
16
+ public:
17
+ inline ~ BaseClass( ) {
18
+ emittedIntoSwiftObject( ) ;
19
+ }
20
+
21
+ int x;
22
+ } ;
23
+
24
+ class Container {
25
+ public:
26
+ Container ( ) : pointer( new BaseClass) { }
27
+ ~ Container( ) { delete pointer; }
28
+
29
+ inline int method( ) const {
30
+ return 42 ;
31
+ }
32
+ private:
33
+ BaseClass * pointer;
34
+ } ;
35
+
36
+
37
+ //--- test.swift
38
+
39
+ import DestroyedUsingDelete
40
+
41
+ public func test( ) {
42
+ let i = Container ( )
43
+ i. method ( )
44
+ }
45
+
46
+ // Make sure we reach destructor accessible from `delete` statement.
47
+
48
+ // CHECK: define linkonce_odr{{( dso_local)?}} void @{{_Z22emittedIntoSwiftObjectv|"\?emittedIntoSwiftObject@@YAXXZ"}}
You can’t perform that action at this time.
0 commit comments