clang 20.0.0git
APINotesWriter.h
Go to the documentation of this file.
1//===-- APINotesWriter.h - API Notes Writer ---------------------*- 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 defines the \c APINotesWriter class that writes out source
10// API notes data providing additional information about source code as
11// a separate input, such as the non-nil/nilable annotations for
12// method parameters.
13//
14//===----------------------------------------------------------------------===//
15#ifndef LLVM_CLANG_APINOTES_WRITER_H
16#define LLVM_CLANG_APINOTES_WRITER_H
17
19#include "llvm/ADT/StringRef.h"
20#include "llvm/Support/VersionTuple.h"
21#include "llvm/Support/raw_ostream.h"
22
23#include <memory>
24
25namespace clang {
26class FileEntry;
27
28namespace api_notes {
29
30/// A class that writes API notes data to a binary representation that can be
31/// read by the \c APINotesReader.
33 class Implementation;
34 std::unique_ptr<Implementation> Implementation;
35
36public:
37 /// Create a new API notes writer with the given module name and
38 /// (optional) source file.
39 APINotesWriter(llvm::StringRef ModuleName, const FileEntry *SF);
41
42 APINotesWriter(const APINotesWriter &) = delete;
44
45 void writeToStream(llvm::raw_ostream &OS);
46
47 /// Add information about a specific Objective-C class or protocol or a C++
48 /// namespace.
49 ///
50 /// \param Name The name of this class/protocol/namespace.
51 /// \param Kind Whether this is a class, a protocol, or a namespace.
52 /// \param Info Information about this class/protocol/namespace.
53 ///
54 /// \returns the ID of the class, protocol, or namespace, which can be used to
55 /// add properties and methods to the class/protocol/namespace.
56 ContextID addContext(std::optional<ContextID> ParentCtxID,
57 llvm::StringRef Name, ContextKind Kind,
58 const ContextInfo &Info,
59 llvm::VersionTuple SwiftVersion);
60
61 /// Add information about a specific Objective-C property.
62 ///
63 /// \param CtxID The context in which this property resides.
64 /// \param Name The name of this property.
65 /// \param Info Information about this property.
66 void addObjCProperty(ContextID CtxID, llvm::StringRef Name,
67 bool IsInstanceProperty, const ObjCPropertyInfo &Info,
68 llvm::VersionTuple SwiftVersion);
69
70 /// Add information about a specific Objective-C method.
71 ///
72 /// \param CtxID The context in which this method resides.
73 /// \param Selector The selector that names this method.
74 /// \param IsInstanceMethod Whether this method is an instance method
75 /// (vs. a class method).
76 /// \param Info Information about this method.
78 bool IsInstanceMethod, const ObjCMethodInfo &Info,
79 llvm::VersionTuple SwiftVersion);
80
81 /// Add information about a specific C++ method.
82 ///
83 /// \param CtxID The context in which this method resides, i.e. a C++ tag.
84 /// \param Name The name of the method.
85 /// \param Info Information about this method.
86 void addCXXMethod(ContextID CtxID, llvm::StringRef Name,
87 const CXXMethodInfo &Info, llvm::VersionTuple SwiftVersion);
88
89 /// Add information about a specific C record field.
90 ///
91 /// \param CtxID The context in which this field resides, i.e. a C/C++ tag.
92 /// \param Name The name of the field.
93 /// \param Info Information about this field.
94 void addField(ContextID CtxID, llvm::StringRef Name, const FieldInfo &Info,
95 llvm::VersionTuple SwiftVersion);
96
97 /// Add information about a global variable.
98 ///
99 /// \param Name The name of this global variable.
100 /// \param Info Information about this global variable.
101 void addGlobalVariable(std::optional<Context> Ctx, llvm::StringRef Name,
102 const GlobalVariableInfo &Info,
103 llvm::VersionTuple SwiftVersion);
104
105 /// Add information about a global function.
106 ///
107 /// \param Name The name of this global function.
108 /// \param Info Information about this global function.
109 void addGlobalFunction(std::optional<Context> Ctx, llvm::StringRef Name,
110 const GlobalFunctionInfo &Info,
111 llvm::VersionTuple SwiftVersion);
112
113 /// Add information about an enumerator.
114 ///
115 /// \param Name The name of this enumerator.
116 /// \param Info Information about this enumerator.
117 void addEnumConstant(llvm::StringRef Name, const EnumConstantInfo &Info,
118 llvm::VersionTuple SwiftVersion);
119
120 /// Add information about a tag (struct/union/enum/C++ class).
121 ///
122 /// \param Name The name of this tag.
123 /// \param Info Information about this tag.
124 void addTag(std::optional<Context> Ctx, llvm::StringRef Name,
125 const TagInfo &Info, llvm::VersionTuple SwiftVersion);
126
127 /// Add information about a typedef.
128 ///
129 /// \param Name The name of this typedef.
130 /// \param Info Information about this typedef.
131 void addTypedef(std::optional<Context> Ctx, llvm::StringRef Name,
132 const TypedefInfo &Info, llvm::VersionTuple SwiftVersion);
133};
134} // namespace api_notes
135} // namespace clang
136
137#endif // LLVM_CLANG_APINOTES_WRITER_H
enum clang::sema::@1655::IndirectLocalPathEntry::EntryKind Kind
Cached information about one file (either on disk or in the virtual file system).
Definition: FileEntry.h:300
Smart pointer class that efficiently represents Objective-C method names.
A class that writes API notes data to a binary representation that can be read by the APINotesReader.
void addObjCMethod(ContextID CtxID, ObjCSelectorRef Selector, bool IsInstanceMethod, const ObjCMethodInfo &Info, llvm::VersionTuple SwiftVersion)
Add information about a specific Objective-C method.
APINotesWriter & operator=(const APINotesWriter &)=delete
void addEnumConstant(llvm::StringRef Name, const EnumConstantInfo &Info, llvm::VersionTuple SwiftVersion)
Add information about an enumerator.
ContextID addContext(std::optional< ContextID > ParentCtxID, llvm::StringRef Name, ContextKind Kind, const ContextInfo &Info, llvm::VersionTuple SwiftVersion)
Add information about a specific Objective-C class or protocol or a C++ namespace.
void addGlobalFunction(std::optional< Context > Ctx, llvm::StringRef Name, const GlobalFunctionInfo &Info, llvm::VersionTuple SwiftVersion)
Add information about a global function.
void addObjCProperty(ContextID CtxID, llvm::StringRef Name, bool IsInstanceProperty, const ObjCPropertyInfo &Info, llvm::VersionTuple SwiftVersion)
Add information about a specific Objective-C property.
void addField(ContextID CtxID, llvm::StringRef Name, const FieldInfo &Info, llvm::VersionTuple SwiftVersion)
Add information about a specific C record field.
void addGlobalVariable(std::optional< Context > Ctx, llvm::StringRef Name, const GlobalVariableInfo &Info, llvm::VersionTuple SwiftVersion)
Add information about a global variable.
void addTypedef(std::optional< Context > Ctx, llvm::StringRef Name, const TypedefInfo &Info, llvm::VersionTuple SwiftVersion)
Add information about a typedef.
void writeToStream(llvm::raw_ostream &OS)
APINotesWriter(const APINotesWriter &)=delete
void addCXXMethod(ContextID CtxID, llvm::StringRef Name, const CXXMethodInfo &Info, llvm::VersionTuple SwiftVersion)
Add information about a specific C++ method.
void addTag(std::optional< Context > Ctx, llvm::StringRef Name, const TagInfo &Info, llvm::VersionTuple SwiftVersion)
Add information about a tag (struct/union/enum/C++ class).
Describes API notes data for a C++ method.
Definition: Types.h:666
Opaque context ID used to refer to an Objective-C class or protocol or a C++ namespace.
Definition: Types.h:800
Describes API notes data for an Objective-C class or protocol or a C++ namespace.
Definition: Types.h:197
Describes API notes data for an enumerator.
Definition: Types.h:672
Describes API notes data for a C/C++ record field.
Definition: Types.h:660
Describes API notes data for a global function.
Definition: Types.h:654
Describes API notes data for a global variable.
Definition: Types.h:648
Describes API notes data for an Objective-C method.
Definition: Types.h:609
Describes API notes data for an Objective-C property.
Definition: Types.h:361
Describes API notes data for a tag.
Definition: Types.h:678
Describes API notes data for a typedef.
Definition: Types.h:768
The JSON file list parser is used to communicate input to InstallAPI.
A temporary reference to an Objective-C selector, suitable for referencing selector data on the stack...
Definition: Types.h:827