]> granicus.if.org Git - clang/commitdiff
Don't throw exceptions in clang-tblgen by switching to PrintFatalError.
authorJoerg Sonnenberger <joerg@bec.de>
Thu, 25 Oct 2012 16:37:08 +0000 (16:37 +0000)
committerJoerg Sonnenberger <joerg@bec.de>
Thu, 25 Oct 2012 16:37:08 +0000 (16:37 +0000)
Add locations in a number of places, where they are available for free.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166691 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/ClangDiagnosticsEmitter.cpp
utils/TableGen/ClangSACheckersEmitter.cpp
utils/TableGen/NeonEmitter.cpp
utils/TableGen/OptParserEmitter.cpp

index 6cf15acac32975e57695065fc3d90ca723dfcbcb..b1472a87cc10a3bbe305ffc548b1be49322048be 100644 (file)
@@ -18,6 +18,7 @@
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/TableGen/Error.h"
 #include "llvm/TableGen/Record.h"
 #include "llvm/TableGen/TableGenBackend.h"
 #include <algorithm>
@@ -394,8 +395,8 @@ void EmitClangDiagsDefs(RecordKeeper &Records, raw_ostream &OS,
       if (DefInit *Group = dyn_cast<DefInit>(R.getValueInit("Group"))) {
         const Record *GroupRec = Group->getDef();
         const std::string &GroupName = GroupRec->getValueAsString("GroupName");
-        throw "Error " + R.getName() + " cannot be in a warning group [" +
-              GroupName + "]";
+        PrintFatalError(R.getLoc(), "Error " + R.getName() +
+                      " cannot be in a warning group [" + GroupName + "]");
       }
     }
 
@@ -556,7 +557,8 @@ void EmitClangDiagGroups(RecordKeeper &Records, raw_ostream &OS) {
     if (I->first.find_first_not_of("abcdefghijklmnopqrstuvwxyz"
                                    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                                    "0123456789!@#$%^*-+=:?")!=std::string::npos)
-      throw "Invalid character in diagnostic group '" + I->first + "'";
+      PrintFatalError("Invalid character in diagnostic group '" +
+                      I->first + "'");
     OS.write_escaped(I->first) << "\","
                                << std::string(MaxLen-I->first.size()+1, ' ');
 
index 26891f80b0fc2ffcfa2ef8db91699f2bb2cebba2..8c74064a63683bf58bacfcd896def5511ad866f3 100644 (file)
@@ -12,6 +12,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/ADT/DenseSet.h"
+#include "llvm/TableGen/Error.h"
 #include "llvm/TableGen/Record.h"
 #include "llvm/TableGen/TableGenBackend.h"
 #include <map>
@@ -133,7 +134,8 @@ void EmitClangSACheckers(RecordKeeper &Records, raw_ostream &OS) {
           DI = dyn_cast<DefInit>(R->getValueInit("ParentPackage")))
       package = DI->getDef();
     if (!isCheckerNamed(R) && !package)
-      throw "Checker '" + R->getName() + "' is neither named, nor in a package!";
+      PrintFatalError(R->getLoc(), "Checker '" + R->getName() +
+                      "' is neither named, nor in a package!");
 
     if (isCheckerNamed(R)) {
       // Create a pseudo-group to hold this checker.
index 68373063baaee76697b3bf1d85bd714957dc479d..d453ededd5e96320562219778a7a360b9bdefcdc 100644 (file)
@@ -245,7 +245,7 @@ static void ParseTypes(Record *r, std::string &s,
       case 'f':
         break;
       default:
-        throw TGError(r->getLoc(),
+        PrintFatalError(r->getLoc(),
                       "Unexpected letter: " + std::string(data + len, 1));
     }
     TV.push_back(StringRef(data, len + 1));
@@ -266,7 +266,8 @@ static char Widen(const char t) {
       return 'l';
     case 'h':
       return 'f';
-    default: throw "unhandled type in widen!";
+    default:
+      PrintFatalError("unhandled type in widen!");
   }
 }
 
@@ -282,7 +283,8 @@ static char Narrow(const char t) {
       return 'i';
     case 'f':
       return 'h';
-    default: throw "unhandled type in narrow!";
+    default:
+      PrintFatalError("unhandled type in narrow!");
   }
 }
 
@@ -453,7 +455,7 @@ static std::string TypeString(const char mod, StringRef typestr) {
       s += quad ? "x4" : "x2";
       break;
     default:
-      throw "unhandled type!";
+      PrintFatalError("unhandled type!");
   }
 
   if (mod == '2')
@@ -635,7 +637,7 @@ static std::string MangleName(const std::string &name, StringRef typestr,
     }
     break;
   default:
-    throw "unhandled type!";
+    PrintFatalError("unhandled type!");
   }
   if (ck == ClassB)
     s += "_v";
