13 #include "clang/AST/Comment.h" 14 #include "clang/Index/USRGeneration.h" 15 #include "llvm/ADT/StringExtras.h" 16 #include "llvm/Support/Error.h" 18 using clang::comments::FullComment;
24 TraverseDecl(Context.getTranslationUnitDecl());
27 template <
typename T>
bool MapASTVisitor::mapDecl(
const T *
D) {
29 if (D->getASTContext().getSourceManager().isInSystemHeader(D->getLocation()))
33 if (D->getParentFunctionOrMethod())
36 llvm::SmallString<128> USR;
38 if (index::generateUSRForDecl(D, USR))
42 D, getComment(D, D->getASTContext()), getLine(D, D->getASTContext()),
43 getFile(D, D->getASTContext()), CDCtx.
PublicOnly);
48 CDCtx.
ECtx->reportResult(llvm::toHex(llvm::toStringRef(I->USR)),
67 if (dyn_cast<CXXMethodDecl>(D))
72 comments::FullComment *
73 MapASTVisitor::getComment(
const NamedDecl *D,
const ASTContext &Context)
const {
74 RawComment *Comment = Context.getRawCommentForDeclNoCache(D);
77 Comment->setAttached();
78 return Comment->parse(Context,
nullptr, D);
83 int MapASTVisitor::getLine(
const NamedDecl *D,
84 const ASTContext &Context)
const {
85 return Context.getSourceManager().getPresumedLoc(D->getBeginLoc()).getLine();
88 llvm::StringRef MapASTVisitor::getFile(
const NamedDecl *D,
89 const ASTContext &Context)
const {
90 return Context.getSourceManager()
91 .getPresumedLoc(D->getBeginLoc())
void HandleTranslationUnit(ASTContext &Context) override
bool VisitEnumDecl(const EnumDecl *D)
bool VisitNamespaceDecl(const NamespaceDecl *D)
static std::string serialize(T &I)
bool VisitRecordDecl(const RecordDecl *D)
bool VisitFunctionDecl(const FunctionDecl *D)
tooling::ExecutionContext * ECtx
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
std::unique_ptr< Info > emitInfo(const NamespaceDecl *D, const FullComment *FC, int LineNumber, llvm::StringRef File, bool PublicOnly)
bool VisitCXXMethodDecl(const CXXMethodDecl *D)