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;
344 Current = Current->getNextInContext();
354 return x.Current == y.Current;
357 return x.Current != y.Current;
429 virtual void anchor();
505 virtual void anchor();
591 virtual void anchor();
611 virtual void anchor();
672 virtual void anchor();
689 virtual void anchor();
707 virtual void anchor();
724 virtual void anchor();
755 virtual void anchor();
815 virtual void anchor();
836 virtual void anchor();
857 virtual void anchor();
879 virtual void anchor();
975 virtual void anchor();
998 virtual void anchor();
1020 virtual void anchor();
1060 virtual void anchor();
1080 virtual void anchor();
1144 virtual void anchor();
1255 virtual void anchor();
1279 virtual void anchor();
1300 virtual void anchor();
1319 virtual void anchor();
1346 virtual void anchor();
1369 StringRef Source =
"");
1375 template <
typename RecordTy,
typename... CtorArgsContTy>
1376 typename std::enable_if_t<std::is_base_of_v<APIRecord, RecordTy>, RecordTy> *
1377 createRecord(StringRef USR, StringRef Name, CtorArgsContTy &&...CtorArgs);
1380 return TopLevelRecords;
1395 llvm::BumpPtrAllocator Allocator;
1397 const llvm::Triple
Target;
1400 struct APIRecordDeleter {
1407 using APIRecordStoredPtr = std::unique_ptr<APIRecord, APIRecordDeleter>;
1408 llvm::DenseMap<StringRef, APIRecordStoredPtr> USRBasedLookupTable;
1409 std::vector<const APIRecord *> TopLevelRecords;
1415template <
typename RecordTy,
typename... CtorArgsContTy>
1416typename std::enable_if_t<std::is_base_of_v<APIRecord, RecordTy>, RecordTy> *
1418 CtorArgsContTy &&...CtorArgs) {
1421 auto Result = USRBasedLookupTable.insert({USRString,
nullptr});
1426 Record =
new (Allocator) RecordTy(
1427 USRString,
copyString(Name), std::forward<CtorArgsContTy>(CtorArgs)...);
1431 if (
auto *ParentContext =
1432 dyn_cast_if_present<RecordContext>(
Record->Parent.Record))
1433 ParentContext->addToRecordChain(
Record);
1435 TopLevelRecords.push_back(
Record);
1437 Record = dyn_cast<RecordTy>(
Result.first->second.get());
1445template <
typename FromTy,
1446 bool IsKnownSubType = std::is_base_of_v<RecordContext, FromTy>>
1448 static_assert(std::is_base_of_v<APIRecord, FromTy>,
1449 "Can only cast APIRecord and derived classes to RecordContext");
1460 static_assert(std::is_base_of_v<APIRecord, FromTy>,
1461 "Can only cast APIRecord and derived classes to RecordContext");
1470template <
typename ToTy,
1471 bool IsKnownSubType = std::is_base_of_v<RecordContext, ToTy>>
1474 std::is_base_of_v<APIRecord, ToTy>,
1475 "Can only class RecordContext to APIRecord and derived classes");
1478 return ToTy::classofKind(Ctx->
getKind());
1489 std::is_base_of_v<APIRecord, ToTy>,
1490 "Can only class RecordContext to APIRecord and derived classes");
1492 return ToTy::classof(Ctx->
getKind());
1495 return static_cast<ToTy *
>(Ctx);
1506template <
typename FromTy>
1510 ::clang::extractapi::RecordContext *, FromTy *,
1511 CastInfo<::clang::extractapi::RecordContext, FromTy *>> {
1513 return ::clang::extractapi::ToRecordContextCastInfoWrapper<
1514 FromTy>::isPossible(From);
1517 static inline ::clang::extractapi::RecordContext *
doCast(FromTy *From) {
1518 return ::clang::extractapi::ToRecordContextCastInfoWrapper<FromTy>::doCast(
1523template <
typename FromTy>
1526 ::clang::extractapi::RecordContext, const FromTy *,
1527 CastInfo<::clang::extractapi::RecordContext, FromTy *>> {};
1529template <
typename ToTy>
1533 ToTy *, ::clang::extractapi::RecordContext *,
1534 CastInfo<ToTy, ::clang::extractapi::RecordContext *>> {
1536 return ::clang::extractapi::FromRecordContextCastInfoWrapper<
1537 ToTy>::isPossible(Ctx);
1541 return ::clang::extractapi::FromRecordContextCastInfoWrapper<ToTy>::doCast(
1546template <
typename ToTy>
1549 ToTy, const ::clang::extractapi::RecordContext *,
1550 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.