Switch to warning level 4 (#240)

This commit is contained in:
Andreas Süßenbach 2018-08-17 17:47:48 +02:00 committed by Markus Tavenrath
parent 58873a31ef
commit a9b5b68572
14 changed files with 46 additions and 37 deletions

View File

@ -30,6 +30,12 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
project(VulkanHppGenerator) project(VulkanHppGenerator)
if(MSVC)
add_compile_options(/W4)
else(MSVC)
add_compile_options(-Wall)
endif(MSVC)
file(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Vulkan-Docs/xml/vk.xml vk_spec) file(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Vulkan-Docs/xml/vk.xml vk_spec)
string(REPLACE "\\" "\\\\" vk_spec ${vk_spec}) string(REPLACE "\\" "\\\\" vk_spec ${vk_spec})
add_definitions(-DVK_SPEC="${vk_spec}") add_definitions(-DVK_SPEC="${vk_spec}")

View File

@ -494,7 +494,7 @@ const std::string inlineHeader = R"(
# elif defined(__GNUC__) # elif defined(__GNUC__)
# define VULKAN_HPP_INLINE __attribute__((always_inline)) __inline__ # define VULKAN_HPP_INLINE __attribute__((always_inline)) __inline__
# elif defined(_MSC_VER) # elif defined(_MSC_VER)
# define VULKAN_HPP_INLINE __forceinline # define VULKAN_HPP_INLINE inline
# else # else
# define VULKAN_HPP_INLINE inline # define VULKAN_HPP_INLINE inline
# endif # endif
@ -909,7 +909,7 @@ void writeVersionCheck(std::ostream & os, std::string const& version);
void skipFeatureRequire(tinyxml2::XMLElement const* element); void skipFeatureRequire(tinyxml2::XMLElement const* element);
void skipImplicitExternSyncParams(tinyxml2::XMLElement const* element); void skipImplicitExternSyncParams(tinyxml2::XMLElement const* element);
void skipTypeEnum(tinyxml2::XMLElement const* element, std::map<std::string, std::string> const& attributes); void skipTypeEnum(tinyxml2::XMLElement const* element, std::map<std::string, std::string> const& attributes);
void skipTypeInclude(tinyxml2::XMLElement const* element, std::map<std::string, std::string> const& attributes); void skipTypeInclude(tinyxml2::XMLElement const* element);
#endif #endif
bool beginsWith(std::string const& text, std::string const& prefix) bool beginsWith(std::string const& text, std::string const& prefix)
@ -1226,7 +1226,7 @@ std::string toCamelCase(std::string const& value)
} }
else else
{ {
result.push_back(tolower(value[i])); result.push_back(static_cast<char>(tolower(value[i])));
} }
} }
} }
@ -1243,7 +1243,7 @@ std::string toUpperCase(std::string const& name)
{ {
convertedName.push_back('_'); convertedName.push_back('_');
} }
convertedName.push_back(toupper(name[i])); convertedName.push_back(static_cast<char>(toupper(name[i])));
} }
return convertedName; return convertedName;
} }
@ -1342,7 +1342,7 @@ void skipTypeEnum(tinyxml2::XMLElement const* element, std::map<std::string, std
checkElements(getChildElements(element), {}); checkElements(getChildElements(element), {});
} }
void skipTypeInclude(tinyxml2::XMLElement const* element, std::map<std::string, std::string> const& attributes) void skipTypeInclude(tinyxml2::XMLElement const* element)
{ {
checkAttributes(getAttributes(element), element->GetLineNum(), { { "category",{ "include" } } }, { { "name",{} } }); checkAttributes(getAttributes(element), element->GetLineNum(), { { "category",{ "include" } } }, { { "name",{} } });
std::vector<tinyxml2::XMLElement const*> children = getChildElements(element); std::vector<tinyxml2::XMLElement const*> children = getChildElements(element);
@ -1475,7 +1475,7 @@ void VulkanHppGenerator::determineReducedName(CommandData & commandData)
size_t pos = commandData.fullName.find(searchName); size_t pos = commandData.fullName.find(searchName);
if ((pos == std::string::npos) && isupper(searchName[0])) if ((pos == std::string::npos) && isupper(searchName[0]))
{ {
searchName[0] = tolower(searchName[0]); searchName[0] = static_cast<char>(tolower(searchName[0]));
pos = commandData.fullName.find(searchName); pos = commandData.fullName.find(searchName);
} }
if (pos != std::string::npos) if (pos != std::string::npos)
@ -1489,7 +1489,7 @@ void VulkanHppGenerator::determineReducedName(CommandData & commandData)
} }
if ((pos == 0) && isupper(commandData.reducedName[0])) if ((pos == 0) && isupper(commandData.reducedName[0]))
{ {
commandData.reducedName[0] = tolower(commandData.reducedName[0]); commandData.reducedName[0] = static_cast<char>(tolower(commandData.reducedName[0]));
} }
} }
@ -1851,7 +1851,7 @@ void VulkanHppGenerator::readComment(tinyxml2::XMLElement const* element)
} }
// replace any '\n' with "\n// " // replace any '\n' with "\n// "
for (size_t pos = m_vulkanLicenseHeader.find('\n'); pos != std::string::npos; pos = m_vulkanLicenseHeader.find('\n', pos + 1)) for (pos = m_vulkanLicenseHeader.find('\n'); pos != std::string::npos; pos = m_vulkanLicenseHeader.find('\n', pos + 1))
{ {
m_vulkanLicenseHeader.replace(pos, 1, "\n// "); m_vulkanLicenseHeader.replace(pos, 1, "\n// ");
} }
@ -2445,7 +2445,7 @@ void VulkanHppGenerator::readType(tinyxml2::XMLElement const* element)
} }
else if (categoryIt->second == "include") else if (categoryIt->second == "include")
{ {
skipTypeInclude(element, attributes); skipTypeInclude(element);
} }
else else
#else #else
@ -2851,6 +2851,7 @@ void VulkanHppGenerator::registerDeleter(CommandData const& commandData)
break; break;
default: default:
assert(false); assert(false);
valueIndex = 0;
} }
assert(m_deleterTypes[key].find(commandData.params[valueIndex].pureType) == m_deleterTypes[key].end()); assert(m_deleterTypes[key].find(commandData.params[valueIndex].pureType) == m_deleterTypes[key].end());
m_deleterTypes[key].insert(commandData.params[valueIndex].pureType); m_deleterTypes[key].insert(commandData.params[valueIndex].pureType);
@ -3228,7 +3229,7 @@ void VulkanHppGenerator::writeFunction(std::ostream & os, std::string const& ind
writeFunctionHeaderTemplate(os, indentation, commandData, enhanced, unique, !definition, isStructureChain); writeFunctionHeaderTemplate(os, indentation, commandData, enhanced, unique, !definition, isStructureChain);
os << indentation << (definition ? "VULKAN_HPP_INLINE " : ""); os << indentation << (definition ? "VULKAN_HPP_INLINE " : "");
writeFunctionHeaderReturnType(os, indentation, commandData, enhanced, singular, unique, isStructureChain); writeFunctionHeaderReturnType(os, commandData, enhanced, singular, unique, isStructureChain);
if (definition && !commandData.className.empty()) if (definition && !commandData.className.empty())
{ {
os << commandData.className << "::"; os << commandData.className << "::";
@ -3719,7 +3720,7 @@ void VulkanHppGenerator::writeFunctionHeaderArgumentsEnhanced(std::ostream & os,
if (commandData.skippedParams.size() + (commandData.className.empty() ? 0 : 1) < commandData.params.size()) if (commandData.skippedParams.size() + (commandData.className.empty() ? 0 : 1) < commandData.params.size())
{ {
// determine the last argument, where we might provide some default for // determine the last argument, where we might provide some default for
size_t lastArgument = ~0; size_t lastArgument = size_t(~0);
for (size_t i = commandData.params.size() - 1; i < commandData.params.size(); i--) for (size_t i = commandData.params.size() - 1; i < commandData.params.size(); i--)
{ {
if (commandData.skippedParams.find(i) == commandData.skippedParams.end()) if (commandData.skippedParams.find(i) == commandData.skippedParams.end())
@ -3914,7 +3915,7 @@ void VulkanHppGenerator::writeFunctionHeaderArgumentsStandard(std::ostream & os,
} }
} }
void VulkanHppGenerator::writeFunctionHeaderReturnType(std::ostream & os, std::string const& indentation, CommandData const& commandData, bool enhanced, bool singular, bool unique, bool isStructureChain) void VulkanHppGenerator::writeFunctionHeaderReturnType(std::ostream & os, CommandData const& commandData, bool enhanced, bool singular, bool unique, bool isStructureChain)
{ {
std::string templateString; std::string templateString;
std::string returnType; std::string returnType;
@ -4076,8 +4077,8 @@ void VulkanHppGenerator::writeStructConstructor(std::ostream & os, std::string c
assert(subStruct != m_structs.end()); assert(subStruct != m_structs.end());
std::string subStructArgumentName = startLowerCase(strip(subStruct->first, "vk")); std::string subStructArgumentName = startLowerCase(strip(subStruct->first, "vk"));
std::string ctorOpening = " explicit " + name + "( "; ctorOpening = " explicit " + name + "( ";
size_t indentSize = ctorOpening.size(); indentSize = ctorOpening.size();
os << ctorOpening << subStruct->first << " const& " << subStructArgumentName; os << ctorOpening << subStruct->first << " const& " << subStructArgumentName;
@ -4087,7 +4088,7 @@ void VulkanHppGenerator::writeStructConstructor(std::ostream & os, std::string c
} }
os << " )" << std::endl; os << " )" << std::endl;
bool firstArgument = true; firstArgument = true;
std::string templateString = " ${sep} ${member}( ${value} )\n"; std::string templateString = " ${sep} ${member}( ${value} )\n";
for (size_t i = 0; i < subStruct->second.members.size(); i++) for (size_t i = 0; i < subStruct->second.members.size(); i++)
{ {
@ -4781,7 +4782,6 @@ void VulkanHppGenerator::writeUniqueTypes(std::ostream &os, std::pair<std::strin
} }
os << std::endl; os << std::endl;
bool first = true;
for (auto const& dt : deleterTypes.second) for (auto const& dt : deleterTypes.second)
{ {
auto ddit = m_deleters.find(dt); auto ddit = m_deleters.find(dt);
@ -4958,18 +4958,18 @@ void VulkanHppGenerator::skipVendorIDs(tinyxml2::XMLElement const* element)
} }
#endif #endif
void VulkanHppGenerator::EnumData::addEnumValue(std::string const &name, std::string const& tag, std::map<std::string, std::string> & nameMap) void VulkanHppGenerator::EnumData::addEnumValue(std::string const &enumName, std::string const& tag, std::map<std::string, std::string> & nameMap)
{ {
EnumValueData evd; EnumValueData evd;
evd.name = createEnumValueName(name, prefix, postfix, bitmask, tag); evd.name = createEnumValueName(enumName, prefix, postfix, bitmask, tag);
evd.value = name; evd.value = enumName;
auto it = std::find_if(values.begin(), values.end(), [&evd](EnumValueData const& _evd) { return _evd.name == evd.name; }); auto it = std::find_if(values.begin(), values.end(), [&evd](EnumValueData const& _evd) { return _evd.name == evd.name; });
if (it == values.end()) if (it == values.end())
{ {
values.push_back(evd); values.push_back(evd);
assert(nameMap.find(name) == nameMap.end()); assert(nameMap.find(enumName) == nameMap.end());
nameMap[name] = this->name + "::" + evd.name; nameMap[enumName] = this->name + "::" + evd.name;
} }
else else
{ {

View File

@ -100,8 +100,8 @@ class VulkanHppGenerator
struct CommandData struct CommandData
{ {
CommandData() CommandData()
: returnParam(~0) : returnParam(size_t(~0))
, templateParam(~0) , templateParam(size_t(~0))
, twoStep(false) , twoStep(false)
, isAlias(false) , isAlias(false)
{} {}
@ -268,7 +268,7 @@ class VulkanHppGenerator
void writeFunctionHeaderArguments(std::ostream & os, CommandData const& commandData, bool enhanced, bool singular, bool withDefaults); void writeFunctionHeaderArguments(std::ostream & os, CommandData const& commandData, bool enhanced, bool singular, bool withDefaults);
void writeFunctionHeaderArgumentsEnhanced(std::ostream & os, CommandData const& commandData, bool singular, bool withDefaults); void writeFunctionHeaderArgumentsEnhanced(std::ostream & os, CommandData const& commandData, bool singular, bool withDefaults);
void writeFunctionHeaderArgumentsStandard(std::ostream & os, CommandData const& commandData, bool withDefaults); void writeFunctionHeaderArgumentsStandard(std::ostream & os, CommandData const& commandData, bool withDefaults);
void writeFunctionHeaderReturnType(std::ostream & os, std::string const& indentation, CommandData const& commandData, bool enhanced, bool singular, bool unique, bool isStructureChain); void writeFunctionHeaderReturnType(std::ostream & os, CommandData const& commandData, bool enhanced, bool singular, bool unique, bool isStructureChain);
void writeFunctionHeaderTemplate(std::ostream & os, std::string const& indentation, CommandData const& commandData, bool enhanced, bool unique, bool withDefault, bool isStructureChain); void writeFunctionHeaderTemplate(std::ostream & os, std::string const& indentation, CommandData const& commandData, bool enhanced, bool unique, bool withDefault, bool isStructureChain);
void writeIndentation(std::ostream & os, size_t indentLength); void writeIndentation(std::ostream & os, size_t indentLength);
void writeStructConstructor(std::ostream & os, std::string const& name, StructData const& structData, std::map<std::string, std::string> const& defaultValues); void writeStructConstructor(std::ostream & os, std::string const& name, StructData const& structData, std::map<std::string, std::string> const& defaultValues);

View File

@ -21,7 +21,7 @@
static char const* AppName = "01_InitInstance"; static char const* AppName = "01_InitInstance";
static char const* EngineName = "Vulkan.hpp"; static char const* EngineName = "Vulkan.hpp";
int main(int argc, char *argv[]) int main(int /*argc*/, char * /*argv[]*/)
{ {
/* VULKAN_HPP_KEY_START */ /* VULKAN_HPP_KEY_START */

View File

@ -21,7 +21,7 @@
static char const* AppName = "02_EnumerateDevices"; static char const* AppName = "02_EnumerateDevices";
static char const* EngineName = "Vulkan.hpp"; static char const* EngineName = "Vulkan.hpp";
int main(int argc, char *argv[]) int main(int /*argc*/, char * /*argv[]*/)
{ {
try try
{ {

View File

@ -21,7 +21,7 @@
static char const* AppName = "03_InitDevice"; static char const* AppName = "03_InitDevice";
static char const* EngineName = "Vulkan.hpp"; static char const* EngineName = "Vulkan.hpp";
int main(int argc, char *argv[]) int main(int /*argc*/, char * /*argv[]*/)
{ {
try try
{ {

View File

@ -21,7 +21,7 @@
static char const* AppName = "04_InitCommandBuffer"; static char const* AppName = "04_InitCommandBuffer";
static char const* EngineName = "Vulkan.hpp"; static char const* EngineName = "Vulkan.hpp";
int main(int argc, char *argv[]) int main(int /*argc*/, char * /*argv[]*/)
{ {
try try
{ {

View File

@ -125,7 +125,7 @@ HWND initializeWindow(std::string const& className, std::string const& windowNam
#endif #endif
int main(int argc, char *argv[]) int main(int /*argc*/, char * /*argv[]*/)
{ {
try try
{ {

View File

@ -125,7 +125,7 @@ HWND initializeWindow(std::string const& className, std::string const& windowNam
#endif #endif
int main(int argc, char *argv[]) int main(int /*argc*/, char * /*argv[]*/)
{ {
try try
{ {
@ -217,7 +217,7 @@ int main(int argc, char *argv[])
vk::PhysicalDeviceMemoryProperties memoryProperties = physicalDevices[0].getMemoryProperties(); vk::PhysicalDeviceMemoryProperties memoryProperties = physicalDevices[0].getMemoryProperties();
vk::MemoryRequirements memoryRequirements = device->getImageMemoryRequirements(depthImage.get()); vk::MemoryRequirements memoryRequirements = device->getImageMemoryRequirements(depthImage.get());
uint32_t typeBits = memoryRequirements.memoryTypeBits; uint32_t typeBits = memoryRequirements.memoryTypeBits;
uint32_t typeIndex = ~0; uint32_t typeIndex = uint32_t(~0);
for (uint32_t i = 0; i < memoryProperties.memoryTypeCount; i++) for (uint32_t i = 0; i < memoryProperties.memoryTypeCount; i++)
{ {
if ((typeBits & 1) && ((memoryProperties.memoryTypes[i].propertyFlags & vk::MemoryPropertyFlagBits::eDeviceLocal) == vk::MemoryPropertyFlagBits::eDeviceLocal)) if ((typeBits & 1) && ((memoryProperties.memoryTypes[i].propertyFlags & vk::MemoryPropertyFlagBits::eDeviceLocal) == vk::MemoryPropertyFlagBits::eDeviceLocal))

View File

@ -19,12 +19,13 @@
#include "vulkan/vulkan.hpp" #include "vulkan/vulkan.hpp"
#define GLM_FORCE_RADIANS #define GLM_FORCE_RADIANS
#pragma warning(disable:4201) // disable warning C4201: nonstandard extension used: nameless struct/union; needed to get glm/detail/type_vec?.hpp without warnings
#include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/matrix_transform.hpp>
static char const* AppName = "07_InitUniformBuffer"; static char const* AppName = "07_InitUniformBuffer";
static char const* EngineName = "Vulkan.hpp"; static char const* EngineName = "Vulkan.hpp";
int main(int argc, char *argv[]) int main(int /*argc*/, char * /*argv[]*/)
{ {
try try
{ {
@ -62,7 +63,7 @@ int main(int argc, char *argv[])
vk::PhysicalDeviceMemoryProperties memoryProperties = physicalDevices[0].getMemoryProperties(); vk::PhysicalDeviceMemoryProperties memoryProperties = physicalDevices[0].getMemoryProperties();
vk::MemoryPropertyFlags requirementsMask = vk::MemoryPropertyFlagBits::eHostVisible | vk::MemoryPropertyFlagBits::eHostCoherent; vk::MemoryPropertyFlags requirementsMask = vk::MemoryPropertyFlagBits::eHostVisible | vk::MemoryPropertyFlagBits::eHostCoherent;
uint32_t typeIndex = ~0; uint32_t typeIndex = uint32_t(~0);
for (uint32_t i = 0; i < memoryProperties.memoryTypeCount; i++) for (uint32_t i = 0; i < memoryProperties.memoryTypeCount; i++)
{ {
if ((typeBits & 1) && ((memoryProperties.memoryTypes[i].propertyFlags & requirementsMask) == requirementsMask)) if ((typeBits & 1) && ((memoryProperties.memoryTypes[i].propertyFlags & requirementsMask) == requirementsMask))

View File

@ -21,7 +21,7 @@
static char const* AppName = "08_InitPipelineLayout"; static char const* AppName = "08_InitPipelineLayout";
static char const* EngineName = "Vulkan.hpp"; static char const* EngineName = "Vulkan.hpp";
int main(int argc, char *argv[]) int main(int /*argc*/, char * /*argv[]*/)
{ {
try try
{ {

View File

@ -19,12 +19,13 @@
#include "vulkan/vulkan.hpp" #include "vulkan/vulkan.hpp"
#define GLM_FORCE_RADIANS #define GLM_FORCE_RADIANS
#pragma warning(disable:4201) // disable warning C4201: nonstandard extension used: nameless struct/union; needed to get glm/detail/type_vec?.hpp without warnings
#include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/matrix_transform.hpp>
static char const* AppName = "09_InitDescriptorSet"; static char const* AppName = "09_InitDescriptorSet";
static char const* EngineName = "Vulkan.hpp"; static char const* EngineName = "Vulkan.hpp";
int main(int argc, char *argv[]) int main(int /*argc*/, char * /*argv[]*/)
{ {
try try
{ {

View File

@ -19,6 +19,7 @@
#include "vulkan/vulkan.hpp" #include "vulkan/vulkan.hpp"
#define GLM_FORCE_RADIANS #define GLM_FORCE_RADIANS
#pragma warning(disable:4201) // disable warning C4201: nonstandard extension used: nameless struct/union; needed to get glm/detail/type_vec?.hpp without warnings
#include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/matrix_transform.hpp>
static char const* AppName = "10_InitRenderPass"; static char const* AppName = "10_InitRenderPass";
@ -105,7 +106,7 @@ HWND initializeWindow(std::string const& className, std::string const& windowNam
#pragma error "unhandled platform" #pragma error "unhandled platform"
#endif #endif
int main(int argc, char *argv[]) int main(int /*argc*/, char * /*argv[]*/)
{ {
try try
{ {

View File

@ -107,7 +107,7 @@ static_assert( VK_HEADER_VERSION == 83 , "Wrong VK_HEADER_VERSION!" );
# elif defined(__GNUC__) # elif defined(__GNUC__)
# define VULKAN_HPP_INLINE __attribute__((always_inline)) __inline__ # define VULKAN_HPP_INLINE __attribute__((always_inline)) __inline__
# elif defined(_MSC_VER) # elif defined(_MSC_VER)
# define VULKAN_HPP_INLINE __forceinline # define VULKAN_HPP_INLINE inline
# else # else
# define VULKAN_HPP_INLINE inline # define VULKAN_HPP_INLINE inline
# endif # endif