Alpaka: clangFormat broke indetation of complex compile-time guards

Created on 19 Nov 2020  路  3Comments  路  Source: alpaka-group/alpaka

Most helpful comment

I think clang-format may have uncovered a bug here. A && B || C is evaluated as (A && B) || C. In the example here:

(BOOST_COMP_GNUC < BOOST_VERSION_NUMBER(11, 0, 0)) && defined(TEST_UNIT_BLOCK_SHARED) || defined(TEST_UNIT_BLOCK_SYNC)

This will turn into (simplified the Boost stuff):

(BOOST_VERSION_CHECK && defined(TEST_UNIT_BLOCK_SHARED)) || defined(TEST_UNIT_BLOCK_SYNC)

Is this the actual intention of the macro?

All 3 comments

Firstly: clang-format is not perfect. But manual formatting is worse. And perfect is the enemy of the good ;)
Secondly: that whole #if directive is horrible IMO and probably needs a simplification anyway. E.g. we could split out all tests where OpenMP5 or OpenACC do not work into a separate macro and then use this macro inside the #if.

I think clang-format may have uncovered a bug here. A && B || C is evaluated as (A && B) || C. In the example here:

(BOOST_COMP_GNUC < BOOST_VERSION_NUMBER(11, 0, 0)) && defined(TEST_UNIT_BLOCK_SHARED) || defined(TEST_UNIT_BLOCK_SYNC)

This will turn into (simplified the Boost stuff):

(BOOST_VERSION_CHECK && defined(TEST_UNIT_BLOCK_SHARED)) || defined(TEST_UNIT_BLOCK_SYNC)

Is this the actual intention of the macro?

There is indeed a pair of parens missing. Still, the clang format did also not propertly reflect the wrong logic.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BenjaminW3 picture BenjaminW3  路  3Comments

BenjaminW3 picture BenjaminW3  路  5Comments

ax3l picture ax3l  路  3Comments

BenjaminW3 picture BenjaminW3  路  6Comments

kloppstock picture kloppstock  路  3Comments