Refactor a bit of duplicated code to useIntegratedAs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177299 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Driver/ToolChain.h b/include/clang/Driver/ToolChain.h
index 870ccc8..b04dbe6 100644
--- a/include/clang/Driver/ToolChain.h
+++ b/include/clang/Driver/ToolChain.h
@@ -137,6 +137,8 @@
/// by default.
virtual bool IsIntegratedAssemblerDefault() const { return false; }
+ bool useIntegratedAs(const ArgList &Args) const;
+
/// IsStrictAliasingDefault - Does this tool chain use -fstrict-aliasing by
/// default.
virtual bool IsStrictAliasingDefault() const { return true; }
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index 0b121b4..bd48b48 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -1296,9 +1296,7 @@
// bottom up, so what we are actually looking for is an assembler job with a
// compiler input.
- if (C.getArgs().hasFlag(options::OPT_integrated_as,
- options::OPT_no_integrated_as,
- TC->IsIntegratedAssemblerDefault()) &&
+ if (TC->useIntegratedAs(C.getArgs()) &&
!C.getArgs().hasArg(options::OPT_save_temps) &&
isa<AssembleJobAction>(JA) &&
Inputs->size() == 1 && isa<CompileJobAction>(*Inputs->begin())) {
diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp
index 21015a6..29aecf2 100644
--- a/lib/Driver/ToolChain.cpp
+++ b/lib/Driver/ToolChain.cpp
@@ -32,6 +32,12 @@
return D;
}
+bool ToolChain::useIntegratedAs(const ArgList &Args) const {
+ return Args.hasFlag(options::OPT_integrated_as,
+ options::OPT_no_integrated_as,
+ IsIntegratedAssemblerDefault());
+}
+
std::string ToolChain::getDefaultUniversalArchName() const {
// In universal driver terms, the arch name accepted by -arch isn't exactly
// the same as the ones that appear in the triple. Roughly speaking, this is
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index c8038d1..5b8f5c9 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -184,10 +184,6 @@
Key = Action::AnalyzeJobClass;
}
- bool UseIntegratedAs = C.getArgs().hasFlag(options::OPT_integrated_as,
- options::OPT_no_integrated_as,
- IsIntegratedAssemblerDefault());
-
Tool *&T = Tools[Key];
if (!T) {
switch (Key) {
@@ -201,7 +197,7 @@
case Action::CompileJobClass:
T = new tools::Clang(*this); break;
case Action::AssembleJobClass: {
- if (UseIntegratedAs)
+ if (useIntegratedAs(C.getArgs()))
T = new tools::ClangAs(*this);
else
T = new tools::darwin::Assemble(*this);
@@ -1733,15 +1729,11 @@
else
Key = JA.getKind();
- bool UseIntegratedAs = C.getArgs().hasFlag(options::OPT_integrated_as,
- options::OPT_no_integrated_as,
- IsIntegratedAssemblerDefault());
-
Tool *&T = Tools[Key];
if (!T) {
switch (Key) {
case Action::AssembleJobClass: {
- if (UseIntegratedAs)
+ if (useIntegratedAs(C.getArgs()))
T = new tools::ClangAs(*this);
else
T = new tools::openbsd::Assemble(*this);
@@ -1772,15 +1764,11 @@
else
Key = JA.getKind();
- bool UseIntegratedAs = C.getArgs().hasFlag(options::OPT_integrated_as,
- options::OPT_no_integrated_as,
- IsIntegratedAssemblerDefault());
-
Tool *&T = Tools[Key];
if (!T) {
switch (Key) {
case Action::AssembleJobClass: {
- if (UseIntegratedAs)
+ if (useIntegratedAs(C.getArgs()))
T = new tools::ClangAs(*this);
else
T = new tools::bitrig::Assemble(*this);
@@ -1863,15 +1851,11 @@
else
Key = JA.getKind();
- bool UseIntegratedAs = C.getArgs().hasFlag(options::OPT_integrated_as,
- options::OPT_no_integrated_as,
- IsIntegratedAssemblerDefault());
-
Tool *&T = Tools[Key];
if (!T) {
switch (Key) {
case Action::AssembleJobClass:
- if (UseIntegratedAs)
+ if (useIntegratedAs(C.getArgs()))
T = new tools::ClangAs(*this);
else
T = new tools::freebsd::Assemble(*this);
@@ -1924,15 +1908,11 @@
else
Key = JA.getKind();
- bool UseIntegratedAs = C.getArgs().hasFlag(options::OPT_integrated_as,
- options::OPT_no_integrated_as,
- IsIntegratedAssemblerDefault());
-
Tool *&T = Tools[Key];
if (!T) {
switch (Key) {
case Action::AssembleJobClass:
- if (UseIntegratedAs)
+ if (useIntegratedAs(C.getArgs()))
T = new tools::ClangAs(*this);
else
T = new tools::netbsd::Assemble(*this);
@@ -2427,15 +2407,11 @@
else
Key = JA.getKind();
- bool UseIntegratedAs = C.getArgs().hasFlag(options::OPT_integrated_as,
- options::OPT_no_integrated_as,
- IsIntegratedAssemblerDefault());
-
Tool *&T = Tools[Key];
if (!T) {
switch (Key) {
case Action::AssembleJobClass:
- if (UseIntegratedAs)
+ if (useIntegratedAs(C.getArgs()))
T = new tools::ClangAs(*this);
else
T = new tools::linuxtools::Assemble(*this);
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index f276031..96d10f5 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -1417,9 +1417,8 @@
/// \brief Check if the toolchain should use the integrated assembler.
static bool ShouldUseIntegratedAssembler(const ArgList &Args,
const ToolChain &TC) {
- return Args.hasFlag(options::OPT_integrated_as,
- options::OPT_no_integrated_as,
- TC.IsIntegratedAssemblerDefault());
+ // FIXME: inline
+ return TC.useIntegratedAs(Args);
}
static bool ShouldDisableCFI(const ArgList &Args,
diff --git a/lib/Driver/WindowsToolChain.cpp b/lib/Driver/WindowsToolChain.cpp
index 6d0d328..a0a71a7 100644
--- a/lib/Driver/WindowsToolChain.cpp
+++ b/lib/Driver/WindowsToolChain.cpp
@@ -42,10 +42,6 @@
else
Key = JA.getKind();
- bool UseIntegratedAs = C.getArgs().hasFlag(options::OPT_integrated_as,
- options::OPT_no_integrated_as,
- IsIntegratedAssemblerDefault());
-
Tool *&T = Tools[Key];
if (!T) {
switch (Key) {
@@ -61,7 +57,8 @@
case Action::CompileJobClass:
T = new tools::Clang(*this); break;
case Action::AssembleJobClass:
- if (!UseIntegratedAs && getTriple().getEnvironment() == llvm::Triple::MachO)
+ if (!useIntegratedAs(C.getArgs()) &&
+ getTriple().getEnvironment() == llvm::Triple::MachO)
T = new tools::darwin::Assemble(*this);
else
T = new tools::ClangAs(*this);