]> granicus.if.org Git - clang/commitdiff
The two libclang crash-recovery tests that involve precompiled
authorDouglas Gregor <dgregor@apple.com>
Sat, 11 Sep 2010 18:05:19 +0000 (18:05 +0000)
committerDouglas Gregor <dgregor@apple.com>
Sat, 11 Sep 2010 18:05:19 +0000 (18:05 +0000)
preambles end up leaving the precompiled preambles around. This is by
design, since we do minimal cleanup during crash recovery. However,
it's unfortunate for testing, so introduce a hook that allows these
two tests to put the precompiled preamble somewhere where we can
delete them after testing.

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

lib/Frontend/ASTUnit.cpp
test/Index/crash-recovery-code-complete.c
test/Index/crash-recovery-reparse.c

index 4cbb2a3f13a0e6fd772f714d4a071d98b2e40832..c203ffa9352333c4d355ddd2a90f3573cc9ce6d1 100644 (file)
@@ -803,6 +803,13 @@ static std::string GetPreamblePCHPath() {
   // FIXME: This is lame; sys::Path should provide this function (in particular,
   // it should know how to find the temporary files dir).
   // FIXME: This is really lame. I copied this code from the Driver!
+  // FIXME: This is a hack so that we can override the preamble file during
+  // crash-recovery testing, which is the only case where the preamble files
+  // are not necessarily cleaned up. 
+  const char *TmpFile = ::getenv("CINDEXTEST_PREAMBLE_FILE");
+  if (TmpFile)
+    return TmpFile;
+  
   std::string Error;
   const char *TmpDir = ::getenv("TMPDIR");
   if (!TmpDir)
index a80bdc2aee800b4286523de1fd669af706755d09..9cad985364f8b0317eebbae8a22d3051c7d2496e 100644 (file)
@@ -1,8 +1,9 @@
-// RUN: env CINDEXTEST_EDITING=1 \
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_PREAMBLE_FILE=%t-preamble.pch \
 // RUN:   not c-index-test -code-completion-at=%s:20:1 \
 // RUN:   "-remap-file=%s;%S/Inputs/crash-recovery-code-complete-remap.c" \
 // RUN:   %s 2> %t.err
 // RUN: FileCheck < %t.err -check-prefix=CHECK-CODE-COMPLETE-CRASH %s
+// RUN: rm %t-preamble.pch
 // CHECK-CODE-COMPLETE-CRASH: Unable to perform code completion!
 //
 // REQUIRES: crash-recovery
index e394bd18dfb5c92098d2df0122a1ab66bb1b7be2..243a914ec40dbbc7bf5fdfba77830f3c092f2542 100644 (file)
@@ -1,8 +1,9 @@
-// RUN: env CINDEXTEST_EDITING=1 \
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_PREAMBLE_FILE=%t-preamble.pch \
 // RUN:   not c-index-test -test-load-source-reparse 1 local \
 // RUN:   -remap-file="%s;%S/Inputs/crash-recovery-reparse-remap.c" \
 // RUN:   %s 2> %t.err
 // RUN: FileCheck < %t.err -check-prefix=CHECK-REPARSE-SOURCE-CRASH %s
+// RUN: rm %t-preamble.pch
 // CHECK-REPARSE-SOURCE-CRASH: Unable to reparse translation unit
 //
 // REQUIRES: crash-recovery