clang  15.0.0git
API.h
Go to the documentation of this file.
1 //===- ExtractAPI/API.h -----------------------------------------*- 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 defines the APIRecord-based structs and the APISet class.
11 ///
12 /// Clang ExtractAPI is a tool to collect API information from a given set of
13 /// header files. The structures in this file describe data representations of
14 /// the API information collected for various kinds of symbols.
15 ///
16 //===----------------------------------------------------------------------===//
17 
18 #ifndef LLVM_CLANG_EXTRACTAPI_API_H
19 #define LLVM_CLANG_EXTRACTAPI_API_H
20 
21 #include "clang/AST/Decl.h"
22 #include "clang/AST/DeclObjC.h"
27 #include "llvm/ADT/MapVector.h"
28 #include "llvm/ADT/StringRef.h"
29 #include "llvm/ADT/Triple.h"
30 #include "llvm/Support/Allocator.h"
31 #include "llvm/Support/Casting.h"
32 #include <memory>
33 #include <type_traits>
34 
35 namespace clang {
36 namespace extractapi {
37 
38 /// DocComment is a vector of RawComment::CommentLine.
39 ///
40 /// Each line represents one line of striped documentation comment,
41 /// with source range information. This simplifies calculating the source
42 /// location of a character in the doc comment for pointing back to the source
43 /// file.
44 /// e.g.
45 /// \code
46 /// /// This is a documentation comment
47 /// ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' First line.
48 /// /// with multiple lines.
49 /// ^~~~~~~~~~~~~~~~~~~~~~~' Second line.
50 /// \endcode
51 using DocComment = std::vector<RawComment::CommentLine>;
52 
53 // Classes deriving from APIRecord need to have USR be the first constructor
54 // argument. This is so that they are compatible with `addTopLevelRecord`
55 // defined in API.cpp
56 /// The base representation of an API record. Holds common symbol information.
57 struct APIRecord {
58  StringRef USR;
59  StringRef Name;
63 
64  /// Documentation comment lines attached to this symbol declaration.
66 
67  /// Declaration fragments of this symbol declaration.
69 
70  /// SubHeading provides a more detailed representation than the plain
71  /// declaration name.
72  ///
73  /// SubHeading is an array of declaration fragments of tagged declaration
74  /// name, with potentially more tokens (for example the \c +/- symbol for
75  /// Objective-C class/instance methods).
77 
78  /// Discriminator for LLVM-style RTTI (dyn_cast<> et al.)
79  enum RecordKind {
94  };
95 
96 private:
97  const RecordKind Kind;
98 
99 public:
100  RecordKind getKind() const { return Kind; }
101 
102  APIRecord() = delete;
103 
104  APIRecord(RecordKind Kind, StringRef USR, StringRef Name,
110  SubHeading(SubHeading), Kind(Kind) {}
111 
112  // Pure virtual destructor to make APIRecord abstract
113  virtual ~APIRecord() = 0;
114 };
115 
116 /// This holds information associated with global functions.
119 
120  GlobalFunctionRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
128  Signature(Signature) {}
129 
130  static bool classof(const APIRecord *Record) {
131  return Record->getKind() == RK_GlobalFunction;
132  }
133 
134 private:
135  virtual void anchor();
136 };
137 
138 /// This holds information associated with global functions.
140  GlobalVariableRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
147 
148  static bool classof(const APIRecord *Record) {
149  return Record->getKind() == RK_GlobalVariable;
150  }
151 
152 private:
153  virtual void anchor();
154 };
155 
156 /// This holds information associated with enum constants.
158  EnumConstantRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
160  const DocComment &Comment,
165 
166  static bool classof(const APIRecord *Record) {
167  return Record->getKind() == RK_EnumConstant;
168  }
169 
170 private:
171  virtual void anchor();
172 };
173 
174 /// This holds information associated with enums.
177 
178  EnumRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
181  : APIRecord(RK_Enum, USR, Name, Loc, Availability, LinkageInfo::none(),
183 
184  static bool classof(const APIRecord *Record) {
185  return Record->getKind() == RK_Enum;
186  }
187 
188 private:
189  virtual void anchor();
190 };
191 
192 /// This holds information associated with struct fields.
194  StructFieldRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
200 
201  static bool classof(const APIRecord *Record) {
202  return Record->getKind() == RK_StructField;
203  }
204 
205 private:
206  virtual void anchor();
207 };
208 
209 /// This holds information associated with structs.
212 
213  StructRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
217  : APIRecord(RK_Struct, USR, Name, Loc, Availability, LinkageInfo::none(),
219 
220  static bool classof(const APIRecord *Record) {
221  return Record->getKind() == RK_Struct;
222  }
223 
224 private:
225  virtual void anchor();
226 };
227 
228 /// This holds information associated with Objective-C properties.
230  /// The attributes associated with an Objective-C property.
231  enum AttributeKind : unsigned {
232  NoAttr = 0,
233  ReadOnly = 1,
234  Class = 1 << 1,
235  Dynamic = 1 << 2,
236  };
237 
239  StringRef GetterName;
240  StringRef SetterName;
242 
243  ObjCPropertyRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
245  const DocComment &Comment,
248  StringRef GetterName, StringRef SetterName,
249  bool IsOptional)
254 
255  bool isReadOnly() const { return Attributes & ReadOnly; }
256  bool isDynamic() const { return Attributes & Dynamic; }
257  bool isClassProperty() const { return Attributes & Class; }
258 
259  static bool classof(const APIRecord *Record) {
260  return Record->getKind() == RK_ObjCProperty;
261  }
262 
263 private:
264  virtual void anchor();
265 };
266 
267 /// This holds information associated with Objective-C instance variables.
271 
272  ObjCInstanceVariableRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
274  const DocComment &Comment,
280  Access(Access) {}
281 
282  static bool classof(const APIRecord *Record) {
283  return Record->getKind() == RK_ObjCIvar;
284  }
285 
286 private:
287  virtual void anchor();
288 };
289 
290 /// This holds information associated with Objective-C methods.
294 
295  ObjCMethodRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
299  bool IsInstanceMethod)
303 
304  static bool classof(const APIRecord *Record) {
305  return Record->getKind() == RK_ObjCMethod;
306  }
307 
308 private:
309  virtual void anchor();
310 };
311 
312 /// This represents a reference to another symbol that might come from external
313 /// sources.
315  StringRef Name;
316  StringRef USR;
317 
318  /// The source project/module/product of the referred symbol.
319  StringRef Source;
320 
321  SymbolReference() = default;
322  SymbolReference(StringRef Name, StringRef USR = "", StringRef Source = "")
323  : Name(Name), USR(USR), Source(Source) {}
324  SymbolReference(const APIRecord &Record)
325  : Name(Record.Name), USR(Record.USR) {}
326 
327  /// Determine if this SymbolReference is empty.
328  ///
329  /// \returns true if and only if all \c Name, \c USR, and \c Source is empty.
330  bool empty() const { return Name.empty() && USR.empty() && Source.empty(); }
331 };
332 
333 /// The base representation of an Objective-C container record. Holds common
334 /// information associated with Objective-C containers.
340 
341  ObjCContainerRecord() = delete;
342 
343  ObjCContainerRecord(RecordKind Kind, StringRef USR, StringRef Name,
348  : APIRecord(Kind, USR, Name, Loc, Availability, Linkage, Comment,
350 
351  virtual ~ObjCContainerRecord() = 0;
352 };
353 
354 /// This holds information associated with Objective-C categories.
357 
358  ObjCCategoryRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
360  const DocComment &Comment,
364  LinkageInfo::none(), Comment, Declaration,
365  SubHeading),
366  Interface(Interface) {}
367 
368  static bool classof(const APIRecord *Record) {
369  return Record->getKind() == RK_ObjCCategory;
370  }
371 
372 private:
373  virtual void anchor();
374 };
375 
376 /// This holds information associated with Objective-C interfaces/classes.
379  // ObjCCategoryRecord%s are stored in and owned by APISet.
381 
382  ObjCInterfaceRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
384  const DocComment &Comment,
391 
392  static bool classof(const APIRecord *Record) {
393  return Record->getKind() == RK_ObjCInterface;
394  }
395 
396 private:
397  virtual void anchor();
398 };
399 
400 /// This holds information associated with Objective-C protocols.
402  ObjCProtocolRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
404  const DocComment &Comment,
408  LinkageInfo::none(), Comment, Declaration,
409  SubHeading) {}
410 
411  static bool classof(const APIRecord *Record) {
412  return Record->getKind() == RK_ObjCProtocol;
413  }
414 
415 private:
416  virtual void anchor();
417 };
418 
419 /// This holds information associated with macro definitions.
421  MacroDefinitionRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
426 
427  static bool classof(const APIRecord *Record) {
428  return Record->getKind() == RK_MacroDefinition;
429  }
430 
431 private:
432  virtual void anchor();
433 };
434 
435 /// This holds information associated with typedefs.
436 ///
437 /// Note: Typedefs for anonymous enums and structs typically don't get emitted
438 /// by the serializers but still get a TypedefRecord. Instead we use the
439 /// typedef name as a name for the underlying anonymous struct or enum.
442 
443  TypedefRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
450 
451  static bool classof(const APIRecord *Record) {
452  return Record->getKind() == RK_Typedef;
453  }
454 
455 private:
456  virtual void anchor();
457 };
458 
459 /// Check if a record type has a function signature mixin.
460 ///
461 /// This is denoted by the record type having a ``Signature`` field of type
462 /// FunctionSignature.
463 template <typename RecordTy>
464 struct has_function_signature : public std::false_type {};
465 template <>
466 struct has_function_signature<GlobalFunctionRecord> : public std::true_type {};
467 template <>
468 struct has_function_signature<ObjCMethodRecord> : public std::true_type {};
469 
470 /// APISet holds the set of API records collected from given inputs.
471 class APISet {
472 public:
473  /// Create and add a global variable record into the API set.
474  ///
475  /// Note: the caller is responsible for keeping the StringRef \p Name and
476  /// \p USR alive. APISet::copyString provides a way to copy strings into
477  /// APISet itself, and APISet::recordUSR(const Decl *D) is a helper method
478  /// to generate the USR for \c D and keep it alive in APISet.
480  addGlobalVar(StringRef Name, StringRef USR, PresumedLoc Loc,
481  const AvailabilityInfo &Availability, LinkageInfo Linkage,
482  const DocComment &Comment, DeclarationFragments Declaration,
483  DeclarationFragments SubHeading);
484 
485  /// Create and add a function record into the API set.
486  ///
487  /// Note: the caller is responsible for keeping the StringRef \p Name and
488  /// \p USR alive. APISet::copyString provides a way to copy strings into
489  /// APISet itself, and APISet::recordUSR(const Decl *D) is a helper method
490  /// to generate the USR for \c D and keep it alive in APISet.
492  addGlobalFunction(StringRef Name, StringRef USR, PresumedLoc Loc,
493  const AvailabilityInfo &Availability, LinkageInfo Linkage,
494  const DocComment &Comment, DeclarationFragments Declaration,
495  DeclarationFragments SubHeading,
496  FunctionSignature Signature);
497 
498  /// Create and add an enum constant record into the API set.
499  ///
500  /// Note: the caller is responsible for keeping the StringRef \p Name and
501  /// \p USR alive. APISet::copyString provides a way to copy strings into
502  /// APISet itself, and APISet::recordUSR(const Decl *D) is a helper method
503  /// to generate the USR for \c D and keep it alive in APISet.
504  EnumConstantRecord *addEnumConstant(EnumRecord *Enum, StringRef Name,
505  StringRef USR, PresumedLoc Loc,
506  const AvailabilityInfo &Availability,
507  const DocComment &Comment,
508  DeclarationFragments Declaration,
509  DeclarationFragments SubHeading);
510 
511  /// Create and add an enum record into the API set.
512  ///
513  /// Note: the caller is responsible for keeping the StringRef \p Name and
514  /// \p USR alive. APISet::copyString provides a way to copy strings into
515  /// APISet itself, and APISet::recordUSR(const Decl *D) is a helper method
516  /// to generate the USR for \c D and keep it alive in APISet.
517  EnumRecord *addEnum(StringRef Name, StringRef USR, PresumedLoc Loc,
518  const AvailabilityInfo &Availability,
519  const DocComment &Comment,
520  DeclarationFragments Declaration,
521  DeclarationFragments SubHeading);
522 
523  /// Create and add a struct field record into the API set.
524  ///
525  /// Note: the caller is responsible for keeping the StringRef \p Name and
526  /// \p USR alive. APISet::copyString provides a way to copy strings into
527  /// APISet itself, and APISet::recordUSR(const Decl *D) is a helper method
528  /// to generate the USR for \c D and keep it alive in APISet.
529  StructFieldRecord *addStructField(StructRecord *Struct, StringRef Name,
530  StringRef USR, PresumedLoc Loc,
531  const AvailabilityInfo &Availability,
532  const DocComment &Comment,
533  DeclarationFragments Declaration,
534  DeclarationFragments SubHeading);
535 
536  /// Create and add a struct record into the API set.
537  ///
538  /// Note: the caller is responsible for keeping the StringRef \p Name and
539  /// \p USR alive. APISet::copyString provides a way to copy strings into
540  /// APISet itself, and APISet::recordUSR(const Decl *D) is a helper method
541  /// to generate the USR for \c D and keep it alive in APISet.
542  StructRecord *addStruct(StringRef Name, StringRef USR, PresumedLoc Loc,
543  const AvailabilityInfo &Availability,
544  const DocComment &Comment,
545  DeclarationFragments Declaration,
546  DeclarationFragments SubHeading);
547 
548  /// Create and add an Objective-C category record into the API set.
549  ///
550  /// Note: the caller is responsible for keeping the StringRef \p Name and
551  /// \p USR alive. APISet::copyString provides a way to copy strings into
552  /// APISet itself, and APISet::recordUSR(const Decl *D) is a helper method
553  /// to generate the USR for \c D and keep it alive in APISet.
555  addObjCCategory(StringRef Name, StringRef USR, PresumedLoc Loc,
556  const AvailabilityInfo &Availability,
557  const DocComment &Comment, DeclarationFragments Declaration,
558  DeclarationFragments SubHeading, SymbolReference Interface);
559 
560  /// Create and add an Objective-C interface record into the API set.
561  ///
562  /// Note: the caller is responsible for keeping the StringRef \p Name and
563  /// \p USR alive. APISet::copyString provides a way to copy strings into
564  /// APISet itself, and APISet::recordUSR(const Decl *D) is a helper method
565  /// to generate the USR for \c D and keep it alive in APISet.
567  addObjCInterface(StringRef Name, StringRef USR, PresumedLoc Loc,
568  const AvailabilityInfo &Availability, LinkageInfo Linkage,
569  const DocComment &Comment, DeclarationFragments Declaration,
570  DeclarationFragments SubHeading, SymbolReference SuperClass);
571 
572  /// Create and add an Objective-C method record into the API set.
573  ///
574  /// Note: the caller is responsible for keeping the StringRef \p Name and
575  /// \p USR alive. APISet::copyString provides a way to copy strings into
576  /// APISet itself, and APISet::recordUSR(const Decl *D) is a helper method
577  /// to generate the USR for \c D and keep it alive in APISet.
579  addObjCMethod(ObjCContainerRecord *Container, StringRef Name, StringRef USR,
580  PresumedLoc Loc, const AvailabilityInfo &Availability,
581  const DocComment &Comment, DeclarationFragments Declaration,
582  DeclarationFragments SubHeading, FunctionSignature Signature,
583  bool IsInstanceMethod);
584 
585  /// Create and add an Objective-C property record into the API set.
586  ///
587  /// Note: the caller is responsible for keeping the StringRef \p Name and
588  /// \p USR alive. APISet::copyString provides a way to copy strings into
589  /// APISet itself, and APISet::recordUSR(const Decl *D) is a helper method
590  /// to generate the USR for \c D and keep it alive in APISet.
592  addObjCProperty(ObjCContainerRecord *Container, StringRef Name, StringRef USR,
593  PresumedLoc Loc, const AvailabilityInfo &Availability,
594  const DocComment &Comment, DeclarationFragments Declaration,
595  DeclarationFragments SubHeading,
597  StringRef GetterName, StringRef SetterName, bool IsOptional);
598 
599  /// Create and add an Objective-C instance variable record into the API set.
600  ///
601  /// Note: the caller is responsible for keeping the StringRef \p Name and
602  /// \p USR alive. APISet::copyString provides a way to copy strings into
603  /// APISet itself, and APISet::recordUSR(const Decl *D) is a helper method
604  /// to generate the USR for \c D and keep it alive in APISet.
606  ObjCContainerRecord *Container, StringRef Name, StringRef USR,
607  PresumedLoc Loc, const AvailabilityInfo &Availability,
608  const DocComment &Comment, DeclarationFragments Declaration,
609  DeclarationFragments SubHeading,
611 
612  /// Create and add an Objective-C protocol record into the API set.
613  ///
614  /// Note: the caller is responsible for keeping the StringRef \p Name and
615  /// \p USR alive. APISet::copyString provides a way to copy strings into
616  /// APISet itself, and APISet::recordUSR(const Decl *D) is a helper method
617  /// to generate the USR for \c D and keep it alive in APISet.
618  ObjCProtocolRecord *addObjCProtocol(StringRef Name, StringRef USR,
619  PresumedLoc Loc,
620  const AvailabilityInfo &Availability,
621  const DocComment &Comment,
622  DeclarationFragments Declaration,
623  DeclarationFragments SubHeading);
624 
625  /// Create a macro definition record into the API set.
626  ///
627  /// Note: the caller is responsible for keeping the StringRef \p Name and
628  /// \p USR alive. APISet::copyString provides a way to copy strings into
629  /// APISet itself, and APISet::recordUSRForMacro(StringRef Name,
630  /// SourceLocation SL, const SourceManager &SM) is a helper method to generate
631  /// the USR for the macro and keep it alive in APISet.
632  MacroDefinitionRecord *addMacroDefinition(StringRef Name, StringRef USR,
633  PresumedLoc Loc,
634  DeclarationFragments Declaration,
635  DeclarationFragments SubHeading);
636 
637  /// Create a typedef record into the API set.
638  ///
639  /// Note: the caller is responsible for keeping the StringRef \p Name and
640  /// \p USR alive. APISet::copyString provides a way to copy strings into
641  /// APISet itself, and APISet::recordUSR(const Decl *D) is a helper method
642  /// to generate the USR for \c D and keep it alive in APISet.
643  TypedefRecord *addTypedef(StringRef Name, StringRef USR, PresumedLoc Loc,
644  const AvailabilityInfo &Availability,
645  const DocComment &Comment,
646  DeclarationFragments Declaration,
647  DeclarationFragments SubHeading,
648  SymbolReference UnderlyingType);
649 
650  /// A mapping type to store a set of APIRecord%s with the USR as the key.
651  template <typename RecordTy,
652  typename =
653  std::enable_if_t<std::is_base_of<APIRecord, RecordTy>::value>>
654  using RecordMap = llvm::MapVector<StringRef, std::unique_ptr<RecordTy>>;
655 
656  /// Get the target triple for the ExtractAPI invocation.
657  const llvm::Triple &getTarget() const { return Target; }
658 
659  /// Get the language used by the APIs.
660  Language getLanguage() const { return Lang; }
661 
663  return GlobalFunctions;
664  }
666  return GlobalVariables;
667  }
668  const RecordMap<EnumRecord> &getEnums() const { return Enums; }
669  const RecordMap<StructRecord> &getStructs() const { return Structs; }
671  return ObjCCategories;
672  }
674  return ObjCInterfaces;
675  }
677  return ObjCProtocols;
678  }
679  const RecordMap<MacroDefinitionRecord> &getMacros() const { return Macros; }
680  const RecordMap<TypedefRecord> &getTypedefs() const { return Typedefs; }
681 
682  /// Generate and store the USR of declaration \p D.
683  ///
684  /// Note: The USR string is stored in and owned by Allocator.
685  ///
686  /// \returns a StringRef of the generated USR string.
687  StringRef recordUSR(const Decl *D);
688 
689  /// Generate and store the USR for a macro \p Name.
690  ///
691  /// Note: The USR string is stored in and owned by Allocator.
692  ///
693  /// \returns a StringRef to the generate USR string.
694  StringRef recordUSRForMacro(StringRef Name, SourceLocation SL,
695  const SourceManager &SM);
696 
697  /// Copy \p String into the Allocator in this APISet.
698  ///
699  /// \returns a StringRef of the copied string in APISet::Allocator.
700  StringRef copyString(StringRef String);
701 
702  APISet(const llvm::Triple &Target, Language Lang)
703  : Target(Target), Lang(Lang) {}
704 
705 private:
706  /// BumpPtrAllocator to store generated/copied strings.
707  ///
708  /// Note: The main use for this is being able to deduplicate strings.
709  llvm::BumpPtrAllocator StringAllocator;
710 
711  const llvm::Triple Target;
712  const Language Lang;
713 
714  RecordMap<GlobalFunctionRecord> GlobalFunctions;
715  RecordMap<GlobalVariableRecord> GlobalVariables;
716  RecordMap<EnumRecord> Enums;
717  RecordMap<StructRecord> Structs;
718  RecordMap<ObjCCategoryRecord> ObjCCategories;
719  RecordMap<ObjCInterfaceRecord> ObjCInterfaces;
720  RecordMap<ObjCProtocolRecord> ObjCProtocols;
721  RecordMap<MacroDefinitionRecord> Macros;
722  RecordMap<TypedefRecord> Typedefs;
723 };
724 
725 } // namespace extractapi
726 } // namespace clang
727 
728 #endif // LLVM_CLANG_EXTRACTAPI_API_H
clang::extractapi::ObjCInterfaceRecord::ObjCInterfaceRecord
ObjCInterfaceRecord(StringRef USR, StringRef Name, PresumedLoc Loc, const AvailabilityInfo &Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, SymbolReference SuperClass)
Definition: API.h:382
clang::extractapi::ObjCPropertyRecord::ReadOnly
@ ReadOnly
Definition: API.h:233
clang::extractapi::APISet::addObjCInstanceVariable
ObjCInstanceVariableRecord * addObjCInstanceVariable(ObjCContainerRecord *Container, StringRef Name, StringRef USR, PresumedLoc Loc, const AvailabilityInfo &Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, ObjCInstanceVariableRecord::AccessControl Access)
Create and add an Objective-C instance variable record into the API set.
Definition: API.cpp:153
clang::extractapi::StructRecord
This holds information associated with structs.
Definition: API.h:210
clang::extractapi::ObjCProtocolRecord
This holds information associated with Objective-C protocols.
Definition: API.h:401
clang::extractapi::SymbolReference::SymbolReference
SymbolReference()=default
clang::extractapi::SymbolReference::SymbolReference
SymbolReference(StringRef Name, StringRef USR="", StringRef Source="")
Definition: API.h:322
clang::extractapi::APISet::getObjCProtocols
const RecordMap< ObjCProtocolRecord > & getObjCProtocols() const
Definition: API.h:676
clang::extractapi::ObjCCategoryRecord::classof
static bool classof(const APIRecord *Record)
Definition: API.h:368
clang::extractapi::APISet::getStructs
const RecordMap< StructRecord > & getStructs() const
Definition: API.h:669
clang::extractapi::APIRecord::Availability
AvailabilityInfo Availability
Definition: API.h:61
clang::extractapi::ObjCMethodRecord::ObjCMethodRecord
ObjCMethodRecord(StringRef USR, StringRef Name, PresumedLoc Loc, const AvailabilityInfo &Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, bool IsInstanceMethod)
Definition: API.h:295
clang::extractapi::APIRecord::Name
StringRef Name
Definition: API.h:59
clang::extractapi::ObjCMethodRecord
This holds information associated with Objective-C methods.
Definition: API.h:291
clang::extractapi::ObjCContainerRecord::Ivars
SmallVector< std::unique_ptr< ObjCInstanceVariableRecord > > Ivars
Definition: API.h:338
llvm::SmallVector
Definition: LLVM.h:38
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
clang::extractapi::ObjCPropertyRecord::Attributes
AttributeKind Attributes
Definition: API.h:238
clang::extractapi::APISet::getGlobalFunctions
const RecordMap< GlobalFunctionRecord > & getGlobalFunctions() const
Definition: API.h:662
clang::MultiVersionKind::Target
@ Target
clang::extractapi::StructRecord::classof
static bool classof(const APIRecord *Record)
Definition: API.h:220
clang::extractapi::GlobalVariableRecord
This holds information associated with global functions.
Definition: API.h:139
clang::extractapi::APISet::getMacros
const RecordMap< MacroDefinitionRecord > & getMacros() const
Definition: API.h:679
clang::extractapi::has_function_signature
Check if a record type has a function signature mixin.
Definition: API.h:464
clang::extractapi::ObjCPropertyRecord::classof
static bool classof(const APIRecord *Record)
Definition: API.h:259
clang::extractapi::DeclarationFragments
DeclarationFragments is a vector of tagged important parts of a symbol's declaration.
Definition: DeclarationFragments.h:43
clang::extractapi::ObjCPropertyRecord::SetterName
StringRef SetterName
Definition: API.h:240
clang::extractapi::APISet::addEnum
EnumRecord * addEnum(StringRef Name, StringRef USR, PresumedLoc Loc, const AvailabilityInfo &Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading)
Create and add an enum record into the API set.
Definition: API.cpp:71
clang::extractapi::FunctionSignature
Store function signature information with DeclarationFragments of the return type and parameters.
Definition: DeclarationFragments.h:147
clang::extractapi::GlobalFunctionRecord::classof
static bool classof(const APIRecord *Record)
Definition: API.h:130
clang::extractapi::APIRecord::RK_ObjCInterface
@ RK_ObjCInterface
Definition: API.h:89
clang::extractapi::APIRecord::Comment
DocComment Comment
Documentation comment lines attached to this symbol declaration.
Definition: API.h:65
clang::extractapi::ObjCPropertyRecord::isReadOnly
bool isReadOnly() const
Definition: API.h:255
clang::extractapi::ObjCPropertyRecord::NoAttr
@ NoAttr
Definition: API.h:232
clang::SourceManager
This class handles loading and caching of source files into memory.
Definition: SourceManager.h:627
clang::extractapi::GlobalVariableRecord::GlobalVariableRecord
GlobalVariableRecord(StringRef USR, StringRef Name, PresumedLoc Loc, const AvailabilityInfo &Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading)
Definition: API.h:140
clang::ObjCIvarDecl::AccessControl
AccessControl
Definition: DeclObjC.h:1927
Decl.h
DeclObjC.h
RawCommentList.h
clang::extractapi::GlobalFunctionRecord
This holds information associated with global functions.
Definition: API.h:117
clang::extractapi::EnumConstantRecord::classof
static bool classof(const APIRecord *Record)
Definition: API.h:166
clang::extractapi::APIRecord::APIRecord
APIRecord(RecordKind Kind, StringRef USR, StringRef Name, PresumedLoc Location, const AvailabilityInfo &Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading)
Definition: API.h:104
clang::extractapi::ObjCInstanceVariableRecord::classof
static bool classof(const APIRecord *Record)
Definition: API.h:282
clang::extractapi::APIRecord::~APIRecord
virtual ~APIRecord()=0
Definition: API.cpp:216
clang::Linkage
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
Definition: Linkage.h:23
clang::extractapi::APIRecord::RK_Enum
@ RK_Enum
Definition: API.h:83
DeclarationFragments.h
clang::extractapi::APIRecord::Declaration
DeclarationFragments Declaration
Declaration fragments of this symbol declaration.
Definition: API.h:68
clang::extractapi::GlobalFunctionRecord::Signature
FunctionSignature Signature
Definition: API.h:118
clang::extractapi::ObjCMethodRecord::IsInstanceMethod
bool IsInstanceMethod
Definition: API.h:293
clang::extractapi::APISet::addGlobalFunction
GlobalFunctionRecord * addGlobalFunction(StringRef Name, StringRef USR, PresumedLoc Loc, const AvailabilityInfo &Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature)
Create and add a function record into the API set.
Definition: API.cpp:53
clang::extractapi::EnumRecord::classof
static bool classof(const APIRecord *Record)
Definition: API.h:184
clang::extractapi::TypedefRecord
This holds information associated with typedefs.
Definition: API.h:440
clang::extractapi::MacroDefinitionRecord
This holds information associated with macro definitions.
Definition: API.h:420
clang::extractapi::APISet::recordUSR
StringRef recordUSR(const Decl *D)
Generate and store the USR of declaration D.
Definition: API.cpp:190
clang::extractapi::APIRecord::RK_Typedef
@ RK_Typedef
Definition: API.h:93
clang::extractapi::APISet::copyString
StringRef copyString(StringRef String)
Copy String into the Allocator in this APISet.
Definition: API.cpp:203
clang::extractapi::TypedefRecord::TypedefRecord
TypedefRecord(StringRef USR, StringRef Name, PresumedLoc Loc, const AvailabilityInfo &Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, SymbolReference UnderlyingType)
Definition: API.h:443
clang::extractapi::MacroDefinitionRecord::classof
static bool classof(const APIRecord *Record)
Definition: API.h:427
clang::extractapi::APIRecord::RK_Struct
@ RK_Struct
Definition: API.h:85
clang::extractapi::SymbolReference::USR
StringRef USR
Definition: API.h:316
clang::extractapi::GlobalFunctionRecord::GlobalFunctionRecord
GlobalFunctionRecord(StringRef USR, StringRef Name, PresumedLoc Loc, const AvailabilityInfo &Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature)
Definition: API.h:120
clang::extractapi::APIRecord::getKind
RecordKind getKind() const
Definition: API.h:100
clang::extractapi::ObjCInstanceVariableRecord
This holds information associated with Objective-C instance variables.
Definition: API.h:268
clang::extractapi::APISet::recordUSRForMacro
StringRef recordUSRForMacro(StringRef Name, SourceLocation SL, const SourceManager &SM)
Generate and store the USR for a macro Name.
Definition: API.cpp:196
clang::LinkageInfo
Definition: Visibility.h:52
clang::extractapi::APIRecord::Location
PresumedLoc Location
Definition: API.h:60
clang::extractapi::DocComment
std::vector< RawComment::CommentLine > DocComment
DocComment is a vector of RawComment::CommentLine.
Definition: API.h:51
clang::extractapi::StructRecord::Fields
SmallVector< std::unique_ptr< StructFieldRecord > > Fields
Definition: API.h:211
clang::extractapi::SymbolReference::Source
StringRef Source
The source project/module/product of the referred symbol.
Definition: API.h:319
clang::extractapi::APIRecord::RK_ObjCCategory
@ RK_ObjCCategory
Definition: API.h:90
clang::extractapi::APISet::getObjCInterfaces
const RecordMap< ObjCInterfaceRecord > & getObjCInterfaces() const
Definition: API.h:673
clang::extractapi::APIRecord::RK_ObjCProperty
@ RK_ObjCProperty
Definition: API.h:86
clang::extractapi::APISet::addStructField
StructFieldRecord * addStructField(StructRecord *Struct, StringRef Name, StringRef USR, PresumedLoc Loc, const AvailabilityInfo &Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading)
Create and add a struct field record into the API set.
Definition: API.cpp:80
clang::extractapi::ObjCInstanceVariableRecord::ObjCInstanceVariableRecord
ObjCInstanceVariableRecord(StringRef USR, StringRef Name, PresumedLoc Loc, const AvailabilityInfo &Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, AccessControl Access)
Definition: API.h:272
clang::extractapi::ObjCContainerRecord::Protocols
SmallVector< SymbolReference > Protocols
Definition: API.h:339
clang::extractapi::APIRecord::RK_GlobalVariable
@ RK_GlobalVariable
Definition: API.h:81
clang::extractapi::SymbolReference::empty
bool empty() const
Determine if this SymbolReference is empty.
Definition: API.h:330
clang::extractapi::ObjCPropertyRecord::Class
@ Class
Definition: API.h:234
SourceLocation.h
clang::extractapi::APISet::addGlobalVar
GlobalVariableRecord * addGlobalVar(StringRef Name, StringRef USR, PresumedLoc Loc, const AvailabilityInfo &Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading)
Create and add a global variable record into the API set.
Definition: API.cpp:45
AvailabilityInfo.h
clang::extractapi::ObjCInterfaceRecord::SuperClass
SymbolReference SuperClass
Definition: API.h:378
clang::Language
Language
The language for the input, used to select and validate the language standard and possible actions.
Definition: LangStandard.h:23
clang::extractapi::ObjCContainerRecord::Properties
SmallVector< std::unique_ptr< ObjCPropertyRecord > > Properties
Definition: API.h:337
clang::extractapi::APIRecord::RK_ObjCIvar
@ RK_ObjCIvar
Definition: API.h:87
clang::extractapi::MacroDefinitionRecord::MacroDefinitionRecord
MacroDefinitionRecord(StringRef USR, StringRef Name, PresumedLoc Loc, DeclarationFragments Declaration, DeclarationFragments SubHeading)
Definition: API.h:421
clang::extractapi::ObjCInstanceVariableRecord::Access
AccessControl Access
Definition: API.h:270
clang::extractapi::AvailabilityInfo
Stores availability attributes of a symbol.
Definition: AvailabilityInfo.h:28
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:83
clang::extractapi::ObjCContainerRecord
The base representation of an Objective-C container record.
Definition: API.h:335
clang::extractapi::APISet::getTarget
const llvm::Triple & getTarget() const
Get the target triple for the ExtractAPI invocation.
Definition: API.h:657
clang::extractapi::ObjCProtocolRecord::classof
static bool classof(const APIRecord *Record)
Definition: API.h:411
clang::extractapi::APISet::APISet
APISet(const llvm::Triple &Target, Language Lang)
Definition: API.h:702
clang::extractapi::ObjCContainerRecord::ObjCContainerRecord
ObjCContainerRecord()=delete
clang::extractapi::ObjCPropertyRecord::isDynamic
bool isDynamic() const
Definition: API.h:256
clang::extractapi::StructRecord::StructRecord
StructRecord(StringRef USR, StringRef Name, PresumedLoc Loc, const AvailabilityInfo &Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading)
Definition: API.h:213
clang::extractapi::GlobalVariableRecord::classof
static bool classof(const APIRecord *Record)
Definition: API.h:148
clang::extractapi::APISet::addObjCProperty
ObjCPropertyRecord * addObjCProperty(ObjCContainerRecord *Container, StringRef Name, StringRef USR, PresumedLoc Loc, const AvailabilityInfo &Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, ObjCPropertyRecord::AttributeKind Attributes, StringRef GetterName, StringRef SetterName, bool IsOptional)
Create and add an Objective-C property record into the API set.
Definition: API.cpp:140
clang::extractapi::SymbolReference::SymbolReference
SymbolReference(const APIRecord &Record)
Definition: API.h:324
clang::extractapi::APIRecord::RK_GlobalFunction
@ RK_GlobalFunction
Definition: API.h:80
clang::extractapi::APISet::addMacroDefinition
MacroDefinitionRecord * addMacroDefinition(StringRef Name, StringRef USR, PresumedLoc Loc, DeclarationFragments Declaration, DeclarationFragments SubHeading)
Create a macro definition record into the API set.
Definition: API.cpp:173
clang::extractapi::APISet::addObjCCategory
ObjCCategoryRecord * addObjCCategory(StringRef Name, StringRef USR, PresumedLoc Loc, const AvailabilityInfo &Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, SymbolReference Interface)
Create and add an Objective-C category record into the API set.
Definition: API.cpp:100
clang::extractapi::TypedefRecord::classof
static bool classof(const APIRecord *Record)
Definition: API.h:451
clang::extractapi::ObjCPropertyRecord
This holds information associated with Objective-C properties.
Definition: API.h:229
clang::extractapi::APISet::getGlobalVariables
const RecordMap< GlobalVariableRecord > & getGlobalVariables() const
Definition: API.h:665
clang::extractapi::EnumRecord::Constants
SmallVector< std::unique_ptr< EnumConstantRecord > > Constants
Definition: API.h:176
clang::extractapi::EnumRecord
This holds information associated with enums.
Definition: API.h:175
clang::extractapi::APISet::addObjCProtocol
ObjCProtocolRecord * addObjCProtocol(StringRef Name, StringRef USR, PresumedLoc Loc, const AvailabilityInfo &Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading)
Create and add an Objective-C protocol record into the API set.
Definition: API.cpp:164
clang::extractapi::APIRecord::USR
StringRef USR
Definition: API.h:58
clang::extractapi::APISet::addEnumConstant
EnumConstantRecord * addEnumConstant(EnumRecord *Enum, StringRef Name, StringRef USR, PresumedLoc Loc, const AvailabilityInfo &Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading)
Create and add an enum constant record into the API set.
Definition: API.cpp:62
clang::extractapi::ObjCCategoryRecord
This holds information associated with Objective-C categories.
Definition: API.h:355
clang
Definition: CalledOnceCheck.h:17
clang::extractapi::ObjCContainerRecord::Methods
SmallVector< std::unique_ptr< ObjCMethodRecord > > Methods
Definition: API.h:336
clang::extractapi::ObjCInterfaceRecord
This holds information associated with Objective-C interfaces/classes.
Definition: API.h:377
clang::extractapi::APISet
APISet holds the set of API records collected from given inputs.
Definition: API.h:471
clang::extractapi::APIRecord::SubHeading
DeclarationFragments SubHeading
SubHeading provides a more detailed representation than the plain declaration name.
Definition: API.h:76
clang::extractapi::ObjCCategoryRecord::Interface
SymbolReference Interface
Definition: API.h:356
clang::extractapi::APIRecord::RK_EnumConstant
@ RK_EnumConstant
Definition: API.h:82
clang::extractapi::EnumRecord::EnumRecord
EnumRecord(StringRef USR, StringRef Name, PresumedLoc Loc, const AvailabilityInfo &Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading)
Definition: API.h:178
clang::extractapi::ObjCMethodRecord::Signature
FunctionSignature Signature
Definition: API.h:292
clang::extractapi::EnumConstantRecord
This holds information associated with enum constants.
Definition: API.h:157
clang::extractapi::StructFieldRecord
This holds information associated with struct fields.
Definition: API.h:193
clang::extractapi::ObjCPropertyRecord::IsOptional
bool IsOptional
Definition: API.h:241
clang::extractapi::ObjCPropertyRecord::ObjCPropertyRecord
ObjCPropertyRecord(StringRef USR, StringRef Name, PresumedLoc Loc, const AvailabilityInfo &Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, AttributeKind Attributes, StringRef GetterName, StringRef SetterName, bool IsOptional)
Definition: API.h:243
clang::extractapi::StructFieldRecord::StructFieldRecord
StructFieldRecord(StringRef USR, StringRef Name, PresumedLoc Loc, const AvailabilityInfo &Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading)
Definition: API.h:194
clang::extractapi::ObjCMethodRecord::classof
static bool classof(const APIRecord *Record)
Definition: API.h:304
clang::extractapi::APIRecord::RK_ObjCProtocol
@ RK_ObjCProtocol
Definition: API.h:91
clang::extractapi::APIRecord::RK_ObjCMethod
@ RK_ObjCMethod
Definition: API.h:88
clang::extractapi::APISet::getObjCCategories
const RecordMap< ObjCCategoryRecord > & getObjCCategories() const
Definition: API.h:670
clang::extractapi::ObjCCategoryRecord::ObjCCategoryRecord
ObjCCategoryRecord(StringRef USR, StringRef Name, PresumedLoc Loc, const AvailabilityInfo &Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, SymbolReference Interface)
Definition: API.h:358
clang::PresumedLoc
Represents an unpacked "presumed" location which can be presented to the user.
Definition: SourceLocation.h:302
clang::extractapi::APISet::addObjCInterface
ObjCInterfaceRecord * addObjCInterface(StringRef Name, StringRef USR, PresumedLoc Loc, const AvailabilityInfo &Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, SymbolReference SuperClass)
Create and add an Objective-C interface record into the API set.
Definition: API.cpp:118
clang::extractapi::APISet::addStruct
StructRecord * addStruct(StringRef Name, StringRef USR, PresumedLoc Loc, const AvailabilityInfo &Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading)
Create and add a struct record into the API set.
Definition: API.cpp:91
clang::extractapi::ObjCPropertyRecord::AttributeKind
AttributeKind
The attributes associated with an Objective-C property.
Definition: API.h:231
clang::extractapi::APISet::getTypedefs
const RecordMap< TypedefRecord > & getTypedefs() const
Definition: API.h:680
clang::extractapi::APISet::addObjCMethod
ObjCMethodRecord * addObjCMethod(ObjCContainerRecord *Container, StringRef Name, StringRef USR, PresumedLoc Loc, const AvailabilityInfo &Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, FunctionSignature Signature, bool IsInstanceMethod)
Create and add an Objective-C method record into the API set.
Definition: API.cpp:128
clang::extractapi::ObjCInterfaceRecord::Categories
SmallVector< ObjCCategoryRecord * > Categories
Definition: API.h:380
clang::extractapi::ObjCPropertyRecord::isClassProperty
bool isClassProperty() const
Definition: API.h:257
clang::extractapi::TypedefRecord::UnderlyingType
SymbolReference UnderlyingType
Definition: API.h:441
clang::extractapi::APISet::getLanguage
Language getLanguage() const
Get the language used by the APIs.
Definition: API.h:660
clang::extractapi::APIRecord::RecordKind
RecordKind
Discriminator for LLVM-style RTTI (dyn_cast<> et al.)
Definition: API.h:79
SM
#define SM(sm)
Definition: Cuda.cpp:81
clang::extractapi::APISet::RecordMap
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:654
clang::extractapi::StructFieldRecord::classof
static bool classof(const APIRecord *Record)
Definition: API.h:201
clang::extractapi::SymbolReference::Name
StringRef Name
Definition: API.h:315
clang::extractapi::ObjCPropertyRecord::Dynamic
@ Dynamic
Definition: API.h:235
clang::extractapi::APIRecord
The base representation of an API record. Holds common symbol information.
Definition: API.h:57
clang::extractapi::ObjCContainerRecord::ObjCContainerRecord
ObjCContainerRecord(RecordKind Kind, StringRef USR, StringRef Name, PresumedLoc Loc, const AvailabilityInfo &Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading)
Definition: API.h:343
clang::extractapi::ObjCInterfaceRecord::classof
static bool classof(const APIRecord *Record)
Definition: API.h:392
clang::extractapi::APISet::addTypedef
TypedefRecord * addTypedef(StringRef Name, StringRef USR, PresumedLoc Loc, const AvailabilityInfo &Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading, SymbolReference UnderlyingType)
Create a typedef record into the API set.
Definition: API.cpp:179
clang::extractapi::APISet::getEnums
const RecordMap< EnumRecord > & getEnums() const
Definition: API.h:668
clang::extractapi::ObjCPropertyRecord::GetterName
StringRef GetterName
Definition: API.h:239
clang::extractapi::APIRecord::Linkage
LinkageInfo Linkage
Definition: API.h:62
clang::extractapi::APIRecord::APIRecord
APIRecord()=delete
clang::extractapi::EnumConstantRecord::EnumConstantRecord
EnumConstantRecord(StringRef USR, StringRef Name, PresumedLoc Loc, const AvailabilityInfo &Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading)
Definition: API.h:158
clang::extractapi::SymbolReference
This represents a reference to another symbol that might come from external sources.
Definition: API.h:314
clang::extractapi::APIRecord::RK_StructField
@ RK_StructField
Definition: API.h:84
clang::extractapi::APIRecord::RK_MacroDefinition
@ RK_MacroDefinition
Definition: API.h:92
clang::extractapi::ObjCContainerRecord::~ObjCContainerRecord
virtual ~ObjCContainerRecord()=0
Definition: API.cpp:218
clang::extractapi::ObjCProtocolRecord::ObjCProtocolRecord
ObjCProtocolRecord(StringRef USR, StringRef Name, PresumedLoc Loc, const AvailabilityInfo &Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading)
Definition: API.h:402