瀏覽代碼

Make overload checking match const and non-const functions

MSVC also makes adjacent const and non-const overloads.

Fixing this results in a seemingly accurate Windows translation
of TF2's CBaseObject vtable.
nosoop 10 月之前
父節點
當前提交
6c25a6b2c0
共有 2 個文件被更改,包括 9 次插入1 次删除
  1. 1 1
      src/smgdc/demangler_helpers.py
  2. 8 0
      tests/test_demangler.py

+ 1 - 1
src/smgdc/demangler_helpers.py

@@ -60,7 +60,7 @@ def extract_method_fname(node: demangler.Node) -> tuple[demangler.Node, ...]:
     def _extract(node: demangler.Node):
         match node:
             case node if node.kind == "cv_qual":
-                return (node.qual, _extract(node.value))
+                return _extract(node.value)
             case node if node.kind == "qual_name":
                 return (node.value[-1],)
         raise ValueError(f"Unexpected node {node!r}")

+ 8 - 0
tests/test_demangler.py

@@ -129,6 +129,14 @@ def test_function_match_signature(fnsym_a: str, fnsym_b: str, expected: bool):
             ),
             True,
         ),
+        (
+            # PASS: same class, one is const-qualified
+            (
+                "_ZN11CBaseObject13CanBeUpgradedEP9CTFPlayer",
+                "_ZNK11CBaseObject13CanBeUpgradedEv",
+            ),
+            True,
+        ),
     ],
 )
 def test_function_overloaded(fnsyms: Iterable[str], expected: bool):