Fixes for PR341
authorChris Lattner <sabre@nondot.org>
Thu, 15 Jul 2004 02:51:31 +0000 (02:51 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 15 Jul 2004 02:51:31 +0000 (02:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14847 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Assembly/CachedWriter.h
lib/ExecutionEngine/ExecutionEngine.cpp
lib/ExecutionEngine/Interpreter/Execution.cpp
lib/VMCore/AsmWriter.cpp

index 1306e37921462ca428d1d650719250318dfbce49..f5c947be52d74853dd301f708b5f28d8400a3019 100644 (file)
 #include "llvm/Value.h"
 #include <iostream>
 
-namespace {
-class SlotMachine;     // Internal private class
-}
-
 namespace llvm {
 
 class Module;
 class PointerType;
 class AssemblyWriter;  // Internal private class
+class SlotMachine;
 
 class CachedWriter {
   AssemblyWriter *AW;
@@ -53,14 +50,9 @@ public:
   // setModule - Invalidate internal state, use the new module instead.
   void setModule(const Module *M);
 
-  CachedWriter &operator<<(const Value *V);
-
-  inline CachedWriter &operator<<(const Value &X) {
-    return *this << &X;
-  }
+  CachedWriter &operator<<(const Value &V);
 
-  CachedWriter &operator<<(const Type *X);
-  inline CachedWriter &operator<<(const PointerType *X);
+  CachedWriter &operator<<(const Type &X);
 
   inline CachedWriter &operator<<(std::ostream &(&Manip)(std::ostream &)) {
     Out << Manip; return *this;
index 465b19e42daf746848334e30224fc9b48274a598..e53c468a2f3daa29e357e196df4c4013fa3bb788 100644 (file)
@@ -278,7 +278,7 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
     }
     break;
   default:
-    std::cout << "ERROR: Constant unimp for type: " << C->getType() << "\n";
+    std::cout << "ERROR: Constant unimp for type: " << *C->getType() << "\n";
     abort();
   }
   return Result;
@@ -319,7 +319,7 @@ void ExecutionEngine::StoreValueToMemory(GenericValue Val, GenericValue *Ptr,
                             Ptr->Untyped[7] = (Val.ULongVal >> 56) & 255;
                             break;
     default:
-      std::cout << "Cannot store value of type " << Ty << "!\n";
+      std::cout << "Cannot store value of type " << *Ty << "!\n";
     }
   } else {
     switch (Ty->getTypeID()) {
@@ -352,7 +352,7 @@ void ExecutionEngine::StoreValueToMemory(GenericValue Val, GenericValue *Ptr,
                             Ptr->Untyped[0] = (Val.ULongVal >> 56) & 255;
                             break;
     default:
-      std::cout << "Cannot store value of type " << Ty << "!\n";
+      std::cout << "Cannot store value of type " << *Ty << "!\n";
     }
   }
 }
@@ -471,7 +471,7 @@ void ExecutionEngine::InitializeMemory(const Constant *Init, void *Addr) {
   }
 
   default:
-    std::cerr << "Bad Type: " << Init->getType() << "\n";
+    std::cerr << "Bad Type: " << *Init->getType() << "\n";
     assert(0 && "Unknown constant type to initialize memory with!");
   }
 }
index a9846705b433825f7edc1c87cd23cbccaccb783a..1095ecbeb02fa82f8862c53aa9a807e43c6d46e2 100644 (file)
@@ -146,7 +146,7 @@ GenericValue Interpreter::getConstantExprValue (ConstantExpr *CE,
                              getOperandValue(CE->getOperand(1), SF),
                              getOperandValue(CE->getOperand(2), SF));
   default:
-    std::cerr << "Unhandled ConstantExpr: " << CE << "\n";
+    std::cerr << "Unhandled ConstantExpr: " << *CE << "\n";
     abort();
     return GenericValue();
   }
@@ -236,7 +236,7 @@ static GenericValue executeMulInst(GenericValue Src1, GenericValue Src2,
     IMPLEMENT_BINARY_OPERATOR(*, Float);
     IMPLEMENT_BINARY_OPERATOR(*, Double);
   default:
-    std::cout << "Unhandled type for Mul instruction: " << Ty << "\n";
+    std::cout << "Unhandled type for Mul instruction: " << *Ty << "\n";
     abort();
   }
   return Dest;
index bd6c09e0e514bde5d8ab361166f576fcb1171b20..0f76712a2b57f47e976e30589c76eae304c0eeb0 100644 (file)
@@ -34,7 +34,7 @@
 #include <algorithm>
 using namespace llvm;
 
-namespace {
+namespace llvm {
 
 /// This class provides computation of slot numbers for LLVM Assembly writing.
 /// @brief LLVM Assembly Writing Slot Computation.
@@ -154,7 +154,7 @@ public:
 
 };
 
-}
+}  // end namespace llvm
 
 static RegisterPass<PrintModulePass>
 X("printm", "Print module to stderr",PassInfo::Analysis|PassInfo::Optimization);
@@ -1213,27 +1213,27 @@ CachedWriter::~CachedWriter() {
   delete SC;
 }
 
-CachedWriter &CachedWriter::operator<<(const Value *V) {
+CachedWriter &CachedWriter::operator<<(const Value &V) {
   assert(AW && SC && "CachedWriter does not have a current module!");
-  if (const Instruction *I = dyn_cast<Instruction>(V))
+  if (const Instruction *I = dyn_cast<Instruction>(&V))
     AW->write(I);
-  else if (const BasicBlock *BB = dyn_cast<BasicBlock>(V))
+  else if (const BasicBlock *BB = dyn_cast<BasicBlock>(&V))
     AW->write(BB);
-  else if (const Function *F = dyn_cast<Function>(V))
+  else if (const Function *F = dyn_cast<Function>(&V))
     AW->write(F);
-  else if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(V))
+  else if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(&V))
     AW->write(GV);
   else 
-    AW->writeOperand(V, true, true);
+    AW->writeOperand(&V, true, true);
   return *this;
 }
 
-CachedWriter& CachedWriter::operator<<(const Type *Ty) {
+CachedWriter& CachedWriter::operator<<(const Type &Ty) {
   if (SymbolicTypes) {
     const Module *M = AW->getModule();
-    if (M) WriteTypeSymbolic(Out, Ty, M);
+    if (M) WriteTypeSymbolic(Out, &Ty, M);
   } else {
-    AW->write(Ty);
+    AW->write(&Ty);
   }
   return *this;
 }