From cb873488988ee4610c32db6a75565717b04ffeba Mon Sep 17 00:00:00 2001 From: asuessenbach Date: Tue, 22 Jun 2021 10:15:24 +0200 Subject: [PATCH] Move check on structureAlias from reading to final correctness check. --- VulkanHppGenerator.cpp | 21 +++++++++++++++------ VulkanHppGenerator.hpp | 10 +++++++++- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 15ee7f2..4a45ae2 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -10555,6 +10555,18 @@ void VulkanHppGenerator::checkCorrectness() } } + // structure alias checks + for ( auto structureAlias : m_structureAliases ) + { + auto structureIt = m_structures.find( structureAlias.second.alias ); + check( structureIt != m_structures.end(), + structureAlias.second.xmlLine, + "missing alias <" + structureAlias.second.alias + ">." ); + check( structureIt->second.aliases.insert( structureAlias.first ).second, + structureAlias.second.xmlLine, + "struct <" + structureAlias.second.alias + "> already uses alias <" + structureAlias.first + ">" ); + } + // structure checks std::set sTypeValues; for ( auto const & structure : m_structures ) @@ -13914,7 +13926,8 @@ void VulkanHppGenerator::readSPIRVCapabilityEnableStruct( int } else if ( attribute.first == "struct" ) { - check( m_structures.find( attribute.second ) != m_structures.end(), + check( ( m_structures.find( attribute.second ) != m_structures.end() ) || + ( m_structureAliases.find( attribute.second ) != m_structureAliases.end() ), xmlLine, "unknown structure <" + attribute.second + "> specified for SPIR-V capability" ); check( attributes.find( "feature" ) != attributes.end(), @@ -14179,11 +14192,7 @@ void VulkanHppGenerator::readStructAlias( tinyxml2::XMLElement const * } } - auto structIt = m_structures.find( alias ); - check( structIt != m_structures.end(), line, "missing alias <" + alias + ">." ); - check( - structIt->second.aliases.insert( name ).second, line, "struct <" + alias + "> already uses alias <" + name + ">" ); - check( m_structureAliases.insert( std::make_pair( name, alias ) ).second, + check( m_structureAliases.insert( std::make_pair( name, StructureAliasData( alias, line ) ) ).second, line, "structure alias <" + name + "> already used" ); check( m_types.insert( std::make_pair( name, TypeCategory::Struct ) ).second, diff --git a/VulkanHppGenerator.hpp b/VulkanHppGenerator.hpp index 39d1975..6dbdcec 100644 --- a/VulkanHppGenerator.hpp +++ b/VulkanHppGenerator.hpp @@ -254,6 +254,14 @@ private: std::string protect; }; + struct StructureAliasData + { + StructureAliasData( std::string const & alias_, int line ) : alias( alias_ ), xmlLine( line ) {} + + std::string alias; + int xmlLine; + }; + struct StructureData { StructureData( std::vector const & extends, int line ) : structExtends( extends ), xmlLine( line ) {} @@ -1181,7 +1189,7 @@ private: std::set m_listedTypes; std::set m_listingTypes; std::map m_platforms; - std::map m_structureAliases; + std::map m_structureAliases; std::map m_structures; std::set m_tags; std::map m_types;