[cfe-commits] r67350 - in /cfe/trunk/lib/Driver: ToolChains.cpp ToolChains.h
Daniel Dunbar
daniel at zuster.org
Thu Mar 19 17:20:03 PDT 2009
Author: ddunbar
Date: Thu Mar 19 19:20:03 2009
New Revision: 67350
URL: http://llvm.org/viewvc/llvm-project?rev=67350&view=rev
Log:
Driver: Move tool chain implementations into ToolChains.cpp.
Added:
cfe/trunk/lib/Driver/ToolChains.cpp
Modified:
cfe/trunk/lib/Driver/ToolChains.h
Added: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=67350&view=auto
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (added)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu Mar 19 19:20:03 2009
@@ -0,0 +1,75 @@
+//===--- ToolChains.cpp - ToolChain Implementations ---------------------*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "ToolChains.h"
+
+using namespace clang::driver;
+using namespace clang::driver::toolchains;
+
+/// Generic_GCC - A tool chain using the 'gcc' command to perform
+/// all subcommands; this relies on gcc translating the majority of
+/// command line options.
+
+Generic_GCC::~Generic_GCC() {
+ // Free tool implementations.
+ for (llvm::DenseMap<unsigned, Tool*>::iterator
+ it = Tools.begin(), ie = Tools.end(); it != ie; ++it)
+ delete it->second;
+}
+
+Tool &Generic_GCC::SelectTool(const Compilation &C,
+ const JobAction &JA) const {
+ Action::ActionClass Key;
+ if (ShouldUseClangCompiler(C, JA))
+ Key = Action::AnalyzeJobClass;
+ else
+ Key = JA.getKind();
+
+ Tool *&T = Tools[Key];
+ if (!T) {
+ switch (Key) {
+ default:
+ assert(0 && "Invalid tool kind.");
+ case Action::PreprocessJobClass:
+ T = new tools::gcc::Preprocess(*this); break;
+ case Action::PrecompileJobClass:
+ T = new tools::gcc::Precompile(*this); break;
+ case Action::AnalyzeJobClass:
+ T = new tools::Clang(*this); break;
+ case Action::CompileJobClass:
+ T = new tools::gcc::Compile(*this); break;
+ case Action::AssembleJobClass:
+ T = new tools::gcc::Assemble(*this); break;
+ case Action::LinkJobClass:
+ T = new tools::gcc::Link(*this); break;
+ }
+ }
+
+ return *T;
+}
+
+bool Generic_GCC::IsMathErrnoDefault() const {
+ return true;
+}
+
+bool Generic_GCC::IsUnwindTablesDefault() const {
+ // FIXME: Gross; we should probably have some separate target definition,
+ // possibly even reusing the one in clang.
+ return getArchName() == "x86_64";
+}
+
+const char *Generic_GCC::GetDefaultRelocationModel() const {
+ return "static";
+}
+
+const char *Generic_GCC::GetForcedPicModel() const {
+ return 0;
+}
+
+
Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=67350&r1=67349&r2=67350&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Thu Mar 19 19:20:03 2009
@@ -31,60 +31,16 @@
public:
Generic_GCC(const HostInfo &Host, const char *Arch, const char *Platform,
const char *OS) : ToolChain(Host, Arch, Platform, OS) {}
- ~Generic_GCC() {
- // Free tool implementations.
- for (llvm::DenseMap<unsigned, Tool*>::iterator
- it = Tools.begin(), ie = Tools.end(); it != ie; ++it)
- delete it->second;
- }
+ ~Generic_GCC();
virtual ArgList *TranslateArgs(ArgList &Args) const { return &Args; }
- virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const {
- Action::ActionClass Key;
- if (ShouldUseClangCompiler(C, JA))
- Key = Action::AnalyzeJobClass;
- else
- Key = JA.getKind();
+ virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
- Tool *&T = Tools[Key];
- if (!T) {
- switch (Key) {
- default:
- assert(0 && "Invalid tool kind.");
- case Action::PreprocessJobClass:
- T = new tools::gcc::Preprocess(*this); break;
- case Action::PrecompileJobClass:
- T = new tools::gcc::Precompile(*this); break;
- case Action::AnalyzeJobClass:
- T = new tools::Clang(*this); break;
- case Action::CompileJobClass:
- T = new tools::gcc::Compile(*this); break;
- case Action::AssembleJobClass:
- T = new tools::gcc::Assemble(*this); break;
- case Action::LinkJobClass:
- T = new tools::gcc::Link(*this); break;
- }
- }
-
- return *T;
- }
-
- virtual bool IsMathErrnoDefault() const { return true; }
-
- virtual bool IsUnwindTablesDefault() const {
- // FIXME: Gross; we should probably have some separate target definition,
- // possibly even reusing the one in clang.
- return getArchName() == "x86_64";
- }
-
- virtual const char *GetDefaultRelocationModel() const {
- return "static";
- }
-
- virtual const char *GetForcedPicModel() const {
- return 0;
- }
+ virtual bool IsMathErrnoDefault() const;
+ virtual bool IsUnwindTablesDefault() const;
+ virtual const char *GetDefaultRelocationModel() const;
+ virtual const char *GetForcedPicModel() const;
};
} // end namespace toolchains
More information about the cfe-commits
mailing list