]> code.delx.au - gnu-emacs/commitdiff
First Coccinelle semantic patch.
authorDmitry Antipov <dmantipov@yandex.ru>
Sun, 24 Jun 2012 16:18:41 +0000 (20:18 +0400)
committerDmitry Antipov <dmantipov@yandex.ru>
Sun, 24 Jun 2012 16:18:41 +0000 (20:18 +0400)
* coccinelle: New subdirectory
* coccinelle/README: Documentation stub.
* coccinelle/vector_contents.cocci: Semantic patch to replace direct
access to `contents' member of Lisp_Vector objects with AREF and ASET
where appropriate.

admin/ChangeLog
admin/coccinelle/README [new file with mode: 0644]
admin/coccinelle/vector_contents.cocci [new file with mode: 0644]

index ec6448dbeee7b849722b3647d5a67eea76546afd..44856f4b4499a71d9401a19b98e308b59a976c5a 100644 (file)
@@ -1,3 +1,12 @@
+2012-06-24  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       First Coccinelle semantic patch.
+       * coccinelle: New subdirectory
+       * coccinelle/README: Documentation stub.
+       * coccinelle/vector_contents.cocci: Semantic patch to replace direct
+        access to `contents' member of Lisp_Vector objects with AREF and ASET
+        where appropriate.
+
 2012-06-22  Paul Eggert  <eggert@cs.ucla.edu>
 
        Support higher-resolution time stamps (Bug#9000).
diff --git a/admin/coccinelle/README b/admin/coccinelle/README
new file mode 100644 (file)
index 0000000..48a88db
--- /dev/null
@@ -0,0 +1,3 @@
+This directory contains semantic patches for Coccinelle, a program matching
+and transformation tool for programs written in C.  For more details, see
+http://coccinelle.lip6.fr.
diff --git a/admin/coccinelle/vector_contents.cocci b/admin/coccinelle/vector_contents.cocci
new file mode 100644 (file)
index 0000000..beebc2d
--- /dev/null
@@ -0,0 +1,16 @@
+// Avoid direct access to `contents' member of
+// Lisp_Vector, use AREF and ASET where possible.
+@expression@
+identifier I1, I2;
+expression E1, E2;
+@@
+(
+- XVECTOR (I1)->contents[I2++] = E1
++ ASET (I1, I2, E1), I2++
+|
+- XVECTOR (I1)->contents[E1] = E2
++ ASET (I1, E1, E2)
+|
+-XVECTOR (I1)->contents[E1]
++AREF (I1, E1)
+)