Some cleanups for compilation with GCC 4.0.0 to remove warnings:
authorReid Spencer <rspencer@reidspencer.com>
Sun, 15 May 2005 16:13:11 +0000 (16:13 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Sun, 15 May 2005 16:13:11 +0000 (16:13 +0000)
* Use C++ style casts, not C style casts
* Abstract base classes should have virtual destructor.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22057 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/FindUsedTypes.h
include/llvm/Analysis/LoopInfo.h
include/llvm/Assembly/AsmAnnotationWriter.h
include/llvm/DerivedTypes.h
include/llvm/Instructions.h
include/llvm/Support/CallSite.h
include/llvm/SymbolTable.h
lib/VMCore/AsmWriter.cpp

index 0595dc331b60db371dcb06534b472d612f5adc08..5f2ef8e6d3c6fdd125341df7af4db47aa5664275 100644 (file)
@@ -60,7 +60,7 @@ public:
 
 // Make sure that any clients of this file link in PostDominators.cpp
 static IncludeFile
-FIND_USED_TYPES_INCLUDE_FILE((void*)&FindUsedTypes::stub);
+FIND_USED_TYPES_INCLUDE_FILE(reinterpret_cast<void*>(&FindUsedTypes::stub));
 
 } // End llvm namespace
 
index acd739b6b4436f7a80313f9807003405bd8c39e2..95626a42922b6a182234cee4be18c1f3963a705f 100644 (file)
@@ -230,7 +230,8 @@ public:
   /// block is in no loop (for example the entry node), null is returned.
   ///
   Loop *getLoopFor(const BasicBlock *BB) const {
-    std::map<BasicBlock *, Loop*>::const_iterator I=BBMap.find((BasicBlock*)BB);
+    std::map<BasicBlock *, Loop*>::const_iterator I=
+      BBMap.find(const_cast<BasicBlock*>(BB));
     return I != BBMap.end() ? I->second : 0;
   }
 
@@ -300,7 +301,7 @@ private:
 
 // Make sure that any clients of this file link in LoopInfo.cpp
 static IncludeFile
-LOOP_INFO_INCLUDE_FILE((void*)&LoopInfo::stub);
+LOOP_INFO_INCLUDE_FILE(reinterpret_cast<void*>(&LoopInfo::stub));
 
 // Allow clients to walk the list of nested loops...
 template <> struct GraphTraits<const Loop*> {
index 7f9556b710185d6a0593c5f199081a1280c6ced7..9ed285a1afbe3c2215a8a85a3ce6546d5d5cb8e1 100644 (file)
@@ -27,6 +27,8 @@ class Instruction;
 
 struct AssemblyAnnotationWriter {
 
+  virtual ~AssemblyAnnotationWriter();
+
   // emitFunctionAnnot - This may be implemented to emit a string right before
   // the start of a function.
   virtual void emitFunctionAnnot(const Function *F, std::ostream &OS) {}
index a41bec8b1bef9772d474b77f1531ca61f1a7f219..22807f1a6b926cd9d94a6a8dcee9850699a40ab9 100644 (file)
@@ -141,7 +141,7 @@ public:
   /// getNumParams - Return the number of fixed parameters this function type
   /// requires.  This does not consider varargs.
   ///
-  unsigned getNumParams() const { return (unsigned)ContainedTys.size()-1; }
+  unsigned getNumParams() const { return unsigned(ContainedTys.size()-1); }
 
   // Implement the AbstractTypeUser interface.
   virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
@@ -207,7 +207,7 @@ public:
   element_iterator element_end() const { return ContainedTys.end(); }
 
   // Random access to the elements
-  unsigned getNumElements() const { return (unsigned)ContainedTys.size(); }
+  unsigned getNumElements() const { return unsigned(ContainedTys.size()); }
   const Type *getElementType(unsigned N) const {
     assert(N < ContainedTys.size() && "Element number out of range!");
     return ContainedTys[N];
index 264e8b64b9245553be38fcbea45d844073eed419..904ca8f3784ef96f7782d0c0de05b828d32bdaf1 100644 (file)
@@ -519,7 +519,7 @@ public:
   /// if it is a direct call.  If it is a call through a function pointer,
   /// return null.
   Function *getCalledFunction() const {
-    return (Function*)dyn_cast<Function>(getOperand(0));
+    return static_cast<Function*>(dyn_cast<Function>(getOperand(0)));
   }
 
   // getCalledValue - Get a pointer to a method that is invoked by this inst.
@@ -1153,7 +1153,7 @@ public:
   // successor.
   inline ConstantInt *getSuccessorValue(unsigned idx) const {
     assert(idx < getNumSuccessors() && "Successor # out of range!");
-    return (ConstantInt*)getOperand(idx*2);
+    return reinterpret_cast<ConstantInt*>(getOperand(idx*2));
   }
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
index 9d393e050b60f5b7cf0bcb9dee04cb31f0969664..e14caad642c1a061ed45a275cb8328094f3019b4 100644 (file)
@@ -32,8 +32,8 @@ class CallSite {
   Instruction *I;
 public:
   CallSite() : I(0) {}
-  CallSite(CallInst *CI) : I((Instruction*)CI) {}
-  CallSite(InvokeInst *II) : I((Instruction*)II) {}
+  CallSite(CallInst *CI) : I(reinterpret_cast<Instruction*>(CI)) {}
+  CallSite(InvokeInst *II) : I(reinterpret_cast<Instruction*>(II)) {}
   CallSite(const CallSite &CS) : I(CS.I) {}
   CallSite &operator=(const CallSite &CS) { I = CS.I; return *this; }
 
@@ -45,9 +45,9 @@ public:
   static CallSite get(Value *V) {
     if (Instruction *I = dyn_cast<Instruction>(V)) {
       if (I->getOpcode() == Instruction::Call)
-        return CallSite((CallInst*)I);
+        return CallSite(reinterpret_cast<CallInst*>(I));
       else if (I->getOpcode() == Instruction::Invoke)
-        return CallSite((InvokeInst*)I);
+        return CallSite(reinterpret_cast<InvokeInst*>(I));
     }
     return CallSite();
   }
index 4a4c70ee89cadb01e09e620b195d67a844fa6c3a..04f009681c1c837d162792e59b68cbb9d9537bcb 100644 (file)
@@ -108,7 +108,7 @@ public:
   inline bool isEmpty() const { return pmap.empty() && tmap.empty(); }
 
   /// @brief The number of name/type pairs is returned.
-  inline unsigned num_types() const { return (unsigned)tmap.size(); }
+  inline unsigned num_types() const { return unsigned(tmap.size()); }
 
   /// Given a base name, return a string that is either equal to it or
   /// derived from it that does not already occur in the symbol table
index 889ae4067cbc74f591b34170747de652252c05f0..9ae3b9a2890d0ada1b524ec48dec4a387e9defa7 100644 (file)
@@ -34,6 +34,9 @@ using namespace llvm;
 
 namespace llvm {
 
+// Make virtual table appear in this compilation unit.
+AssemblyAnnotationWriter::~AssemblyAnnotationWriter() {}
+
 /// This class provides computation of slot numbers for LLVM Assembly writing.
 /// @brief LLVM Assembly Writing Slot Computation.
 class SlotMachine {