[PATCH] [PATCH] Remove AssemblyAnnotationWriter from Value::print

Robert Matusewicz matekm at gmail.com
Wed Mar 19 12:17:56 PDT 2014


Hi #llvm,

Hi,

I was inspecting LLVM code and noticed that AssemblyAnnotationWriter parameter in Value::print method is always a nullptr. I attach a patch that will remove it.

I also changed some 0s that were used as nullptr indication to nullptrs.

After changes llvm and tool is compiling correctly and there is no regression in tests (at least those from make check-all).

BTW: I can see that there are other classes that have print method with AAW pointer, but the pointer are always null. If this patch will be accepted, I change them too.

Best regards,
Robert Matusewicz

http://llvm-reviews.chandlerc.com/D3123

Files:
  include/llvm/IR/Value.h
  lib/IR/AsmWriter.cpp

Index: include/llvm/IR/Value.h
===================================================================
--- include/llvm/IR/Value.h
+++ include/llvm/IR/Value.h
@@ -196,7 +196,7 @@
 
   /// print - Implement operator<< on Value.
   ///
-  void print(raw_ostream &O, AssemblyAnnotationWriter *AAW = 0) const;
+  void print(raw_ostream &O) const;
 
   /// \brief Print the name of this Value out to the specified raw_ostream.
   /// This is useful when you just want to print 'int %reg126', not the
Index: lib/IR/AsmWriter.cpp
===================================================================
--- lib/IR/AsmWriter.cpp
+++ lib/IR/AsmWriter.cpp
@@ -2170,24 +2170,24 @@
     }
 }
 
-void Value::print(raw_ostream &ROS, AssemblyAnnotationWriter *AAW) const {
+void Value::print(raw_ostream &ROS) const {
   if (this == 0) {
     ROS << "printing a <null> value\n";
     return;
   }
   formatted_raw_ostream OS(ROS);
   if (const Instruction *I = dyn_cast<Instruction>(this)) {
-    const Function *F = I->getParent() ? I->getParent()->getParent() : 0;
+    const Function *F = I->getParent() ? I->getParent()->getParent() : nullptr;
     SlotTracker SlotTable(F);
-    AssemblyWriter W(OS, SlotTable, getModuleFromVal(I), AAW);
+    AssemblyWriter W(OS, SlotTable, getModuleFromVal(I), nullptr);
     W.printInstruction(*I);
   } else if (const BasicBlock *BB = dyn_cast<BasicBlock>(this)) {
     SlotTracker SlotTable(BB->getParent());
-    AssemblyWriter W(OS, SlotTable, getModuleFromVal(BB), AAW);
+    AssemblyWriter W(OS, SlotTable, getModuleFromVal(BB), nullptr);
     W.printBasicBlock(BB);
   } else if (const GlobalValue *GV = dyn_cast<GlobalValue>(this)) {
     SlotTracker SlotTable(GV->getParent());
-    AssemblyWriter W(OS, SlotTable, GV->getParent(), AAW);
+    AssemblyWriter W(OS, SlotTable, GV->getParent(), nullptr);
     if (const GlobalVariable *V = dyn_cast<GlobalVariable>(GV))
       W.printGlobal(V);
     else if (const Function *F = dyn_cast<Function>(GV))
@@ -2197,13 +2197,13 @@
   } else if (const MDNode *N = dyn_cast<MDNode>(this)) {
     const Function *F = N->getFunction();
     SlotTracker SlotTable(F);
-    AssemblyWriter W(OS, SlotTable, F ? F->getParent() : 0, AAW);
+    AssemblyWriter W(OS, SlotTable, F ? F->getParent() : nullptr, nullptr);
     W.printMDNodeBody(N);
   } else if (const Constant *C = dyn_cast<Constant>(this)) {
     TypePrinting TypePrinter;
     TypePrinter.print(C->getType(), OS);
     OS << ' ';
-    WriteConstantInternal(OS, C, TypePrinter, 0, 0);
+    WriteConstantInternal(OS, C, TypePrinter, nullptr, nullptr);
   } else if (isa<InlineAsm>(this) || isa<MDString>(this) ||
              isa<Argument>(this)) {
     this->printAsOperand(OS);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3123.1.patch
Type: text/x-patch
Size: 2703 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140319/05dcec25/attachment.bin>


More information about the llvm-commits mailing list