[modules] If we hit a failure while loading a PCH/module, abort parsing instead of trying to continue in an invalid state.
Also don't let libclang create a PCH with such an error.
Fixes rdar://13953768
llvm-svn: 182629
diff --git a/clang/test/Modules/fatal-module-loader-error.m b/clang/test/Modules/fatal-module-loader-error.m
new file mode 100644
index 0000000..acfc539
--- /dev/null
+++ b/clang/test/Modules/fatal-module-loader-error.m
@@ -0,0 +1,26 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: touch %t/Module.pcm
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t %s -fdisable-module-hash -F %S/Inputs -verify
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t %s -fdisable-module-hash -F %S/Inputs -DIMPLICIT -verify
+
+// This tests that after a fatal module loader error, we do not continue parsing.
+
+#ifdef IMPLICIT
+
+// expected-error@+1{{does not appear to be}}
+#import <Module/Module.h>
+#pragma clang __debug crash;
+
+#else
+
+// expected-error@+1{{does not appear to be}}
+@import Module;
+#pragma clang __debug crash;
+
+#endif
+
+// Also check that libclang does not create a PCH with such an error.
+// RUN: c-index-test -write-pch %t.pch -fmodules -fmodules-cache-path=%t %s \
+// RUN: -Xclang -fdisable-module-hash -F %S/Inputs 2>&1 | Filecheck %s
+// CHECK: Unable to write PCH file