void mangleOperatorName(OverloadedOperatorKind OO, unsigned Arity);
void mangleQualifiers(Qualifiers Quals);
+ void mangleObjCMethodName(const ObjCMethodDecl *MD);
+
// Declare manglers for every type class.
#define ABSTRACT_TYPE(CLASS, PARENT)
#define NON_CANONICAL_TYPE(CLASS, PARENT)
return;
}
- if (isa<FunctionDecl>(DC)) {
+ if (isa<FunctionDecl>(DC) || isa<ObjCMethodDecl>(DC)) {
mangleLocalName(ND);
return;
}
// := Z <function encoding> E s [<discriminator>]
// <discriminator> := _ <non-negative number>
Out << 'Z';
- mangleFunctionEncoding(cast<FunctionDecl>(ND->getDeclContext()));
+
+ if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(ND->getDeclContext()))
+ mangleObjCMethodName(MD);
+ else
+ mangleFunctionEncoding(cast<FunctionDecl>(ND->getDeclContext()));
+
Out << 'E';
mangleSourceName(ND->getIdentifier());
}
// ::= <template-param>
// ::= # empty
// ::= <substitution>
- // FIXME: We only handle mangling of namespaces and classes at the moment.
while (isa<LinkageSpecDecl>(DC))
DC = DC->getParent();
// FIXME: For now, just drop all extension qualifiers on the floor.
}
+void CXXNameMangler::mangleObjCMethodName(const ObjCMethodDecl *MD) {
+ llvm::SmallString<64> Name;
+ llvm::raw_svector_ostream OS(Name);
+
+ const ObjCContainerDecl *CD =
+ dyn_cast<ObjCContainerDecl>(MD->getDeclContext());
+ assert (CD && "Missing container decl in GetNameForMethod");
+ OS << (MD->isInstanceMethod() ? '-' : '+') << '[' << CD->getName();
+ if (const ObjCCategoryImplDecl *CID = dyn_cast<ObjCCategoryImplDecl>(CD))
+ OS << '(' << CID->getNameAsString() << ')';
+ OS << ' ' << MD->getSelector().getAsString() << ']';
+
+ Out << OS.str().size() << OS.str();
+}
+
void CXXNameMangler::mangleType(QualType T) {
// Only operate on the canonical type!
T = Context.getASTContext().getCanonicalType(T);