From: Chuanqi Xu Date: Wed, 8 Dec 2021 09:11:40 +0000 (+0800) Subject: [NFC] Only attach a declaration to global module fragment if it appears in a module X-Git-Tag: upstream/15.0.7~23673 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=96b92d5b3ec43be18146a346b65cc82766cf8b3a;p=platform%2Fupstream%2Fllvm.git [NFC] Only attach a declaration to global module fragment if it appears in a module --- diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 558ee3f..4a0eda2 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -16153,7 +16153,7 @@ Decl *Sema::ActOnStartLinkageSpecification(Scope *S, SourceLocation ExternLoc, /// - ... /// - appears within a linkage-specification, /// it is attached to the global module. - if (getLangOpts().CPlusPlusModules) { + if (getLangOpts().CPlusPlusModules && getCurrentModule()) { Module *GlobalModule = PushGlobalModuleFragment(ExternLoc, /*IsImplicit=*/true); D->setModuleOwnershipKind(Decl::ModuleOwnershipKind::ModulePrivate); @@ -16177,7 +16177,7 @@ Decl *Sema::ActOnFinishLinkageSpecification(Scope *S, LSDecl->setRBraceLoc(RBraceLoc); } - if (getLangOpts().CPlusPlusModules) + if (getLangOpts().CPlusPlusModules && getCurrentModule()) PopGlobalModuleFragment(); PopDeclContext();