From dc1a7ce93e9825b0479095e4ad0ee6b0a824269e Mon Sep 17 00:00:00 2001 From: asuessenbach Date: Thu, 30 Apr 2020 14:28:48 +0200 Subject: [PATCH] Add filter for identical alias enum values --- VulkanHppGenerator.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index eb3028a..b42b118 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -4122,10 +4122,11 @@ void VulkanHppGenerator::EnumData::addEnumAlias( int line, std::string const & vkName ) { // check that the aliasName is either a known enum value or at least a known alias - check( (std::find_if( values.begin(), - values.end(), - [&aliasName]( EnumValueData const & evd ) { return evd.vulkanValue == aliasName; } ) != - values.end()) || (aliases.find(aliasName) != aliases.end()), + check( ( std::find_if( values.begin(), + values.end(), + [&aliasName]( EnumValueData const & evd ) { return evd.vulkanValue == aliasName; } ) != + values.end() ) || + ( aliases.find( aliasName ) != aliases.end() ), line, "unknown enum alias <" + aliasName + ">" ); @@ -4134,7 +4135,16 @@ void VulkanHppGenerator::EnumData::addEnumAlias( int line, line, "enum alias <" + name + "> already listed for a different enum value" ); - aliases.insert( std::make_pair( name, std::make_pair( aliasName, vkName ) ) ); + // only list aliases that map to different vkNames + aliasIt = std::find_if( aliases.begin(), + aliases.end(), + [&vkName]( std::pair> const & aliasEntry ) { + return vkName == aliasEntry.second.second; + } ); + if ( aliasIt == aliases.end() ) + { + aliases.insert( std::make_pair( name, std::make_pair( aliasName, vkName ) ) ); + } } void VulkanHppGenerator::EnumData::addEnumValue( int line,