From 135837e046948fc858446c22dbfca83dd9df56aa Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Wed, 4 Mar 2009 23:02:50 +0000 Subject: [PATCH] Driver: Add Arg::dump and SeparateArg stubs. llvm-svn: 66100 --- clang/include/clang/Driver/Arg.h | 2 ++ clang/lib/Driver/Arg.cpp | 41 ++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/clang/include/clang/Driver/Arg.h b/clang/include/clang/Driver/Arg.h index 4bf6be6d56cb..b558a84b89d6 100644 --- a/clang/include/clang/Driver/Arg.h +++ b/clang/include/clang/Driver/Arg.h @@ -71,6 +71,8 @@ namespace driver { virtual void render(const ArgList &Args, ArgStringList &Output) const = 0; static bool classof(const Arg *) { return true; } + + void dump() const; }; /// PositionalArg - A simple positional argument. diff --git a/clang/lib/Driver/Arg.cpp b/clang/lib/Driver/Arg.cpp index ad3c16d98aa5..9f0ed7245d19 100644 --- a/clang/lib/Driver/Arg.cpp +++ b/clang/lib/Driver/Arg.cpp @@ -8,6 +8,8 @@ //===----------------------------------------------------------------------===// #include "clang/Driver/Arg.h" +#include "clang/Driver/Option.h" +#include "llvm/Support/raw_ostream.h" using namespace clang::driver; @@ -20,6 +22,33 @@ Arg::Arg(ArgClass _Kind, const Option *_Opt, unsigned _Index) Arg::~Arg() { } +void Arg::dump() const { + llvm::errs() << "<"; + switch (Kind) { + default: + assert(0 && "Invalid kind"); +#define P(N) case N: llvm::errs() << #N; break + P(PositionalClass); + P(JoinedClass); + P(SeparateClass); + P(CommaJoinedClass); + P(JoinedAndSeparateClass); +#undef P + } + + llvm::errs() << " Opt:"; + Opt->dump(); + + llvm::errs() << " Index:" << Index; + + if (const CommaJoinedArg *CJA = dyn_cast(this)) + llvm::errs() << " NumValues:" << CJA->getNumValues(); + + llvm::errs() << ">\n"; + + llvm::errs().flush(); // FIXME +} + PositionalArg::PositionalArg(const Option *Opt, unsigned Index) : Arg(PositionalClass, Opt, Index) { } @@ -57,6 +86,18 @@ const char *CommaJoinedArg::getValue(const ArgList &Args, unsigned N) const { assert(0 && "FIXME: Implement"); } +SeparateArg::SeparateArg(const Option *Opt, unsigned Index, unsigned _NumValues) + : Arg(SeparateClass, Opt, Index), NumValues(_NumValues) { +} + +void SeparateArg::render(const ArgList &Args, ArgStringList &Output) const { + assert(0 && "FIXME: Implement"); +} + +const char *SeparateArg::getValue(const ArgList &Args, unsigned N) const { + assert(0 && "FIXME: Implement"); +} + JoinedAndSeparateArg::JoinedAndSeparateArg(const Option *Opt, unsigned Index) : Arg(JoinedAndSeparateClass, Opt, Index) { }