Skip to content

Conversation

@WillAyd
Copy link
Contributor

@WillAyd WillAyd commented Apr 23, 2024

Rationale for this change

This is a follow up to #41111 which was created as an issue in #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

@kou
Copy link
Member

kou commented Apr 23, 2024

Could you open a new issue for this? In general, we use one issue per PR.

@kou
Copy link
Member

kou commented Apr 23, 2024

@github-actions crossbow submit almalinux-8-amd64

@github-actions
Copy link

Revision: 9abc710

Submitted crossbow builds: ursacomputing/crossbow @ actions-4f5b08fc0b

Task Status
almalinux-8-amd64 GitHub Actions

@vibhatha vibhatha requested a review from bkietz April 23, 2024 23:52
@WillAyd WillAyd changed the title GH-41112: [C++] Replace [[maybe_unused]] with Arrow macro GH-41367: [C++] Replace [[maybe_unused]] with Arrow macro Apr 24, 2024
@github-actions
Copy link

⚠️ GitHub issue #41367 has been automatically assigned in GitHub to PR creator.

@WillAyd
Copy link
Contributor Author

WillAyd commented Apr 24, 2024

As far as I can tell none of the current CI failures are related to this change

@kou
Copy link
Member

kou commented Apr 24, 2024

The "AMD64 macOS 12 GLib & Ruby" failure: #41369

@kou
Copy link
Member

kou commented Apr 24, 2024

The "AMD64 macOS 12 MATLAB" failure: #41370

@kou
Copy link
Member

kou commented Apr 24, 2024

The "Source Release and Merge Script on macos-latest" failure: #41371

Comment on lines 153 to 156
virtual Result<std::shared_ptr<Stream>> WrapStream(void* device_stream,
Stream::release_fn_t release_fn) {
ARROW_UNUSED(device_stream);
ARROW_UNUSED(release_fn);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use ARROW_ARG_UNUSED() by adding ARROW_ARG_UNUSED(x)=x to Doxygen's PREDEFINED?

(ARROW_ARG_UNUSED(x)=x is added and the list is sorted.)

diff --git a/cpp/apidoc/Doxyfile b/cpp/apidoc/Doxyfile
index e19c933cd4..5be93032c0 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

See also: https://www.doxygen.nl/manual/preprocessing.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can get this to work with smaller examples but no such luck yet with the Arrow build. Need to investigate further

Copy link
Contributor Author

@WillAyd WillAyd Apr 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After some more digging it seems like what you suggested works for Doxygen to generate the appropriate output, but that seems to have no bearing on clang. I think this issue upstream is related llvm/llvm-project#77489

Copy link
Contributor Author

@WillAyd WillAyd Apr 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's an MRE.

test.cc:

#define ARG_UNUSED(x)

/// @brief A function
///
/// @param foo - this is not really used
void SomeFunction(void ARG_UNUSED(foo)) {
  return;
}

Doxyfile:

PROJECT_NAME      = foo
INPUT             = test.cc
MACRO_EXPANSION   = YES
PREDEFINED        = ARG_UNUSED(x)=x

doxygen -d Preprocessor output:

Doxygen version used: 1.9.1
Searching for include files...
Searching for example files...
Searching for images...
Searching for dot files...
Searching for msc files...
Searching for dia files...
Searching for files to exclude
Searching INPUT for files to process...
Reading and parsing tag files
Parsing files
Preprocessing /home/willayd/Desktop/test.cc...
Preprocessor output of /home/willayd/Desktop/test.cc (size: 134 bytes):
---------
00001 #define ARG_UNUSED(x)
00002 
00003 /// @brief A function
00004 ///
00005 /// @param foo - this is not really used
00006 void SomeFunction(void  foo ) {
00007   return;
00008 }
00009 
---------
Macros accessible in this file (/home/willayd/Desktop/test.cc):
---------
ARG_UNUSED 
---------

clang++ test.cc -Wdocumentation -shared output:

test.cc:5:12: warning: parameter 'foo' not found in the function declaration [-Wdocumentation]
/// @param foo - this is not really used
           ^~~
1 warning generated.

Copy link
Member

@kou kou Apr 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh... How about this?

diff --git a/cpp/cmake_modules/SetupCxxFlags.cmake b/cpp/cmake_modules/SetupCxxFlags.cmake
index d56609c123..ea357b4779 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 d80828869b..6faf25b3c9 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))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pushed up this change

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting review Awaiting review labels Apr 24, 2024
@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Apr 24, 2024
@kevingurney
Copy link
Member

The "AMD64 macOS 12 MATLAB" failure: #41370

FYI - this issue has been addressed in #41384.

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting change review Awaiting change review labels Apr 26, 2024
@raulcd
Copy link
Member

raulcd commented Apr 26, 2024

@github-actions crossbow submit centos

@github-actions
Copy link

Revision: dd0c7d4

Submitted crossbow builds: ursacomputing/crossbow @ actions-71b6b957bd

Task Status
centos-7-amd64 GitHub Actions
centos-8-stream-amd64 GitHub Actions
centos-8-stream-arm64 GitHub Actions
centos-9-stream-amd64 GitHub Actions
centos-9-stream-arm64 GitHub Actions
test-r-rstudio-r-base-4.2-centos7-devtoolset-8 Azure

@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Apr 26, 2024
@kou
Copy link
Member

kou commented Apr 27, 2024

@github-actions crossbow submit preview-docs

@github-actions
Copy link

Revision: bdf0bff

Submitted crossbow builds: ursacomputing/crossbow @ actions-eb949ffd4d

Task Status
preview-docs GitHub Actions

@jonkeane
Copy link
Member

@github-actions crossbow submit test-r-rstudio-r-base-4.1-opensuse153

@github-actions
Copy link

Revision: bdf0bff

Submitted crossbow builds: ursacomputing/crossbow @ actions-8f6e4a0c9c

Task Status
test-r-rstudio-r-base-4.1-opensuse153 Azure

Copy link
Member

@kou kou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@github-actions github-actions bot added awaiting merge Awaiting merge and removed awaiting change review Awaiting change review labels Apr 27, 2024
@kou kou merged commit 5ee70ee into apache:main Apr 27, 2024
@kou kou removed the awaiting merge Awaiting merge label Apr 27, 2024
@conbench-apache-arrow
Copy link

After merging your PR, Conbench analyzed the 7 benchmarking runs that have been run so far on merge-commit 5ee70ee.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 8 possible false positives for unstable benchmarks that are known to sometimes produce them.

@WillAyd WillAyd deleted the arrow-unused branch April 28, 2024 17:36
vibhatha pushed a commit to vibhatha/arrow that referenced this pull request May 25, 2024
…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 <william.ayd@icloud.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants