[libcxx-commits] [pstl] r357401 - [pstl] Indent preprocessor directives as part of the clang-format rules

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Mon Apr 1 08:21:46 PDT 2019


Author: ldionne
Date: Mon Apr  1 08:21:46 2019
New Revision: 357401

URL: http://llvm.org/viewvc/llvm-project?rev=357401&view=rev
Log:
[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

Modified:
    pstl/trunk/.clang-format
    pstl/trunk/include/pstl/algorithm
    pstl/trunk/include/pstl/execution
    pstl/trunk/include/pstl/internal/algorithm_impl.h
    pstl/trunk/include/pstl/internal/glue_execution_defs.h
    pstl/trunk/include/pstl/internal/numeric_impl.h
    pstl/trunk/include/pstl/internal/parallel_backend.h
    pstl/trunk/include/pstl/internal/parallel_backend_tbb.h
    pstl/trunk/include/pstl/internal/pstl_config.h
    pstl/trunk/include/pstl/memory
    pstl/trunk/include/pstl/numeric

Modified: pstl/trunk/.clang-format
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/.clang-format?rev=357401&r1=357400&r2=357401&view=diff
==============================================================================
--- pstl/trunk/.clang-format (original)
+++ pstl/trunk/.clang-format Mon Apr  1 08:21:46 2019
@@ -15,3 +15,6 @@ BreakBeforeBraces: Allman
 # Disable formatting options which may break tests.
 SortIncludes: false
 ReflowComments: false
+
+# Indent preprocessor directives
+IndentPPDirectives: AfterHash

Modified: pstl/trunk/include/pstl/algorithm
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/algorithm?rev=357401&r1=357400&r2=357401&view=diff
==============================================================================
--- pstl/trunk/include/pstl/algorithm (original)
+++ pstl/trunk/include/pstl/algorithm Mon Apr  1 08:21:46 2019
@@ -14,11 +14,11 @@
 
 #if __PSTL_EXECUTION_POLICIES_DEFINED
 // If <execution> has already been included, pull in implementations
-#include "internal/glue_algorithm_impl.h"
+#    include "internal/glue_algorithm_impl.h"
 #else
 // Otherwise just pull in forward declarations
-#include "internal/glue_algorithm_defs.h"
-#define __PSTL_ALGORITHM_FORWARD_DECLARED 1
+#    include "internal/glue_algorithm_defs.h"
+#    define __PSTL_ALGORITHM_FORWARD_DECLARED 1
 #endif
 
 #endif /* __PSTL_algorithm */

Modified: pstl/trunk/include/pstl/execution
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/execution?rev=357401&r1=357400&r2=357401&view=diff
==============================================================================
--- pstl/trunk/include/pstl/execution (original)
+++ pstl/trunk/include/pstl/execution Mon Apr  1 08:21:46 2019
@@ -16,21 +16,21 @@
 #define __PSTL_EXECUTION_POLICIES_DEFINED 1
 
 #if __PSTL_ALGORITHM_FORWARD_DECLARED
-#include "internal/glue_algorithm_impl.h"
+#    include "internal/glue_algorithm_impl.h"
 #endif
 
 #if __PSTL_MEMORY_FORWARD_DECLARED
-#include "internal/glue_memory_impl.h"
+#    include "internal/glue_memory_impl.h"
 #endif
 
 #if __PSTL_NUMERIC_FORWARD_DECLARED
-#include "internal/glue_numeric_impl.h"
+#    include "internal/glue_numeric_impl.h"
 #endif
 
 #if __PSTL_CPP17_EXECUTION_POLICIES_PRESENT
 __PSTL_PRAGMA_MESSAGE_POLICIES("The <Parallel STL> execution policies are defined in the namespace __pstl::execution")
 #else
-#include "internal/glue_execution_defs.h"
+#    include "internal/glue_execution_defs.h"
 __PSTL_PRAGMA_MESSAGE_POLICIES(
     "The <Parallel STL> execution policies are injected into the standard namespace std::execution")
 #endif

Modified: pstl/trunk/include/pstl/internal/algorithm_impl.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/algorithm_impl.h?rev=357401&r1=357400&r2=357401&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/algorithm_impl.h (original)
+++ pstl/trunk/include/pstl/internal/algorithm_impl.h Mon Apr  1 08:21:46 2019
@@ -22,8 +22,8 @@
 #include "unseq_backend_simd.h"
 
 #if __PSTL_USE_PAR_POLICIES
-#include "parallel_backend.h"
-#include "parallel_impl.h"
+#    include "parallel_backend.h"
+#    include "parallel_impl.h"
 #endif
 
 namespace __pstl
@@ -2194,11 +2194,11 @@ __pattern_partial_sort_copy(_ExecutionPo
                     _ForwardIterator __j1 = __first + (__j - __d_first);
 
                 // 1. Copy elements from input to output
-#if !__PSTL_ICC_18_OMP_SIMD_BROKEN
+#    if !__PSTL_ICC_18_OMP_SIMD_BROKEN
                     __internal::__brick_copy(__i1, __j1, __i, __is_vector);
-#else
+#    else
                     std::copy(__i1, __j1, __i);
-#endif
+#    endif
                     // 2. Sort elements in output sequence
                     std::sort(__i, __j, __comp);
                 },

Modified: pstl/trunk/include/pstl/internal/glue_execution_defs.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/glue_execution_defs.h?rev=357401&r1=357400&r2=357401&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/glue_execution_defs.h (original)
+++ pstl/trunk/include/pstl/internal/glue_execution_defs.h Mon Apr  1 08:21:46 2019
@@ -19,12 +19,12 @@ namespace std
 // Type trait
 using __pstl::execution::is_execution_policy;
 #if __PSTL_CPP14_VARIABLE_TEMPLATES_PRESENT
-#if __INTEL_COMPILER
+#    if __INTEL_COMPILER
 template <class T>
 constexpr bool is_execution_policy_v = is_execution_policy<T>::value;
-#else
+#    else
 using __pstl::execution::is_execution_policy_v;
-#endif
+#    endif
 #endif
 
 namespace execution

Modified: pstl/trunk/include/pstl/internal/numeric_impl.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/numeric_impl.h?rev=357401&r1=357400&r2=357401&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/numeric_impl.h (original)
+++ pstl/trunk/include/pstl/internal/numeric_impl.h Mon Apr  1 08:21:46 2019
@@ -19,7 +19,7 @@
 #include "algorithm_fwd.h"
 
 #if __PSTL_USE_PAR_POLICIES
-#include "parallel_backend.h"
+#    include "parallel_backend.h"
 #endif
 
 namespace __pstl

Modified: pstl/trunk/include/pstl/internal/parallel_backend.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/parallel_backend.h?rev=357401&r1=357400&r2=357401&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/parallel_backend.h (original)
+++ pstl/trunk/include/pstl/internal/parallel_backend.h Mon Apr  1 08:21:46 2019
@@ -11,7 +11,7 @@
 #define __PSTL_parallel_backend_H
 
 #if __PSTL_PAR_BACKEND_TBB
-#include "parallel_backend_tbb.h"
+#    include "parallel_backend_tbb.h"
 #else
 __PSTL_PRAGMA_MESSAGE("Parallel backend was not specified");
 #endif

Modified: pstl/trunk/include/pstl/internal/parallel_backend_tbb.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/parallel_backend_tbb.h?rev=357401&r1=357400&r2=357401&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/parallel_backend_tbb.h (original)
+++ pstl/trunk/include/pstl/internal/parallel_backend_tbb.h Mon Apr  1 08:21:46 2019
@@ -26,7 +26,7 @@
 #include <tbb/tbb_allocator.h>
 
 #if TBB_INTERFACE_VERSION < 10000
-#error Intel(R) Threading Building Blocks 2018 is required; older versions are not supported.
+#    error Intel(R) Threading Building Blocks 2018 is required; older versions are not supported.
 #endif
 
 namespace __pstl

Modified: pstl/trunk/include/pstl/internal/pstl_config.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/pstl_config.h?rev=357401&r1=357400&r2=357401&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/pstl_config.h (original)
+++ pstl/trunk/include/pstl/internal/pstl_config.h Mon Apr  1 08:21:46 2019
@@ -16,35 +16,35 @@
 
 // Check the user-defined macro for parallel policies
 #if defined(PSTL_USE_PARALLEL_POLICIES)
-#undef __PSTL_USE_PAR_POLICIES
-#define __PSTL_USE_PAR_POLICIES PSTL_USE_PARALLEL_POLICIES
+#    undef __PSTL_USE_PAR_POLICIES
+#    define __PSTL_USE_PAR_POLICIES PSTL_USE_PARALLEL_POLICIES
 // Check the internal macro for parallel policies
 #elif !defined(__PSTL_USE_PAR_POLICIES)
-#define __PSTL_USE_PAR_POLICIES 1
+#    define __PSTL_USE_PAR_POLICIES 1
 #endif
 
 #if __PSTL_USE_PAR_POLICIES
-#if !defined(__PSTL_PAR_BACKEND_TBB)
-#define __PSTL_PAR_BACKEND_TBB 1
-#endif
+#    if !defined(__PSTL_PAR_BACKEND_TBB)
+#        define __PSTL_PAR_BACKEND_TBB 1
+#    endif
 #else
-#undef __PSTL_PAR_BACKEND_TBB
+#    undef __PSTL_PAR_BACKEND_TBB
 #endif
 
 // Check the user-defined macro for warnings
 #if defined(PSTL_USAGE_WARNINGS)
-#undef __PSTL_USAGE_WARNINGS
-#define __PSTL_USAGE_WARNINGS PSTL_USAGE_WARNINGS
+#    undef __PSTL_USAGE_WARNINGS
+#    define __PSTL_USAGE_WARNINGS PSTL_USAGE_WARNINGS
 // Check the internal macro for warnings
 #elif !defined(__PSTL_USAGE_WARNINGS)
-#define __PSTL_USAGE_WARNINGS 0
+#    define __PSTL_USAGE_WARNINGS 0
 #endif
 
 // Portability "#pragma" definition
 #ifdef _MSC_VER
-#define __PSTL_PRAGMA(x) __pragma(x)
+#    define __PSTL_PRAGMA(x) __pragma(x)
 #else
-#define __PSTL_PRAGMA(x) _Pragma(#x)
+#    define __PSTL_PRAGMA(x) _Pragma(#    x)
 #endif
 
 #define __PSTL_STRING_AUX(x) #x
@@ -57,38 +57,38 @@
 
 #if __clang__
 // according to clang documentation, version can be vendor specific
-#define __PSTL_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
+#    define __PSTL_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
 #endif
 
 // Enable SIMD for compilers that support OpenMP 4.0
 #if (_OPENMP >= 201307) || (__INTEL_COMPILER >= 1600) || (!defined(__INTEL_COMPILER) && __PSTL_GCC_VERSION >= 40900)
-#define __PSTL_PRAGMA_SIMD __PSTL_PRAGMA(omp simd)
-#define __PSTL_PRAGMA_DECLARE_SIMD __PSTL_PRAGMA(omp declare simd)
-#define __PSTL_PRAGMA_SIMD_REDUCTION(PRM) __PSTL_PRAGMA(omp simd reduction(PRM))
+#    define __PSTL_PRAGMA_SIMD __PSTL_PRAGMA(omp simd)
+#    define __PSTL_PRAGMA_DECLARE_SIMD __PSTL_PRAGMA(omp declare simd)
+#    define __PSTL_PRAGMA_SIMD_REDUCTION(PRM) __PSTL_PRAGMA(omp simd reduction(PRM))
 #elif !defined(_MSC_VER) //#pragma simd
-#define __PSTL_PRAGMA_SIMD __PSTL_PRAGMA(simd)
-#define __PSTL_PRAGMA_DECLARE_SIMD
-#define __PSTL_PRAGMA_SIMD_REDUCTION(PRM) __PSTL_PRAGMA(simd reduction(PRM))
+#    define __PSTL_PRAGMA_SIMD __PSTL_PRAGMA(simd)
+#    define __PSTL_PRAGMA_DECLARE_SIMD
+#    define __PSTL_PRAGMA_SIMD_REDUCTION(PRM) __PSTL_PRAGMA(simd reduction(PRM))
 #else //no simd
-#define __PSTL_PRAGMA_SIMD
-#define __PSTL_PRAGMA_DECLARE_SIMD
-#define __PSTL_PRAGMA_SIMD_REDUCTION(PRM)
+#    define __PSTL_PRAGMA_SIMD
+#    define __PSTL_PRAGMA_DECLARE_SIMD
+#    define __PSTL_PRAGMA_SIMD_REDUCTION(PRM)
 #endif //Enable SIMD
 
 #if (__INTEL_COMPILER)
-#define __PSTL_PRAGMA_FORCEINLINE __PSTL_PRAGMA(forceinline)
+#    define __PSTL_PRAGMA_FORCEINLINE __PSTL_PRAGMA(forceinline)
 #else
-#define __PSTL_PRAGMA_FORCEINLINE
+#    define __PSTL_PRAGMA_FORCEINLINE
 #endif
 
 #if (__INTEL_COMPILER >= 1900)
-#define __PSTL_PRAGMA_SIMD_SCAN(PRM) __PSTL_PRAGMA(omp simd reduction(inscan, PRM))
-#define __PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM) __PSTL_PRAGMA(omp scan inclusive(PRM))
-#define __PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM) __PSTL_PRAGMA(omp scan exclusive(PRM))
-#else
-#define __PSTL_PRAGMA_SIMD_SCAN(PRM)
-#define __PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
-#define __PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
+#    define __PSTL_PRAGMA_SIMD_SCAN(PRM) __PSTL_PRAGMA(omp simd reduction(inscan, PRM))
+#    define __PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM) __PSTL_PRAGMA(omp scan inclusive(PRM))
+#    define __PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM) __PSTL_PRAGMA(omp scan exclusive(PRM))
+#else
+#    define __PSTL_PRAGMA_SIMD_SCAN(PRM)
+#    define __PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
+#    define __PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
 #endif
 
 // Should be defined to 1 for environments with a vendor implementation of C++17 execution policies
@@ -106,25 +106,25 @@
 #define __PSTL_MONOTONIC_PRESENT (__INTEL_COMPILER >= 1800)
 
 #if (__INTEL_COMPILER >= 1900 || !defined(__INTEL_COMPILER) && __PSTL_GCC_VERSION >= 40900 || _OPENMP >= 201307)
-#define __PSTL_UDR_PRESENT 1
+#    define __PSTL_UDR_PRESENT 1
 #else
-#define __PSTL_UDR_PRESENT 0
+#    define __PSTL_UDR_PRESENT 0
 #endif
 
 #define __PSTL_UDS_PRESENT (__INTEL_COMPILER >= 1900 && __INTEL_COMPILER_BUILD_DATE >= 20180626)
 
 #if __PSTL_EARLYEXIT_PRESENT
-#define __PSTL_PRAGMA_SIMD_EARLYEXIT __PSTL_PRAGMA(omp simd early_exit)
+#    define __PSTL_PRAGMA_SIMD_EARLYEXIT __PSTL_PRAGMA(omp simd early_exit)
 #else
-#define __PSTL_PRAGMA_SIMD_EARLYEXIT
+#    define __PSTL_PRAGMA_SIMD_EARLYEXIT
 #endif
 
 #if __PSTL_MONOTONIC_PRESENT
-#define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(PRM) __PSTL_PRAGMA(omp ordered simd monotonic(PRM))
-#define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(PRM1, PRM2) __PSTL_PRAGMA(omp ordered simd monotonic(PRM1, PRM2))
+#    define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(PRM) __PSTL_PRAGMA(omp ordered simd monotonic(PRM))
+#    define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(PRM1, PRM2) __PSTL_PRAGMA(omp ordered simd monotonic(PRM1, PRM2))
 #else
-#define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(PRM)
-#define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(PRM1, PRM2)
+#    define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(PRM)
+#    define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(PRM1, PRM2)
 #endif
 
 // Declaration of reduction functor, where
@@ -135,35 +135,35 @@
 // omp_priv - refers to the private copy of the initial value
 // omp_orig - refers to the original variable to be reduced
 #define __PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP)                                                                      \
-    __PSTL_PRAGMA(omp declare reduction(NAME : OP : omp_out(omp_in)) initializer(omp_priv = omp_orig))
+    __PSTL_PRAGMA(omp declare reduction(NAME:OP : omp_out(omp_in)) initializer(omp_priv = omp_orig))
 
 #if (__INTEL_COMPILER >= 1600)
-#define __PSTL_PRAGMA_VECTOR_UNALIGNED __PSTL_PRAGMA(vector unaligned)
+#    define __PSTL_PRAGMA_VECTOR_UNALIGNED __PSTL_PRAGMA(vector unaligned)
 #else
-#define __PSTL_PRAGMA_VECTOR_UNALIGNED
+#    define __PSTL_PRAGMA_VECTOR_UNALIGNED
 #endif
 
 // Check the user-defined macro to use non-temporal stores
 #if defined(PSTL_USE_NONTEMPORAL_STORES) && (__INTEL_COMPILER >= 1600)
-#define __PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED __PSTL_PRAGMA(vector nontemporal)
+#    define __PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED __PSTL_PRAGMA(vector nontemporal)
 #else
-#define __PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
+#    define __PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
 #endif
 
 #if _MSC_VER || __INTEL_COMPILER //the preprocessors don't type a message location
-#define __PSTL_PRAGMA_LOCATION __FILE__ ":" __PSTL_STRING(__LINE__) ": [Parallel STL message]: "
+#    define __PSTL_PRAGMA_LOCATION __FILE__ ":" __PSTL_STRING(__LINE__) ": [Parallel STL message]: "
 #else
-#define __PSTL_PRAGMA_LOCATION " [Parallel STL message]: "
+#    define __PSTL_PRAGMA_LOCATION " [Parallel STL message]: "
 #endif
 
 #define __PSTL_PRAGMA_MESSAGE_IMPL(x) __PSTL_PRAGMA(message(__PSTL_STRING_CONCAT(__PSTL_PRAGMA_LOCATION, x)))
 
 #if __PSTL_USAGE_WARNINGS
-#define __PSTL_PRAGMA_MESSAGE(x) __PSTL_PRAGMA_MESSAGE_IMPL(x)
-#define __PSTL_PRAGMA_MESSAGE_POLICIES(x) __PSTL_PRAGMA_MESSAGE_IMPL(x)
+#    define __PSTL_PRAGMA_MESSAGE(x) __PSTL_PRAGMA_MESSAGE_IMPL(x)
+#    define __PSTL_PRAGMA_MESSAGE_POLICIES(x) __PSTL_PRAGMA_MESSAGE_IMPL(x)
 #else
-#define __PSTL_PRAGMA_MESSAGE(x)
-#define __PSTL_PRAGMA_MESSAGE_POLICIES(x)
+#    define __PSTL_PRAGMA_MESSAGE(x)
+#    define __PSTL_PRAGMA_MESSAGE_POLICIES(x)
 #endif
 
 // broken macros

Modified: pstl/trunk/include/pstl/memory
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/memory?rev=357401&r1=357400&r2=357401&view=diff
==============================================================================
--- pstl/trunk/include/pstl/memory (original)
+++ pstl/trunk/include/pstl/memory Mon Apr  1 08:21:46 2019
@@ -14,11 +14,11 @@
 
 #if __PSTL_EXECUTION_POLICIES_DEFINED
 // If <execution> has already been included, pull in implementations
-#include "internal/glue_memory_impl.h"
+#    include "internal/glue_memory_impl.h"
 #else
 // Otherwise just pull in forward declarations
-#include "internal/glue_memory_defs.h"
-#define __PSTL_MEMORY_FORWARD_DECLARED 1
+#    include "internal/glue_memory_defs.h"
+#    define __PSTL_MEMORY_FORWARD_DECLARED 1
 #endif
 
 #endif /* __PSTL_memory */

Modified: pstl/trunk/include/pstl/numeric
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/numeric?rev=357401&r1=357400&r2=357401&view=diff
==============================================================================
--- pstl/trunk/include/pstl/numeric (original)
+++ pstl/trunk/include/pstl/numeric Mon Apr  1 08:21:46 2019
@@ -14,11 +14,11 @@
 
 #if __PSTL_EXECUTION_POLICIES_DEFINED
 // If <execution> has already been included, pull in implementations
-#include "internal/glue_numeric_impl.h"
+#    include "internal/glue_numeric_impl.h"
 #else
 // Otherwise just pull in forward declarations
-#include "internal/glue_numeric_defs.h"
-#define __PSTL_NUMERIC_FORWARD_DECLARED 1
+#    include "internal/glue_numeric_defs.h"
+#    define __PSTL_NUMERIC_FORWARD_DECLARED 1
 #endif
 
 #endif /* __PSTL_numeric */




More information about the libcxx-commits mailing list