Skip to content

Commit 3c824dd

Browse files
committed
Include Foundation framework instead of minimal NSObject.h
This change is for preventing scenarios like https://bugs.swift.org/projects/SR/issues/SR-2250
1 parent 53500e6 commit 3c824dd

File tree

8 files changed

+10
-7
lines changed

8 files changed

+10
-7
lines changed

lib/PrintAsObjC/PrintAsObjC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2438,7 +2438,7 @@ class ModuleWriter {
24382438
"#endif\n"
24392439
"\n"
24402440
"#pragma clang diagnostic ignored \"-Wauto-import\"\n"
2441-
"#include <objc/NSObject.h>\n"
2441+
"#include <Foundation/Foundation.h>\n"
24422442
"#include <stdint.h>\n"
24432443
"#include <stddef.h>\n"
24442444
"#include <stdbool.h>\n"

test/ClangImporter/MixedSource/resolve-cross-language.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource) -emit-module -enable-objc-interop -emit-objc-header -o %t %S/Inputs/resolve-cross-language/Base.swift -disable-objc-attr-requires-foundation-module
44
// RUN: cp %S/Inputs/resolve-cross-language/Base-module.map %t/module.map
5-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource) -enable-objc-interop -typecheck -I %t -F %S/Inputs/resolve-cross-language %s -verify
5+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource) -enable-objc-interop -typecheck -I %t -F %S/../../PrintAsObjC/Inputs/ -F %S/Inputs/resolve-cross-language %s -verify
66

77
import Base
88
import BaseUser

test/Index/cross_language.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
// RUN: cat %s > %t/combined.m
1010
// RUN: cat %S/Inputs/cross_language.m >> %t/combined.m
11-
// RUN: c-index-test core -print-source-symbols -- %t/combined.m -I %t -isysroot %S/../Inputs/clang-importer-sdk >> %t.idx.out
11+
// RUN: c-index-test core -print-source-symbols -- %t/combined.m -F %S/../PrintAsObjC/Inputs -I %t -isysroot %S/../Inputs/clang-importer-sdk >> %t.idx.out
1212
// RUN: %FileCheck %t/combined.m -input-file %t.idx.out
1313

1414
#if SWIFT_CODE
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include <objc/NSObject.h>

test/PrintAsObjC/empty.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// CHECK-NEXT: # define __has_feature(x) 0
2222
// CHECK-NEXT: #endif
2323

24-
// CHECK-LABEL: #include <objc/NSObject.h>
24+
// CHECK-LABEL: #include <Foundation/Foundation.h>
2525
// CHECK: #include <stdint.h>
2626
// CHECK: #include <stddef.h>
2727
// CHECK: #include <stdbool.h>

test/PrintAsObjC/lit.local.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ config.substitutions.insert(0, ('%check-in-clang',
66
'-fmodules-validate-system-headers '
77
'-Weverything -Werror -Wno-unused-macros -Wno-incomplete-module '
88
'-Wno-auto-import '
9+
'-F %%S/Inputs/ '
910
'-I %%clang-include-dir '
1011
'-isysroot %r/Inputs/clang-importer-sdk' % config.test_source_root) )
1112

@@ -14,5 +15,6 @@ config.substitutions.insert(0, ('%check-in-clang\+\+',
1415
'-Weverything -Werror -Wno-unused-macros -Wno-incomplete-module '
1516
'-Wno-auto-import -Wno-variadic-macros -Wno-c++98-compat-pedantic '
1617
'-Wno-unused-command-line-argument ' # for -fmodules-cache-path
18+
'-F %%S/Inputs/ '
1719
'-I %%clang-include-dir '
1820
'-isysroot %r/Inputs/clang-importer-sdk' % config.test_source_root) )

test/PrintAsObjC/reintroduced-new.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88

99
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/../../test/Inputs/clang-importer-sdk -I %t) -emit-module -o %t %S/Inputs/reintroduced-new.swift -swift-version 4 -disable-objc-attr-requires-foundation-module -module-name main
1010
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/../../test/Inputs/clang-importer-sdk -I %t) -parse-as-library %t/main.swiftmodule -typecheck -emit-objc-header-path %t/generated.h -disable-objc-attr-requires-foundation-module -swift-version 4
11-
// RUN: not %clang -fsyntax-only -x objective-c %s -include %t/generated.h -fobjc-arc -fmodules -Werror -isysroot %S/../../test/Inputs/clang-importer-sdk 2>&1 | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-4 %s
11+
// RUN: not %clang -fsyntax-only -x objective-c %s -include %t/generated.h -fobjc-arc -fmodules -Werror -F %S/Inputs/ -isysroot %S/../../test/Inputs/clang-importer-sdk 2>&1 | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-4 %s
1212

1313
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/../../test/Inputs/clang-importer-sdk -I %t) -emit-module -o %t %S/Inputs/reintroduced-new.swift -disable-objc-attr-requires-foundation-module -module-name main -swift-version 5
1414
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/../../test/Inputs/clang-importer-sdk -I %t) -parse-as-library %t/main.swiftmodule -typecheck -emit-objc-header-path %t/generated.h -disable-objc-attr-requires-foundation-module -swift-version 5
15-
// RUN: not %clang -fsyntax-only -x objective-c %s -include %t/generated.h -fobjc-arc -fmodules -Werror -isysroot %S/../../test/Inputs/clang-importer-sdk 2>&1 | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-5 %s
15+
// RUN: not %clang -fsyntax-only -x objective-c %s -include %t/generated.h -fobjc-arc -fmodules -Werror -F %S/Inputs/ -isysroot %S/../../test/Inputs/clang-importer-sdk 2>&1 | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-5 %s
1616

1717
// CHECK-NOT: error:
1818

test/PrintAsObjC/swift_name.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %empty-directory(%t)
22
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %S/../Inputs/empty.swift -typecheck -emit-objc-header-path %t/empty.h
3-
// RUN: %clang -E -fobjc-arc -fmodules -isysroot %clang-importer-sdk-path -I %t %s | %FileCheck %s
3+
// RUN: %clang -F %S/Inputs/ -E -fobjc-arc -fmodules -isysroot %clang-importer-sdk-path -I %t %s | %FileCheck %s
44

55
// REQUIRES: objc_interop
66

0 commit comments

Comments
 (0)