Skip to content

Commit 294715b

Browse files
author
Reid Spencer
committed
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
1 parent b62a5f0 commit 294715b

File tree

8 files changed

+18
-12
lines changed

8 files changed

+18
-12
lines changed

llvm/include/llvm/Analysis/FindUsedTypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class FindUsedTypes : public ModulePass {
6060

6161
// Make sure that any clients of this file link in PostDominators.cpp
6262
static IncludeFile
63-
FIND_USED_TYPES_INCLUDE_FILE((void*)&FindUsedTypes::stub);
63+
FIND_USED_TYPES_INCLUDE_FILE(reinterpret_cast<void*>(&FindUsedTypes::stub));
6464

6565
} // End llvm namespace
6666

llvm/include/llvm/Analysis/LoopInfo.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ class LoopInfo : public FunctionPass {
230230
/// block is in no loop (for example the entry node), null is returned.
231231
///
232232
Loop *getLoopFor(const BasicBlock *BB) const {
233-
std::map<BasicBlock *, Loop*>::const_iterator I=BBMap.find((BasicBlock*)BB);
233+
std::map<BasicBlock *, Loop*>::const_iterator I=
234+
BBMap.find(const_cast<BasicBlock*>(BB));
234235
return I != BBMap.end() ? I->second : 0;
235236
}
236237

@@ -300,7 +301,7 @@ class LoopInfo : public FunctionPass {
300301

301302
// Make sure that any clients of this file link in LoopInfo.cpp
302303
static IncludeFile
303-
LOOP_INFO_INCLUDE_FILE((void*)&LoopInfo::stub);
304+
LOOP_INFO_INCLUDE_FILE(reinterpret_cast<void*>(&LoopInfo::stub));
304305

305306
// Allow clients to walk the list of nested loops...
306307
template <> struct GraphTraits<const Loop*> {

llvm/include/llvm/Assembly/AsmAnnotationWriter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class Instruction;
2727

2828
struct AssemblyAnnotationWriter {
2929

30+
virtual ~AssemblyAnnotationWriter();
31+
3032
// emitFunctionAnnot - This may be implemented to emit a string right before
3133
// the start of a function.
3234
virtual void emitFunctionAnnot(const Function *F, std::ostream &OS) {}

llvm/include/llvm/DerivedTypes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class FunctionType : public DerivedType {
141141
/// getNumParams - Return the number of fixed parameters this function type
142142
/// requires. This does not consider varargs.
143143
///
144-
unsigned getNumParams() const { return (unsigned)ContainedTys.size()-1; }
144+
unsigned getNumParams() const { return unsigned(ContainedTys.size()-1); }
145145

146146
// Implement the AbstractTypeUser interface.
147147
virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
@@ -207,7 +207,7 @@ class StructType : public CompositeType {
207207
element_iterator element_end() const { return ContainedTys.end(); }
208208

209209
// Random access to the elements
210-
unsigned getNumElements() const { return (unsigned)ContainedTys.size(); }
210+
unsigned getNumElements() const { return unsigned(ContainedTys.size()); }
211211
const Type *getElementType(unsigned N) const {
212212
assert(N < ContainedTys.size() && "Element number out of range!");
213213
return ContainedTys[N];

llvm/include/llvm/Instructions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ class CallInst : public Instruction {
519519
/// if it is a direct call. If it is a call through a function pointer,
520520
/// return null.
521521
Function *getCalledFunction() const {
522-
return (Function*)dyn_cast<Function>(getOperand(0));
522+
return static_cast<Function*>(dyn_cast<Function>(getOperand(0)));
523523
}
524524

525525
// getCalledValue - Get a pointer to a method that is invoked by this inst.
@@ -1153,7 +1153,7 @@ class SwitchInst : public TerminatorInst {
11531153
// successor.
11541154
inline ConstantInt *getSuccessorValue(unsigned idx) const {
11551155
assert(idx < getNumSuccessors() && "Successor # out of range!");
1156-
return (ConstantInt*)getOperand(idx*2);
1156+
return reinterpret_cast<ConstantInt*>(getOperand(idx*2));
11571157
}
11581158

11591159
// Methods for support type inquiry through isa, cast, and dyn_cast:

llvm/include/llvm/Support/CallSite.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class CallSite {
3232
Instruction *I;
3333
public:
3434
CallSite() : I(0) {}
35-
CallSite(CallInst *CI) : I((Instruction*)CI) {}
36-
CallSite(InvokeInst *II) : I((Instruction*)II) {}
35+
CallSite(CallInst *CI) : I(reinterpret_cast<Instruction*>(CI)) {}
36+
CallSite(InvokeInst *II) : I(reinterpret_cast<Instruction*>(II)) {}
3737
CallSite(const CallSite &CS) : I(CS.I) {}
3838
CallSite &operator=(const CallSite &CS) { I = CS.I; return *this; }
3939

@@ -45,9 +45,9 @@ class CallSite {
4545
static CallSite get(Value *V) {
4646
if (Instruction *I = dyn_cast<Instruction>(V)) {
4747
if (I->getOpcode() == Instruction::Call)
48-
return CallSite((CallInst*)I);
48+
return CallSite(reinterpret_cast<CallInst*>(I));
4949
else if (I->getOpcode() == Instruction::Invoke)
50-
return CallSite((InvokeInst*)I);
50+
return CallSite(reinterpret_cast<InvokeInst*>(I));
5151
}
5252
return CallSite();
5353
}

llvm/include/llvm/SymbolTable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class SymbolTable : public AbstractTypeUser {
108108
inline bool isEmpty() const { return pmap.empty() && tmap.empty(); }
109109

110110
/// @brief The number of name/type pairs is returned.
111-
inline unsigned num_types() const { return (unsigned)tmap.size(); }
111+
inline unsigned num_types() const { return unsigned(tmap.size()); }
112112

113113
/// Given a base name, return a string that is either equal to it or
114114
/// derived from it that does not already occur in the symbol table

llvm/lib/VMCore/AsmWriter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ using namespace llvm;
3434

3535
namespace llvm {
3636

37+
// Make virtual table appear in this compilation unit.
38+
AssemblyAnnotationWriter::~AssemblyAnnotationWriter() {}
39+
3740
/// This class provides computation of slot numbers for LLVM Assembly writing.
3841
/// @brief LLVM Assembly Writing Slot Computation.
3942
class SlotMachine {

0 commit comments

Comments
 (0)