Skip to content

Commit 3921244

Browse files
[SYCL] Fixed bug reported by a static verifier (#10452)
The static verifier tool reported following three issues and fixed with adding a copy constructor & assignment operator, and removing dead code. Logically dead code Missing assignment operator Copy without assign --------- Signed-off-by: Kim, Euna <[email protected]> Co-authored-by: Dmitry Vodopyanov <[email protected]>
1 parent ee0d5ed commit 3921244

File tree

6 files changed

+16
-5
lines changed

6 files changed

+16
-5
lines changed

sycl/source/detail/global_handler.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class GlobalHandler {
5454

5555
GlobalHandler(const GlobalHandler &) = delete;
5656
GlobalHandler(GlobalHandler &&) = delete;
57+
GlobalHandler &operator=(const GlobalHandler &) = delete;
5758

5859
void registerSchedulerUsage(bool ModifyCounter = true);
5960
Scheduler &getScheduler();

sycl/source/detail/program_impl.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ program_impl::program_impl(ContextImplPtr Context,
165165
sycl::detail::pi::PiDevice Device =
166166
getSyclObjImpl(MDevices[0])->getHandleRef();
167167
// TODO check build for each device instead
168-
cl_program_binary_type BinaryType;
168+
cl_program_binary_type BinaryType = PI_PROGRAM_BINARY_TYPE_NONE;
169169
Plugin->call<PiApiKind::piProgramGetBuildInfo>(
170170
MProgram, Device, PI_PROGRAM_BUILD_INFO_BINARY_TYPE,
171171
sizeof(cl_program_binary_type), &BinaryType, nullptr);
@@ -184,20 +184,21 @@ program_impl::program_impl(ContextImplPtr Context,
184184
OptionsVector.data(), nullptr);
185185
std::string Options(OptionsVector.begin(), OptionsVector.end());
186186
switch (BinaryType) {
187-
case PI_PROGRAM_BINARY_TYPE_NONE:
188-
assert(false);
189-
break;
190187
case PI_PROGRAM_BINARY_TYPE_COMPILED_OBJECT:
191188
MState = program_state::compiled;
192189
MCompileOptions = Options;
193190
MBuildOptions = Options;
194-
break;
191+
return;
195192
case PI_PROGRAM_BINARY_TYPE_LIBRARY:
196193
case PI_PROGRAM_BINARY_TYPE_EXECUTABLE:
197194
MState = program_state::linked;
198195
MLinkOptions = "";
199196
MBuildOptions = Options;
197+
return;
200198
}
199+
// TODO: uncomment the assert when UR_PROGRAM_BINARY_TYPE_EXECUTABLE
200+
// value matches to PI_PROGRAM_BINARY_TYPE_EXECUTABLE value
201+
// assert(false && "BinaryType is invalid.");
201202
}
202203

203204
program_impl::program_impl(ContextImplPtr Context,

sycl/source/detail/scheduler/commands.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ bool CurrentCodeLocationValid() {
7070
struct DemangleHandle {
7171
char *p;
7272
DemangleHandle(char *ptr) : p(ptr) {}
73+
74+
DemangleHandle &operator=(const DemangleHandle &) = delete;
75+
7376
~DemangleHandle() { std::free(p); }
7477
};
7578
static std::string demangleKernelName(std::string Name) {

sycl/source/detail/scheduler/leaves_collection.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ class LeavesCollection {
221221
(!MGenericIsActive && MHACIt != Rhs.MHACIt));
222222
}
223223

224+
IteratorT &operator=(const IteratorT<IsConst> &) = delete;
225+
224226
// pre-increment
225227
IteratorT<IsConst> &operator++() {
226228
increment();

sycl/source/detail/xpti_registry.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ class XPTIScope {
199199
}
200200
}
201201

202+
XPTIScope &operator=(const XPTIScope &) = delete;
203+
202204
xpti::trace_event_data_t *traceEvent() { return MTraceEvent; }
203205

204206
uint8_t streamID() { return MStreamID; }

xpti/src/xpti_proxy.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ class ProxyLoader {
9393
tryToEnable();
9494
}
9595

96+
ProxyLoader &operator=(const ProxyLoader &) = delete;
97+
9698
~ProxyLoader() {
9799
// If the loading of the framework library was
98100
// successful, we should close the handle in the

0 commit comments

Comments
 (0)