diff options
author | Chris Lattner <sabre@nondot.org> | 2001-10-02 03:41:24 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-10-02 03:41:24 +0000 |
commit | b00c582b6d40e6b9ff2d1ed4f5eaf7930e792ace (patch) | |
tree | 44b5f879c16e7ecb2e9334ad120e3454270e1bb3 /lib | |
parent | 1d87bcf4909b06dcd86320722653341f08b8b396 (diff) | |
download | external_llvm-b00c582b6d40e6b9ff2d1ed4f5eaf7930e792ace.zip external_llvm-b00c582b6d40e6b9ff2d1ed4f5eaf7930e792ace.tar.gz external_llvm-b00c582b6d40e6b9ff2d1ed4f5eaf7930e792ace.tar.bz2 |
Commit more code over to new cast style
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@697 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
25 files changed, 127 insertions, 133 deletions
diff --git a/lib/Analysis/Expressions.cpp b/lib/Analysis/Expressions.cpp index cb83d41..abe2a18 100644 --- a/lib/Analysis/Expressions.cpp +++ b/lib/Analysis/Expressions.cpp @@ -97,7 +97,7 @@ static const ConstPoolInt *Add(const ConstPoolInt *Arg1, ConstPoolVal *Result = *Arg1 + *Arg2; assert(Result && Result->getType() == Arg1->getType() && "Couldn't perform addition!"); - ConstPoolInt *ResultI = (ConstPoolInt*)Result; + ConstPoolInt *ResultI = cast<ConstPoolInt>(Result); // Check to see if the result is one of the special cases that we want to // recognize... @@ -147,7 +147,7 @@ inline const ConstPoolInt *Mul(const ConstPoolInt *Arg1, ConstPoolVal *Result = *Arg1 * *Arg2; assert(Result && Result->getType() == Arg1->getType() && "Couldn't perform mult!"); - ConstPoolInt *ResultI = (ConstPoolInt*)Result; + ConstPoolInt *ResultI = cast<ConstPoolInt>(Result); // Check to see if the result is one of the special cases that we want to // recognize... @@ -203,7 +203,7 @@ static inline ExprType negate(const ExprType &E, Value *V) { const Type *ETy = E.getExprType(Ty); ConstPoolInt *Zero = getUnsignedConstant(0, ETy); ConstPoolInt *One = getUnsignedConstant(1, ETy); - ConstPoolInt *NegOne = (ConstPoolInt*)(*Zero - *One); + ConstPoolInt *NegOne = cast<ConstPoolInt>(*Zero - *One); if (NegOne == 0) return V; // Couldn't subtract values... return ExprType(DefOne (E.Scale , Ty) * NegOne, E.Var, @@ -230,7 +230,7 @@ ExprType analysis::ClassifyExpression(Value *Expr) { case Value::ConstantVal: // Constant value, just return constant ConstPoolVal *CPV = cast<ConstPoolVal>(Expr); if (CPV->getType()->isIntegral()) { // It's an integral constant! - ConstPoolInt *CPI = (ConstPoolInt*)Expr; + ConstPoolInt *CPI = cast<ConstPoolInt>(Expr); return ExprType(CPI->equalsInt(0) ? 0 : CPI); } return Expr; @@ -297,7 +297,7 @@ ExprType analysis::ClassifyExpression(Value *Expr) { const ConstPoolVal *CPV =ConstRules::get(*Offs)->castTo(Offs, DestTy); if (!CPV) return I; assert(CPV->getType()->isIntegral() && "Must have an integral type!"); - return (ConstPoolInt*)CPV; + return cast<ConstPoolInt>(CPV); } // end case Instruction::Cast // TODO: Handle SUB, SHR? diff --git a/lib/Analysis/IPA/CallGraph.cpp b/lib/Analysis/IPA/CallGraph.cpp index b1a272f..87dbf2b 100644 --- a/lib/Analysis/IPA/CallGraph.cpp +++ b/lib/Analysis/IPA/CallGraph.cpp @@ -38,10 +38,8 @@ void CallGraph::addToCallGraph(Method *M) { for (Method::inst_iterator II = M->inst_begin(), IE = M->inst_end(); II != IE; ++II) { - if (II->getOpcode() == Instruction::Call) { - CallInst *CI = (CallInst*)*II; + if (CallInst *CI = dyn_cast<CallInst>(*II)) Node->addCalledMethod(getNodeFor(CI->getCalledMethod())); - } } } diff --git a/lib/Analysis/ModuleAnalyzer.cpp b/lib/Analysis/ModuleAnalyzer.cpp index 8212287..d543216 100644 --- a/lib/Analysis/ModuleAnalyzer.cpp +++ b/lib/Analysis/ModuleAnalyzer.cpp @@ -46,7 +46,7 @@ inline bool ModuleAnalyzer::handleType(set<const Type *> &TypeSet, break; case Type::StructTyID: { - const StructType *ST = (const StructType*)T; + const StructType *ST = cast<const StructType>(T); const StructType::ElementTypes &Elements = ST->getElementTypes(); for (StructType::ElementTypes::const_iterator I = Elements.begin(); I != Elements.end(); ++I) diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index 819f962..a0c9673 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -397,10 +397,9 @@ static void setValueName(Value *V, char *NameStr) { // There is only one case where this is allowed: when we are refining an // opaque type. In this case, Existing will be an opaque type. if (const Type *Ty = cast<const Type>(Existing)) - if (Ty->isOpaqueType()) { + if (OpaqueType *OpTy = dyn_cast<OpaqueType>(Ty)) { // We ARE replacing an opaque type! - - cast<DerivedType>(Ty)->refineAbstractTypeTo(cast<Type>(V)); + OpTy->refineAbstractTypeTo(cast<Type>(V)); return; } @@ -1232,7 +1231,7 @@ InstVal : BinaryOps Types ValueRef ',' ValueRef { while ($2->begin() != $2->end()) { if ($2->front().first->getType() != Ty) ThrowException("All elements of a PHI node must be of the same type!"); - ((PHINode*)$$)->addIncoming($2->front().first, $2->front().second); + cast<PHINode>($$)->addIncoming($2->front().first, $2->front().second); $2->pop_front(); } delete $2; // Free the list... @@ -1291,7 +1290,7 @@ MemoryInst : MALLOC Types { delete $2; } | MALLOC Types ',' UINT ValueRef { - if (!(*$2)->isArrayType() || ((const ArrayType*)$2->get())->isSized()) + if (!(*$2)->isArrayType() || cast<const ArrayType>($2->get())->isSized()) ThrowException("Trying to allocate " + (*$2)->getName() + " as unsized array!"); const Type *Ty = PointerType::get(*$2); @@ -1303,7 +1302,7 @@ MemoryInst : MALLOC Types { delete $2; } | ALLOCA Types ',' UINT ValueRef { - if (!(*$2)->isArrayType() || ((const ArrayType*)$2->get())->isSized()) + if (!(*$2)->isArrayType() || cast<const ArrayType>($2->get())->isSized()) ThrowException("Trying to allocate " + (*$2)->getName() + " as unsized array!"); const Type *Ty = PointerType::get(*$2); diff --git a/lib/Bytecode/Reader/ConstantReader.cpp b/lib/Bytecode/Reader/ConstantReader.cpp index aaecedd..4c7f7c9 100644 --- a/lib/Bytecode/Reader/ConstantReader.cpp +++ b/lib/Bytecode/Reader/ConstantReader.cpp @@ -229,7 +229,7 @@ bool BytecodeParser::parseConstPoolValue(const uchar *&Buf, abort(); case Type::ArrayTyID: { - const ArrayType *AT = (const ArrayType*)Ty; + const ArrayType *AT = cast<const ArrayType>(Ty); unsigned NumElements; if (AT->isSized()) // Sized array, # elements stored in type! NumElements = (unsigned)AT->getNumElements(); @@ -249,7 +249,7 @@ bool BytecodeParser::parseConstPoolValue(const uchar *&Buf, } case Type::StructTyID: { - const StructType *ST = Ty->castStructType(); + const StructType *ST = cast<StructType>(Ty); const StructType::ElementTypes &ET = ST->getElementTypes(); vector<ConstPoolVal *> Elements; @@ -267,7 +267,7 @@ bool BytecodeParser::parseConstPoolValue(const uchar *&Buf, } case Type::PointerTyID: { - const PointerType *PT = Ty->castPointerType(); + const PointerType *PT = cast<const PointerType>(Ty); unsigned SubClass; if (read_vbr(Buf, EndBuf, SubClass)) return failure(true); if (SubClass != 0) return failure(true); diff --git a/lib/Bytecode/Reader/InstructionReader.cpp b/lib/Bytecode/Reader/InstructionReader.cpp index 300c409..b6eec66 100644 --- a/lib/Bytecode/Reader/InstructionReader.cpp +++ b/lib/Bytecode/Reader/InstructionReader.cpp @@ -122,11 +122,11 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf, delete PN; return failure(true); case 2: PN->addIncoming(getValue(Raw.Ty, Raw.Arg1), - (BasicBlock*)getValue(Type::LabelTy, Raw.Arg2)); + cast<BasicBlock>(getValue(Type::LabelTy,Raw.Arg2))); break; default: PN->addIncoming(getValue(Raw.Ty, Raw.Arg1), - (BasicBlock*)getValue(Type::LabelTy, Raw.Arg2)); + cast<BasicBlock>(getValue(Type::LabelTy, Raw.Arg2))); if (Raw.VarArgs->size() & 1) { cerr << "PHI Node with ODD number of arguments!\n"; delete PN; @@ -135,7 +135,7 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf, vector<unsigned> &args = *Raw.VarArgs; for (unsigned i = 0; i < args.size(); i+=2) PN->addIncoming(getValue(Raw.Ty, args[i]), - (BasicBlock*)getValue(Type::LabelTy, args[i+1])); + cast<BasicBlock>(getValue(Type::LabelTy, args[i+1]))); } delete Raw.VarArgs; break; @@ -160,12 +160,12 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf, case Instruction::Br: if (Raw.NumOperands == 1) { - Res = new BranchInst((BasicBlock*)getValue(Type::LabelTy, Raw.Arg1)); + Res = new BranchInst(cast<BasicBlock>(getValue(Type::LabelTy, Raw.Arg1))); return false; } else if (Raw.NumOperands == 3) { - Res = new BranchInst((BasicBlock*)getValue(Type::LabelTy, Raw.Arg1), - (BasicBlock*)getValue(Type::LabelTy, Raw.Arg2), - getValue(Type::BoolTy , Raw.Arg3)); + Res = new BranchInst(cast<BasicBlock>(getValue(Type::LabelTy, Raw.Arg1)), + cast<BasicBlock>(getValue(Type::LabelTy, Raw.Arg2)), + getValue(Type::BoolTy , Raw.Arg3)); return false; } break; @@ -173,7 +173,7 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf, case Instruction::Switch: { SwitchInst *I = new SwitchInst(getValue(Raw.Ty, Raw.Arg1), - (BasicBlock*)getValue(Type::LabelTy, Raw.Arg2)); + cast<BasicBlock>(getValue(Type::LabelTy, Raw.Arg2))); Res = I; if (Raw.NumOperands < 3) return false; // No destinations? Wierd. @@ -185,15 +185,15 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf, vector<unsigned> &args = *Raw.VarArgs; for (unsigned i = 0; i < args.size(); i += 2) - I->dest_push_back((ConstPoolVal*)getValue(Raw.Ty, args[i]), - (BasicBlock*)getValue(Type::LabelTy, args[i+1])); + I->dest_push_back(cast<ConstPoolVal>(getValue(Raw.Ty, args[i])), + cast<BasicBlock>(getValue(Type::LabelTy, args[i+1]))); delete Raw.VarArgs; return false; } case Instruction::Call: { - Method *M = (Method*)getValue(Raw.Ty, Raw.Arg1); + Method *M = cast<Method>(getValue(Raw.Ty, Raw.Arg1)); if (M == 0) return failure(true); vector<Value *> Params; diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index 0e48830..14e89e2 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -338,7 +338,7 @@ bool BytecodeParser::ParseModuleGlobalInfo(const uchar *&Buf, const uchar *End, unsigned InitSlot; if (read_vbr(Buf, End, InitSlot)) return failure(true); - Value *V = getValue(Ty->castPointerType()->getValueType(), + Value *V = getValue(cast<const PointerType>(Ty)->getValueType(), InitSlot, false); if (V == 0) return failure(true); Initializer = cast<ConstPoolVal>(V); @@ -382,7 +382,7 @@ bool BytecodeParser::ParseModuleGlobalInfo(const uchar *&Buf, const uchar *End, // Keep track of this information in a linked list that is emptied as // methods are loaded... // - MethodSignatureList.push_back(make_pair((const MethodType*)Ty, SlotNo)); + MethodSignatureList.push_back(make_pair(cast<const MethodType>(Ty),SlotNo)); if (read_vbr(Buf, End, MethSignature)) return failure(true); BCR_TRACE(2, "Method of type: " << Ty << endl); } diff --git a/lib/Bytecode/Writer/ConstantWriter.cpp b/lib/Bytecode/Writer/ConstantWriter.cpp index dde47d5..d0c58f1 100644 --- a/lib/Bytecode/Writer/ConstantWriter.cpp +++ b/lib/Bytecode/Writer/ConstantWriter.cpp @@ -23,7 +23,7 @@ void BytecodeWriter::outputType(const Type *T) { switch (T->getPrimitiveID()) { // Handle derived types now. case Type::MethodTyID: { - const MethodType *MT = (const MethodType*)T; + const MethodType *MT = cast<const MethodType>(T); int Slot = Table.getValSlot(MT->getReturnType()); assert(Slot != -1 && "Type used but not available!!"); output_vbr((unsigned)Slot, Out); @@ -46,7 +46,7 @@ void BytecodeWriter::outputType(const Type *T) { } case Type::ArrayTyID: { - const ArrayType *AT = (const ArrayType*)T; + const ArrayType *AT = cast<const ArrayType>(T); int Slot = Table.getValSlot(AT->getElementType()); assert(Slot != -1 && "Type used but not available!!"); output_vbr((unsigned)Slot, Out); @@ -57,7 +57,7 @@ void BytecodeWriter::outputType(const Type *T) { } case Type::StructTyID: { - const StructType *ST = (const StructType*)T; + const StructType *ST = cast<const StructType>(T); // Output all of the element types... StructType::ElementTypes::const_iterator I = ST->getElementTypes().begin(); @@ -73,7 +73,7 @@ void BytecodeWriter::outputType(const Type *T) { } case Type::PointerTyID: { - const PointerType *PT = (const PointerType*)T; + const PointerType *PT = cast<const PointerType>(T); int Slot = Table.getValSlot(PT->getValueType()); assert(Slot != -1 && "Type used but not available!!"); output_vbr((unsigned)Slot, Out); @@ -91,7 +91,7 @@ void BytecodeWriter::outputType(const Type *T) { bool BytecodeWriter::outputConstant(const ConstPoolVal *CPV) { switch (CPV->getType()->getPrimitiveID()) { case Type::BoolTyID: // Boolean Types - if (((const ConstPoolBool*)CPV)->getValue()) + if (cast<const ConstPoolBool>(CPV)->getValue()) output_vbr((unsigned)1, Out); else output_vbr((unsigned)0, Out); diff --git a/lib/CodeGen/InstrSched/SchedGraph.cpp b/lib/CodeGen/InstrSched/SchedGraph.cpp index 852c4f2..fd09e9e 100644 --- a/lib/CodeGen/InstrSched/SchedGraph.cpp +++ b/lib/CodeGen/InstrSched/SchedGraph.cpp @@ -21,6 +21,7 @@ #include "llvm/Target/MachineInstrInfo.h" #include "llvm/Target/MachineRegInfo.h" #include "llvm/Support/StringExtras.h" +#include "llvm/iOther.h" #include <algorithm> @@ -540,7 +541,7 @@ SchedGraph::addSSAEdge(SchedGraphNode* node, // Phi instructions are the only ones that produce a value but don't get // any non-dummy machine instructions. Return here as an optimization. // - if (defVMInstr->isPHINode()) + if (isa<PHINode>(defVMInstr)) return; // Now add the graph edge for the appropriate machine instruction(s). @@ -642,7 +643,7 @@ void SchedGraph::addNonSSAEdgesForValue(const Instruction* instr, const TargetMachine& target) { - if (instr->isPHINode()) + if (isa<PHINode>(instr)) return; MachineCodeForVMInstr& mvec = instr->getMachineInstrVec(); diff --git a/lib/CodeGen/InstrSelection/InstrForest.cpp b/lib/CodeGen/InstrSelection/InstrForest.cpp index f5a5247..199ed65 100644 --- a/lib/CodeGen/InstrSelection/InstrForest.cpp +++ b/lib/CodeGen/InstrSelection/InstrForest.cpp @@ -26,6 +26,7 @@ #include "llvm/Method.h" #include "llvm/iTerminators.h" #include "llvm/iMemory.h" +#include "llvm/iOther.h" #include "llvm/ConstPoolVals.h" #include "llvm/BasicBlock.h" #include "llvm/CodeGen/MachineInstr.h" @@ -57,11 +58,11 @@ InstructionNode::InstructionNode(Instruction* I) // Distinguish special cases of some instructions such as Ret and Br // - if (opLabel == Instruction::Ret && ((ReturnInst*)I)->getReturnValue()) + if (opLabel == Instruction::Ret && cast<ReturnInst>(I)->getReturnValue()) { opLabel = RetValueOp; // ret(value) operation } - else if (opLabel == Instruction::Br && ! ((BranchInst*)I)->isUnconditional()) + else if (opLabel ==Instruction::Br && !cast<BranchInst>(I)->isUnconditional()) { opLabel = BrCondOp; // br(cond) operation } @@ -302,7 +303,7 @@ InstrForest::buildTreeForInstruction(Instruction *instr) InstrTreeNode* opTreeNode; if (isa<Instruction>(operand) && operand->use_size() == 1 && cast<Instruction>(operand)->getParent() == instr->getParent() && - ! instr->isPHINode() && + !isa<PHINode>(instr) && instr->getOpcode() != Instruction::Call) { // Recursively create a treeNode for it. diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp index d88d91f..34a80fe 100644 --- a/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -351,9 +351,9 @@ void Interpreter::executeAllocInst(AllocationInst *I, ExecutionContext &SF) { unsigned NumElements = 1; if (I->getNumOperands()) { // Allocating a unsized array type? - assert(Ty->isArrayType() && Ty->castArrayType()->isUnsized() && + assert(isa<ArrayType>(Ty) && cast<const ArrayType>(Ty)->isUnsized() && "Allocation inst with size operand for !unsized array type???"); - Ty = ((const ArrayType*)Ty)->getElementType(); // Get the actual type... + Ty = cast<const ArrayType>(Ty)->getElementType(); // Get the actual type... // Get the number of elements being allocated by the array... GenericValue NumEl = getOperandValue(I->getOperand(0), SF); @@ -665,16 +665,16 @@ bool Interpreter::executeInstruction() { // Memory Instructions case Instruction::Alloca: case Instruction::Malloc: executeAllocInst ((AllocationInst*)I, SF); break; - case Instruction::Free: executeFreeInst ((FreeInst*) I, SF); break; - case Instruction::Load: executeLoadInst ((LoadInst*) I, SF); break; - case Instruction::Store: executeStoreInst ((StoreInst*) I, SF); break; + case Instruction::Free: executeFreeInst (cast<FreeInst> (I), SF); break; + case Instruction::Load: executeLoadInst (cast<LoadInst> (I), SF); break; + case Instruction::Store: executeStoreInst (cast<StoreInst>(I), SF); break; // Miscellaneous Instructions - case Instruction::Call: executeCallInst ((CallInst*) I, SF); break; - case Instruction::PHINode: executePHINode ((PHINode*) I, SF); break; - case Instruction::Shl: executeShlInst ((ShiftInst*) I, SF); break; - case Instruction::Shr: executeShrInst ((ShiftInst*) I, SF); break; - case Instruction::Cast: executeCastInst ((CastInst*) I, SF); break; + case Instruction::Call: executeCallInst (cast<CallInst> (I), SF); break; + case Instruction::PHINode: executePHINode (cast<PHINode> (I), SF); break; + case Instruction::Shl: executeShlInst (cast<ShiftInst>(I), SF); break; + case Instruction::Shr: executeShrInst (cast<ShiftInst>(I), SF); break; + case Instruction::Cast: executeCastInst (cast<CastInst> (I), SF); break; default: cout << "Don't know how to execute this instruction!\n-->" << I; } diff --git a/lib/Target/SparcV9/InstrSched/SchedGraph.cpp b/lib/Target/SparcV9/InstrSched/SchedGraph.cpp index 852c4f2..fd09e9e 100644 --- a/lib/Target/SparcV9/InstrSched/SchedGraph.cpp +++ b/lib/Target/SparcV9/InstrSched/SchedGraph.cpp @@ -21,6 +21,7 @@ #include "llvm/Target/MachineInstrInfo.h" #include "llvm/Target/MachineRegInfo.h" #include "llvm/Support/StringExtras.h" +#include "llvm/iOther.h" #include <algorithm> @@ -540,7 +541,7 @@ SchedGraph::addSSAEdge(SchedGraphNode* node, // Phi instructions are the only ones that produce a value but don't get // any non-dummy machine instructions. Return here as an optimization. // - if (defVMInstr->isPHINode()) + if (isa<PHINode>(defVMInstr)) return; // Now add the graph edge for the appropriate machine instruction(s). @@ -642,7 +643,7 @@ void SchedGraph::addNonSSAEdgesForValue(const Instruction* instr, const TargetMachine& target) { - if (instr->isPHINode()) + if (isa<PHINode>(instr)) return; MachineCodeForVMInstr& mvec = instr->getMachineInstrVec(); diff --git a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp index f5a5247..199ed65 100644 --- a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp +++ b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp @@ -26,6 +26,7 @@ #include "llvm/Method.h" #include "llvm/iTerminators.h" #include "llvm/iMemory.h" +#include "llvm/iOther.h" #include "llvm/ConstPoolVals.h" #include "llvm/BasicBlock.h" #include "llvm/CodeGen/MachineInstr.h" @@ -57,11 +58,11 @@ InstructionNode::InstructionNode(Instruction* I) // Distinguish special cases of some instructions such as Ret and Br // - if (opLabel == Instruction::Ret && ((ReturnInst*)I)->getReturnValue()) + if (opLabel == Instruction::Ret && cast<ReturnInst>(I)->getReturnValue()) { opLabel = RetValueOp; // ret(value) operation } - else if (opLabel == Instruction::Br && ! ((BranchInst*)I)->isUnconditional()) + else if (opLabel ==Instruction::Br && !cast<BranchInst>(I)->isUnconditional()) { opLabel = BrCondOp; // br(cond) operation } @@ -302,7 +303,7 @@ InstrForest::buildTreeForInstruction(Instruction *instr) InstrTreeNode* opTreeNode; if (isa<Instruction>(operand) && operand->use_size() == 1 && cast<Instruction>(operand)->getParent() == instr->getParent() && - ! instr->isPHINode() && + !isa<PHINode>(instr) && instr->getOpcode() != Instruction::Call) { // Recursively create a treeNode for it. diff --git a/lib/Target/SparcV9/SparcV9InstrSelection.cpp b/lib/Target/SparcV9/SparcV9InstrSelection.cpp index b1b5e01..e4ae8a8 100644 --- a/lib/Target/SparcV9/SparcV9InstrSelection.cpp +++ b/lib/Target/SparcV9/SparcV9InstrSelection.cpp @@ -2010,9 +2010,8 @@ GetInstructionsByRule(InstructionNode* subtreeRoot, // Also, mark the operands of the Call as implicit operands // of the machine instruction. { - CallInst* callInstr = (CallInst*) subtreeRoot->getInstruction(); + CallInst *callInstr = cast<CallInst>(subtreeRoot->getInstruction()); Method* callee = callInstr->getCalledMethod(); - assert(callInstr->getOpcode() == Instruction::Call); Instruction* jmpAddrReg = new TmpInstruction(Instruction::UserOp1, callee, NULL); diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp index 24a5e85..0b4dc98 100644 --- a/lib/Target/TargetData.cpp +++ b/lib/Target/TargetData.cpp @@ -147,14 +147,14 @@ unsigned char TargetData::getTypeAlignment(const Type *Ty) const { unsigned TargetData::getIndexedOffset(const Type *ptrTy, const vector<ConstPoolVal*> &Idx) const { - const PointerType *PtrTy = ptrTy->castPointerType(); + const PointerType *PtrTy = cast<const PointerType>(ptrTy); unsigned Result = 0; // Get the type pointed to... const Type *Ty = PtrTy->getValueType(); for (unsigned CurIDX = 0; CurIDX < Idx.size(); ++CurIDX) { - if (const StructType *STy = Ty->dyncastStructType()) { + if (const StructType *STy = dyn_cast<const StructType>(Ty)) { assert(Idx[CurIDX]->getType() == Type::UByteTy && "Illegal struct idx"); unsigned FieldNo = ((ConstPoolUInt*)Idx[CurIDX++])->getValue(); @@ -168,7 +168,7 @@ unsigned TargetData::getIndexedOffset(const Type *ptrTy, // Update Ty to refer to current element Ty = STy->getElementTypes()[FieldNo]; - } else if (const ArrayType *ATy = Ty->dyncastArrayType()) { + } else if (const ArrayType *ATy = dyn_cast<const ArrayType>(Ty)) { assert(0 && "Loading from arrays not implemented yet!"); } else { assert(0 && "Indexing type that is not struct or array?"); diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp index 8bc0a77..c8afc27 100644 --- a/lib/Transforms/IPO/InlineSimple.cpp +++ b/lib/Transforms/IPO/InlineSimple.cpp @@ -63,12 +63,11 @@ static inline void RemapInstruction(Instruction *I, // method by one level. // bool opt::InlineMethod(BasicBlock::iterator CIIt) { - assert((*CIIt)->getOpcode() == Instruction::Call && - "InlineMethod only works on CallInst nodes!"); + assert(isa<CallInst>(*CIIt) && "InlineMethod only works on CallInst nodes!"); assert((*CIIt)->getParent() && "Instruction not embedded in basic block!"); assert((*CIIt)->getParent()->getParent() && "Instruction not in method!"); - CallInst *CI = (CallInst*)*CIIt; + CallInst *CI = cast<CallInst>(*CIIt); const Method *CalledMeth = CI->getCalledMethod(); if (CalledMeth->isExternal()) return false; // Can't inline external method! Method *CurrentMeth = CI->getParent()->getParent(); @@ -152,13 +151,13 @@ bool opt::InlineMethod(BasicBlock::iterator CIIt) { // Copy over the terminator now... switch (TI->getOpcode()) { case Instruction::Ret: { - const ReturnInst *RI = (const ReturnInst*)TI; + const ReturnInst *RI = cast<const ReturnInst>(TI); if (PHI) { // The PHI node should include this value! assert(RI->getReturnValue() && "Ret should have value!"); assert(RI->getReturnValue()->getType() == PHI->getType() && "Ret value not consistent in method!"); - PHI->addIncoming((Value*)RI->getReturnValue(), (BasicBlock*)BB); + PHI->addIncoming((Value*)RI->getReturnValue(), cast<BasicBlock>(BB)); } // Add a branch to the code that was after the original Call. @@ -236,9 +235,8 @@ static inline bool ShouldInlineMethod(const CallInst *CI, const Method *M) { static inline bool DoMethodInlining(BasicBlock *BB) { for (BasicBlock::iterator I = BB->begin(); I != BB->end(); ++I) { - if ((*I)->getOpcode() == Instruction::Call) { + if (CallInst *CI = dyn_cast<CallInst>(*I)) { // Check to see if we should inline this method - CallInst *CI = (CallInst*)*I; Method *M = CI->getCalledMethod(); if (ShouldInlineMethod(CI, M)) return InlineMethod(I); diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp index ea36745..18c851b 100644 --- a/lib/Transforms/Scalar/ADCE.cpp +++ b/lib/Transforms/Scalar/ADCE.cpp @@ -14,6 +14,7 @@ #include "llvm/Support/DepthFirstIterator.h" #include "llvm/Analysis/Writer.h" #include "llvm/iTerminators.h" +#include "llvm/iOther.h" #include <set> #include <algorithm> @@ -171,15 +172,15 @@ bool ADCE::doADCE() { set<BasicBlock*> VisitedBlocks; BasicBlock *EntryBlock = fixupCFG(M->front(), VisitedBlocks, AliveBlocks); if (EntryBlock && EntryBlock != M->front()) { - if (EntryBlock->front()->isPHINode()) { + if (isa<PHINode>(EntryBlock->front())) { // Cannot make the first block be a block with a PHI node in it! Instead, // strip the first basic block of the method to contain no instructions, // then add a simple branch to the "real" entry node... // BasicBlock *E = M->front(); - if (!E->front()->isTerminator() || // Check for an actual change... - ((TerminatorInst*)E->front())->getNumSuccessors() != 1 || - ((TerminatorInst*)E->front())->getSuccessor(0) != EntryBlock) { + if (!isa<TerminatorInst>(E->front()) || // Check for an actual change... + cast<TerminatorInst>(E->front())->getNumSuccessors() != 1 || + cast<TerminatorInst>(E->front())->getSuccessor(0) != EntryBlock) { E->getInstList().delete_all(); // Delete all instructions in block E->getInstList().push_back(new BranchInst(EntryBlock)); MadeChanges = true; diff --git a/lib/Transforms/Scalar/ConstantProp.cpp b/lib/Transforms/Scalar/ConstantProp.cpp index d43f693..61c026a 100644 --- a/lib/Transforms/Scalar/ConstantProp.cpp +++ b/lib/Transforms/Scalar/ConstantProp.cpp @@ -82,8 +82,7 @@ ConstantFoldBinaryInst(Method *M, Method::inst_iterator &DI, // bool opt::ConstantFoldTerminator(TerminatorInst *T) { // Branch - See if we are conditional jumping on constant - if (T->getOpcode() == Instruction::Br) { - BranchInst *BI = (BranchInst*)T; + if (BranchInst *BI = dyn_cast<BranchInst>(T)) { if (BI->isUnconditional()) return false; // Can't optimize uncond branch BasicBlock *Dest1 = cast<BasicBlock>(BI->getOperand(0)); BasicBlock *Dest2 = cast<BasicBlock>(BI->getOperand(1)); @@ -136,22 +135,22 @@ bool opt::ConstantFoldTerminator(TerminatorInst *T) { inline static bool ConstantFoldInstruction(Method *M, Method::inst_iterator &II) { Instruction *Inst = *II; - if (Inst->isBinaryOp()) { + if (BinaryOperator *BInst = dyn_cast<BinaryOperator>(Inst)) { ConstPoolVal *D1 = dyn_cast<ConstPoolVal>(Inst->getOperand(0)); ConstPoolVal *D2 = dyn_cast<ConstPoolVal>(Inst->getOperand(1)); if (D1 && D2) - return ConstantFoldBinaryInst(M, II, (BinaryOperator*)Inst, D1, D2); + return ConstantFoldBinaryInst(M, II, cast<BinaryOperator>(Inst), D1, D2); - } else if (Inst->isUnaryOp()) { - ConstPoolVal *D = dyn_cast<ConstPoolVal>(Inst->getOperand(0)); - if (D) return ConstantFoldUnaryInst(M, II, (UnaryOperator*)Inst, D); - } else if (Inst->isTerminator()) { - return opt::ConstantFoldTerminator((TerminatorInst*)Inst); + } else if (UnaryOperator *UInst = dyn_cast<UnaryOperator>(Inst)) { + ConstPoolVal *D = dyn_cast<ConstPoolVal>(UInst->getOperand(0)); + if (D) return ConstantFoldUnaryInst(M, II, UInst, D); + } else if (TerminatorInst *TInst = dyn_cast<TerminatorInst>(Inst)) { + return opt::ConstantFoldTerminator(TInst); - } else if (Inst->isPHINode()) { - PHINode *PN = (PHINode*)Inst; // If it's a PHI node and only has one operand - // Then replace it directly with that operand. + } else if (PHINode *PN = dyn_cast<PHINode>(Inst)) { + // If it's a PHI node and only has one operand + // Then replace it directly with that operand. assert(PN->getOperand(0) && "PHI Node must have at least one operand!"); if (PN->getNumOperands() == 1) { // If the PHI Node has exactly 1 operand Value *V = PN->getOperand(0); diff --git a/lib/Transforms/Scalar/DCE.cpp b/lib/Transforms/Scalar/DCE.cpp index ba3db99..10dcf1e 100644 --- a/lib/Transforms/Scalar/DCE.cpp +++ b/lib/Transforms/Scalar/DCE.cpp @@ -84,7 +84,7 @@ static bool RemoveSingularPHIs(BasicBlock *BB) { return false; // More than one predecessor... Instruction *I = BB->front(); - if (!I->isPHINode()) return false; // No PHI nodes + if (!isa<PHINode>(I)) return false; // No PHI nodes //cerr << "Killing PHIs from " << BB; //cerr << "Pred #0 = " << *BB->pred_begin(); @@ -92,7 +92,7 @@ static bool RemoveSingularPHIs(BasicBlock *BB) { //cerr << "Method == " << BB->getParent(); do { - PHINode *PN = (PHINode*)I; + PHINode *PN = cast<PHINode>(I); assert(PN->getNumOperands() == 2 && "PHI node should only have one value!"); Value *V = PN->getOperand(0); @@ -100,7 +100,7 @@ static bool RemoveSingularPHIs(BasicBlock *BB) { delete BB->getInstList().remove(BB->begin()); I = BB->front(); - } while (I->isPHINode()); + } while (isa<PHINode>(I)); return true; // Yes, we nuked at least one phi node } @@ -120,7 +120,7 @@ static void ReplaceUsesWithConstant(Instruction *I) { // Assumption: BB is the single predecessor of Succ. // static void PropogatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) { - assert(Succ->front()->isPHINode() && "Only works on PHId BBs!"); + assert(isa<PHINode>(Succ->front()) && "Only works on PHId BBs!"); // If there is more than one predecessor, and there are PHI nodes in // the successor, then we need to add incoming edges for the PHI nodes @@ -129,7 +129,7 @@ static void PropogatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) { BasicBlock::iterator I = Succ->begin(); do { // Loop over all of the PHI nodes in the successor BB - PHINode *PN = (PHINode*)*I; + PHINode *PN = cast<PHINode>(*I); Value *OldVal = PN->removeIncomingValue(BB); assert(OldVal && "No entry in PHI for Pred BB!"); @@ -140,7 +140,7 @@ static void PropogatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) { } ++I; - } while ((*I)->isPHINode()); + } while (isa<PHINode>(*I)); } @@ -198,7 +198,7 @@ bool opt::SimplifyCFG(Method::iterator &BBIt) { //cerr << "Killing Trivial BB: \n" << BB; if (Succ != BB) { // Arg, don't hurt infinite loops! - if (Succ->front()->isPHINode()) { + if (isa<PHINode>(Succ->front())) { // If our successor has PHI nodes, then we need to update them to // include entries for BB's predecessors, not for BB itself. // diff --git a/lib/Transforms/Scalar/InductionVars.cpp b/lib/Transforms/Scalar/InductionVars.cpp index f2dcb45..9a8eb12 100644 --- a/lib/Transforms/Scalar/InductionVars.cpp +++ b/lib/Transforms/Scalar/InductionVars.cpp @@ -41,7 +41,7 @@ static bool isLoopInvariant(cfg::Interval *Int, Value *V) { if (!isa<Instruction>(V)) return true; // Constants and arguments are always loop invariant - BasicBlock *ValueBlock = ((Instruction*)V)->getParent(); + BasicBlock *ValueBlock = cast<Instruction>(V)->getParent(); assert(ValueBlock && "Instruction not embedded in basic block!"); // For now, only consider values from outside of the interval, regardless of @@ -80,8 +80,8 @@ static LIVType isLinearInductionVariableH(cfg::Interval *Int, Value *V, switch (I->getOpcode()) { // Handle each instruction seperately case Instruction::Add: case Instruction::Sub: { - Value *SubV1 = ((BinaryOperator*)I)->getOperand(0); - Value *SubV2 = ((BinaryOperator*)I)->getOperand(1); + Value *SubV1 = cast<BinaryOperator>(I)->getOperand(0); + Value *SubV2 = cast<BinaryOperator>(I)->getOperand(1); LIVType SubLIVType1 = isLinearInductionVariableH(Int, SubV1, PN); if (SubLIVType1 == isOther) return isOther; // Early bailout LIVType SubLIVType2 = isLinearInductionVariableH(Int, SubV2, PN); @@ -144,12 +144,11 @@ static inline bool isSimpleInductionVar(PHINode *PN) { Value *StepExpr = PN->getIncomingValue(1); if (!isa<Instruction>(StepExpr) || - ((Instruction*)StepExpr)->getOpcode() != Instruction::Add) + cast<Instruction>(StepExpr)->getOpcode() != Instruction::Add) return false; - BinaryOperator *I = (BinaryOperator*)StepExpr; - assert(isa<Instruction>(I->getOperand(0)) && - ((Instruction*)I->getOperand(0))->isPHINode() && + BinaryOperator *I = cast<BinaryOperator>(StepExpr); + assert(isa<PHINode>(I->getOperand(0)) && "PHI node should be first operand of ADD instruction!"); // Get the right hand side of the ADD node. See if it is a constant 1. @@ -225,7 +224,7 @@ static PHINode *InjectSimpleInductionVariable(cfg::Interval *Int) { // Insert the Add instruction as the first (non-phi) instruction in the // header node's basic block. BasicBlock::iterator I = IL.begin(); - while ((*I)->isPHINode()) ++I; + while (isa<PHINode>(*I)) ++I; IL.insert(I, AddNode); return PN; } @@ -256,8 +255,8 @@ static bool ProcessInterval(cfg::Interval *Int) { BasicBlock *Header = Int->getHeaderNode(); // Loop over all of the PHI nodes in the interval header... for (BasicBlock::iterator I = Header->begin(), E = Header->end(); - I != E && (*I)->isPHINode(); ++I) { - PHINode *PN = (PHINode*)*I; + I != E && isa<PHINode>(*I); ++I) { + PHINode *PN = cast<PHINode>(*I); if (PN->getNumIncomingValues() != 2) { // These should be eliminated by now. cerr << "Found interval header with more than 2 predecessors! Ignoring\n"; return false; // Todo, make an assertion. diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index 91e002d..b92b54f 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -270,7 +270,7 @@ bool SCCP::doSCCP() { MadeChanges = true; continue; // Skip the ++II at the end of the loop here... } else if (Inst->isTerminator()) { - MadeChanges |= opt::ConstantFoldTerminator((TerminatorInst*)Inst); + MadeChanges |= opt::ConstantFoldTerminator(cast<TerminatorInst>(Inst)); } ++II; @@ -312,7 +312,7 @@ void SCCP::UpdateInstruction(Instruction *I) { // Handle PHI nodes... // case Instruction::PHINode: { - PHINode *PN = (PHINode*)I; + PHINode *PN = cast<PHINode>(I); unsigned NumValues = PN->getNumIncomingValues(), i; InstVal *OperandIV = 0; @@ -380,7 +380,7 @@ void SCCP::UpdateInstruction(Instruction *I) { // case Instruction::Ret: return; // Method return doesn't affect anything case Instruction::Br: { // Handle conditional branches... - BranchInst *BI = (BranchInst*)I; + BranchInst *BI = cast<BranchInst>(I); if (BI->isUnconditional()) return; // Unconditional branches are already handled! @@ -391,7 +391,7 @@ void SCCP::UpdateInstruction(Instruction *I) { markExecutable(BI->getSuccessor(1)); } else if (BCValue.isConstant()) { // Constant condition variables mean the branch can only go a single way. - ConstPoolBool *CPB = (ConstPoolBool*)BCValue.getConstant(); + ConstPoolBool *CPB = cast<ConstPoolBool>(BCValue.getConstant()); if (CPB->getValue()) // If the branch condition is TRUE... markExecutable(BI->getSuccessor(0)); else // Else if the br cond is FALSE... @@ -401,7 +401,7 @@ void SCCP::UpdateInstruction(Instruction *I) { } case Instruction::Switch: { - SwitchInst *SI = (SwitchInst*)I; + SwitchInst *SI = cast<SwitchInst>(I); InstVal &SCValue = getValueState(SI->getCondition()); if (SCValue.isOverdefined()) { // Overdefined condition? All dests are exe for(unsigned i = 0; BasicBlock *Succ = SI->getSuccessor(i); ++i) @@ -432,9 +432,9 @@ void SCCP::UpdateInstruction(Instruction *I) { // Also treated as unary here, are cast instructions and getelementptr // instructions on struct* operands. // - if (I->isUnaryOp() || I->getOpcode() == Instruction::Cast || - (I->getOpcode() == Instruction::GetElementPtr && - ((GetElementPtrInst*)I)->isStructSelector())) { + if (isa<UnaryOperator>(I) || isa<CastInst>(I) || + (isa<GetElementPtrInst>(I) && + cast<GetElementPtrInst>(I)->isStructSelector())) { Value *V = I->getOperand(0); InstVal &VState = getValueState(V); @@ -458,8 +458,7 @@ void SCCP::UpdateInstruction(Instruction *I) { //===-----------------------------------------------------------------===// // Handle Binary instructions... // - if (I->isBinaryOp() || I->getOpcode() == Instruction::Shl || - I->getOpcode() == Instruction::Shr) { + if (isa<BinaryOperator>(I) || isa<ShiftInst>(I)) { Value *V1 = I->getOperand(0); Value *V2 = I->getOperand(1); diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index b9a1c6d..d317bd7 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -192,7 +192,7 @@ void AssemblyWriter::processMethod(const Method *M) { // Finish printing arguments... - const MethodType *MT = (const MethodType*)M->getType(); + const MethodType *MT = cast<const MethodType>(M->getType()); if (MT->isVarArg()) { if (MT->getParamTypes().size()) Out << ", "; Out << "..."; // Output varargs portion of signature! @@ -287,7 +287,7 @@ void AssemblyWriter::processInstruction(const Instruction *I) { writeOperand(I->getOperand(op+1), true); } Out << "\n\t]"; - } else if (I->isPHINode()) { + } else if (isa<PHINode>(I)) { Out << " " << Operand->getType(); Out << " ["; writeOperand(Operand, false); Out << ","; @@ -311,7 +311,7 @@ void AssemblyWriter::processInstruction(const Instruction *I) { Out << " )"; } else if (I->getOpcode() == Instruction::Malloc || I->getOpcode() == Instruction::Alloca) { - Out << " " << ((const PointerType*)I->getType())->getValueType(); + Out << " " << cast<const PointerType>(I->getType())->getValueType(); if (I->getNumOperands()) { Out << ","; writeOperand(I->getOperand(0), true); diff --git a/lib/VMCore/BasicBlock.cpp b/lib/VMCore/BasicBlock.cpp index 81c1f11..462b98f 100644 --- a/lib/VMCore/BasicBlock.cpp +++ b/lib/VMCore/BasicBlock.cpp @@ -54,14 +54,14 @@ void BasicBlock::setParent(Method *parent) { TerminatorInst *BasicBlock::getTerminator() { if (InstList.empty()) return 0; Instruction *T = InstList.back(); - if (T->isTerminator()) return (TerminatorInst*)T; + if (isa<TerminatorInst>(T)) return cast<TerminatorInst>(T); return 0; } const TerminatorInst *const BasicBlock::getTerminator() const { if (InstList.empty()) return 0; - const Instruction *T = InstList.back(); - if (T->isTerminator()) return (TerminatorInst*)T; + if (const TerminatorInst *TI = dyn_cast<TerminatorInst>(InstList.back())) + return TI; return 0; } @@ -92,7 +92,7 @@ bool BasicBlock::hasConstantPoolReferences() const { void BasicBlock::removePredecessor(BasicBlock *Pred) { assert(find(pred_begin(), pred_end(), Pred) != pred_end() && "removePredecessor: BB is not a predecessor!"); - if (!front()->isPHINode()) return; // Quick exit. + if (!isa<PHINode>(front())) return; // Quick exit. pred_iterator PI(pred_begin()), EI(pred_end()); unsigned max_idx; @@ -105,8 +105,8 @@ void BasicBlock::removePredecessor(BasicBlock *Pred) { // altogether. assert(max_idx != 0 && "PHI Node in block with 0 predecessors!?!?!"); if (max_idx <= 2) { // <= Two predecessors BEFORE I remove one? - while (front()->isPHINode()) { // Yup, loop through and nuke the PHI nodes - PHINode *PN = (PHINode*)front(); + // Yup, loop through and nuke the PHI nodes + while (PHINode *PN = dyn_cast<PHINode>(front())) { PN->removeIncomingValue(Pred); // Remove the predecessor first... assert(PN->getNumIncomingValues() == max_idx-1 && @@ -121,10 +121,8 @@ void BasicBlock::removePredecessor(BasicBlock *Pred) { // Okay, now we know that we need to remove predecessor #pred_idx from all // PHI nodes. Iterate over each PHI node fixing them up iterator II(begin()); - for (; (*II)->isPHINode(); ++II) { - PHINode *PN = (PHINode*)*II; - PN->removeIncomingValue(Pred); - } + for (; isa<PHINode>(*II); ++II) + cast<PHINode>(*II)->removeIncomingValue(Pred); } } diff --git a/lib/VMCore/ConstPoolVals.cpp b/lib/VMCore/ConstPoolVals.cpp index bf538bd..f53c090 100644 --- a/lib/VMCore/ConstPoolVals.cpp +++ b/lib/VMCore/ConstPoolVals.cpp @@ -45,13 +45,13 @@ ConstPoolVal *ConstPoolVal::getNullConstant(const Type *Ty) { case Type::DoubleTyID: return ConstPoolFP::get(Ty, 0); case Type::PointerTyID: - return ConstPoolPointer::getNullPointer(Ty->castPointerType()); + return ConstPoolPointer::getNullPointer(cast<PointerType>(Ty)); default: return 0; } } -bool ConstPoolInt::isa(const ConstPoolVal *CPV) { +bool ConstPoolInt::classof(const ConstPoolVal *CPV) { return CPV->getType()->isIntegral(); } diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index 3b95fb7..a103b60 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -192,7 +192,7 @@ static string getTypeProps(const Type *Ty, vector<const Type *> &TypeStack, if (!Ty->isAbstract() && !Ty->isRecursive() && // Base case for the recursion Ty->getDescription().size()) { Result = Ty->getDescription(); // Primitive = leaf type - } else if (Ty->isOpaqueType()) { // Base case for the recursion + } else if (isa<OpaqueType>(Ty)) { // Base case for the recursion Result = Ty->getDescription(); // Opaque = leaf type isAbstract = true; // This whole type is abstract! } else { @@ -212,7 +212,7 @@ static string getTypeProps(const Type *Ty, vector<const Type *> &TypeStack, switch (Ty->getPrimitiveID()) { case Type::MethodTyID: { - const MethodType *MTy = (const MethodType*)Ty; + const MethodType *MTy = cast<const MethodType>(Ty); Result = getTypeProps(MTy->getReturnType(), TypeStack, isAbstract, isRecursive)+" ("; for (MethodType::ParamTypes::const_iterator @@ -230,7 +230,7 @@ static string getTypeProps(const Type *Ty, vector<const Type *> &TypeStack, break; } case Type::StructTyID: { - const StructType *STy = (const StructType*)Ty; + const StructType *STy = cast<const StructType>(Ty); Result = "{ "; for (StructType::ElementTypes::const_iterator I = STy->getElementTypes().begin(), @@ -243,13 +243,13 @@ static string getTypeProps(const Type *Ty, vector<const Type *> &TypeStack, break; } case Type::PointerTyID: { - const PointerType *PTy = (const PointerType*)Ty; + const PointerType *PTy = cast<const PointerType>(Ty); Result = getTypeProps(PTy->getValueType(), TypeStack, isAbstract, isRecursive) + " *"; break; } case Type::ArrayTyID: { - const ArrayType *ATy = (const ArrayType*)Ty; + const ArrayType *ATy = cast<const ArrayType>(Ty); int NumElements = ATy->getNumElements(); Result = "["; if (NumElements != -1) Result += itostr(NumElements) + " x "; @@ -319,8 +319,8 @@ static bool TypesEqual(const Type *Ty, const Type *Ty2, // algorithm is the fact that arraytypes have sizes that differentiates types, // consider this now. if (Ty->isArrayType()) - if (((const ArrayType*)Ty)->getNumElements() != - ((const ArrayType*)Ty2)->getNumElements()) return false; + if (cast<const ArrayType>(Ty)->getNumElements() != + cast<const ArrayType>(Ty2)->getNumElements()) return false; return I == IE && I2 == IE2; // Types equal if both iterators are done } |