On Wednesday 13 January 2010 13:25:13 Michael Stefaniuc wrote:
> Nicolas Palix wrote:
> > On Wednesday 13 January 2010 12:10:20 Michael Stefaniuc wrote:
> >> Nicolas Palix wrote:
> >>> On Saturday 09 January 2010 17:26:37 Michael Stefaniuc wrote:
> > 
> > Please, could you report any performance improvement/degradation if you try 
> > this?
> Heh, I tried it already but I need to know the type of "SPAM" aka if
> it's an ERR or FIXME or WARN. I've done \(e...@p\|fi...@p\|w...@p\) and
> the last element matched is stored in p but that seems to be the
> function name and not the element to which p is attached.

That's indeed what p.current_element contains. To filter things at the SmPL
level without the regexp, you should to the following:

Rule rid matches any identifier. They are then filtered by the rule r which
request the same position (so it's the same id! :) )

As the identifier is a metavariable in the rule rid, you can use it in
Python or other SmPL rules in conjunction with "depends on r".

Note: The last Python rule is useless in your case. It's just for my tests and 
the record.

In doing so, you only have 2 SmPL rules and 1 Python one.

Hope it helps.

=========================================
@rid@
identifier xid;
position p;
@@

x...@p

@r@
position rid.p;
@@

 \(x...@p\|y...@p\)

@script:python depends on r@
p << rid.p;
x << rid.xid;
@@

print "Matched:  ", x, " ", p[0].current_element, " ",p[0].file , " ", 
p[0].line," ",p[0].column, " ", p[0].line_end," ",p[0].column_end

@script:python depends on !r@
p << rid.p;
x << rid.xid;
@@

print "Filtered: ", x, " ", p[0].current_element, " ",p[0].file , " ", 
p[0].line," ",p[0].column, " ", p[0].line_end," ",p[0].column_end
=========================================

-- 
Nicolas Palix
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to