[LLVMdev] Proposal for better assertions in LLVM

Talin viridia at gmail.com
Wed Jul 27 17:25:40 PDT 2011

If LLVM decides not to adopt it, I'd still like it for my own frontend. (If
it does decide to adopt it, I'll use the LLVM version in my frontend.)

On Wed, Jul 27, 2011 at 4:00 PM, Chandler Carruth <chandlerc at google.com>wrote:

> On Wed, Jul 27, 2011 at 3:31 PM, Talin <viridia at gmail.com> wrote:
>> Can you explain how it avoids evaluating the arguments in the false case?
>> I looked at the code but it's pretty complex.
> Essentially it expands to something like:
> !(Ty == STy) ? (void)0 : Voidifier() & llvm::dbgs() << ...
> where you have something vaguely along the lines of
> struct Voidifier {
>   void operator&(raw_ostream &);
> };
> The conditional expression ensures that the side-effects of the LHS and RHS
> are contained, while allowing the convenient syntax. The voidifier hack is
> just for types, there are other simple ways to phrase it that boil down to
> the same construct. You could also implement it in LLVM as:
> if (!(Ty == STy)) {} else llvm::dbgs()
> which works as long as its not used as the lone statement in an unbraced
> else statement.
> The existing implementations are much more complex in order to support
> various different constructs. Something like the above would likely serve
> LLVM's needs. Again, I'm happy to provide a very minimal implementation for
> consideration if there is interest, I'm just not sure there is interest.

-- Talin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110727/2a9c1d0c/attachment.html>

More information about the llvm-dev mailing list