[cfe-commits] r67037 - in /cfe/trunk: include/clang/Driver/Compilation.h include/clang/Driver/Driver.h lib/Driver/Compilation.cpp lib/Driver/Driver.cpp
Daniel Dunbar
daniel at zuster.org
Sun Mar 15 23:42:31 PDT 2009
Author: ddunbar
Date: Mon Mar 16 01:42:30 2009
New Revision: 67037
URL: http://llvm.org/viewvc/llvm-project?rev=67037&view=rev
Log:
Driver: Migrate some data into the Compilation; after pipelining
access to most data should go through the current Compilation, not the
Driver (which shouldn't be specialized on variables for a single
compilation).
Modified:
cfe/trunk/include/clang/Driver/Compilation.h
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/lib/Driver/Compilation.cpp
cfe/trunk/lib/Driver/Driver.cpp
Modified: cfe/trunk/include/clang/Driver/Compilation.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Compilation.h?rev=67037&r1=67036&r2=67037&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Compilation.h (original)
+++ cfe/trunk/include/clang/Driver/Compilation.h Mon Mar 16 01:42:30 2009
@@ -10,16 +10,44 @@
#ifndef CLANG_DRIVER_COMPILATION_H_
#define CLANG_DRIVER_COMPILATION_H_
+#include "clang/Driver/Job.h"
+
+#include "llvm/ADT/DenseMap.h"
+
namespace clang {
namespace driver {
+ class ArgList;
+ class JobList;
+ class ToolChain;
/// Compilation - A set of tasks to perform for a single driver
/// invocation.
class Compilation {
+ /// The default tool chain.
+ ToolChain &DefaultToolChain;
+
+ /// The original (untranslated) input argument list.
+ ArgList *Args;
+
+ /// The root list of jobs.
+ JobList Jobs;
+
+ /// TCArgs - Cache of translated arguments for a particular tool
+ /// chain.
+ llvm::DenseMap<const ToolChain*, ArgList*> TCArgs;
+
public:
- Compilation();
+ Compilation(ToolChain &DefaultToolChain, ArgList *Args);
~Compilation();
+ const ArgList &getArgs() const { return *Args; }
+ JobList &getJobs() { return Jobs; }
+
+ /// getArgsForToolChain - Return the argument list, possibly
+ /// translated by the tool chain \arg TC (or by the default tool
+ /// chain, if TC is not specified).
+ const ArgList &getArgsForToolChain(const ToolChain *TC = 0);
+
/// Execute - Execute the compilation jobs and return an
/// appropriate exit code.
int Execute() const;
Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=67037&r1=67036&r2=67037&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Mon Mar 16 01:42:30 2009
@@ -139,7 +139,9 @@
/// BuildJobs - Bind actions to concrete tools and translate
/// arguments to form the list of jobs to run.
- Compilation *BuildJobs(const ArgList &Args, const ActionList &Actions) const;
+ ///
+ /// \arg C - The compilation that is being built.
+ void BuildJobs(Compilation &C, const ActionList &Actions) const;
/// @}
/// @name Helper Methods
Modified: cfe/trunk/lib/Driver/Compilation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Compilation.cpp?rev=67037&r1=67036&r2=67037&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Compilation.cpp (original)
+++ cfe/trunk/lib/Driver/Compilation.cpp Mon Mar 16 01:42:30 2009
@@ -8,12 +8,38 @@
//===----------------------------------------------------------------------===//
#include "clang/Driver/Compilation.h"
+
+#include "clang/Driver/ArgList.h"
+#include "clang/Driver/ToolChain.h"
+
using namespace clang::driver;
-Compilation::Compilation() {
+Compilation::Compilation(ToolChain &_DefaultToolChain,
+ ArgList *_Args)
+ : DefaultToolChain(_DefaultToolChain), Args(_Args) {
+}
+
+Compilation::~Compilation() {
+ delete Args;
+
+ // Free any derived arg lists.
+ for (llvm::DenseMap<const ToolChain*, ArgList*>::iterator
+ it = TCArgs.begin(), ie = TCArgs.end(); it != ie; ++it) {
+ ArgList *A = it->second;
+ if (A != Args)
+ delete Args;
+ }
}
-Compilation::~Compilation() {
+const ArgList &Compilation::getArgsForToolChain(const ToolChain *TC) {
+ if (!TC)
+ TC = &DefaultToolChain;
+
+ ArgList *&Args = TCArgs[TC];
+ if (!Args)
+ Args = TC->TranslateArgs(*Args);
+
+ return *Args;
}
int Compilation::Execute() const {
Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=67037&r1=67036&r2=67037&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Mar 16 01:42:30 2009
@@ -171,19 +171,9 @@
return 0;
}
- Compilation *C = BuildJobs(*Args, Actions);
-
- // If there were no errors, warn about any unused arguments.
- for (ArgList::iterator it = Args->begin(), ie = Args->end(); it != ie; ++it) {
- Arg *A = *it;
-
- // FIXME: It would be nice to be able to send the argument to the
- // Diagnostic, so that extra values, position, and so on could be
- // printed.
- if (!A->isClaimed())
- Diag(clang::diag::warn_drv_unused_argument)
- << A->getOption().getName();
- }
+ // The compilation takes ownership of Args.
+ Compilation *C = new Compilation(*DefaultToolChain, Args);
+ BuildJobs(*C, Actions);
return C;
}
@@ -577,9 +567,21 @@
return 0;
}
-Compilation *Driver::BuildJobs(const ArgList &Args,
- const ActionList &Actions) const {
- return 0;
+void Driver::BuildJobs(Compilation &C,
+ const ActionList &Actions) const {
+
+ // If there were no errors, warn about any unused arguments.
+ for (ArgList::const_iterator it = C.getArgs().begin(), ie = C.getArgs().end();
+ it != ie; ++it) {
+ Arg *A = *it;
+
+ // FIXME: It would be nice to be able to send the argument to the
+ // Diagnostic, so that extra values, position, and so on could be
+ // printed.
+ if (!A->isClaimed())
+ Diag(clang::diag::warn_drv_unused_argument)
+ << A->getOption().getName();
+ }
}
llvm::sys::Path Driver::GetFilePath(const char *Name,
More information about the cfe-commits
mailing list