[clang] 1fa7f05 - [clang] Construct SmallVector with ArrayRef (NFC) (#101898)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 4 23:46:37 PDT 2024
Author: Kazu Hirata
Date: 2024-08-04T23:46:34-07:00
New Revision: 1fa7f05b709748e8a36936cbb5508070c8214354
URL: https://github.com/llvm/llvm-project/commit/1fa7f05b709748e8a36936cbb5508070c8214354
DIFF: https://github.com/llvm/llvm-project/commit/1fa7f05b709748e8a36936cbb5508070c8214354.diff
LOG: [clang] Construct SmallVector with ArrayRef (NFC) (#101898)
Added:
Modified:
clang/include/clang/AST/ASTConcept.h
clang/include/clang/Index/DeclOccurrence.h
clang/include/clang/Tooling/Refactoring/ASTSelection.h
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/Format/AffectedRangeManager.h
clang/lib/Format/TokenAnalyzer.cpp
clang/lib/Format/UnwrappedLineParser.h
clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
clang/lib/Frontend/DiagnosticRenderer.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Support/RISCVVIntrinsicUtils.cpp
clang/unittests/Format/MacroCallReconstructorTest.cpp
clang/utils/TableGen/SveEmitter.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/AST/ASTConcept.h b/clang/include/clang/AST/ASTConcept.h
index 3c5fdf81d4b1e..00500e214f4ce 100644
--- a/clang/include/clang/AST/ASTConcept.h
+++ b/clang/include/clang/AST/ASTConcept.h
@@ -43,9 +43,8 @@ class ConstraintSatisfaction : public llvm::FoldingSetNode {
ConstraintSatisfaction() = default;
ConstraintSatisfaction(const NamedDecl *ConstraintOwner,
- ArrayRef<TemplateArgument> TemplateArgs) :
- ConstraintOwner(ConstraintOwner), TemplateArgs(TemplateArgs.begin(),
- TemplateArgs.end()) { }
+ ArrayRef<TemplateArgument> TemplateArgs)
+ : ConstraintOwner(ConstraintOwner), TemplateArgs(TemplateArgs) {}
using SubstitutionDiagnostic = std::pair<SourceLocation, StringRef>;
using Detail = llvm::PointerUnion<Expr *, SubstitutionDiagnostic *>;
diff --git a/clang/include/clang/Index/DeclOccurrence.h b/clang/include/clang/Index/DeclOccurrence.h
index 72f5799466bd4..9928ca243e8f2 100644
--- a/clang/include/clang/Index/DeclOccurrence.h
+++ b/clang/include/clang/Index/DeclOccurrence.h
@@ -29,8 +29,7 @@ struct DeclOccurrence {
DeclOccurrence(SymbolRoleSet R, unsigned Offset, const Decl *D,
ArrayRef<SymbolRelation> Relations)
- : Roles(R), Offset(Offset), DeclOrMacro(D),
- Relations(Relations.begin(), Relations.end()) {}
+ : Roles(R), Offset(Offset), DeclOrMacro(D), Relations(Relations) {}
DeclOccurrence(SymbolRoleSet R, unsigned Offset, const IdentifierInfo *Name,
const MacroInfo *MI)
: Roles(R), Offset(Offset), DeclOrMacro(MI), MacroName(Name) {}
diff --git a/clang/include/clang/Tooling/Refactoring/ASTSelection.h b/clang/include/clang/Tooling/Refactoring/ASTSelection.h
index 009437fde03fc..ae778acb5e017 100644
--- a/clang/include/clang/Tooling/Refactoring/ASTSelection.h
+++ b/clang/include/clang/Tooling/Refactoring/ASTSelection.h
@@ -138,7 +138,7 @@ class CodeRangeASTSelection {
CodeRangeASTSelection(SelectedASTNode::ReferenceType SelectedNode,
ArrayRef<SelectedASTNode::ReferenceType> Parents,
bool AreChildrenSelected)
- : SelectedNode(SelectedNode), Parents(Parents.begin(), Parents.end()),
+ : SelectedNode(SelectedNode), Parents(Parents),
AreChildrenSelected(AreChildrenSelected) {}
/// The reference to the selected node (or reference to the selected
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 6a5faa1e8f343..8b9c17a3f4a24 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -5309,7 +5309,7 @@ class CodeGenFunction : public CodeGenTypeCache {
llvm::SmallVector<StringRef, 8> Features;
Conds(StringRef Arch, ArrayRef<StringRef> Feats)
- : Architecture(Arch), Features(Feats.begin(), Feats.end()) {}
+ : Architecture(Arch), Features(Feats) {}
} Conditions;
MultiVersionResolverOption(llvm::Function *F, StringRef Arch,
diff --git a/clang/lib/Format/AffectedRangeManager.h b/clang/lib/Format/AffectedRangeManager.h
index 8cf39443fd415..add16bdd7a7c3 100644
--- a/clang/lib/Format/AffectedRangeManager.h
+++ b/clang/lib/Format/AffectedRangeManager.h
@@ -26,7 +26,7 @@ class AffectedRangeManager {
public:
AffectedRangeManager(const SourceManager &SourceMgr,
const ArrayRef<CharSourceRange> Ranges)
- : SourceMgr(SourceMgr), Ranges(Ranges.begin(), Ranges.end()) {}
+ : SourceMgr(SourceMgr), Ranges(Ranges) {}
// Determines which lines are affected by the SourceRanges given as input.
// Returns \c true if at least one line in \p Lines or one of their
diff --git a/clang/lib/Format/TokenAnalyzer.cpp b/clang/lib/Format/TokenAnalyzer.cpp
index 804a2b0f5e8c1..207442fe0c2c0 100644
--- a/clang/lib/Format/TokenAnalyzer.cpp
+++ b/clang/lib/Format/TokenAnalyzer.cpp
@@ -106,7 +106,7 @@ TokenAnalyzer::process(bool SkipAnnotation) {
Env.getFirstStartColumn(), Style, Encoding, Allocator,
IdentTable);
ArrayRef<FormatToken *> Toks(Lex.lex());
- SmallVector<FormatToken *, 10> Tokens(Toks.begin(), Toks.end());
+ SmallVector<FormatToken *, 10> Tokens(Toks);
UnwrappedLineParser Parser(Env.getSourceManager(), Style, Lex.getKeywords(),
Env.getFirstStartColumn(), Tokens, *this,
Allocator, IdentTable);
diff --git a/clang/lib/Format/UnwrappedLineParser.h b/clang/lib/Format/UnwrappedLineParser.h
index d5eeb3d57149c..b7daf8d9f4401 100644
--- a/clang/lib/Format/UnwrappedLineParser.h
+++ b/clang/lib/Format/UnwrappedLineParser.h
@@ -410,7 +410,7 @@ struct UnwrappedLineNode {
UnwrappedLineNode() : Tok(nullptr) {}
UnwrappedLineNode(FormatToken *Tok,
llvm::ArrayRef<UnwrappedLine> Children = {})
- : Tok(Tok), Children(Children.begin(), Children.end()) {}
+ : Tok(Tok), Children(Children) {}
FormatToken *Tok;
SmallVector<UnwrappedLine, 0> Children;
diff --git a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp b/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
index 1df3a12fce144..638757a245024 100644
--- a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
+++ b/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
@@ -34,7 +34,7 @@ clang::createInvocation(ArrayRef<const char *> ArgList,
? std::move(Opts.Diags)
: CompilerInstance::createDiagnostics(new DiagnosticOptions);
- SmallVector<const char *, 16> Args(ArgList.begin(), ArgList.end());
+ SmallVector<const char *, 16> Args(ArgList);
// FIXME: Find a cleaner way to force the driver into restricted modes.
Args.insert(
diff --git a/clang/lib/Frontend/DiagnosticRenderer.cpp b/clang/lib/Frontend/DiagnosticRenderer.cpp
index 18c8be7a72936..017ce1c17d5c9 100644
--- a/clang/lib/Frontend/DiagnosticRenderer.cpp
+++ b/clang/lib/Frontend/DiagnosticRenderer.cpp
@@ -98,8 +98,7 @@ void DiagnosticRenderer::emitDiagnostic(FullSourceLoc Loc,
emitDiagnosticMessage(Loc, PresumedLoc(), Level, Message, Ranges, D);
else {
// Get the ranges into a local array we can hack on.
- SmallVector<CharSourceRange, 20> MutableRanges(Ranges.begin(),
- Ranges.end());
+ SmallVector<CharSourceRange, 20> MutableRanges(Ranges);
SmallVector<FixItHint, 8> MergedFixits;
if (!FixItHints.empty()) {
diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp
index 1e31fcc3d731e..1d671ab72b0c0 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -290,7 +290,7 @@ void Preprocessor::dumpMacroInfo(const IdentifierInfo *II) {
State ? State->getActiveModuleMacros(*this, II) : std::nullopt)
Active.insert(MM);
llvm::DenseSet<ModuleMacro*> Visited;
- llvm::SmallVector<ModuleMacro *, 16> Worklist(Leaf.begin(), Leaf.end());
+ llvm::SmallVector<ModuleMacro *, 16> Worklist(Leaf);
while (!Worklist.empty()) {
auto *MM = Worklist.pop_back_val();
llvm::errs() << " ModuleMacro " << MM << " "
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 4fea38d1b02a9..2cefa97cdc600 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -12840,7 +12840,7 @@ QualType Sema::deduceVarTypeFromInitializer(VarDecl *VDecl,
InitializationKind Kind = InitializationKind::CreateForInit(
VDecl->getLocation(), DirectInit, Init);
// FIXME: Initialization should not be taking a mutable list of inits.
- SmallVector<Expr*, 8> InitsCopy(DeduceInits.begin(), DeduceInits.end());
+ SmallVector<Expr *, 8> InitsCopy(DeduceInits);
return DeduceTemplateSpecializationFromInitializer(TSI, Entity, Kind,
InitsCopy);
}
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index cecb80f8fb7fd..71a36786554b2 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -6058,11 +6058,8 @@ StmtResult SemaOpenMP::ActOnOpenMPExecutableDirective(
VarsWithInheritedDSA = DSAChecker.getVarsWithInheritedDSA();
SmallVector<Expr *, 4> ImplicitFirstprivates(
- DSAChecker.getImplicitFirstprivate().begin(),
- DSAChecker.getImplicitFirstprivate().end());
- SmallVector<Expr *, 4> ImplicitPrivates(
- DSAChecker.getImplicitPrivate().begin(),
- DSAChecker.getImplicitPrivate().end());
+ DSAChecker.getImplicitFirstprivate());
+ SmallVector<Expr *, 4> ImplicitPrivates(DSAChecker.getImplicitPrivate());
const unsigned DefaultmapKindNum = OMPC_DEFAULTMAP_unknown + 1;
SmallVector<Expr *, 4> ImplicitMaps[DefaultmapKindNum][OMPC_MAP_delete];
SmallVector<OpenMPMapModifierKind, NumberOfOMPMapClauseModifiers>
@@ -21737,8 +21734,7 @@ SemaOpenMP::DeclGroupPtrTy SemaOpenMP::ActOnOpenMPDeclareMapperDirective(
}
// Build expressions for implicit maps of data members with 'default'
// mappers.
- SmallVector<OMPClause *, 4> ClausesWithImplicit(Clauses.begin(),
- Clauses.end());
+ SmallVector<OMPClause *, 4> ClausesWithImplicit(Clauses);
if (getLangOpts().OpenMP >= 50)
processImplicitMapsWithDefaultMappers(SemaRef, DSAStack,
ClausesWithImplicit);
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index c5f56ac62b458..54a9bba9391d1 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -16125,7 +16125,7 @@ ExprResult Sema::FixOverloadedFunctionReference(Expr *E, DeclAccessPair Found,
// Replace the resulting type information before rebuilding the generic
// selection expression.
ArrayRef<Expr *> A = GSE->getAssocExprs();
- SmallVector<Expr *, 4> AssocExprs(A.begin(), A.end());
+ SmallVector<Expr *, 4> AssocExprs(A);
unsigned ResultIdx = GSE->getResultIndex();
AssocExprs[ResultIdx] = SubExpr.get();
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index f0f9d397f1717..bd9b150c265c1 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -2610,7 +2610,7 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) {
// We write out exported module macros for PCH as well.
auto Leafs = PP.getLeafModuleMacros(Name);
- SmallVector<ModuleMacro *, 8> Worklist(Leafs.begin(), Leafs.end());
+ SmallVector<ModuleMacro *, 8> Worklist(Leafs);
llvm::DenseMap<ModuleMacro *, unsigned> Visits;
while (!Worklist.empty()) {
auto *Macro = Worklist.pop_back_val();
diff --git a/clang/lib/Support/RISCVVIntrinsicUtils.cpp b/clang/lib/Support/RISCVVIntrinsicUtils.cpp
index e3718130ca06a..ed506e06d2ba0 100644
--- a/clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ b/clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -1039,8 +1039,7 @@ llvm::SmallVector<PrototypeDescriptor> RVVIntrinsic::computeBuiltinTypes(
llvm::ArrayRef<PrototypeDescriptor> Prototype, bool IsMasked,
bool HasMaskedOffOperand, bool HasVL, unsigned NF,
PolicyScheme DefaultScheme, Policy PolicyAttrs, bool IsTuple) {
- SmallVector<PrototypeDescriptor> NewPrototype(Prototype.begin(),
- Prototype.end());
+ SmallVector<PrototypeDescriptor> NewPrototype(Prototype);
bool HasPassthruOp = DefaultScheme == PolicyScheme::HasPassthruOperand;
if (IsMasked) {
// If HasMaskedOffOperand, insert result type as first input operand if
diff --git a/clang/unittests/Format/MacroCallReconstructorTest.cpp b/clang/unittests/Format/MacroCallReconstructorTest.cpp
index acef5e79eaaea..b4ee8d0e37efa 100644
--- a/clang/unittests/Format/MacroCallReconstructorTest.cpp
+++ b/clang/unittests/Format/MacroCallReconstructorTest.cpp
@@ -87,10 +87,8 @@ class Expansion {
};
struct Chunk {
- Chunk(ArrayRef<FormatToken *> Tokens)
- : Tokens(Tokens.begin(), Tokens.end()) {}
- Chunk(ArrayRef<UnwrappedLine> Children)
- : Children(Children.begin(), Children.end()) {}
+ Chunk(ArrayRef<FormatToken *> Tokens) : Tokens(Tokens) {}
+ Chunk(ArrayRef<UnwrappedLine> Children) : Children(Children) {}
SmallVector<UnwrappedLineNode, 1> Tokens;
SmallVector<UnwrappedLine, 0> Children;
};
diff --git a/clang/utils/TableGen/SveEmitter.cpp b/clang/utils/TableGen/SveEmitter.cpp
index caedd5978a87c..ca63bd354bfc7 100644
--- a/clang/utils/TableGen/SveEmitter.cpp
+++ b/clang/utils/TableGen/SveEmitter.cpp
@@ -969,7 +969,7 @@ Intrinsic::Intrinsic(StringRef Name, StringRef Proto, uint64_t MergeTy,
: Name(Name.str()), LLVMName(LLVMName), Proto(Proto.str()),
BaseTypeSpec(BT), Class(Class), SVEGuard(SVEGuard.str()),
SMEGuard(SMEGuard.str()), MergeSuffix(MergeSuffix.str()),
- BaseType(BT, 'd'), Flags(Flags), ImmChecks(Checks.begin(), Checks.end()) {
+ BaseType(BT, 'd'), Flags(Flags), ImmChecks(Checks) {
// Types[0] is the return value.
for (unsigned I = 0; I < (getNumParams() + 1); ++I) {
char Mod;
More information about the cfe-commits
mailing list