This is an archive of the discontinued LLVM Phabricator instance.

Add inclusion filename filters to llvm-cov
Needs ReviewPublic

Authored by tinloaf on May 3 2021, 3:29 AM.

Details

Summary

Currently, llvm-cov only supports exclusion of files (based on regular expressions). This adds the possibility to also specify a "whitelist" of files via regex. All files not matching one of the supplied regular expressions will be excluded from coverage reporting.

Diff Detail

Event Timeline

tinloaf requested review of this revision.May 3 2021, 3:29 AM
tinloaf created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptMay 3 2021, 3:29 AM

I tested this locally and it seems to work; however, I would feel better if I had some tests for this (and the ignore-regex filters, too).

As far as I can tell, there would be two steps to adding tests to this:

  • Add a test script at (e.g.) llvm/test/tools/llvm-cov/filename_filters.test
  • Add some input data for this test script in the form of a "proftext" file at (e.g.) llvm/test/tools/llvm-cov/Inputs/filename_filters.proftext

However, I know neither the syntax of the .test scripts nor the syntax of the proftext format. If I generate some "proftext" file by running llvm-profdata -text …, I can see the file names in the resulting output file, but no paths. Searching for "proftext llvm" or "proftext format" does give me lots of other tests using this format, but no docs on the format itsef. If somebody could point me in the right direction, I'll gladly add some tests.

tinloaf updated this revision to Diff 342374.May 3 2021, 6:39 AM
  • Fix logic for empty test sets
tinloaf updated this revision to Diff 342404.May 3 2021, 8:34 AM
  • Reformat
tinloaf updated this revision to Diff 342682.May 4 2021, 2:22 AM
  • Suppress clang-tidy diagnostics for push_back
vsk added a comment.May 7 2021, 10:19 AM

Please take a look at this patch by Michael Daniels that implements a similar feature:
bfed824b57d14e2ba98ddbaf1a1410cf04a3e279

It includes a test and documentation updates that could be folded into this patch. (The patch was reverted in 8d24d72f7f8b7a111f96510fc6d62b05bfb7dbec due to buildbot failures I didn't have the bandwidth to investigate.)