Skip to content

[clang][module] Improve incomplete-umbrella warning #1860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 25, 2020
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
12 changes: 7 additions & 5 deletions clang/lib/Lex/PPLexerChange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,12 @@ static void collectAllSubModulesWithUmbrellaHeader(
}

void Preprocessor::diagnoseMissingHeaderInUmbrellaDir(const Module &Mod) {
assert(Mod.getUmbrellaHeader() && "Module must use umbrella header");
SourceLocation StartLoc =
SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID());
if (getDiagnostics().isIgnored(diag::warn_uncovered_module_header, StartLoc))
const Module::Header &UmbrellaHeader = Mod.getUmbrellaHeader();
assert(UmbrellaHeader.Entry && "Module must use umbrella header");
const FileID &File = SourceMgr.translateFile(UmbrellaHeader.Entry);
SourceLocation ExpectedHeadersLoc = SourceMgr.getLocForEndOfFile(File);
if (getDiagnostics().isIgnored(diag::warn_uncovered_module_header,
ExpectedHeadersLoc))
return;

ModuleMap &ModMap = getHeaderSearchInfo().getModuleMap();
Expand All @@ -291,7 +293,7 @@ void Preprocessor::diagnoseMissingHeaderInUmbrellaDir(const Module &Mod) {
// Find the relative path that would access this header.
SmallString<128> RelativePath;
computeRelativePath(FileMgr, Dir, *Header, RelativePath);
Diag(StartLoc, diag::warn_uncovered_module_header)
Diag(ExpectedHeadersLoc, diag::warn_uncovered_module_header)
<< Mod.getFullModuleName() << RelativePath;
}
}
Expand Down
8 changes: 6 additions & 2 deletions clang/test/Modules/incomplete-umbrella.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
#import <Foo/Baz.h>
@import Foo.Private;

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