[PATCH] D82118: [clang][module] Improve incomplete-umbrella warning
Zixu Wang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 11 18:16:56 PDT 2020
zixuw updated this revision to Diff 291364.
zixuw added a comment.
Separate warning message improvement and fix-it hint.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D82118/new/
https://reviews.llvm.org/D82118
Files:
clang/lib/Lex/PPLexerChange.cpp
clang/test/Modules/incomplete-umbrella.m
Index: clang/test/Modules/incomplete-umbrella.m
===================================================================
--- clang/test/Modules/incomplete-umbrella.m
+++ 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;
Index: clang/lib/Lex/PPLexerChange.cpp
===================================================================
--- clang/lib/Lex/PPLexerChange.cpp
+++ clang/lib/Lex/PPLexerChange.cpp
@@ -263,10 +263,11 @@
}
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 auto &UmbrellaHeader = Mod.getUmbrellaHeader();
+ assert(UmbrellaHeader.Entry && "Module must use umbrella header");
+ const FileID &File = SourceMgr.translateFile(UmbrellaHeader.Entry);
+ SourceLocation EndLoc = SourceMgr.getLocForEndOfFile(File);
+ if (getDiagnostics().isIgnored(diag::warn_uncovered_module_header, EndLoc))
return;
ModuleMap &ModMap = getHeaderSearchInfo().getModuleMap();
@@ -291,7 +292,7 @@
// 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(EndLoc, diag::warn_uncovered_module_header)
<< Mod.getFullModuleName() << RelativePath;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82118.291364.patch
Type: text/x-patch
Size: 2442 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200912/6fdfd949/attachment.bin>
More information about the cfe-commits
mailing list