ParseFile() may throw, so extend the try/catch to handle that.
authorJim Grosbach <grosbach@apple.com>
Fri, 6 May 2011 18:39:28 +0000 (18:39 +0000)
committerJim Grosbach <grosbach@apple.com>
Fri, 6 May 2011 18:39:28 +0000 (18:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131004 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/TableGen.cpp

index aa923025242138d6ea07d3a26a3eb684990040c3..d88a2d6a0e26491526573ad52ee84fb1cc6a0217 100644 (file)
@@ -228,19 +228,19 @@ int main(int argc, char **argv) {
   cl::ParseCommandLineOptions(argc, argv);
 
 
-  // Parse the input file.
-  if (ParseFile(InputFilename, IncludeDirs, SrcMgr, Records))
-    return 1;
+  try {
+    // Parse the input file.
+    if (ParseFile(InputFilename, IncludeDirs, SrcMgr, Records))
+      return 1;
 
-  std::string Error;
-  tool_output_file Out(OutputFilename.c_str(), Error);
-  if (!Error.empty()) {
-    errs() << argv[0] << ": error opening " << OutputFilename
-           << ":" << Error << "\n";
-    return 1;
-  }
+    std::string Error;
+    tool_output_file Out(OutputFilename.c_str(), Error);
+    if (!Error.empty()) {
+      errs() << argv[0] << ": error opening " << OutputFilename
+        << ":" << Error << "\n";
+      return 1;
+    }
 
-  try {
     switch (Action) {
     case PrintRecords:
       Out.os() << Records;           // No argument, dump all contents