Skip to content

Commit e8e46cd

Browse files
committed
[NFC] [C++20] [Modules] Use Sema::isCurrentModulePurview() to simplify the codes
1 parent 5588985 commit e8e46cd

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

clang/lib/Sema/Sema.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,9 +1216,7 @@ void Sema::ActOnEndOfTranslationUnit() {
12161216
// module declaration by now.
12171217
if (getLangOpts().getCompilingModule() ==
12181218
LangOptions::CMK_ModuleInterface &&
1219-
(ModuleScopes.empty() ||
1220-
!ModuleScopes.back().Module->isModulePurview()) &&
1221-
!DiagnosedMissingModuleDeclaration) {
1219+
!isCurrentModulePurview() && !DiagnosedMissingModuleDeclaration) {
12221220
// FIXME: Make a better guess as to where to put the module declaration.
12231221
Diag(getSourceManager().getLocForStartOfFile(
12241222
getSourceManager().getMainFileID()),

clang/lib/Sema/SemaModule.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,7 @@ Sema::ActOnModuleDecl(SourceLocation StartLoc, SourceLocation ModuleLoc,
207207
// here, in order to support macro import.
208208

209209
// Only one module-declaration is permitted per source file.
210-
if (!ModuleScopes.empty() &&
211-
ModuleScopes.back().Module->isModulePurview()) {
210+
if (isCurrentModulePurview()) {
212211
Diag(ModuleLoc, diag::err_module_redeclaration);
213212
Diag(VisibleModules.getImportLoc(ModuleScopes.back().Module),
214213
diag::note_prev_module_declaration);
@@ -717,7 +716,7 @@ Decl *Sema::ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc,
717716
// An export-declaration shall appear only [...] in the purview of a module
718717
// interface unit. An export-declaration shall not appear directly or
719718
// indirectly within [...] a private-module-fragment.
720-
if (ModuleScopes.empty() || !ModuleScopes.back().Module->isModulePurview()) {
719+
if (!isCurrentModulePurview()) {
721720
Diag(ExportLoc, diag::err_export_not_in_module_interface) << 0;
722721
D->setInvalidDecl();
723722
return D;

0 commit comments

Comments
 (0)