clang 24.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
15#include "llvm/ADT/BitmaskEnum.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#define DSS_LAST_BITMASK_ENUM(Id) \
34 LLVM_MARK_AS_BITMASK_ENUM(Id), All = llvm::NextPowerOf2(Id) - 1
35
37 None = 0,
38
39 /// Remove unused header search paths including header maps.
41
42 /// Remove warnings from system modules.
43 SystemWarnings = (1 << 1),
44
45 /// Remove unused -ivfsoverlay arguments.
46 VFS = (1 << 2),
47
48 /// Canonicalize -D and -U options.
49 Macros = (1 << 3),
50
51 /// Ignore the compiler's working directory if it is safe.
52 IgnoreCWD = (1 << 4),
53
55
56 // The build system needs to be aware that the current working
57 // directory is ignored. Without a good way of notifying the build
58 // system, it is less risky to default to off.
60};
61
62#undef DSS_LAST_BITMASK_ENUM
63
65
66/// \return true if failed stats for files with this name should be cached,
67/// false otherwise.
68bool shouldCacheNegativeStatsForPath(StringRef Path);
69
70/// The configuration knobs for the dependency scanning service.
73
74 /// The function invoked to create each worker's VFS. This function and the
75 /// VFS itself must be thread-safe whenever using multiple workers
76 /// concurrently or whenever \c AsyncScanModules is true.
78 MakeVFS; // = [] { return llvm::vfs::createPhysicalFileSystem(); }
79 /// Whether to use optimized dependency directive scan or full preprocessing.
81 /// How to optimize resulting explicit module command lines.
83 /// Whether the scanner should emit warnings.
84 bool EmitWarnings = true;
85 /// Whether to make reported file paths absolute.
87 /// Whether to report modules visible from modules that are imported directly.
89 /// Whether the resulting command lines should load explicit PCMs eagerly.
90 bool EagerLoadModules = false;
91 /// Whether to trace VFS accesses during the scan.
92 bool TraceVFS = false;
93 /// Whether to scan modules asynchronously.
94 bool AsyncScanModules = false;
95 /// The build session timestamp for validate-once-per-build-session logic.
96 std::time_t BuildSessionTimestamp; // = std::chrono::system_clock::now();
97 /// Whether to automatically flush the module cache from memory to disk at the
98 /// end of the service lifetime.
99 bool FlushModuleCache = true;
100 /// Whether the caching VFS should cache missing filesystem entries.
102 /// The path to a log file, which logs timing of actions performed by
103 /// the dependency scanner.
104 std::string LogPath;
105};
106
107/// The dependency scanning service contains shared configuration and state that
108/// is used by the individual dependency scanning workers.
110public:
112 : Opts(std::move(Opts)), Logger(this->Opts.LogPath) {}
113
115 if (Opts.FlushModuleCache)
116 ModCacheEntries.flush();
117 }
118
119 const DependencyScanningServiceOptions &getOpts() const { return Opts; }
120
122 return SharedCache;
123 }
124
125 ModuleCacheEntries &getModuleCacheEntries() { return ModCacheEntries; }
126
127 AtomicLineLogger &getLogger() { return Logger; }
128
129private:
130 /// The options customizing dependency scanning behavior.
132 /// The global file system cache.
134 /// The global module cache entries.
135 ModuleCacheEntries ModCacheEntries;
136 /// The logger of dependency scanning actions.
137 AtomicLineLogger Logger;
138};
139
140} // end namespace dependencies
141} // end namespace clang
142
143#endif // LLVM_CLANG_DEPENDENCYSCANNING_DEPENDENCYSCANNINGSERVICE_H
Defines a logger where each line is written atomically to the file.
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.
std::string LogPath
The path to a log file, which logs timing of actions performed by the dependency scanner.
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.