[llvm-commits] CVS: llvm/lib/CWriter/Writer.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed Apr 23 14:10:03 PDT 2003


Changes in directory llvm/lib/CWriter:

Writer.cpp updated: 1.79 -> 1.80

---
Log message:

Fix the super obnoxious "cast to pointer from integer of different size" warnings


---
Diffs of the changes:

Index: llvm/lib/CWriter/Writer.cpp
diff -u llvm/lib/CWriter/Writer.cpp:1.79 llvm/lib/CWriter/Writer.cpp:1.80
--- llvm/lib/CWriter/Writer.cpp:1.79	Wed Apr 23 11:36:08 2003
+++ llvm/lib/CWriter/Writer.cpp	Wed Apr 23 14:09:22 2003
@@ -946,13 +946,8 @@
 
 void CWriter::visitBinaryOperator(Instruction &I) {
   // binary instructions, shift instructions, setCond instructions.
-  if (isa<PointerType>(I.getType())) {
-    Out << "(";
-    printType(Out, I.getType());
-    Out << ")";
-  }
+  assert(!isa<PointerType>(I.getType()));
       
-  if (isa<PointerType>(I.getType())) Out << "(long long)";
   writeOperand(I.getOperand(0));
 
   switch (I.getOpcode()) {
@@ -975,14 +970,20 @@
   default: std::cerr << "Invalid operator type!" << I; abort();
   }
 
-  if (isa<PointerType>(I.getType())) Out << "(long long)";
   writeOperand(I.getOperand(1));
 }
 
 void CWriter::visitCastInst(CastInst &I) {
   Out << "(";
-  printType(Out, I.getType(), string(""),/*ignoreName*/false, /*namedContext*/false);
+  printType(Out, I.getType(), string(""),/*ignoreName*/false,
+            /*namedContext*/false);
   Out << ")";
+  if (isa<PointerType>(I.getType())&&I.getOperand(0)->getType()->isIntegral() ||
+      isa<PointerType>(I.getOperand(0)->getType())&&I.getType()->isIntegral()) {
+    // Avoid "cast to pointer from integer of different size" warnings
+    Out << "(long)";  
+  }
+
   writeOperand(I.getOperand(0));
 }
 





More information about the llvm-commits mailing list