Skip to content

Commit 7ab9af6

Browse files
committed
Revert "[clang][Modules] Reporting Errors for Duplicating Link Declarations in modulemaps (llvm#148959) (llvm#11265)"
This reverts commit b11f60b.
1 parent 25ea17b commit 7ab9af6

File tree

3 files changed

+4
-92
lines changed

3 files changed

+4
-92
lines changed

clang/include/clang/Basic/DiagnosticLexKinds.td

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -916,11 +916,6 @@ def err_mmap_nested_submodule_id : Error<
916916
"qualified module name can only be used to define modules at the top level">;
917917
def err_mmap_expected_feature : Error<"expected a feature name">;
918918
def err_mmap_expected_attribute : Error<"expected an attribute name">;
919-
def warn_mmap_link_redeclaration : Warning<"redeclaration of link library '%0'">,
920-
InGroup<DiagGroup<"module-link-redeclaration">>, DefaultError;
921-
def note_mmap_prev_link_declaration : Note<"previously declared here">;
922-
def err_mmap_submodule_link_decl
923-
: Error<"link declaration is not allowed in submodules">;
924919
def warn_mmap_unknown_attribute : Warning<"unknown attribute '%0'">,
925920
InGroup<IgnoredAttributes>;
926921
def warn_mmap_mismatched_private_submodule : Warning<

clang/lib/Lex/ModuleMapFile.cpp

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -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

clang/test/ClangScanDeps/link-libraries-diag-dup.c

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)