[cfe-commits] r149200 - in /cfe/trunk: lib/Frontend/ASTUnit.cpp lib/Frontend/CompilerInstance.cpp test/Index/Inputs/Headers/crash.h test/Index/Inputs/Headers/module.map test/Index/crash-recovery-modules.m

Douglas Gregor dgregor at apple.com
Sun Jan 29 11:57:03 PST 2012


Author: dgregor
Date: Sun Jan 29 13:57:03 2012
New Revision: 149200

URL: http://llvm.org/viewvc/llvm-project?rev=149200&view=rev
Log:
Ensure that we clean up after a failed module build and cope with the
results in libclang.


Added:
    cfe/trunk/test/Index/Inputs/Headers/crash.h   (with props)
    cfe/trunk/test/Index/crash-recovery-modules.m
Modified:
    cfe/trunk/lib/Frontend/ASTUnit.cpp
    cfe/trunk/lib/Frontend/CompilerInstance.cpp
    cfe/trunk/test/Index/Inputs/Headers/module.map

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=149200&r1=149199&r2=149200&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Sun Jan 29 13:57:03 2012
@@ -576,6 +576,9 @@
   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();
   }
 };

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=149200&r1=149199&r2=149200&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Sun Jan 29 13:57:03 2012
@@ -926,7 +926,7 @@
   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

Added: cfe/trunk/test/Index/Inputs/Headers/crash.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Inputs/Headers/crash.h?rev=149200&view=auto
==============================================================================
--- cfe/trunk/test/Index/Inputs/Headers/crash.h (added)
+++ cfe/trunk/test/Index/Inputs/Headers/crash.h Sun Jan 29 13:57:03 2012
@@ -0,0 +1,6 @@
+// Produce a crash if CRASH is defined.
+#ifdef CRASH
+#  pragma clang __debug crash
+#endif
+
+const char *getCrashString();

Propchange: cfe/trunk/test/Index/Inputs/Headers/crash.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cfe/trunk/test/Index/Inputs/Headers/crash.h
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cfe/trunk/test/Index/Inputs/Headers/crash.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: cfe/trunk/test/Index/Inputs/Headers/module.map
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Inputs/Headers/module.map?rev=149200&r1=149199&r2=149200&view=diff
==============================================================================
--- cfe/trunk/test/Index/Inputs/Headers/module.map (original)
+++ cfe/trunk/test/Index/Inputs/Headers/module.map Sun Jan 29 13:57:03 2012
@@ -5,3 +5,6 @@
   }
 }
 
+module Crash {
+  header "crash.h"
+}

Added: cfe/trunk/test/Index/crash-recovery-modules.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/crash-recovery-modules.m?rev=149200&view=auto
==============================================================================
--- cfe/trunk/test/Index/crash-recovery-modules.m (added)
+++ cfe/trunk/test/Index/crash-recovery-modules.m Sun Jan 29 13:57:03 2012
@@ -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
+
+ at import Crash;
+
+void test() {
+  const char* error = getCrashString();
+}





More information about the cfe-commits mailing list