From 052d95a6d697f973172b08b2f743dda9bd58dcf3 Mon Sep 17 00:00:00 2001 From: Bruno Cardoso Lopes Date: Thu, 12 Jan 2017 19:15:33 +0000 Subject: [PATCH] [Modules] Fix misleading warning about missing textual header in umbrella header When a textual header is present inside a umbrella dir but not in the header, we get the misleading warning: warning: umbrella header for module 'FooFramework' does not include header 'Baz_Private.h' The module map in question: framework module FooFramework { umbrella header "FooUmbrella.h" export * module * { export * } module Private { textual header "Baz_Private.h" } } Fix this by taking textual headers into account. llvm-svn: 291794 --- clang/lib/Lex/ModuleMap.cpp | 14 ++++++++++++-- .../Modules/module.modulemap | 12 ++++++++++++ .../FooFramework.framework/PrivateHeaders/Bar.h | 2 ++ .../PrivateHeaders/Baz_Private.h | 3 +++ .../FooFramework.framework/PrivateHeaders/Foo.h | 10 ++++++++++ .../PrivateHeaders/FooUmbrella.h | 3 +++ clang/test/Modules/textual-hdr-in-umbrella-hdr.m | 10 ++++++++++ 7 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 clang/test/Modules/Inputs/FooFramework.framework/Modules/module.modulemap create mode 100644 clang/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Bar.h create mode 100644 clang/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Baz_Private.h create mode 100644 clang/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Foo.h create mode 100644 clang/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/FooUmbrella.h create mode 100644 clang/test/Modules/textual-hdr-in-umbrella-hdr.m diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index db834ede022e..1488f624da64 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -446,9 +446,19 @@ ModuleMap::isHeaderUnavailableInModule(const FileEntry *Header, I = Known->second.begin(), E = Known->second.end(); I != E; ++I) { - if (I->isAvailable() && (!RequestingModule || - I->getModule()->isSubModuleOf(RequestingModule))) + + if (I->isAvailable() && + (!RequestingModule || + I->getModule()->isSubModuleOf(RequestingModule))) { + // When no requesting module is available, the caller is looking if a + // header is part a module by only looking into the module map. This is + // done by warn_uncovered_module_header checks; don't consider textual + // headers part of it in this mode, otherwise we get misleading warnings + // that a umbrella header is not including a textual header. + if (!RequestingModule && I->getRole() == ModuleMap::TextualHeader) + continue; return false; + } } return true; } diff --git a/clang/test/Modules/Inputs/FooFramework.framework/Modules/module.modulemap b/clang/test/Modules/Inputs/FooFramework.framework/Modules/module.modulemap new file mode 100644 index 000000000000..62e56364abaf --- /dev/null +++ b/clang/test/Modules/Inputs/FooFramework.framework/Modules/module.modulemap @@ -0,0 +1,12 @@ +framework module FooFramework { + umbrella header "FooUmbrella.h" + + export * + module * { + export * + } + + explicit module Private { + textual header "Baz_Private.h" + } +} diff --git a/clang/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Bar.h b/clang/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Bar.h new file mode 100644 index 000000000000..d16b395055f9 --- /dev/null +++ b/clang/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Bar.h @@ -0,0 +1,2 @@ +@interface Bar +@end diff --git a/clang/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Baz_Private.h b/clang/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Baz_Private.h new file mode 100644 index 000000000000..3ea082b874c0 --- /dev/null +++ b/clang/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Baz_Private.h @@ -0,0 +1,3 @@ +#ifndef Baz_h +#define Baz_h +#endif /* Baz_h */ diff --git a/clang/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Foo.h b/clang/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Foo.h new file mode 100644 index 000000000000..26b96988d588 --- /dev/null +++ b/clang/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Foo.h @@ -0,0 +1,10 @@ +__attribute__((objc_root_class)) +@interface NSObject ++ (instancetype) alloc; +- (instancetype) init; +- (instancetype)retain; +- (void)release; +@end + +@interface Foo : NSObject +@end diff --git a/clang/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/FooUmbrella.h b/clang/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/FooUmbrella.h new file mode 100644 index 000000000000..c752fb299e00 --- /dev/null +++ b/clang/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/FooUmbrella.h @@ -0,0 +1,3 @@ +#import +#import + diff --git a/clang/test/Modules/textual-hdr-in-umbrella-hdr.m b/clang/test/Modules/textual-hdr-in-umbrella-hdr.m new file mode 100644 index 000000000000..f92cdb91b236 --- /dev/null +++ b/clang/test/Modules/textual-hdr-in-umbrella-hdr.m @@ -0,0 +1,10 @@ +// RUN: rm -rf %t.cache +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.cache \ +// RUN: %s -fsyntax-only -F %S/Inputs -Wincomplete-umbrella -verify + +// expected-no-diagnostics + +#import + +@implementation Foo +@end