Skip to content
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
4 changes: 4 additions & 0 deletions lib/PrintAsObjC/PrintAsObjC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2727,6 +2727,10 @@ class ModuleWriter {
void writeImports(raw_ostream &out) {
out << "#if __has_feature(modules)\n";

out << "#if __has_warning(\"-Watimport-in-framework-header\")\n"
<< "#pragma clang diagnostic ignored \"-Watimport-in-framework-header\"\n"
<< "#endif\n";

// Sort alphabetically for determinism and consistency.
SmallVector<ImportModuleTy, 8> sortedImports{imports.begin(),
imports.end()};
Expand Down
4 changes: 2 additions & 2 deletions test/PrintAsObjC/arc-conventions.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// RUN: %empty-directory(%t)
// RUN: %target-build-swift -c %s -parse-as-library -force-single-frontend-invocation -o %t/swift.o -emit-objc-header-path %t/swift.h

// RUN: %target-clang -c -Weverything -Werror -Wno-unused-macros -Wno-incomplete-module -fobjc-arc -fmodules %S/Inputs/arc-conventions.m -o %t/main.o -I %t
// RUN: %clang -c %target-cc-options -isysroot %sdk -Weverything -Werror -Wno-unused-macros -Wno-incomplete-module -fobjc-arc -fmodules %S/Inputs/arc-conventions.m -o %t/main.o -I %t
// RUN: %target-build-swift %t/swift.o %t/main.o -o %t/main
// RUN: %target-codesign %t/main
// RUN: %target-run %t/main | %FileCheck %S/Inputs/arc-conventions.m

// RUN: %target-clang -c -Weverything -Werror -Wno-unused-macros -Wno-incomplete-module -fno-objc-arc -fmodules %S/Inputs/arc-conventions.m -o %t/main.o -I %t
// RUN: %clang -c %target-cc-options -isysroot %sdk -Weverything -Werror -Wno-unused-macros -Wno-incomplete-module -fno-objc-arc -fmodules %S/Inputs/arc-conventions.m -o %t/main.o -I %t
// RUN: %target-build-swift %t/swift.o %t/main.o -o %t/main2
// RUN: %target-codesign %t/main2
// RUN: %target-run %t/main2 | %FileCheck %S/Inputs/arc-conventions.m
Expand Down
3 changes: 3 additions & 0 deletions test/PrintAsObjC/empty.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
// CHECK: # define OBJC_DESIGNATED_INITIALIZER

// CHECK-LABEL: #if __has_feature(modules)
// CHECK-NEXT: #if __has_warning
// CHECK-NEXT: #pragma clang diagnostic
// CHECK-NEXT: #endif
// CHECK-NEXT: #endif


Expand Down
2 changes: 1 addition & 1 deletion test/PrintAsObjC/imports.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -I %S/Inputs/custom-modules/ -F %S/Inputs/ -parse-as-library %t/imports.swiftmodule -typecheck -emit-objc-header-path %t/imports.h -import-objc-header %S/../Inputs/empty.h -disable-objc-attr-requires-foundation-module
// RUN: %FileCheck %s < %t/imports.h
// RUN: %FileCheck -check-prefix=NEGATIVE %s < %t/imports.h
// RUN: %check-in-clang %t/imports.h -I %S/Inputs/custom-modules/ -F %S/Inputs/
// RUN: %check-in-clang %t/imports.h -I %S/Inputs/custom-modules/ -F %S/Inputs/ -Watimport-in-framework-header

// REQUIRES: objc_interop

Expand Down
3 changes: 3 additions & 0 deletions test/PrintAsObjC/mixed-framework-fwd.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
// REQUIRES: objc_interop

// CHECK-LABEL: #if __has_feature(modules)
// CHECK-NEXT: #if __has_warning
// CHECK-NEXT: #pragma clang diagnostic
// CHECK-NEXT: #endif
// CHECK-NEXT: @import Foundation;
// CHECK-NEXT: #endif

Expand Down
22 changes: 15 additions & 7 deletions test/PrintAsObjC/mixed-framework.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -F %S/Inputs/ -module-name Mixed -import-underlying-module -parse-as-library %s -typecheck -emit-objc-header-path %t/mixed.h
// RUN: %FileCheck -check-prefix=CHECK -check-prefix=FRAMEWORK %s < %t/mixed.h
// RUN: %check-in-clang -F %S/Inputs/ %t/mixed.h
// RUN: %empty-directory(%t.framework)
// RUN: %empty-directory(%t.framework/Headers)
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -F %S/Inputs/ -module-name Mixed -import-underlying-module -parse-as-library %s -typecheck -emit-objc-header-path %t.framework/Headers/mixed.h
// RUN: %FileCheck -check-prefix=CHECK -check-prefix=FRAMEWORK %s < %t.framework/Headers/mixed.h
// RUN: %check-in-clang -Watimport-in-framework-header -F %S/Inputs/ %t.framework/Headers/mixed.h

// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -module-name Mixed -import-objc-header %S/Inputs/Mixed.framework/Headers/Mixed.h %s -typecheck -emit-objc-header-path %t/mixed-header.h
// RUN: %FileCheck -check-prefix=CHECK -check-prefix=HEADER %s < %t/mixed-header.h
// RUN: %check-in-clang -include %S/Inputs/Mixed.framework/Headers/Mixed.h %t/mixed-header.h
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -module-name Mixed -import-objc-header %S/Inputs/Mixed.framework/Headers/Mixed.h %s -typecheck -emit-objc-header-path %t.framework/Headers/mixed-header.h
// RUN: %FileCheck -check-prefix=CHECK -check-prefix=HEADER %s < %t.framework/Headers/mixed-header.h
// RUN: %check-in-clang -Watimport-in-framework-header -include %S/Inputs/Mixed.framework/Headers/Mixed.h %t.framework/Headers/mixed-header.h

// REQUIRES: objc_interop

// CHECK: #pragma clang diagnostic push

// CHECK-LABEL: #if __has_feature(modules)
// CHECK-NEXT: #if __has_warning("-Watimport-in-framework-header")
// CHECK-NEXT: #pragma clang diagnostic ignored "-Watimport-in-framework-header"
// CHECK-NEXT: #endif
// CHECK-NEXT: @import Foundation;
// CHECK-NEXT: #endif

Expand All @@ -32,3 +38,5 @@ public class Dummy: NSNumber {
// HEADER: @property (nonatomic) NSInteger extraData;
@objc public internal(set) var extraData: Int = 0
} // CHECK: @end

// CHECK: #pragma clang diagnostic pop