]> granicus.if.org Git - clang/commitdiff
Ensure that we clean up after a failed module build and cope with the
authorDouglas Gregor <dgregor@apple.com>
Sun, 29 Jan 2012 19:57:03 +0000 (19:57 +0000)
committerDouglas Gregor <dgregor@apple.com>
Sun, 29 Jan 2012 19:57:03 +0000 (19:57 +0000)
results in libclang.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149200 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/ASTUnit.cpp
lib/Frontend/CompilerInstance.cpp
test/Index/Inputs/Headers/crash.h [new file with mode: 0644]
test/Index/Inputs/Headers/module.map
test/Index/crash-recovery-modules.m [new file with mode: 0644]

index c23c64497afd1249557d460fef83f96eacc6e1e0..abeb3174bd39c4c99101f6f69f85807b56400885 100644 (file)
@@ -576,6 +576,9 @@ public:
   DiagnosticConsumer *clone(DiagnosticsEngine &Diags) const {
     // Just drop any diagnostics that come from cloned consumers; they'll
     // have different source managers anyway.
+    // FIXME: We'd like to be able to capture these somehow, even if it's just
+    // file/line/column, because they could occur when parsing module maps or
+    // building modules on-demand.
     return new IgnoringDiagConsumer();
   }
 };
index cc8d3b48a281a4587b338c724ecf389d71d75c2a..4f6ba166a778b30fdb46e02d6a32110901a7ce6e 100644 (file)
@@ -926,7 +926,7 @@ void LockFileManager::waitForUnlock() {
   const unsigned MaxSeconds = 3600;
   do {
     // Sleep for the designated interval, to allow the owning process time to
-    // finish up and
+    // finish up and remove the lock file.
     // FIXME: Should we hook in to system APIs to get a notification when the
     // lock file is deleted?
 #if LLVM_ON_WIN32
diff --git a/test/Index/Inputs/Headers/crash.h b/test/Index/Inputs/Headers/crash.h
new file mode 100644 (file)
index 0000000..238359a
--- /dev/null
@@ -0,0 +1,6 @@
+// Produce a crash if CRASH is defined.
+#ifdef CRASH
+#  pragma clang __debug crash
+#endif
+
+const char *getCrashString();
index e875210662e0caa35b0fa73bcf2b9f273e2abd2d..55f8eb7eaa24260a2fda94dd1102beddee42d6ce 100644 (file)
@@ -5,3 +5,6 @@ module LibA {
   }
 }
 
+module Crash {
+  header "crash.h"
+}
diff --git a/test/Index/crash-recovery-modules.m b/test/Index/crash-recovery-modules.m
new file mode 100644 (file)
index 0000000..195b50f
--- /dev/null
@@ -0,0 +1,19 @@
+// Clear out the module cache entirely, so we start from nothing.
+// RUN: rm -rf %t
+
+// Parse the file, such that building the module will cause Clang to crash.
+// RUN: not env CINDEXTEST_FAILONERROR=1 c-index-test -test-load-source all -fmodules -fmodule-cache-path %t -Xclang -fdisable-module-hash -I %S/Inputs/Headers -DCRASH %s 2> %t.err
+// RUN: FileCheck < %t.err -check-prefix=CHECK-CRASH %s
+// CHECK-CRASH: crash-recovery-modules.m:15:9:{15:2-15:14}: fatal error: could not build module 'Crash'
+
+// Parse the file again, without crashing, to make sure that
+// subsequent parses do the right thing.
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -test-load-source all -fmodules -fmodule-cache-path %t -Xclang -fdisable-module-hash -I %S/Inputs/Headers %s
+
+// REQUIRES: crash-recovery
+
+@import Crash;
+
+void test() {
+  const char* error = getCrashString();
+}