aboutsummaryrefslogtreecommitdiff
path: root/clang
diff options
context:
space:
mode:
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>2022-07-27 14:14:45 +0800
committerChuanqi Xu <yedeng.yd@linux.alibaba.com>2022-07-27 14:15:32 +0800
commite8e46cdce3ed3fbd1a0a632a7f69abb97be33cf4 (patch)
tree4fd86e3fb23b5ccf1977711274084b705649b77f /clang
parent55889852127245b830bc3231f172eed53dcb355e (diff)
downloadllvm-e8e46cdce3ed3fbd1a0a632a7f69abb97be33cf4.zip
llvm-e8e46cdce3ed3fbd1a0a632a7f69abb97be33cf4.tar.gz
llvm-e8e46cdce3ed3fbd1a0a632a7f69abb97be33cf4.tar.bz2
[NFC] [C++20] [Modules] Use Sema::isCurrentModulePurview() to simplify the codes
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Sema/Sema.cpp4
-rw-r--r--clang/lib/Sema/SemaModule.cpp5
2 files changed, 3 insertions, 6 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 08957ce..1d27f74 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -1216,9 +1216,7 @@ void Sema::ActOnEndOfTranslationUnit() {
// module declaration by now.
if (getLangOpts().getCompilingModule() ==
LangOptions::CMK_ModuleInterface &&
- (ModuleScopes.empty() ||
- !ModuleScopes.back().Module->isModulePurview()) &&
- !DiagnosedMissingModuleDeclaration) {
+ !isCurrentModulePurview() && !DiagnosedMissingModuleDeclaration) {
// FIXME: Make a better guess as to where to put the module declaration.
Diag(getSourceManager().getLocForStartOfFile(
getSourceManager().getMainFileID()),
diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index f5c24bd..757c611 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -207,8 +207,7 @@ Sema::ActOnModuleDecl(SourceLocation StartLoc, SourceLocation ModuleLoc,
// here, in order to support macro import.
// Only one module-declaration is permitted per source file.
- if (!ModuleScopes.empty() &&
- ModuleScopes.back().Module->isModulePurview()) {
+ if (isCurrentModulePurview()) {
Diag(ModuleLoc, diag::err_module_redeclaration);
Diag(VisibleModules.getImportLoc(ModuleScopes.back().Module),
diag::note_prev_module_declaration);
@@ -717,7 +716,7 @@ Decl *Sema::ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc,
// An export-declaration shall appear only [...] in the purview of a module
// interface unit. An export-declaration shall not appear directly or
// indirectly within [...] a private-module-fragment.
- if (ModuleScopes.empty() || !ModuleScopes.back().Module->isModulePurview()) {
+ if (!isCurrentModulePurview()) {
Diag(ExportLoc, diag::err_export_not_in_module_interface) << 0;
D->setInvalidDecl();
return D;