eriwen / lcov-to-cobertura-xml

Converts lcov output to Cobertura-compatible XML for CI
https://eriwen.github.io/lcov-to-cobertura-xml/
Apache License 2.0
187 stars 73 forks source link

Fix duplicate C++ ctor/dtor entries with --demangle. #52

Open calin-iorgulescu opened 9 months ago

calin-iorgulescu commented 9 months ago

Under certain circumstances, gcc seems to emit multiple symbols for ctors and dtors. This seems to be in adherence with the specification of the Itanium C++ ABI. A pretty good description of the issue can be found here .

However, c++filt generates the same demangled names for these symbols. Apparently, this was not always the case. Since demangling is currently done after reading the lcov files, this results in duplicate entries in the output XML file.

According to the Cobertura DTD, each class should only have a single method entry. This can lead to issues with certain parsers. For example, the Jenkins Coverage plugin will not accept XML files with duplicate method entries for the same class.

This PR resolves the issue by applying the demangling operation when the function hit data is stored, and summing the hit counts as needed.

dieram3 commented 2 days ago

Thanks for digging that out! I was wondering why the new coverage Jenkins plugin has the java.lang. IllegalArgumentException: There is already the same child [METHOD] foo::~foo() error.