[clang] ed79827 - [clang][module] Improve incomplete-umbrella warning
Zixu Wang via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 18 14:57:11 PDT 2020
Author: Zixu Wang
Date: 2020-09-18T14:56:47-07:00
New Revision: ed79827aea444e6995fb3d36abc2bfd36331773c
URL: https://github.com/llvm/llvm-project/commit/ed79827aea444e6995fb3d36abc2bfd36331773c
DIFF: https://github.com/llvm/llvm-project/commit/ed79827aea444e6995fb3d36abc2bfd36331773c.diff
LOG: [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
Added:
Modified:
clang/lib/Lex/PPLexerChange.cpp
clang/test/Modules/incomplete-umbrella.m
Removed:
################################################################################
diff --git a/clang/lib/Lex/PPLexerChange.cpp b/clang/lib/Lex/PPLexerChange.cpp
index b7c7e2693ef1..de7b9b73ddf7 100644
--- a/clang/lib/Lex/PPLexerChange.cpp
+++ b/clang/lib/Lex/PPLexerChange.cpp
@@ -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();
@@ -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;
}
}
diff --git a/clang/test/Modules/incomplete-umbrella.m b/clang/test/Modules/incomplete-umbrella.m
index 8760b815718b..0574921203b2 100644
--- a/clang/test/Modules/incomplete-umbrella.m
+++ b/clang/test/Modules/incomplete-umbrella.m
@@ -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;
More information about the cfe-commits
mailing list