aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-01-29 19:57:03 +0000
committerDouglas Gregor <dgregor@apple.com>2012-01-29 19:57:03 +0000
commit85ae12db3bbc60b920c086f1cb23cc94ad4802ae (patch)
treec93593a3fec8753d321518cad0b1e7f6cbc76369
parentc5b2e58840748145d1706c1d1481369d1863fabf (diff)
Ensure that we clean up after a failed module build and cope with the
results in libclang. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149200 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Frontend/ASTUnit.cpp3
-rw-r--r--lib/Frontend/CompilerInstance.cpp2
-rw-r--r--test/Index/Inputs/Headers/crash.h6
-rw-r--r--test/Index/Inputs/Headers/module.map3
-rw-r--r--test/Index/crash-recovery-modules.m19
5 files changed, 32 insertions, 1 deletions
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp
index c23c64497a..abeb3174bd 100644
--- a/lib/Frontend/ASTUnit.cpp
+++ b/lib/Frontend/ASTUnit.cpp
@@ -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();
}
};
diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp
index cc8d3b48a2..4f6ba166a7 100644
--- a/lib/Frontend/CompilerInstance.cpp
+++ b/lib/Frontend/CompilerInstance.cpp
@@ -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
index 0000000000..238359abbe
--- /dev/null
+++ b/test/Index/Inputs/Headers/crash.h
@@ -0,0 +1,6 @@
+// Produce a crash if CRASH is defined.
+#ifdef CRASH
+# pragma clang __debug crash
+#endif
+
+const char *getCrashString();
diff --git a/test/Index/Inputs/Headers/module.map b/test/Index/Inputs/Headers/module.map
index e875210662..55f8eb7eaa 100644
--- a/test/Index/Inputs/Headers/module.map
+++ b/test/Index/Inputs/Headers/module.map
@@ -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
index 0000000000..195b50f42d
--- /dev/null
+++ b/test/Index/crash-recovery-modules.m
@@ -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();
+}