extern(Objective-C) void ofun();
void foo(typeof(ofun)* fn);
void goo(...);
pragma(msg, typeof(foo).mangleof);
pragma(msg, typeof(goo).mangleof);
produces:
FPYZvZv
FYv
'Y' at the position of a function argument can both be an Objective-C function type or the end of the argument list of variadic function.
Granted, the function type might never appear without a pointer prefix in the argument list, but this special case makes it harder for a demangler.
Objective-C functions should use a different character (or a combination of characters, e.g. "No") instead.
Comment #1 by r.sagitario — 2017-04-14T15:13:58Z
> Granted, the function type might never appear without a pointer prefix in the argument list
It appears inside QualifiedName for nested symbols inside an extern(Objective-C ) function.
$ ./cxxfilt -s dlang
_D8demangle3fooFPYZvZv
demangle.foo(extern(Objective-C) void() function)
_D8demangle3gooFYv
demangle.goo(...)
I have no problem handling this. ;-)
Comment #4 by ibuclaw — 2017-04-15T08:54:04Z
(In reply to Rainer Schuetze from comment #0)
>
> Granted, the function type might never appear without a pointer prefix in
> the argument list, but this special case makes it harder for a demangler.
>
I think it should be assumed that the demangler rejects this anyway.
$ ./cxxfilt -s dlang
_D8demangle3fooFYZvZv
_D8demangle3fooFYZvZv <- Not demangled.
As a litmus test, I also tried.
_D8demangle3gooYZv <- extern(Objective-C) goo()
demangle.goo()
_D8demangle3gooYYv <- extern(Objective-C) goo(...)
demangle.goo(...)
But the compiler will never emit functions like the above two anyway...
Comment #5 by r.sagitario — 2017-04-15T09:18:28Z
Try these:
module test;
struct S {}
extern(Objective-C) void ofun()
{
void foo(S s, ...);
void goo(typeof(&foo) fn);
pragma(msg, foo.mangleof); // _D4test4ofunYZ3fooMFS4test1SYv
pragma(msg, goo.mangleof); // _D4test4ofunYZ3gooMFDFS4test1SYvZv
}
The 'Y' after 4test1S looks ambiguous to me.
Comment #6 by razvan.nitu1305 — 2023-05-18T08:47:50Z
Even if adding support for Objective-C to the demangler, it fails to demangle the symbols in comment 5, while it works for `extern(Windows)`. So I guess it is still valid if Objective-C support is not deprecated.
See https://run.dlang.io/is/4sFOLJ
Comment #8 by robert.schadek — 2024-12-13T18:51:57Z