[libcxx-commits] [libcxx] 5a6e6ad - [libc++] Make sure our .clang-format is used for all languages
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jun 20 12:01:02 PDT 2023
Author: Louis Dionne
Date: 2023-06-20T15:00:53-04:00
New Revision: 5a6e6adb915835e09fb38d8a8bcba2807fdc4093
URL: https://github.com/llvm/llvm-project/commit/5a6e6adb915835e09fb38d8a8bcba2807fdc4093
DIFF: https://github.com/llvm/llvm-project/commit/5a6e6adb915835e09fb38d8a8bcba2807fdc4093.diff
LOG: [libc++] Make sure our .clang-format is used for all languages
In particular, this ensures that it is used for Objective-C and
Objective-C++, since we have a few files that get detected as that.
Differential Revision: https://reviews.llvm.org/D153289
Added:
Modified:
libcxx/.clang-format
libcxx/include/__config
libcxx/include/__type_traits/is_scalar.h
libcxx/utils/data/ignore_format.txt
Removed:
################################################################################
diff --git a/libcxx/.clang-format b/libcxx/.clang-format
index bb7abc6efc494..662c84783ac7f 100644
--- a/libcxx/.clang-format
+++ b/libcxx/.clang-format
@@ -1,4 +1,7 @@
BasedOnStyle: LLVM
+# Note that we don't specify the language in this file because some files are
+# detected as Cpp, but others are detected as ObjC and we want this formatting
+# to apply to all types of files.
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: Consecutive
@@ -66,7 +69,6 @@ PackConstructorInitializers: NextLine
PenaltyIndentedWhitespace: 2
-Language: Cpp
Standard: c++20
SpacesInAngles: Leave
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 40f7891a04105..37fb7f77924f4 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -313,8 +313,8 @@
# endif // __BYTE_ORDER__
# ifdef __FreeBSD__
-# include <sys/endian.h>
# include <osreldate.h>
+# include <sys/endian.h>
# if _BYTE_ORDER == _LITTLE_ENDIAN
# define _LIBCPP_LITTLE_ENDIAN
# else // _BYTE_ORDER == _LITTLE_ENDIAN
@@ -681,7 +681,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
# define _LIBCPP_PREFERRED_OVERLOAD __attribute__((__enable_if__(true, "")))
# endif
-#if !defined(__SIZEOF_INT128__) || defined(_MSC_VER)
+# if !defined(__SIZEOF_INT128__) || defined(_MSC_VER)
# define _LIBCPP_HAS_NO_INT128
# endif
@@ -699,7 +699,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
# ifdef _LIBCPP_CXX03_LANG
# define _LIBCPP_DECLARE_STRONG_ENUM(x) \
- struct _LIBCPP_EXPORTED_FROM_ABI x { \
+ struct _LIBCPP_EXPORTED_FROM_ABI x { \
enum __lx
// clang-format off
# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
@@ -807,11 +807,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
# define _LIBCPP_DEPRECATED_IN_CXX20
# endif
-#if _LIBCPP_STD_VER >= 23
-# define _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_DEPRECATED
-#else
-# define _LIBCPP_DEPRECATED_IN_CXX23
-#endif
+# if _LIBCPP_STD_VER >= 23
+# define _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_DEPRECATED
+# else
+# define _LIBCPP_DEPRECATED_IN_CXX23
+# endif
# if !defined(_LIBCPP_HAS_NO_CHAR8_T)
# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
@@ -1275,20 +1275,20 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
# endif
// TODO: Make this a proper configuration option
-#define _PSTL_PAR_BACKEND_SERIAL
+# define _PSTL_PAR_BACKEND_SERIAL
-#define _PSTL_PRAGMA(x) _Pragma(# x)
+# define _PSTL_PRAGMA(x) _Pragma(#x)
// Enable SIMD for compilers that support OpenMP 4.0
-#if (defined(_OPENMP) && _OPENMP >= 201307)
+# if (defined(_OPENMP) && _OPENMP >= 201307)
-# define _PSTL_UDR_PRESENT
-# 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_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))
+# define _PSTL_UDR_PRESENT
+# 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_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))
// Declaration of reduction functor, where
// NAME - the name of the functor
@@ -1297,22 +1297,22 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
// omp_out - refers to the final value of the combiner operator
// 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))
+# define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP) \
+ _PSTL_PRAGMA(omp declare reduction(NAME:OP : omp_out(omp_in)) initializer(omp_priv = omp_orig))
-#else // (defined(_OPENMP) && _OPENMP >= 201307)
+# else // (defined(_OPENMP) && _OPENMP >= 201307)
-# define _PSTL_PRAGMA_SIMD
-# define _PSTL_PRAGMA_DECLARE_SIMD
-# define _PSTL_PRAGMA_SIMD_REDUCTION(PRM)
-# define _PSTL_PRAGMA_SIMD_SCAN(PRM)
-# define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
-# define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
-# define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP)
+# define _PSTL_PRAGMA_SIMD
+# define _PSTL_PRAGMA_DECLARE_SIMD
+# define _PSTL_PRAGMA_SIMD_REDUCTION(PRM)
+# define _PSTL_PRAGMA_SIMD_SCAN(PRM)
+# define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
+# define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
+# define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP)
-#endif // (defined(_OPENMP) && _OPENMP >= 201307)
+# endif // (defined(_OPENMP) && _OPENMP >= 201307)
-#define _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
+# define _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
#endif // __cplusplus
diff --git a/libcxx/include/__type_traits/is_scalar.h b/libcxx/include/__type_traits/is_scalar.h
index 2bfedc3693659..15f1c71554f22 100644
--- a/libcxx/include/__type_traits/is_scalar.h
+++ b/libcxx/include/__type_traits/is_scalar.h
@@ -18,7 +18,7 @@
#include <__type_traits/is_pointer.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -28,17 +28,19 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_scalar : _BoolConstant<__is_scalar(_Tp)> {};
-#if _LIBCPP_STD_VER >= 17
-template <class _Tp> inline constexpr bool is_scalar_v = __is_scalar(_Tp);
-#endif
+# if _LIBCPP_STD_VER >= 17
+template <class _Tp>
+inline constexpr bool is_scalar_v = __is_scalar(_Tp);
+# endif
#else // __has_builtin(__is_scalar)
-template <class _Tp> struct __is_block : false_type {};
-#if defined(_LIBCPP_HAS_EXTENSION_BLOCKS)
+template <class _Tp>
+struct __is_block : false_type {};
+# if defined(_LIBCPP_HAS_EXTENSION_BLOCKS)
template <class _Rp, class... _Args>
struct __is_block<_Rp (^)(_Args...)> : true_type {};
-#endif
+# endif
// clang-format off
template <class _Tp>
@@ -55,9 +57,10 @@ struct _LIBCPP_TEMPLATE_VIS is_scalar
template <>
struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {};
-#if _LIBCPP_STD_VER >= 17
-template <class _Tp> inline constexpr bool is_scalar_v = is_scalar<_Tp>::value;
-#endif
+# if _LIBCPP_STD_VER >= 17
+template <class _Tp>
+inline constexpr bool is_scalar_v = is_scalar<_Tp>::value;
+# endif
#endif // __has_builtin(__is_scalar)
diff --git a/libcxx/utils/data/ignore_format.txt b/libcxx/utils/data/ignore_format.txt
index 5e5a23dfca1b6..c6d95af5a988c 100644
--- a/libcxx/utils/data/ignore_format.txt
+++ b/libcxx/utils/data/ignore_format.txt
@@ -149,7 +149,6 @@ libcxx/include/__compare/three_way_comparable.h
libcxx/include/__compare/weak_order.h
libcxx/include/complex
libcxx/include/condition_variable
-libcxx/include/__config
libcxx/include/__coroutine/coroutine_handle.h
libcxx/include/__coroutine/coroutine_traits.h
libcxx/include/__coroutine/noop_coroutine_handle.h
More information about the libcxx-commits
mailing list