Check for duplicate Results when doing codegen

This commit is contained in:
Alex Barney 2020-03-23 09:37:50 -07:00
parent 1f4c904b04
commit 84cb7cd6b1

View file

@ -25,6 +25,7 @@ namespace LibHacBuild.CodeGen
SetEmptyResultValues(modules);
ValidateResults(modules);
CheckForDuplicates(modules);
ValidateHierarchy(modules);
CheckIfAggressiveInliningNeeded(modules);
@ -119,6 +120,24 @@ namespace LibHacBuild.CodeGen
}
}
private static void CheckForDuplicates(ModuleInfo[] modules)
{
foreach (ModuleInfo module in modules)
{
var set = new HashSet<long>();
foreach (ResultInfo result in module.Results)
{
long description = (long)result.DescriptionStart << 32 | (uint)result.DescriptionEnd;
if (!set.Add(description))
{
throw new InvalidDataException($"Duplicate result {result.Module}-{result.DescriptionStart}-{result.DescriptionEnd}.");
}
}
}
}
private static void ValidateHierarchy(ModuleInfo[] modules)
{
foreach (ModuleInfo module in modules)