This revision was automatically updated to reflect the committed changes.
Closed by commit rL301597: [Modules] Improve diagnostics for incomplete
umbrella (authored by bruno).
Changed prior to commit:
https://reviews.llvm.org/D32576?vs=96857&id=97007#toc
Repository:
rL LLVM
https://reviews.llvm.org/D32576
Files:
cfe/trunk/lib/Lex/PPLexerChange.cpp
cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h
cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h
cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap
cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.private.modulemap
cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Baz.h
cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Foo.h
cfe/trunk/test/Modules/incomplete-umbrella.m
Index: cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h
===================================================================
--- cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h
+++ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h
@@ -0,0 +1 @@
+#define BAR_PUBLIC 1
Index: cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h
===================================================================
--- cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h
+++ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h
@@ -0,0 +1 @@
+// FooPublic.h
Index: cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap
===================================================================
--- cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap
+++ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap
@@ -0,0 +1,5 @@
+framework module Foo {
+ umbrella header "FooPublic.h"
+ requires objc
+ export *
+}
Index: cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.private.modulemap
===================================================================
--- cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.private.modulemap
+++ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.private.modulemap
@@ -0,0 +1,5 @@
+explicit module Foo.Private {
+ umbrella header "Foo.h"
+ requires objc
+ export *
+}
Index: cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Baz.h
===================================================================
--- cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Baz.h
+++ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Baz.h
@@ -0,0 +1 @@
+#define BAZ_PRIVATE 1
Index: cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Foo.h
===================================================================
--- cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Foo.h
+++ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Foo.h
@@ -0,0 +1 @@
+// Foo.h
Index: cfe/trunk/test/Modules/incomplete-umbrella.m
===================================================================
--- cfe/trunk/test/Modules/incomplete-umbrella.m
+++ cfe/trunk/test/Modules/incomplete-umbrella.m
@@ -0,0 +1,15 @@
+// RUN: rm -rf %t
+// RUN: not %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -F%S/Inputs/incomplete-umbrella -fsyntax-only %s 2>&1 | FileCheck %s
+
+#import <Foo/Foo.h>
+#import <Foo/Bar.h>
+#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'
+int foo() {
+ int a = BAR_PUBLIC;
+ int b = BAZ_PRIVATE;
+ return 0;
+}
Index: cfe/trunk/lib/Lex/PPLexerChange.cpp
===================================================================
--- cfe/trunk/lib/Lex/PPLexerChange.cpp
+++ cfe/trunk/lib/Lex/PPLexerChange.cpp
@@ -287,6 +287,14 @@
return EndPos;
}
+static void collectAllSubModulesWithUmbrellaHeader(
+ const Module &Mod, SmallVectorImpl<const Module *> &SubMods) {
+ if (Mod.getUmbrellaHeader())
+ SubMods.push_back(&Mod);
+ for (auto *M : Mod.submodules())
+ collectAllSubModulesWithUmbrellaHeader(*M, SubMods);
+}
+
void Preprocessor::diagnoseMissingHeaderInUmbrellaDir(const Module &Mod) {
assert(Mod.getUmbrellaHeader() && "Module must use umbrella header");
SourceLocation StartLoc =
@@ -507,10 +515,15 @@
}
// If we are building a module that has an umbrella header, make sure that
- // each of the headers within the directory covered by the umbrella header
- // was actually included by the umbrella header.
- if (Module *Mod = getCurrentModule())
- diagnoseMissingHeaderInUmbrellaDir(*Mod);
+ // each of the headers within the directory, including all submodules, is
+ // covered by the umbrella header was actually included by the umbrella
+ // header.
+ if (Module *Mod = getCurrentModule()) {
+ llvm::SmallVector<const Module *, 4> AllMods;
+ collectAllSubModulesWithUmbrellaHeader(*Mod, AllMods);
+ for (auto *M : AllMods)
+ diagnoseMissingHeaderInUmbrellaDir(*M);
+ }
return true;
}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits