Skip to content

Commit 7a2260f

Browse files
[SYCL][NFC] Refactor __SYCL_INLINE macro (#1121)
The problem with previous definition of macro is that clang-format insert additional indentation: Original code: ```c++ __SYCL_INLINE namespace cl { // some code ``` When applied clang-format: ```c++ __SYCL_INLINE namespace cl { // some code ``` Replaced `__SYCL_INLINE` with `__SYCL_INLINE_NAMESPACE(X)` which defines either inline or regular namespace and marked it as `NamespaceMacro` in clang-format config file to avoid dealing with broken formatting while adding new code Signed-off-by: Alexey Sachkov <[email protected]>
1 parent 49911de commit 7a2260f

File tree

168 files changed

+342
-341
lines changed

Some content is hidden

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

168 files changed

+342
-341
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,7 +1672,7 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
16721672
}
16731673
O << "\n";
16741674

1675-
O << "__SYCL_INLINE namespace cl {\n";
1675+
O << "__SYCL_INLINE_NAMESPACE(cl) {\n";
16761676
O << "namespace sycl {\n";
16771677
O << "namespace detail {\n";
16781678

@@ -1765,7 +1765,7 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
17651765
O << "\n";
17661766
O << "} // namespace detail\n";
17671767
O << "} // namespace sycl\n";
1768-
O << "} // namespace cl\n";
1768+
O << "} // __SYCL_INLINE_NAMESPACE(cl)\n";
17691769
O << "\n";
17701770
}
17711771

clang/test/CodeGenSYCL/wrapped-accessor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
// CHECK: class wrapped_access;
77

8-
// CHECK: namespace cl {
8+
// CHECK: __SYCL_INLINE_NAMESPACE(cl) {
99
// CHECK-NEXT: namespace sycl {
1010
// CHECK-NEXT: namespace detail {
1111

sycl/.clang-format

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
BasedOnStyle: LLVM
22
TypenameMacros: ['PI_CALL' ,'PI_CALL_THROW', 'PI_CALL_NOCHECK']
3+
NamespaceMacros: ['__SYCL_INLINE_NAMESPACE']

sycl/include/CL/sycl/access/access.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include <CL/sycl/detail/defines.hpp>
1111

12-
__SYCL_INLINE namespace cl {
12+
__SYCL_INLINE_NAMESPACE(cl) {
1313
namespace sycl {
1414
namespace access {
1515

@@ -180,4 +180,4 @@ struct remove_AS<__OPENCL_CONSTANT_AS__ T> {
180180
} // namespace detail
181181

182182
} // namespace sycl
183-
} // namespace cl
183+
} // __SYCL_INLINE_NAMESPACE(cl)

sycl/include/CL/sycl/accessor.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
// accessor_common contains several helpers common for both accessor(1) and
144144
// accessor(3)
145145

146-
__SYCL_INLINE namespace cl {
146+
__SYCL_INLINE_NAMESPACE(cl) {
147147
namespace sycl {
148148

149149
template <typename DataT, int Dimensions, access::mode AccessMode,
@@ -1264,7 +1264,7 @@ class accessor<DataT, Dimensions, AccessMode, access::target::image_array,
12641264
};
12651265

12661266
} // namespace sycl
1267-
} // namespace cl
1267+
} // __SYCL_INLINE_NAMESPACE(cl)
12681268

12691269
namespace std {
12701270
template <typename DataT, int Dimensions, cl::sycl::access::mode AccessMode,

sycl/include/CL/sycl/aliases.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <cstddef>
1414
#include <cstdint>
1515

16-
__SYCL_INLINE namespace cl {
16+
__SYCL_INLINE_NAMESPACE(cl) {
1717
namespace sycl {
1818
template <typename T, int N> class vec;
1919
namespace detail {
@@ -22,7 +22,7 @@ class half;
2222
} // namespace half_impl
2323
} // namespace detail
2424
} // namespace sycl
25-
} // namespace cl
25+
} // __SYCL_INLINE_NAMESPACE(cl)
2626

2727
// FIXME: line below exports 'half' into global namespace, which seems incorrect
2828
// However, SYCL 1.2.1 spec considers 'half' to be a fundamental C++ data type
@@ -69,7 +69,7 @@ using half = cl::sycl::detail::half_impl::half;
6969
MAKE_VECTOR_ALIASES_FOR_OPENCL_TYPES(N) \
7070
MAKE_VECTOR_ALIASES_FOR_SIGNED_AND_UNSIGNED_TYPES(N)
7171

72-
__SYCL_INLINE namespace cl {
72+
__SYCL_INLINE_NAMESPACE(cl) {
7373
namespace sycl {
7474
using byte = std::uint8_t;
7575
using schar = signed char;
@@ -101,7 +101,7 @@ MAKE_VECTOR_ALIASES_FOR_VECTOR_LENGTH(4)
101101
MAKE_VECTOR_ALIASES_FOR_VECTOR_LENGTH(8)
102102
MAKE_VECTOR_ALIASES_FOR_VECTOR_LENGTH(16)
103103
} // namespace sycl
104-
} // namespace cl
104+
} // __SYCL_INLINE_NAMESPACE(cl)
105105

