<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>I don't think you'd really be able to do this with matchers without major modifications to the matcher architecture.<br></div>
<div> </div>
<div>Your best bet would be - I believe - to only have the ifStmt(...) as your matcher, and do the "isFollowedBy" logic in the callback. You'll also need to bind the containing CompoundStmt.<br></div>
<div> </div>
<div id="sig19426265"><div class="signature">---<br></div>
<div class="signature">Best regards,<br></div>
<div class="signature"> </div>
<div class="signature">Gábor 'ShdNx' Kozár<br></div>
<div class="signature"><a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__gaborkozar.me&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=CnzuN65ENJ1H9py9XLiRvC_UQz6u3oG6GUNn7_wosSM&m=Ew0Z4kXtXqFRKCBQzJQJiO_HqoQfL8TwILpY1QTIIhc&s=euYT5CPehXyXNmRBraqQYVw20qr0GUqwzN_lB0JGy38&e=">http://gaborkozar.me</a><br></div>
</div>
<div> </div>
<div> </div>
<div>On Tue, May 26, 2015, at 21:25, Richard wrote:<br></div>
<blockquote type="cite"><div>I recently had to go through a bit of manual coding in order to match<br></div>
<div>this in clang-tidy:<br></div>
<div> </div>
<div>if (expr)<br></div>
<div>  return true;<br></div>
<div>return false;<br></div>
<div> </div>
<div>What I really wanted was to be able to write something like this:<br></div>
<div> </div>
<div>compoundStmt(<br></div>
<div>  isFollowedBy(<br></div>
<div>    ifStmt(<br></div>
<div>      hasThen(returnStmt(has(booleanLiteral(equals(true))))),<br></div>
<div>      unless(hasElse(anything()))),<br></div>
<div>    returnStmt(has(booleanLiteral(equals(false))))<br></div>
<div>  )<br></div>
<div>)<br></div>
<div> </div>
<div>There are matchers that tell me if a compound statment has <b>*any*</b><br></div>
<div>substatement, but there aren't any matchers that allow me to specify<br></div>
<div>the order in which related statements appear within a compound<br></div>
<div>statement.<br></div>
<div> </div>
<div>(Aside: note the heavy-handed use of the has() matcher above on a<br></div>
<div>returnStmt.  There's no way to access the return expression directly<br></div>
<div>on a returnStmt.)<br></div>
<div> </div>
<div>In my case I really needed an "isFollowedBy" style matcher, because I<br></div>
<div>didn't want to match this:<br></div>
<div> </div>
<div>if (expr)<br></div>
<div>  return true;<br></div>
<div>doSomethingElse();<br></div>
<div>return false;<br></div>
<div> </div>
<div>However, I can easily see people wanting to match a compound statement<br></div>
<div>that has two related statements in a particular order, but possibly<br></div>
<div>with other statements in between.<br></div>
<div> </div>
<div>I'm interested in hearing thoughts on such a squential matcher<br></div>
<div>"isFollowedBy" and how I would implement such a thing.  So far my<br></div>
<div>forays into matchers have been really small and I haven't yet learned<br></div>
<div>the subtleties or the full vocabulary of the matcher macros.<br></div>
<div> </div>
<div> </div>
<div>PS: Mail filters are blocking my messages, so ignore this, its<br></div>
<div>only for them.  Lorem ipsum dolor sit amet, consectetur adipiscing<br></div>
<div>elit. Phasellus consequat ullamcorper mollis. Sed blandit semper tortor<br></div>
<div>ultricies dictum. Proin hendrerit et quam in sagittis. Maecenas vel<br></div>
<div>blandit ante, in auctor sem.  Phasellus condimentum leo vel finibus<br></div>
<div>viverra. Duis fermentum sollicitudin est, ac iaculis lectus auctor vel.<br></div>
<div>Nam condimentum nulla feugiat, venenatis nibh a, elementum nulla. Nulla<br></div>
<div>vitae malesuada eros. Nulla cursus maximus ligula non hendrerit.<br></div>
<div> </div>
<div>Curabitur lobortis nulla vel sapien posuere, id aliquam orci<br></div>
<div>bibendum. Vestibulum at vulputate risus. Proin in purus commodo,<br></div>
<div>tempus lectus vitae, faucibus nunc. Aenean congue faucibus elit, sit<br></div>
<div>amet facilisis nibh ultrices eget. Nam pulvinar leo ac nunc ultricies,<br></div>
<div>nec tincidunt nulla tincidunt. Etiam placerat felis tellus, ut ultricies<br></div>
<div>nunc ultricies quis. In placerat sapien nec ultricies mattis. Integer<br></div>
<div>sed tempor orci, ac imperdiet orci. Integer ac augue et augue convallis<br></div>
<div>faucibus.<br></div>
<div>--<br></div>
<div>"The Direct3D Graphics Pipeline" free book<br></div>
<div><<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__tinyurl.com_d3d-2Dpipeline&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=CnzuN65ENJ1H9py9XLiRvC_UQz6u3oG6GUNn7_wosSM&m=Ew0Z4kXtXqFRKCBQzJQJiO_HqoQfL8TwILpY1QTIIhc&s=y0mPrvlbgBKGPRJOSnvoz0whDUCK1GvXSaP3DL4u3bY&e=">http://tinyurl.com/d3d-pipeline</a>><br></div>
<div>    The Computer Graphics Museum <<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__ComputerGraphicsMuseum.org&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=CnzuN65ENJ1H9py9XLiRvC_UQz6u3oG6GUNn7_wosSM&m=Ew0Z4kXtXqFRKCBQzJQJiO_HqoQfL8TwILpY1QTIIhc&s=ltslajns1hVGH5rDkVZgYRWH4r1UvTXWNJ-1NQ7C9Kc&e=">http://ComputerGraphicsMuseum.org</a>><br></div>
<div>        The Terminals Wiki <<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__terminals.classiccmp.org&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=CnzuN65ENJ1H9py9XLiRvC_UQz6u3oG6GUNn7_wosSM&m=Ew0Z4kXtXqFRKCBQzJQJiO_HqoQfL8TwILpY1QTIIhc&s=EbtQ1Pce_oXNB8OnVz-XmDrJktyzfUZvmZ9_BAORACU&e=">http://terminals.classiccmp.org</a>><br></div>
<div>  Legalize Adulthood! (my blog) <<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__LegalizeAdulthood.wordpress.com&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=CnzuN65ENJ1H9py9XLiRvC_UQz6u3oG6GUNn7_wosSM&m=Ew0Z4kXtXqFRKCBQzJQJiO_HqoQfL8TwILpY1QTIIhc&s=zNFKXNjxneuMnIceEzq91JxqrU8CuwiD0p6BkKCOQAs&e=">http://LegalizeAdulthood.wordpress.com</a>><br></div>
<div><u>_______________________________________________</u><br></div>
<div>cfe-dev mailing list<br></div>
<div><a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br></div>
<div><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br></div>
</blockquote><div> </div>
</body>
</html>