13 #include "clang/AST/Comment.h" 14 #include "clang/Index/USRGeneration.h" 15 #include "llvm/ADT/StringExtras.h" 17 using clang::comments::FullComment;
23 TraverseDecl(Context.getTranslationUnitDecl());
26 template <
typename T>
bool MapASTVisitor::mapDecl(
const T *D) {
28 if (D->getASTContext().getSourceManager().isInSystemHeader(D->getLocation()))
31 llvm::SmallString<128> USR;
33 if (index::generateUSRForDecl(D, USR))
37 D, getComment(D, D->getASTContext()), getLine(D, D->getASTContext()),
38 getFile(D, D->getASTContext()), CDCtx.
PublicOnly);
41 CDCtx.
ECtx->reportResult(
61 if (dyn_cast<CXXMethodDecl>(D))
66 comments::FullComment *
67 MapASTVisitor::getComment(
const NamedDecl *D,
const ASTContext &Context)
const {
68 RawComment *Comment = Context.getRawCommentForDeclNoCache(D);
71 Comment->setAttached();
72 return Comment->parse(Context,
nullptr, D);
77 int MapASTVisitor::getLine(
const NamedDecl *D,
78 const ASTContext &Context)
const {
79 return Context.getSourceManager().getPresumedLoc(D->getLocStart()).getLine();
82 llvm::StringRef MapASTVisitor::getFile(
const NamedDecl *D,
83 const ASTContext &Context)
const {
84 return Context.getSourceManager()
85 .getPresumedLoc(D->getLocStart())
void HandleTranslationUnit(ASTContext &Context) override
bool VisitEnumDecl(const EnumDecl *D)
bool VisitNamespaceDecl(const NamespaceDecl *D)
bool VisitRecordDecl(const RecordDecl *D)
bool VisitFunctionDecl(const FunctionDecl *D)
tooling::ExecutionContext * ECtx
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
std::string emitInfo(const NamespaceDecl *D, const FullComment *FC, int LineNumber, llvm::StringRef File, bool PublicOnly)
SymbolID hashUSR(llvm::StringRef USR)
bool VisitCXXMethodDecl(const CXXMethodDecl *D)