[llvm] [TableGen] Add PrintError family overload that take a print function (PR #107333)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 4 22:03:11 PDT 2024
================
@@ -1600,18 +1601,13 @@ static TreePatternNode &getOperandNum(unsigned OpNo, TreePatternNode &N,
return N;
}
- OpNo -= NumResults;
-
- if (OpNo >= N.getNumChildren()) {
- std::string S;
- raw_string_ostream OS(S);
- OS << "Invalid operand number in type constraint " << (OpNo + NumResults)
- << " ";
- N.print(OS);
- PrintFatalError(S);
+ if (OpNo - NumResults >= N.getNumChildren()) {
+ PrintFatalError([&N, OpNo](raw_ostream &OS) {
+ OS << formatv("Invalid operand number {0} in type constraint ", OpNo);
----------------
topperc wrote:
Doesn't formatv create a buffer to hold the full string before printing? Would `OS << "Invalid operand number " << OpNo << "in type constraint" be better?
https://github.com/llvm/llvm-project/pull/107333
More information about the llvm-commits
mailing list