Skip to content

Commit 34e602b

Browse files
authored
[PrintAsObjC] Don't define char{16,32}_t in C++-pre-11 (#12537)
Turns out libc++ already defines compatibility typedefs in this case, and we don't care about any other C++ stdlibs on Apple platforms at the moment. rdar://problem/34861807
1 parent 44e3e17 commit 34e602b

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

lib/PrintAsObjC/PrintAsObjC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2385,7 +2385,7 @@ class ModuleWriter {
23852385
"# define SWIFT_TYPEDEFS 1\n"
23862386
"# if __has_include(<uchar.h>)\n"
23872387
"# include <uchar.h>\n"
2388-
"# elif !defined(__cplusplus) || __cplusplus < 201103L\n"
2388+
"# elif !defined(__cplusplus)\n"
23892389
"typedef uint_least16_t char16_t;\n"
23902390
"typedef uint_least32_t char32_t;\n"
23912391
"# endif\n"

test/PrintAsObjC/empty.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
// RUN: %empty-directory(%t)
22
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %s -typecheck -emit-objc-header-path %t/empty.h
33
// RUN: %FileCheck %s < %t/empty.h
4+
45
// RUN: %check-in-clang -std=c99 %t/empty.h
6+
// RUN: %check-in-clang -std=c11 %t/empty.h
7+
// RUN: %check-in-clang++ -std=c++98 %t/empty.h
8+
// RUN: %check-in-clang++ -std=c++14 %t/empty.h
9+
510
// RUN: %check-in-clang -std=c99 -fno-modules -Qunused-arguments %t/empty.h
611
// RUN: not %check-in-clang -I %S/Inputs/clang-headers %t/empty.h 2>&1 | %FileCheck %s --check-prefix=CUSTOM-OBJC-PROLOGUE
712

test/PrintAsObjC/lit.local.cfg

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,11 @@ config.substitutions.insert(0, ('%check-in-clang',
88
'-Wno-auto-import '
99
'-I %%clang-include-dir '
1010
'-isysroot %r/Inputs/clang-importer-sdk' % config.test_source_root) )
11+
12+
config.substitutions.insert(0, ('%check-in-clang\+\+',
13+
'%%clang++ -fsyntax-only -x objective-c++-header -fobjc-arc '
14+
'-Weverything -Werror -Wno-unused-macros -Wno-incomplete-module '
15+
'-Wno-auto-import -Wno-variadic-macros -Wno-c++98-compat-pedantic '
16+
'-Wno-unused-command-line-argument ' # for -fmodules-cache-path
17+
'-I %%clang-include-dir '
18+
'-isysroot %r/Inputs/clang-importer-sdk' % config.test_source_root) )

0 commit comments

Comments
 (0)