Skip to content

Commit 5ad0b3e

Browse files
authored
apacheGH-43796: [C++] Indent preprocessor directives (apache#43798)
### Rationale for this change This is for easy to read. FYI: Google C++ style guide doesn't require indent in preprocessor directives nor deny it: https://google.github.io/styleguide/cppguide.html#Preprocessor_Directives ```cpp // Good - directives at beginning of line if (lopsided_score) { #if DISASTER_PENDING // Correct -- Starts at beginning of line DropEverything(); # if NOTIFY // OK but not required -- Spaces after # NotifyClient(); # endif #endif BackToNormal(); } ``` ### What changes are included in this PR? * Add clang-format configurations for preprocessor directives indentation * Apply these configurations ### Are these changes tested? Yes. ### Are there any user-facing changes? No. * GitHub Issue: apache#43796 Authored-by: Sutou Kouhei <[email protected]> Signed-off-by: Sutou Kouhei <[email protected]>
1 parent 262d6f6 commit 5ad0b3e

File tree

147 files changed

+1425
-1418
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+1425
-1418
lines changed

.clang-format

+1
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ BasedOnStyle: Google
1919
ColumnLimit: 90
2020
DerivePointerAlignment: false
2121
IncludeBlocks: Preserve
22+
IndentPPDirectives: AfterHash

cpp/src/arrow/acero/aggregate_benchmark.cc

+8-8
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,11 @@ struct SumSentinelUnrolled : public Summer<T> {
165165
static void Sum(const ArrayType& array, SumState<T>* state) {
166166
SumState<T> local;
167167

168-
#define SUM_NOT_NULL(ITEM) \
169-
do { \
170-
local.total += values[i + ITEM] * Traits<T>::NotNull(values[i + ITEM]); \
171-
local.valid_count++; \
172-
} while (0)
168+
# define SUM_NOT_NULL(ITEM) \
169+
do { \
170+
local.total += values[i + ITEM] * Traits<T>::NotNull(values[i + ITEM]); \
171+
local.valid_count++; \
172+
} while (0)
173173

174174
const auto values = array.raw_values();
175175
const auto length = array.length();
@@ -185,7 +185,7 @@ struct SumSentinelUnrolled : public Summer<T> {
185185
SUM_NOT_NULL(7);
186186
}
187187

188-
#undef SUM_NOT_NULL
188+
# undef SUM_NOT_NULL
189189

190190
for (int64_t i = length_rounded * 8; i < length; ++i) {
191191
local.total += values[i] * Traits<T>::NotNull(values[i]);
@@ -256,7 +256,7 @@ struct SumBitmapVectorizeUnroll : public Summer<T> {
256256
for (int64_t i = 0; i < length_rounded; i += 8) {
257257
const uint8_t valid_byte = bitmap[i / 8];
258258

259-
#define SUM_SHIFT(ITEM) (values[i + ITEM] * ((valid_byte >> ITEM) & 1))
259+
# define SUM_SHIFT(ITEM) (values[i + ITEM] * ((valid_byte >> ITEM) & 1))
260260

261261
if (valid_byte < 0xFF) {
262262
// Some nulls
@@ -277,7 +277,7 @@ struct SumBitmapVectorizeUnroll : public Summer<T> {
277277
}
278278
}
279279

280-
#undef SUM_SHIFT
280+
# undef SUM_SHIFT
281281

282282
for (int64_t i = length_rounded; i < length; ++i) {
283283
if (bit_util::GetBit(bitmap, i)) {

cpp/src/arrow/acero/asof_join_node.cc

+11-11
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@
3434
#include "arrow/acero/options.h"
3535
#include "arrow/acero/unmaterialized_table_internal.h"
3636
#ifndef NDEBUG
37-
#include "arrow/acero/options_internal.h"
37+
# include "arrow/acero/options_internal.h"
3838
#endif
3939
#include "arrow/acero/query_context.h"
4040
#include "arrow/acero/schema_util.h"
4141
#include "arrow/acero/util.h"
4242
#include "arrow/array/builder_binary.h"
4343
#include "arrow/array/builder_primitive.h"
4444
#ifndef NDEBUG
45-
#include "arrow/compute/function_internal.h"
45+
# include "arrow/compute/function_internal.h"
4646
#endif
4747
#include "arrow/acero/time_series_util.h"
4848
#include "arrow/compute/key_hash_internal.h"
@@ -207,16 +207,16 @@ class DebugSync {
207207
std::unique_lock<std::mutex> debug_lock_;
208208
};
209209

210-
#define DEBUG_SYNC(node, ...) DebugSync(node).insert(__VA_ARGS__)
211-
#define DEBUG_MANIP(manip) \
212-
DebugSync::Manip([](DebugSync& d) -> DebugSync& { return d << manip; })
213-
#define NDEBUG_EXPLICIT
214-
#define DEBUG_ADD(ndebug, ...) ndebug, __VA_ARGS__
210+
# define DEBUG_SYNC(node, ...) DebugSync(node).insert(__VA_ARGS__)
211+
# define DEBUG_MANIP(manip) \
212+
DebugSync::Manip([](DebugSync& d) -> DebugSync& { return d << manip; })
213+
# define NDEBUG_EXPLICIT
214+
# define DEBUG_ADD(ndebug, ...) ndebug, __VA_ARGS__
215215
#else
216-
#define DEBUG_SYNC(...)
217-
#define DEBUG_MANIP(...)
218-
#define NDEBUG_EXPLICIT explicit
219-
#define DEBUG_ADD(ndebug, ...) ndebug
216+
# define DEBUG_SYNC(...)
217+
# define DEBUG_MANIP(...)
218+
# define NDEBUG_EXPLICIT explicit
219+
# define DEBUG_ADD(ndebug, ...) ndebug
220220
#endif
221221

222222
struct MemoStore {

cpp/src/arrow/acero/asof_join_node_test.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
#include "arrow/acero/exec_plan.h"
2727
#include "arrow/testing/future_util.h"
2828
#ifndef NDEBUG
29-
#include <sstream>
29+
# include <sstream>
3030
#endif
3131
#include <unordered_set>
3232

3333
#include "arrow/acero/options.h"
3434
#ifndef NDEBUG
35-
#include "arrow/acero/options_internal.h"
35+
# include "arrow/acero/options_internal.h"
3636
#endif
3737
#include "arrow/acero/map_node.h"
3838
#include "arrow/acero/query_context.h"

cpp/src/arrow/acero/bloom_filter.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#pragma once
1919

2020
#if defined(ARROW_HAVE_RUNTIME_AVX2)
21-
#include <immintrin.h>
21+
# include <immintrin.h>
2222
#endif
2323

2424
#include <atomic>

cpp/src/arrow/acero/bloom_filter_test.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,9 @@ TEST(BloomFilter, Scaling) {
503503
num_build.push_back(4000000);
504504

505505
std::vector<BloomFilterBuildStrategy> strategies;
506-
#ifdef ARROW_ENABLE_THREADING
506+
# ifdef ARROW_ENABLE_THREADING
507507
strategies.push_back(BloomFilterBuildStrategy::PARALLEL);
508-
#endif
508+
# endif
509509
strategies.push_back(BloomFilterBuildStrategy::SINGLE_THREADED);
510510

511511
for (const auto hardware_flags : HardwareFlagsForTesting()) {

cpp/src/arrow/acero/options_internal.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
#pragma once
1919

2020
#ifndef NDEBUG
21-
#include <mutex>
22-
#include <ostream>
21+
# include <mutex>
22+
# include <ostream>
2323
#endif
2424

2525
namespace arrow {

cpp/src/arrow/acero/visibility.h

+21-21
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,31 @@
2020
#pragma once
2121

2222
#if defined(_WIN32) || defined(__CYGWIN__)
23-
#if defined(_MSC_VER)
24-
#pragma warning(push)
25-
#pragma warning(disable : 4251)
26-
#else
27-
#pragma GCC diagnostic ignored "-Wattributes"
28-
#endif
23+
# if defined(_MSC_VER)
24+
# pragma warning(push)
25+
# pragma warning(disable : 4251)
26+
# else
27+
# pragma GCC diagnostic ignored "-Wattributes"
28+
# endif
2929

30-
#ifdef ARROW_ACERO_STATIC
31-
#define ARROW_ACERO_EXPORT
32-
#elif defined(ARROW_ACERO_EXPORTING)
33-
#define ARROW_ACERO_EXPORT __declspec(dllexport)
34-
#else
35-
#define ARROW_ACERO_EXPORT __declspec(dllimport)
36-
#endif
30+
# ifdef ARROW_ACERO_STATIC
31+
# define ARROW_ACERO_EXPORT
32+
# elif defined(ARROW_ACERO_EXPORTING)
33+
# define ARROW_ACERO_EXPORT __declspec(dllexport)
34+
# else
35+
# define ARROW_ACERO_EXPORT __declspec(dllimport)
36+
# endif
3737

38-
#define ARROW_ACERO_NO_EXPORT
38+
# define ARROW_ACERO_NO_EXPORT
3939
#else // Not Windows
40-
#ifndef ARROW_ACERO_EXPORT
41-
#define ARROW_ACERO_EXPORT __attribute__((visibility("default")))
42-
#endif
43-
#ifndef ARROW_ACERO_NO_EXPORT
44-
#define ARROW_ACERO_NO_EXPORT __attribute__((visibility("hidden")))
45-
#endif
40+
# ifndef ARROW_ACERO_EXPORT
41+
# define ARROW_ACERO_EXPORT __attribute__((visibility("default")))
42+
# endif
43+
# ifndef ARROW_ACERO_NO_EXPORT
44+
# define ARROW_ACERO_NO_EXPORT __attribute__((visibility("hidden")))
45+
# endif
4646
#endif // Not-Windows
4747

4848
#if defined(_MSC_VER)
49-
#pragma warning(pop)
49+
# pragma warning(pop)
5050
#endif

cpp/src/arrow/adapters/orc/adapter.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <vector>
2626

2727
#ifdef ARROW_ORC_NEED_TIME_ZONE_DATABASE_CHECK
28-
#include <filesystem>
28+
# include <filesystem>
2929
#endif
3030

3131
#include "arrow/adapters/orc/util.h"

cpp/src/arrow/c/abi.h

+21-21
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ extern "C" {
4141
#endif
4242

4343
#ifndef ARROW_C_DATA_INTERFACE
44-
#define ARROW_C_DATA_INTERFACE
44+
# define ARROW_C_DATA_INTERFACE
4545

46-
#define ARROW_FLAG_DICTIONARY_ORDERED 1
47-
#define ARROW_FLAG_NULLABLE 2
48-
#define ARROW_FLAG_MAP_KEYS_SORTED 4
46+
# define ARROW_FLAG_DICTIONARY_ORDERED 1
47+
# define ARROW_FLAG_NULLABLE 2
48+
# define ARROW_FLAG_MAP_KEYS_SORTED 4
4949

5050
struct ArrowSchema {
5151
// Array type description
@@ -83,41 +83,41 @@ struct ArrowArray {
8383
#endif // ARROW_C_DATA_INTERFACE
8484

8585
#ifndef ARROW_C_DEVICE_DATA_INTERFACE
86-
#define ARROW_C_DEVICE_DATA_INTERFACE
86+
# define ARROW_C_DEVICE_DATA_INTERFACE
8787

8888
// Spec and Documentation: https://arrow.apache.org/docs/format/CDeviceDataInterface.html
8989

9090
// DeviceType for the allocated memory
9191
typedef int32_t ArrowDeviceType;
9292

9393
// CPU device, same as using ArrowArray directly
94-
#define ARROW_DEVICE_CPU 1
94+
# define ARROW_DEVICE_CPU 1
9595
// CUDA GPU Device
96-
#define ARROW_DEVICE_CUDA 2
96+
# define ARROW_DEVICE_CUDA 2
9797
// Pinned CUDA CPU memory by cudaMallocHost
98-
#define ARROW_DEVICE_CUDA_HOST 3
98+
# define ARROW_DEVICE_CUDA_HOST 3
9999
// OpenCL Device
100-
#define ARROW_DEVICE_OPENCL 4
100+
# define ARROW_DEVICE_OPENCL 4
101101
// Vulkan buffer for next-gen graphics
102-
#define ARROW_DEVICE_VULKAN 7
102+
# define ARROW_DEVICE_VULKAN 7
103103
// Metal for Apple GPU
104-
#define ARROW_DEVICE_METAL 8
104+
# define ARROW_DEVICE_METAL 8
105105
// Verilog simulator buffer
106-
#define ARROW_DEVICE_VPI 9
106+
# define ARROW_DEVICE_VPI 9
107107
// ROCm GPUs for AMD GPUs
108-
#define ARROW_DEVICE_ROCM 10
108+
# define ARROW_DEVICE_ROCM 10
109109
// Pinned ROCm CPU memory allocated by hipMallocHost
110-
#define ARROW_DEVICE_ROCM_HOST 11
110+
# define ARROW_DEVICE_ROCM_HOST 11
111111
// Reserved for extension
112-
#define ARROW_DEVICE_EXT_DEV 12
112+
# define ARROW_DEVICE_EXT_DEV 12
113113
// CUDA managed/unified memory allocated by cudaMallocManaged
114-
#define ARROW_DEVICE_CUDA_MANAGED 13
114+
# define ARROW_DEVICE_CUDA_MANAGED 13
115115
// unified shared memory allocated on a oneAPI non-partitioned device.
116-
#define ARROW_DEVICE_ONEAPI 14
116+
# define ARROW_DEVICE_ONEAPI 14
117117
// GPU support for next-gen WebGPU standard
118-
#define ARROW_DEVICE_WEBGPU 15
118+
# define ARROW_DEVICE_WEBGPU 15
119119
// Qualcomm Hexagon DSP
120-
#define ARROW_DEVICE_HEXAGON 16
120+
# define ARROW_DEVICE_HEXAGON 16
121121

122122
struct ArrowDeviceArray {
123123
// the Allocated Array
@@ -138,7 +138,7 @@ struct ArrowDeviceArray {
138138
#endif // ARROW_C_DEVICE_DATA_INTERFACE
139139

140140
#ifndef ARROW_C_STREAM_INTERFACE
141-
#define ARROW_C_STREAM_INTERFACE
141+
# define ARROW_C_STREAM_INTERFACE
142142

143143
struct ArrowArrayStream {
144144
// Callback to get the stream type
@@ -179,7 +179,7 @@ struct ArrowArrayStream {
179179
#endif // ARROW_C_STREAM_INTERFACE
180180

181181
#ifndef ARROW_C_DEVICE_STREAM_INTERFACE
182-
#define ARROW_C_DEVICE_STREAM_INTERFACE
182+
# define ARROW_C_DEVICE_STREAM_INTERFACE
183183

184184
// Equivalent to ArrowArrayStream, but for ArrowDeviceArrays.
185185
//

cpp/src/arrow/c/bridge_test.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
// TODO(GH-37221): Remove these ifdef checks when compute dependency is removed
5050
#ifdef ARROW_COMPUTE
51-
#include "arrow/compute/api_vector.h"
51+
# include "arrow/compute/api_vector.h"
5252
#endif
5353

5454
namespace arrow {

cpp/src/arrow/c/dlpack_abi.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
* \brief Compatibility with C++
1313
*/
1414
#ifdef __cplusplus
15-
#define DLPACK_EXTERN_C extern "C"
15+
# define DLPACK_EXTERN_C extern "C"
1616
#else
17-
#define DLPACK_EXTERN_C
17+
# define DLPACK_EXTERN_C
1818
#endif
1919

2020
/*! \brief The current major version of dlpack */
@@ -25,13 +25,13 @@
2525

2626
/*! \brief DLPACK_DLL prefix for windows */
2727
#ifdef _WIN32
28-
#ifdef DLPACK_EXPORTS
29-
#define DLPACK_DLL __declspec(dllexport)
28+
# ifdef DLPACK_EXPORTS
29+
# define DLPACK_DLL __declspec(dllexport)
30+
# else
31+
# define DLPACK_DLL __declspec(dllimport)
32+
# endif
3033
#else
31-
#define DLPACK_DLL __declspec(dllimport)
32-
#endif
33-
#else
34-
#define DLPACK_DLL
34+
# define DLPACK_DLL
3535
#endif
3636

3737
#include <stddef.h>

cpp/src/arrow/compute/kernel.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
// macOS defines PREALLOCATE as a preprocessor macro in the header sys/vnode.h.
4343
// No other BSD seems to do so. The name is used as an identifier in MemAllocation enum.
4444
#if defined(__APPLE__) && defined(PREALLOCATE)
45-
#undef PREALLOCATE
45+
# undef PREALLOCATE
4646
#endif
4747

4848
namespace arrow {

cpp/src/arrow/compute/kernels/scalar_cast_string.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ struct TemporalToStringCastFunctor<O, TimestampType> {
217217

218218
#if defined(_MSC_VER)
219219
// Silence warning: """'visitor': unreferenced local variable"""
220-
#pragma warning(push)
221-
#pragma warning(disable : 4101)
220+
# pragma warning(push)
221+
# pragma warning(disable : 4101)
222222
#endif
223223

224224
struct Utf8Validator {
@@ -422,7 +422,7 @@ BinaryToBinaryCastExec(KernelContext* ctx, const ExecSpan& batch, ExecResult* ou
422422
}
423423

424424
#if defined(_MSC_VER)
425-
#pragma warning(pop)
425+
# pragma warning(pop)
426426
#endif
427427

428428
// ----------------------------------------------------------------------

0 commit comments

Comments
 (0)