Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/Driver/ToolChains/MSVC.cpp
Show First 20 Lines • Show All 429 Lines • ▼ Show 20 Lines | void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA, | ||||
} | } | ||||
auto CRTPath = TC.getCompilerRTPath(); | auto CRTPath = TC.getCompilerRTPath(); | ||||
if (TC.getVFS().exists(CRTPath)) | if (TC.getVFS().exists(CRTPath)) | ||||
CmdArgs.push_back(Args.MakeArgString("-libpath:" + CRTPath)); | CmdArgs.push_back(Args.MakeArgString("-libpath:" + CRTPath)); | ||||
if (!C.getDriver().IsCLMode() && Args.hasArg(options::OPT_L)) | if (!C.getDriver().IsCLMode() && Args.hasArg(options::OPT_L)) | ||||
for (const auto &LibPath : Args.getAllArgValues(options::OPT_L)) | for (const auto &LibPath : Args.getAllArgValues(options::OPT_L)) | ||||
CmdArgs.push_back(Args.MakeArgString("-libpath:" + LibPath)); | CmdArgs.push_back(Args.MakeArgString("-libpath:" + LibPath)); | ||||
// Add library directories for standard library shipped with the toolchain. | |||||
for (const auto &LibPath : TC.getFilePaths()) { | |||||
if (TC.getVFS().exists(LibPath)) | |||||
CmdArgs.push_back(Args.MakeArgString("-libpath:" + LibPath)); | |||||
} | |||||
CmdArgs.push_back("-nologo"); | CmdArgs.push_back("-nologo"); | ||||
if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7)) | if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7)) | ||||
CmdArgs.push_back("-debug"); | CmdArgs.push_back("-debug"); | ||||
// Pass on /Brepro if it was passed to the compiler. | // Pass on /Brepro if it was passed to the compiler. | ||||
// Note that /Brepro maps to -mno-incremental-linker-compatible. | // Note that /Brepro maps to -mno-incremental-linker-compatible. | ||||
▲ Show 20 Lines • Show All 872 Lines • ▼ Show 20 Lines | const StringRef Paths[] = { | ||||
"C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Include" | "C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Include" | ||||
}; | }; | ||||
addSystemIncludes(DriverArgs, CC1Args, Paths); | addSystemIncludes(DriverArgs, CC1Args, Paths); | ||||
#endif | #endif | ||||
} | } | ||||
void MSVCToolChain::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs, | void MSVCToolChain::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs, | ||||
ArgStringList &CC1Args) const { | ArgStringList &CC1Args) const { | ||||
// FIXME: There should probably be logic here to find libc++ on Windows. | if (DriverArgs.hasArg(options::OPT_nostdlibinc) || | ||||
DriverArgs.hasArg(options::OPT_nostdincxx)) | |||||
return; | |||||
switch (GetCXXStdlibType(DriverArgs)) { | |||||
case ToolChain::CST_Libcxx: { | |||||
SmallString<128> P(getDriver().Dir); | |||||
rnk: I'm guessing this is copy-pasted code from the other toolchains, but this lambda makes less… | |||||
llvm::sys::path::append(P, "..", "include"); | |||||
std::string Version = detectLibcxxVersion(P); | |||||
if (Version.empty()) | |||||
return; | |||||
// First add the per-target include path if it exists. | |||||
SmallString<128> TargetDir(P); | |||||
llvm::sys::path::append(TargetDir, getTripleString(), "c++", Version); | |||||
if (getVFS().exists(TargetDir)) | |||||
addSystemInclude(DriverArgs, CC1Args, TargetDir); | |||||
// Second add the generic one. | |||||
SmallString<128> Dir(P); | |||||
llvm::sys::path::append(Dir, "c++", Version); | |||||
addSystemInclude(DriverArgs, CC1Args, Dir); | |||||
break; | |||||
} | |||||
default: | |||||
// TODO: Shall we report an error for other C++ standard libraries? | |||||
break; | |||||
} | |||||
} | } | ||||
VersionTuple MSVCToolChain::computeMSVCVersion(const Driver *D, | VersionTuple MSVCToolChain::computeMSVCVersion(const Driver *D, | ||||
const ArgList &Args) const { | const ArgList &Args) const { | ||||
bool IsWindowsMSVC = getTriple().isWindowsMSVCEnvironment(); | bool IsWindowsMSVC = getTriple().isWindowsMSVCEnvironment(); | ||||
VersionTuple MSVT = ToolChain::computeMSVCVersion(D, Args); | VersionTuple MSVT = ToolChain::computeMSVCVersion(D, Args); | ||||
if (MSVT.empty()) | if (MSVT.empty()) | ||||
MSVT = getMSVCVersionFromTriple(getTriple()); | MSVT = getMSVCVersionFromTriple(getTriple()); | ||||
▲ Show 20 Lines • Show All 207 Lines • Show Last 20 Lines |
I'm guessing this is copy-pasted code from the other toolchains, but this lambda makes less sense when its only called once. If you inline it, we don't need an extra SmallString or lambda.