Skip to content

Commit 515f8ef

Browse files
authored
Merge pull request #4693 from apple/egorzhdan/libstdcxx-path-20211026
[cxx-interop] Allow Swift to extract libstdc++ installation path from Clang
2 parents 3bd3d12 + dd4e712 commit 515f8ef

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

clang/include/clang/Driver/Driver.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,18 @@ class Driver {
565565
return IsOffload ? OffloadLTOMode : LTOMode;
566566
}
567567

568+
/// Addition for Swift. Allows ClangImporter to extract the path to libstdc++.
569+
std::vector<std::string>
570+
getLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
571+
const llvm::Triple &Target) const {
572+
llvm::opt::ArgStringList ArgStrings;
573+
getToolChain(DriverArgs, Target)
574+
.addLibStdCxxIncludePaths(DriverArgs, ArgStrings);
575+
unsigned Unused1, Unused2;
576+
auto ParsedArgs = getOpts().ParseArgs(ArgStrings, Unused1, Unused2);
577+
return ParsedArgs.getAllArgValues(options::OPT_internal_isystem);
578+
}
579+
568580
private:
569581

570582
/// Tries to load options from configuration file.

clang/include/clang/Driver/ToolChain.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ class ToolChain {
222222
llvm::vfs::FileSystem &getVFS() const;
223223
const llvm::Triple &getTriple() const { return Triple; }
224224

225+
/// Addition for Swift. Allows ClangImporter to extract the path to libstdc++.
226+
virtual void
227+
addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
228+
llvm::opt::ArgStringList &CC1Args) const {};
229+
225230
/// Get the toolchain's aux triple, if it has one.
226231
///
227232
/// Exactly what the aux triple represents depends on the toolchain, but for

0 commit comments

Comments
 (0)