[Option] Introduce Arg::print(raw_ostream&) and use llvm::dbgs
authorVedant Kumar <vsk@apple.com>
Fri, 18 Dec 2015 02:27:52 +0000 (02:27 +0000)
committerVedant Kumar <vsk@apple.com>
Fri, 18 Dec 2015 02:27:52 +0000 (02:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255977 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Option/Arg.h
lib/Option/Arg.cpp

index e1b72b6267cf195d2f12d78b3774ab3fad4ffa0b..f56ef080dcfb9ec831cdde25a7d48ceeb407a353 100644 (file)
@@ -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 {
@@ -113,6 +114,8 @@ public:
   /// 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
index ac000736c1f3aac9bf21b76ec83745b89c83dd81..b14493d7dd79feab02ef184a42ab0f5ab3a31b2b 100644 (file)
@@ -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;
@@ -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 {