summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>2017-08-10 15:16:24 +0000
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>2017-08-10 15:16:24 +0000
commitfca5abc9d23354a98562b55f4ee80347c7ae2c6a (patch)
tree20f2c6fbe3bcb86307939aaf13202678f57ee762 /clang
parent926e2d39bf3862200586fbb061afb3121391dfc2 (diff)
downloadbcm5719-llvm-fca5abc9d23354a98562b55f4ee80347c7ae2c6a.tar.gz
bcm5719-llvm-fca5abc9d23354a98562b55f4ee80347c7ae2c6a.zip
[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 llvm-svn: 310605
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Lex/HeaderSearch.cpp2
-rw-r--r--clang/test/Modules/Inputs/import-textual/x.h6
-rw-r--r--clang/test/Modules/import-textual-nomodules.m8
3 files changed, 15 insertions, 1 deletions
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 1ebcc0a1c65..4b5df8c1cc6 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -1143,7 +1143,7 @@ bool HeaderSearch::ShouldEnterIncludeFile(Preprocessor &PP,
// 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;
diff --git a/clang/test/Modules/Inputs/import-textual/x.h b/clang/test/Modules/Inputs/import-textual/x.h
new file mode 100644
index 00000000000..9b41ccd0bdc
--- /dev/null
+++ b/clang/test/Modules/Inputs/import-textual/x.h
@@ -0,0 +1,6 @@
+#ifndef RANDOM_DEP
+
+@interface X
+@end
+
+#endif // RANDOM_DEP
diff --git a/clang/test/Modules/import-textual-nomodules.m b/clang/test/Modules/import-textual-nomodules.m
new file mode 100644
index 00000000000..7cf8c1e186d
--- /dev/null
+++ b/clang/test/Modules/import-textual-nomodules.m
@@ -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"
+
OpenPOWER on IntegriCloud