diff options
author | Kousik Kumar <kousikk@google.com> | 2019-10-22 05:05:18 +0000 |
---|---|---|
committer | Kousik Kumar <kousikk@google.com> | 2019-10-22 05:05:18 +0000 |
commit | 7e03c676e4d1b9bde9d8a50ba6521f07df218704 (patch) | |
tree | 1b0a64e06e8ce66212daa0882016fa78e0c1db9d /include | |
parent | c6761990bda8885d0f421ff03675a3d5f584d483 (diff) | |
download | clang-7e03c676e4d1b9bde9d8a50ba6521f07df218704.tar.gz |
Refactor DependencyScanningTool to its own file
Summary:
There's no behavior change - just moving DependencyScanningTool to its own file
since this tool can be reused across both clang-scan-deps binary and an interface
exposed as part of libClang APIs.
Reviewers: arphaman, jkorous, Bigcheese, dexonsmith
Subscribers: mgorny, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D69186
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@375483 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/Tooling/DependencyScanning/DependencyScanningTool.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h b/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h new file mode 100644 index 0000000000..0c9efccb1d --- /dev/null +++ b/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h @@ -0,0 +1,48 @@ +//===- DependencyScanningTool.h - clang-scan-deps service ------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_TOOLING_DEPENDENCY_SCANNING_TOOL_H +#define LLVM_CLANG_TOOLING_DEPENDENCY_SCANNING_TOOL_H + +#include "clang/Tooling/DependencyScanning/DependencyScanningService.h" +#include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h" +#include "clang/Tooling/JSONCompilationDatabase.h" +#include <string> + +namespace clang{ +namespace tooling{ +namespace dependencies{ + +/// The high-level implementation of the dependency discovery tool that runs on +/// an individual worker thread. +class DependencyScanningTool { +public: + /// Construct a dependency scanning tool. + /// + /// \param Compilations The reference to the compilation database that's + /// used by the clang tool. + DependencyScanningTool(DependencyScanningService &Service, const clang::tooling::CompilationDatabase &Compilations); + + /// Print out the dependency information into a string using the dependency + /// file format that is specified in the options (-MD is the default) and + /// return it. + /// + /// \returns A \c StringError with the diagnostic output if clang errors + /// occurred, dependency file contents otherwise. + llvm::Expected<std::string> getDependencyFile(const std::string &Input, StringRef CWD); + +private: + DependencyScanningWorker Worker; + const tooling::CompilationDatabase &Compilations; +}; + +} // end namespace dependencies +} // end namespace tooling +} // end namespace clang + +#endif // LLVM_CLANG_TOOLING_DEPENDENCY_SCANNING_TOOL_H |