This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Support SystemHeaders in .clang-tidy
ClosedPublic

Authored by carlosgalvezp on May 4 2023, 1:28 PM.

Details

Summary

A previous patch update the clang-tidy documentation
incorrectly claiming that SystemHeaders can be provided
in the .clang-tidy configuration file.

This patch adds support for it, together with tests.

Fixes https://github.com/llvm/llvm-project/issues/62547

Diff Detail

Event Timeline

carlosgalvezp created this revision.May 4 2023, 1:28 PM
Herald added a project: Restricted Project. · View Herald Transcript
carlosgalvezp requested review of this revision.May 4 2023, 1:28 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 4 2023, 1:28 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
carlosgalvezp edited the summary of this revision. (Show Details)

Update commit message with Github issue.

PiotrZSL accepted this revision.May 5 2023, 1:38 AM

From functionally point of view, LGTM.

clang-tools-extra/test/clang-tidy/infrastructure/system-headers.cpp
12

I missing 2 types of tests here:

  • config value override, -config='SystemHeaders: true' -system-headers=false
  • config file override, when one file has false, other true, but InheritConfig is used.

Both should work, but would be good to test them.

This revision is now accepted and ready to land.May 5 2023, 1:38 AM
carlosgalvezp added inline comments.May 5 2023, 3:59 AM
clang-tools-extra/test/clang-tidy/infrastructure/system-headers.cpp
12

Thanks for the input! Essentially I followed the same testing pattern as UseColor, which is also a global boolean option.

Adding the first suggestion should be trivial in the current test case, but I have some doubts about the proposed second test. When I look at the tests/clang-tidy/infrastructure/config-files.cpp it only takes into account enabled checks, no other global options are tested such that one overrides the other. Therefore I wonder if there is a rationale for not having such level of testing, perhaps easier maintenance, given that it's already tested by the unit tests? In that case I would propose to not add such a test here, for consistency. WDYT?

PiotrZSL added inline comments.May 5 2023, 4:12 AM
clang-tools-extra/test/clang-tidy/infrastructure/system-headers.cpp
12

I'm fine with that. I'm mainly concern about the first one, simply because I'm not sure about outcome, what will have higher priority, command line argument or config option.

  • Add test where both command line and config settings are used.
  • Document that the command-line option overrides the config option, for consistency with other command-line options.
carlosgalvezp marked an inline comment as done.May 6 2023, 11:41 PM
carlosgalvezp marked an inline comment as done.

Revert unwanted change to UseColor

This revision was automatically updated to reflect the committed changes.