From 294715b33e47d5d9f1e5be26d696f7d7a13d6de2 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Sun, 15 May 2005 16:13:11 +0000 Subject: 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. llvm-svn: 22057 --- llvm/include/llvm/Analysis/FindUsedTypes.h | 2 +- llvm/include/llvm/Analysis/LoopInfo.h | 5 +++-- llvm/include/llvm/Assembly/AsmAnnotationWriter.h | 2 ++ llvm/include/llvm/DerivedTypes.h | 4 ++-- llvm/include/llvm/Instructions.h | 4 ++-- llvm/include/llvm/Support/CallSite.h | 8 ++++---- llvm/include/llvm/SymbolTable.h | 2 +- llvm/lib/VMCore/AsmWriter.cpp | 3 +++ 8 files changed, 18 insertions(+), 12 deletions(-) diff --git a/llvm/include/llvm/Analysis/FindUsedTypes.h b/llvm/include/llvm/Analysis/FindUsedTypes.h index 0595dc3..5f2ef8e 100644 --- a/llvm/include/llvm/Analysis/FindUsedTypes.h +++ b/llvm/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/llvm/include/llvm/Analysis/LoopInfo.h b/llvm/include/llvm/Analysis/LoopInfo.h index acd739b..95626a4 100644 --- a/llvm/include/llvm/Analysis/LoopInfo.h +++ b/llvm/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/llvm/include/llvm/Assembly/AsmAnnotationWriter.h b/llvm/include/llvm/Assembly/AsmAnnotationWriter.h index 7f9556b..9ed285a 100644 --- a/llvm/include/llvm/Assembly/AsmAnnotationWriter.h +++ b/llvm/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/llvm/include/llvm/DerivedTypes.h b/llvm/include/llvm/DerivedTypes.h index a41bec8..22807f1 100644 --- a/llvm/include/llvm/DerivedTypes.h +++ b/llvm/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/llvm/include/llvm/Instructions.h b/llvm/include/llvm/Instructions.h index 264e8b64..904ca8f 100644 --- a/llvm/include/llvm/Instructions.h +++ b/llvm/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/llvm/include/llvm/Support/CallSite.h b/llvm/include/llvm/Support/CallSite.h index 9d393e0..e14caad 100644 --- a/llvm/include/llvm/Support/CallSite.h +++ b/llvm/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/llvm/include/llvm/SymbolTable.h b/llvm/include/llvm/SymbolTable.h index 4a4c70e..04f0096 100644 --- a/llvm/include/llvm/SymbolTable.h +++ b/llvm/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/llvm/lib/VMCore/AsmWriter.cpp b/llvm/lib/VMCore/AsmWriter.cpp index 889ae40..9ae3b9a 100644 --- a/llvm/lib/VMCore/AsmWriter.cpp +++ b/llvm/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 { -- cgit v1.1