Skip to content

Commit

Permalink
[cxx-interop] Extend libstdc++ modulemap
Browse files Browse the repository at this point in the history
The modulemap needs to include the headers even if they are not supposed to be used directly from Swift:

If a C++ header is being imported into Swift, and the header includes a stdlib header, clang needs to correctly deduce that the stdlib header is a part of the stdlib module, and not a part of the C++ module that we're importing.
  • Loading branch information
egorzhdan committed Jul 4, 2022
1 parent beaabe5 commit 513d41d
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 1 deletion.
71 changes: 70 additions & 1 deletion stdlib/public/Cxx/std/libstdcxx.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,76 @@ module std {
module compat {
module cassert {
header "cassert"
requires cplusplus
export *
}

module cerrno {
header "cerrno"
export *
}

module cctype {
header "cctype"
export *
}

module cfloat {
header "cfloat"
export *
}

module ciso646 {
header "ciso646"
export *
}

module climits {
header "climits"
export *
}

module cmath {
header "cmath"
export *
}

module cstdarg {
header "cstdarg"
export *
}

module cstddef {
header "cstddef"
export *
}

module cstdio {
header "cstdio"
export *
}

module cstdlib {
header "cstdlib"
export *
}

module cstring {
header "cstring"
export *
}

module ctime {
header "ctime"
export *
}

module cwchar {
header "cwchar"
export *
}

module cwctype {
header "cwctype"
export *
}
}
Expand Down
2 changes: 2 additions & 0 deletions test/Interop/Cxx/stdlib/libstdcxx-module-interface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
// This test is specific to libstdc++ and only runs on platforms where libstdc++ is used.
// REQUIRES: OS=linux-gnu

// CHECK-STD: import std.compat

// CHECK-STD: enum std {
// CHECK-STRING: struct {{__CxxTemplateInstNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE|__CxxTemplateInstSs}} {
// CHECK-STRING: typealias value_type = std.__CxxTemplateInstSt11char_traitsIcE.char_type
Expand Down

0 comments on commit 513d41d

Please sign in to comment.