From 7807f00835ab028596fc3e0455ddd441a0e3c7ef Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 16 Dec 2013 14:57:22 +0000 Subject: [PATCH] Revert "Modules: Make missing headers in a module.map a warning not an error." This was committed accidentally. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197389 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticGroups.td | 2 -- include/clang/Basic/DiagnosticLexKinds.td | 5 ++-- include/clang/Lex/ModuleMap.h | 4 +-- lib/Lex/HeaderSearch.cpp | 2 +- lib/Lex/ModuleMap.cpp | 27 ++++++++++++------- .../declare-use/{custom.map => module.map} | 1 - test/Modules/Inputs/modular_maps/modulea.map | 1 - test/Modules/modular_maps.cpp | 4 +-- 8 files changed, 23 insertions(+), 23 deletions(-) rename test/Modules/Inputs/declare-use/{custom.map => module.map} (96%) diff --git a/include/clang/Basic/DiagnosticGroups.td b/include/clang/Basic/DiagnosticGroups.td index c6304dadc7..14b01040de 100644 --- a/include/clang/Basic/DiagnosticGroups.td +++ b/include/clang/Basic/DiagnosticGroups.td @@ -207,7 +207,6 @@ def MismatchedReturnTypes : DiagGroup<"mismatched-return-types">; def MismatchedTags : DiagGroup<"mismatched-tags">; def MissingFieldInitializers : DiagGroup<"missing-field-initializers">; def ModuleConflict : DiagGroup<"module-conflict">; -def ModuleMapWarnings : DiagGroup<"module-map-warnings">; def NewlineEOF : DiagGroup<"newline-eof">; def NullArithmetic : DiagGroup<"null-arithmetic">; def NullCharacter : DiagGroup<"null-character">; @@ -490,7 +489,6 @@ def Most : DiagGroup<"most", [ Implicit, MismatchedTags, MissingBraces, - ModuleMapWarnings, MultiChar, Reorder, ReturnType, diff --git a/include/clang/Basic/DiagnosticLexKinds.td b/include/clang/Basic/DiagnosticLexKinds.td index 7e49c42d90..e9de4db036 100644 --- a/include/clang/Basic/DiagnosticLexKinds.td +++ b/include/clang/Basic/DiagnosticLexKinds.td @@ -551,6 +551,8 @@ def err_mmap_expected_mmap_file : Error<"expected a module map file name">; def err_mmap_module_redefinition : Error< "redefinition of module '%0'">; def note_mmap_prev_definition : Note<"previously defined here">; +def err_mmap_header_not_found : Error< + "%select{|umbrella }0header '%1' not found">; def err_mmap_umbrella_dir_not_found : Error< "umbrella directory '%0' not found">; def err_mmap_umbrella_clash : Error< @@ -597,9 +599,6 @@ def err_mmap_expected_feature : Error<"expected a feature name">; def err_mmap_expected_attribute : Error<"expected an attribute name">; def warn_mmap_unknown_attribute : Warning<"unknown attribute '%0'">, InGroup; -def warn_mmap_header_not_found : - Warning<"%select{|umbrella }0header '%1' not found">, - InGroup; def warn_auto_module_import : Warning< "treating #%select{include|import|include_next|__include_macros}0 as an " diff --git a/include/clang/Lex/ModuleMap.h b/include/clang/Lex/ModuleMap.h index 5339ec13b2..483ae3d592 100644 --- a/include/clang/Lex/ModuleMap.h +++ b/include/clang/Lex/ModuleMap.h @@ -38,7 +38,7 @@ class ModuleMapParser; class ModuleMap { SourceManager &SourceMgr; - DiagnosticsEngine &Diags; + IntrusiveRefCntPtr Diags; const LangOptions &LangOpts; const TargetInfo *Target; HeaderSearch &HeaderInfo; @@ -188,7 +188,7 @@ public: /// \param LangOpts Language options for this translation unit. /// /// \param Target The target for this translation unit. - ModuleMap(SourceManager &SourceMgr, DiagnosticsEngine &Diags, + ModuleMap(SourceManager &SourceMgr, DiagnosticConsumer &DC, const LangOptions &LangOpts, const TargetInfo *Target, HeaderSearch &HeaderInfo); diff --git a/lib/Lex/HeaderSearch.cpp b/lib/Lex/HeaderSearch.cpp index 254c0293df..5770aaadf4 100644 --- a/lib/Lex/HeaderSearch.cpp +++ b/lib/Lex/HeaderSearch.cpp @@ -48,7 +48,7 @@ HeaderSearch::HeaderSearch(IntrusiveRefCntPtr HSOpts, const LangOptions &LangOpts, const TargetInfo *Target) : HSOpts(HSOpts), FileMgr(SourceMgr.getFileManager()), FrameworkMap(64), - ModMap(SourceMgr, Diags, LangOpts, Target, *this) + ModMap(SourceMgr, *Diags.getClient(), LangOpts, Target, *this) { AngledDirIdx = 0; SystemDirIdx = 0; diff --git a/lib/Lex/ModuleMap.cpp b/lib/Lex/ModuleMap.cpp index 59cb40151a..8a1fcaa69e 100644 --- a/lib/Lex/ModuleMap.cpp +++ b/lib/Lex/ModuleMap.cpp @@ -59,7 +59,7 @@ Module *ModuleMap::resolveModuleId(const ModuleId &Id, Module *Mod, Module *Context = lookupModuleUnqualified(Id[0].first, Mod); if (!Context) { if (Complain) - Diags.Report(Id[0].second, diag::err_mmap_missing_module_unqualified) + Diags->Report(Id[0].second, diag::err_mmap_missing_module_unqualified) << Id[0].first << Mod->getFullModuleName(); return 0; @@ -70,7 +70,7 @@ Module *ModuleMap::resolveModuleId(const ModuleId &Id, Module *Mod, Module *Sub = lookupModuleQualified(Id[I].first, Context); if (!Sub) { if (Complain) - Diags.Report(Id[I].second, diag::err_mmap_missing_module_qualified) + Diags->Report(Id[I].second, diag::err_mmap_missing_module_qualified) << Id[I].first << Context->getFullModuleName() << SourceRange(Id[0].second, Id[I-1].second); @@ -83,12 +83,19 @@ Module *ModuleMap::resolveModuleId(const ModuleId &Id, Module *Mod, return Context; } -ModuleMap::ModuleMap(SourceManager &SourceMgr, DiagnosticsEngine &Diags, +ModuleMap::ModuleMap(SourceManager &SourceMgr, DiagnosticConsumer &DC, const LangOptions &LangOpts, const TargetInfo *Target, HeaderSearch &HeaderInfo) - : SourceMgr(SourceMgr), Diags(Diags), LangOpts(LangOpts), Target(Target), + : SourceMgr(SourceMgr), LangOpts(LangOpts), Target(Target), HeaderInfo(HeaderInfo), BuiltinIncludeDir(0), CompilingModule(0), - SourceModule(0) {} + SourceModule(0) { + IntrusiveRefCntPtr DiagIDs(new DiagnosticIDs); + Diags = IntrusiveRefCntPtr( + new DiagnosticsEngine(DiagIDs, new DiagnosticOptions)); + Diags->setClient(new ForwardingDiagnosticConsumer(DC), + /*ShouldOwnClient=*/true); + Diags->setSourceManager(&SourceMgr); +} ModuleMap::~ModuleMap() { for (llvm::StringMap::iterator I = Modules.begin(), @@ -1571,11 +1578,9 @@ void ModuleMapParser::parseHeaderDecl(MMToken::TokenKind LeadingToken, } else if (LeadingToken != MMToken::ExcludeKeyword) { // Ignore excluded header files. They're optional anyway. - // If we find a module that has a missing header, we mark this module as - // unavailable. Layering warnings like -fmodules-decluse can still be used. - ActiveModule->IsAvailable = false; - Diags.Report(FileNameLoc, diag::warn_mmap_header_not_found) + Diags.Report(FileNameLoc, diag::err_mmap_header_not_found) << (LeadingToken == MMToken::UmbrellaKeyword) << FileName; + HadError = true; } } @@ -2114,9 +2119,11 @@ bool ModuleMap::parseModuleMapFile(const FileEntry *File, bool IsSystem) { // Parse this module map file. Lexer L(ID, SourceMgr.getBuffer(ID), SourceMgr, MMapLangOpts); - ModuleMapParser Parser(L, SourceMgr, Target, Diags, *this, File->getDir(), + Diags->getClient()->BeginSourceFile(MMapLangOpts); + ModuleMapParser Parser(L, SourceMgr, Target, *Diags, *this, File->getDir(), BuiltinIncludeDir, IsSystem); bool Result = Parser.parseModuleMapFile(); + Diags->getClient()->EndSourceFile(); ParsedModuleMap[File] = Result; return Result; } diff --git a/test/Modules/Inputs/declare-use/custom.map b/test/Modules/Inputs/declare-use/module.map similarity index 96% rename from test/Modules/Inputs/declare-use/custom.map rename to test/Modules/Inputs/declare-use/module.map index c5f43e86dc..ba615b6714 100644 --- a/test/Modules/Inputs/declare-use/custom.map +++ b/test/Modules/Inputs/declare-use/module.map @@ -26,7 +26,6 @@ module XE { module XF { header "f.h" - header "missing.h" use XA use XB } diff --git a/test/Modules/Inputs/modular_maps/modulea.map b/test/Modules/Inputs/modular_maps/modulea.map index e0da6f358d..58c5f6464e 100644 --- a/test/Modules/Inputs/modular_maps/modulea.map +++ b/test/Modules/Inputs/modular_maps/modulea.map @@ -1,7 +1,6 @@ module A { header "common.h" header "a.h" - header "doesnotexists.h" } extern module B "moduleb.map" diff --git a/test/Modules/modular_maps.cpp b/test/Modules/modular_maps.cpp index cb305f2dfd..9c9aba85a9 100644 --- a/test/Modules/modular_maps.cpp +++ b/test/Modules/modular_maps.cpp @@ -1,7 +1,5 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -fmodules -fmodule-maps -fmodules-cache-path=%t -fmodule-map-file=%S/Inputs/modular_maps/modulea.map -I %S/Inputs/modular_maps %s -verify - -// expected-warning@Inputs/modular_maps/modulea.map:4{{header 'doesnotexists.h' not found}} +// RUN: %clang_cc1 -x objective-c++ -fmodules-cache-path=%t -fmodules -fmodule-map-file=%S/Inputs/modular_maps/modulea.map -I %S/Inputs/modular_maps %s -verify #include "common.h" #include "a.h" -- 2.40.0