106106
#undef MAKE_VECTOR_ALIAS
107107
#undef MAKE_VECTOR_ALIASES_FOR_ARITHMETIC_TYPES

sycl/include/CL/sycl/atomic.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
static_assert(!std::is_same<T, float>::value, \
2424
"SYCL atomic function not available for float type")
2525

26-
__SYCL_INLINE namespace cl {
26+
__SYCL_INLINE_NAMESPACE(cl) {
2727
namespace sycl {
2828

2929
enum class memory_order : int { relaxed };
@@ -62,11 +62,11 @@ template <> struct GetSpirvMemoryScope<access::address_space::local_space> {
6262

6363
} // namespace detail
6464
} // namespace sycl
65-
} // namespace cl
65+
} // __SYCL_INLINE_NAMESPACE(cl)
6666

6767
#ifndef __SYCL_DEVICE_ONLY__
6868
// host implementation of SYCL atomics
69-
__SYCL_INLINE namespace cl {
69+
__SYCL_INLINE_NAMESPACE(cl) {
7070
namespace sycl {
7171
namespace detail {
7272
// Translate cl::sycl::memory_order or __spv::MemorySemanticsMask
@@ -81,7 +81,7 @@ static inline std::memory_order getStdMemoryOrder(::cl::sycl::memory_order MS) {
8181
}
8282
} // namespace detail
8383
} // namespace sycl
84-
} // namespace cl
84+
} // __SYCL_INLINE_NAMESPACE(cl)
8585

8686
// std::atomic version of atomic SPIR-V builtins
8787

@@ -161,7 +161,7 @@ extern T __spirv_AtomicMax(std::atomic<T> *Ptr, __spv::Scope S,
161161

162162
#endif // !defined(__SYCL_DEVICE_ONLY__)
163163

164-
__SYCL_INLINE namespace cl {
164+
__SYCL_INLINE_NAMESPACE(cl) {
165165
namespace sycl {
166166

167167
template <typename T, access::address_space addressSpace =
@@ -369,6 +369,6 @@ T atomic_fetch_max(atomic<T, addressSpace> Object, T Operand,
369369
}
370370

371371
} // namespace sycl
372-
} // namespace cl
372+
} // __SYCL_INLINE_NAMESPACE(cl)
373373

374374
#undef STATIC_ASSERT_NOT_FLOAT

sycl/include/CL/sycl/buffer.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
// TODO: 4.3.4 Properties
1616

17-
__SYCL_INLINE namespace cl {
17+
__SYCL_INLINE_NAMESPACE(cl) {
1818
namespace sycl {
1919
class handler;
2020
class queue;
@@ -396,7 +396,7 @@ buffer(const T *, const range<dimensions> &, const property_list & = {})
396396
#endif // __cpp_deduction_guides
397397

398398
} // namespace sycl
399-
} // namespace cl
399+
} // __SYCL_INLINE_NAMESPACE(cl)
400400

401401
namespace std {
402402
template <typename T, int dimensions, typename AllocatorT>

sycl/include/CL/sycl/builtins.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717
// TODO Decide whether to mark functions with this attribute.
1818
#define __NOEXC /*noexcept*/
1919

20-
__SYCL_INLINE namespace cl {
20+
__SYCL_INLINE_NAMESPACE(cl) {
2121
namespace sycl {
2222
#ifdef __SYCL_DEVICE_ONLY__
2323
#define __sycl_std
2424
#else
2525
namespace __sycl_std = __host_std;
2626
#endif
2727
} // namespace sycl
28-
} // namespace cl
28+
} // __SYCL_INLINE_NAMESPACE(cl)
2929

30-
__SYCL_INLINE namespace cl {
30+
__SYCL_INLINE_NAMESPACE(cl) {
3131
namespace sycl {
3232
/* ----------------- 4.13.3 Math functions. ---------------------------------*/
3333
// genfloat acos (genfloat x)
@@ -1546,6 +1546,6 @@ detail::enable_if_t<detail::is_genfloatf<T>::value, T> tan(T x) __NOEXC {
15461546

15471547
} // namespace half_precision
15481548
} // namespace sycl
1549-
} // namespace cl
1549+
} // __SYCL_INLINE_NAMESPACE(cl)
15501550

15511551
#undef __NOEXC

sycl/include/CL/sycl/context.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <type_traits>
1515
// 4.6.2 Context class
1616

17-
__SYCL_INLINE namespace cl {
17+
__SYCL_INLINE_NAMESPACE(cl) {
1818
namespace sycl {
1919
// Forward declarations
2020
class device;
@@ -139,7 +139,7 @@ class context {
139139
};
140140

141141
} // namespace sycl
142-
} // namespace cl
142+
} // __SYCL_INLINE_NAMESPACE(cl)
143143

144144
namespace std {
145145
template <> struct hash<cl::sycl::context> {

0 commit comments

Comments
 (0)