[PATCH] D152453: llvm-cov produces inconsistent result when file appears multiple times in gcno
Oleksii Odynochenko via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 8 08:56:22 PDT 2023
tenta4 created this revision.
tenta4 added reviewers: dnovillo, bogner.
Herald added a subscriber: hiraditya.
Herald added a project: All.
tenta4 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
My gcno/gcda files contain some of sources multiple times with a different FS-format.
For example
llvm-cov gcov test_unit_MXR_Settings_SettingsEngine_CSettingsHandler.dir/__/__/__/src/CSettingsHandler.cpp.gcno -b -x -i | grep CSettingsHandler.cpp
File '../../../src/Settings/SettingsEngine/test/unit_test/CSettingsHandler/../../../src/CSettingsHandler.cpp'
Lines executed:75.00% of 8
Branches executed:100.00% of 12
Taken at least once:41.67% of 12
No calls
--
File '../../../src/Settings/SettingsEngine/src/CSettingsHandler.cpp'
Lines executed:98.37% of 184
Branches executed:97.34% of 601
Taken at least once:56.91% of 601
No calls
llvm-cov randomly takes one of record and adds it to cov-file.
That is why my coverage results usually wrong and furthermore they differ every now and than
https://reviews.llvm.org/D152453
Files:
llvm/lib/ProfileData/GCOV.cpp
Index: llvm/lib/ProfileData/GCOV.cpp
===================================================================
--- llvm/lib/ProfileData/GCOV.cpp
+++ llvm/lib/ProfileData/GCOV.cpp
@@ -140,6 +140,13 @@
if (version >= GCOV::V900)
fn->endColumn = buf.getWord();
}
+
+ // unify filename, as the same path can have different form
+ SmallString<256> P;
+ P.assign(filename);
+ sys::path::remove_dots(P, true);
+ filename = P.str();
+
auto r = filenameToIdx.try_emplace(filename, filenameToIdx.size());
if (r.second)
filenames.emplace_back(filename);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152453.529608.patch
Type: text/x-patch
Size: 612 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230608/33e70b4b/attachment.bin>
More information about the llvm-commits
mailing list