18#ifndef LLVM_CLANG_EXTRACTAPI_API_H
19#define LLVM_CLANG_EXTRACTAPI_API_H
26#include "llvm/ADT/SmallVector.h"
27#include "llvm/Support/Allocator.h"
28#include "llvm/Support/Casting.h"
29#include "llvm/Support/Compiler.h"
30#include "llvm/TargetParser/Triple.h"
50 unsigned int Depth,
bool IsParameterPack)
51 :
Type(
Type), Name(Name), Index(Index), Depth(Depth),
52 IsParameterPack(IsParameterPack) {}
55 struct TemplateConstraint {
68 for (
auto *
const Parameter : *
Decl->getTemplateParameters()) {
69 const auto *Param = dyn_cast<TemplateTypeParmDecl>(
Parameter);
73 if (Param->hasTypeConstraint())
74 Type = Param->getTypeConstraint()->getNamedConcept()->getName().str();
75 else if (Param->wasDeclaredWithTypename())
81 Param->getDepth(), Param->isParameterPack());
86 for (
auto *
const Parameter : *
Decl->getTemplateParameters()) {
87 const auto *Param = dyn_cast<TemplateTypeParmDecl>(
Parameter);
91 if (Param->hasTypeConstraint())
92 Type = Param->getTypeConstraint()->getNamedConcept()->getName().str();
93 else if (Param->wasDeclaredWithTypename())
99 Param->getDepth(), Param->isParameterPack());
104 for (
auto *
const Parameter : *
Decl->getTemplateParameters()) {
105 const auto *Param = dyn_cast<TemplateTypeParmDecl>(
Parameter);
109 if (Param->hasTypeConstraint())
110 Type = Param->getTypeConstraint()->getNamedConcept()->getName().str();
111 else if (Param->wasDeclaredWithTypename())
117 Param->getDepth(), Param->isParameterPack());
130 unsigned int Index,
unsigned int Depth,
131 bool IsParameterPack) {
132 Parameters.emplace_back(
Type, Name, Index, Depth, IsParameterPack);
135 bool empty()
const {
return Parameters.empty() && Constraints.empty(); }
269 mutable APIRecord *NextInContext =
nullptr;
346 Current = Current->getNextInContext();
356 return x.Current == y.Current;
359 return x.Current != y.Current;
375 bool IsWellFormed()
const;
432 virtual void anchor();
513 virtual void anchor();
599 virtual void anchor();
663 virtual void anchor();
743 virtual void anchor();
762 virtual void anchor();
780 virtual void anchor();
799 virtual void anchor();
832 virtual void anchor();
892 virtual void anchor();
913 virtual void anchor();
934 virtual void anchor();
956 virtual void anchor();
1052 virtual void anchor();
1075 virtual void anchor();
1097 virtual void anchor();
1137 virtual void anchor();
1157 virtual void anchor();
1221 virtual void anchor();
1332 virtual void anchor();
1356 virtual void anchor();
1377 virtual void anchor();
1396 virtual void anchor();
1423 virtual void anchor();
1446 StringRef Source =
"");
1452 template <
typename RecordTy,
typename... CtorArgsContTy>
1453 typename std::enable_if_t<std::is_base_of_v<APIRecord, RecordTy>, RecordTy> *
1454 createRecord(StringRef USR, StringRef Name, CtorArgsContTy &&...CtorArgs);
1457 return TopLevelRecords;
1476 llvm::BumpPtrAllocator Allocator;
1478 const llvm::Triple
Target;
1481 struct APIRecordDeleter {
1488 using APIRecordStoredPtr = std::unique_ptr<APIRecord, APIRecordDeleter>;
1489 llvm::DenseMap<StringRef, APIRecordStoredPtr> USRBasedLookupTable;
1496template <
typename RecordTy,
typename... CtorArgsContTy>
1497typename std::enable_if_t<std::is_base_of_v<APIRecord, RecordTy>, RecordTy> *
1499 CtorArgsContTy &&...CtorArgs) {
1502 auto Result = USRBasedLookupTable.insert({USRString,
nullptr});
1507 Record =
new (Allocator) RecordTy(
1508 USRString,
copyString(Name), std::forward<CtorArgsContTy>(CtorArgs)...);
1512 if (
auto *ParentContext =
1513 dyn_cast_if_present<RecordContext>(
Record->Parent.Record))
1514 ParentContext->addToRecordChain(
Record);
1516 TopLevelRecords.push_back(
Record);
1518 Record = dyn_cast<RecordTy>(
Result.first->second.get());
1526template <
typename FromTy,
1527 bool IsKnownSubType = std::is_base_of_v<RecordContext, FromTy>>
1529 static_assert(std::is_base_of_v<APIRecord, FromTy>,
1530 "Can only cast APIRecord and derived classes to RecordContext");
1541 static_assert(std::is_base_of_v<APIRecord, FromTy>,
1542 "Can only cast APIRecord and derived classes to RecordContext");
1551template <
typename ToTy,
1552 bool IsKnownSubType = std::is_base_of_v<RecordContext, ToTy>>
1555 std::is_base_of_v<APIRecord, ToTy>,
1556 "Can only class RecordContext to APIRecord and derived classes");
1559 return ToTy::classofKind(Ctx->
getKind());
1570 std::is_base_of_v<APIRecord, ToTy>,
1571 "Can only class RecordContext to APIRecord and derived classes");
1573 return ToTy::classof(Ctx->
getKind());
1576 return static_cast<ToTy *
>(Ctx);
1587template <
typename FromTy>
1591 ::clang::extractapi::RecordContext *, FromTy *,
1592 CastInfo<::clang::extractapi::RecordContext, FromTy *>> {
1594 return ::clang::extractapi::ToRecordContextCastInfoWrapper<
1595 FromTy>::isPossible(From);
1598 static inline ::clang::extractapi::RecordContext *
doCast(FromTy *From) {
1599 return ::clang::extractapi::ToRecordContextCastInfoWrapper<FromTy>::doCast(
1604template <
typename FromTy>
1607 ::clang::extractapi::RecordContext, const FromTy *,
1608 CastInfo<::clang::extractapi::RecordContext, FromTy *>> {};
1610template <
typename ToTy>
1614 ToTy *, ::clang::extractapi::RecordContext *,
1615 CastInfo<ToTy, ::clang::extractapi::RecordContext *>> {
1617 return ::clang::extractapi::FromRecordContextCastInfoWrapper<
1618 ToTy>::isPossible(Ctx);
1622 return ::clang::extractapi::FromRecordContextCastInfoWrapper<ToTy>::doCast(
1627template <
typename ToTy>
1630 ToTy, const ::clang::extractapi::RecordContext *,
1631 CastInfo<ToTy, ::clang::extractapi::RecordContext *>> {};
enum clang::sema::@1718::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.
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.