Skip to content

Commit

Permalink
[clang] Construct SmallVector with ArrayRef (NFC) (llvm#101898)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazutakahirata authored Aug 5, 2024
1 parent 120740b commit 1fa7f05
Show file tree
Hide file tree
Showing 17 changed files with 21 additions and 31 deletions.
5 changes: 2 additions & 3 deletions clang/include/clang/AST/ASTConcept.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *>;
Expand Down
3 changes: 1 addition & 2 deletions clang/include/clang/Index/DeclOccurrence.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Tooling/Refactoring/ASTSelection.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CodeGenFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Format/AffectedRangeManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Format/TokenAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Format/UnwrappedLineParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/Frontend/DiagnosticRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Lex/PPMacroExpansion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 << " "
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
10 changes: 3 additions & 7 deletions clang/lib/Sema/SemaOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaOverload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Serialization/ASTWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/Support/RISCVVIntrinsicUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions clang/unittests/Format/MacroCallReconstructorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
2 changes: 1 addition & 1 deletion clang/utils/TableGen/SveEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1fa7f05

Please sign in to comment.