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
63/// The configuration knobs for the dependency scanning service.
66
67 /// The function invoked to create each worker's VFS. This function and the
68 /// VFS itself must be thread-safe whenever using multiple workers
69 /// concurrently or whenever \c AsyncScanModules is true.
71 MakeVFS; // = [] { return llvm::vfs::createPhysicalFileSystem(); }
72 /// Whether to use optimized dependency directive scan or full preprocessing.
74 /// How to optimize resulting explicit module command lines.
76 /// Whether the scanner should emit warnings.
77 bool EmitWarnings = true;
78 /// Whether to make reported file paths absolute.
80 /// Whether to report modules visible from modules that are imported directly.
82 /// Whether the resulting command lines should load explicit PCMs eagerly.
83 bool EagerLoadModules = false;
84 /// Whether to trace VFS accesses during the scan.
85 bool TraceVFS = false;
86 /// Whether to scan modules asynchronously.
87 bool AsyncScanModules = false;
88 /// The build session timestamp for validate-once-per-build-session logic.
89 std::time_t BuildSessionTimestamp; // = std::chrono::system_clock::now();
90 /// Whether to automatically flush the module cache from memory to disk at the
91 /// end of the service lifetime.
92 bool FlushModuleCache = true;
93};
94
95/// The dependency scanning service contains shared configuration and state that
96/// is used by the individual dependency scanning workers.
98public:
100 : Opts(std::move(Opts)) {}
101
103 if (Opts.FlushModuleCache)
104 ModCacheEntries.flush();
105 }
106
107 const DependencyScanningServiceOptions &getOpts() const { return Opts; }
108
110 return SharedCache;
111 }
112
113 ModuleCacheEntries &getModuleCacheEntries() { return ModCacheEntries; }
114
115private:
116 /// The options customizing dependency scanning behavior.
118 /// The global file system cache.
120 /// The global module cache entries.
121 ModuleCacheEntries ModCacheEntries;
122};
123
124} // end namespace dependencies
125} // end namespace clang
126
127#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.
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 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.