[cxx-interop] start to emitting a unified header file for a Swift module

This change removes the -emit-cxx-header option, and adds a new -emit-clang-header-path option instead. It's aliased to -emit-objc-header-path for now, but in the future, -emit-objc-header-path will alias to it. After this change Swift can start emitting a single header file that can be expose declarations to C, Objective-C, or C++. For now C++ interface is generated (for all public decls) only when -enable-cxx-interop flag is passed, but that behavior will change once  attribute is supported.
This commit is contained in:
Alex Lorenz
2022-03-15 19:26:36 -07:00
parent 683224acd4
commit 9d52099d5b
29 changed files with 163 additions and 218 deletions

View File

@@ -1,13 +1,7 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %s -typecheck -emit-cxx-header-path %t/empty.h
// RUN: %target-swift-frontend %s -typecheck -enable-cxx-interop -emit-clang-header-path %t/empty.h
// RUN: %FileCheck %s < %t/empty.h
// RUN: %check-cxx-header-in-clang -std=c++14 %t/empty.h
// RUN: %check-cxx-header-in-clang -std=c++17 %t/empty.h
// CHECK-NOT: @import Swift;
// CHECK-NOT: IBSegueAction
// CHECK-LABEL: #ifndef EMPTY_SWIFT_H
// CHECK-NEXT: #define EMPTY_SWIFT_H
@@ -63,7 +57,19 @@
// CHECK: # define SWIFT_EXTENSION(M)
// CHECK: # define OBJC_DESIGNATED_INITIALIZER
// CHECK-LABEL: namespace empty {
// CHECK: } // namespace empty
// CHECK-LABEL: #if defined(__OBJC__)
// CHECK-NEXT: #if !defined(IBSegueAction)
// CHECK-NEXT: # define IBSegueAction
// CHECK-NEXT: #endif
// CHECK-LABEL: #if defined(__OBJC__)
// CHECK-NEXT: #if __has_feature(modules)
// CHECK-LABEL: #if defined(__OBJC__)
// CHECK-NEXT: #endif
// CHECK-NEXT: #if defined(__cplusplus)
// CHECK-NEXT: namespace empty {
// CHECK: } // namespace empty
// CHECK: #endif
// CHECK-NOT: @