forked from OSchip/llvm-project
Make clang_Cursor_getMangling not mangle if the declaration isn't mangled
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. Patch by Michael Wu <mwu@mozilla.com>. llvm-svn: 249639
This commit is contained in:
parent
94fe836afa
commit
f8d44de143
|
@ -29,3 +29,8 @@ int foo(S, S&);
|
|||
// ITANIUM: mangled=_Z3foo1SRS_
|
||||
// MACHO: mangled=__Z3foo1SRS_
|
||||
// MICROSOFT: mangled=?foo@@YAHUS
|
||||
|
||||
extern "C" int foo(int);
|
||||
// ITANIUM: mangled=foo
|
||||
// MACHO: mangled=_foo
|
||||
// MICROSOFT: mangled=_foo
|
||||
|
|
|
@ -1429,6 +1429,8 @@ static enum CXChildVisitResult PrintTypeSize(CXCursor cursor, CXCursor p,
|
|||
|
||||
static enum CXChildVisitResult PrintMangledName(CXCursor cursor, CXCursor p,
|
||||
CXClientData d) {
|
||||
if (clang_isUnexposed(clang_getCursorKind(cursor)))
|
||||
return CXChildVisit_Recurse;
|
||||
CXString MangledName;
|
||||
PrintCursor(cursor, NULL);
|
||||
MangledName = clang_Cursor_getMangling(cursor);
|
||||
|
|
|
@ -3890,7 +3890,11 @@ CXString clang_Cursor_getMangling(CXCursor C) {
|
|||
|
||||
std::string FrontendBuf;
|
||||
llvm::raw_string_ostream FrontendBufOS(FrontendBuf);
|
||||
MC->mangleName(ND, FrontendBufOS);
|
||||
if (MC->shouldMangleDeclName(ND)) {
|
||||
MC->mangleName(ND, FrontendBufOS);
|
||||
} else {
|
||||
ND->printName(FrontendBufOS);
|
||||
}
|
||||
|
||||
// Now apply backend mangling.
|
||||
std::unique_ptr<llvm::DataLayout> DL(
|
||||
|
|
Loading…
Reference in New Issue