Skip to content

Commit

Permalink
[Option] Introduce Arg::print(raw_ostream&) and use llvm::dbgs
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255977 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
vedantk committed Dec 18, 2015
1 parent cca8dbe commit e116b55
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
3 changes: 3 additions & 0 deletions include/llvm/Option/Arg.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Option/Option.h"
#include "llvm/Support/raw_ostream.h"
#include <string>

namespace llvm {
Expand Down Expand Up @@ -113,6 +114,8 @@ class Arg {
/// when rendered as a input (e.g., Xlinker).
void renderAsInput(const ArgList &Args, ArgStringList &Output) const;

void print(raw_ostream &OS) const;

void dump() const;

/// \brief Return a formatted version of the argument and
Expand Down
21 changes: 12 additions & 9 deletions lib/Option/Arg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "llvm/ADT/Twine.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Option/Option.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Debug.h"

using namespace llvm;
using namespace llvm::opt;
Expand Down Expand Up @@ -43,21 +43,24 @@ Arg::~Arg() {
}
}

void Arg::dump() const {
llvm::errs() << "<";
void Arg::print(raw_ostream &OS) const {
OS << "<";

llvm::errs() << " Opt:";
OS << " Opt:";
Opt.dump();

llvm::errs() << " Index:" << Index;
OS << " Index:" << Index;

llvm::errs() << " Values: [";
OS << " Values: [";
for (unsigned i = 0, e = Values.size(); i != e; ++i) {
if (i) llvm::errs() << ", ";
llvm::errs() << "'" << Values[i] << "'";
OS << "'" << Values[i] << "'";
if (i != e - 1) llvm::errs() << ", ";
}
OS << "]>\n";
}

llvm::errs() << "]>\n";
void Arg::dump() const {
print(llvm::dbgs());
}

std::string Arg::getAsString(const ArgList &Args) const {
Expand Down

0 comments on commit e116b55

Please sign in to comment.