[cfe-dev] how to implement "statement P is followed by statement Q" matcher?
Manuel Klimek
klimek at google.com
Thu Jun 11 03:35:34 PDT 2015
On Thu, May 28, 2015 at 5:51 PM Richard <legalize at xmission.com> wrote:
>
> In article <
> 1432806087.2498925.280264065.1368E918 at webmail.messagingengine.com>,
> Gabor Kozar <kozargabor at fastmail.fm> writes:
>
> > I don't think you'd really be able to do this with matchers without
> > major modifications to the matcher architecture.
>
> Why do you say that? All the information is available from within
> CompoundStmt provided I have the other two matchers. That's what I
> currently do now in the callback -- walk the CompoundStmt looking for
> the two consecutive statements that match my criteria (simplified and
> hard-coded for my case):
>
It sounds like we could implement an isnext matcher via the parent map:
hasPreviousNode(m):
parent = getParentFromParentMap()
loop over the compound statements children until we find the current node
return value of m on previous node
Patches welcome :)
>
> CompoundStmt::const_body_iterator BeforeIt = Compound->body_begin();
> CompoundStmt::const_body_iterator AfterIt = Compound->body_begin();
> for (++AfterIt;
> AfterIt != Compound->body_end() && *BeforeIt != Ret;
> ++BeforeIt, ++AfterIt) {
> if (auto *If = dyn_cast<IfStmt>(*BeforeIt)) {
> if (*AfterIt == Ret) {
> // ...
> }
> }
> }
>
> PS: Mail filters are blocking my messages, so ignore this, its
> only for them. Lorem ipsum dolor sit amet, consectetur adipiscing
> elit. Phasellus consequat ullamcorper mollis. Sed blandit semper tortor
> ultricies dictum. Proin hendrerit et quam in sagittis. Maecenas vel
> blandit ante, in auctor sem. Phasellus condimentum leo vel finibus
> viverra. Duis fermentum sollicitudin est, ac iaculis lectus auctor vel.
> Nam condimentum nulla feugiat, venenatis nibh a, elementum nulla. Nulla
> vitae malesuada eros. Nulla cursus maximus ligula non hendrerit.
>
> Curabitur lobortis nulla vel sapien posuere, id aliquam orci
> bibendum. Vestibulum at vulputate risus. Proin in purus commodo,
> tempus lectus vitae, faucibus nunc. Aenean congue faucibus elit, sit
> amet facilisis nibh ultrices eget. Nam pulvinar leo ac nunc ultricies,
> nec tincidunt nulla tincidunt. Etiam placerat felis tellus, ut ultricies
> nunc ultricies quis. In placerat sapien nec ultricies mattis. Integer
> sed tempor orci, ac imperdiet orci. Integer ac augue et augue convallis
> faucibus.
> --
> "The Direct3D Graphics Pipeline" free book <
> http://tinyurl.com/d3d-pipeline>
> The Computer Graphics Museum <http://ComputerGraphicsMuseum.org>
> The Terminals Wiki <http://terminals.classiccmp.org>
> Legalize Adulthood! (my blog) <http://LegalizeAdulthood.wordpress.com>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150611/2cdca357/attachment.html>
More information about the cfe-dev
mailing list