1//===- InstallAPI/FrontendRecords.h ------------------------------*- 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#ifndef LLVM_CLANG_INSTALLAPI_FRONTENDRECORDS_H
10#define LLVM_CLANG_INSTALLAPI_FRONTENDRECORDS_H
11
12#include "clang/AST/Availability.h"
13#include "clang/AST/DeclObjC.h"
14#include "clang/InstallAPI/HeaderFile.h"
15#include "clang/InstallAPI/MachO.h"
16
17namespace clang {
18namespace installapi {
19
20/// Frontend information captured about records.
21struct FrontendAttrs {
22 const AvailabilityInfo Avail;
23 const Decl *D;
24 const SourceLocation Loc;
25 const HeaderType Access;
26};
27
28// Represents a collection of frontend records for a library that are tied to a
29// darwin target triple.
30class FrontendRecordsSlice : public llvm::MachO::RecordsSlice {
31public:
32 FrontendRecordsSlice(const llvm::Triple &T)
33 : llvm::MachO::RecordsSlice({T}) {}
34
35 /// Add non-ObjC global record with attributes from AST.
36 ///
37 /// \param Name The name of symbol.
38 /// \param Linkage The linkage of symbol.
39 /// \param GV The kind of global.
40 /// \param Avail The availability information tied to the active target
41 /// triple.
42 /// \param D The pointer to the declaration from traversing AST.
43 /// \param Access The intended access level of symbol.
44 /// \param Flags The flags that describe attributes of the symbol.
45 /// \param Inlined Whether declaration is inlined, only applicable to
46 /// functions.
47 /// \return The non-owning pointer to added record in slice with it's frontend
48 /// attributes.
49 std::pair<GlobalRecord *, FrontendAttrs *>
50 addGlobal(StringRef Name, RecordLinkage Linkage, GlobalRecord::Kind GV,
51 const clang::AvailabilityInfo Avail, const Decl *D,
52 const HeaderType Access, SymbolFlags Flags = SymbolFlags::None,
53 bool Inlined = false);
54
55 /// Add ObjC Class record with attributes from AST.
56 ///
57 /// \param Name The name of class, not symbol.
58 /// \param Linkage The linkage of symbol.
59 /// \param Avail The availability information tied to the active target
60 /// triple.
61 /// \param D The pointer to the declaration from traversing AST.
62 /// \param Access The intended access level of symbol.
63 /// \param IsEHType Whether declaration has an exception attribute.
64 /// \return The non-owning pointer to added record in slice with it's frontend
65 /// attributes.
66 std::pair<ObjCInterfaceRecord *, FrontendAttrs *>
67 addObjCInterface(StringRef Name, RecordLinkage Linkage,
68 const clang::AvailabilityInfo Avail, const Decl *D,
69 HeaderType Access, bool IsEHType);
70
71 /// Add ObjC Category record with attributes from AST.
72 ///
73 /// \param ClassToExtend The name of class that is extended by category, not
74 /// symbol.
75 /// \param CategoryName The name of category, not symbol.
76 /// \param Avail The availability information tied
77 /// to the active target triple.
78 /// \param D The pointer to the declaration from traversing AST.
79 /// \param Access The intended access level of symbol.
80 /// \return The non-owning pointer to added record in slice with it's frontend
81 /// attributes.
82 std::pair<ObjCCategoryRecord *, FrontendAttrs *>
83 addObjCCategory(StringRef ClassToExtend, StringRef CategoryName,
84 const clang::AvailabilityInfo Avail, const Decl *D,
85 HeaderType Access);
86
87 /// Add ObjC IVar record with attributes from AST.
88 ///
89 /// \param Container The owning pointer for instance variable.
90 /// \param Name The name of ivar, not symbol.
91 /// \param Linkage The linkage of symbol.
92 /// \param Avail The availability information tied to the active target
93 /// triple.
94 /// \param D The pointer to the declaration from traversing AST.
95 /// \param Access The intended access level of symbol.
96 /// \param AC The access control tied to the ivar declaration.
97 /// \return The non-owning pointer to added record in slice with it's frontend
98 /// attributes.
99 std::pair<ObjCIVarRecord *, FrontendAttrs *>
100 addObjCIVar(ObjCContainerRecord *Container, StringRef IvarName,
101 RecordLinkage Linkage, const clang::AvailabilityInfo Avail,
102 const Decl *D, HeaderType Access,
103 const clang::ObjCIvarDecl::AccessControl AC);
104
105private:
106 /// Mapping of records stored in slice to their frontend attributes.
107 llvm::DenseMap<Record *, FrontendAttrs> FrontendRecords;
108};
109
110} // namespace installapi
111} // namespace clang
112
113#endif // LLVM_CLANG_INSTALLAPI_FRONTENDRECORDS_H
114

source code of clang/include/clang/InstallAPI/FrontendRecords.h