@@ -773,7 +775,7 @@ static unsigned GetNumElements(StringRef typestr, bool &quad) {
   case 'h': nElts = 4; break;
   case 'f': nElts = 2; break;
   default:
-    throw "unhandled type!";
+    PrintFatalError("unhandled type!");
   }
   if (quad) nElts <<= 1;
   return nElts;
@@ -1004,7 +1006,7 @@ static std::string GenOpString(OpKind op, const std::string &proto,
     break;
   }
   default:
-    throw "unknown OpKind!";
+    PrintFatalError("unknown OpKind!");
   }
   return s;
 }
@@ -1049,7 +1051,7 @@ static unsigned GetNeonEnum(const std::string &proto, StringRef typestr) {
       ET = NeonTypeFlags::Float32;
       break;
     default:
-      throw "unhandled type!";
+      PrintFatalError("unhandled type!");
   }
   NeonTypeFlags Flags(ET, usgn, quad && proto[1] != 'g');
   return Flags.getFlags();
@@ -1381,7 +1383,7 @@ void NeonEmitter::emitIntrinsic(raw_ostream &OS, Record *R) {
   if (R->getSuperClasses().size() >= 2)
     classKind = ClassMap[R->getSuperClasses()[1]];
   if (classKind == ClassNone && kind == OpNone)
-    throw TGError(R->getLoc(), "Builtin has no class kind");
+    PrintFatalError(R->getLoc(), "Builtin has no class kind");
 
   for (unsigned ti = 0, te = TypeVec.size(); ti != te; ++ti) {
     if (kind == OpReinterpret) {
@@ -1423,7 +1425,7 @@ static unsigned RangeFromType(const char mod, StringRef typestr) {
     case 'l':
       return (1 << (int)quad) - 1;
     default:
-      throw "unhandled type!";
+      PrintFatalError("unhandled type!");
   }
 }
 
@@ -1456,7 +1458,7 @@ void NeonEmitter::runHeader(raw_ostream &OS) {
     ParseTypes(R, Types, TypeVec);
 
     if (R->getSuperClasses().size() < 2)
-      throw TGError(R->getLoc(), "Builtin has no class kind");
+      PrintFatalError(R->getLoc(), "Builtin has no class kind");
 
     std::string name = R->getValueAsString("Name");
     ClassKind ck = ClassMap[R->getSuperClasses()[1]];
@@ -1501,7 +1503,7 @@ void NeonEmitter::runHeader(raw_ostream &OS) {
     ParseTypes(R, Types, TypeVec);
 
     if (R->getSuperClasses().size() < 2)
-      throw TGError(R->getLoc(), "Builtin has no class kind");
+      PrintFatalError(R->getLoc(), "Builtin has no class kind");
 
     int si = -1, qi = -1;
     uint64_t mask = 0, qmask = 0;
@@ -1600,7 +1602,7 @@ void NeonEmitter::runHeader(raw_ostream &OS) {
     ParseTypes(R, Types, TypeVec);
 
     if (R->getSuperClasses().size() < 2)
-      throw TGError(R->getLoc(), "Builtin has no class kind");
+      PrintFatalError(R->getLoc(), "Builtin has no class kind");
 
     ClassKind ck = ClassMap[R->getSuperClasses()[1]];
 
index f095a28b4a72c128858291b5325491f32586357f..674c89af9f992fcbc2a8168e553c2fc733817287 100644 (file)
@@ -77,7 +77,7 @@ static int CompareOptionRecords(const void *Av, const void *Bv) {
       B->getValueAsListOfStrings("Prefixes")) {
     PrintError(A->getLoc(), Twine("Option is equivilent to"));
     PrintError(B->getLoc(), Twine("Other defined here"));
-    throw "Eqivilant Options found.";
+    PrintFatalError("Equivalent Options found.");
   }
   return APrec < BPrec ? -1 : 1;
 }