Index: utils/TableGen/AsmMatcherEmitter.cpp =================================================================== --- utils/TableGen/AsmMatcherEmitter.cpp +++ utils/TableGen/AsmMatcherEmitter.cpp @@ -1159,8 +1159,9 @@ // use it, else just fall back to the underlying register class. const RecordVal *R = Rec->getValue("ParserMatchClass"); if (!R || !R->getValue()) - PrintFatalError("Record `" + Rec->getName() + - "' does not have a ParserMatchClass!\n"); + PrintFatalError(Rec->getLoc(), + "Record `" + Rec->getName() + + "' does not have a ParserMatchClass!\n"); if (DefInit *DI= dyn_cast(R->getValue())) { Record *MatchClass = DI->getDef(); Index: utils/TableGen/AsmWriterInst.cpp =================================================================== --- utils/TableGen/AsmWriterInst.cpp +++ utils/TableGen/AsmWriterInst.cpp @@ -93,8 +93,10 @@ != std::string::npos) { AddLiteralString(std::string(1, AsmString[DollarPos+1])); } else { - PrintFatalError("Non-supported escaped character found in instruction '" + - CGI.TheDef->getName() + "'!"); + PrintFatalError( + CGI.TheDef->getLoc(), + "Non-supported escaped character found in instruction '" + + CGI.TheDef->getName() + "'!"); } LastEmitted = DollarPos+2; continue; @@ -131,15 +133,19 @@ // brace. if (hasCurlyBraces) { if (VarEnd >= AsmString.size()) - PrintFatalError("Reached end of string before terminating curly brace in '" - + CGI.TheDef->getName() + "'"); + PrintFatalError( + CGI.TheDef->getLoc(), + "Reached end of string before terminating curly brace in '" + + CGI.TheDef->getName() + "'"); // Look for a modifier string. if (AsmString[VarEnd] == ':') { ++VarEnd; if (VarEnd >= AsmString.size()) - PrintFatalError("Reached end of string before terminating curly brace in '" - + CGI.TheDef->getName() + "'"); + PrintFatalError( + CGI.TheDef->getLoc(), + "Reached end of string before terminating curly brace in '" + + CGI.TheDef->getName() + "'"); std::string::size_type ModifierStart = VarEnd; while (VarEnd < AsmString.size() && isIdentChar(AsmString[VarEnd])) @@ -147,17 +153,22 @@ Modifier = std::string(AsmString.begin()+ModifierStart, AsmString.begin()+VarEnd); if (Modifier.empty()) - PrintFatalError("Bad operand modifier name in '"+ CGI.TheDef->getName() + "'"); + PrintFatalError(CGI.TheDef->getLoc(), + "Bad operand modifier name in '" + + CGI.TheDef->getName() + "'"); } if (AsmString[VarEnd] != '}') - PrintFatalError("Variable name beginning with '{' did not end with '}' in '" - + CGI.TheDef->getName() + "'"); + PrintFatalError( + CGI.TheDef->getLoc(), + "Variable name beginning with '{' did not end with '}' in '" + + CGI.TheDef->getName() + "'"); ++VarEnd; } if (VarName.empty() && Modifier.empty()) - PrintFatalError("Stray '$' in '" + CGI.TheDef->getName() + - "' asm string, maybe you want $$?"); + PrintFatalError(CGI.TheDef->getLoc(), + "Stray '$' in '" + CGI.TheDef->getName() + + "' asm string, maybe you want $$?"); if (VarName.empty()) { // Just a modifier, pass this into PrintSpecial. Index: utils/TableGen/CallingConvEmitter.cpp =================================================================== --- utils/TableGen/CallingConvEmitter.cpp +++ utils/TableGen/CallingConvEmitter.cpp @@ -108,7 +108,7 @@ O << Action->getValueAsString("Predicate"); } else { errs() << *Action; - PrintFatalError("Unknown CCPredicateAction!"); + PrintFatalError(Action->getLoc(), "Unknown CCPredicateAction!"); } O << ") {\n"; @@ -145,7 +145,8 @@ ListInit *RegList = Action->getValueAsListInit("RegList"); ListInit *ShadowRegList = Action->getValueAsListInit("ShadowRegList"); if (!ShadowRegList->empty() && ShadowRegList->size() != RegList->size()) - PrintFatalError("Invalid length of list of shadowed registers"); + PrintFatalError(Action->getLoc(), + "Invalid length of list of shadowed registers"); if (RegList->size() == 1) { O << IndentStr << "if (unsigned Reg = State.AllocateReg("; @@ -248,7 +249,8 @@ MVT::SimpleValueType DestVT = getValueType(DestTy); O << IndentStr << "LocVT = " << getEnumName(DestVT) << ";\n"; if (MVT(DestVT).isFloatingPoint()) { - PrintFatalError("CCPromoteToUpperBitsInType does not handle floating " + PrintFatalError(Action->getLoc(), + "CCPromoteToUpperBitsInType does not handle floating " "point"); } else { O << IndentStr << "if (ArgFlags.isSExt())\n" @@ -280,7 +282,7 @@ O << IndentStr << IndentStr << "return false;\n"; } else { errs() << *Action; - PrintFatalError("Unknown CCAction!"); + PrintFatalError(Action->getLoc(), "Unknown CCAction!"); } } } Index: utils/TableGen/CodeGenDAGPatterns.cpp =================================================================== --- utils/TableGen/CodeGenDAGPatterns.cpp +++ utils/TableGen/CodeGenDAGPatterns.cpp @@ -1407,7 +1407,8 @@ x.SDTCisSameSizeAs_Info.OtherOperandNum = R->getValueAsInt("OtherOperandNum"); } else { - PrintFatalError("Unrecognized SDTypeConstraint '" + R->getName() + "'!\n"); + PrintFatalError(R->getLoc(), + "Unrecognized SDTypeConstraint '" + R->getName() + "'!\n"); } } Index: utils/TableGen/CodeGenInstruction.cpp =================================================================== --- utils/TableGen/CodeGenInstruction.cpp +++ utils/TableGen/CodeGenInstruction.cpp @@ -33,18 +33,24 @@ if (DefInit *Init = dyn_cast(OutDI->getOperator())) { if (Init->getDef()->getName() != "outs") - PrintFatalError(R->getName() + ": invalid def name for output list: use 'outs'"); + PrintFatalError(R->getLoc(), + R->getName() + + ": invalid def name for output list: use 'outs'"); } else - PrintFatalError(R->getName() + ": invalid output list: use 'outs'"); + PrintFatalError(R->getLoc(), + R->getName() + ": invalid output list: use 'outs'"); NumDefs = OutDI->getNumArgs(); DagInit *InDI = R->getValueAsDag("InOperandList"); if (DefInit *Init = dyn_cast(InDI->getOperator())) { if (Init->getDef()->getName() != "ins") - PrintFatalError(R->getName() + ": invalid def name for input list: use 'ins'"); + PrintFatalError(R->getLoc(), + R->getName() + + ": invalid def name for input list: use 'ins'"); } else - PrintFatalError(R->getName() + ": invalid input list: use 'ins'"); + PrintFatalError(R->getLoc(), + R->getName() + ": invalid input list: use 'ins'"); unsigned MIOperandNo = 0; std::set OperandNames; @@ -63,7 +69,8 @@ DefInit *Arg = dyn_cast(ArgInit); if (!Arg) - PrintFatalError("Illegal operand for the '" + R->getName() + "' instruction!"); + PrintFatalError(R->getLoc(), "Illegal operand for the '" + R->getName() + + "' instruction!"); Record *Rec = Arg->getDef(); std::string PrintMethod = "printOperand"; @@ -88,8 +95,9 @@ // Verify that MIOpInfo has an 'ops' root value. if (!isa(MIOpInfo->getOperator()) || cast(MIOpInfo->getOperator())->getDef()->getName() != "ops") - PrintFatalError("Bad value for MIOperandInfo in operand '" + Rec->getName() + - "'\n"); + PrintFatalError(R->getLoc(), + "Bad value for MIOperandInfo in operand '" + + Rec->getName() + "'\n"); // If we have MIOpInfo, then we have #operands equal to number of entries // in MIOperandInfo. @@ -107,16 +115,20 @@ OperandType = "OPERAND_REGISTER"; } else if (!Rec->isSubClassOf("PointerLikeRegClass") && !Rec->isSubClassOf("unknown_class")) - PrintFatalError("Unknown operand class '" + Rec->getName() + - "' in '" + R->getName() + "' instruction!"); + PrintFatalError(R->getLoc(), "Unknown operand class '" + Rec->getName() + + "' in '" + R->getName() + + "' instruction!"); // Check that the operand has a name and that it's unique. if (ArgName.empty()) - PrintFatalError("In instruction '" + R->getName() + "', operand #" + - Twine(i) + " has no name!"); + PrintFatalError(R->getLoc(), "In instruction '" + R->getName() + + "', operand #" + Twine(i) + + " has no name!"); if (!OperandNames.insert(ArgName).second) - PrintFatalError("In instruction '" + R->getName() + "', operand #" + - Twine(i) + " has the same name as a previous operand!"); + PrintFatalError(R->getLoc(), + "In instruction '" + R->getName() + "', operand #" + + Twine(i) + + " has the same name as a previous operand!"); OperandList.emplace_back(Rec, ArgName, PrintMethod, EncoderMethod, OperandNamespace + "::" + OperandType, MIOperandNo, @@ -138,9 +150,11 @@ /// unsigned CGIOperandList::getOperandNamed(StringRef Name) const { unsigned OpIdx; - if (hasOperandNamed(Name, OpIdx)) return OpIdx; - PrintFatalError("'" + TheDef->getName() + - "' does not have an operand named '$" + Name + "'!"); + if (hasOperandNamed(Name, OpIdx)) + return OpIdx; + PrintFatalError(TheDef->getLoc(), "'" + TheDef->getName() + + "' does not have an operand named '$" + + Name + "'!"); } /// hasOperandNamed - Query whether the instruction has an operand of the @@ -159,7 +173,8 @@ std::pair CGIOperandList::ParseOperandName(const std::string &Op, bool AllowWholeOp) { if (Op.empty() || Op[0] != '$') - PrintFatalError(TheDef->getName() + ": Illegal operand name: '" + Op + "'"); + PrintFatalError(TheDef->getLoc(), + TheDef->getName() + ": Illegal operand name: '" + Op + "'"); std::string OpName = Op.substr(1); std::string SubOpName; @@ -169,7 +184,9 @@ if (DotIdx != std::string::npos) { SubOpName = OpName.substr(DotIdx+1); if (SubOpName.empty()) - PrintFatalError(TheDef->getName() + ": illegal empty suboperand name in '" +Op +"'"); + PrintFatalError(TheDef->getLoc(), + TheDef->getName() + + ": illegal empty suboperand name in '" + Op + "'"); OpName = OpName.substr(0, DotIdx); } @@ -179,8 +196,11 @@ // If one was needed, throw. if (OperandList[OpIdx].MINumOperands > 1 && !AllowWholeOp && SubOpName.empty()) - PrintFatalError(TheDef->getName() + ": Illegal to refer to" - " whole operand part of complex operand '" + Op + "'"); + PrintFatalError(TheDef->getLoc(), + TheDef->getName() + + ": Illegal to refer to" + " whole operand part of complex operand '" + + Op + "'"); // Otherwise, return the operand. return std::make_pair(OpIdx, 0U); @@ -189,7 +209,9 @@ // Find the suboperand number involved. DagInit *MIOpInfo = OperandList[OpIdx].MIOperandInfo; if (!MIOpInfo) - PrintFatalError(TheDef->getName() + ": unknown suboperand name in '" + Op + "'"); + PrintFatalError(TheDef->getLoc(), TheDef->getName() + + ": unknown suboperand name in '" + + Op + "'"); // Find the operand with the right name. for (unsigned i = 0, e = MIOpInfo->getNumArgs(); i != e; ++i) @@ -197,7 +219,9 @@ return std::make_pair(OpIdx, i); // Otherwise, didn't find it! - PrintFatalError(TheDef->getName() + ": unknown suboperand name in '" + Op + "'"); + PrintFatalError(TheDef->getLoc(), TheDef->getName() + + ": unknown suboperand name in '" + Op + + "'"); return std::make_pair(0U, 0U); } Index: utils/TableGen/CodeGenRegisters.cpp =================================================================== --- utils/TableGen/CodeGenRegisters.cpp +++ utils/TableGen/CodeGenRegisters.cpp @@ -739,8 +739,9 @@ for (unsigned i = 0, e = TypeList.size(); i != e; ++i) { Record *Type = TypeList[i]; if (!Type->isSubClassOf("ValueType")) - PrintFatalError("RegTypes list member '" + Type->getName() + - "' does not derive from the ValueType class!"); + PrintFatalError(R->getLoc(), + "RegTypes list member '" + Type->getName() + + "' does not derive from the ValueType class!"); VTs.push_back(getValueTypeByHwMode(Type, RegBank.getHwModes())); } assert(!VTs.empty() && "RegisterClass must contain at least one ValueType!"); Index: utils/TableGen/CodeGenSchedule.cpp =================================================================== --- utils/TableGen/CodeGenSchedule.cpp +++ utils/TableGen/CodeGenSchedule.cpp @@ -1935,8 +1935,9 @@ unsigned SCIdx = getSchedClassIdx(*Inst); if (!SCIdx) { if (Inst->TheDef->isValueUnset("SchedRW") && !HadCompleteModel) { - PrintError("No schedule information for instruction '" - + Inst->TheDef->getName() + "'"); + PrintError(Inst->TheDef->getLoc(), + "No schedule information for instruction '" + + Inst->TheDef->getName() + "'"); Complete = false; } continue; @@ -1954,8 +1955,9 @@ return R->getValueAsDef("SchedModel") == ProcModel.ModelDef; }); if (I == InstRWs.end()) { - PrintError("'" + ProcModel.ModelName + "' lacks information for '" + - Inst->TheDef->getName() + "'"); + PrintError(Inst->TheDef->getLoc(), "'" + ProcModel.ModelName + + "' lacks information for '" + + Inst->TheDef->getName() + "'"); Complete = false; } } Index: utils/TableGen/CodeGenTarget.cpp =================================================================== --- utils/TableGen/CodeGenTarget.cpp +++ utils/TableGen/CodeGenTarget.cpp @@ -491,9 +491,10 @@ } else if (PropList[i]->getName() == "SDNPWantParent") { Properties |= 1 << SDNPWantParent; } else { - PrintFatalError("Unsupported SD Node property '" + - PropList[i]->getName() + "' on ComplexPattern '" + - R->getName() + "'!"); + PrintFatalError(R->getLoc(), "Unsupported SD Node property '" + + PropList[i]->getName() + + "' on ComplexPattern '" + R->getName() + + "'!"); } } @@ -529,6 +530,7 @@ CodeGenIntrinsic::CodeGenIntrinsic(Record *R) { TheDef = R; std::string DefName = R->getName(); + ArrayRef DefLoc = R->getLoc(); ModRef = ReadWriteMem; Properties = 0; isOverloaded = false; @@ -543,7 +545,8 @@ if (DefName.size() <= 4 || std::string(DefName.begin(), DefName.begin() + 4) != "int_") - PrintFatalError("Intrinsic '" + DefName + "' does not start with 'int_'!"); + PrintFatalError(DefLoc, + "Intrinsic '" + DefName + "' does not start with 'int_'!"); EnumName = std::string(DefName.begin()+4, DefName.end()); @@ -565,7 +568,8 @@ // Verify it starts with "llvm.". if (Name.size() <= 5 || std::string(Name.begin(), Name.begin() + 5) != "llvm.") - PrintFatalError("Intrinsic '" + DefName + "'s name does not start with 'llvm.'!"); + PrintFatalError(DefLoc, "Intrinsic '" + DefName + + "'s name does not start with 'llvm.'!"); } // If TargetPrefix is specified, make sure that Name starts with @@ -574,8 +578,9 @@ if (Name.size() < 6+TargetPrefix.size() || std::string(Name.begin() + 5, Name.begin() + 6 + TargetPrefix.size()) != (TargetPrefix + ".")) - PrintFatalError("Intrinsic '" + DefName + "' does not start with 'llvm." + - TargetPrefix + ".'!"); + PrintFatalError(DefLoc, "Intrinsic '" + DefName + + "' does not start with 'llvm." + + TargetPrefix + ".'!"); } // Parse the list of return types. @@ -607,7 +612,8 @@ // Reject invalid types. if (VT == MVT::isVoid) - PrintFatalError("Intrinsic '" + DefName + " has void in result type list!"); + PrintFatalError(DefLoc, "Intrinsic '" + DefName + + " has void in result type list!"); IS.RetVTs.push_back(VT); IS.RetTypeDefs.push_back(TyEl); @@ -625,7 +631,8 @@ PrintError(R->getLoc(), "Parameter #" + Twine(i) + " has out of bounds matching " "number " + Twine(MatchTy)); - PrintFatalError(Twine("ParamTypes is ") + TypeList->getAsString()); + PrintFatalError(DefLoc, + Twine("ParamTypes is ") + TypeList->getAsString()); } VT = OverloadedVTs[MatchTy]; // It only makes sense to use the extended and truncated vector element @@ -646,7 +653,8 @@ // Reject invalid types. if (VT == MVT::isVoid && i != e-1 /*void at end means varargs*/) - PrintFatalError("Intrinsic '" + DefName + " has void in result type list!"); + PrintFatalError(DefLoc, "Intrinsic '" + DefName + + " has void in result type list!"); IS.ParamVTs.push_back(VT); IS.ParamTypeDefs.push_back(TyEl); Index: utils/TableGen/InstrInfoEmitter.cpp =================================================================== --- utils/TableGen/InstrInfoEmitter.cpp +++ utils/TableGen/InstrInfoEmitter.cpp @@ -628,13 +628,14 @@ // Emit all of the target-specific flags... BitsInit *TSF = Inst.TheDef->getValueAsBitsInit("TSFlags"); if (!TSF) - PrintFatalError("no TSFlags?"); + PrintFatalError(Inst.TheDef->getLoc(), "no TSFlags?"); uint64_t Value = 0; for (unsigned i = 0, e = TSF->getNumBits(); i != e; ++i) { if (const auto *Bit = dyn_cast(TSF->getBit(i))) Value |= uint64_t(Bit->getValue()) << i; else - PrintFatalError("Invalid TSFlags bit in " + Inst.TheDef->getName()); + PrintFatalError(Inst.TheDef->getLoc(), + "Invalid TSFlags bit in " + Inst.TheDef->getName()); } OS << ", 0x"; OS.write_hex(Value); Index: utils/TableGen/IntrinsicEmitter.cpp =================================================================== --- utils/TableGen/IntrinsicEmitter.cpp +++ utils/TableGen/IntrinsicEmitter.cpp @@ -770,8 +770,9 @@ BuiltinMap[Ints[i].TargetPrefix]; if (!BIM.insert(std::make_pair(BuiltinName, Ints[i].EnumName)).second) - PrintFatalError("Intrinsic '" + Ints[i].TheDef->getName() + - "': duplicate " + CompilerName + " builtin name!"); + PrintFatalError(Ints[i].TheDef->getLoc(), + "Intrinsic '" + Ints[i].TheDef->getName() + + "': duplicate " + CompilerName + " builtin name!"); Table.GetOrAddStringOffset(BuiltinName); } } Index: utils/TableGen/RISCVCompressInstEmitter.cpp =================================================================== --- utils/TableGen/RISCVCompressInstEmitter.cpp +++ utils/TableGen/RISCVCompressInstEmitter.cpp @@ -252,12 +252,14 @@ // Source instructions are non compressed instructions and don't have tied // operands. if (IsSource) - PrintFatalError("Input operands for Inst '" + Inst.TheDef->getName() + - "' and input Dag operand count mismatch"); + PrintFatalError(Inst.TheDef->getLoc(), + "Input operands for Inst '" + Inst.TheDef->getName() + + "' and input Dag operand count mismatch"); // The Dag can't have more arguments than the Instruction. if (Dag->getNumArgs() > Inst.Operands.size()) - PrintFatalError("Inst '" + Inst.TheDef->getName() + - "' and Dag operand count mismatch"); + PrintFatalError(Inst.TheDef->getLoc(), + "Inst '" + Inst.TheDef->getName() + + "' and Dag operand count mismatch"); // The Instruction might have tied operands so the Dag might have // a fewer operand count. @@ -267,8 +269,9 @@ --RealCount; if (Dag->getNumArgs() != RealCount) - PrintFatalError("Inst '" + Inst.TheDef->getName() + - "' and Dag operand count mismatch"); + PrintFatalError(Inst.TheDef->getLoc(), + "Inst '" + Inst.TheDef->getName() + + "' and Dag operand count mismatch"); return true; } @@ -529,7 +532,8 @@ bool Compress) { Record *AsmWriter = Target.getAsmWriter(); if (!AsmWriter->getValueAsInt("PassSubtarget")) - PrintFatalError("'PassSubtarget' is false. SubTargetInfo object is needed " + PrintFatalError(AsmWriter->getLoc(), + "'PassSubtarget' is false. SubTargetInfo object is needed " "for target features.\n"); std::string Namespace = Target.getName(); Index: utils/TableGen/SDNodeProperties.cpp =================================================================== --- utils/TableGen/SDNodeProperties.cpp +++ utils/TableGen/SDNodeProperties.cpp @@ -38,9 +38,9 @@ } else if (Property->getName() == "SDNPVariadic") { Properties |= 1 << SDNPVariadic; } else { - PrintFatalError("Unknown SD Node property '" + - Property->getName() + "' on node '" + - R->getName() + "'!"); + PrintFatalError(R->getLoc(), "Unknown SD Node property '" + + Property->getName() + "' on node '" + + R->getName() + "'!"); } } Index: utils/TableGen/SearchableTableEmitter.cpp =================================================================== --- utils/TableGen/SearchableTableEmitter.cpp +++ utils/TableGen/SearchableTableEmitter.cpp @@ -599,9 +599,10 @@ for (auto &Field : Table.Fields) { auto TI = dyn_cast(EntryRec->getValueInit(Field.Name)); if (!TI) { - PrintFatalError(Twine("Record '") + EntryRec->getName() + - "' in table '" + Table.Name + "' is missing field '" + - Field.Name + "'"); + PrintFatalError(EntryRec->getLoc(), + Twine("Record '") + EntryRec->getName() + + "' in table '" + Table.Name + + "' is missing field '" + Field.Name + "'"); } if (!Field.RecType) { Field.RecType = TI->getType(); @@ -653,8 +654,8 @@ StringRef FilterClass = EnumRec->getValueAsString("FilterClass"); Enum->Class = Records.getClass(FilterClass); if (!Enum->Class) - PrintFatalError(Twine("Enum FilterClass '") + FilterClass + - "' does not exist"); + PrintFatalError(EnumRec->getLoc(), Twine("Enum FilterClass '") + + FilterClass + "' does not exist"); collectEnumEntries(*Enum, NameField, ValueField, Records.getAllDerivedDefinitions(FilterClass)); @@ -674,9 +675,10 @@ if (auto TypeOfVal = TableRec->getValue(("TypeOf_" + FieldName).str())) { if (!parseFieldType(Table->Fields.back(), TypeOfVal->getValue())) { - PrintFatalError(Twine("Table '") + Table->Name + - "' has bad 'TypeOf_" + FieldName + "': " + - TypeOfVal->getValue()->getAsString()); + PrintFatalError(TableRec->getLoc(), + Twine("Table '") + Table->Name + + "' has bad 'TypeOf_" + FieldName + + "': " + TypeOfVal->getValue()->getAsString()); } } } @@ -704,8 +706,10 @@ Record *TableRec = IndexRec->getValueAsDef("Table"); auto It = TableMap.find(TableRec); if (It == TableMap.end()) - PrintFatalError(Twine("SearchIndex '") + IndexRec->getName() + - "' refers to non-existing table '" + TableRec->getName()); + PrintFatalError(IndexRec->getLoc(), + Twine("SearchIndex '") + IndexRec->getName() + + "' refers to non-existing table '" + + TableRec->getName()); GenericTable &Table = *It->second; Table.Indices.push_back(parseSearchIndex(