Out << "!DIExpression(";
FieldSeparator FS;
if (N->isValid()) {
- for (auto I = N->expr_op_begin(), E = N->expr_op_end(); I != E; ++I) {
- auto OpStr = dwarf::OperationEncodingString(I->getOp());
+ for (const DIExpression::ExprOperand &Op : N->expr_ops()) {
+ auto OpStr = dwarf::OperationEncodingString(Op.getOp());
assert(!OpStr.empty() && "Expected valid opcode");
Out << FS << OpStr;
- if (I->getOp() == dwarf::DW_OP_LLVM_convert) {
- Out << FS << I->getArg(0);
- Out << FS << dwarf::AttributeEncodingString(I->getArg(1));
+ if (Op.getOp() == dwarf::DW_OP_LLVM_convert) {
+ Out << FS << Op.getArg(0);
+ Out << FS << dwarf::AttributeEncodingString(Op.getArg(1));
} else {
- for (unsigned A = 0, AE = I->getNumArgs(); A != AE; ++A)
- Out << FS << I->getArg(A);
+ for (unsigned A = 0, AE = Op.getNumArgs(); A != AE; ++A)
+ Out << FS << Op.getArg(A);
}
}
} else {
}
// Print the TypeIdMap entries.
- for (auto TidIter = TheIndex->typeIds().begin();
- TidIter != TheIndex->typeIds().end(); TidIter++) {
- Out << "^" << Machine.getTypeIdSlot(TidIter->second.first)
- << " = typeid: (name: \"" << TidIter->second.first << "\"";
- printTypeIdSummary(TidIter->second.second);
- Out << ") ; guid = " << TidIter->first << "\n";
+ for (const auto &TID : TheIndex->typeIds()) {
+ Out << "^" << Machine.getTypeIdSlot(TID.second.first)
+ << " = typeid: (name: \"" << TID.second.first << "\"";
+ printTypeIdSummary(TID.second.second);
+ Out << ") ; guid = " << TID.first << "\n";
}
// Print the TypeIdCompatibleVtableMap entries.
} else if (const ExtractValueInst *EVI = dyn_cast<ExtractValueInst>(&I)) {
Out << ' ';
writeOperand(I.getOperand(0), true);
- for (const unsigned *i = EVI->idx_begin(), *e = EVI->idx_end(); i != e; ++i)
- Out << ", " << *i;
+ for (unsigned i : EVI->indices())
+ Out << ", " << i;
} else if (const InsertValueInst *IVI = dyn_cast<InsertValueInst>(&I)) {
Out << ' ';
writeOperand(I.getOperand(0), true); Out << ", ";
if (Attrs != B.Attrs)
return false;
- for (td_const_iterator I = TargetDepAttrs.begin(),
- E = TargetDepAttrs.end(); I != E; ++I)
- if (B.TargetDepAttrs.find(I->first) == B.TargetDepAttrs.end())
+ for (const auto &TDA : TargetDepAttrs)
+ if (B.TargetDepAttrs.find(TDA.first) == B.TargetDepAttrs.end())
return false;
return Alignment == B.Alignment && StackAlignment == B.StackAlignment &&
// Cope with being called on a BasicBlock that doesn't have a terminator
// yet. Clang's CodeGenFunction::EmitReturnBlock() likes to do this.
return;
- llvm::for_each(successors(TI), [Old, New](BasicBlock *Succ) {
+ for (BasicBlock *Succ : successors(TI))
Succ->replacePhiUsesWith(Old, New);
- });
}
void BasicBlock::replaceSuccessorsPhiUsesWith(BasicBlock *New) {
void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest) {
FunctionType *Ty = unwrap<FunctionType>(FunctionTy);
- for (FunctionType::param_iterator I = Ty->param_begin(),
- E = Ty->param_end(); I != E; ++I)
- *Dest++ = wrap(*I);
+ for (Type *T : Ty->params())
+ *Dest++ = wrap(T);
}
/*--.. Operations on struct types ..........................................--*/
void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest) {
StructType *Ty = unwrap<StructType>(StructTy);
- for (StructType::element_iterator I = Ty->element_begin(),
- E = Ty->element_end(); I != E; ++I)
- *Dest++ = wrap(*I);
+ for (Type *T : Ty->elements())
+ *Dest++ = wrap(T);
}
LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i) {
void LLVMGetParams(LLVMValueRef FnRef, LLVMValueRef *ParamRefs) {
Function *Fn = unwrap<Function>(FnRef);
- for (Function::arg_iterator I = Fn->arg_begin(),
- E = Fn->arg_end(); I != E; I++)
- *ParamRefs++ = wrap(&*I);
+ for (Argument &A : Fn->args())
+ *ParamRefs++ = wrap(&A);
}
LLVMValueRef LLVMGetParam(LLVMValueRef FnRef, unsigned index) {
if (Locs.size() == 1)
return Locs[0];
auto *Merged = Locs[0];
- for (auto I = std::next(Locs.begin()), E = Locs.end(); I != E; ++I) {
- Merged = getMergedLocation(Merged, *I);
+ for (const DILocation *L : llvm::drop_begin(Locs)) {
+ Merged = getMergedLocation(Merged, L);
if (Merged == nullptr)
break;
}
// other predecessors. Since the only way out of X is via NormalDest, X can
// only properly dominate a node if NormalDest dominates that node too.
int IsDuplicateEdge = 0;
- for (const_pred_iterator PI = pred_begin(End), E = pred_end(End);
- PI != E; ++PI) {
- const BasicBlock *BB = *PI;
+ for (const BasicBlock *BB : predecessors(End)) {
if (BB == Start) {
// If there are multiple edges between Start and End, by definition they
// can't dominate anything.
assert(!Mask.empty() && "Shuffle mask must contain elements");
bool UsesLHS = false;
bool UsesRHS = false;
- for (int i = 0, NumMaskElts = Mask.size(); i < NumMaskElts; ++i) {
- if (Mask[i] == -1)
+ for (int I : Mask) {
+ if (I == -1)
continue;
- assert(Mask[i] >= 0 && Mask[i] < (NumOpElts * 2) &&
+ assert(I >= 0 && I < (NumOpElts * 2) &&
"Out-of-bounds shuffle mask element");
- UsesLHS |= (Mask[i] < NumOpElts);
- UsesRHS |= (Mask[i] >= NumOpElts);
+ UsesLHS |= (I < NumOpElts);
+ UsesRHS |= (I >= NumOpElts);
if (UsesLHS && UsesRHS)
return false;
}
// Check inherited analysis also. If P is not preserving analysis
// provided by parent manager then remove it here.
- for (unsigned Index = 0; Index < PMT_Last; ++Index) {
-
- if (!InheritedAnalysis[Index])
+ for (DenseMap<AnalysisID, Pass *> *IA : InheritedAnalysis) {
+ if (!IA)
continue;
- for (DenseMap<AnalysisID, Pass*>::iterator
- I = InheritedAnalysis[Index]->begin(),
- E = InheritedAnalysis[Index]->end(); I != E; ) {
+ for (DenseMap<AnalysisID, Pass *>::iterator I = IA->begin(),
+ E = IA->end();
+ I != E;) {
DenseMap<AnalysisID, Pass *>::iterator Info = I++;
if (Info->second->getAsImmutablePass() == nullptr &&
!is_contained(PreservedSet, Info->first)) {
dbgs() << " -- '" << P->getPassName() << "' is not preserving '";
dbgs() << S->getPassName() << "'\n";
}
- InheritedAnalysis[Index]->erase(Info);
+ IA->erase(Info);
}
}
}
const unsigned PtrSize = DL.getPointerSize();
- for (Function::const_arg_iterator AI = F->arg_begin(), AE = F->arg_end();
- AI != AE; ++AI) {
+ for (const Argument &A : F->args()) {
// 'Dereference' type in case of byval or inalloca parameter attribute.
- uint64_t AllocSize = AI->hasPassPointeeByValueCopyAttr() ?
- AI->getPassPointeeByValueCopySize(DL) :
- DL.getTypeAllocSize(AI->getType());
+ uint64_t AllocSize = A.hasPassPointeeByValueCopyAttr() ?
+ A.getPassPointeeByValueCopySize(DL) :
+ DL.getTypeAllocSize(A.getType());
// Size should be aligned to pointer size.
ArgWords += alignTo(AllocSize, PtrSize);