Right now clang_Cursor_getMangling will attempt to mangle any declaration, even if the declaration isn't mangled (extern "C"). This results in a partially mangled name which isn't useful for much. This patch makes clang_Cursor_getMangling return an empty string if the declaration isn't mangled.
Details
Diff Detail
Event Timeline
tools/libclang/CIndex.cpp | ||
---|---|---|
3892 | You should use shouldMangleDeclName here instead; this will do the wrong thing if there's an asm label on the declaration (where presumably we do want to list a "mangling"). | |
3893 | In this case, we should presumably use the decl's identifier as the "mangled name" rather than just giving up; there could still be backend mangling that applies here, and we should be producing the final symbol name here. In fact, MangleContext::mangleName should probably be changed to produce the identifier name in this case, rather than handling it here. |
Thanks for the review. I switched to shouldMangleDeclName instead of shouldMangleCXXName, and made it skip the frontend mangling instead of returning an empty string. I tried making mangleName do that instead, but it seemed to cause a bunch of test failures..
The nice thing about returning a valid symbol name instead of an empty string is that I discovered my new test was incomplete. This diff also adds a change to properly handle declarations inside an extern "C".
This uses clang_isInvalid in PrintMangledName instead of checking for CXCursor_UnexposedDecl.
Turns out clang_isUnexposed is what I wanted, rather than clang_isInvalid. I remember seeing clang_isInvalid work though..
You should use shouldMangleDeclName here instead; this will do the wrong thing if there's an asm label on the declaration (where presumably we do want to list a "mangling").