From b2d0d40c3db3e789663c97c705e4e7325dba513d Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 6 Sep 2010 02:36:23 +0000 Subject: [PATCH] Make "-ccc-cxx" option work on Linux. Patch by nobled. I also took the opportunity to make the field private since now it is only ready from the outside. llvm-svn: 113138 --- clang/include/clang/Driver/Driver.h | 10 +++++++--- clang/lib/Driver/Driver.cpp | 6 ++++-- clang/lib/Driver/Tools.cpp | 2 +- clang/tools/driver/driver.cpp | 1 - 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h index 28eff4f1d71d..1622c4be51e8 100644 --- a/clang/include/clang/Driver/Driver.h +++ b/clang/include/clang/Driver/Driver.h @@ -92,9 +92,6 @@ public: /// Information about the host which can be overriden by the user. std::string HostBits, HostMachine, HostSystem, HostRelease; - /// Name to use when calling the generic gcc. - std::string CCCGenericGCCName; - /// The file to log CC_PRINT_OPTIONS output to, if enabled. const char *CCPrintOptionsFilename; @@ -112,6 +109,9 @@ public: unsigned CCPrintOptions : 1; private: + /// Name to use when calling the generic gcc. + std::string CCCGenericGCCName; + /// Whether to check that input files exist when constructing compilation /// jobs. unsigned CheckInputsExist : 1; @@ -157,6 +157,10 @@ public: /// @name Accessors /// @{ + /// Name to use when calling the generic gcc. + const std::string &getCCCGenericGCCName() const { return CCCGenericGCCName; } + + const OptTable &getOpts() const { return *Opts; } const Diagnostic &getDiags() const { return Diags; } diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 82f913484f48..f5ba96549bac 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -50,8 +50,8 @@ Driver::Driver(llvm::StringRef _ClangExecutable, DefaultImageName(_DefaultImageName), DriverTitle("clang \"gcc-compatible\" driver"), Host(0), - CCCGenericGCCName("gcc"), CCPrintOptionsFilename(0), CCCIsCXX(false), - CCCEcho(false), CCCPrintBindings(false), CCPrintOptions(false), + CCPrintOptionsFilename(0), CCCIsCXX(false), + CCCEcho(false), CCCPrintBindings(false), CCPrintOptions(false), CCCGenericGCCName("gcc"), CheckInputsExist(true), CCCUseClang(true), CCCUseClangCXX(true), CCCUseClangCPP(true), CCCUsePCH(true), SuppressMissingInputWarning(false) { if (IsProduction) { @@ -205,6 +205,8 @@ Compilation *Driver::BuildCompilation(int argc, const char **argv) { 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) + CCCGenericGCCName = "g++"; CCCEcho = Args->hasArg(options::OPT_ccc_echo); if (const Arg *A = Args->getLastArg(options::OPT_ccc_gcc_name)) CCCGenericGCCName = A->getValue(*Args); diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 8436561e6ef9..a055904a892f 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -1619,7 +1619,7 @@ void gcc::Common::ConstructJob(Compilation &C, const JobAction &JA, II.getInputArg().render(Args, CmdArgs); } - const char *GCCName = getToolChain().getDriver().CCCGenericGCCName.c_str(); + const char *GCCName = getToolChain().getDriver().getCCCGenericGCCName().c_str(); const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath(GCCName)); C.addCommand(new Command(JA, *this, Exec, CmdArgs)); diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp index c058ece0dc9b..c1172817ed91 100644 --- a/clang/tools/driver/driver.cpp +++ b/clang/tools/driver/driver.cpp @@ -334,7 +334,6 @@ int main(int argc_, const char **argv_) { if (llvm::StringRef(ProgName).endswith("++") || llvm::StringRef(ProgName).rsplit('-').first.endswith("++")) { TheDriver.CCCIsCXX = true; - TheDriver.CCCGenericGCCName = "g++"; } // Handle CC_PRINT_OPTIONS and CC_PRINT_OPTIONS_FILE.