clang 22.0.0git
DependencyScanningService.h
Go to the documentation of this file.
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
14#include "llvm/ADT/BitmaskEnum.h"
15#include "llvm/Support/Chrono.h"
16
17namespace clang {
18namespace tooling {
19namespace dependencies {
20
21/// The mode in which the dependency scanner will operate to find the
22/// dependencies.
23enum class ScanningMode {
24 /// This mode is used to compute the dependencies by running the preprocessor
25 /// over the source files.
27
28 /// This mode is used to compute the dependencies by running the preprocessor
29 /// with special kind of lexing after scanning header and source files to get
30 /// the minimum necessary preprocessor directives for evaluating includes.
32};
33
34/// The format that is output by the dependency scanner.
36 /// This is the Makefile compatible dep format. This will include all of the
37 /// deps necessary for an implicit modules build, but won't include any
38 /// intermodule dependency information.
40
41 /// This outputs the full clang module dependency graph suitable for use for
42 /// explicitly building modules.
44
45 /// This outputs the dependency graph for standard c++ modules in P1689R5
46 /// format.
48};
49
50#define DSS_LAST_BITMASK_ENUM(Id) \
51 LLVM_MARK_AS_BITMASK_ENUM(Id), All = llvm::NextPowerOf2(Id) - 1
52
54 None = 0,
55
56 /// Remove unused header search paths including header maps.
58
59 /// Remove warnings from system modules.
60 SystemWarnings = (1 << 1),
61
62 /// Remove unused -ivfsoverlay arguments.
63 VFS = (1 << 2),
64
65 /// Canonicalize -D and -U options.
66 Macros = (1 << 3),
67
68 /// Ignore the compiler's working directory if it is safe.
69 IgnoreCWD = (1 << 4),
70
72
73 // The build system needs to be aware that the current working
74 // directory is ignored. Without a good way of notifying the build
75 // system, it is less risky to default to off.
77};
78
79#undef DSS_LAST_BITMASK_ENUM
80
81/// The dependency scanning service contains shared configuration and state that
82/// is used by the individual dependency scanning workers.
84public:
88 bool EagerLoadModules = false, bool TraceVFS = false,
89 std::time_t BuildSessionTimestamp =
90 llvm::sys::toTimeT(std::chrono::system_clock::now()));
91
92 ScanningMode getMode() const { return Mode; }
93
94 ScanningOutputFormat getFormat() const { return Format; }
95
96 ScanningOptimizations getOptimizeArgs() const { return OptimizeArgs; }
97
98 bool shouldEagerLoadModules() const { return EagerLoadModules; }
99
100 bool shouldTraceVFS() const { return TraceVFS; }
101
103 return SharedCache;
104 }
105
106 ModuleCacheEntries &getModuleCacheEntries() { return ModCacheEntries; }
107
108 std::time_t getBuildSessionTimestamp() const { return BuildSessionTimestamp; }
109
110private:
111 const ScanningMode Mode;
112 const ScanningOutputFormat Format;
113 /// Whether to optimize the modules' command-line arguments.
114 const ScanningOptimizations OptimizeArgs;
115 /// Whether to set up command-lines to load PCM files eagerly.
116 const bool EagerLoadModules;
117 /// Whether to trace VFS accesses.
118 const bool TraceVFS;
119 /// The global file system cache.
121 /// The global module cache entries.
122 ModuleCacheEntries ModCacheEntries;
123 /// The build session timestamp.
124 std::time_t BuildSessionTimestamp;
125};
126
127} // end namespace dependencies
128} // end namespace tooling
129} // end namespace clang
130
131#endif // LLVM_CLANG_TOOLING_DEPENDENCYSCANNING_DEPENDENCYSCANNINGSERVICE_H
This class is a shared cache, that caches the 'stat' and 'open' calls to the underlying real file sys...
DependencyScanningService(ScanningMode Mode, ScanningOutputFormat Format, ScanningOptimizations OptimizeArgs=ScanningOptimizations::Default, bool EagerLoadModules=false, bool TraceVFS=false, std::time_t BuildSessionTimestamp=llvm::sys::toTimeT(std::chrono::system_clock::now()))
DependencyScanningFilesystemSharedCache & getSharedCache()
ScanningOutputFormat
The format that is output by the dependency scanner.
@ Make
This is the Makefile compatible dep format.
@ Full
This outputs the full clang module dependency graph suitable for use for explicitly building modules.
@ P1689
This outputs the dependency graph for standard c++ modules in P1689R5 format.
ScanningMode
The mode in which the dependency scanner will operate to find the dependencies.
@ DependencyDirectivesScan
This mode is used to compute the dependencies by running the preprocessor with special kind of lexing...
@ CanonicalPreprocessing
This mode is used to compute the dependencies by running the preprocessor over the source files.
@ IgnoreCWD
Ignore the compiler's working directory if it is safe.
@ HeaderSearch
Remove unused header search paths including header maps.
The JSON file list parser is used to communicate input to InstallAPI.