15#ifndef LLVM_CLANG_APINOTES_READER_H
16#define LLVM_CLANG_APINOTES_READER_H
19#include "llvm/ADT/ArrayRef.h"
20#include "llvm/ADT/SmallVector.h"
21#include "llvm/Support/Error.h"
22#include "llvm/Support/MemoryBuffer.h"
23#include "llvm/Support/VersionTuple.h"
37 APINotesReader(llvm::MemoryBuffer *InputBuffer,
38 llvm::VersionTuple SwiftVersion, llvm::Error &Err);
46 Create(std::unique_ptr<llvm::MemoryBuffer> InputBuffer,
47 llvm::VersionTuple SwiftVersion);
52 APINotesReader &
operator=(
const APINotesReader &) =
delete;
63 std::optional<unsigned> Selected;
72 llvm::VersionTuple Version,
76 std::optional<unsigned>
getSelected()
const {
return Selected; }
79 unsigned size()
const {
return Results.size(); }
82 const std::pair<llvm::VersionTuple, T> *
begin()
const {
83 assert(!Results.empty());
84 return Results.begin();
86 const std::pair<llvm::VersionTuple, T> *
end()
const {
92 assert(
index < Results.size());
93 return Results[
index];
134 VersionedInfo<ObjCPropertyInfo>
147 bool IsInstanceMethod);
164 llvm::StringRef Name);
169 VersionedInfo<CXXMethodInfo>
174 std::optional<APINotesFunctionSelectorKey>
179 std::optional<APINotesFunctionSelectorKey>
188 VersionedInfo<GlobalVariableInfo>
190 std::optional<Context> Ctx = std::nullopt);
197 VersionedInfo<GlobalFunctionInfo>
199 std::optional<Context> Ctx = std::nullopt);
204 VersionedInfo<GlobalFunctionInfo>
207 std::optional<Context> Ctx = std::nullopt);
210 std::optional<APINotesFunctionSelectorKey>
212 std::optional<Context> Ctx = std::nullopt);
216 std::optional<APINotesFunctionSelectorKey>
219 std::optional<Context> Ctx = std::nullopt);
226 std::optional<llvm::SmallVector<std::string, 4>>
244 std::optional<ContextID>
246 std::optional<Context> ParentCtx = std::nullopt);
254 VersionedInfo<TagInfo>
lookupTag(llvm::StringRef Name,
255 std::optional<Context> Ctx = std::nullopt);
262 VersionedInfo<TypedefInfo>
264 std::optional<Context> Ctx = std::nullopt);
271 std::optional<ContextID>
273 std::optional<ContextID> ParentNamespaceID = std::nullopt);
276 VersionedInfo<CXXMethodInfo> lookupCXXMethodImpl(
ContextID CtxID,
277 llvm::StringRef Name);
278 template <
typename ParameterT>
279 VersionedInfo<CXXMethodInfo>
280 lookupCXXMethodImpl(
ContextID CtxID, llvm::StringRef Name,
283 VersionedInfo<GlobalFunctionInfo>
284 lookupGlobalFunctionImpl(llvm::StringRef Name, std::optional<Context> Ctx);
285 template <
typename ParameterT>
286 VersionedInfo<GlobalFunctionInfo>
287 lookupGlobalFunctionImpl(llvm::StringRef Name,
289 std::optional<Context> Ctx);
Smart pointer class that efficiently represents Objective-C method names.
VersionedInfo(std::nullopt_t)
Form an empty set of versioned information.
const std::pair< llvm::VersionTuple, T > & operator[](unsigned index) const
Access a specific versioned result.
const std::pair< llvm::VersionTuple, T > * end() const
unsigned size() const
Return the number of versioned results we know about.
std::optional< unsigned > getSelected() const
Retrieve the selected index in the result set.
const std::pair< llvm::VersionTuple, T > * begin() const
Access all versioned results.
VersionedInfo< ContextInfo > lookupObjCClassInfo(llvm::StringRef Name)
Look for information regarding the given Objective-C class.
VersionedInfo< FieldInfo > lookupField(ContextID CtxID, llvm::StringRef Name)
Look for information regarding the given field of a C struct.
VersionedInfo< CXXMethodInfo > lookupCXXMethod(ContextID CtxID, llvm::StringRef Name)
Look for information regarding the given C++ method in the given C++ tag context.
VersionedInfo< TagInfo > lookupTag(llvm::StringRef Name, std::optional< Context > Ctx=std::nullopt)
Look for information regarding the given tag (struct/union/enum/C++ class).
VersionedInfo< GlobalFunctionInfo > lookupGlobalFunction(llvm::StringRef Name, std::optional< Context > Ctx=std::nullopt)
Look for information regarding the given global function.
VersionedInfo< ObjCPropertyInfo > lookupObjCProperty(ContextID CtxID, llvm::StringRef Name, bool IsInstance)
Look for information regarding the given Objective-C property in the given context.
VersionedInfo< ObjCMethodInfo > lookupObjCMethod(ContextID CtxID, ObjCSelectorRef Selector, bool IsInstanceMethod)
Look for information regarding the given Objective-C method in the given context.
std::optional< APINotesFunctionSelectorKey > getGlobalFunctionSelectorKey(llvm::StringRef Name, std::optional< Context > Ctx=std::nullopt)
Build the selector key for the given global function.
VersionedInfo< GlobalVariableInfo > lookupGlobalVariable(llvm::StringRef Name, std::optional< Context > Ctx=std::nullopt)
Look for information regarding the given global variable.
std::optional< APINotesFunctionSelectorKey > getCXXMethodSelectorKey(ContextID CtxID, llvm::StringRef Name)
Build the selector key for the given C++ method.
std::optional< ContextID > lookupNamespaceID(llvm::StringRef Name, std::optional< ContextID > ParentNamespaceID=std::nullopt)
Look for the context ID of the given C++ namespace.
std::optional< ContextID > lookupTagID(llvm::StringRef Name, std::optional< Context > ParentCtx=std::nullopt)
Look for the context ID of the given C++ tag.
VersionedInfo< TypedefInfo > lookupTypedef(llvm::StringRef Name, std::optional< Context > Ctx=std::nullopt)
Look for information regarding the given typedef.
std::optional< ContextID > lookupObjCClassID(llvm::StringRef Name)
Look for the context ID of the given Objective-C class.
std::optional< llvm::SmallVector< std::string, 4 > > getParameterSelectorSpellingsForDiagnostics(const APINotesFunctionSelectorKey &Key)
Reconstruct parameter selector strings for a stored exact selector key.
APINotesReader & operator=(const APINotesReader &)=delete
VersionedInfo< ContextInfo > lookupObjCProtocolInfo(llvm::StringRef Name)
Look for information regarding the given Objective-C protocol.
void collectExactFunctionParameterSelectors(llvm::SmallVectorImpl< APINotesFunctionSelectorKey > &Selectors)
Collect exact parameter selector keys stored by this reader.
std::optional< ContextID > lookupObjCProtocolID(llvm::StringRef Name)
Look for the context ID of the given Objective-C protocol.
VersionedInfo< EnumConstantInfo > lookupEnumConstant(llvm::StringRef Name)
Look for information regarding the given enumerator.
APINotesReader(const APINotesReader &)=delete
Opaque context ID used to refer to an Objective-C class or protocol or a C++ namespace.
The JSON file list parser is used to communicate input to InstallAPI.
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
Stable reader-facing identity for an API notes function selector entry.
A temporary reference to an Objective-C selector, suitable for referencing selector data on the stack...