clang-tools 22.0.0git
Serialize.h
Go to the documentation of this file.
1//===-- Serializer.h - ClangDoc Serializer ----------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the serializing functions fro the clang-doc tool. Given
10// a particular declaration, it collects the appropriate information and returns
11// a serialized bitcode string for the declaration.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_SERIALIZE_H
16#define LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_SERIALIZE_H
17
18#include "Representation.h"
19#include <string>
20
21using namespace clang::comments;
22
23namespace clang {
24namespace doc {
25namespace serialize {
26
27// The first element will contain the relevant information about the declaration
28// passed as parameter.
29// The second element will contain the relevant information about the
30// declaration's parent, it can be a NamespaceInfo or RecordInfo.
31// Both elements can be nullptrs if the declaration shouldn't be handled.
32// When the declaration is handled, the first element will be a nullptr for
33// EnumDecl, FunctionDecl and CXXMethodDecl; they are only returned wrapped in
34// its parent scope. For NamespaceDecl and RecordDecl both elements are not
35// nullptr.
36std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
37emitInfo(const NamespaceDecl *D, const FullComment *FC, Location Loc,
38 bool PublicOnly);
39
40std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
41emitInfo(const RecordDecl *D, const FullComment *FC, Location Loc,
42 bool PublicOnly);
43
44std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
45emitInfo(const EnumDecl *D, const FullComment *FC, Location Loc,
46 bool PublicOnly);
47
48std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
49emitInfo(const FunctionDecl *D, const FullComment *FC, Location Loc,
50 bool PublicOnly);
51
52std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
53emitInfo(const VarDecl *D, const FullComment *FC, int LineNumber,
54 StringRef File, bool IsFileInRootDir, bool PublicOnly);
55
56std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
57emitInfo(const CXXMethodDecl *D, const FullComment *FC, Location Loc,
58 bool PublicOnly);
59
60std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
61emitInfo(const TypedefDecl *D, const FullComment *FC, Location Loc,
62 bool PublicOnly);
63
64std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
65emitInfo(const TypeAliasDecl *D, const FullComment *FC, Location Loc,
66 bool PublicOnly);
67
68std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
69emitInfo(const ConceptDecl *D, const FullComment *FC, const Location &Loc,
70 bool PublicOnly);
71
72std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
73emitInfo(const VarDecl *D, const FullComment *FC, const Location &Loc,
74 bool PublicOnly);
75
76// Function to hash a given USR value for storage.
77// As USRs (Unified Symbol Resolution) could be large, especially for functions
78// with long type arguments, we use 160-bits SHA1(USR) values to
79// guarantee the uniqueness of symbols while using a relatively small amount of
80// memory (vs storing USRs directly).
81SymbolID hashUSR(llvm::StringRef USR);
82
83std::string serialize(std::unique_ptr<Info> &I);
84
85} // namespace serialize
86} // namespace doc
87} // namespace clang
88
89#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_SERIALIZE_H
static llvm::cl::opt< bool > PublicOnly("public", llvm::cl::desc("Document only public declarations."), llvm::cl::init(false), llvm::cl::cat(ClangDocCategory))
std::pair< std::unique_ptr< Info >, std::unique_ptr< Info > > emitInfo(const NamespaceDecl *D, const FullComment *FC, Location Loc, bool PublicOnly)
static std::string serialize(T &I)
SymbolID hashUSR(llvm::StringRef USR)
Definition Serialize.cpp:40
std::array< uint8_t, 20 > SymbolID
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//