未验证 提交 fc6d4399 编写于 作者: G Galaxy1458 提交者: GitHub

remove some [-Wunused-parameter] warning (#53092)

* test,test=develop

* test,test=develop

* test,test=develop

* test,test=develop
上级 8a1cdc70
...@@ -474,7 +474,7 @@ struct KernelRegistrar { ...@@ -474,7 +474,7 @@ struct KernelRegistrar {
variadic_kernel_unfold_marco, \ variadic_kernel_unfold_marco, \
__VA_ARGS__); \ __VA_ARGS__); \
void __PD_KERNEL_args_def_FN_##kernel_name##_##backend##_##layout( \ void __PD_KERNEL_args_def_FN_##kernel_name##_##backend##_##layout( \
const ::phi::KernelKey& kernel_key, ::phi::Kernel* kernel) const ::phi::KernelKey& kernel_key UNUSED, ::phi::Kernel* kernel UNUSED)
#else #else
/** /**
* `template decltype(fn) fn` can work on gcc and clang, * `template decltype(fn) fn` can work on gcc and clang,
......
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
// This file copy from llvm/ADT/SmallVector.h, version: 12.0.0 // This file copy from llvm/ADT/SmallVector.h, version: 12.0.0
// Modified the following points // Modified the following points
// 1. remove macro // 1. remove macro
...@@ -47,11 +48,12 @@ class iterator_range { ...@@ -47,11 +48,12 @@ class iterator_range {
IteratorT begin_iterator, end_iterator; IteratorT begin_iterator, end_iterator;
public: public:
// TODO: Add SFINAE to test that the Container's iterators match the range's // TODO(others): Add SFINAE to test that the Container's iterators match the
// range's
// iterators. // iterators.
template <typename Container> template <typename Container>
iterator_range(Container &&c) explicit iterator_range(Container &&c)
// TODO: Consider ADL/non-member begin/end calls. // TODO(others): Consider ADL/non-member begin/end calls.
: begin_iterator(c.begin()), end_iterator(c.end()) {} : begin_iterator(c.begin()), end_iterator(c.end()) {}
iterator_range(IteratorT begin_iterator, IteratorT end_iterator) iterator_range(IteratorT begin_iterator, IteratorT end_iterator)
: begin_iterator(std::move(begin_iterator)), : begin_iterator(std::move(begin_iterator)),
...@@ -102,7 +104,7 @@ class small_vector_base { ...@@ -102,7 +104,7 @@ class small_vector_base {
/// This is a helper for \a grow() that's out of line to reduce code /// This is a helper for \a grow() that's out of line to reduce code
/// duplication. This function will report a fatal error if it can't grow at /// duplication. This function will report a fatal error if it can't grow at
/// least to \p MinSize. /// least to \p MinSize.
void *mallocForGrow(size_t MinSize, size_t TSize, size_t &NewCapacity); void *mallocForGrow(size_t MinSize, size_t TSize, size_t *NewCapacity);
/// This is an implementation of the grow() method which only works /// This is an implementation of the grow() method which only works
/// on POD-like data types and is out of line to reduce code duplication. /// on POD-like data types and is out of line to reduce code duplication.
...@@ -162,7 +164,8 @@ class small_vector_template_common ...@@ -162,7 +164,8 @@ class small_vector_template_common
// Space after 'FirstEl' is clobbered, do not add any instance vars after it. // Space after 'FirstEl' is clobbered, do not add any instance vars after it.
protected: protected:
small_vector_template_common(size_t Size) : Base(getFirstEl(), Size) {} explicit small_vector_template_common(size_t Size)
: Base(getFirstEl(), Size) {}
void grow_pod(size_t MinSize, size_t TSize) { void grow_pod(size_t MinSize, size_t TSize) {
Base::grow_pod(getFirstEl(), MinSize, TSize); Base::grow_pod(getFirstEl(), MinSize, TSize);
...@@ -217,6 +220,8 @@ class small_vector_template_common ...@@ -217,6 +220,8 @@ class small_vector_template_common
/// Check whether Elt will be invalidated by resizing the vector to NewSize. /// Check whether Elt will be invalidated by resizing the vector to NewSize.
void assertSafeToReferenceAfterResize(const void *Elt, size_t NewSize) { void assertSafeToReferenceAfterResize(const void *Elt, size_t NewSize) {
(void)Elt;
(void)NewSize; // just remove [-Wunused-paremeter]
assert(isSafeToReferenceAfterResize(Elt, NewSize) && assert(isSafeToReferenceAfterResize(Elt, NewSize) &&
"Attempting to reference an element of the vector in an operation " "Attempting to reference an element of the vector in an operation "
"that invalidates it"); "that invalidates it");
...@@ -376,7 +381,7 @@ class small_vector_template_base : public small_vector_template_common<T> { ...@@ -376,7 +381,7 @@ class small_vector_template_base : public small_vector_template_common<T> {
static constexpr bool TakesParamByValue = false; static constexpr bool TakesParamByValue = false;
using ValueParamT = const T &; using ValueParamT = const T &;
small_vector_template_base(size_t Size) explicit small_vector_template_base(size_t Size)
: small_vector_template_common<T>(Size) {} : small_vector_template_common<T>(Size) {}
static void destroy_range(T *S, T *E) { static void destroy_range(T *S, T *E) {
...@@ -408,7 +413,7 @@ class small_vector_template_base : public small_vector_template_common<T> { ...@@ -408,7 +413,7 @@ class small_vector_template_base : public small_vector_template_common<T> {
/// Create a new allocation big enough for \p MinSize and pass back its size /// Create a new allocation big enough for \p MinSize and pass back its size
/// in \p NewCapacity. This is the first section of \a grow(). /// in \p NewCapacity. This is the first section of \a grow().
T *mallocForGrow(size_t MinSize, size_t &NewCapacity) { T *mallocForGrow(size_t MinSize, size_t *NewCapacity) {
return static_cast<T *>( return static_cast<T *>(
small_vector_base<SmallVectorSizeType<T>>::mallocForGrow( small_vector_base<SmallVectorSizeType<T>>::mallocForGrow(
MinSize, sizeof(T), NewCapacity)); MinSize, sizeof(T), NewCapacity));
...@@ -423,13 +428,7 @@ class small_vector_template_base : public small_vector_template_common<T> { ...@@ -423,13 +428,7 @@ class small_vector_template_base : public small_vector_template_common<T> {
/// Reserve enough space to add one element, and return the updated element /// Reserve enough space to add one element, and return the updated element
/// pointer in case it was a reference to the storage. /// pointer in case it was a reference to the storage.
const T *reserveForParamAndGetAddress(const T &Elt, size_t N = 1) { T *reserveForParamAndGetAddress(const T &Elt, size_t N = 1) {
return this->reserveForParamAndGetAddressImpl(this, Elt, N);
}
/// Reserve enough space to add one element, and return the updated element
/// pointer in case it was a reference to the storage.
T *reserveForParamAndGetAddress(T &Elt, size_t N = 1) {
return const_cast<T *>( return const_cast<T *>(
this->reserveForParamAndGetAddressImpl(this, Elt, N)); this->reserveForParamAndGetAddressImpl(this, Elt, N));
} }
...@@ -439,8 +438,8 @@ class small_vector_template_base : public small_vector_template_common<T> { ...@@ -439,8 +438,8 @@ class small_vector_template_base : public small_vector_template_common<T> {
void growAndAssign(size_t NumElts, const T &Elt) { void growAndAssign(size_t NumElts, const T &Elt) {
// Grow manually in case Elt is an internal reference. // Grow manually in case Elt is an internal reference.
size_t NewCapacity; size_t NewCapacity = 0;
T *NewElts = mallocForGrow(NumElts, NewCapacity); T *NewElts = mallocForGrow(NumElts, &NewCapacity);
std::uninitialized_fill_n(NewElts, NumElts, Elt); std::uninitialized_fill_n(NewElts, NumElts, Elt);
this->destroy_range(this->begin(), this->end()); this->destroy_range(this->begin(), this->end());
takeAllocationForGrow(NewElts, NewCapacity); takeAllocationForGrow(NewElts, NewCapacity);
...@@ -450,9 +449,10 @@ class small_vector_template_base : public small_vector_template_common<T> { ...@@ -450,9 +449,10 @@ class small_vector_template_base : public small_vector_template_common<T> {
template <typename... ArgTypes> template <typename... ArgTypes>
T &growAndEmplaceBack(ArgTypes &&...Args) { T &growAndEmplaceBack(ArgTypes &&...Args) {
// Grow manually in case one of Args is an internal reference. // Grow manually in case one of Args is an internal reference.
size_t NewCapacity; size_t NewCapacity = 0;
T *NewElts = mallocForGrow(0, NewCapacity); T *NewElts = mallocForGrow(0, &NewCapacity);
::new ((void *)(NewElts + this->size())) T(std::forward<ArgTypes>(Args)...); ::new (reinterpret_cast<void *>(NewElts + this->size()))
T(std::forward<ArgTypes>(Args)...);
moveElementsForGrow(NewElts); moveElementsForGrow(NewElts);
takeAllocationForGrow(NewElts, NewCapacity); takeAllocationForGrow(NewElts, NewCapacity);
this->set_size(this->size() + 1); this->set_size(this->size() + 1);
...@@ -462,13 +462,13 @@ class small_vector_template_base : public small_vector_template_common<T> { ...@@ -462,13 +462,13 @@ class small_vector_template_base : public small_vector_template_common<T> {
public: public:
void push_back(const T &Elt) { void push_back(const T &Elt) {
const T *EltPtr = reserveForParamAndGetAddress(Elt); const T *EltPtr = reserveForParamAndGetAddress(Elt);
::new ((void *)this->end()) T(*EltPtr); ::new (reinterpret_cast<void *>(this->end())) T(*EltPtr);
this->set_size(this->size() + 1); this->set_size(this->size() + 1);
} }
void push_back(T &&Elt) { void push_back(T &&Elt) {
T *EltPtr = reserveForParamAndGetAddress(Elt); T *EltPtr = reserveForParamAndGetAddress(Elt);
::new ((void *)this->end()) T(::std::move(*EltPtr)); ::new (reinterpret_cast<void *>(this->end())) T(::std::move(*EltPtr));
this->set_size(this->size() + 1); this->set_size(this->size() + 1);
} }
...@@ -481,8 +481,8 @@ class small_vector_template_base : public small_vector_template_common<T> { ...@@ -481,8 +481,8 @@ class small_vector_template_base : public small_vector_template_common<T> {
// Define this out-of-line to dissuade the C++ compiler from inlining it. // Define this out-of-line to dissuade the C++ compiler from inlining it.
template <typename T, bool TriviallyCopyable> template <typename T, bool TriviallyCopyable>
void small_vector_template_base<T, TriviallyCopyable>::grow(size_t MinSize) { void small_vector_template_base<T, TriviallyCopyable>::grow(size_t MinSize) {
size_t NewCapacity; size_t NewCapacity = 0;
T *NewElts = mallocForGrow(MinSize, NewCapacity); T *NewElts = mallocForGrow(MinSize, &NewCapacity);
moveElementsForGrow(NewElts); moveElementsForGrow(NewElts);
takeAllocationForGrow(NewElts, NewCapacity); takeAllocationForGrow(NewElts, NewCapacity);
} }
...@@ -528,7 +528,7 @@ class small_vector_template_base<T, true> ...@@ -528,7 +528,7 @@ class small_vector_template_base<T, true>
using ValueParamT = using ValueParamT =
typename std::conditional<TakesParamByValue, T, const T &>::type; typename std::conditional<TakesParamByValue, T, const T &>::type;
small_vector_template_base(size_t Size) explicit small_vector_template_base(size_t Size)
: small_vector_template_common<T>(Size) {} : small_vector_template_common<T>(Size) {}
// No need to do a destroy loop for POD's. // No need to do a destroy loop for POD's.
...@@ -572,13 +572,7 @@ class small_vector_template_base<T, true> ...@@ -572,13 +572,7 @@ class small_vector_template_base<T, true>
/// Reserve enough space to add one element, and return the updated element /// Reserve enough space to add one element, and return the updated element
/// pointer in case it was a reference to the storage. /// pointer in case it was a reference to the storage.
const T *reserveForParamAndGetAddress(const T &Elt, size_t N = 1) { T *reserveForParamAndGetAddress(const T &Elt, size_t N = 1) {
return this->reserveForParamAndGetAddressImpl(this, Elt, N);
}
/// Reserve enough space to add one element, and return the updated element
/// pointer in case it was a reference to the storage.
T *reserveForParamAndGetAddress(T &Elt, size_t N = 1) {
return const_cast<T *>( return const_cast<T *>(
this->reserveForParamAndGetAddressImpl(this, Elt, N)); this->reserveForParamAndGetAddressImpl(this, Elt, N));
} }
...@@ -813,7 +807,7 @@ class small_vector_impl : public small_vector_template_base<T> { ...@@ -813,7 +807,7 @@ class small_vector_impl : public small_vector_template_base<T> {
this->reserveForParamAndGetAddress(Elt); this->reserveForParamAndGetAddress(Elt);
I = this->begin() + Index; I = this->begin() + Index;
::new ((void *)this->end()) T(::std::move(this->back())); ::new (reinterpret_cast<void *>(this->end())) T(::std::move(this->back()));
// Push everything else over. // Push everything else over.
std::move_backward(I, this->end() - 1, this->end()); std::move_backward(I, this->end() - 1, this->end());
this->set_size(this->size() + 1); this->set_size(this->size() + 1);
...@@ -973,7 +967,8 @@ class small_vector_impl : public small_vector_template_base<T> { ...@@ -973,7 +967,8 @@ class small_vector_impl : public small_vector_template_base<T> {
if (this->size() >= this->capacity()) if (this->size() >= this->capacity())
return this->growAndEmplaceBack(std::forward<ArgTypes>(Args)...); return this->growAndEmplaceBack(std::forward<ArgTypes>(Args)...);
::new ((void *)this->end()) T(std::forward<ArgTypes>(Args)...); ::new (reinterpret_cast<void *>(this->end()))
T(std::forward<ArgTypes>(Args)...);
this->set_size(this->size() + 1); this->set_size(this->size() + 1);
return this->back(); return this->back();
} }
...@@ -1276,7 +1271,7 @@ class small_vector : public small_vector_impl<T>, small_vector_storage<T, N> { ...@@ -1276,7 +1271,7 @@ class small_vector : public small_vector_impl<T>, small_vector_storage<T, N> {
if (!RHS.empty()) small_vector_impl<T>::operator=(::std::move(RHS)); if (!RHS.empty()) small_vector_impl<T>::operator=(::std::move(RHS));
} }
small_vector(small_vector_impl<T> &&RHS) : small_vector_impl<T>(N) { explicit small_vector(small_vector_impl<T> &&RHS) : small_vector_impl<T>(N) {
if (!RHS.empty()) small_vector_impl<T>::operator=(::std::move(RHS)); if (!RHS.empty()) small_vector_impl<T>::operator=(::std::move(RHS));
} }
...@@ -1349,14 +1344,14 @@ inline void *safe_realloc(void *Ptr, size_t Sz) { ...@@ -1349,14 +1344,14 @@ inline void *safe_realloc(void *Ptr, size_t Sz) {
} }
// Check that no bytes are wasted and everything is well-aligned. // Check that no bytes are wasted and everything is well-aligned.
namespace {
struct Struct16B { struct Struct16B {
alignas(16) void *X; alignas(16) void *X;
}; };
struct Struct32B { struct Struct32B {
alignas(32) void *X; alignas(32) void *X;
}; };
} // namespace
static_assert(sizeof(small_vector<void *, 0>) == static_assert(sizeof(small_vector<void *, 0>) ==
sizeof(unsigned) * 2 + sizeof(void *), sizeof(unsigned) * 2 + sizeof(void *),
"wasted space in small_vector size 0"); "wasted space in small_vector size 0");
...@@ -1399,7 +1394,7 @@ static void report_at_maximum_capacity(size_t MaxSize) { ...@@ -1399,7 +1394,7 @@ static void report_at_maximum_capacity(size_t MaxSize) {
// Note: Moving this function into the header may cause performance regression. // Note: Moving this function into the header may cause performance regression.
template <class Size_T> template <class Size_T>
static size_t getNewCapacity(size_t MinSize, size_t TSize, size_t OldCapacity) { static size_t getNewCapacity(size_t MinSize, size_t OldCapacity) {
constexpr size_t MaxSize = (std::numeric_limits<Size_T>::max)(); constexpr size_t MaxSize = (std::numeric_limits<Size_T>::max)();
// Ensure we can fit the new capacity. // Ensure we can fit the new capacity.
...@@ -1422,9 +1417,9 @@ static size_t getNewCapacity(size_t MinSize, size_t TSize, size_t OldCapacity) { ...@@ -1422,9 +1417,9 @@ static size_t getNewCapacity(size_t MinSize, size_t TSize, size_t OldCapacity) {
template <class Size_T> template <class Size_T>
void *small_vector_base<Size_T>::mallocForGrow(size_t MinSize, void *small_vector_base<Size_T>::mallocForGrow(size_t MinSize,
size_t TSize, size_t TSize,
size_t &NewCapacity) { size_t *NewCapacity) {
NewCapacity = getNewCapacity<Size_T>(MinSize, TSize, this->capacity()); *NewCapacity = getNewCapacity<Size_T>(MinSize, this->capacity());
return safe_malloc(NewCapacity * TSize); return safe_malloc((*NewCapacity) * TSize);
} }
// Note: Moving this function into the header may cause performance regression. // Note: Moving this function into the header may cause performance regression.
...@@ -1432,7 +1427,7 @@ template <class Size_T> ...@@ -1432,7 +1427,7 @@ template <class Size_T>
void small_vector_base<Size_T>::grow_pod(void *FirstEl, void small_vector_base<Size_T>::grow_pod(void *FirstEl,
size_t MinSize, size_t MinSize,
size_t TSize) { size_t TSize) {
size_t NewCapacity = getNewCapacity<Size_T>(MinSize, TSize, this->capacity()); size_t NewCapacity = getNewCapacity<Size_T>(MinSize, this->capacity());
void *NewElts; void *NewElts;
if (BeginX == FirstEl) { if (BeginX == FirstEl) {
NewElts = safe_malloc(NewCapacity * TSize); NewElts = safe_malloc(NewCapacity * TSize);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册