clang 20.0.0git
Functions
SemaModule.cpp File Reference
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTMutationListener.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Sema/SemaInternal.h"
#include "llvm/ADT/StringExtras.h"
#include <optional>

Go to the source code of this file.

Functions

static void checkModuleImportContext (Sema &S, Module *M, SourceLocation ImportLoc, DeclContext *DC, bool FromInclude=false)
 
static std::string stringFromPath (ModuleIdPath Path)
 
static bool isImportingModuleUnitFromSameModule (ASTContext &Ctx, Module *Imported, Module *CurrentModule, Module *&FoundPrimaryModuleInterface)
 Helper function for makeTransitiveImportsVisible to decide whether the.
 
static void makeTransitiveImportsVisible (ASTContext &Ctx, 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 imports another module unit U of M, it also imports all translation units imported by non-exported module-import-declarations in the module unit purview of U.
 
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 ExportDeclgetEnclosingExportDecl (const Decl *D)
 Determine whether D is lexically within an export-declaration.
 
static bool checkExportedDecl (Sema &S, Decl *D, SourceLocation BlockStart)
 Check that it's valid to export D.
 
static bool checkExportedDeclContext (Sema &S, DeclContext *DC, SourceLocation BlockStart)
 Check that it's valid to export all the declarations in DC.
 

Function Documentation

◆ checkExportedDecl()

static bool checkExportedDecl ( Sema S,
Decl D,
SourceLocation  BlockStart 
)
static

◆ checkExportedDeclContext()

static bool checkExportedDeclContext ( Sema S,
DeclContext DC,
SourceLocation  BlockStart 
)
static

Check that it's valid to export all the declarations in DC.

Definition at line 920 of file SemaModule.cpp.

References checkExportedDecl(), D, and clang::DeclContext::decls().

Referenced by checkExportedDecl().

◆ checkModuleImportContext()

static void checkModuleImportContext ( Sema S,
Module M,
SourceLocation  ImportLoc,
DeclContext DC,
bool  FromInclude = false 
)
static

◆ DiagReservedModuleName()

static bool DiagReservedModuleName ( Sema S,
const IdentifierInfo II,
SourceLocation  Loc 
)
static

Tests whether the given identifier is reserved as a module name and diagnoses if it is.

Returns true if a diagnostic is emitted and false otherwise.

Definition at line 226 of file SemaModule.cpp.

References clang::SemaBase::Diag(), clang::Sema::getLangOpts(), clang::Sema::getSourceManager(), clang::Invalid, clang::SourceManager::isInSystemHeader(), clang::IdentifierInfo::isReserved(), clang::IdentifierInfo::isStr(), Loc, and clang::NotReserved.

Referenced by clang::Sema::ActOnModuleDecl().

◆ getEnclosingExportDecl()

static const ExportDecl * getEnclosingExportDecl ( const Decl D)
static

Determine whether D is lexically within an export-declaration.

Definition at line 633 of file SemaModule.cpp.

References D, clang::Decl::getLexicalDeclContext(), and clang::DeclContext::getLexicalParent().

Referenced by clang::Sema::ActOnModuleImport(), and clang::Sema::ActOnStartExportDecl().

◆ isImportingModuleUnitFromSameModule()

static bool isImportingModuleUnitFromSameModule ( ASTContext Ctx,
Module Imported,
Module CurrentModule,
Module *&  FoundPrimaryModuleInterface 
)
static

Helper function for makeTransitiveImportsVisible to decide whether the.

Parameters
Importedmodule unit is in the same module with the
CurrentModule.
FoundPrimaryModuleInterfaceis a helper parameter to record the primary module interface unit corresponding to the module
CurrentModule.Since currently it is expensive to decide whether two module units come from the same module by comparing the module name.

Definition at line 85 of file SemaModule.cpp.

References clang::ASTContext::isInSameModule(), clang::Module::isModulePartition(), clang::Module::isModulePartitionImplementation(), and clang::Module::isNamedModule().

Referenced by makeTransitiveImportsVisible().

◆ makeTransitiveImportsVisible()

static void makeTransitiveImportsVisible ( ASTContext Ctx,
VisibleModuleSet VisibleModules,
Module Imported,
Module CurrentModule,
SourceLocation  ImportLoc,
bool  IsImportingPrimaryModuleInterface = false 
)
static

[module.import]p7: Additionally, when a module-import-declaration in a module unit of some module M imports another module unit U of M, it also imports all translation units imported by non-exported module-import-declarations in the module unit purview of U.

These rules can in turn lead to the importation of yet more translation units.

Definition at line 130 of file SemaModule.cpp.

References clang::Module::Imports, isImportingModuleUnitFromSameModule(), clang::Module::isNamedModule(), clang::VisibleModuleSet::isVisible(), and clang::VisibleModuleSet::setVisible().

Referenced by clang::Sema::ActOnModuleDecl(), and clang::Sema::ActOnModuleImport().

◆ stringFromPath()

static std::string stringFromPath ( ModuleIdPath  Path)
static

Definition at line 64 of file SemaModule.cpp.

References Path.

Referenced by clang::Sema::ActOnModuleDecl(), and clang::Sema::ActOnModuleImport().