aboutsummaryrefslogtreecommitdiffstats
path: root/utils/TableGen/TableGen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utils/TableGen/TableGen.cpp')
-rw-r--r--utils/TableGen/TableGen.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/utils/TableGen/TableGen.cpp b/utils/TableGen/TableGen.cpp
index e8eacb841d..23a67c0b84 100644
--- a/utils/TableGen/TableGen.cpp
+++ b/utils/TableGen/TableGen.cpp
@@ -208,6 +208,7 @@ int main(int argc, char **argv) {
if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputFilename.c_str(), File)) {
errs() << "Could not open input file '" << InputFilename << "': "
<< ec.message() <<"\n";
+ Init::ReleaseMemory();
return 1;
}
MemoryBuffer *F = File.take();
@@ -221,25 +222,30 @@ int main(int argc, char **argv) {
TGParser Parser(SrcMgr, Records);
- if (Parser.ParseFile())
+ if (Parser.ParseFile()) {
+ Init::ReleaseMemory();
return 1;
+ }
std::string Error;
tool_output_file Out(OutputFilename.c_str(), Error);
if (!Error.empty()) {
errs() << argv[0] << ": error opening " << OutputFilename
<< ":" << Error << "\n";
+ Init::ReleaseMemory();
return 1;
}
if (!DependFilename.empty()) {
if (OutputFilename == "-") {
errs() << argv[0] << ": the option -d must be used together with -o\n";
+ Init::ReleaseMemory();
return 1;
}
tool_output_file DepOut(DependFilename.c_str(), Error);
if (!Error.empty()) {
errs() << argv[0] << ": error opening " << DependFilename
<< ":" << Error << "\n";
+ Init::ReleaseMemory();
return 1;
}
DepOut.os() << DependFilename << ":";
@@ -382,11 +388,14 @@ int main(int argc, char **argv) {
}
default:
assert(1 && "Invalid Action");
+ Init::ReleaseMemory();
return 1;
}
// Declare success.
Out.keep();
+
+ Init::ReleaseMemory();
return 0;
} catch (const TGError &Error) {
@@ -399,5 +408,7 @@ int main(int argc, char **argv) {
errs() << argv[0] << ": Unknown unexpected exception occurred.\n";
}
+ Init::ReleaseMemory();
+
return 1;
}