[cfe-commits] r81276 - in /cfe/trunk: include/clang/Driver/Driver.h lib/Driver/Driver.cpp lib/Driver/ToolChains.cpp test/Driver/bindings.c
Daniel Dunbar
daniel at zuster.org
Tue Sep 8 16:36:55 PDT 2009
Author: ddunbar
Date: Tue Sep 8 18:36:55 2009
New Revision: 81276
URL: http://llvm.org/viewvc/llvm-project?rev=81276&view=rev
Log:
Fix ShouldUseClangCompiler to use llvm::Triple.
- -1 FIXME, and fixes 'clang -arch armv4t ...', for example.
Modified:
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/test/Driver/bindings.c
Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=81276&r1=81275&r2=81276&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Tue Sep 8 18:36:55 2009
@@ -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 @@
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 @@
/// 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;
/// @}
Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=81276&r1=81275&r2=81276&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue Sep 8 18:36:55 2009
@@ -60,12 +60,9 @@
{
#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 @@
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 @@
}
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 @@
// 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;
}
Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=81276&r1=81275&r2=81276&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Sep 8 18:36:55 2009
@@ -103,7 +103,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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();
Modified: cfe/trunk/test/Driver/bindings.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/bindings.c?rev=81276&r1=81275&r2=81276&view=diff
==============================================================================
--- cfe/trunk/test/Driver/bindings.c (original)
+++ cfe/trunk/test/Driver/bindings.c Tue Sep 8 18:36:55 2009
@@ -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 &&
More information about the cfe-commits
mailing list