[cfe-commits] r143846 - in /cfe/trunk: lib/Driver/Compilation.cpp lib/Driver/Tools.cpp lib/Driver/Tools.h test/Driver/crash-cleanup.c

Peter Collingbourne peter at pcc.me.uk
Sat Nov 5 17:40:05 PDT 2011


Author: pcc
Date: Sat Nov  5 19:40:05 2011
New Revision: 143846

URL: http://llvm.org/viewvc/llvm-project?rev=143846&view=rev
Log:
Add the depfile as a result file so that it is deleted if we crash,
and prevent the diagnostic preprocessor run from writing a depfile.

Added:
    cfe/trunk/test/Driver/crash-cleanup.c
Modified:
    cfe/trunk/lib/Driver/Compilation.cpp
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/lib/Driver/Tools.h

Modified: cfe/trunk/lib/Driver/Compilation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Compilation.cpp?rev=143846&r1=143845&r2=143846&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Compilation.cpp (original)
+++ cfe/trunk/lib/Driver/Compilation.cpp Sat Nov  5 19:40:05 2011
@@ -217,8 +217,12 @@
 
   // Remove any user specified output.  Claim any unclaimed arguments, so as
   // to avoid emitting warnings about unused args.
-  if (TranslatedArgs->hasArg(options::OPT_o))
-    TranslatedArgs->eraseArg(options::OPT_o);
+  OptSpecifier OutputOpts[] = { options::OPT_o, options::OPT_MD,
+                                options::OPT_MMD };
+  for (unsigned i = 0; i != sizeof(OutputOpts)/sizeof(OutputOpts[0]); ++i) {
+    if (TranslatedArgs->hasArg(OutputOpts[i]))
+      TranslatedArgs->eraseArg(OutputOpts[i]);
+  }
   TranslatedArgs->ClaimAllArgs();
 
   // Redirect stdout/stderr to /dev/null.

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=143846&r1=143845&r2=143846&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Sat Nov  5 19:40:05 2011
@@ -203,7 +203,8 @@
   }
 }
 
-void Clang::AddPreprocessingOptions(const Driver &D,
+void Clang::AddPreprocessingOptions(Compilation &C,
+                                    const Driver &D,
                                     const ArgList &Args,
                                     ArgStringList &CmdArgs,
                                     const InputInfo &Output,
@@ -225,11 +226,13 @@
       DepFile = Output.getFilename();
     } else if (Arg *MF = Args.getLastArg(options::OPT_MF)) {
       DepFile = MF->getValue(Args);
+      C.addResultFile(DepFile);
     } else if (A->getOption().matches(options::OPT_M) ||
                A->getOption().matches(options::OPT_MM)) {
       DepFile = "-";
     } else {
       DepFile = darwin::CC1::getDependencyFileName(Args, Inputs);
+      C.addResultFile(DepFile);
     }
     CmdArgs.push_back("-dependency-file");
     CmdArgs.push_back(DepFile);
@@ -1541,7 +1544,7 @@
   //
   // FIXME: Support -fpreprocessed
   if (types::getPreprocessedType(InputType) != types::TY_INVALID)
-    AddPreprocessingOptions(D, Args, CmdArgs, Output, Inputs);
+    AddPreprocessingOptions(C, D, Args, CmdArgs, Output, Inputs);
 
   // Don't warn about "clang -c -DPIC -fPIC test.i" because libtool.m4 assumes
   // that "The compiler can only warn and ignore the option if not recognized".

Modified: cfe/trunk/lib/Driver/Tools.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.h?rev=143846&r1=143845&r2=143846&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.h (original)
+++ cfe/trunk/lib/Driver/Tools.h Sat Nov  5 19:40:05 2011
@@ -29,7 +29,8 @@
 
   /// \brief Clang compiler tool.
   class LLVM_LIBRARY_VISIBILITY Clang : public Tool {
-    void AddPreprocessingOptions(const Driver &D,
+    void AddPreprocessingOptions(Compilation &C,
+                                 const Driver &D,
                                  const ArgList &Args,
                                  ArgStringList &CmdArgs,
                                  const InputInfo &Output,

Added: cfe/trunk/test/Driver/crash-cleanup.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/crash-cleanup.c?rev=143846&view=auto
==============================================================================
--- cfe/trunk/test/Driver/crash-cleanup.c (added)
+++ cfe/trunk/test/Driver/crash-cleanup.c Sat Nov  5 19:40:05 2011
@@ -0,0 +1,7 @@
+// RUN: not %clang -o %t.o -MMD -MF %t.d %s
+// RUN: test ! -f %t.o
+// RUN: test ! -f %t.d
+// REQUIRES: shell
+// REQUIRES: crash-recovery
+
+#pragma clang __debug crash





More information about the cfe-commits mailing list