Skip to content

[SR-2250] Include Foundation framework instead of minimal NSObject.h #17615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/PrintAsObjC/PrintAsObjC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2438,7 +2438,7 @@ class ModuleWriter {
"#endif\n"
"\n"
"#pragma clang diagnostic ignored \"-Wauto-import\"\n"
"#include <objc/NSObject.h>\n"
"#include <Foundation/Foundation.h>\n"
"#include <stdint.h>\n"
"#include <stddef.h>\n"
"#include <stdbool.h>\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// 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
// RUN: cp %S/Inputs/resolve-cross-language/Base-module.map %t/module.map
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource) -enable-objc-interop -typecheck -I %t -F %S/Inputs/resolve-cross-language %s -verify
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-objc-interop -typecheck -I %t -F %clang-importer-sdk-path/frameworks -F %S/Inputs/resolve-cross-language %s -verify

import Base
import BaseUser
Expand Down
2 changes: 1 addition & 1 deletion test/Index/cross_language.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

// RUN: cat %s > %t/combined.m
// RUN: cat %S/Inputs/cross_language.m >> %t/combined.m
// RUN: c-index-test core -print-source-symbols -- %t/combined.m -I %t -isysroot %S/../Inputs/clang-importer-sdk >> %t.idx.out
// RUN: c-index-test core -print-source-symbols -- %t/combined.m -F %clang-importer-sdk-path/frameworks -I %t -isysroot %S/../Inputs/clang-importer-sdk >> %t.idx.out
// RUN: %FileCheck %t/combined.m -input-file %t.idx.out

#if SWIFT_CODE
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#import <Foundation.h>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define __COREFOUNDATION__ 1

typedef const struct __CFAllocator * CFAllocatorRef;
const CFAllocatorRef kCFAllocatorDefault;
extern const CFAllocatorRef kCFAllocatorDefault;


typedef const void *CFTypeRef;
Expand Down
2 changes: 1 addition & 1 deletion test/PrintAsObjC/cdecl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -parse-as-library %t/cdecl.swiftmodule -typecheck -emit-objc-header-path %t/cdecl.h -import-objc-header %S/../Inputs/empty.h -disable-objc-attr-requires-foundation-module
// RUN: %FileCheck %s < %t/cdecl.h
// RUN: %check-in-clang %t/cdecl.h
// RUN: %check-in-clang -fno-modules -Qunused-arguments %t/cdecl.h -include Foundation.h -include ctypes.h -include CoreFoundation.h
// RUN: %check-in-clang -fno-modules -Qunused-arguments %t/cdecl.h -include ctypes.h -include CoreFoundation.h

// REQUIRES: objc_interop

Expand Down
2 changes: 1 addition & 1 deletion test/PrintAsObjC/classes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// RUN: %FileCheck --check-prefix=NEGATIVE %s < %t/classes.h
// RUN: %check-in-clang -I %S/Inputs/custom-modules/ %t/classes.h
// RUN: not %check-in-clang -I %S/Inputs/custom-modules/ -fno-modules -Qunused-arguments %t/classes.h
// RUN: %check-in-clang -I %S/Inputs/custom-modules/ -fno-modules -Qunused-arguments %t/classes.h -include Foundation.h -include CoreFoundation.h -include objc_generics.h -include SingleGenericClass.h -include CompatibilityAlias.h
// RUN: %check-in-clang -I %S/Inputs/custom-modules/ -fno-modules -Qunused-arguments %t/classes.h -include CoreFoundation.h -include objc_generics.h -include SingleGenericClass.h -include CompatibilityAlias.h

// CHECK-NOT: AppKit;
// CHECK-NOT: Properties;
Expand Down
2 changes: 1 addition & 1 deletion test/PrintAsObjC/empty.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// CHECK-NEXT: # define __has_feature(x) 0
// CHECK-NEXT: #endif

// CHECK-LABEL: #include <objc/NSObject.h>
// CHECK-LABEL: #include <Foundation/Foundation.h>
// CHECK: #include <stdint.h>
// CHECK: #include <stddef.h>
// CHECK: #include <stdbool.h>
Expand Down
2 changes: 1 addition & 1 deletion test/PrintAsObjC/enums-frozen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -parse-as-library %t/enums.swiftmodule -typecheck -emit-objc-header-path %t/enums.h -import-objc-header %S/Inputs/enums.h -disable-objc-attr-requires-foundation-module -enable-resilience
// RUN: %FileCheck %s < %t/enums.h
// RUN: %check-in-clang %t/enums.h
// RUN: %check-in-clang -fno-modules -Qunused-arguments %t/enums.h -include Foundation.h -include ctypes.h -include CoreFoundation.h
// RUN: %check-in-clang -fno-modules -Qunused-arguments %t/enums.h -include ctypes.h -include CoreFoundation.h

