Skip to content

Commit 573e951

Browse files
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.
1 parent 38db490 commit 573e951

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/SPIRV/SPIRVRegularizeLLVM.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -513,13 +513,14 @@ void prepareCacheControlsTranslation(Metadata *MD, Instruction *Inst) {
513513
for (unsigned I = 0, E = ArgDecoMD->getNumOperands(); I != E; ++I) {
514514
auto *DecoMD = dyn_cast<MDNode>(ArgDecoMD->getOperand(I));
515515
if (!DecoMD) {
516-
assert(!"Decoration does not name metadata");
516+
assert(false && "Decoration does not name metadata");
517517
return;
518518
}
519519

520520
constexpr size_t CacheControlsNumOps = 4;
521521
if (DecoMD->getNumOperands() != CacheControlsNumOps) {
522-
assert(!"Cache controls metadata on instruction must have 4 operands");
522+
assert(false &&
523+
"Cache controls metadata on instruction must have 4 operands");
523524
return;
524525
}
525526

@@ -532,7 +533,7 @@ void prepareCacheControlsTranslation(Metadata *MD, Instruction *Inst) {
532533
->getZExtValue();
533534
Value *PtrInstOp = Inst->getOperand(TargetArgNo);
534535
if (!PtrInstOp->getType()->isPointerTy()) {
535-
assert(!"Cache controls must decorate a pointer");
536+
assert(false && "Cache controls must decorate a pointer");
536537
return;
537538
}
538539

lib/SPIRV/SPIRVWriter.cpp

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

54525452
StringRef AnnotationString;
54535453
if (!getConstantStringInfo(GV, AnnotationString)) {
5454-
assert(!"Annotation string missing");
5454+
assert(false && "Annotation string missing");
54555455
return;
54565456
}
54575457
DecorationsInfoVec Decorations =

0 commit comments

Comments
 (0)