[PATCH] D13317: clang_Cursor_getMangling shouldn't mangle if the declaration isn't mangled
Michael Wu via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 30 16:39:18 PDT 2015
michaelwu created this revision.
michaelwu added a subscriber: cfe-commits.
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.
http://reviews.llvm.org/D13317
Files:
test/Index/print-mangled-name.cpp
tools/libclang/CIndex.cpp
Index: tools/libclang/CIndex.cpp
===================================================================
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -3891,6 +3891,10 @@
ASTContext &Ctx = ND->getASTContext();
std::unique_ptr<MangleContext> MC(Ctx.createMangleContext());
+ // Don't mangle if we don't need to.
+ if (!MC->shouldMangleCXXName(ND))
+ return cxstring::createEmpty();
+
std::string FrontendBuf;
llvm::raw_string_ostream FrontendBufOS(FrontendBuf);
MC->mangleName(ND, FrontendBufOS);
Index: test/Index/print-mangled-name.cpp
===================================================================
--- test/Index/print-mangled-name.cpp
+++ test/Index/print-mangled-name.cpp
@@ -29,3 +29,8 @@
// ITANIUM: mangled=_Z3foo1SRS_
// MACHO: mangled=__Z3foo1SRS_
// MICROSOFT: mangled=?foo@@YAHUS
+
+extern "C" int foo(int);
+// ITANIUM: mangled=
+// MACHO: mangled=
+// MICROSOFT: mangled=
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13317.36161.patch
Type: text/x-patch
Size: 928 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150930/e7d5af4f/attachment.bin>
More information about the cfe-commits
mailing list