UNSUPPORT test on 64-bit AIX too
[llvm-project.git] / clang-tools-extra / clang-doc / Serialize.h
blobda1361e66fa482c0f76a568cfbd00d214d65a64d
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.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_SERIALIZE_H
16 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_SERIALIZE_H
18 #include "Representation.h"
19 #include "clang/AST/AST.h"
20 #include "clang/AST/CommentVisitor.h"
21 #include <string>
22 #include <vector>
24 using namespace clang::comments;
26 namespace clang {
27 namespace doc {
28 namespace serialize {
30 // The first element will contain the relevant information about the declaration
31 // passed as parameter.
32 // The second element will contain the relevant information about the
33 // declaration's parent, it can be a NamespaceInfo or RecordInfo.
34 // Both elements can be nullptrs if the declaration shouldn't be handled.
35 // When the declaration is handled, the first element will be a nullptr for
36 // EnumDecl, FunctionDecl and CXXMethodDecl; they are only returned wrapped in
37 // its parent scope. For NamespaceDecl and RecordDecl both elements are not
38 // nullptr.
39 std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
40 emitInfo(const NamespaceDecl *D, const FullComment *FC, int LineNumber,
41 StringRef File, bool IsFileInRootDir, bool PublicOnly);
42 std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
43 emitInfo(const RecordDecl *D, const FullComment *FC, int LineNumber,
44 StringRef File, bool IsFileInRootDir, bool PublicOnly);
45 std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
46 emitInfo(const EnumDecl *D, const FullComment *FC, int LineNumber,
47 StringRef File, bool IsFileInRootDir, bool PublicOnly);
48 std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
49 emitInfo(const FunctionDecl *D, const FullComment *FC, int LineNumber,
50 StringRef File, bool IsFileInRootDir, bool PublicOnly);
51 std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
52 emitInfo(const CXXMethodDecl *D, const FullComment *FC, int LineNumber,
53 StringRef File, bool IsFileInRootDir, bool PublicOnly);
55 // Function to hash a given USR value for storage.
56 // As USRs (Unified Symbol Resolution) could be large, especially for functions
57 // with long type arguments, we use 160-bits SHA1(USR) values to
58 // guarantee the uniqueness of symbols while using a relatively small amount of
59 // memory (vs storing USRs directly).
60 SymbolID hashUSR(llvm::StringRef USR);
62 std::string serialize(std::unique_ptr<Info> &I);
64 } // namespace serialize
65 } // namespace doc
66 } // namespace clang
68 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_SERIALIZE_H