From 84cb7cd6b1bc55b065b547f62682ae70d9c65f70 Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Mon, 23 Mar 2020 09:37:50 -0700 Subject: [PATCH] Check for duplicate Results when doing codegen --- build/CodeGen/ResultCodegen.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/build/CodeGen/ResultCodegen.cs b/build/CodeGen/ResultCodegen.cs index 6ca773b2..6a4ffc51 100644 --- a/build/CodeGen/ResultCodegen.cs +++ b/build/CodeGen/ResultCodegen.cs @@ -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(); + + 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)