From 09d1b8d976f1d89435700a8f1e70bf8bee1cda69 Mon Sep 17 00:00:00 2001 From: Calin Iorgulescu Date: Thu, 9 Nov 2023 00:04:08 +0100 Subject: [PATCH] Fix duplicate C++ ctor/dtor entries with --demangle. * Fixes an issue where duplicate ctor/dtor functions are demangled to the same name, creating duplicate function entries. --- lcov_cobertura/lcov_cobertura.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lcov_cobertura/lcov_cobertura.py b/lcov_cobertura/lcov_cobertura.py index 379e405..fc27c34 100755 --- a/lcov_cobertura/lcov_cobertura.py +++ b/lcov_cobertura/lcov_cobertura.py @@ -205,13 +205,14 @@ def parse(self, **kwargs): elif input_type == 'FN': # FN:5,(anonymous_1) function_line, function_name = line_parts[-1].strip().split(',', 1) - file_methods[function_name] = [function_line, '0'] + file_methods[self.format(function_name)] = [function_line, '0'] elif input_type == 'FNDA': # FNDA:0,(anonymous_1) (function_hits, function_name) = line_parts[-1].strip().split(',', 1) - if function_name not in file_methods: - file_methods[function_name] = ['0', '0'] - file_methods[function_name][-1] = function_hits + demangled_fn_name = self.format(function_name) + if demangled_fn_name not in file_methods: + file_methods[demangled_fn_name] = ['0', '0'] + file_methods[demangled_fn_name][-1] += function_hits # Exclude packages excluded = [x for x in coverage_data['packages'] for e in self.excludes @@ -291,7 +292,7 @@ def generate_cobertura_xml(self, coverage_data, **kwargs): methods_el = self._el(document, 'methods', {}) for method_name, (line, hits) in list(class_data['methods'].items()): method_el = self._el(document, 'method', { - 'name': self.format(method_name), + 'name': method_name, 'signature': '', 'line-rate': '1.0' if int(hits) > 0 else '0.0', 'branch-rate': '1.0' if int(hits) > 0 else '0.0',