diff options
author | Duncan Sands <baldrick@free.fr> | 2010-02-16 11:11:14 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2010-02-16 11:11:14 +0000 |
commit | 1df9859c40492511b8aa4321eb76496005d3b75b (patch) | |
tree | 3e65bf258ff243ac3c149c418c7f201fbc9097d6 | |
parent | 30fb00aac02682cf1edef9f89b905621aa7a3c04 (diff) |
There are two ways of checking for a given type, for example isa<PointerType>(T)
and T->isPointerTy(). Convert most instances of the first form to the second form.
Requested by Chris.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96344 91177308-0d34-0410-b5e6-96231b3b80d8
70 files changed, 585 insertions, 581 deletions
diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index 1ae495fa25..d2f7404255 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -591,7 +591,7 @@ public: "Both operands to ICmp instruction are not of the same type!"); // Check that the operands are the right type assert((getOperand(0)->getType()->isIntOrIntVectorTy() || - isa<PointerType>(getOperand(0)->getType())) && + getOperand(0)->getType()->isPointerTy()) && "Invalid operand types for ICmp instruction"); } @@ -612,7 +612,7 @@ public: "Both operands to ICmp instruction are not of the same type!"); // Check that the operands are the right type assert((getOperand(0)->getType()->isIntOrIntVectorTy() || - isa<PointerType>(getOperand(0)->getType())) && + getOperand(0)->getType()->isPointerTy()) && "Invalid operand types for ICmp instruction"); } @@ -631,7 +631,7 @@ public: "Both operands to ICmp instruction are not of the same type!"); // Check that the operands are the right type assert((getOperand(0)->getType()->isIntOrIntVectorTy() || - isa<PointerType>(getOperand(0)->getType())) && + getOperand(0)->getType()->isPointerTy()) && "Invalid operand types for ICmp instruction"); } diff --git a/include/llvm/Type.h b/include/llvm/Type.h index c52419c869..8780db749d 100644 --- a/include/llvm/Type.h +++ b/include/llvm/Type.h @@ -243,6 +243,10 @@ public: /// bool isStructTy() const { return ID == StructTyID; } + /// isUnionTy - True if this is an instance of UnionType. + /// + bool isUnionTy() const { return ID == UnionTyID; } + /// isArrayTy - True if this is an instance of ArrayType. /// bool isArrayTy() const { return ID == ArrayTyID; } diff --git a/lib/Analysis/AliasAnalysisEvaluator.cpp b/lib/Analysis/AliasAnalysisEvaluator.cpp index 6b0a956a3e..308b9e3f64 100644 --- a/lib/Analysis/AliasAnalysisEvaluator.cpp +++ b/lib/Analysis/AliasAnalysisEvaluator.cpp @@ -115,11 +115,11 @@ bool AAEval::runOnFunction(Function &F) { SetVector<CallSite> CallSites; for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(); I != E; ++I) - if (isa<PointerType>(I->getType())) // Add all pointer arguments + if (I->getType()->isPointerTy()) // Add all pointer arguments Pointers.insert(I); for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) { - if (isa<PointerType>(I->getType())) // Add all pointer instructions + if (I->getType()->isPointerTy()) // Add all pointer instructions Pointers.insert(&*I); Instruction &Inst = *I; User::op_iterator OI = Inst.op_begin(); @@ -128,7 +128,7 @@ bool AAEval::runOnFunction(Function &F) { isa<Function>(CS.getCalledValue())) ++OI; // Skip actual functions for direct function calls. for (; OI != Inst.op_end(); ++OI) - if (isa<PointerType>((*OI)->getType()) && !isa<ConstantPointerNull>(*OI)) + if ((*OI)->getType()->isPointerTy() && !isa<ConstantPointerNull>(*OI)) Pointers.insert(*OI); if (CS.getInstruction()) CallSites.insert(CS); diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index 36b831c0ef..31a649d5cc 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -290,7 +290,7 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) { for (CallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end(); CI != CE; ++CI, ++ArgNo) { // Only look at the no-capture pointer arguments. - if (!isa<PointerType>((*CI)->getType()) || + if (!(*CI)->getType()->isPointerTy() || !CS.paramHasAttr(ArgNo+1, Attribute::NoCapture)) continue; @@ -662,7 +662,7 @@ BasicAliasAnalysis::aliasCheck(const Value *V1, unsigned V1Size, // Are we checking for alias of the same value? if (V1 == V2) return MustAlias; - if (!isa<PointerType>(V1->getType()) || !isa<PointerType>(V2->getType())) + if (!V1->getType()->isPointerTy() || !V2->getType()->isPointerTy()) return NoAlias; // Scalars cannot alias each other // Figure out what objects these things are pointing to if we can. diff --git a/lib/Analysis/CaptureTracking.cpp b/lib/Analysis/CaptureTracking.cpp index 10a8b1165d..8767c18141 100644 --- a/lib/Analysis/CaptureTracking.cpp +++ b/lib/Analysis/CaptureTracking.cpp @@ -44,7 +44,7 @@ static int const Threshold = 20; /// counts as capturing it or not. bool llvm::PointerMayBeCaptured(const Value *V, bool ReturnCaptures, bool StoreCaptures) { - assert(isa<PointerType>(V->getType()) && "Capture is for pointers only!"); + assert(V->getType()->isPointerTy() && "Capture is for pointers only!"); SmallVector<Use*, Threshold> Worklist; SmallSet<Use*, Threshold> Visited; int Count = 0; diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp index 808e6fa38c..6bab5eca20 100644 --- a/lib/Analysis/ConstantFolding.cpp +++ b/lib/Analysis/ConstantFolding.cpp @@ -359,7 +359,7 @@ static Constant *FoldReinterpretLoadFromConstPtr(Constant *C, MapTy = Type::getInt32PtrTy(C->getContext()); else if (LoadTy->isDoubleTy()) MapTy = Type::getInt64PtrTy(C->getContext()); - else if (isa<VectorType>(LoadTy)) { + else if (LoadTy->isVectorTy()) { MapTy = IntegerType::get(C->getContext(), TD.getTypeAllocSizeInBits(LoadTy)); MapTy = PointerType::getUnqual(MapTy); @@ -605,7 +605,7 @@ static Constant *SymbolicallyEvaluateGEP(Constant *const *Ops, unsigned NumOps, SmallVector<Constant*, 32> NewIdxs; do { if (const SequentialType *ATy = dyn_cast<SequentialType>(Ty)) { - if (isa<PointerType>(ATy)) { + if (ATy->isPointerTy()) { // The only pointer indexing we'll do is on the first index of the GEP. if (!NewIdxs.empty()) break; diff --git a/lib/Analysis/IPA/Andersens.cpp b/lib/Analysis/IPA/Andersens.cpp index 418020600d..2e35a56e7d 100644 --- a/lib/Analysis/IPA/Andersens.cpp +++ b/lib/Analysis/IPA/Andersens.cpp @@ -750,7 +750,7 @@ void Andersens::IdentifyObjects(Module &M) { // The function itself is a memory object. unsigned First = NumObjects; ValueNodes[F] = NumObjects++; - if (isa<PointerType>(F->getFunctionType()->getReturnType())) + if (F->getFunctionType()->getReturnType()->isPointerTy()) ReturnNodes[F] = NumObjects++; if (F->getFunctionType()->isVarArg()) VarargNodes[F] = NumObjects++; @@ -760,7 +760,7 @@ void Andersens::IdentifyObjects(Module &M) { for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I) { - if (isa<PointerType>(I->getType())) + if (I->getType()->isPointerTy()) ValueNodes[I] = NumObjects++; } MaxK[First] = NumObjects - First; @@ -771,7 +771,7 @@ void Andersens::IdentifyObjects(Module &M) { for (inst_iterator II = inst_begin(F), E = inst_end(F); II != E; ++II) { // If this is an heap or stack allocation, create a node for the memory // object. - if (isa<PointerType>(II->getType())) { + if (II->getType()->isPointerTy()) { ValueNodes[&*II] = NumObjects++; if (AllocaInst *AI = dyn_cast<AllocaInst>(&*II)) ObjectNodes[AI] = NumObjects++; @@ -801,7 +801,7 @@ void Andersens::IdentifyObjects(Module &M) { /// getNodeForConstantPointer - Return the node corresponding to the constant /// pointer itself. unsigned Andersens::getNodeForConstantPointer(Constant *C) { - assert(isa<PointerType>(C->getType()) && "Not a constant pointer!"); + assert(C->getType()->isPointerTy() && "Not a constant pointer!"); if (isa<ConstantPointerNull>(C) || isa<UndefValue>(C)) return NullPtr; @@ -828,7 +828,7 @@ unsigned Andersens::getNodeForConstantPointer(Constant *C) { /// getNodeForConstantPointerTarget - Return the node POINTED TO by the /// specified constant pointer. unsigned Andersens::getNodeForConstantPointerTarget(Constant *C) { - assert(isa<PointerType>(C->getType()) && "Not a constant pointer!"); + assert(C->getType()->isPointerTy() && "Not a constant pointer!"); if (isa<ConstantPointerNull>(C)) return NullObject; @@ -857,7 +857,7 @@ unsigned Andersens::getNodeForConstantPointerTarget(Constant *C) { void Andersens::AddGlobalInitializerConstraints(unsigned NodeIndex, Constant *C) { if (C->getType()->isSingleValueType()) { - if (isa<PointerType>(C->getType())) + if (C->getType()->isPointerTy()) Constraints.push_back(Constraint(Constraint::Copy, NodeIndex, getNodeForConstantPointer(C))); } else if (C->isNullValue()) { @@ -878,7 +878,7 @@ void Andersens::AddGlobalInitializerConstraints(unsigned NodeIndex, /// returned by this function. void Andersens::AddConstraintsForNonInternalLinkage(Function *F) { for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I) - if (isa<PointerType>(I->getType())) + if (I->getType()->isPointerTy()) // If this is an argument of an externally accessible function, the // incoming pointer might point to anything. Constraints.push_back(Constraint(Constraint::Copy, getNode(I), @@ -940,8 +940,8 @@ bool Andersens::AddConstraintsForExternalCall(CallSite CS, Function *F) { const FunctionType *FTy = F->getFunctionType(); if (FTy->getNumParams() > 1 && - isa<PointerType>(FTy->getParamType(0)) && - isa<PointerType>(FTy->getParamType(1))) { + FTy->getParamType(0)->isPointerTy() && + FTy->getParamType(1)->isPointerTy()) { // *Dest = *Src, which requires an artificial graph node to represent the // constraint. It is broken up into *Dest = temp, temp = *Src @@ -966,7 +966,7 @@ bool Andersens::AddConstraintsForExternalCall(CallSite CS, Function *F) { F->getName() == "strtok") { const FunctionType *FTy = F->getFunctionType(); if (FTy->getNumParams() > 0 && - isa<PointerType>(FTy->getParamType(0))) { + FTy->getParamType(0)->isPointerTy()) { Constraints.push_back(Constraint(Constraint::Copy, getNode(CS.getInstruction()), getNode(CS.getArgument(0)))); @@ -984,7 +984,7 @@ bool Andersens::AddConstraintsForExternalCall(CallSite CS, Function *F) { /// true. bool Andersens::AnalyzeUsesOfFunction(Value *V) { - if (!isa<PointerType>(V->getType())) return true; + if (!V->getType()->isPointerTy()) return true; for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E; ++UI) if (isa<LoadInst>(*UI)) { @@ -1063,7 +1063,7 @@ void Andersens::CollectConstraints(Module &M) { for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) { // Set up the return value node. - if (isa<PointerType>(F->getFunctionType()->getReturnType())) + if (F->getFunctionType()->getReturnType()->isPointerTy()) GraphNodes[getReturnNode(F)].setValue(F); if (F->getFunctionType()->isVarArg()) GraphNodes[getVarargNode(F)].setValue(F); @@ -1071,7 +1071,7 @@ void Andersens::CollectConstraints(Module &M) { // Set up incoming argument nodes. for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I) - if (isa<PointerType>(I->getType())) + if (I->getType()->isPointerTy()) getNodeValue(*I); // At some point we should just add constraints for the escaping functions @@ -1087,7 +1087,7 @@ void Andersens::CollectConstraints(Module &M) { visit(F); } else { // External functions that return pointers return the universal set. - if (isa<PointerType>(F->getFunctionType()->getReturnType())) + if (F->getFunctionType()->getReturnType()->isPointerTy()) Constraints.push_back(Constraint(Constraint::Copy, getReturnNode(F), UniversalSet)); @@ -1096,7 +1096,7 @@ void Andersens::CollectConstraints(Module &M) { // stored into them. for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I) - if (isa<PointerType>(I->getType())) { + if (I->getType()->isPointerTy()) { // Pointers passed into external functions could have anything stored // through them. Constraints.push_back(Constraint(Constraint::Store, getNode(I), @@ -1159,7 +1159,7 @@ void Andersens::visitAlloc(Instruction &I) { } void Andersens::visitReturnInst(ReturnInst &RI) { - if (RI.getNumOperands() && isa<PointerType>(RI.getOperand(0)->getType())) + if (RI.getNumOperands() && RI.getOperand(0)->getType()->isPointerTy()) // return V --> <Copy/retval{F}/v> Constraints.push_back(Constraint(Constraint::Copy, getReturnNode(RI.getParent()->getParent()), @@ -1167,14 +1167,14 @@ void Andersens::visitReturnInst(ReturnInst &RI) { } void Andersens::visitLoadInst(LoadInst &LI) { - if (isa<PointerType>(LI.getType())) + if (LI.getType()->isPointerTy()) // P1 = load P2 --> <Load/P1/P2> Constraints.push_back(Constraint(Constraint::Load, getNodeValue(LI), getNode(LI.getOperand(0)))); } void Andersens::visitStoreInst(StoreInst &SI) { - if (isa<PointerType>(SI.getOperand(0)->getType())) + if (SI.getOperand(0)->getType()->isPointerTy()) // store P1, P2 --> <Store/P2/P1> Constraints.push_back(Constraint(Constraint::Store, getNode(SI.getOperand(1)), @@ -1188,7 +1188,7 @@ void Andersens::visitGetElementPtrInst(GetElementPtrInst &GEP) { } void Andersens::visitPHINode(PHINode &PN) { - if (isa<PointerType>(PN.getType())) { + if (PN.getType()->isPointerTy()) { unsigned PNN = getNodeValue(PN); for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i) // P1 = phi P2, P3 --> <Copy/P1/P2>, <Copy/P1/P3>, ... @@ -1199,8 +1199,8 @@ void Andersens::visitPHINode(PHINode &PN) { void Andersens::visitCastInst(CastInst &CI) { Value *Op = CI.getOperand(0); - if (isa<PointerType>(CI.getType())) { - if (isa<PointerType>(Op->getType())) { + if (CI.getType()->isPointerTy()) { + if (Op->getType()->isPointerTy()) { // P1 = cast P2 --> <Copy/P1/P2> Constraints.push_back(Constraint(Constraint::Copy, getNodeValue(CI), getNode(CI.getOperand(0)))); @@ -1213,7 +1213,7 @@ void Andersens::visitCastInst(CastInst &CI) { getNodeValue(CI); #endif } - } else if (isa<PointerType>(Op->getType())) { + } else if (Op->getType()->isPointerTy()) { // int = cast P1 --> <Copy/Univ/P1> #if 0 Constraints.push_back(Constraint(Constraint::Copy, @@ -1226,7 +1226,7 @@ void Andersens::visitCastInst(CastInst &CI) { } void Andersens::visitSelectInst(SelectInst &SI) { - if (isa<PointerType>(SI.getType())) { + if (SI.getType()->isPointerTy()) { unsigned SIN = getNodeValue(SI); // P1 = select C, P2, P3 ---> <Copy/P1/P2>, <Copy/P1/P3> Constraints.push_back(Constraint(Constraint::Copy, SIN, @@ -1254,9 +1254,9 @@ void Andersens::AddConstraintsForCall(CallSite CS, Function *F) { if (F && F->isDeclaration() && AddConstraintsForExternalCall(CS, F)) return; - if (isa<PointerType>(CS.getType())) { + if (CS.getType()->isPointerTy()) { unsigned CSN = getNode(CS.getInstruction()); - if (!F || isa<PointerType>(F->getFunctionType()->getReturnType())) { + if (!F || F->getFunctionType()->getReturnType()->isPointerTy()) { if (IsDeref) Constraints.push_back(Constraint(Constraint::Load, CSN, getNode(CallValue), CallReturnPos)); @@ -1269,7 +1269,7 @@ void Andersens::AddConstraintsForCall(CallSite CS, Function *F) { Constraints.push_back(Constraint(Constraint::Copy, CSN, UniversalSet)); } - } else if (F && isa<PointerType>(F->getFunctionType()->getReturnType())) { + } else if (F && F->getFunctionType()->getReturnType()->isPointerTy()) { #if FULL_UNIVERSAL Constraints.push_back(Constraint(Constraint::Copy, UniversalSet, @@ -1291,7 +1291,7 @@ void Andersens::AddConstraintsForCall(CallSite CS, Function *F) { for (; AI != AE && ArgI != ArgE; ++AI, ++ArgI) { #if !FULL_UNIVERSAL - if (external && isa<PointerType>((*ArgI)->getType())) + if (external && (*ArgI)->getType()->isPointerTy()) { // Add constraint that ArgI can now point to anything due to // escaping, as can everything it points to. The second portion of @@ -1301,8 +1301,8 @@ void Andersens::AddConstraintsForCall(CallSite CS, Function *F) { UniversalSet)); } #endif - if (isa<PointerType>(AI->getType())) { - if (isa<PointerType>((*ArgI)->getType())) { + if (AI->getType()->isPointerTy()) { + if ((*ArgI)->getType()->isPointerTy()) { // Copy the actual argument into the formal argument. Constraints.push_back(Constraint(Constraint::Copy, getNode(AI), getNode(*ArgI))); @@ -1310,7 +1310,7 @@ void Andersens::AddConstraintsForCall(CallSite CS, Function *F) { Constraints.push_back(Constraint(Constraint::Copy, getNode(AI), UniversalSet)); } - } else if (isa<PointerType>((*ArgI)->getType())) { + } else if ((*ArgI)->getType()->isPointerTy()) { #if FULL_UNIVERSAL Constraints.push_back(Constraint(Constraint::Copy, UniversalSet, @@ -1326,7 + |