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"
41 struct TemplateParameter {
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()
79 else if (Param->wasDeclaredWithTypename())
85 Param->getDepth(), Param->isParameterPack());
90 for (
auto *
const Parameter : *
Decl->getTemplateParameters()) {
91 const auto *Param = dyn_cast<TemplateTypeParmDecl>(
Parameter);
95 if (Param->hasTypeConstraint())
96 Type = Param->getTypeConstraint()
101 else if (Param->wasDeclaredWithTypename())
107 Param->getDepth(), Param->isParameterPack());
112 for (
auto *
const Parameter : *
Decl->getTemplateParameters()) {
113 const auto *Param = dyn_cast<TemplateTypeParmDecl>(
Parameter);
117 if (Param->hasTypeConstraint())
118 Type = Param->getTypeConstraint()
123 else if (Param->wasDeclaredWithTypename())
129 Param->getDepth(), Param->isParameterPack());
142 unsigned int Index,
unsigned int Depth,
143 bool IsParameterPack) {
144 Parameters.emplace_back(
Type, Name, Index, Depth, IsParameterPack);
147 bool empty()
const {
return Parameters.empty() && Constraints.empty(); }
281 mutable APIRecord *NextInContext =
nullptr;
368 return x.Current == y.Current;
371 return x.Current != y.Current;
387 bool IsWellFormed()
const;
444 virtual void anchor();
525 virtual void anchor();
611 virtual void anchor();
675 virtual void anchor();
755 virtual void anchor();
774 virtual void anchor();
792 virtual void anchor();
811 virtual void anchor();
844 virtual void anchor();
904 virtual void anchor();
925 virtual void anchor();
946 virtual void anchor();
968 virtual void anchor();
1064 virtual void anchor();
1087 virtual void anchor();
1109 virtual void anchor();
1149 virtual void anchor();
1169 virtual void anchor();
1233 virtual void anchor();
1344 virtual void anchor();
1368 virtual void anchor();
1389 virtual void anchor();
1409 virtual void anchor();
1436 virtual void anchor();
1459 StringRef Source =
"");
1465 template <
typename RecordTy,
typename... CtorArgsContTy>
1466 typename std::enable_if_t<std::is_base_of_v<APIRecord, RecordTy>, RecordTy> *
1467 createRecord(StringRef USR, StringRef Name, CtorArgsContTy &&...CtorArgs);
1470 return TopLevelRecords;
1489 llvm::BumpPtrAllocator Allocator;
1491 const llvm::Triple Target;
1494 struct APIRecordDeleter {
1501 using APIRecordStoredPtr = std::unique_ptr<APIRecord, APIRecordDeleter>;
1502 llvm::DenseMap<StringRef, APIRecordStoredPtr> USRBasedLookupTable;
1509template <
typename RecordTy,
typename... CtorArgsContTy>
1510typename std::enable_if_t<std::is_base_of_v<APIRecord, RecordTy>, RecordTy> *
1512 CtorArgsContTy &&...CtorArgs) {
1515 auto Result = USRBasedLookupTable.try_emplace(USRString);
1520 Record =
new (Allocator) RecordTy(
1521 USRString,
copyString(Name), std::forward<CtorArgsContTy>(CtorArgs)...);
1525 if (
auto *ParentContext =
1526 dyn_cast_if_present<RecordContext>(
Record->Parent.Record))
1527 ParentContext->addToRecordChain(
Record);
1529 TopLevelRecords.push_back(
Record);
1531 Record = dyn_cast<RecordTy>(
Result.first->second.get());
1539template <
typename FromTy,
1540 bool IsKnownSubType = std::is_base_of_v<RecordContext, FromTy>>
1542 static_assert(std::is_base_of_v<APIRecord, FromTy>,
1543 "Can only cast APIRecord and derived classes to RecordContext");
1554 static_assert(std::is_base_of_v<APIRecord, FromTy>,
1555 "Can only cast APIRecord and derived classes to RecordContext");
1564template <
typename ToTy,
1565 bool IsKnownSubType = std::is_base_of_v<RecordContext, ToTy>>
1568 std::is_base_of_v<APIRecord, ToTy>,
1569 "Can only class RecordContext to APIRecord and derived classes");
1572 return ToTy::classofKind(Ctx->
getKind());
1583 std::is_base_of_v<APIRecord, ToTy>,
1584 "Can only class RecordContext to APIRecord and derived classes");
1586 return ToTy::classof(Ctx->
getKind());
1589 return static_cast<ToTy *
>(Ctx);
1600template <
typename FromTy>
1604 ::clang::extractapi::RecordContext *, FromTy *,
1605 CastInfo<::clang::extractapi::RecordContext, FromTy *>> {
1607 return ::clang::extractapi::ToRecordContextCastInfoWrapper<
1611 static inline ::clang::extractapi::RecordContext *
doCast(FromTy *From) {
1612 return ::clang::extractapi::ToRecordContextCastInfoWrapper<FromTy>::doCast(
1617template <
typename FromTy>
1620 ::clang::extractapi::RecordContext, const FromTy *,
1621 CastInfo<::clang::extractapi::RecordContext, FromTy *>> {};
1623template <
typename ToTy>
1627 ToTy *, ::clang::extractapi::RecordContext *,
1628 CastInfo<ToTy, ::clang::extractapi::RecordContext *>> {
1630 return ::clang::extractapi::FromRecordContextCastInfoWrapper<
1635 return ::clang::extractapi::FromRecordContextCastInfoWrapper<ToTy>::doCast(
1640template <
typename ToTy>
1643 ToTy, const ::clang::extractapi::RecordContext *,
1644 CastInfo<ToTy, ::clang::extractapi::RecordContext *>> {};
This file defines the Declaration Fragments related classes.
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.
Top level wrappers for InstallAPI frontend operations.
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.
@ Type
The name was classified as a type.
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.