[cfe-commits] r129212 - in /cfe/trunk: include/clang/Driver/Driver.h lib/Driver/Driver.cpp lib/Driver/Tools.cpp
Dylan Noblesmith
nobled at dreamwidth.org
Sat Apr 9 06:32:00 PDT 2011
Author: nobled
Date: Sat Apr 9 08:31:59 2011
New Revision: 129212
URL: http://llvm.org/viewvc/llvm-project?rev=129212&view=rev
Log:
refactor -ccc-gcc-name code
Put the logic for deciding the default name for gcc/g++
in the only place that actually cares about it.
This also pushes an ifdef out of the generic driver code
to a little further down, when the target is actually known.
Hopefully it can be changed into just a runtime check
in the future.
Modified:
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/Tools.cpp
Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=129212&r1=129211&r2=129212&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Sat Apr 9 08:31:59 2011
@@ -135,7 +135,7 @@
unsigned CCLogDiagnostics : 1;
private:
- /// Name to use when calling the generic gcc.
+ /// Name to use when invoking gcc/g++.
std::string CCCGenericGCCName;
/// Whether to check that input files exist when constructing compilation
@@ -183,7 +183,7 @@
/// @name Accessors
/// @{
- /// Name to use when calling the generic gcc.
+ /// Name to use when invoking gcc/g++.
const std::string &getCCCGenericGCCName() const { return CCCGenericGCCName; }
Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=129212&r1=129211&r2=129212&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Sat Apr 9 08:31:59 2011
@@ -43,13 +43,6 @@
#include <map>
-#ifdef __CYGWIN__
-#include <cygwin/version.h>
-#if defined(CYGWIN_VERSION_DLL_MAJOR) && CYGWIN_VERSION_DLL_MAJOR<1007
-#define IS_CYGWIN15 1
-#endif
-#endif
-
using namespace clang::driver;
using namespace clang;
@@ -67,7 +60,7 @@
CCLogDiagnosticsFilename(0), CCCIsCXX(false),
CCCIsCPP(false),CCCEcho(false), CCCPrintBindings(false),
CCPrintOptions(false), CCPrintHeaders(false), CCLogDiagnostics(false),
- CCCGenericGCCName("gcc"), CheckInputsExist(true), CCCUseClang(true),
+ CCCGenericGCCName(""), CheckInputsExist(true), CCCUseClang(true),
CCCUseClangCXX(true), CCCUseClangCPP(true), CCCUsePCH(true),
SuppressMissingInputWarning(false) {
if (IsProduction) {
@@ -238,13 +231,6 @@
CCCPrintActions = Args->hasArg(options::OPT_ccc_print_phases);
CCCPrintBindings = Args->hasArg(options::OPT_ccc_print_bindings);
CCCIsCXX = Args->hasArg(options::OPT_ccc_cxx) || CCCIsCXX;
- if (CCCIsCXX) {
-#ifdef IS_CYGWIN15
- CCCGenericGCCName = "g++-4";
-#else
- CCCGenericGCCName = "g++";
-#endif
- }
CCCEcho = Args->hasArg(options::OPT_ccc_echo);
if (const Arg *A = Args->getLastArg(options::OPT_ccc_gcc_name))
CCCGenericGCCName = A->getValue(*Args);
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=129212&r1=129211&r2=129212&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Sat Apr 9 08:31:59 2011
@@ -34,6 +34,13 @@
#include "InputInfo.h"
#include "ToolChains.h"
+#ifdef __CYGWIN__
+#include <cygwin/version.h>
+#if defined(CYGWIN_VERSION_DLL_MAJOR) && CYGWIN_VERSION_DLL_MAJOR<1007
+#define IS_CYGWIN15 1
+#endif
+#endif
+
using namespace clang::driver;
using namespace clang::driver::tools;
@@ -2065,7 +2072,20 @@
}
}
- const char *GCCName = getToolChain().getDriver().getCCCGenericGCCName().c_str();
+ const std::string customGCCName = D.getCCCGenericGCCName();
+ const char *GCCName;
+ if (!customGCCName.empty())
+ GCCName = customGCCName.c_str();
+ else if (D.CCCIsCXX) {
+#ifdef IS_CYGWIN15
+ // FIXME: Detect the version of Cygwin at runtime?
+ GCCName = "g++-4";
+#else
+ GCCName = "g++";
+#endif
+ } else
+ GCCName = "gcc";
+
const char *Exec =
Args.MakeArgString(getToolChain().GetProgramPath(GCCName));
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
More information about the cfe-commits
mailing list