Skip to content

Commit

Permalink
Move from llvm::makeArrayRef to ArrayRef deduction guides - clang/ part
Browse files Browse the repository at this point in the history
This is a follow-up to https://reviews.llvm.org/D140896, split into
several parts as it touches a lot of files.

Differential Revision: https://reviews.llvm.org/D141139
  • Loading branch information
serge-sans-paille committed Jan 9, 2023
1 parent 5b24d42 commit a3c248d
Show file tree
Hide file tree
Showing 138 changed files with 563 additions and 637 deletions.
2 changes: 1 addition & 1 deletion clang/include/clang/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3205,7 +3205,7 @@ class IndirectFieldDecl : public ValueDecl,
using chain_iterator = ArrayRef<NamedDecl *>::const_iterator;

ArrayRef<NamedDecl *> chain() const {
return llvm::makeArrayRef(Chaining, ChainingSize);
return llvm::ArrayRef(Chaining, ChainingSize);
}
chain_iterator chain_begin() const { return chain().begin(); }
chain_iterator chain_end() const { return chain().end(); }
Expand Down
8 changes: 4 additions & 4 deletions clang/include/clang/AST/DeclCXX.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,11 @@ class CXXRecordDecl : public RecordDecl {
}

ArrayRef<CXXBaseSpecifier> bases() const {
return llvm::makeArrayRef(getBases(), NumBases);
return llvm::ArrayRef(getBases(), NumBases);
}

ArrayRef<CXXBaseSpecifier> vbases() const {
return llvm::makeArrayRef(getVBases(), NumVBases);
return llvm::ArrayRef(getVBases(), NumVBases);
}

private:
Expand Down Expand Up @@ -3739,7 +3739,7 @@ class UsingPackDecl final
/// Get the set of using declarations that this pack expanded into. Note that
/// some of these may still be unresolved.
ArrayRef<NamedDecl *> expansions() const {
return llvm::makeArrayRef(getTrailingObjects<NamedDecl *>(), NumExpansions);
return llvm::ArrayRef(getTrailingObjects<NamedDecl *>(), NumExpansions);
}

static UsingPackDecl *Create(ASTContext &C, DeclContext *DC,
Expand Down Expand Up @@ -4109,7 +4109,7 @@ class DecompositionDecl final
unsigned NumBindings);

ArrayRef<BindingDecl *> bindings() const {
return llvm::makeArrayRef(getTrailingObjects<BindingDecl *>(), NumBindings);
return llvm::ArrayRef(getTrailingObjects<BindingDecl *>(), NumBindings);
}

