Skip to content

Commit

Permalink
Fix issue 1346. Store and print mangled name for symbols.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andersbakken committed Mar 13, 2024
1 parent 05117a9 commit cf4046a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/ClangIndexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2136,6 +2136,8 @@ CXChildVisitResult ClangIndexer::handleCursor(const CXCursor &cursor, CXCursorKi
}
}

c.mangledName = RTags::eatString(clang_Cursor_getMangling(cursor));

if (RTags::isFunction(c.kind)) {
const bool definition = c.flags & Symbol::Definition;
mScopeStack.push_back({definition ? Scope::FunctionDefinition : Scope::FunctionDeclaration, definition ? &c : nullptr,
Expand Down
3 changes: 3 additions & 0 deletions src/Symbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ String Symbol::toString(const List<std::shared_ptr<Project>> &projects,
writePiece("Arguments", "arguments", String::join(args, ", "));
if (!bases.empty())
writePiece("Base classes", "baseclasses", String::join(bases, ", "));
writePiece("Mangled name", "mangledname", mangledName);
writePiece("Brief comment", "briefcomment", briefComment);
writePiece("XML comment", "xmlcomment", xmlComment);

Expand Down Expand Up @@ -401,6 +402,8 @@ Value Symbol::toValue(const List<std::shared_ptr<Project>> &projects,
ret["linkage"] = str;
}

if (!symbol.mangledName.empty() && filterPiece("mangledname"))
ret["mangledName"] = symbol.mangledName;
if (!symbol.briefComment.empty() && filterPiece("briefcomment"))
ret["briefComment"] = symbol.briefComment;
if (!symbol.xmlComment.empty() && filterPiece("xmlcomment"))
Expand Down
7 changes: 4 additions & 3 deletions src/Symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ struct Symbol
FileSymbol = 0x1000,
TemplateFunction = 0x2000
};
String briefComment, xmlComment;
String mangledName, briefComment, xmlComment;
union {
int32_t stackCost; // cost for function definitions
int64_t enumValue; // only used if type == CXCursor_EnumConstantDecl
Expand All @@ -118,6 +118,7 @@ struct Symbol
type = CXType_Invalid;
enumValue = 0;
flags = 0;
mangledName.clear();
briefComment.clear();
xmlComment.clear();
startLine = startColumn = endLine = endColumn = size = fieldOffset = alignment = -1;
Expand Down Expand Up @@ -218,7 +219,7 @@ template <> inline Serializer &operator<<(Serializer &s, const Symbol &t)
s << t.location << t.argumentUsage << t.symbolName << t.usr
<< t.typeName << t.baseClasses << t.arguments << t.symbolLength
<< static_cast<uint16_t>(t.kind) << static_cast<uint16_t>(t.type)
<< static_cast<uint8_t>(t.linkage) << t.flags << t.briefComment << t.xmlComment
<< static_cast<uint8_t>(t.linkage) << t.flags << t.mangledName << t.briefComment << t.xmlComment
<< t.enumValue << t.startLine << t.endLine << t.startColumn << t.endColumn
<< t.size << t.fieldOffset << t.alignment;
return s;
Expand All @@ -231,7 +232,7 @@ template <> inline Deserializer &operator>>(Deserializer &s, Symbol &t)
s >> t.location >> t.argumentUsage >> t.symbolName
>> t.usr >> t.typeName >> t.baseClasses >> t.arguments
>> t.symbolLength >> kind >> type >> linkage >> t.flags
>> t.briefComment >> t.xmlComment >> t.enumValue
>> t.mangledName >> t.briefComment >> t.xmlComment >> t.enumValue
>> t.startLine >> t.endLine >> t.startColumn >> t.endColumn
>> t.size >> t.fieldOffset >> t.alignment;

Expand Down

0 comments on commit cf4046a

Please sign in to comment.