[llvm] r255977 - [Option] Introduce Arg::print(raw_ostream&) and use llvm::dbgs

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 17 18:27:52 PST 2015


Author: vedantk
Date: Thu Dec 17 20:27:52 2015
New Revision: 255977

URL: http://llvm.org/viewvc/llvm-project?rev=255977&view=rev
Log:
[Option] Introduce Arg::print(raw_ostream&) and use llvm::dbgs

Modified:
    llvm/trunk/include/llvm/Option/Arg.h
    llvm/trunk/lib/Option/Arg.cpp

Modified: llvm/trunk/include/llvm/Option/Arg.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Option/Arg.h?rev=255977&r1=255976&r2=255977&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Option/Arg.h (original)
+++ llvm/trunk/include/llvm/Option/Arg.h Thu Dec 17 20:27:52 2015
@@ -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

Modified: llvm/trunk/lib/Option/Arg.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Option/Arg.cpp?rev=255977&r1=255976&r2=255977&view=diff
==============================================================================
--- llvm/trunk/lib/Option/Arg.cpp (original)
+++ llvm/trunk/lib/Option/Arg.cpp Thu Dec 17 20:27:52 2015
@@ -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 {




More information about the llvm-commits mailing list