This is an archive of the discontinued LLVM Phabricator instance.

AST: Implement mangling support for function types without a prototype.
ClosedPublic

Authored by pcc on Aug 7 2015, 2:24 PM.

Details

Summary

Function types without prototypes can arise when mangling a function type
within an overloadable function in C. We mangle these as the absence of
any parameter types (not even an empty parameter list).

Diff Detail

Repository
rL LLVM

Event Timeline

pcc updated this revision to Diff 31543.Aug 7 2015, 2:24 PM
pcc retitled this revision from to AST: Implement mangling support for function types without a prototype..
pcc updated this object.
pcc added a reviewer: majnemer.
pcc added a subscriber: cfe-commits.
rsmith added a subscriber: rsmith.Aug 7 2015, 2:43 PM
rsmith added inline comments.
lib/AST/ItaniumMangle.cpp
2060–2062 ↗(On Diff #31543)

This seems like a suboptimal mangling; a no-prototype function type is not compatible with a varargs function type, and in particular may have a different calling convention across a C/C++ ABI boundary. How about instead mangling this as the absence of any parameter types? (That is, drop the z, and mangle your testcase below as just _Z1fPFvzE.) libc++abi already demangles that as desired (but libstdc++ considers it an invalid mangled name).

pcc added inline comments.Aug 7 2015, 2:55 PM
lib/AST/ItaniumMangle.cpp
2060–2062 ↗(On Diff #31543)

Do you mean _Z1fPFvE? Sounds reasonable to me. I guess on the MS side we can use @ instead of Z to create the distinction there.

rsmith added inline comments.Aug 7 2015, 3:10 PM
lib/AST/ItaniumMangle.cpp
2060–2062 ↗(On Diff #31543)

Er, yes, thanks :)

pcc updated this revision to Diff 31546.Aug 7 2015, 3:12 PM
  • Use a mangling distinct from (...) as suggested by Richard
pcc updated this object.Aug 7 2015, 3:13 PM
rsmith accepted this revision.Aug 7 2015, 4:04 PM
rsmith added a reviewer: rsmith.

LGTM

This revision is now accepted and ready to land.Aug 7 2015, 4:04 PM
This revision was automatically updated to reflect the committed changes.