forked from OSchip/llvm-project
Use llvm::append_range instead of push_back loops where applicable. NFCI.
This commit is contained in:
parent
964398ccb1
commit
5d2ce7663b
|
@ -7928,8 +7928,7 @@ AST_MATCHER_P(Stmt, forFunction, internal::Matcher<FunctionDecl>,
|
|||
return true;
|
||||
}
|
||||
} else {
|
||||
for (const auto &Parent : Finder->getASTContext().getParents(CurNode))
|
||||
Stack.push_back(Parent);
|
||||
llvm::append_range(Stack, Finder->getASTContext().getParents(CurNode));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -7987,8 +7986,7 @@ AST_MATCHER_P(Stmt, forCallable, internal::Matcher<Decl>, InnerMatcher) {
|
|||
return true;
|
||||
}
|
||||
} else {
|
||||
for (const auto &Parent : Finder->getASTContext().getParents(CurNode))
|
||||
Stack.push_back(Parent);
|
||||
llvm::append_range(Stack, Finder->getASTContext().getParents(CurNode));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -132,10 +132,7 @@ struct VariadicFunction {
|
|||
// We also allow calls with an already created array, in case the caller
|
||||
// already had it.
|
||||
ResultT operator()(ArrayRef<ArgT> Args) const {
|
||||
SmallVector<const ArgT*, 8> InnerArgs;
|
||||
for (const ArgT &Arg : Args)
|
||||
InnerArgs.push_back(&Arg);
|
||||
return Func(InnerArgs);
|
||||
return Func(llvm::to_vector<8>(llvm::make_pointer_range(Args)));
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -208,13 +208,7 @@ public:
|
|||
// The initial assumption is that there is only one clone group and every
|
||||
// statement is a clone of the others. This clone group will then be
|
||||
// split up with the help of the constraints.
|
||||
CloneGroup AllClones;
|
||||
AllClones.reserve(Sequences.size());
|
||||
for (const auto &C : Sequences) {
|
||||
AllClones.push_back(C);
|
||||
}
|
||||
|
||||
Result.push_back(AllClones);
|
||||
Result.push_back(Sequences);
|
||||
|
||||
constrainClones(Result, ConstraintList...);
|
||||
}
|
||||
|
|
|
@ -42,8 +42,7 @@ template <> struct MappingTraits<clang::tooling::DiagnosticMessage> {
|
|||
Io.mapOptional("FileOffset", M.FileOffset);
|
||||
std::vector<clang::tooling::Replacement> Fixes;
|
||||
for (auto &Replacements : M.Fix) {
|
||||
for (auto &Replacement : Replacements.second)
|
||||
Fixes.push_back(Replacement);
|
||||
llvm::append_range(Fixes, Replacements.second);
|
||||
}
|
||||
Io.mapRequired("Replacements", Fixes);
|
||||
for (auto &Fix : Fixes) {
|
||||
|
|
|
@ -739,8 +739,8 @@ canonicalizeImmediatelyDeclaredConstraint(const ASTContext &C, Expr *IDC,
|
|||
// template<typename... T> concept C = true;
|
||||
// template<C<int> T> struct S; -> constraint is C<{T, int}>
|
||||
NewConverted.push_back(ConstrainedType);
|
||||
for (auto &Arg : OldConverted.front().pack_elements().drop_front(1))
|
||||
NewConverted.push_back(Arg);
|
||||
llvm::append_range(NewConverted,
|
||||
OldConverted.front().pack_elements().drop_front(1));
|
||||
TemplateArgument NewPack(NewConverted);
|
||||
|
||||
NewConverted.clear();
|
||||
|
@ -752,8 +752,7 @@ canonicalizeImmediatelyDeclaredConstraint(const ASTContext &C, Expr *IDC,
|
|||
"Unexpected first argument kind for immediately-declared "
|
||||
"constraint");
|
||||
NewConverted.push_back(ConstrainedType);
|
||||
for (auto &Arg : OldConverted.drop_front(1))
|
||||
NewConverted.push_back(Arg);
|
||||
llvm::append_range(NewConverted, OldConverted.drop_front(1));
|
||||
}
|
||||
Expr *NewIDC = ConceptSpecializationExpr::Create(
|
||||
C, CSE->getNamedConcept(), NewConverted, nullptr,
|
||||
|
@ -2601,8 +2600,7 @@ void ASTContext::DeepCollectObjCIvars(const ObjCInterfaceDecl *OI,
|
|||
if (const ObjCInterfaceDecl *SuperClass = OI->getSuperClass())
|
||||
DeepCollectObjCIvars(SuperClass, false, Ivars);
|
||||
if (!leafClass) {
|
||||
for (const auto *I : OI->ivars())
|
||||
Ivars.push_back(I);
|
||||
llvm::append_range(Ivars, OI->ivars());
|
||||
} else {
|
||||
auto *IDecl = const_cast<ObjCInterfaceDecl *>(OI);
|
||||
for (const ObjCIvarDecl *Iv = IDecl->all_declared_ivar_begin(); Iv;
|
||||
|
|
|
@ -3385,10 +3385,8 @@ static bool rebucketPaths(VPtrInfoVector &Paths) {
|
|||
// sorted vector to implement a multiset to form the buckets. Note that the
|
||||
// ordering is based on pointers, but it doesn't change our output order. The
|
||||
// current algorithm is designed to match MSVC 2012's names.
|
||||
llvm::SmallVector<std::reference_wrapper<VPtrInfo>, 2> PathsSorted;
|
||||
PathsSorted.reserve(Paths.size());
|
||||
for (auto& P : Paths)
|
||||
PathsSorted.push_back(*P);
|
||||
llvm::SmallVector<std::reference_wrapper<VPtrInfo>, 2> PathsSorted(
|
||||
llvm::make_pointee_range(Paths));
|
||||
llvm::sort(PathsSorted, [](const VPtrInfo &LHS, const VPtrInfo &RHS) {
|
||||
return LHS.MangledPath < RHS.MangledPath;
|
||||
});
|
||||
|
|
|
@ -441,8 +441,7 @@ reverse_children::reverse_children(Stmt *S) {
|
|||
}
|
||||
|
||||
// Default case for all other statements.
|
||||
for (Stmt *SubStmt : S->children())
|
||||
childrenBuf.push_back(SubStmt);
|
||||
llvm::append_range(childrenBuf, S->children());
|
||||
|
||||
// This needs to be done *after* childrenBuf has been populated.
|
||||
children = childrenBuf;
|
||||
|
|
|
@ -1160,8 +1160,7 @@ llvm::Type *CodeGenModule::getGenericBlockLiteralType() {
|
|||
SmallVector<llvm::Type *, 8> StructFields(
|
||||
{IntTy, IntTy, getOpenCLRuntime().getGenericVoidPointerType()});
|
||||
if (auto *Helper = getTargetCodeGenInfo().getTargetOpenCLBlockHelper()) {
|
||||
for (auto I : Helper->getCustomFieldTypes())
|
||||
StructFields.push_back(I);
|
||||
llvm::append_range(StructFields, Helper->getCustomFieldTypes());
|
||||
}
|
||||
GenericBlockLiteralType = llvm::StructType::create(
|
||||
StructFields, "struct.__opencl_block_literal_generic");
|
||||
|
|
|
@ -942,8 +942,7 @@ getTypeExpansion(QualType Ty, const ASTContext &Context) {
|
|||
if (const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
|
||||
assert(!CXXRD->isDynamicClass() &&
|
||||
"cannot expand vtable pointers in dynamic classes");
|
||||
for (const CXXBaseSpecifier &BS : CXXRD->bases())
|
||||
Bases.push_back(&BS);
|
||||
llvm::append_range(Bases, llvm::make_pointer_range(CXXRD->bases()));
|
||||
}
|
||||
|
||||
for (const auto *FD : RD->fields()) {
|
||||
|
|
|
@ -315,8 +315,7 @@ static const CGFunctionInfo &getFunctionInfo(CodeGenModule &CGM,
|
|||
Ctx, nullptr, SourceLocation(), &Ctx.Idents.get(ValNameStr[I]), ParamTy,
|
||||
ImplicitParamDecl::Other));
|
||||
|
||||
for (auto &P : Params)
|
||||
Args.push_back(P);
|
||||
llvm::append_range(Args, Params);
|
||||
|
||||
return CGM.getTypes().arrangeBuiltinFunctionDeclaration(Ctx.VoidTy, Args);
|
||||
}
|
||||
|
|
|
@ -400,9 +400,7 @@ void CodeGenFunction::EmitMustTailThunk(GlobalDecl GD,
|
|||
// to translate AST arguments into LLVM IR arguments. For thunks, we know
|
||||
// that the caller prototype more or less matches the callee prototype with
|
||||
// the exception of 'this'.
|
||||
SmallVector<llvm::Value *, 8> Args;
|
||||
for (llvm::Argument &A : CurFn->args())
|
||||
Args.push_back(&A);
|
||||
SmallVector<llvm::Value *, 8> Args(llvm::make_pointer_range(CurFn->args()));
|
||||
|
||||
// Set the adjusted 'this' pointer.
|
||||
const ABIArgInfo &ThisAI = CurFnInfo->arg_begin()->info;
|
||||
|
|
|
@ -1409,8 +1409,7 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn,
|
|||
|
||||
// Save parameters for coroutine function.
|
||||
if (Body && isa_and_nonnull<CoroutineBodyStmt>(Body))
|
||||
for (const auto *ParamDecl : FD->parameters())
|
||||
FnArgs.push_back(ParamDecl);
|
||||
llvm::append_range(FnArgs, FD->parameters());
|
||||
|
||||
// Generate the body of the function.
|
||||
PGO.assignRegionCounters(GD, CurFn);
|
||||
|
@ -2626,9 +2625,8 @@ static void CreateMultiVersionResolverReturn(CodeGenModule &CGM,
|
|||
return;
|
||||
}
|
||||
|
||||
llvm::SmallVector<llvm::Value *, 10> Args;
|
||||
llvm::for_each(Resolver->args(),
|
||||
[&](llvm::Argument &Arg) { Args.push_back(&Arg); });
|
||||
llvm::SmallVector<llvm::Value *, 10> Args(
|
||||
llvm::make_pointer_range(Resolver->args()));
|
||||
|
||||
llvm::CallInst *Result = Builder.CreateCall(FuncToReturn, Args);
|
||||
Result->setTailCallKind(llvm::CallInst::TCK_MustTail);
|
||||
|
|
|
@ -2508,8 +2508,8 @@ void CodeGenModule::EmitDeferred() {
|
|||
// Note we should not clear CUDADeviceVarODRUsedByHost since it is still
|
||||
// needed for further handling.
|
||||
if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice)
|
||||
for (const auto *V : getContext().CUDADeviceVarODRUsedByHost)
|
||||
DeferredDeclsToEmit.push_back(V);
|
||||
llvm::append_range(DeferredDeclsToEmit,
|
||||
getContext().CUDADeviceVarODRUsedByHost);
|
||||
|
||||
// Stop if we're out of both deferred vtables and deferred declarations.
|
||||
if (DeferredDeclsToEmit.empty())
|
||||
|
|
|
@ -11463,21 +11463,17 @@ TargetCodeGenInfo::createEnqueuedBlockKernel(CodeGenFunction &CGF,
|
|||
llvm::Function *Invoke,
|
||||
llvm::Type *BlockTy) const {
|
||||
auto *InvokeFT = Invoke->getFunctionType();
|
||||
llvm::SmallVector<llvm::Type *, 2> ArgTys;
|
||||
for (auto &P : InvokeFT->params())
|
||||
ArgTys.push_back(P);
|
||||
auto &C = CGF.getLLVMContext();
|
||||
std::string Name = Invoke->getName().str() + "_kernel";
|
||||
auto *FT = llvm::FunctionType::get(llvm::Type::getVoidTy(C), ArgTys, false);
|
||||
auto *FT = llvm::FunctionType::get(llvm::Type::getVoidTy(C),
|
||||
InvokeFT->params(), false);
|
||||
auto *F = llvm::Function::Create(FT, llvm::GlobalValue::ExternalLinkage, Name,
|
||||
&CGF.CGM.getModule());
|
||||
auto IP = CGF.Builder.saveIP();
|
||||
auto *BB = llvm::BasicBlock::Create(C, "entry", F);
|
||||
auto &Builder = CGF.Builder;
|
||||
Builder.SetInsertPoint(BB);
|
||||
llvm::SmallVector<llvm::Value *, 2> Args;
|
||||
for (auto &A : F->args())
|
||||
Args.push_back(&A);
|
||||
llvm::SmallVector<llvm::Value *, 2> Args(llvm::make_pointer_range(F->args()));
|
||||
llvm::CallInst *call = Builder.CreateCall(Invoke, Args);
|
||||
call->setCallingConv(Invoke->getCallingConv());
|
||||
Builder.CreateRetVoid();
|
||||
|
|
|
@ -551,8 +551,7 @@ void HexagonToolChain::getHexagonLibraryPaths(const ArgList &Args,
|
|||
// -L Args
|
||||
//----------------------------------------------------------------------------
|
||||
for (Arg *A : Args.filtered(options::OPT_L))
|
||||
for (const char *Value : A->getValues())
|
||||
LibPaths.push_back(Value);
|
||||
llvm::append_range(LibPaths, A->getValues());
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Other standard paths
|
||||
|
|
|
@ -355,9 +355,7 @@ bool Sema::inferCUDATargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl,
|
|||
}
|
||||
|
||||
if (!ClassDecl->isAbstract()) {
|
||||
for (const auto &VB : ClassDecl->vbases()) {
|
||||
Bases.push_back(&VB);
|
||||
}
|
||||
llvm::append_range(Bases, llvm::make_pointer_range(ClassDecl->vbases()));
|
||||
}
|
||||
|
||||
for (const auto *B : Bases) {
|
||||
|
|
|
@ -9505,8 +9505,7 @@ void Sema::CodeCompleteObjCMethodDecl(Scope *S, Optional<bool> IsInstanceMethod,
|
|||
IFace = Category->getClassInterface();
|
||||
|
||||
if (IFace)
|
||||
for (auto *Cat : IFace->visible_categories())
|
||||
Containers.push_back(Cat);
|
||||
llvm::append_range(Containers, IFace->visible_categories());
|
||||
|
||||
if (IsInstanceMethod) {
|
||||
for (unsigned I = 0, N = Containers.size(); I != N; ++I)
|
||||
|
|
|
@ -1390,8 +1390,7 @@ bool CoroutineStmtBuilder::makeNewAndDeleteExpr() {
|
|||
return false;
|
||||
|
||||
SmallVector<Expr *, 2> NewArgs(1, FrameSize);
|
||||
for (auto Arg : PlacementArgs)
|
||||
NewArgs.push_back(Arg);
|
||||
llvm::append_range(NewArgs, PlacementArgs);
|
||||
|
||||
ExprResult NewExpr =
|
||||
S.BuildCallExpr(S.getCurScope(), NewRef.get(), Loc, NewArgs, Loc);
|
||||
|
|
|
@ -9126,8 +9126,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
|
|||
Diag(D.getIdentifierLoc(), diag::err_function_decl_cmse_ns_call);
|
||||
|
||||
SmallVector<TemplateParameterList *, 4> TemplateParamLists;
|
||||
for (TemplateParameterList *TPL : TemplateParamListsRef)
|
||||
TemplateParamLists.push_back(TPL);
|
||||
llvm::append_range(TemplateParamLists, TemplateParamListsRef);
|
||||
if (TemplateParameterList *Invented = D.getInventedTemplateParameterList()) {
|
||||
if (!TemplateParamLists.empty() &&
|
||||
Invented->getDepth() == TemplateParamLists.back()->getDepth())
|
||||
|
|
|
@ -14751,8 +14751,7 @@ static void checkMoveAssignmentForRepeatedMove(Sema &S, CXXRecordDecl *Class,
|
|||
continue;
|
||||
|
||||
// We're going to move the base classes of Base. Add them to the list.
|
||||
for (auto &BI : Base->bases())
|
||||
Worklist.push_back(&BI);
|
||||
llvm::append_range(Worklist, llvm::make_pointer_range(Base->bases()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18295,8 +18294,7 @@ void Sema::ActOnStartFunctionDeclarationDeclarator(
|
|||
}
|
||||
if (ExplicitParams) {
|
||||
Info.AutoTemplateParameterDepth = ExplicitParams->getDepth();
|
||||
for (NamedDecl *Param : *ExplicitParams)
|
||||
Info.TemplateParams.push_back(Param);
|
||||
llvm::append_range(Info.TemplateParams, *ExplicitParams);
|
||||
Info.NumExplicitTemplateParams = ExplicitParams->size();
|
||||
} else {
|
||||
Info.AutoTemplateParameterDepth = TemplateParameterDepth;
|
||||
|
|
|
@ -3279,8 +3279,7 @@ void Sema::ActOnOpenMPAssumesDirective(SourceLocation Loc,
|
|||
continue;
|
||||
if (auto *CTD = dyn_cast<ClassTemplateDecl>(SubDC)) {
|
||||
DeclContexts.push_back(CTD->getTemplatedDecl());
|
||||
for (auto *S : CTD->specializations())
|
||||
DeclContexts.push_back(S);
|
||||
llvm::append_range(DeclContexts, CTD->specializations());
|
||||
continue;
|
||||
}
|
||||
if (auto *DC = dyn_cast<DeclContext>(SubDC))
|
||||
|
@ -13829,8 +13828,8 @@ bool Sema::checkTransformableLoopNest(
|
|||
llvm_unreachable("Unhandled loop transformation");
|
||||
if (!DependentPreInits)
|
||||
return;
|
||||
for (Decl *C : cast<DeclStmt>(DependentPreInits)->getDeclGroup())
|
||||
OriginalInits.back().push_back(C);
|
||||
llvm::append_range(OriginalInits.back(),
|
||||
cast<DeclStmt>(DependentPreInits)->getDeclGroup());
|
||||
});
|
||||
assert(OriginalInits.back().empty() && "No preinit after innermost loop");
|
||||
OriginalInits.pop_back();
|
||||
|
|
|
@ -14353,7 +14353,7 @@ ExprResult Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
|
|||
if (!AllowRecovery)
|
||||
return ExprError();
|
||||
std::vector<Expr *> SubExprs = {MemExprE};
|
||||
llvm::for_each(Args, [&SubExprs](Expr *E) { SubExprs.push_back(E); });
|
||||
llvm::append_range(SubExprs, Args);
|
||||
return CreateRecoveryExpr(MemExprE->getBeginLoc(), RParenLoc, SubExprs,
|
||||
Type);
|
||||
};
|
||||
|
|
|
@ -520,8 +520,7 @@ static void instantiateOMPDeclareVariantAttr(
|
|||
continue;
|
||||
NeedDevicePtrExprs.push_back(ER.get());
|
||||
}
|
||||
for (auto A : Attr.appendArgs())
|
||||
AppendArgs.push_back(A);
|
||||
llvm::append_range(AppendArgs, Attr.appendArgs());
|
||||
|
||||
S.ActOnOpenMPDeclareVariantDirective(
|
||||
FD, E, TI, NothingExprs, NeedDevicePtrExprs, AppendArgs, SourceLocation(),
|
||||
|
|
|
@ -236,8 +236,8 @@ namespace {
|
|||
if (hasSavedAttrs) return;
|
||||
|
||||
DeclSpec &spec = getMutableDeclSpec();
|
||||
for (ParsedAttr &AL : spec.getAttributes())
|
||||
savedAttrs.push_back(&AL);
|
||||
llvm::append_range(savedAttrs,
|
||||
llvm::make_pointer_range(spec.getAttributes()));
|
||||
trivial &= savedAttrs.empty();
|
||||
hasSavedAttrs = true;
|
||||
}
|
||||
|
|
|
@ -10612,9 +10612,8 @@ void ASTReader::diagnoseOdrViolations() {
|
|||
ExpandedList.push_back(&TA);
|
||||
continue;
|
||||
}
|
||||
for (const TemplateArgument &PackTA : TA.getPackAsArray()) {
|
||||
ExpandedList.push_back(&PackTA);
|
||||
}
|
||||
llvm::append_range(ExpandedList, llvm::make_pointer_range(
|
||||
TA.getPackAsArray()));
|
||||
}
|
||||
return ExpandedList;
|
||||
};
|
||||
|
|
|
@ -1317,8 +1317,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
|
|||
Record.push_back(M.Signature ? 0 : M.File->getSize());
|
||||
Record.push_back(M.Signature ? 0 : getTimestampForOutput(M.File));
|
||||
|
||||
for (auto I : M.Signature)
|
||||
Record.push_back(I);
|
||||
llvm::append_range(Record, M.Signature);
|
||||
|
||||
AddString(M.ModuleName, Record);
|
||||
AddPath(M.FileName, Record);
|
||||
|
@ -3702,8 +3701,7 @@ public:
|
|||
|
||||
data_type ImportData(const reader::ASTDeclContextNameLookupTrait::data_type &FromReader) {
|
||||
unsigned Start = DeclIDs.size();
|
||||
for (auto ID : FromReader)
|
||||
DeclIDs.push_back(ID);
|
||||
llvm::append_range(DeclIDs, FromReader);
|
||||
return std::make_pair(Start, DeclIDs.size());
|
||||
}
|
||||
|
||||
|
@ -5912,8 +5910,7 @@ void ASTWriter::AddedVisibleDecl(const DeclContext *DC, const Decl *D) {
|
|||
// We're adding a visible declaration to a predefined decl context. Ensure
|
||||
// that we write out all of its lookup results so we don't get a nasty
|
||||
// surprise when we try to emit its lookup table.
|
||||
for (auto *Child : DC->decls())
|
||||
DeclsToEmitEvenIfUnreferenced.push_back(Child);
|
||||
llvm::append_range(DeclsToEmitEvenIfUnreferenced, DC->decls());
|
||||
}
|
||||
DeclsToEmitEvenIfUnreferenced.push_back(D);
|
||||
}
|
||||
|
|
|
@ -962,8 +962,7 @@ void ASTDeclWriter::VisitMSGuidDecl(MSGuidDecl *D) {
|
|||
Record.push_back(Parts.Part1);
|
||||
Record.push_back(Parts.Part2);
|
||||
Record.push_back(Parts.Part3);
|
||||
for (auto C : Parts.Part4And5)
|
||||
Record.push_back(C);
|
||||
Record.append(std::begin(Parts.Part4And5), std::end(Parts.Part4And5));
|
||||
Code = serialization::DECL_MS_GUID;
|
||||
}
|
||||
|
||||
|
|
|
@ -152,13 +152,9 @@ public:
|
|||
using iterator = typename VectorTy::iterator;
|
||||
|
||||
AllocGroupSmallMap() = default;
|
||||
AllocGroupSmallMap(std::initializer_list<std::pair<AllocGroup, T>> Inits) {
|
||||
Elems.reserve(Inits.size());
|
||||
for (const auto &E : Inits)
|
||||
Elems.push_back(E);
|
||||
llvm::sort(Elems, [](const ElemT &LHS, const ElemT &RHS) {
|
||||
return LHS.first < RHS.first;
|
||||
});
|
||||
AllocGroupSmallMap(std::initializer_list<std::pair<AllocGroup, T>> Inits)
|
||||
: Elems(Inits) {
|
||||
llvm::sort(Elems, llvm::less_first());
|
||||
}
|
||||
|
||||
iterator begin() { return Elems.begin(); }
|
||||
|
|
Loading…
Reference in New Issue