1 //===- DependencyScanningService.h - clang-scan-deps service ===-*- C++ -*-===//
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_DEPENDENCYSCANNING_DEPENDENCYSCANNINGSERVICE_H
10 #define LLVM_CLANG_TOOLING_DEPENDENCYSCANNING_DEPENDENCYSCANNINGSERVICE_H
11 
12 #include "clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h"
13 
14 namespace clang {
15 namespace tooling {
16 namespace dependencies {
17 
18 /// The mode in which the dependency scanner will operate to find the
19 /// dependencies.
20 enum class ScanningMode {
21   /// This mode is used to compute the dependencies by running the preprocessor
22   /// over the source files.
23   CanonicalPreprocessing,
24 
25   /// This mode is used to compute the dependencies by running the preprocessor
26   /// with special kind of lexing after scanning header and source files to get
27   /// the minimum necessary preprocessor directives for evaluating includes.
28   DependencyDirectivesScan,
29 };
30 
31 /// The format that is output by the dependency scanner.
32 enum class ScanningOutputFormat {
33   /// This is the Makefile compatible dep format. This will include all of the
34   /// deps necessary for an implicit modules build, but won't include any
35   /// intermodule dependency information.
36   Make,
37 
38   /// This outputs the full module dependency graph suitable for use for
39   /// explicitly building modules.
40   Full,
41 };
42 
43 /// The dependency scanning service contains the shared state that is used by
44 /// the invidual dependency scanning workers.
45 class DependencyScanningService {
46 public:
47   DependencyScanningService(ScanningMode Mode, ScanningOutputFormat Format,
48                             bool ReuseFileManager = true,
49                             bool OptimizeArgs = false);
50 
51   ScanningMode getMode() const { return Mode; }
52 
53   ScanningOutputFormat getFormat() const { return Format; }
54 
55   bool canReuseFileManager() const { return ReuseFileManager; }
56 
57   bool canOptimizeArgs() const { return OptimizeArgs; }
58 
59   DependencyScanningFilesystemSharedCache &getSharedCache() {
60     return SharedCache;
61   }
62 
63 private:
64   const ScanningMode Mode;
65   const ScanningOutputFormat Format;
66   const bool ReuseFileManager;
67   /// Whether to optimize the modules' command-line arguments.
68   const bool OptimizeArgs;
69   /// The global file system cache.
70   DependencyScanningFilesystemSharedCache SharedCache;
71 };
72 
73 } // end namespace dependencies
74 } // end namespace tooling
75 } // end namespace clang
76 
77 #endif // LLVM_CLANG_TOOLING_DEPENDENCYSCANNING_DEPENDENCYSCANNINGSERVICE_H
78