File: print-symbolic-module-interface.swift

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (120 lines) | stat: -rw-r--r-- 3,318 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: %target-swift-ide-test -print-module -module-to-print=CxxModule -I %t/Inputs -source-filename=x -enable-experimental-cxx-interop -enable-experimental-feature ImportSymbolicCXXDecls | %FileCheck %s

// REQUIRES: asserts

//--- Inputs/module.modulemap
module CxxModule {
    header "headerA.h"
    header "headerB.h"
    requires cplusplus
}

//--- Inputs/headerA.h

namespace ns {
    int freeFunction(int x, int y);
}

//--- Inputs/headerB.h

#include "headerA.h"

namespace ns {
    struct B {
        int y;
    };

    template<class T>
    struct TemplateRecord {
        void methodFunc(int x);

        struct InnerRecord {
            int innerMethod(int y);
        };

        template<class T2>
        struct InnerTemplate {
            void innerTemplateMethod();
            void innerTemplateMethodWithDefaultArg(T2 x = 123);
        };

        InnerTemplate<int> returnsTemplateMethod();
    };
}

using MyType = ns::TemplateRecord<int>;

template<class X>
class OuterTemp2 {
public:
    template<class T, class G>
    class InnerTemp2 {
    public:
        void testMe(const T& p, const X& x);

        X x2;

        using Y = X;
    };
};

#define IMMORTAL_FRT                                                         \
    __attribute__((swift_attr("import_reference")))                              \
    __attribute__((swift_attr("retain:immortal")))                               \
    __attribute__((swift_attr("release:immortal")))

struct IMMORTAL_FRT MyImmortal {
    virtual void foo() const {};
};

struct NonCopyable {
    NonCopyable(const NonCopyable& other) = delete;
};

// CHECK:     enum ns {
// CHECK-NEXT: struct B {
// CHECK-NEXT:    init()
// CHECK-NEXT:    init(y: Int32)
// CHECK-NEXT:    var y: Int32
// CHECK-NEXT:  }
// CHECK-NEXT:  struct TemplateRecord {
// CHECK-NEXT:    @available(*, deprecated, message:
// CHECK-NEXT:    init()
// CHECK-NEXT:    mutating func methodFunc(_ x: Any)
// CHECK-NEXT:    struct InnerRecord {
// CHECK-NEXT:      @available(*, deprecated, message:
// CHECK-NEXT:      init()
// CHECK-NEXT:      mutating func innerMethod(_ y: Any)
// CHECK-NEXT:    }
// CHECK-NEXT:    struct InnerTemplate {
// CHECK-NEXT:      @available(*, deprecated, message:
// CHECK-NEXT:      init()
// CHECK-NEXT:      mutating func innerTemplateMethod()
// CHECK-NEXT:      mutating func innerTemplateMethodWithDefaultArg(_ x: Any = cxxDefaultArg)
// CHECK-NEXT:    }
// CHECK-NEXT:    mutating func returnsTemplateMethod()
// CHECK-NEXT:  }
// CHECK-NEXT:  static func freeFunction(_ x: Int32, _ y: Int32) -> Int32
// CHECK-NEXT: }
// CHECK-NEXT: typealias MyType = ns.TemplateRecord
// CHECK-NEXT: struct OuterTemp2 {
// CHECK-NEXT:   @available(*, deprecated, message:
// CHECK-NEXT:   init()
// CHECK-NEXT:   struct InnerTemp2 {
// CHECK-NEXT:     @available(*, deprecated, message:
// CHECK-NEXT:     init()
// CHECK-NEXT:     init(x2: Any)
// CHECK-NEXT:     mutating func testMe(_ p: Any, _ x: Any)
// CHECK-NEXT:     var x2: Any
// CHECK-NEXT:     typealias Y = Any
// CHECK-NEXT:   }
// CHECK-NEXT: }
// CHECK: class MyImmortal {
// CHECK-NEXT:   func foo()
// CHECK-NEXT: }
// CHECK-NEXT: struct NonCopyable {
// CHECK-NEXT:   @available(*, deprecated, message:
// CHECK-NEXT:   init()
// CHECK-NEXT: }