[PATCH] Expose name mangling to libclang

Hans Wennborg hans at chromium.org
Thu Jul 31 10:41:17 PDT 2014


On Wed, Jul 30, 2014 at 7:16 PM, Argyrios Kyrtzidis <kyrtzidis at apple.com> wrote:
> +  // Mangling only works for functions and variables.
> +  if (!D || !(llvm::isa<FunctionDecl>(D) || llvm::isa<VarDecl>(D)))
> +    return cxstring::createEmpty();
> +
> +  const NamedDecl *ND = llvm::cast<NamedDecl>(D);
>
> This is a minor nitpick but could you remove "llvm::” from isa<> and cast<>, these are used everywhere unqualified.
>
> +  // The Microsoft mangler may insert a special character in the beginning to
> +  // prevent further mangling. We can strip that for display purposes.
> +  if (Buf[0] == '\x01') {
> +    Buf.erase(0, 1);
> +  }
>
> It’s not clear to me, is this character part of the final mangled name or not ?
> If this is part of the actual mangled name shouldn’t we keep it to be correct and let the display printer handle it (e.g. by displaying it as “\x01” or something) ?

It's not part of the final name, it's just a magic prefix that Clang
prepends to names in the LLVM IR to make sure LLVM won't mangle them
further. (See note at bullet 1 in
http://llvm.org/docs/LangRef.html#identifiers).

I think stripping the prefix here makes sense.

 - Hans




More information about the cfe-commits mailing list