r177299 - Refactor a bit of duplicated code to useIntegratedAs.
Rafael Espindola
rafael.espindola at gmail.com
Mon Mar 18 10:52:57 PDT 2013
Author: rafael
Date: Mon Mar 18 12:52:57 2013
New Revision: 177299
URL: http://llvm.org/viewvc/llvm-project?rev=177299&view=rev
Log:
Refactor a bit of duplicated code to useIntegratedAs.
Modified:
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Driver/WindowsToolChain.cpp
Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=177299&r1=177298&r2=177299&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Mon Mar 18 12:52:57 2013
@@ -137,6 +137,8 @@ public:
/// 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; }
Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=177299&r1=177298&r2=177299&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Mar 18 12:52:57 2013
@@ -1296,9 +1296,7 @@ static const Tool &SelectToolForJob(Comp
// 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())) {
Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=177299&r1=177298&r2=177299&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Mon Mar 18 12:52:57 2013
@@ -32,6 +32,12 @@ const Driver &ToolChain::getDriver() con
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
Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=177299&r1=177298&r2=177299&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Mon Mar 18 12:52:57 2013
@@ -184,10 +184,6 @@ Tool &Darwin::SelectTool(const Compilati
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 @@ Tool &Darwin::SelectTool(const Compilati
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 @@ Tool &OpenBSD::SelectTool(const Compilat
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 @@ Tool &Bitrig::SelectTool(const Compilati
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 @@ Tool &FreeBSD::SelectTool(const Compilat
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 @@ Tool &NetBSD::SelectTool(const Compilati
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 @@ Tool &Linux::SelectTool(const Compilatio
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);
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=177299&r1=177298&r2=177299&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Mar 18 12:52:57 2013
@@ -1417,9 +1417,8 @@ static void addExceptionArgs(const ArgLi
/// \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,
Modified: cfe/trunk/lib/Driver/WindowsToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/WindowsToolChain.cpp?rev=177299&r1=177298&r2=177299&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/WindowsToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/WindowsToolChain.cpp Mon Mar 18 12:52:57 2013
@@ -42,10 +42,6 @@ Tool &Windows::SelectTool(const Compilat
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 @@ Tool &Windows::SelectTool(const Compilat
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);
More information about the cfe-commits
mailing list