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()->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;
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();
1397 virtual void anchor();
1424 virtual void anchor();
1447 StringRef Source =
"");
1453 template <
typename RecordTy,
typename... CtorArgsContTy>
1454 typename std::enable_if_t<std::is_base_of_v<APIRecord, RecordTy>, RecordTy> *
1455 createRecord(StringRef USR, StringRef Name, CtorArgsContTy &&...CtorArgs);
1458 return TopLevelRecords;
1477 llvm::BumpPtrAllocator Allocator;
1479 const llvm::Triple Target;
1482 struct APIRecordDeleter {
1489 using APIRecordStoredPtr = std::unique_ptr<APIRecord, APIRecordDeleter>;
1490 llvm::DenseMap<StringRef, APIRecordStoredPtr> USRBasedLookupTable;
1497template <
typename RecordTy,
typename... CtorArgsContTy>
1498typename std::enable_if_t<std::is_base_of_v<APIRecord, RecordTy>, RecordTy> *
1500 CtorArgsContTy &&...CtorArgs) {
1503 auto Result = USRBasedLookupTable.try_emplace(USRString);
1508 Record =
new (Allocator) RecordTy(
1509 USRString,
copyString(Name), std::forward<CtorArgsContTy>(CtorArgs)...);
1513 if (
auto *ParentContext =
1514 dyn_cast_if_present<RecordContext>(
Record->Parent.Record))
1515 ParentContext->addToRecordChain(
Record);
1517 TopLevelRecords.push_back(
Record);
1519 Record = dyn_cast<RecordTy>(
Result.first->second.get());
1527template <
typename FromTy,
1528 bool IsKnownSubType = std::is_base_of_v<RecordContext, FromTy>>
1530 static_assert(std::is_base_of_v<APIRecord, FromTy>,
1531 "Can only cast APIRecord and derived classes to RecordContext");
1542 static_assert(std::is_base_of_v<APIRecord, FromTy>,
1543 "Can only cast APIRecord and derived classes to RecordContext");
1552template <
typename ToTy,
1553 bool IsKnownSubType = std::is_base_of_v<RecordContext, ToTy>>
1556 std::is_base_of_v<APIRecord, ToTy>,
1557 "Can only class RecordContext to APIRecord and derived classes");
1560 return ToTy::classofKind(Ctx->
getKind());
1571 std::is_base_of_v<APIRecord, ToTy>,
1572 "Can only class RecordContext to APIRecord and derived classes");
1574 return ToTy::classof(Ctx->
getKind());
1577 return static_cast<ToTy *
>(Ctx);
1588template <
typename FromTy>
1592 ::clang::extractapi::RecordContext *, FromTy *,
1593 CastInfo<::clang::extractapi::RecordContext, FromTy *>> {
1595 return ::clang::extractapi::ToRecordContextCastInfoWrapper<
1599 static inline ::clang::extractapi::RecordContext *
doCast(FromTy *From) {
1600 return ::clang::extractapi::ToRecordContextCastInfoWrapper<FromTy>::doCast(
1605template <
typename FromTy>
1608 ::clang::extractapi::RecordContext, const FromTy *,
1609 CastInfo<::clang::extractapi::RecordContext, FromTy *>> {};
1611template <
typename ToTy>
1615 ToTy *, ::clang::extractapi::RecordContext *,
1616 CastInfo<ToTy, ::clang::extractapi::RecordContext *>> {
1618 return ::clang::extractapi::FromRecordContextCastInfoWrapper<
1623 return ::clang::extractapi::FromRecordContextCastInfoWrapper<ToTy>::doCast(
1628template <
typename ToTy>
1631 ToTy, const ::clang::extractapi::RecordContext *,
1632 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.
The JSON file list parser is used to communicate input to InstallAPI.
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.