aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Driver/Driver.h5
-rw-r--r--lib/Driver/Driver.cpp50
-rw-r--r--lib/Driver/ToolChains.cpp12
-rw-r--r--test/Driver/bindings.c2
4 files changed, 32 insertions, 37 deletions
diff --git a/include/clang/Driver/Driver.h b/include/clang/Driver/Driver.h
index 623485bc6a..bdc6f3b18a 100644
--- a/include/clang/Driver/Driver.h
+++ b/include/clang/Driver/Driver.h
@@ -15,6 +15,7 @@
#include "clang/Driver/Phases.h"
#include "clang/Driver/Util.h"
+#include "llvm/ADT/Triple.h"
#include "llvm/System/Path.h" // FIXME: Kill when CompilationInfo
// lands.
#include <list>
@@ -102,7 +103,7 @@ public:
private:
/// Only use clang for the given architectures (only used when
/// non-empty).
- std::set<std::string> CCCClangArchs;
+ std::set<llvm::Triple::ArchType> CCCClangArchs;
/// Certain options suppress the 'no input files' warning.
bool SuppressMissingInputWarning : 1;
@@ -260,7 +261,7 @@ public:
/// ShouldUseClangCompilar - Should the clang compiler be used to
/// handle this action.
bool ShouldUseClangCompiler(const Compilation &C, const JobAction &JA,
- const std::string &ArchName) const;
+ const llvm::Triple &ArchName) const;
/// @}
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index 93fbe54ebe..26bcb59ffd 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -60,12 +60,9 @@ Driver::Driver(const char *_Name, const char *_Dir,
{
#ifdef USE_PRODUCTION_CLANG
// In a "production" build, only use clang on architectures we expect to work.
- CCCClangArchs.insert("i386");
- CCCClangArchs.insert("x86_64");
- CCCClangArchs.insert("arm");
- CCCClangArchs.insert("armv5");
- CCCClangArchs.insert("armv6");
- CCCClangArchs.insert("armv7");
+ CCCClangArchs.insert(llvm::Triple::x86);
+ CCCClangArchs.insert(llvm::Triple::x86_64);
+ CCCClangArchs.insert(llvm::Triple::arm);
#endif
}
@@ -169,23 +166,27 @@ Compilation *Driver::BuildCompilation(int argc, const char **argv) {
CCCUseClangCPP = false;
} else if (!strcmp(Opt, "clang-archs")) {
assert(Start+1 < End && "FIXME: -ccc- argument handling.");
- const char *Cur = *++Start;
+ llvm::StringRef Cur = *++Start;
CCCClangArchs.clear();
- for (;;) {
- const char *Next = strchr(Cur, ',');
+ while (!Cur.empty()) {
+ std::pair<llvm::StringRef, llvm::StringRef> Split = Cur.split(',');
- if (Next) {
- if (Cur != Next)
- CCCClangArchs.insert(std::string(Cur, Next));
- Cur = Next + 1;
- } else {
- if (*Cur != '\0')
- CCCClangArchs.insert(std::string(Cur));
- break;
+ if (!Split.first.empty()) {
+ llvm::Triple::ArchType Arch =
+ llvm::Triple(Split.first, "", "").getArch();
+
+ if (Arch == llvm::Triple::UnknownArch) {
+ // FIXME: Error handling.
+ llvm::errs() << "invalid arch name: " << Split.first << "\n";
+ exit(1);
+ }
+
+ CCCClangArchs.insert(Arch);
}
- }
+ Cur = Split.second;
+ }
} else if (!strcmp(Opt, "host-triple")) {
assert(Start+1 < End && "FIXME: -ccc- argument handling.");
HostTriple = *++Start;
@@ -1262,14 +1263,7 @@ const HostInfo *Driver::GetHostInfo(const char *TripleStr) const {
}
bool Driver::ShouldUseClangCompiler(const Compilation &C, const JobAction &JA,
- const std::string &ArchNameStr) const {
- // FIXME: Remove this hack.
- const char *ArchName = ArchNameStr.c_str();
- if (ArchNameStr == "powerpc")
- ArchName = "ppc";
- else if (ArchNameStr == "powerpc64")
- ArchName = "ppc64";
-
+ const llvm::Triple &Triple) const {
// Check if user requested no clang, or clang doesn't understand this type (we
// only handle single inputs for now).
if (!CCCUseClang || JA.size() != 1 ||
@@ -1297,8 +1291,8 @@ bool Driver::ShouldUseClangCompiler(const Compilation &C, const JobAction &JA,
// Finally, don't use clang if this isn't one of the user specified archs to
// build.
- if (!CCCClangArchs.empty() && !CCCClangArchs.count(ArchName)) {
- Diag(clang::diag::warn_drv_not_using_clang_arch) << ArchName;
+ if (!CCCClangArchs.empty() && !CCCClangArchs.count(Triple.getArch())) {
+ Diag(clang::diag::warn_drv_not_using_clang_arch) << Triple.getArchName();
return false;
}
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index d6067afc3d..6512203d09 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -103,7 +103,7 @@ Darwin::~Darwin() {
Tool &Darwin::SelectTool(const Compilation &C, const JobAction &JA) const {
Action::ActionClass Key;
- if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getArchName()))
+ if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
Key = Action::AnalyzeJobClass;
else
Key = JA.getKind();
@@ -338,7 +338,7 @@ Generic_GCC::~Generic_GCC() {
Tool &Generic_GCC::SelectTool(const Compilation &C,
const JobAction &JA) const {
Action::ActionClass Key;
- if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getArchName()))
+ if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
Key = Action::AnalyzeJobClass;
else
Key = JA.getKind();
@@ -404,7 +404,7 @@ OpenBSD::OpenBSD(const HostInfo &Host, const llvm::Triple& Triple)
Tool &OpenBSD::SelectTool(const Compilation &C, const JobAction &JA) const {
Action::ActionClass Key;
- if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getArchName()))
+ if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
Key = Action::AnalyzeJobClass;
else
Key = JA.getKind();
@@ -439,7 +439,7 @@ FreeBSD::FreeBSD(const HostInfo &Host, const llvm::Triple& Triple, bool Lib32)
Tool &FreeBSD::SelectTool(const Compilation &C, const JobAction &JA) const {
Action::ActionClass Key;
- if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getArchName()))
+ if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
Key = Action::AnalyzeJobClass;
else
Key = JA.getKind();
@@ -480,7 +480,7 @@ AuroraUX::AuroraUX(const HostInfo &Host, const llvm::Triple& Triple)
Tool &AuroraUX::SelectTool(const Compilation &C, const JobAction &JA) const {
Action::ActionClass Key;
- if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getArchName()))
+ if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
Key = Action::AnalyzeJobClass;
else
Key = JA.getKind();
@@ -545,7 +545,7 @@ DragonFly::DragonFly(const HostInfo &Host, const llvm::Triple& Triple)
Tool &DragonFly::SelectTool(const Compilation &C, const JobAction &JA) const {
Action::ActionClass Key;
- if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getArchName()))
+ if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
Key = Action::AnalyzeJobClass;
else
Key = JA.getKind();
diff --git a/test/Driver/bindings.c b/test/Driver/bindings.c
index 3d0bf35c1e..393739006b 100644
--- a/test/Driver/bindings.c
+++ b/test/Driver/bindings.c
@@ -39,7 +39,7 @@
// RUN: grep '"clang", inputs: \[".*\.i"\], output: (nothing)' %t &&
// RUN: clang -ccc-host-triple i386-apple-darwin9 -ccc-print-bindings -ccc-clang-archs i386 %s -S -arch ppc 2> %t &&
// RUN: grep '"gcc::Compile", inputs: \[".*bindings.c"\], output: "bindings.s"' %t &&
-// RUN: clang -ccc-host-triple i386-apple-darwin9 -ccc-print-bindings -ccc-clang-archs ppc %s -S -arch ppc 2> %t &&
+// RUN: clang -ccc-host-triple i386-apple-darwin9 -ccc-print-bindings -ccc-clang-archs powerpc %s -S -arch ppc 2> %t &&
// RUN: grep '"clang", inputs: \[".*bindings.c"\], output: "bindings.s"' %t &&
// RUN: clang -ccc-host-triple powerpc-unknown-unknown -ccc-print-bindings -ccc-clang-archs "" %s -S 2> %t &&