clang 23.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
16namespace clang {
17namespace dependencies {
18
19/// The mode in which the dependency scanner will operate to find the
20/// dependencies.
21enum class ScanningMode {
22 /// This mode is used to compute the dependencies by running the preprocessor
23 /// over the source files.
25
26 /// This mode is used to compute the dependencies by running the preprocessor
27 /// with special kind of lexing after scanning header and source files to get
28 /// the minimum necessary preprocessor directives for evaluating includes.
30};
31
32#define DSS_LAST_BITMASK_ENUM(Id) \
33 LLVM_MARK_AS_BITMASK_ENUM(Id), All = llvm::NextPowerOf2(Id) - 1
34
36 None = 0,
37
38 /// Remove unused header search paths including header maps.
40
41 /// Remove warnings from system modules.
42 SystemWarnings = (1 << 1),
43
44 /// Remove unused -ivfsoverlay arguments.
45 VFS = (1 << 2),
46
47 /// Canonicalize -D and -U options.
48 Macros = (1 << 3),
49
50 /// Ignore the compiler's working directory if it is safe.
51 IgnoreCWD = (1 << 4),
52
54
55 // The build system needs to be aware that the current working
56 // directory is ignored. Without a good way of notifying the build
57 // system, it is less risky to default to off.
59};
60
61#undef DSS_LAST_BITMASK_ENUM
62
64
65/// \return true if failed stats for files with this name should be cached,
66/// false otherwise.
67bool shouldCacheNegativeStatsForPath(StringRef Path);
68
69/// The configuration knobs for the dependency scanning service.
72
73 /// The function invoked to create each worker's VFS. This function and the
74 /// VFS itself must be thread-safe whenever using multiple workers
75 /// concurrently or whenever \c AsyncScanModules is true.
77 MakeVFS; // = [] { return llvm::vfs::createPhysicalFileSystem(); }
78 /// Whether to use optimized dependency directive scan or full preprocessing.
80 /// How to optimize resulting explicit module command lines.
82 /// Whether the scanner should emit warnings.
83 bool EmitWarnings = true;
84 /// Whether to make reported file paths absolute.
86 /// Whether to report modules visible from modules that are imported directly.
88 /// Whether the resulting command lines should load explicit PCMs eagerly.
89 bool EagerLoadModules = false;
90 /// Whether to trace VFS accesses during the scan.
91 bool TraceVFS = false;
92 /// Whether to scan modules asynchronously.
93 bool AsyncScanModules = false;
94 /// The build session timestamp for validate-once-per-build-session logic.
95 std::time_t BuildSessionTimestamp; // = std::chrono::system_clock::now();
96 /// Whether to automatically flush the module cache from memory to disk at the
97 /// end of the service lifetime.
98 bool FlushModuleCache = true;
99 /// Whether the caching VFS should cache missing filesystem entries.
101};
102
103/// The dependency scanning service contains shared configuration and state that
104/// is used by the individual dependency scanning workers.
106public:
108 : Opts(std::move(Opts)) {}
109
111 if (Opts.FlushModuleCache)
112 ModCacheEntries.flush();
113 }
114
115 const DependencyScanningServiceOptions &getOpts() const { return Opts; }
116
118 return SharedCache;
119 }
120
121 ModuleCacheEntries &getModuleCacheEntries() { return ModCacheEntries; }
122
123private:
124 /// The options customizing dependency scanning behavior.
126 /// The global file system cache.
128 /// The global module cache entries.
129 ModuleCacheEntries ModCacheEntries;
130};
131
132} // end namespace dependencies
133} // end namespace clang
134
135#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...
const DependencyScanningServiceOptions & getOpts() const
DependencyScanningService(DependencyScanningServiceOptions Opts)
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.
bool shouldCacheNegativeStatsForPath(StringRef Path)
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.
int const char * function
Definition c++config.h:31
The configuration knobs for the dependency scanning service.
bool FlushModuleCache
Whether to automatically flush the module cache from memory to disk at the end of the service lifetim...
std::function< IntrusiveRefCntPtr< llvm::vfs::FileSystem >()> MakeVFS
The function invoked to create each worker's VFS.
bool AsyncScanModules
Whether to scan modules asynchronously.
ScanningMode Mode
Whether to use optimized dependency directive scan or full preprocessing.
bool ReportVisibleModules
Whether to report modules visible from modules that are imported directly.
bool EmitWarnings
Whether the scanner should emit warnings.
bool CacheNegativeStats
Whether the caching VFS should cache missing filesystem entries.
bool TraceVFS
Whether to trace VFS accesses during the scan.
bool EagerLoadModules
Whether the resulting command lines should load explicit PCMs eagerly.
bool ReportAbsolutePaths
Whether to make reported file paths absolute.
std::time_t BuildSessionTimestamp
The build session timestamp for validate-once-per-build-session logic.
ScanningOptimizations OptimizeArgs
How to optimize resulting explicit module command lines.