Skip to content

Commit f9aa02b

Browse files
committed
[interop][SwiftToCxx] fix the source compat failures
1 parent ff37c4e commit f9aa02b

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

lib/PrintAsClang/PrintAsClang.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,15 @@ static void emitObjCConditional(raw_ostream &out,
5252
}
5353

5454
static void writePtrauthPrologue(raw_ostream &os) {
55-
os << "#if __has_include(<ptrauth.h>)\n";
56-
os << "# include <ptrauth.h>\n";
57-
os << "#else\n";
58-
os << "# ifndef __ptrauth_swift_value_witness_function_pointer\n";
59-
os << "# define __ptrauth_swift_value_witness_function_pointer(x)\n";
60-
os << "# endif\n";
61-
os << "#endif\n";
55+
emitCxxConditional(os, [&]() {
56+
os << "#if __has_include(<ptrauth.h>)\n";
57+
os << "# include <ptrauth.h>\n";
58+
os << "#else\n";
59+
os << "# ifndef __ptrauth_swift_value_witness_function_pointer\n";
60+
os << "# define __ptrauth_swift_value_witness_function_pointer(x)\n";
61+
os << "# endif\n";
62+
os << "#endif\n";
63+
});
6264
}
6365

6466
static void writePrologue(raw_ostream &out, ASTContext &ctx,

test/PrintAsCxx/empty.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@
3535
// CHECK-NEXT: #include <stdbool.h>
3636
// CHECK-NEXT: #include <string.h>
3737
// CHECK-NEXT: #endif
38+
// CHECK-NEXT: #if defined(__cplusplus)
3839
// CHECK-NEXT: #if __has_include(<ptrauth.h>)
3940
// CHECK-NEXT: # include <ptrauth.h>
4041
// CHECK-NEXT: #else
4142
// CHECK-NEXT: # ifndef __ptrauth_swift_value_witness_function_pointer
4243
// CHECK-NEXT: # define __ptrauth_swift_value_witness_function_pointer(x)
4344
// CHECK-NEXT: # endif
4445
// CHECK-NEXT: #endif
46+
// CHECK-NEXT: #endif
4547

4648
// CHECK-LABEL: !defined(SWIFT_TYPEDEFS)
4749
// CHECK-NEXT: # define SWIFT_TYPEDEFS 1

0 commit comments

Comments
 (0)