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
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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)