in facebook-clang-plugins/libtooling/ASTExporter.h [2526:2601]
void ASTExporter<ATDWriter>::VisitObjCMethodDecl(const ObjCMethodDecl *D) {
VisitNamedDecl(D);
// We purposedly do not call VisitDeclContext(D).
bool IsInstanceMethod = D->isInstanceMethod();
bool IsPropertyAccessor = D->isPropertyAccessor();
const ObjCPropertyDecl *PropertyDecl = nullptr;
std::string selectorName = D->getSelector().getAsString();
// work around bug in clang
if (selectorName != ".cxx_construct" && selectorName != ".cxx_destruct") {
PropertyDecl = D->findPropertyDecl();
}
ObjCMethodDecl::param_const_iterator I = D->param_begin(), E = D->param_end();
bool HasParameters = I != E;
std::vector<ImplicitParamDecl *> ImplicitParams;
if (D->getSelfDecl()) {
ImplicitParams.push_back(D->getSelfDecl());
}
if (D->getCmdDecl()) {
ImplicitParams.push_back(D->getCmdDecl());
}
bool HasImplicitParameters = !ImplicitParams.empty();
bool IsVariadic = D->isVariadic();
bool IsOverriding = D->isOverriding();
bool IsOptional = D->isOptional();
const Stmt *Body = D->getBody();
SmallString<64> Buf;
llvm::raw_svector_ostream StrOS(Buf);
Mangler->mangleObjCMethodName(D, StrOS,
/*includePrefixByte=*/false,
/*includeCategoryNamespace=*/true);
std::string MangledName = StrOS.str().str();
ObjectScope Scope(OF,
1 + IsInstanceMethod + IsPropertyAccessor +
(bool)PropertyDecl + HasParameters +
HasImplicitParameters + IsVariadic + IsOverriding +
IsOptional + (bool)Body + 1 /*MangledName */);
OF.emitFlag("is_instance_method", IsInstanceMethod);
OF.emitTag("result_type");
dumpQualType(D->getReturnType());
OF.emitFlag("is_property_accessor", IsPropertyAccessor);
if (PropertyDecl) {
OF.emitTag("property_decl");
dumpDeclRef(*PropertyDecl);
}
if (HasParameters) {
OF.emitTag("parameters");
ArrayScope Scope(OF, std::distance(I, E));
for (; I != E; ++I) {
dumpDecl(*I);
}
}
if (HasImplicitParameters) {
OF.emitTag("implicit_parameters");
ArrayScope Scope(OF, ImplicitParams.size());
for (const ImplicitParamDecl *P : ImplicitParams) {
dumpDecl(P);
}
}
OF.emitFlag("is_variadic", IsVariadic);
OF.emitFlag("is_overriding", IsOverriding);
OF.emitFlag("is_optional", IsOptional);
if (Body) {
OF.emitTag("body");
dumpStmt(Body);
}
OF.emitTag("mangled_name");
OF.emitString(MangledName);
}