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