clang 18.0.0git
API.cpp
Go to the documentation of this file.
1//===- ExtractAPI/API.cpp ---------------------------------------*- 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/// \file
10/// This file implements the APIRecord and derived record structs,
11/// and the APISet class.
12///
13//===----------------------------------------------------------------------===//
14
20#include "llvm/ADT/StringRef.h"
21#include <memory>
22
23using namespace clang::extractapi;
24using namespace llvm;
25
26namespace {
27
28template <typename RecordTy, typename... CtorArgsTy>
29RecordTy *addTopLevelRecord(DenseMap<StringRef, APIRecord *> &USRLookupTable,
31 StringRef USR, CtorArgsTy &&...CtorArgs) {
32 auto Result = RecordMap.insert({USR, nullptr});
33
34 // Create the record if it does not already exist
35 if (Result.second)
36 Result.first->second =
37 std::make_unique<RecordTy>(USR, std::forward<CtorArgsTy>(CtorArgs)...);
38
39 auto *Record = Result.first->second.get();
40 USRLookupTable.insert({USR, Record});
41 return Record;
42}
43
44} // namespace
45
47APISet::addNamespace(APIRecord *Parent, StringRef Name, StringRef USR,
48 PresumedLoc Loc, AvailabilitySet Availability,
49 LinkageInfo Linkage, const DocComment &Comment,
50 DeclarationFragments Declaration,
51 DeclarationFragments SubHeading, bool IsFromSystemHeader) {
52 auto *Record = addTopLevelRecord(
53 USRBasedLookupTable, Namespaces, USR, Name, Loc, std::move(Availability),
54 Linkage, Comment, Declaration, SubHeading, IsFromSystemHeader);
55
56 if (Parent)
57 Record->ParentInformation = APIRecord::HierarchyInformation(
58 Parent->USR, Parent->Name, Parent->getKind(), Parent);
59 return Record;
60}
61
63APISet::addGlobalVar(StringRef Name, StringRef USR, PresumedLoc Loc,
64 AvailabilitySet Availabilities, LinkageInfo Linkage,
65 const DocComment &Comment, DeclarationFragments Fragments,
66 DeclarationFragments SubHeading, bool IsFromSystemHeader) {
67 return addTopLevelRecord(USRBasedLookupTable, GlobalVariables, USR, Name, Loc,
68 std::move(Availabilities), Linkage, Comment,
69 Fragments, SubHeading, IsFromSystemHeader);
70}
71
73 StringRef Name, StringRef USR, PresumedLoc Loc,
77 bool IsFromSystemHeader) {
78 return addTopLevelRecord(USRBasedLookupTable, GlobalVariableTemplates, USR,
79 Name, Loc, std::move(Availability), Linkage, Comment,
80 Declaration, SubHeading, Template,
81 IsFromSystemHeader);
82}
83
85 StringRef Name, StringRef USR, PresumedLoc Loc,
86 AvailabilitySet Availabilities, LinkageInfo Linkage,
87 const DocComment &Comment, DeclarationFragments Fragments,
88 DeclarationFragments SubHeading, FunctionSignature Signature,
89 bool IsFromSystemHeader) {
90 return addTopLevelRecord(USRBasedLookupTable, GlobalFunctions, USR, Name, Loc,
91 std::move(Availabilities), Linkage, Comment,
92 Fragments, SubHeading, Signature,
93 IsFromSystemHeader);
94}
95
97 StringRef Name, StringRef USR, PresumedLoc Loc,
100 DeclarationFragments SubHeading, FunctionSignature Signature,
101 Template Template, bool IsFromSystemHeader) {
102 return addTopLevelRecord(USRBasedLookupTable, GlobalFunctionTemplates, USR,
103 Name, Loc, std::move(Availability), Linkage, Comment,
104 Declaration, SubHeading, Signature, Template,
105 IsFromSystemHeader);
106}
107
110 StringRef Name, StringRef USR, PresumedLoc Loc,
111 AvailabilitySet Availability, LinkageInfo Linkage,
113 DeclarationFragments SubHeading, FunctionSignature Signature,
114 bool IsFromSystemHeader) {
115 return addTopLevelRecord(
116 USRBasedLookupTable, GlobalFunctionTemplateSpecializations, USR, Name,
117 Loc, std::move(Availability), Linkage, Comment, Declaration, SubHeading,
118 Signature, IsFromSystemHeader);
119}
120
122 StringRef USR, PresumedLoc Loc,
123 AvailabilitySet Availabilities,
124 const DocComment &Comment,
126 DeclarationFragments SubHeading,
127 bool IsFromSystemHeader) {
128 auto Record = std::make_unique<EnumConstantRecord>(
129 USR, Name, Loc, std::move(Availabilities), Comment, Declaration,
130 SubHeading, IsFromSystemHeader);
131 Record->ParentInformation = APIRecord::HierarchyInformation(
132 Enum->USR, Enum->Name, Enum->getKind(), Enum);
133 USRBasedLookupTable.insert({USR, Record.get()});
134 return Enum->Constants.emplace_back(std::move(Record)).get();
135}
136
137EnumRecord *APISet::addEnum(StringRef Name, StringRef USR, PresumedLoc Loc,
138 AvailabilitySet Availabilities,
139 const DocComment &Comment,
141 DeclarationFragments SubHeading,
142 bool IsFromSystemHeader) {
143 return addTopLevelRecord(USRBasedLookupTable, Enums, USR, Name, Loc,
144 std::move(Availabilities), Comment, Declaration,
145 SubHeading, IsFromSystemHeader);
146}
147
149 StringRef USR, PresumedLoc Loc,
150 AvailabilitySet Availabilities,
151 const DocComment &Comment,
153 DeclarationFragments SubHeading,
154 bool IsFromSystemHeader) {
155 auto Record = std::make_unique<StructFieldRecord>(
156 USR, Name, Loc, std::move(Availabilities), Comment, Declaration,
157 SubHeading, IsFromSystemHeader);
158 Record->ParentInformation = APIRecord::HierarchyInformation(
159 Struct->USR, Struct->Name, Struct->getKind(), Struct);
160 USRBasedLookupTable.insert({USR, Record.get()});
161 return Struct->Fields.emplace_back(std::move(Record)).get();
162}
163
164StructRecord *APISet::addStruct(StringRef Name, StringRef USR, PresumedLoc Loc,
165 AvailabilitySet Availabilities,
166 const DocComment &Comment,
168 DeclarationFragments SubHeading,
169 bool IsFromSystemHeader) {
170 return addTopLevelRecord(USRBasedLookupTable, Structs, USR, Name, Loc,
171 std::move(Availabilities), Comment, Declaration,
172 SubHeading, IsFromSystemHeader);
173}
174
176APISet::addStaticField(StringRef Name, StringRef USR, PresumedLoc Loc,
177 AvailabilitySet Availabilities, LinkageInfo Linkage,
178 const DocComment &Comment,
180 DeclarationFragments SubHeading, SymbolReference Context,
181 AccessControl Access, bool IsFromSystemHeader) {
182 return addTopLevelRecord(USRBasedLookupTable, StaticFields, USR, Name, Loc,
183 std::move(Availabilities), Linkage, Comment,
184 Declaration, SubHeading, Context, Access,
185 IsFromSystemHeader);
186}
187
189APISet::addCXXField(APIRecord *CXXClass, StringRef Name, StringRef USR,
190 PresumedLoc Loc, AvailabilitySet Availabilities,
192 DeclarationFragments SubHeading, AccessControl Access,
193 bool IsFromSystemHeader) {
194 auto *Record = addTopLevelRecord(
195 USRBasedLookupTable, CXXFields, USR, Name, Loc, std::move(Availabilities),
196 Comment, Declaration, SubHeading, Access, IsFromSystemHeader);
197 Record->ParentInformation = APIRecord::HierarchyInformation(
198 CXXClass->USR, CXXClass->Name, CXXClass->getKind(), CXXClass);
199 return Record;
200}
201
203 APIRecord *Parent, StringRef Name, StringRef USR, PresumedLoc Loc,
204 AvailabilitySet Availability, const DocComment &Comment,
206 AccessControl Access, Template Template, bool IsFromSystemHeader) {
207 auto *Record =
208 addTopLevelRecord(USRBasedLookupTable, CXXFieldTemplates, USR, Name, Loc,
209 std::move(Availability), Comment, Declaration,
210 SubHeading, Access, Template, IsFromSystemHeader);
211 Record->ParentInformation = APIRecord::HierarchyInformation(
212 Parent->USR, Parent->Name, Parent->getKind(), Parent);
213
214 return Record;
215}
216
218APISet::addCXXClass(APIRecord *Parent, StringRef Name, StringRef USR,
219 PresumedLoc Loc, AvailabilitySet Availabilities,
222 AccessControl Access, bool IsFromSystemHeader) {
223 auto *Record =
224 addTopLevelRecord(USRBasedLookupTable, CXXClasses, USR, Name, Loc,
225 std::move(Availabilities), Comment, Declaration,
226 SubHeading, Kind, Access, IsFromSystemHeader);
227 if (Parent)
228 Record->ParentInformation = APIRecord::HierarchyInformation(
229 Parent->USR, Parent->Name, Parent->getKind(), Parent);
230 return Record;
231}
232
234 APIRecord *Parent, StringRef Name, StringRef USR, PresumedLoc Loc,
235 AvailabilitySet Availability, const DocComment &Comment,
237 Template Template, AccessControl Access, bool IsFromSystemHeader) {
238 auto *Record =
239 addTopLevelRecord(USRBasedLookupTable, ClassTemplates, USR, Name, Loc,
240 std::move(Availability), Comment, Declaration,
241 SubHeading, Template, Access, IsFromSystemHeader);
242 if (Parent)
243 Record->ParentInformation = APIRecord::HierarchyInformation(
244 Parent->USR, Parent->Name, Parent->getKind(), Parent);
245 return Record;
246}
247
249 APIRecord *Parent, StringRef Name, StringRef USR, PresumedLoc Loc,
250 AvailabilitySet Availability, const DocComment &Comment,
252 AccessControl Access, bool IsFromSystemHeader) {
253 auto *Record =
254 addTopLevelRecord(USRBasedLookupTable, ClassTemplateSpecializations, USR,
255 Name, Loc, std::move(Availability), Comment,
256 Declaration, SubHeading, Access, IsFromSystemHeader);
257 if (Parent)
258 Record->ParentInformation = APIRecord::HierarchyInformation(
259 Parent->USR, Parent->Name, Parent->getKind(), Parent);
260 return Record;
261}
262
265 APIRecord *Parent, StringRef Name, StringRef USR, PresumedLoc Loc,
266 AvailabilitySet Availability, const DocComment &Comment,
268 Template Template, AccessControl Access, bool IsFromSystemHeader) {
269 auto *Record = addTopLevelRecord(
270 USRBasedLookupTable, ClassTemplatePartialSpecializations, USR, Name, Loc,
271 std::move(Availability), Comment, Declaration, SubHeading, Template,
272 Access, IsFromSystemHeader);
273 if (Parent)
274 Record->ParentInformation = APIRecord::HierarchyInformation(
275 Parent->USR, Parent->Name, Parent->getKind(), Parent);
276 return Record;
277}
278
281 StringRef Name, StringRef USR, PresumedLoc Loc,
282 AvailabilitySet Availability, LinkageInfo Linkage,
284 DeclarationFragments SubHeading, bool IsFromSystemHeader) {
285 return addTopLevelRecord(USRBasedLookupTable,
286 GlobalVariableTemplateSpecializations, USR, Name,
287 Loc, std::move(Availability), Linkage, Comment,
288 Declaration, SubHeading, IsFromSystemHeader);
289}
290
293 StringRef Name, StringRef USR, PresumedLoc Loc,
294 AvailabilitySet Availability, LinkageInfo Linkage,
297 bool IsFromSystemHeader) {
298 return addTopLevelRecord(
299 USRBasedLookupTable, GlobalVariableTemplatePartialSpecializations, USR,
300 Name, Loc, std::move(Availability), Linkage, Comment, Declaration,
301 SubHeading, Template, IsFromSystemHeader);
302}
303
304ConceptRecord *APISet::addConcept(StringRef Name, StringRef USR,
305 PresumedLoc Loc, AvailabilitySet Availability,
306 const DocComment &Comment,
308 DeclarationFragments SubHeading,
309 Template Template, bool IsFromSystemHeader) {
310 return addTopLevelRecord(USRBasedLookupTable, Concepts, USR, Name, Loc,
311 std::move(Availability), Comment, Declaration,
312 SubHeading, Template, IsFromSystemHeader);
313}
314
316 APIRecord *CXXClassRecord, StringRef Name, StringRef USR, PresumedLoc Loc,
317 AvailabilitySet Availability, const DocComment &Comment,
319 FunctionSignature Signature, AccessControl Access,
320 bool IsFromSystemHeader) {
321 CXXMethodRecord *Record =
322 addTopLevelRecord(USRBasedLookupTable, CXXInstanceMethods, USR, Name, Loc,
323 std::move(Availability), Comment, Declaration,
324 SubHeading, Signature, Access, IsFromSystemHeader);
325
326 Record->ParentInformation = APIRecord::HierarchyInformation(
329 return Record;
330}
331
333 APIRecord *CXXClassRecord, StringRef Name, StringRef USR, PresumedLoc Loc,
334 AvailabilitySet Availability, const DocComment &Comment,
336 FunctionSignature Signature, AccessControl Access,
337 bool IsFromSystemHeader) {
338 CXXMethodRecord *Record =
339 addTopLevelRecord(USRBasedLookupTable, CXXStaticMethods, USR, Name, Loc,
340 std::move(Availability), Comment, Declaration,
341 SubHeading, Signature, Access, IsFromSystemHeader);
342
343 Record->ParentInformation = APIRecord::HierarchyInformation(
346 return Record;
347}
348
350 APIRecord *Parent, StringRef Name, StringRef USR, PresumedLoc Loc,
351 AvailabilitySet Availability, const DocComment &Comment,
354 bool IsFromSystemHeader) {
355 auto *Record = addTopLevelRecord(USRBasedLookupTable, CXXMethodTemplates, USR,
356 Name, Loc, std::move(Availability), Comment,
357 Declaration, SubHeading, Signature, Access,
358 Template, IsFromSystemHeader);
359 Record->ParentInformation = APIRecord::HierarchyInformation(
360 Parent->USR, Parent->Name, Parent->getKind(), Parent);
361
362 return Record;
363}
364
366 APIRecord *Parent, StringRef Name, StringRef USR, PresumedLoc Loc,
367 AvailabilitySet Availability, const DocComment &Comment,
369 FunctionSignature Signature, AccessControl Access,
370 bool IsFromSystemHeader) {
371
372 auto *Record = addTopLevelRecord(
373 USRBasedLookupTable, CXXMethodTemplateSpecializations, USR, Name, Loc,
374 std::move(Availability), Comment, Declaration, SubHeading, Signature,
375 Access, IsFromSystemHeader);
376 Record->ParentInformation = APIRecord::HierarchyInformation(
377 Parent->USR, Parent->Name, Parent->getKind(), Parent);
378
379 return Record;
380}
381
383 StringRef Name, StringRef USR, PresumedLoc Loc,
384 AvailabilitySet Availabilities, const DocComment &Comment,
386 SymbolReference Interface, bool IsFromSystemHeader,
387 bool IsFromExternalModule) {
388 // Create the category record.
389 auto *Record =
390 addTopLevelRecord(USRBasedLookupTable, ObjCCategories, USR, Name, Loc,
391 std::move(Availabilities), Comment, Declaration,
392 SubHeading, Interface, IsFromSystemHeader);
393
394 Record->IsFromExternalModule = IsFromExternalModule;
395
396 auto It = ObjCInterfaces.find(Interface.USR);
397 if (It != ObjCInterfaces.end())
398 It->second->Categories.push_back(Record);
399
400 return Record;
401}
402
404APISet::addObjCInterface(StringRef Name, StringRef USR, PresumedLoc Loc,
405 AvailabilitySet Availabilities, LinkageInfo Linkage,
406 const DocComment &Comment,
408 DeclarationFragments SubHeading,
409 SymbolReference SuperClass, bool IsFromSystemHeader) {
410 return addTopLevelRecord(USRBasedLookupTable, ObjCInterfaces, USR, Name, Loc,
411 std::move(Availabilities), Linkage, Comment,
412 Declaration, SubHeading, SuperClass,
413 IsFromSystemHeader);
414}
415
417 ObjCContainerRecord *Container, StringRef Name, StringRef USR,
418 PresumedLoc Loc, AvailabilitySet Availabilities, const DocComment &Comment,
420 FunctionSignature Signature, bool IsInstanceMethod,
421 bool IsFromSystemHeader) {
422 std::unique_ptr<ObjCMethodRecord> Record;
423 if (IsInstanceMethod)
424 Record = std::make_unique<ObjCInstanceMethodRecord>(
425 USR, Name, Loc, std::move(Availabilities), Comment, Declaration,
426 SubHeading, Signature, IsFromSystemHeader);
427 else
428 Record = std::make_unique<ObjCClassMethodRecord>(
429 USR, Name, Loc, std::move(Availabilities), Comment, Declaration,
430 SubHeading, Signature, IsFromSystemHeader);
431
432 Record->ParentInformation = APIRecord::HierarchyInformation(
433 Container->USR, Container->Name, Container->getKind(), Container);
434 USRBasedLookupTable.insert({USR, Record.get()});
435 return Container->Methods.emplace_back(std::move(Record)).get();
436}
437
439 ObjCContainerRecord *Container, StringRef Name, StringRef USR,
440 PresumedLoc Loc, AvailabilitySet Availabilities, const DocComment &Comment,
442 ObjCPropertyRecord::AttributeKind Attributes, StringRef GetterName,
443 StringRef SetterName, bool IsOptional, bool IsInstanceProperty,
444 bool IsFromSystemHeader) {
445 std::unique_ptr<ObjCPropertyRecord> Record;
446 if (IsInstanceProperty)
447 Record = std::make_unique<ObjCInstancePropertyRecord>(
448 USR, Name, Loc, std::move(Availabilities), Comment, Declaration,
449 SubHeading, Attributes, GetterName, SetterName, IsOptional,
450 IsFromSystemHeader);
451 else
452 Record = std::make_unique<ObjCClassPropertyRecord>(
453 USR, Name, Loc, std::move(Availabilities), Comment, Declaration,
454 SubHeading, Attributes, GetterName, SetterName, IsOptional,
455 IsFromSystemHeader);
456 Record->ParentInformation = APIRecord::HierarchyInformation(
457 Container->USR, Container->Name, Container->getKind(), Container);
458 USRBasedLookupTable.insert({USR, Record.get()});
459 return Container->Properties.emplace_back(std::move(Record)).get();
460}
461
463 ObjCContainerRecord *Container, StringRef Name, StringRef USR,
464 PresumedLoc Loc, AvailabilitySet Availabilities, const DocComment &Comment,
466 ObjCInstanceVariableRecord::AccessControl Access, bool IsFromSystemHeader) {
467 auto Record = std::make_unique<ObjCInstanceVariableRecord>(
468 USR, Name, Loc, std::move(Availabilities), Comment, Declaration,
469 SubHeading, Access, IsFromSystemHeader);
470 Record->ParentInformation = APIRecord::HierarchyInformation(
471 Container->USR, Container->Name, Container->getKind(), Container);
472 USRBasedLookupTable.insert({USR, Record.get()});
473 return Container->Ivars.emplace_back(std::move(Record)).get();
474}
475
476ObjCProtocolRecord *APISet::addObjCProtocol(StringRef Name, StringRef USR,
477 PresumedLoc Loc,
478 AvailabilitySet Availabilities,
479 const DocComment &Comment,
481 DeclarationFragments SubHeading,
482 bool IsFromSystemHeader) {
483 return addTopLevelRecord(USRBasedLookupTable, ObjCProtocols, USR, Name, Loc,
484 std::move(Availabilities), Comment, Declaration,
485 SubHeading, IsFromSystemHeader);
486}
487
489APISet::addMacroDefinition(StringRef Name, StringRef USR, PresumedLoc Loc,
491 DeclarationFragments SubHeading,
492 bool IsFromSystemHeader) {
493 return addTopLevelRecord(USRBasedLookupTable, Macros, USR, Name, Loc,
494 Declaration, SubHeading, IsFromSystemHeader);
495}
496
498APISet::addTypedef(StringRef Name, StringRef USR, PresumedLoc Loc,
499 AvailabilitySet Availabilities, const DocComment &Comment,
501 DeclarationFragments SubHeading,
502 SymbolReference UnderlyingType, bool IsFromSystemHeader) {
503 return addTopLevelRecord(USRBasedLookupTable, Typedefs, USR, Name, Loc,
504 std::move(Availabilities), Comment, Declaration,
505 SubHeading, UnderlyingType, IsFromSystemHeader);
506}
507
508APIRecord *APISet::findRecordForUSR(StringRef USR) const {
509 if (USR.empty())
510 return nullptr;
511
512 return USRBasedLookupTable.lookup(USR);
513}
514
515StringRef APISet::recordUSR(const Decl *D) {
518 return copyString(USR);
519}
520
521StringRef APISet::recordUSRForMacro(StringRef Name, SourceLocation SL,
522 const SourceManager &SM) {
524 index::generateUSRForMacro(Name, SL, SM, USR);
525 return copyString(USR);
526}
527
528StringRef APISet::copyString(StringRef String) {
529 if (String.empty())
530 return {};
531
532 // No need to allocate memory and copy if the string has already been stored.
533 if (StringAllocator.identifyObject(String.data()))
534 return String;
535
536 void *Ptr = StringAllocator.Allocate(String.size(), 1);
537 memcpy(Ptr, String.data(), String.size());
538 return StringRef(reinterpret_cast<const char *>(Ptr), String.size());
539}
540
546
547void GlobalFunctionRecord::anchor() {}
548void GlobalVariableRecord::anchor() {}
549void EnumConstantRecord::anchor() {}
550void EnumRecord::anchor() {}
551void StructFieldRecord::anchor() {}
552void StructRecord::anchor() {}
553void CXXFieldRecord::anchor() {}
554void CXXClassRecord::anchor() {}
555void CXXConstructorRecord::anchor() {}
556void CXXDestructorRecord::anchor() {}
557void CXXInstanceMethodRecord::anchor() {}
558void CXXStaticMethodRecord::anchor() {}
559void ObjCInstancePropertyRecord::anchor() {}
560void ObjCClassPropertyRecord::anchor() {}
561void ObjCInstanceVariableRecord::anchor() {}
562void ObjCInstanceMethodRecord::anchor() {}
563void ObjCClassMethodRecord::anchor() {}
564void ObjCCategoryRecord::anchor() {}
565void ObjCInterfaceRecord::anchor() {}
566void ObjCProtocolRecord::anchor() {}
567void MacroDefinitionRecord::anchor() {}
568void TypedefRecord::anchor() {}
This file defines the APIRecord-based structs and the APISet class.
NodeId Parent
Definition: ASTDiff.cpp:191
#define SM(sm)
Definition: Cuda.cpp:80
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:85
Represents an unpacked "presumed" location which can be presented to the user.
Encodes a location in the source.
This class handles loading and caching of source files into memory.
NamespaceRecord * addNamespace(APIRecord *Parent, StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeaderg)
Definition: API.cpp:47
ObjCMethodRecord * addObjCMethod(ObjCContainerRecord *Container, StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, bool IsInstanceMethod, bool IsFromSystemHeader)
Create and add an Objective-C method record into the API set.
Definition: API.cpp:416
GlobalVariableTemplatePartialSpecializationRecord * addGlobalVariableTemplatePartialSpecialization(StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, Template Template, bool IsFromSystemHeader)
Definition: API.cpp:292
ObjCPropertyRecord * addObjCProperty(ObjCContainerRecord *Container, StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, ObjCPropertyRecord::AttributeKind Attributes, StringRef GetterName, StringRef SetterName, bool IsOptional, bool IsInstanceProperty, bool IsFromSystemHeader)
Create and add an Objective-C property record into the API set.
Definition: API.cpp:438
CXXMethodTemplateRecord * addCXXMethodTemplate(APIRecord *Parent, StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, AccessControl Access, Template Template, bool IsFromSystemHeader)
Definition: API.cpp:349
StaticFieldRecord * addStaticField(StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availabilities, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, SymbolReference Context, AccessControl Access, bool IsFromSystemHeaderg)
Definition: API.cpp:176
StringRef copyString(StringRef String)
Copy String into the Allocator in this APISet.
Definition: API.cpp:528
TypedefRecord * addTypedef(StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, SymbolReference UnderlyingType, bool IsFromSystemHeader)
Create a typedef record into the API set.
Definition: API.cpp:498
GlobalVariableRecord * addGlobalVar(StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeadin, bool IsFromSystemHeaderg)
Create and add a global variable record into the API set.
Definition: API.cpp:63
ClassTemplateRecord * addClassTemplate(APIRecord *Parent, StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, Template Template, AccessControl Access, bool IsFromSystemHeader)
Definition: API.cpp:233
ClassTemplateSpecializationRecord * addClassTemplateSpecialization(APIRecord *Parent, StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, AccessControl Access, bool IsFromSystemHeader)
Definition: API.cpp:248
StructFieldRecord * addStructField(StructRecord *Struct, StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Create and add a struct field record into the API set.
Definition: API.cpp:148
GlobalVariableTemplateSpecializationRecord * addGlobalVariableTemplateSpecialization(StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Definition: API.cpp:280
ObjCProtocolRecord * addObjCProtocol(StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Create and add an Objective-C protocol record into the API set.
Definition: API.cpp:476
ObjCInstanceVariableRecord * addObjCInstanceVariable(ObjCContainerRecord *Container, StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, ObjCInstanceVariableRecord::AccessControl Access, bool IsFromSystemHeader)
Create and add an Objective-C instance variable record into the API set.
Definition: API.cpp:462
CXXMethodTemplateSpecializationRecord * addCXXMethodTemplateSpec(APIRecord *Parent, StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, AccessControl Access, bool IsFromSystemHeader)
Definition: API.cpp:365
ObjCInterfaceRecord * addObjCInterface(StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, SymbolReference SuperClass, bool IsFromSystemHeader)
Create and add an Objective-C interface record into the API set.
Definition: API.cpp:404
GlobalFunctionRecord * addGlobalFunction(StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, bool IsFromSystemHeader)
Create and add a function record into the API set.
Definition: API.cpp:84
GlobalFunctionTemplateRecord * addGlobalFunctionTemplate(StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, Template Template, bool IsFromSystemHeader)
Definition: API.cpp:96
CXXMethodRecord * addCXXInstanceMethod(APIRecord *Parent, StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, AccessControl Access, bool IsFromSystemHeader)
Definition: API.cpp:315
GlobalVariableTemplateRecord * addGlobalVariableTemplate(StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, Template Template, bool IsFromSystemHeader)
Definition: API.cpp:72
CXXFieldTemplateRecord * addCXXFieldTemplate(APIRecord *Parent, StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, AccessControl Access, Template Template, bool IsFromSystemHeader)
Definition: API.cpp:202
MacroDefinitionRecord * addMacroDefinition(StringRef Name, StringRef USR, PresumedLoc Loc, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Create a macro definition record into the API set.
Definition: API.cpp:489
CXXMethodRecord * addCXXStaticMethod(APIRecord *Parent, StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, AccessControl Access, bool IsFromSystemHeader)
Definition: API.cpp:332
CXXFieldRecord * addCXXField(APIRecord *CXXClass, StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availabilities, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, AccessControl Access, bool IsFromSystemHeader)
Definition: API.cpp:189
GlobalFunctionTemplateSpecializationRecord * addGlobalFunctionTemplateSpecialization(StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, bool IsFromSystemHeader)
Definition: API.cpp:109
ObjCCategoryRecord * addObjCCategory(StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, SymbolReference Interface, bool IsFromSystemHeader, bool IsFromExternalModule)
Create and add an Objective-C category record into the API set.
Definition: API.cpp:382
CXXClassRecord * addCXXClass(APIRecord *Parent, StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, APIRecord::RecordKind Kind, AccessControl Access, bool IsFromSystemHeader)
Definition: API.cpp:218
EnumConstantRecord * addEnumConstant(EnumRecord *Enum, StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Create and add an enum constant record into the API set.
Definition: API.cpp:121
ConceptRecord * addConcept(StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, Template Template, bool IsFromSystemHeader)
Definition: API.cpp:304
StringRef recordUSR(const Decl *D)
Generate and store the USR of declaration D.
Definition: API.cpp:515
StringRef recordUSRForMacro(StringRef Name, SourceLocation SL, const SourceManager &SM)
Generate and store the USR for a macro Name.
Definition: API.cpp:521
StructRecord * addStruct(StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Create and add a struct record into the API set.
Definition: API.cpp:164
APIRecord * findRecordForUSR(StringRef USR) const
Finds the APIRecord for a given USR.
Definition: API.cpp:508
llvm::MapVector< StringRef, std::unique_ptr< RecordTy > > RecordMap
A mapping type to store a set of APIRecords with the USR as the key.
Definition: API.h:1509
EnumRecord * addEnum(StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, bool IsFromSystemHeader)
Create and add an enum record into the API set.
Definition: API.cpp:137
ClassTemplatePartialSpecializationRecord * addClassTemplatePartialSpecialization(APIRecord *Parent, StringRef Name, StringRef USR, PresumedLoc Loc, AvailabilitySet Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, Template Template, AccessControl Access, bool IsFromSystemHeader)
Definition: API.cpp:264
DeclarationFragments is a vector of tagged important parts of a symbol's declaration.
Store function signature information with DeclarationFragments of the return type and parameters.
std::vector< RawComment::CommentLine > DocComment
DocComment is a vector of RawComment::CommentLine.
Definition: API.h:150
bool generateUSRForMacro(const MacroDefinitionRecord *MD, const SourceManager &SM, SmallVectorImpl< char > &Buf)
Generate a USR for a macro, including the USR prefix.
bool generateUSRForDecl(const Decl *D, SmallVectorImpl< char > &Buf)
Generate a USR for a Decl, including the USR prefix.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
Definition: Linkage.h:24
@ Interface
The "__interface" keyword introduces the elaborated-type-specifier.
@ Struct
The "struct" keyword introduces the elaborated-type-specifier.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
YAML serialization mapping.
Definition: Dominators.h:30
Stores information about the context of the declaration of this API.
Definition: API.h:202
The base representation of an API record. Holds common symbol information.
Definition: API.h:156
RecordKind getKind() const
Definition: API.h:254
virtual ~APIRecord()=0
Definition: API.cpp:541
RecordKind
Discriminator for LLVM-style RTTI (dyn_cast<> et al.)
Definition: API.h:158
This holds information associated with enum constants.
Definition: API.h:443
This holds information associated with enums.
Definition: API.h:461
This holds information associated with global functions.
Definition: API.h:290
This holds information associated with global functions.
Definition: API.h:361
This holds information associated with macro definitions.
Definition: API.h:1076
This holds information associated with Objective-C categories.
Definition: API.h:1007
The base representation of an Objective-C container record.
Definition: API.h:899
This holds information associated with Objective-C instance variables.
Definition: API.h:777
This holds information associated with Objective-C interfaces/classes.
Definition: API.h:1032
This holds information associated with Objective-C methods.
Definition: API.h:801
This holds information associated with Objective-C properties.
Definition: API.h:700
AttributeKind
The attributes associated with an Objective-C property.
Definition: API.h:702
This holds information associated with Objective-C protocols.
Definition: API.h:1057
This holds information associated with struct fields.
Definition: API.h:481
This holds information associated with structs.
Definition: API.h:499
This represents a reference to another symbol that might come from external sources.
Definition: API.h:858
This holds information associated with typedefs.
Definition: API.h:1098