r249437 - Make clang_Cursor_getMangling don't mangle if the declaration isn't mangled
Ehsan Akhgari via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 6 11:24:33 PDT 2015
Author: ehsan
Date: Tue Oct 6 13:24:33 2015
New Revision: 249437
URL: http://llvm.org/viewvc/llvm-project?rev=249437&view=rev
Log:
Make clang_Cursor_getMangling don't 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 at mozilla.com>.
Modified:
cfe/trunk/test/Index/print-mangled-name.cpp
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CIndex.cpp
Modified: cfe/trunk/test/Index/print-mangled-name.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-mangled-name.cpp?rev=249437&r1=249436&r2=249437&view=diff
==============================================================================
--- cfe/trunk/test/Index/print-mangled-name.cpp (original)
+++ cfe/trunk/test/Index/print-mangled-name.cpp Tue Oct 6 13:24:33 2015
@@ -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
Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=249437&r1=249436&r2=249437&view=diff
==============================================================================
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Tue Oct 6 13:24:33 2015
@@ -1429,6 +1429,8 @@ static enum CXChildVisitResult PrintType
static enum CXChildVisitResult PrintMangledName(CXCursor cursor, CXCursor p,
CXClientData d) {
+ if (clang_isInvalid(clang_getCursorKind(cursor)))
+ return CXChildVisit_Recurse;
CXString MangledName;
PrintCursor(cursor, NULL);
MangledName = clang_Cursor_getMangling(cursor);
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=249437&r1=249436&r2=249437&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue Oct 6 13:24:33 2015
@@ -3890,7 +3890,11 @@ CXString clang_Cursor_getMangling(CXCurs
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(
More information about the cfe-commits
mailing list