18#ifndef LLVM_CLANG_EXTRACTAPI_API_H
19#define LLVM_CLANG_EXTRACTAPI_API_H
29#include "llvm/ADT/ArrayRef.h"
30#include "llvm/ADT/MapVector.h"
31#include "llvm/ADT/StringRef.h"
32#include "llvm/Support/Allocator.h"
33#include "llvm/Support/Casting.h"
34#include "llvm/Support/Compiler.h"
35#include "llvm/Support/ErrorHandling.h"
36#include "llvm/Support/raw_ostream.h"
37#include "llvm/TargetParser/Triple.h"
57 unsigned int Depth,
bool IsParameterPack)
58 :
Type(
Type), Name(Name), Index(Index), Depth(Depth),
59 IsParameterPack(IsParameterPack) {}
62 struct TemplateConstraint {
75 for (
auto *
const Parameter : *
Decl->getTemplateParameters()) {
76 const auto *Param = dyn_cast<TemplateTypeParmDecl>(
Parameter);
80 if (Param->hasTypeConstraint())
81 Type = Param->getTypeConstraint()->getNamedConcept()->getName().str();
82 else if (Param->wasDeclaredWithTypename())
88 Param->getDepth(), Param->isParameterPack());
93 for (
auto *
const Parameter : *
Decl->getTemplateParameters()) {
94 const auto *Param = dyn_cast<TemplateTypeParmDecl>(
Parameter);
98 if (Param->hasTypeConstraint())
99 Type = Param->getTypeConstraint()->getNamedConcept()->getName().str();
100 else if (Param->wasDeclaredWithTypename())
106 Param->getDepth(), Param->isParameterPack());
111 for (
auto *
const Parameter : *
Decl->getTemplateParameters()) {
112 const auto *Param = dyn_cast<TemplateTypeParmDecl>(
Parameter);
116 if (Param->hasTypeConstraint())
117 Type = Param->getTypeConstraint()->getNamedConcept()->getName().str();
118 else if (Param->wasDeclaredWithTypename())
124 Param->getDepth(), Param->isParameterPack());
137 unsigned int Index,
unsigned int Depth,
138 bool IsParameterPack) {
139 Parameters.emplace_back(
Type, Name, Index, Depth, IsParameterPack);
142 bool empty()
const {
return Parameters.empty() && Constraints.empty(); }
274 mutable APIRecord *NextInContext =
nullptr;
348 Current = Current->getNextInContext();
358 return x.Current == y.Current;
361 return x.Current != y.Current;
377 bool IsWellFormed()
const;
434 virtual void anchor();
515 virtual void anchor();
601 virtual void anchor();
648 virtual void anchor();
713 virtual void anchor();
732 virtual void anchor();
750 virtual void anchor();
769 virtual void anchor();
802 virtual void anchor();
862 virtual void anchor();
883 virtual void anchor();
904 virtual void anchor();
926 virtual void anchor();
1022 virtual void anchor();
1045 virtual void anchor();
1067 virtual void anchor();
1107 virtual void anchor();
1127 virtual void anchor();
1191 virtual void anchor();
1302 virtual void anchor();
1326 virtual void anchor();
1347 virtual void anchor();
1366 virtual void anchor();
1393 virtual void anchor();
1416 StringRef Source =
"");
1422 template <
typename RecordTy,
typename... CtorArgsContTy>
1423 typename std::enable_if_t<std::is_base_of_v<APIRecord, RecordTy>, RecordTy> *
1424 createRecord(StringRef USR, StringRef Name, CtorArgsContTy &&...CtorArgs);
1427 return TopLevelRecords;
1442 llvm::BumpPtrAllocator Allocator;
1444 const llvm::Triple
Target;
1447 struct APIRecordDeleter {
1454 using APIRecordStoredPtr = std::unique_ptr<APIRecord, APIRecordDeleter>;
1455 llvm::DenseMap<StringRef, APIRecordStoredPtr> USRBasedLookupTable;
1456 std::vector<const APIRecord *> TopLevelRecords;
1462template <
typename RecordTy,
typename... CtorArgsContTy>
1463typename std::enable_if_t<std::is_base_of_v<APIRecord, RecordTy>, RecordTy> *
1465 CtorArgsContTy &&...CtorArgs) {
1468 auto Result = USRBasedLookupTable.insert({USRString,
nullptr});
1473 Record =
new (Allocator) RecordTy(
1474 USRString,
copyString(Name), std::forward<CtorArgsContTy>(CtorArgs)...);
1478 if (
auto *ParentContext =
1479 dyn_cast_if_present<RecordContext>(
Record->Parent.Record))
1480 ParentContext->addToRecordChain(
Record);
1482 TopLevelRecords.push_back(
Record);
1484 Record = dyn_cast<RecordTy>(
Result.first->second.get());
1492template <
typename FromTy,
1493 bool IsKnownSubType = std::is_base_of_v<RecordContext, FromTy>>
1495 static_assert(std::is_base_of_v<APIRecord, FromTy>,
1496 "Can only cast APIRecord and derived classes to RecordContext");
1507 static_assert(std::is_base_of_v<APIRecord, FromTy>,
1508 "Can only cast APIRecord and derived classes to RecordContext");
1517template <
typename ToTy,
1518 bool IsKnownSubType = std::is_base_of_v<RecordContext, ToTy>>
1521 std::is_base_of_v<APIRecord, ToTy>,
1522 "Can only class RecordContext to APIRecord and derived classes");
1525 return ToTy::classofKind(Ctx->
getKind());
1536 std::is_base_of_v<APIRecord, ToTy>,
1537 "Can only class RecordContext to APIRecord and derived classes");
1539 return ToTy::classof(Ctx->
getKind());
1542 return static_cast<ToTy *
>(Ctx);
1553template <
typename FromTy>
1557 ::clang::extractapi::RecordContext *, FromTy *,
1558 CastInfo<::clang::extractapi::RecordContext, FromTy *>> {
1560 return ::clang::extractapi::ToRecordContextCastInfoWrapper<
1561 FromTy>::isPossible(From);
1564 static inline ::clang::extractapi::RecordContext *
doCast(FromTy *From) {
1565 return ::clang::extractapi::ToRecordContextCastInfoWrapper<FromTy>::doCast(
1570template <
typename FromTy>
1573 ::clang::extractapi::RecordContext, const FromTy *,
1574 CastInfo<::clang::extractapi::RecordContext, FromTy *>> {};
1576template <
typename ToTy>
1580 ToTy *, ::clang::extractapi::RecordContext *,
1581 CastInfo<ToTy, ::clang::extractapi::RecordContext *>> {
1583 return ::clang::extractapi::FromRecordContextCastInfoWrapper<
1584 ToTy>::isPossible(Ctx);
1588 return ::clang::extractapi::FromRecordContextCastInfoWrapper<ToTy>::doCast(
1593template <
typename ToTy>
1596 ToTy, const ::clang::extractapi::RecordContext *,
1597 CastInfo<ToTy, ::clang::extractapi::RecordContext *>> {};
This file defines the Declaration Fragments related classes.
llvm::MachO::Target Target
llvm::MachO::Record Record
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
Decl - This represents one declaration (or definition), e.g.
Represents an unpacked "presumed" location which can be presented to the user.
The base class of all kinds of template declarations (e.g., class, function, etc.).
The base class of the type hierarchy.
The JSON file list parser is used to communicate input to InstallAPI.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
Language
The language for the input, used to select and validate the language standard and possible actions.
@ Parameter
The parameter type of a method or function.
@ Result
The result type of a method or function.
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
@ Other
Other implicit parameter.
Diagnostic wrappers for TextAPI types for error reporting.
Storage of availability attributes for a declaration.