Thread overview
[Issue 588] New: lazy argument and nested symbol support to std.demangle
Nov 23, 2006
d-bugmail
Nov 23, 2006
d-bugmail
Nov 23, 2006
d-bugmail
Feb 08, 2007
d-bugmail
Feb 08, 2007
d-bugmail
Jul 30, 2007
d-bugmail
November 23, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=588

           Summary: lazy argument and nested symbol support to std.demangle
           Product: D
           Version: 0.174
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: patch
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: thomas-dloop@kuehne.cn


The attachment is DMD-0.174's std.demangle with added support for lazy arguments and nested symbols.


-- 

November 23, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=588





------- Comment #1 from thomas-dloop@kuehne.cn  2006-11-23 15:09 -------
Created an attachment (id=80)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=80&action=view)
demangle.d


-- 

November 23, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=588





------- Comment #2 from fvbommel@wxs.nl  2006-11-23 16:58 -------
I was recently working on nested symbol support for std.demangle as well, and
ran into a bug. Your version has that same bug:
    urxae@ubuntu:~/tmp$ cat test.d
    int intfunc() {
        void inner() {
        }
        return 0;
    }

    class UDT {}

    UDT udtfunc() {
        void inner () {
        }
        return new UDT;
    }
    urxae@ubuntu:~/tmp$ dmd -c test.d
    urxae@ubuntu:~/tmp$ nm test.o | grep inner
    00000000 T _D4test7intfuncFZi5innerFZv
    00000000 T _D4test7udtfuncFZC4test3UDT5innerFZv
    urxae@ubuntu:~/tmp$ nm test.o | grep inner | ./demangle
    00000000 T int test.intfunc() . void inner()
    00000000 T class test.UDT.inner test.udtfunc() . void function()
(same effect for struct UDT & typedef UDT, IIRC)

It's caused by an ambiguity in the mangling. It is caused by several factors:
* Functions have their name first, and their return type last.
* UDTs (structs, classes and typedefs) have a mangled name of multiple parts
with no terminator.
* Inner functions are mangled as <mangled outer function> ~ <inner function>
* Inner function names (which comes directly after the mangled outer function)
have the same syntax as one part of an UDT name.

All of this causes the name of the inner function to be mistaken for the last part of the return type.

The easiest fix would be for the mangling to change :). A simple terminator char after an UDT name would do it.


-- 

February 08, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=588


fvbommel@wxs.nl changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #80 is|0                           |1
           obsolete|                            |




------- Comment #3 from fvbommel@wxs.nl  2007-02-08 10:13 -------
Created an attachment (id=96)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=96&action=view)
std.demangle with Thomas' patch and some modifications by me.

I've been working a bit on std.demangle again, based on this patch and the
latest version from Phobos.
I've made these changes:
* bit -> bool
* Added support for 'M' attribute to functions (which indicates a 'this' or
context pointer as last argument)


-- 

February 08, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=588





------- Comment #4 from fvbommel@wxs.nl  2007-02-08 10:14 -------
Created an attachment (id=97)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=97&action=view)
Patch corresponding to previous attachment (against file from v1.005)


-- 

July 30, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=588


bugzilla@digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #5 from bugzilla@digitalmars.com  2007-07-30 15:47 -------
Fixed DMD 1.019 and 2.003


--