From 31b1e5437e7435879fc044afb77ff27096008e72 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Tue, 17 Mar 2009 22:45:24 +0000 Subject: [PATCH] Driver: Add name to Tool (for testing/debugging) and move GCC_* tools into gcc:: namespace. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67120 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Driver/Tool.h | 8 +++++++- lib/Driver/Tool.cpp | 3 ++- lib/Driver/ToolChains.h | 10 +++++----- lib/Driver/Tools.h | 25 ++++++++++++++----------- 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/include/clang/Driver/Tool.h b/include/clang/Driver/Tool.h index 28db064258..06f5e37ec2 100644 --- a/include/clang/Driver/Tool.h +++ b/include/clang/Driver/Tool.h @@ -16,14 +16,20 @@ namespace driver { /// Tool - Information on a specific compilation tool. class Tool { + /// The tool name (for debugging). + const char *Name; + + /// The tool chain this tool is a part of. const ToolChain &TheToolChain; public: - Tool(const ToolChain &TC); + Tool(const char *Name, const ToolChain &TC); public: virtual ~Tool(); + const char *getName() const { return Name; } + const ToolChain &getToolChain() const { return TheToolChain; } virtual bool acceptsPipedInput() const = 0; diff --git a/lib/Driver/Tool.cpp b/lib/Driver/Tool.cpp index 090418e3be..6f6589ab13 100644 --- a/lib/Driver/Tool.cpp +++ b/lib/Driver/Tool.cpp @@ -11,7 +11,8 @@ using namespace clang::driver; -Tool::Tool(const ToolChain &TC) : TheToolChain(TC) { +Tool::Tool(const char *_Name, const ToolChain &TC) : Name(_Name), + TheToolChain(TC) { } Tool::~Tool() { diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h index c5e01ba5ac..aa8d2a1bab 100644 --- a/lib/Driver/ToolChains.h +++ b/lib/Driver/ToolChains.h @@ -47,17 +47,17 @@ public: default: assert(0 && "Invalid tool kind."); case Action::PreprocessJobClass: - T = new tools::GCC_Preprocess(*this); break; + T = new tools::gcc::Preprocess(*this); break; case Action::PrecompileJobClass: - T = new tools::GCC_Precompile(*this); break; + 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; + T = new tools::gcc::Compile(*this); break; case Action::AssembleJobClass: - T = new tools::GCC_Assemble(*this); break; + T = new tools::gcc::Assemble(*this); break; case Action::LinkJobClass: - T = new tools::GCC_Assemble(*this); break; + T = new tools::gcc::Link(*this); break; } } diff --git a/lib/Driver/Tools.h b/lib/Driver/Tools.h index 6f6b3dffbc..6aaa04051f 100644 --- a/lib/Driver/Tools.h +++ b/lib/Driver/Tools.h @@ -20,57 +20,60 @@ namespace tools { class VISIBILITY_HIDDEN Clang : public Tool { public: - Clang(const ToolChain &TC) : Tool(TC) {} + Clang(const ToolChain &TC) : Tool("clang", TC) {} virtual bool acceptsPipedInput() const { return true; } virtual bool canPipeOutput() const { return true; } virtual bool hasIntegratedCPP() const { return true; } }; - class VISIBILITY_HIDDEN GCC_Preprocess : public Tool { + /// gcc - Generic GCC tool implementations. +namespace gcc { + class VISIBILITY_HIDDEN Preprocess : public Tool { public: - GCC_Preprocess(const ToolChain &TC) : Tool(TC) {} + Preprocess(const ToolChain &TC) : Tool("gcc::Preprocess", TC) {} virtual bool acceptsPipedInput() const { return true; } virtual bool canPipeOutput() const { return true; } virtual bool hasIntegratedCPP() const { return false; } }; - class VISIBILITY_HIDDEN GCC_Precompile : public Tool { + class VISIBILITY_HIDDEN Precompile : public Tool { public: - GCC_Precompile(const ToolChain &TC) : Tool(TC) {} + Precompile(const ToolChain &TC) : Tool("gcc::Precompile", TC) {} virtual bool acceptsPipedInput() const { return true; } virtual bool canPipeOutput() const { return false; } virtual bool hasIntegratedCPP() const { return true; } }; - class VISIBILITY_HIDDEN GCC_Compile : public Tool { + class VISIBILITY_HIDDEN Compile : public Tool { public: - GCC_Compile(const ToolChain &TC) : Tool(TC) {} + Compile(const ToolChain &TC) : Tool("gcc::Compile", TC) {} virtual bool acceptsPipedInput() const { return true; } virtual bool canPipeOutput() const { return true; } virtual bool hasIntegratedCPP() const { return true; } }; - class VISIBILITY_HIDDEN GCC_Assemble : public Tool { + class VISIBILITY_HIDDEN Assemble : public Tool { public: - GCC_Assemble(const ToolChain &TC) : Tool(TC) {} + Assemble(const ToolChain &TC) : Tool("gcc::Assemble", TC) {} virtual bool acceptsPipedInput() const { return true; } virtual bool canPipeOutput() const { return false; } virtual bool hasIntegratedCPP() const { return false; } }; - class VISIBILITY_HIDDEN GCC_Link : public Tool { + class VISIBILITY_HIDDEN Link : public Tool { public: - GCC_Link(const ToolChain &TC) : Tool(TC) {} + Link(const ToolChain &TC) : Tool("gcc::Link", TC) {} virtual bool acceptsPipedInput() const { return false; } virtual bool canPipeOutput() const { return false; } virtual bool hasIntegratedCPP() const { return false; } }; +} // end namespace gcc } // end namespace toolchains } // end namespace driver -- 2.40.0