When an error occurs while building a module on demand, provide "While
building module 'Foo' imported from..." notes (the same we we provide
"In file included from..." notes) in the diagnostic, so that we know
how this module got included in the first place. This is part of
<rdar://problem/12696425>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169021 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Modules/build-fail-notes.m b/test/Modules/build-fail-notes.m
new file mode 100644
index 0000000..fe55223
--- /dev/null
+++ b/test/Modules/build-fail-notes.m
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodule-cache-path %t -fmodules -F %S/Inputs -DgetModuleVersion="epic fail" %s 2>&1 | FileCheck %s
+
+@__experimental_modules_import DependsOnModule;
+
+// CHECK: While building module 'DependsOnModule' imported from
+// CHECK: While building module 'Module' imported from
+// CHECK: error: expected ';' after top level declarator
+// CHECK: note: expanded from macro 'getModuleVersion'
+// CHECK: fatal error: could not build module 'Module'
+// CHECK: fatal error: could not build module 'DependsOnModule'
+// CHECK-NOT: error: