On Wed, 7 Jul 2010, Lucas De Marchi wrote: > On Wed, Jul 7, 2010 at 10:25 AM, Julia Lawall <[email protected]> wrote: > > I'm not completely sure to understand what the code looks like, so perhaps > > you could send an example. > > See the test-pure.c example attached. Function h is an example of a > function that can not be declared as pure since the result will be > returned as argument. Doing so will result in wrong results for some > optimization levels. > > What I want to do is to search for functions declared with this > attribute (by means of the #define EINA_PURE, as in the example) and > emit a warning if the function should not be declared that way. The > second part I can deal with, but I couldn't find a way to search for > functions with a certain attribute.
The only solution I have is quite hackish... Match a function prototype declaration and put a position variable on the ) and another one on the ;. Use python to find cases where they are not adjacent. Assume that those are the ones that contain the annotation. Depending on your code, this might generate a lot of false positives. But perhaps not so many that it would be completely useless. Unfortunately there is no way to get access to the text that appears between the ) and the ; julia _______________________________________________ Cocci mailing list [email protected] http://lists.diku.dk/mailman/listinfo/cocci (Web access from inside DIKUs LAN only)
