@@ -118,8 +118,7 @@ struct ModuleMapFileParser {
118118 std::optional<ExcludeDecl> parseExcludeDecl (clang::SourceLocation LeadingLoc);
119119 std::optional<UmbrellaDirDecl>
120120 parseUmbrellaDirDecl (SourceLocation UmbrellaLoc);
121- std::optional<LinkDecl>
122- parseLinkDecl (llvm::StringMap<SourceLocation> &SeenLinkDecl, bool Allowed);
121+ std::optional<LinkDecl> parseLinkDecl ();
123122
124123 SourceLocation consumeToken ();
125124 void skipUntil (MMToken::TokenKind K);
@@ -326,7 +325,6 @@ std::optional<ModuleDecl> ModuleMapFileParser::parseModuleDecl(bool TopLevel) {
326325 SourceLocation LBraceLoc = consumeToken ();
327326
328327 bool Done = false ;
329- llvm::StringMap<SourceLocation> SeenLinkDecl;
330328 do {
331329 std::optional<Decl> SubDecl;
332330 switch (Tok.Kind ) {
@@ -407,9 +405,7 @@ std::optional<ModuleDecl> ModuleMapFileParser::parseModuleDecl(bool TopLevel) {
407405 break ;
408406
409407 case MMToken::LinkKeyword:
410- // Link decls are only allowed in top level modules or explicit
411- // submodules.
412- SubDecl = parseLinkDecl (SeenLinkDecl, TopLevel || MDecl.Explicit );
408+ SubDecl = parseLinkDecl ();
413409 break ;
414410
415411 default :
@@ -826,8 +822,7 @@ ModuleMapFileParser::parseUmbrellaDirDecl(clang::SourceLocation UmbrellaLoc) {
826822// /
827823// / module-declaration:
828824// / 'link' 'framework'[opt] string-literal
829- std::optional<LinkDecl> ModuleMapFileParser::parseLinkDecl (
830- llvm::StringMap<SourceLocation> &SeenLinkDecl, bool Allowed) {
825+ std::optional<LinkDecl> ModuleMapFileParser::parseLinkDecl () {
831826 assert (Tok.is (MMToken::LinkKeyword));
832827 LinkDecl LD;
833828 LD.Location = consumeToken ();
@@ -843,33 +838,12 @@ std::optional<LinkDecl> ModuleMapFileParser::parseLinkDecl(
843838 if (!Tok.is (MMToken::StringLiteral)) {
844839 Diags.Report (Tok.getLocation (), diag::err_mmap_expected_library_name)
845840 << LD.Framework << SourceRange (LD.Location );
846- consumeToken ();
847841 HadError = true ;
848842 return std::nullopt ;
849843 }
850844
851- StringRef Library = Tok.getString ();
852-
853- LD.Library = Library;
845+ LD.Library = Tok.getString ();
854846 consumeToken ();
855-
856- // Make sure we eat all the tokens when we report the errors so parsing
857- // can continue.
858- if (!Allowed) {
859- Diags.Report (LD.Location , diag::err_mmap_submodule_link_decl);
860- HadError = true ;
861- return std::nullopt ;
862- }
863-
864- auto [It, Inserted] =
865- SeenLinkDecl.insert (std::make_pair (Library, LD.Location ));
866- if (!Inserted) {
867- Diags.Report (LD.Location , diag::warn_mmap_link_redeclaration) << Library;
868- Diags.Report (It->second , diag::note_mmap_prev_link_declaration);
869- HadError = true ;
870- return std::nullopt ;
871- }
872-
873847 return std::move (LD);
874848}
875849
0 commit comments