35#include "llvm/ADT/ArrayRef.h"
36#include "llvm/ADT/DenseMap.h"
37#include "llvm/ADT/SmallString.h"
38#include "llvm/ADT/StringRef.h"
39#include "llvm/ADT/Twine.h"
40#include "llvm/Support/Casting.h"
41#include "llvm/Support/Compiler.h"
42#include "llvm/Support/ErrorHandling.h"
43#include "llvm/Support/SaveAndRestore.h"
44#include "llvm/Support/raw_ostream.h"
54class IncludeStrongLifetimeRAII {
60 : Policy(Policy), Old(Policy.SuppressStrongLifetime) {
68class ParamPolicyRAII {
74 : Policy(Policy), Old(Policy.SuppressSpecifiers) {
81class DefaultTemplateArgsPolicyRAII {
87 : Policy(Policy), Old(Policy.SuppressDefaultTemplateArgs) {
94class ElaboratedTypePolicyRAII {
96 bool SuppressTagKeyword;
100 explicit ElaboratedTypePolicyRAII(
PrintingPolicy &Policy) : Policy(Policy) {
107 ~ElaboratedTypePolicyRAII() {
115 unsigned Indentation;
116 bool HasEmptyPlaceHolder =
false;
117 bool InsideCCAttribute =
false;
120 explicit TypePrinter(
const PrintingPolicy &Policy,
unsigned Indentation = 0)
121 : Policy(Policy), Indentation(Indentation) {}
124 StringRef PlaceHolder);
125 void print(
QualType T, raw_ostream &OS, StringRef PlaceHolder);
127 static bool canPrefixQualifiers(
const Type *T,
bool &NeedARCStrongQualifier);
128 void spaceBeforePlaceHolder(raw_ostream &OS);
129 void printTypeSpec(
NamedDecl *D, raw_ostream &OS);
133 void printBefore(
QualType T, raw_ostream &OS);
134 void printAfter(
QualType T, raw_ostream &OS);
137 void printTag(
TagDecl *T, raw_ostream &OS);
139#define ABSTRACT_TYPE(CLASS, PARENT)
140#define TYPE(CLASS, PARENT) \
141 void print##CLASS##Before(const CLASS##Type *T, raw_ostream &OS); \
142 void print##CLASS##After(const CLASS##Type *T, raw_ostream &OS);
143#include "clang/AST/TypeNodes.inc"
153 bool HasRestrictKeyword) {
154 bool appendSpace =
false;
160 if (appendSpace) OS <<
' ';
165 if (appendSpace) OS <<
' ';
166 if (HasRestrictKeyword) {
174void TypePrinter::spaceBeforePlaceHolder(raw_ostream &OS) {
175 if (!HasEmptyPlaceHolder)
186void TypePrinter::print(
QualType t, raw_ostream &OS, StringRef PlaceHolder) {
191void TypePrinter::print(
const Type *T,
Qualifiers Quals, raw_ostream &OS,
192 StringRef PlaceHolder) {
200 printBefore(T, Quals, OS);
202 printAfter(T, Quals, OS);
205bool TypePrinter::canPrefixQualifiers(
const Type *T,
206 bool &NeedARCStrongQualifier) {
212 bool CanPrefixQualifiers =
false;
213 NeedARCStrongQualifier =
false;
214 const Type *UnderlyingType = T;
215 if (
const auto *AT = dyn_cast<AutoType>(T))
216 UnderlyingType = AT->desugar().getTypePtr();
217 if (
const auto *Subst = dyn_cast<SubstTemplateTypeParmType>(T))
218 UnderlyingType = Subst->getReplacementType().getTypePtr();
225 case Type::UnresolvedUsing:
228 case Type::TypeOfExpr:
231 case Type::UnaryTransform:
234 case Type::Elaborated:
235 case Type::TemplateTypeParm:
236 case Type::SubstTemplateTypeParmPack:
237 case Type::DeducedTemplateSpecialization:
238 case Type::TemplateSpecialization:
239 case Type::InjectedClassName:
240 case Type::DependentName:
241 case Type::DependentTemplateSpecialization:
242 case Type::ObjCObject:
243 case Type::ObjCTypeParam:
244 case Type::ObjCInterface:
248 case Type::DependentBitInt:
249 case Type::BTFTagAttributed:
250 CanPrefixQualifiers =
true;
253 case Type::ObjCObjectPointer:
258 case Type::VariableArray:
259 case Type::DependentSizedArray:
260 NeedARCStrongQualifier =
true;
263 case Type::ConstantArray:
264 case Type::IncompleteArray:
265 return canPrefixQualifiers(
266 cast<ArrayType>(UnderlyingType)->getElementType().getTypePtr(),
267 NeedARCStrongQualifier);
272 case Type::BlockPointer:
273 case Type::LValueReference:
274 case Type::RValueReference:
275 case Type::MemberPointer:
276 case Type::DependentAddressSpace:
277 case Type::DependentVector:
278 case Type::DependentSizedExtVector:
280 case Type::ExtVector:
281 case Type::ConstantMatrix:
282 case Type::DependentSizedMatrix:
283 case Type::FunctionProto:
284 case Type::FunctionNoProto:
286 case Type::PackExpansion:
287 case Type::SubstTemplateTypeParm:
288 case Type::MacroQualified:
289 CanPrefixQualifiers =
false;
292 case Type::Attributed: {
295 const auto *AttrTy = cast<AttributedType>(UnderlyingType);
296 CanPrefixQualifiers = AttrTy->getAttrKind() == attr::AddressSpace;
301 return CanPrefixQualifiers;
304void TypePrinter::printBefore(
QualType T, raw_ostream &OS) {
310 if (
const auto *Subst = dyn_cast<SubstTemplateTypeParmType>(
Split.Ty))
313 printBefore(
Split.Ty, Quals, OS);
318void TypePrinter::printBefore(
const Type *T,
Qualifiers Quals, raw_ostream &OS) {
326 bool CanPrefixQualifiers =
false;
327 bool NeedARCStrongQualifier =
false;
328 CanPrefixQualifiers = canPrefixQualifiers(T, NeedARCStrongQualifier);
330 if (CanPrefixQualifiers && !Quals.
empty()) {
331 if (NeedARCStrongQualifier) {
332 IncludeStrongLifetimeRAII Strong(Policy);
333 Quals.
print(OS, Policy,
true);
335 Quals.
print(OS, Policy,
true);
339 bool hasAfterQuals =
false;
340 if (!CanPrefixQualifiers && !Quals.
empty()) {
343 HasEmptyPlaceHolder =
false;
347#define ABSTRACT_TYPE(CLASS, PARENT)
348#define TYPE(CLASS, PARENT) case Type::CLASS: \
349 print##CLASS##Before(cast<CLASS##Type>(T), OS); \
351#include "clang/AST/TypeNodes.inc"
355 if (NeedARCStrongQualifier) {
356 IncludeStrongLifetimeRAII Strong(Policy);
357 Quals.
print(OS, Policy, !PrevPHIsEmpty.get());
359 Quals.
print(OS, Policy, !PrevPHIsEmpty.get());
364void TypePrinter::printAfter(
QualType t, raw_ostream &OS) {
366 printAfter(split.
Ty, split.
Quals, OS);
371void TypePrinter::printAfter(
const Type *T,
Qualifiers Quals, raw_ostream &OS) {
373#define ABSTRACT_TYPE(CLASS, PARENT)
374#define TYPE(CLASS, PARENT) case Type::CLASS: \
375 print##CLASS##After(cast<CLASS##Type>(T), OS); \
377#include "clang/AST/TypeNodes.inc"
381void TypePrinter::printBuiltinBefore(
const BuiltinType *T, raw_ostream &OS) {
383 spaceBeforePlaceHolder(OS);
386void TypePrinter::printBuiltinAfter(
const BuiltinType *T, raw_ostream &OS) {}
388void TypePrinter::printComplexBefore(
const ComplexType *T, raw_ostream &OS) {
393void TypePrinter::printComplexAfter(
const ComplexType *T, raw_ostream &OS) {
397void TypePrinter::printPointerBefore(
const PointerType *T, raw_ostream &OS) {
398 IncludeStrongLifetimeRAII Strong(Policy);
408void TypePrinter::printPointerAfter(
const PointerType *T, raw_ostream &OS) {
409 IncludeStrongLifetimeRAII Strong(Policy);
441 IncludeStrongLifetimeRAII Strong(Policy);
444 printBefore(Inner, OS);
447 if (isa<ArrayType>(Inner))
454 IncludeStrongLifetimeRAII Strong(Policy);
459 if (isa<ArrayType>(Inner))
461 printAfter(Inner, OS);
466 IncludeStrongLifetimeRAII Strong(Policy);
469 printBefore(Inner, OS);
472 if (isa<ArrayType>(Inner))
479 IncludeStrongLifetimeRAII Strong(Policy);
484 if (isa<ArrayType>(Inner))
486 printAfter(Inner, OS);
491 IncludeStrongLifetimeRAII Strong(Policy);
500 InnerPolicy.IncludeTagDefinition =
false;
501 TypePrinter(InnerPolicy).print(
QualType(T->
getClass(), 0), OS, StringRef());
508 IncludeStrongLifetimeRAII Strong(Policy);
519 IncludeStrongLifetimeRAII Strong(Policy);
535 OS << T->
getSize().getZExtValue() <<
']';
541 IncludeStrongLifetimeRAII Strong(Policy);
553 IncludeStrongLifetimeRAII Strong(Policy);
577void TypePrinter::printAdjustedBefore(
const AdjustedType *T, raw_ostream &OS) {
583void TypePrinter::printAdjustedAfter(
const AdjustedType *T, raw_ostream &OS) {
587void TypePrinter::printDecayedBefore(
const DecayedType *T, raw_ostream &OS) {
589 printAdjustedBefore(T, OS);
592void TypePrinter::printDecayedAfter(
const DecayedType *T, raw_ostream &OS) {
593 printAdjustedAfter(T, OS);
596void TypePrinter::printDependentSizedArrayBefore(
599 IncludeStrongLifetimeRAII Strong(Policy);
603void TypePrinter::printDependentSizedArrayAfter(
613void TypePrinter::printDependentAddressSpaceBefore(
618void TypePrinter::printDependentAddressSpaceAfter(
620 OS <<
" __attribute__((address_space(";
627void TypePrinter::printDependentSizedExtVectorBefore(
633void TypePrinter::printDependentSizedExtVectorAfter(
636 OS <<
" __attribute__((ext_vector_type(";
643void TypePrinter::printVectorBefore(
const VectorType *T, raw_ostream &OS) {
646 OS <<
"__vector __pixel ";
649 OS <<
"__vector __bool ";
657 OS <<
"__attribute__((neon_vector_type("
662 OS <<
"__attribute__((neon_polyvector_type(" <<
669 OS <<
"__attribute__((__vector_size__("
681 OS <<
"__attribute__((__arm_sve_vector_bits__(";
699 OS <<
"__attribute__((__riscv_rvv_vector_bits__(";
712void TypePrinter::printVectorAfter(
const VectorType *T, raw_ostream &OS) {
716void TypePrinter::printDependentVectorBefore(
720 OS <<
"__vector __pixel ";
723 OS <<
"__vector __bool ";
731 OS <<
"__attribute__((neon_vector_type(";
738 OS <<
"__attribute__((neon_polyvector_type(";
747 OS <<
"__attribute__((__vector_size__(";
760 OS <<
"__attribute__((__arm_sve_vector_bits__(";
778 OS <<
"__attribute__((__riscv_rvv_vector_bits__(";
792void TypePrinter::printDependentVectorAfter(
797void TypePrinter::printExtVectorBefore(
const ExtVectorType *T,
802void TypePrinter::printExtVectorAfter(
const ExtVectorType *T, raw_ostream &OS) {
804 OS <<
" __attribute__((ext_vector_type(";
812 OS <<
" __attribute__((matrix_type(";
822void TypePrinter::printDependentSizedMatrixBefore(
825 OS <<
" __attribute__((matrix_type(";
836void TypePrinter::printDependentSizedMatrixAfter(
858 OS <<
" __attribute__((nothrow))";
876 if (!HasEmptyPlaceHolder)
882 if (!PrevPHIsEmpty.get())
890 llvm_unreachable(
"asking for spelling of ordinary parameter ABI");
892 return "swift_context";
894 return "swift_async_context";
896 return "swift_error_result";
898 return "swift_indirect_result";
900 llvm_unreachable(
"bad parameter ABI kind");
906 if (!HasEmptyPlaceHolder)
912 ParamPolicyRAII ParamPolicy(Policy);
913 for (
unsigned i = 0, e = T->
getNumParams(); i != e; ++i) {
917 if (EPI.isConsumed()) OS <<
"__attribute__((ns_consumed)) ";
918 if (EPI.isNoEscape())
919 OS <<
"__attribute__((noescape)) ";
920 auto ABI = EPI.getABI();
932 }
else if (T->
getNumParams() == 0 && Policy.UseVoidForZeroParams) {
941 printFunctionAfter(Info, OS);
969 if (!InsideCCAttribute) {
970 switch (Info.
getCC()) {
981 OS <<
" __attribute__((stdcall))";
984 OS <<
" __attribute__((fastcall))";
987 OS <<
" __attribute__((thiscall))";
990 OS <<
" __attribute__((vectorcall))";
993 OS <<
" __attribute__((pascal))";
996 OS <<
" __attribute__((pcs(\"aapcs\")))";
999 OS <<
" __attribute__((pcs(\"aapcs-vfp\")))";
1002 OS <<
"__attribute__((aarch64_vector_pcs))";
1005 OS <<
"__attribute__((aarch64_sve_pcs))";
1008 OS <<
"__attribute__((amdgpu_kernel))";
1011 OS <<
" __attribute__((intel_ocl_bicc))";
1014 OS <<
" __attribute__((ms_abi))";
1017 OS <<
" __attribute__((sysv_abi))";
1020 OS <<
" __attribute__((regcall))";
1027 OS <<
" __attribute__((swiftcall))";
1030 OS <<
"__attribute__((swiftasynccall))";
1033 OS <<
" __attribute__((preserve_most))";
1036 OS <<
" __attribute__((preserve_all))";
1042 OS <<
" __attribute__((noreturn))";
1044 OS <<
" __attribute__((cmse_nonsecure_call))";
1046 OS <<
" __attribute__((ns_returns_retained))";
1048 OS <<
" __attribute__((regparm ("
1051 OS <<
" __attribute__((no_caller_saved_registers))";
1053 OS <<
" __attribute__((nocf_check))";
1061 if (!PrevPHIsEmpty.get())
1068 if (!HasEmptyPlaceHolder)
1077void TypePrinter::printTypeSpec(
NamedDecl *D, raw_ostream &OS) {
1082 if (!Policy.SuppressScope)
1087 spaceBeforePlaceHolder(OS);
1092 printTypeSpec(T->
getDecl(), OS);
1098void TypePrinter::printUsingBefore(
const UsingType *T, raw_ostream &OS) {
1111void TypePrinter::printUsingAfter(
const UsingType *T, raw_ostream &OS) {}
1113void TypePrinter::printTypedefBefore(
const TypedefType *T, raw_ostream &OS) {
1114 printTypeSpec(T->
getDecl(), OS);
1120 OS << MacroName <<
" ";
1132void TypePrinter::printTypedefAfter(
const TypedefType *T, raw_ostream &OS) {}
1140 spaceBeforePlaceHolder(OS);
1146void TypePrinter::printTypeOfBefore(
const TypeOfType *T, raw_ostream &OS) {
1151 spaceBeforePlaceHolder(OS);
1154void TypePrinter::printTypeOfAfter(
const TypeOfType *T, raw_ostream &OS) {}
1156void TypePrinter::printDecltypeBefore(
const DecltypeType *T, raw_ostream &OS) {
1161 spaceBeforePlaceHolder(OS);
1164void TypePrinter::printDecltypeAfter(
const DecltypeType *T, raw_ostream &OS) {}
1168 IncludeStrongLifetimeRAII Strong(Policy);
1170 static llvm::DenseMap<int, const char *> Transformation = {{
1171#define TRANSFORM_TYPE_TRAIT_DEF(Enum, Trait) \
1172 {UnaryTransformType::Enum, "__" #Trait},
1173#include "clang/Basic/TransformTypeTraits.def"
1175 OS << Transformation[T->
getUTTKind()] <<
'(';
1178 spaceBeforePlaceHolder(OS);
1184void TypePrinter::printAutoBefore(
const AutoType *T, raw_ostream &OS) {
1205 spaceBeforePlaceHolder(OS);
1209void TypePrinter::printAutoAfter(
const AutoType *T, raw_ostream &OS) {
1215void TypePrinter::printDeducedTemplateSpecializationBefore(
1221 IncludeStrongLifetimeRAII Strong(Policy);
1223 spaceBeforePlaceHolder(OS);
1227void TypePrinter::printDeducedTemplateSpecializationAfter(
1234void TypePrinter::printAtomicBefore(
const AtomicType *T, raw_ostream &OS) {
1235 IncludeStrongLifetimeRAII Strong(Policy);
1240 spaceBeforePlaceHolder(OS);
1243void TypePrinter::printAtomicAfter(
const AtomicType *T, raw_ostream &OS) {}
1245void TypePrinter::printPipeBefore(
const PipeType *T, raw_ostream &OS) {
1246 IncludeStrongLifetimeRAII Strong(Policy);
1251 OS <<
"write_only ";
1254 spaceBeforePlaceHolder(OS);
1257void TypePrinter::printPipeAfter(
const PipeType *T, raw_ostream &OS) {}
1259void TypePrinter::printBitIntBefore(
const BitIntType *T, raw_ostream &OS) {
1263 spaceBeforePlaceHolder(OS);
1266void TypePrinter::printBitIntAfter(
const BitIntType *T, raw_ostream &OS) {}
1275 spaceBeforePlaceHolder(OS);
1282void TypePrinter::AppendScope(
DeclContext *DC, raw_ostream &OS,
1292 if (Policy.Callbacks && Policy.Callbacks->isScopeVisible(DC))
1295 if (
const auto *NS = dyn_cast<NamespaceDecl>(DC)) {
1296 if (Policy.SuppressUnwrittenScope && NS->isAnonymousNamespace())
1297 return AppendScope(DC->
getParent(), OS, NameInScope);
1301 if (Policy.SuppressInlineNamespace && NS->isInline() && NameInScope &&
1302 NS->isRedundantInlineQualifierFor(NameInScope))
1303 return AppendScope(DC->
getParent(), OS, NameInScope);
1305 AppendScope(DC->
getParent(), OS, NS->getDeclName());
1306 if (NS->getIdentifier())
1307 OS << NS->getName() <<
"::";
1309 OS <<
"(anonymous namespace)::";
1310 }
else if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
1311 AppendScope(DC->
getParent(), OS, Spec->getDeclName());
1312 IncludeStrongLifetimeRAII Strong(Policy);
1313 OS << Spec->getIdentifier()->getName();
1316 OS, TemplateArgs.
asArray(), Policy,
1317 Spec->getSpecializedTemplate()->getTemplateParameters());
1319 }
else if (
const auto *Tag = dyn_cast<TagDecl>(DC)) {
1320 AppendScope(DC->
getParent(), OS, Tag->getDeclName());
1322 OS << Typedef->getIdentifier()->getName() <<
"::";
1323 else if (Tag->getIdentifier())
1324 OS << Tag->getIdentifier()->getName() <<
"::";
1328 AppendScope(DC->
getParent(), OS, NameInScope);
1332void TypePrinter::printTag(
TagDecl *D, raw_ostream &OS) {
1333 if (Policy.IncludeTagDefinition) {
1336 D->
print(OS, SubPolicy, Indentation);
1337 spaceBeforePlaceHolder(OS);
1341 bool HasKindDecoration =
false;
1346 HasKindDecoration =
true;
1354 if (!Policy.SuppressScope)
1360 assert(Typedef->getIdentifier() &&
"Typedef without identifier?");
1361 OS << Typedef->getIdentifier()->getName();
1365 OS << (Policy.MSVCFormatting ?
'`' :
'(');
1367 if (isa<CXXRecordDecl>(D) && cast<CXXRecordDecl>(D)->isLambda()) {
1369 HasKindDecoration =
true;
1370 }
else if ((isa<RecordDecl>(D) && cast<RecordDecl>(D)->isAnonymousStructOrUnion())) {
1376 if (Policy.AnonymousTagLocations) {
1380 if (!HasKindDecoration)
1389 if (
auto *Callbacks = Policy.Callbacks)
1390 WrittenFile = Callbacks->remapPath(
File);
1394 llvm::sys::path::Style Style =
1395 llvm::sys::path::is_absolute(WrittenFile)
1396 ? llvm::sys::path::Style::native
1397 : (Policy.MSVCFormatting
1398 ? llvm::sys::path::Style::windows_backslash
1399 : llvm::sys::path::Style::posix);
1400 llvm::sys::path::native(WrittenFile, Style);
1405 OS << (Policy.MSVCFormatting ?
'\'' :
')');
1410 if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
1413 if (!Policy.PrintCanonicalTypes && TAW) {
1415 cast<TemplateSpecializationType>(TAW->
getType());
1419 Args = TemplateArgs.
asArray();
1421 IncludeStrongLifetimeRAII Strong(Policy);
1424 Spec->getSpecializedTemplate()->getTemplateParameters());
1427 spaceBeforePlaceHolder(OS);
1430void TypePrinter::printRecordBefore(
const RecordType *T, raw_ostream &OS) {
1432 if (Policy.UsePreferredNames) {
1438 QualType T = PNA->getTypedefType();
1440 if (
auto *TT = dyn_cast<TypedefType>(T))
1441 return printTypeSpec(TT->getDecl(), OS);
1442 if (
auto *TST = dyn_cast<TemplateSpecializationType>(T))
1443 return printTemplateId(TST, OS,
true);
1449 printTag(T->getDecl(), OS);
1452void TypePrinter::printRecordAfter(
const RecordType *T, raw_ostream &OS) {}
1454void TypePrinter::printEnumBefore(
const EnumType *T, raw_ostream &OS) {
1458void TypePrinter::printEnumAfter(
const EnumType *T, raw_ostream &OS) {}
1465 TC->
print(OS, Policy);
1470 OS << (Policy.CleanUglifiedParameters ?
Id->deuglifiedName()
1475 spaceBeforePlaceHolder(OS);
1481void TypePrinter::printSubstTemplateTypeParmBefore(
1484 IncludeStrongLifetimeRAII Strong(Policy);
1488void TypePrinter::printSubstTemplateTypeParmAfter(
1491 IncludeStrongLifetimeRAII Strong(Policy);
1495void TypePrinter::printSubstTemplateTypeParmPackBefore(
1498 IncludeStrongLifetimeRAII Strong(Policy);
1502 TC->print(OS, Policy);
1507 OS << (Policy.CleanUglifiedParameters ?
Id->deuglifiedName()
1512 spaceBeforePlaceHolder(OS);
1516void TypePrinter::printSubstTemplateTypeParmPackAfter(
1519 IncludeStrongLifetimeRAII Strong(Policy);
1523 raw_ostream &OS,
bool FullyQualify) {
1524 IncludeStrongLifetimeRAII Strong(Policy);
1528 if (FullyQualify && TD) {
1529 if (!Policy.SuppressScope)
1537 DefaultTemplateArgsPolicyRAII TemplateArgs(Policy);
1540 spaceBeforePlaceHolder(OS);
1543void TypePrinter::printTemplateSpecializationBefore(
1546 printTemplateId(T, OS, Policy.FullyQualifiedName);
1549void TypePrinter::printTemplateSpecializationAfter(
1555 if (Policy.PrintInjectedClassNameWithArguments)
1556 return printTemplateSpecializationBefore(T->
getInjectedTST(), OS);
1558 IncludeStrongLifetimeRAII Strong(Policy);
1560 spaceBeforePlaceHolder(OS);
1571 "OwnedTagDecl expected to be a declaration for the type");
1574 OwnedTagDecl->
print(OS, SubPolicy, Indentation);
1575 spaceBeforePlaceHolder(OS);
1580 if (!Policy.IncludeTagDefinition)
1590 ElaboratedTypePolicyRAII PolicyRAII(Policy);
1598 ElaboratedTypePolicyRAII PolicyRAII(Policy);
1602void TypePrinter::printParenBefore(
const ParenType *T, raw_ostream &OS) {
1603 if (!HasEmptyPlaceHolder && !isa<FunctionType>(T->
getInnerType())) {
1610void TypePrinter::printParenAfter(
const ParenType *T, raw_ostream &OS) {
1611 if (!HasEmptyPlaceHolder && !isa<FunctionType>(T->
getInnerType())) {
1627 spaceBeforePlaceHolder(OS);
1633void TypePrinter::printDependentTemplateSpecializationBefore(
1635 IncludeStrongLifetimeRAII Strong(Policy);
1645 spaceBeforePlaceHolder(OS);
1648void TypePrinter::printDependentTemplateSpecializationAfter(
1682 case attr::Ptr32: OS <<
" __ptr32";
break;
1683 case attr::Ptr64: OS <<
" __ptr64";
break;
1684 case attr::SPtr: OS <<
" __sptr";
break;
1685 case attr::UPtr: OS <<
" __uptr";
break;
1687 spaceBeforePlaceHolder(OS);
1699 else if (T->
getAttrKind() == attr::TypeNullUnspecified)
1700 OS <<
" _Null_unspecified";
1701 else if (T->
getAttrKind() == attr::TypeNullableResult)
1702 OS <<
" _Nullable_result";
1704 llvm_unreachable(
"unhandled nullability");
1705 spaceBeforePlaceHolder(OS);
1731 if (T->
getAttrKind() == attr::ObjCInertUnsafeUnretained)
1735 if (T->
getAttrKind() == attr::NSReturnsRetained &&
1741 OS <<
" [[clang::lifetimebound]]";
1756 OS <<
" [[clang::annotate_type(...)]]";
1760 OS <<
" __attribute__((";
1762#define TYPE_ATTR(NAME)
1763#define DECL_OR_TYPE_ATTR(NAME)
1764#define ATTR(NAME) case attr::NAME:
1765#include "clang/Basic/AttrList.inc"
1766 llvm_unreachable(
"non-type attribute attached to type");
1768 case attr::BTFTypeTag:
1769 llvm_unreachable(
"BTFTypeTag attribute handled separately");
1771 case attr::OpenCLPrivateAddressSpace:
1772 case attr::OpenCLGlobalAddressSpace:
1773 case attr::OpenCLGlobalDeviceAddressSpace:
1774 case attr::OpenCLGlobalHostAddressSpace:
1775 case attr::OpenCLLocalAddressSpace:
1776 case attr::OpenCLConstantAddressSpace:
1777 case attr::OpenCLGenericAddressSpace:
1778 case attr::HLSLGroupSharedAddressSpace:
1783 case attr::LifetimeBound:
1784 case attr::TypeNonNull:
1785 case attr::TypeNullable:
1786 case attr::TypeNullableResult:
1787 case attr::TypeNullUnspecified:
1789 case attr::ObjCInertUnsafeUnretained:
1790 case attr::ObjCKindOf:
1791 case attr::ObjCOwnership:
1796 case attr::AddressSpace:
1797 case attr::CmseNSCall:
1798 case attr::AnnotateType:
1799 case attr::WebAssemblyFuncref:
1800 llvm_unreachable(
"This attribute should have been handled already");
1802 case attr::NSReturnsRetained:
1803 OS <<
"ns_returns_retained";
1808 case attr::AnyX86NoCfCheck: OS <<
"nocf_check";
break;
1809 case attr::CDecl: OS <<
"cdecl";
break;
1810 case attr::FastCall: OS <<
"fastcall";
break;
1811 case attr::StdCall: OS <<
"stdcall";
break;
1812 case attr::ThisCall: OS <<
"thiscall";
break;
1813 case attr::SwiftCall: OS <<
"swiftcall";
break;
1814 case attr::SwiftAsyncCall: OS <<
"swiftasynccall";
break;
1815 case attr::VectorCall: OS <<
"vectorcall";
break;
1816 case attr::Pascal: OS <<
"pascal";
break;
1817 case attr::MSABI: OS <<
"ms_abi";
break;
1818 case attr::SysVABI: OS <<
"sysv_abi";
break;
1819 case attr::RegCall: OS <<
"regcall";
break;
1826 "\"aapcs\"" :
"\"aapcs-vfp\"");
1830 case attr::AArch64VectorPcs: OS <<
"aarch64_vector_pcs";
break;
1831 case attr::AArch64SVEPcs: OS <<
"aarch64_sve_pcs";
break;
1832 case attr::AMDGPUKernelCall: OS <<
"amdgpu_kernel";
break;
1833 case attr::IntelOclBicc: OS <<
"inteloclbicc";
break;
1834 case attr::PreserveMost:
1835 OS <<
"preserve_most";
1838 case attr::PreserveAll:
1839 OS <<
"preserve_all";
1844 case attr::AcquireHandle:
1845 OS <<
"acquire_handle";
1847 case attr::ArmMveStrictPolymorphism:
1848 OS <<
"__clang_arm_mve_strict_polymorphism";
1857 OS <<
" __attribute__((btf_type_tag(\"" << T->
getAttr()->getBTFTypeTag() <<
"\")))";
1868 spaceBeforePlaceHolder(OS);
1878 bool isFirst =
true;
1880 for (
const auto *I : T->
quals()) {
1890 spaceBeforePlaceHolder(OS);
1908 bool isFirst =
true;
1916 print(typeArg, OS, StringRef());
1922 bool isFirst =
true;
1924 for (
const auto *I : T->
quals()) {
1934 spaceBeforePlaceHolder(OS);
1951 if (HasEmptyPlaceHolder)
1968 llvm::raw_ostream &OS,
bool IncludeType) {
1969 A.
print(PP, OS, IncludeType);
1993 if (TTPT->getDepth() == Depth && TTPT->getIndex() < Args.size() &&
1996 Args[TTPT->getIndex()].getAsType(), Pattern.
getQualifiers());
2008 if (TQual != PatQual)
2026 Template = TTST->getTemplateName();
2027 TemplateArgs = TTST->template_arguments();
2028 }
else if (
auto *CTSD = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
2030 Template =
TemplateName(CTSD->getSpecializedTemplate());
2031 TemplateArgs = CTSD->getTemplateArgs().asArray();
2039 if (TemplateArgs.size() != PTST->template_arguments().size())
2041 for (
unsigned I = 0, N = TemplateArgs.size(); I != N; ++I)
2043 Ctx, TemplateArgs[I], PTST->template_arguments()[I], Args, Depth))
2094 if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(DRE->getDecl()))
2095 return NTTP->getDepth() == Depth && Args.size() > NTTP->getIndex() &&
2096 Args[NTTP->getIndex()].structurallyEquals(Arg);
2112 if (
auto *TTPD = dyn_cast_or_null<TemplateTemplateParmDecl>(PatTD))
2113 return TTPD->getDepth() == Depth && Args.size() > TTPD->getIndex() &&
2130 if (
auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Param)) {
2131 return TTPD->hasDefaultArgument() &&
2134 }
else if (
auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Param)) {
2135 return TTPD->hasDefaultArgument() &&
2137 Ctx, Arg, TTPD->getDefaultArgument().getArgument(), Args, Depth);
2138 }
else if (
auto *NTTPD = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
2139 return NTTPD->hasDefaultArgument() &&
2146template <
typename TA>
2153 Args.size() <= TPL->
size()) {
2155 for (
const TA &A : Args)
2158 Args = Args.drop_back();
2165 bool NeedSpace =
false;
2166 bool FirstArg =
true;
2167 for (
const auto &Arg : Args) {
2170 llvm::raw_svector_ostream ArgOS(Buf);
2183 Policy, TPL, ParmIndex));
2185 StringRef ArgString = ArgOS.str();
2190 if (FirstArg && !ArgString.empty() && ArgString[0] ==
':')
2197 if (!ArgString.empty()) {
2225 printTo(OS, Args, Policy, TPL,
false, 0);
2232 printTo(OS, Args, Policy, TPL,
false, 0);
2245 llvm::raw_svector_ostream StrOS(Buf);
2246 print(StrOS, Policy);
2247 return std::string(StrOS.str());
2281 return "__constant";
2286 return "__global_device";
2289 return "__global_host";
2291 return "__device__";
2293 return "__constant__";
2295 return "__shared__";
2297 return "__sptr __ptr32";
2299 return "__uptr __ptr32";
2305 return "groupshared";
2315 bool appendSpaceIfNonEmpty)
const {
2316 bool addSpace =
false;
2326 OS <<
"__unaligned";
2330 if (!ASStr.empty()) {
2336 OS <<
"__attribute__((address_space(" << ASStr <<
")))";
2370 if (appendSpaceIfNonEmpty && addSpace)
2392 const Twine &PlaceHolder,
unsigned Indentation)
const {
2399 const Twine &PlaceHolder,
unsigned Indentation) {
2401 StringRef PH = PlaceHolder.toStringRef(PHBuf);
2403 TypePrinter(policy, Indentation).print(ty, qs, OS, PH);
2413 std::string &buffer,
2416 llvm::raw_svector_ostream StrOS(Buf);
2417 TypePrinter(policy).print(ty, qs, StrOS, buffer);
2418 std::string str = std::string(StrOS.str());
2424 TypePrinter(
LangOptions()).print(S.Ty, S.Quals, OS,
"");
Defines the clang::ASTContext interface.
Provides definitions for the various language-specific address spaces.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
Defines the ExceptionSpecificationType enumeration and various utility functions.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
static void print(llvm::raw_ostream &OS, const T &V, ASTContext &, QualType)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
Defines the clang::SourceLocation class and associated facilities.
Defines the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
static void printTo(raw_ostream &OS, ArrayRef< TA > Args, const PrintingPolicy &Policy, const TemplateParameterList *TPL, bool IsPack, unsigned ParmIndex)
static const TemplateArgument & getArgument(const TemplateArgument &A)
static bool isSubstitutedType(ASTContext &Ctx, QualType T, QualType Pattern, ArrayRef< TemplateArgument > Args, unsigned Depth)
static void printArgument(const TemplateArgument &A, const PrintingPolicy &PP, llvm::raw_ostream &OS, bool IncludeType)
static QualType skipTopLevelReferences(QualType T)
static SplitQualType splitAccordingToPolicy(QualType QT, const PrintingPolicy &Policy)
static bool isSubstitutedTemplateArgument(ASTContext &Ctx, TemplateArgument Arg, TemplateArgument Pattern, ArrayRef< TemplateArgument > Args, unsigned Depth)
static void AppendTypeQualList(raw_ostream &OS, unsigned TypeQuals, bool HasRestrictKeyword)
static bool templateArgumentExpressionsEqual(ASTContext const &Ctx, TemplateArgument const &Pattern, TemplateArgument const &Arg)
Evaluates the expression template argument 'Pattern' and returns true if 'Arg' evaluates to the same ...
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
SourceManager & getSourceManager()
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals)
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals.
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons.
QualType getAdjustedType() const
ArraySizeModifier getSizeModifier() const
Qualifiers getIndexTypeQualifiers() const
QualType getElementType() const
unsigned getIndexTypeCVRQualifiers() const
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
An attributed type is a type to which a type attribute has been applied.
QualType getModifiedType() const
bool isCallingConv() const
std::optional< NullabilityKind > getImmediateNullability() const
bool isMSTypeSpec() const
QualType getEquivalentType() const
bool isWebAssemblyFuncrefSpec() const
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
ArrayRef< TemplateArgument > getTypeConstraintArguments() const
ConceptDecl * getTypeConstraintConcept() const
AutoTypeKeyword getKeyword() const
bool isConstrained() const
const BTFTypeTagAttr * getAttr() const
QualType getWrappedType() const
A fixed int type of a specified bitwidth.
unsigned getNumBits() const
QualType getPointeeType() const
This class is used for builtin types like 'int'.
StringRef getName(const PrintingPolicy &Policy) const
Complex values, per C99 6.2.5p11.
QualType getElementType() const
Represents the canonical version of C arrays with a specified constant size.
const llvm::APInt & getSize() const
Represents a concrete matrix type with constant number of rows and columns.
unsigned getNumColumns() const
Returns the number of columns in the matrix.
unsigned getNumRows() const
Returns the number of rows in the matrix.
Represents a pointer type decayed from an array or function type.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isTranslationUnit() const
bool isFunctionOrMethod() const
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
SourceLocation getLocation() const
DeclContext * getDeclContext()
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
The name of a declaration.
void print(raw_ostream &OS, const PrintingPolicy &Policy) const
Represents the type decltype(expr) (C++11).
Expr * getUnderlyingExpr() const
Represents a C++17 deduced template specialization type.
TemplateName getTemplateName() const
Retrieve the name of the template that we are deducing.
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it has not been deduced.
Represents an extended address space qualifier where the input address space value is dependent.
Expr * getAddrSpaceExpr() const
QualType getPointeeType() const
Expr * getNumBitsExpr() const
Represents a qualified type name for which the type name is dependent.
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
const IdentifierInfo * getIdentifier() const
Retrieve the type named by the typename specifier as an identifier.
Represents an array type in C++ whose size is a value-dependent expression.
Expr * getSizeExpr() const
Represents an extended vector type where either the type or size is dependent.
Expr * getSizeExpr() const
QualType getElementType() const
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
Expr * getColumnExpr() const
Expr * getRowExpr() const
Represents a template specialization type whose template cannot be resolved, e.g.
const IdentifierInfo * getIdentifier() const
ArrayRef< TemplateArgument > template_arguments() const
NestedNameSpecifier * getQualifier() const
Represents a vector type where either the type or size is dependent.
Expr * getSizeExpr() const
VectorType::VectorKind getVectorKind() const
QualType getElementType() const
Represents a type that was referred to using an elaborated type keyword, e.g., struct S,...
TagDecl * getOwnedTagDecl() const
Return the (re)declaration of this type owned by this occurrence of this type, or nullptr if there is...
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
QualType getNamedType() const
Retrieve the type named by the qualified-id.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
EnumDecl * getDecl() const
This represents one expression.
bool isValueDependent() const
Determines whether the value of this expression depends on.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
bool isIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc=nullptr) const
ExtVectorType - Extended vector type.
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Represents a prototype with parameter type info, e.g.
ExtParameterInfo getExtParameterInfo(unsigned I) const
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
unsigned getNumParams() const
void printExceptionSpecification(raw_ostream &OS, const PrintingPolicy &Policy) const
bool hasTrailingReturn() const
Whether this function prototype has a trailing return type.
Qualifiers getMethodQuals() const
QualType getParamType(unsigned i) const
QualType getExceptionType(unsigned i) const
Return the ith exception type, where 0 <= i < getNumExceptions().
unsigned getNumExceptions() const
Return the number of types in the exception specification.
bool hasDynamicExceptionSpec() const
Return whether this function has a dynamic (throw) exception spec.
bool isVariadic() const
Whether this function prototype is variadic.
Expr * getNoexceptExpr() const
Return the expression inside noexcept(expression), or a null pointer if there is none (because the ex...
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
A class which abstracts out some details necessary for making a call.
CallingConv getCC() const
bool getCmseNSCall() const
bool getNoCfCheck() const
unsigned getRegParm() const
bool getNoCallerSavedRegs() const
bool getProducesResult() const
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
QualType getReturnType() const
One of these records is kept for each identifier that is lexed.
StringRef getName() const
Return the actual identifier string.
Represents a C array with an unspecified size.
The injected class name of a C++ class template or class template partial specialization.
const TemplateSpecializationType * getInjectedTST() const
TemplateName getTemplateName() const
An lvalue reference type, per C++11 [dcl.ref].
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Sugar type that represents a type that was qualified by a qualifier written as a macro invocation.
QualType getModifiedType() const
Return this attributed type's modified type with no qualifiers attached to it.
const IdentifierInfo * getMacroIdentifier() const
QualType getElementType() const
Returns type of the elements being stored in the matrix.
A pointer to member type per C++ 8.3.3 - Pointers to members.
QualType getPointeeType() const
const Type * getClass() const
This represents a decl that may have a name.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false) const
Print this nested name specifier to the given output stream.
Interfaces are the core concept in Objective-C for object oriented design.
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
Represents a pointer to an Objective C object.
bool isObjCQualifiedClassType() const
True if this is equivalent to 'Class.
bool isObjCQualifiedIdType() const
True if this is equivalent to 'id.
bool isObjCIdType() const
True if this is equivalent to the 'id' type, i.e.
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
bool isObjCClassType() const
True if this is equivalent to the 'Class' type, i.e.
Represents a class type in Objective C.
bool isKindOfTypeAsWritten() const
Whether this is a "__kindof" type as written.
ArrayRef< QualType > getTypeArgsAsWritten() const
Retrieve the type arguments of this object type as they were written.
bool isUnspecializedAsWritten() const
Determine whether this object type is "unspecialized" as written, meaning that it has no type argumen...
QualType getBaseType() const
Gets the base type of this object type.
bool isSpecializedAsWritten() const
Determine whether this object type was written with type arguments.
Represents a type parameter type in Objective C.
ObjCTypeParamDecl * getDecl() const
Represents a pack expansion of types.
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
Sugar for parentheses used when specifying types.
QualType getInnerType() const
QualType getElementType() const
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
Represents an unpacked "presumed" location which can be presented to the user.
unsigned getColumn() const
Return the presumed column number of this location.
const char * getFilename() const
Return the presumed filename of this location.
unsigned getLine() const
Return the presumed line number of this location.
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
QualType getCanonicalType() const
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
std::string getAsString() const
StreamedQualTypeHelper stream(const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
The collection of all-type qualifiers we support.
unsigned getCVRQualifiers() const
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_None
There is no lifetime qualification on this type.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
bool hasQualifiers() const
Return true if the set contains any qualifiers.
bool hasUnaligned() const
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool appendSpaceIfNonEmpty=false) const
bool isEmptyWhenPrinted(const PrintingPolicy &Policy) const
ObjCLifetime getObjCLifetime() const
std::string getAsString() const
LangAS getAddressSpace() const
static std::string getAddrSpaceAsString(LangAS AS)
An rvalue reference type, per C++11 [dcl.ref].
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
Base for LValueReferenceType and RValueReferenceType.
QualType getPointeeTypeAsWritten() const
PresumedLoc getPresumedLoc(SourceLocation Loc, bool UseLineDirectives=true) const
Returns the "presumed" location of a SourceLocation specifies.
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\n", const ASTContext *Context=nullptr) const
Represents the result of substituting a set of types for a template type parameter pack.
const TemplateTypeParmDecl * getReplacedParameter() const
Gets the template parameter declaration that was substituted for.
Represents the result of substituting a type for a template type parameter.
QualType getReplacementType() const
Gets the type that was substituted for the template parameter.
Represents the declaration of a struct/union/class/enum.
StringRef getKindName() const
TypedefNameDecl * getTypedefNameForAnonDecl() const
A convenient class for passing around template argument information.
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
A template argument list.
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
Location wrapper for a TemplateArgument.
const TemplateArgument & getArgument() const
TypeSourceInfo * getTypeSourceInfo() const
Represents a template argument.
ArrayRef< TemplateArgument > getPackAsArray() const
Return the array of arguments in this template argument pack.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
QualType getAsType() const
Retrieve the type for a type template argument.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
bool structurallyEquals(const TemplateArgument &Other) const
Determines whether two template arguments are superficially the same.
void print(const PrintingPolicy &Policy, raw_ostream &Out, bool IncludeType) const
Print this template argument to the given output stream.
bool getIsDefaulted() const
If returns 'true', this TemplateArgument corresponds to a default template parameter.
ArgKind
The kind of template argument we're storing.
@ Template
The template argument is a template name that was provided for a template template parameter.
@ Pack
The template argument is actually a parameter pack.
@ Type
The template argument is a type.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known.
void print(raw_ostream &OS, const PrintingPolicy &Policy, Qualified Qual=Qualified::AsWritten) const
Print the template name.
Stores a list of template parameters for a TemplateDecl and its derived classes.
static bool shouldIncludeTypeForArgument(const PrintingPolicy &Policy, const TemplateParameterList *TPL, unsigned Idx)
Represents a type template specialization; the template must be a class template, a type alias templa...
ArrayRef< TemplateArgument > template_arguments() const
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
Declaration of a template type parameter.
unsigned getIndex() const
Retrieve the index of the template parameter.
const TypeConstraint * getTypeConstraint() const
Returns the type constraint associated with this template parameter (if any).
unsigned getDepth() const
Retrieve the depth of the template parameter.
TemplateTypeParmDecl * getDecl() const
unsigned getIndex() const
IdentifierInfo * getIdentifier() const
unsigned getDepth() const
const Type * getTypeForDecl() const
Represents a typeof (or typeof) expression (a C2x feature and GCC extension) or a typeof_unqual expre...
TypeOfKind getKind() const
Returns the kind of 'typeof' type this is.
Expr * getUnderlyingExpr() const
Represents typeof(type), a C2x feature and GCC extension, or `typeof_unqual(type),...
TypeOfKind getKind() const
Returns the kind of 'typeof' type this is.
QualType getUnmodifiedType() const
A container of type source information.
QualType getType() const
Return the type wrapped by this type source info.
static StringRef getKeywordName(ElaboratedTypeKeyword Keyword)
ElaboratedTypeKeyword getKeyword() const
The base class of the type hierarchy.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
QualType getLocallyUnqualifiedSingleStepDesugaredType() const
Pull a single level of sugar off of this locally-unqualified type.
const T * castAs() const
Member-template castAs<specific type>.
bool isObjCQualifiedIdType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isObjCIdType() const
bool isSpecifierType() const
Returns true if this type can be represented by some set of type specifiers.
bool isFunctionType() const
bool isObjCQualifiedClassType() const
bool isObjCClassType() const
TypeClass getTypeClass() const
const T * getAs() const
Member-template getAs<specific type>'.
Base class for declarations which introduce a typedef-name.
TypedefNameDecl * getDecl() const
Represents the dependent type named by a dependently-scoped typename using declaration,...
UnresolvedUsingTypenameDecl * getDecl() const
UsingShadowDecl * getFoundDecl() const
Represents a C array with a specified size that is not an integer-constant-expression.
Expr * getSizeExpr() const
Represents a GCC generic vector type.
unsigned getNumElements() const
@ AltiVecBool
is AltiVec 'vector bool ...'
@ RVVFixedLengthDataVector
is RISC-V RVV fixed-length data vector
@ SveFixedLengthPredicateVector
is AArch64 SVE fixed-length predicate vector
@ NeonPolyVector
is ARM Neon polynomial vector
@ GenericVector
not a target-specific vector type
@ AltiVecPixel
is AltiVec 'vector Pixel'
@ SveFixedLengthDataVector
is AArch64 SVE fixed-length data vector
@ AltiVecVector
is AltiVec vector
@ NeonVector
is ARM Neon vector
VectorKind getVectorKind() const
QualType getElementType() const
@ GNUAutoType
__auto_type (GNU extension)
@ DecltypeAuto
decltype(auto)
llvm::StringRef getParameterABISpelling(ParameterABI kind)
bool isTargetAddressSpace(LangAS AS)
@ RQ_None
No ref-qualifier was provided.
@ RQ_LValue
An lvalue ref-qualifier was provided (&).
@ RQ_RValue
An rvalue ref-qualifier was provided (&&).
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
unsigned toTargetAddressSpace(LangAS AS)
ParameterABI
Kinds of parameter ABI.
@ SwiftAsyncContext
This parameter (which must have pointer type) uses the special Swift asynchronous context-pointer ABI...
@ SwiftErrorResult
This parameter (which must have pointer-to-pointer type) uses the special Swift error-result ABI trea...
@ Ordinary
This parameter uses ordinary ABI rules for its type.
@ SwiftIndirectResult
This parameter (which must have pointer type) is a Swift indirect result parameter.
@ SwiftContext
This parameter (which must have pointer type) uses the special Swift context-pointer ABI treatment.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
bool isNoexceptExceptionSpec(ExceptionSpecificationType ESpecType)
LangAS
Defines the address space values used by the address space qualifier of QualType.
bool isSubstitutedDefaultArgument(ASTContext &Ctx, TemplateArgument Arg, const NamedDecl *Param, ArrayRef< TemplateArgument > Args, unsigned Depth)
Make a best-effort determination of whether the type T can be produced by substituting Args into the ...
void printTemplateArgumentList(raw_ostream &OS, ArrayRef< TemplateArgument > Args, const PrintingPolicy &Policy, const TemplateParameterList *TPL=nullptr)
Print a template argument list, including the '<' and '>' enclosing the template arguments.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
@ ETK_None
No keyword precedes the qualified type name.
@ EST_NoThrow
Microsoft __declspec(nothrow) extension.
@ EST_MSAny
Microsoft throw(...) extension.
Describes how types, statements, expressions, and declarations should be printed.
unsigned MSVCFormatting
Use whitespace and punctuation like MSVC does.
unsigned SuppressDefaultTemplateArgs
When true, attempt to suppress template arguments that match the default argument for the parameter.
unsigned SplitTemplateClosers
Whether nested templates must be closed like 'a<b<c> >' rather than 'a<b<c>>'.
unsigned PrintCanonicalTypes
Whether to print types as written or canonically.
unsigned SuppressSpecifiers
Whether we should suppress printing of the actual specifiers for the given type or declaration.
unsigned SuppressTagKeyword
Whether type printing should skip printing the tag keyword.
unsigned SuppressStrongLifetime
When true, suppress printing of the __strong lifetime qualifier in ARC.
unsigned Restrict
Whether we can use 'restrict' rather than '__restrict'.
unsigned SuppressScope
Suppresses printing of scope specifiers.
unsigned IncludeTagDefinition
When true, include the body of a tag definition.
unsigned SuppressLifetimeQualifiers
When true, suppress printing of lifetime qualifier in ARC.
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
const Type * Ty
The locally-unqualified type.
Qualifiers Quals
The local qualifiers.