r310605 - [Modules] Prevent #import to reenter header if not building a module.
Bruno Cardoso Lopes via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 10 08:16:24 PDT 2017
Author: bruno
Date: Thu Aug 10 08:16:24 2017
New Revision: 310605
URL: http://llvm.org/viewvc/llvm-project?rev=310605&view=rev
Log:
[Modules] Prevent #import to reenter header if not building a module.
When non-modular headers are imported while not building a module but
in -fmodules mode, be conservative and preserve the default #import
semantic: do not reenter headers.
rdar://problem/33745031
Added:
cfe/trunk/test/Modules/Inputs/import-textual/x.h
cfe/trunk/test/Modules/import-textual-nomodules.m
Modified:
cfe/trunk/lib/Lex/HeaderSearch.cpp
Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=310605&r1=310604&r2=310605&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Thu Aug 10 08:16:24 2017
@@ -1143,7 +1143,7 @@ bool HeaderSearch::ShouldEnterIncludeFil
// headers find in the wild might rely only on #import and do not contain
// controlling macros, be conservative and only try to enter textual headers
// if such macro is present.
- if (!FileInfo.isModuleHeader &&
+ if (FileInfo.isCompilingModuleHeader && !FileInfo.isModuleHeader &&
FileInfo.getControllingMacro(ExternalLookup))
TryEnterHdr = true;
return TryEnterHdr;
Added: cfe/trunk/test/Modules/Inputs/import-textual/x.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/import-textual/x.h?rev=310605&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/import-textual/x.h (added)
+++ cfe/trunk/test/Modules/Inputs/import-textual/x.h Thu Aug 10 08:16:24 2017
@@ -0,0 +1,6 @@
+#ifndef RANDOM_DEP
+
+ at interface X
+ at end
+
+#endif // RANDOM_DEP
Added: cfe/trunk/test/Modules/import-textual-nomodules.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/import-textual-nomodules.m?rev=310605&view=auto
==============================================================================
--- cfe/trunk/test/Modules/import-textual-nomodules.m (added)
+++ cfe/trunk/test/Modules/import-textual-nomodules.m Thu Aug 10 08:16:24 2017
@@ -0,0 +1,8 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps -I%S/Inputs/import-textual -fmodules-cache-path=%t %s -verify
+
+// expected-no-diagnostics
+
+#import "x.h"
+#import "x.h"
+
More information about the cfe-commits
mailing list