From 136608dfec0552d5a49f4f414e6cafa920b53828 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 24 Feb 2021 12:21:57 -0500 Subject: cmCreateTestSourceList: avoid generating duplicate declarations This avoids warnings with `clang-tidy`'s `-readability-redundant-declaration` lint in generated source code. --- Source/cmCreateTestSourceList.cxx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Source/cmCreateTestSourceList.cxx b/Source/cmCreateTestSourceList.cxx index 3001ae0..a2fac73 100644 --- a/Source/cmCreateTestSourceList.cxx +++ b/Source/cmCreateTestSourceList.cxx @@ -90,10 +90,15 @@ bool cmCreateTestSourceList(std::vector const& args, std::replace(func_name.begin(), func_name.end(), ' ', '_'); std::replace(func_name.begin(), func_name.end(), '/', '_'); std::replace(func_name.begin(), func_name.end(), ':', '_'); + bool already_declared = + std::find(tests_func_name.begin(), tests_func_name.end(), func_name) != + tests_func_name.end(); tests_func_name.push_back(func_name); - forwardDeclareCode += "int "; - forwardDeclareCode += func_name; - forwardDeclareCode += "(int, char*[]);\n"; + if (!already_declared) { + forwardDeclareCode += "int "; + forwardDeclareCode += func_name; + forwardDeclareCode += "(int, char*[]);\n"; + } } std::string functionMapCode; -- cgit v0.12