From edd5d9ece15f73ec1a31423a4ae39774aa6c521c Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Sun, 15 May 2005 16:13:11 +0000 Subject: [PATCH] Some cleanups for compilation with GCC 4.0.0 to remove warnings: * 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 | 2 +- include/llvm/Analysis/LoopInfo.h | 5 +++-- include/llvm/Assembly/AsmAnnotationWriter.h | 2 ++ include/llvm/DerivedTypes.h | 4 ++-- include/llvm/Instructions.h | 4 ++-- include/llvm/Support/CallSite.h | 8 ++++---- include/llvm/SymbolTable.h | 2 +- lib/VMCore/AsmWriter.cpp | 3 +++ 8 files changed, 18 insertions(+), 12 deletions(-) diff --git a/include/llvm/Analysis/FindUsedTypes.h b/include/llvm/Analysis/FindUsedTypes.h index 0595dc331b6..5f2ef8e6d3c 100644 --- a/include/llvm/Analysis/FindUsedTypes.h +++ b/include/llvm/Analysis/FindUsedTypes.h @@ -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(&FindUsedTypes::stub)); } // End llvm namespace diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index acd739b6b44..95626a42922 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -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::const_iterator I=BBMap.find((BasicBlock*)BB); + std::map::const_iterator I= + BBMap.find(const_cast(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(&LoopInfo::stub)); // Allow clients to walk the list of nested loops... template <> struct GraphTraits { diff --git a/include/llvm/Assembly/AsmAnnotationWriter.h b/include/llvm/Assembly/AsmAnnotationWriter.h index 7f9556b7101..9ed285a1afb 100644 --- a/include/llvm/Assembly/AsmAnnotationWriter.h +++ b/include/llvm/Assembly/AsmAnnotationWriter.h @@ -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) {} diff --git a/include/llvm/DerivedTypes.h b/include/llvm/DerivedTypes.h index a41bec8b1be..22807f1a6b9 100644 --- a/include/llvm/DerivedTypes.h +++ b/include/llvm/DerivedTypes.h @@ -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]; diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index 264e8b64b92..904ca8f3784 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -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(getOperand(0)); + return static_cast(dyn_cast(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(getOperand(idx*2)); } // Methods for support type inquiry through isa, cast, and dyn_cast: diff --git a/include/llvm/Support/CallSite.h b/include/llvm/Support/CallSite.h index 9d393e050b6..e14caad642c 100644 --- a/include/llvm/Support/CallSite.h +++ b/include/llvm/Support/CallSite.h @@ -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(CI)) {} + CallSite(InvokeInst *II) : I(reinterpret_cast(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(V)) { if (I->getOpcode() == Instruction::Call) - return CallSite((CallInst*)I); + return CallSite(reinterpret_cast(I)); else if (I->getOpcode() == Instruction::Invoke) - return CallSite((InvokeInst*)I); + return CallSite(reinterpret_cast(I)); } return CallSite(); } diff --git a/include/llvm/SymbolTable.h b/include/llvm/SymbolTable.h index 4a4c70ee89c..04f009681c1 100644 --- a/include/llvm/SymbolTable.h +++ b/include/llvm/SymbolTable.h @@ -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 diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 889ae4067cb..9ae3b9a2890 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -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 { -- 2.34.1