1 //===- ModuleMap.h - Describe the layout of modules -------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file defines the ModuleMap interface, which describes the layout of a 11 // module as it relates to headers. 12 // 13 //===----------------------------------------------------------------------===// 14 15 #ifndef LLVM_CLANG_LEX_MODULEMAP_H 16 #define LLVM_CLANG_LEX_MODULEMAP_H 17 18 #include "clang/Basic/LangOptions.h" 19 #include "clang/Basic/Module.h" 20 #include "clang/Basic/SourceLocation.h" 21 #include "llvm/ADT/ArrayRef.h" 22 #include "llvm/ADT/DenseMap.h" 23 #include "llvm/ADT/PointerIntPair.h" 24 #include "llvm/ADT/SmallPtrSet.h" 25 #include "llvm/ADT/SmallVector.h" 26 #include "llvm/ADT/StringMap.h" 27 #include "llvm/ADT/StringRef.h" 28 #include "llvm/ADT/TinyPtrVector.h" 29 #include "llvm/ADT/Twine.h" 30 #include <ctime> 31 #include <memory> 32 #include <string> 33 #include <utility> 34 35 namespace clang { 36 37 class DiagnosticsEngine; 38 class DirectoryEntry; 39 class FileEntry; 40 class FileManager; 41 class HeaderSearch; 42 class SourceManager; 43 44 /// \brief A mechanism to observe the actions of the module map parser as it 45 /// reads module map files. 46 class ModuleMapCallbacks { 47 public: 48 virtual ~ModuleMapCallbacks() = default; 49 50 /// \brief Called when a module map file has been read. 51 /// 52 /// \param FileStart A SourceLocation referring to the start of the file's 53 /// contents. 54 /// \param File The file itself. 55 /// \param IsSystem Whether this is a module map from a system include path. 56 virtual void moduleMapFileRead(SourceLocation FileStart, 57 const FileEntry &File, bool IsSystem) {} 58 59 /// \brief Called when a header is added during module map parsing. 60 /// 61 /// \param Filename The header file itself. 62 virtual void moduleMapAddHeader(StringRef Filename) {} 63 64 /// \brief Called when an umbrella header is added during module map parsing. 65 /// 66 /// \param FileMgr FileManager instance 67 /// \param Header The umbrella header to collect. 68 virtual void moduleMapAddUmbrellaHeader(FileManager *FileMgr, 69 const FileEntry *Header) {} 70 }; 71 72 class ModuleMap { 73 SourceManager &SourceMgr; 74 DiagnosticsEngine &Diags; 75 const LangOptions &LangOpts; 76 const TargetInfo *Target; 77 HeaderSearch &HeaderInfo; 78 79 llvm::SmallVector<std::unique_ptr<ModuleMapCallbacks>, 1> Callbacks; 80 81 /// \brief The directory used for Clang-supplied, builtin include headers, 82 /// such as "stdint.h". 83 const DirectoryEntry *BuiltinIncludeDir = nullptr; 84 85 /// \brief Language options used to parse the module map itself. 86 /// 87 /// These are always simple C language options. 88 LangOptions MMapLangOpts; 89 90 /// The module that the main source file is associated with (the module 91 /// named LangOpts::CurrentModule, if we've loaded it). 92 Module *SourceModule = nullptr; 93 94 /// The global module for the current TU, if we still own it. (Ownership is 95 /// transferred if/when we create an enclosing module. 96 std::unique_ptr<Module> PendingGlobalModule; 97 98 /// \brief The top-level modules that are known. 99 llvm::StringMap<Module *> Modules; 100 101 /// Shadow modules created while building this module map. 102 llvm::SmallVector<Module*, 2> ShadowModules; 103 104 /// \brief The number of modules we have created in total. 105 unsigned NumCreatedModules = 0; 106 107 public: 108 /// \brief Flags describing the role of a module header. 109 enum ModuleHeaderRole { 110 /// \brief This header is normally included in the module. 111 NormalHeader = 0x0, 112 113 /// \brief This header is included but private. 114 PrivateHeader = 0x1, 115 116 /// \brief This header is part of the module (for layering purposes) but 117 /// should be textually included. 118 TextualHeader = 0x2, 119 120 // Caution: Adding an enumerator needs other changes. 121 // Adjust the number of bits for KnownHeader::Storage. 122 // Adjust the bitfield HeaderFileInfo::HeaderRole size. 123 // Adjust the HeaderFileInfoTrait::ReadData streaming. 124 // Adjust the HeaderFileInfoTrait::EmitData streaming. 125 // Adjust ModuleMap::addHeader. 126 }; 127 128 /// Convert a header kind to a role. Requires Kind to not be HK_Excluded. 129 static ModuleHeaderRole headerKindToRole(Module::HeaderKind Kind); 130 131 /// Convert a header role to a kind. 132 static Module::HeaderKind headerRoleToKind(ModuleHeaderRole Role); 133 134 /// \brief A header that is known to reside within a given module, 135 /// whether it was included or excluded. 136 class KnownHeader { 137 llvm::PointerIntPair<Module *, 2, ModuleHeaderRole> Storage; 138 139 public: 140 KnownHeader() : Storage(nullptr, NormalHeader) {} 141 KnownHeader(Module *M, ModuleHeaderRole Role) : Storage(M, Role) {} 142 143 friend bool operator==(const KnownHeader &A, const KnownHeader &B) { 144 return A.Storage == B.Storage; 145 } 146 friend bool operator!=(const KnownHeader &A, const KnownHeader &B) { 147 return A.Storage != B.Storage; 148 } 149 150 /// \brief Retrieve the module the header is stored in. 151 Module *getModule() const { return Storage.getPointer(); } 152 153 /// \brief The role of this header within the module. 154 ModuleHeaderRole getRole() const { return Storage.getInt(); } 155 156 /// \brief Whether this header is available in the module. 157 bool isAvailable() const { 158 return getModule()->isAvailable(); 159 } 160 161 /// \brief Whether this header is accessible from the specified module. 162 bool isAccessibleFrom(Module *M) const { 163 return !(getRole() & PrivateHeader) || 164 (M && M->getTopLevelModule() == getModule()->getTopLevelModule()); 165 } 166 167 // \brief Whether this known header is valid (i.e., it has an 168 // associated module). 169 explicit operator bool() const { 170 return Storage.getPointer() != nullptr; 171 } 172 }; 173 174 using AdditionalModMapsSet = llvm::SmallPtrSet<const FileEntry *, 1>; 175 176 private: 177 friend class ModuleMapParser; 178 179 using HeadersMap = 180 llvm::DenseMap<const FileEntry *, SmallVector<KnownHeader, 1>>; 181 182 /// \brief Mapping from each header to the module that owns the contents of 183 /// that header. 184 HeadersMap Headers; 185 186 /// Map from file sizes to modules with lazy header directives of that size. 187 mutable llvm::DenseMap<off_t, llvm::TinyPtrVector<Module*>> LazyHeadersBySize; 188 189 /// Map from mtimes to modules with lazy header directives with those mtimes. 190 mutable llvm::DenseMap<time_t, llvm::TinyPtrVector<Module*>> 191 LazyHeadersByModTime; 192 193 /// \brief Mapping from directories with umbrella headers to the module 194 /// that is generated from the umbrella header. 195 /// 196 /// This mapping is used to map headers that haven't explicitly been named 197 /// in the module map over to the module that includes them via its umbrella 198 /// header. 199 llvm::DenseMap<const DirectoryEntry *, Module *> UmbrellaDirs; 200 201 /// \brief A generation counter that is used to test whether modules of the 202 /// same name may shadow or are illegal redefintions. 203 /// 204 /// Modules from earlier scopes may shadow modules from later ones. 205 /// Modules from the same scope may not have the same name. 206 unsigned CurrentModuleScopeID = 0; 207 208 llvm::DenseMap<Module *, unsigned> ModuleScopeIDs; 209 210 /// \brief The set of attributes that can be attached to a module. 211 struct Attributes { 212 /// \brief Whether this is a system module. 213 unsigned IsSystem : 1; 214 215 /// \brief Whether this is an extern "C" module. 216 unsigned IsExternC : 1; 217 218 /// \brief Whether this is an exhaustive set of configuration macros. 219 unsigned IsExhaustive : 1; 220 221 /// \brief Whether files in this module can only include non-modular headers 222 /// and headers from used modules. 223 unsigned NoUndeclaredIncludes : 1; 224 225 Attributes() 226 : IsSystem(false), IsExternC(false), IsExhaustive(false), 227 NoUndeclaredIncludes(false) {} 228 }; 229 230 /// \brief A directory for which framework modules can be inferred. 231 struct InferredDirectory { 232 /// \brief Whether to infer modules from this directory. 233 unsigned InferModules : 1; 234 235 /// \brief The attributes to use for inferred modules. 236 Attributes Attrs; 237 238 /// \brief If \c InferModules is non-zero, the module map file that allowed 239 /// inferred modules. Otherwise, nullptr. 240 const FileEntry *ModuleMapFile; 241 242 /// \brief The names of modules that cannot be inferred within this 243 /// directory. 244 SmallVector<std::string, 2> ExcludedModules; 245 246 InferredDirectory() : InferModules(false) {} 247 }; 248 249 /// \brief A mapping from directories to information about inferring 250 /// framework modules from within those directories. 251 llvm::DenseMap<const DirectoryEntry *, InferredDirectory> InferredDirectories; 252 253 /// A mapping from an inferred module to the module map that allowed the 254 /// inference. 255 llvm::DenseMap<const Module *, const FileEntry *> InferredModuleAllowedBy; 256 257 llvm::DenseMap<const Module *, AdditionalModMapsSet> AdditionalModMaps; 258 259 /// \brief Describes whether we haved parsed a particular file as a module 260 /// map. 261 llvm::DenseMap<const FileEntry *, bool> ParsedModuleMap; 262 263 /// \brief Resolve the given export declaration into an actual export 264 /// declaration. 265 /// 266 /// \param Mod The module in which we're resolving the export declaration. 267 /// 268 /// \param Unresolved The export declaration to resolve. 269 /// 270 /// \param Complain Whether this routine should complain about unresolvable 271 /// exports. 272 /// 273 /// \returns The resolved export declaration, which will have a NULL pointer 274 /// if the export could not be resolved. 275 Module::ExportDecl 276 resolveExport(Module *Mod, const Module::UnresolvedExportDecl &Unresolved, 277 bool Complain) const; 278 279 /// \brief Resolve the given module id to an actual module. 280 /// 281 /// \param Id The module-id to resolve. 282 /// 283 /// \param Mod The module in which we're resolving the module-id. 284 /// 285 /// \param Complain Whether this routine should complain about unresolvable 286 /// module-ids. 287 /// 288 /// \returns The resolved module, or null if the module-id could not be 289 /// resolved. 290 Module *resolveModuleId(const ModuleId &Id, Module *Mod, bool Complain) const; 291 292 /// Add an unresolved header to a module. 293 void addUnresolvedHeader(Module *Mod, 294 Module::UnresolvedHeaderDirective Header); 295 296 /// Look up the given header directive to find an actual header file. 297 /// 298 /// \param M The module in which we're resolving the header directive. 299 /// \param Header The header directive to resolve. 300 /// \param RelativePathName Filled in with the relative path name from the 301 /// module to the resolved header. 302 /// \return The resolved file, if any. 303 const FileEntry *findHeader(Module *M, 304 const Module::UnresolvedHeaderDirective &Header, 305 SmallVectorImpl<char> &RelativePathName); 306 307 /// Resolve the given header directive. 308 void resolveHeader(Module *M, 309 const Module::UnresolvedHeaderDirective &Header); 310 311 /// Attempt to resolve the specified header directive as naming a builtin 312 /// header. 313 /// \return \c true if a corresponding builtin header was found. 314 bool resolveAsBuiltinHeader(Module *M, 315 const Module::UnresolvedHeaderDirective &Header); 316 317 /// \brief Looks up the modules that \p File corresponds to. 318 /// 319 /// If \p File represents a builtin header within Clang's builtin include 320 /// directory, this also loads all of the module maps to see if it will get 321 /// associated with a specific module (e.g. in /usr/include). 322 HeadersMap::iterator findKnownHeader(const FileEntry *File); 323 324 /// \brief Searches for a module whose umbrella directory contains \p File. 325 /// 326 /// \param File The header to search for. 327 /// 328 /// \param IntermediateDirs On success, contains the set of directories 329 /// searched before finding \p File. 330 KnownHeader findHeaderInUmbrellaDirs(const FileEntry *File, 331 SmallVectorImpl<const DirectoryEntry *> &IntermediateDirs); 332 333 /// \brief Given that \p File is not in the Headers map, look it up within 334 /// umbrella directories and find or create a module for it. 335 KnownHeader findOrCreateModuleForHeaderInUmbrellaDir(const FileEntry *File); 336 337 /// \brief A convenience method to determine if \p File is (possibly nested) 338 /// in an umbrella directory. 339 bool isHeaderInUmbrellaDirs(const FileEntry *File) { 340 SmallVector<const DirectoryEntry *, 2> IntermediateDirs; 341 return static_cast<bool>(findHeaderInUmbrellaDirs(File, IntermediateDirs)); 342 } 343 344 Module *inferFrameworkModule(const DirectoryEntry *FrameworkDir, 345 Attributes Attrs, Module *Parent); 346 347 public: 348 /// \brief Construct a new module map. 349 /// 350 /// \param SourceMgr The source manager used to find module files and headers. 351 /// This source manager should be shared with the header-search mechanism, 352 /// since they will refer to the same headers. 353 /// 354 /// \param Diags A diagnostic engine used for diagnostics. 355 /// 356 /// \param LangOpts Language options for this translation unit. 357 /// 358 /// \param Target The target for this translation unit. 359 ModuleMap(SourceManager &SourceMgr, DiagnosticsEngine &Diags, 360 const LangOptions &LangOpts, const TargetInfo *Target, 361 HeaderSearch &HeaderInfo); 362 363 /// \brief Destroy the module map. 364 ~ModuleMap(); 365 366 /// \brief Set the target information. 367 void setTarget(const TargetInfo &Target); 368 369 /// \brief Set the directory that contains Clang-supplied include 370 /// files, such as our stdarg.h or tgmath.h. 371 void setBuiltinIncludeDir(const DirectoryEntry *Dir) { 372 BuiltinIncludeDir = Dir; 373 } 374 375 /// \brief Get the directory that contains Clang-supplied include files. 376 const DirectoryEntry *getBuiltinDir() const { 377 return BuiltinIncludeDir; 378 } 379 380 /// \brief Is this a compiler builtin header? 381 static bool isBuiltinHeader(StringRef FileName); 382 383 /// \brief Add a module map callback. 384 void addModuleMapCallbacks(std::unique_ptr<ModuleMapCallbacks> Callback) { 385 Callbacks.push_back(std::move(Callback)); 386 } 387 388 /// \brief Retrieve the module that owns the given header file, if any. 389 /// 390 /// \param File The header file that is likely to be included. 391 /// 392 /// \param AllowTextual If \c true and \p File is a textual header, return 393 /// its owning module. Otherwise, no KnownHeader will be returned if the 394 /// file is only known as a textual header. 395 /// 396 /// \returns The module KnownHeader, which provides the module that owns the 397 /// given header file. The KnownHeader is default constructed to indicate 398 /// that no module owns this header file. 399 KnownHeader findModuleForHeader(const FileEntry *File, 400 bool AllowTextual = false); 401 402 /// \brief Retrieve all the modules that contain the given header file. This 403 /// may not include umbrella modules, nor information from external sources, 404 /// if they have not yet been inferred / loaded. 405 /// 406 /// Typically, \ref findModuleForHeader should be used instead, as it picks 407 /// the preferred module for the header. 408 ArrayRef<KnownHeader> findAllModulesForHeader(const FileEntry *File) const; 409 410 /// Resolve all lazy header directives for the specified file. 411 /// 412 /// This ensures that the HeaderFileInfo on HeaderSearch is up to date. This 413 /// is effectively internal, but is exposed so HeaderSearch can call it. 414 void resolveHeaderDirectives(const FileEntry *File) const; 415 416 /// Resolve all lazy header directives for the specified module. 417 void resolveHeaderDirectives(Module *Mod) const; 418 419 /// \brief Reports errors if a module must not include a specific file. 420 /// 421 /// \param RequestingModule The module including a file. 422 /// 423 /// \param RequestingModuleIsModuleInterface \c true if the inclusion is in 424 /// the interface of RequestingModule, \c false if it's in the 425 /// implementation of RequestingModule. Value is ignored and 426 /// meaningless if RequestingModule is nullptr. 427 /// 428 /// \param FilenameLoc The location of the inclusion's filename. 429 /// 430 /// \param Filename The included filename as written. 431 /// 432 /// \param File The included file. 433 void diagnoseHeaderInclusion(Module *RequestingModule, 434 bool RequestingModuleIsModuleInterface, 435 SourceLocation FilenameLoc, StringRef Filename, 436 const FileEntry *File); 437 438 /// \brief Determine whether the given header is part of a module 439 /// marked 'unavailable'. 440 bool isHeaderInUnavailableModule(const FileEntry *Header) const; 441 442 /// \brief Determine whether the given header is unavailable as part 443 /// of the specified module. 444 bool isHeaderUnavailableInModule(const FileEntry *Header, 445 const Module *RequestingModule) const; 446 447 /// \brief Retrieve a module with the given name. 448 /// 449 /// \param Name The name of the module to look up. 450 /// 451 /// \returns The named module, if known; otherwise, returns null. 452 Module *findModule(StringRef Name) const; 453 454 /// \brief Retrieve a module with the given name using lexical name lookup, 455 /// starting at the given context. 456 /// 457 /// \param Name The name of the module to look up. 458 /// 459 /// \param Context The module context, from which we will perform lexical 460 /// name lookup. 461 /// 462 /// \returns The named module, if known; otherwise, returns null. 463 Module *lookupModuleUnqualified(StringRef Name, Module *Context) const; 464 465 /// \brief Retrieve a module with the given name within the given context, 466 /// using direct (qualified) name lookup. 467 /// 468 /// \param Name The name of the module to look up. 469 /// 470 /// \param Context The module for which we will look for a submodule. If 471 /// null, we will look for a top-level module. 472 /// 473 /// \returns The named submodule, if known; otherwose, returns null. 474 Module *lookupModuleQualified(StringRef Name, Module *Context) const; 475 476 /// \brief Find a new module or submodule, or create it if it does not already 477 /// exist. 478 /// 479 /// \param Name The name of the module to find or create. 480 /// 481 /// \param Parent The module that will act as the parent of this submodule, 482 /// or nullptr to indicate that this is a top-level module. 483 /// 484 /// \param IsFramework Whether this is a framework module. 485 /// 486 /// \param IsExplicit Whether this is an explicit submodule. 487 /// 488 /// \returns The found or newly-created module, along with a boolean value 489 /// that will be true if the module is newly-created. 490 std::pair<Module *, bool> findOrCreateModule(StringRef Name, Module *Parent, 491 bool IsFramework, 492 bool IsExplicit); 493 494 /// \brief Create a 'global module' for a C++ Modules TS module interface 495 /// unit. 496 /// 497 /// We model the global module as a submodule of the module interface unit. 498 /// Unfortunately, we can't create the module interface unit's Module until 499 /// later, because we don't know what it will be called. 500 Module *createGlobalModuleForInterfaceUnit(SourceLocation Loc); 501 502 /// \brief Create a new module for a C++ Modules TS module interface unit. 503 /// The module must not already exist, and will be configured for the current 504 /// compilation. 505 /// 506 /// Note that this also sets the current module to the newly-created module. 507 /// 508 /// \returns The newly-created module. 509 Module *createModuleForInterfaceUnit(SourceLocation Loc, StringRef Name, 510 Module *GlobalModule); 511 512 /// \brief Infer the contents of a framework module map from the given 513 /// framework directory. 514 Module *inferFrameworkModule(const DirectoryEntry *FrameworkDir, 515 bool IsSystem, Module *Parent); 516 517 /// \brief Create a new top-level module that is shadowed by 518 /// \p ShadowingModule. 519 Module *createShadowedModule(StringRef Name, bool IsFramework, 520 Module *ShadowingModule); 521 522 /// \brief Creates a new declaration scope for module names, allowing 523 /// previously defined modules to shadow definitions from the new scope. 524 /// 525 /// \note Module names from earlier scopes will shadow names from the new 526 /// scope, which is the opposite of how shadowing works for variables. 527 void finishModuleDeclarationScope() { CurrentModuleScopeID += 1; } 528 529 bool mayShadowNewModule(Module *ExistingModule) { 530 assert(!ExistingModule->Parent && "expected top-level module"); 531 assert(ModuleScopeIDs.count(ExistingModule) && "unknown module"); 532 return ModuleScopeIDs[ExistingModule] < CurrentModuleScopeID; 533 } 534 535 /// \brief Retrieve the module map file containing the definition of the given 536 /// module. 537 /// 538 /// \param Module The module whose module map file will be returned, if known. 539 /// 540 /// \returns The file entry for the module map file containing the given 541 /// module, or nullptr if the module definition was inferred. 542 const FileEntry *getContainingModuleMapFile(const Module *Module) const; 543 544 /// \brief Get the module map file that (along with the module name) uniquely 545 /// identifies this module. 546 /// 547 /// The particular module that \c Name refers to may depend on how the module 548 /// was found in header search. However, the combination of \c Name and 549 /// this module map will be globally unique for top-level modules. In the case 550 /// of inferred modules, returns the module map that allowed the inference 551 /// (e.g. contained 'module *'). Otherwise, returns 552 /// getContainingModuleMapFile(). 553 const FileEntry *getModuleMapFileForUniquing(const Module *M) const; 554 555 void setInferredModuleAllowedBy(Module *M, const FileEntry *ModuleMap); 556 557 /// \brief Get any module map files other than getModuleMapFileForUniquing(M) 558 /// that define submodules of a top-level module \p M. This is cheaper than 559 /// getting the module map file for each submodule individually, since the 560 /// expected number of results is very small. 561 AdditionalModMapsSet *getAdditionalModuleMapFiles(const Module *M) { 562 auto I = AdditionalModMaps.find(M); 563 if (I == AdditionalModMaps.end()) 564 return nullptr; 565 return &I->second; 566 } 567 568 void addAdditionalModuleMapFile(const Module *M, const FileEntry *ModuleMap) { 569 AdditionalModMaps[M].insert(ModuleMap); 570 } 571 572 /// \brief Resolve all of the unresolved exports in the given module. 573 /// 574 /// \param Mod The module whose exports should be resolved. 575 /// 576 /// \param Complain Whether to emit diagnostics for failures. 577 /// 578 /// \returns true if any errors were encountered while resolving exports, 579 /// false otherwise. 580 bool resolveExports(Module *Mod, bool Complain); 581 582 /// \brief Resolve all of the unresolved uses in the given module. 583 /// 584 /// \param Mod The module whose uses should be resolved. 585 /// 586 /// \param Complain Whether to emit diagnostics for failures. 587 /// 588 /// \returns true if any errors were encountered while resolving uses, 589 /// false otherwise. 590 bool resolveUses(Module *Mod, bool Complain); 591 592 /// \brief Resolve all of the unresolved conflicts in the given module. 593 /// 594 /// \param Mod The module whose conflicts should be resolved. 595 /// 596 /// \param Complain Whether to emit diagnostics for failures. 597 /// 598 /// \returns true if any errors were encountered while resolving conflicts, 599 /// false otherwise. 600 bool resolveConflicts(Module *Mod, bool Complain); 601 602 /// \brief Sets the umbrella header of the given module to the given 603 /// header. 604 void setUmbrellaHeader(Module *Mod, const FileEntry *UmbrellaHeader, 605 Twine NameAsWritten); 606 607 /// \brief Sets the umbrella directory of the given module to the given 608 /// directory. 609 void setUmbrellaDir(Module *Mod, const DirectoryEntry *UmbrellaDir, 610 Twine NameAsWritten); 611 612 /// \brief Adds this header to the given module. 613 /// \param Role The role of the header wrt the module. 614 void addHeader(Module *Mod, Module::Header Header, 615 ModuleHeaderRole Role, bool Imported = false); 616 617 /// \brief Marks this header as being excluded from the given module. 618 void excludeHeader(Module *Mod, Module::Header Header); 619 620 /// \brief Parse the given module map file, and record any modules we 621 /// encounter. 622 /// 623 /// \param File The file to be parsed. 624 /// 625 /// \param IsSystem Whether this module map file is in a system header 626 /// directory, and therefore should be considered a system module. 627 /// 628 /// \param HomeDir The directory in which relative paths within this module 629 /// map file will be resolved. 630 /// 631 /// \param ID The FileID of the file to process, if we've already entered it. 632 /// 633 /// \param Offset [inout] On input the offset at which to start parsing. On 634 /// output, the offset at which the module map terminated. 635 /// 636 /// \param ExternModuleLoc The location of the "extern module" declaration 637 /// that caused us to load this module map file, if any. 638 /// 639 /// \returns true if an error occurred, false otherwise. 640 bool parseModuleMapFile(const FileEntry *File, bool IsSystem, 641 const DirectoryEntry *HomeDir, 642 FileID ID = FileID(), unsigned *Offset = nullptr, 643 SourceLocation ExternModuleLoc = SourceLocation()); 644 645 /// \brief Dump the contents of the module map, for debugging purposes. 646 void dump(); 647 648 using module_iterator = llvm::StringMap<Module *>::const_iterator; 649 650 module_iterator module_begin() const { return Modules.begin(); } 651 module_iterator module_end() const { return Modules.end(); } 652 }; 653 654 } // namespace clang 655 656 #endif // LLVM_CLANG_LEX_MODULEMAP_H 657