By using FrontendAction and ASTConsumer API, we can print the name of each function, such as:
bool VisitFunctionDecl(FunctionDecl *f) {
DeclarationName DeclName = f->getNameInfo().getName();
std::string FuncName = DeclName.getAsString();
out << FuncName << '\n';
return true;
}
Now each of FuncName we got is not mangled, and I want to get the mangled name by using API, I have found this API in clang/include/AST/Mangle.h, which is:
void MangleContext::mangleName(GlobalDecl GD, raw_ostream &Out);
This API seems to receive a GlobalDecl type param and a raw_ostream& param, but now I have only a FunctionDecl* type param, how can I use this API to get a mangled function name which has type of std::string?