diff --git a/lib/ClangImporter/ImportName.cpp b/lib/ClangImporter/ImportName.cpp index 1a1585f40d529..23d49a3be21ea 100644 --- a/lib/ClangImporter/ImportName.cpp +++ b/lib/ClangImporter/ImportName.cpp @@ -1423,6 +1423,8 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D, case clang::OverloadedOperatorKind::OO_Minus: case clang::OverloadedOperatorKind::OO_Star: case clang::OverloadedOperatorKind::OO_Slash: + case clang::OverloadedOperatorKind::OO_LessLess: + case clang::OverloadedOperatorKind::OO_GreaterGreater: case clang::OverloadedOperatorKind::OO_AmpAmp: case clang::OverloadedOperatorKind::OO_PipePipe: if (auto FD = dyn_cast(D)) { diff --git a/test/Interop/Cxx/operators/Inputs/non-member-inline.h b/test/Interop/Cxx/operators/Inputs/non-member-inline.h index f287a611e4fc1..7c4f28dfcd703 100644 --- a/test/Interop/Cxx/operators/Inputs/non-member-inline.h +++ b/test/Interop/Cxx/operators/Inputs/non-member-inline.h @@ -21,6 +21,14 @@ inline IntBox operator/(IntBox lhs, IntBox rhs) { return IntBox{.value = lhs.value / rhs.value}; } +inline IntBox operator<<(IntBox lhs, IntBox rhs) { + return IntBox{.value = lhs.value << rhs.value}; +} + +inline IntBox operator>>(IntBox lhs, IntBox rhs) { + return IntBox{.value = lhs.value >> rhs.value}; +} + struct BoolBox { bool value; }; diff --git a/test/Interop/Cxx/operators/non-member-inline-module-interface.swift b/test/Interop/Cxx/operators/non-member-inline-module-interface.swift index 8c8f165fb64ba..b056312cd4e26 100644 --- a/test/Interop/Cxx/operators/non-member-inline-module-interface.swift +++ b/test/Interop/Cxx/operators/non-member-inline-module-interface.swift @@ -4,6 +4,8 @@ // CHECK-NEXT: func - (lhs: IntBox, rhs: IntBox) -> IntBox // CHECK-NEXT: func * (lhs: IntBox, rhs: IntBox) -> IntBox // CHECK-NEXT: func / (lhs: IntBox, rhs: IntBox) -> IntBox +// CHECK-NEXT: func << (lhs: IntBox, rhs: IntBox) -> IntBox +// CHECK-NEXT: func >> (lhs: IntBox, rhs: IntBox) -> IntBox // CHECK: func && (lhs: BoolBox, rhs: BoolBox) -> BoolBox // CHECK-NEXT: func || (lhs: BoolBox, rhs: BoolBox) -> BoolBox diff --git a/test/Interop/Cxx/operators/non-member-inline-typechecker.swift b/test/Interop/Cxx/operators/non-member-inline-typechecker.swift index 9d02eec58a544..92a09901517be 100644 --- a/test/Interop/Cxx/operators/non-member-inline-typechecker.swift +++ b/test/Interop/Cxx/operators/non-member-inline-typechecker.swift @@ -9,6 +9,8 @@ let resultPlus = lhs + rhs let resultMinus = lhs - rhs let resultStar = lhs * rhs let resultSlash = lhs / rhs +let resultLessLess = lhs << rhs +let resultGreaterGreater = lhs >> rhs var lhsBool = BoolBox(value: true) var rhsBool = BoolBox(value: false) diff --git a/test/Interop/Cxx/operators/non-member-inline.swift b/test/Interop/Cxx/operators/non-member-inline.swift index 2f5fa56f766ae..c383c165a980f 100644 --- a/test/Interop/Cxx/operators/non-member-inline.swift +++ b/test/Interop/Cxx/operators/non-member-inline.swift @@ -7,7 +7,7 @@ import StdlibUnittest var OperatorsTestSuite = TestSuite("Operators") -OperatorsTestSuite.test("plus") { +OperatorsTestSuite.test("plus (+)") { let lhs = IntBox(value: 42) let rhs = IntBox(value: 23) @@ -16,7 +16,7 @@ OperatorsTestSuite.test("plus") { expectEqual(65, result.value) } -OperatorsTestSuite.test("minus") { +OperatorsTestSuite.test("minus (-)") { let lhs = IntBox(value: 42) let rhs = IntBox(value: 23) @@ -25,7 +25,7 @@ OperatorsTestSuite.test("minus") { expectEqual(19, result.value) } -OperatorsTestSuite.test("star") { +OperatorsTestSuite.test("star (*)") { let lhs = IntBox(value: 42) let rhs = IntBox(value: 23) @@ -34,7 +34,7 @@ OperatorsTestSuite.test("star") { expectEqual(966, result.value) } -OperatorsTestSuite.test("slash") { +OperatorsTestSuite.test("slash (/)") { let lhs = IntBox(value: 42) let rhs = IntBox(value: 23) @@ -43,6 +43,24 @@ OperatorsTestSuite.test("slash") { expectEqual(1, result.value) } +OperatorsTestSuite.test("less less (<<)") { + let lhs = IntBox(value: 2) + let rhs = IntBox(value: 4) + + let result = lhs << rhs + + expectEqual(32, result.value) +} + +OperatorsTestSuite.test("greater greater (>>)") { + let lhs = IntBox(value: 512) + let rhs = IntBox(value: 8) + + let result = lhs >> rhs + + expectEqual(2, result.value) +} + OperatorsTestSuite.test("amp amp (&&)") { let lhs = BoolBox(value: true) let rhs = BoolBox(value: false)