It looks like I need ~ too?  (I don't know C++ at all :)

julia


On Fri, 17 Dec 2010, Michael T wrote:

> Julia Lawall <julia <at> diku.dk> writes:
> > Could you send a small example of code you would like to be able to parse?  
> > With only toplevel functions.
> 
> Here is a nice example of C++-ish stuff for a start.  I note that spatch works
> fine on the function testclass() right now, so your suggestion of adding [:<>]
> as supported characters might go a long way.  For the sake of an argument I
> included a .cocci file below.
> 
> Regards,
> 
> Michael
> 
> ####  BEGIN C++  #####
> 
> #include <list>
> #include <iostream>
> 
> using namespace std;
> 
> #define RETVAL(a) a
> 
> class myclass
> {
> private:
>     std::list<int> mylist;
>     int someval;
> public:
>     myclass() : someval(1) {}
>     ~myclass();
>     RETVAL(void) add(int val);
>     RETVAL(void) print(void);
>     RETVAL(void) excep(void);
> };
> 
> myclass::~myclass()
> {
>     mylist.clear();
> }
> 
> RETVAL(void) myclass::add(int val)
> {
>     mylist.push_back(val);
> }
> 
> RETVAL(void) myclass::print(void)
> {
>     for (std::list<int>::iterator it = mylist.begin(); it != mylist.end();
>          ++it)
>         std::cout << "List element: " << *it << std::endl;
> }
> 
> RETVAL(void) myclass::excep(void)
> {
>     throw std::bad_alloc();
> }
> 
> extern "C"{
> 
> void testclass(void);
> 
> }
> 
> void testclass(void)
> {
>     myclass test;
>     test.add(1);
>     test.add(2);
>     test.print();
> }
> 
> int main()
> {
>     testclass();
>     return 0;
> }
> 
> ####  END C++  #####
> 
> ####  BEGIN COCCI  #####
> 
> @ r1 @
> @@
> 
> -test.add(1)
> +test.add(5)
> 
> @ r2 @
> @@
> 
>  mylist.push_back(val);
> +mylist.push_back(0);
> 
> ####  END COCCI  #####
> 
> 
> _______________________________________________
> Cocci mailing list
> [email protected]
> http://lists.diku.dk/mailman/listinfo/cocci
> (Web access from inside DIKUs LAN only)
> 
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to