|
26 | 26 | #include "llvm/ADT/SmallVector.h" |
27 | 27 | #include "llvm/ADT/StringMap.h" |
28 | 28 | #include "llvm/ADT/StringRef.h" |
| 29 | +#include "llvm/ADT/TinyPtrVector.h" |
29 | 30 | #include "llvm/ADT/Twine.h" |
30 | 31 | #include <algorithm> |
31 | 32 | #include <memory> |
@@ -116,6 +117,11 @@ class ModuleMap { |
116 | 117 | // Adjust ModuleMap::addHeader. |
117 | 118 | }; |
118 | 119 |
|
| 120 | + /// Convert a header kind to a role. Requires Kind to not be HK_Excluded. |
| 121 | + static ModuleHeaderRole headerKindToRole(Module::HeaderKind Kind); |
| 122 | + /// Convert a header role to a kind. |
| 123 | + static Module::HeaderKind headerRoleToKind(ModuleHeaderRole Role); |
| 124 | + |
119 | 125 | /// \brief A header that is known to reside within a given module, |
120 | 126 | /// whether it was included or excluded. |
121 | 127 | class KnownHeader { |
@@ -165,7 +171,13 @@ class ModuleMap { |
165 | 171 | /// \brief Mapping from each header to the module that owns the contents of |
166 | 172 | /// that header. |
167 | 173 | HeadersMap Headers; |
168 | | - |
| 174 | + |
| 175 | + /// Map from file sizes to modules with lazy header directives of that size. |
| 176 | + mutable llvm::DenseMap<off_t, llvm::TinyPtrVector<Module*>> LazyHeadersBySize; |
| 177 | + /// Map from mtimes to modules with lazy header directives with those mtimes. |
| 178 | + mutable llvm::DenseMap<time_t, llvm::TinyPtrVector<Module*>> |
| 179 | + LazyHeadersByModTime; |
| 180 | + |
169 | 181 | /// \brief Mapping from directories with umbrella headers to the module |
170 | 182 | /// that is generated from the umbrella header. |
171 | 183 | /// |
@@ -257,22 +269,30 @@ class ModuleMap { |
257 | 269 | /// resolved. |
258 | 270 | Module *resolveModuleId(const ModuleId &Id, Module *Mod, bool Complain) const; |
259 | 271 |
|
260 | | - /// Resolve the given header directive to an actual header file. |
| 272 | + /// Add an unresolved header to a module. |
| 273 | + void addUnresolvedHeader(Module *Mod, |
| 274 | + Module::UnresolvedHeaderDirective Header); |
| 275 | + |
| 276 | + /// Look up the given header directive to find an actual header file. |
261 | 277 | /// |
262 | 278 | /// \param M The module in which we're resolving the header directive. |
263 | 279 | /// \param Header The header directive to resolve. |
264 | 280 | /// \param RelativePathName Filled in with the relative path name from the |
265 | 281 | /// module to the resolved header. |
266 | 282 | /// \return The resolved file, if any. |
267 | | - const FileEntry *resolveHeader(Module *M, |
268 | | - Module::UnresolvedHeaderDirective Header, |
269 | | - SmallVectorImpl<char> &RelativePathName); |
| 283 | + const FileEntry *findHeader(Module *M, |
| 284 | + const Module::UnresolvedHeaderDirective &Header, |
| 285 | + SmallVectorImpl<char> &RelativePathName); |
| 286 | + |
| 287 | + /// Resolve the given header directive. |
| 288 | + void resolveHeader(Module *M, |
| 289 | + const Module::UnresolvedHeaderDirective &Header); |
270 | 290 |
|
271 | 291 | /// Attempt to resolve the specified header directive as naming a builtin |
272 | 292 | /// header. |
273 | | - const FileEntry * |
274 | | - resolveAsBuiltinHeader(Module *M, Module::UnresolvedHeaderDirective Header, |
275 | | - SmallVectorImpl<char> &BuiltinPathName); |
| 293 | + /// \return \c true if a corresponding builtin header was found. |
| 294 | + bool resolveAsBuiltinHeader(Module *M, |
| 295 | + const Module::UnresolvedHeaderDirective &Header); |
276 | 296 |
|
277 | 297 | /// \brief Looks up the modules that \p File corresponds to. |
278 | 298 | /// |
@@ -368,6 +388,15 @@ class ModuleMap { |
368 | 388 | /// the preferred module for the header. |
369 | 389 | ArrayRef<KnownHeader> findAllModulesForHeader(const FileEntry *File) const; |
370 | 390 |
|
| 391 | + /// Resolve all lazy header directives for the specified file. |
| 392 | + /// |
| 393 | + /// This ensures that the HeaderFileInfo on HeaderSearch is up to date. This |
| 394 | + /// is effectively internal, but is exposed so HeaderSearch can call it. |
| 395 | + void resolveHeaderDirectives(const FileEntry *File) const; |
| 396 | + |
| 397 | + /// Resolve all lazy header directives for the specified module. |
| 398 | + void resolveHeaderDirectives(Module *Mod) const; |
| 399 | + |
371 | 400 | /// \brief Reports errors if a module must not include a specific file. |
372 | 401 | /// |
373 | 402 | /// \param RequestingModule The module including a file. |
|
0 commit comments