Skip to content

Commit 95c585e

Browse files
committedApr 1, 2019
[pstl] Indent preprocessor directives as part of the clang-format rules
Summary: Indenting preprocessor directives provides a significant gain in readability. We do it for normal if statements, and it makes sense to do it for preprocessor ifs too. Reviewers: rodgert, MikeDvorskiy Subscribers: jkorous, dexonsmith, jdoerfert, libcxx-commits Differential Revision: https://reviews.llvm.org/D59767 llvm-svn: 357401
1 parent 0a30f33 commit 95c585e

11 files changed

+76
-73
lines changed
 

‎pstl/.clang-format

+3
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ BreakBeforeBraces: Allman
1515
# Disable formatting options which may break tests.
1616
SortIncludes: false
1717
ReflowComments: false
18+
19+
# Indent preprocessor directives
20+
IndentPPDirectives: AfterHash

‎pstl/include/pstl/algorithm

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414

1515
#if __PSTL_EXECUTION_POLICIES_DEFINED
1616
// If <execution> has already been included, pull in implementations
17-
#include "internal/glue_algorithm_impl.h"
17+
# include "internal/glue_algorithm_impl.h"
1818
#else
1919
// Otherwise just pull in forward declarations
20-
#include "internal/glue_algorithm_defs.h"
21-
#define __PSTL_ALGORITHM_FORWARD_DECLARED 1
20+
# include "internal/glue_algorithm_defs.h"
21+
# define __PSTL_ALGORITHM_FORWARD_DECLARED 1
2222
#endif
2323

2424
#endif /* __PSTL_algorithm */

‎pstl/include/pstl/execution

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@
1616
#define __PSTL_EXECUTION_POLICIES_DEFINED 1
1717

1818
#if __PSTL_ALGORITHM_FORWARD_DECLARED
19-
#include "internal/glue_algorithm_impl.h"
19+
# include "internal/glue_algorithm_impl.h"
2020
#endif
2121

2222
#if __PSTL_MEMORY_FORWARD_DECLARED
23-
#include "internal/glue_memory_impl.h"
23+
# include "internal/glue_memory_impl.h"
2424
#endif
2525

2626
#if __PSTL_NUMERIC_FORWARD_DECLARED
27-
#include "internal/glue_numeric_impl.h"
27+
# include "internal/glue_numeric_impl.h"
2828
#endif
2929

3030
#if __PSTL_CPP17_EXECUTION_POLICIES_PRESENT
3131
__PSTL_PRAGMA_MESSAGE_POLICIES("The <Parallel STL> execution policies are defined in the namespace __pstl::execution")
3232
#else
33-
#include "internal/glue_execution_defs.h"
33+
# include "internal/glue_execution_defs.h"
3434
__PSTL_PRAGMA_MESSAGE_POLICIES(
3535
"The <Parallel STL> execution policies are injected into the standard namespace std::execution")
3636
#endif

‎pstl/include/pstl/internal/algorithm_impl.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
#include "unseq_backend_simd.h"
2323

2424
#if __PSTL_USE_PAR_POLICIES
25-
#include "parallel_backend.h"
26-
#include "parallel_impl.h"
25+
# include "parallel_backend.h"
26+
# include "parallel_impl.h"
2727
#endif
2828

2929
namespace __pstl
@@ -2194,11 +2194,11 @@ __pattern_partial_sort_copy(_ExecutionPolicy&& __exec, _ForwardIterator __first,
21942194
_ForwardIterator __j1 = __first + (__j - __d_first);
21952195

21962196
// 1. Copy elements from input to output
2197-
#if !__PSTL_ICC_18_OMP_SIMD_BROKEN
2197+
# if !__PSTL_ICC_18_OMP_SIMD_BROKEN
21982198
__internal::__brick_copy(__i1, __j1, __i, __is_vector);
2199-
#else
2199+
# else
22002200
std::copy(__i1, __j1, __i);
2201-
#endif
2201+
# endif
22022202
// 2. Sort elements in output sequence
22032203
std::sort(__i, __j, __comp);
22042204
},

‎pstl/include/pstl/internal/glue_execution_defs.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ namespace std
1919
// Type trait
2020
using __pstl::execution::is_execution_policy;
2121
#if __PSTL_CPP14_VARIABLE_TEMPLATES_PRESENT
22-
#if __INTEL_COMPILER
22+
# if __INTEL_COMPILER
2323
template <class T>
2424
constexpr bool is_execution_policy_v = is_execution_policy<T>::value;
25-
#else
25+
# else
2626
using __pstl::execution::is_execution_policy_v;
27-
#endif
27+
# endif
2828
#endif
2929

3030
namespace execution

‎pstl/include/pstl/internal/numeric_impl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "algorithm_fwd.h"
2020

