annotate clang-tools-extra/clang-doc/Mapper.h @ 201:a96fbbdf2d0f

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 04 Jun 2021 21:07:06 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 //===-- Mapper.h - ClangDoc Mapper ------------------------------*- C++ -*-===//
anatofuz
parents:
diff changeset
2 //
anatofuz
parents:
diff changeset
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
anatofuz
parents:
diff changeset
4 // See https://llvm.org/LICENSE.txt for license information.
anatofuz
parents:
diff changeset
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
anatofuz
parents:
diff changeset
6 //
anatofuz
parents:
diff changeset
7 //===----------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
8 //
anatofuz
parents:
diff changeset
9 // This file implements the Mapper piece of the clang-doc tool. It implements
anatofuz
parents:
diff changeset
10 // a RecursiveASTVisitor to look at each declaration and populate the info
anatofuz
parents:
diff changeset
11 // into the internal representation. Each seen declaration is serialized to
anatofuz
parents:
diff changeset
12 // to bitcode and written out to the ExecutionContext as a KV pair where the
anatofuz
parents:
diff changeset
13 // key is the declaration's USR and the value is the serialized bitcode.
anatofuz
parents:
diff changeset
14 //
anatofuz
parents:
diff changeset
15 //===----------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_MAPPER_H
anatofuz
parents:
diff changeset
18 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_MAPPER_H
anatofuz
parents:
diff changeset
19
anatofuz
parents:
diff changeset
20 #include "Representation.h"
anatofuz
parents:
diff changeset
21 #include "clang/AST/RecursiveASTVisitor.h"
anatofuz
parents:
diff changeset
22 #include "clang/Tooling/Execution.h"
anatofuz
parents:
diff changeset
23
anatofuz
parents:
diff changeset
24 using namespace clang::comments;
anatofuz
parents:
diff changeset
25 using namespace clang::tooling;
anatofuz
parents:
diff changeset
26
anatofuz
parents:
diff changeset
27 namespace clang {
anatofuz
parents:
diff changeset
28 namespace doc {
anatofuz
parents:
diff changeset
29
anatofuz
parents:
diff changeset
30 class MapASTVisitor : public clang::RecursiveASTVisitor<MapASTVisitor>,
anatofuz
parents:
diff changeset
31 public ASTConsumer {
anatofuz
parents:
diff changeset
32 public:
anatofuz
parents:
diff changeset
33 explicit MapASTVisitor(ASTContext *Ctx, ClangDocContext CDCtx)
anatofuz
parents:
diff changeset
34 : CDCtx(CDCtx) {}
anatofuz
parents:
diff changeset
35
anatofuz
parents:
diff changeset
36 void HandleTranslationUnit(ASTContext &Context) override;
anatofuz
parents:
diff changeset
37 bool VisitNamespaceDecl(const NamespaceDecl *D);
anatofuz
parents:
diff changeset
38 bool VisitRecordDecl(const RecordDecl *D);
anatofuz
parents:
diff changeset
39 bool VisitEnumDecl(const EnumDecl *D);
anatofuz
parents:
diff changeset
40 bool VisitCXXMethodDecl(const CXXMethodDecl *D);
anatofuz
parents:
diff changeset
41 bool VisitFunctionDecl(const FunctionDecl *D);
anatofuz
parents:
diff changeset
42
anatofuz
parents:
diff changeset
43 private:
anatofuz
parents:
diff changeset
44 template <typename T> bool mapDecl(const T *D);
anatofuz
parents:
diff changeset
45
anatofuz
parents:
diff changeset
46 int getLine(const NamedDecl *D, const ASTContext &Context) const;
anatofuz
parents:
diff changeset
47 llvm::SmallString<128> getFile(const NamedDecl *D, const ASTContext &Context,
anatofuz
parents:
diff changeset
48 StringRef RootDir,
anatofuz
parents:
diff changeset
49 bool &IsFileInRootDir) const;
anatofuz
parents:
diff changeset
50 comments::FullComment *getComment(const NamedDecl *D,
anatofuz
parents:
diff changeset
51 const ASTContext &Context) const;
anatofuz
parents:
diff changeset
52
anatofuz
parents:
diff changeset
53 ClangDocContext CDCtx;
anatofuz
parents:
diff changeset
54 };
anatofuz
parents:
diff changeset
55
anatofuz
parents:
diff changeset
56 } // namespace doc
anatofuz
parents:
diff changeset
57 } // namespace clang
anatofuz
parents:
diff changeset
58
anatofuz
parents:
diff changeset
59 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_MAPPER_H