r279838 - Don't diagnose non-modular includes when we are not compiling a module.
Manman Ren via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 26 10:16:47 PDT 2016
Author: mren
Date: Fri Aug 26 12:16:46 2016
New Revision: 279838
URL: http://llvm.org/viewvc/llvm-project?rev=279838&view=rev
Log:
Don't diagnose non-modular includes when we are not compiling a module.
This is triggered when we are compiling an implementation of a module,
it has relative includes to a VFS-mapped module with umbrella headers.
Currently we will find the real path to headers under the umbrella directory,
but the umbrella directories are using virtual path.
rdar://27951255
Thanks Ben and Richard for reviewing the patch!
Differential Revision: http://reviews.llvm.org/D23858
Added:
cfe/trunk/test/VFS/Inputs/Nonmodular/
cfe/trunk/test/VFS/Inputs/Nonmodular/A.h
cfe/trunk/test/VFS/Inputs/Nonmodular/Nonmodular.modulemap
cfe/trunk/test/VFS/Inputs/Nonmodular/nonmodular-headers.yaml
cfe/trunk/test/VFS/Inputs/Nonmodular/test.c
cfe/trunk/test/VFS/Inputs/Nonmodular/umbrella.h
cfe/trunk/test/VFS/test_nonmodular.c
Modified:
cfe/trunk/lib/Lex/ModuleMap.cpp
Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=279838&r1=279837&r2=279838&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Fri Aug 26 12:16:46 2016
@@ -297,7 +297,9 @@ void ModuleMap::diagnoseHeaderInclusion(
if (LangOpts.ModulesStrictDeclUse) {
Diags.Report(FilenameLoc, diag::err_undeclared_use_of_module)
<< RequestingModule->getFullModuleName() << Filename;
- } else if (RequestingModule && RequestingModuleIsModuleInterface) {
+ } else if (RequestingModule && RequestingModuleIsModuleInterface &&
+ LangOpts.isCompilingModule()) {
+ // Do not diagnose when we are not compiling a module.
diag::kind DiagID = RequestingModule->getTopLevelModule()->IsFramework ?
diag::warn_non_modular_include_in_framework_module :
diag::warn_non_modular_include_in_module;
Added: cfe/trunk/test/VFS/Inputs/Nonmodular/A.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/VFS/Inputs/Nonmodular/A.h?rev=279838&view=auto
==============================================================================
--- cfe/trunk/test/VFS/Inputs/Nonmodular/A.h (added)
+++ cfe/trunk/test/VFS/Inputs/Nonmodular/A.h Fri Aug 26 12:16:46 2016
@@ -0,0 +1 @@
+// A.h
Added: cfe/trunk/test/VFS/Inputs/Nonmodular/Nonmodular.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/VFS/Inputs/Nonmodular/Nonmodular.modulemap?rev=279838&view=auto
==============================================================================
--- cfe/trunk/test/VFS/Inputs/Nonmodular/Nonmodular.modulemap (added)
+++ cfe/trunk/test/VFS/Inputs/Nonmodular/Nonmodular.modulemap Fri Aug 26 12:16:46 2016
@@ -0,0 +1,5 @@
+framework module Nonmodular [extern_c] {
+ umbrella header "umbrella.h"
+ export *
+ module * { export * }
+}
Added: cfe/trunk/test/VFS/Inputs/Nonmodular/nonmodular-headers.yaml
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/VFS/Inputs/Nonmodular/nonmodular-headers.yaml?rev=279838&view=auto
==============================================================================
--- cfe/trunk/test/VFS/Inputs/Nonmodular/nonmodular-headers.yaml (added)
+++ cfe/trunk/test/VFS/Inputs/Nonmodular/nonmodular-headers.yaml Fri Aug 26 12:16:46 2016
@@ -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"
+ }
+ ]
+ }
+ ]
+}
Added: cfe/trunk/test/VFS/Inputs/Nonmodular/test.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/VFS/Inputs/Nonmodular/test.c?rev=279838&view=auto
==============================================================================
--- cfe/trunk/test/VFS/Inputs/Nonmodular/test.c (added)
+++ cfe/trunk/test/VFS/Inputs/Nonmodular/test.c Fri Aug 26 12:16:46 2016
@@ -0,0 +1,3 @@
+// expected-no-diagnostics
+
+#include "umbrella.h"
Added: cfe/trunk/test/VFS/Inputs/Nonmodular/umbrella.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/VFS/Inputs/Nonmodular/umbrella.h?rev=279838&view=auto
==============================================================================
--- cfe/trunk/test/VFS/Inputs/Nonmodular/umbrella.h (added)
+++ cfe/trunk/test/VFS/Inputs/Nonmodular/umbrella.h Fri Aug 26 12:16:46 2016
@@ -0,0 +1,5 @@
+#ifndef __umbrella_h__
+#define __umbrella_h__
+
+#include <Nonmodular/A.h>
+#endif
Added: cfe/trunk/test/VFS/test_nonmodular.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/VFS/test_nonmodular.c?rev=279838&view=auto
==============================================================================
--- cfe/trunk/test/VFS/test_nonmodular.c (added)
+++ cfe/trunk/test/VFS/test_nonmodular.c Fri Aug 26 12:16:46 2016
@@ -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
More information about the cfe-commits
mailing list