From 9abc710d84dc04670e9c3420df89d2779d5aacf8 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Tue, 23 Apr 2024 18:52:38 -0400 Subject: [PATCH 1/8] GH-41112: [C++] Replace [[maybe_unused]] with Arrow macro --- cpp/src/arrow/array/builder_base.h | 6 +++--- cpp/src/arrow/array/builder_nested.h | 2 +- cpp/src/arrow/array/builder_primitive.h | 4 ++-- cpp/src/arrow/device.h | 6 +++--- cpp/src/arrow/type.h | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cpp/src/arrow/array/builder_base.h b/cpp/src/arrow/array/builder_base.h index e6c0b2d2387..3a85318735f 100644 --- a/cpp/src/arrow/array/builder_base.h +++ b/cpp/src/arrow/array/builder_base.h @@ -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()); } diff --git a/cpp/src/arrow/array/builder_nested.h b/cpp/src/arrow/array/builder_nested.h index 9f7b0fcdbce..6089cf04d42 100644 --- a/cpp/src/arrow/array/builder_nested.h +++ b/cpp/src/arrow/array/builder_nested.h @@ -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)); } diff --git a/cpp/src/arrow/array/builder_primitive.h b/cpp/src/arrow/array/builder_primitive.h index db8d2cbaabb..de7af1b46bd 100644 --- a/cpp/src/arrow/array/builder_primitive.h +++ b/cpp/src/arrow/array/builder_primitive.h @@ -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& type, + explicit NullBuilder(const std::shared_ptr& ARROW_ARG_UNUSED(type), MemoryPool* pool = default_memory_pool(), int64_t alignment = kDefaultBufferAlignment) : NullBuilder(pool, alignment) {} diff --git a/cpp/src/arrow/device.h b/cpp/src/arrow/device.h index 3003bad7c45..a591167ef9a 100644 --- a/cpp/src/arrow/device.h +++ b/cpp/src/arrow/device.h @@ -140,7 +140,7 @@ class ARROW_EXPORT Device : public std::enable_shared_from_this, /// derived from Device::Stream to allow for stream ordered events /// and memory allocations. virtual Result> MakeStream( - [[maybe_unused]] unsigned int flags) { + unsigned int ARROW_ARG_UNUSED(flags)) { return NULLPTR; } @@ -151,8 +151,8 @@ class ARROW_EXPORT Device : public std::enable_shared_from_this, /// a no-op function can be passed to indicate ownership is maintained /// externally virtual Result> 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; } diff --git a/cpp/src/arrow/type.h b/cpp/src/arrow/type.h index 58c9df04ec5..bb05e6efdb9 100644 --- a/cpp/src/arrow/type.h +++ b/cpp/src/arrow/type.h @@ -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"; } @@ -1761,7 +1761,7 @@ class ARROW_EXPORT DayTimeIntervalType : public IntervalType { int bit_width() const override { return static_cast(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"; } @@ -1803,7 +1803,7 @@ class ARROW_EXPORT MonthDayNanoIntervalType : public IntervalType { int bit_width() const override { return static_cast(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"; } From f59188524c5d4f8f080b63dd572730d3df98ab27 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Wed, 24 Apr 2024 12:21:46 -0400 Subject: [PATCH 2/8] ARROW_ARG_UNUSED -> ARROW_UNUSED --- cpp/src/arrow/device.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cpp/src/arrow/device.h b/cpp/src/arrow/device.h index a591167ef9a..2757c2696fe 100644 --- a/cpp/src/arrow/device.h +++ b/cpp/src/arrow/device.h @@ -150,9 +150,10 @@ class ARROW_EXPORT Device : public std::enable_shared_from_this, /// @param release_fn a function to call during destruction, `nullptr` or /// a no-op function can be passed to indicate ownership is maintained /// externally - virtual Result> WrapStream( - void* ARROW_ARG_UNUSED(device_stream), - Stream::release_fn_t ARROW_ARG_UNUSED(release_fn)) { + virtual Result> WrapStream(void* device_stream, + Stream::release_fn_t release_fn) { + ARROW_UNUSED(device_stream); + ARROW_UNUSED(release_fn); return NULLPTR; } From f7defe45ab7013677ba360498874bfa75399f684 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Wed, 24 Apr 2024 17:17:55 -0400 Subject: [PATCH 3/8] Update Doxygen --- cpp/apidoc/Doxyfile | 11 ++++++----- cpp/src/arrow/device.h | 7 +++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cpp/apidoc/Doxyfile b/cpp/apidoc/Doxyfile index e19c933cd45..5be93032c00 100644 --- a/cpp/apidoc/Doxyfile +++ b/cpp/apidoc/Doxyfile @@ -2168,16 +2168,17 @@ INCLUDE_FILE_PATTERNS = PREDEFINED = __attribute__(x)= \ __declspec(x)= \ - PARQUET_EXPORT= \ - GANDIVA_EXPORT= \ - ARROW_EXPORT= \ ARROW_ACERO_EXPORT= \ + ARROW_ARG_UNUSED(x)=x \ + ARROW_DEPRECATED(x)= \ ARROW_DS_EXPORT= \ ARROW_ENGINE_EXPORT= \ + ARROW_EXPORT= \ + ARROW_EXTERN_TEMPLATE= \ ARROW_FLIGHT_EXPORT= \ ARROW_FLIGHT_SQL_EXPORT= \ - ARROW_EXTERN_TEMPLATE= \ - ARROW_DEPRECATED(x)= + GANDIVA_EXPORT= \ + PARQUET_EXPORT= # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The diff --git a/cpp/src/arrow/device.h b/cpp/src/arrow/device.h index 2757c2696fe..a591167ef9a 100644 --- a/cpp/src/arrow/device.h +++ b/cpp/src/arrow/device.h @@ -150,10 +150,9 @@ class ARROW_EXPORT Device : public std::enable_shared_from_this, /// @param release_fn a function to call during destruction, `nullptr` or /// a no-op function can be passed to indicate ownership is maintained /// externally - virtual Result> WrapStream(void* device_stream, - Stream::release_fn_t release_fn) { - ARROW_UNUSED(device_stream); - ARROW_UNUSED(release_fn); + virtual Result> WrapStream( + void* ARROW_ARG_UNUSED(device_stream), + Stream::release_fn_t ARROW_ARG_UNUSED(release_fn)) { return NULLPTR; } From 84cc37ea4c5dd1267dbf80e367b26ebc5b83c066 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Wed, 24 Apr 2024 18:15:25 -0400 Subject: [PATCH 4/8] Try EXPAND_AS_DEFINED --- cpp/apidoc/Doxyfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cpp/apidoc/Doxyfile b/cpp/apidoc/Doxyfile index 5be93032c00..5d4644bf403 100644 --- a/cpp/apidoc/Doxyfile +++ b/cpp/apidoc/Doxyfile @@ -2169,7 +2169,6 @@ INCLUDE_FILE_PATTERNS = PREDEFINED = __attribute__(x)= \ __declspec(x)= \ ARROW_ACERO_EXPORT= \ - ARROW_ARG_UNUSED(x)=x \ ARROW_DEPRECATED(x)= \ ARROW_DS_EXPORT= \ ARROW_ENGINE_EXPORT= \ @@ -2187,7 +2186,7 @@ PREDEFINED = __attribute__(x)= \ # definition found in the source code. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -EXPAND_AS_DEFINED = +EXPAND_AS_DEFINED = ARROW_ARG_UNUSED # If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will # remove all references to function-like macros that are alone on a line, have From 0e888e49f50fd214c6f0571ff076ebaf8e25ba36 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Wed, 24 Apr 2024 21:42:56 -0400 Subject: [PATCH 5/8] Revert "Try EXPAND_AS_DEFINED" This reverts commit 84cc37ea4c5dd1267dbf80e367b26ebc5b83c066. --- cpp/apidoc/Doxyfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpp/apidoc/Doxyfile b/cpp/apidoc/Doxyfile index 5d4644bf403..5be93032c00 100644 --- a/cpp/apidoc/Doxyfile +++ b/cpp/apidoc/Doxyfile @@ -2169,6 +2169,7 @@ INCLUDE_FILE_PATTERNS = PREDEFINED = __attribute__(x)= \ __declspec(x)= \ ARROW_ACERO_EXPORT= \ + ARROW_ARG_UNUSED(x)=x \ ARROW_DEPRECATED(x)= \ ARROW_DS_EXPORT= \ ARROW_ENGINE_EXPORT= \ @@ -2186,7 +2187,7 @@ PREDEFINED = __attribute__(x)= \ # definition found in the source code. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -EXPAND_AS_DEFINED = ARROW_ARG_UNUSED +EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will # remove all references to function-like macros that are alone on a line, have From dd0c7d409f03459a9eba94cb7aab374c34661242 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Thu, 25 Apr 2024 18:44:04 -0400 Subject: [PATCH 6/8] Undo doxygen changes --- cpp/apidoc/Doxyfile | 11 +++++------ cpp/src/arrow/device.h | 7 ++++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cpp/apidoc/Doxyfile b/cpp/apidoc/Doxyfile index 5be93032c00..e19c933cd45 100644 --- a/cpp/apidoc/Doxyfile +++ b/cpp/apidoc/Doxyfile @@ -2168,17 +2168,16 @@ INCLUDE_FILE_PATTERNS = PREDEFINED = __attribute__(x)= \ __declspec(x)= \ + PARQUET_EXPORT= \ + GANDIVA_EXPORT= \ + ARROW_EXPORT= \ ARROW_ACERO_EXPORT= \ - ARROW_ARG_UNUSED(x)=x \ - ARROW_DEPRECATED(x)= \ ARROW_DS_EXPORT= \ ARROW_ENGINE_EXPORT= \ - ARROW_EXPORT= \ - ARROW_EXTERN_TEMPLATE= \ ARROW_FLIGHT_EXPORT= \ ARROW_FLIGHT_SQL_EXPORT= \ - GANDIVA_EXPORT= \ - PARQUET_EXPORT= + ARROW_EXTERN_TEMPLATE= \ + ARROW_DEPRECATED(x)= # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The diff --git a/cpp/src/arrow/device.h b/cpp/src/arrow/device.h index a591167ef9a..2757c2696fe 100644 --- a/cpp/src/arrow/device.h +++ b/cpp/src/arrow/device.h @@ -150,9 +150,10 @@ class ARROW_EXPORT Device : public std::enable_shared_from_this, /// @param release_fn a function to call during destruction, `nullptr` or /// a no-op function can be passed to indicate ownership is maintained /// externally - virtual Result> WrapStream( - void* ARROW_ARG_UNUSED(device_stream), - Stream::release_fn_t ARROW_ARG_UNUSED(release_fn)) { + virtual Result> WrapStream(void* device_stream, + Stream::release_fn_t release_fn) { + ARROW_UNUSED(device_stream); + ARROW_UNUSED(release_fn); return NULLPTR; } From 19c3020a995feed87d2f1b5aa08d2b13981dd9a2 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Fri, 26 Apr 2024 12:39:25 -0400 Subject: [PATCH 7/8] Revert "Undo doxygen changes" This reverts commit dd0c7d409f03459a9eba94cb7aab374c34661242. --- cpp/apidoc/Doxyfile | 11 ++++++----- cpp/src/arrow/device.h | 7 +++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cpp/apidoc/Doxyfile b/cpp/apidoc/Doxyfile index e19c933cd45..5be93032c00 100644 --- a/cpp/apidoc/Doxyfile +++ b/cpp/apidoc/Doxyfile @@ -2168,16 +2168,17 @@ INCLUDE_FILE_PATTERNS = PREDEFINED = __attribute__(x)= \ __declspec(x)= \ - PARQUET_EXPORT= \ - GANDIVA_EXPORT= \ - ARROW_EXPORT= \ ARROW_ACERO_EXPORT= \ + ARROW_ARG_UNUSED(x)=x \ + ARROW_DEPRECATED(x)= \ ARROW_DS_EXPORT= \ ARROW_ENGINE_EXPORT= \ + ARROW_EXPORT= \ + ARROW_EXTERN_TEMPLATE= \ ARROW_FLIGHT_EXPORT= \ ARROW_FLIGHT_SQL_EXPORT= \ - ARROW_EXTERN_TEMPLATE= \ - ARROW_DEPRECATED(x)= + GANDIVA_EXPORT= \ + PARQUET_EXPORT= # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The diff --git a/cpp/src/arrow/device.h b/cpp/src/arrow/device.h index 2757c2696fe..a591167ef9a 100644 --- a/cpp/src/arrow/device.h +++ b/cpp/src/arrow/device.h @@ -150,10 +150,9 @@ class ARROW_EXPORT Device : public std::enable_shared_from_this, /// @param release_fn a function to call during destruction, `nullptr` or /// a no-op function can be passed to indicate ownership is maintained /// externally - virtual Result> WrapStream(void* device_stream, - Stream::release_fn_t release_fn) { - ARROW_UNUSED(device_stream); - ARROW_UNUSED(release_fn); + virtual Result> WrapStream( + void* ARROW_ARG_UNUSED(device_stream), + Stream::release_fn_t ARROW_ARG_UNUSED(release_fn)) { return NULLPTR; } From bdf0bfff1332e4446005d485462e2c9a0088fa9c Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Fri, 26 Apr 2024 12:40:59 -0400 Subject: [PATCH 8/8] Use macro for -Wdocumentation control --- cpp/cmake_modules/SetupCxxFlags.cmake | 1 + cpp/src/arrow/util/macros.h | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/cpp/cmake_modules/SetupCxxFlags.cmake b/cpp/cmake_modules/SetupCxxFlags.cmake index d56609c1239..ea357b47794 100644 --- a/cpp/cmake_modules/SetupCxxFlags.cmake +++ b/cpp/cmake_modules/SetupCxxFlags.cmake @@ -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") diff --git a/cpp/src/arrow/util/macros.h b/cpp/src/arrow/util/macros.h index d80828869b3..d0c05a79082 100644 --- a/cpp/src/arrow/util/macros.h +++ b/cpp/src/arrow/util/macros.h @@ -67,7 +67,11 @@ // [5] J. Doerfert et al. 2019. "Performance Exploration Through Optimistic Static // Program Annotations". https://github.com/jdoerfert/PETOSPA/blob/master/ISC19.pdf #define ARROW_UNUSED(x) (void)(x) +#ifdef ARROW_WARN_DOCUMENTATION +#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))