diff options
author | Ilya Biryukov <ibiryukov@google.com> | 2018-01-23 12:31:06 +0000 |
---|---|---|
committer | Ilya Biryukov <ibiryukov@google.com> | 2018-01-23 12:31:06 +0000 |
commit | 5ab428935c22f97dcb5e73e937d0c49a0eae773e (patch) | |
tree | 46fc7435e468aeda0914d51fe57644790a910ca1 /clang-tidy/ClangTidy.cpp | |
parent | 273625937ba76676e925ae785b9ec39ab6c7abbd (diff) |
[clang-tidy] Add -vfsoverlay flag
Summary:
It allows to remap and override files and directories on disk when
running clang-tidy. The intended use case for the flag is running
standalone clang-tidy binary for IDE and editor integration.
Patch by Vladimir Plyashkun.
Reviewers: alexfh, benlangmuir, ilya-biryukov
Reviewed By: ilya-biryukov
Subscribers: ilya-biryukov, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D41535
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@323196 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-tidy/ClangTidy.cpp')
-rw-r--r-- | clang-tidy/ClangTidy.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/clang-tidy/ClangTidy.cpp b/clang-tidy/ClangTidy.cpp index c3ddc458..a68111b4 100644 --- a/clang-tidy/ClangTidy.cpp +++ b/clang-tidy/ClangTidy.cpp @@ -89,8 +89,9 @@ private: class ErrorReporter { public: - ErrorReporter(ClangTidyContext &Context, bool ApplyFixes) - : Files(FileSystemOptions()), DiagOpts(new DiagnosticOptions()), + ErrorReporter(ClangTidyContext &Context, bool ApplyFixes, + llvm::IntrusiveRefCntPtr<vfs::FileSystem> BaseFS) + : Files(FileSystemOptions(), BaseFS), DiagOpts(new DiagnosticOptions()), DiagPrinter(new TextDiagnosticPrinter(llvm::outs(), &*DiagOpts)), Diags(IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs), &*DiagOpts, DiagPrinter), @@ -474,8 +475,11 @@ ClangTidyOptions::OptionMap getCheckOptions(const ClangTidyOptions &Options) { void runClangTidy(clang::tidy::ClangTidyContext &Context, const CompilationDatabase &Compilations, - ArrayRef<std::string> InputFiles, ProfileData *Profile) { - ClangTool Tool(Compilations, InputFiles); + ArrayRef<std::string> InputFiles, + llvm::IntrusiveRefCntPtr<vfs::FileSystem> BaseFS, + ProfileData *Profile) { + ClangTool Tool(Compilations, InputFiles, + std::make_shared<PCHContainerOperations>(), BaseFS); // Add extra arguments passed by the clang-tidy command-line. ArgumentsAdjuster PerFileExtraArgumentsInserter = @@ -546,8 +550,9 @@ void runClangTidy(clang::tidy::ClangTidyContext &Context, } void handleErrors(ClangTidyContext &Context, bool Fix, - unsigned &WarningsAsErrorsCount) { - ErrorReporter Reporter(Context, Fix); + unsigned &WarningsAsErrorsCount, + llvm::IntrusiveRefCntPtr<vfs::FileSystem> BaseFS) { + ErrorReporter Reporter(Context, Fix, BaseFS); vfs::FileSystem &FileSystem = *Reporter.getSourceManager().getFileManager().getVirtualFileSystem(); auto InitialWorkingDir = FileSystem.getCurrentWorkingDirectory(); |