// REQUIRES: objc_interop

Expand Down
2 changes: 1 addition & 1 deletion test/PrintAsObjC/enums.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// RUN: %FileCheck %s < %t/enums.h
// RUN: %FileCheck -check-prefix=NEGATIVE %s < %t/enums.h
// RUN: %check-in-clang %t/enums.h
// RUN: %check-in-clang -fno-modules -Qunused-arguments %t/enums.h -include Foundation.h -include ctypes.h -include CoreFoundation.h
// RUN: %check-in-clang -fno-modules -Qunused-arguments %t/enums.h -include ctypes.h -include CoreFoundation.h

// REQUIRES: objc_interop

Expand Down
2 changes: 2 additions & 0 deletions test/PrintAsObjC/lit.local.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ config.substitutions.insert(0, ('%check-in-clang',
'-fmodules-validate-system-headers '
'-Weverything -Werror -Wno-unused-macros -Wno-incomplete-module '
'-Wno-auto-import '
'-F %%clang-importer-sdk-path/frameworks '
'-I %%clang-include-dir '
'-isysroot %r/Inputs/clang-importer-sdk' % config.test_source_root) )

Expand All @@ -14,5 +15,6 @@ config.substitutions.insert(0, ('%check-in-clang\+\+',
'-Weverything -Werror -Wno-unused-macros -Wno-incomplete-module '
'-Wno-auto-import -Wno-variadic-macros -Wno-c++98-compat-pedantic '
'-Wno-unused-command-line-argument ' # for -fmodules-cache-path
'-F %%clang-importer-sdk-path/frameworks '
'-I %%clang-include-dir '
'-isysroot %r/Inputs/clang-importer-sdk' % config.test_source_root) )
6 changes: 3 additions & 3 deletions test/PrintAsObjC/reintroduced-new.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

// 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
// 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
// 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
// RUN: not %clang -fsyntax-only -x objective-c %s -include %t/generated.h -fobjc-arc -fmodules -Werror -F %clang-importer-sdk-path/frameworks -isysroot %S/../../test/Inputs/clang-importer-sdk 2>&1 | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-4 %s

// 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
// 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
// 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
// RUN: not %clang -fsyntax-only -x objective-c %s -include %t/generated.h -fobjc-arc -fmodules -Werror -F %clang-importer-sdk-path/frameworks -isysroot %S/../../test/Inputs/clang-importer-sdk 2>&1 | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-5 %s

// CHECK-NOT: error:

Expand All @@ -28,4 +28,4 @@ void test() {
(void)[Sub new];
}

// CHECK-NOT: error:
// CHECK-NOT: error:
2 changes: 1 addition & 1 deletion test/PrintAsObjC/simd.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -parse-as-library %t/simd_test.swiftmodule -typecheck -emit-objc-header-path %t/simd.h -import-objc-header %S/../Inputs/empty.h -disable-objc-attr-requires-foundation-module
// RUN: %FileCheck %s < %t/simd.h
// RUN: %check-in-clang %t/simd.h
// RUN: %check-in-clang -fno-modules -Qunused-arguments %t/simd.h -include Foundation.h
// RUN: %check-in-clang -fno-modules -Qunused-arguments %t/simd.h

// REQUIRES: objc_interop

Expand Down
2 changes: 1 addition & 1 deletion test/PrintAsObjC/swift_name.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %S/../Inputs/empty.swift -typecheck -emit-objc-header-path %t/empty.h
// RUN: %clang -E -fobjc-arc -fmodules -isysroot %clang-importer-sdk-path -I %t %s | %FileCheck %s
// RUN: %clang -F %clang-importer-sdk-path/frameworks -E -fobjc-arc -fmodules -isysroot %clang-importer-sdk-path -I %t %s | %FileCheck %s

// REQUIRES: objc_interop

Expand Down
2 changes: 1 addition & 1 deletion test/PrintAsObjC/versioned.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -parse-as-library %t/versioned.swiftmodule -typecheck -I %S/Inputs/custom-modules -emit-objc-header-path %t/versioned.h -import-objc-header %S/../Inputs/empty.h -disable-objc-attr-requires-foundation-module -swift-version 3
// RUN: %FileCheck %s < %t/versioned.h
// RUN: %check-in-clang -I %S/Inputs/custom-modules/ %t/versioned.h
// RUN: %check-in-clang -I %S/Inputs/custom-modules/ -fno-modules -Qunused-arguments %t/versioned.h -include Foundation.h -include VersionedFMWK.h
// RUN: %check-in-clang -I %S/Inputs/custom-modules/ -fno-modules -Qunused-arguments %t/versioned.h -include VersionedFMWK.h

import VersionedFMWK

Expand Down