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/Compiler.h"
41#include "llvm/Support/ErrorHandling.h"
42#include "llvm/Support/SaveAndRestore.h"
43#include "llvm/Support/raw_ostream.h"
53class IncludeStrongLifetimeRAII {
54 PrintingPolicy &Policy;
58 explicit IncludeStrongLifetimeRAII(PrintingPolicy &Policy)
59 : Policy(Policy), Old(Policy.SuppressStrongLifetime) {
60 if (!Policy.SuppressLifetimeQualifiers)
61 Policy.SuppressStrongLifetime =
false;
64 ~IncludeStrongLifetimeRAII() { Policy.SuppressStrongLifetime = Old; }
67class ParamPolicyRAII {
68 PrintingPolicy &Policy;
72 explicit ParamPolicyRAII(PrintingPolicy &Policy)
73 : Policy(Policy), Old(Policy.SuppressSpecifiers) {
74 Policy.SuppressSpecifiers =
false;
77 ~ParamPolicyRAII() { Policy.SuppressSpecifiers = Old; }
80class DefaultTemplateArgsPolicyRAII {
81 PrintingPolicy &Policy;
85 explicit DefaultTemplateArgsPolicyRAII(PrintingPolicy &Policy)
86 : Policy(Policy), Old(Policy.SuppressDefaultTemplateArgs) {
87 Policy.SuppressDefaultTemplateArgs =
false;
90 ~DefaultTemplateArgsPolicyRAII() { Policy.SuppressDefaultTemplateArgs = Old; }
93class ElaboratedTypePolicyRAII {
94 PrintingPolicy &Policy;
95 bool SuppressTagKeyword;
99 explicit ElaboratedTypePolicyRAII(PrintingPolicy &Policy) : Policy(Policy) {
100 SuppressTagKeyword = Policy.SuppressTagKeyword;
101 SuppressScope = Policy.SuppressScope;
102 Policy.SuppressTagKeyword =
true;
103 Policy.SuppressScope =
true;
106 ~ElaboratedTypePolicyRAII() {
107 Policy.SuppressTagKeyword = SuppressTagKeyword;
108 Policy.SuppressScope = SuppressScope;
113 PrintingPolicy Policy;
114 unsigned Indentation;
115 bool HasEmptyPlaceHolder =
false;
116 bool InsideCCAttribute =
false;
119 explicit TypePrinter(
const PrintingPolicy &Policy,
unsigned Indentation = 0)
120 : Policy(Policy), Indentation(Indentation) {}
122 void print(
const Type *ty, Qualifiers qs, raw_ostream &OS,
123 StringRef PlaceHolder);
124 void print(QualType
T, raw_ostream &OS, StringRef PlaceHolder);
126 static bool canPrefixQualifiers(
const Type *
T,
bool &NeedARCStrongQualifier);
127 void spaceBeforePlaceHolder(raw_ostream &OS);
128 void printTypeSpec(NamedDecl *D, raw_ostream &OS);
129 void printTemplateId(
const TemplateSpecializationType *
T, raw_ostream &OS,
132 void printBefore(QualType
T, raw_ostream &OS);
133 void printAfter(QualType
T, raw_ostream &OS);
134 void AppendScope(DeclContext *DC, raw_ostream &OS,
135 DeclarationName NameInScope);
136 void printTagType(
const TagType *
T, raw_ostream &OS);
137 void printFunctionAfter(
const FunctionType::ExtInfo &Info, raw_ostream &OS);
138#define ABSTRACT_TYPE(CLASS, PARENT)
139#define TYPE(CLASS, PARENT) \
140 void print##CLASS##Before(const CLASS##Type *T, raw_ostream &OS); \
141 void print##CLASS##After(const CLASS##Type *T, raw_ostream &OS);
142#include "clang/AST/TypeNodes.inc"
152 bool HasRestrictKeyword) {
153 bool appendSpace =
false;
159 if (appendSpace) OS <<
' ';
164 if (appendSpace) OS <<
' ';
165 if (HasRestrictKeyword) {
173void TypePrinter::spaceBeforePlaceHolder(raw_ostream &OS) {
174 if (!HasEmptyPlaceHolder)
185void TypePrinter::print(QualType t, raw_ostream &OS, StringRef PlaceHolder) {
190void TypePrinter::print(
const Type *
T, Qualifiers Quals, raw_ostream &OS,
191 StringRef PlaceHolder) {
197 SaveAndRestore PHVal(HasEmptyPlaceHolder, PlaceHolder.empty());
199 printBefore(
T, Quals, OS);
201 printAfter(
T, Quals, OS);
204bool TypePrinter::canPrefixQualifiers(
const Type *
T,
205 bool &NeedARCStrongQualifier) {
211 bool CanPrefixQualifiers =
false;
212 NeedARCStrongQualifier =
false;
213 const Type *UnderlyingType =
T;
214 if (
const auto *AT = dyn_cast<AutoType>(
T))
215 UnderlyingType = AT->desugar().getTypePtr();
216 if (
const auto *Subst = dyn_cast<SubstTemplateTypeParmType>(
T))
217 UnderlyingType = Subst->getReplacementType().getTypePtr();
224 case Type::UnresolvedUsing:
227 case Type::TypeOfExpr:
230 case Type::UnaryTransform:
233 case Type::TemplateTypeParm:
234 case Type::SubstTemplateTypeParmPack:
235 case Type::SubstBuiltinTemplatePack:
236 case Type::DeducedTemplateSpecialization:
237 case Type::TemplateSpecialization:
238 case Type::InjectedClassName:
239 case Type::DependentName:
240 case Type::ObjCObject:
241 case Type::ObjCTypeParam:
242 case Type::ObjCInterface:
246 case Type::DependentBitInt:
247 case Type::BTFTagAttributed:
248 case Type::HLSLAttributedResource:
249 case Type::HLSLInlineSpirv:
250 case Type::PredefinedSugar:
251 CanPrefixQualifiers =
true;
254 case Type::ObjCObjectPointer:
259 case Type::VariableArray:
260 case Type::DependentSizedArray:
261 NeedARCStrongQualifier =
true;
264 case Type::ConstantArray:
265 case Type::IncompleteArray:
266 return canPrefixQualifiers(
268 NeedARCStrongQualifier);
272 case Type::ArrayParameter:
274 case Type::BlockPointer:
275 case Type::LValueReference:
276 case Type::RValueReference:
277 case Type::MemberPointer:
278 case Type::DependentAddressSpace:
279 case Type::DependentVector:
280 case Type::DependentSizedExtVector:
282 case Type::ExtVector:
283 case Type::ConstantMatrix:
284 case Type::DependentSizedMatrix:
285 case Type::FunctionProto:
286 case Type::FunctionNoProto:
288 case Type::PackExpansion:
289 case Type::SubstTemplateTypeParm:
290 case Type::MacroQualified:
291 case Type::CountAttributed:
292 CanPrefixQualifiers =
false;
295 case Type::Attributed: {
299 CanPrefixQualifiers = AttrTy->getAttrKind() == attr::AddressSpace;
302 case Type::PackIndexing: {
303 return canPrefixQualifiers(
305 NeedARCStrongQualifier);
309 return CanPrefixQualifiers;
312void TypePrinter::printBefore(QualType
T, raw_ostream &OS) {
317 Qualifiers Quals =
Split.Quals;
318 if (
const auto *Subst = dyn_cast<SubstTemplateTypeParmType>(
Split.Ty))
319 Quals -= QualType(Subst, 0).getQualifiers();
321 printBefore(
Split.Ty, Quals, OS);
326void TypePrinter::printBefore(
const Type *
T,Qualifiers Quals, raw_ostream &OS) {
330 SaveAndRestore PrevPHIsEmpty(HasEmptyPlaceHolder);
334 bool CanPrefixQualifiers =
false;
335 bool NeedARCStrongQualifier =
false;
336 CanPrefixQualifiers = canPrefixQualifiers(
T, NeedARCStrongQualifier);
338 if (CanPrefixQualifiers && !Quals.
empty()) {
339 if (NeedARCStrongQualifier) {
340 IncludeStrongLifetimeRAII Strong(Policy);
341 Quals.
print(OS, Policy,
true);
343 Quals.
print(OS, Policy,
true);
347 bool hasAfterQuals =
false;
348 if (!CanPrefixQualifiers && !Quals.
empty()) {
351 HasEmptyPlaceHolder =
false;
355#define ABSTRACT_TYPE(CLASS, PARENT)
356#define TYPE(CLASS, PARENT) case Type::CLASS: \
357 print##CLASS##Before(cast<CLASS##Type>(T), OS); \
359#include "clang/AST/TypeNodes.inc"
363 if (NeedARCStrongQualifier) {
364 IncludeStrongLifetimeRAII Strong(Policy);
365 Quals.
print(OS, Policy, !PrevPHIsEmpty.get());
367 Quals.
print(OS, Policy, !PrevPHIsEmpty.get());
372void TypePrinter::printAfter(QualType t, raw_ostream &OS) {
374 printAfter(split.
Ty, split.
Quals, OS);
379void TypePrinter::printAfter(
const Type *
T, Qualifiers Quals, raw_ostream &OS) {
381#define ABSTRACT_TYPE(CLASS, PARENT)
382#define TYPE(CLASS, PARENT) case Type::CLASS: \
383 print##CLASS##After(cast<CLASS##Type>(T), OS); \
385#include "clang/AST/TypeNodes.inc"
389void TypePrinter::printBuiltinBefore(
const BuiltinType *
T, raw_ostream &OS) {
390 OS <<
T->getName(Policy);
391 spaceBeforePlaceHolder(OS);
394void TypePrinter::printBuiltinAfter(
const BuiltinType *
T, raw_ostream &OS) {}
396void TypePrinter::printComplexBefore(
const ComplexType *
T, raw_ostream &OS) {
398 printBefore(
T->getElementType(), OS);
401void TypePrinter::printComplexAfter(
const ComplexType *
T, raw_ostream &OS) {
402 printAfter(
T->getElementType(), OS);
405void TypePrinter::printPointerBefore(
const PointerType *
T, raw_ostream &OS) {
406 IncludeStrongLifetimeRAII Strong(Policy);
407 SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder,
false);
416void TypePrinter::printPointerAfter(
const PointerType *
T, raw_ostream &OS) {
417 IncludeStrongLifetimeRAII Strong(Policy);
418 SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder,
false);
426void TypePrinter::printBlockPointerBefore(
const BlockPointerType *
T,
428 SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder,
false);
433void TypePrinter::printBlockPointerAfter(
const BlockPointerType *
T,
435 SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder,
false);
447void TypePrinter::printLValueReferenceBefore(
const LValueReferenceType *
T,
449 IncludeStrongLifetimeRAII Strong(Policy);
450 SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder,
false);
452 printBefore(Inner, OS);
460void TypePrinter::printLValueReferenceAfter(
const LValueReferenceType *
T,
462 IncludeStrongLifetimeRAII Strong(Policy);
463 SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder,
false);
469 printAfter(Inner, OS);
472void TypePrinter::printRValueReferenceBefore(
const RValueReferenceType *
T,
474 IncludeStrongLifetimeRAII Strong(Policy);
475 SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder,
false);
477 printBefore(Inner, OS);
485void TypePrinter::printRValueReferenceAfter(
const RValueReferenceType *
T,
487 IncludeStrongLifetimeRAII Strong(Policy);
488 SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder,
false);
494 printAfter(Inner, OS);
497void TypePrinter::printMemberPointerBefore(
const MemberPointerType *
T,
499 IncludeStrongLifetimeRAII Strong(Policy);
500 SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder,
false);
506 T->getQualifier().print(OS, Policy);
510void TypePrinter::printMemberPointerAfter(
const MemberPointerType *
T,
512 IncludeStrongLifetimeRAII Strong(Policy);
513 SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder,
false);
521void TypePrinter::printConstantArrayBefore(
const ConstantArrayType *
T,
523 IncludeStrongLifetimeRAII Strong(Policy);
524 printBefore(
T->getElementType(), OS);
527void TypePrinter::printConstantArrayAfter(
const ConstantArrayType *
T,
530 if (
T->getIndexTypeQualifiers().hasQualifiers()) {
536 if (
T->getSizeModifier() == ArraySizeModifier::Static)
539 OS <<
T->getZExtSize() <<
']';
540 printAfter(
T->getElementType(), OS);
543void TypePrinter::printIncompleteArrayBefore(
const IncompleteArrayType *
T,
545 IncludeStrongLifetimeRAII Strong(Policy);
546 printBefore(
T->getElementType(), OS);
549void TypePrinter::printIncompleteArrayAfter(
const IncompleteArrayType *
T,
552 printAfter(
T->getElementType(), OS);
555void TypePrinter::printVariableArrayBefore(
const VariableArrayType *
T,
557 IncludeStrongLifetimeRAII Strong(Policy);
558 printBefore(
T->getElementType(), OS);
561void TypePrinter::printVariableArrayAfter(
const VariableArrayType *
T,
564 if (
T->getIndexTypeQualifiers().hasQualifiers()) {
569 if (
T->getSizeModifier() == ArraySizeModifier::Static)
571 else if (
T->getSizeModifier() == ArraySizeModifier::Star)
574 if (
T->getSizeExpr())
575 T->getSizeExpr()->printPretty(OS,
nullptr, Policy);
578 printAfter(
T->getElementType(), OS);
581void TypePrinter::printAdjustedBefore(
const AdjustedType *
T, raw_ostream &OS) {
584 printBefore(
T->getAdjustedType(), OS);
587void TypePrinter::printAdjustedAfter(
const AdjustedType *
T, raw_ostream &OS) {
588 printAfter(
T->getAdjustedType(), OS);
591void TypePrinter::printDecayedBefore(
const DecayedType *
T, raw_ostream &OS) {
593 printAdjustedBefore(
T, OS);
596void TypePrinter::printArrayParameterAfter(
const ArrayParameterType *
T,
598 printConstantArrayAfter(
T, OS);
601void TypePrinter::printArrayParameterBefore(
const ArrayParameterType *
T,
603 printConstantArrayBefore(
T, OS);
606void TypePrinter::printDecayedAfter(
const DecayedType *
T, raw_ostream &OS) {
607 printAdjustedAfter(
T, OS);
610void TypePrinter::printDependentSizedArrayBefore(
611 const DependentSizedArrayType *
T,
613 IncludeStrongLifetimeRAII Strong(Policy);
614 printBefore(
T->getElementType(), OS);
617void TypePrinter::printDependentSizedArrayAfter(
618 const DependentSizedArrayType *
T,
621 if (
T->getSizeExpr())
622 T->getSizeExpr()->printPretty(OS,
nullptr, Policy);
624 printAfter(
T->getElementType(), OS);
627void TypePrinter::printDependentAddressSpaceBefore(
628 const DependentAddressSpaceType *
T, raw_ostream &OS) {
632void TypePrinter::printDependentAddressSpaceAfter(
633 const DependentAddressSpaceType *
T, raw_ostream &OS) {
634 OS <<
" __attribute__((address_space(";
635 if (
T->getAddrSpaceExpr())
636 T->getAddrSpaceExpr()->printPretty(OS,
nullptr, Policy);
641void TypePrinter::printDependentSizedExtVectorBefore(
642 const DependentSizedExtVectorType *
T,
646 printBefore(
T->getElementType(), OS);
649void TypePrinter::printDependentSizedExtVectorAfter(
650 const DependentSizedExtVectorType *
T,
654 if (
T->getSizeExpr())
655 T->getSizeExpr()->printPretty(OS,
nullptr, Policy);
658 OS <<
" __attribute__((ext_vector_type(";
659 if (
T->getSizeExpr())
660 T->getSizeExpr()->printPretty(OS,
nullptr, Policy);
663 printAfter(
T->getElementType(), OS);
666void TypePrinter::printVectorBefore(
const VectorType *
T, raw_ostream &OS) {
667 switch (
T->getVectorKind()) {
668 case VectorKind::AltiVecPixel:
669 OS <<
"__vector __pixel ";
671 case VectorKind::AltiVecBool:
672 OS <<
"__vector __bool ";
673 printBefore(
T->getElementType(), OS);
675 case VectorKind::AltiVecVector:
677 printBefore(
T->getElementType(), OS);
679 case VectorKind::Neon:
680 OS <<
"__attribute__((neon_vector_type("
681 <<
T->getNumElements() <<
"))) ";
682 printBefore(
T->getElementType(), OS);
684 case VectorKind::NeonPoly:
685 OS <<
"__attribute__((neon_polyvector_type(" <<
686 T->getNumElements() <<
"))) ";
687 printBefore(
T->getElementType(), OS);
689 case VectorKind::Generic: {
692 OS <<
"__attribute__((__vector_size__("
693 <<
T->getNumElements()
695 print(
T->getElementType(), OS, StringRef());
697 printBefore(
T->getElementType(), OS);
700 case VectorKind::SveFixedLengthData:
701 case VectorKind::SveFixedLengthPredicate:
704 OS <<
"__attribute__((__arm_sve_vector_bits__(";
706 if (
T->getVectorKind() == VectorKind::SveFixedLengthPredicate)
709 OS <<
T->getNumElements() * 8;
711 OS <<
T->getNumElements();
714 print(
T->getElementType(), OS, StringRef());
717 printBefore(
T->getElementType(), OS);
719 case VectorKind::RVVFixedLengthData:
720 case VectorKind::RVVFixedLengthMask:
721 case VectorKind::RVVFixedLengthMask_1:
722 case VectorKind::RVVFixedLengthMask_2:
723 case VectorKind::RVVFixedLengthMask_4:
726 OS <<
"__attribute__((__riscv_rvv_vector_bits__(";
728 OS <<
T->getNumElements();
731 print(
T->getElementType(), OS, StringRef());
734 printBefore(
T->getElementType(), OS);
739void TypePrinter::printVectorAfter(
const VectorType *
T, raw_ostream &OS) {
740 printAfter(
T->getElementType(), OS);
743void TypePrinter::printDependentVectorBefore(
744 const DependentVectorType *
T, raw_ostream &OS) {
745 switch (
T->getVectorKind()) {
746 case VectorKind::AltiVecPixel:
747 OS <<
"__vector __pixel ";
749 case VectorKind::AltiVecBool:
750 OS <<
"__vector __bool ";
751 printBefore(
T->getElementType(), OS);
753 case VectorKind::AltiVecVector:
755 printBefore(
T->getElementType(), OS);
757 case VectorKind::Neon:
758 OS <<
"__attribute__((neon_vector_type(";
759 if (
T->getSizeExpr())
760 T->getSizeExpr()->printPretty(OS,
nullptr, Policy);
762 printBefore(
T->getElementType(), OS);
764 case VectorKind::NeonPoly:
765 OS <<
"__attribute__((neon_polyvector_type(";
766 if (
T->getSizeExpr())
767 T->getSizeExpr()->printPretty(OS,
nullptr, Policy);
769 printBefore(
T->getElementType(), OS);
771 case VectorKind::Generic: {
774 OS <<
"__attribute__((__vector_size__(";
775 if (
T->getSizeExpr())
776 T->getSizeExpr()->printPretty(OS,
nullptr, Policy);
778 print(
T->getElementType(), OS, StringRef());
780 printBefore(
T->getElementType(), OS);
783 case VectorKind::SveFixedLengthData:
784 case VectorKind::SveFixedLengthPredicate:
787 OS <<
"__attribute__((__arm_sve_vector_bits__(";
788 if (
T->getSizeExpr()) {
789 T->getSizeExpr()->printPretty(OS,
nullptr, Policy);
790 if (
T->getVectorKind() == VectorKind::SveFixedLengthPredicate)
795 print(
T->getElementType(), OS, StringRef());
800 printBefore(
T->getElementType(), OS);
802 case VectorKind::RVVFixedLengthData:
803 case VectorKind::RVVFixedLengthMask:
804 case VectorKind::RVVFixedLengthMask_1:
805 case VectorKind::RVVFixedLengthMask_2:
806 case VectorKind::RVVFixedLengthMask_4:
809 OS <<
"__attribute__((__riscv_rvv_vector_bits__(";
810 if (
T->getSizeExpr()) {
811 T->getSizeExpr()->printPretty(OS,
nullptr, Policy);
813 print(
T->getElementType(), OS, StringRef());
818 printBefore(
T->getElementType(), OS);
823void TypePrinter::printDependentVectorAfter(
824 const DependentVectorType *
T, raw_ostream &OS) {
825 printAfter(
T->getElementType(), OS);
828void TypePrinter::printExtVectorBefore(
const ExtVectorType *
T,
832 printBefore(
T->getElementType(), OS);
835void TypePrinter::printExtVectorAfter(
const ExtVectorType *
T, raw_ostream &OS) {
836 printAfter(
T->getElementType(), OS);
840 OS <<
T->getNumElements();
843 OS <<
" __attribute__((ext_vector_type(";
844 OS <<
T->getNumElements();
850 OS <<
T->getNumRows() <<
", " <<
T->getNumColumns();
856 TP.printBefore(
T->getElementType(), OS);
867 TP.printBefore(
T->getElementType(), OS);
868 OS <<
" __attribute__((matrix_type(";
873void TypePrinter::printConstantMatrixBefore(
const ConstantMatrixType *
T,
882void TypePrinter::printConstantMatrixAfter(
const ConstantMatrixType *
T,
888 printAfter(
T->getElementType(), OS);
891void TypePrinter::printDependentSizedMatrixBefore(
892 const DependentSizedMatrixType *
T, raw_ostream &OS) {
893 printBefore(
T->getElementType(), OS);
894 OS <<
" __attribute__((matrix_type(";
895 if (
T->getRowExpr()) {
896 T->getRowExpr()->printPretty(OS,
nullptr, Policy);
899 if (
T->getColumnExpr()) {
900 T->getColumnExpr()->printPretty(OS,
nullptr, Policy);
905void TypePrinter::printDependentSizedMatrixAfter(
906 const DependentSizedMatrixType *
T, raw_ostream &OS) {
907 printAfter(
T->getElementType(), OS);
927 OS <<
" __attribute__((nothrow))";
943 if (
T->hasTrailingReturn()) {
945 if (!HasEmptyPlaceHolder)
950 printBefore(
T->getReturnType(), OS);
951 if (!PrevPHIsEmpty.get())
959 llvm_unreachable(
"asking for spelling of ordinary parameter ABI");
961 return "swift_context";
963 return "swift_async_context";
965 return "swift_error_result";
967 return "swift_indirect_result";
973 llvm_unreachable(
"bad parameter ABI kind");
979 if (!HasEmptyPlaceHolder)
985 ParamPolicyRAII ParamPolicy(Policy);
986 for (
unsigned i = 0, e =
T->getNumParams(); i != e; ++i) {
989 auto EPI =
T->getExtParameterInfo(i);
990 if (EPI.isConsumed()) OS <<
"__attribute__((ns_consumed)) ";
991 if (EPI.isNoEscape())
992 OS <<
"__attribute__((noescape)) ";
993 auto ABI = EPI.getABI();
1001 print(
T->getParamType(i).getNonReferenceType(), OS, StringRef());
1004 }
else if (ABI != ParameterABI::Ordinary)
1026 OS <<
" __arm_streaming_compatible";
1028 OS <<
" __arm_streaming";
1030 OS <<
"__arm_agnostic(\"sme_za_state\")";
1032 OS <<
" __arm_preserves(\"za\")";
1034 OS <<
" __arm_in(\"za\")";
1036 OS <<
" __arm_out(\"za\")";
1038 OS <<
" __arm_inout(\"za\")";
1040 OS <<
" __arm_preserves(\"zt0\")";
1042 OS <<
" __arm_in(\"zt0\")";
1044 OS <<
" __arm_out(\"zt0\")";
1046 OS <<
" __arm_inout(\"zt0\")";
1048 printFunctionAfter(Info, OS);
1068 for (
const auto &CFE : FX) {
1069 OS <<
" __attribute__((" << CFE.Effect.name();
1070 if (
const Expr *E = CFE.Cond.getCondition()) {
1072 E->printPretty(OS,
nullptr, Policy);
1079 OS <<
" __attribute__((cfi_unchecked_callee))";
1088void TypePrinter::printFunctionAfter(
const FunctionType::ExtInfo &Info,
1090 if (!InsideCCAttribute) {
1091 switch (Info.
getCC()) {
1102 OS <<
" __attribute__((stdcall))";
1105 OS <<
" __attribute__((fastcall))";
1108 OS <<
" __attribute__((thiscall))";
1111 OS <<
" __attribute__((vectorcall))";
1114 OS <<
" __attribute__((pascal))";
1117 OS <<
" __attribute__((pcs(\"aapcs\")))";
1120 OS <<
" __attribute__((pcs(\"aapcs-vfp\")))";
1123 OS <<
" __attribute__((aarch64_vector_pcs))";
1126 OS <<
" __attribute__((aarch64_sve_pcs))";
1129 OS <<
" __attribute__((device_kernel))";
1132 OS <<
" __attribute__((intel_ocl_bicc))";
1135 OS <<
" __attribute__((ms_abi))";
1138 OS <<
" __attribute__((sysv_abi))";
1141 OS <<
" __attribute__((regcall))";
1147 OS <<
" __attribute__((swiftcall))";
1150 OS <<
"__attribute__((swiftasynccall))";
1153 OS <<
" __attribute__((preserve_most))";
1156 OS <<
" __attribute__((preserve_all))";
1159 OS <<
" __attribute__((m68k_rtd))";
1162 OS <<
" __attribute__((preserve_none))";
1165 OS <<
"__attribute__((riscv_vector_cc))";
1167#define CC_VLS_CASE(ABI_VLEN) \
1168 case CC_RISCVVLSCall_##ABI_VLEN: \
1169 OS << "__attribute__((riscv_vls_cc" #ABI_VLEN "))"; \
1188 OS <<
" __attribute__((noreturn))";
1190 OS <<
" __attribute__((cmse_nonsecure_call))";
1192 OS <<
" __attribute__((ns_returns_retained))";
1194 OS <<
" __attribute__((regparm ("
1197 OS <<
" __attribute__((no_caller_saved_registers))";
1199 OS <<
" __attribute__((nocf_check))";
1202void TypePrinter::printFunctionNoProtoBefore(
const FunctionNoProtoType *
T,
1205 SaveAndRestore PrevPHIsEmpty(HasEmptyPlaceHolder,
false);
1207 if (!PrevPHIsEmpty.get())
1211void TypePrinter::printFunctionNoProtoAfter(
const FunctionNoProtoType *
T,
1214 if (!HasEmptyPlaceHolder)
1216 SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder,
false);
1223void TypePrinter::printTypeSpec(NamedDecl *D, raw_ostream &OS) {
1233 spaceBeforePlaceHolder(OS);
1236void TypePrinter::printUnresolvedUsingBefore(
const UnresolvedUsingType *
T,
1238 OS << TypeWithKeyword::getKeywordName(
T->getKeyword());
1239 if (
T->getKeyword() != ElaboratedTypeKeyword::None)
1241 auto *D =
T->getDecl();
1245 T->getQualifier().print(OS, Policy);
1248 spaceBeforePlaceHolder(OS);
1251void TypePrinter::printUnresolvedUsingAfter(
const UnresolvedUsingType *
T,
1254void TypePrinter::printUsingBefore(
const UsingType *
T, raw_ostream &OS) {
1255 OS << TypeWithKeyword::getKeywordName(
T->getKeyword());
1256 if (
T->getKeyword() != ElaboratedTypeKeyword::None)
1258 auto *D =
T->getDecl();
1262 T->getQualifier().print(OS, Policy);
1265 spaceBeforePlaceHolder(OS);
1268void TypePrinter::printUsingAfter(
const UsingType *
T, raw_ostream &OS) {}
1270void TypePrinter::printTypedefBefore(
const TypedefType *
T, raw_ostream &OS) {
1271 OS << TypeWithKeyword::getKeywordName(
T->getKeyword());
1272 if (
T->getKeyword() != ElaboratedTypeKeyword::None)
1274 auto *D =
T->getDecl();
1278 T->getQualifier().print(OS, Policy);
1281 spaceBeforePlaceHolder(OS);
1284void TypePrinter::printMacroQualifiedBefore(
const MacroQualifiedType *
T,
1286 StringRef MacroName =
T->getMacroIdentifier()->getName();
1287 OS << MacroName <<
" ";
1291 printBefore(
T->getModifiedType(), OS);
1294void TypePrinter::printMacroQualifiedAfter(
const MacroQualifiedType *
T,
1296 printAfter(
T->getModifiedType(), OS);
1299void TypePrinter::printTypedefAfter(
const TypedefType *
T, raw_ostream &OS) {}
1301void TypePrinter::printTypeOfExprBefore(
const TypeOfExprType *
T,
1303 OS << (
T->getKind() == TypeOfKind::Unqualified ?
"typeof_unqual "
1305 if (
T->getUnderlyingExpr())
1306 T->getUnderlyingExpr()->printPretty(OS,
nullptr, Policy);
1307 spaceBeforePlaceHolder(OS);
1310void TypePrinter::printTypeOfExprAfter(
const TypeOfExprType *
T,
1313void TypePrinter::printTypeOfBefore(
const TypeOfType *
T, raw_ostream &OS) {
1314 OS << (
T->getKind() == TypeOfKind::Unqualified ?
"typeof_unqual("
1316 print(
T->getUnmodifiedType(), OS, StringRef());
1318 spaceBeforePlaceHolder(OS);
1321void TypePrinter::printTypeOfAfter(
const TypeOfType *
T, raw_ostream &OS) {}
1323void TypePrinter::printDecltypeBefore(
const DecltypeType *
T, raw_ostream &OS) {
1325 if (
const Expr *E =
T->getUnderlyingExpr()) {
1326 PrintingPolicy ExprPolicy = Policy;
1328 E->printPretty(OS,
nullptr, ExprPolicy);
1331 spaceBeforePlaceHolder(OS);
1334void TypePrinter::printPackIndexingBefore(
const PackIndexingType *
T,
1336 if (
T->hasSelectedType()) {
1337 OS <<
T->getSelectedType();
1339 OS <<
T->getPattern() <<
"...[";
1340 T->getIndexExpr()->printPretty(OS,
nullptr, Policy);
1343 spaceBeforePlaceHolder(OS);
1346void TypePrinter::printPackIndexingAfter(
const PackIndexingType *
T,
1349void TypePrinter::printDecltypeAfter(
const DecltypeType *
T, raw_ostream &OS) {}
1351void TypePrinter::printUnaryTransformBefore(
const UnaryTransformType *
T,
1353 IncludeStrongLifetimeRAII Strong(Policy);
1355 static llvm::DenseMap<int, const char *> Transformation = {{
1356#define TRANSFORM_TYPE_TRAIT_DEF(Enum, Trait) \
1357 {UnaryTransformType::Enum, "__" #Trait},
1358#include "clang/Basic/TransformTypeTraits.def"
1360 OS << Transformation[
T->getUTTKind()] <<
'(';
1361 print(
T->getBaseType(), OS, StringRef());
1363 spaceBeforePlaceHolder(OS);
1366void TypePrinter::printUnaryTransformAfter(
const UnaryTransformType *
T,
1369void TypePrinter::printAutoBefore(
const AutoType *
T, raw_ostream &OS) {
1371 if (!
T->getDeducedType().isNull()) {
1372 printBefore(
T->getDeducedType(), OS);
1374 if (
T->isConstrained()) {
1377 T->getTypeConstraintConcept()->getDeclName().print(OS, Policy);
1378 auto Args =
T->getTypeConstraintArguments();
1380 printTemplateArgumentList(
1382 T->getTypeConstraintConcept()->getTemplateParameters());
1385 switch (
T->getKeyword()) {
1386 case AutoTypeKeyword::Auto:
OS <<
"auto";
break;
1387 case AutoTypeKeyword::DecltypeAuto:
OS <<
"decltype(auto)";
break;
1388 case AutoTypeKeyword::GNUAutoType:
OS <<
"__auto_type";
break;
1390 spaceBeforePlaceHolder(OS);
1394void TypePrinter::printAutoAfter(
const AutoType *
T, raw_ostream &OS) {
1396 if (!
T->getDeducedType().isNull())
1397 printAfter(
T->getDeducedType(), OS);
1400void TypePrinter::printDeducedTemplateSpecializationBefore(
1401 const DeducedTemplateSpecializationType *
T, raw_ostream &OS) {
1403 T->getKeyword() != ElaboratedTypeKeyword::None)
1413 ArrayRef<TemplateArgument> Args;
1414 TemplateDecl *DeducedTD =
nullptr;
1415 if (!
T->getDeducedType().isNull()) {
1416 if (
const auto *TST =
1417 dyn_cast<TemplateSpecializationType>(
T->getDeducedType())) {
1418 DeducedTD = TST->getTemplateName().getAsTemplateDecl(
1420 Args = TST->template_arguments();
1425 DeducedTD = CD->getSpecializedTemplate();
1426 Args = CD->getTemplateArgs().asArray();
1440 IncludeStrongLifetimeRAII Strong(Policy);
1441 Name.
print(OS, Policy);
1444 printTemplateArgumentList(OS, Args, Policy,
1448 spaceBeforePlaceHolder(OS);
1451void TypePrinter::printDeducedTemplateSpecializationAfter(
1452 const DeducedTemplateSpecializationType *
T, raw_ostream &OS) {
1454 if (!
T->getDeducedType().isNull())
1455 printAfter(
T->getDeducedType(), OS);
1458void TypePrinter::printAtomicBefore(
const AtomicType *
T, raw_ostream &OS) {
1459 IncludeStrongLifetimeRAII Strong(Policy);
1462 print(
T->getValueType(), OS, StringRef());
1464 spaceBeforePlaceHolder(OS);
1467void TypePrinter::printAtomicAfter(
const AtomicType *
T, raw_ostream &OS) {}
1469void TypePrinter::printPipeBefore(
const PipeType *
T, raw_ostream &OS) {
1470 IncludeStrongLifetimeRAII Strong(Policy);
1472 if (
T->isReadOnly())
1475 OS <<
"write_only ";
1477 print(
T->getElementType(), OS, StringRef());
1478 spaceBeforePlaceHolder(OS);
1481void TypePrinter::printPipeAfter(
const PipeType *
T, raw_ostream &OS) {}
1483void TypePrinter::printBitIntBefore(
const BitIntType *
T, raw_ostream &OS) {
1484 if (
T->isUnsigned())
1486 OS <<
"_BitInt(" <<
T->getNumBits() <<
")";
1487 spaceBeforePlaceHolder(OS);
1490void TypePrinter::printBitIntAfter(
const BitIntType *
T, raw_ostream &OS) {}
1492void TypePrinter::printDependentBitIntBefore(
const DependentBitIntType *
T,
1494 if (
T->isUnsigned())
1497 T->getNumBitsExpr()->printPretty(OS,
nullptr, Policy);
1499 spaceBeforePlaceHolder(OS);
1502void TypePrinter::printDependentBitIntAfter(
const DependentBitIntType *
T,
1505void TypePrinter::printPredefinedSugarBefore(
const PredefinedSugarType *
T,
1507 OS <<
T->getIdentifier()->getName();
1508 spaceBeforePlaceHolder(OS);
1511void TypePrinter::printPredefinedSugarAfter(
const PredefinedSugarType *
T,
1515void TypePrinter::AppendScope(DeclContext *DC, raw_ostream &OS,
1516 DeclarationName NameInScope) {
1528 if (
const auto *NS = dyn_cast<NamespaceDecl>(DC)) {
1530 return AppendScope(DC->
getParent(), OS, NameInScope);
1535 PrintingPolicy::SuppressInlineNamespaceMode::None &&
1536 NS->isInline() && NameInScope &&
1537 NS->isRedundantInlineQualifierFor(NameInScope))
1538 return AppendScope(DC->
getParent(), OS, NameInScope);
1540 AppendScope(DC->
getParent(), OS, NS->getDeclName());
1541 if (NS->getIdentifier())
1542 OS << NS->getName() <<
"::";
1544 OS <<
"(anonymous namespace)::";
1545 }
else if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
1546 AppendScope(DC->
getParent(), OS, Spec->getDeclName());
1547 IncludeStrongLifetimeRAII Strong(Policy);
1548 OS << Spec->getIdentifier()->getName();
1549 const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
1550 printTemplateArgumentList(
1551 OS, TemplateArgs.
asArray(), Policy,
1552 Spec->getSpecializedTemplate()->getTemplateParameters());
1554 }
else if (
const auto *Tag = dyn_cast<TagDecl>(DC)) {
1556 if (TypedefNameDecl *
Typedef =
Tag->getTypedefNameForAnonDecl())
1557 OS <<
Typedef->getIdentifier()->getName() <<
"::";
1558 else if (
Tag->getIdentifier())
1559 OS <<
Tag->getIdentifier()->getName() <<
"::";
1563 AppendScope(DC->
getParent(), OS, NameInScope);
1567void TypePrinter::printTagType(
const TagType *
T, raw_ostream &OS) {
1568 TagDecl *D =
T->getOriginalDecl();
1571 D->
print(OS, Policy, Indentation);
1572 spaceBeforePlaceHolder(OS);
1576 bool HasKindDecoration =
false;
1580 HasKindDecoration =
true;
1585 OS << TypeWithKeyword::getKeywordName(
T->getKeyword());
1586 if (
T->getKeyword() != ElaboratedTypeKeyword::None)
1591 T->getQualifier().print(OS, Policy);
1602 assert(
Typedef->getIdentifier() &&
"Typedef without identifier?");
1603 OS <<
Typedef->getIdentifier()->getName();
1611 HasKindDecoration =
true;
1622 if (!HasKindDecoration)
1630 llvm::SmallString<1024> WrittenFile(
File);
1632 WrittenFile = Callbacks->remapPath(
File);
1636 llvm::sys::path::Style Style =
1637 llvm::sys::path::is_absolute(WrittenFile)
1638 ? llvm::sys::path::Style::native
1640 ? llvm::sys::path::Style::windows_backslash
1641 : llvm::sys::path::Style::posix);
1642 llvm::sys::path::native(WrittenFile, Style);
1652 if (
auto *S = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
1653 const TemplateParameterList *TParams =
1654 S->getSpecializedTemplate()->getTemplateParameters();
1655 const ASTTemplateArgumentListInfo *TArgAsWritten =
1656 S->getTemplateArgsAsWritten();
1657 IncludeStrongLifetimeRAII Strong(Policy);
1659 printTemplateArgumentList(OS, TArgAsWritten->
arguments(), Policy,
1662 printTemplateArgumentList(OS, S->getTemplateArgs().asArray(), Policy,
1666 spaceBeforePlaceHolder(OS);
1669void TypePrinter::printRecordBefore(
const RecordType *
T, raw_ostream &OS) {
1672 for (
const auto *PNA :
T->getOriginalDecl()
1673 ->getMostRecentDecl()
1674 ->specific_attrs<PreferredNameAttr>()) {
1676 T->getOriginalDecl()))
1679 QualType
T = PNA->getTypedefType();
1681 if (
auto *TT = dyn_cast<TypedefType>(
T))
1682 return printTypeSpec(TT->getDecl(), OS);
1683 if (
auto *TST = dyn_cast<TemplateSpecializationType>(
T))
1684 return printTemplateId(TST, OS,
true);
1690 printTagType(
T, OS);
1693void TypePrinter::printRecordAfter(
const RecordType *
T, raw_ostream &OS) {}
1695void TypePrinter::printEnumBefore(
const EnumType *
T, raw_ostream &OS) {
1696 printTagType(
T, OS);
1699void TypePrinter::printEnumAfter(
const EnumType *
T, raw_ostream &OS) {}
1701void TypePrinter::printInjectedClassNameBefore(
const InjectedClassNameType *
T,
1703 const ASTContext &Ctx =
T->getOriginalDecl()->getASTContext();
1704 IncludeStrongLifetimeRAII Strong(Policy);
1705 T->getTemplateName(Ctx).print(OS, Policy);
1707 auto *
Decl =
T->getOriginalDecl();
1710 if (
auto *RD = dyn_cast<ClassTemplateSpecializationDecl>(Decl)) {
1711 printTemplateArgumentList(OS, RD->getTemplateArgsAsWritten()->arguments(),
1713 T->getTemplateDecl()->getTemplateParameters());
1715 ClassTemplateDecl *TD =
Decl->getDescribedClassTemplate();
1717 printTemplateArgumentList(
1719 T->getTemplateDecl()->getTemplateParameters());
1722 spaceBeforePlaceHolder(OS);
1725void TypePrinter::printInjectedClassNameAfter(
const InjectedClassNameType *
T,
1728void TypePrinter::printTemplateTypeParmBefore(
const TemplateTypeParmType *
T,
1730 TemplateTypeParmDecl *D =
T->getDecl();
1733 TC->print(OS, Policy);
1737 }
else if (IdentifierInfo *Id =
T->getIdentifier())
1741 OS <<
"type-parameter-" <<
T->getDepth() <<
'-' <<
T->getIndex();
1743 spaceBeforePlaceHolder(OS);
1746void TypePrinter::printTemplateTypeParmAfter(
const TemplateTypeParmType *
T,
1749void TypePrinter::printSubstTemplateTypeParmBefore(
1750 const SubstTemplateTypeParmType *
T,
1752 IncludeStrongLifetimeRAII Strong(Policy);
1753 printBefore(
T->getReplacementType(), OS);
1756void TypePrinter::printSubstTemplateTypeParmAfter(
1757 const SubstTemplateTypeParmType *
T,
1759 IncludeStrongLifetimeRAII Strong(Policy);
1760 printAfter(
T->getReplacementType(), OS);
1763void TypePrinter::printSubstBuiltinTemplatePackBefore(
1764 const SubstBuiltinTemplatePackType *
T, raw_ostream &OS) {
1765 IncludeStrongLifetimeRAII Strong(Policy);
1769void TypePrinter::printSubstBuiltinTemplatePackAfter(
1770 const SubstBuiltinTemplatePackType *
T, raw_ostream &OS) {}
1772void TypePrinter::printSubstTemplateTypeParmPackBefore(
1773 const SubstTemplateTypeParmPackType *
T,
1775 IncludeStrongLifetimeRAII Strong(Policy);
1776 if (
const TemplateTypeParmDecl *D =
T->getReplacedParameter()) {
1779 TC->print(OS, Policy);
1789 spaceBeforePlaceHolder(OS);
1793void TypePrinter::printSubstTemplateTypeParmPackAfter(
1794 const SubstTemplateTypeParmPackType *
T,
1796 IncludeStrongLifetimeRAII Strong(Policy);
1799void TypePrinter::printTemplateId(
const TemplateSpecializationType *
T,
1800 raw_ostream &OS,
bool FullyQualify) {
1801 IncludeStrongLifetimeRAII Strong(Policy);
1804 K != ElaboratedTypeKeyword::None)
1805 OS << TypeWithKeyword::getKeywordName(K) <<
' ';
1808 T->getTemplateName().getAsTemplateDecl(
true);
1810 if (FullyQualify && TD) {
1816 T->getTemplateName().print(OS, Policy,
1818 ? TemplateName::Qualified::AsWritten
1819 : TemplateName::Qualified::None);
1822 DefaultTemplateArgsPolicyRAII TemplateArgs(Policy);
1824 printTemplateArgumentList(OS,
T->template_arguments(), Policy, TPL);
1825 spaceBeforePlaceHolder(OS);
1828void TypePrinter::printTemplateSpecializationBefore(
1829 const TemplateSpecializationType *
T,
1834void TypePrinter::printTemplateSpecializationAfter(
1835 const TemplateSpecializationType *
T,
1838void TypePrinter::printParenBefore(
const ParenType *
T, raw_ostream &OS) {
1840 printBefore(
T->getInnerType(), OS);
1843 printBefore(
T->getInnerType(), OS);
1846void TypePrinter::printParenAfter(
const ParenType *
T, raw_ostream &OS) {
1849 printAfter(
T->getInnerType(), OS);
1851 printAfter(
T->getInnerType(), OS);
1854void TypePrinter::printDependentNameBefore(
const DependentNameType *
T,
1856 OS << TypeWithKeyword::getKeywordName(
T->getKeyword());
1857 if (
T->getKeyword() != ElaboratedTypeKeyword::None)
1859 T->getQualifier().print(OS, Policy);
1860 OS <<
T->getIdentifier()->getName();
1861 spaceBeforePlaceHolder(OS);
1864void TypePrinter::printDependentNameAfter(
const DependentNameType *
T,
1867void TypePrinter::printPackExpansionBefore(
const PackExpansionType *
T,
1869 printBefore(
T->getPattern(), OS);
1872void TypePrinter::printPackExpansionAfter(
const PackExpansionType *
T,
1874 printAfter(
T->getPattern(), OS);
1882 if (
T->isCountInBytes() &&
T->isOrNull())
1883 OS <<
"__sized_by_or_null(";
1884 else if (
T->isCountInBytes())
1885 OS <<
"__sized_by(";
1886 else if (
T->isOrNull())
1887 OS <<
"__counted_by_or_null(";
1889 OS <<
"__counted_by(";
1890 if (
T->getCountExpr())
1891 T->getCountExpr()->printPretty(OS,
nullptr, Policy);
1895void TypePrinter::printCountAttributedBefore(
const CountAttributedType *
T,
1902void TypePrinter::printCountAttributedAfter(
const CountAttributedType *
T,
1909void TypePrinter::printAttributedBefore(
const AttributedType *
T,
1914 if (
T->getAttrKind() == attr::ObjCGC ||
1915 T->getAttrKind() == attr::ObjCOwnership)
1916 return printBefore(
T->getEquivalentType(), OS);
1918 if (
T->getAttrKind() == attr::ObjCKindOf)
1921 if (
T->getAttrKind() == attr::PreserveNone) {
1922 OS <<
"__attribute__((preserve_none)) ";
1923 spaceBeforePlaceHolder(OS);
1924 }
else if (
T->getAttrKind() == attr::PreserveMost) {
1925 OS <<
"__attribute__((preserve_most)) ";
1926 spaceBeforePlaceHolder(OS);
1927 }
else if (
T->getAttrKind() == attr::PreserveAll) {
1928 OS <<
"__attribute__((preserve_all)) ";
1929 spaceBeforePlaceHolder(OS);
1932 if (
T->getAttrKind() == attr::AddressSpace)
1933 printBefore(
T->getEquivalentType(), OS);
1935 printBefore(
T->getModifiedType(), OS);
1937 if (
T->isMSTypeSpec()) {
1938 switch (
T->getAttrKind()) {
1940 case attr::Ptr32:
OS <<
" __ptr32";
break;
1941 case attr::Ptr64:
OS <<
" __ptr64";
break;
1942 case attr::SPtr:
OS <<
" __sptr";
break;
1943 case attr::UPtr:
OS <<
" __uptr";
break;
1945 spaceBeforePlaceHolder(OS);
1948 if (
T->isWebAssemblyFuncrefSpec())
1952 if (
T->getImmediateNullability()) {
1953 if (
T->getAttrKind() == attr::TypeNonNull)
1955 else if (
T->getAttrKind() == attr::TypeNullable)
1957 else if (
T->getAttrKind() == attr::TypeNullUnspecified)
1958 OS <<
" _Null_unspecified";
1959 else if (
T->getAttrKind() == attr::TypeNullableResult)
1960 OS <<
" _Nullable_result";
1962 llvm_unreachable(
"unhandled nullability");
1963 spaceBeforePlaceHolder(OS);
1967void TypePrinter::printAttributedAfter(
const AttributedType *
T,
1972 if (
T->getAttrKind() == attr::ObjCGC ||
1973 T->getAttrKind() == attr::ObjCOwnership)
1974 return printAfter(
T->getEquivalentType(), OS);
1978 SaveAndRestore MaybeSuppressCC(InsideCCAttribute,
T->isCallingConv());
1980 printAfter(
T->getModifiedType(), OS);
1984 if (
T->getAttrKind() == attr::ObjCKindOf ||
T->isMSTypeSpec() ||
1985 T->getImmediateNullability() ||
T->isWebAssemblyFuncrefSpec())
1989 if (
T->getAttrKind() == attr::ObjCInertUnsafeUnretained)
1993 if (
T->getAttrKind() == attr::NSReturnsRetained &&
1994 !
T->getEquivalentType()->
castAs<FunctionType>()
1995 ->getExtInfo().getProducesResult())
1998 if (
T->getAttrKind() == attr::LifetimeBound) {
1999 OS <<
" [[clang::lifetimebound]]";
2002 if (
T->getAttrKind() == attr::LifetimeCaptureBy) {
2003 OS <<
" [[clang::lifetime_capture_by(";
2004 if (
auto *attr = dyn_cast_or_null<LifetimeCaptureByAttr>(
T->getAttr()))
2005 llvm::interleaveComma(
attr->getArgIdents(), OS,
2006 [&](
auto it) { OS << it->getName(); });
2014 if (
T->getAttrKind() == attr::AddressSpace)
2017 if (
T->getAttrKind() == attr::AnnotateType) {
2022 OS <<
" [[clang::annotate_type(...)]]";
2026 if (
T->getAttrKind() == attr::ArmStreaming) {
2027 OS <<
"__arm_streaming";
2030 if (
T->getAttrKind() == attr::ArmStreamingCompatible) {
2031 OS <<
"__arm_streaming_compatible";
2035 if (
T->getAttrKind() == attr::SwiftAttr) {
2036 if (
auto *swiftAttr = dyn_cast_or_null<SwiftAttrAttr>(
T->getAttr())) {
2037 OS <<
" __attribute__((swift_attr(\"" << swiftAttr->getAttribute()
2043 if (
T->getAttrKind() == attr::PreserveAll ||
2044 T->getAttrKind() == attr::PreserveMost ||
2045 T->getAttrKind() == attr::PreserveNone) {
2050 OS <<
" __attribute__((";
2051 switch (
T->getAttrKind()) {
2052#define TYPE_ATTR(NAME)
2053#define DECL_OR_TYPE_ATTR(NAME)
2054#define ATTR(NAME) case attr::NAME:
2055#include "clang/Basic/AttrList.inc"
2056 llvm_unreachable(
"non-type attribute attached to type");
2058 case attr::BTFTypeTag:
2059 llvm_unreachable(
"BTFTypeTag attribute handled separately");
2061 case attr::HLSLResourceClass:
2063 case attr::HLSLRawBuffer:
2064 case attr::HLSLContainedType:
2065 llvm_unreachable(
"HLSL resource type attributes handled separately");
2067 case attr::OpenCLPrivateAddressSpace:
2068 case attr::OpenCLGlobalAddressSpace:
2069 case attr::OpenCLGlobalDeviceAddressSpace:
2070 case attr::OpenCLGlobalHostAddressSpace:
2071 case attr::OpenCLLocalAddressSpace:
2072 case attr::OpenCLConstantAddressSpace:
2073 case attr::OpenCLGenericAddressSpace:
2074 case attr::HLSLGroupSharedAddressSpace:
2079 case attr::CountedBy:
2080 case attr::CountedByOrNull:
2082 case attr::SizedByOrNull:
2083 case attr::LifetimeBound:
2084 case attr::LifetimeCaptureBy:
2085 case attr::TypeNonNull:
2086 case attr::TypeNullable:
2087 case attr::TypeNullableResult:
2088 case attr::TypeNullUnspecified:
2090 case attr::ObjCInertUnsafeUnretained:
2091 case attr::ObjCKindOf:
2092 case attr::ObjCOwnership:
2097 case attr::PointerAuth:
2098 case attr::AddressSpace:
2099 case attr::CmseNSCall:
2100 case attr::AnnotateType:
2101 case attr::WebAssemblyFuncref:
2102 case attr::ArmAgnostic:
2103 case attr::ArmStreaming:
2104 case attr::ArmStreamingCompatible:
2107 case attr::ArmInOut:
2108 case attr::ArmPreserves:
2109 case attr::NonBlocking:
2110 case attr::NonAllocating:
2111 case attr::Blocking:
2112 case attr::Allocating:
2113 case attr::SwiftAttr:
2114 case attr::PreserveAll:
2115 case attr::PreserveMost:
2116 case attr::PreserveNone:
2117 llvm_unreachable(
"This attribute should have been handled already");
2119 case attr::NSReturnsRetained:
2120 OS <<
"ns_returns_retained";
2125 case attr::AnyX86NoCfCheck:
OS <<
"nocf_check";
break;
2126 case attr::CDecl:
OS <<
"cdecl";
break;
2127 case attr::FastCall:
OS <<
"fastcall";
break;
2128 case attr::StdCall:
OS <<
"stdcall";
break;
2129 case attr::ThisCall:
OS <<
"thiscall";
break;
2130 case attr::SwiftCall:
OS <<
"swiftcall";
break;
2131 case attr::SwiftAsyncCall:
OS <<
"swiftasynccall";
break;
2132 case attr::VectorCall:
OS <<
"vectorcall";
break;
2133 case attr::Pascal:
OS <<
"pascal";
break;
2134 case attr::MSABI:
OS <<
"ms_abi";
break;
2135 case attr::SysVABI:
OS <<
"sysv_abi";
break;
2136 case attr::RegCall:
OS <<
"regcall";
break;
2139 QualType t =
T->getEquivalentType();
2143 "\"aapcs\"" :
"\"aapcs-vfp\"");
2147 case attr::AArch64VectorPcs:
OS <<
"aarch64_vector_pcs";
break;
2148 case attr::AArch64SVEPcs:
OS <<
"aarch64_sve_pcs";
break;
2149 case attr::DeviceKernel:
2150 OS <<
T->getAttr()->getSpelling();
2152 case attr::IntelOclBicc:
2153 OS <<
"inteloclbicc";
2158 case attr::RISCVVectorCC:
2159 OS <<
"riscv_vector_cc";
2161 case attr::RISCVVLSCC:
2162 OS <<
"riscv_vls_cc";
2167 case attr::CFIUncheckedCallee:
2168 OS <<
"cfi_unchecked_callee";
2170 case attr::AcquireHandle:
2171 OS <<
"acquire_handle";
2173 case attr::ArmMveStrictPolymorphism:
2174 OS <<
"__clang_arm_mve_strict_polymorphism";
2176 case attr::ExtVectorType:
2177 OS <<
"ext_vector_type";
2186void TypePrinter::printBTFTagAttributedBefore(
const BTFTagAttributedType *
T,
2188 printBefore(
T->getWrappedType(), OS);
2189 OS <<
" __attribute__((btf_type_tag(\"" <<
T->getAttr()->getBTFTypeTag() <<
"\")))";
2192void TypePrinter::printBTFTagAttributedAfter(
const BTFTagAttributedType *
T,
2194 printAfter(
T->getWrappedType(), OS);
2197void TypePrinter::printHLSLAttributedResourceBefore(
2198 const HLSLAttributedResourceType *
T, raw_ostream &OS) {
2199 printBefore(
T->getWrappedType(), OS);
2202void TypePrinter::printHLSLAttributedResourceAfter(
2203 const HLSLAttributedResourceType *
T, raw_ostream &OS) {
2204 printAfter(
T->getWrappedType(), OS);
2205 const HLSLAttributedResourceType::Attributes &Attrs =
T->getAttrs();
2206 OS <<
" [[hlsl::resource_class("
2207 << HLSLResourceClassAttr::ConvertResourceClassToStr(Attrs.ResourceClass)
2210 OS <<
" [[hlsl::is_rov]]";
2211 if (Attrs.RawBuffer)
2212 OS <<
" [[hlsl::raw_buffer]]";
2214 QualType ContainedTy =
T->getContainedType();
2215 if (!ContainedTy.
isNull()) {
2216 OS <<
" [[hlsl::contained_type(";
2217 printBefore(ContainedTy, OS);
2218 printAfter(ContainedTy, OS);
2223void TypePrinter::printHLSLInlineSpirvBefore(
const HLSLInlineSpirvType *
T,
2225 OS <<
"__hlsl_spirv_type<" <<
T->getOpcode();
2227 OS <<
", " <<
T->getSize();
2228 OS <<
", " <<
T->getAlignment();
2230 for (
auto &Operand :
T->getOperands()) {
2231 using SpirvOperandKind = SpirvOperand::SpirvOperandKind;
2235 case SpirvOperandKind::ConstantId: {
2236 QualType ConstantType =
Operand.getResultType();
2237 OS <<
"vk::integral_constant<";
2238 printBefore(ConstantType, OS);
2239 printAfter(ConstantType, OS);
2245 case SpirvOperandKind::Literal:
2246 OS <<
"vk::Literal<vk::integral_constant<uint, ";
2250 case SpirvOperandKind::TypeId: {
2252 printBefore(
Type, OS);
2253 printAfter(
Type, OS);
2257 llvm_unreachable(
"Invalid SpirvOperand kind!");
2265void TypePrinter::printHLSLInlineSpirvAfter(
const HLSLInlineSpirvType *
T,
2270void TypePrinter::printObjCInterfaceBefore(
const ObjCInterfaceType *
T,
2272 OS <<
T->getDecl()->getName();
2273 spaceBeforePlaceHolder(OS);
2276void TypePrinter::printObjCInterfaceAfter(
const ObjCInterfaceType *
T,
2279void TypePrinter::printObjCTypeParamBefore(
const ObjCTypeParamType *
T,
2281 OS <<
T->getDecl()->getName();
2282 if (!
T->qual_empty()) {
2283 bool isFirst =
true;
2285 for (
const auto *I :
T->quals()) {
2295 spaceBeforePlaceHolder(OS);
2298void TypePrinter::printObjCTypeParamAfter(
const ObjCTypeParamType *
T,
2301void TypePrinter::printObjCObjectBefore(
const ObjCObjectType *
T,
2303 if (
T->qual_empty() &&
T->isUnspecializedAsWritten() &&
2304 !
T->isKindOfTypeAsWritten())
2305 return printBefore(
T->getBaseType(), OS);
2307 if (
T->isKindOfTypeAsWritten())
2310 print(
T->getBaseType(), OS, StringRef());
2312 if (
T->isSpecializedAsWritten()) {
2313 bool isFirst =
true;
2315 for (
auto typeArg :
T->getTypeArgsAsWritten()) {
2321 print(typeArg, OS, StringRef());
2326 if (!
T->qual_empty()) {
2327 bool isFirst =
true;
2329 for (
const auto *I :
T->quals()) {
2339 spaceBeforePlaceHolder(OS);
2342void TypePrinter::printObjCObjectAfter(
const ObjCObjectType *
T,
2344 if (
T->qual_empty() &&
T->isUnspecializedAsWritten() &&
2345 !
T->isKindOfTypeAsWritten())
2346 return printAfter(
T->getBaseType(), OS);
2349void TypePrinter::printObjCObjectPointerBefore(
const ObjCObjectPointerType *
T,
2356 if (HasEmptyPlaceHolder)
2362void TypePrinter::printObjCObjectPointerAfter(
const ObjCObjectPointerType *
T,
2373 llvm::raw_ostream &OS,
bool IncludeType) {
2374 A.
print(PP, OS, IncludeType);
2387 TemplateArgument Pattern,
2388 ArrayRef<TemplateArgument> Args,
2397 if (
auto *TTPT = Pattern->
getAsCanonical<TemplateTypeParmType>()) {
2398 if (TTPT->getDepth() == Depth && TTPT->getIndex() < Args.size() &&
2401 Args[TTPT->getIndex()].getAsType(), Pattern.
getQualifiers());
2413 if (TQual != PatQual)
2418 QualType TPointee =
T->getPointeeType();
2430 if (
auto *TTST =
T->getAs<TemplateSpecializationType>()) {
2431 Template = TTST->getTemplateName();
2432 TemplateArgs = TTST->template_arguments();
2433 }
else if (
auto *CTSD = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
2434 T->getAsCXXRecordDecl())) {
2436 TemplateArgs = CTSD->getTemplateArgs().asArray();
2444 if (TemplateArgs.size() != PTST->template_arguments().size())
2446 for (
unsigned I = 0, N = TemplateArgs.size(); I != N; ++I)
2448 Ctx, TemplateArgs[I], PTST->template_arguments()[I], Args, Depth))
2499 if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(DRE->getDecl()))
2500 return NTTP->getDepth() == Depth && Args.size() > NTTP->getIndex() &&
2501 Args[NTTP->getIndex()].structurallyEquals(Arg);
2517 if (
auto *TTPD = dyn_cast_or_null<TemplateTemplateParmDecl>(PatTD))
2518 return TTPD->getDepth() == Depth && Args.size() > TTPD->getIndex() &&
2527bool clang::isSubstitutedDefaultArgument(ASTContext &Ctx, TemplateArgument Arg,
2528 const NamedDecl *Param,
2529 ArrayRef<TemplateArgument> Args,
2535 if (
auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Param)) {
2536 return TTPD->hasDefaultArgument() &&
2538 Ctx, Arg, TTPD->getDefaultArgument().getArgument(), Args, Depth);
2539 }
else if (
auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Param)) {
2540 return TTPD->hasDefaultArgument() &&
2542 Ctx, Arg, TTPD->getDefaultArgument().getArgument(), Args, Depth);
2543 }
else if (
auto *NTTPD = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
2544 return NTTPD->hasDefaultArgument() &&
2546 Ctx, Arg, NTTPD->getDefaultArgument().getArgument(), Args,
2552template <
typename TA>
2558 !Args.empty() && !IsPack && Args.size() <= TPL->
size()) {
2560 for (
const TA &A : Args)
2562 while (!Args.empty() &&
getArgument(Args.back()).getIsDefaulted())
2563 Args = Args.drop_back();
2570 bool NeedSpace =
false;
2571 bool FirstArg =
true;
2572 for (
const auto &Arg : Args) {
2575 llvm::raw_svector_ostream ArgOS(Buf);
2588 Policy, TPL, ParmIndex));
2590 StringRef ArgString = ArgOS.str();
2595 if (FirstArg && ArgString.starts_with(
":"))
2602 if (!ArgString.empty()) {
2619void clang::printTemplateArgumentList(raw_ostream &OS,
2620 const TemplateArgumentListInfo &Args,
2621 const PrintingPolicy &Policy,
2622 const TemplateParameterList *TPL) {
2623 printTemplateArgumentList(OS, Args.
arguments(), Policy, TPL);
2626void clang::printTemplateArgumentList(raw_ostream &OS,
2627 ArrayRef<TemplateArgument> Args,
2628 const PrintingPolicy &Policy,
2629 const TemplateParameterList *TPL) {
2630 PrintingPolicy InnerPolicy = Policy;
2632 printTo(OS, Args, InnerPolicy, TPL,
false, 0);
2635void clang::printTemplateArgumentList(raw_ostream &OS,
2636 ArrayRef<TemplateArgumentLoc> Args,
2637 const PrintingPolicy &Policy,
2638 const TemplateParameterList *TPL) {
2639 PrintingPolicy InnerPolicy = Policy;
2641 printTo(OS, Args, InnerPolicy, TPL,
false, 0);
2651 llvm::raw_svector_ostream StrOS(Buf);
2653 return StrOS.str().str();
2681 llvm::raw_svector_ostream StrOS(Buf);
2682 print(StrOS, Policy);
2683 return std::string(StrOS.str());
2701 PointerAuth && !PointerAuth.isEmptyWhenPrinted(Policy))
2721 return "__constant";
2726 return "__global_device";
2729 return "__global_host";
2731 return "__device__";
2733 return "__constant__";
2735 return "__shared__";
2737 return "__sptr __ptr32";
2739 return "__uptr __ptr32";
2743 return "groupshared";
2745 return "hlsl_constant";
2747 return "hlsl_private";
2749 return "hlsl_device";
2751 return "hlsl_input";
2763 bool appendSpaceIfNonEmpty)
const {
2764 bool addSpace =
false;
2774 OS <<
"__unaligned";
2778 if (!ASStr.empty()) {
2784 OS <<
"__attribute__((address_space(" << ASStr <<
")))";
2823 PointerAuth.print(OS, Policy);
2826 if (appendSpaceIfNonEmpty && addSpace)
2848 const Twine &PlaceHolder,
unsigned Indentation)
const {
2855 const Twine &PlaceHolder,
unsigned Indentation) {
2857 StringRef PH = PlaceHolder.toStringRef(PHBuf);
2859 TypePrinter(policy, Indentation).print(ty, qs, OS, PH);
2869 std::string &buffer,
2872 llvm::raw_svector_ostream StrOS(Buf);
2873 TypePrinter(policy).print(ty, qs, StrOS, buffer);
2874 std::string str = std::string(StrOS.str());
Defines the clang::ASTContext interface.
Provides definitions for the various language-specific address spaces.
Defines the clang::attr::Kind enum.
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 &ASTCtx, QualType Ty)
#define CC_VLS_CASE(ABI_VLEN)
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 printHLSLMatrixBefore(TypePrinter &TP, const ConstantMatrixType *T, raw_ostream &OS)
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 void printClangMatrixBefore(TypePrinter &TP, const ConstantMatrixType *T, raw_ostream &OS)
static void printDims(const ConstantMatrixType *T, raw_ostream &OS)
static void printHLSLMatrixAfter(const ConstantMatrixType *T, raw_ostream &OS)
static void printCountAttributedImpl(const CountAttributedType *T, raw_ostream &OS, const PrintingPolicy &Policy)
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) const
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals.
Represents a concrete matrix type with constant number of rows and columns.
Represents a sugar type with __counted_by or __sized_by annotations, including their _or_null variant...
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.
SourceLocation getLocation() const
DeclContext * getDeclContext()
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
This represents one expression.
bool isIntegerConstantExpr(const ASTContext &Ctx) const
bool isValueDependent() const
Determines whether the value of this expression depends on.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx) 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...
Represents a prototype with parameter type info, e.g.
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
FunctionEffectsRef getFunctionEffects() const
unsigned getAArch64SMEAttributes() const
Return a bitmask describing the SME attributes on the function type, see AArch64SMETypeAttributes for...
QualType getExceptionType(unsigned i) const
Return the ith exception type, where 0 <= i < getNumExceptions().
bool hasCFIUncheckedCallee() const
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.
CallingConv getCC() const
bool getCmseNSCall() const
bool getNoCfCheck() const
unsigned getRegParm() const
bool getNoCallerSavedRegs() const
bool getProducesResult() const
ExtInfo getExtInfo() const
@ SME_PStateSMEnabledMask
@ SME_PStateSMCompatibleMask
@ SME_AgnosticZAStateMask
static ArmStateValue getArmZT0State(unsigned AttrBits)
static ArmStateValue getArmZAState(unsigned AttrBits)
QualType getReturnType() const
StringRef getName() const
Return the actual identifier string.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
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.
Pointer-authentication qualifiers.
bool isAddressDiscriminated() const
unsigned getExtraDiscriminator() const
void print(raw_ostream &OS, const PrintingPolicy &Policy) const
bool isEmptyWhenPrinted(const PrintingPolicy &Policy) const
std::string getAsString() const
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.
virtual bool isScopeVisible(const DeclContext *DC) const
When printing type to be inserted into code in specific context, this callback can be used to avoid p...
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
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
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 hasUnaligned() const
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool appendSpaceIfNonEmpty=false) const
bool isEmptyWhenPrinted(const PrintingPolicy &Policy) const
PointerAuthQualifier getPointerAuth() const
ObjCLifetime getObjCLifetime() const
std::string getAsString() const
LangAS getAddressSpace() const
static std::string getAddrSpaceAsString(LangAS AS)
Base for LValueReferenceType and RValueReferenceType.
PresumedLoc getPresumedLoc(SourceLocation Loc, bool UseLineDirectives=true) const
Returns the "presumed" location of a SourceLocation specifies.
StringRef getKindName() const
TypedefNameDecl * getTypedefNameForAnonDecl() const
ArrayRef< TemplateArgumentLoc > arguments() const
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.
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(bool IgnoreDeduced=false) 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.
ArrayRef< TemplateArgument > getInjectedTemplateArgs(const ASTContext &Context)
Get the template argument list of the template parameter list.
static bool shouldIncludeTypeForArgument(const PrintingPolicy &Policy, const TemplateParameterList *TPL, unsigned Idx)
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.
QualType getType() const
Return the type wrapped by this type source info.
The base class of the type hierarchy.
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
const T * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
TypeClass getTypeClass() const
bool isCanonicalUnqualified() const
Determines if this type would be canonical if it had no further qualification.
const T * getAs() const
Member-template getAs<specific type>'.
const internal::VariadicAllOfMatcher< Attr > attr
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
std::variant< struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl, struct ModuleDecl, struct ExcludeDecl, struct ExportDecl, struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl, struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl > Decl
All declarations that can appear in a module declaration.
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
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 (&&).
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
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.
const FunctionProtoType * T
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
@ Template
We are parsing a template declaration.
bool isNoexceptExceptionSpec(ExceptionSpecificationType ESpecType)
@ Keyword
The name has been typo-corrected to a keyword.
@ Type
The name was classified as a type.
LangAS
Defines the address space values used by the address space qualifier of QualType.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
llvm::StringRef getAsString(SyncScope S)
U cast(CodeGen::Address addr)
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
@ EST_NoThrow
Microsoft __declspec(nothrow) extension.
@ EST_MSAny
Microsoft throw(...) extension.
ArrayRef< TemplateArgumentLoc > arguments() const
static StringRef getKeywordName(ElaboratedTypeKeyword Keyword)
Describes how types, statements, expressions, and declarations should be printed.
unsigned SuppressUnwrittenScope
Suppress printing parts of scope specifiers that are never written, e.g., for anonymous namespaces.
unsigned FullyQualifiedName
When true, print the fully qualified name of function declarations.
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 PrintInjectedClassNameWithArguments
Whether to print an InjectedClassNameType with template arguments or as written.
unsigned UseVoidForZeroParams
Whether we should use '(void)' rather than '()' for a function prototype with zero parameters.
unsigned AnonymousTagLocations
When printing an anonymous tag name, also print the location of that entity (e.g.,...
unsigned CleanUglifiedParameters
Whether to strip underscores when printing reserved parameter names.
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 UsePreferredNames
Whether to use C++ template preferred_name attributes when printing templates.
unsigned SuppressStrongLifetime
When true, suppress printing of the __strong lifetime qualifier in ARC.
unsigned Restrict
Whether we can use 'restrict' rather than '__restrict'.
unsigned UseHLSLTypes
Whether or not we're printing known HLSL code and should print HLSL sugared types when possible.
unsigned SuppressInlineNamespace
Suppress printing parts of scope specifiers that correspond to inline namespaces.
unsigned SuppressScope
Suppresses printing of scope specifiers.
const PrintingCallbacks * Callbacks
Callbacks to use to allow the behavior of printing to be customized.
unsigned IncludeTagDefinition
When true, include the body of a tag definition.
unsigned PrintAsCanonical
Whether to print entities as written or canonically.
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.