DependencyScanningTool.h revision 360784
1//===- DependencyScanningTool.h - clang-scan-deps service -----------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CLANG_TOOLING_DEPENDENCY_SCANNING_TOOL_H
10#define LLVM_CLANG_TOOLING_DEPENDENCY_SCANNING_TOOL_H
11
12#include "clang/Tooling/DependencyScanning/DependencyScanningService.h"
13#include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h"
14#include "clang/Tooling/JSONCompilationDatabase.h"
15#include <string>
16
17namespace clang{
18namespace tooling{
19namespace dependencies{
20
21/// The high-level implementation of the dependency discovery tool that runs on
22/// an individual worker thread.
23class DependencyScanningTool {
24public:
25  /// Construct a dependency scanning tool.
26  DependencyScanningTool(DependencyScanningService &Service);
27
28  /// Print out the dependency information into a string using the dependency
29  /// file format that is specified in the options (-MD is the default) and
30  /// return it.
31  ///
32  /// \returns A \c StringError with the diagnostic output if clang errors
33  /// occurred, dependency file contents otherwise.
34  llvm::Expected<std::string>
35  getDependencyFile(const tooling::CompilationDatabase &Compilations,
36                    StringRef CWD);
37
38private:
39  const ScanningOutputFormat Format;
40  DependencyScanningWorker Worker;
41};
42
43} // end namespace dependencies
44} // end namespace tooling
45} // end namespace clang
46
47#endif // LLVM_CLANG_TOOLING_DEPENDENCY_SCANNING_TOOL_H
48