Changeset View
Changeset View
Standalone View
Standalone View
lib/Driver/Tools.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 2,459 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
/// \brief Check whether the given input tree contains any compilation actions. | /// \brief Check whether the given input tree contains any compilation actions. | ||||
static bool ContainsCompileAction(const Action *A) { | static bool ContainsCompileAction(const Action *A) { | ||||
if (isa<CompileJobAction>(A) || isa<BackendJobAction>(A)) | if (isa<CompileJobAction>(A) || isa<BackendJobAction>(A)) | ||||
return true; | return true; | ||||
for (const auto &Act : *A) | for (const auto &Act : *A) | ||||
if (ContainsCompileAction(Act)) | if (ContainsCompileAction(Act.get())) | ||||
return true; | return true; | ||||
return false; | return false; | ||||
} | } | ||||
/// \brief Check if -relax-all should be passed to the internal assembler. | /// \brief Check if -relax-all should be passed to the internal assembler. | ||||
/// This is done by default when compiling non-assembler source with -O0. | /// This is done by default when compiling non-assembler source with -O0. | ||||
static bool UseRelaxAll(Compilation &C, const ArgList &Args) { | static bool UseRelaxAll(Compilation &C, const ArgList &Args) { | ||||
bool RelaxDefault = true; | bool RelaxDefault = true; | ||||
if (Arg *A = Args.getLastArg(options::OPT_O_Group)) | if (Arg *A = Args.getLastArg(options::OPT_O_Group)) | ||||
RelaxDefault = A->getOption().matches(options::OPT_O0); | RelaxDefault = A->getOption().matches(options::OPT_O0); | ||||
if (RelaxDefault) { | if (RelaxDefault) { | ||||
RelaxDefault = false; | RelaxDefault = false; | ||||
for (const auto &Act : C.getActions()) { | for (const auto &Act : C.getActions()) { | ||||
if (ContainsCompileAction(Act)) { | if (ContainsCompileAction(Act.get())) { | ||||
RelaxDefault = true; | RelaxDefault = true; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
return Args.hasFlag(options::OPT_mrelax_all, options::OPT_mno_relax_all, | return Args.hasFlag(options::OPT_mrelax_all, options::OPT_mno_relax_all, | ||||
RelaxDefault); | RelaxDefault); | ||||
▲ Show 20 Lines • Show All 3,470 Lines • ▼ Show 20 Lines | void ClangAs::ConstructJob(Compilation &C, const JobAction &JA, | ||||
// Pass along any -I options so we get proper .include search paths. | // Pass along any -I options so we get proper .include search paths. | ||||
Args.AddAllArgs(CmdArgs, options::OPT_I_Group); | Args.AddAllArgs(CmdArgs, options::OPT_I_Group); | ||||
// Determine the original source input. | // Determine the original source input. | ||||
const Action *SourceAction = &JA; | const Action *SourceAction = &JA; | ||||
while (SourceAction->getKind() != Action::InputClass) { | while (SourceAction->getKind() != Action::InputClass) { | ||||
assert(!SourceAction->getInputs().empty() && "unexpected root action!"); | assert(!SourceAction->getInputs().empty() && "unexpected root action!"); | ||||
SourceAction = SourceAction->getInputs()[0]; | SourceAction = SourceAction->getInputs()[0].get(); | ||||
} | } | ||||
// Forward -g and handle debug info related flags, assuming we are dealing | // Forward -g and handle debug info related flags, assuming we are dealing | ||||
// with an actual assembly file. | // with an actual assembly file. | ||||
if (SourceAction->getType() == types::TY_Asm || | if (SourceAction->getType() == types::TY_Asm || | ||||
SourceAction->getType() == types::TY_PP_Asm) { | SourceAction->getType() == types::TY_PP_Asm) { | ||||
bool WantDebug = false; | bool WantDebug = false; | ||||
unsigned DwarfVersion = 0; | unsigned DwarfVersion = 0; | ||||
▲ Show 20 Lines • Show All 907 Lines • ▼ Show 20 Lines | void darwin::Assembler::ConstructJob(Compilation &C, const JobAction &JA, | ||||
assert(Inputs.size() == 1 && "Unexpected number of inputs."); | assert(Inputs.size() == 1 && "Unexpected number of inputs."); | ||||
const InputInfo &Input = Inputs[0]; | const InputInfo &Input = Inputs[0]; | ||||
// Determine the original source input. | // Determine the original source input. | ||||
const Action *SourceAction = &JA; | const Action *SourceAction = &JA; | ||||
while (SourceAction->getKind() != Action::InputClass) { | while (SourceAction->getKind() != Action::InputClass) { | ||||
assert(!SourceAction->getInputs().empty() && "unexpected root action!"); | assert(!SourceAction->getInputs().empty() && "unexpected root action!"); | ||||
SourceAction = SourceAction->getInputs()[0]; | SourceAction = SourceAction->getInputs()[0].get(); | ||||
} | } | ||||
// If -fno-integrated-as is used add -Q to the darwin assember driver to make | // If -fno-integrated-as is used add -Q to the darwin assember driver to make | ||||
// sure it runs its system assembler not clang's integrated assembler. | // sure it runs its system assembler not clang's integrated assembler. | ||||
// Applicable to darwin11+ and Xcode 4+. darwin<10 lacked integrated-as. | // Applicable to darwin11+ and Xcode 4+. darwin<10 lacked integrated-as. | ||||
// FIXME: at run-time detect assembler capabilities or rely on version | // FIXME: at run-time detect assembler capabilities or rely on version | ||||
// information forwarded by -target-assembler-version. | // information forwarded by -target-assembler-version. | ||||
if (Args.hasArg(options::OPT_fno_integrated_as)) { | if (Args.hasArg(options::OPT_fno_integrated_as)) { | ||||
▲ Show 20 Lines • Show All 3,702 Lines • Show Last 20 Lines |