aboutsummaryrefslogtreecommitdiff
path: root/lib/Driver/Driver.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-03-24 19:02:31 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-03-24 19:02:31 +0000
commit0f99d2e57d8e3cf2508e7f9f868d41eccdc229c9 (patch)
treeb4da1ecaceb5f3c54aadab6d0133a6630f442bb0 /lib/Driver/Driver.cpp
parentaf80e1ffafeb77929cc0b9ba8940a7f1c0b80d51 (diff)
Driver: Change default use of "clang" compiler.
- Don't default to using clang for C++ (use -ccc-clang-cxx to override). - Default to only using clang on i386 and x86_64 (use -ccc-clang-archs "" to override). - <rdar://problem/6712350> [driver] clang should not be used on powerpc by default - <rdar://problem/6705767> driver should default to -ccc-no-clang-cxx I plan to add a warning that we are not using the clang compiler for the given compilation so that users do not think clang is being used in situations it isn't. This change is motivated by the desire to be able to drop clang into a build and have things "just work", even if it happens to get used to compile C++ code or code for an architecture we don't support yet. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67640 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Driver.cpp')
-rw-r--r--lib/Driver/Driver.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index 1e10ac5c8f..4411ac6fd2 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -43,9 +43,12 @@ Driver::Driver(const char *_Name, const char *_Dir,
DefaultImageName(_DefaultImageName),
Host(0),
CCCIsCXX(false), CCCEcho(false), CCCPrintBindings(false),
- CCCNoClang(false), CCCNoClangCXX(false), CCCNoClangCPP(false),
+ CCCUseClang(true), CCCUseClangCXX(false), CCCUseClangCPP(true),
SuppressMissingInputWarning(false)
{
+ // Only use clang on i386 and x86_64 by default.
+ CCCClangArchs.insert("i386");
+ CCCClangArchs.insert("x86_64");
}
Driver::~Driver() {
@@ -132,24 +135,27 @@ Compilation *Driver::BuildCompilation(int argc, const char **argv) {
} else if (!strcmp(Opt, "echo")) {
CCCEcho = true;
+ } else if (!strcmp(Opt, "clang-cxx")) {
+ CCCUseClangCXX = true;
} else if (!strcmp(Opt, "no-clang")) {
- CCCNoClang = true;
- } else if (!strcmp(Opt, "no-clang-cxx")) {
- CCCNoClangCXX = true;
+ CCCUseClang = false;
} else if (!strcmp(Opt, "no-clang-cpp")) {
- CCCNoClangCPP = true;
+ CCCUseClangCPP = false;
} else if (!strcmp(Opt, "clang-archs")) {
assert(Start+1 < End && "FIXME: -ccc- argument handling.");
const char *Cur = *++Start;
+ CCCClangArchs.clear();
for (;;) {
const char *Next = strchr(Cur, ',');
if (Next) {
- CCCClangArchs.insert(std::string(Cur, Next));
+ if (Cur != Next)
+ CCCClangArchs.insert(std::string(Cur, Next));
Cur = Next + 1;
} else {
- CCCClangArchs.insert(std::string(Cur));
+ if (*Cur != '\0')
+ CCCClangArchs.insert(std::string(Cur));
break;
}
}
@@ -986,19 +992,19 @@ bool Driver::ShouldUseClangCompiler(const Compilation &C, const JobAction &JA,
const std::string &ArchName) const {
// Check if user requested no clang, or clang doesn't understand
// this type (we only handle single inputs for now).
- if (CCCNoClang || JA.size() != 1 ||
+ if (!CCCUseClang || JA.size() != 1 ||
!types::isAcceptedByClang((*JA.begin())->getType()))
return false;
- // Otherwise make sure this is an action clang undertands.
+ // Otherwise make sure this is an action clang understands.
if (isa<PreprocessJobAction>(JA)) {
- if (CCCNoClangCPP)
+ if (!CCCUseClangCPP)
return false;
} else if (!isa<PrecompileJobAction>(JA) && !isa<CompileJobAction>(JA))
return false;
- // Avoid CXX if the user requested.
- if (CCCNoClangCXX && types::isCXX((*JA.begin())->getType()))
+ // Use clang for C++?
+ if (!CCCUseClangCXX && types::isCXX((*JA.begin())->getType()))
return false;
// Finally, don't use clang if this isn't one of the user specified