Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions clang/include/clang/Basic/DiagnosticLexKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -916,11 +916,6 @@ def err_mmap_nested_submodule_id : Error<
"qualified module name can only be used to define modules at the top level">;
def err_mmap_expected_feature : Error<"expected a feature name">;
def err_mmap_expected_attribute : Error<"expected an attribute name">;
def warn_mmap_link_redeclaration : Warning<"redeclaration of link library '%0'">,
InGroup<DiagGroup<"module-link-redeclaration">>, DefaultError;
def note_mmap_prev_link_declaration : Note<"previously declared here">;
def err_mmap_submodule_link_decl
: Error<"link declaration is not allowed in submodules">;
def warn_mmap_unknown_attribute : Warning<"unknown attribute '%0'">,
InGroup<IgnoredAttributes>;
def warn_mmap_mismatched_private_submodule : Warning<
Expand Down
34 changes: 4 additions & 30 deletions clang/lib/Lex/ModuleMapFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ struct ModuleMapFileParser {
std::optional<ExcludeDecl> parseExcludeDecl(clang::SourceLocation LeadingLoc);
std::optional<UmbrellaDirDecl>
parseUmbrellaDirDecl(SourceLocation UmbrellaLoc);
std::optional<LinkDecl>
parseLinkDecl(llvm::StringMap<SourceLocation> &SeenLinkDecl, bool Allowed);
std::optional<LinkDecl> parseLinkDecl();

SourceLocation consumeToken();
void skipUntil(MMToken::TokenKind K);
Expand Down Expand Up @@ -326,7 +325,6 @@ std::optional<ModuleDecl> ModuleMapFileParser::parseModuleDecl(bool TopLevel) {
SourceLocation LBraceLoc = consumeToken();

bool Done = false;
llvm::StringMap<SourceLocation> SeenLinkDecl;
do {
std::optional<Decl> SubDecl;
switch (Tok.Kind) {
Expand Down Expand Up @@ -407,9 +405,7 @@ std::optional<ModuleDecl> ModuleMapFileParser::parseModuleDecl(bool TopLevel) {
break;

case MMToken::LinkKeyword:
// Link decls are only allowed in top level modules or explicit
// submodules.
SubDecl = parseLinkDecl(SeenLinkDecl, TopLevel || MDecl.Explicit);
SubDecl = parseLinkDecl();
break;

default:
Expand Down Expand Up @@ -826,8 +822,7 @@ ModuleMapFileParser::parseUmbrellaDirDecl(clang::SourceLocation UmbrellaLoc) {
///
/// module-declaration:
/// 'link' 'framework'[opt] string-literal
std::optional<LinkDecl> ModuleMapFileParser::parseLinkDecl(
llvm::StringMap<SourceLocation> &SeenLinkDecl, bool Allowed) {
std::optional<LinkDecl> ModuleMapFileParser::parseLinkDecl() {
assert(Tok.is(MMToken::LinkKeyword));
LinkDecl LD;
LD.Location = consumeToken();
Expand All @@ -843,33 +838,12 @@ std::optional<LinkDecl> ModuleMapFileParser::parseLinkDecl(
if (!Tok.is(MMToken::StringLiteral)) {
Diags.Report(Tok.getLocation(), diag::err_mmap_expected_library_name)
<< LD.Framework << SourceRange(LD.Location);
consumeToken();
HadError = true;
return std::nullopt;
}

StringRef Library = Tok.getString();

LD.Library = Library;
LD.Library = Tok.getString();
consumeToken();

// Make sure we eat all the tokens when we report the errors so parsing
// can continue.
if (!Allowed) {
Diags.Report(LD.Location, diag::err_mmap_submodule_link_decl);
HadError = true;
return std::nullopt;
}

auto [It, Inserted] =
SeenLinkDecl.insert(std::make_pair(Library, LD.Location));
if (!Inserted) {
Diags.Report(LD.Location, diag::warn_mmap_link_redeclaration) << Library;
Diags.Report(It->second, diag::note_mmap_prev_link_declaration);
HadError = true;
return std::nullopt;
}

return std::move(LD);
}

Expand Down
57 changes: 0 additions & 57 deletions clang/test/ClangScanDeps/link-libraries-diag-dup.c

This file was deleted.