Skip to content

Commit 1fa7f05

Browse files
[clang] Construct SmallVector with ArrayRef (NFC) (#101898)
1 parent 120740b commit 1fa7f05

File tree

17 files changed

+21
-31
lines changed

17 files changed

+21
-31
lines changed

clang/include/clang/AST/ASTConcept.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ class ConstraintSatisfaction : public llvm::FoldingSetNode {
4343
ConstraintSatisfaction() = default;
4444

4545
ConstraintSatisfaction(const NamedDecl *ConstraintOwner,
46-
ArrayRef<TemplateArgument> TemplateArgs) :
47-
ConstraintOwner(ConstraintOwner), TemplateArgs(TemplateArgs.begin(),
48-
TemplateArgs.end()) { }
46+
ArrayRef<TemplateArgument> TemplateArgs)
47+
: ConstraintOwner(ConstraintOwner), TemplateArgs(TemplateArgs) {}
4948

5049
using SubstitutionDiagnostic = std::pair<SourceLocation, StringRef>;
5150
using Detail = llvm::PointerUnion<Expr *, SubstitutionDiagnostic *>;

clang/include/clang/Index/DeclOccurrence.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ struct DeclOccurrence {
2929

3030
DeclOccurrence(SymbolRoleSet R, unsigned Offset, const Decl *D,
3131
ArrayRef<SymbolRelation> Relations)
32-
: Roles(R), Offset(Offset), DeclOrMacro(D),
33-
Relations(Relations.begin(), Relations.end()) {}
32+
: Roles(R), Offset(Offset), DeclOrMacro(D), Relations(Relations) {}
3433
DeclOccurrence(SymbolRoleSet R, unsigned Offset, const IdentifierInfo *Name,
3534
const MacroInfo *MI)
3635
: Roles(R), Offset(Offset), DeclOrMacro(MI), MacroName(Name) {}

clang/include/clang/Tooling/Refactoring/ASTSelection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class CodeRangeASTSelection {
138138
CodeRangeASTSelection(SelectedASTNode::ReferenceType SelectedNode,
139139
ArrayRef<SelectedASTNode::ReferenceType> Parents,
140140
bool AreChildrenSelected)
141-
: SelectedNode(SelectedNode), Parents(Parents.begin(), Parents.end()),
141+
: SelectedNode(SelectedNode), Parents(Parents),
142142
AreChildrenSelected(AreChildrenSelected) {}
143143

144144
/// The reference to the selected node (or reference to the selected

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5309,7 +5309,7 @@ class CodeGenFunction : public CodeGenTypeCache {
53095309
llvm::SmallVector<StringRef, 8> Features;
53105310

53115311
Conds(StringRef Arch, ArrayRef<StringRef> Feats)
5312-
: Architecture(Arch), Features(Feats.begin(), Feats.end()) {}
5312+
: Architecture(Arch), Features(Feats) {}
53135313
} Conditions;
53145314

53155315
MultiVersionResolverOption(llvm::Function *F, StringRef Arch,

clang/lib/Format/AffectedRangeManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class AffectedRangeManager {
2626
public:
2727
AffectedRangeManager(const SourceManager &SourceMgr,
2828
const ArrayRef<CharSourceRange> Ranges)
29-
: SourceMgr(SourceMgr), Ranges(Ranges.begin(), Ranges.end()) {}
29+
: SourceMgr(SourceMgr), Ranges(Ranges) {}
3030

3131
// Determines which lines are affected by the SourceRanges given as input.
3232
// Returns \c true if at least one line in \p Lines or one of their

clang/lib/Format/TokenAnalyzer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ TokenAnalyzer::process(bool SkipAnnotation) {
106106
Env.getFirstStartColumn(), Style, Encoding, Allocator,
107107
IdentTable);
108108
ArrayRef<FormatToken *> Toks(Lex.lex());
109-
SmallVector<FormatToken *, 10> Tokens(Toks.begin(), Toks.end());
109+
SmallVector<FormatToken *, 10> Tokens(Toks);
110110
UnwrappedLineParser Parser(Env.getSourceManager(), Style, Lex.getKeywords(),
111111
Env.getFirstStartColumn(), Tokens, *this,
112112
Allocator, IdentTable);

clang/lib/Format/UnwrappedLineParser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ struct UnwrappedLineNode {
410410
UnwrappedLineNode() : Tok(nullptr) {}
411411
UnwrappedLineNode(FormatToken *Tok,
412412
llvm::ArrayRef<UnwrappedLine> Children = {})
413-
: Tok(Tok), Children(Children.begin(), Children.end()) {}
413+
: Tok(Tok), Children(Children) {}
414414

415415
FormatToken *Tok;
416416
SmallVector<UnwrappedLine, 0> Children;

clang/lib/Frontend/CreateInvocationFromCommandLine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ clang::createInvocation(ArrayRef<const char *> ArgList,
3434
? std::move(Opts.Diags)
3535
: CompilerInstance::createDiagnostics(new DiagnosticOptions);
3636

37-
SmallVector<const char *, 16> Args(ArgList.begin(), ArgList.end());
37+
SmallVector<const char *, 16> Args(ArgList);
3838

3939
// FIXME: Find a cleaner way to force the driver into restricted modes.
4040
Args.insert(

clang/lib/Frontend/DiagnosticRenderer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ void DiagnosticRenderer::emitDiagnostic(FullSourceLoc Loc,
9898
emitDiagnosticMessage(Loc, PresumedLoc(), Level, Message, Ranges, D);
9999
else {
100100
// Get the ranges into a local array we can hack on.
101-
SmallVector<CharSourceRange, 20> MutableRanges(Ranges.begin(),
102-
Ranges.end());
101+
SmallVector<CharSourceRange, 20> MutableRanges(Ranges);
103102

104103
SmallVector<FixItHint, 8> MergedFixits;
105104
if (!FixItHints.empty()) {

clang/lib/Lex/PPMacroExpansion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ void Preprocessor::dumpMacroInfo(const IdentifierInfo *II) {
290290
State ? State->getActiveModuleMacros(*this, II) : std::nullopt)
291291
Active.insert(MM);
292292
llvm::DenseSet<ModuleMacro*> Visited;
293-
llvm::SmallVector<ModuleMacro *, 16> Worklist(Leaf.begin(), Leaf.end());
293+
llvm::SmallVector<ModuleMacro *, 16> Worklist(Leaf);
294294
while (!Worklist.empty()) {
295295
auto *MM = Worklist.pop_back_val();
296296
llvm::errs() << " ModuleMacro " << MM << " "

clang/lib/Sema/SemaDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12840,7 +12840,7 @@ QualType Sema::deduceVarTypeFromInitializer(VarDecl *VDecl,
1284012840
InitializationKind Kind = InitializationKind::CreateForInit(
1284112841
VDecl->getLocation(), DirectInit, Init);
1284212842
// FIXME: Initialization should not be taking a mutable list of inits.
12843-
SmallVector<Expr*, 8> InitsCopy(DeduceInits.begin(), DeduceInits.end());
12843+
SmallVector<Expr *, 8> InitsCopy(DeduceInits);
1284412844
return DeduceTemplateSpecializationFromInitializer(TSI, Entity, Kind,
1284512845
InitsCopy);
1284612846
}

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6058,11 +6058,8 @@ StmtResult SemaOpenMP::ActOnOpenMPExecutableDirective(
60586058
VarsWithInheritedDSA = DSAChecker.getVarsWithInheritedDSA();
60596059

60606060
SmallVector<Expr *, 4> ImplicitFirstprivates(
6061-
DSAChecker.getImplicitFirstprivate().begin(),
6062-
DSAChecker.getImplicitFirstprivate().end());
6063-
SmallVector<Expr *, 4> ImplicitPrivates(
6064-
DSAChecker.getImplicitPrivate().begin(),
6065-
DSAChecker.getImplicitPrivate().end());
6061+
DSAChecker.getImplicitFirstprivate());
6062+
SmallVector<Expr *, 4> ImplicitPrivates(DSAChecker.getImplicitPrivate());
60666063
const unsigned DefaultmapKindNum = OMPC_DEFAULTMAP_unknown + 1;
60676064
SmallVector<Expr *, 4> ImplicitMaps[DefaultmapKindNum][OMPC_MAP_delete];
60686065
SmallVector<OpenMPMapModifierKind, NumberOfOMPMapClauseModifiers>
@@ -21737,8 +21734,7 @@ SemaOpenMP::DeclGroupPtrTy SemaOpenMP::ActOnOpenMPDeclareMapperDirective(
2173721734
}
2173821735
// Build expressions for implicit maps of data members with 'default'
2173921736
// mappers.
21740-
SmallVector<OMPClause *, 4> ClausesWithImplicit(Clauses.begin(),
21741-
Clauses.end());
21737+
SmallVector<OMPClause *, 4> ClausesWithImplicit(Clauses);
2174221738
if (getLangOpts().OpenMP >= 50)
2174321739
processImplicitMapsWithDefaultMappers(SemaRef, DSAStack,
2174421740
ClausesWithImplicit);

clang/lib/Sema/SemaOverload.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16125,7 +16125,7 @@ ExprResult Sema::FixOverloadedFunctionReference(Expr *E, DeclAccessPair Found,
1612516125
// Replace the resulting type information before rebuilding the generic
1612616126
// selection expression.
1612716127
ArrayRef<Expr *> A = GSE->getAssocExprs();
16128-
SmallVector<Expr *, 4> AssocExprs(A.begin(), A.end());
16128+
SmallVector<Expr *, 4> AssocExprs(A);
1612916129
unsigned ResultIdx = GSE->getResultIndex();
1613016130
AssocExprs[ResultIdx] = SubExpr.get();
1613116131

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2610,7 +2610,7 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) {
26102610

26112611
// We write out exported module macros for PCH as well.
26122612
auto Leafs = PP.getLeafModuleMacros(Name);
2613-
SmallVector<ModuleMacro *, 8> Worklist(Leafs.begin(), Leafs.end());
2613+
SmallVector<ModuleMacro *, 8> Worklist(Leafs);
26142614
llvm::DenseMap<ModuleMacro *, unsigned> Visits;
26152615
while (!Worklist.empty()) {
26162616
auto *Macro = Worklist.pop_back_val();

clang/lib/Support/RISCVVIntrinsicUtils.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,8 +1039,7 @@ llvm::SmallVector<PrototypeDescriptor> RVVIntrinsic::computeBuiltinTypes(
10391039
llvm::ArrayRef<PrototypeDescriptor> Prototype, bool IsMasked,
10401040
bool HasMaskedOffOperand, bool HasVL, unsigned NF,
10411041
PolicyScheme DefaultScheme, Policy PolicyAttrs, bool IsTuple) {
1042-
SmallVector<PrototypeDescriptor> NewPrototype(Prototype.begin(),
1043-
Prototype.end());
1042+
SmallVector<PrototypeDescriptor> NewPrototype(Prototype);
10441043
bool HasPassthruOp = DefaultScheme == PolicyScheme::HasPassthruOperand;
10451044
if (IsMasked) {
10461045
// If HasMaskedOffOperand, insert result type as first input operand if

clang/unittests/Format/MacroCallReconstructorTest.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,8 @@ class Expansion {
8787
};
8888

8989
struct Chunk {
90-
Chunk(ArrayRef<FormatToken *> Tokens)
91-
: Tokens(Tokens.begin(), Tokens.end()) {}
92-
Chunk(ArrayRef<UnwrappedLine> Children)
93-
: Children(Children.begin(), Children.end()) {}
90+
Chunk(ArrayRef<FormatToken *> Tokens) : Tokens(Tokens) {}
91+
Chunk(ArrayRef<UnwrappedLine> Children) : Children(Children) {}
9492
SmallVector<UnwrappedLineNode, 1> Tokens;
9593
SmallVector<UnwrappedLine, 0> Children;
9694
};

clang/utils/TableGen/SveEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ Intrinsic::Intrinsic(StringRef Name, StringRef Proto, uint64_t MergeTy,
969969
: Name(Name.str()), LLVMName(LLVMName), Proto(Proto.str()),
970970
BaseTypeSpec(BT), Class(Class), SVEGuard(SVEGuard.str()),
971971
SMEGuard(SMEGuard.str()), MergeSuffix(MergeSuffix.str()),
972-
BaseType(BT, 'd'), Flags(Flags), ImmChecks(Checks.begin(), Checks.end()) {
972+
BaseType(BT, 'd'), Flags(Flags), ImmChecks(Checks) {
973973
// Types[0] is the return value.
974974
for (unsigned I = 0; I < (getNumParams() + 1); ++I) {
975975
char Mod;

0 commit comments

Comments
 (0)