Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:27

0001 //===-- APINotesWriter.h - API Notes Writer ---------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file defines the \c APINotesWriter class that writes out source
0010 // API notes data providing additional information about source code as
0011 // a separate input, such as the non-nil/nilable annotations for
0012 // method parameters.
0013 //
0014 //===----------------------------------------------------------------------===//
0015 #ifndef LLVM_CLANG_APINOTES_WRITER_H
0016 #define LLVM_CLANG_APINOTES_WRITER_H
0017 
0018 #include "clang/APINotes/Types.h"
0019 #include "llvm/ADT/StringRef.h"
0020 #include "llvm/Support/VersionTuple.h"
0021 #include "llvm/Support/raw_ostream.h"
0022 
0023 #include <memory>
0024 
0025 namespace clang {
0026 class FileEntry;
0027 
0028 namespace api_notes {
0029 
0030 /// A class that writes API notes data to a binary representation that can be
0031 /// read by the \c APINotesReader.
0032 class APINotesWriter {
0033   class Implementation;
0034   std::unique_ptr<Implementation> Implementation;
0035 
0036 public:
0037   /// Create a new API notes writer with the given module name and
0038   /// (optional) source file.
0039   APINotesWriter(llvm::StringRef ModuleName, const FileEntry *SF);
0040   ~APINotesWriter();
0041 
0042   APINotesWriter(const APINotesWriter &) = delete;
0043   APINotesWriter &operator=(const APINotesWriter &) = delete;
0044 
0045   void writeToStream(llvm::raw_ostream &OS);
0046 
0047   /// Add information about a specific Objective-C class or protocol or a C++
0048   /// namespace.
0049   ///
0050   /// \param Name The name of this class/protocol/namespace.
0051   /// \param Kind Whether this is a class, a protocol, or a namespace.
0052   /// \param Info Information about this class/protocol/namespace.
0053   ///
0054   /// \returns the ID of the class, protocol, or namespace, which can be used to
0055   /// add properties and methods to the class/protocol/namespace.
0056   ContextID addContext(std::optional<ContextID> ParentCtxID,
0057                        llvm::StringRef Name, ContextKind Kind,
0058                        const ContextInfo &Info,
0059                        llvm::VersionTuple SwiftVersion);
0060 
0061   /// Add information about a specific Objective-C property.
0062   ///
0063   /// \param CtxID The context in which this property resides.
0064   /// \param Name The name of this property.
0065   /// \param Info Information about this property.
0066   void addObjCProperty(ContextID CtxID, llvm::StringRef Name,
0067                        bool IsInstanceProperty, const ObjCPropertyInfo &Info,
0068                        llvm::VersionTuple SwiftVersion);
0069 
0070   /// Add information about a specific Objective-C method.
0071   ///
0072   /// \param CtxID The context in which this method resides.
0073   /// \param Selector The selector that names this method.
0074   /// \param IsInstanceMethod Whether this method is an instance method
0075   /// (vs. a class method).
0076   /// \param Info Information about this method.
0077   void addObjCMethod(ContextID CtxID, ObjCSelectorRef Selector,
0078                      bool IsInstanceMethod, const ObjCMethodInfo &Info,
0079                      llvm::VersionTuple SwiftVersion);
0080 
0081   /// Add information about a specific C++ method.
0082   ///
0083   /// \param CtxID The context in which this method resides, i.e. a C++ tag.
0084   /// \param Name The name of the method.
0085   /// \param Info Information about this method.
0086   void addCXXMethod(ContextID CtxID, llvm::StringRef Name,
0087                     const CXXMethodInfo &Info, llvm::VersionTuple SwiftVersion);
0088 
0089   /// Add information about a specific C record field.
0090   ///
0091   /// \param CtxID The context in which this field resides, i.e. a C/C++ tag.
0092   /// \param Name The name of the field.
0093   /// \param Info Information about this field.
0094   void addField(ContextID CtxID, llvm::StringRef Name, const FieldInfo &Info,
0095                 llvm::VersionTuple SwiftVersion);
0096 
0097   /// Add information about a global variable.
0098   ///
0099   /// \param Name The name of this global variable.
0100   /// \param Info Information about this global variable.
0101   void addGlobalVariable(std::optional<Context> Ctx, llvm::StringRef Name,
0102                          const GlobalVariableInfo &Info,
0103                          llvm::VersionTuple SwiftVersion);
0104 
0105   /// Add information about a global function.
0106   ///
0107   /// \param Name The name of this global function.
0108   /// \param Info Information about this global function.
0109   void addGlobalFunction(std::optional<Context> Ctx, llvm::StringRef Name,
0110                          const GlobalFunctionInfo &Info,
0111                          llvm::VersionTuple SwiftVersion);
0112 
0113   /// Add information about an enumerator.
0114   ///
0115   /// \param Name The name of this enumerator.
0116   /// \param Info Information about this enumerator.
0117   void addEnumConstant(llvm::StringRef Name, const EnumConstantInfo &Info,
0118                        llvm::VersionTuple SwiftVersion);
0119 
0120   /// Add information about a tag (struct/union/enum/C++ class).
0121   ///
0122   /// \param Name The name of this tag.
0123   /// \param Info Information about this tag.
0124   void addTag(std::optional<Context> Ctx, llvm::StringRef Name,
0125               const TagInfo &Info, llvm::VersionTuple SwiftVersion);
0126 
0127   /// Add information about a typedef.
0128   ///
0129   /// \param Name The name of this typedef.
0130   /// \param Info Information about this typedef.
0131   void addTypedef(std::optional<Context> Ctx, llvm::StringRef Name,
0132                   const TypedefInfo &Info, llvm::VersionTuple SwiftVersion);
0133 };
0134 } // namespace api_notes
0135 } // namespace clang
0136 
0137 #endif // LLVM_CLANG_APINOTES_WRITER_H