Skip to content

Commit cdfee11

Browse files
author
Sergey Kanaev
committed
[SYCL] Fix some code-style issues
Signed-off-by: Sergey Kanaev <sergey.kanaev@intel.com>
1 parent a806343 commit cdfee11

File tree

8 files changed

+109
-108
lines changed

8 files changed

+109
-108
lines changed

clang/lib/Sema/SemaDecl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17942,9 +17942,9 @@ Decl *Sema::getObjCDeclContext() const {
1794217942
Sema::FunctionEmissionStatus Sema::getEmissionStatus(FunctionDecl *FD) {
1794317943
// Due to SYCL functions are template we check if they have appropriate
1794417944
// attribute prior to checking if it is a template
17945-
if (LangOpts.SYCLIsDevice && (FD->hasAttr<SYCLDeviceAttr>() ||
17946-
FD->hasAttr<SYCLKernelAttr>()))
17947-
return FunctionEmissionStatus::Emitted;
17945+
if (LangOpts.SYCLIsDevice &&
17946+
(FD->hasAttr<SYCLDeviceAttr>() || FD->hasAttr<SYCLKernelAttr>()))
17947+
return FunctionEmissionStatus::Emitted;
1794817948

1794917949
// Templates are emitted when they're instantiated.
1795017950
if (FD->isDependentContext())

clang/test/SemaSYCL/call-to-undefined-function.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void definedPartialTpl() {
3131
// empty
3232
}
3333

34-
template<>
34+
template <>
3535
void definedPartialTpl<char, true>() {
3636
// empty
3737
}

clang/test/SemaSYCL/restrict-recursion4.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,24 @@
22

33
// This recursive function is not called from sycl kernel,
44
// so it should not be diagnosed.
5-
int fib(int n)
6-
{
7-
if (n <= 1)
8-
return n;
9-
return fib(n-1) + fib(n-2);
5+
int fib(int n) {
6+
if (n <= 1)
7+
return n;
8+
return fib(n - 1) + fib(n - 2);
109
}
1110

12-
// expected-note@+1 2{{function implemented using recursion declared here}}
11+
// expected-note@+1 2{{function implemented using recursion declared here}}
1312
void kernel2(void) {
1413
// expected-error@+1 {{SYCL kernel cannot call a recursive function}}
1514
kernel2();
1615
}
1716

18-
using myFuncDef = int(int,int);
17+
using myFuncDef = int(int, int);
1918

2019
typedef __typeof__(sizeof(int)) size_t;
2120

2221
SYCL_EXTERNAL
23-
void* operator new(size_t);
22+
void *operator new(size_t);
2423

2524
void usage2(myFuncDef functionPtr) {
2625
// expected-error@+1 {{SYCL kernel cannot allocate storage}}
@@ -30,7 +29,7 @@ void usage2(myFuncDef functionPtr) {
3029
}
3130

3231
int addInt(int n, int m) {
33-
return n+m;
32+
return n + m;
3433
}
3534

3635
template <typename name, typename Func>
@@ -41,6 +40,6 @@ __attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
4140

4241
int main() {
4342
// expected-note@+1 {{called by 'operator()'}}
44-
kernel_single_task<class fake_kernel>([]() {usage2(&addInt);});
43+
kernel_single_task<class fake_kernel>([]() { usage2(&addInt); });
4544
return fib(5);
4645
}

clang/test/SemaSYCL/sycl-restrict.cpp

Lines changed: 63 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,46 @@
22
// RUN: %clang_cc1 -fcxx-exceptions -triple spir64 -fsycl-is-device -fno-sycl-allow-func-ptr -Wno-return-type -verify -fsyntax-only -std=c++17 %s
33
// RUN: %clang_cc1 -fcxx-exceptions -triple spir64 -fsycl-is-device -DALLOW_FP=1 -fsycl-allow-func-ptr -Wno-return-type -verify -fsyntax-only -std=c++17 %s
44

5-
65
namespace std {
7-
class type_info;
8-
typedef __typeof__(sizeof(int)) size_t;
9-
}
6+
class type_info;
7+
typedef __typeof__(sizeof(int)) size_t;
8+
} // namespace std
109

1110
// we're testing a restricted mode, thus just provide a stub implementation for
1211
// function with address-space-unspecified pointers.
13-
void* operator new(std::size_t) {
12+
void *operator new(std::size_t) {
1413
return reinterpret_cast<void *>(1);
1514
}
1615

1716
namespace Check_User_Operators {
18-
class Fraction
19-
{
20-
// expected-error@+2 {{SYCL kernel cannot call a recursive function}}
21-
// expected-note@+1 {{function implemented using recursion declared here}}
22-
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
23-
int n, d;
17+
class Fraction {
18+
// expected-error@+2 {{SYCL kernel cannot call a recursive function}}
19+
// expected-note@+1 {{function implemented using recursion declared here}}
20+
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
21+
int n, d;
22+
2423
public:
25-
Fraction(int n, int d = 1) : n(n/gcd(n, d)), d(d/gcd(n, d)) { }
26-
int num() const { return n; }
27-
int den() const { return d; }
24+
Fraction(int n, int d = 1) : n(n / gcd(n, d)), d(d / gcd(n, d)) {}
25+
int num() const { return n; }
26+
int den() const { return d; }
2827
};
29-
bool operator==(const Fraction& lhs, const Fraction& rhs)
30-
{
31-
new int; // expected-error {{SYCL kernel cannot allocate storage}}
32-
return lhs.num() == rhs.num() && lhs.den() == rhs.den();
33-
}}
28+
bool operator==(const Fraction &lhs, const Fraction &rhs) {
29+
new int; // expected-error {{SYCL kernel cannot allocate storage}}
30+
return lhs.num() == rhs.num() && lhs.den() == rhs.den();
31+
}
32+
} // namespace Check_User_Operators
3433

3534
namespace Check_VLA_Restriction {
3635
void no_restriction(int p) {
37-
int index[p+2];
36+
int index[p + 2];
3837
}
3938
void restriction(int p) {
4039
// expected-error@+1 {{variable length arrays are not supported for the current target}}
41-
int index[p+2];
42-
}
40+
int index[p + 2];
4341
}
42+
} // namespace Check_VLA_Restriction
4443

45-
void* operator new (std::size_t size, void* ptr) throw() { return ptr; };
44+
void *operator new(std::size_t size, void *ptr) throw() { return ptr; };
4645
namespace Check_RTTI_Restriction {
4746
struct A {
4847
virtual ~A(){};
@@ -57,35 +56,38 @@ struct OverloadedNewDelete {
5756
void *operator new(std::size_t size) throw() {
5857
// expected-error@+1 {{SYCL kernel cannot allocate storage}}
5958
float *pt = new float;
60-
return 0;}
59+
return 0;
60+
}
6161
// This overload does not allocate: no diagnostic.
62-
void *operator new[](std::size_t size) throw() {return 0;}
62+
void *operator new[](std::size_t size) throw() { return 0; }
6363
void operator delete(void *){};
6464
void operator delete[](void *){};
6565
};
6666

6767
bool isa_B(A *a) {
6868
Check_User_Operators::Fraction f1(3, 8), f2(1, 2), f3(10, 2);
69-
if (f1 == f2) return false;
69+
if (f1 == f2)
70+
return false;
7071

7172
Check_VLA_Restriction::restriction(7);
7273
// expected-error@+1 {{SYCL kernel cannot allocate storage}}
7374
int *ip = new int;
74-
int i; int *p3 = new(&i) int; // no error on placement new
75+
int i;
76+
int *p3 = new (&i) int; // no error on placement new
7577
// expected-note@+1 {{called by 'isa_B'}}
76-
OverloadedNewDelete *x = new( struct OverloadedNewDelete );
77-
auto y = new struct OverloadedNewDelete [5];
78+
OverloadedNewDelete *x = new (struct OverloadedNewDelete);
79+
auto y = new struct OverloadedNewDelete[5];
7880
// expected-error@+1 {{SYCL kernel cannot use rtti}}
7981
(void)typeid(int);
8082
// expected-error@+1 {{SYCL kernel cannot use rtti}}
8183
return dynamic_cast<B *>(a) != 0;
8284
}
8385

84-
template<typename N, typename L>
86+
template <typename N, typename L>
8587
__attribute__((sycl_kernel)) void kernel1(L l) {
8688
l();
8789
}
88-
}
90+
} // namespace Check_RTTI_Restriction
8991

9092
typedef struct Base {
9193
virtual void f() const {}
@@ -94,22 +96,19 @@ typedef struct Base {
9496
typedef struct A {
9597
static int stat_member;
9698
const static int const_stat_member;
97-
constexpr static int constexpr_stat_member=0;
99+
constexpr static int constexpr_stat_member = 0;
98100

99-
int fm(void)
100-
{
101+
int fm(void) {
101102
// expected-error@+1 {{SYCL kernel cannot use a non-const static data variable}}
102103
return stat_member;
103104
}
104105
} a_type;
105106

106-
107107
b_type b;
108108

109-
using myFuncDef = int(int,int);
109+
using myFuncDef = int(int, int);
110110

111-
void eh_ok(void)
112-
{
111+
void eh_ok(void) {
113112
__float128 A;
114113
try {
115114
;
@@ -119,8 +118,7 @@ void eh_ok(void)
119118
throw 20;
120119
}
121120

122-
void eh_not_ok(void)
123-
{
121+
void eh_not_ok(void) {
124122
// expected-error@+1 {{SYCL kernel cannot use exceptions}}
125123
try {
126124
;
@@ -153,44 +151,50 @@ void usage(myFuncDef functionPtr) {
153151
}
154152

155153
namespace ns {
156-
int glob;
154+
int glob;
157155
}
158156
extern "C++" {
159-
int another_global = 5;
160-
namespace AnotherNS {
161-
int moar_globals = 5;
162-
}
157+
int another_global = 5;
158+
namespace AnotherNS {
159+
int moar_globals = 5;
160+
}
163161
}
164162

165163
int addInt(int n, int m) {
166-
return n+m;
164+
return n + m;
167165
}
168166

169-
int use2 ( a_type ab, a_type *abp ) {
167+
int use2(a_type ab, a_type *abp) {
170168

171-
if (ab.constexpr_stat_member) return 2;
172-
if (ab.const_stat_member) return 1;
169+
if (ab.constexpr_stat_member)
170+
return 2;
171+
if (ab.const_stat_member)
172+
return 1;
173173
// expected-error@+1 {{SYCL kernel cannot use a non-const static data variable}}
174-
if (ab.stat_member) return 0;
174+
if (ab.stat_member)
175+
return 0;
175176
// expected-error@+1 {{SYCL kernel cannot use a non-const static data variable}}
176-
if (abp->stat_member) return 0;
177-
if (ab.fm()) return 0;
177+
if (abp->stat_member)
178+
return 0;
179+
if (ab.fm())
180+
return 0;
178181
// expected-error@+1 {{SYCL kernel cannot use a global variable}}
179-
return another_global ;
182+
return another_global;
180183
// expected-error@+1 {{SYCL kernel cannot use a global variable}}
181184
return ns::glob +
182-
// expected-error@+1 {{SYCL kernel cannot use a global variable}}
183-
AnotherNS::moar_globals;
185+
// expected-error@+1 {{SYCL kernel cannot use a global variable}}
186+
AnotherNS::moar_globals;
184187
// expected-note@+1 {{called by 'use2'}}
185188
eh_not_ok();
186-
Check_RTTI_Restriction:: A *a;
189+
Check_RTTI_Restriction::A *a;
187190
// expected-note@+1 2{{called by 'use2'}}
188-
Check_RTTI_Restriction:: isa_B(a);
191+
Check_RTTI_Restriction::isa_B(a);
189192
// expected-note@+1 {{called by 'use2'}}
190193
usage(&addInt);
191194
Check_User_Operators::Fraction f1(3, 8), f2(1, 2), f3(10, 2);
192195
// expected-note@+1 {{called by 'use2'}}
193-
if (f1 == f2) return false;
196+
if (f1 == f2)
197+
return false;
194198
}
195199

196200
template <typename name, typename Func>
@@ -204,7 +208,6 @@ __attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
204208

205209
int main() {
206210
a_type ab;
207-
kernel_single_task<class fake_kernel>([]() { usage( &addInt ); });
211+
kernel_single_task<class fake_kernel>([]() { usage(&addInt); });
208212
return 0;
209213
}
210-

clang/test/SemaSYCL/sycl-varargs-cconv.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#if defined(PRINTF_INVALID_DECL)
1010
extern "C" SYCL_EXTERNAL int __spirv_ocl_printf(const char *__format, ...);
1111
namespace A {
12-
SYCL_EXTERNAL int __spirv_ocl_printf(const char *__format, ...);
12+
SYCL_EXTERNAL int __spirv_ocl_printf(const char *__format, ...);
1313
}
1414
#elif defined(PRINTF_INVALID_DEF)
1515
int __spirv_ocl_printf(const char *__format, ...) {
@@ -23,10 +23,10 @@ SYCL_EXTERNAL
2323
int __spirv_ocl_printf(const char *__format, ...);
2424
#elif defined(PRINTF_VALID2)
2525
extern "C" {
26-
extern "C++" {
27-
SYCL_EXTERNAL
28-
int __spirv_ocl_printf(const char *__format, ...);
29-
}
26+
extern "C++" {
27+
SYCL_EXTERNAL
28+
int __spirv_ocl_printf(const char *__format, ...);
29+
}
3030
}
3131
#else
3232
SYCL_EXTERNAL
@@ -38,7 +38,7 @@ SYCL_EXTERNAL int __cdecl foo(int, ...); // expected-no-error
3838
float bar(float f, ...) { return ++f; } // expected-no-error
3939

4040
void bar() {
41-
foo(5); // expected-no-error
41+
foo(5); // expected-no-error
4242
bar(7.0f); // expected-no-error
4343
}
4444

sycl/include/CL/sycl/builtins.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,14 +1545,13 @@ detail::enable_if_t<detail::is_genfloatf<T>::value, T> tan(T x) __NOEXC {
15451545
#ifdef __SYCL_DEVICE_ONLY__
15461546
#if defined(__GNUC__) || defined(__clang__)
15471547
extern "C" {
1548-
extern SYCL_EXTERNAL
1549-
void __assert_fail(const char *expr, const char *file,
1550-
unsigned int line, const char *func);
1548+
extern SYCL_EXTERNAL void __assert_fail(const char *expr, const char *file,
1549+
unsigned int line, const char *func);
15511550
}
15521551
#elif defined(_MSC_VER)
15531552
extern "C" {
1554-
extern SYCL_EXTERNAL
1555-
void _wassert(const wchar_t *wexpr, const wchar_t *wfile, unsigned line);
1553+
extern SYCL_EXTERNAL void _wassert(const wchar_t *wexpr, const wchar_t *wfile,
1554+
unsigned line);
15561555
}
15571556
#endif // defined(_MSC_VER_)
15581557
#endif // __SYCL_DEVICE_ONLY__

0 commit comments

Comments
 (0)