manmanren created this revision.
manmanren added reviewers: rsmith, benlangmuir.
manmanren added a subscriber: cfe-commits.
We used to have -fmodule-implementation-of and it was merged with
-fmodule-name. But this causes some regression on our internal projects. We are
now seeing non-modular include warnings.
This is triggered when we have relative includes to a VFS-mapped module, -I
that points us to the real header and -F that points us to the vfs. The real
header that is part of the umbrella directory will be classified as non-modular.
It seems like we can use CompilingModule to tell if we are compiling the
interface of a module or the implementation file of a module. When compiling
the implementation file, we don't diagnose non-modular includes. The
non-modular includes will be diagnosed when building the interface and writing
the pcm file.
Related changes:
http://llvm.org/viewvc/llvm-project?rev=213767&view=rev
http://llvm.org/viewvc/llvm-project?rev=261372&view=rev
http://llvm.org/viewvc/llvm-project?rev=263449&view=rev
https://reviews.llvm.org/D23858
Files:
lib/Lex/PPDirectives.cpp
test/VFS/Inputs/Nonmodular/A.h
test/VFS/Inputs/Nonmodular/Nonmodular.modulemap
test/VFS/Inputs/Nonmodular/nonmodular-headers.yaml
test/VFS/Inputs/Nonmodular/test.c
test/VFS/Inputs/Nonmodular/umbrella.h
test/VFS/test_nonmodular.c
Index: test/VFS/test_nonmodular.c
===================================================================
--- test/VFS/test_nonmodular.c
+++ test/VFS/test_nonmodular.c
@@ -0,0 +1,11 @@
+// REQUIRES: shell
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/vdir %t/cache %t/outdir
+// We can't have module.map inside Inputs/Nonmodular.
+// RUN: cp %S/Inputs/Nonmodular/Nonmodular.modulemap %t/outdir/module.modulemap
+//
+// RUN: sed -e "s:VDIR:%t/vdir:g" -e "s:IN_DIR:%S:g" -e "s:OUT_DIR:%t/outdir:g" %S/Inputs/Nonmodular/nonmodular-headers.yaml > %t/vdir/nonmodular-headers.yaml
+// RUN: %clang_cc1 -fmodule-name=Nonmodular -fmodules -Wnon-modular-include-in-framework-module -verify -fimplicit-module-maps -fmodules-cache-path=%t/cache -ivfsoverlay %t/vdir/nonmodular-headers.yaml -I %S/Inputs -F %t/vdir -fsyntax-only %S/Inputs/Nonmodular/test.c
+
+// expected-no-diagnostics
Index: test/VFS/Inputs/Nonmodular/umbrella.h
===================================================================
--- test/VFS/Inputs/Nonmodular/umbrella.h
+++ test/VFS/Inputs/Nonmodular/umbrella.h
@@ -0,0 +1,5 @@
+#ifndef __umbrella_h__
+#define __umbrella_h__
+
+#include <Nonmodular/A.h>
+#endif
Index: test/VFS/Inputs/Nonmodular/test.c
===================================================================
--- test/VFS/Inputs/Nonmodular/test.c
+++ test/VFS/Inputs/Nonmodular/test.c
@@ -0,0 +1,3 @@
+// expected-no-diagnostics
+
+#include "umbrella.h"
Index: test/VFS/Inputs/Nonmodular/nonmodular-headers.yaml
===================================================================
--- test/VFS/Inputs/Nonmodular/nonmodular-headers.yaml
+++ test/VFS/Inputs/Nonmodular/nonmodular-headers.yaml
@@ -0,0 +1,34 @@
+{
+ 'version': 0,
+ 'case-sensitive': 'false',
+ 'ignore-non-existent-contents': 'true',
+ 'roots': [
+ {
+ 'type': 'directory',
+ 'name': "VDIR/Nonmodular.framework/Headers",
+ 'contents': [
+ {
+ 'type': 'file',
+ 'name': "umbrella.h",
+ 'external-contents': "IN_DIR/Inputs/Nonmodular/umbrella.h"
+ },
+ {
+ 'type': 'file',
+ 'name': "A.h",
+ 'external-contents': "IN_DIR/Inputs/Nonmodular/A.h"
+ }
+ ]
+ },
+ {
+ 'type': 'directory',
+ 'name': "VDIR/Nonmodular.framework/Modules",
+ 'contents': [
+ {
+ 'type': 'file',
+ 'name': "module.modulemap",
+ 'external-contents': "OUT_DIR/module.modulemap"
+ }
+ ]
+ }
+ ]
+}
Index: test/VFS/Inputs/Nonmodular/Nonmodular.modulemap
===================================================================
--- test/VFS/Inputs/Nonmodular/Nonmodular.modulemap
+++ test/VFS/Inputs/Nonmodular/Nonmodular.modulemap
@@ -0,0 +1,5 @@
+framework module Nonmodular [extern_c] {
+ umbrella header "umbrella.h"
+ export *
+ module * { export * }
+}
Index: test/VFS/Inputs/Nonmodular/A.h
===================================================================
--- test/VFS/Inputs/Nonmodular/A.h
+++ test/VFS/Inputs/Nonmodular/A.h
@@ -0,0 +1 @@
+// A.h
Index: lib/Lex/PPDirectives.cpp
===================================================================
--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -746,7 +746,8 @@
ModuleMap::KnownHeader *SuggestedModule,
bool SkipCache) {
Module *RequestingModule = getModuleForLocation(FilenameLoc);
- bool RequestingModuleIsModuleInterface = !SourceMgr.isInMainFile(FilenameLoc);
+ bool RequestingModuleIsModuleInterface =
+ !SourceMgr.isInMainFile(FilenameLoc) && getLangOpts().CompilingModule;
// If the header lookup mechanism may be relative to the current inclusion
// stack, record the parent #includes.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits