Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
cfe/trunk/lib/Driver/Driver.cpp
Show First 20 Lines • Show All 2,985 Lines • ▼ Show 20 Lines | if (YuArg && YuArg->getValue()[0] == '\0') { | ||||
YuArg = nullptr; | YuArg = nullptr; | ||||
} | } | ||||
if (YcArg && YuArg && strcmp(YcArg->getValue(), YuArg->getValue()) != 0) { | if (YcArg && YuArg && strcmp(YcArg->getValue(), YuArg->getValue()) != 0) { | ||||
Diag(clang::diag::warn_drv_ycyu_different_arg_clang_cl); | Diag(clang::diag::warn_drv_ycyu_different_arg_clang_cl); | ||||
Args.eraseArg(options::OPT__SLASH_Yc); | Args.eraseArg(options::OPT__SLASH_Yc); | ||||
Args.eraseArg(options::OPT__SLASH_Yu); | Args.eraseArg(options::OPT__SLASH_Yu); | ||||
YcArg = YuArg = nullptr; | YcArg = YuArg = nullptr; | ||||
} | } | ||||
if (YcArg || YuArg) { | |||||
StringRef Val = YcArg ? YcArg->getValue() : YuArg->getValue(); | |||||
bool FoundMatchingInclude = false; | |||||
for (const Arg *Inc : Args.filtered(options::OPT_include)) { | |||||
// FIXME: Do case-insensitive matching and consider / and \ as equal. | |||||
if (Inc->getValue() == Val) | |||||
FoundMatchingInclude = true; | |||||
} | |||||
if (!FoundMatchingInclude) { | |||||
Diag(clang::diag::warn_drv_ycyu_no_fi_arg_clang_cl) | |||||
<< (YcArg ? YcArg : YuArg)->getSpelling(); | |||||
Args.eraseArg(options::OPT__SLASH_Yc); | |||||
Args.eraseArg(options::OPT__SLASH_Yu); | |||||
YcArg = YuArg = nullptr; | |||||
} | |||||
} | |||||
if (YcArg && Inputs.size() > 1) { | if (YcArg && Inputs.size() > 1) { | ||||
Diag(clang::diag::warn_drv_yc_multiple_inputs_clang_cl); | Diag(clang::diag::warn_drv_yc_multiple_inputs_clang_cl); | ||||
Args.eraseArg(options::OPT__SLASH_Yc); | Args.eraseArg(options::OPT__SLASH_Yc); | ||||
YcArg = nullptr; | YcArg = nullptr; | ||||
} | } | ||||
if (Args.hasArg(options::OPT__SLASH_Y_)) { | if (Args.hasArg(options::OPT__SLASH_Y_)) { | ||||
// /Y- disables all pch handling. Rather than check for it everywhere, | // /Y- disables all pch handling. Rather than check for it everywhere, | ||||
// just remove clang-cl pch-related flags here. | // just remove clang-cl pch-related flags here. | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | for (auto &I : Inputs) { | ||||
} | } | ||||
if (YcArg) { | if (YcArg) { | ||||
// Add a separate precompile phase for the compile phase. | // Add a separate precompile phase for the compile phase. | ||||
if (FinalPhase >= phases::Compile) { | if (FinalPhase >= phases::Compile) { | ||||
const types::ID HeaderType = lookupHeaderTypeForSourceType(InputType); | const types::ID HeaderType = lookupHeaderTypeForSourceType(InputType); | ||||
llvm::SmallVector<phases::ID, phases::MaxNumberOfPhases> PCHPL; | llvm::SmallVector<phases::ID, phases::MaxNumberOfPhases> PCHPL; | ||||
types::getCompilationPhases(HeaderType, PCHPL); | types::getCompilationPhases(HeaderType, PCHPL); | ||||
Arg *PchInputArg = MakeInputArg(Args, *Opts, YcArg->getValue()); | |||||
// Build the pipeline for the pch file. | // Build the pipeline for the pch file. | ||||
Action *ClangClPch = | Action *ClangClPch = | ||||
C.MakeAction<InputAction>(*PchInputArg, HeaderType); | C.MakeAction<InputAction>(*InputArg, HeaderType); | ||||
for (phases::ID Phase : PCHPL) | for (phases::ID Phase : PCHPL) | ||||
ClangClPch = ConstructPhaseAction(C, Args, Phase, ClangClPch); | ClangClPch = ConstructPhaseAction(C, Args, Phase, ClangClPch); | ||||
assert(ClangClPch); | assert(ClangClPch); | ||||
Actions.push_back(ClangClPch); | Actions.push_back(ClangClPch); | ||||
// The driver currently exits after the first failed command. This | // The driver currently exits after the first failed command. This | ||||
// relies on that behavior, to make sure if the pch generation fails, | // relies on that behavior, to make sure if the pch generation fails, | ||||
// the main compilation won't run. | // the main compilation won't run. | ||||
// FIXME: If the main compilation fails, the PCH generation should | // FIXME: If the main compilation fails, the PCH generation should | ||||
▲ Show 20 Lines • Show All 1,172 Lines • ▼ Show 20 Lines | if (Arg *FpArg = C.getArgs().getLastArg(options::OPT__SLASH_Fp)) { | ||||
// "If you specify a directory without a file name, the default file name | // "If you specify a directory without a file name, the default file name | ||||
// is VCx0.pch., where x is the major version of Visual C++ in use." | // is VCx0.pch., where x is the major version of Visual C++ in use." | ||||
Output = FpArg->getValue(); | Output = FpArg->getValue(); | ||||
// "If you do not specify an extension as part of the path name, an | // "If you do not specify an extension as part of the path name, an | ||||
// extension of .pch is assumed. " | // extension of .pch is assumed. " | ||||
if (!llvm::sys::path::has_extension(Output)) | if (!llvm::sys::path::has_extension(Output)) | ||||
Output += ".pch"; | Output += ".pch"; | ||||
} else if (Arg *YcArg = C.getArgs().getLastArg(options::OPT__SLASH_Yc)) { | |||||
Output = YcArg->getValue(); | |||||
llvm::sys::path::replace_extension(Output, ".pch"); | |||||
} else { | } else { | ||||
Output = BaseName; | Output = BaseName; | ||||
llvm::sys::path::replace_extension(Output, ".pch"); | llvm::sys::path::replace_extension(Output, ".pch"); | ||||
} | } | ||||
return Output.str(); | return Output.str(); | ||||
} | } | ||||
const ToolChain &Driver::getToolChain(const ArgList &Args, | const ToolChain &Driver::getToolChain(const ArgList &Args, | ||||
▲ Show 20 Lines • Show All 244 Lines • Show Last 20 Lines |