Make sure to delete the output file if there is an error
authorChris Lattner <sabre@nondot.org>
Fri, 1 Aug 2003 19:21:43 +0000 (19:21 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 1 Aug 2003 19:21:43 +0000 (19:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7481 91177308-0d34-0410-b5e6-96231b3b80d8

support/tools/TableGen/TableGen.cpp
utils/TableGen/TableGen.cpp

index 4b0cd9d2a33e2951d6b0b642c7dd3b31cb4a648d..088dcbe0e393fde7fb1211b4df58d97d2f908fcc 100644 (file)
@@ -431,7 +431,10 @@ int main(int argc, char **argv) {
     }
   } catch (const std::string &Error) {
     std::cerr << Error << "\n";
-    if (Out != &std::cout) delete Out;
+    if (Out != &std::cout) {
+      delete Out;                             // Close the file
+      std::remove(OutputFilename.c_str());    // Remove the file, it's broken
+    }
     return 1;
   }
 
index 4b0cd9d2a33e2951d6b0b642c7dd3b31cb4a648d..088dcbe0e393fde7fb1211b4df58d97d2f908fcc 100644 (file)
@@ -431,7 +431,10 @@ int main(int argc, char **argv) {
     }
   } catch (const std::string &Error) {
     std::cerr << Error << "\n";
-    if (Out != &std::cout) delete Out;
+    if (Out != &std::cout) {
+      delete Out;                             // Close the file
+      std::remove(OutputFilename.c_str());    // Remove the file, it's broken
+    }
     return 1;
   }