17#include "llvm/ADT/STLExtras.h"
18#include "llvm/Support/BLAKE3.h"
36 for (
const auto Dep : ModuleFileDependents) {
39 PrebuiltModulesMap[Dep].updateDependentsNotInStableDirs(PrebuiltModulesMap);
50 std::vector<HeaderSearchOptions::Entry> Entries;
53 llvm::BitVector SearchPathUsage(Entries.size());
54 llvm::DenseSet<const serialization::ModuleFile *> Visited;
60 if (!Visited.contains(Import))
65 if (SearchPathUsage.size() != Entries.size())
66 llvm::report_fatal_error(
67 "Inconsistent search path options between modules detected");
69 for (
auto Idx : SearchPathUsage.set_bits())
70 Opts.
UserEntries.push_back(std::move(Entries[Idx]));
73 std::vector<std::string> VFSOverlayFiles;
76 llvm::BitVector VFSUsage(VFSOverlayFiles.size());
77 llvm::DenseSet<const serialization::ModuleFile *> Visited;
86 if (!Visited.contains(Import))
91 auto PrebuiltModulePropIt =
92 PrebuiltModulesASTMap.find(MF->
FileName);
93 if (PrebuiltModulePropIt == PrebuiltModulesASTMap.end())
95 for (std::size_t I = 0, E = VFSOverlayFiles.size(); I != E; ++I) {
96 if (PrebuiltModulePropIt->second.getVFS().contains(
104 if (VFSUsage.size() != VFSOverlayFiles.size())
105 llvm::report_fatal_error(
106 "Inconsistent -ivfsoverlay options between modules detected");
108 for (
auto Idx : VFSUsage.set_bits())
114 bool IsSystemModule) {
119 bool Wsystem_headers =
false;
120 for (StringRef Opt : Opts.
Warnings) {
121 bool isPositive = !Opt.consume_front(
"no-");
122 if (Opt ==
"system-headers")
123 Wsystem_headers = isPositive;
141static std::vector<std::string>
splitString(std::string S,
char Separator) {
143 StringRef(S).split(Segments, Separator, -1,
false);
144 std::vector<std::string>
Result;
145 Result.reserve(Segments.size());
146 for (StringRef Segment : Segments)
147 Result.push_back(Segment.str());
151void ModuleDepCollector::addOutputPaths(CowCompilerInvocation &CI,
157 Controller.lookupModuleOutput(
197 const StringRef Input) {
198 using namespace llvm::sys;
200 if (!path::is_absolute(Input))
203 auto PathStartsWith = [](StringRef Prefix, StringRef Path) {
204 auto PrefixIt = path::begin(Prefix), PrefixEnd = path::end(Prefix);
205 for (
auto PathIt = path::begin(Path), PathEnd = path::end(Path);
206 PrefixIt != PrefixEnd && PathIt != PathEnd; ++PrefixIt, ++PathIt) {
207 if (*PrefixIt != *PathIt)
210 return PrefixIt == PrefixEnd;
213 return any_of(Directories, [&](StringRef Dir) {
214 return !Dir.empty() && PathStartsWith(Dir, Input);
221 "Sysroots differ between module dependencies and current TU");
224 "ResourceDirs differ between module dependencies and current TU");
227 if (!Entry.IgnoreSysRoot)
288 [&CI](
const std::pair<std::string, bool> &Def) {
289 StringRef MacroDef = Def.first;
290 return CI.getHeaderSearchOpts().ModulesIgnoreMacros.contains(
291 llvm::CachedHashString(MacroDef.split(
'=').first));
302 return CI.getHeaderSearchOpts().ModulesIgnoreSearchPaths.contains(
303 llvm::CachedHashString(E.Path));
313ModuleDepCollector::getInvocationAdjustedForModuleBuildWithoutOutputs(
315 llvm::function_ref<
void(CowCompilerInvocation &)> Optimize)
const {
316 CowCompilerInvocation CI = CommonInvocation;
357 llvm::SmallDenseSet<const FileEntry *, 16> &SeenModuleMapFiles,
360 if (!SeenModuleMapFiles.insert(ModuleMapFile).second)
368 ModuleMapFiles.emplace_back(Path);
371void ModuleDepCollector::collectModuleMapFiles(
372 std::vector<std::string> &ModuleMapFiles,
373 llvm::SmallDenseSet<const FileEntry *, 16> &SeenModuleMapFiles,
374 ArrayRef<ModuleID> ClangModuleDeps)
const {
377 for (
const ModuleID &MID : ClangModuleDeps) {
378 ModuleDeps *MD = ModuleDepsByID.lookup(MID);
379 assert(MD &&
"Inconsistent dependency info");
381 auto FE = ScanInstance.getFileManager().getOptionalFileRef(
383 assert(FE &&
"Missing module map file that was previously found");
389 !Service.getOpts().EagerLoadModules);
393void ModuleDepCollector::addModuleFiles(
394 CompilerInvocation &CI, ArrayRef<ModuleID> ClangModuleDeps)
const {
395 for (
const ModuleID &MID : ClangModuleDeps) {
396 ModuleDeps *MD = ModuleDepsByID.lookup(MID);
397 std::string PCMPath =
400 if (Service.getOpts().EagerLoadModules)
404 {MID.ModuleName, std::move(PCMPath)});
408void ModuleDepCollector::addModuleFiles(
409 CowCompilerInvocation &CI, ArrayRef<ModuleID> ClangModuleDeps)
const {
410 for (
const ModuleID &MID : ClangModuleDeps) {
411 ModuleDeps *MD = ModuleDepsByID.lookup(MID);
412 std::string PCMPath =
415 if (Service.getOpts().EagerLoadModules)
419 {MID.ModuleName, std::move(PCMPath)});
444 for (
const auto &KV : ModularDeps)
445 if (DirectModularDeps.contains(KV.first))
446 DirectDeps.push_back(KV.second->ID);
448 addModuleFiles(CI, DirectDeps);
450 for (
const auto &KV : DirectPrebuiltModularDeps)
453 llvm::SmallDenseSet<const FileEntry *, 16> SeenModuleMapFiles;
459 SeenModuleMapFiles, *CurrentModuleMap,
460 CurrentModuleMap->getNameAsRequested(),
464 SeenModuleMapFiles, DirectDeps);
472 bool AnyRelative =
false;
474 assert(!AnyRelative &&
"Continuing path visitation despite relative path");
475 AnyRelative |= !Path.empty() && !llvm::sys::path::is_absolute(Path);
483 bool EagerLoadModules,
484 llvm::vfs::FileSystem &
VFS) {
485 llvm::HashBuilder<llvm::TruncatedBLAKE3<16>, llvm::endianness::native>
492 llvm::ErrorOr<std::string> CWD =
VFS.getCurrentWorkingDirectory();
494 HashBuilder.add(*CWD);
498 ArgVec.reserve(4096);
500 Arg.toVector(ArgVec);
501 ArgVec.push_back(
'\0');
503 HashBuilder.add(ArgVec);
511 HashBuilder.add(ID.ModuleName);
512 HashBuilder.add(ID.ContextHash);
515 HashBuilder.add(EagerLoadModules);
517 llvm::BLAKE3Result<16> Hash = HashBuilder.final();
518 std::array<uint64_t, 2> Words;
519 static_assert(
sizeof(Hash) ==
sizeof(Words),
"Hash must match Words");
520 std::memcpy(Words.data(), Hash.data(),
sizeof(Hash));
521 return toString(llvm::APInt(
sizeof(Words) * 8, Words), 36,
false);
524void ModuleDepCollector::associateWithContextHash(
525 const CowCompilerInvocation &CI,
ModuleDeps &Deps) {
528 ScanInstance.getVirtualFileSystem());
529 bool Inserted = ModuleDepsByID.insert({Deps.
ID, &Deps}).second;
531 assert(Inserted &&
"duplicate module mapping");
555 MDC.addFileDep(llvm::sys::path::remove_leading_dotslash(*Filename));
562 MDC.addFileDep(
File->getName());
569 StringRef RelativePath,
const Module *SuggestedModule,
572 if (!
File && !ModuleImported) {
577 if (ModuleImported && SuggestedModule &&
578 MDC.ScanInstance.getPreprocessorOpts()
579 .DependencyScanningModuleMapImports)
581 MDC.handleImport(SuggestedModule);
585 const Module *Imported)
override {
586 auto &PP = MDC.ScanInstance.getPreprocessor();
587 if (PP.getLangOpts().CPlusPlusModules && PP.isImportingCXXNamedModules()) {
588 MDC.addRequiredStdCXXModule(Path[0].getIdentifierInfo()->getName());
592 MDC.handleImport(Imported);
596void ModuleDepCollector::addRequiredStdCXXModule(StringRef ModuleName) {
597 if (llvm::any_of(RequiredStdCXXModules,
599 return RequiredModule.
ModuleName == ModuleName;
606 RequiredStdCXXModules.push_back(std::move(RequiredModule));
609void ModuleDepCollector::handleImport(
const Module *Imported) {
620 MDC.ScanInstance.getASTReader()->getModuleManager().lookup(*MFKey);
622 if (MDC.isPrebuiltModule(MF))
625 MDC.DirectModularDeps.insert(MF);
626 MDC.DirectImports.insert(Imported);
633 FileID MainFileID = MDC.ScanInstance.getSourceManager().getMainFileID();
634 MDC.MainFile = std::string(MDC.ScanInstance.getSourceManager()
635 .getFileEntryRefForID(MainFileID)
638 auto &PP = MDC.ScanInstance.getPreprocessor();
639 if (PP.isInNamedModule()) {
641 ProvidedModule.
ModuleName = PP.getNamedModuleName();
647 if (PP.isInImplementationUnit())
648 MDC.addRequiredStdCXXModule(ProvidedModule.
ModuleName);
650 MDC.ProvidedStdCXXModule = ProvidedModule;
653 if (!MDC.ScanInstance.getPreprocessorOpts().ImplicitPCHInclude.empty())
654 MDC.addFileDep(MDC.ScanInstance.getPreprocessorOpts().ImplicitPCHInclude);
656 for (StringRef
VFS : MDC.ScanInstance.getHeaderSearchOpts().VFSOverlayFiles)
659 if (
Module *CurrentModule = PP.getCurrentModuleImplementation()) {
661 PP.getHeaderSearchInfo().getModuleMap().getModuleMapFileForUniquing(
663 MDC.addFileDep(CurrentModuleMap->getName());
667 MDC.ScanInstance.getPreprocessor().getAffectingClangModules()) {
669 MDC.ScanInstance.getASTReader()->getModuleManager().lookup(
670 *M->getASTFileKey());
671 if (!MDC.isPrebuiltModule(MF))
672 MDC.DirectModularDeps.insert(MF);
675 if (MDC.Service.getOpts().ReportVisibleModules)
676 MDC.addVisibleModules();
679 handleTopLevelModule(MF);
682 MDC.ScanInstance.getInvocation().computeContextHash());
687 MDC.RequiredStdCXXModules);
689 for (
auto &&I : MDC.ModularDeps)
693 auto It = MDC.ModularDeps.find(MF);
695 if (It != MDC.ModularDeps.end())
699 for (
auto &&I : MDC.VisibleModules)
702 for (
auto &&I : MDC.FileDeps)
705 for (
auto &&I : MDC.DirectPrebuiltModularDeps)
714 Storage.assign(Path.begin(), Path.end());
716 return StringRef(Storage.data(), Storage.size());
719std::optional<ModuleID>
720ModuleDepCollector::handleTopLevelModule(serialization::ModuleFile *MF) {
724 if (
auto ModI = MDC.ModularDeps.find(MF); ModI != MDC.ModularDeps.end())
725 return ModI->second->ID;
727 Module *M = MDC.ScanInstance.getPreprocessor()
728 .getHeaderSearchInfo()
732 "ModuleFile without top-level Module");
734 auto OwnedMD = std::make_unique<ModuleDeps>();
735 ModuleDeps &MD = *OwnedMD;
750 ModuleMap &ModMapInfo =
751 MDC.ScanInstance.getPreprocessor().getHeaderSearchInfo().getModuleMap();
755 if (CurrentModuleMapEntry) {
761 llvm::SmallString<256>
Storage;
764 MDC.ScanInstance.getASTReader()->visitInputFileInfos(
766 [&](
const serialization::InputFileInfo &IFI,
bool IsSystem) {
777 addAllModuleDeps(*MF, MD);
780 llvm::SmallDenseSet<const FileEntry *, 16> SeenModuleMapFiles;
784 SmallString<0> PathBuf;
785 PathBuf.reserve(256);
786 MDC.ScanInstance.getASTReader()->visitInputFileInfos(
788 [&](
const serialization::InputFileInfo &IFI,
bool IsSystem) {
798 "__inferred_module.map"))
804 auto ModuleMapEntry =
805 MDC.ScanInstance.getFileManager().getOptionalFileRef(
806 *ResolvedFilenameAsRequested);
807 assert(ModuleMapEntry &&
"module map file entry not found");
813 if (CurrentModuleMapEntry && *ModuleMapEntry == *CurrentModuleMapEntry)
822 *ModuleMapEntry, *ResolvedFilenameAsRequested,
829 CowCompilerInvocation CI =
830 MDC.getInvocationAdjustedForModuleBuildWithoutOutputs(
831 MD, [&](CowCompilerInvocation &BuildInvocation) {
832 if (
any(MDC.Service.getOpts().OptimizeArgs &
836 *MDC.ScanInstance.getASTReader(), *MF,
837 MDC.PrebuiltModulesASTMap,
838 MDC.Service.getOpts().OptimizeArgs);
840 if (
any(MDC.Service.getOpts().OptimizeArgs &
850 llvm::ErrorOr<std::string> CWD =
851 MDC.ScanInstance.getVirtualFileSystem()
852 .getCurrentWorkingDirectory();
859 (void)MDC.Controller.finalizeModuleInvocation(MDC.ScanInstance, CI, MD);
868 MDC.associateWithContextHash(CI, MD);
871 MDC.addOutputPaths(CI, MD);
873 MD.BuildInfo = std::move(CI);
875 MDC.ModularDeps.insert({MF, std::move(OwnedMD)});
880void ModuleDepCollector::addAllModuleDeps(serialization::ModuleFile &MF,
884 llvm::DenseSet<const Module *> Seen;
885 for (serialization::ModuleFile *Import : MF.
Imports) {
886 if (MDC.isPrebuiltModule(Import)) {
889 auto It = MDC.PrebuiltModulesASTMap.find(
892 It != MDC.PrebuiltModulesASTMap.end() && It->second.isInStableDir();
895 if (
auto ID = handleTopLevelModule(Import)) {
899 MDC.ModularDeps[
Import]->IsInStableDirectories;
907 std::unique_ptr<DependencyOutputOptions> Opts,
912 : Service(Service), ScanInstance(ScanInstance), Controller(Controller),
913 PrebuiltModulesASTMap(
std::move(PrebuiltModulesASTMap)),
914 StableDirs(StableDirs), Opts(
std::move(Opts)),
919 auto CollectorPP = std::make_unique<ModuleDepCollectorPP>(*
this);
920 CollectorPPPtr = CollectorPP.get();
927 const auto &PrebuiltModuleFiles =
929 auto PrebuiltModuleFileIt = PrebuiltModuleFiles.find(MF->
ModuleName);
930 if (PrebuiltModuleFileIt == PrebuiltModuleFiles.end())
932 assert(
"Prebuilt module came from the expected AST file" &&
933 PrebuiltModuleFileIt->second == MF->
FileName.
str());
937void ModuleDepCollector::addVisibleModules() {
938 llvm::DenseSet<const Module *> ImportedModules;
939 auto InsertVisibleModules = [&](
const Module *M) {
940 if (ImportedModules.contains(M))
946 while (!Stack.empty()) {
947 const Module *CurrModule = Stack.pop_back_val();
948 if (ImportedModules.contains(CurrModule))
950 ImportedModules.insert(CurrModule);
956 for (
const Module *Import : DirectImports)
957 InsertVisibleModules(Import);
960void ModuleDepCollector::addFileDep(StringRef Path) {
961 if (!Service.getOpts().ReportAbsolutePaths) {
962 FileDeps.emplace_back(Path);
966 llvm::SmallString<256>
Storage;
968 FileDeps.emplace_back(Path);
971void ModuleDepCollector::addFileDep(
ModuleDeps &MD, StringRef Path) {
972 MD.FileDeps.emplace_back(Path);
Result
Implement __builtin_bit_cast and related operations.
static std::vector< std::string > splitString(std::string S, char Separator)
static std::string getModuleContextHash(const ModuleDeps &MD, const CowCompilerInvocation &CI, bool EagerLoadModules, llvm::vfs::FileSystem &VFS)
static PrebuiltModuleDep createPrebuiltModuleDep(const serialization::ModuleFile *MF)
static void optimizeHeaderSearchOpts(HeaderSearchOptions &Opts, ASTReader &Reader, const serialization::ModuleFile &MF, const PrebuiltModulesAttrsMap &PrebuiltModulesASTMap, ScanningOptimizations OptimizeArgs)
static void optimizeDiagnosticOpts(DiagnosticOptions &Opts, bool IsSystemModule)
static void collectModuleMap(std::vector< std::string > &ModuleMapFiles, llvm::SmallDenseSet< const FileEntry *, 16 > &SeenModuleMapFiles, FileEntryRef ModuleMapFile, StringRef Path, const bool Report)
static CowCompilerInvocation makeCommonInvocationForModuleBuild(CompilerInvocation CI)
static bool needsModules(FrontendInputFile FIF)
static bool isSafeToIgnoreCWD(const CowCompilerInvocation &CI)
static void optimizeCWD(CowCompilerInvocation &BuildInvocation, StringRef CWD)
static StringRef makeAbsoluteAndCanonicalize(CompilerInstance &CI, StringRef Path, SmallVectorImpl< char > &Storage)
Defines the clang::Preprocessor interface.
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
Callback that records textual includes and direct modular includes/imports during preprocessing.
void HasInclude(SourceLocation Loc, StringRef FileName, bool IsAngled, OptionalFileEntryRef File, SrcMgr::CharacteristicKind FileType) override
Hook called when a '__has_include' or '__has_include_next' directive is read.
void moduleImport(SourceLocation ImportLoc, ModuleIdPath Path, const Module *Imported) override
Callback invoked whenever there was an explicit module-import syntax.
void LexedFileChanged(FileID FID, LexedFileChangeReason Reason, SrcMgr::CharacteristicKind FileType, FileID PrevFID, SourceLocation Loc) override
Callback invoked whenever the Lexer moves to a different file for lexing.
ModuleDepCollectorPP(ModuleDepCollector &MDC)
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, OptionalFileEntryRef File, StringRef SearchPath, StringRef RelativePath, const Module *SuggestedModule, bool ModuleImported, SrcMgr::CharacteristicKind FileType) override
Callback invoked whenever an inclusion directive of any kind (#include, #import, etc....
Reads an AST files chain containing the contents of a translation unit.
static TemporarilyOwnedStringRef ResolveImportedPath(SmallString< 0 > &Buf, StringRef Path, ModuleFile &ModF)
Resolve Path in the context of module file M.
Represents a byte-granular source range.
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
std::string CoverageNotesFile
The filename with path we use for coverage notes files.
std::string ProfileInstrumentUsePath
Name of the profile file to use as input for -fprofile-instr-use.
std::string SampleProfileFile
Name of the profile file to use with -fprofile-sample-use.
std::string CoverageDataFile
The filename with path we use for coverage data files.
std::string DebugCompilationDir
The string to embed in debug information as the current working directory.
std::string MainFileName
The user provided name for the "main file", if non-empty.
std::string CoverageCompilationDir
The string to embed in coverage mapping as the current working directory.
std::string ProfileRemappingFile
Name of the profile remapping file to apply to the profile data supplied by -fprofile-sample-use or -...
const char * Argv0
Executable and command-line used to create a given CompilerInvocation.
std::vector< std::string > CommandLineArgs
std::string DwarfDebugFlags
The string to embed in the debug information for the compile unit, if non-empty.
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
FileManager & getFileManager() const
Return the current file manager to the caller.
HeaderSearchOptions & getHeaderSearchOpts()
const FrontendOptions & getFrontendOpts() const
void generateCC1CommandLine(llvm::SmallVectorImpl< const char * > &Args, StringAllocator SA) const
Generate cc1-compatible command line arguments from this instance.
const DependencyOutputOptions & getDependencyOutputOpts() const
const HeaderSearchOptions & getHeaderSearchOpts() const
const DiagnosticOptions & getDiagnosticOpts() const
Helper class for holding the data necessary to invoke the compiler.
PreprocessorOptions & getPreprocessorOpts()
void clearImplicitModuleBuildOptions()
Disable implicit modules and canonicalize options that are only used by implicit modules.
LangOptions & getLangOpts()
Mutable getters.
DependencyOutputOptions & getDependencyOutputOpts()
void resetNonModularOptions()
Reset all of the options that are not considered when building a module.
FrontendOptions & getFrontendOpts()
CodeGenOptions & getCodeGenOpts()
HeaderSearchOptions & getHeaderSearchOpts()
DiagnosticOptions & getDiagnosticOpts()
Same as CompilerInvocation, but with copy-on-write optimization.
FrontendOptions & getMutFrontendOpts()
LangOptions & getMutLangOpts()
Mutable getters.
HeaderSearchOptions & getMutHeaderSearchOpts()
CodeGenOptions & getMutCodeGenOpts()
FileSystemOptions & getMutFileSystemOpts()
DiagnosticOptions & getMutDiagnosticOpts()
DependencyOutputOptions & getMutDependencyOutputOpts()
void visitPaths(llvm::function_ref< VisitConstResult(StringRef)> Cb) const
Visits paths stored in the invocation.
std::string OutputFile
The file to write dependency output to.
std::vector< std::string > Targets
A list of names to use as the targets in the dependency file; this list must contain at least one ent...
unsigned IncludeModuleFiles
Include module file dependencies.
Options for controlling the compiler diagnostics engine.
std::vector< std::string > Remarks
The list of -R... options used to alter the diagnostic mappings, with the prefixes removed.
std::vector< std::string > Warnings
The list of -W... options used to alter the diagnostic mappings, with the prefixes removed.
std::vector< std::string > UndefPrefixes
The list of prefixes from -Wundef-prefix=... used to generate warnings for undefined macros.
std::vector< std::string > SystemHeaderWarningsModules
The list of -Wsystem-headers-in-module=... options used to override whether -Wsystem-headers is enabl...
std::string DiagnosticSerializationFile
The file to serialize diagnostics to (non-appending).
A reference to a FileEntry that includes the name of the file as it was accessed by the FileManager's...
StringRef getNameAsRequested() const
The name of this FileEntry, as originally requested without applying any remappings for VFS 'use-exte...
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
bool makeAbsolutePath(SmallVectorImpl< char > &Path, bool Canonicalize=false) const
Makes Path absolute taking into account FileSystemOptions and the working directory option,...
std::string WorkingDir
If set, paths are resolved as if the working directory was set to the value of WorkingDir.
InputKind DashX
The input kind, either specified via -x argument or deduced from the input file name.
std::vector< std::string > ModuleFiles
The list of additional prebuilt module files to load before processing the input.
unsigned IsSystemModule
When using -emit-module, treat the modulemap as a system module.
std::vector< std::string > LLVMArgs
A list of arguments to forward to LLVM's option processing; this should only be used for debugging an...
std::string OutputFile
The output file, if any.
unsigned GenReducedBMI
Whether to generate reduced BMI for C++20 named modules.
std::string ModuleOutputPath
Output Path for module output file.
SmallVector< FrontendInputFile, 0 > Inputs
The input files and their types.
frontend::ActionKind ProgramAction
The frontend action to perform.
std::vector< std::string > ModuleMapFiles
The list of module map files to load before processing the input.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
std::string ModuleName
The module currently being compiled as specified by -fmodule-name.
Deduplication key for a loaded module file in ModuleManager.
StringRef str() const
Returns the plain module file name.
OptionalFileEntryRef getModuleMapFileForUniquing(const Module *M) const
std::error_code canonicalizeModuleMapPath(SmallVectorImpl< char > &Path)
Canonicalize Path in a manner suitable for a module map file.
Describes a module or submodule.
StringRef getTopLevelModuleName() const
Retrieve the name of the top-level module.
const ModuleFileKey * getASTFileKey() const
The serialized AST file key for this module, if one was created.
unsigned IsSystem
Whether this is a "system" module (which assumes that all headers in it are system headers).
llvm::SmallVector< LinkLibrary, 2 > LinkLibraries
The set of libraries or frameworks to link against when an entity from this module is used.
void getExportedModules(SmallVectorImpl< Module * > &Exported) const
Appends this module's list of exported modules to Exported.
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
Module * getTopLevelModule()
Retrieve the top-level module for this (sub)module, which may be this module.
bool UseExportAsModuleLinkName
Autolinking uses the framework name for linking purposes when this is false and the export_as name ot...
This interface provides a way to observe the actions of the preprocessor as it does its thing.
std::vector< std::pair< std::string, bool > > Macros
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
void addPPCallbacks(std::unique_ptr< PPCallbacks > C)
Module * getCurrentModuleImplementation()
Retrieves the module whose implementation we're current compiling, if any.
HeaderSearch & getHeaderSearchInfo() const
Encodes a location in the source.
This class handles loading and caching of source files into memory.
std::optional< StringRef > getNonBuiltinFilenameForID(FileID FID) const
Returns the filename for the provided FileID, unless it's a built-in buffer that's not represented by...
Token - This structure provides full information about a lexed token.
Dependency scanner callbacks that are used during scanning to influence the behaviour of the scan - f...
virtual void handleFileDependency(StringRef Filename)=0
virtual void handleDependencyOutputOpts(const DependencyOutputOptions &Opts)=0
virtual void handleModuleDependency(ModuleDeps MD)=0
virtual void handleVisibleModule(std::string ModuleName)=0
virtual void handlePrebuiltModuleDependency(PrebuiltModuleDep PMD)=0
virtual void handleDirectModuleDependency(ModuleID MD)=0
virtual void handleContextHash(std::string Hash)=0
virtual void handleProvidedAndRequiredStdCXXModules(std::optional< P1689ModuleInfo > Provided, std::vector< P1689ModuleInfo > Requires)
The dependency scanning service contains shared configuration and state that is used by the individua...
void run(DependencyConsumer &Consumer)
Processes the accumulated dependency information and reports it to the Consumer.
ModuleDepCollector(DependencyScanningService &Service, std::unique_ptr< DependencyOutputOptions > Opts, CompilerInstance &ScanInstance, DependencyActionController &Controller, CompilerInvocation OriginalCI, const PrebuiltModulesAttrsMap PrebuiltModulesASTMap, const ArrayRef< StringRef > StableDirs)
void applyDiscoveredDependencies(CompilerInvocation &CI)
Apply any changes implied by the discovered dependencies to the given invocation, (e....
void attachToPreprocessor(Preprocessor &PP) override
void attachToASTReader(ASTReader &R) override
void updateDependentsNotInStableDirs(PrebuiltModulesAttrsMap &PrebuiltModulesMap)
When a module is discovered to not be in stable directories, traverse & update all modules that depen...
bool isInStableDir() const
Read-only access to whether the module is made up of dependencies in stable directories.
void setInStableDir(bool V=false)
Update whether the prebuilt module resolves entirely in a stable directories.
Information about a module that has been loaded by the ASTReader.
std::vector< std::string > DirectoryDependencies
Directories this module file depends on the listing of.
llvm::SetVector< ModuleFile * > Imports
List of modules which this module directly imported.
std::string ModuleMapPath
llvm::BitVector SearchPathUsage
The bit vector denoting usage of each header search entry (true = used).
ModuleFileName FileName
The file name of the module file.
llvm::BitVector VFSUsage
The bit vector denoting usage of each VFS entry (true = used).
ModuleKind Kind
The type of this module.
std::string ModuleName
The name of the module.
std::string BaseDirectory
The base directory of the module.
CharacteristicKind
Indicates whether a file or directory holds normal user code, system code, or system code which is im...
bool areOptionsInStableDir(const ArrayRef< StringRef > Directories, const HeaderSearchOptions &HSOpts)
Determine if options collected from a module's compilation can safely be considered as stable.
@ 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.
@ DiagnosticSerializationFile
The path of the serialized diagnostic file (.dia), if any.
@ DependencyFile
The path of the dependency file (.d), if any.
@ DependencyTargets
The null-separated list of names to use as the targets in the dependency file, if any.
@ ModuleFile
The module file (.pcm). Required.
llvm::StringMap< PrebuiltModuleASTAttrs > PrebuiltModulesAttrsMap
Attributes loaded from AST files of prebuilt modules collected prior to ModuleDepCollector creation.
bool isPathInStableDir(const ArrayRef< StringRef > Directories, const StringRef Input)
Determine if Input can be resolved within a stable directory.
void resetBenignCodeGenOptions(frontend::ActionKind ProgramAction, const LangOptions &LangOpts, CodeGenOptions &CGOpts)
Resets codegen options that don't affect modules/PCH.
@ GeneratePCH
Generate pre-compiled header.
@ GenerateModule
Generate pre-compiled module from a module map.
const unsigned VERSION_MINOR
AST file minor version number supported by this version of Clang.
const unsigned VERSION_MAJOR
AST file major version number supported by this version of Clang.
@ MK_ImplicitModule
File is an implicitly-loaded module.
Top level wrappers for InstallAPI frontend operations.
CustomizableOptional< FileEntryRef > OptionalFileEntryRef
void quoteMakeTarget(StringRef Target, SmallVectorImpl< char > &Res)
Quote target names for inclusion in GNU Make dependency files.
ArrayRef< IdentifierLoc > ModuleIdPath
A sequence of identifier/location pairs used to describe a particular module or submodule,...
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
@ Asm
Assembly: we accept this only so that we can preprocess it.
@ MFDK_Direct
Include only directly imported module file dependencies.
std::string getClangFullRepositoryVersion()
Retrieves the full repository version that is an amalgamation of the information in getClangRepositor...
int const char * function
int __ovld __cnfn any(char)
Returns 1 if the most significant bit in any component of x is set; otherwise returns 0.
The result of const visitation.
std::vector< std::string > ModuleMapFileDeps
A collection of absolute paths to module map files that this module needs to know about.
bool IsInStableDirectories
Whether this module is fully composed of file & module inputs from locations likely to stay the same ...
ModuleID ID
The identifier of the module.
std::vector< std::string > DirectoryDeps
Absolute paths to directories this module depends on the listing of, including their subdirectories.
bool IgnoreCWD
Whether current working directory is ignored.
std::vector< PrebuiltModuleDep > PrebuiltModuleDeps
A collection of prebuilt modular dependencies this module directly depends on, not including transiti...
llvm::SmallVector< Module::LinkLibrary, 2 > LinkLibraries
The set of libraries or frameworks to link against when an entity from this module is used.
std::vector< ModuleID > ClangModuleDeps
A list of module identifiers this module directly depends on, not including transitive dependencies.
std::string ClangModuleMapFile
The path to the modulemap file which defines this module.
bool IsSystem
Whether this is a "system" module.
std::string ModuleName
The name of the module.
std::string ContextHash
The context hash of a module represents the compiler options that affect the resulting command-line i...
P1689ModuleInfo - Represents the needed information of standard C++20 modules for P1689 format.
bool IsStdCXXModuleInterface
If this module is a standard c++ interface unit.
std::string ModuleName
The name of the module. This may include : for partitions.
Modular dependency that has already been built prior to the dependency scan.
std::string ModuleMapFile