Skip to content

Commit 8b22761

Browse files
DavidSpickettjsji
authored andcommitted
Fix string to bool conversion warnings in asserts (#2746)
/SPIRV-LLVM-Translator/lib/SPIRV/SPIRVRegularizeLLVM.cpp:535:15: warning: implicit conversion turns string literal into bool: 'const char[39]' to 'bool' [-Wstring-conversion] 535 | assert(!"Cache controls must decorate a pointer"); | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/assert.h:93:27: note: expanded from macro 'assert' 93 | (static_cast <bool> (expr) \ | ^~~~ The original code is not wrong but `false &&` is only a few characters more and does the same thing without warning. Original commit: KhronosGroup/SPIRV-LLVM-Translator@573e951a3207fe9
1 parent f6ec759 commit 8b22761

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

llvm-spirv/lib/SPIRV/SPIRVRegularizeLLVM.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -574,13 +574,14 @@ void prepareCacheControlsTranslation(Metadata *MD, Instruction *Inst) {
574574
for (unsigned I = 0, E = ArgDecoMD->getNumOperands(); I != E; ++I) {
575575
auto *DecoMD = dyn_cast<MDNode>(ArgDecoMD->getOperand(I));
576576
if (!DecoMD) {
577-
assert(!"Decoration does not name metadata");
577+
assert(false && "Decoration does not name metadata");
578578
return;
579579
}
580580

581581
constexpr size_t CacheControlsNumOps = 4;
582582
if (DecoMD->getNumOperands() != CacheControlsNumOps) {
583-
assert(!"Cache controls metadata on instruction must have 4 operands");
583+
assert(false &&
584+
"Cache controls metadata on instruction must have 4 operands");
584585
return;
585586
}
586587

@@ -593,7 +594,7 @@ void prepareCacheControlsTranslation(Metadata *MD, Instruction *Inst) {
593594
->getZExtValue();
594595
Value *PtrInstOp = Inst->getOperand(TargetArgNo);
595596
if (!PtrInstOp->getType()->isPointerTy()) {
596-
assert(!"Cache controls must decorate a pointer");
597+
assert(false && "Cache controls must decorate a pointer");
597598
return;
598599
}
599600

llvm-spirv/lib/SPIRV/SPIRVWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5458,7 +5458,7 @@ void LLVMToSPIRVBase::transGlobalAnnotation(GlobalVariable *V) {
54585458

54595459
StringRef AnnotationString;
54605460
if (!getConstantStringInfo(GV, AnnotationString)) {
5461-
assert(!"Annotation string missing");
5461+
assert(false && "Annotation string missing");
54625462
return;
54635463
}
54645464
DecorationsInfoVec Decorations =

0 commit comments

Comments
 (0)