[applied] ini: Support '[' and ']' in arguments of function call expressions

Message ID 87sf6hpdoz.fsf@redhat.com
State New
Headers
Series [applied] ini: Support '[' and ']' in arguments of function call expressions |

Commit Message

Dodji Seketeli Oct. 11, 2023, 12:05 p.m. UTC
  Hello,

Consider the suppression specification below:

    [suppress_type]
      type_kind = struct
      has_data_member_inserted_at = offset_of_first_data_member_regexp(.*p[0-9]?$)

The parser wrongly considers that in the regular expression
".*p[0-9]?$", the characters '[' and ']' should be escaped.  Fixed
thus.

	* src/abg-ini.cc (char_is_function_name_char): The only delimiters
	should be the '(' and ')' characters.
	* tests/data/test-diff-suppr/test-has-data-member-inserted-at-1-report-2.txt:
	New reference test output.
	* tests/data/test-diff-suppr/test-has-data-member-inserted-at-1.2.suppr:
	New suppression specification.
	* tests/data/Makefile.am: Add the new test material above to
	source distribution.
	* tests/test-diff-suppr.cc (in_out_specs): Add the new test
	material above to this test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Applied to master
---
 src/abg-ini.cc                                         |  2 +-
 tests/data/Makefile.am                                 |  2 ++
 .../test-has-data-member-inserted-at-1-report-2.txt    |  4 ++++
 .../test-has-data-member-inserted-at-1.2.suppr         |  3 +++
 tests/test-diff-suppr.cc                               | 10 ++++++++++
 5 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100644 tests/data/test-diff-suppr/test-has-data-member-inserted-at-1-report-2.txt
 create mode 100644 tests/data/test-diff-suppr/test-has-data-member-inserted-at-1.2.suppr
  

Patch

diff --git a/src/abg-ini.cc b/src/abg-ini.cc
index 830b3ab8..4510675f 100644
--- a/src/abg-ini.cc
+++ b/src/abg-ini.cc
@@ -145,7 +145,7 @@  char_is_function_name_char(int b)
 static bool
 char_is_function_argument_char(int b)
 {
-  if (char_is_delimiter(b) || b == '(' || b == ')')
+  if (b == '(' || b == ')')
     return false;
   return true;
 }
diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
index 7b07236e..6031b48d 100644
--- a/tests/data/Makefile.am
+++ b/tests/data/Makefile.am
@@ -1893,6 +1893,8 @@  test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1-report-0.txt \
 test-diff-dwarf-abixml/PR25409-librte_bus_dpaa.so.20.0 \
 test-diff-dwarf-abixml/PR25409-librte_bus_dpaa.so.20.0.abi \
 test-diff-dwarf-abixml/PR25409-librte_bus_dpaa.so.20.0-report-0.txt \
+test-diff-suppr/test-has-data-member-inserted-at-1-report-2.txt \
+test-diff-suppr/test-has-data-member-inserted-at-1.2.suppr \
 \
 test-lookup-syms/test0.cc		\
 test-lookup-syms/test0.o		\
diff --git a/tests/data/test-diff-suppr/test-has-data-member-inserted-at-1-report-2.txt b/tests/data/test-diff-suppr/test-has-data-member-inserted-at-1-report-2.txt
new file mode 100644
index 00000000..b4ea5bf1
--- /dev/null
+++ b/tests/data/test-diff-suppr/test-has-data-member-inserted-at-1-report-2.txt
@@ -0,0 +1,4 @@ 
+Functions changes summary: 0 Removed, 0 Changed, 0 Added function
+Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
+Unreachable types summary: 0 removed, 0 changed (1 filtered out), 0 added type
+
diff --git a/tests/data/test-diff-suppr/test-has-data-member-inserted-at-1.2.suppr b/tests/data/test-diff-suppr/test-has-data-member-inserted-at-1.2.suppr
new file mode 100644
index 00000000..bbf52d92
--- /dev/null
+++ b/tests/data/test-diff-suppr/test-has-data-member-inserted-at-1.2.suppr
@@ -0,0 +1,3 @@ 
+[suppress_type]
+  type_kind = struct
+  has_data_member_inserted_at = offset_of_first_data_member_regexp(.*p[0-9]?$)
diff --git a/tests/test-diff-suppr.cc b/tests/test-diff-suppr.cc
index 19db440b..4e63b2cc 100644
--- a/tests/test-diff-suppr.cc
+++ b/tests/test-diff-suppr.cc
@@ -2266,6 +2266,16 @@  InOutSpec in_out_specs[] =
     "data/test-diff-suppr/test-has-data-member-inserted-at-1-report-1.txt",
     "output/test-diff-suppr/test-has-data-member-inserted-at-1-report-1.txt"
   },
+  {
+    "data/test-diff-suppr/test-has-data-member-inserted-at-1-v0.o",
+    "data/test-diff-suppr/test-has-data-member-inserted-at-1-v1.o",
+    "",
+    "",
+    "data/test-diff-suppr/test-has-data-member-inserted-at-1.2.suppr",
+    "--drop-private-types --no-default-suppression --non-reachable-types",
+    "data/test-diff-suppr/test-has-data-member-inserted-at-1-report-2.txt",
+    "output/test-diff-suppr/test-has-data-member-inserted-at-1-report-2.txt"
+  },
   // This should be the last entry
   {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
 };