[llvm] [ADT] Refactor SmallVector::assertSafeToAddRange with "constexpr if" (PR #160004)
Peter Klausler via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 22 11:16:07 PDT 2025
klausler wrote:
This commit is breaking my flang builds.
```
In file included from /home/pklausler/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:13,
from /home/pklausler/llvm-project/llvm/include/llvm/Support/MemoryBuffer.h:17,
from /home/pklausler/llvm-project/flang/include/flang/Parser/source.h:19,
from /home/pklausler/llvm-project/flang/include/flang/Parser/provenance.h:15,
from /home/pklausler/llvm-project/flang/include/flang/Parser/message.h:17,
from /home/pklausler/llvm-project/flang/include/flang/Evaluate/common.h:19,
from /home/pklausler/llvm-project/flang/include/flang/Evaluate/expression.h:19,
from /home/pklausler/llvm-project/flang/include/flang/Semantics/type.h:13,
from /home/pklausler/llvm-project/flang/include/flang/Semantics/symbol.h:12,
from /home/pklausler/llvm-project/flang/include/flang/Support/OpenMP-utils.h:12,
from /home/pklausler/llvm-project/flang/lib/Support/OpenMP-utils.cpp:9:
/home/pklausler/llvm-project/llvm/include/llvm/ADT/SmallVector.h: In instantiation of ‘void llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::asser
tSafeToAddRange(ItTy, ItTy) [with ItTy = llvm::mapped_iterator<const mlir::AffineExpr*, mlir::AffineMap::shiftDims(unsigned int, unsigned int) const::<lambda(ml
ir::AffineExpr)>, mlir::AffineExpr>; T = mlir::AffineExpr; <template-parameter-1-2> = void]’:
/home/pklausler/llvm-project/llvm/include/llvm/ADT/SmallVector.h:684:5: required from ‘void llvm::SmallVectorImpl<T>::append(ItTy, ItTy) [with ItTy = llvm::ma
pped_iterator<const mlir::AffineExpr*, mlir::AffineMap::shiftDims(unsigned int, unsigned int) const::<lambda(mlir::AffineExpr)>, mlir::AffineExpr>; <template-pa
rameter-2-2> = void; T = mlir::AffineExpr]’
/home/pklausler/llvm-project/llvm/include/llvm/ADT/SmallVector.h:1217:5: required from ‘llvm::SmallVector<T, N>::SmallVector(ItTy, ItTy) [with ItTy = llvm::ma
pped_iterator<const mlir::AffineExpr*, mlir::AffineMap::shiftDims(unsigned int, unsigned int) const::<lambda(mlir::AffineExpr)>, mlir::AffineExpr>; <template-pa
rameter-2-2> = void; T = mlir::AffineExpr; unsigned int N = 4]’
/home/pklausler/llvm-project/llvm/include/llvm/ADT/SmallVector.h:1300:45: required from ‘llvm::SmallVector<typename std::remove_const<typename std::remove_ref
erence<decltype (* std::begin(declval<R&>()))>::type>::type, Size> llvm::to_vector(R&&) [with unsigned int Size = 4; R = llvm::iterator_range<llvm::mapped_itera
tor<const mlir::AffineExpr*, mlir::AffineMap::shiftDims(unsigned int, unsigned int) const::<lambda(mlir::AffineExpr)>, mlir::AffineExpr> >; typename std::remove
_const<typename std::remove_reference<decltype (* std::begin(declval<R&>()))>::type>::type = mlir::AffineExpr]’
/home/pklausler/llvm-project/llvm/include/llvm/ADT/SmallVectorExtras.h:39:25: required from ‘auto llvm::map_to_vector(ContainerTy&&, FuncTy&&) [with unsigned
int Size = 4; ContainerTy = llvm::ArrayRef<mlir::AffineExpr>; FuncTy = mlir::AffineMap::shiftDims(unsigned int, unsigned int) const::<lambda(mlir::AffineExpr)>]
’
/home/pklausler/llvm-project/mlir/include/mlir/IR/AffineMap.h:274:32: required from here
/home/pklausler/llvm-project/llvm/include/llvm/ADT/SmallVector.h:215:56: error: parameter ‘From’ set but not used [-Werror=unused-but-set-parameter]
215 | template <class ItTy> void assertSafeToAddRange(ItTy From, ItTy To) {
| ~~~~~^~~~
/home/pklausler/llvm-project/llvm/include/llvm/ADT/SmallVector.h:215:67: error: parameter ‘To’ set but not used [-Werror=unused-but-set-parameter]
215 | template <class ItTy> void assertSafeToAddRange(ItTy From, ItTy To) {
| ~~~~~^~
```
This is on x86-64 with GCC 9.3.0.
Please advise, fix, or revert.
https://github.com/llvm/llvm-project/pull/160004
More information about the llvm-commits
mailing list