aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-08-01 19:21:43 +0000
committerChris Lattner <sabre@nondot.org>2003-08-01 19:21:43 +0000
commitf1e366acffbe4bdbb1d4a573c178f5531efdf7f8 (patch)
treecbbd823923bf627904cab192aad92ca3866c0c11
parentfafac12dcd9c6e9411f1f60da6b0b563c9148789 (diff)
downloadexternal_llvm-f1e366acffbe4bdbb1d4a573c178f5531efdf7f8.zip
external_llvm-f1e366acffbe4bdbb1d4a573c178f5531efdf7f8.tar.gz
external_llvm-f1e366acffbe4bdbb1d4a573c178f5531efdf7f8.tar.bz2
Make sure to delete the output file if there is an error
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7481 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--support/tools/TableGen/TableGen.cpp5
-rw-r--r--utils/TableGen/TableGen.cpp5
2 files changed, 8 insertions, 2 deletions
diff --git a/support/tools/TableGen/TableGen.cpp b/support/tools/TableGen/TableGen.cpp
index 4b0cd9d..088dcbe 100644
--- a/support/tools/TableGen/TableGen.cpp
+++ b/support/tools/TableGen/TableGen.cpp
@@ -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;
}
diff --git a/utils/TableGen/TableGen.cpp b/utils/TableGen/TableGen.cpp
index 4b0cd9d..088dcbe 100644
--- a/utils/TableGen/TableGen.cpp
+++ b/utils/TableGen/TableGen.cpp
@@ -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;
}