Skip to content

Commit 1617e53

Browse files
authored
Merge pull request #37379 from compnerd/cxx-interop-5.4
Backport some fixes for C++ interop tests on 5.4
2 parents b19c4d0 + 255eac0 commit 1617e53

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+125
-45
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -520,21 +520,44 @@ importer::getNormalInvocationArguments(
520520
invocationArgStrs.push_back(
521521
"-Werror=non-modular-include-in-framework-module");
522522

523+
bool EnableCXXInterop = LangOpts.EnableCXXInterop;
524+
523525
if (LangOpts.EnableObjCInterop) {
524-
bool EnableCXXInterop = LangOpts.EnableCXXInterop;
525-
invocationArgStrs.insert(
526-
invocationArgStrs.end(),
527-
{"-x", EnableCXXInterop ? "objective-c++" : "objective-c",
528-
EnableCXXInterop ? "-std=gnu++17" : "-std=gnu11", "-fobjc-arc"});
526+
invocationArgStrs.insert(invocationArgStrs.end(), {"-fobjc-arc"});
529527
// TODO: Investigate whether 7.0 is a suitable default version.
530528
if (!triple.isOSDarwin())
531529
invocationArgStrs.insert(invocationArgStrs.end(),
532530
{"-fobjc-runtime=ios-7.0"});
531+
invocationArgStrs.insert(invocationArgStrs.end(), {
532+
"-x", EnableCXXInterop ? "objective-c++" : "objective-c"
533+
});
533534
} else {
534-
bool EnableCXXInterop = LangOpts.EnableCXXInterop;
535-
invocationArgStrs.insert(invocationArgStrs.end(),
536-
{"-x", EnableCXXInterop ? "c++" : "c",
537-
EnableCXXInterop ? "-std=gnu++17" : "-std=gnu11"});
535+
invocationArgStrs.insert(invocationArgStrs.end(), {
536+
"-x", EnableCXXInterop ? "c++" : "c"
537+
});
538+
}
539+
540+
{
541+
const clang::LangStandard &stdcxx =
542+
#if defined(CLANG_DEFAULT_STD_CXX)
543+
*clang::LangStandard::getLangStandardForName(CLANG_DEFAULT_STD_CXX);
544+
#else
545+
clang::LangStandard::getLangStandardForKind(
546+
clang::LangStandard::lang_gnucxx14);
547+
#endif
548+
549+
const clang::LangStandard &stdc =
550+
#if defined(CLANG_DEFAULT_STD_C)
551+
*clang::LangStandard::getLangStandardForName(CLANG_DEFAULT_STD_C);
552+
#else
553+
clang::LangStandard::getLangStandardForKind(
554+
clang::LangStandard::lang_gnu11);
555+
#endif
556+
557+
invocationArgStrs.insert(invocationArgStrs.end(), {
558+
(Twine("-std=") + StringRef(EnableCXXInterop ? stdcxx.getName()
559+
: stdc.getName())).str()
560+
});
538561
}
539562

540563
// Set C language options.

test/ClangImporter/cxx_interop.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend -typecheck %s -I %S/Inputs/custom-modules -module-cache-path %t -enable-cxx-interop
2+
// RUN: %target-swiftxx-frontend -typecheck %s -I %S/Inputs/custom-modules
33

44
import CXXInterop
55

test/ClangImporter/cxx_interop_ir.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -module-name cxx_ir -I %S/Inputs/custom-modules -module-cache-path %t -enable-cxx-interop -emit-ir -o - -primary-file %s | %FileCheck %s
1+
// RUN: %target-swiftxx-frontend -module-name cxx_ir -I %S/Inputs/custom-modules -emit-ir -o - -primary-file %s | %FileCheck %s
22

33
import CXXInterop
44

test/ClangImporter/enum-cxx.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -emit-ir -primary-file %s -I %S/Inputs/custom-modules -module-cache-path %t -enable-cxx-interop -o - | %FileCheck %s
1+
// RUN: %target-swiftxx-frontend -emit-ir -primary-file %s -I %S/Inputs/custom-modules -o - | %FileCheck %s
22

33
import CXXInterop
44

test/Interop/C/function/emit-called-inline-function-irgen.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
// RUN: %empty-directory(%t)
88
// RUN: %target-swift-frontend %s -I %S/Inputs -Xcc -std=c99 -emit-ir -o - | %FileCheck %s -check-prefix C99 --implicit-check-not notCalled
9-
// RUN: %target-swift-frontend %s -I %S/Inputs -enable-cxx-interop -emit-ir -o - | %FileCheck %s -check-prefix CXX --implicit-check-not notCalled
9+
// RUN: %target-swiftxx-frontend %s -I %S/Inputs -emit-ir -o - | %FileCheck %s -check-prefix CXX --implicit-check-not notCalled
1010

1111
import EmitCalledInlineFunction
1212

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,59 @@
11
module AccessSpecifiers {
22
header "access-specifiers.h"
3+
requires cplusplus
34
}
45

56
module TypeClassification {
67
header "type-classification.h"
8+
requires cplusplus
79
}
810

911
module Constructors {
1012
header "constructors.h"
13+
requires cplusplus
1114
}
1215

1316
module ConstructorsObjC {
1417
header "constructors-objc.h"
18+
requires cplusplus
1519
}
1620

1721
module LoadableTypes {
1822
header "loadable-types.h"
23+
requires cplusplus
1924
}
2025

2126
module MemberwiseInitializer {
2227
header "memberwise-initializer.h"
28+
requires cplusplus
2329
}
2430

2531
module MemoryLayout {
2632
header "memory-layout.h"
33+
requires cplusplus
2734
}
2835

2936
module MemberVariables {
3037
header "member-variables.h"
38+
requires cplusplus
3139
}
3240

3341
module ProtocolConformance {
3442
header "protocol-conformance.h"
43+
requires cplusplus
3544
}
3645

3746
module SynthesizedInitializers {
3847
header "synthesized-initializers.h"
48+
requires cplusplus
3949
}
4050

4151
module DebugInfo {
4252
header "debug-info.h"
53+
requires cplusplus
4354
}
4455

4556
module NestedRecords {
4657
header "nested-records.h"
58+
requires cplusplus
4759
}

test/Interop/Cxx/class/constructors-silgen.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -I %S/Inputs -enable-cxx-interop -emit-silgen %s | %FileCheck %s
1+
// RUN: %target-swiftxx-frontend -I %S/Inputs -emit-silgen %s | %FileCheck %s
22

33
import Constructors
44

test/Interop/Cxx/class/debug-info-irgen.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -enable-cxx-interop -I %S/Inputs %s -emit-ir -g | %FileCheck %s
1+
// RUN: %target-swiftxx-frontend -I %S/Inputs %s -emit-ir -g | %FileCheck %s
22

33
// Validate that we don't crash when trying to deserialize C++ type debug info.
44
// Note, however, that the actual debug info is not generated, see SR-13223.

test/Interop/Cxx/class/memory-layout-silgen.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -I %S/Inputs -enable-cxx-interop -emit-ir -o - %s | %FileCheck %s
1+
// RUN: %target-swiftxx-frontend -I %S/Inputs -emit-ir -o - %s | %FileCheck %s
22

33
import MemoryLayout
44

test/Interop/Cxx/class/type-classification-non-trivial-irgen.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -enable-cxx-interop -I %S/Inputs %s -emit-ir | %FileCheck %s
1+
// RUN: %target-swiftxx-frontend -I %S/Inputs %s -emit-ir | %FileCheck %s
22

33
// Verify that non-trival/address-only C++ classes are constructed and accessed
44
// correctly. Make sure that we correctly IRGen functions that construct

0 commit comments

Comments
 (0)