Skip to content

Commit 2c2fa56

Browse files
committed
[cxx-interop][test] add %check-interop-cxx-header-in-clang test command substitution to parse and validated generated C++ header in multiple C++ language modes
This ensures that we validate C++14, C++17, and C++20
1 parent 9bf7a6e commit 2c2fa56

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

test/Interop/SwiftToCxx/functions/cdecl.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend %s -typecheck -module-name CdeclFunctions -emit-cxx-header-path %t/empty.h
3-
// RUN: %FileCheck %s < %t/empty.h
2+
// RUN: %target-swift-frontend %s -typecheck -module-name CdeclFunctions -emit-cxx-header-path %t/cdecl.h
3+
// RUN: %FileCheck %s < %t/cdecl.h
44

5-
// RUN: %check-cxx-header-in-clang -std=c++14 %t/empty.h
6-
// RUN: %check-cxx-header-in-clang -std=c++17 %t/empty.h
5+
// RUN: %check-interop-cxx-header-in-clang(%t/cdecl.h)
76

87
// CHECK-LABEL: namespace CdeclFunctions {
98

test/Interop/SwiftToCxx/functions/function-availability.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// RUN: %target-swift-frontend %s -typecheck -module-name Functions -emit-cxx-header-path %t/functions.h
33
// RUN: %FileCheck %s < %t/functions.h
44

5-
// RUN: %check-cxx-header-in-clang -std=c++14 %t/functions.h
6-
// RUN: %check-cxx-header-in-clang -std=c++17 %t/functions.h
5+
// RUN: %check-interop-cxx-header-in-clang(%t/functions.h)
76

87
// CHECK-LABEL: namespace Functions {
98

test/Interop/SwiftToCxx/functions/swift-functions.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// RUN: %target-swift-frontend %s -typecheck -module-name Functions -emit-cxx-header-path %t/functions.h
33
// RUN: %FileCheck %s < %t/functions.h
44

5-
// RUN: %check-cxx-header-in-clang -std=c++14 %t/functions.h
6-
// RUN: %check-cxx-header-in-clang -std=c++17 %t/functions.h
5+
// RUN: %check-interop-cxx-header-in-clang(%t/functions.h)
76

87
// CHECK-LABEL: namespace Functions {
98

test/Interop/SwiftToCxx/module/module-to-namespace.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %s -typecheck -module-name Test -emit-cxx-header-path %t/empty.h
33
// RUN: %FileCheck %s < %t/empty.h
44

5-
// RUN: %check-cxx-header-in-clang -std=c++14 %t/empty.h
6-
// RUN: %check-cxx-header-in-clang -std=c++17 %t/empty.h
5+
// RUN: %check-interop-cxx-header-in-clang(%t/empty.h)
76

87
// CHECK-LABEL: namespace Test {
98
// CHECK: } // namespace Test

test/Interop/lit.local.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@ config.substitutions.insert(0, ('%target-interop-build-swift',
2222
'%target-build-swift -Xfrontend -enable-cxx-interop '))
2323
# Build C++ files with matching link settings, if required by the target.
2424
config.substitutions.insert(0, ('%target-interop-build-clangxx', '%target-clangxx ' + clang_opt))
25+
26+
# Test parsing of the generated C++ header in different C++ language modes.
27+
config.substitutions.insert(0, ('%check-interop-cxx-header-in-clang\(([^)]+)\)',
28+
SubstituteCaptures(r'%check-cxx-header-in-clang -std=c++14 \1 && '
29+
r'%check-cxx-header-in-clang -std=c++17 \1 && '
30+
r'%check-cxx-header-in-clang -std=c++20 \1')))

0 commit comments

Comments
 (0)