aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Analysis')
-rw-r--r--lib/Analysis/Expressions.cpp10
-rw-r--r--lib/Analysis/IPA/CallGraph.cpp4
-rw-r--r--lib/Analysis/ModuleAnalyzer.cpp2
3 files changed, 7 insertions, 9 deletions
diff --git a/lib/Analysis/Expressions.cpp b/lib/Analysis/Expressions.cpp
index cb83d41236..abe2a18b94 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 b1a272f032..87dbf2b425 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 8212287962..d543216349 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)