From d28c6f49213e4ff44b670de6bf95b29f04f5cc85 Mon Sep 17 00:00:00 2001 From: Lifeng Pan Date: Wed, 16 Aug 2017 18:28:35 +0800 Subject: [PATCH] Fix typo in an assert message (#220) * 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. --- lib/SPIRV/libSPIRV/SPIRVDecorate.cpp | 2 +- lib/SPIRV/libSPIRV/SPIRVModule.cpp | 2 +- lib/SPIRV/libSPIRV/SPIRVType.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/SPIRV/libSPIRV/SPIRVDecorate.cpp b/lib/SPIRV/libSPIRV/SPIRVDecorate.cpp index 92a84619d19..9790b1886a9 100644 --- a/lib/SPIRV/libSPIRV/SPIRVDecorate.cpp +++ b/lib/SPIRV/libSPIRV/SPIRVDecorate.cpp @@ -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]; } diff --git a/lib/SPIRV/libSPIRV/SPIRVModule.cpp b/lib/SPIRV/libSPIRV/SPIRVModule.cpp index d24db9bb36e..308c7da3951 100644 --- a/lib/SPIRV/libSPIRV/SPIRVModule.cpp +++ b/lib/SPIRV/libSPIRV/SPIRVModule.cpp @@ -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(V); assert(I32 == V && "Integer value truncated"); return getLiteralAsConstant(I32); } diff --git a/lib/SPIRV/libSPIRV/SPIRVType.cpp b/lib/SPIRV/libSPIRV/SPIRVType.cpp index a8277f504aa..82cf0e05fd3 100644 --- a/lib/SPIRV/libSPIRV/SPIRVType.cpp +++ b/lib/SPIRV/libSPIRV/SPIRVType.cpp @@ -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 // @@ -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(this)->getBitWidth(); }