12 #include "clang/AST/Comment.h" 13 #include "clang/Index/USRGeneration.h" 14 #include "llvm/ADT/StringExtras.h" 15 #include "llvm/Support/Error.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()))
32 if (D->getParentFunctionOrMethod())
35 llvm::SmallString<128> USR;
37 if (index::generateUSRForDecl(D, USR))
41 D, getComment(D, D->getASTContext()), getLine(D, D->getASTContext()),
42 getFile(D, D->getASTContext()), CDCtx.
PublicOnly);
47 CDCtx.
ECtx->reportResult(llvm::toHex(llvm::toStringRef(I.first->USR)),
50 CDCtx.
ECtx->reportResult(llvm::toHex(llvm::toStringRef(I.second->USR)),
69 if (dyn_cast<CXXMethodDecl>(D))
74 comments::FullComment *
75 MapASTVisitor::getComment(
const NamedDecl *D,
const ASTContext &Context)
const {
76 RawComment *Comment = Context.getRawCommentForDeclNoCache(D);
79 Comment->setAttached();
80 return Comment->parse(Context,
nullptr, D);
85 int MapASTVisitor::getLine(
const NamedDecl *D,
86 const ASTContext &Context)
const {
87 return Context.getSourceManager().getPresumedLoc(D->getBeginLoc()).getLine();
90 llvm::StringRef MapASTVisitor::getFile(
const NamedDecl *D,
91 const ASTContext &Context)
const {
92 return Context.getSourceManager()
93 .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)
std::pair< std::unique_ptr< Info >, std::unique_ptr< Info > > emitInfo(const NamespaceDecl *D, const FullComment *FC, int LineNumber, llvm::StringRef File, bool PublicOnly)
bool VisitFunctionDecl(const FunctionDecl *D)
tooling::ExecutionContext * ECtx
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
bool VisitCXXMethodDecl(const CXXMethodDecl *D)