Skip to content

Commit

Permalink
apacheGH-41367: [C++] Replace [[maybe_unused]] with Arrow macro (apac…
Browse files Browse the repository at this point in the history
…he#41359)

### Rationale for this change

This is a follow up to apache#41111 which was created as an issue in apache#41367

### What changes are included in this PR?

Replace [[maybe_unused]] with Arrow macro

### Are these changes tested?

Builds cleanly

### Are there any user-facing changes?

No

* GitHub Issue: apache#41367

Authored-by: Will Ayd <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
  • Loading branch information
WillAyd authored and rok committed May 8, 2024
1 parent 07af4bf commit b522f63
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions cpp/cmake_modules/SetupCxxFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ if("${BUILD_WARNING_LEVEL}" STREQUAL "CHECKIN")
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wall")
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wextra")
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wdocumentation")
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -DARROW_WARN_DOCUMENTATION")
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
# size_t is 32 bit in Emscripten wasm32 - ignore conversion errors
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-shorten-64-to-32")
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/arrow/array/builder_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ class ARROW_EXPORT ArrayBuilder {
/// \brief Append a range of values from an array.
///
/// The given array must be the same type as the builder.
virtual Status AppendArraySlice([[maybe_unused]] const ArraySpan& array,
[[maybe_unused]] int64_t offset,
[[maybe_unused]] int64_t length) {
virtual Status AppendArraySlice(const ArraySpan& ARROW_ARG_UNUSED(array),
int64_t ARROW_ARG_UNUSED(offset),
int64_t ARROW_ARG_UNUSED(length)) {
return Status::NotImplemented("AppendArraySlice for builder for ", *type());
}

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/array/builder_nested.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class ARROW_EXPORT VarLengthListLikeBuilder : public ArrayBuilder {
/// \brief Append dimensions for a single list slot.
///
/// ListViewBuilder overrides this to also append the size.
virtual void UnsafeAppendDimensions(int64_t offset, [[maybe_unused]] int64_t size) {
virtual void UnsafeAppendDimensions(int64_t offset, int64_t ARROW_ARG_UNUSED(size)) {
offsets_builder_.UnsafeAppend(static_cast<offset_type>(offset));
}

Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/array/builder_primitive.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ namespace arrow {
class ARROW_EXPORT NullBuilder : public ArrayBuilder {
public:
explicit NullBuilder(MemoryPool* pool = default_memory_pool(),
[[maybe_unused]] int64_t alignment = kDefaultBufferAlignment)
int64_t ARROW_ARG_UNUSED(alignment) = kDefaultBufferAlignment)
: ArrayBuilder(pool) {}

explicit NullBuilder([[maybe_unused]] const std::shared_ptr<DataType>& type,
explicit NullBuilder(const std::shared_ptr<DataType>& ARROW_ARG_UNUSED(type),
MemoryPool* pool = default_memory_pool(),
int64_t alignment = kDefaultBufferAlignment)
: NullBuilder(pool, alignment) {}
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/arrow/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class ARROW_EXPORT Device : public std::enable_shared_from_this<Device>,
/// derived from Device::Stream to allow for stream ordered events
/// and memory allocations.
virtual Result<std::shared_ptr<Stream>> MakeStream(
[[maybe_unused]] unsigned int flags) {
unsigned int ARROW_ARG_UNUSED(flags)) {
return NULLPTR;
}

Expand All @@ -151,8 +151,8 @@ class ARROW_EXPORT Device : public std::enable_shared_from_this<Device>,
/// a no-op function can be passed to indicate ownership is maintained
/// externally
virtual Result<std::shared_ptr<Stream>> WrapStream(
[[maybe_unused]] void* device_stream,
[[maybe_unused]] Stream::release_fn_t release_fn) {
void* ARROW_ARG_UNUSED(device_stream),
Stream::release_fn_t ARROW_ARG_UNUSED(release_fn)) {
return NULLPTR;
}

Expand Down
6 changes: 3 additions & 3 deletions cpp/src/arrow/type.h
Original file line number Diff line number Diff line change
Expand Up @@ -1723,7 +1723,7 @@ class ARROW_EXPORT MonthIntervalType : public IntervalType {

MonthIntervalType() : IntervalType(type_id) {}

std::string ToString([[maybe_unused]] bool show_metadata = false) const override {
std::string ToString(bool ARROW_ARG_UNUSED(show_metadata) = false) const override {
return name();
}
std::string name() const override { return "month_interval"; }
Expand Down Expand Up @@ -1761,7 +1761,7 @@ class ARROW_EXPORT DayTimeIntervalType : public IntervalType {

int bit_width() const override { return static_cast<int>(sizeof(c_type) * CHAR_BIT); }

std::string ToString([[maybe_unused]] bool show_metadata = false) const override {
std::string ToString(bool ARROW_ARG_UNUSED(show_metadata) = false) const override {
return name();
}
std::string name() const override { return "day_time_interval"; }
Expand Down Expand Up @@ -1803,7 +1803,7 @@ class ARROW_EXPORT MonthDayNanoIntervalType : public IntervalType {

int bit_width() const override { return static_cast<int>(sizeof(c_type) * CHAR_BIT); }

std::string ToString([[maybe_unused]] bool show_metadata = false) const override {
std::string ToString(bool ARROW_ARG_UNUSED(show_metadata) = false) const override {
return name();
}
std::string name() const override { return "month_day_nano_interval"; }
Expand Down
1 change: 1 addition & 0 deletions cpp/src/arrow/util/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
#define ARROW_ARG_UNUSED(x) x
#else
#define ARROW_ARG_UNUSED(x)
#endif
#if defined(__GNUC__) // GCC and compatible compilers (clang, Intel ICC)
#define ARROW_NORETURN __attribute__((noreturn))
#define ARROW_NOINLINE __attribute__((noinline))
Expand Down

0 comments on commit b522f63

Please sign in to comment.