diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-03-13 12:19:02 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-03-13 12:19:02 +0000 |
commit | aaf1ea6386ff56946e9e2d5fc949e7241863767e (patch) | |
tree | 2950cd48e49bd7641affc19a0dd14482c9e14fe7 /clang/lib/Driver/Driver.cpp | |
parent | 80665fb0c514958da9f22e06d6caeb3635e6db43 (diff) | |
download | bcm5719-llvm-aaf1ea6386ff56946e9e2d5fc949e7241863767e.tar.gz bcm5719-llvm-aaf1ea6386ff56946e9e2d5fc949e7241863767e.zip |
Driver: Support -ccc-print-phases.
llvm-svn: 66888
Diffstat (limited to 'clang/lib/Driver/Driver.cpp')
-rw-r--r-- | clang/lib/Driver/Driver.cpp | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 75e9df25e05..4efd4608e1a 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -22,6 +22,9 @@ #include "llvm/ADT/StringMap.h" #include "llvm/Support/raw_ostream.h" #include "llvm/System/Path.h" + +#include <map> + using namespace clang::driver; Driver::Driver(const char *_Name, const char *_Dir, @@ -165,7 +168,7 @@ Compilation *Driver::BuildCompilation(int argc, const char **argv) { // FIXME: This behavior shouldn't be here. if (CCCPrintActions) { - PrintActions(Actions); + PrintActions(*Args, Actions); exit(0); } @@ -229,8 +232,48 @@ bool Driver::HandleImmediateArgs(const ArgList &Args) { return true; } -void Driver::PrintActions(const ActionList &Actions) const { - llvm::errs() << "FIXME: Print actions."; +// FIXME: This shouldn't be here? +static unsigned PrintActions1(const ArgList &Args, + Action *A, + std::map<Action*, unsigned> &Ids) { + if (Ids.count(A)) + return Ids[A]; + + std::string str; + llvm::raw_string_ostream os(str); + + os << Action::getClassName(A->getKind()) << ", "; + if (InputAction *IA = dyn_cast<InputAction>(A)) { + os << IA->getInputArg().getValue(Args) << "\""; + } else if (BindArchAction *BIA = dyn_cast<BindArchAction>(A)) { + os << "\"" << BIA->getArchName() << "\", " + << "{" << PrintActions1(Args, *BIA->begin(), Ids) << "}"; + } else { + os << "{"; + for (Action::iterator it = A->begin(), ie = A->end(); it != ie;) { + os << PrintActions1(Args, *it, Ids); + ++it; + if (it != ie) + os << ", "; + } + os << "}"; + } + + unsigned Id = Ids.size(); + Ids[A] = Id; + llvm::outs() << Id << ": " << os.str() << ", " + << types::getTypeName(A->getType()) << "\n"; + + return Id; +} + +void Driver::PrintActions(const ArgList &Args, + const ActionList &Actions) const { + std::map<Action*, unsigned> Ids; + for (ActionList::const_iterator it = Actions.begin(), ie = Actions.end(); + it != ie; ++it) { + PrintActions1(Args, *it, Ids); + } } void Driver::BuildUniversalActions(ArgList &Args, ActionList &Actions) { |