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)
282 [&CI](
const std::pair<std::string, bool> &Def) {
283 StringRef MacroDef = Def.first;
284 return CI.getHeaderSearchOpts().ModulesIgnoreMacros.contains(
285 llvm::CachedHashString(MacroDef.split(
'=').first));
295ModuleDepCollector::getInvocationAdjustedForModuleBuildWithoutOutputs(
297 llvm::function_ref<
void(CowCompilerInvocation &)> Optimize)
const {
298 CowCompilerInvocation CI = CommonInvocation;
309 auto CurrentModuleMapEntry =
311 assert(CurrentModuleMapEntry &&
"module map file entry not found");
320 auto ModuleMapEntry =
321 ScanInstance.getFileManager().getOptionalFileRef(ModuleMapFile);
322 assert(ModuleMapEntry &&
"module map file entry not found");
329 if (Service.getOpts().EagerLoadModules &&
330 DepModuleMapFiles.contains(*ModuleMapEntry))
335 if (*ModuleMapEntry == *CurrentModuleMapEntry &&
336 !DepModuleMapFiles.contains(*ModuleMapEntry))
363llvm::DenseSet<const FileEntry *> ModuleDepCollector::collectModuleMapFiles(
364 ArrayRef<ModuleID> ClangModuleDeps)
const {
365 llvm::DenseSet<const FileEntry *> ModuleMapFiles;
366 for (
const ModuleID &MID : ClangModuleDeps) {
367 ModuleDeps *MD = ModuleDepsByID.lookup(MID);
368 assert(MD &&
"Inconsistent dependency info");
370 auto FE = ScanInstance.getFileManager().getOptionalFileRef(
372 assert(FE &&
"Missing module map file that was previously found");
373 ModuleMapFiles.insert(*FE);
375 return ModuleMapFiles;
378void ModuleDepCollector::addModuleMapFiles(
379 CompilerInvocation &CI, ArrayRef<ModuleID> ClangModuleDeps)
const {
380 if (Service.getOpts().EagerLoadModules)
383 for (
const ModuleID &MID : ClangModuleDeps) {
384 ModuleDeps *MD = ModuleDepsByID.lookup(MID);
385 assert(MD &&
"Inconsistent dependency info");
390void ModuleDepCollector::addModuleFiles(
391 CompilerInvocation &CI, ArrayRef<ModuleID> ClangModuleDeps)
const {
392 for (
const ModuleID &MID : ClangModuleDeps) {
393 ModuleDeps *MD = ModuleDepsByID.lookup(MID);
394 std::string PCMPath =
397 if (Service.getOpts().EagerLoadModules)
401 {MID.ModuleName, std::move(PCMPath)});
405void ModuleDepCollector::addModuleFiles(
406 CowCompilerInvocation &CI, ArrayRef<ModuleID> ClangModuleDeps)
const {
407 for (
const ModuleID &MID : ClangModuleDeps) {
408 ModuleDeps *MD = ModuleDepsByID.lookup(MID);
409 std::string PCMPath =
412 if (Service.getOpts().EagerLoadModules)
416 {MID.ModuleName, std::move(PCMPath)});
445 CurrentModuleMap->getNameAsRequested());
448 for (
const auto &KV : ModularDeps)
449 if (DirectModularDeps.contains(KV.first))
450 DirectDeps.push_back(KV.second->ID);
453 addModuleMapFiles(CI, DirectDeps);
455 addModuleFiles(CI, DirectDeps);
457 for (
const auto &KV : DirectPrebuiltModularDeps)
466 bool AnyRelative =
false;
468 assert(!AnyRelative &&
"Continuing path visitation despite returning true");
469 AnyRelative |= !Path.empty() && !llvm::sys::path::is_absolute(Path);
477 bool EagerLoadModules,
478 llvm::vfs::FileSystem &
VFS) {
479 llvm::HashBuilder<llvm::TruncatedBLAKE3<16>, llvm::endianness::native>
486 llvm::ErrorOr<std::string> CWD =
VFS.getCurrentWorkingDirectory();
488 HashBuilder.add(*CWD);
492 ArgVec.reserve(4096);
494 Arg.toVector(ArgVec);
495 ArgVec.push_back(
'\0');
497 HashBuilder.add(ArgVec);
505 HashBuilder.add(ID.ModuleName);
506 HashBuilder.add(ID.ContextHash);
509 HashBuilder.add(EagerLoadModules);
511 llvm::BLAKE3Result<16> Hash = HashBuilder.final();
512 std::array<uint64_t, 2> Words;
513 static_assert(
sizeof(Hash) ==
sizeof(Words),
"Hash must match Words");
514 std::memcpy(Words.data(), Hash.data(),
sizeof(Hash));
515 return toString(llvm::APInt(
sizeof(Words) * 8, Words), 36,
false);
518void ModuleDepCollector::associateWithContextHash(
519 const CowCompilerInvocation &CI,
ModuleDeps &Deps) {
522 ScanInstance.getVirtualFileSystem());
523 bool Inserted = ModuleDepsByID.insert({Deps.
ID, &Deps}).second;
525 assert(Inserted &&
"duplicate module mapping");
548 if (std::optional<StringRef> Filename =
SM.getNonBuiltinFilenameForID(FID))
549 MDC.addFileDep(llvm::sys::path::remove_leading_dotslash(*Filename));
556 MDC.addFileDep(
File->getName());
563 StringRef RelativePath,
const Module *SuggestedModule,
566 if (!
File && !ModuleImported) {
571 MDC.handleImport(SuggestedModule);
575 const Module *Imported)
override {
576 auto &PP = MDC.ScanInstance.getPreprocessor();
577 if (PP.getLangOpts().CPlusPlusModules && PP.isImportingCXXNamedModules()) {
579 RequiredModule.
ModuleName = Path[0].getIdentifierInfo()->getName().str();
581 MDC.RequiredStdCXXModules.push_back(std::move(RequiredModule));
585 MDC.handleImport(Imported);
589void ModuleDepCollector::handleImport(
const Module *Imported) {
600 MDC.ScanInstance.getASTReader()->getModuleManager().lookup(*MFKey);
602 if (MDC.isPrebuiltModule(MF))
605 MDC.DirectModularDeps.insert(MF);
606 MDC.DirectImports.insert(Imported);
613 FileID MainFileID = MDC.ScanInstance.getSourceManager().getMainFileID();
614 MDC.MainFile = std::string(MDC.ScanInstance.getSourceManager()
615 .getFileEntryRefForID(MainFileID)
618 auto &PP = MDC.ScanInstance.getPreprocessor();
619 if (PP.isInNamedModule()) {
621 ProvidedModule.
ModuleName = PP.getNamedModuleName();
627 if (PP.isInImplementationUnit())
628 MDC.RequiredStdCXXModules.push_back(ProvidedModule);
630 MDC.ProvidedStdCXXModule = ProvidedModule;
633 if (!MDC.ScanInstance.getPreprocessorOpts().ImplicitPCHInclude.empty())
634 MDC.addFileDep(MDC.ScanInstance.getPreprocessorOpts().ImplicitPCHInclude);
636 for (StringRef
VFS : MDC.ScanInstance.getHeaderSearchOpts().VFSOverlayFiles)
639 if (
Module *CurrentModule = PP.getCurrentModuleImplementation()) {
641 PP.getHeaderSearchInfo().getModuleMap().getModuleMapFileForUniquing(
643 MDC.addFileDep(CurrentModuleMap->getName());
647 MDC.ScanInstance.getPreprocessor().getAffectingClangModules()) {
649 MDC.ScanInstance.getASTReader()->getModuleManager().lookup(
650 *M->getASTFileKey());
651 if (!MDC.isPrebuiltModule(MF))
652 MDC.DirectModularDeps.insert(MF);
655 if (MDC.Service.getOpts().ReportVisibleModules)
656 MDC.addVisibleModules();
659 handleTopLevelModule(MF);
662 MDC.ScanInstance.getInvocation().computeContextHash());
667 MDC.RequiredStdCXXModules);
669 for (
auto &&I : MDC.ModularDeps)
673 auto It = MDC.ModularDeps.find(MF);
675 if (It != MDC.ModularDeps.end())
679 for (
auto &&I : MDC.VisibleModules)
682 for (
auto &&I : MDC.FileDeps)
685 for (
auto &&I : MDC.DirectPrebuiltModularDeps)
694 Storage.assign(Path.begin(), Path.end());
696 return StringRef(Storage.data(), Storage.size());
699std::optional<ModuleID>
700ModuleDepCollector::handleTopLevelModule(serialization::ModuleFile *MF) {
704 if (
auto ModI = MDC.ModularDeps.find(MF); ModI != MDC.ModularDeps.end())
705 return ModI->second->ID;
707 Module *M = MDC.ScanInstance.getPreprocessor()
708 .getHeaderSearchInfo()
712 "ModuleFile without top-level Module");
714 auto OwnedMD = std::make_unique<ModuleDeps>();
715 ModuleDeps &MD = *OwnedMD;
730 ModuleMap &ModMapInfo =
731 MDC.ScanInstance.getPreprocessor().getHeaderSearchInfo().getModuleMap();
734 SmallString<128> Path = ModuleMap->getNameAsRequested();
739 llvm::SmallString<256>
Storage;
742 MDC.ScanInstance.getASTReader()->visitInputFileInfos(
744 [&](
const serialization::InputFileInfo &IFI,
bool IsSystem) {
755 addAllModuleDeps(*MF, MD);
757 SmallString<0> PathBuf;
758 PathBuf.reserve(256);
759 MDC.ScanInstance.getASTReader()->visitInputFileInfos(
761 [&](
const serialization::InputFileInfo &IFI,
bool IsSystem) {
771 "__inferred_module.map"))
780 CowCompilerInvocation CI =
781 MDC.getInvocationAdjustedForModuleBuildWithoutOutputs(
782 MD, [&](CowCompilerInvocation &BuildInvocation) {
783 if (
any(MDC.Service.getOpts().OptimizeArgs &
787 *MDC.ScanInstance.getASTReader(), *MF,
788 MDC.PrebuiltModulesASTMap,
789 MDC.Service.getOpts().OptimizeArgs);
791 if (
any(MDC.Service.getOpts().OptimizeArgs &
801 llvm::ErrorOr<std::string> CWD =
802 MDC.ScanInstance.getVirtualFileSystem()
803 .getCurrentWorkingDirectory();
810 (void)MDC.Controller.finalizeModuleInvocation(MDC.ScanInstance, CI, MD);
819 MDC.associateWithContextHash(CI, MD);
822 MDC.addOutputPaths(CI, MD);
824 MD.BuildInfo = std::move(CI);
826 MDC.ModularDeps.insert({MF, std::move(OwnedMD)});
831void ModuleDepCollector::addAllModuleDeps(serialization::ModuleFile &MF,
835 llvm::DenseSet<const Module *> Seen;
836 for (serialization::ModuleFile *Import : MF.
Imports) {
837 if (MDC.isPrebuiltModule(Import)) {
840 auto It = MDC.PrebuiltModulesASTMap.find(
843 It != MDC.PrebuiltModulesASTMap.end() && It->second.isInStableDir();
846 if (
auto ID = handleTopLevelModule(Import)) {
850 MDC.ModularDeps[
Import]->IsInStableDirectories;
858 std::unique_ptr<DependencyOutputOptions> Opts,
863 : Service(Service), ScanInstance(ScanInstance), Controller(Controller),
864 PrebuiltModulesASTMap(
std::move(PrebuiltModulesASTMap)),
865 StableDirs(StableDirs), Opts(
std::move(Opts)),
870 auto CollectorPP = std::make_unique<ModuleDepCollectorPP>(*
this);
871 CollectorPPPtr = CollectorPP.get();
878 const auto &PrebuiltModuleFiles =
880 auto PrebuiltModuleFileIt = PrebuiltModuleFiles.find(MF->
ModuleName);
881 if (PrebuiltModuleFileIt == PrebuiltModuleFiles.end())
883 assert(
"Prebuilt module came from the expected AST file" &&
884 PrebuiltModuleFileIt->second == MF->
FileName.
str());
888void ModuleDepCollector::addVisibleModules() {
889 llvm::DenseSet<const Module *> ImportedModules;
890 auto InsertVisibleModules = [&](
const Module *M) {
891 if (ImportedModules.contains(M))
897 while (!Stack.empty()) {
898 const Module *CurrModule = Stack.pop_back_val();
899 if (ImportedModules.contains(CurrModule))
901 ImportedModules.insert(CurrModule);
907 for (
const Module *Import : DirectImports)
908 InsertVisibleModules(Import);
911void ModuleDepCollector::addFileDep(StringRef Path) {
912 if (!Service.getOpts().ReportAbsolutePaths) {
913 FileDeps.emplace_back(Path);
917 llvm::SmallString<256>
Storage;
919 FileDeps.emplace_back(Path);
922void ModuleDepCollector::addFileDep(
ModuleDeps &MD, StringRef Path) {
923 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 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 -...
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 visitPaths(llvm::function_ref< bool(StringRef)> Callback) const
Visitation.
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()
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).
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.
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.
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.
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.
The JSON file list parser is used to communicate input to InstallAPI.
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.
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.
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