2121
#if __PSTL_USE_PAR_POLICIES
22-
#include "parallel_backend.h"
22+
# include "parallel_backend.h"
2323
#endif
2424

2525
namespace __pstl

‎pstl/include/pstl/internal/parallel_backend.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define __PSTL_parallel_backend_H
1212

1313
#if __PSTL_PAR_BACKEND_TBB
14-
#include "parallel_backend_tbb.h"
14+
# include "parallel_backend_tbb.h"
1515
#else
1616
__PSTL_PRAGMA_MESSAGE("Parallel backend was not specified");
1717
#endif

‎pstl/include/pstl/internal/parallel_backend_tbb.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <tbb/tbb_allocator.h>
2727

2828
#if TBB_INTERFACE_VERSION < 10000
29-
#error Intel(R) Threading Building Blocks 2018 is required; older versions are not supported.
29+
# error Intel(R) Threading Building Blocks 2018 is required; older versions are not supported.
3030
#endif
3131

3232
namespace __pstl

‎pstl/include/pstl/internal/pstl_config.h

+49-49
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,35 @@
1616

1717
// Check the user-defined macro for parallel policies
1818
#if defined(PSTL_USE_PARALLEL_POLICIES)
19-
#undef __PSTL_USE_PAR_POLICIES
20-
#define __PSTL_USE_PAR_POLICIES PSTL_USE_PARALLEL_POLICIES
19+
# undef __PSTL_USE_PAR_POLICIES
20+
# define __PSTL_USE_PAR_POLICIES PSTL_USE_PARALLEL_POLICIES
2121
// Check the internal macro for parallel policies
2222
#elif !defined(__PSTL_USE_PAR_POLICIES)
23-
#define __PSTL_USE_PAR_POLICIES 1
23+
# define __PSTL_USE_PAR_POLICIES 1
2424
#endif
2525

2626
#if __PSTL_USE_PAR_POLICIES
27-
#if !defined(__PSTL_PAR_BACKEND_TBB)
28-
#define __PSTL_PAR_BACKEND_TBB 1
29-
#endif
27+
# if !defined(__PSTL_PAR_BACKEND_TBB)
28+
# define __PSTL_PAR_BACKEND_TBB 1
29+
# endif
3030
#else
31-
#undef __PSTL_PAR_BACKEND_TBB
31+
# undef __PSTL_PAR_BACKEND_TBB
3232
#endif
3333

3434
// Check the user-defined macro for warnings
3535
#if defined(PSTL_USAGE_WARNINGS)
36-
#undef __PSTL_USAGE_WARNINGS
37-
#define __PSTL_USAGE_WARNINGS PSTL_USAGE_WARNINGS
36+
# undef __PSTL_USAGE_WARNINGS
37+
# define __PSTL_USAGE_WARNINGS PSTL_USAGE_WARNINGS
3838
// Check the internal macro for warnings
3939
#elif !defined(__PSTL_USAGE_WARNINGS)
40-
#define __PSTL_USAGE_WARNINGS 0
40+
# define __PSTL_USAGE_WARNINGS 0
4141
#endif
4242

4343
// Portability "#pragma" definition
4444
#ifdef _MSC_VER
45-
#define __PSTL_PRAGMA(x) __pragma(x)
45+
# define __PSTL_PRAGMA(x) __pragma(x)
4646
#else
47-
#define __PSTL_PRAGMA(x) _Pragma(#x)
47+
# define __PSTL_PRAGMA(x) _Pragma(# x)
4848
#endif
4949

5050
#define __PSTL_STRING_AUX(x) #x
@@ -57,38 +57,38 @@
5757

5858
#if __clang__
5959
// according to clang documentation, version can be vendor specific
60-
#define __PSTL_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
60+
# define __PSTL_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
6161
#endif
6262

