Skip to content

[flang] Construct SmallVector with ArrayRef (NFC) #101901

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flang/include/flang/Lower/CallInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class CallInterface {
FirPlaceHolder(mlir::Type t, int passedPosition, Property p,
llvm::ArrayRef<mlir::NamedAttribute> attrs)
: type{t}, passedEntityPosition{passedPosition}, property{p},
attributes{attrs.begin(), attrs.end()} {}
attributes{attrs} {}
/// Type for this input/output
mlir::Type type;
/// Position of related passedEntity in passedArguments.
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Lower/IterationSpace.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class IterationSpace {
explicit IterationSpace(const IterationSpace &from,
llvm::ArrayRef<mlir::Value> idxs)
: inArg(from.inArg), outRes(from.outRes), element(from.element),
indices(idxs.begin(), idxs.end()) {}
indices(idxs) {}

/// Create a copy of the \p from IterationSpace and prepend the \p prefix
/// values and append the \p suffix values, respectively.
Expand Down
5 changes: 2 additions & 3 deletions flang/include/flang/Optimizer/Builder/BoxValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ class AbstractArrayBox {
AbstractArrayBox() = default;
AbstractArrayBox(llvm::ArrayRef<mlir::Value> extents,
llvm::ArrayRef<mlir::Value> lbounds)
: extents{extents.begin(), extents.end()}, lbounds{lbounds.begin(),
lbounds.end()} {}
: extents{extents}, lbounds{lbounds} {}

// Every array has extents that describe its shape.
const llvm::SmallVectorImpl<mlir::Value> &getExtents() const {
Expand Down Expand Up @@ -296,7 +295,7 @@ class BoxValue : public AbstractIrBox {
llvm::ArrayRef<mlir::Value> explicitParams,
llvm::ArrayRef<mlir::Value> explicitExtents = {})
: AbstractIrBox{addr, lbounds, explicitExtents},
explicitParams{explicitParams.begin(), explicitParams.end()} {
explicitParams{explicitParams} {
assert(verify());
}
// TODO: check contiguous attribute of addr
Expand Down
5 changes: 2 additions & 3 deletions flang/include/flang/Optimizer/Support/InternalNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ struct NameUniquer {
DeconstructedName(llvm::ArrayRef<std::string> modules,
llvm::ArrayRef<std::string> procs, std::int64_t blockId,
llvm::StringRef name, llvm::ArrayRef<std::int64_t> kinds)
: modules{modules.begin(), modules.end()}, procs{procs.begin(),
procs.end()},
blockId{blockId}, name{name}, kinds{kinds.begin(), kinds.end()} {}
: modules{modules}, procs{procs}, blockId{blockId}, name{name},
kinds{kinds} {}

llvm::SmallVector<std::string> modules;
llvm::SmallVector<std::string> procs;
Expand Down
6 changes: 2 additions & 4 deletions flang/lib/Lower/ConvertArrayConstructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,7 @@ class AsElementalStrategy : public StrategyBase {
fir::SequenceType declaredType, mlir::Value extent,
llvm::ArrayRef<mlir::Value> lengths)
: StrategyBase{stmtCtx, symMap}, shape{builder.genShape(loc, {extent})},
lengthParams{lengths.begin(), lengths.end()},
exprType{getExprType(declaredType)} {}
lengthParams{lengths}, exprType{getExprType(declaredType)} {}

static hlfir::ExprType getExprType(fir::SequenceType declaredType) {
// Note: 7.8 point 4: the dynamic type of an array constructor is its static
Expand Down Expand Up @@ -331,8 +330,7 @@ class RuntimeTempStrategy : public StrategyBase {
// Prepare the initial state of the allocatable descriptor with a
// deallocated status and all the available knowledge about the extent
// and length parameters.
llvm::SmallVector<mlir::Value> emboxLengths(lengths.begin(),
lengths.end());
llvm::SmallVector<mlir::Value> emboxLengths(lengths);
if (!extent)
extent = builder.createIntegerConstant(loc, builder.getIndexType(), 0);
if (missingLengthParameters) {
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Lower/IterationSpace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ArrayBaseFinder {
using RT = bool;

ArrayBaseFinder(llvm::ArrayRef<Fortran::lower::FrontEndSymbol> syms)
: controlVars(syms.begin(), syms.end()) {}
: controlVars(syms) {}

template <typename T>
void operator()(const T &x) {
Expand Down
5 changes: 2 additions & 3 deletions flang/lib/Optimizer/Transforms/AffineDemotion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,8 @@ class ConvertConversion : public mlir::OpRewritePattern<fir::ConvertOp> {
};

mlir::Type convertMemRef(mlir::MemRefType type) {
return fir::SequenceType::get(
SmallVector<int64_t>(type.getShape().begin(), type.getShape().end()),
type.getElementType());
return fir::SequenceType::get(SmallVector<int64_t>(type.getShape()),
type.getElementType());
}

class StdAllocConversion : public mlir::OpRewritePattern<memref::AllocOp> {
Expand Down
5 changes: 2 additions & 3 deletions flang/unittests/Optimizer/InternalNamesTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ struct DeconstructedName {
DeconstructedName(llvm::ArrayRef<std::string> modules,
llvm::ArrayRef<std::string> procs, std::int64_t blockId,
llvm::StringRef name, llvm::ArrayRef<std::int64_t> kinds)
: modules{modules.begin(), modules.end()}, procs{procs.begin(),
procs.end()},
blockId{blockId}, name{name}, kinds{kinds.begin(), kinds.end()} {}
: modules{modules}, procs{procs}, blockId{blockId}, name{name},
kinds{kinds} {}

bool isObjEqual(const NameUniquer::DeconstructedName &actualObj) {
return actualObj.modules == modules && actualObj.procs == procs &&
Expand Down
Loading