summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
diff options
context:
space:
mode:
authorHaojian Wu <hokein@google.com>2018-04-18 08:54:28 +0000
committerHaojian Wu <hokein@google.com>2018-04-18 08:54:28 +0000
commit10e50c87976cf999e1acc373da4b8b9a2ee5ac89 (patch)
tree45af05476c898db8366ebc335b94a8888d7defb0 /clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
parentdeff7536278d355977171726124f83aa4bb95419 (diff)
downloadbcm5719-llvm-10e50c87976cf999e1acc373da4b8b9a2ee5ac89.tar.gz
bcm5719-llvm-10e50c87976cf999e1acc373da4b8b9a2ee5ac89.zip
[clang-tidy] Fix clang-tidy doesn't read .clangtidy configuration file.
Summary: Fix https://bugs.llvm.org/show_bug.cgi?id=34900. Reviewers: alexfh Reviewed By: alexfh Subscribers: JonasToth, klimek, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D45697 llvm-svn: 330245
Diffstat (limited to 'clang-tools-extra/clang-tidy/ClangTidyOptions.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/ClangTidyOptions.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
index 7cbe6ac3621..63b2b5eb650 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -204,9 +204,12 @@ ConfigOptionsProvider::getRawOptions(llvm::StringRef FileName) {
FileOptionsProvider::FileOptionsProvider(
const ClangTidyGlobalOptions &GlobalOptions,
const ClangTidyOptions &DefaultOptions,
- const ClangTidyOptions &OverrideOptions)
+ const ClangTidyOptions &OverrideOptions,
+ llvm::IntrusiveRefCntPtr<vfs::FileSystem> VFS)
: DefaultOptionsProvider(GlobalOptions, DefaultOptions),
- OverrideOptions(OverrideOptions) {
+ OverrideOptions(OverrideOptions), FS(std::move(VFS)) {
+ if (!FS)
+ FS = vfs::getRealFileSystem();
ConfigHandlers.emplace_back(".clang-tidy", parseConfiguration);
}
@@ -224,14 +227,19 @@ FileOptionsProvider::FileOptionsProvider(
std::vector<OptionsSource>
FileOptionsProvider::getRawOptions(StringRef FileName) {
DEBUG(llvm::dbgs() << "Getting options for file " << FileName << "...\n");
+ assert(FS && "FS must be set.");
+
+ llvm::SmallString<128> AbsoluteFilePath(FileName);
+ if (std::error_code ec = FS->makeAbsolute(AbsoluteFilePath))
+ return {};
std::vector<OptionsSource> RawOptions =
- DefaultOptionsProvider::getRawOptions(FileName);
+ DefaultOptionsProvider::getRawOptions(AbsoluteFilePath.str());
OptionsSource CommandLineOptions(OverrideOptions,
OptionsSourceTypeCheckCommandLineOption);
// Look for a suitable configuration file in all parent directories of the
// file. Start with the immediate parent directory and move up.
- StringRef Path = llvm::sys::path::parent_path(FileName);
+ StringRef Path = llvm::sys::path::parent_path(AbsoluteFilePath.str());
for (StringRef CurrentPath = Path; !CurrentPath.empty();
CurrentPath = llvm::sys::path::parent_path(CurrentPath)) {
llvm::Optional<OptionsSource> Result;
OpenPOWER on IntegriCloud