Skip to content

Commit a8b33a3

Browse files
committed
[interop][sourcekit] interface generator should show unavailable C++ declarations
1 parent 476823b commit a8b33a3

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: split-file %s %t
3+
4+
// RUN: %sourcekitd-test -req=interface-gen -module CxxModule -- -Xfrontend -disable-implicit-concurrency-module-import -Xfrontend -disable-implicit-string-processing-module-import -Xfrontend -enable-experimental-cxx-interop -I %t/Inputs -target %target-triple %clang-importer-sdk-nosource | %FileCheck %s
5+
6+
//--- Inputs/module.modulemap
7+
module CxxModule {
8+
header "headerA.h"
9+
requires cplusplus
10+
}
11+
12+
//--- Inputs/headerA.h
13+
14+
template<class T>
15+
struct X {
16+
public:
17+
int x;
18+
X(): x(0) {}
19+
20+
int *xy();
21+
};
22+
23+
using XofInt = X<int>;
24+
25+
//--- test.swift
26+
27+
import CxxModule
28+
29+
func testMe() {
30+
var v = XofInt();
31+
print(v.x);
32+
}
33+
34+
// CHECK: @available(*, unavailable, message: "Un-specialized class templates are not currently supported. Please use a specialization of this type.")
35+
// CHECK-NEXT: public struct X<T> {
36+
// CHECK-NEXT: }
37+
// CHECK: public struct X<Int32> {
38+
// CHECK: public typealias XofInt = X<Int32>

tools/SourceKit/lib/SwiftLang/SwiftEditorInterfaceGen.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,11 @@ static bool getModuleInterfaceInfo(ASTContext &Ctx,
290290

291291
PrintOptions Options = PrintOptions::printModuleInterface(
292292
Ctx.TypeCheckerOpts.PrintFullConvention);
293+
if (Mod->findUnderlyingClangModule()) {
294+
// Show unavailable C++ APIs.
295+
if (Ctx.LangOpts.EnableCXXInterop)
296+
Options.SkipUnavailable = false;
297+
}
293298
ModuleTraversalOptions TraversalOptions = None; // Don't print submodules.
294299
SmallString<128> Text;
295300
llvm::raw_svector_ostream OS(Text);

0 commit comments

Comments
 (0)