diff options
| author | Mingming Liu <mingmingl@google.com> | 2025-09-10 15:25:31 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-10 15:25:31 -0700 |
| commit | 1417dafa1db9cb1b2b09438aa9f53ea5ab6e36e2 (patch) | |
| tree | 57f4b1f313c8cf74eed8819870f39c36ea263c68 /clang/lib/Lex/ModuleMapFile.cpp | |
| parent | 898b813bc8a6d0276bf0f4769f5f2f64b34e632d (diff) | |
| parent | b8cefcb601ddaa18482555c4ff363c01a270c2fe (diff) | |
Merge branch 'main' into users/mingmingl-llvm/samplefdo-profile-formatusers/mingmingl-llvm/samplefdo-profile-format
Diffstat (limited to 'clang/lib/Lex/ModuleMapFile.cpp')
| -rw-r--r-- | clang/lib/Lex/ModuleMapFile.cpp | 34 |
1 files changed, 4 insertions, 30 deletions
diff --git a/clang/lib/Lex/ModuleMapFile.cpp b/clang/lib/Lex/ModuleMapFile.cpp index f0cd9d2bee82..183e919d14c2 100644 --- a/clang/lib/Lex/ModuleMapFile.cpp +++ b/clang/lib/Lex/ModuleMapFile.cpp @@ -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); @@ -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) { @@ -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: @@ -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(); @@ -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); } |
