Skip to content

Commit 296cb64

Browse files
authored
Fix static analysis issues (#1827)
In some cases, return value of consume_front is ignored. This change fixes the issue. Signed-off-by: Arvind Sudarsanam <arvind.sudarsanam@intel.com>
1 parent 308daff commit 296cb64

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

lib/SPIRV/OCLToSPIRV.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -811,8 +811,8 @@ void OCLToSPIRVBase::visitCallGroupBuiltin(CallInst *CI,
811811
.Case("ballot_inclusive_scan", "add")
812812
.Case("ballot_exclusive_scan", "add")
813813
.Default(FuncName.take_back(
814-
3)); // assumes op is three characters
815-
GroupOp.consume_front("_"); // when op is two characters
814+
3)); // assumes op is three characters
815+
(void)(GroupOp.consume_front("_")); // when op is two characters
816816
assert(!GroupOp.empty() && "Invalid OpenCL group builtin function");
817817
char OpTyC = 0;
818818
auto OpTy = F->getReturnType();

lib/SPIRV/OCLUtil.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,8 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
11811181
} else if (NameRef.contains("broadcast")) {
11821182
addUnsignedArg(-1);
11831183
} else if (NameRef.startswith(kOCLBuiltinName::SampledReadImage)) {
1184-
NameRef.consume_front(kOCLBuiltinName::Sampled);
1184+
if (!NameRef.consume_front(kOCLBuiltinName::Sampled))
1185+
report_fatal_error(llvm::Twine("Builtin name illformed"));
11851186
addSamplerArg(1);
11861187
} else if (NameRef.contains(kOCLSubgroupsAVCIntel::Prefix)) {
11871188
if (NameRef.contains("evaluate_ipe"))

lib/SPIRV/SPIRVUtil.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ bool isSYCLHalfType(llvm::Type *Ty) {
219219
if (!ST->hasName())
220220
return false;
221221
StringRef Name = ST->getName();
222-
Name.consume_front("class.");
222+
if (!Name.consume_front("class."))
223+
return false;
223224
if ((Name.startswith("sycl::") || Name.startswith("cl::sycl::") ||
224225
Name.startswith("__sycl_internal::")) &&
225226
Name.endswith("::half")) {
@@ -234,7 +235,8 @@ bool isSYCLBfloat16Type(llvm::Type *Ty) {
234235
if (!ST->hasName())
235236
return false;
236237
StringRef Name = ST->getName();
237-
Name.consume_front("class.");
238+
if (!Name.consume_front("class."))
239+
return false;
238240
if ((Name.startswith("sycl::") || Name.startswith("cl::sycl::") ||
239241
Name.startswith("__sycl_internal::")) &&
240242
Name.endswith("::bfloat16")) {

0 commit comments

Comments
 (0)