)]}'
{
  "commit": "137c886e9a624f68cba212ebdb156298957c25c4",
  "tree": "df46341752b65499df1fe7a3893456461c814ca9",
  "parents": [
    "4eeb0013059856b8660b4a0351589b096167b4d1"
  ],
  "author": {
    "name": "Tom de Vries",
    "email": "tdevries@suse.de",
    "time": "Fri Sep 30 05:47:54 2022 +0200"
  },
  "committer": {
    "name": "Tom de Vries",
    "email": "tdevries@suse.de",
    "time": "Fri Sep 30 05:47:54 2022 +0200"
  },
  "message": "[gdb/c++] Print destructor the same for gcc and clang\n\nConsider the test-case contained in this patch.\n\nWith g++ (7.5.0) we have for \"ptype A\":\n...\ntype \u003d class A {\n  public:\n    int a;\n\n    A(void);\n    ~A();\n}\n...\nand with clang++ (13.0.1):\n...\ntype \u003d class A {\n  public:\n    int a;\n\n    A(void);\n    ~A(void);\n}\n...\nand we observe that the destructor is printed differently.\n\nThere\u0027s a difference in debug info between the two cases: in the clang case,\nthere\u0027s one artificial parameter, but in the g++ case, there are two, and\nthese similar cases are handled differently in cp_type_print_method_args.\n\nThis is due to this slightly convoluted bit of code:\n...\n  i \u003d staticp ? 0 : 1;\n  if (nargs \u003e i)\n    {\n      while (i \u003c nargs)\n        ...\n    }\n  else if (varargs)\n    gdb_printf (stream, \"...\");\n  else if (language \u003d\u003d language_cplus)\n    gdb_printf (stream, \"void\");\n...\n\nThe purpose of \"i \u003d staticp ? 0 : 1\" is to skip the printing of the implicit\nthis parameter.\n\nIn commit 5f4d1085085 (\"c++/8218: Destructors w/arguments\"), skipping of other\nartificial parameters was added, but using a different method: rather than\nadjusting the potential loop start, it skips the parameter in the loop.\n\nThe observed difference in printing is explained by whether we enter the loop:\n- in the clang case, the loop is not entered and we print \"void\".\n- in the gcc case, the loop is entered, and nothing is printed.\n\nFix this by rewriting the code to:\n- always enter the loop\n- handle whether arguments need printing in the loop\n- keep track of how many arguments are printed, and\n  use that after the loop to print void etc.\nsuch that we have the same for both gcc and clang:\n...\n    A(void);\n    ~A(void);\n...\n\nNote that I consider the discussion of whether we want to print:\n- A(void) / ~A(void), or\n- A() / ~A()\nout-of-scope for this patch.\n\nTested on x86_64-linux.\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "3a611cdac5d1423abcc021af2b72d11c3e8a3938",
      "old_mode": 33188,
      "old_path": "gdb/c-typeprint.c",
      "new_id": "23e8a5a4d6f669a4264dfe81c9e5e278ce9fe833",
      "new_mode": 33188,
      "new_path": "gdb/c-typeprint.c"
    },
    {
      "type": "modify",
      "old_id": "e80d876fa32c5b180f96e2c20f0ca9f87d1f162f",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/gdb.base/ptype-offsets.exp",
      "new_id": "eb41bafb3e6a96fed9bc79b43405a07641fc034f",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.base/ptype-offsets.exp"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "98be8286aeb9d2f023dedd10ad2c113163f04545",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.cp/print-method-args.cc"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "7773e041e21b8eb0c0791320775938772960e774",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.cp/print-method-args.exp"
    },
    {
      "type": "modify",
      "old_id": "27c9bbc1c7e5342db9dd8475543f8755f86518a1",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/gdb.cp/templates.exp",
      "new_id": "d3ede5a5fb68b227db395d75e10150f24c62b6bc",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.cp/templates.exp"
    }
  ]
}
