[2/3] gdb: refactor make-target-delegates.py's ARGTYPES

Message ID fcd59d8fc507387a2e5023a9e06d16c54a6ed2bc.1699953637.git.tankut.baris.aktemur@intel.com
State New
Headers
Series [1/3] gdb: regenerate target-delegates.c |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_build--master-arm fail Patch failed to apply

Commit Message

Aktemur, Tankut Baris Nov. 14, 2023, 9:41 a.m. UTC
  Refactor the ARGTYPES regular expression in make-target-delegates.py
to eliminate '.*' for better control on what is matched.  This will be
helpful in the next patch where we recognize default argument values.
Also, simplify the "E" match group, for which the optional SYMBOL
becomes redundant because that case can be matched by the "T" group.

After applying this patch, running './make-target-delegates.py' does not
change anything in 'target-delegates.c'.
---
 gdb/make-target-delegates.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
  

Comments

Pedro Alves Nov. 14, 2023, 1:47 p.m. UTC | #1
Hi Baris,

On 2023-11-14 09:41, Tankut Baris Aktemur wrote:
> Refactor the ARGTYPES regular expression in make-target-delegates.py
> to eliminate '.*' for better control on what is matched.  This will be
> helpful in the next patch where we recognize default argument values.
> Also, simplify the "E" match group, for which the optional SYMBOL
> becomes redundant because that case can be matched by the "T" group.
> 
> After applying this patch, running './make-target-delegates.py' does not
> change anything in 'target-delegates.c'.

With the tweak to the commit log to not mention default arguments:

  Approved-By: Pedro Alves <pedro@palves.net>
  

Patch

diff --git a/gdb/make-target-delegates.py b/gdb/make-target-delegates.py
index 5bbe7c0b930..fd5f436a43d 100755
--- a/gdb/make-target-delegates.py
+++ b/gdb/make-target-delegates.py
@@ -73,17 +73,18 @@  METHOD = re.compile(
     + METHOD_TRAILER
 )
 
+# Space-separated symbols.
+CP_SYMBOLS = CP_SYMBOL + r"(\s+" + CP_SYMBOL + r")*"
+
 # Regular expression used to dissect argument types.
 ARGTYPES = re.compile(
     "^("
     + r"(?P<E>enum\s+"
     + SYMBOL
-    + r"\s*)("
-    + SYMBOL
-    + ")?"
-    + r"|(?P<T>.*(enum\s+)?"
-    + SYMBOL
-    + r".*(\s|\*|&))"
+    + r")"
+    + r"|(?P<T>"
+    + CP_SYMBOLS
+    + r"(\s|\*|&)+)"
     + SYMBOL
     + ")$"
 )