Skip to content

Commit

Permalink
Fix typo in an assert message (KhronosGroup#220)
Browse files Browse the repository at this point in the history
* Fix typo in an assert message and get rid of build warnings.

Value of size_t type is always >= 0; Use explicit conversion from uint64_t to unsigned.
  • Loading branch information
Lifeng Pan authored and bader committed Aug 16, 2017
1 parent 0d6cd12 commit d28c6f4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/SPIRV/libSPIRV/SPIRVDecorate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ SPIRVDecorateGeneric::getDecorateKind()const {

SPIRVWord
SPIRVDecorateGeneric::getLiteral(size_t i) const {
assert(0 <= i && i <= Literals.size() && "Out of bounds");
assert(i <= Literals.size() && "Out of bounds");
return Literals[i];
}

Expand Down
2 changes: 1 addition & 1 deletion lib/SPIRV/libSPIRV/SPIRVModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ SPIRVModuleImpl::addConstant(SPIRVType *Ty, uint64_t V) {
SPIRVValue *
SPIRVModuleImpl::addIntegerConstant(SPIRVTypeInt *Ty, uint64_t V) {
if (Ty->getBitWidth() == 32) {
unsigned I32 = V;
unsigned I32 = static_cast<unsigned>(V);
assert(I32 == V && "Integer value truncated");
return getLiteralAsConstant(I32);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/SPIRV/libSPIRV/SPIRVType.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- SPIRVtype.cpp – Class to represent a SPIR-V type ----------*- C++ -*-===//
//===- SPIRVtype.cpp – Class to represent a SPIR-V type ----------*- C++ -*-===//
//
// The LLVM/SPIRV Translator
//
Expand Down Expand Up @@ -70,7 +70,7 @@ SPIRVType::getBitWidth() const {

SPIRVWord
SPIRVType::getFloatBitWidth()const {
assert(OpCode == OpTypeFloat && "Not an integer type");
assert(OpCode == OpTypeFloat && "Not a float type");
return static_cast<const SPIRVTypeFloat *const>(this)->getBitWidth();
}

Expand Down

0 comments on commit d28c6f4

Please sign in to comment.