Skip to content

Commit ed79827

Browse files
committed
[clang][module] Improve incomplete-umbrella warning
Change the warning message for -Wincomplete-umbrella to report the location of the umbrella header; Differential Revision: https://reviews.llvm.org/D82118
1 parent 06f136f commit ed79827

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

clang/lib/Lex/PPLexerChange.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,12 @@ static void collectAllSubModulesWithUmbrellaHeader(
263263
}
264264

265265
void Preprocessor::diagnoseMissingHeaderInUmbrellaDir(const Module &Mod) {
266-
assert(Mod.getUmbrellaHeader() && "Module must use umbrella header");
267-
SourceLocation StartLoc =
268-
SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID());
269-
if (getDiagnostics().isIgnored(diag::warn_uncovered_module_header, StartLoc))
266+
const Module::Header &UmbrellaHeader = Mod.getUmbrellaHeader();
267+
assert(UmbrellaHeader.Entry && "Module must use umbrella header");
268+
const FileID &File = SourceMgr.translateFile(UmbrellaHeader.Entry);
269+
SourceLocation ExpectedHeadersLoc = SourceMgr.getLocForEndOfFile(File);
270+
if (getDiagnostics().isIgnored(diag::warn_uncovered_module_header,
271+
ExpectedHeadersLoc))
270272
return;
271273

272274
ModuleMap &ModMap = getHeaderSearchInfo().getModuleMap();
@@ -291,7 +293,7 @@ void Preprocessor::diagnoseMissingHeaderInUmbrellaDir(const Module &Mod) {
291293
// Find the relative path that would access this header.
292294
SmallString<128> RelativePath;
293295
computeRelativePath(FileMgr, Dir, *Header, RelativePath);
294-
Diag(StartLoc, diag::warn_uncovered_module_header)
296+
Diag(ExpectedHeadersLoc, diag::warn_uncovered_module_header)
295297
<< Mod.getFullModuleName() << RelativePath;
296298
}
297299
}

clang/test/Modules/incomplete-umbrella.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@
66
#import <Foo/Baz.h>
77
@import Foo.Private;
88

9-
// CHECK: warning: umbrella header for module 'Foo' does not include header 'Bar.h'
10-
// CHECK: warning: umbrella header for module 'Foo.Private' does not include header 'Baz.h'
9+
// CHECK: While building module 'Foo' imported from {{.*[/\]}}incomplete-umbrella.m:4:
10+
// CHECK-NEXT: In file included from <module-includes>:1:
11+
// CHECK-NEXT: {{.*Foo[.]framework[/\]Headers[/\]}}FooPublic.h:2:1: warning: umbrella header for module 'Foo' does not include header 'Bar.h'
12+
// CHECK: While building module 'Foo' imported from {{.*[/\]}}incomplete-umbrella.m:4:
13+
// CHECK-NEXT: In file included from <module-includes>:2:
14+
// CHECK-NEXT: {{.*Foo[.]framework[/\]PrivateHeaders[/\]}}Foo.h:2:1: warning: umbrella header for module 'Foo.Private' does not include header 'Baz.h'
1115
int foo() {
1216
int a = BAR_PUBLIC;
1317
int b = BAZ_PRIVATE;

0 commit comments

Comments
 (0)