void printName(raw_ostream &OS, const PrintingPolicy &Policy) const override;
Expand Down
3 changes: 1 addition & 2 deletions clang/include/clang/AST/DeclObjC.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,7 @@ class ObjCMethodDecl : public NamedDecl, public DeclContext {
// ArrayRef access to formal parameters. This should eventually
// replace the iterator interface above.
ArrayRef<ParmVarDecl*> parameters() const {
return llvm::makeArrayRef(const_cast<ParmVarDecl**>(getParams()),
NumParams);
return llvm::ArrayRef(const_cast<ParmVarDecl **>(getParams()), NumParams);
}

ParmVarDecl *getParamDecl(unsigned Idx) {
Expand Down
4 changes: 2 additions & 2 deletions clang/include/clang/AST/DeclOpenMP.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class OMPThreadPrivateDecl final : public OMPDeclarativeDirective<Decl> {

ArrayRef<const Expr *> getVars() const {
auto **Storage = reinterpret_cast<Expr **>(Data->getChildren().data());
return llvm::makeArrayRef(Storage, Data->getNumChildren());
return llvm::ArrayRef(Storage, Data->getNumChildren());
}

MutableArrayRef<Expr *> getVars() {
Expand Down Expand Up @@ -481,7 +481,7 @@ class OMPAllocateDecl final : public OMPDeclarativeDirective<Decl> {

ArrayRef<const Expr *> getVars() const {
auto **Storage = reinterpret_cast<Expr **>(Data->getChildren().data());
return llvm::makeArrayRef(Storage, Data->getNumChildren());
return llvm::ArrayRef(Storage, Data->getNumChildren());
}

MutableArrayRef<Expr *> getVars() {
Expand Down
10 changes: 4 additions & 6 deletions clang/include/clang/AST/DeclTemplate.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,9 @@ class TemplateParameterList final

unsigned size() const { return NumParams; }

ArrayRef<NamedDecl*> asArray() {
return llvm::makeArrayRef(begin(), end());
}
ArrayRef<NamedDecl *> asArray() { return llvm::ArrayRef(begin(), end()); }
ArrayRef<const NamedDecl*> asArray() const {
return llvm::makeArrayRef(begin(), size());
return llvm::ArrayRef(begin(), size());
}

NamedDecl* getParam(unsigned Idx) {
Expand Down Expand Up @@ -289,7 +287,7 @@ class TemplateArgumentList final

/// Produce this as an array ref.
ArrayRef<TemplateArgument> asArray() const {
return llvm::makeArrayRef(data(), size());
return llvm::ArrayRef(data(), size());
}

/// Retrieve the number of template arguments in this
Expand Down Expand Up @@ -741,7 +739,7 @@ class DependentFunctionTemplateSpecializationInfo final
unsigned getNumTemplateArgs() const { return NumArgs; }

llvm::ArrayRef<TemplateArgumentLoc> arguments() const {
return llvm::makeArrayRef(getTemplateArgs(), getNumTemplateArgs());
return llvm::ArrayRef(getTemplateArgs(), getNumTemplateArgs());
}

/// Returns the nth template argument.
Expand Down
18 changes: 7 additions & 11 deletions clang/include/clang/AST/Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -3020,7 +3020,7 @@ class CallExpr : public Expr {
/// Compute and set dependence bits.
void computeDependence() {
setDependence(clang::computeDependence(
this, llvm::makeArrayRef(
this, llvm::ArrayRef(
reinterpret_cast<Expr **>(getTrailingStmts() + PREARGS_START),
getNumPreArgs())));
}
Expand Down Expand Up @@ -3067,8 +3067,8 @@ class CallExpr : public Expr {
/// interface. This provides efficient reverse iteration of the
/// subexpressions. This is currently used for CFG construction.
ArrayRef<Stmt *> getRawSubExprs() {
return llvm::makeArrayRef(getTrailingStmts(),
PREARGS_START + getNumPreArgs() + getNumArgs());
return llvm::ArrayRef(getTrailingStmts(),
PREARGS_START + getNumPreArgs() + getNumArgs());
}

/// Get FPOptionsOverride from trailing storage.
Expand Down Expand Up @@ -4834,12 +4834,10 @@ class InitListExpr : public Expr {
return reinterpret_cast<Expr * const *>(InitExprs.data());
}

ArrayRef<Expr *> inits() {
return llvm::makeArrayRef(getInits(), getNumInits());
}
ArrayRef<Expr *> inits() { return llvm::ArrayRef(getInits(), getNumInits()); }

ArrayRef<Expr *> inits() const {
return llvm::makeArrayRef(getInits(), getNumInits());
return llvm::ArrayRef(getInits(), getNumInits());
}

const Expr *getInit(unsigned Init) const {
Expand Down Expand Up @@ -5581,9 +5579,7 @@ class ParenListExpr final
return reinterpret_cast<Expr **>(getTrailingObjects<Stmt *>());
}

ArrayRef<Expr *> exprs() {
return llvm::makeArrayRef(getExprs(), getNumExprs());
}
ArrayRef<Expr *> exprs() { return llvm::ArrayRef(getExprs(), getNumExprs()); }

SourceLocation getLParenLoc() const { return LParenLoc; }
SourceLocation getRParenLoc() const { return RParenLoc; }
Expand Down Expand Up @@ -6434,7 +6430,7 @@ class RecoveryExpr final : public Expr,

ArrayRef<Expr *> subExpressions() {
auto *B = getTrailingObjects<Expr *>();
return llvm::makeArrayRef(B, B + NumExprs);
return llvm::ArrayRef(B, B + NumExprs);
}

ArrayRef<const Expr *> subExpressions() const {
Expand Down
8 changes: 3 additions & 5 deletions clang/include/clang/AST/ExprCXX.h
Original file line number Diff line number Diff line change
Expand Up @@ -2796,8 +2796,7 @@ class TypeTraitExpr final

/// Retrieve the argument types.
ArrayRef<TypeSourceInfo *> getArgs() const {
return llvm::makeArrayRef(getTrailingObjects<TypeSourceInfo *>(),
getNumArgs());
return llvm::ArrayRef(getTrailingObjects<TypeSourceInfo *>(), getNumArgs());
}

SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
Expand Down Expand Up @@ -3443,8 +3442,7 @@ class ExprWithCleanups final
ArrayRef<CleanupObject> objects);

ArrayRef<CleanupObject> getObjects() const {
return llvm::makeArrayRef(getTrailingObjects<CleanupObject>(),
getNumObjects());
return llvm::ArrayRef(getTrailingObjects<CleanupObject>(), getNumObjects());
}

unsigned getNumObjects() const { return ExprWithCleanupsBits.NumObjects; }
Expand Down Expand Up @@ -4295,7 +4293,7 @@ class SizeOfPackExpr final
ArrayRef<TemplateArgument> getPartialArguments() const {
assert(isPartiallySubstituted());
const auto *Args = getTrailingObjects<TemplateArgument>();
return llvm::makeArrayRef(Args, Args + Length);
return llvm::ArrayRef(Args, Args + Length);
}

SourceLocation getBeginLoc() const LLVM_READONLY { return OperatorLoc; }
Expand Down
9 changes: 4 additions & 5 deletions clang/include/clang/AST/ExprObjC.h
Original file line number Diff line number Diff line change
Expand Up @@ -1415,11 +1415,10 @@ class ObjCMessageExpr final
SourceLocation getSelectorLoc(unsigned Index) const {
assert(Index < getNumSelectorLocs() && "Index out of range!");
if (hasStandardSelLocs())
return getStandardSelectorLoc(Index, getSelector(),
getSelLocsKind() == SelLoc_StandardWithSpace,
llvm::makeArrayRef(const_cast<Expr**>(getArgs()),
getNumArgs()),
RBracLoc);
return getStandardSelectorLoc(
Index, getSelector(), getSelLocsKind() == SelLoc_StandardWithSpace,
llvm::ArrayRef(const_cast<Expr **>(getArgs()), getNumArgs()),
RBracLoc);
return getStoredSelLocs()[Index];
}

Expand Down
4 changes: 2 additions & 2 deletions clang/include/clang/AST/ExprOpenMP.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ class OMPArrayShapingExpr final

/// Fetches the dimensions for array shaping expression.
ArrayRef<Expr *> getDimensions() const {
return llvm::makeArrayRef(getTrailingObjects<Expr *>(), NumDims);
return llvm::ArrayRef(getTrailingObjects<Expr *>(), NumDims);
}

/// Fetches source ranges for the brackets os the array shaping expression.
ArrayRef<SourceRange> getBracketsRanges() const {
return llvm::makeArrayRef(getTrailingObjects<SourceRange>(), NumDims);
return llvm::ArrayRef(getTrailingObjects<SourceRange>(), NumDims);
}

/// Fetches base expression of array shaping expression.
Expand Down
Loading

0 comments on commit a3c248d

Please sign in to comment.