6363
// Enable SIMD for compilers that support OpenMP 4.0
6464
#if (_OPENMP >= 201307) || (__INTEL_COMPILER >= 1600) || (!defined(__INTEL_COMPILER) && __PSTL_GCC_VERSION >= 40900)
65-
#define __PSTL_PRAGMA_SIMD __PSTL_PRAGMA(omp simd)
66-
#define __PSTL_PRAGMA_DECLARE_SIMD __PSTL_PRAGMA(omp declare simd)
67-
#define __PSTL_PRAGMA_SIMD_REDUCTION(PRM) __PSTL_PRAGMA(omp simd reduction(PRM))
65+
# define __PSTL_PRAGMA_SIMD __PSTL_PRAGMA(omp simd)
66+
# define __PSTL_PRAGMA_DECLARE_SIMD __PSTL_PRAGMA(omp declare simd)
67+
# define __PSTL_PRAGMA_SIMD_REDUCTION(PRM) __PSTL_PRAGMA(omp simd reduction(PRM))
6868
#elif !defined(_MSC_VER) //#pragma simd
69-
#define __PSTL_PRAGMA_SIMD __PSTL_PRAGMA(simd)
70-
#define __PSTL_PRAGMA_DECLARE_SIMD
71-
#define __PSTL_PRAGMA_SIMD_REDUCTION(PRM) __PSTL_PRAGMA(simd reduction(PRM))
69+
# define __PSTL_PRAGMA_SIMD __PSTL_PRAGMA(simd)
70+
# define __PSTL_PRAGMA_DECLARE_SIMD
71+
# define __PSTL_PRAGMA_SIMD_REDUCTION(PRM) __PSTL_PRAGMA(simd reduction(PRM))
7272
#else //no simd
73-
#define __PSTL_PRAGMA_SIMD
74-
#define __PSTL_PRAGMA_DECLARE_SIMD
75-
#define __PSTL_PRAGMA_SIMD_REDUCTION(PRM)
73+
# define __PSTL_PRAGMA_SIMD
74+
# define __PSTL_PRAGMA_DECLARE_SIMD
75+
# define __PSTL_PRAGMA_SIMD_REDUCTION(PRM)
7676
#endif //Enable SIMD
7777

7878
#if (__INTEL_COMPILER)
79-
#define __PSTL_PRAGMA_FORCEINLINE __PSTL_PRAGMA(forceinline)
79+
# define __PSTL_PRAGMA_FORCEINLINE __PSTL_PRAGMA(forceinline)
8080
#else
81-
#define __PSTL_PRAGMA_FORCEINLINE
81+
# define __PSTL_PRAGMA_FORCEINLINE
8282
#endif
8383

8484
#if (__INTEL_COMPILER >= 1900)
85-
#define __PSTL_PRAGMA_SIMD_SCAN(PRM) __PSTL_PRAGMA(omp simd reduction(inscan, PRM))
86-
#define __PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM) __PSTL_PRAGMA(omp scan inclusive(PRM))
87-
#define __PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM) __PSTL_PRAGMA(omp scan exclusive(PRM))
85+
# define __PSTL_PRAGMA_SIMD_SCAN(PRM) __PSTL_PRAGMA(omp simd reduction(inscan, PRM))
86+
# define __PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM) __PSTL_PRAGMA(omp scan inclusive(PRM))
87+
# define __PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM) __PSTL_PRAGMA(omp scan exclusive(PRM))
8888
#else
89-
#define __PSTL_PRAGMA_SIMD_SCAN(PRM)
90-
#define __PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
91-
#define __PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
89+
# define __PSTL_PRAGMA_SIMD_SCAN(PRM)
90+
# define __PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
91+
# define __PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
9292
#endif
9393

9494
// Should be defined to 1 for environments with a vendor implementation of C++17 execution policies
@@ -106,25 +106,25 @@
106106
#define __PSTL_MONOTONIC_PRESENT (__INTEL_COMPILER >= 1800)
107107

108108
#if (__INTEL_COMPILER >= 1900 || !defined(__INTEL_COMPILER) && __PSTL_GCC_VERSION >= 40900 || _OPENMP >= 201307)
109-
#define __PSTL_UDR_PRESENT 1
109+
# define __PSTL_UDR_PRESENT 1
110110
#else
111-
#define __PSTL_UDR_PRESENT 0
111+
# define __PSTL_UDR_PRESENT 0
112112
#endif
113113

114114
#define __PSTL_UDS_PRESENT (__INTEL_COMPILER >= 1900 && __INTEL_COMPILER_BUILD_DATE >= 20180626)
115115

116116
#if __PSTL_EARLYEXIT_PRESENT
117-
#define __PSTL_PRAGMA_SIMD_EARLYEXIT __PSTL_PRAGMA(omp simd early_exit)
117+
# define __PSTL_PRAGMA_SIMD_EARLYEXIT __PSTL_PRAGMA(omp simd early_exit)
118118
#else
119-
#define __PSTL_PRAGMA_SIMD_EARLYEXIT
119+
# define __PSTL_PRAGMA_SIMD_EARLYEXIT
120120
#endif
121121

122122
#if __PSTL_MONOTONIC_PRESENT
123-
#define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(PRM) __PSTL_PRAGMA(omp ordered simd monotonic(PRM))
124-
#define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(PRM1, PRM2) __PSTL_PRAGMA(omp ordered simd monotonic(PRM1, PRM2))
123+
# define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(PRM) __PSTL_PRAGMA(omp ordered simd monotonic(PRM))
124+
# define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(PRM1, PRM2) __PSTL_PRAGMA(omp ordered simd monotonic(PRM1, PRM2))
125125
#else
126-
#define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(PRM)
127-
#define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(PRM1, PRM2)
126+
# define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(PRM)
127+
# define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(PRM1, PRM2)
128128
#endif
129129

