in facebook-clang-plugins/libtooling/ASTExporter.h [1099:1163]
void ASTExporter<ATDWriter>::VisitDecl(const Decl *D) {
{
bool ShouldEmitParentPointer =
alwaysEmitParent(D) ||
D->getLexicalDeclContext() != D->getDeclContext();
Module *M = D->getImportedOwningModule();
if (!M) {
M = D->getLocalOwningModule();
}
const NamedDecl *ND = dyn_cast<NamedDecl>(D);
bool IsNDHidden = ND && !ND->isUnconditionallyVisible();
bool IsDImplicit = D->isImplicit();
bool IsDUsed = D->isUsed();
bool IsDReferenced = D->isThisDeclarationReferenced();
bool IsDInvalid = D->isInvalidDecl();
bool HasAttributes = D->hasAttrs();
const FullComment *Comment =
Options.dumpComments
? D->getASTContext().getLocalCommentForDeclUncached(D)
: nullptr;
AccessSpecifier Access = D->getAccess();
bool HasAccess = Access != AccessSpecifier::AS_none;
int size = 2 + ShouldEmitParentPointer + (bool)M + IsNDHidden +
IsDImplicit + IsDUsed + IsDReferenced + IsDInvalid +
HasAttributes + (bool)Comment + HasAccess;
ObjectScope Scope(OF, size);
OF.emitTag("pointer");
dumpPointer(D);
if (ShouldEmitParentPointer) {
OF.emitTag("parent_pointer");
dumpPointer(cast<Decl>(D->getDeclContext()));
}
OF.emitTag("source_range");
dumpSourceRange(D->getSourceRange());
if (M) {
OF.emitTag("owning_module");
OF.emitString(M->getFullModuleName());
}
OF.emitFlag("is_hidden", IsNDHidden);
OF.emitFlag("is_implicit", IsDImplicit);
OF.emitFlag("is_used", IsDUsed);
OF.emitFlag("is_this_declaration_referenced", IsDReferenced);
OF.emitFlag("is_invalid_decl", IsDInvalid);
if (HasAttributes) {
OF.emitTag("attributes");
ArrayScope ArrayAttr(OF, D->getAttrs().size());
for (auto I : D->getAttrs()) {
dumpAttr(I);
}
}
if (Comment) {
OF.emitTag("full_comment");
dumpFullComment(Comment);
}
if (HasAccess) {
OF.emitTag("access");
dumpAccessSpecifier(Access);
}
}
}