asmdiff icon indicating copy to clipboard operation
asmdiff copied to clipboard

C++ scope handling is broken for functions that have namespaced parameters

Open qookei opened this issue 1 year ago • 0 comments

If a demangled function name has namespaced parameters, e.g.:

llvm::ScopedHashTable<(anonymous namespace)::SimpleValue, llvm::Value*, llvm::DenseMapInfo<(anonymous namespace)::SimpleValue, void>, llvm::MallocAllocator>::~ScopedHashTable()

the code will split the name on ::, but not skip the normal and template parameter lists, so the list of scopes ends up being:

["llvm","ScopedHashTable<(anonymous namespace)", "SimpleValue, llvm", "Value*, llvm", ..., "~ScopedHashTable()"]

In certain cases, this ends up breaking the code inserting the function into the scope tree:

Traceback (most recent call last):
  File "/home/qookie/projects/gcc-14-bug/asmdiff/asmdiff.py", line 397, in <module>
    old = read_objdump(sys.argv[1])
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/qookie/projects/gcc-14-bug/asmdiff/asmdiff.py", line 394, in read_objdump
    return ObjDump(f)
           ^^^^^^^^^^
  File "/home/qookie/projects/gcc-14-bug/asmdiff/asmdiff.py", line 204, in __init__
    self._on_function(from_hex(m.group(1)), m.group(2))
  File "/home/qookie/projects/gcc-14-bug/asmdiff/asmdiff.py", line 241, in _on_function
    if scope not in curscope:
       ^^^^^^^^^^^^^^^^^^^^^
TypeError: argument of type 'Function' is not iterable

qookei avatar Mar 31 '24 19:03 qookei