130130
// Declaration of reduction functor, where
@@ -135,35 +135,35 @@
135135
// omp_priv - refers to the private copy of the initial value
136136
// omp_orig - refers to the original variable to be reduced
137137
#define __PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP) \
138-
__PSTL_PRAGMA(omp declare reduction(NAME : OP : omp_out(omp_in)) initializer(omp_priv = omp_orig))
138+
__PSTL_PRAGMA(omp declare reduction(NAME:OP : omp_out(omp_in)) initializer(omp_priv = omp_orig))
139139

140140
#if (__INTEL_COMPILER >= 1600)
141-
#define __PSTL_PRAGMA_VECTOR_UNALIGNED __PSTL_PRAGMA(vector unaligned)
141+
# define __PSTL_PRAGMA_VECTOR_UNALIGNED __PSTL_PRAGMA(vector unaligned)
142142
#else
143-
#define __PSTL_PRAGMA_VECTOR_UNALIGNED
143+
# define __PSTL_PRAGMA_VECTOR_UNALIGNED
144144
#endif
145145

146146
// Check the user-defined macro to use non-temporal stores
147147
#if defined(PSTL_USE_NONTEMPORAL_STORES) && (__INTEL_COMPILER >= 1600)
148-
#define __PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED __PSTL_PRAGMA(vector nontemporal)
148+
# define __PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED __PSTL_PRAGMA(vector nontemporal)
149149
#else
150-
#define __PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
150+
# define __PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
151151
#endif
152152

153153
#if _MSC_VER || __INTEL_COMPILER //the preprocessors don't type a message location
154-
#define __PSTL_PRAGMA_LOCATION __FILE__ ":" __PSTL_STRING(__LINE__) ": [Parallel STL message]: "
154+
# define __PSTL_PRAGMA_LOCATION __FILE__ ":" __PSTL_STRING(__LINE__) ": [Parallel STL message]: "
155155
#else
156-
#define __PSTL_PRAGMA_LOCATION " [Parallel STL message]: "
156+
# define __PSTL_PRAGMA_LOCATION " [Parallel STL message]: "
157157
#endif
158158

159159
#define __PSTL_PRAGMA_MESSAGE_IMPL(x) __PSTL_PRAGMA(message(__PSTL_STRING_CONCAT(__PSTL_PRAGMA_LOCATION, x)))
160160

161161
#if __PSTL_USAGE_WARNINGS
162-
#define __PSTL_PRAGMA_MESSAGE(x) __PSTL_PRAGMA_MESSAGE_IMPL(x)
163-
#define __PSTL_PRAGMA_MESSAGE_POLICIES(x) __PSTL_PRAGMA_MESSAGE_IMPL(x)
162+
# define __PSTL_PRAGMA_MESSAGE(x) __PSTL_PRAGMA_MESSAGE_IMPL(x)
163+
# define __PSTL_PRAGMA_MESSAGE_POLICIES(x) __PSTL_PRAGMA_MESSAGE_IMPL(x)
164164
#else
165-
#define __PSTL_PRAGMA_MESSAGE(x)
166-
#define __PSTL_PRAGMA_MESSAGE_POLICIES(x)
165+
# define __PSTL_PRAGMA_MESSAGE(x)
166+
# define __PSTL_PRAGMA_MESSAGE_POLICIES(x)
167167
#endif
168168

169169
// broken macros

‎pstl/include/pstl/memory

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414

1515
#if __PSTL_EXECUTION_POLICIES_DEFINED
1616
// If <execution> has already been included, pull in implementations
17-
#include "internal/glue_memory_impl.h"
17+
# include "internal/glue_memory_impl.h"
1818
#else
1919
// Otherwise just pull in forward declarations
20-
#include "internal/glue_memory_defs.h"
21-
#define __PSTL_MEMORY_FORWARD_DECLARED 1
20+
# include "internal/glue_memory_defs.h"
21+
# define __PSTL_MEMORY_FORWARD_DECLARED 1
2222
#endif
2323

2424
#endif /* __PSTL_memory */

‎pstl/include/pstl/numeric

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414

1515
#if __PSTL_EXECUTION_POLICIES_DEFINED
1616
// If <execution> has already been included, pull in implementations
17-
#include "internal/glue_numeric_impl.h"
17+
# include "internal/glue_numeric_impl.h"
1818
#else
1919
// Otherwise just pull in forward declarations
20-
#include "internal/glue_numeric_defs.h"
21-
#define __PSTL_NUMERIC_FORWARD_DECLARED 1
20+
# include "internal/glue_numeric_defs.h"
21+
# define __PSTL_NUMERIC_FORWARD_DECLARED 1
2222
#endif
2323

2424
#endif /* __PSTL_numeric */

0 commit comments

Comments
 (0)
Please sign in to comment.