Skip to content

Commit 35ca7d9

Browse files
committed
Use getArch instead of getArchName + string compare.
llvm-svn: 165370
1 parent 668043f commit 35ca7d9

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

clang/lib/Driver/ToolChains.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -713,11 +713,11 @@ DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args,
713713
if (A->getOption().matches(options::OPT_Xarch__)) {
714714
// Skip this argument unless the architecture matches either the toolchain
715715
// triple arch, or the arch being bound.
716-
//
717-
// FIXME: Canonicalize name.
718-
StringRef XarchArch = A->getValue(Args, 0);
719-
if (!(XarchArch == getArchName() ||
720-
(BoundArch && XarchArch == BoundArch)))
716+
llvm::Triple::ArchType XarchArch =
717+
llvm::Triple::getArchTypeForDarwinArchName(A->getValue(Args, 0));
718+
if (!(XarchArch == getArch() ||
719+
(BoundArch && XarchArch ==
720+
llvm::Triple::getArchTypeForDarwinArchName(BoundArch))))
721721
continue;
722722

723723
Arg *OriginalArg = A;
@@ -975,14 +975,14 @@ const char *Darwin::GetDefaultRelocationModel() const {
975975
}
976976

977977
const char *Darwin::GetForcedPicModel() const {
978-
if (getArchName() == "x86_64")
978+
if (getArch() == llvm::Triple::x86_64)
979979
return "pic";
980980
return 0;
981981
}
982982

983983
bool Darwin::SupportsProfiling() const {
984984
// Profiling instrumentation is only supported on x86.
985-
return getArchName() == "i386" || getArchName() == "x86_64";
985+
return getArch() == llvm::Triple::x86 || getArch() == llvm::Triple::x86_64;
986986
}
987987

988988
bool Darwin::SupportsObjCGC() const {

clang/lib/Driver/Tools.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3194,27 +3194,27 @@ void gcc::Common::ConstructJob(Compilation &C, const JobAction &JA,
31943194
RenderExtraToolArgs(JA, CmdArgs);
31953195

31963196
// If using a driver driver, force the arch.
3197-
const std::string &Arch = getToolChain().getArchName();
3197+
llvm::Triple::ArchType Arch = getToolChain().getArch();
31983198
if (getToolChain().getTriple().isOSDarwin()) {
31993199
CmdArgs.push_back("-arch");
32003200

32013201
// FIXME: Remove these special cases.
3202-
if (Arch == "powerpc")
3202+
if (Arch == llvm::Triple::ppc)
32033203
CmdArgs.push_back("ppc");
3204-
else if (Arch == "powerpc64")
3204+
else if (Arch == llvm::Triple::ppc64)
32053205
CmdArgs.push_back("ppc64");
32063206
else
3207-
CmdArgs.push_back(Args.MakeArgString(Arch));
3207+
CmdArgs.push_back(Args.MakeArgString(getToolChain().getArchName()));
32083208
}
32093209

32103210
// Try to force gcc to match the tool chain we want, if we recognize
32113211
// the arch.
32123212
//
32133213
// FIXME: The triple class should directly provide the information we want
32143214
// here.
3215-
if (Arch == "i386" || Arch == "powerpc")
3215+
if (Arch == llvm::Triple::x86 || Arch == llvm::Triple::ppc)
32163216
CmdArgs.push_back("-m32");
3217-
else if (Arch == "x86_64" || Arch == "powerpc64")
3217+
else if (Arch == llvm::Triple::x86_64 || Arch == llvm::Triple::x86_64)
32183218
CmdArgs.push_back("-m64");
32193219

32203220
if (Output.isFilename()) {
@@ -3874,7 +3874,7 @@ void darwin::CC1::AddCPPUniqueOptionsArgs(const ArgList &Args,
38743874
Args.AddLastArg(CmdArgs, options::OPT_P);
38753875

38763876
// FIXME: Handle %I properly.
3877-
if (getToolChain().getArchName() == "x86_64") {
3877+
if (getToolChain().getArch() == llvm::Triple::x86_64) {
38783878
CmdArgs.push_back("-imultilib");
38793879
CmdArgs.push_back("x86_64");
38803880
}
@@ -4552,7 +4552,7 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA,
45524552
!Args.hasArg(options::OPT_nodefaultlibs)) {
45534553
// Avoid linking compatibility stubs on i386 mac.
45544554
if (!getDarwinToolChain().isTargetMacOS() ||
4555-
getDarwinToolChain().getArchName() != "i386") {
4555+
getDarwinToolChain().getArch() != llvm::Triple::x86) {
45564556
// If we don't have ARC or subscripting runtime support, link in the
45574557
// runtime stubs. We have to do this *before* adding any of the normal
45584558
// linker inputs so that its initializer gets run first.
@@ -5301,12 +5301,12 @@ void freebsd::Link::ConstructJob(Compilation &C, const JobAction &JA,
53015301

53025302
// When building 32-bit code on FreeBSD/amd64, we have to explicitly
53035303
// instruct ld in the base system to link 32-bit code.
5304-
if (ToolChain.getArchName() == "i386") {
5304+
if (ToolChain.getArch() == llvm::Triple::x86) {
53055305
CmdArgs.push_back("-m");
53065306
CmdArgs.push_back("elf_i386_fbsd");
53075307
}
53085308

5309-
if (ToolChain.getArchName() == "powerpc") {
5309+
if (ToolChain.getArch() == llvm::Triple::ppc) {
53105310
CmdArgs.push_back("-m");
53115311
CmdArgs.push_back("elf32ppc_fbsd");
53125312
}
@@ -5442,9 +5442,9 @@ void netbsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
54425442
CmdArgs.push_back("--32");
54435443

54445444
// Set byte order explicitly
5445-
if (getToolChain().getArchName() == "mips")
5445+
if (getToolChain().getArch() == llvm::Triple::mips)
54465446
CmdArgs.push_back("-EB");
5447-
else if (getToolChain().getArchName() == "mipsel")
5447+
else if (getToolChain().getArch() == llvm::Triple::mipsel)
54485448
CmdArgs.push_back("-EL");
54495449

54505450
Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA,
@@ -6002,7 +6002,7 @@ void dragonfly::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
60026002

60036003
// When building 32-bit code on DragonFly/pc64, we have to explicitly
60046004
// instruct as in the base system to assemble 32-bit code.
6005-
if (getToolChain().getArchName() == "i386")
6005+
if (getToolChain().getArch() == llvm::Triple::x86)
60066006
CmdArgs.push_back("--32");
60076007

60086008
Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA,
@@ -6046,7 +6046,7 @@ void dragonfly::Link::ConstructJob(Compilation &C, const JobAction &JA,
60466046

60476047
// When building 32-bit code on DragonFly/pc64, we have to explicitly
60486048
// instruct ld in the base system to link 32-bit code.
6049-
if (getToolChain().getArchName() == "i386") {
6049+
if (getToolChain().getArch() == llvm::Triple::x86) {
60506050
CmdArgs.push_back("-m");
60516051
CmdArgs.push_back("elf_i386");
60526052
}

clang/lib/Driver/WindowsToolChain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const char *Windows::GetDefaultRelocationModel() const {
8989
}
9090

9191
const char *Windows::GetForcedPicModel() const {
92-
if (getArchName() == "x86_64")
92+
if (getArch() == llvm::Triple::x86_64)
9393
return "pic";
9494
return 0;
9595
}

0 commit comments

Comments
 (0)