Skip to content

Commit 8ed891a

Browse files
authored
Merge pull request swiftlang#14535 from compnerd/driver-simplification
Driver: collapse getClangLibraryPath[On*] (NFC)
2 parents 8d745dc + fe01c6a commit 8ed891a

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

lib/Driver/ToolChains.cpp

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,22 +1045,16 @@ static void getRuntimeLibraryPath(SmallVectorImpl<char> &runtimeLibPath,
10451045
getPlatformNameForTriple(TC.getTriple()));
10461046
}
10471047

1048-
static void getClangLibraryPathOnDarwin(SmallVectorImpl<char> &libPath,
1049-
const ArgList &args,
1050-
const ToolChain &TC) {
1051-
getRuntimeLibraryPath(libPath, args, TC);
1052-
// Remove platform name.
1053-
llvm::sys::path::remove_filename(libPath);
1054-
llvm::sys::path::append(libPath, "clang", "lib", "darwin");
1055-
}
1048+
static void getClangLibraryPath(const ToolChain &TC, const ArgList &Args,
1049+
SmallString<128> &LibPath) {
1050+
const llvm::Triple &T = TC.getTriple();
10561051

1057-
static void getClangLibraryPathOnLinux(SmallVectorImpl<char> &libPath,
1058-
const ArgList &args,
1059-
const ToolChain &TC) {
1060-
getRuntimeLibraryPath(libPath, args, TC);
1052+
getRuntimeLibraryPath(LibPath, Args, TC);
10611053
// Remove platform name.
1062-
llvm::sys::path::remove_filename(libPath);
1063-
llvm::sys::path::append(libPath, "clang", "lib", "linux");
1054+
llvm::sys::path::remove_filename(LibPath);
1055+
llvm::sys::path::append(LibPath, "clang", "lib",
1056+
T.isOSDarwin() ? "darwin"
1057+
: getPlatformNameForTriple(T));
10641058
}
10651059

10661060
/// Get the runtime library link path for static linking,
@@ -1142,7 +1136,7 @@ getSanitizerRuntimeLibNameForLinux(StringRef Sanitizer, const llvm::Triple &Trip
11421136
bool toolchains::Darwin::sanitizerRuntimeLibExists(
11431137
const ArgList &args, StringRef sanitizer) const {
11441138
SmallString<128> sanitizerLibPath;
1145-
getClangLibraryPathOnDarwin(sanitizerLibPath, args, *this);
1139+
getClangLibraryPath(*this, args, sanitizerLibPath);
11461140
llvm::sys::path::append(sanitizerLibPath,
11471141
getSanitizerRuntimeLibNameForDarwin(sanitizer, this->getTriple()));
11481142
return llvm::sys::fs::exists(sanitizerLibPath.str());
@@ -1151,7 +1145,7 @@ bool toolchains::Darwin::sanitizerRuntimeLibExists(
11511145
bool toolchains::GenericUnix::sanitizerRuntimeLibExists(
11521146
const ArgList &args, StringRef sanitizer) const {
11531147
SmallString<128> sanitizerLibPath;
1154-
getClangLibraryPathOnLinux(sanitizerLibPath, args, *this);
1148+
getClangLibraryPath(*this, args, sanitizerLibPath);
11551149
llvm::sys::path::append(sanitizerLibPath,
11561150
getSanitizerRuntimeLibNameForLinux(sanitizer, this->getTriple()));
11571151
return llvm::sys::fs::exists(sanitizerLibPath.str());
@@ -1163,7 +1157,7 @@ addLinkRuntimeLibForDarwin(const ArgList &Args, ArgStringList &Arguments,
11631157
StringRef DarwinLibName, bool AddRPath,
11641158
const ToolChain &TC) {
11651159
SmallString<128> ClangLibraryPath;
1166-
getClangLibraryPathOnDarwin(ClangLibraryPath, Args, TC);
1160+
getClangLibraryPath(TC, Args, ClangLibraryPath);
11671161

11681162
SmallString<128> P(ClangLibraryPath);
11691163
llvm::sys::path::append(P, DarwinLibName);

0 commit comments

Comments
 (0)