This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Use vfs::FileSystem when getting config
ClosedPublic

Authored by njames93 on Nov 6 2020, 4:44 PM.

Details

Summary

The config providers that look for configuration files currently take a pointer to a FileSystem in the constructor.
For some reason this isn't actually used when trying to read those configuration files, Essentially it just follows the behaviour of the real filesystem.
Using clang-tidy standalone this doesn't cause any issue.
But if its used as a library and the user wishes to use say an InMemoryFileSystem it will try to read the files from the disc instead.

Diff Detail

Event Timeline

njames93 created this revision.Nov 6 2020, 4:44 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 6 2020, 4:44 PM
njames93 requested review of this revision.Nov 6 2020, 4:44 PM
njames93 updated this revision to Diff 303629.Nov 7 2020, 3:10 AM

Added unittest for loading configs from an InMemoryFileSystem.

njames93 updated this revision to Diff 303630.Nov 7 2020, 3:13 AM

Small tweak to the tests.

aaron.ballman accepted this revision.Nov 7 2020, 5:38 AM

LGTM aside from a nit with the test.

clang-tools-extra/unittests/clang-tidy/OptionsProviderTest.cpp
68

Can you add the newline to the end of the file?

This revision is now accepted and ready to land.Nov 7 2020, 5:38 AM
This revision was automatically updated to reflect the committed changes.
thakis added a subscriber: thakis.Nov 8 2020, 6:28 AM
thakis added inline comments.
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
366

This breaks bootstrap builds against the gcc 5.3 libstdc++: https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8864218000842553296/+/steps/package_clang/0/stdout?format=raw

/b/s/w/ir/cache/builder/src/third_party/llvm/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp:366:12: error: no matching constructor for initialization of 'clang::tidy::ClangTidyOptionsProvider::OptionsSource' (aka 'pair<clang::tidy::ClangTidyOptions, basic_string<char>>')
    return OptionsSource(*ParsedOptions, ConfigFile.str());
           ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Can we undo the change on this line?

PTAL!