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(); }
276 mutable APIRecord *NextInContext =
nullptr;
351 Current = Current->getNextInContext();
361 return x.Current == y.Current;
364 return x.Current != y.Current;
380 bool IsWellFormed()
const;
437 virtual void anchor();
518 virtual void anchor();
604 virtual void anchor();
651 virtual void anchor();
716 virtual void anchor();
735 virtual void anchor();
753 virtual void anchor();
772 virtual void anchor();
805 virtual void anchor();
865 virtual void anchor();
886 virtual void anchor();
907 virtual void anchor();
929 virtual void anchor();
1025 virtual void anchor();
1048 virtual void anchor();
1070 virtual void anchor();
1110 virtual void anchor();
1130 virtual void anchor();
1194 virtual void anchor();
1305 virtual void anchor();
1329 virtual void anchor();
1350 virtual void anchor();
1369 virtual void anchor();
1396 virtual void anchor();
1419 StringRef Source =
"");
1425 template <
typename RecordTy,
typename... CtorArgsContTy>
1426 typename std::enable_if_t<std::is_base_of_v<APIRecord, RecordTy>, RecordTy> *
1427 createRecord(StringRef USR, StringRef Name, CtorArgsContTy &&...CtorArgs);
1430 return TopLevelRecords;
1445 llvm::BumpPtrAllocator Allocator;
1447 const llvm::Triple
Target;
1450 struct APIRecordDeleter {
1457 using APIRecordStoredPtr = std::unique_ptr<APIRecord, APIRecordDeleter>;
1458 llvm::DenseMap<StringRef, APIRecordStoredPtr> USRBasedLookupTable;
1459 std::vector<const APIRecord *> TopLevelRecords;
1465template <
typename RecordTy,
typename... CtorArgsContTy>
1466typename std::enable_if_t<std::is_base_of_v<APIRecord, RecordTy>, RecordTy> *
1468 CtorArgsContTy &&...CtorArgs) {
1471 auto Result = USRBasedLookupTable.insert({USRString,
nullptr});
1476 Record =
new (Allocator) RecordTy(
1477 USRString,
copyString(Name), std::forward<CtorArgsContTy>(CtorArgs)...);
1481 if (
auto *ParentContext =
1482 dyn_cast_if_present<RecordContext>(
Record->Parent.Record))
1483 ParentContext->addToRecordChain(
Record);
1485 TopLevelRecords.push_back(
Record);
1487 Record = dyn_cast<RecordTy>(
Result.first->second.get());
1495template <
typename FromTy,
1496 bool IsKnownSubType = std::is_base_of_v<RecordContext, FromTy>>
1498 static_assert(std::is_base_of_v<APIRecord, FromTy>,
1499 "Can only cast APIRecord and derived classes to RecordContext");
1510 static_assert(std::is_base_of_v<APIRecord, FromTy>,
1511 "Can only cast APIRecord and derived classes to RecordContext");
1520template <
typename ToTy,
1521 bool IsKnownSubType = std::is_base_of_v<RecordContext, ToTy>>
1524 std::is_base_of_v<APIRecord, ToTy>,
1525 "Can only class RecordContext to APIRecord and derived classes");
1528 return ToTy::classofKind(Ctx->
getKind());
1539 std::is_base_of_v<APIRecord, ToTy>,
1540 "Can only class RecordContext to APIRecord and derived classes");
1542 return ToTy::classof(Ctx->
getKind());
1545 return static_cast<ToTy *
>(Ctx);
1556template <
typename FromTy>
1560 ::clang::extractapi::RecordContext *, FromTy *,
1561 CastInfo<::clang::extractapi::RecordContext, FromTy *>> {
1563 return ::clang::extractapi::ToRecordContextCastInfoWrapper<
1564 FromTy>::isPossible(From);
1567 static inline ::clang::extractapi::RecordContext *
doCast(FromTy *From) {
1568 return ::clang::extractapi::ToRecordContextCastInfoWrapper<FromTy>::doCast(
1573template <
typename FromTy>
1576 ::clang::extractapi::RecordContext, const FromTy *,
1577 CastInfo<::clang::extractapi::RecordContext, FromTy *>> {};
1579template <
typename ToTy>
1583 ToTy *, ::clang::extractapi::RecordContext *,
1584 CastInfo<ToTy, ::clang::extractapi::RecordContext *>> {
1586 return ::clang::extractapi::FromRecordContextCastInfoWrapper<
1587 ToTy>::isPossible(Ctx);
1591 return ::clang::extractapi::FromRecordContextCastInfoWrapper<ToTy>::doCast(
1596template <
typename ToTy>
1599 ToTy, const ::clang::extractapi::RecordContext *,
1600 CastInfo<ToTy, ::clang::extractapi::RecordContext *>> {};
enum clang::sema::@1658::IndirectLocalPathEntry::EntryKind Kind
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.