Skip to content

Commit c29e436

Browse files
committed
[cxx-interop] Make sure interop does not trigger TBD validation errors
This disables TBD validation when C++ interop is enabled, unless an explicit `-validate-tbd-against-ir=` flag was passed. rdar://83405989 / #56458 (cherry picked from commit 8f58eaf)
1 parent 403a7dc commit c29e436

11 files changed

+22
-17
lines changed

lib/Frontend/ArgsToFrontendOptionsConverter.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,9 @@ void ArgsToFrontendOptionsConverter::computeDebugTimeOptions() {
402402

403403
void ArgsToFrontendOptionsConverter::computeTBDOptions() {
404404
using namespace options;
405+
using Mode = FrontendOptions::TBDValidationMode;
406+
405407
if (const Arg *A = Args.getLastArg(OPT_validate_tbd_against_ir_EQ)) {
406-
using Mode = FrontendOptions::TBDValidationMode;
407408
StringRef value = A->getValue();
408409
if (value == "none") {
409410
Opts.ValidateTBDAgainstIR = Mode::None;
@@ -415,6 +416,16 @@ void ArgsToFrontendOptionsConverter::computeTBDOptions() {
415416
Diags.diagnose(SourceLoc(), diag::error_unsupported_option_argument,
416417
A->getOption().getPrefixedName(), value);
417418
}
419+
} else if (Args.hasArg(OPT_enable_experimental_cxx_interop) ||
420+
Args.hasArg(OPT_cxx_interoperability_mode)) {
421+
// TBD validation currently emits diagnostics when C++ interop is enabled,
422+
// which is likely caused by IRGen incorrectly applying attributes to
423+
// symbols, forcing the user to pass `-validate-tbd-against-ir=none`.
424+
// If no explicit TBD validation mode was specified, disable it if C++
425+
// interop is enabled.
426+
// See https://github.com/apple/swift/issues/56458.
427+
// FIXME: the TBD validation diagnostics are correct and should be enabled.
428+
Opts.ValidateTBDAgainstIR = Mode::None;
418429
}
419430
}
420431

test/Interop/Cxx/class/inline-function-codegen/static-var-init-calls-function-execution.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop -Xfrontend -validate-tbd-against-ir=none)
1+
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop)
22
//
33
// REQUIRES: executable_test
44

5-
// TODO: See why -validate-tbd-against-ir=none is needed here
6-
// (https://github.com/apple/swift/issues/56458).
7-
85
import StaticVarInitCallsFunction
96
import StdlibUnittest
107

test/Interop/Cxx/class/inline-function-codegen/static-var-init-calls-function-irgen.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
// RUN: %target-swift-emit-ir %s -I %S/Inputs -enable-experimental-cxx-interop -validate-tbd-against-ir=none | %FileCheck %s
2-
3-
// TODO: See why -validate-tbd-against-ir=none is needed here
4-
// (https://github.com/apple/swift/issues/56458).
1+
// RUN: %target-swift-emit-ir %s -I %S/Inputs -enable-experimental-cxx-interop | %FileCheck %s
52

63
import StaticVarInitCallsFunction
74

test/Interop/Cxx/stdlib/overlay/custom-convertible-to-collection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop -Xfrontend -validate-tbd-against-ir=none)
1+
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop)
22
//
33
// REQUIRES: executable_test
44
// REQUIRES: OS=macosx || OS=linux-gnu

test/Interop/Cxx/stdlib/overlay/std-string-overlay.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-cxx-interop -Xfrontend -validate-tbd-against-ir=none)
1+
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-cxx-interop)
22
//
33
// REQUIRES: executable_test
44
// REQUIRES: OS=macosx || OS=linux-gnu

test/Interop/Cxx/stdlib/use-std-map.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop -Xfrontend -validate-tbd-against-ir=none)
1+
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop)
22
//
33
// REQUIRES: executable_test
44
//

test/Interop/Cxx/stdlib/use-std-optional.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop -Xcc -std=c++17 -Xfrontend -validate-tbd-against-ir=none)
1+
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop -Xcc -std=c++17)
22
//
33
// REQUIRES: executable_test
44
// REQUIRES: OS=macosx

test/Interop/Cxx/stdlib/use-std-pair.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop -Xfrontend -validate-tbd-against-ir=none)
1+
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop)
22
//
33
// REQUIRES: executable_test
44
//

test/Interop/Cxx/stdlib/use-std-set.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop -Xfrontend -validate-tbd-against-ir=none)
1+
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop)
22
//
33
// REQUIRES: executable_test
44
//

test/Interop/Cxx/stdlib/use-std-string.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop -Xfrontend -validate-tbd-against-ir=none)
1+
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop)
22
//
33
// REQUIRES: executable_test
44

test/Interop/Cxx/stdlib/use-std-vector.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop -Xfrontend -validate-tbd-against-ir=none)
1+
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop)
22
//
33
// REQUIRES: executable_test
44
//

0 commit comments

Comments
 (0)