diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp index 6cf15acac329..b1472a87cc10 100644 --- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp +++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp @@ -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 @@ -394,8 +395,8 @@ void EmitClangDiagsDefs(RecordKeeper &Records, raw_ostream &OS, if (DefInit *Group = dyn_cast(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, ' '); diff --git a/clang/utils/TableGen/ClangSACheckersEmitter.cpp b/clang/utils/TableGen/ClangSACheckersEmitter.cpp index 26891f80b0fc..8c74064a6368 100644 --- a/clang/utils/TableGen/ClangSACheckersEmitter.cpp +++ b/clang/utils/TableGen/ClangSACheckersEmitter.cpp @@ -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 @@ -133,7 +134,8 @@ void EmitClangSACheckers(RecordKeeper &Records, raw_ostream &OS) { DI = dyn_cast(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. diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp index 68373063baae..d453ededd5e9 100644 --- a/clang/utils/TableGen/NeonEmitter.cpp +++ b/clang/utils/TableGen/NeonEmitter.cpp @@ -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]]; diff --git a/clang/utils/TableGen/OptParserEmitter.cpp b/clang/utils/TableGen/OptParserEmitter.cpp index f095a28b4a72..674c89af9f99 100644 --- a/clang/utils/TableGen/OptParserEmitter.cpp +++ b/clang/utils/TableGen/OptParserEmitter.cpp @@ -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; }