summaryrefslogtreecommitdiff
path: root/lib/Option
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2015-12-18 18:55:26 +0000
committerEric Christopher <echristo@gmail.com>2015-12-18 18:55:26 +0000
commit96e80fcbfd852a6bc6ed1a15c87e709ac1080dbc (patch)
treea9732a71f5fd2905c512ea6e588b7bc8ef655223 /lib/Option
parent8281fa78381570e6685ce0d6068136f69bd7c6fb (diff)
Convert Arg, ArgList, and Option to dump() to dbgs() rather than errs().
Also add print() functions. Patch by Justin Lebar! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256010 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Option')
-rw-r--r--lib/Option/Arg.cpp21
-rw-r--r--lib/Option/ArgList.cpp9
-rw-r--r--lib/Option/Option.cpp31
3 files changed, 35 insertions, 26 deletions
diff --git a/lib/Option/Arg.cpp b/lib/Option/Arg.cpp
index ac000736c1f..c3de2d1a496 100644
--- a/lib/Option/Arg.cpp
+++ b/lib/Option/Arg.cpp
@@ -13,6 +13,7 @@
#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;
@@ -43,23 +44,25 @@ Arg::~Arg() {
}
}
-void Arg::dump() const {
- llvm::errs() << "<";
+void Arg::print(raw_ostream& O) const {
+ O << "<";
- llvm::errs() << " Opt:";
- Opt.dump();
+ O << " Opt:";
+ Opt.print(O);
- llvm::errs() << " Index:" << Index;
+ O << " Index:" << Index;
- llvm::errs() << " Values: [";
+ O << " Values: [";
for (unsigned i = 0, e = Values.size(); i != e; ++i) {
- if (i) llvm::errs() << ", ";
- llvm::errs() << "'" << Values[i] << "'";
+ if (i) O << ", ";
+ O << "'" << Values[i] << "'";
}
- llvm::errs() << "]>\n";
+ O << "]>\n";
}
+LLVM_DUMP_METHOD void Arg::dump() const { print(dbgs()); }
+
std::string Arg::getAsString(const ArgList &Args) const {
SmallString<256> Res;
llvm::raw_svector_ostream OS(Res);
diff --git a/lib/Option/ArgList.cpp b/lib/Option/ArgList.cpp
index 48f1a71d986..0826ef87319 100644
--- a/lib/Option/ArgList.cpp
+++ b/lib/Option/ArgList.cpp
@@ -13,6 +13,7 @@
#include "llvm/ADT/Twine.h"
#include "llvm/Option/Arg.h"
#include "llvm/Option/Option.h"
+#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
@@ -328,13 +329,15 @@ const char *ArgList::GetOrMakeJoinedArgString(unsigned Index,
return MakeArgString(LHS + RHS);
}
-LLVM_DUMP_METHOD void ArgList::dump() const {
+void ArgList::print(raw_ostream &O) const {
for (Arg *A : *this) {
- llvm::errs() << "* ";
- A->dump();
+ O << "* ";
+ A->print(O);
}
}
+LLVM_DUMP_METHOD void ArgList::dump() const { print(dbgs()); }
+
//
void InputArgList::releaseMemory() {
diff --git a/lib/Option/Option.cpp b/lib/Option/Option.cpp
index 221414d79e7..ebf05aab764 100644
--- a/lib/Option/Option.cpp
+++ b/lib/Option/Option.cpp
@@ -11,6 +11,7 @@
#include "llvm/ADT/Twine.h"
#include "llvm/Option/Arg.h"
#include "llvm/Option/ArgList.h"
+#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
@@ -35,10 +36,10 @@ Option::Option(const OptTable::Info *info, const OptTable *owner)
}
}
-void Option::dump() const {
- llvm::errs() << "<";
+void Option::print(raw_ostream &O) const {
+ O << "<";
switch (getKind()) {
-#define P(N) case N: llvm::errs() << #N; break
+#define P(N) case N: O << #N; break
P(GroupClass);
P(InputClass);
P(UnknownClass);
@@ -54,33 +55,35 @@ void Option::dump() const {
}
if (Info->Prefixes) {
- llvm::errs() << " Prefixes:[";
- for (const char * const *Pre = Info->Prefixes; *Pre != nullptr; ++Pre) {
- llvm::errs() << '"' << *Pre << (*(Pre + 1) == nullptr ? "\"" : "\", ");
+ O << " Prefixes:[";
+ for (const char *const *Pre = Info->Prefixes; *Pre != nullptr; ++Pre) {
+ O << '"' << *Pre << (*(Pre + 1) == nullptr ? "\"" : "\", ");
}
- llvm::errs() << ']';
+ O << ']';
}
- llvm::errs() << " Name:\"" << getName() << '"';
+ O << " Name:\"" << getName() << '"';
const Option Group = getGroup();
if (Group.isValid()) {
- llvm::errs() << " Group:";
- Group.dump();
+ O << " Group:";
+ Group.print(O);
}
const Option Alias = getAlias();
if (Alias.isValid()) {
- llvm::errs() << " Alias:";
- Alias.dump();
+ O << " Alias:";
+ Alias.print(O);
}
if (getKind() == MultiArgClass)
- llvm::errs() << " NumArgs:" << getNumArgs();
+ O << " NumArgs:" << getNumArgs();
- llvm::errs() << ">\n";
+ O << ">\n";
}
+void Option::dump() const { print(dbgs()); }
+
bool Option::matches(OptSpecifier Opt) const {
// Aliases are never considered in matching, look through them.
const Option Alias = getAlias();