[llvm] [TableGen] Add PrintError family overload that take a print function (PR #107333)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 4 22:39:22 PDT 2024


jurahul wrote:

But your suggestion works as well.

On Wed, Sep 4, 2024 at 10:35 PM Rahul Joshi ***@***.***> wrote:

> AFAIK it does not. It splits the format string into fragments and prints
> them one-by-one.
>
> On Wed, Sep 4, 2024 at 10:03 PM Craig Topper ***@***.***>
> wrote:
>
>> ***@***.**** commented on this pull request.
>> ------------------------------
>>
>> In llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
>> <https://github.com/llvm/llvm-project/pull/107333#discussion_r1744805014>
>> :
>>
>> > @@ -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);
>>
>> Doesn't formatv create a buffer to hold the full string before printing?
>> Would `OS << "Invalid operand number " << OpNo << "in type constraint" be
>> better?
>>
>>>> Reply to this email directly, view it on GitHub
>> <https://github.com/llvm/llvm-project/pull/107333#pullrequestreview-2281854626>,
>> or unsubscribe
>> <https://github.com/notifications/unsubscribe-auth/APRMUB7RGNH547SHXTC6XTDZU7Q2BAVCNFSM6AAAAABNVK2A5WVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDEOBRHA2TINRSGY>
>> .
>> You are receiving this because you authored the thread.Message ID:
>> ***@***.***>
>>
>


https://github.com/llvm/llvm-project/pull/107333


More information about the llvm-commits mailing list