Skip to content

Commit aab5c45

Browse files
committed
[interop][SwiftToCxx] include _SwiftCxxInteroperability.h in the toolchain, relative to clang's resource dir
1 parent 09dcbde commit aab5c45

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/PrintAsClang/PrintAsClang.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,13 @@ static void writePrologue(raw_ostream &out, ASTContext &ctx,
105105
"#include <cstring>\n";
106106
out << "#include <stdlib.h>\n";
107107
out << "#include <new>\n";
108-
out << "#if __has_include(<shims/_SwiftCxxInteroperability.h>)\n";
108+
// FIXME: Look for the header in the SDK.
109+
out << "// Look for the C++ interop support header relative to clang's resource dir:\n";
110+
out << "// '<toolchain>/usr/lib/clang/<version>/include/../../../swift/shims'.\n";
111+
out << "#if __has_include(<../../../swift/shims/_SwiftCxxInteroperability.h>)\n";
112+
out << "#include <../../../swift/shims/_SwiftCxxInteroperability.h>\n";
113+
out << "// Alternatively, allow user to find the header using additional include path into 'swift'.\n";
114+
out << "#elif __has_include(<shims/_SwiftCxxInteroperability.h>)\n";
109115
out << "#include <shims/_SwiftCxxInteroperability.h>\n";
110116
out << "#endif\n";
111117
},

test/PrintAsCxx/empty.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@
3131
// CHECK-NEXT: #include <cstring>
3232
// CHECK-NEXT: #include <stdlib.h>
3333
// CHECK-NEXT: #include <new>
34-
// CHECK-NEXT: #if __has_include(<shims/_SwiftCxxInteroperability.h>)
34+
// CHECK-NEXT: // Look for the C++ interop support header relative to clang's resource dir:
35+
// CHECK-NEXT: // '<toolchain>/usr/lib/clang/<version>/include/../../../swift/shims'.
36+
// CHECK-NEXT: #if __has_include(<../../../swift/shims/_SwiftCxxInteroperability.h>)
37+
// CHECK-NEXT: #include <../../../swift/shims/_SwiftCxxInteroperability.h>
38+
// CHECK-NEXT: // Alternatively, allow user to find the header using additional include path into 'swift'.
39+
// CHECK-NEXT: #elif __has_include(<shims/_SwiftCxxInteroperability.h>)
3540
// CHECK-NEXT: #include <shims/_SwiftCxxInteroperability.h>
3641
// CHECK-NEXT: #endif
3742
// CHECK-NEXT: #else

0 commit comments

Comments
 (0)