[llvm] r231577 - Make the assertion macros in Verifier and Linter truly variadic.
Duncan P. N. Exon Smith
dexonsmith at apple.com
Fri Mar 13 20:16:09 PDT 2015
> On 2015 Mar 13, at 20:14, Duncan P. N. Exon Smith <dexonsmith at apple.com> wrote:
>
>
>> On 2015 Mar 7, at 13:15, Benjamin Kramer <benny.kra at googlemail.com> wrote:
>>
>> Author: d0k
>> Date: Sat Mar 7 15:15:40 2015
>> New Revision: 231577
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=231577&view=rev
>> Log:
>> Make the assertion macros in Verifier and Linter truly variadic.
>>
>
> Nice cleanup!
>
>> NFC.
>
> Actually... (see below)
>
>>
>> Modified:
>> llvm/trunk/lib/Analysis/Lint.cpp
>> llvm/trunk/lib/IR/Verifier.cpp
>>
>> Modified: llvm/trunk/lib/Analysis/Lint.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/Lint.cpp?rev=231577&r1=231576&r2=231577&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Analysis/Lint.cpp (original)
>> +++ llvm/trunk/lib/Analysis/Lint.cpp Sat Mar 7 15:15:40 2015
>> @@ -129,27 +129,26 @@ namespace {
>> }
>> void print(raw_ostream &O, const Module *M) const override {}
>>
>> - void WriteValue(const Value *V) {
>> - if (!V) return;
>> - if (isa<Instruction>(V)) {
>> - MessagesStr << *V << '\n';
>> - } else {
>> - V->printAsOperand(MessagesStr, true, Mod);
>> - MessagesStr << '\n';
>> + void WriteValues(ArrayRef<const Value *> Vs) {
>> + for (const Value *V : Vs) {
>> + if (!V)
>> + continue;
>> + if (isa<Instruction>(V)) {
>> + MessagesStr << *V << '\n';
>> + } else {
>> + V->printAsOperand(MessagesStr, true, Mod);
>> + MessagesStr << '\n';
>> + }
>> }
>> }
>>
>> // CheckFailed - A check failed, so print out the condition and the message
>> // that failed. This provides a nice place to put a breakpoint if you want
>> // to see why something is not correct.
>
> This is no longer true. I was playing with a similar patch myself
> while I was on holiday -- strange timing -- and I noticed that
> `b CheckFailed` no longer works (at least, not in `lldb`). The
> problem is that you need to specify `CheckFailed<...>` as the
> breakpoint target.
>
> My workaround was to add a `CheckFailedMsg()` function:
>
> void CheckFailedMsg(const Twine &Message) {
> MessagesStr << Message.str() << "\n";
> }
>
> and have `CheckFailed()` call it. Then `CheckFailedMsg()` serves
> as a nice target for a breakpoint.
>
> Any other ideas?
FTR, I noticed this with the Verifier, but I assume the same applies
to the Linter.
>
>> - void CheckFailed(const Twine &Message,
>> - const Value *V1 = nullptr, const Value *V2 = nullptr,
>> - const Value *V3 = nullptr, const Value *V4 = nullptr) {
>> - MessagesStr << Message.str() << "\n";
>> - WriteValue(V1);
>> - WriteValue(V2);
>> - WriteValue(V3);
>> - WriteValue(V4);
>> + template <typename... Ts>
>> + void CheckFailed(const Twine &Message, const Ts &...Vs) {
>> + MessagesStr << Message << '\n';
>> + WriteValues({Vs...});
>> }
>> };
>>
More information about the llvm-commits
mailing list