Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/swift/AST/KnownIdentifiers.def
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ IDENTIFIER(CoreFoundation)
IDENTIFIER(count)
IDENTIFIER(CVarArg)
IDENTIFIER(Cxx)
IDENTIFIER(CxxStdlib)
IDENTIFIER(Darwin)
IDENTIFIER(Distributed)
IDENTIFIER(dealloc)
Expand Down
8 changes: 8 additions & 0 deletions lib/ClangImporter/ClangImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2001,6 +2001,14 @@ ClangImporter::loadModule(SourceLoc importLoc,
ModuleDecl *ClangImporter::Implementation::loadModule(
SourceLoc importLoc, ImportPath::Module path) {
ModuleDecl *MD = nullptr;
ASTContext &ctx = getNameImporter().getContext();

if (path.front().Item == ctx.Id_CxxStdlib) {
ImportPath::Builder adjustedPath(ctx.getIdentifier("std"), importLoc);
adjustedPath.append(path.getSubmodulePath());
path = adjustedPath.get().getModulePath(ImportKind::Module);
}

if (!DisableSourceImport)
MD = loadModuleClang(importLoc, path);
if (!MD)
Expand Down
6 changes: 3 additions & 3 deletions test/Interop/Cxx/stdlib/libcxx-module-interface.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %target-swift-ide-test -print-module -module-to-print=std -source-filename=x -enable-experimental-cxx-interop -tools-directory=%llvm_obj_root/bin -module-cache-path %t | %FileCheck %s -check-prefix=CHECK-STD
// RUN: %target-swift-ide-test -print-module -module-to-print=std.iosfwd -source-filename=x -enable-experimental-cxx-interop -tools-directory=%llvm_obj_root/bin -module-cache-path %t | %FileCheck %s -check-prefix=CHECK-IOSFWD
// RUN: %target-swift-ide-test -print-module -module-to-print=std.string -source-filename=x -enable-experimental-cxx-interop -tools-directory=%llvm_obj_root/bin -module-cache-path %t | %FileCheck %s -check-prefix=CHECK-STRING
// RUN: %target-swift-ide-test -print-module -module-to-print=CxxStdlib -source-filename=x -enable-experimental-cxx-interop -tools-directory=%llvm_obj_root/bin -module-cache-path %t | %FileCheck %s -check-prefix=CHECK-STD
// RUN: %target-swift-ide-test -print-module -module-to-print=CxxStdlib.iosfwd -source-filename=x -enable-experimental-cxx-interop -tools-directory=%llvm_obj_root/bin -module-cache-path %t | %FileCheck %s -check-prefix=CHECK-IOSFWD
// RUN: %target-swift-ide-test -print-module -module-to-print=CxxStdlib.string -source-filename=x -enable-experimental-cxx-interop -tools-directory=%llvm_obj_root/bin -module-cache-path %t | %FileCheck %s -check-prefix=CHECK-STRING

// This test is specific to libc++ and therefore only runs on Darwin platforms.
// REQUIRES: OS=macosx || OS=ios
Expand Down
2 changes: 1 addition & 1 deletion test/Interop/Cxx/stdlib/libstdcxx-module-interface.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-ide-test -print-module -module-to-print=std -source-filename=x -enable-experimental-cxx-interop -module-cache-path %t > %t/interface.swift
// RUN: %target-swift-ide-test -print-module -module-to-print=CxxStdlib -source-filename=x -enable-experimental-cxx-interop -module-cache-path %t > %t/interface.swift
// RUN: %FileCheck %s -check-prefix=CHECK-STD < %t/interface.swift
// RUN: %FileCheck %s -check-prefix=CHECK-SIZE-T < %t/interface.swift
// RUN: %FileCheck %s -check-prefix=CHECK-TO-STRING < %t/interface.swift
Expand Down
4 changes: 2 additions & 2 deletions test/Interop/Cxx/stdlib/msvcprt-module-interface.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-ide-test -print-module -module-to-print std -source-filename none -enable-experimental-cxx-interop -module-cache-path %t | %FileCheck %s -check-prefix CHECK-STD
// RUN: %target-swift-ide-test -print-module -module-to-print=std.string -source-filename=x -enable-experimental-cxx-interop -module-cache-path %t | %FileCheck %s -check-prefix CHECK-STRING
// RUN: %target-swift-ide-test -print-module -module-to-print CxxStdlib -source-filename none -enable-experimental-cxx-interop -module-cache-path %t | %FileCheck %s -check-prefix CHECK-STD
// RUN: %target-swift-ide-test -print-module -module-to-print=CxxStdlib.string -source-filename=x -enable-experimental-cxx-interop -module-cache-path %t | %FileCheck %s -check-prefix CHECK-STRING

// This test is specific to msvcprt and therefore only runs on Windows.
// REQUIRES: OS=windows-msvc
Expand Down
11 changes: 10 additions & 1 deletion test/Interop/Cxx/stdlib/use-std-string.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop)
// RUN: %target-run-simple-swift(-D USE_CXXSTDLIB_SPELLING -I %S/Inputs -Xfrontend -enable-experimental-cxx-interop)
//
// REQUIRES: executable_test
//
Expand All @@ -8,11 +9,19 @@
import StdlibUnittest
import StdString
#if os(Linux)
#if USE_CXXSTDLIB_SPELLING
import CxxStdlib
#else
import std
// FIXME: import std.string once libstdc++ is split into submodules.
#endif
// FIXME: import CxxStdlib.string once libstdc++ is split into submodules.
#else
#if USE_CXXSTDLIB_SPELLING
import CxxStdlib.string
#else
import std.string
#endif
#endif

var StdStringTestSuite = TestSuite("StdString")

Expand Down