r328857 - [Modules] Improve fixit for framework private module maps
Bruno Cardoso Lopes via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 29 22:17:58 PDT 2018
Author: bruno
Date: Thu Mar 29 22:17:58 2018
New Revision: 328857
URL: http://llvm.org/viewvc/llvm-project?rev=328857&view=rev
Log:
[Modules] Improve fixit for framework private module maps
The wrong source range was being provided in some case, fix that to get
a better fixit.
rdar://problem/38520199
Modified:
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/test/Modules/implicit-private-with-submodule.m
Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=328857&r1=328856&r2=328857&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Thu Mar 29 22:17:58 2018
@@ -1630,14 +1630,15 @@ namespace {
/// in other ways (FooPrivate and Foo.Private), providing notes and fixits.
static void diagnosePrivateModules(const ModuleMap &Map,
DiagnosticsEngine &Diags,
- const Module *ActiveModule) {
+ const Module *ActiveModule,
+ SourceLocation InlineParent) {
auto GenNoteAndFixIt = [&](StringRef BadName, StringRef Canonical,
- const Module *M) {
+ const Module *M, SourceRange ReplLoc) {
auto D = Diags.Report(ActiveModule->DefinitionLoc,
diag::note_mmap_rename_top_level_private_module);
D << BadName << M->Name;
- D << FixItHint::CreateReplacement(ActiveModule->DefinitionLoc, Canonical);
+ D << FixItHint::CreateReplacement(ReplLoc, Canonical);
};
for (auto E = Map.module_begin(); E != Map.module_end(); ++E) {
@@ -1657,7 +1658,8 @@ static void diagnosePrivateModules(const
Diags.Report(ActiveModule->DefinitionLoc,
diag::warn_mmap_mismatched_private_submodule)
<< FullName;
- GenNoteAndFixIt(FullName, Canonical, M);
+ GenNoteAndFixIt(FullName, Canonical, M,
+ SourceRange(InlineParent, ActiveModule->DefinitionLoc));
continue;
}
@@ -1667,7 +1669,8 @@ static void diagnosePrivateModules(const
Diags.Report(ActiveModule->DefinitionLoc,
diag::warn_mmap_mismatched_private_module_name)
<< ActiveModule->Name;
- GenNoteAndFixIt(ActiveModule->Name, Canonical, M);
+ GenNoteAndFixIt(ActiveModule->Name, Canonical, M,
+ SourceRange(ActiveModule->DefinitionLoc));
}
}
}
@@ -1753,6 +1756,7 @@ void ModuleMapParser::parseModuleDecl()
}
Module *PreviousActiveModule = ActiveModule;
+ SourceLocation LastInlineParentLoc = SourceLocation();
if (Id.size() > 1) {
// This module map defines a submodule. Go find the module of which it
// is a submodule.
@@ -1763,6 +1767,7 @@ void ModuleMapParser::parseModuleDecl()
if (I == 0)
TopLevelModule = Next;
ActiveModule = Next;
+ LastInlineParentLoc = Id[I].second;
continue;
}
@@ -1882,7 +1887,7 @@ void ModuleMapParser::parseModuleDecl()
StartLoc) &&
(MapFileName.endswith("module.private.modulemap") ||
MapFileName.endswith("module_private.map")))
- diagnosePrivateModules(Map, Diags, ActiveModule);
+ diagnosePrivateModules(Map, Diags, ActiveModule, LastInlineParentLoc);
bool Done = false;
do {
Modified: cfe/trunk/test/Modules/implicit-private-with-submodule.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/implicit-private-with-submodule.m?rev=328857&r1=328856&r2=328857&view=diff
==============================================================================
--- cfe/trunk/test/Modules/implicit-private-with-submodule.m (original)
+++ cfe/trunk/test/Modules/implicit-private-with-submodule.m Thu Mar 29 22:17:58 2018
@@ -13,7 +13,7 @@
// expected-warning at Inputs/implicit-private-with-submodule/A.framework/Modules/module.private.modulemap:1{{private submodule 'A.Private' in private module map, expected top-level module}}
// expected-note at Inputs/implicit-private-with-submodule/A.framework/Modules/module.private.modulemap:1{{rename 'A.Private' to ensure it can be found by name}}
-// CHECK: fix-it:"{{.*}}module.private.modulemap":{1:20-1:27}:"A_Private"
+// CHECK: fix-it:"{{.*}}module.private.modulemap":{1:18-1:27}:"A_Private"
#ifndef HEADER
#define HEADER
More information about the cfe-commits
mailing list