19#include "llvm/ADT/StringExtras.h"
27 bool FromInclude =
false) {
30 if (
auto *LSD = dyn_cast<LinkageSpecDecl>(DC)) {
31 switch (LSD->getLanguage()) {
32 case LinkageSpecLanguageIDs::C:
34 ExternCLoc = LSD->getBeginLoc();
36 case LinkageSpecLanguageIDs::CXX:
42 while (isa<LinkageSpecDecl>(DC) || isa<ExportDecl>(DC))
45 if (!isa<TranslationUnitDecl>(DC)) {
47 ? diag::ext_module_import_not_at_top_level_noop
48 : diag::err_module_import_not_at_top_level_fatal)
50 S.
Diag(cast<Decl>(DC)->getBeginLoc(),
51 diag::note_module_import_not_at_top_level)
54 S.
Diag(ImportLoc, diag::ext_module_import_in_extern_c)
56 S.
Diag(ExternCLoc, diag::note_extern_c_begins_here);
69 for (
auto &Piece : Path) {
72 Name += Piece.first->getName();
86 Module *&FoundPrimaryModuleInterface) {
97 if (FoundPrimaryModuleInterface)
98 return Imported == FoundPrimaryModuleInterface;
114 assert(!FoundPrimaryModuleInterface ||
115 FoundPrimaryModuleInterface == Imported);
116 FoundPrimaryModuleInterface = Imported;
132 bool IsImportingPrimaryModuleInterface =
false) {
134 "'makeTransitiveImportsVisible()' is intended for standard C++ named "
138 Worklist.push_back(Imported);
140 Module *FoundPrimaryModuleInterface =
141 IsImportingPrimaryModuleInterface ? Imported :
nullptr;
143 while (!Worklist.empty()) {
144 Module *Importing = Worklist.pop_back_val();
151 VisibleModules.
setVisible(Importing, ImportLoc);
154 FoundPrimaryModuleInterface))
156 if (!VisibleModules.
isVisible(TransImported))
157 Worklist.push_back(TransImported);
165 PushGlobalModuleFragment(ModuleLoc);
177 TU->setLocalOwningModule(GlobalModule);
183void Sema::HandleStartOfHeaderUnit() {
185 "Header units are only valid for C++20 modules");
190 if (HUName.empty()) {
205 assert(F &&
"failed to find the header unit source?");
208 Module *Mod = Map.createHeaderUnit(StartOfTU, HUName, H);
209 assert(Mod &&
"module creation should not fail");
210 ModuleScopes.push_back({});
211 ModuleScopes.back().BeginLoc = StartOfTU;
212 ModuleScopes.back().Module = Mod;
219 TU->setLocalOwningModule(Mod);
233 if (II->
isStr(
"module") || II->
isStr(
"import"))
249 return S.
Diag(
Loc, diag::err_invalid_module_name) << II;
251 S.
Diag(
Loc, diag::warn_reserved_module_name) << II;
254 llvm_unreachable(
"fell off a fully covered switch");
262 "should only have module decl in standard C++ modules");
270 bool IsPartition = !Partition.empty();
280 llvm_unreachable(
"how did we get a partition type set?");
299 Diag(ModuleLoc, diag::err_module_interface_implementation_mismatch)
305 Diag(ModuleLoc, diag::err_module_decl_in_module_map_module);
309 Diag(ModuleLoc, diag::err_module_decl_in_header_unit);
313 assert(ModuleScopes.size() <= 1 &&
"expected to be at global module scope");
319 if (isCurrentModulePurview()) {
320 Diag(ModuleLoc, diag::err_module_redeclaration);
322 diag::note_prev_module_declaration);
327 SeenGMF == (
bool)this->TheGlobalModuleFragment) &&
328 "mismatched global module state");
332 if (
getLangOpts().CPlusPlusModules && !IsFirstDecl && !SeenGMF) {
333 Diag(ModuleLoc, diag::err_module_decl_not_at_start);
337 : ModuleScopes.back().BeginLoc;
339 Diag(BeginLoc, diag::note_global_module_introducer_missing)
353 StringRef FirstComponentName = Path[0].first->getName();
355 (FirstComponentName ==
"std" ||
356 (FirstComponentName.starts_with(
"std") &&
357 llvm::all_of(FirstComponentName.drop_front(3), &llvm::isDigit))))
358 Diag(Path[0].second, diag::warn_reserved_module_name) << Path[0].first;
362 for (
auto Part : Path) {
379 Diag(Path.front().second, diag::err_current_module_name_mismatch)
381 ? Partition.back().second
382 : Path.back().second)
396 if (
auto *M = Map.findModule(ModuleName)) {
397 Diag(Path[0].second, diag::err_module_redefinition) << ModuleName;
398 if (M->DefinitionLoc.isValid())
399 Diag(M->DefinitionLoc, diag::note_prev_module_definition);
401 Diag(M->DefinitionLoc, diag::note_prev_module_definition_from_ast_file)
408 Mod = Map.createModuleForInterfaceUnit(ModuleLoc, ModuleName);
411 assert(Mod &&
"module creation should not fail");
420 std::pair<IdentifierInfo *, SourceLocation> ModuleNameLoc(
434 Diag(ModuleLoc, diag::err_module_not_defined) << ModuleName;
436 Mod = Map.createModuleForInterfaceUnit(ModuleLoc, ModuleName);
438 Mod = Map.createModuleForImplementationUnit(ModuleLoc, ModuleName);
445 Mod = Map.createModuleForInterfaceUnit(ModuleLoc, ModuleName);
450 if (!this->TheGlobalModuleFragment) {
451 ModuleScopes.push_back({});
453 ModuleScopes.back().OuterVisibleModules = std::move(VisibleModules);
460 ModuleScopes.back().BeginLoc = StartLoc;
461 ModuleScopes.back().Module = Mod;
471 TU->setLocalOwningModule(Mod);
480 Listener->EnteringModulePurview();
516 : ModuleScopes.back().Module->Kind) {
523 Diag(PrivateLoc, diag::err_private_module_fragment_not_module);
527 Diag(PrivateLoc, diag::err_private_module_fragment_redefined);
528 Diag(ModuleScopes.back().BeginLoc, diag::note_previous_definition);
532 Diag(PrivateLoc, diag::err_private_module_fragment_not_module_interface);
533 Diag(ModuleScopes.back().BeginLoc,
534 diag::note_not_module_interface_add_export)
550 Module *PrivateModuleFragment =
551 Map.createPrivateModuleFragmentForInterfaceUnit(
552 ModuleScopes.back().Module, PrivateLoc);
553 assert(PrivateModuleFragment &&
"module creation should not fail");
556 ModuleScopes.push_back({});
557 ModuleScopes.back().BeginLoc = ModuleLoc;
558 ModuleScopes.back().Module = PrivateModuleFragment;
559 VisibleModules.
setVisible(PrivateModuleFragment, ModuleLoc);
566 TU->setLocalOwningModule(PrivateModuleFragment);
576 assert((!IsPartition ||
getLangOpts().CPlusPlusModules) &&
577 "partition seen in non-C++20 code?");
581 std::pair<IdentifierInfo *, SourceLocation> ModuleNameLoc;
583 std::string ModuleName;
586 assert(!ModuleScopes.empty() &&
"in a module purview, but no module?");
587 Module *NamedMod = ModuleScopes.back().Module;
608 if (
getLangOpts().CPlusPlusModules && isCurrentModulePurview() &&
610 Diag(ImportLoc, diag::err_module_self_import_cxx20)
622 Diag(ImportLoc, diag::err_module_import_non_interface_nor_parition)
633 if (
auto *ED = dyn_cast<ExportDecl>(DC))
643 Diag(ImportLoc, diag::warn_experimental_header_unit);
659 ? diag::err_module_self_import
660 : diag::err_module_import_in_implementation)
670 for (
Module *ModCheck = Mod; ModCheck; ModCheck = ModCheck->
Parent)
674 IdentifierLocs.push_back(Path[0].second);
677 for (
unsigned I = 0, N = Path.size(); I != N; ++I) {
682 ModCheck = ModCheck->
Parent;
684 IdentifierLocs.push_back(Path[I].second);
689 Mod, IdentifierLocs);
694 if (!ModuleScopes.empty())
700 Diag(ExportLoc, diag::err_export_partition_impl)
710 }
else if (ExportLoc.
isValid()) {
714 Diag(ExportLoc, diag::err_export_not_in_module_interface);
731 bool IsInModuleIncludes =
737 if (
getLangOpts().Modules && !IsInModuleIncludes) {
742 if (!ModuleScopes.empty())
753 getLangOpts().CurrentModule, DirectiveLoc,
false,
false);
755 assert(ThisModule &&
"was expecting a module if building one");
762 ModuleScopes.push_back({});
763 ModuleScopes.back().Module = Mod;
765 ModuleScopes.back().OuterVisibleModules = std::move(VisibleModules);
774 cast<Decl>(DC)->setModuleOwnershipKind(
778 cast<Decl>(DC)->setLocalOwningModule(Mod);
785 VisibleModules = std::move(ModuleScopes.back().OuterVisibleModules);
791 assert(!ModuleScopes.empty() && ModuleScopes.back().Module == Mod &&
792 "left the wrong module scope");
793 ModuleScopes.pop_back();
802 "end of submodule in main source file");
806 DirectiveLoc = EomLoc;
817 cast<Decl>(DC)->setModuleOwnershipKind(
858 if (!isCurrentModulePurview()) {
859 Diag(ExportLoc, diag::err_export_not_in_module_interface) << 0;
863 Diag(ExportLoc, diag::err_export_not_in_module_interface) << 1;
864 Diag(ModuleScopes.back().BeginLoc,
865 diag::note_not_module_interface_add_export)
869 }
else if (ModuleScopes.back().Module->Kind ==
871 Diag(ExportLoc, diag::err_export_in_private_module_fragment);
872 Diag(ModuleScopes.back().BeginLoc, diag::note_private_module_fragment);
878 if (
const auto *ND = dyn_cast<NamespaceDecl>(DC)) {
881 if (ND->isAnonymousNamespace()) {
882 Diag(ExportLoc, diag::err_export_within_anonymous_namespace);
883 Diag(ND->getLocation(), diag::note_anonymous_namespace);
894 if (!DeferredExportedNamespaces.insert(ND).second)
902 Diag(ExportLoc, diag::err_export_within_export);
904 Diag(ED->getLocation(), diag::note_export);
918 bool AllUnnamed =
true;
919 for (
auto *D : DC->
decls())
929 bool HasName =
false;
930 if (
auto *ND = dyn_cast<NamedDecl>(D)) {
933 HasName = (
bool)ND->getDeclName();
935 S.
Diag(ND->getLocation(), diag::err_export_internal) << ND;
937 S.
Diag(BlockStart, diag::note_export);
945 if (
auto *USD = dyn_cast<UsingShadowDecl>(D)) {
949 S.
Diag(USD->getLocation(), diag::err_export_using_internal)
951 S.
Diag(
Target->getLocation(), diag::note_using_decl_target);
953 S.
Diag(BlockStart, diag::note_export);
960 if (
auto *DC = dyn_cast<DeclContext>(D)) {
961 if (!isa<NamespaceDecl>(D))
964 if (
auto *ND = dyn_cast<NamedDecl>(D)) {
965 if (!ND->getDeclName()) {
966 S.
Diag(ND->getLocation(), diag::err_export_anon_ns_internal);
968 S.
Diag(BlockStart, diag::note_export);
970 }
else if (!DC->decls().empty() &&
971 DC->getRedeclContext()->isFileContext()) {
981 auto *ED = cast<ExportDecl>(D);
983 ED->setRBraceLoc(RBraceLoc);
990 for (
auto *Child : ED->decls()) {
992 if (
auto *FD = dyn_cast<FunctionDecl>(Child)) {
1000 if (FD->isInlineSpecified() && !FD->isDefined())
1001 PendingInlineFuncDecls.insert(FD);
1007 for (
auto *Exported : ED->decls())
1016 if (!TheGlobalModuleFragment) {
1022 assert(TheGlobalModuleFragment &&
"module creation should not fail");
1025 ModuleScopes.push_back({BeginLoc, TheGlobalModuleFragment,
1027 VisibleModules.
setVisible(TheGlobalModuleFragment, BeginLoc);
1029 return TheGlobalModuleFragment;
1032void Sema::PopGlobalModuleFragment() {
1033 assert(!ModuleScopes.empty() &&
1035 "left the wrong module scope, which is not global module fragment");
1036 ModuleScopes.pop_back();
1040 if (!TheImplicitGlobalModuleFragment) {
1042 TheImplicitGlobalModuleFragment =
1046 assert(TheImplicitGlobalModuleFragment &&
"module creation should not fail");
1049 ModuleScopes.push_back({BeginLoc, TheImplicitGlobalModuleFragment,
1051 VisibleModules.
setVisible(TheImplicitGlobalModuleFragment, BeginLoc);
1052 return TheImplicitGlobalModuleFragment;
1055void Sema::PopImplicitGlobalModuleFragment() {
1056 assert(!ModuleScopes.empty() &&
1058 "left the wrong module scope, which is not global module fragment");
1059 ModuleScopes.pop_back();
1062bool Sema::isCurrentModulePurview()
const {
llvm::MachO::Target Target
Defines the clang::Preprocessor interface.
static void makeTransitiveImportsVisible(VisibleModuleSet &VisibleModules, Module *Imported, Module *CurrentModule, SourceLocation ImportLoc, bool IsImportingPrimaryModuleInterface=false)
[module.import]p7: Additionally, when a module-import-declaration in a module unit of some module M i...
static bool DiagReservedModuleName(Sema &S, const IdentifierInfo *II, SourceLocation Loc)
Tests whether the given identifier is reserved as a module name and diagnoses if it is.
static const ExportDecl * getEnclosingExportDecl(const Decl *D)
Determine whether D is lexically within an export-declaration.
static bool checkExportedDecl(Sema &, Decl *, SourceLocation)
Check that it's valid to export D.
static std::string stringFromPath(ModuleIdPath Path)
static void checkModuleImportContext(Sema &S, Module *M, SourceLocation ImportLoc, DeclContext *DC, bool FromInclude=false)
static bool isImportingModuleUnitFromSameModule(Module *Imported, Module *CurrentModule, Module *&FoundPrimaryModuleInterface)
Helper function for makeTransitiveImportsVisible to decide whether the.
static bool checkExportedDeclContext(Sema &S, DeclContext *DC, SourceLocation BlockStart)
Check that it's valid to export all the declarations in DC.
virtual void HandleImplicitImportDecl(ImportDecl *D)
Handle an ImportDecl that was implicitly created due to an inclusion directive.
TranslationUnitDecl * getTranslationUnitDecl() const
void setCurrentNamedModule(Module *M)
Set the (C++20) module we are building.
void addModuleInitializer(Module *M, Decl *Init)
Add a declaration to the list of declarations that are initialized for a module.
The result of parsing/analyzing an expression, statement etc.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
void addDecl(Decl *D)
Add the declaration D into this context.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
Decl - This represents one declaration (or definition), e.g.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
bool isInvalidDecl() const
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
@ VisibleWhenImported
This declaration has an owning module, and is visible when that module is imported.
@ Unowned
This declaration is not owned by a module.
@ ReachableWhenImported
This declaration has an owning module, and is visible to lookups that occurs within that module.
@ ModulePrivate
This declaration has an owning module, but is only visible to lookups that occur within that module.
@ Visible
This declaration has an owning module, but is globally visible (typically because its owning module i...
void setModuleOwnershipKind(ModuleOwnershipKind MOK)
Set whether this declaration is hidden from name lookup.
Represents a standard C++ module export declaration.
static ExportDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation ExportLoc)
void setRBraceLoc(SourceLocation L)
StringRef getName() const
The name of this FileEntry.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
OptionalFileEntryRef getOptionalFileRef(StringRef Filename, bool OpenFile=false, bool CacheFailure=true)
Get a FileEntryRef if it exists, without doing anything on error.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
One of these records is kept for each identifier that is lexed.
ReservedIdentifierStatus isReserved(const LangOptions &LangOpts) const
Determine whether this is a name reserved for the implementation (C99 7.1.3, C++ [lib....
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Describes a module import declaration, which makes the contents of the named module visible in the cu...
static ImportDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, Module *Imported, ArrayRef< SourceLocation > IdentifierLocs)
Create a new module import declaration.
static ImportDecl * CreateImplicit(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, Module *Imported, SourceLocation EndLoc)
Create a new module import declaration for an implicitly-generated import.
@ CMK_None
Not compiling a module interface at all.
@ CMK_HeaderUnit
Compiling a module header unit.
@ CMK_ModuleMap
Compiling a module from a module map.
@ CMK_ModuleInterface
Compiling a C++ modules interface unit.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
std::string CurrentModule
The name of the current module, of which the main source file is a part.
virtual ModuleLoadResult loadModule(SourceLocation ImportLoc, ModuleIdPath Path, Module::NameVisibilityKind Visibility, bool IsInclusionDirective)=0
Attempt to load the given module.
virtual void makeModuleVisible(Module *Mod, Module::NameVisibilityKind Visibility, SourceLocation ImportLoc)=0
Make the given module visible.
Module * createGlobalModuleFragmentForModuleUnit(SourceLocation Loc, Module *Parent=nullptr)
Create a global module fragment for a C++ module unit.
Module * createImplicitGlobalModuleFragmentForModuleUnit(SourceLocation Loc, Module *Parent)
Describes a module or submodule.
SmallVector< ExportDecl, 2 > Exports
The set of export declarations.
bool isForBuilding(const LangOptions &LangOpts) const
Determine whether this module can be built in this compilation.
bool isInterfaceOrPartition() const
bool isModulePartitionImplementation() const
Is this a module partition implementation unit.
@ AllVisible
All of the names in this module are visible.
Module * Parent
The parent of this module.
ModuleKind Kind
The kind of this module.
llvm::SmallSetVector< Module *, 2 > Imports
The set of modules imported by this module, and on which this module depends.
unsigned IsExternC
Whether this is an 'extern "C"' module (which implicitly puts all headers in it within an 'extern "C"...
StringRef getPrimaryModuleInterfaceName() const
Get the primary module interface name from a partition.
bool isModulePartition() const
Is this a module partition.
bool isHeaderUnit() const
Is this module a header unit.
@ ModuleImplementationUnit
This is a C++20 module implementation unit.
@ ModuleMapModule
This is a module that was defined by a module map and built out of header files.
@ ImplicitGlobalModuleFragment
This is an implicit fragment of the global module which contains only language linkage declarations (...
@ ModulePartitionInterface
This is a C++20 module partition interface.
@ ModuleInterfaceUnit
This is a C++20 module interface unit.
@ ModuleHeaderUnit
This is a C++20 header unit.
@ ModulePartitionImplementation
This is a C++20 module partition implementation.
@ PrivateModuleFragment
This is the private module fragment within some C++ module.
@ ExplicitGlobalModuleFragment
This is the explicit Global Module Fragment of a modular TU.
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
bool isNamedModule() const
Does this Module is a named module of a standard named module?
This represents a decl that may have a name.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
Wrapper for void* pointer.
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
HeaderSearch & getHeaderSearchInfo() const
Scope - A scope is a transient data structure that is used while parsing the program.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
Sema - This implements semantic analysis and AST building for C.
void ActOnAnnotModuleBegin(SourceLocation DirectiveLoc, Module *Mod)
The parsed has entered a submodule.
void ActOnAnnotModuleInclude(SourceLocation DirectiveLoc, Module *Mod)
The parser has processed a module import translated from a #include or similar preprocessing directiv...
const TranslationUnitKind TUKind
The kind of translation unit we are processing.
@ PartitionImplementation
'module X:Y;'
@ Interface
'export module X;'
@ Implementation
'module X;'
@ PartitionInterface
'export module X:Y;'
DeclGroupPtrTy ActOnModuleDecl(SourceLocation StartLoc, SourceLocation ModuleLoc, ModuleDeclKind MDK, ModuleIdPath Path, ModuleIdPath Partition, ModuleImportState &ImportState)
The parser has processed a module-declaration that begins the definition of a module interface or imp...
llvm::DenseMap< NamedDecl *, NamedDecl * > VisibleNamespaceCache
Map from the most recent declaration of a namespace to the most recent visible declaration of that na...
void ActOnAnnotModuleEnd(SourceLocation DirectiveLoc, Module *Mod)
The parser has left a submodule.
bool currentModuleIsImplementation() const
Is the module scope we are an implementation unit?
DeclResult ActOnModuleImport(SourceLocation StartLoc, SourceLocation ExportLoc, SourceLocation ImportLoc, ModuleIdPath Path, bool IsPartition=false)
The parser has processed a module import declaration.
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
ASTContext & getASTContext() const
Decl * ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc, SourceLocation LBraceLoc)
We have parsed the start of an export declaration, including the '{' (if present).
const LangOptions & getLangOpts() const
void ActOnEndOfTranslationUnitFragment(TUFragmentKind Kind)
DeclGroupPtrTy ActOnGlobalModuleFragmentDecl(SourceLocation ModuleLoc)
The parser has processed a global-module-fragment declaration that begins the definition of the globa...
std::optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
Module * getCurrentModule() const
Get the module unit whose scope we are currently within.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
DeclGroupPtrTy ActOnPrivateModuleFragmentDecl(SourceLocation ModuleLoc, SourceLocation PrivateLoc)
The parser has processed a private-module-fragment declaration that begins the definition of the priv...
SourceManager & getSourceManager() const
void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod)
bool isModuleVisible(const Module *M, bool ModulePrivate=false)
@ Global
The global module fragment, between 'module;' and a module-declaration.
@ Normal
A normal translation unit fragment.
ModuleImportState
An enumeration to represent the transition of states in parsing module fragments and imports.
@ FirstDecl
Parsing the first decl in a TU.
@ GlobalFragment
after 'module;' but before 'module X;'
@ NotACXX20Module
Not a C++20 TU, or an invalid state was found.
@ ImportAllowed
after 'module X;' but before any non-import decl.
ModuleLoader & getModuleLoader() const
Retrieve the module loader associated with the preprocessor.
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
SourceManager & SourceMgr
Decl * ActOnFinishExportDecl(Scope *S, Decl *ExportDecl, SourceLocation RBraceLoc)
Complete the definition of an export declaration.
ASTMutationListener * getASTMutationListener() const
void createImplicitModuleImportForErrorRecovery(SourceLocation Loc, Module *Mod)
Create an implicit import of the given module at the given source location, for error recovery,...
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
OptionalFileEntryRef getFileEntryRefForID(FileID FID) const
Returns the FileEntryRef for the provided FileID.
FileManager & getFileManager() const
FileID getMainFileID() const
Returns the FileID of the main source file.
SourceLocation getIncludeLoc(FileID FID) const
Returns the include location if FID is a #include'd file otherwise it returns an invalid location.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file.
bool isWrittenInMainFile(SourceLocation Loc) const
Returns true if the spelling location for the given location is in the main file buffer.
A trivial tuple used to represent a source range.
The top declaration context.
A set of visible modules.
SourceLocation getImportLoc(const Module *M) const
Get the location at which the import of a module was triggered.
bool isVisible(const Module *M) const
Determine whether a module is visible.
void setVisible(Module *M, SourceLocation Loc, VisibleCallback Vis=[](Module *) {}, ConflictCallback Cb=[](ArrayRef< Module * >, Module *, StringRef) {})
Make a specific module visible.
The JSON file list parser is used to communicate input to InstallAPI.
ArrayRef< std::pair< IdentifierInfo *, SourceLocation > > ModuleIdPath
A sequence of identifier/location pairs used to describe a particular module or submodule,...
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
@ Internal
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
@ TU_ClangModule
The translation unit is a clang module.