[PATCH] D91884: clang+lld: Improve clang+ld.darwinnew.lld interaction, pass -demangle

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 23 16:06:52 PST 2020

thakis added a comment.


I think the lld bits of this are small enough to qualify for post-commit review.

Comment at: lld/Common/Strings.cpp:24
 std::string lld::demangleItanium(StringRef name) {
-  // itaniumDemangle can be used to demangle strings other than symbol
-  // names which do not necessarily start with "_Z". Name can be
-  // either a C or C++ symbol. Don't call demangle if the name
-  // does not look like a C++ symbol name to avoid getting unexpected
-  // result for a C symbol that happens to match a mangled type name.
-  if (!name.startswith("_Z"))
+  // itaniumDemangle() can be called for all symbols. Only demangle C++ symbols,
+  // to avoid getting unexpected result for a C symbol that happens to match a
MaskRay wrote:
> The comment should be fixed.
> Itanium mangling scheme does not allow `__Z`/`___Z`. They are Mach-O extensions and probably also COFF i386's (where symbols start with an additional `_`)
I think that's consistent with the new comment, no? Darwin prefixes all symbols with an extra underscore (including C), and after stripping that leading underscore the names are regular itanium names.

(It's not just Darwin btw: gcc on normal linux also adds that underscore with `-fleading-underscore`, for example.)



More information about the llvm-commits mailing list