name_codelets.cocci 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * StarPU --- Runtime system for heterogeneous multicore architectures.
  3. *
  4. * Copyright (C) 2012 inria
  5. *
  6. * StarPU is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation; either version 2.1 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * StarPU is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. */
  17. /*
  18. * Codelets have a "name" attribute that is really useful for debugging
  19. * purposes. Lots of codelets do not use this attribute though, mostly because
  20. * they were written when it was not available.
  21. *
  22. * This semantic patch tries to add a "name" attribute when it is necessary.
  23. * The chosen name is the name of the codelet variable : it should be good
  24. * enough for debugging.
  25. */
  26. virtual context
  27. virtual org
  28. virtual patch
  29. virtual report
  30. @initialize:python depends on org || report@
  31. msg = "Warning: %s has no attribute name"
  32. @found@
  33. identifier cl;
  34. position p;
  35. @@
  36. struct starpu_codelet cl@p = {
  37. ...
  38. };
  39. @named depends on found@
  40. position found.p;
  41. identifier found.cl;
  42. expression E;
  43. @@
  44. struct starpu_codelet cl@p = {
  45. .name = E,
  46. };
  47. // Context mode.
  48. @depends on found && !named && context@
  49. identifier found.cl;
  50. position found.p;
  51. @@
  52. *struct starpu_codelet cl@p = {...};
  53. // Org mode.
  54. @script:python depends on found && !named && org@
  55. cl << found.cl;
  56. p << found.p;
  57. @@
  58. coccilib.org.print_todo(p[0], msg % cl)
  59. // Patch mode.
  60. @script:python stringify depends on found && !named && patch@
  61. cl_name << found.cl;
  62. guess;
  63. @@
  64. coccinelle.guess = '"' + str(cl_name) + '"'
  65. @depends on found && !named && patch@
  66. position found.p;
  67. identifier found.cl;
  68. identifier stringify.guess;
  69. @@
  70. struct starpu_codelet cl@p = {
  71. +.name = guess,
  72. };
  73. // Report mode.
  74. @script:python depends on found && !named && report@
  75. cl << found.cl;
  76. p << found.p;
  77. @@
  78. coccilib.report.print_report(p[0], msg % cl)