clang  19.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 
18 #include "clang/APINotes/Types.h"
19 #include "llvm/ADT/StringRef.h"
20 #include "llvm/Support/VersionTuple.h"
21 #include "llvm/Support/raw_ostream.h"
22 
23 #include <memory>
24 
25 namespace clang {
26 class FileEntry;
27 
28 namespace 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 
36 public:
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 addObjCContext(std::optional<ContextID> ParentCtxID,
57  llvm::StringRef Name, ContextKind Kind,
58  const ObjCContextInfo &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 global variable.
82  ///
83  /// \param Name The name of this global variable.
84  /// \param Info Information about this global variable.
85  void addGlobalVariable(std::optional<Context> Ctx, llvm::StringRef Name,
86  const GlobalVariableInfo &Info,
87  llvm::VersionTuple SwiftVersion);
88 
89  /// Add information about a global function.
90  ///
91  /// \param Name The name of this global function.
92  /// \param Info Information about this global function.
93  void addGlobalFunction(std::optional<Context> Ctx, llvm::StringRef Name,
94  const GlobalFunctionInfo &Info,
95  llvm::VersionTuple SwiftVersion);
96 
97  /// Add information about an enumerator.
98  ///
99  /// \param Name The name of this enumerator.
100  /// \param Info Information about this enumerator.
101  void addEnumConstant(llvm::StringRef Name, const EnumConstantInfo &Info,
102  llvm::VersionTuple SwiftVersion);
103 
104  /// Add information about a tag (struct/union/enum/C++ class).
105  ///
106  /// \param Name The name of this tag.
107  /// \param Info Information about this tag.
108  void addTag(std::optional<Context> Ctx, llvm::StringRef Name,
109  const TagInfo &Info, llvm::VersionTuple SwiftVersion);
110 
111  /// Add information about a typedef.
112  ///
113  /// \param Name The name of this typedef.
114  /// \param Info Information about this typedef.
115  void addTypedef(std::optional<Context> Ctx, llvm::StringRef Name,
116  const TypedefInfo &Info, llvm::VersionTuple SwiftVersion);
117 };
118 } // namespace api_notes
119 } // namespace clang
120 
121 #endif // LLVM_CLANG_APINOTES_WRITER_H
llvm::raw_ostream & OS
Definition: Logger.cpp:24
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.
APINotesWriter & operator=(const APINotesWriter &)=delete
void addObjCMethod(ContextID CtxID, ObjCSelectorRef Selector, bool IsInstanceMethod, const ObjCMethodInfo &Info, llvm::VersionTuple SwiftVersion)
Add information about a specific Objective-C method.
void addEnumConstant(llvm::StringRef Name, const EnumConstantInfo &Info, llvm::VersionTuple SwiftVersion)
Add information about an enumerator.
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 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
ContextID addObjCContext(std::optional< ContextID > ParentCtxID, llvm::StringRef Name, ContextKind Kind, const ObjCContextInfo &Info, llvm::VersionTuple SwiftVersion)
Add information about a specific Objective-C class or protocol or a C++ namespace.
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).
APINotesWriter(llvm::StringRef ModuleName, const FileEntry *SF)
Create a new API notes writer with the given module name and (optional) source file.
Opaque context ID used to refer to an Objective-C class or protocol or a C++ namespace.
Definition: Types.h:787
Describes API notes data for an enumerator.
Definition: Types.h:666
Describes API notes data for a global function.
Definition: Types.h:660
Describes API notes data for a global variable.
Definition: Types.h:654
Describes API notes data for an Objective-C class or protocol.
Definition: Types.h:196
Describes API notes data for an Objective-C method.
Definition: Types.h:615
Describes API notes data for an Objective-C property.
Definition: Types.h:367
Describes API notes data for a tag.
Definition: Types.h:672
Describes API notes data for a typedef.
Definition: Types.h:755
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:813