Skip to content

Commit 6b3e18b

Browse files
authored
Merge pull request swiftlang#59965 from apple/egorzhdan/fix-bad-merge
[cxx-interop] NFC: fix bad merge
2 parents 20b00dd + 59cc7c4 commit 6b3e18b

File tree

3 files changed

+10
-62
lines changed

3 files changed

+10
-62
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -440,66 +440,6 @@ ClangImporter::~ClangImporter() {
440440

441441
#pragma mark Module loading
442442

443-
static Optional<StringRef> getModuleMapFilePath(StringRef name,
444-
SearchPathOptions &Opts,
445-
llvm::Triple triple,
446-
SmallVectorImpl<char> &buffer) {
447-
StringRef platform = swift::getPlatformNameForTriple(triple);
448-
StringRef arch = swift::getMajorArchitectureName(triple);
449-
450-
StringRef SDKPath = Opts.getSDKPath();
451-
if (!SDKPath.empty()) {
452-
buffer.clear();
453-
buffer.append(SDKPath.begin(), SDKPath.end());
454-
llvm::sys::path::append(buffer, "usr", "lib", "swift");
455-
llvm::sys::path::append(buffer, platform, arch, name);
456-
457-
// Only specify the module map if that file actually exists. It may not;
458-
// for example in the case that `swiftc -target x86_64-unknown-linux-gnu
459-
// -emit-ir` is invoked using a Swift compiler not built for Linux targets.
460-
if (llvm::sys::fs::exists(buffer))
461-
return StringRef(buffer.data(), buffer.size());
462-
}
463-
464-
if (!Opts.RuntimeResourcePath.empty()) {
465-
buffer.clear();
466-
buffer.append(Opts.RuntimeResourcePath.begin(),
467-
Opts.RuntimeResourcePath.end());
468-
llvm::sys::path::append(buffer, platform, arch, name);
469-
470-
// Only specify the module map if that file actually exists. It may not;
471-
// for example in the case that `swiftc -target x86_64-unknown-linux-gnu
472-
// -emit-ir` is invoked using a Swift compiler not built for Linux targets.
473-
if (llvm::sys::fs::exists(buffer))
474-
return StringRef(buffer.data(), buffer.size());
475-
}
476-
477-
return None;
478-
}
479-
480-
/// Finds the glibc.modulemap file relative to the provided resource dir.
481-
///
482-
/// Note that the module map used for Glibc depends on the target we're
483-
/// compiling for, and is not included in the resource directory with the other
484-
/// implicit module maps. It's at {freebsd|linux}/{arch}/glibc.modulemap.
485-
static Optional<StringRef>
486-
getGlibcModuleMapPath(SearchPathOptions &Opts, llvm::Triple triple,
487-
SmallVectorImpl<char> &buffer) {
488-
return getModuleMapFilePath("glibc.modulemap", Opts, triple, buffer);
489-
}
490-
491-
static Optional<StringRef>
492-
getLibStdCxxModuleMapPath(SearchPathOptions &opts, llvm::Triple triple,
493-
SmallVectorImpl<char> &buffer) {
494-
return getModuleMapFilePath("libstdcxx.modulemap", opts, triple, buffer);
495-
}
496-
497-
static Optional<StringRef>
498-
getLibShimCxxModuleMapPath(SearchPathOptions &Opts, llvm::Triple triple,
499-
SmallVectorImpl<char> &buffer) {
500-
return getModuleMapFilePath("libcxxshim.modulemap", Opts, triple, buffer);
501-
}
502-
503443
static bool clangSupportsPragmaAttributeWithSwiftAttr() {
504444
clang::AttributeCommonInfo swiftAttrInfo(clang::SourceRange(),
505445
clang::AttributeCommonInfo::AT_SwiftAttr,
@@ -613,8 +553,7 @@ importer::getNormalInvocationArguments(
613553
});
614554
}
615555

616-
SmallString<128> buffer;
617-
if (auto path = getLibShimCxxModuleMapPath(searchPathOpts, triple, buffer)) {
556+
if (auto path = getCxxShimModuleMapPath(searchPathOpts, triple)) {
618557
invocationArgStrs.push_back((Twine("-fmodule-map-file=") + *path).str());
619558
}
620559

lib/ClangImporter/ClangIncludePaths.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ getLibStdCxxModuleMapPath(SearchPathOptions &opts, const llvm::Triple &triple) {
9191
return getActualModuleMapPath("libstdcxx.modulemap", opts, triple);
9292
}
9393

94+
Optional<SmallString<128>>
95+
swift::getCxxShimModuleMapPath(SearchPathOptions &opts,
96+
const llvm::Triple &triple) {
97+
return getActualModuleMapPath("libcxxshim.modulemap", opts, triple);
98+
}
99+
94100
static llvm::opt::InputArgList
95101
parseClangDriverArgs(const clang::driver::Driver &clangDriver,
96102
const ArrayRef<const char *> args) {

lib/ClangImporter/ClangIncludePaths.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ namespace swift {
2323
SmallVector<std::pair<std::string, std::string>, 2>
2424
getClangInvocationFileMapping(ASTContext &ctx);
2525

26+
Optional<SmallString<128>> getCxxShimModuleMapPath(SearchPathOptions &opts,
27+
const llvm::Triple &triple);
28+
2629
} // namespace swift
2730

2831
#endif // SWIFT_CLANG_INCLUDE_PATHS_H

0 commit comments

Comments
 (0)